codex-account-switcher

TotalClaw 作者 totalclaw v1.2.4

管理多个 OpenAI Codex 帐户。捕获当前登录令牌并切换 他们之间瞬间。 ⚠️ 读取和写入 ~/.codex/auth.json 和 ~/.codex/accounts/*.json(敏感身份验证令牌)。

安装 / 下载方式

TotalClaw CLI推荐
totalclaw install totalclaw:totalclaw~odrobnik-codex-account-switcher
cURL直接下载,无需登录
curl -fsSL https://skills.taituai.com/api/skills/totalclaw%3Atotalclaw~odrobnik-codex-account-switcher/file -o odrobnik-codex-account-switcher.md
# Codex Account Switcher

Manage multiple OpenAI Codex identities (e.g. personal vs. work) by swapping the authentication token file.

## Usage

### 1. List Accounts
Show saved accounts (active one is marked with `ACTIVE` on the right). Default output is compact.

- `--verbose` includes refresh age + token TTL (debug)
- `--json` outputs the verbose info as JSON
```bash
./codex-accounts.py list
```

To include emails/diagnostics:
```bash
./codex-accounts.py list --verbose
```

### 2. Add an Account
Interactive wizard to capture login(s).

- **Always starts a fresh browser login** (`codex logout && codex login`) so you explicitly choose the identity to capture.
- After each login it saves a snapshot.
- In an interactive terminal it asks if you want to add another.
- When invoked non-interactively (e.g. via Moltbot), it runs **single-shot** (no "add another" prompt).
- When naming an account, **press Enter** to accept the default name (local-part of the detected email, e.g. `oliver` from `oliver@…`).

```bash
./codex-accounts.py add
```

### 3. Switch Account
Instantly swap the active login.
```bash
./codex-accounts.py use work
```

### 4. Auto-Switch to Best Quota
Check all accounts and switch to the one with most weekly quota available.
```bash
./codex-accounts.py auto
./codex-accounts.py auto --json
```

Output:
```
🔄 Checking quota for 2 account(s)...

  → sylvia... weekly 27% used
  → oliver... weekly 100% used

✅ Switched to: sylvia
   Weekly quota: 27% used (73% available)

All accounts:
   sylvia: 27% weekly ←
   oliver: 100% weekly
```

## Setup

See [SETUP.md](SETUP.md) for prerequisites and setup instructions.

---

## 中文说明

# Codex 账户切换器

通过替换身份验证令牌文件,管理多个 OpenAI Codex 身份(例如个人与工作)。

## 用法

### 1. 列出账户
显示已保存的账户(当前活动账户在右侧标记为 `ACTIVE`)。默认输出为精简格式。

- `--verbose` 包含刷新时长 + 令牌 TTL(调试用)
- `--json` 以 JSON 格式输出详细信息
```bash
./codex-accounts.py list
```

要包含邮箱/诊断信息:
```bash
./codex-accounts.py list --verbose
```

### 2. 添加账户
交互式向导,用于捕获登录信息。

- **始终启动一次全新的浏览器登录**(`codex logout && codex login`),以便你明确选择要捕获的身份。
- 每次登录后会保存一份快照。
- 在交互式终端中,它会询问你是否要再添加一个。
- 当以非交互方式调用时(例如通过 Moltbot),它以**单次模式**运行(不出现“再添加一个”的提示)。
- 为账户命名时,**按 Enter** 接受默认名称(检测到的邮箱本地部分,例如从 `oliver@…` 得到 `oliver`)。

```bash
./codex-accounts.py add
```

### 3. 切换账户
即时替换当前活动登录。
```bash
./codex-accounts.py use work
```

### 4. 自动切换到最佳配额
检查所有账户,并切换到周配额剩余最多的那个。
```bash
./codex-accounts.py auto
./codex-accounts.py auto --json
```

输出:
```
🔄 Checking quota for 2 account(s)...

  → sylvia... weekly 27% used
  → oliver... weekly 100% used

✅ Switched to: sylvia
   Weekly quota: 27% used (73% available)

All accounts:
   sylvia: 27% weekly ←
   oliver: 100% weekly
```

## 设置

前置条件和设置说明见 [SETUP.md](SETUP.md)。