@loongphy/codex-auth-linux-x64 0.3.0-alpha.2 → 0.3.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +23 -261
  2. package/bin/codex-auth +0 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -51,285 +51,52 @@ Remove the npm package:
51
51
  npm uninstall -g @loongphy/codex-auth
52
52
  ```
53
53
 
54
- #### Legacy Bash Installer
55
-
56
- > [!NOTE]
57
- > If you only installed `@loongphy/codex-auth` with npm, you do not need any legacy cleanup steps.
58
- > Older Bash/PowerShell GitHub-release installs could leave a standalone `codex-auth` binary outside npm's install path.
59
- > If you previously used those legacy installers, remove the leftover binaries and profile changes during migration.
60
- > API-backed usage refresh and team-name refresh use Node.js `fetch`.
61
- > npm installs already satisfy that requirement.
62
-
63
- For non-npm installs on Linux/macOS/WSL2 only:
64
-
65
- ```shell
66
- rm -f ~/.local/bin/codex-auth
67
- rm -f ~/.local/bin/codex-auth-auto
68
- sed -i '/# Added by codex-auth installer/,+1d' ~/.bashrc ~/.bash_profile ~/.profile ~/.zshrc ~/.zprofile 2>/dev/null || true
69
- ```
70
-
71
- If you used fish, also remove the old profile entry:
72
-
73
- ```shell
74
- sed -i '/# Added by codex-auth installer/,+3d' ~/.config/fish/config.fish 2>/dev/null || true
75
- ```
76
-
77
- #### Legacy PowerShell Installer
78
-
79
- For non-npm installs on Windows only:
80
-
81
- ```powershell
82
- Remove-Item "$env:LOCALAPPDATA\codex-auth\bin\codex-auth.exe" -Force -ErrorAction SilentlyContinue
83
- Remove-Item "$env:LOCALAPPDATA\codex-auth\bin\codex-auth-auto.exe" -Force -ErrorAction SilentlyContinue
84
- [Environment]::SetEnvironmentVariable(
85
- "Path",
86
- (($env:Path -split ';' | Where-Object { $_ -and $_ -ne "$env:LOCALAPPDATA\codex-auth\bin" }) -join ';'),
87
- "User"
88
- )
89
- ```
90
-
91
54
  ## Commands
92
55
 
56
+ Detailed command documentation lives in [docs/commands/README.md](./docs/commands/README.md).
57
+
93
58
  ### Account Management
94
59
 
95
60
  | Command | Description |
96
61
  |---------|-------------|
97
- | `codex-auth list [--live] [--api\|--skip-api]` | List all accounts. `--live` keeps refreshing the terminal view; `--api` forces remote refresh, while `--skip-api` forbids remote API use for this command. |
98
- | `codex-auth login [--device-auth]` | Run `codex login` (optionally with `--device-auth`), then add the current account |
99
- | `codex-auth switch [--live] [--auto] [--api\|--skip-api]` | Switch the active account interactively. Without `--live` it exits after one switch; with `--live` it stays open and keeps refreshing. `--auto` requires `--live` and auto-switches away from the current account when the live view shows it as exhausted or returns a non-200 usage API status. |
100
- | `codex-auth switch <query>` | Switch the active account directly by row number, alias, or fuzzy match using stored local data only. |
101
- | `codex-auth remove [--live] [--api\|--skip-api]` | Interactive remove. `--live` keeps the picker open after each deletion; `--api` forces remote refresh and `--skip-api` forbids remote API use for this command. |
102
- | `codex-auth remove <query> [<query>...]` | Remove one or more accounts by row number, alias, email, account name, or `account_key` match using stored local data. |
103
- | `codex-auth remove --all` | Remove all stored accounts. |
104
- | `codex-auth status` | Show auto-switch, service, and usage status |
62
+ | [`codex-auth list [--live] [--api\|--skip-api]`](./docs/commands/list.md) | List stored accounts and usage state |
63
+ | [`codex-auth login [--device-auth]`](./docs/commands/login.md) | Run `codex login`, then add the current account |
64
+ | [`codex-auth switch [--live] [--api\|--skip-api]`](./docs/commands/switch.md) | Switch the active account interactively |
65
+ | [`codex-auth switch <query>`](./docs/commands/switch.md) | Switch directly by row number or account selector |
66
+ | [`codex-auth remove [--live] [--api\|--skip-api]`](./docs/commands/remove.md) | Remove accounts interactively |
67
+ | [`codex-auth remove <query> [<query>...]`](./docs/commands/remove.md) | Remove accounts by selector |
68
+ | [`codex-auth remove --all`](./docs/commands/remove.md) | Remove all stored accounts |
69
+ | [`codex-auth status`](./docs/commands/status.md) | Show auto-switch, service, and usage status |
105
70
 
106
- ### Import
71
+ ### Import and Maintenance
107
72
 
108
73
  | Command | Description |
109
74
  |---------|-------------|
110
- | `codex-auth import <path> [--alias <alias>]` | Import a single file or batch import from a folder |
111
- | `codex-auth import --cpa [<path>]` | Import [CLIProxyAPI](https://github.com/router-for-me/CLIProxyAPI) (CPA) token JSON |
112
- | `codex-auth import --purge [<path>]` | Rebuild `registry.json` from existing auth files |
75
+ | [`codex-auth import <path> [--alias <alias>]`](./docs/commands/import.md) | Import a single auth file or batch import a folder |
76
+ | [`codex-auth import --cpa [<path>]`](./docs/commands/import.md) | Import CLIProxyAPI token JSON |
77
+ | [`codex-auth import --purge [<path>]`](./docs/commands/import.md) | Rebuild `registry.json` from auth files |
78
+ | [`codex-auth clean`](./docs/commands/clean.md) | Delete managed backup and stale account files |
113
79
 
114
80
  ### Configuration
115
81
 
116
82
  | Command | Description |
117
83
  |---------|-------------|
118
- | `codex-auth config auto enable\|disable` | Enable or disable experimental background auto-switching |
119
- | `codex-auth config api enable\|disable` | Enable or disable both usage refresh and team name refresh API calls |
84
+ | [`codex-auth config auto enable\|disable`](./docs/commands/config.md) | Enable or disable background auto-switching |
85
+ | [`codex-auth config auto --5h <percent> [--weekly <percent>]`](./docs/commands/config.md) | Configure background auto-switch thresholds |
86
+ | [`codex-auth config api enable\|disable`](./docs/commands/config.md) | Enable or disable default API-backed refresh |
120
87
 
121
- ---
122
-
123
- ## Examples
124
-
125
- ### List Accounts
126
-
127
- > [!IMPORTANT]
128
- > Built-in Node proxy support for API refresh requires Node.js `22.21.0+` or `24.0.0+`.
88
+ ## Quick Examples
129
89
 
130
90
  ```shell
