@loongphy/codex-auth-linux-x64 0.1.4 → 0.2.0-alpha.1
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 +121 -8
- package/bin/codex-auth +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,11 +1,29 @@
|
|
|
1
1
|
# Codex Auth
|
|
2
2
|
|
|
3
|
-

|
|
4
4
|
|
|
5
|
-
`codex-auth` is a
|
|
5
|
+
`codex-auth` is a command-line tool for switching Codex accounts.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
> [!IMPORTANT]
|
|
8
|
+
> For **Codex CLI** users, after switching accounts, you must fully exit `codex` (type `/exit` or close the terminal session) and start it again for the new account to take effect.
|
|
9
|
+
>
|
|
10
|
+
> If you want seamless automatic account switching without restarting `codex`, use forked [codext](https://github.com/Loongphy/codext), but you need to build it yourself because there is no prebuilt install method yet.
|
|
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` or `codex-auth login` to sign in and add accounts more easily.
|
|
9
27
|
|
|
10
28
|
## Install
|
|
11
29
|
|
|
@@ -21,6 +39,8 @@ npm install -g @loongphy/codex-auth
|
|
|
21
39
|
npx @loongphy/codex-auth list
|
|
22
40
|
```
|
|
23
41
|
|
|
42
|
+
npm packages currently support Linux x64, macOS x64, macOS arm64, and Windows x64.
|
|
43
|
+
|
|
24
44
|
- Linux/macOS/WSL2:
|
|
25
45
|
|
|
26
46
|
```shell
|
|
@@ -40,16 +60,44 @@ irm https://raw.githubusercontent.com/loongphy/codex-auth/main/scripts/install.p
|
|
|
40
60
|
The installer adds the install dir to current/user `PATH` by default.
|
|
41
61
|
Use `-NoAddToPath` to skip user `PATH` persistence.
|
|
42
62
|
|
|
63
|
+
## Upgrade
|
|
64
|
+
|
|
65
|
+
If you are upgrading from any `v0.1.x` release to `v0.2.0`, back up these files first to avoid data loss:
|
|
66
|
+
|
|
67
|
+
- Always back up `~/.codex/auth.json`
|
|
68
|
+
- If you have already used `codex-auth`, also back up `~/.codex/accounts/`
|
|
69
|
+
|
|
70
|
+
Then complete these steps:
|
|
71
|
+
|
|
72
|
+
1. Install the latest `v0.2.0` release:
|
|
73
|
+
|
|
74
|
+
```shell
|
|
75
|
+
npm install -g @loongphy/codex-auth@latest
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
1. Enable API-based usage refresh if needed (see the Disclaimer for more details):
|
|
79
|
+
|
|
80
|
+
```shell
|
|
81
|
+
codex-auth config api enable
|
|
82
|
+
```
|
|
83
|
+
|
|
43
84
|
## Full Commands
|
|
44
85
|
|
|
45
86
|
```shell
|
|
46
87
|
codex-auth list # list all accounts
|
|
47
|
-
codex-auth
|
|
88
|
+
codex-auth login # run `codex login`, then add the current account
|
|
48
89
|
codex-auth switch [<email>] # switch active account (interactive or partial/fragment match)
|
|
49
90
|
codex-auth import <path> [--alias <alias>] # smart import: file -> single import, folder -> batch import
|
|
91
|
+
codex-auth import --purge [<path>] # rebuild registry.json from auth files for the current version
|
|
50
92
|
codex-auth remove # remove accounts (interactive multi-select)
|
|
93
|
+
codex-auth status # show auto-switch/service/api usage status
|
|
94
|
+
codex-auth config auto enable|disable # manage background auto-switching
|
|
95
|
+
codex-auth config auto --5h <percent> [--weekly <percent>] # configure auto-switch thresholds
|
|
96
|
+
codex-auth config api enable|disable # choose API-only or local-sessions-only usage refresh
|
|
51
97
|
```
|
|
52
98
|
|
|
99
|
+
Compatibility note: `codex-auth add` is still accepted as a deprecated alias for `codex-auth login`.
|
|
100
|
+
|
|
53
101
|
### Examples
|
|
54
102
|
|
|
55
103
|
List accounts (default table with borders):
|
|
@@ -61,7 +109,7 @@ codex-auth list
|
|
|
61
109
|
Add the currently logged-in Codex account:
|
|
62
110
|
|
|
63
111
|
```shell
|
|
64
|
-
codex-auth
|
|
112
|
+
codex-auth login
|
|
65
113
|
```
|
|
66
114
|
|
|
67
115
|
Import an auth.json backup:
|
|
@@ -76,12 +124,21 @@ Batch import from a folder:
|
|
|
76
124
|
codex-auth import /path/to/auth-exports
|
|
77
125
|
```
|
|
78
126
|
|
|
127
|
+
Rebuild `registry.json` from imported auth files:
|
|
128
|
+
|
|
129
|
+
```shell
|
|
130
|
+
codex-auth import --purge /path/to/auth-exports
|
|
131
|
+
codex-auth import --purge # rebuild from ~/.codex/accounts/*.auth.json
|
|
132
|
+
```
|
|
133
|
+
|
|
79
134
|
Switch accounts (interactive list shows email, 5h, weekly, last activity):
|
|
80
135
|
|
|
81
136
|
```shell
|
|
82
|
-
codex-auth switch # arrow + number input
|
|
137
|
+
codex-auth switch # arrow + number input, q to quit
|
|
83
138
|
```
|
|
84
139
|
|
|
140
|
+
Before the switch picker opens, `codex-auth switch` refreshes the current active account's usage once so the currently selected row is not stale. It does not refresh the newly selected account after the switch completes.
|
|
141
|
+
|
|
85
142
|

|
|
86
143
|
|
|
87
144
|
Switch account non-interactively (for scripts/other CLIs):
|
|
@@ -90,10 +147,66 @@ Switch account non-interactively (for scripts/other CLIs):
|
|
|
90
147
|
codex-auth switch user
|
|
91
148
|
```
|
|
92
149
|
|
|
93
|
-
If multiple accounts match, interactive selection is shown.
|
|
150
|
+
If multiple accounts match, interactive selection is shown, and you can press `q` to quit without switching.
|
|
94
151
|
|
|
95
152
|
Remove accounts (interactive multi-select):
|
|
96
153
|
|
|
97
154
|
```shell
|
|
98
155
|
codex-auth remove
|
|
99
156
|
```
|
|
157
|
+
|
|
158
|
+
Show current status:
|
|
159
|
+
|
|
160
|
+
```shell
|
|
161
|
+
codex-auth status
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
Enable background auto-switching:
|
|
165
|
+
|
|
166
|
+
```shell
|
|
167
|
+
codex-auth config auto enable
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Configure auto-switch thresholds:
|
|
171
|
+
|
|
172
|
+
```shell
|
|
173
|
+
codex-auth config auto --5h 12
|
|
174
|
+
codex-auth config auto --5h 12 --weekly 8
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Use API-only usage refresh:
|
|
178
|
+
|
|
179
|
+
```shell
|
|
180
|
+
codex-auth config api enable
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Use pure local rollout refresh without any API calls:
|
|
184
|
+
|
|
185
|
+
```shell
|
|
186
|
+
codex-auth config api disable
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
When auto-switching is enabled, a background worker refreshes the active account's usage from the configured source and silently switches accounts when:
|
|
190
|
+
|
|
191
|
+
- 5h remaining drops below the configured 5h threshold (default `10%`), or
|
|
192
|
+
- weekly remaining drops below the configured weekly threshold (default `5%`)
|
|
193
|
+
|
|
194
|
+
Accounts without any usage snapshot are treated as fresh accounts with full quota when ranking candidates.
|
|
195
|
+
On Linux/WSL, background checks run through `systemd --user` as a oneshot service triggered every minute by a timer. On Windows, a user scheduled task runs the same one-shot check every minute. On macOS, the background worker remains long-running.
|
|
196
|
+
Successful foreground `codex-auth` commands also reconcile the managed auto-switch service, so a disabled config removes stale background units while an enabled background worker is refreshed onto the current binary after upgrades or stale service drift.
|
|
197
|
+
Changing thresholds updates `registry.json`; Linux/WSL and Windows pick them up on the next scheduled run, while macOS picks them up on the next polling cycle, without a service restart.
|
|
198
|
+
Changing `config api` updates `registry.json` immediately; `api enable` means API-only and `api disable` means local-sessions-only.
|
|
199
|
+
`codex-auth help` also shows whether auto-switching and usage API calls are currently enabled.
|
|
200
|
+
|
|
201
|
+
## Disclaimer
|
|
202
|
+
|
|
203
|
+
This project is provided as-is and use is at your own risk.
|
|
204
|
+
|
|
205
|
+
**Usage Data Refresh Source:**
|
|
206
|
+
`codex-auth` supports two sources for refreshing account usage/quota information:
|
|
207
|
+
|
|
208
|
+
1. **Local (default):** Scans local `~/.codex/sessions/*/rollout-*.jsonl` files. This mode is strictly local.
|
|
209
|
+
2. **API:** When `config api enable` is on, the tool will make direct HTTPS requests to OpenAI's endpoints using your account's access token.
|
|
210
|
+
|
|
211
|
+
**API Call Declaration:**
|
|
212
|
+
By enabling API-based usage refresh, this tool will send your ChatGPT access token to OpenAI's servers (specifically `https://chatgpt.com/backend-api/wham/usage`) to fetch current quota information. 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
CHANGED
|
Binary file
|