codex-multi-auth 2.3.0-beta.2 → 2.3.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.
Files changed (162) hide show
  1. package/.codex-plugin/plugin.json +2 -1
  2. package/README.md +2 -2
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +6 -0
  5. package/dist/lib/account-policy.d.ts.map +1 -1
  6. package/dist/lib/account-policy.js +2 -1
  7. package/dist/lib/accounts/rate-limits.d.ts +8 -0
  8. package/dist/lib/accounts/rate-limits.d.ts.map +1 -1
  9. package/dist/lib/accounts/rate-limits.js +13 -0
  10. package/dist/lib/accounts.d.ts +19 -1
  11. package/dist/lib/accounts.d.ts.map +1 -1
  12. package/dist/lib/accounts.js +31 -2
  13. package/dist/lib/audit.d.ts +0 -9
  14. package/dist/lib/audit.d.ts.map +1 -1
  15. package/dist/lib/auth/device-auth.d.ts +1 -6
  16. package/dist/lib/auth/device-auth.d.ts.map +1 -1
  17. package/dist/lib/auth/device-auth.js +5 -5
  18. package/dist/lib/budget-guard.d.ts.map +1 -1
  19. package/dist/lib/budget-guard.js +2 -1
  20. package/dist/lib/codex-cli/writer.d.ts.map +1 -1
  21. package/dist/lib/codex-cli/writer.js +2 -1
  22. package/dist/lib/codex-manager/backend-settings-helpers.d.ts +0 -1
  23. package/dist/lib/codex-manager/backend-settings-helpers.d.ts.map +1 -1
  24. package/dist/lib/codex-manager/backend-settings-helpers.js +1 -1
  25. package/dist/lib/codex-manager/behavior-settings-panel.d.ts +0 -19
  26. package/dist/lib/codex-manager/behavior-settings-panel.d.ts.map +1 -1
  27. package/dist/lib/codex-manager/commands/report.d.ts.map +1 -1
  28. package/dist/lib/codex-manager/commands/report.js +2 -1
  29. package/dist/lib/codex-manager/commands/uninstall.d.ts +2 -2
  30. package/dist/lib/codex-manager/commands/uninstall.d.ts.map +1 -1
  31. package/dist/lib/codex-manager/commands/uninstall.js +1 -1
  32. package/dist/lib/codex-manager/commands/usage.d.ts.map +1 -1
  33. package/dist/lib/codex-manager/commands/usage.js +2 -1
  34. package/dist/lib/codex-manager/commands/verify.d.ts +2 -2
  35. package/dist/lib/codex-manager/commands/verify.d.ts.map +1 -1
  36. package/dist/lib/codex-manager/commands/why-selected.d.ts +1 -22
  37. package/dist/lib/codex-manager/commands/why-selected.d.ts.map +1 -1
  38. package/dist/lib/codex-manager/dashboard-display-panel.d.ts +0 -14
  39. package/dist/lib/codex-manager/dashboard-display-panel.d.ts.map +1 -1
  40. package/dist/lib/codex-manager/experimental-settings-prompt.d.ts +2 -1
  41. package/dist/lib/codex-manager/experimental-settings-prompt.d.ts.map +1 -1
  42. package/dist/lib/codex-manager/forecast-report-shared.d.ts +2 -2
  43. package/dist/lib/codex-manager/forecast-report-shared.d.ts.map +1 -1
  44. package/dist/lib/codex-manager/forecast-report-shared.js +2 -2
  45. package/dist/lib/codex-manager/formatters/quota-formatters.d.ts +0 -2
  46. package/dist/lib/codex-manager/formatters/quota-formatters.d.ts.map +1 -1
  47. package/dist/lib/codex-manager/formatters/quota-formatters.js +2 -2
  48. package/dist/lib/codex-manager/help.d.ts +2 -1
  49. package/dist/lib/codex-manager/help.d.ts.map +1 -1
  50. package/dist/lib/codex-manager/repair-commands.d.ts +0 -15
  51. package/dist/lib/codex-manager/repair-commands.d.ts.map +1 -1
  52. package/dist/lib/codex-manager/repair-commands.js +5 -5
  53. package/dist/lib/codex-manager/settings-hub/backend.d.ts +0 -5
  54. package/dist/lib/codex-manager/settings-hub/backend.d.ts.map +1 -1
  55. package/dist/lib/codex-manager/settings-hub/backend.js +1 -1
  56. package/dist/lib/codex-manager/settings-hub/dashboard.d.ts +1 -14
  57. package/dist/lib/codex-manager/settings-hub/dashboard.d.ts.map +1 -1
  58. package/dist/lib/codex-manager/settings-hub/dashboard.js +8 -8
  59. package/dist/lib/codex-manager/settings-write-queue.d.ts +0 -10
  60. package/dist/lib/codex-manager/settings-write-queue.d.ts.map +1 -1
  61. package/dist/lib/codex-manager/settings-write-queue.js +10 -10
  62. package/dist/lib/codex-manager/statusline-settings-panel.d.ts +2 -17
  63. package/dist/lib/codex-manager/statusline-settings-panel.d.ts.map +1 -1
  64. package/dist/lib/codex-manager/theme-settings-panel.d.ts +0 -13
  65. package/dist/lib/codex-manager/theme-settings-panel.d.ts.map +1 -1
  66. package/dist/lib/config.d.ts +0 -13
  67. package/dist/lib/config.d.ts.map +1 -1
  68. package/dist/lib/config.js +22 -19
  69. package/dist/lib/dashboard-settings.d.ts +3 -3
  70. package/dist/lib/dashboard-settings.d.ts.map +1 -1
  71. package/dist/lib/dashboard-settings.js +0 -1
  72. package/dist/lib/errors.d.ts +0 -1
  73. package/dist/lib/errors.d.ts.map +1 -1
  74. package/dist/lib/forecast.d.ts +4 -3
  75. package/dist/lib/forecast.d.ts.map +1 -1
  76. package/dist/lib/fs-retry.d.ts +0 -3
  77. package/dist/lib/fs-retry.d.ts.map +1 -1
  78. package/dist/lib/fs-retry.js +3 -3
  79. package/dist/lib/index.d.ts +1 -0
  80. package/dist/lib/index.d.ts.map +1 -1
  81. package/dist/lib/index.js +1 -0
  82. package/dist/lib/local-client-tokens.d.ts.map +1 -1
  83. package/dist/lib/local-client-tokens.js +2 -1
  84. package/dist/lib/oc-chatgpt-import-adapter.d.ts +1 -1
  85. package/dist/lib/oc-chatgpt-import-adapter.d.ts.map +1 -1
  86. package/dist/lib/oc-chatgpt-orchestrator.d.ts.map +1 -1
  87. package/dist/lib/oc-chatgpt-orchestrator.js +2 -1
  88. package/dist/lib/oc-chatgpt-target-detection.d.ts +1 -1
  89. package/dist/lib/oc-chatgpt-target-detection.d.ts.map +1 -1
  90. package/dist/lib/prompts/codex-host-bridge.d.ts +0 -8
  91. package/dist/lib/prompts/codex-host-bridge.d.ts.map +1 -1
  92. package/dist/lib/prompts/codex-host-bridge.js +0 -20
  93. package/dist/lib/prompts/codex.d.ts.map +1 -1
  94. package/dist/lib/prompts/codex.js +2 -1
  95. package/dist/lib/prompts/fetch-utils.d.ts +0 -2
  96. package/dist/lib/prompts/fetch-utils.d.ts.map +1 -1
  97. package/dist/lib/prompts/fetch-utils.js +2 -2
  98. package/dist/lib/prompts/host-codex-prompt.d.ts.map +1 -1
  99. package/dist/lib/prompts/host-codex-prompt.js +2 -1
  100. package/dist/lib/quota-cache.d.ts.map +1 -1
  101. package/dist/lib/quota-cache.js +2 -1
  102. package/dist/lib/recovery/storage.d.ts.map +1 -1
  103. package/dist/lib/recovery/storage.js +5 -3
  104. package/dist/lib/recovery/types.d.ts +4 -12
  105. package/dist/lib/recovery/types.d.ts.map +1 -1
  106. package/dist/lib/recovery.d.ts +2 -2
  107. package/dist/lib/recovery.d.ts.map +1 -1
  108. package/dist/lib/request/response-compaction.d.ts +2 -1
  109. package/dist/lib/request/response-compaction.d.ts.map +1 -1
  110. package/dist/lib/request/stream-failover-runtime.d.ts.map +1 -1
  111. package/dist/lib/request/stream-failover-runtime.js +30 -1
  112. package/dist/lib/rotation.d.ts +1 -3
  113. package/dist/lib/rotation.d.ts.map +1 -1
  114. package/dist/lib/rotation.js +1 -2
  115. package/dist/lib/routing-profiles.d.ts.map +1 -1
  116. package/dist/lib/routing-profiles.js +2 -1
  117. package/dist/lib/runtime/config-toml.d.ts +0 -6
  118. package/dist/lib/runtime/config-toml.d.ts.map +1 -1
  119. package/dist/lib/runtime/config-toml.js +6 -6
  120. package/dist/lib/runtime/event-handler.d.ts +0 -31
  121. package/dist/lib/runtime/event-handler.d.ts.map +1 -1
  122. package/dist/lib/runtime/event-handler.js +0 -22
  123. package/dist/lib/runtime/first-run.d.ts +3 -5
  124. package/dist/lib/runtime/first-run.d.ts.map +1 -1
  125. package/dist/lib/runtime/first-run.js +2 -2
  126. package/dist/lib/runtime/quota-headers.d.ts +1 -6
  127. package/dist/lib/runtime/quota-headers.d.ts.map +1 -1
  128. package/dist/lib/runtime/quota-headers.js +5 -5
  129. package/dist/lib/runtime/rotation-proxy-state.d.ts.map +1 -1
  130. package/dist/lib/runtime/rotation-proxy-state.js +24 -0
  131. package/dist/lib/runtime/runtime-current-account.d.ts +3 -3
  132. package/dist/lib/runtime/runtime-current-account.d.ts.map +1 -1
  133. package/dist/lib/runtime/runtime-current-account.js +1 -1
  134. package/dist/lib/runtime/runtime-observability.d.ts +2 -2
  135. package/dist/lib/runtime/runtime-observability.d.ts.map +1 -1
  136. package/dist/lib/runtime/runtime-observability.js +0 -4
  137. package/dist/lib/runtime-rotation-proxy.d.ts.map +1 -1
  138. package/dist/lib/runtime-rotation-proxy.js +20 -6
  139. package/dist/lib/schemas.d.ts +3 -91
  140. package/dist/lib/schemas.d.ts.map +1 -1
  141. package/dist/lib/schemas.js +8 -8
  142. package/dist/lib/storage/file-paths.d.ts +2 -2
  143. package/dist/lib/storage/file-paths.d.ts.map +1 -1
  144. package/dist/lib/storage/file-paths.js +2 -2
  145. package/dist/lib/storage/flagged-storage-io.d.ts.map +1 -1
  146. package/dist/lib/storage/flagged-storage-io.js +2 -2
  147. package/dist/lib/storage/import-export.d.ts.map +1 -1
  148. package/dist/lib/storage/import-export.js +2 -2
  149. package/dist/lib/storage/migrations.d.ts +2 -1
  150. package/dist/lib/storage/migrations.d.ts.map +1 -1
  151. package/dist/lib/storage.d.ts.map +1 -1
  152. package/dist/lib/storage.js +30 -23
  153. package/dist/lib/temp-path.d.ts +26 -0
  154. package/dist/lib/temp-path.d.ts.map +1 -0
  155. package/dist/lib/temp-path.js +30 -0
  156. package/dist/lib/ui/theme.d.ts +3 -2
  157. package/dist/lib/ui/theme.d.ts.map +1 -1
  158. package/dist/lib/unified-settings.d.ts.map +1 -1
  159. package/dist/lib/unified-settings.js +2 -1
  160. package/dist/lib/update-notice.d.ts.map +1 -1
  161. package/dist/lib/update-notice.js +2 -1
  162. package/package.json +1 -2