131
91
  codex-auth list
132
- codex-auth list --live
133
- codex-auth list --api # force usage/team-name API refresh, even if config api is disabled
134
- codex-auth list --skip-api # forbid usage/team-name API refresh for this command
135
- ```
136
-
137
- `--live` keeps the list refreshing inside the terminal UI.
138
- `--api` forces the foreground usage and team-name refresh path for this command only.
139
- `--skip-api` forbids remote refresh for this command only. Usage can still refresh locally for the active account when local rollout data exists.
140
-
141
- ### Switch Account
142
-
143
- ```shell
144
92
  codex-auth switch
145
- codex-auth switch --live
146
- codex-auth switch --live --auto
147
- codex-auth switch --api
148
- codex-auth switch --skip-api
149
- ```
150
-
151
- `codex-auth switch`
152
- Opens the interactive picker. It shows email, 5h, weekly, and last activity, then exits after one successful switch.
153
-
154
- `codex-auth switch --live`
155
- Keeps the picker open after Enter, keeps refreshing the terminal view, and updates the footer with the latest switch result.
156
-
157
- `codex-auth switch --live --auto`
158
- Keeps watching the current live display and auto-switches only when the active account reaches `0%` on 5h or weekly, or when the usage API returns a non-200 status for the active account.
159
-
160
- `codex-auth switch --api`
161
- Forces a foreground remote refresh before opening the picker.
162
-
163
- `codex-auth switch --skip-api`
164
- Forbids remote API use for this command and relies on local-only usage refresh where available.
165
-
166
- `codex-auth switch <query>`
167
- Switches directly by displayed row number, alias, or fuzzy email/alias match using stored local data only. The row number follows the interactive `switch` list, and the same number from `codex-auth list` also works because both commands use the same ordering. `switch <query>` does not accept `--live`, `--auto`, `--api`, or `--skip-api`.
168
-
169
- When `--live --auto` is active, auto-switch candidates still follow the live picker rules and skip accounts whose current 5h or weekly value is already `0%`.
170
-
171
- ![command switch](https://github.com/user-attachments/assets/48a86acf-2a6e-4206-a8c4-591989fdc0df)
172
-
173
- ```shell
174
- codex-auth switch 02 # switch by displayed row number
175
- codex-auth switch john # fuzzy match by email or alias
176
- codex-auth switch work # match by alias set during import
177
- ```
178
-
179
- If `<query>` matches multiple accounts, the command falls back to interactive selection. Press `q` to quit without switching.
180
-
181
- ### Remove Accounts
182
-
183
- ```shell
184
- codex-auth remove
185
- codex-auth remove --live
186
- codex-auth remove --api
187
- codex-auth remove --skip-api
188
- ```
189
-
190
- `codex-auth remove`
191
- Opens the interactive remove picker. It stays local-only by default so deletion is not blocked by API refresh work.
192
-
193
- `codex-auth remove --live`
194
- Keeps the picker open after each deletion so you can continue cleaning up accounts in one session.
195
-
196
- `codex-auth remove --api`
197
- Attempts a best-effort foreground refresh for picker display. Successful rows show live API data when it is available; rows that cannot refresh may show live error overlays such as `403`, `TimedOut`, or `MissingAuth` instead.
198
-
199
- `codex-auth remove --skip-api`
200
- Keeps the picker local-only explicitly and forbids remote API use for this command.
201
-
202
- `codex-auth remove <query> [<query>...]`
203
- Removes one or more accounts by row number, alias, email, account name, or `account_key` match using stored local data only.
204
-
205
- `codex-auth remove --all`
206
- Removes all stored accounts.
207
-
208
- Each selector supports the same query forms as `switch`: row number, alias, or fuzzy email/alias match.
209
- The row number follows the interactive `switch` list, and the same number from `codex-auth list` also works because both commands use the same ordering.
210
- You can pass multiple selectors in one command.
211
- Selector-based `remove` and `remove --all` do not accept `--live`, `--api`, or `--skip-api`.
212
-
213
- ```shell
214
- codex-auth remove 01 03
215
- codex-auth remove work personal
216
- codex-auth remove 01 jane@example.com
217
- codex-auth remove --all
218
- ```
219
-
220
- If any selector matches multiple accounts, `remove` asks for confirmation in interactive terminals before deleting.
221
-
222
- ### Login (Add Account)
223
-
224
- Add the currently logged-in Codex account:
225
-
226
- ```shell
227
- codex-auth login
228
- codex-auth login --device-auth
229
- ```
230
-
231
- ### Import
232
-
233
- #### Single File
234
-
235
- ```shell
93
+ codex-auth switch 02
94
+ codex-auth remove work
236
95
  codex-auth import /path/to/auth.json --alias personal
