codex-multi-auth 2.8.1 → 2.8.3

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.
Files changed (76) hide show
  1. package/.codex-plugin/plugin.json +1 -1
  2. package/README.md +3 -1
  3. package/dist/lib/accounts.d.ts +15 -0
  4. package/dist/lib/accounts.d.ts.map +1 -1
  5. package/dist/lib/accounts.js +126 -21
  6. package/dist/lib/codex-manager/account-pool-write.d.ts.map +1 -1
  7. package/dist/lib/codex-manager/account-pool-write.js +4 -0
  8. package/dist/lib/codex-manager/backend-settings-schema.js +1 -1
  9. package/dist/lib/codex-manager/commands/status.d.ts.map +1 -1
  10. package/dist/lib/codex-manager/commands/status.js +5 -1
  11. package/dist/lib/codex-manager/commands/uninstall.d.ts +1 -0
  12. package/dist/lib/codex-manager/commands/uninstall.d.ts.map +1 -1
  13. package/dist/lib/codex-manager/commands/uninstall.js +12 -1
  14. package/dist/lib/codex-manager/commands/why-selected.d.ts +1 -1
  15. package/dist/lib/codex-manager/commands/why-selected.d.ts.map +1 -1
  16. package/dist/lib/codex-manager/commands/why-selected.js +1 -1
  17. package/dist/lib/codex-manager/formatters/quota-formatters.d.ts.map +1 -1
  18. package/dist/lib/codex-manager/formatters/quota-formatters.js +32 -2
  19. package/dist/lib/codex-manager/health-check.d.ts.map +1 -1
  20. package/dist/lib/codex-manager/health-check.js +19 -3
  21. package/dist/lib/codex-manager/login-oauth.d.ts.map +1 -1
  22. package/dist/lib/codex-manager/login-oauth.js +13 -7
  23. package/dist/lib/codex-manager.d.ts +4 -0
  24. package/dist/lib/codex-manager.d.ts.map +1 -1
  25. package/dist/lib/codex-manager.js +50 -16
  26. package/dist/lib/config.d.ts +3 -1
  27. package/dist/lib/config.d.ts.map +1 -1
  28. package/dist/lib/config.js +3 -1
  29. package/dist/lib/forecast.d.ts.map +1 -1
  30. package/dist/lib/forecast.js +7 -1
  31. package/dist/lib/index.d.ts +1 -0
  32. package/dist/lib/index.d.ts.map +1 -1
  33. package/dist/lib/index.js +1 -0
  34. package/dist/lib/parallel-probe.d.ts.map +1 -1
  35. package/dist/lib/parallel-probe.js +3 -1
  36. package/dist/lib/policy/runtime-policy.d.ts +1 -0
  37. package/dist/lib/policy/runtime-policy.d.ts.map +1 -1
  38. package/dist/lib/policy/runtime-policy.js +7 -0
  39. package/dist/lib/preemptive-quota-scheduler.d.ts.map +1 -1
  40. package/dist/lib/preemptive-quota-scheduler.js +35 -15
  41. package/dist/lib/rotation.d.ts +4 -0
  42. package/dist/lib/rotation.d.ts.map +1 -1
  43. package/dist/lib/rotation.js +13 -6
  44. package/dist/lib/runtime/app-bind.d.ts +40 -0
  45. package/dist/lib/runtime/app-bind.d.ts.map +1 -1
  46. package/dist/lib/runtime/app-bind.js +550 -20
  47. package/dist/lib/runtime/rotation-account-selection.d.ts.map +1 -1
  48. package/dist/lib/runtime/rotation-account-selection.js +2 -0
  49. package/dist/lib/runtime/rotation-proxy-state.d.ts +2 -0
  50. package/dist/lib/runtime/rotation-proxy-state.d.ts.map +1 -1
  51. package/dist/lib/runtime/rotation-token-refresh.d.ts.map +1 -1
  52. package/dist/lib/runtime/rotation-token-refresh.js +3 -0
  53. package/dist/lib/runtime-constants.d.ts +2 -0
  54. package/dist/lib/runtime-constants.d.ts.map +1 -1
  55. package/dist/lib/runtime-constants.js +2 -0
  56. package/dist/lib/runtime-rotation-proxy.d.ts +8 -0
  57. package/dist/lib/runtime-rotation-proxy.d.ts.map +1 -1
  58. package/dist/lib/runtime-rotation-proxy.js +59 -5
  59. package/dist/lib/schemas.d.ts +15 -0
  60. package/dist/lib/schemas.d.ts.map +1 -1
  61. package/dist/lib/schemas.js +3 -0
  62. package/dist/lib/storage/flagged-storage.d.ts.map +1 -1
  63. package/dist/lib/storage/flagged-storage.js +15 -0
  64. package/dist/lib/storage/path-state.d.ts +1 -0
  65. package/dist/lib/storage/path-state.d.ts.map +1 -1
  66. package/dist/lib/storage/path-state.js +30 -3
  67. package/dist/lib/storage/public-types.d.ts +6 -0
  68. package/dist/lib/storage/public-types.d.ts.map +1 -1
  69. package/dist/lib/storage.d.ts.map +1 -1
  70. package/dist/lib/storage.js +17 -4
  71. package/package.json +198 -198
  72. package/scripts/codex-app-router.js +47 -3
  73. package/scripts/codex.js +165 -21
  74. package/scripts/install-codex-auth-utils.js +9 -2
  75. package/scripts/postinstall.js +2 -0
  76. package/scripts/preuninstall.js +11 -0
