@loongphy/codex-auth-linux-x64 0.1.5 → 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 CHANGED
@@ -1,11 +1,29 @@
1
1
  # Codex Auth
2
2
 
3
- ![command list](https://github.com/user-attachments/assets/7bbd463b-c5ed-4b90-b1f6-8dfbf21a8944)
3
+ ![command list](https://github.com/user-attachments/assets/6c13a2d6-f9da-47ea-8ec8-0394fc072d40)
4
4
 
5
- `codex-auth` is a local-only command-line tool for switching Codex accounts.
5
+ `codex-auth` is a command-line tool for switching Codex accounts.
6
6
 
7
- - It never calls OpenAI APIs; all operations happen locally on your machine.
8
- - It reads and updates local Codex files under `~/.codex` (including `sessions/` and auth files).
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
 
@@ -42,16 +60,44 @@ irm https://raw.githubusercontent.com/loongphy/codex-auth/main/scripts/install.p
42
60
  The installer adds the install dir to current/user `PATH` by default.
43
61
  Use `-NoAddToPath` to skip user `PATH` persistence.
44
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
+
45
84
  ## Full Commands
46
85
 
47
86
  ```shell
48
87
  codex-auth list # list all accounts
49
- codex-auth add [--no-login] # add current account (runs `codex login` by default)
88
+ codex-auth login # run `codex login`, then add the current account
50
89
  codex-auth switch [<email>] # switch active account (interactive or partial/fragment match)
51
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
52
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
53
97
  ```
54
98
 
99
+ Compatibility note: `codex-auth add` is still accepted as a deprecated alias for `codex-auth login`.
100
+
55
101
  ### Examples
56
102
 
57
103
  List accounts (default table with borders):
@@ -63,7 +109,7 @@ codex-auth list
63
109
  Add the currently logged-in Codex account:
64
110
 
65
111
  ```shell
66
- codex-auth add
112
+ codex-auth login
67
113
  ```
68
114
 
69
115
  Import an auth.json backup:
@@ -78,12 +124,21 @@ Batch import from a folder:
78
124
  codex-auth import /path/to/auth-exports
79
125
  ```
80
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
+
81
134
  Switch accounts (interactive list shows email, 5h, weekly, last activity):
82
135
 
83
136
  ```shell
84
- codex-auth switch # arrow + number input
137
+ codex-auth switch # arrow + number input, q to quit
85
138
  ```
86
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
+
87
142
  ![command switch](https://github.com/user-attachments/assets/48a86acf-2a6e-4206-a8c4-591989fdc0df)
88
143
 
89
144
  Switch account non-interactively (for scripts/other CLIs):
@@ -92,10 +147,66 @@ Switch account non-interactively (for scripts/other CLIs):
92
147
  codex-auth switch user
93
148
  ```
94
149
 
95
- 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.
96
151
 
97
152
  Remove accounts (interactive multi-select):
98
153
 
99
154
  ```shell
100
155
  codex-auth remove
101
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loongphy/codex-auth-linux-x64",
3
- "version": "0.1.5",
3
+ "version": "0.2.0-alpha.1",
4
4
  "description": "@loongphy/codex-auth binary for linux x64",
5
5
  "license": "MIT",
6
6
  "repository": {