@loongphy/codex-auth 0.2.3 → 0.2.5

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
@@ -47,7 +47,22 @@ npx @loongphy/codex-auth list
47
47
  > If you previously used those legacy installers, remove the leftover binaries and profile changes during migration.
48
48
  > API-backed usage refresh and team-name refresh use Node.js `fetch`.
49
49
  > npm installs already satisfy that requirement.
50
- > Legacy standalone binary installs need Node.js 18+ on `PATH` when `codex-auth config api enable` is used.
50
+ > Legacy standalone binary installs need Node.js 22+ on `PATH` when `codex-auth config api enable` is used.
51
+
52
+ ## Storage Root
53
+
54
+ `codex-auth` uses the same Codex state root as the current process. Resolution order:
55
+
56
+ 1. `CODEX_HOME` when set to a non-empty existing directory
57
+ 2. `HOME/.codex`
58
+ 3. `USERPROFILE/.codex` on Windows
59
+
60
+ When `CODEX_HOME` is set, `codex-auth` follows Codex and requires that directory to already exist.
61
+ That means you can isolate auth, registry, config, and session files by running:
62
+
63
+ ```shell
64
+ CODEX_HOME=/path/to/custom-codex codex-auth list
65
+ ```
51
66
 
52
67
  ### Uninstall
53
68
 
@@ -95,7 +110,7 @@ Remove-Item "$env:LOCALAPPDATA\codex-auth\bin\codex-auth-auto.exe" -Force -Error
95
110
 
96
111
  | Command | Description |
97
112
  |---------|-------------|
98
- | `codex-auth list` | List all accounts |
113
+ | `codex-auth list [--debug]` | List all accounts |
99
114
  | `codex-auth login [--device-auth]` | Run `codex login` (optionally with `--device-auth`), then add the current account |
100
115
  | `codex-auth switch [<email>]` | Switch active account interactively or by partial match |
101
116
  | `codex-auth remove` | Remove accounts with interactive multi-select |
@@ -113,8 +128,8 @@ Remove-Item "$env:LOCALAPPDATA\codex-auth\bin\codex-auth-auto.exe" -Force -Error
113
128
 
114
129
  | Command | Description |
115
130
  |---------|-------------|
116
- | `codex-auth config auto enable\|disable` | Enable or disable background auto-switching |
117
- | `codex-auth config auto [--5h <%>] [--weekly <%>]` | Set auto-switch thresholds |
131
+ | `codex-auth config auto enable\|disable` | Enable or disable experimental background auto-switching |
132
+ | `codex-auth config auto [--5h <%>] [--weekly <%>]` | Set experimental auto-switch thresholds |
118
133
  | `codex-auth config api enable\|disable` | Enable or disable both usage refresh and team name refresh API calls |
119
134
 
120
135
  ---
@@ -125,6 +140,7 @@ Remove-Item "$env:LOCALAPPDATA\codex-auth\bin\codex-auth-auto.exe" -Force -Error
125
140
 
126
141
  ```shell
127
142
  codex-auth list
143
+ codex-auth list --debug
128
144
  ```
129
145
 
130
146
  ### Switch Account
@@ -135,8 +151,6 @@ Interactive: shows email, 5h, weekly, and last activity.
135
151
  codex-auth switch
136
152
  ```
137
153
 
138
- Before the picker opens, the current active account's usage is refreshed once so the selected row is not stale. The newly selected account is not refreshed after the switch completes.
139
-
140
154
  ![command switch](https://github.com/user-attachments/assets/48a86acf-2a6e-4206-a8c4-591989fdc0df)
141
155
 
142
156
  Non-interactive: fuzzy match by email or alias.
@@ -223,6 +237,9 @@ codex-auth status
223
237
 
224
238
  #### Auto-Switch
225
239
 
240
+ > [!WARNING]
241
+ > Auto-switch is experimental. Behavior, defaults, and platform integration may change in future releases while the feature matures.
242
+
226
243
  Enable or disable:
227
244
 
228
245
  ```shell
@@ -307,7 +324,7 @@ This project is provided as-is and use is at your own risk.
307
324
  **Usage Data Refresh Source:**
308
325
  `codex-auth` supports two sources for refreshing account usage/usage limit information:
309
326
 
310
- 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.
327
+ 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`.
311
328
  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.
312
329
 
313
330
  **API Call Declaration:**
package/bin/codex-auth.js CHANGED
@@ -4,6 +4,21 @@ const path = require("node:path");
4
4
  const { spawnSync } = require("node:child_process");
5
5
  const fs = require("node:fs");
6
6
  const rootPackageJsonPath = path.join(__dirname, "..", "package.json");
7
+ const requiredNodeMajor = 22;
8
+
9
+ function ensureSupportedNodeVersion() {
10
+ const major = Number(process.versions?.node?.split(".")[0] ?? 0);
11
+ if (Number.isInteger(major) && major >= requiredNodeMajor) {
12
+ return;
13
+ }
14
+
15
+ console.error(
16
+ `Node.js ${requiredNodeMajor}+ is required to run @loongphy/codex-auth. Current version: ${process.version}.`
17
+ );
18
+ process.exit(1);
19
+ }
20
+
21
+ ensureSupportedNodeVersion();
7
22
 
8
23
  const packageMap = {
9
24
  "linux:x64": "@loongphy/codex-auth-linux-x64",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loongphy/codex-auth",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "CLI for switching Codex accounts",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -20,12 +20,12 @@
20
20
  "README.md"
21
21
  ],
22
22
  "optionalDependencies": {
23
- "@loongphy/codex-auth-linux-x64": "0.2.3",
24
- "@loongphy/codex-auth-linux-arm64": "0.2.3",
25
- "@loongphy/codex-auth-darwin-x64": "0.2.3",
26
- "@loongphy/codex-auth-darwin-arm64": "0.2.3",
27
- "@loongphy/codex-auth-win32-x64": "0.2.3",
28
- "@loongphy/codex-auth-win32-arm64": "0.2.3"
23
+ "@loongphy/codex-auth-linux-x64": "0.2.5",
24
+ "@loongphy/codex-auth-linux-arm64": "0.2.5",
25
+ "@loongphy/codex-auth-darwin-x64": "0.2.5",
26
+ "@loongphy/codex-auth-darwin-arm64": "0.2.5",
27
+ "@loongphy/codex-auth-win32-x64": "0.2.5",
28
+ "@loongphy/codex-auth-win32-arm64": "0.2.5"
29
29
  },
30
30
  "scripts": {
31
31
  "check:versions": "node scripts/npm/check-versions.mjs",
@@ -35,6 +35,6 @@
35
35
  "access": "public"
36
36
  },
37
37
  "engines": {
38
- "node": ">=18"
38
+ "node": ">=22"
39
39
  }
40
40
  }