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.
- package/.codex-plugin/plugin.json +2 -1
- package/README.md +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/lib/account-policy.d.ts.map +1 -1
- package/dist/lib/account-policy.js +2 -1
- package/dist/lib/accounts/rate-limits.d.ts +8 -0
- package/dist/lib/accounts/rate-limits.d.ts.map +1 -1
- package/dist/lib/accounts/rate-limits.js +13 -0
- package/dist/lib/accounts.d.ts +19 -1
- package/dist/lib/accounts.d.ts.map +1 -1
- package/dist/lib/accounts.js +31 -2
- package/dist/lib/audit.d.ts +0 -9
- package/dist/lib/audit.d.ts.map +1 -1
- package/dist/lib/auth/device-auth.d.ts +1 -6
- package/dist/lib/auth/device-auth.d.ts.map +1 -1
- package/dist/lib/auth/device-auth.js +5 -5
- package/dist/lib/budget-guard.d.ts.map +1 -1
- package/dist/lib/budget-guard.js +2 -1
- package/dist/lib/codex-cli/writer.d.ts.map +1 -1
- package/dist/lib/codex-cli/writer.js +2 -1
- package/dist/lib/codex-manager/backend-settings-helpers.d.ts +0 -1
- package/dist/lib/codex-manager/backend-settings-helpers.d.ts.map +1 -1
- package/dist/lib/codex-manager/backend-settings-helpers.js +1 -1
- package/dist/lib/codex-manager/behavior-settings-panel.d.ts +0 -19
- package/dist/lib/codex-manager/behavior-settings-panel.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/report.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/report.js +2 -1
- package/dist/lib/codex-manager/commands/uninstall.d.ts +2 -2
- package/dist/lib/codex-manager/commands/uninstall.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/uninstall.js +1 -1
- package/dist/lib/codex-manager/commands/usage.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/usage.js +2 -1
- package/dist/lib/codex-manager/commands/verify.d.ts +2 -2
- package/dist/lib/codex-manager/commands/verify.d.ts.map +1 -1
- package/dist/lib/codex-manager/commands/why-selected.d.ts +1 -22
- package/dist/lib/codex-manager/commands/why-selected.d.ts.map +1 -1
- package/dist/lib/codex-manager/dashboard-display-panel.d.ts +0 -14
- package/dist/lib/codex-manager/dashboard-display-panel.d.ts.map +1 -1
- package/dist/lib/codex-manager/experimental-settings-prompt.d.ts +2 -1
- package/dist/lib/codex-manager/experimental-settings-prompt.d.ts.map +1 -1
- package/dist/lib/codex-manager/forecast-report-shared.d.ts +2 -2
- package/dist/lib/codex-manager/forecast-report-shared.d.ts.map +1 -1
- package/dist/lib/codex-manager/forecast-report-shared.js +2 -2
- package/dist/lib/codex-manager/formatters/quota-formatters.d.ts +0 -2
- package/dist/lib/codex-manager/formatters/quota-formatters.d.ts.map +1 -1
- package/dist/lib/codex-manager/formatters/quota-formatters.js +2 -2
- package/dist/lib/codex-manager/help.d.ts +2 -1
- package/dist/lib/codex-manager/help.d.ts.map +1 -1
- package/dist/lib/codex-manager/repair-commands.d.ts +0 -15
- package/dist/lib/codex-manager/repair-commands.d.ts.map +1 -1
- package/dist/lib/codex-manager/repair-commands.js +5 -5
- package/dist/lib/codex-manager/settings-hub/backend.d.ts +0 -5
- package/dist/lib/codex-manager/settings-hub/backend.d.ts.map +1 -1
- package/dist/lib/codex-manager/settings-hub/backend.js +1 -1
- package/dist/lib/codex-manager/settings-hub/dashboard.d.ts +1 -14
- package/dist/lib/codex-manager/settings-hub/dashboard.d.ts.map +1 -1
- package/dist/lib/codex-manager/settings-hub/dashboard.js +8 -8
- package/dist/lib/codex-manager/settings-write-queue.d.ts +0 -10
- package/dist/lib/codex-manager/settings-write-queue.d.ts.map +1 -1
- package/dist/lib/codex-manager/settings-write-queue.js +10 -10
- package/dist/lib/codex-manager/statusline-settings-panel.d.ts +2 -17
- package/dist/lib/codex-manager/statusline-settings-panel.d.ts.map +1 -1
- package/dist/lib/codex-manager/theme-settings-panel.d.ts +0 -13
- package/dist/lib/codex-manager/theme-settings-panel.d.ts.map +1 -1
- package/dist/lib/config.d.ts +0 -13
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +22 -19
- package/dist/lib/dashboard-settings.d.ts +3 -3
- package/dist/lib/dashboard-settings.d.ts.map +1 -1
- package/dist/lib/dashboard-settings.js +0 -1
- package/dist/lib/errors.d.ts +0 -1
- package/dist/lib/errors.d.ts.map +1 -1
- package/dist/lib/forecast.d.ts +4 -3
- package/dist/lib/forecast.d.ts.map +1 -1
- package/dist/lib/fs-retry.d.ts +0 -3
- package/dist/lib/fs-retry.d.ts.map +1 -1
- package/dist/lib/fs-retry.js +3 -3
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +1 -0
- package/dist/lib/local-client-tokens.d.ts.map +1 -1
- package/dist/lib/local-client-tokens.js +2 -1
- package/dist/lib/oc-chatgpt-import-adapter.d.ts +1 -1
- package/dist/lib/oc-chatgpt-import-adapter.d.ts.map +1 -1
- package/dist/lib/oc-chatgpt-orchestrator.d.ts.map +1 -1
- package/dist/lib/oc-chatgpt-orchestrator.js +2 -1
- package/dist/lib/oc-chatgpt-target-detection.d.ts +1 -1
- package/dist/lib/oc-chatgpt-target-detection.d.ts.map +1 -1
- package/dist/lib/prompts/codex-host-bridge.d.ts +0 -8
- package/dist/lib/prompts/codex-host-bridge.d.ts.map +1 -1
- package/dist/lib/prompts/codex-host-bridge.js +0 -20
- package/dist/lib/prompts/codex.d.ts.map +1 -1
- package/dist/lib/prompts/codex.js +2 -1
- package/dist/lib/prompts/fetch-utils.d.ts +0 -2
- package/dist/lib/prompts/fetch-utils.d.ts.map +1 -1
- package/dist/lib/prompts/fetch-utils.js +2 -2
- package/dist/lib/prompts/host-codex-prompt.d.ts.map +1 -1
- package/dist/lib/prompts/host-codex-prompt.js +2 -1
- package/dist/lib/quota-cache.d.ts.map +1 -1
- package/dist/lib/quota-cache.js +2 -1
- package/dist/lib/recovery/storage.d.ts.map +1 -1
- package/dist/lib/recovery/storage.js +5 -3
- package/dist/lib/recovery/types.d.ts +4 -12
- package/dist/lib/recovery/types.d.ts.map +1 -1
- package/dist/lib/recovery.d.ts +2 -2
- package/dist/lib/recovery.d.ts.map +1 -1
- package/dist/lib/request/response-compaction.d.ts +2 -1
- package/dist/lib/request/response-compaction.d.ts.map +1 -1
- package/dist/lib/request/stream-failover-runtime.d.ts.map +1 -1
- package/dist/lib/request/stream-failover-runtime.js +30 -1
- package/dist/lib/rotation.d.ts +1 -3
- package/dist/lib/rotation.d.ts.map +1 -1
- package/dist/lib/rotation.js +1 -2
- package/dist/lib/routing-profiles.d.ts.map +1 -1
- package/dist/lib/routing-profiles.js +2 -1
- package/dist/lib/runtime/config-toml.d.ts +0 -6
- package/dist/lib/runtime/config-toml.d.ts.map +1 -1
- package/dist/lib/runtime/config-toml.js +6 -6
- package/dist/lib/runtime/event-handler.d.ts +0 -31
- package/dist/lib/runtime/event-handler.d.ts.map +1 -1
- package/dist/lib/runtime/event-handler.js +0 -22
- package/dist/lib/runtime/first-run.d.ts +3 -5
- package/dist/lib/runtime/first-run.d.ts.map +1 -1
- package/dist/lib/runtime/first-run.js +2 -2
- package/dist/lib/runtime/quota-headers.d.ts +1 -6
- package/dist/lib/runtime/quota-headers.d.ts.map +1 -1
- package/dist/lib/runtime/quota-headers.js +5 -5
- package/dist/lib/runtime/rotation-proxy-state.d.ts.map +1 -1
- package/dist/lib/runtime/rotation-proxy-state.js +24 -0
- package/dist/lib/runtime/runtime-current-account.d.ts +3 -3
- package/dist/lib/runtime/runtime-current-account.d.ts.map +1 -1
- package/dist/lib/runtime/runtime-current-account.js +1 -1
- package/dist/lib/runtime/runtime-observability.d.ts +2 -2
- package/dist/lib/runtime/runtime-observability.d.ts.map +1 -1
- package/dist/lib/runtime/runtime-observability.js +0 -4
- package/dist/lib/runtime-rotation-proxy.d.ts.map +1 -1
- package/dist/lib/runtime-rotation-proxy.js +20 -6
- package/dist/lib/schemas.d.ts +3 -91
- package/dist/lib/schemas.d.ts.map +1 -1
- package/dist/lib/schemas.js +8 -8
- package/dist/lib/storage/file-paths.d.ts +2 -2
- package/dist/lib/storage/file-paths.d.ts.map +1 -1
- package/dist/lib/storage/file-paths.js +2 -2
- package/dist/lib/storage/flagged-storage-io.d.ts.map +1 -1
- package/dist/lib/storage/flagged-storage-io.js +2 -2
- package/dist/lib/storage/import-export.d.ts.map +1 -1
- package/dist/lib/storage/import-export.js +2 -2
- package/dist/lib/storage/migrations.d.ts +2 -1
- package/dist/lib/storage/migrations.d.ts.map +1 -1
- package/dist/lib/storage.d.ts.map +1 -1
- package/dist/lib/storage.js +30 -23
- package/dist/lib/temp-path.d.ts +26 -0
- package/dist/lib/temp-path.d.ts.map +1 -0
- package/dist/lib/temp-path.js +30 -0
- package/dist/lib/ui/theme.d.ts +3 -2
- package/dist/lib/ui/theme.d.ts.map +1 -1
- package/dist/lib/unified-settings.d.ts.map +1 -1
- package/dist/lib/unified-settings.js +2 -1
- package/dist/lib/update-notice.d.ts.map +1 -1
- package/dist/lib/update-notice.js +2 -1
- package/package.json +1 -2
|
@@ -3,9 +3,6 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Based on Codex-antigravity-auth recovery module.
|
|
5
5
|
*/
|
|
6
|
-
export type ThinkingPartType = "thinking" | "redacted_thinking" | "reasoning";
|
|
7
|
-
export type MetaPartType = "step-start" | "step-finish";
|
|
8
|
-
export type ContentPartType = "text" | "tool" | "tool_use" | "tool_result";
|
|
9
6
|
export interface StoredMessageMeta {
|
|
10
7
|
id: string;
|
|
11
8
|
sessionID: string;
|
|
@@ -26,7 +23,7 @@ export interface StoredTextPart {
|
|
|
26
23
|
synthetic?: boolean;
|
|
27
24
|
ignored?: boolean;
|
|
28
25
|
}
|
|
29
|
-
|
|
26
|
+
interface StoredToolPart {
|
|
30
27
|
id: string;
|
|
31
28
|
sessionID: string;
|
|
32
29
|
messageID: string;
|
|
@@ -40,14 +37,14 @@ export interface StoredToolPart {
|
|
|
40
37
|
error?: string;
|
|
41
38
|
};
|
|
42
39
|
}
|
|
43
|
-
|
|
40
|
+
interface StoredReasoningPart {
|
|
44
41
|
id: string;
|
|
45
42
|
sessionID: string;
|
|
46
43
|
messageID: string;
|
|
47
44
|
type: "reasoning";
|
|
48
45
|
text: string;
|
|
49
46
|
}
|
|
50
|
-
|
|
47
|
+
interface StoredStepPart {
|
|
51
48
|
id: string;
|
|
52
49
|
sessionID: string;
|
|
53
50
|
messageID: string;
|
|
@@ -102,15 +99,10 @@ export interface ResumeConfig {
|
|
|
102
99
|
};
|
|
103
100
|
}
|
|
104
101
|
export type RecoveryErrorType = "tool_result_missing" | "thinking_block_order" | "thinking_disabled_violation" | null;
|
|
105
|
-
export interface ToolUsePart {
|
|
106
|
-
type: "tool_use";
|
|
107
|
-
id: string;
|
|
108
|
-
name: string;
|
|
109
|
-
input: Record<string, unknown>;
|
|
110
|
-
}
|
|
111
102
|
export interface ToolResultPart {
|
|
112
103
|
type: "tool_result";
|
|
113
104
|
tool_use_id: string;
|
|
114
105
|
content: string;
|
|
115
106
|
}
|
|
107
|
+
export {};
|
|
116
108
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../lib/recovery/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../lib/recovery/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE;QACL,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,KAAK,CAAC,EAAE,OAA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MAAM,CAAC;KACjB,CAAC;CACH;AAMD,MAAM,MAAM,iBAAiB,GACzB,qBAAqB,GACrB,sBAAsB,GACtB,6BAA6B,GAC7B,IAAI,CAAC;AAET,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,aAAa,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB"}
|
package/dist/lib/recovery.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PluginInput } from "@codex-ai/plugin";
|
|
2
2
|
import type { PluginConfig } from "./types.js";
|
|
3
|
-
import type { MessageInfo,
|
|
4
|
-
export type { RecoveryErrorType
|
|
3
|
+
import type { MessageInfo, RecoveryErrorType } from "./recovery/types.js";
|
|
4
|
+
export type { RecoveryErrorType };
|
|
5
5
|
type PluginClient = PluginInput["client"];
|
|
6
6
|
export declare function detectErrorType(error: unknown): RecoveryErrorType;
|
|
7
7
|
export declare function isRecoverableError(error: unknown): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recovery.d.ts","sourceRoot":"","sources":["../../lib/recovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAS/C,OAAO,KAAK,EACV,WAAW,
|
|
1
|
+
{"version":3,"file":"recovery.d.ts","sourceRoot":"","sources":["../../lib/recovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAS/C,OAAO,KAAK,EACV,WAAW,EAIX,iBAAiB,EAElB,MAAM,qBAAqB,CAAC;AAE7B,YAAY,EAAE,iBAAiB,EAAE,CAAC;AAElC,KAAK,YAAY,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC;AAuC1C,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,iBAAiB,CAsBjE;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAE1D;AAkKD,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,iBAAiB,GAAG;IACrE,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,CAWA;AAED,wBAAgB,uBAAuB,IAAI;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,CAKA;AAED,wBAAgB,uBAAuB,IAAI;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB,CAKA;AAED,MAAM,WAAW,mBAAmB;IAClC,qBAAqB,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/D,kBAAkB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC;IAChD,kBAAkB,EAAE,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,KAAK,IAAI,CAAC;IACpE,6BAA6B,EAAE,CAAC,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,KAAK,IAAI,CAAC;CAChF;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,YAAY,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,sBAAsB,EAC3B,MAAM,EAAE,YAAY,GACnB,mBAAmB,GAAG,IAAI,CA6H5B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RequestBody } from "../types.js";
|
|
2
|
-
|
|
2
|
+
interface DeferredFastSessionInputTrim {
|
|
3
3
|
maxItems: number;
|
|
4
4
|
preferLatestUserOnly: boolean;
|
|
5
5
|
}
|
|
@@ -17,4 +17,5 @@ export interface ApplyResponseCompactionParams {
|
|
|
17
17
|
timeoutMs?: number;
|
|
18
18
|
}
|
|
19
19
|
export declare function applyResponseCompaction(params: ApplyResponseCompactionParams): Promise<ResponseCompactionResult>;
|
|
20
|
+
export {};
|
|
20
21
|
//# sourceMappingURL=response-compaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response-compaction.d.ts","sourceRoot":"","sources":["../../../lib/request/response-compaction.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAa,WAAW,EAAE,MAAM,aAAa,CAAC;AAK1D,
|
|
1
|
+
{"version":3,"file":"response-compaction.d.ts","sourceRoot":"","sources":["../../../lib/request/response-compaction.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAa,WAAW,EAAE,MAAM,aAAa,CAAC;AAK1D,UAAU,4BAA4B;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,oBAAoB,EAAE,OAAO,CAAC;CAC9B;AAED,MAAM,WAAW,wBAAwB;IACxC,IAAI,EAAE,WAAW,CAAC;IAClB,IAAI,EAAE,WAAW,GAAG,SAAS,GAAG,WAAW,CAAC;CAC5C;AAED,MAAM,WAAW,6BAA6B;IAC7C,IAAI,EAAE,WAAW,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,4BAA4B,CAAC;IACnC,SAAS,EAAE,OAAO,KAAK,CAAC;IACxB,MAAM,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAoED,wBAAsB,uBAAuB,CAC5C,MAAM,EAAE,6BAA6B,GACnC,OAAO,CAAC,wBAAwB,CAAC,CAoEnC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream-failover-runtime.d.ts","sourceRoot":"","sources":["../../../lib/request/stream-failover-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;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ClB,GAAG,EAAE,cAAc,EACnB,MAAM,EAAE,0BAA0B,EAClC,aAAa,EAAE,MAAM,IAAI,EACzB,oBAAoB,EAAE,MAAM,GAC1B,OAAO,CAAC,OAAO,CAAC,CAqDlB"}
|
|
@@ -111,6 +111,23 @@ export async function readErrorBody(response, timeoutMs, maxBytes = 1024 * 1024)
|
|
|
111
111
|
return "";
|
|
112
112
|
}
|
|
113
113
|
}
|
|
114
|
+
// Resolve once the client response can accept more data again. Also resolves
|
|
115
|
+
// on close/error so a client that disconnects mid-backpressure cannot park the
|
|
116
|
+
// forwarder forever — the next reader.read() then observes the cancellation
|
|
117
|
+
// installed by the close handler.
|
|
118
|
+
function waitForDrain(res) {
|
|
119
|
+
return new Promise((resolve) => {
|
|
120
|
+
const settle = () => {
|
|
121
|
+
res.off("drain", settle);
|
|
122
|
+
res.off("close", settle);
|
|
123
|
+
res.off("error", settle);
|
|
124
|
+
resolve();
|
|
125
|
+
};
|
|
126
|
+
res.once("drain", settle);
|
|
127
|
+
res.once("close", settle);
|
|
128
|
+
res.once("error", settle);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
114
131
|
export async function forwardStreamingResponse(upstream, res, status, onStreamError, streamStallTimeoutMs) {
|
|
115
132
|
status.streamsStarted += 1;
|
|
116
133
|
res.writeHead(upstream.status, responseHeadersForClient(upstream.headers));
|
|
@@ -132,7 +149,19 @@ export async function forwardStreamingResponse(upstream, res, status, onStreamEr
|
|
|
132
149
|
if (done)
|
|
133
150
|
break;
|
|
134
151
|
if (value && value.byteLength > 0) {
|
|
135
|
-
|
|
152
|
+
// If the response is already finished (clean end by a concurrent
|
|
153
|
+
// close-then-reader-cancel path), stop writing. Do NOT guard on
|
|
154
|
+
// res.destroyed here: a socket-error-during-backpressure scenario sets
|
|
155
|
+
// destroyed=true and then lets the next res.write() throw so the catch
|
|
156
|
+
// block can record the error and fire onStreamError correctly.
|
|
157
|
+
if (res.writableEnded)
|
|
158
|
+
break;
|
|
159
|
+
// Respect backpressure: when the client's socket buffer is full,
|
|
160
|
+
// pause upstream reads until it drains instead of buffering the
|
|
161
|
+
// whole stream in memory for a slow consumer.
|
|
162
|
+
if (!res.write(Buffer.from(value)) && !res.destroyed) {
|
|
163
|
+
await waitForDrain(res);
|
|
164
|
+
}
|
|
136
165
|
}
|
|
137
166
|
}
|
|
138
167
|
res.end();
|
package/dist/lib/rotation.d.ts
CHANGED
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
* Ported from antigravity-auth rotation logic for optimal account rotation
|
|
6
6
|
* when rate limits are encountered.
|
|
7
7
|
*/
|
|
8
|
-
export type { SelectionRecord, RoutingMutexMode, AsyncMutex, } from "./routing-mutex.js";
|
|
9
|
-
export { createAsyncMutex, getRoutingMutex, withRoutingMutex, } from "./routing-mutex.js";
|
|
10
8
|
export interface HealthScoreConfig {
|
|
11
9
|
/** Points added on successful request */
|
|
12
10
|
successDelta: number;
|
|
@@ -104,7 +102,6 @@ export interface HybridSelectionConfig {
|
|
|
104
102
|
/** Weight for freshness/last used (default: 2) */
|
|
105
103
|
freshnessWeight: number;
|
|
106
104
|
}
|
|
107
|
-
export declare const DEFAULT_HYBRID_SELECTION_CONFIG: HybridSelectionConfig;
|
|
108
105
|
/**
|
|
109
106
|
* Selects the best account using a hybrid scoring strategy.
|
|
110
107
|
*
|
|
@@ -231,4 +228,5 @@ export declare function exponentialBackoff(attempt: number, baseMs?: number, max
|
|
|
231
228
|
export declare function getHealthTracker(config?: Partial<HealthScoreConfig>): HealthScoreTracker;
|
|
232
229
|
export declare function getTokenTracker(config?: Partial<TokenBucketConfig>): TokenBucketTracker;
|
|
233
230
|
export declare function resetTrackers(): void;
|
|
231
|
+
export {};
|
|
234
232
|
//# sourceMappingURL=rotation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rotation.d.ts","sourceRoot":"","sources":["../../lib/rotation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"rotation.d.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AgB,kBAAkB,CACjC,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,EACd,YAAY,CAAC,EAAE,MAAM,GACnB,MAAM,CAAC;AA2DV,wBAAgB,gBAAgB,CAC/B,MAAM,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,GACjC,kBAAkB,CAKpB;AAED,wBAAgB,eAAe,CAC9B,MAAM,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,GACjC,kBAAkB,CAKpB;AAED,wBAAgB,aAAa,IAAI,IAAI,CAGpC"}
|
package/dist/lib/rotation.js
CHANGED
|
@@ -6,7 +6,6 @@
|
|
|
6
6
|
* when rate limits are encountered.
|
|
7
7
|
*/
|
|
8
8
|
import { createLogger } from "./logger.js";
|
|
9
|
-
export { createAsyncMutex, getRoutingMutex, withRoutingMutex, } from "./routing-mutex.js";
|
|
10
9
|
const log = createLogger("rotation");
|
|
11
10
|
export const DEFAULT_HEALTH_SCORE_CONFIG = {
|
|
12
11
|
successDelta: 1,
|
|
@@ -261,7 +260,7 @@ export class TokenBucketTracker {
|
|
|
261
260
|
}
|
|
262
261
|
}
|
|
263
262
|
}
|
|
264
|
-
|
|
263
|
+
const DEFAULT_HYBRID_SELECTION_CONFIG = {
|
|
265
264
|
healthWeight: 2,
|
|
266
265
|
tokenWeight: 5,
|
|
267
266
|
freshnessWeight: 2.0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing-profiles.d.ts","sourceRoot":"","sources":["../../lib/routing-profiles.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"routing-profiles.d.ts","sourceRoot":"","sources":["../../lib/routing-profiles.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,cAAc;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,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mBAAmB,CAA2B,GACvE,OAAO,CAAC,4BAA4B,CAAC,CAqBvC;AAED,wBAAgB,qCAAqC,IAAI,IAAI,CAE5D"}
|
|
@@ -4,6 +4,7 @@ import { logWarn } from "./logger.js";
|
|
|
4
4
|
import { getCodexMultiAuthDir } from "./runtime-paths.js";
|
|
5
5
|
import { findProjectRoot, getProjectStorageKey, resolveProjectStorageIdentityRoot, } from "./storage/paths.js";
|
|
6
6
|
import { isRecord, sleep } from "./utils.js";
|
|
7
|
+
import { tempPathFor } from "./temp-path.js";
|
|
7
8
|
const ROUTING_PROFILES_FILE_NAME = "routing-profiles.json";
|
|
8
9
|
const RETRYABLE_FS_CODES = new Set(["EBUSY", "EPERM"]);
|
|
9
10
|
let writeQueue = Promise.resolve();
|
|
@@ -116,7 +117,7 @@ export async function saveRoutingProfileStore(store) {
|
|
|
116
117
|
const payload = normalizeStore(store);
|
|
117
118
|
const task = async () => {
|
|
118
119
|
await fs.mkdir(getCodexMultiAuthDir(), { recursive: true, mode: 0o700 });
|
|
119
|
-
const tempPath =
|
|
120
|
+
const tempPath = tempPathFor(path);
|
|
120
121
|
let moved = false;
|
|
121
122
|
try {
|
|
122
123
|
await fs.writeFile(tempPath, `${JSON.stringify(payload, null, 2)}\n`, {
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
export declare function tomlStringLiteral(value: string): string;
|
|
2
|
-
export declare function readTomlTableName(line: string): string | null;
|
|
3
|
-
export declare function removeRuntimeRotationProviderBlock(rawConfig: string): string;
|
|
4
|
-
export declare function rewriteTopLevelModelProvider(rawConfig: string): string;
|
|
5
|
-
export declare function enableTopLevelResponseStorage(rawConfig: string): string;
|
|
6
2
|
export declare function restoreTopLevelModelProvider(currentConfig: string, originalConfig: string): string;
|
|
7
3
|
export declare function restoreTopLevelResponseStorage(currentConfig: string, originalConfig: string): string;
|
|
8
|
-
export declare function ensureTomlTrailingNewline(value: string): string;
|
|
9
|
-
export declare function createRuntimeRotationProviderBlock(baseUrl: string, clientApiKey?: string): string[];
|
|
10
4
|
export declare function rewriteConfigTomlForRuntimeRotationProvider(rawConfig: string, baseUrl: string, clientApiKey?: string): string;
|
|
11
5
|
export declare function restoreConfigTomlFromRuntimeRotationProvider(currentConfig: string, originalConfig: string): string;
|
|
12
6
|
//# sourceMappingURL=config-toml.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-toml.d.ts","sourceRoot":"","sources":["../../../lib/runtime/config-toml.ts"],"names":[],"mappings":"AAEA,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAqBvD;
|
|
1
|
+
{"version":3,"file":"config-toml.d.ts","sourceRoot":"","sources":["../../../lib/runtime/config-toml.ts"],"names":[],"mappings":"AAEA,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAqBvD;AA4FD,wBAAgB,4BAA4B,CAC3C,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,GACpB,MAAM,CAiCR;AAED,wBAAgB,8BAA8B,CAC7C,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,GACpB,MAAM,CAkDR;AA2BD,wBAAgB,2CAA2C,CAC1D,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,YAAY,SAAK,GACf,MAAM,CAkBR;AAED,wBAAgB,4CAA4C,CAC3D,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,GACpB,MAAM,CAYR"}
|
|
@@ -21,11 +21,11 @@ export function tomlStringLiteral(value) {
|
|
|
21
21
|
}
|
|
22
22
|
})}"`;
|
|
23
23
|
}
|
|
24
|
-
|
|
24
|
+
function readTomlTableName(line) {
|
|
25
25
|
const match = /^\s*\[{1,2}\s*([^\]]+?)\s*\]{1,2}\s*$/.exec(line);
|
|
26
26
|
return match?.[1]?.trim() ?? null;
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
function removeRuntimeRotationProviderBlock(rawConfig) {
|
|
29
29
|
const lines = rawConfig.split(/\r?\n/);
|
|
30
30
|
const output = [];
|
|
31
31
|
let skipping = false;
|
|
@@ -47,7 +47,7 @@ export function removeRuntimeRotationProviderBlock(rawConfig) {
|
|
|
47
47
|
}
|
|
48
48
|
return output.join(rawConfig.includes("\r\n") ? "\r\n" : "\n");
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
function rewriteTopLevelModelProvider(rawConfig) {
|
|
51
51
|
const lineEnding = rawConfig.includes("\r\n") ? "\r\n" : "\n";
|
|
52
52
|
const lines = rawConfig.length > 0 ? rawConfig.split(/\r?\n/) : [];
|
|
53
53
|
const rewrittenLine = `model_provider = ${tomlStringLiteral(RUNTIME_ROTATION_PROXY_PROVIDER_ID)}`;
|
|
@@ -70,7 +70,7 @@ export function rewriteTopLevelModelProvider(rawConfig) {
|
|
|
70
70
|
output.push(rewrittenLine);
|
|
71
71
|
return output.join(lineEnding);
|
|
72
72
|
}
|
|
73
|
-
|
|
73
|
+
function enableTopLevelResponseStorage(rawConfig) {
|
|
74
74
|
const lineEnding = rawConfig.includes("\r\n") ? "\r\n" : "\n";
|
|
75
75
|
const lines = rawConfig.length > 0 ? rawConfig.split(/\r?\n/) : [];
|
|
76
76
|
const output = [];
|
|
@@ -175,10 +175,10 @@ export function restoreTopLevelResponseStorage(currentConfig, originalConfig) {
|
|
|
175
175
|
}
|
|
176
176
|
return output.join(lineEnding);
|
|
177
177
|
}
|
|
178
|
-
|
|
178
|
+
function ensureTomlTrailingNewline(value) {
|
|
179
179
|
return value.replace(/[\r\n]*$/, "\n");
|
|
180
180
|
}
|
|
181
|
-
|
|
181
|
+
function createRuntimeRotationProviderBlock(baseUrl, clientApiKey = "") {
|
|
182
182
|
const lines = [
|
|
183
183
|
`[model_providers.${RUNTIME_ROTATION_PROXY_PROVIDER_ID}]`,
|
|
184
184
|
'name = "codex-multi-auth"',
|
|
@@ -1,36 +1,5 @@
|
|
|
1
1
|
import type { ModelFamily } from "../prompts/codex.js";
|
|
2
2
|
import type { AccountStorageV3 } from "../storage.js";
|
|
3
|
-
export declare function createRuntimeEventHandler<TLoadedStorage, TSavedStorage, TModelFamily extends string, TManager>(deps: {
|
|
4
|
-
handleAccountSelectEvent: (input: {
|
|
5
|
-
event: {
|
|
6
|
-
type: string;
|
|
7
|
-
properties?: unknown;
|
|
8
|
-
};
|
|
9
|
-
providerId: string;
|
|
10
|
-
loadAccounts: () => Promise<TLoadedStorage>;
|
|
11
|
-
saveAccounts: (storage: TSavedStorage) => Promise<void>;
|
|
12
|
-
modelFamilies: readonly TModelFamily[];
|
|
13
|
-
cachedAccountManager: TManager;
|
|
14
|
-
reloadAccountManagerFromDisk: () => Promise<void>;
|
|
15
|
-
setLastCodexCliActiveSyncIndex: (index: number) => void;
|
|
16
|
-
showToast: (message: string, variant?: "info" | "success" | "warning" | "error") => Promise<void>;
|
|
17
|
-
}) => Promise<boolean>;
|
|
18
|
-
providerId: string;
|
|
19
|
-
loadAccounts: () => Promise<TLoadedStorage>;
|
|
20
|
-
saveAccounts: (storage: TSavedStorage) => Promise<void>;
|
|
21
|
-
modelFamilies: readonly TModelFamily[];
|
|
22
|
-
getCachedAccountManager: () => TManager;
|
|
23
|
-
reloadAccountManagerFromDisk: () => Promise<void>;
|
|
24
|
-
setLastCodexCliActiveSyncIndex: (index: number) => void;
|
|
25
|
-
showToast: (message: string, variant?: "info" | "success" | "warning" | "error") => Promise<void>;
|
|
26
|
-
logDebug: (message: string) => void;
|
|
27
|
-
pluginName: string;
|
|
28
|
-
}): (input: {
|
|
29
|
-
event: {
|
|
30
|
-
type: string;
|
|
31
|
-
properties?: unknown;
|
|
32
|
-
};
|
|
33
|
-
}) => Promise<void>;
|
|
34
3
|
export declare function handleRuntimeEvent(params: {
|
|
35
4
|
input: {
|
|
36
5
|
event: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-handler.d.ts","sourceRoot":"","sources":["../../../lib/runtime/event-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAA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+1,4 @@
|
|
|
1
1
|
import { handleAccountSelectEvent } from "./account-select-event.js";
|
|
2
|
-
export function createRuntimeEventHandler(deps) {
|
|
3
|
-
return async (input) => {
|
|
4
|
-
try {
|
|
5
|
-
const handled = await deps.handleAccountSelectEvent({
|
|
6
|
-
event: input.event,
|
|
7
|
-
providerId: deps.providerId,
|
|
8
|
-
loadAccounts: deps.loadAccounts,
|
|
9
|
-
saveAccounts: deps.saveAccounts,
|
|
10
|
-
modelFamilies: deps.modelFamilies,
|
|
11
|
-
cachedAccountManager: deps.getCachedAccountManager(),
|
|
12
|
-
reloadAccountManagerFromDisk: deps.reloadAccountManagerFromDisk,
|
|
13
|
-
setLastCodexCliActiveSyncIndex: deps.setLastCodexCliActiveSyncIndex,
|
|
14
|
-
showToast: deps.showToast,
|
|
15
|
-
});
|
|
16
|
-
if (handled)
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
catch (error) {
|
|
20
|
-
deps.logDebug(`[${deps.pluginName}] Event handler error: ${error instanceof Error ? error.message : String(error)}`);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
2
|
export async function handleRuntimeEvent(params) {
|
|
25
3
|
try {
|
|
26
4
|
await handleAccountSelectEvent({
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export declare const FIRST_RUN_MARKER_VERSION = 1;
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
type FirstRunStepStatus = "completed" | "skipped" | "failed";
|
|
3
|
+
interface FirstRunSetupOutcome {
|
|
4
4
|
appBind: FirstRunStepStatus;
|
|
5
5
|
launcher: FirstRunStepStatus;
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
type FirstRunSkipReason = "ci" | "not-installed" | "already-done" | "claim-race" | "error";
|
|
8
8
|
export type FirstRunResult = {
|
|
9
9
|
ran: false;
|
|
10
10
|
reason: FirstRunSkipReason;
|
|
@@ -22,7 +22,6 @@ export interface FirstRunSetupDeps {
|
|
|
22
22
|
notify?: (message: string) => void;
|
|
23
23
|
now?: () => number;
|
|
24
24
|
}
|
|
25
|
-
export declare function readOptionalBoolean(value: string | undefined): boolean | null;
|
|
26
25
|
export declare function isCiEnvironment(env?: NodeJS.ProcessEnv): boolean;
|
|
27
26
|
export interface DesktopAppDetectionOptions {
|
|
28
27
|
env?: NodeJS.ProcessEnv;
|
|
@@ -57,7 +56,6 @@ export declare function shouldInstallCodexAppLauncherOnFirstRun(options: FirstRu
|
|
|
57
56
|
* machine-level install either
|
|
58
57
|
*/
|
|
59
58
|
export declare function isInstalledPackageContext(modulePath?: string, cwd?: string): boolean;
|
|
60
|
-
export declare function getFirstRunMarkerPath(): string;
|
|
61
59
|
type LauncherInstallFn = (options: {
|
|
62
60
|
log: (message: string) => void;
|
|
63
61
|
}) => Promise<unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"first-run.d.ts","sourceRoot":"","sources":["../../../lib/runtime/first-run.ts"],"names":[],"mappings":"AA2BA,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAkB1C,
|
|
1
|
+
{"version":3,"file":"first-run.d.ts","sourceRoot":"","sources":["../../../lib/runtime/first-run.ts"],"names":[],"mappings":"AA2BA,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAkB1C,KAAK,kBAAkB,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE7D,UAAU,oBAAoB;IAC7B,OAAO,EAAE,kBAAkB,CAAC;IAC5B,QAAQ,EAAE,kBAAkB,CAAC;CAC7B;AAED,KAAK,kBAAkB,GACpB,IAAI,GACJ,eAAe,GACf,cAAc,GACd,YAAY,GACZ,OAAO,CAAC;AAEX,MAAM,MAAM,cAAc,GACvB;IAAE,GAAG,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,kBAAkB,CAAA;CAAE,GAC1C,CAAC;IAAE,GAAG,EAAE,IAAI,CAAA;CAAE,GAAG,oBAAoB,CAAC,CAAC;AAE1C,MAAM,WAAW,iBAAiB;IACjC,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B,GAClC,OAAO,CAUT;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CACxC,UAAU,GAAE,MAAuC,EACnD,GAAG,GAAE,MAAsB,GACzB,OAAO,CAST;AAkGD,KAAK,iBAAiB,GAAG,CAAC,OAAO,EAAE;IAClC,GAAG,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/B,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;AAEvB;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CACxC,iBAAiB,CAAC,EAAE,SAAS,MAAM,EAAE,GACnC,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAenC;AAkCD;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACxC,IAAI,GAAE,iBAAsB,GAC1B,OAAO,CAAC,cAAc,CAAC,CAoDzB"}
|
|
@@ -38,7 +38,7 @@ const CI_ENV_KEYS = [
|
|
|
38
38
|
"APPVEYOR",
|
|
39
39
|
"BITBUCKET_BUILD_NUMBER",
|
|
40
40
|
];
|
|
41
|
-
|
|
41
|
+
function readOptionalBoolean(value) {
|
|
42
42
|
if (value === undefined || value.trim().length === 0)
|
|
43
43
|
return null;
|
|
44
44
|
const normalized = value.trim().toLowerCase();
|
|
@@ -144,7 +144,7 @@ export function isInstalledPackageContext(modulePath = fileURLToPath(import.meta
|
|
|
144
144
|
}
|
|
145
145
|
return true;
|
|
146
146
|
}
|
|
147
|
-
|
|
147
|
+
function getFirstRunMarkerPath() {
|
|
148
148
|
return join(getCodexMultiAuthDir(), FIRST_RUN_MARKER_FILE);
|
|
149
149
|
}
|
|
150
150
|
function errorMessage(error) {
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import type { CodexQuotaSnapshot } from "../quota-probe.js";
|
|
2
|
-
export type { CodexQuotaSnapshot
|
|
2
|
+
export type { CodexQuotaSnapshot } from "../quota-probe.js";
|
|
3
3
|
export type ParsedCodexQuotaSnapshot = Omit<CodexQuotaSnapshot, "model">;
|
|
4
|
-
export declare function parseFiniteNumberHeader(headers: Headers, name: string): number | undefined;
|
|
5
|
-
export declare function parseFiniteIntHeader(headers: Headers, name: string): number | undefined;
|
|
6
4
|
export declare function parseResetAtMs(headers: Headers, prefix: string): number | undefined;
|
|
7
|
-
export declare function hasCodexQuotaHeaders(headers: Headers): boolean;
|
|
8
5
|
export declare function parseCodexQuotaSnapshot(headers: Headers, status: number): ParsedCodexQuotaSnapshot | null;
|
|
9
|
-
export declare function formatQuotaWindowLabel(windowMinutes: number | undefined): string;
|
|
10
|
-
export declare function formatResetAt(resetAtMs: number | undefined): string | undefined;
|
|
11
6
|
export declare function formatCodexQuotaLine(snapshot: Pick<CodexQuotaSnapshot, "status" | "planType" | "activeLimit" | "primary" | "secondary">): string;
|
|
12
7
|
//# sourceMappingURL=quota-headers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quota-headers.d.ts","sourceRoot":"","sources":["../../../lib/runtime/quota-headers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAoB,MAAM,mBAAmB,CAAC;AAE9E,YAAY,EAAE,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"quota-headers.d.ts","sourceRoot":"","sources":["../../../lib/runtime/quota-headers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAoB,MAAM,mBAAmB,CAAC;AAE9E,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAE5D,MAAM,MAAM,wBAAwB,GAAG,IAAI,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;AAsBzE,wBAAgB,cAAc,CAC7B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,GACZ,MAAM,GAAG,SAAS,CA0BpB;AAgBD,wBAAgB,uBAAuB,CACtC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,GACZ,wBAAwB,GAAG,IAAI,CAkCjC;AAyCD,wBAAgB,oBAAoB,CACnC,QAAQ,EAAE,IAAI,CACb,kBAAkB,EAClB,QAAQ,GAAG,UAAU,GAAG,aAAa,GAAG,SAAS,GAAG,WAAW,CAC/D,GACC,MAAM,CAkCR"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
function parseFiniteNumberHeader(headers, name) {
|
|
2
2
|
const raw = headers.get(name);
|
|
3
3
|
if (!raw)
|
|
4
4
|
return undefined;
|
|
5
5
|
const parsed = Number(raw);
|
|
6
6
|
return Number.isFinite(parsed) ? parsed : undefined;
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
function parseFiniteIntHeader(headers, name) {
|
|
9
9
|
const raw = headers.get(name);
|
|
10
10
|
if (!raw)
|
|
11
11
|
return undefined;
|
|
@@ -32,7 +32,7 @@ export function parseResetAtMs(headers, prefix) {
|
|
|
32
32
|
const parsedDate = Date.parse(trimmed);
|
|
33
33
|
return Number.isFinite(parsedDate) ? parsedDate : undefined;
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
function hasCodexQuotaHeaders(headers) {
|
|
36
36
|
const keys = [
|
|
37
37
|
"x-codex-primary-used-percent",
|
|
38
38
|
"x-codex-primary-window-minutes",
|
|
@@ -65,7 +65,7 @@ export function parseCodexQuotaSnapshot(headers, status) {
|
|
|
65
65
|
const activeLimit = parseFiniteIntHeader(headers, "x-codex-active-limit");
|
|
66
66
|
return { status, planType, activeLimit, primary, secondary };
|
|
67
67
|
}
|
|
68
|
-
|
|
68
|
+
function formatQuotaWindowLabel(windowMinutes) {
|
|
69
69
|
if (!windowMinutes || !Number.isFinite(windowMinutes) || windowMinutes <= 0) {
|
|
70
70
|
return "quota";
|
|
71
71
|
}
|
|
@@ -75,7 +75,7 @@ export function formatQuotaWindowLabel(windowMinutes) {
|
|
|
75
75
|
return `${windowMinutes / 60}h`;
|
|
76
76
|
return `${windowMinutes}m`;
|
|
77
77
|
}
|
|
78
|
-
|
|
78
|
+
function formatResetAt(resetAtMs) {
|
|
79
79
|
if (!resetAtMs || !Number.isFinite(resetAtMs) || resetAtMs <= 0)
|
|
80
80
|
return undefined;
|
|
81
81
|
const date = new Date(resetAtMs);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rotation-proxy-state.d.ts","sourceRoot":"","sources":["../../../lib/runtime/rotation-proxy-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAKhD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAEnE;;;;;;GAMG;AACH,MAAM,WAAW,sBAAsB;IACtC,oBAAoB,EAAE,cAAc,CAAC;IACrC,gBAAgB,EAAE,SAAS,GAAG,QAAQ,CAAC;IACvC,kBAAkB,EAAE,QAAQ,GAAG,YAAY,CAAC;IAC5C,SAAS,EAAE,OAAO,KAAK,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,MAAM,MAAM,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,sBAAsB,EAAE,MAAM,CAAC;IAC/B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,2BAA2B,EAAE,MAAM,CAAC;IACpC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,yBAAyB,EAAE,MAAM,CAAC;IAClC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,8BAA8B,EAAE,MAAM,CAAC;IACvC,oBAAoB,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAClD,8BAA8B,EAAE,MAAM,CAAC;CACvC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAmB,SAAQ,sBAAsB;IACjE,QAAQ,CAAC,o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AC;IAC9B,2BAA2B,EAAE,MAAM,CAAC;IACpC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,yBAAyB,EAAE,MAAM,CAAC;IAClC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,8BAA8B,EAAE,MAAM,CAAC;IACvC,oBAAoB,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAClD,8BAA8B,EAAE,MAAM,CAAC;CACvC;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAmB,SAAQ,sBAAsB;IACjE,QAAQ,CAAC,oBAAoB,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IACnD,QAAQ,CAAC,MAAM,EAAE,0BAA0B,CAAC;IAC5C,QAAQ,CAAC,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;IACzD,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,yBAAyB,EAAE,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IACjE,wBAAwB,EAAE,MAAM,CAAC;CACjC;AAID,gBAAgB;AAChB,wBAAgB,wBAAwB,CACvC,IAAI,EAAE,sBAAsB,GAC1B,kBAAkB,CAuBpB;AAED,gBAAgB;AAChB,wBAAsB,wBAAwB,CAC7C,KAAK,EAAE,kBAAkB,GACvB,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAkDhC"}
|
|
@@ -39,6 +39,30 @@ export async function recoverStaleRuntimeState(state) {
|
|
|
39
39
|
recordRuntimeReset("pool-exhausted-no-account");
|
|
40
40
|
const reloaded = await AccountManager.loadFromDisk();
|
|
41
41
|
reloaded.setRoutingMutexMode(state.routingMutexMode);
|
|
42
|
+
// Wipe per-account cooldowns and rate-limit windows on the freshly
|
|
43
|
+
// reloaded pool. `resetVolatileRuntimeState` above only cleared global
|
|
44
|
+
// singletons (trackers, circuit breakers); the per-account transient
|
|
45
|
+
// state is serialized to disk, so loadFromDisk restores the same state
|
|
46
|
+
// that wedged the pool. Clearing it here gives recovery a real clean
|
|
47
|
+
// slate before any request can pick up the manager (issue #606). Runs
|
|
48
|
+
// before the `state.activeAccountManager` assignment so no concurrent
|
|
49
|
+
// request can observe the reloaded manager with stale state.
|
|
50
|
+
//
|
|
51
|
+
// This also drops still-future rate-limit windows from genuine upstream
|
|
52
|
+
// 429s, not just stale ones from a dead prior process. That is the
|
|
53
|
+
// intended trade-off: recovery only runs at full pool exhaustion, where
|
|
54
|
+
// the alternative is a hard 503 anyway, and the 1s reload dedupe bounds
|
|
55
|
+
// re-probing to ~1/sec — the upstream simply re-429s and re-populates the
|
|
56
|
+
// window until the next exhaustion. Availability is preferred over
|
|
57
|
+
// honoring backoff in this already-degraded state.
|
|
58
|
+
reloaded.clearAccountTransientState();
|
|
59
|
+
// Force the cleared snapshot to disk now rather than waiting out the
|
|
60
|
+
// debounce window inside clearAccountTransientState. If the process
|
|
61
|
+
// exited during that window the next startup would reload the wedged
|
|
62
|
+
// snapshot; flushing here makes the "next reload starts clean" guarantee
|
|
63
|
+
// durable across a restart, not just best-effort. Recovery is rare
|
|
64
|
+
// (full-pool exhaustion), so the extra synchronous write is cheap.
|
|
65
|
+
await reloaded.flushPendingSave();
|
|
42
66
|
state.activeAccountManager = reloaded;
|
|
43
67
|
state.knownAccountManagers.add(reloaded);
|
|
44
68
|
state.lastStaleRuntimeReloadAt = Date.now();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { RuntimeObservabilitySnapshot } from "./runtime-observability.js";
|
|
2
2
|
import type { AppBindRouterStatus } from "./app-bind.js";
|
|
3
3
|
import type { AccountStorageV3 } from "../storage.js";
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
type RuntimeCurrentAccountSource = "runtime-observability" | "app-bind" | "app-helper";
|
|
5
|
+
type RuntimeCurrentAccountMatch = "account-id" | "email" | "index";
|
|
6
6
|
export type AccountCurrentMarker = "current" | "in-use" | "selected";
|
|
7
7
|
export interface RuntimeAccountSignal {
|
|
8
8
|
source: RuntimeCurrentAccountSource;
|
|
@@ -31,7 +31,6 @@ export interface RuntimeCurrentAccountSources {
|
|
|
31
31
|
appBindStatus?: AppBindRouterStatus | null;
|
|
32
32
|
appHelperStatus?: RuntimeAccountSignal | null;
|
|
33
33
|
}
|
|
34
|
-
export declare const RUNTIME_CURRENT_ACCOUNT_MAX_AGE_MS: number;
|
|
35
34
|
export interface AppRuntimeHelperAccountStatus {
|
|
36
35
|
kind: string | null;
|
|
37
36
|
state: string | null;
|
|
@@ -49,4 +48,5 @@ export declare function readAppRuntimeHelperAccountSignal(): RuntimeAccountSigna
|
|
|
49
48
|
export declare function resolveRuntimeCurrentAccount(storage: AccountStorageV3, sources: RuntimeCurrentAccountSources, options?: RuntimeCurrentAccountOptions): RuntimeCurrentAccountSelection | null;
|
|
50
49
|
export declare function resolveAccountCurrentMarkers(index: number, storedCurrentIndex: number, runtimeCurrent: RuntimeCurrentAccountSelection | null): AccountCurrentMarker[];
|
|
51
50
|
export declare function isDisplayCurrentAccount(index: number, storedCurrentIndex: number, runtimeCurrent: RuntimeCurrentAccountSelection | null): boolean;
|
|
51
|
+
export {};
|
|
52
52
|
//# sourceMappingURL=runtime-current-account.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-current-account.d.ts","sourceRoot":"","sources":["../../../lib/runtime/runtime-current-account.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAGtD,
|
|
1
|
+
{"version":3,"file":"runtime-current-account.d.ts","sourceRoot":"","sources":["../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E } from "../runtime-constants.js";
|
|
5
5
|
import { getCodexMultiAuthDir } from "../runtime-paths.js";
|
|
6
6
|
import { isRecord } from "../utils.js";
|
|
7
|
-
|
|
7
|
+
const RUNTIME_CURRENT_ACCOUNT_MAX_AGE_MS = 24 * 60 * 60 * 1000;
|
|
8
8
|
const APP_RUNTIME_HELPER_KIND = "codex-app-runtime-rotation-helper";
|
|
9
9
|
const MAX_STATUS_FILE_BYTES = 1024 * 1024; // 1 MB sanity cap
|
|
10
10
|
function normalizeString(value) {
|