package/package.json CHANGED
@@ -1,198 +1,198 @@
1
- {
2
- "name": "codex-multi-auth",
3
- "version": "2.8.1",
4
- "description": "Codex CLI multi-account OAuth manager with account switching, health checks, runtime rotation, diagnostics, and recovery tools for @openai/codex",
5
- "main": "./dist/index.js",
6
- "types": "./dist/index.d.ts",
7
- "exports": {
8
- ".": {
9
- "types": "./dist/index.d.ts",
10
- "import": "./dist/index.js",
11
- "default": "./dist/index.js"
12
- },
13
- "./auth": {
14
- "types": "./dist/lib/auth/index.d.ts",
15
- "import": "./dist/lib/auth/index.js",
16
- "default": "./dist/lib/auth/index.js"
17
- },
18
- "./storage": {
19
- "types": "./dist/lib/storage.d.ts",
20
- "import": "./dist/lib/storage.js",
21
- "default": "./dist/lib/storage.js"
22
- },
23
- "./config": {
24
- "types": "./dist/lib/config.d.ts",
25
- "import": "./dist/lib/config.js",
26
- "default": "./dist/lib/config.js"
27
- },
28
- "./request": {
29
- "types": "./dist/lib/request/index.d.ts",
30
- "import": "./dist/lib/request/index.js",
31
- "default": "./dist/lib/request/index.js"
32
- },
33
- "./cli": {
34
- "types": "./dist/lib/codex-cli/index.d.ts",
35
- "import": "./dist/lib/codex-cli/index.js",
36
- "default": "./dist/lib/codex-cli/index.js"
37
- },
38
- "./package.json": "./package.json"
39
- },
40
- "type": "module",
41
- "license": "MIT",
42
- "author": "ndycode",
43
- "repository": {
44
- "type": "git",
45
- "url": "git+https://github.com/ndycode/codex-multi-auth.git"
46
- },
47
- "keywords": [
48
- "openai",
49
- "codex",
50
- "codex-cli",
51
- "codex-auth",
52
- "codex-multi-account",
53
- "chatgpt",
54
- "oauth",
55
- "oauth2",
56
- "pkce",
57
- "multi-account",
58
- "account-switching",
59
- "oauth-manager",
60
- "runtime-rotation",
61
- "responses-api",
62
- "local-proxy",
63
- "quota-management",
64
- "diagnostics",
65
- "fault-tolerance",
66
- "terminal-ui",
67
- "cli-tool",
68
- "typescript",
69
- "nodejs",
70
- "developer-tools",
71
- "authentication",
72
- "account-health",
73
- "recovery-tools",
74
- "project-scoped-storage"
75
- ],
76
- "homepage": "https://github.com/ndycode/codex-multi-auth#readme",
77
- "bugs": {
78
- "url": "https://github.com/ndycode/codex-multi-auth/issues"
79
- },
80
- "scripts": {
81
- "build": "tsc && node scripts/copy-oauth-success.js",
82
- "generate:schema": "npm run build && node scripts/generate-config-schema.mjs",
83
- "typecheck": "tsc --noEmit",
84
- "typecheck:scripts": "tsc -p tsconfig.scripts.json",
85
- "lint": "npm run lint:ts && npm run lint:scripts",
86
- "lint:ts": "eslint . --ext .ts",
87
- "lint:scripts": "eslint scripts --ext .js,.mjs",
88
- "lint:fix": "npm run lint:ts:fix && npm run lint:scripts:fix",
89
- "lint:ts:fix": "eslint . --ext .ts --fix",
90
- "lint:scripts:fix": "eslint scripts --ext .js,.mjs --fix",
91
- "test": "vitest run --maxWorkers=1",
92
- "test:watch": "vitest",
93
- "test:ui": "vitest --ui",
94
- "test:model-matrix": "node scripts/test-model-matrix.js",
95
- "test:model-matrix:smoke": "node scripts/test-model-matrix.js --smoke",
96
- "test:model-matrix:report": "node scripts/test-model-matrix.js --smoke --report-json=.tmp/model-matrix-report.json",
97
- "clean:repo": "node scripts/repo-hygiene.js clean --mode aggressive",
98
- "clean:repo:check": "node scripts/repo-hygiene.js check",
99
- "pack:check": "npm run build && node scripts/check-pack-budget.mjs",
100
- "bench:edit-formats": "node scripts/benchmark-edit-formats.mjs --preset=codex-core",
101
- "bench:edit-formats:smoke": "node scripts/benchmark-edit-formats.mjs --smoke --preset=codex-core",
102
- "bench:edit-formats:render": "node scripts/benchmark-render-dashboard.mjs",
103
- "bench:runtime-path": "npm run build && node scripts/benchmark-runtime-path.mjs",
104
- "bench:runtime-path:quick": "node scripts/benchmark-runtime-path.mjs",
105
- "test:coverage": "vitest run --coverage --maxWorkers=1",
106
- "coverage": "npm run build && vitest run --coverage --maxWorkers=1",
107
- "audit:prod": "npm audit --omit=dev --audit-level=high",
108
- "audit:all": "npm audit --audit-level=high",
109
- "audit:dev:allowlist": "node scripts/audit-dev-allowlist.js",
110
- "audit:ci": "npm run audit:prod && npm run audit:dev:allowlist",
111
- "vendor:verify": "node scripts/verify-vendor-provenance.mjs",
112
- "vendor:update-manifest": "node scripts/update-vendor-provenance.mjs",
113
- "postinstall": "node scripts/postinstall.js",
114
- "prepublishOnly": "npm run build",
115
- "prepare": "husky"
116
- },
117
- "bin": {
118
- "mcodex": "scripts/mcodex.js",
119
- "codex-multi-auth-codex": "scripts/codex.js",
120
- "codex-multi-auth-app-launcher": "scripts/codex-app-launcher.js",
121
- "codex-multi-auth": "scripts/codex-multi-auth.js"
122
- },
123
- "files": [
124
- ".codex-plugin/plugin.json",
125
- "dist/",
126
- "assets/",
127
- "config/",
128
- "scripts/codex.js",
129
- "scripts/codex-app-launcher.js",
130
- "scripts/codex-app-router.js",
131
- "scripts/codex-bin-resolver.js",
132
- "scripts/codex-multi-auth.js",
133
- "scripts/codex-routing.js",
134
- "scripts/mcodex.js",
135
- "scripts/install-codex-auth-utils.js",
136
- "scripts/postinstall.js",
137
- "scripts/preuninstall.js",
138
- "vendor/codex-ai-plugin/",
139
- "vendor/codex-ai-sdk/",
140
- "README.md",
141
- "LICENSE"
142
- ],
143
- "bundleDependencies": [
144
- "@codex-ai/plugin",
145
- "@codex-ai/sdk"
146
- ],
147
- "lint-staged": {
148
- "*.ts": [
149
- "eslint --max-warnings=0 --fix --no-warn-ignored"
150
- ],
151
- "scripts/**/*.{js,mjs}": [
152
- "eslint --max-warnings=0 --fix --no-warn-ignored"
153
- ]
154
- },
155
- "engines": {
156
- "node": ">=18.17.0"
157
- },
158
- "devDependencies": {
159
- "@types/node": "^20.19.42",
160
- "@typescript-eslint/eslint-plugin": "^8.56.0",
161
- "@typescript-eslint/parser": "^8.56.0",
162
- "@vitest/coverage-v8": "^4.1.8",
163
- "@vitest/ui": "^4.1.8",
164
- "eslint": "^10.0.0",
165
- "eslint-import-resolver-typescript": "^4.4.5",
166
- "eslint-plugin-import-x": "^4.16.2",
167
- "fast-check": "^4.5.3",
168
- "husky": "^9.1.7",
169
- "lint-staged": "^16.2.7",
170
- "typescript": "^5.9.3",
171
- "typescript-language-server": "^5.1.3",
172
- "vitest": "^4.1.8"
173
- },
174
- "dependencies": {
175
- "@codex-ai/plugin": "file:vendor/codex-ai-plugin",
176
- "@codex-ai/sdk": "file:vendor/codex-ai-sdk",
177
- "@openauthjs/openauth": "^0.4.3",
178
- "hono": "4.12.33",
179
- "undici": "6.28.0",
180
- "zod": "4.4.3"
181
- },
182
- "overrides": {
183
- "hono": "4.12.33",
184
- "flatted": "3.4.2",
185
- "minimatch": "10.2.4",
186
- "picomatch": "4.0.4",
187
- "rollup": "4.59.0",
188
- "vite": "^7.3.2",
189
- "micromatch": {
190
- "picomatch": "2.3.2"
191
- },
192
- "@typescript-eslint/typescript-estree": {
193
- "minimatch": "9.0.9"
194
- },
195
- "brace-expansion": "5.0.9",
196
- "postcss": "8.5.25"
197
- }
198
- }
1
+ {
2
+ "name": "codex-multi-auth",
3
+ "version": "2.8.3",
4
+ "description": "Codex CLI multi-account OAuth manager with account switching, health checks, runtime rotation, diagnostics, and recovery tools for @openai/codex",
5
+ "main": "./dist/index.js",
6
+ "types": "./dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js",
11
+ "default": "./dist/index.js"
12
+ },
13
+ "./auth": {
14
+ "types": "./dist/lib/auth/index.d.ts",
15
+ "import": "./dist/lib/auth/index.js",
16
+ "default": "./dist/lib/auth/index.js"
17
+ },
18
+ "./storage": {
19
+ "types": "./dist/lib/storage.d.ts",
20
+ "import": "./dist/lib/storage.js",
21
+ "default": "./dist/lib/storage.js"
22
+ },
23
+ "./config": {
24
+ "types": "./dist/lib/config.d.ts",
25
+ "import": "./dist/lib/config.js",
26
+ "default": "./dist/lib/config.js"
27
+ },
28
+ "./request": {
29
+ "types": "./dist/lib/request/index.d.ts",
30
+ "import": "./dist/lib/request/index.js",
31
+ "default": "./dist/lib/request/index.js"
32
+ },
33
+ "./cli": {
34
+ "types": "./dist/lib/codex-cli/index.d.ts",
35
+ "import": "./dist/lib/codex-cli/index.js",
36
+ "default": "./dist/lib/codex-cli/index.js"
37
+ },
38
+ "./package.json": "./package.json"
39
+ },
40
+ "type": "module",
41
+ "license": "MIT",
42
+ "author": "ndycode",
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "git+https://github.com/ndycode/codex-multi-auth.git"
46
+ },
47
+ "keywords": [
48
+ "openai",
49
+ "codex",
50
+ "codex-cli",
51
+ "codex-auth",
52
+ "codex-multi-account",
53
+ "chatgpt",
54
+ "oauth",
55
+ "oauth2",
56
+ "pkce",
57
+ "multi-account",
58
+ "account-switching",
59
+ "oauth-manager",
60
+ "runtime-rotation",
61
+ "responses-api",
62
+ "local-proxy",
63
+ "quota-management",
64
+ "diagnostics",
65
+ "fault-tolerance",
66
+ "terminal-ui",
67
+ "cli-tool",
68
+ "typescript",
69
+ "nodejs",
70
+ "developer-tools",
71
+ "authentication",
72
+ "account-health",
73
+ "recovery-tools",
74
+ "project-scoped-storage"
75
+ ],
76
+ "homepage": "https://github.com/ndycode/codex-multi-auth#readme",
77
+ "bugs": {
78
+ "url": "https://github.com/ndycode/codex-multi-auth/issues"
79
+ },
80
+ "scripts": {
81
+ "build": "tsc && node scripts/copy-oauth-success.js",
82
+ "generate:schema": "npm run build && node scripts/generate-config-schema.mjs",
83
+ "typecheck": "tsc --noEmit",
84
+ "typecheck:scripts": "tsc -p tsconfig.scripts.json",
85
+ "lint": "npm run lint:ts && npm run lint:scripts",
86
+ "lint:ts": "eslint . --ext .ts",
87
+ "lint:scripts": "eslint scripts --ext .js,.mjs",
88
+ "lint:fix": "npm run lint:ts:fix && npm run lint:scripts:fix",
89
+ "lint:ts:fix": "eslint . --ext .ts --fix",
90
+ "lint:scripts:fix": "eslint scripts --ext .js,.mjs --fix",
91
+ "test": "vitest run --maxWorkers=1",
92
+ "test:watch": "vitest",
93
+ "test:ui": "vitest --ui",
94
+ "test:model-matrix": "node scripts/test-model-matrix.js",
95
+ "test:model-matrix:smoke": "node scripts/test-model-matrix.js --smoke",
96
+ "test:model-matrix:report": "node scripts/test-model-matrix.js --smoke --report-json=.tmp/model-matrix-report.json",
97
+ "clean:repo": "node scripts/repo-hygiene.js clean --mode aggressive",
98
+ "clean:repo:check": "node scripts/repo-hygiene.js check",
99
+ "pack:check": "npm run build && node scripts/check-pack-budget.mjs",
100
+ "bench:edit-formats": "node scripts/benchmark-edit-formats.mjs --preset=codex-core",
101
+ "bench:edit-formats:smoke": "node scripts/benchmark-edit-formats.mjs --smoke --preset=codex-core",
102
+ "bench:edit-formats:render": "node scripts/benchmark-render-dashboard.mjs",
103
+ "bench:runtime-path": "npm run build && node scripts/benchmark-runtime-path.mjs",
104
+ "bench:runtime-path:quick": "node scripts/benchmark-runtime-path.mjs",
105
+ "test:coverage": "vitest run --coverage --maxWorkers=1",
106
+ "coverage": "npm run build && vitest run --coverage --maxWorkers=1",
107
+ "audit:prod": "npm audit --omit=dev --audit-level=high",
108
+ "audit:all": "npm audit --audit-level=high",
109
+ "audit:dev:allowlist": "node scripts/audit-dev-allowlist.js",
110
+ "audit:ci": "npm run audit:prod && npm run audit:dev:allowlist",
111
+ "vendor:verify": "node scripts/verify-vendor-provenance.mjs",
112
+ "vendor:update-manifest": "node scripts/update-vendor-provenance.mjs",
113
+ "postinstall": "node scripts/postinstall.js",
114
+ "prepublishOnly": "npm run build",
115
+ "prepare": "husky"
116
+ },
117
+ "bin": {
118
+ "mcodex": "scripts/mcodex.js",
119
+ "codex-multi-auth-codex": "scripts/codex.js",
120
+ "codex-multi-auth-app-launcher": "scripts/codex-app-launcher.js",
121
+ "codex-multi-auth": "scripts/codex-multi-auth.js"
122
+ },
123
+ "files": [
124
+ ".codex-plugin/plugin.json",
125
+ "dist/",
126
+ "assets/",
127
+ "config/",
128
+ "scripts/codex.js",
129
+ "scripts/codex-app-launcher.js",
130
+ "scripts/codex-app-router.js",
131
+ "scripts/codex-bin-resolver.js",
132
+ "scripts/codex-multi-auth.js",
133
+ "scripts/codex-routing.js",
134
+ "scripts/mcodex.js",
135
+ "scripts/install-codex-auth-utils.js",
136
+ "scripts/postinstall.js",
137
+ "scripts/preuninstall.js",
138
+ "vendor/codex-ai-plugin/",
139
+ "vendor/codex-ai-sdk/",
140
+ "README.md",
141
+ "LICENSE"
142
+ ],
143
+ "bundleDependencies": [
144
+ "@codex-ai/plugin",
145
+ "@codex-ai/sdk"
146
+ ],
147
+ "lint-staged": {
148
+ "*.ts": [
149
+ "eslint --max-warnings=0 --fix --no-warn-ignored"
150
+ ],
151
+ "scripts/**/*.{js,mjs}": [
152
+ "eslint --max-warnings=0 --fix --no-warn-ignored"
153
+ ]
154
+ },
155
+ "engines": {
156
+ "node": ">=18.17.0"
157
+ },
158
+ "devDependencies": {
159
+ "@types/node": "^20.19.42",
160
+ "@typescript-eslint/eslint-plugin": "^8.56.0",
161
+ "@typescript-eslint/parser": "^8.56.0",
162
+ "@vitest/coverage-v8": "^4.1.8",
163
+ "@vitest/ui": "^4.1.8",
164
+ "eslint": "^10.0.0",
165
+ "eslint-import-resolver-typescript": "^4.4.5",
166
+ "eslint-plugin-import-x": "^4.16.2",
167
+ "fast-check": "^4.5.3",
168
+ "husky": "^9.1.7",
169
+ "lint-staged": "^16.2.7",
170
+ "typescript": "^5.9.3",
171
+ "typescript-language-server": "^5.1.3",
172
+ "vitest": "^4.1.8"
173
+ },
174
+ "dependencies": {
175
+ "@codex-ai/plugin": "file:vendor/codex-ai-plugin",
176
+ "@codex-ai/sdk": "file:vendor/codex-ai-sdk",
177
+ "@openauthjs/openauth": "^0.4.3",
178
+ "hono": "4.12.33",
179
+ "undici": "6.28.0",
180
+ "zod": "4.4.3"
181
+ },
182
+ "overrides": {
183
+ "hono": "4.12.33",
184
+ "flatted": "3.4.2",
185
+ "minimatch": "10.2.4",
186
+ "picomatch": "4.0.4",
187
+ "rollup": "4.59.0",
188
+ "vite": "^7.3.2",
189
+ "micromatch": {
190
+ "picomatch": "2.3.2"
191
+ },
192
+ "@typescript-eslint/typescript-estree": {
193
+ "minimatch": "9.0.9"
194
+ },
195
+ "brace-expansion": "5.0.9",
196
+ "postcss": "8.5.25"
197
+ }
198
+ }
@@ -36,6 +36,7 @@ function parseArgs(argv) {
36
36
  host: "127.0.0.1",
37
37
  port: 0,
38
38
  statusPath: "",
39
+ identityToken: "",
39
40
  statePath: "",
40
41
  logPath: "",
41
42
  maxLogBytes: DEFAULT_MAX_LOG_BYTES,
@@ -58,6 +59,11 @@ function parseArgs(argv) {
58
59
  index += 1;
59
60
  continue;
60
61
  }
62
+ if (arg === "--identity-token") {
63
+ result.identityToken = next;
64
+ index += 1;
65
+ continue;
66
+ }
61
67
  if (arg === "--state") {
62
68
  result.statePath = next;
63
69
  index += 1;
@@ -133,7 +139,16 @@ function writeStatus(statusPath, payload) {
133
139
  }
134
140
  }
135
141
 
136
- function createStatusPayload({ state, proxyServer, error, stateRecord }) {
142
+ function createStatusPayload({
143
+ state,
144
+ proxyServer,
145
+ error,
146
+ stateRecord,
147
+ startedAt,
148
+ statusPath,
149
+ routerScriptPath,
150
+ identityToken,
151
+ }) {
137
152
  const proxyStatus =
138
153
  typeof proxyServer?.getStatus === "function" ? proxyServer.getStatus() : {};
139
154
  const lastAccountIndex = proxyStatus.lastAccountIndex ?? null;
@@ -149,6 +164,15 @@ function createStatusPayload({ state, proxyServer, error, stateRecord }) {
149
164
  kind: "codex-app-runtime-rotation-router",
150
165
  state,
151
166
  pid: process.pid,
167
+ startedAt,
168
+ statusPath: statusPath || readTrimmedString(stateRecord, "statusPath") || null,
169
+ identityToken:
170
+ identityToken || readTrimmedString(stateRecord, "identityToken") || null,
171
+ routerScriptPath:
172
+ routerScriptPath ||
173
+ readTrimmedString(stateRecord, "routerScriptPath") ||
174
+ process.argv[1] ||
175
+ null,
152
176
  updatedAt: Date.now(),
153
177
  baseUrl: proxyServer?.baseUrl ?? stateRecord?.baseUrl ?? null,
154
178
  totalRequests: proxyStatus.totalRequests ?? 0,
@@ -232,6 +256,7 @@ function installLogBounds(maxBytes, logPath) {
232
256
  }
233
257
 
234
258
  async function main() {
259
+ const routerStartedAt = Date.now();
235
260
  const args = parseArgs(process.argv.slice(2));
236
261
  installLogBounds(args.maxLogBytes, args.logPath).unref?.();
237
262
  const stateRecord = readState(args.statePath);
@@ -241,7 +266,16 @@ async function main() {
241
266
  );
242
267
  writeStatus(
243
268
  args.statusPath,
244
- createStatusPayload({ state: "error", proxyServer: null, error, stateRecord: null }),
269
+ createStatusPayload({
270
+ state: "error",
271
+ proxyServer: null,
272
+ error,
273
+ stateRecord: null,
274
+ startedAt: routerStartedAt,
275
+ statusPath: args.statusPath,
276
+ routerScriptPath: process.argv[1],
277
+ identityToken: args.identityToken,
278
+ }),
245
279
  );
246
280
  throw error;
247
281
  }
@@ -272,7 +306,17 @@ async function main() {
272
306
  const writeCurrentStatus = (state, error) => {
273
307
  writeStatus(
274
308
  args.statusPath || stateRecord?.statusPath || "",
275
- createStatusPayload({ state, proxyServer, error, stateRecord }),
309
+ createStatusPayload({
310
+ state,
311
+ proxyServer,
312
+ error,
313
+ stateRecord,
314
+ startedAt: routerStartedAt,
315
+ statusPath: args.statusPath || stateRecord?.statusPath || "",
316
+ routerScriptPath: stateRecord?.routerScriptPath || process.argv[1],
317
+ identityToken:
318
+ args.identityToken || stateRecord?.identityToken || "",
319
+ }),
276
320
  );
277
321
  };
278
322