@@ -1,4 +1,4 @@
1
- export interface RuntimeMetricsSnapshot {
1
+ interface RuntimeMetricsSnapshot {
2
2
  startedAt: number;
3
3
  totalRequests: number;
4
4
  successfulRequests: number;
@@ -73,5 +73,5 @@ export declare function recordRuntimeReset(reason: string): void;
73
73
  */
74
74
  export declare function recordRuntimeAccountRecovery(index: number): void;
75
75
  export declare function loadPersistedRuntimeObservabilitySnapshot(): Promise<RuntimeObservabilitySnapshot | null>;
76
- export declare function resetRuntimeObservabilitySnapshotForTests(): void;
76
+ export {};
77
77
  //# sourceMappingURL=runtime-observability.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-observability.d.ts","sourceRoot":"","sources":["../../../lib/runtime/runtime-observability.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,sBAAsB;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,uBAAuB,EAAE,MAAM,CAAC;IAChC,4BAA4B,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5C,+BAA+B,EAAE,MAAM,CAAC;IACxC,+BAA+B,EAAE,MAAM,CAAC;IACxC,uBAAuB,EAAE,MAAM,CAAC;IAChC,oBAAoB,EAAE,MAAM,CAAC;IAC7B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,gBAAgB,EAAE,MAAM,CAAC;IACzB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,kCAAkC,EAAE,MAAM,CAAC;IAC3C,gCAAgC,EAAE,MAAM,CAAC;IACzC,wBAAwB,EAAE,MAAM,CAAC;IACjC,oCAAoC,EAAE,MAAM,CAAC;IAC7C,mBAAmB,EAAE,MAAM,CAAC;IAC5B,aAAa,EAAE,MAAM,GAAG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,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,sBAAsB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,uBAAuB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;IAChC,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C,cAAc,EAAE,sBAAsB,CAAC;CACvC;AA6LD,wBAAgB,+BAA+B,IAAI,4BAA4B,CAE9E;AAED,wBAAgB,kCAAkC,CACjD,OAAO,EAAE,CAAC,QAAQ,EAAE,4BAA4B,KAAK,IAAI,GACvD,IAAI,CAYN;AAED,wBAAgB,2BAA2B,CAAC,MAAM,EAAE;IACnD,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3C,GAAG,IAAI,CAOP;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAKxD;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAWvD;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAoBhE;AAED,wBAAsB,yCAAyC,IAAI,OAAO,CAAC,4BAA4B,GAAG,IAAI,CAAC,CAY9G"}
@@ -263,7 +263,3 @@ export async function loadPersistedRuntimeObservabilitySnapshot() {
263
263
  return null;
264
264
  }
265
265
  }
266
- export function resetRuntimeObservabilitySnapshotForTests() {
267
- snapshotState = createDefaultSnapshot();
268
- pendingWrite = null;
269
- }
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-rotation-proxy.d.ts","sourceRoot":"","sources":["../../lib/runtime-rotation-proxy.ts"],"names":[],"mappings":"AAuEA,OAAO,KAAK,EAKX,2BAA2B,EAC3B,0BAA0B,EAE1B,MAAM,oCAAoC,CAAC;AAe5C,YAAY,EACX,2BAA2B,EAC3B,0BAA0B,EAC1B,0BAA0B,GAC1B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,+BAA+B,EAC/B,0BAA0B,GAC1B,MAAM,kCAAkC,CAAC;AAC1C,YAAY,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AACxE,OAAO,EACN,+BAA+B,EAC/B,8BAA8B,EAC9B,uBAAuB,EACvB,uBAAuB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,YAAY,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AA6etE,wBAAsB,yBAAyB,CAC9C,OAAO,EAAE,2BAA2B,GAClC,OAAO,CAAC,0BAA0B,CAAC,CA2IrC"}
1
+ {"version":3,"file":"runtime-rotation-proxy.d.ts","sourceRoot":"","sources":["../../lib/runtime-rotation-proxy.ts"],"names":[],"mappings":"AAwEA,OAAO,KAAK,EAKX,2BAA2B,EAC3B,0BAA0B,EAE1B,MAAM,oCAAoC,CAAC;AAe5C,YAAY,EACX,2BAA2B,EAC3B,0BAA0B,EAC1B,0BAA0B,GAC1B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACN,+BAA+B,EAC/B,0BAA0B,GAC1B,MAAM,kCAAkC,CAAC;AAC1C,YAAY,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AACxE,OAAO,EACN,+BAA+B,EAC/B,8BAA8B,EAC9B,uBAAuB,EACvB,uBAAuB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,YAAY,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AA6etE,wBAAsB,yBAAyB,CAC9C,OAAO,EAAE,2BAA2B,GAClC,OAAO,CAAC,0BAA0B,CAAC,CA+IrC"}
@@ -10,6 +10,7 @@ import { mutateRuntimeObservabilitySnapshot, recordRuntimeAccountRecovery, recor
10
10
  import { createRuntimeUsageRecorder, evaluateRuntimePolicy, loadRuntimePolicyState, } from "./policy/runtime-policy.js";
11
11
  import { isWorkspaceDisabledError } from "./request/fetch-helpers.js";
12
12
  import { createLogger, maskString, runWithCorrelationId } from "./logger.js";
13
+ import { CodexValidationError } from "./errors.js";
13
14
  import { buildPinnedUnavailableErrorBody, buildTokenInvalidationBody, extractErrorCodeFromBody, getQuotaNearExhaustionWaitMs, isTokenInvalidationError, normalizeExhaustionStatus, parseRetryAfterBodyMs, parseRetryAfterHeaderMs, } from "./request/rate-limit-decision.js";
14
15
  import { forwardStreamingResponse, HOP_BY_HOP_HEADERS, readErrorBody, responseHeadersForClient, withTimeout, } from "./request/stream-failover-runtime.js";
15
16
  import { chooseAccount } from "./runtime/rotation-account-selection.js";
@@ -435,8 +436,8 @@ export async function startRuntimeRotationProxy(options) {
435
436
  // binding a non-loopback host would expose every managed account to the
436
437
  // network, so it is refused unconditionally.
437
438
  if (!isLoopbackHost(host)) {
438
- throw new Error(`Runtime rotation proxy refuses to bind non-loopback host "${host}". ` +
439
- "It forwards managed OAuth tokens and is loopback-only.");
439
+ throw new CodexValidationError(`Runtime rotation proxy refuses to bind non-loopback host "${host}". ` +
440
+ "It forwards managed OAuth tokens and is loopback-only.", { field: "host", expected: "a loopback host", context: { host } });
440
441
  }
441
442
  // Normalize the validated host into its two representations exactly once so the
442
443
  // listen() bind and the emitted baseUrl can never disagree under concurrent
@@ -451,7 +452,7 @@ export async function startRuntimeRotationProxy(options) {
451
452
  ? options.clientApiKey.trim()
452
453
  : null;
453
454
  if (!clientApiKey) {
454
- throw new Error("Runtime rotation proxy requires a clientApiKey.");
455
+ throw new CodexValidationError("Runtime rotation proxy requires a clientApiKey.", { field: "clientApiKey", expected: "a non-empty string" });
455
456
  }
456
457
  const now = options.now ?? Date.now;
457
458
  const tokenRefreshSkewMs = getTokenRefreshSkewMs(pluginConfig);
@@ -737,9 +738,16 @@ async function handleRequestInner(state, req, res, traceId) {
737
738
  accountCount > 0 &&
738
739
  exhaustionReason === "no-account" &&
739
740
  (policyDecision?.blockedAccountIndexes.size ?? 0) === 0 &&
740
- ![...accountSkipReasons.values()].some((reason) => reason === "rate-limited" ||
741
- reason.startsWith("cooling-down") ||
742
- reason === "policy-blocked")) {
741
+ ![...accountSkipReasons.values()].some(
742
+ // Only policy blocks still suppress stale-state recovery: a policy
743
+ // decision is external and won't change across a disk reload, so
744
+ // reloading cannot help. "rate-limited" and "cooling-down*" are
745
+ // transient states that recovery is *designed* to escape — they are
746
+ // persisted to disk (buildStorageSnapshot) and so survive a reload,
747
+ // which previously deadlocked the pool against the very recovery that
748
+ // would clear them. recoverStaleRuntimeState now wipes that transient
749
+ // state after reloading, so let those reasons through (issue #606).
750
+ (reason) => reason === "policy-blocked")) {
743
751
  reloadedAfterNoAccount = true;
744
752
  const reloadedManager = await recoverStaleRuntimeState(state);
745
753
  if (reloadedManager) {
@@ -801,6 +809,12 @@ async function handleRequestInner(state, req, res, traceId) {
801
809
  accountManager.refundToken(refreshed.account, context.family, context.model);
802
810
  accountManager.recordFailure(refreshed.account, context.family, context.model);
803
811
  accountManager.markAccountCoolingDown(refreshed.account, DEFAULT_AUTH_FAILURE_COOLDOWN_MS, "auth-failure");
812
+ // Persist the cooldown like every other cooldown branch in this loop
813
+ // (network-error, 429, server-error, 401). `coolingDownUntil`/
814
+ // `cooldownReason` are serialized in the V3 snapshot, so without this
815
+ // a restart inside the cooldown window loses it and immediately
816
+ // re-selects the still-broken account.
817
+ accountManager.saveToDiskDebounced();
804
818
  exhaustionReason = "auth-failure";
805
819
  transientAttempts += 1;
806
820
  transientExhaustionReason = "auth-failure";
@@ -84,35 +84,13 @@ export type PluginConfigFromSchema = z.infer<typeof PluginConfigSchema>;
84
84
  /**
85
85
  * Source of the accountId used for ChatGPT requests.
86
86
  */
87
- export declare const AccountIdSourceSchema: z.ZodEnum<{
87
+ declare const AccountIdSourceSchema: z.ZodEnum<{
88
88
  token: "token";
89
89
  id_token: "id_token";
90
90
  org: "org";
91
91
  manual: "manual";
92
92
  }>;
93
93
  export type AccountIdSourceFromSchema = z.infer<typeof AccountIdSourceSchema>;
94
- /**
95
- * Cooldown reason for temporary account suspension.
96
- */
97
- export declare const CooldownReasonSchema: z.ZodEnum<{
98
- "auth-failure": "auth-failure";
99
- "network-error": "network-error";
100
- "server-error": "server-error";
101
- "rate-limit": "rate-limit";
102
- }>;
103
- export type CooldownReasonFromSchema = z.infer<typeof CooldownReasonSchema>;
104
- /**
105
- * Last switch reason for account rotation tracking.
106
- */
107
- export declare const SwitchReasonSchema: z.ZodEnum<{
108
- manual: "manual";
109
- "rate-limit": "rate-limit";
110
- initial: "initial";
111
- rotation: "rotation";
112
- best: "best";
113
- restore: "restore";
114
- }>;
115
- export type SwitchReasonFromSchema = z.infer<typeof SwitchReasonSchema>;
116
94
  /**
117
95
  * Switch reasons that callers may pass to `persistAndSyncSelectedAccount`.
118
96
  * Excludes the runtime-internal reasons (`rate-limit`, `initial`) which are
@@ -125,25 +103,6 @@ export declare const PersistedSwitchReasonSchema: z.ZodEnum<{
125
103
  restore: "restore";
126
104
  }>;
127
105
  export type PersistedSwitchReason = z.infer<typeof PersistedSwitchReasonSchema>;
128
- /**
129
- * Rate limit state - maps model family to reset timestamp.
130
- */
131
- export declare const RateLimitStateV3Schema: z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodNumber>>;
132
- export type RateLimitStateV3FromSchema = z.infer<typeof RateLimitStateV3Schema>;
133
- /**
134
- * Workspace entry within an account. Supports a single OpenAI/Google account
135
- * that belongs to multiple ChatGPT workspaces (e.g. personal Plus + a
136
- * business/team workspace), each a distinct quota pool keyed by its org_id
137
- * (`id`). Mirrors the `Workspace` TS interface in `lib/accounts.ts`. See #491.
138
- */
139
- export declare const WorkspaceSchema: z.ZodObject<{
140
- id: z.ZodString;
141
- name: z.ZodOptional<z.ZodString>;
142
- enabled: z.ZodBoolean;
143
- disabledAt: z.ZodOptional<z.ZodNumber>;
144
- isDefault: z.ZodOptional<z.ZodBoolean>;
145
- }, z.core.$strip>;
146
- export type WorkspaceFromSchema = z.infer<typeof WorkspaceSchema>;
147
106
  /**
148
107
  * Account metadata V3 - current storage format.
149
108
  */
@@ -188,15 +147,6 @@ export declare const AccountMetadataV3Schema: z.ZodObject<{
188
147
  }, z.core.$strip>>>;
189
148
  currentWorkspaceIndex: z.ZodOptional<z.ZodNumber>;
190
149
  }, z.core.$strip>;
191
- export type AccountMetadataV3FromSchema = z.infer<typeof AccountMetadataV3Schema>;
192
- export declare const ActiveIndexByFamilySchema: z.ZodObject<{
193
- "gpt-5-codex": z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
194
- "codex-max": z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
195
- codex: z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
196
- "gpt-5.2": z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
197
- "gpt-5.1": z.ZodOptional<z.ZodOptional<z.ZodNumber>>;
198
- }, z.core.$strip>;
199
- export type ActiveIndexByFamilyFromSchema = z.infer<typeof ActiveIndexByFamilySchema>;
200
150
  /**
201
151
  * Account storage V3 - current storage format with per-family active indices.
202
152
  */
@@ -255,43 +205,6 @@ export declare const AccountStorageV3Schema: z.ZodObject<{
255
205
  affinityGeneration: z.ZodOptional<z.ZodNumber>;
256
206
  }, z.core.$strip>;
257
207
  export type AccountStorageV3FromSchema = z.infer<typeof AccountStorageV3Schema>;
258
- /**
259
- * Legacy V1 account metadata for migration support.
260
- */
261
- export declare const AccountMetadataV1Schema: z.ZodObject<{
262
- accountId: z.ZodOptional<z.ZodString>;
263
- accountIdSource: z.ZodOptional<z.ZodEnum<{
264
- token: "token";
265
- id_token: "id_token";
266
- org: "org";
267
- manual: "manual";
268
- }>>;
269
- accountLabel: z.ZodOptional<z.ZodString>;
270
- email: z.ZodOptional<z.ZodString>;
271
- refreshToken: z.ZodString;
272
- accessToken: z.ZodOptional<z.ZodString>;
273
- expiresAt: z.ZodOptional<z.ZodNumber>;
274
- enabled: z.ZodOptional<z.ZodBoolean>;
275
- addedAt: z.ZodNumber;
276
- lastUsed: z.ZodNumber;
277
- lastSwitchReason: z.ZodOptional<z.ZodEnum<{
278
- manual: "manual";
279
- "rate-limit": "rate-limit";
280
- initial: "initial";
281
- rotation: "rotation";
282
- best: "best";
283
- restore: "restore";
284
- }>>;
285
- rateLimitResetTime: z.ZodOptional<z.ZodNumber>;
286
- coolingDownUntil: z.ZodOptional<z.ZodNumber>;
287
- cooldownReason: z.ZodOptional<z.ZodEnum<{
288
- "auth-failure": "auth-failure";
289
- "network-error": "network-error";
290
- "server-error": "server-error";
291
- "rate-limit": "rate-limit";
292
- }>>;
293
- }, z.core.$strip>;
294
- export type AccountMetadataV1FromSchema = z.infer<typeof AccountMetadataV1Schema>;
295
208
  /**
296
209
  * Legacy V1 storage format for migration support.
297
210
  */
@@ -332,7 +245,6 @@ export declare const AccountStorageV1Schema: z.ZodObject<{
332
245
  }, z.core.$strip>>;
333
246
  activeIndex: z.ZodNumber;
334
247
  }, z.core.$strip>;
335
- export type AccountStorageV1FromSchema = z.infer<typeof AccountStorageV1Schema>;
336
248
  /**
337
249
  * Union of V1 and V3 storage formats for migration detection.
338
250
  */
@@ -476,7 +388,6 @@ export declare const FlaggedAccountMetadataV1Schema: z.ZodObject<{
476
388
  flaggedReason: z.ZodOptional<z.ZodString>;
477
389
  lastError: z.ZodOptional<z.ZodString>;
478
390
  }, z.core.$loose>;
479
- export type FlaggedAccountMetadataV1FromSchema = z.infer<typeof FlaggedAccountMetadataV1Schema>;
480
391
  /**
481
392
  * Flagged account storage V1 format (version: 1, accounts: []).
482
393
  */
@@ -544,7 +455,7 @@ export type AccountsJournalEntryFromSchema = z.infer<typeof AccountsJournalEntry
544
455
  /**
545
456
  * Token failure reason codes.
546
457
  */
547
- export declare const TokenFailureReasonSchema: z.ZodEnum<{
458
+ declare const TokenFailureReasonSchema: z.ZodEnum<{
548
459
  unknown: "unknown";
549
460
  http_error: "http_error";
550
461
  invalid_response: "invalid_response";
@@ -673,4 +584,5 @@ export declare function safeParseJson<T>(raw: unknown, schema: z.ZodType<T>, con
673
584
  * Useful for logging and error messages.
674
585
  */
675
586
  export declare function getValidationErrors(schema: z.ZodType, data: unknown): string[];
587
+ export {};
676
588
  //# sourceMappingURL=schemas.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../lib/schemas.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAmBxB,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyD7B,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAMxE;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;EAKhC,CAAC;AAEH,MAAM,MAAM,yBAAyB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE9E;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;EAK/B,CAAC;AAEH,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAE5E;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;EAO7B,CAAC;AAEH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAExE;;;;GAIG;AACH,eAAO,MAAM,2BAA2B;;;;;EAKtC,CAAC;AAEH,MAAM,MAAM,qBAAqB,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C,IAAI,EAAE,OAAO,GACX,sBAAsB,GAAG,IAAI,CAM/B;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CACtC,IAAI,EAAE,OAAO,GACX,2BAA2B,GAAG,IAAI,CAMpC;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACxC,IAAI,EAAE,OAAO,GACX,0BAA0B,GAAG,IAAI,CAMnC;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CACnC,IAAI,EAAE,OAAO,GACX,qBAAqB,GAAG,IAAI,CAM9B;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAC1C,IAAI,EAAE,OAAO,GACX,4BAA4B,GAAG,IAAI,CAMrC;AAED;;;GAGG;AACH,wBAAgB,gCAAgC,CAC/C,IAAI,EAAE,OAAO,GACX,iCAAiC,GAAG,IAAI,CAM1C;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAC5C,IAAI,EAAE,OAAO,GACX,8BAA8B,GAAG,IAAI,CAMvC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC9B,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EACpB,OAAO,SAAkB,GACvB,CAAC,GAAG,IAAI,CA8BV;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAClC,MAAM,EAAE,CAAC,CAAC,OAAO,EACjB,IAAI,EAAE,OAAO,GACX,MAAM,EAAE,CASV"}
@@ -85,7 +85,7 @@ export const PluginConfigSchema = z.object({
85
85
  /**
86
86
  * Source of the accountId used for ChatGPT requests.
87
87
  */
88
- export const AccountIdSourceSchema = z.enum([
88
+ const AccountIdSourceSchema = z.enum([
89
89
  "token",
90
90
  "id_token",
91
91
  "org",
@@ -94,7 +94,7 @@ export const AccountIdSourceSchema = z.enum([
94
94
  /**
95
95
  * Cooldown reason for temporary account suspension.
96
96
  */
97
- export const CooldownReasonSchema = z.enum([
97
+ const CooldownReasonSchema = z.enum([
98
98
  "auth-failure",
99
99
  "network-error",
100
100
  "server-error",
@@ -103,7 +103,7 @@ export const CooldownReasonSchema = z.enum([
103
103
  /**
104
104
  * Last switch reason for account rotation tracking.
105
105
  */
106
- export const SwitchReasonSchema = z.enum([
106
+ const SwitchReasonSchema = z.enum([
107
107
  "rate-limit",
108
108
  "initial",
109
109
  "rotation",
@@ -125,14 +125,14 @@ export const PersistedSwitchReasonSchema = z.enum([
125
125
  /**
126
126
  * Rate limit state - maps model family to reset timestamp.
127
127
  */
128
- export const RateLimitStateV3Schema = z.record(z.string(), z.number().optional());
128
+ const RateLimitStateV3Schema = z.record(z.string(), z.number().optional());
129
129
  /**
130
130
  * Workspace entry within an account. Supports a single OpenAI/Google account
131
131
  * that belongs to multiple ChatGPT workspaces (e.g. personal Plus + a
132
132
  * business/team workspace), each a distinct quota pool keyed by its org_id
133
133
  * (`id`). Mirrors the `Workspace` TS interface in `lib/accounts.ts`. See #491.
134
134
  */
135
- export const WorkspaceSchema = z.object({
135
+ const WorkspaceSchema = z.object({
136
136
  id: z.string(),
137
137
  name: z.string().optional(),
138
138
  enabled: z.boolean(),
@@ -170,7 +170,7 @@ const modelFamilyEntries = MODEL_FAMILIES.map((family) => [
170
170
  family,
171
171
  z.number().optional(),
172
172
  ]);
173
- export const ActiveIndexByFamilySchema = z
173
+ const ActiveIndexByFamilySchema = z
174
174
  .object(Object.fromEntries(modelFamilyEntries))
175
175
  .partial();
176
176
  /**
@@ -187,7 +187,7 @@ export const AccountStorageV3Schema = z.object({
187
187
  /**
188
188
  * Legacy V1 account metadata for migration support.
189
189
  */
190
- export const AccountMetadataV1Schema = z.object({
190
+ const AccountMetadataV1Schema = z.object({
191
191
  accountId: z.string().optional(),
192
192
  accountIdSource: AccountIdSourceSchema.optional(),
193
193
  accountLabel: z.string().optional(),
@@ -259,7 +259,7 @@ export const AccountsJournalEntrySchema = z.object({
259
259
  /**
260
260
  * Token failure reason codes.
261
261
  */
262
- export const TokenFailureReasonSchema = z.enum([
262
+ const TokenFailureReasonSchema = z.enum([
263
263
  "http_error",
264
264
  "invalid_response",
265
265
  "network_error",
@@ -1,5 +1,5 @@
1
- import { ACCOUNTS_BACKUP_SUFFIX, ACCOUNTS_WAL_SUFFIX, getAccountsBackupPath, getAccountsBackupPathAtIndex, getAccountsWalPath, getIntentionalResetMarkerPath, RESET_MARKER_SUFFIX } from "./backup-paths.js";
2
- export { ACCOUNTS_BACKUP_SUFFIX, ACCOUNTS_WAL_SUFFIX, getAccountsBackupPath, getAccountsBackupPathAtIndex, getAccountsWalPath, getIntentionalResetMarkerPath, RESET_MARKER_SUFFIX, };
1
+ import { ACCOUNTS_BACKUP_SUFFIX, ACCOUNTS_WAL_SUFFIX, getAccountsBackupPath, getAccountsWalPath, getIntentionalResetMarkerPath, RESET_MARKER_SUFFIX } from "./backup-paths.js";
2
+ export { ACCOUNTS_BACKUP_SUFFIX, ACCOUNTS_WAL_SUFFIX, getAccountsBackupPath, getAccountsWalPath, getIntentionalResetMarkerPath, RESET_MARKER_SUFFIX, };
3
3
  export declare function getAccountsBackupRecoveryCandidates(path: string): string[];
4
4
  export declare function getFlaggedAccountsPath(storagePath: string, fileName: string): string;
5
5
  export declare function getLegacyFlaggedAccountsPath(storagePath: string, legacyFileName: string): string;
@@ -1 +1 @@
1
- {"version":3,"file":"file-paths.d.ts","sourceRoot":"","sources":["../../../lib/storage/file-paths.ts"],"names":[],"mappings":"AACA,OAAO,EACN,sBAAsB,EACtB,mBAAmB,EACnB,qBAAqB,EACrB,4BAA4B,EAE5B,kBAAkB,EAClB,6BAA6B,EAC7B,mBAAmB,EACnB,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EACN,sBAAsB,EACtB,mBAAmB,EACnB,qBAAqB,EACrB,4BAA4B,EAC5B,kBAAkB,EAClB,6BAA6B,EAC7B,mBAAmB,GACnB,CAAC;AAEF,wBAAgB,mCAAmC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAE1E;AAED,wBAAgB,sBAAsB,CACrC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,GACd,MAAM,CAER;AAMD,wBAAgB,4BAA4B,CAC3C,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,GACpB,MAAM,CAER"}
1
+ {"version":3,"file":"file-paths.d.ts","sourceRoot":"","sources":["../../../lib/storage/file-paths.ts"],"names":[],"mappings":"AACA,OAAO,EACN,sBAAsB,EACtB,mBAAmB,EACnB,qBAAqB,EAErB,kBAAkB,EAClB,6BAA6B,EAC7B,mBAAmB,EACnB,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EACN,sBAAsB,EACtB,mBAAmB,EACnB,qBAAqB,EACrB,kBAAkB,EAClB,6BAA6B,EAC7B,mBAAmB,GACnB,CAAC;AAEF,wBAAgB,mCAAmC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAE1E;AAED,wBAAgB,sBAAsB,CACrC,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,GACd,MAAM,CAER;AAMD,wBAAgB,4BAA4B,CAC3C,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,GACpB,MAAM,CAER"}
@@ -1,7 +1,7 @@
1
1
  import { dirname, join } from "node:path";
2
- import { ACCOUNTS_BACKUP_SUFFIX, ACCOUNTS_WAL_SUFFIX, getAccountsBackupPath, getAccountsBackupPathAtIndex, getAccountsBackupRecoveryCandidates as getBackupRecoveryCandidates, getAccountsWalPath, getIntentionalResetMarkerPath, RESET_MARKER_SUFFIX, } from "./backup-paths.js";
2
+ import { ACCOUNTS_BACKUP_SUFFIX, ACCOUNTS_WAL_SUFFIX, getAccountsBackupPath, getAccountsBackupRecoveryCandidates as getBackupRecoveryCandidates, getAccountsWalPath, getIntentionalResetMarkerPath, RESET_MARKER_SUFFIX, } from "./backup-paths.js";
3
3
  const ACCOUNTS_BACKUP_HISTORY_DEPTH = 3;
4
- export { ACCOUNTS_BACKUP_SUFFIX, ACCOUNTS_WAL_SUFFIX, getAccountsBackupPath, getAccountsBackupPathAtIndex, getAccountsWalPath, getIntentionalResetMarkerPath, RESET_MARKER_SUFFIX, };
4
+ export { ACCOUNTS_BACKUP_SUFFIX, ACCOUNTS_WAL_SUFFIX, getAccountsBackupPath, getAccountsWalPath, getIntentionalResetMarkerPath, RESET_MARKER_SUFFIX, };
5
5
  export function getAccountsBackupRecoveryCandidates(path) {
6
6
  return getBackupRecoveryCandidates(path, ACCOUNTS_BACKUP_HISTORY_DEPTH);
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"flagged-storage-io.d.ts","sourceRoot":"","sources":["../../../lib/storage/flagged-storage-io.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AA2EjE,wBAAsB,wBAAwB,CAAC,MAAM,EAAE;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,uBAAuB,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,uBAAuB,CAAC;IACpE,sBAAsB,EAAE,CACvB,OAAO,EAAE,uBAAuB,EAChC,eAAe,EAAE,MAAM,KACnB,OAAO,CAAC,OAAO,CAAC,CAAC;IACtB,mBAAmB,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzE,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IACtE,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;CACrE,GAAG,OAAO,CAAC,uBAAuB,CAAC,CA0InC;AAED,wBAAsB,iCAAiC,CACtD,OAAO,EAAE,uBAAuB,EAChC,MAAM,EAAE;IACP,IAAI,EAAE,MAAM,CA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OAAO,CAAC,IAAI,CAAC,CAyCf;AAED,wBAAsB,0BAA0B,CAAC,MAAM,EAAE;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;CACtE,GAAG,OAAO,CAAC,IAAI,CAAC,CA8ChB"}
@@ -3,6 +3,7 @@ import { dirname } from "node:path";
3
3
  import { FlaggedAccountStorageV1Schema, safeParseJson } from "../schemas.js";
4
4
  import { readFileWithRetry } from "./flagged-storage-file.js";
5
5
  import { FILE_RETRY_CODES } from "../fs-retry.js";
6
+ import { tempPathFor } from "../temp-path.js";
6
7
  // storage-07: align with the single shared retryable-code set (adds ENOTEMPTY/
7
8
  // EACCES) instead of a local subset.
8
9
  const RETRYABLE_UNLINK_CODES = FILE_RETRY_CODES;
@@ -183,8 +184,7 @@ export async function loadFlaggedAccountsState(params) {
183
184
  }
184
185
  }
185
186
  export async function saveFlaggedAccountsUnlockedToDisk(storage, params) {
186
- const uniqueSuffix = `${Date.now()}.${Math.random().toString(36).slice(2, 8)}`;
187
- const tempPath = `${params.path}.${uniqueSuffix}.tmp`;
187
+ const tempPath = tempPathFor(params.path);
188
188
  try {
189
189
  await fs.mkdir(dirname(params.path), { recursive: true });
190
190
  if (existsSync(params.path)) {
@@ -1 +1 @@
1
- {"version":3,"file":"import-export.d.ts","sourceRoot":"","sources":["../../../lib/storage/import-export.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAsD1D,wBAAsB,oBAAoB,CAAC,MAAM,EAAE;IAClD,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACjC,YAAY,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O,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;CACrE,GAAG,OAAO,CAAC,IAAI,CAAC,CAuChB;AAED,wBAAsB,cAAc,CAAC,MAAM,EAAE;IAC5C,YAAY,EAAE,MAAM,CAAC;IACrB,uBAAuB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,gBAAgB,GAAG,IAAI,CAAC;CACrE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA8C5B;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE;IAC7C,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAClC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB,EAAE,CACpB,QAAQ,EAAE,gBAAgB,CAAC,UAAU,CAAC,KAClC,gBAAgB,CAAC,UAAU,CAAC,CAAC;CAClC,GAAG;IACH,UAAU,EAAE,gBAAgB,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CAChB,CAgCA"}
@@ -2,6 +2,7 @@ import { existsSync, promises as fs } from "node:fs";
2
2
  import { dirname } from "node:path";
3
3
  import { AnyAccountStorageSchema, safeParseJson } from "../schemas.js";
4
4
  import { shouldRetryFileOperation } from "../fs-retry.js";
5
+ import { tempPathFor } from "../temp-path.js";
5
6
  const EXPORT_RENAME_MAX_ATTEMPTS = 4;
6
7
  const EXPORT_RENAME_BASE_DELAY_MS = 25;
7
8
  const MAX_IMPORT_BYTES = 4 * 1024 * 1024;
@@ -64,8 +65,7 @@ export async function exportAccountsToFile(params) {
64
65
  activeIndex: params.storage.activeIndex,
65
66
  activeIndexByFamily: params.storage.activeIndexByFamily,
66
67
  }, null, 2);
67
- const uniqueSuffix = `${Date.now()}.${Math.random().toString(36).slice(2, 8)}`;
68
- const tempPath = `${params.resolvedPath}.${uniqueSuffix}.tmp`;
68
+ const tempPath = tempPathFor(params.resolvedPath);
69
69
  try {
70
70
  await fs.writeFile(tempPath, content, {
71
71
  encoding: "utf-8",
@@ -8,7 +8,7 @@
8
8
  */
9
9
  import type { AccountIdSource } from "../types.js";
10
10
  import type { AccountStorageV3, CooldownReason } from "./public-types.js";
11
- export interface AccountMetadataV1 {
11
+ interface AccountMetadataV1 {
12
12
  accountId?: string;
13
13
  accountIdSource?: AccountIdSource;
14
14
  accountLabel?: string;
@@ -32,4 +32,5 @@ export interface AccountStorageV1 {
32
32
  activeIndex: number;
33
33
  }
34
34
  export declare function migrateV1ToV3(v1: AccountStorageV1): AccountStorageV3;
35
+ export {};
35
36
  //# sourceMappingURL=migrations.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../../lib/storage/migrations.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EACX,gBAAgB,EAChB,cAAc,EAEd,MAAM,mBAAmB,CAAC;AAE3B,MAAM,WAAW,iBAAiB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,uDAAuD;IACvD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+DAA+D;IAC/D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EACd,YAAY,GACZ,SAAS,GACT,UAAU,GACV,MAAM,GACN,SAAS,GACT,QAAQ,CAAC;IACZ,kBAAkB,CAAC,EAAE,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cAAc,CACnC,QAAQ,EAAE,MAAM,EAChB,KAAK,UAAO,EACZ,YAAY,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,GAC3D,OAAO,CAAC,IAAI,CAAC,CAgBf;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CACnC,QAAQ,EAAE,MAAM,GACd,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAc/D"}
@@ -31,6 +31,7 @@ import { computeSha256 } from "./storage/hash.js";
31
31
  import { ensureCodexGitignoreEntry } from "./storage/gitignore.js";
32
32
  import { exportAccountsToFile, mergeImportedAccounts, readImportFile, } from "./storage/import-export.js";
33
33
  import { formatStorageErrorHint } from "./storage/error-hints.js";
34
+ import { tempFileNonce, tempPathFor } from "./temp-path.js";
34
35
  export { StorageError } from "./errors.js";
35
36
  export { formatStorageErrorHint, toStorageError, } from "./storage/error-hints.js";
36
37
  export { getAccountIdentityKey, normalizeEmailKey, } from "./storage/identity.js";
@@ -143,7 +144,7 @@ function renameFileWithRetry(sourcePath, destinationPath) {
143
144
  }
144
145
  async function createRotatingAccountsBackup(path) {
145
146
  const candidates = getAccountsBackupRecoveryCandidates(path, ACCOUNTS_BACKUP_HISTORY_DEPTH);
146
- const rotationNonce = `${Date.now()}.${Math.random().toString(36).slice(2, 8)}`;
147
+ const rotationNonce = tempFileNonce();
147
148
  const stagedWrites = [];
148
149
  const buildStagedPath = (targetPath, label) => `${targetPath}.rotate.${rotationNonce}.${label}.tmp`;
149
150
  try {
@@ -731,7 +732,7 @@ export function resolveAccountSelectionIndex(accounts, candidate, fallbackIndex
731
732
  return matchedIndex;
732
733
  return clampIndex(fallbackIndex, accounts.length);
733
734
  }
734
- function deduplicateAccountsByIdentity(accounts) {
735
+ function deduplicateAccountsByIdentityPass(accounts) {
735
736
  const deduplicated = [];
736
737
  for (const account of accounts) {
737
738
  if (!account)
@@ -745,6 +746,21 @@ function deduplicateAccountsByIdentity(accounts) {
745
746
  }
746
747
  return deduplicated;
747
748
  }
749
+ function deduplicateAccountsByIdentity(accounts) {
750
+ // A single pass is not a fixpoint: a newest-wins merge can replace a kept
751
+ // entry with an account that itself duplicates an earlier survivor through
752
+ // a different matching tier (e.g. an email-tier merge installs an account
753
+ // whose accountId + refresh token already match a record that carried no
754
+ // email). Re-run until stable; every merge strictly shrinks the array, so
755
+ // this terminates after at most accounts.length passes.
756
+ let current = deduplicateAccountsByIdentityPass(accounts);
757
+ for (;;) {
758
+ const next = deduplicateAccountsByIdentityPass(current);
759
+ if (next.length === current.length)
760
+ return next;
761
+ current = next;
762
+ }
763
+ }
748
764
  /**
749
765
  * Removes duplicate accounts, keeping the most recently used entry for each
750
766
  * safely matched identity.
@@ -1390,26 +1406,17 @@ async function saveAccountsUnlocked(storage) {
1390
1406
  },
1391
1407
  writeTemp: (tempPath, content) => withFileOperationRetry(() => fs.writeFile(tempPath, content, { encoding: "utf-8", mode: 0o600 })),
1392
1408
  statTemp: (tempPath) => fs.stat(tempPath),
1393
- renameTempToPath: async (tempPath) => {
1394
- let lastError = null;
1395
- for (let attempt = 0; attempt < 5; attempt++) {
1396
- try {
1397
- await fs.rename(tempPath, path);
1398
- return;
1399
- }
1400
- catch (renameError) {
1401
- const code = renameError.code;
1402
- if (code === "EPERM" || code === "EBUSY") {
1403
- lastError = renameError;
1404
- await new Promise((r) => setTimeout(r, 10 * 2 ** attempt));
1405
- continue;
1406
- }
1407
- throw renameError;
1408
- }
1409
- }
1410
- if (lastError)
1411
- throw lastError;
1412
- },
1409
+ renameTempToPath: (tempPath) =>
1410
+ // Windows can hold the destination briefly (AV/indexer); retry only the
1411
+ // lock codes rename actually surfaces there, on the original
1412
+ // 10ms-doubling schedule. (The hand-rolled loop this replaces also
1413
+ // slept once more after the final failure; withRetry rethrows
1414
+ // immediately instead.)
1415
+ withRetry(() => fs.rename(tempPath, path), {
1416
+ maxAttempts: 5,
1417
+ backoffMs: (attempt) => 10 * 2 ** (attempt - 1),
1418
+ retryableCodes: ["EPERM", "EBUSY"],
1419
+ }),
1413
1420
  cleanupResetMarker: async () => {
1414
1421
  try {
1415
1422
  await fs.unlink(resetMarkerPath);
@@ -1453,7 +1460,7 @@ async function saveAccountsUnlocked(storage) {
1453
1460
  return new StorageError(`Failed to save accounts: ${err?.message || "Unknown error"}`, code, path, hint, err instanceof Error ? err : undefined);
1454
1461
  },
1455
1462
  backupPath: getAccountsBackupPath(path),
1456
- createTempPath: () => `${path}.${Date.now()}.${Math.random().toString(36).slice(2, 8)}.tmp`,
1463
+ createTempPath: () => tempPathFor(path),
1457
1464
  });
1458
1465
  }
1459
1466
  function cloneFlaggedStorageForPersistence(storage) {
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Unpredictable nonce for temp/staging file names: `<pid>.<epochMs>.<hex8>`.
3
+ *
4
+ * The random component comes from `crypto.randomBytes` instead of
5
+ * `Math.random()`. `Math.random()` output is predictable once its internal
6
+ * state is known, so a local attacker who can observe one staged path could
7
+ * predict the next one and pre-create (or symlink) it before the atomic
8
+ * write-then-rename lands. An 8-hex-char CSPRNG suffix removes that
9
+ * predictability while keeping names short and `endsWith(".tmp")`-sweepable.
10
+ *
11
+ * Assumes the process CSPRNG is available: `randomBytes` throws on entropy
12
+ * failure (e.g. misconfigured FIPS builds), which is the correct outcome here —
13
+ * the same crypto primitives back the OAuth flow itself, so staging a token
14
+ * file with weaker randomness instead would be strictly worse.
15
+ */
16
+ export declare function tempFileNonce(): string;
17
+ /**
18
+ * Staging path for an atomic write-then-rename of `targetPath`:
19
+ * `<targetPath>.<pid>.<epochMs>.<hex8>.tmp`.
20
+ *
21
+ * Keeps the trailing `.tmp` extension so existing stale-artifact sweepers
22
+ * (`entry.name.endsWith(".tmp")` in lib/storage.ts, lib/runtime-paths.ts,
23
+ * lib/oc-chatgpt-target-detection.ts) continue to skip/collect staged files.
24
+ */
25
+ export declare function tempPathFor(targetPath: string): string;
26
+ //# sourceMappingURL=temp-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"temp-path.d.ts","sourceRoot":"","sources":["../../lib/temp-path.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEtD"}
@@ -0,0 +1,30 @@
1
+ import { randomBytes } from "node:crypto";
2
+ /**
3
+ * Unpredictable nonce for temp/staging file names: `<pid>.<epochMs>.<hex8>`.
4
+ *
5
+ * The random component comes from `crypto.randomBytes` instead of
6
+ * `Math.random()`. `Math.random()` output is predictable once its internal
7
+ * state is known, so a local attacker who can observe one staged path could
8
+ * predict the next one and pre-create (or symlink) it before the atomic
9
+ * write-then-rename lands. An 8-hex-char CSPRNG suffix removes that
10
+ * predictability while keeping names short and `endsWith(".tmp")`-sweepable.
11
+ *
12
+ * Assumes the process CSPRNG is available: `randomBytes` throws on entropy
13
+ * failure (e.g. misconfigured FIPS builds), which is the correct outcome here —
14
+ * the same crypto primitives back the OAuth flow itself, so staging a token
15
+ * file with weaker randomness instead would be strictly worse.
16
+ */
17
+ export function tempFileNonce() {
18
+ return `${process.pid}.${Date.now()}.${randomBytes(4).toString("hex")}`;
19
+ }
20
+ /**
21
+ * Staging path for an atomic write-then-rename of `targetPath`:
22
+ * `<targetPath>.<pid>.<epochMs>.<hex8>.tmp`.
23
+ *
24
+ * Keeps the trailing `.tmp` extension so existing stale-artifact sweepers
25
+ * (`entry.name.endsWith(".tmp")` in lib/storage.ts, lib/runtime-paths.ts,
26
+ * lib/oc-chatgpt-target-detection.ts) continue to skip/collect staged files.
27
+ */
28
+ export function tempPathFor(targetPath) {
29
+ return `${targetPath}.${tempFileNonce()}.tmp`;
30
+ }