@loongphy/codex-auth 0.3.0-alpha.1 → 0.3.0-alpha.10
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.
- package/README.md +86 -287
- package/bin/codex-auth.js +1 -20
- package/package.json +8 -10
package/README.md
CHANGED
|
@@ -1,30 +1,9 @@
|
|
|
1
|
-
# Codex Auth
|
|
1
|
+
# Codex Auth [](https://github.com/Loongphy/codex-auth/releases/latest) [](https://github.com/Loongphy/codex-auth/releases)
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|
|
|
5
5
|
`codex-auth` is a command-line tool for switching Codex accounts.
|
|
6
6
|
|
|
7
|
-
> [!IMPORTANT]
|
|
8
|
-
> For **Codex CLI** and **Codex App** users, switch accounts, then restart the client for the new account to take effect.
|
|
9
|
-
>
|
|
10
|
-
> If you use the CLI and want seamless automatic account switching without restarting, use the forked [`codext`](https://github.com/Loongphy/codext), an enhanced Codex CLI. Install it with `npm i -g @loongphy/codext` and run `codext`.
|
|
11
|
-
|
|
12
|
-
## Supported Platforms
|
|
13
|
-
|
|
14
|
-
`codex-auth` works with these Codex clients:
|
|
15
|
-
|
|
16
|
-
- Codex CLI
|
|
17
|
-
- VS Code extension
|
|
18
|
-
- Codex App
|
|
19
|
-
|
|
20
|
-
For the best experience, install the Codex CLI even if you mainly use the VS Code extension or the App, because it makes adding accounts easier:
|
|
21
|
-
|
|
22
|
-
```shell
|
|
23
|
-
npm install -g @openai/codex
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
After that, you can use `codex login`, `codex login --device-auth`, `codex-auth login`, or `codex-auth login --device-auth` to sign in and add accounts more easily.
|
|
27
|
-
|
|
28
7
|
## Install
|
|
29
8
|
|
|
30
9
|
Install with npm:
|
|
@@ -33,330 +12,146 @@ Install with npm:
|
|
|
33
12
|
npm install -g @loongphy/codex-auth
|
|
34
13
|
```
|
|
35
14
|
|
|
36
|
-
|
|
15
|
+
You can also run it without a global install:
|
|
37
16
|
|
|
38
17
|
```shell
|
|
39
18
|
npx @loongphy/codex-auth list
|
|
40
19
|
```
|
|
41
20
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
### Uninstall
|
|
45
|
-
|
|
46
|
-
#### npm
|
|
47
|
-
|
|
48
|
-
Remove the npm package:
|
|
49
|
-
|
|
50
|
-
```shell
|
|
51
|
-
npm uninstall -g @loongphy/codex-auth
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
#### Legacy Bash Installer
|
|
21
|
+
## Supported Platforms
|
|
55
22
|
|
|
56
|
-
|
|
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.
|
|
23
|
+
`codex-auth` works with these Codex clients:
|
|
62
24
|
|
|
63
|
-
|
|
25
|
+
- Codex CLI
|
|
26
|
+
- VS Code extension
|
|
27
|
+
- Codex App
|
|
64
28
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
29
|
+
> [!IMPORTANT]
|
|
30
|
+
> For **Codex CLI** and **Codex App** users, switch accounts, then restart the client for the new account to take effect.
|
|
31
|
+
>
|
|
32
|
+
> If you want seamless automatic account switching without restarting, use the forked [`codext`](https://github.com/Loongphy/codext), an enhanced Codex CLI.
|
|
33
|
+
>
|
|
34
|
+
> Install it with `npm i -g @loongphy/codext` and run `codext`.
|
|
35
|
+
>
|
|
36
|
+
> Codex App users can use `codex-auth app`, but it is not stable. See [Details](#codex-app).
|
|
70
37
|
|
|
71
|
-
|
|
38
|
+
Install the Codex CLI even if you mainly use the VS Code extension or the App, because it makes adding accounts easier:
|
|
72
39
|
|
|
73
40
|
```shell
|
|
74
|
-
|
|
41
|
+
npm install -g @openai/codex
|
|
75
42
|
```
|
|
76
43
|
|
|
77
|
-
|
|
44
|
+
After that, you can use `codex-auth login`, or `codex-auth login --device-auth` to sign in and add accounts more easily.
|
|
78
45
|
|
|
79
|
-
|
|
46
|
+
## Commands
|
|
80
47
|
|
|
81
|
-
|
|
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
|
-
```
|
|
48
|
+
Detailed command documentation lives in [docs/commands/README.md](./docs/commands/README.md).
|
|
90
49
|
|
|
91
|
-
|
|
50
|
+
> [!NOTE]
|
|
51
|
+
> This documentation is based on **v0.3.x**. Some commands described here may not be available in the current release.
|
|
52
|
+
>
|
|
53
|
+
> To try the latest features, please install the alpha version via:
|
|
54
|
+
>
|
|
55
|
+
> ```bash
|
|
56
|
+
> npm install -g @loongphy/codex-auth@next
|
|
57
|
+
> ```
|
|
58
|
+
>
|
|
59
|
+
> If you want to downgrade to **v0.2.x**, you may need to manually update the `~/.codex/accounts/registry.json`:
|
|
60
|
+
>
|
|
61
|
+
> ```json
|
|
62
|
+
> "schema_version": 3
|
|
63
|
+
> ```
|
|
92
64
|
|
|
93
65
|
### Account Management
|
|
94
66
|
|
|
95
67
|
| Command | Description |
|
|
96
68
|
|---------|-------------|
|
|
97
|
-
| `codex-auth list [--live] [--api\|--skip-api]` | List
|
|
98
|
-
| `codex-auth login [--device-auth]` | Run `codex login
|
|
99
|
-
| `codex-auth switch [--live] [--
|
|
100
|
-
| `codex-auth switch <query>` | Switch
|
|
101
|
-
| `codex-auth remove [--live] [--api\|--skip-api]`
|
|
102
|
-
| `codex-auth remove <query> [<query>...]` | Remove
|
|
103
|
-
| `codex-auth remove --all` | Remove all stored accounts
|
|
104
|
-
| `codex-auth
|
|
105
|
-
|
|
106
|
-
|
|
69
|
+
| [`codex-auth list [--live] [--active] [--api\|--skip-api]`](./docs/commands/list.md) | List stored accounts and usage state |
|
|
70
|
+
| [`codex-auth login [--device-auth]`](./docs/commands/login.md) | Run `codex login`, then add the current account |
|
|
71
|
+
| [`codex-auth switch [--live] [--api\|--skip-api]`](./docs/commands/switch.md) | Switch the active account interactively |
|
|
72
|
+
| [`codex-auth switch <query>`](./docs/commands/switch.md) | Switch directly by row number or account selector |
|
|
73
|
+
| [`codex-auth remove [--live] [--api\|--skip-api]`](./docs/commands/remove.md) | Remove accounts interactively |
|
|
74
|
+
| [`codex-auth remove <query> [<query>...]`](./docs/commands/remove.md) | Remove accounts by selector |
|
|
75
|
+
| [`codex-auth remove --all`](./docs/commands/remove.md) | Remove all stored accounts |
|
|
76
|
+
| [`codex-auth alias set <query> <alias>`](./docs/commands/alias.md) | Set an alias for an account |
|
|
77
|
+
| [`codex-auth alias clear <query>`](./docs/commands/alias.md) | Clear the alias for an account |
|
|
78
|
+
|
|
79
|
+
### Import and Maintenance
|
|
107
80
|
|
|
108
81
|
| Command | Description |
|
|
109
82
|
|---------|-------------|
|
|
110
|
-
| `codex-auth import <path> [--alias <alias>]` | Import a single file or batch import
|
|
111
|
-
| `codex-auth import --cpa [<path>]` | Import
|
|
112
|
-
| `codex-auth import --purge [<path>]` | Rebuild `registry.json` from
|
|
83
|
+
| [`codex-auth import <path> [--alias <alias>]`](./docs/commands/import.md) | Import a single auth file or batch import a folder |
|
|
84
|
+
| [`codex-auth import --cpa [<path>]`](./docs/commands/import.md) | Import CLIProxyAPI token JSON |
|
|
85
|
+
| [`codex-auth import --purge [<path>]`](./docs/commands/import.md) | Rebuild `registry.json` from auth files |
|
|
86
|
+
| [`codex-auth export [<dir>]`](./docs/commands/export.md) | Export stored account auth files |
|
|
87
|
+
| [`codex-auth export --cpa [<dir>]`](./docs/commands/export.md) | Export CLIProxyAPI token JSON |
|
|
88
|
+
| [`codex-auth clean`](./docs/commands/clean.md) | Delete managed backup and stale account files |
|
|
113
89
|
|
|
114
90
|
### Configuration
|
|
115
91
|
|
|
116
92
|
| Command | Description |
|
|
117
93
|
|---------|-------------|
|
|
118
|
-
| `codex-auth config
|
|
119
|
-
| `codex-auth config api enable\|disable` | Enable or disable both usage refresh and team name refresh API calls |
|
|
120
|
-
|
|
121
|
-
---
|
|
94
|
+
| [`codex-auth config live --interval <seconds>`](./docs/commands/config.md) | Configure live TUI refresh interval |
|
|
122
95
|
|
|
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+`.
|
|
96
|
+
## Quick Examples
|
|
129
97
|
|
|
130
98
|
```shell
|
|
131
99
|
codex-auth list
|
|
132
|
-
codex-auth list --
|
|
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
|
|
100
|
+
codex-auth list --active
|
|
144
101
|
codex-auth switch
|
|
145
|
-
codex-auth switch
|
|
146
|
-
codex-auth
|
|
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
|
-

|
|
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
|
|
102
|
+
codex-auth switch 02
|
|
103
|
+
codex-auth remove work
|
|
236
104
|
codex-auth import /path/to/auth.json --alias personal
|
|
105
|
+
codex-auth list --skip-api
|
|
237
106
|
```
|
|
238
107
|
|
|
239
|
-
|
|
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)
|
|
108
|
+
## Codex App
|
|
270
109
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
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:
|
|
110
|
+
> [!IMPORTANT]
|
|
111
|
+
> The `app` command is **experimental** and may never become a stable feature.
|
|
112
|
+
>
|
|
113
|
+
> It is designed to enable seamless account switching without restarting the Codex App. By leveraging the `CODEX_CLI_PATH` environment variable, it dynamically injects our managed codext CLI to handle authentication on the fly.
|
|
114
|
+
>
|
|
115
|
+
> The `app` command is constrained by ongoing changes in the official Codex App and [Codex CLI](https://github.com/openai/codex). It may not always take effect and may also break your app.
|
|
312
116
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
-
|
|
117
|
+
| Command | Description |
|
|
118
|
+
|---------|-------------|
|
|
119
|
+
| [`codex-auth app [--id <id>] [--codex-cli-path <path>]`](./docs/commands/app.md) | Experimental: launch Codex App with detected defaults, CODEX_HOME, CODEX_CLI_PATH, and platform overrides |
|
|
316
120
|
|
|
317
|
-
|
|
121
|
+
Support seamless account switching including:
|
|
318
122
|
|
|
319
|
-
|
|
123
|
+
- New Chat
|
|
124
|
+
- Restoring or resuming an existing conversation
|
|
125
|
+
- Continuing a previously completed, interrupted, or manually stopped conversation
|
|
320
126
|
|
|
321
|
-
|
|
322
|
-
codex-auth config api enable
|
|
323
|
-
```
|
|
127
|
+
### Uninstall
|
|
324
128
|
|
|
325
|
-
|
|
129
|
+
Remove the npm package:
|
|
326
130
|
|
|
327
131
|
```shell
|
|
328
|
-
codex-auth
|
|
132
|
+
npm uninstall -g @loongphy/codex-auth
|
|
329
133
|
```
|
|
330
134
|
|
|
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
135
|
## Q&A
|
|
334
136
|
|
|
335
137
|
### Why is my usage limit not refreshing?
|
|
336
138
|
|
|
337
|
-
|
|
139
|
+
API-backed refresh is the default. When you pass `--skip-api`, `codex-auth` reads the newest `~/.codex/sessions/**/rollout-*.jsonl` file instead. Recent Codex builds often write `token_count` events with `rate_limits: null`. The local files may still contain older usable usage limit data, but in practice they can lag by several hours, so local-only refresh may show a usage limit snapshot from hours ago instead of your latest state.
|
|
338
140
|
|
|
339
141
|
- Upstream Codex issue: [openai/codex#14880](https://github.com/openai/codex/issues/14880)
|
|
340
142
|
|
|
341
|
-
|
|
143
|
+
Run the API-backed default with:
|
|
342
144
|
|
|
343
145
|
```shell
|
|
344
|
-
codex-auth
|
|
146
|
+
codex-auth list
|
|
345
147
|
```
|
|
346
148
|
|
|
347
|
-
|
|
149
|
+
Run one local-only command with:
|
|
348
150
|
|
|
349
151
|
```shell
|
|
350
|
-
codex-auth
|
|
152
|
+
codex-auth list --skip-api
|
|
351
153
|
```
|
|
352
154
|
|
|
353
|
-
`status` should show `usage: api`.
|
|
354
|
-
|
|
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
155
|
Verify with:
|
|
361
156
|
|
|
362
157
|
```shell
|
|
@@ -370,8 +165,12 @@ This project is provided as-is and use is at your own risk.
|
|
|
370
165
|
**Usage Data Refresh Source:**
|
|
371
166
|
`codex-auth` supports two sources for refreshing account usage/usage limit information:
|
|
372
167
|
|
|
373
|
-
1. **API (default):**
|
|
374
|
-
2. **Local-only:**
|
|
168
|
+
1. **API (default):** 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. `curl` must be available at runtime.
|
|
169
|
+
2. **Local-only:** With per-command `--skip-api`, 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
170
|
|
|
376
171
|
**API Call Declaration:**
|
|
377
|
-
By
|
|
172
|
+
By using the default API-backed refresh, this tool will send your ChatGPT access token to OpenAI's servers for usage limit and team name refresh. The exact endpoints are:
|
|
173
|
+
- `GET https://chatgpt.com/backend-api/wham/usage`
|
|
174
|
+
- `GET https://chatgpt.com/backend-api/accounts`
|
|
175
|
+
|
|
176
|
+
This behavior may be detected by OpenAI and could violate their terms of service, potentially leading to account suspension or other risks. The decision to use this feature and any resulting consequences are entirely yours.
|
package/bin/codex-auth.js
CHANGED
|
@@ -10,21 +10,6 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
10
10
|
const __dirname = path.dirname(__filename);
|
|
11
11
|
const require = createRequire(import.meta.url);
|
|
12
12
|
const rootPackageJsonPath = path.join(__dirname, "..", "package.json");
|
|
13
|
-
const requiredNodeMajor = 22;
|
|
14
|
-
|
|
15
|
-
function ensureSupportedNodeVersion() {
|
|
16
|
-
const major = Number(process.versions?.node?.split(".")[0] ?? 0);
|
|
17
|
-
if (Number.isInteger(major) && major >= requiredNodeMajor) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
console.error(
|
|
22
|
-
`Node.js ${requiredNodeMajor}+ is required to run @loongphy/codex-auth. Current version: ${process.version}.`
|
|
23
|
-
);
|
|
24
|
-
process.exit(1);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
ensureSupportedNodeVersion();
|
|
28
13
|
|
|
29
14
|
const packageMap = {
|
|
30
15
|
"linux:x64": "@loongphy/codex-auth-linux-x64",
|
|
@@ -92,11 +77,7 @@ function resolveBinary() {
|
|
|
92
77
|
|
|
93
78
|
const binaryPath = resolveBinary();
|
|
94
79
|
const child = spawnSync(binaryPath, process.argv.slice(2), {
|
|
95
|
-
stdio: "inherit"
|
|
96
|
-
env: {
|
|
97
|
-
...process.env,
|
|
98
|
-
CODEX_AUTH_NODE_EXECUTABLE: process.execPath
|
|
99
|
-
}
|
|
80
|
+
stdio: "inherit"
|
|
100
81
|
});
|
|
101
82
|
|
|
102
83
|
if (child.error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loongphy/codex-auth",
|
|
3
|
-
"version": "0.3.0-alpha.
|
|
3
|
+
"version": "0.3.0-alpha.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "CLI for switching Codex accounts",
|
|
6
6
|
"license": "MIT",
|
|
@@ -21,21 +21,19 @@
|
|
|
21
21
|
"README.md"
|
|
22
22
|
],
|
|
23
23
|
"optionalDependencies": {
|
|
24
|
-
"@loongphy/codex-auth-linux-x64": "0.3.0-alpha.
|
|
25
|
-
"@loongphy/codex-auth-linux-arm64": "0.3.0-alpha.
|
|
26
|
-
"@loongphy/codex-auth-darwin-x64": "0.3.0-alpha.
|
|
27
|
-
"@loongphy/codex-auth-darwin-arm64": "0.3.0-alpha.
|
|
28
|
-
"@loongphy/codex-auth-win32-x64": "0.3.0-alpha.
|
|
29
|
-
"@loongphy/codex-auth-win32-arm64": "0.3.0-alpha.
|
|
24
|
+
"@loongphy/codex-auth-linux-x64": "0.3.0-alpha.10",
|
|
25
|
+
"@loongphy/codex-auth-linux-arm64": "0.3.0-alpha.10",
|
|
26
|
+
"@loongphy/codex-auth-darwin-x64": "0.3.0-alpha.10",
|
|
27
|
+
"@loongphy/codex-auth-darwin-arm64": "0.3.0-alpha.10",
|
|
28
|
+
"@loongphy/codex-auth-win32-x64": "0.3.0-alpha.10",
|
|
29
|
+
"@loongphy/codex-auth-win32-arm64": "0.3.0-alpha.10"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
32
|
"check:versions": "node scripts/npm/check-versions.mjs",
|
|
33
|
+
"check:release-metadata": "node scripts/npm/check-release-metadata.mjs",
|
|
33
34
|
"stage:npm": "node scripts/npm/stage-packages.mjs"
|
|
34
35
|
},
|
|
35
36
|
"publishConfig": {
|
|
36
37
|
"access": "public"
|
|
37
|
-
},
|
|
38
|
-
"engines": {
|
|
39
|
-
"node": ">=22"
|
|
40
38
|
}
|
|
41
39
|
}
|