237
- ```
238
-
239
- #### Batch Import from a Folder
240
-
241
- Scans all `.json` files in the directory:
242
-
243
- ```shell
244
- codex-auth import /path/to/auth-exports
245
- ```
246
-
247
- Typical output:
248
-
249
- ```text
250
- Scanning /path/to/auth-exports...
251
- ✓ imported token_ryan.taylor.alpha@email.com
252
- ✓ updated token_jane.smith.alpha@email.com
253
- ✗ skipped token_invalid: MalformedJson
254
- Import Summary: 1 imported, 1 updated, 1 skipped (total 3 files)
255
- ```
256
-
257
- `stdout` carries scanning, success, and summary lines. Skipped files and warnings stay on `stderr`.
258
-
259
- #### Import CLIProxyAPI (CPA) Tokens
260
-
261
- [CLIProxyAPI](https://github.com/router-for-me/CLIProxyAPI) stores tokens as flat JSON under `~/.cli-proxy-api/`. Import them directly without conversion:
262
-
263
- ```shell
264
- codex-auth import --cpa # scan default ~/.cli-proxy-api/*.json
265
- codex-auth import --cpa /path/to/cpa-dir # scan a specific directory
266
- codex-auth import --cpa /path/to/token.json --alias bob # import a single CPA file
267
- ```
268
-
269
- #### Fix Broken Account Data (Rebuild Registry)
270
-
271
- If `codex-auth list` shows missing accounts or wrong usage data, the internal registry file may be out of sync with the actual auth files on disk. This command re-reads all auth files and rebuilds the registry from scratch:
272
-
273
- ```shell
274
- codex-auth import --purge # rebuild from ~/.codex/accounts/*.auth.json
275
- codex-auth import --purge /path/to/auth-exports # rebuild from a specific folder
276
- ```
277
-
278
- This does not import new files. It repairs the registry index for auth snapshots that already exist on disk.
279
-
280
- ### Show Status
281
-
282
- ```shell
283
- codex-auth status
284
- ```
285
-
286
- ### Config
287
-
288
- #### Auto-Switch
289
-
290
- > [!WARNING]
291
- > Auto-switch is experimental. Behavior, defaults, and platform integration may change in future releases while the feature matures.
292
-
293
- Enable or disable:
294
-
295
- ```shell
296
- codex-auth config auto enable
297
- codex-auth config auto disable
298
- ```
299
-
300
- `config auto enable` prints the current usage mode after installing the watcher, so you can immediately see whether auto-switch is running with default API-backed usage or local-only fallback semantics.
301
-
302
- When auto-switching is enabled, a long-running background watcher refreshes the active account's usage and silently switches accounts when:
303
-
304
- - 5h remaining reaches `0`, or
305
- - weekly remaining reaches `0`
306
-
307
- Auto-switch evaluates both 5h and weekly by default, without separate threshold configuration.
308
- Candidates whose current 5h or weekly value is already `0` are skipped.
309
- When choosing the next account, `codex-auth` prefers a usable account whose remaining quota resets sooner, so a reset at `05:11` wins over `05:30`.
310
-
311
- The managed background worker is long-running on all supported platforms:
312
-
313
- - Linux/WSL: persistent `systemd --user` service
314
- - macOS: `LaunchAgent`
315
- - Windows: scheduled task that launches the long-running helper at logon, restarts it after failures, has no 72-hour execution cap, and also starts it immediately on enable
316
-
317
- #### Usage Refresh Source
318
-
319
- API-backed fallback:
320
-
321
- ```shell
322
- codex-auth config api enable
323
- ```
324
-
325
- Local-only, no usage API calls:
326
-
327
- ```shell
328
96
  codex-auth config api disable
