@loongphy/codex-auth-linux-x64 0.1.5 → 0.2.0

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
 
@@ -46,12 +64,19 @@ irm https://raw.githubusercontent.com/loongphy/codex-auth/main/scripts/install.p
46
64
 
47
65
  ```shell
48
66
  codex-auth list # list all accounts
49
- codex-auth add [--no-login] # add current account (runs `codex login` by default)
67
+ codex-auth login # run `codex login`, then add the current account
50
68
  codex-auth switch [<email>] # switch active account (interactive or partial/fragment match)
51
69
  codex-auth import <path> [--alias <alias>] # smart import: file -> single import, folder -> batch import
70
+ codex-auth import --purge [<path>] # rebuild registry.json from auth files for the current version
52
71
  codex-auth remove # remove accounts (interactive multi-select)
72
+ codex-auth status # show auto-switch/service/api usage status
73
+ codex-auth config auto enable|disable # manage background auto-switching
74
+ codex-auth config auto --5h <percent> [--weekly <percent>] # configure auto-switch thresholds
75
+ codex-auth config api enable|disable # choose API-only or local-sessions-only usage refresh
53
76
  ```
54
77
 
78
+ Compatibility note: `codex-auth add` is still accepted as a deprecated alias for `codex-auth login`.
79
+
55
80
  ### Examples
56
81
 
57
82
  List accounts (default table with borders):
@@ -63,7 +88,7 @@ codex-auth list
63
88
  Add the currently logged-in Codex account:
64
89
 
65
90
  ```shell
66
- codex-auth add
91
+ codex-auth login
67
92
  ```
68
93
 
69
94
  Import an auth.json backup:
@@ -78,12 +103,21 @@ Batch import from a folder:
78
103
  codex-auth import /path/to/auth-exports
79
104
  ```
80
105
 
106
+ Rebuild `registry.json` from imported auth files:
107
+
108
+ ```shell
109
+ codex-auth import --purge /path/to/auth-exports
110
+ codex-auth import --purge # rebuild from ~/.codex/accounts/*.auth.json
111
+ ```
112
+
81
113
  Switch accounts (interactive list shows email, 5h, weekly, last activity):
82
114
 
83
115
  ```shell
84
- codex-auth switch # arrow + number input
116
+ codex-auth switch # arrow + number input, q to quit
85
117
  ```
86
118
 
119
+ 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.
120
+
87
121
  ![command switch](https://github.com/user-attachments/assets/48a86acf-2a6e-4206-a8c4-591989fdc0df)
88
122
 
89
123
  Switch account non-interactively (for scripts/other CLIs):
@@ -92,10 +126,66 @@ Switch account non-interactively (for scripts/other CLIs):
92
126
  codex-auth switch user
93
127
  ```
94
128
 
95
- If multiple accounts match, interactive selection is shown.
129
+ If multiple accounts match, interactive selection is shown, and you can press `q` to quit without switching.
96
130
 
97
131
  Remove accounts (interactive multi-select):
98
132
 
99
133
  ```shell
100
134
  codex-auth remove
101
135
  ```
136
+
137
+ Show current status:
138
+
139
+ ```shell
140
+ codex-auth status
141
+ ```
142
+
143
+ Enable background auto-switching:
144
+
145
+ ```shell
146
+ codex-auth config auto enable
147
+ ```
148
+
149
+ Configure auto-switch thresholds:
150
+
151
+ ```shell
152
+ codex-auth config auto --5h 12
153
+ codex-auth config auto --5h 12 --weekly 8
154
+ ```
155
+
156
+ Use API-only usage refresh:
157
+
158
+ ```shell
159
+ codex-auth config api enable
160
+ ```
161
+
162
+ Use pure local rollout refresh without any API calls:
163
+
164
+ ```shell
165
+ codex-auth config api disable
166
+ ```
167
+
168
+ When auto-switching is enabled, a background worker refreshes the active account's usage from the configured source and silently switches accounts when:
169
+
170
+ - 5h remaining drops below the configured 5h threshold (default `10%`), or
171
+ - weekly remaining drops below the configured weekly threshold (default `5%`)
172
+
173
+ Accounts without any usage snapshot are treated as fresh accounts with full quota when ranking candidates.
174
+ 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.
175
+ 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.
176
+ 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.
177
+ Changing `config api` updates `registry.json` immediately; `api enable` means API-only and `api disable` means local-sessions-only.
178
+ `codex-auth help` also shows whether auto-switching and usage API calls are currently enabled.
179
+
180
+ ## Disclaimer
181
+
182
+ This project is provided as-is and use is at your own risk.
183
+
184
+ **Usage Data Refresh Source:**
185
+ `codex-auth` supports two sources for refreshing account usage/quota information:
186
+
187
+ 1. **Local (default):** Scans local `~/.codex/sessions/*/rollout-*.jsonl` files. This mode is strictly local.
188
+ 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.
189
+
190
+ **API Call Declaration:**
191
+ 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",
4
4
  "description": "@loongphy/codex-auth binary for linux x64",
5
5
  "license": "MIT",
6
6
  "repository": {