97
+ codex-auth status
329
98
  ```
330
99
 
331
- Changing `config api` updates `registry.json` immediately. `api enable` is shown as API mode and `api disable` is shown as local mode.
332
-
333
100
  ## Q&A
334
101
 
335
102
  ### Why is my usage limit not refreshing?
@@ -352,11 +119,6 @@ codex-auth status
352
119
 
353
120
  `status` should show `usage: api`.
354
121
 
355
- Upgrade notes:
356
-
357
- - If you are upgrading from `v0.1.x` to the latest `v0.2.x`, API usage refresh is enabled by default.
358
- - If you previously used an early `v0.2` prerelease/test build and `status` still shows `usage: local`, run `codex-auth config api enable` once to switch back to API mode.
359
-
360
122
  Verify with:
361
123
 
362
124
  ```shell
@@ -370,7 +132,7 @@ This project is provided as-is and use is at your own risk.
370
132
  **Usage Data Refresh Source:**
371
133
  `codex-auth` supports two sources for refreshing account usage/usage limit information:
372
134
 
373
- 1. **API (default):** When `config api enable` is on, the tool makes direct HTTPS requests to OpenAI's endpoints using your account's access token. This enables both usage refresh and team name refresh. npm installs already satisfy the runtime requirement; legacy standalone binary installs need Node.js 22+ on `PATH`.
135
+ 1. **API (default):** When `config api enable` is on, the tool makes direct HTTPS requests to OpenAI's endpoints using your account's access token. This enables both usage refresh and team name refresh. npm installs already satisfy the runtime requirement.
374
136
  2. **Local-only:** When `config api disable` is on, the tool scans local `~/.codex/sessions/*/rollout-*.jsonl` files for usage data and skips team name refresh API calls. This mode is safer, but it can be less accurate because recent Codex rollout files often contain `rate_limits: null`, so the latest local usage limit data may lag by several hours.
375
137
 
376
138
  **API Call Declaration:**
package/bin/codex-auth CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loongphy/codex-auth-linux-x64",
3
- "version": "0.3.0-alpha.2",
3
+ "version": "0.3.0-alpha.4",
4
4
  "description": "@loongphy/codex-auth binary for linux x64",
5
5
  "license": "MIT",
6
6
  "repository": {