codex-multi-auth 2.9.1 → 2.10.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 +1 -1
- package/README.md +2 -1
- package/config/schema/config.schema.json +23 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +62 -2
- package/dist/lib/accounts.d.ts +25 -1
- package/dist/lib/accounts.d.ts.map +1 -1
- package/dist/lib/accounts.js +26 -6
- package/dist/lib/codex-manager/backend-settings-helpers.d.ts.map +1 -1
- package/dist/lib/codex-manager/backend-settings-helpers.js +10 -1
- package/dist/lib/codex-manager/backend-settings-schema.d.ts +18 -0
- package/dist/lib/codex-manager/backend-settings-schema.d.ts.map +1 -1
- package/dist/lib/codex-manager/backend-settings-schema.js +19 -0
- package/dist/lib/codex-manager/experimental-settings-prompt.d.ts +1 -0
- package/dist/lib/codex-manager/experimental-settings-prompt.d.ts.map +1 -1
- package/dist/lib/codex-manager/experimental-settings-prompt.js +12 -0
- package/dist/lib/codex-manager/experimental-settings-schema.d.ts +2 -0
- package/dist/lib/codex-manager/experimental-settings-schema.d.ts.map +1 -1
- package/dist/lib/codex-manager/experimental-settings-schema.js +2 -0
- package/dist/lib/config.d.ts +29 -0
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +88 -0
- package/dist/lib/context-budget/model-context-windows.d.ts +25 -0
- package/dist/lib/context-budget/model-context-windows.d.ts.map +1 -0
- package/dist/lib/context-budget/model-context-windows.js +118 -0
- package/dist/lib/context-budget-guard.d.ts +100 -0
- package/dist/lib/context-budget-guard.d.ts.map +1 -0
- package/dist/lib/context-budget-guard.js +183 -0
- package/dist/lib/context-budget-response.d.ts +25 -0
- package/dist/lib/context-budget-response.d.ts.map +1 -0
- package/dist/lib/context-budget-response.js +57 -0
- package/dist/lib/context-overflow.d.ts.map +1 -1
- package/dist/lib/context-overflow.js +5 -60
- package/dist/lib/request/rate-limit-decision.d.ts +4 -5
- package/dist/lib/request/rate-limit-decision.d.ts.map +1 -1
- package/dist/lib/request/rate-limit-decision.js +33 -4
- package/dist/lib/request/response-metadata.d.ts.map +1 -1
- package/dist/lib/request/response-metadata.js +1 -0
- package/dist/lib/request/stream-failover-runtime.d.ts +3 -1
- package/dist/lib/request/stream-failover-runtime.d.ts.map +1 -1
- package/dist/lib/request/stream-failover-runtime.js +7 -2
- package/dist/lib/runtime/context-budget-settings.d.ts +13 -0
- package/dist/lib/runtime/context-budget-settings.d.ts.map +1 -0
- package/dist/lib/runtime/context-budget-settings.js +8 -0
- package/dist/lib/runtime/loader-setup.d.ts +1 -0
- package/dist/lib/runtime/loader-setup.d.ts.map +1 -1
- package/dist/lib/runtime/loader-setup.js +1 -0
- package/dist/lib/runtime/rotation-account-selection.d.ts +23 -0
- package/dist/lib/runtime/rotation-account-selection.d.ts.map +1 -1
- package/dist/lib/runtime/rotation-account-selection.js +15 -6
- package/dist/lib/runtime/rotation-proxy-state.d.ts +2 -0
- package/dist/lib/runtime/rotation-proxy-state.d.ts.map +1 -1
- package/dist/lib/runtime/rotation-server-types.d.ts +11 -0
- package/dist/lib/runtime/rotation-server-types.d.ts.map +1 -1
- package/dist/lib/runtime-rotation-proxy.d.ts.map +1 -1
- package/dist/lib/runtime-rotation-proxy.js +251 -43
- package/dist/lib/schemas.d.ts +4 -0
- package/dist/lib/schemas.d.ts.map +1 -1
- package/dist/lib/schemas.js +10 -0
- package/dist/lib/synthetic-response.d.ts +31 -0
- package/dist/lib/synthetic-response.d.ts.map +1 -0
- package/dist/lib/synthetic-response.js +79 -0
- package/dist/lib/ui/ui-copy.d.ts +2 -1
- package/dist/lib/ui/ui-copy.d.ts.map +1 -1
- package/dist/lib/ui/ui-copy.js +2 -1
- package/package.json +2 -2
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* This prevents the host session from getting locked on 400 errors.
|
|
7
7
|
*/
|
|
8
8
|
import { logDebug } from "./logger.js";
|
|
9
|
+
import { createSyntheticSseResponse } from "./synthetic-response.js";
|
|
9
10
|
/**
|
|
10
11
|
* Error patterns that indicate context overflow
|
|
11
12
|
*/
|
|
@@ -54,67 +55,11 @@ Alternatively, you can switch to a model with a larger context window.`;
|
|
|
54
55
|
* (recovery-01). Returns 200 OK so the host session does not lock on the 400.
|
|
55
56
|
*/
|
|
56
57
|
export function createContextOverflowResponse(model = "unknown") {
|
|
57
|
-
|
|
58
|
-
.toString(36)
|
|
59
|
-
.slice(2, 8)}`;
|
|
60
|
-
const responseId = `resp_synthetic_overflow_${Date.now()}_${Math.random()
|
|
61
|
-
.toString(36)
|
|
62
|
-
.slice(2, 8)}`;
|
|
63
|
-
const events = [];
|
|
64
|
-
const push = (type, payload) => {
|
|
65
|
-
events.push(`event: ${type}\ndata: ${JSON.stringify({ type, ...payload })}\n\n`);
|
|
66
|
-
};
|
|
67
|
-
const baseResponse = {
|
|
68
|
-
id: responseId,
|
|
69
|
-
object: "response",
|
|
58
|
+
return createSyntheticSseResponse({
|
|
70
59
|
model,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
// output item (assistant message) added
|
|
75
|
-
push("response.output_item.added", {
|
|
76
|
-
output_index: 0,
|
|
77
|
-
item: {
|
|
78
|
-
id: messageId,
|
|
79
|
-
type: "message",
|
|
80
|
-
role: "assistant",
|
|
81
|
-
content: [],
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
// streamed text + its terminal "done" carrying the final canonical text
|
|
85
|
-
push("response.output_text.delta", {
|
|
86
|
-
output_index: 0,
|
|
87
|
-
content_index: 0,
|
|
88
|
-
delta: CONTEXT_OVERFLOW_MESSAGE,
|
|
89
|
-
});
|
|
90
|
-
push("response.output_text.done", {
|
|
91
|
-
output_index: 0,
|
|
92
|
-
content_index: 0,
|
|
93
|
-
text: CONTEXT_OVERFLOW_MESSAGE,
|
|
94
|
-
});
|
|
95
|
-
// terminal response.completed with the full output array
|
|
96
|
-
push("response.completed", {
|
|
97
|
-
response: {
|
|
98
|
-
...baseResponse,
|
|
99
|
-
status: "completed",
|
|
100
|
-
output: [
|
|
101
|
-
{
|
|
102
|
-
id: messageId,
|
|
103
|
-
type: "message",
|
|
104
|
-
role: "assistant",
|
|
105
|
-
content: [{ type: "output_text", text: CONTEXT_OVERFLOW_MESSAGE }],
|
|
106
|
-
},
|
|
107
|
-
],
|
|
108
|
-
usage: { input_tokens: 0, output_tokens: 0, total_tokens: 0 },
|
|
109
|
-
},
|
|
110
|
-
});
|
|
111
|
-
return new Response(events.join(""), {
|
|
112
|
-
status: 200,
|
|
113
|
-
headers: {
|
|
114
|
-
"Content-Type": "text/event-stream",
|
|
115
|
-
"X-Codex-Plugin-Synthetic": "true",
|
|
116
|
-
"X-Codex-Plugin-Error-Type": "context_overflow",
|
|
117
|
-
},
|
|
60
|
+
message: CONTEXT_OVERFLOW_MESSAGE,
|
|
61
|
+
idPrefix: "synthetic_overflow",
|
|
62
|
+
errorType: "context_overflow",
|
|
118
63
|
});
|
|
119
64
|
}
|
|
120
65
|
/**
|
|
@@ -60,11 +60,10 @@ export interface PinnedUnavailableContext {
|
|
|
60
60
|
recoveryBound?: "rate-limit" | "other" | "unknown";
|
|
61
61
|
/**
|
|
62
62
|
* The pin's CURRENT runtime skip reason, re-read from account state at the
|
|
63
|
-
* moment the 503 is built. `accountSkipReasons` holds the
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* did not re-read runtime state.
|
|
63
|
+
* moment the 503 is built. `accountSkipReasons` holds the most recent
|
|
64
|
+
* selection or attempt verdict, which can be less specific than a cooldown
|
|
65
|
+
* or breaker created later in the same pass. Omitted when the caller did not
|
|
66
|
+
* re-read runtime state.
|
|
68
67
|
*/
|
|
69
68
|
currentSkipReason?: string | null;
|
|
70
69
|
now?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate-limit-decision.d.ts","sourceRoot":"","sources":["../../../lib/request/rate-limit-decision.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,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CAE1E;AAED;;;;;;GAMG;AACH,MAAM,WAAW,0BAA0B;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,kCAAkC,CAAC;IACzC,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,mEAAmE;IACnE,UAAU,EAAE,QAAQ,GAAG,QAAQ,GAAG,IAAI,CAAC;IACvC,2EAA2E;IAC3E,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7C;AAQD,MAAM,WAAW,wBAAwB;IACxC;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,IAAI,CAAC;IACvC,uEAAuE;IACvE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B;;;;;;;;;;;;;;;;OAgBG;IACH,aAAa,CAAC,EAAE,YAAY,GAAG,OAAO,GAAG,SAAS,CAAC;IACnD;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,GAAG,CAAC,EAAE,MAAM,CAAC;CACb;AAwKD,wBAAgB,+BAA+B,CAC9C,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACtC,kBAAkB,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EAC/C,OAAO,CAAC,EAAE,wBAAwB,GAChC,0BAA0B,CA8E5B"}
|
|
@@ -232,6 +232,34 @@ const BLOCKER_DESCRIPTIONS = new Map([
|
|
|
232
232
|
description,
|
|
233
233
|
]),
|
|
234
234
|
]);
|
|
235
|
+
// Retry-budget exhaustion can end immediately after an upstream attempt,
|
|
236
|
+
// before selection gets another pass to translate that attempt into a live
|
|
237
|
+
// cooldown or breaker. Keep these final verdicts operator-facing without
|
|
238
|
+
// treating them as live blockers: a concurrently opened circuit or cooldown
|
|
239
|
+
// must still take precedence in buildPinnedUnavailableErrorBody below.
|
|
240
|
+
const ATTEMPT_VERDICT_DESCRIPTIONS = new Map([
|
|
241
|
+
[
|
|
242
|
+
"auth-failure",
|
|
243
|
+
{
|
|
244
|
+
parenthetical: "authentication failure",
|
|
245
|
+
deadlineNoun: "available-again",
|
|
246
|
+
},
|
|
247
|
+
],
|
|
248
|
+
[
|
|
249
|
+
"network-error",
|
|
250
|
+
{
|
|
251
|
+
parenthetical: "upstream network error",
|
|
252
|
+
deadlineNoun: "available-again",
|
|
253
|
+
},
|
|
254
|
+
],
|
|
255
|
+
[
|
|
256
|
+
"server-error",
|
|
257
|
+
{
|
|
258
|
+
parenthetical: "upstream server error",
|
|
259
|
+
deadlineNoun: "available-again",
|
|
260
|
+
},
|
|
261
|
+
],
|
|
262
|
+
]);
|
|
235
263
|
/** Whether the sentence has real wording for this token, or must echo it raw. */
|
|
236
264
|
function isDescribedBlocker(skipReason) {
|
|
237
265
|
return BLOCKER_DESCRIPTIONS.has(skipReason);
|
|
@@ -252,7 +280,8 @@ function describePinnedBlocker(skipReason, rateLimitBoundsRecovery) {
|
|
|
252
280
|
deadline: DEADLINE_SENTENCES["available-again"],
|
|
253
281
|
};
|
|
254
282
|
}
|
|
255
|
-
const described = BLOCKER_DESCRIPTIONS.get(skipReason)
|
|
283
|
+
const described = BLOCKER_DESCRIPTIONS.get(skipReason) ??
|
|
284
|
+
ATTEMPT_VERDICT_DESCRIPTIONS.get(skipReason);
|
|
256
285
|
if (described === undefined) {
|
|
257
286
|
// Permanent blockers never reach the deadline clause (the call site
|
|
258
287
|
// suppresses their reset time), and future or internal tokens stay
|
|
@@ -311,9 +340,9 @@ export function buildPinnedUnavailableErrorBody(pinnedIndex, accountSkipReasons,
|
|
|
311
340
|
// recorded verdict that names a real blocker class wins, because the
|
|
312
341
|
// selection-only classes ("missing", "policy-blocked") have no
|
|
313
342
|
// runtime-state equivalent and would be lost. Otherwise the re-read runtime
|
|
314
|
-
// state is the truth and the recorded token is the
|
|
315
|
-
//
|
|
316
|
-
//
|
|
343
|
+
// state is the truth and the recorded token is only the earlier attempt
|
|
344
|
+
// verdict. This also preserves compatibility with legacy callers that may
|
|
345
|
+
// still supply an internal bookkeeping token.
|
|
317
346
|
const describedSkipReason = skipReason !== null && isDescribedBlocker(skipReason)
|
|
318
347
|
? skipReason
|
|
319
348
|
: context?.currentSkipReason ?? skipReason;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response-metadata.d.ts","sourceRoot":"","sources":["../../../lib/request/response-metadata.ts"],"names":[],"mappings":"AASA,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAyBrE;AAED,wBAAgB,6BAA6B,CAC5C,OAAO,EAAE,OAAO,GACd,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"response-metadata.d.ts","sourceRoot":"","sources":["../../../lib/request/response-metadata.ts"],"names":[],"mappings":"AASA,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAyBrE;AAED,wBAAgB,6BAA6B,CAC5C,OAAO,EAAE,OAAO,GACd,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA2BxB"}
|
|
@@ -45,6 +45,7 @@ export function sanitizeResponseHeadersForLog(headers) {
|
|
|
45
45
|
"x-codex-secondary-window-minutes",
|
|
46
46
|
"x-codex-secondary-reset-at",
|
|
47
47
|
"x-codex-secondary-reset-after-seconds",
|
|
48
|
+
"x-codex-context-budget-percent",
|
|
48
49
|
"retry-after",
|
|
49
50
|
"x-ratelimit-reset",
|
|
50
51
|
"x-ratelimit-reset-requests",
|
|
@@ -11,5 +11,7 @@ export declare function forwardStreamingResponse(upstream: Response, res: Server
|
|
|
11
11
|
* chunk and is called before the write, so a slow observer delays the
|
|
12
12
|
* forward. Implementations are expected to swallow their own errors.
|
|
13
13
|
*/
|
|
14
|
-
onChunk?: (chunk: Uint8Array) => void
|
|
14
|
+
onChunk?: (chunk: Uint8Array) => void,
|
|
15
|
+
/** Additional response headers, applied after (so they can override) the forwarded upstream ones. */
|
|
16
|
+
extraHeaders?: Record<string, string>): Promise<boolean>;
|
|
15
17
|
//# sourceMappingURL=stream-failover-runtime.d.ts.map
|
|
@@ -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;AAChD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AAEtF,eAAO,MAAM,kBAAkB,aAW7B,CAAC;AAWH,wBAAgB,wBAAwB,CAAC,eAAe,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAUzF;AAED,wBAAsB,WAAW,CAAC,CAAC,EAClC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,IAAI,EACrB,OAAO,EAAE,MAAM,GACb,OAAO,CAAC,CAAC,CAAC,CAmBZ;AAED,wBAAsB,aAAa,CAClC,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,MAAM,EACjB,QAAQ,SAAc,GACpB,OAAO,CAAC,MAAM,CAAC,CAuDjB;AAoBD,wBAAsB,wBAAwB,CAC7C,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,cAAc,EACnB,MAAM,EAAE,0BAA0B,EAClC,aAAa,EAAE,MAAM,IAAI,EACzB,oBAAoB,EAAE,MAAM;AAC5B;;;;;GAKG;AACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GACnC,OAAO,CAAC,OAAO,CAAC,CAsDlB"}
|
|
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;AAChD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qCAAqC,CAAC;AAEtF,eAAO,MAAM,kBAAkB,aAW7B,CAAC;AAWH,wBAAgB,wBAAwB,CAAC,eAAe,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAUzF;AAED,wBAAsB,WAAW,CAAC,CAAC,EAClC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,IAAI,EACrB,OAAO,EAAE,MAAM,GACb,OAAO,CAAC,CAAC,CAAC,CAmBZ;AAED,wBAAsB,aAAa,CAClC,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,MAAM,EACjB,QAAQ,SAAc,GACpB,OAAO,CAAC,MAAM,CAAC,CAuDjB;AAoBD,wBAAsB,wBAAwB,CAC7C,QAAQ,EAAE,QAAQ,EAClB,GAAG,EAAE,cAAc,EACnB,MAAM,EAAE,0BAA0B,EAClC,aAAa,EAAE,MAAM,IAAI,EACzB,oBAAoB,EAAE,MAAM;AAC5B;;;;;GAKG;AACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI;AACrC,qGAAqG;AACrG,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GACnC,OAAO,CAAC,OAAO,CAAC,CAsDlB"}
|
|
@@ -135,9 +135,14 @@ export async function forwardStreamingResponse(upstream, res, status, onStreamEr
|
|
|
135
135
|
* chunk and is called before the write, so a slow observer delays the
|
|
136
136
|
* forward. Implementations are expected to swallow their own errors.
|
|
137
137
|
*/
|
|
138
|
-
onChunk
|
|
138
|
+
onChunk,
|
|
139
|
+
/** Additional response headers, applied after (so they can override) the forwarded upstream ones. */
|
|
140
|
+
extraHeaders) {
|
|
139
141
|
status.streamsStarted += 1;
|
|
140
|
-
res.writeHead(upstream.status,
|
|
142
|
+
res.writeHead(upstream.status, {
|
|
143
|
+
...responseHeadersForClient(upstream.headers),
|
|
144
|
+
...extraHeaders,
|
|
145
|
+
});
|
|
141
146
|
if (!upstream.body) {
|
|
142
147
|
res.end();
|
|
143
148
|
return true;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare function applyContextBudgetGuardSettingsFromConfig(pluginConfig: ReturnType<typeof import("../config.js").loadPluginConfig>, deps: {
|
|
2
|
+
configure: (options: {
|
|
3
|
+
enabled: boolean;
|
|
4
|
+
softPercent: number;
|
|
5
|
+
hardPercent: number;
|
|
6
|
+
modelWindowOverrides: Record<string, number>;
|
|
7
|
+
}) => void;
|
|
8
|
+
getContextBudgetGuardEnabled: (config: ReturnType<typeof import("../config.js").loadPluginConfig>) => boolean;
|
|
9
|
+
getContextBudgetGuardSoftPercent: (config: ReturnType<typeof import("../config.js").loadPluginConfig>) => number;
|
|
10
|
+
getContextBudgetGuardHardPercent: (config: ReturnType<typeof import("../config.js").loadPluginConfig>) => number;
|
|
11
|
+
getContextBudgetGuardModelWindowOverrides: (config: ReturnType<typeof import("../config.js").loadPluginConfig>) => Record<string, number>;
|
|
12
|
+
}): void;
|
|
13
|
+
//# sourceMappingURL=context-budget-settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-budget-settings.d.ts","sourceRoot":"","sources":["../../../lib/runtime/context-budget-settings.ts"],"names":[],"mappings":"AAAA,wBAAgB,yCAAyC,CACxD,YAAY,EAAE,UAAU,CAAC,cAAc,cAAc,EAAE,gBAAgB,CAAC,EACxE,IAAI,EAAE;IACL,SAAS,EAAE,CAAC,OAAO,EAAE;QACpB,OAAO,EAAE,OAAO,CAAC;QACjB,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC;QACpB,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAC7C,KAAK,IAAI,CAAC;IACX,4BAA4B,EAAE,CAC7B,MAAM,EAAE,UAAU,CAAC,cAAc,cAAc,EAAE,gBAAgB,CAAC,KAC9D,OAAO,CAAC;IACb,gCAAgC,EAAE,CACjC,MAAM,EAAE,UAAU,CAAC,cAAc,cAAc,EAAE,gBAAgB,CAAC,KAC9D,MAAM,CAAC;IACZ,gCAAgC,EAAE,CACjC,MAAM,EAAE,UAAU,CAAC,cAAc,cAAc,EAAE,gBAAgB,CAAC,KAC9D,MAAM,CAAC;IACZ,yCAAyC,EAAE,CAC1C,MAAM,EAAE,UAAU,CAAC,cAAc,cAAc,EAAE,gBAAgB,CAAC,KAC9D,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5B,GACC,IAAI,CAQN"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function applyContextBudgetGuardSettingsFromConfig(pluginConfig, deps) {
|
|
2
|
+
deps.configure({
|
|
3
|
+
enabled: deps.getContextBudgetGuardEnabled(pluginConfig),
|
|
4
|
+
softPercent: deps.getContextBudgetGuardSoftPercent(pluginConfig),
|
|
5
|
+
hardPercent: deps.getContextBudgetGuardHardPercent(pluginConfig),
|
|
6
|
+
modelWindowOverrides: deps.getContextBudgetGuardModelWindowOverrides(pluginConfig),
|
|
7
|
+
});
|
|
8
|
+
}
|
|
@@ -5,5 +5,6 @@ export declare function applyLoaderRuntimeSetup(params: {
|
|
|
5
5
|
ensureSessionAffinity: (pluginConfig: ReturnType<typeof import("../config.js").loadPluginConfig>) => void;
|
|
6
6
|
ensureRefreshGuardian: (pluginConfig: ReturnType<typeof import("../config.js").loadPluginConfig>) => void;
|
|
7
7
|
applyPreemptiveQuotaSettings: (pluginConfig: ReturnType<typeof import("../config.js").loadPluginConfig>) => void;
|
|
8
|
+
applyContextBudgetGuardSettings: (pluginConfig: ReturnType<typeof import("../config.js").loadPluginConfig>) => void;
|
|
8
9
|
}): void;
|
|
9
10
|
//# sourceMappingURL=loader-setup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader-setup.d.ts","sourceRoot":"","sources":["../../../lib/runtime/loader-setup.ts"],"names":[],"mappings":"AAAA,wBAAgB,uBAAuB,CAAC,MAAM,EAAE;IAC/C,YAAY,EAAE,UAAU,CAAC,cAAc,cAAc,EAAE,gBAAgB,CAAC,CAAC;IACzE,wBAAwB,EAAE,CACzB,YAAY,EAAE,UAAU,CAAC,cAAc,cAAc,EAAE,gBAAgB,CAAC,KACpE,IAAI,CAAC;IACV,wBAAwB,EAAE,CACzB,YAAY,EAAE,UAAU,CAAC,cAAc,cAAc,EAAE,gBAAgB,CAAC,KACpE,IAAI,CAAC;IACV,qBAAqB,EAAE,CACtB,YAAY,EAAE,UAAU,CAAC,cAAc,cAAc,EAAE,gBAAgB,CAAC,KACpE,IAAI,CAAC;IACV,qBAAqB,EAAE,CACtB,YAAY,EAAE,UAAU,CAAC,cAAc,cAAc,EAAE,gBAAgB,CAAC,KACpE,IAAI,CAAC;IACV,4BAA4B,EAAE,CAC7B,YAAY,EAAE,UAAU,CAAC,cAAc,cAAc,EAAE,gBAAgB,CAAC,KACpE,IAAI,CAAC;CACV,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"loader-setup.d.ts","sourceRoot":"","sources":["../../../lib/runtime/loader-setup.ts"],"names":[],"mappings":"AAAA,wBAAgB,uBAAuB,CAAC,MAAM,EAAE;IAC/C,YAAY,EAAE,UAAU,CAAC,cAAc,cAAc,EAAE,gBAAgB,CAAC,CAAC;IACzE,wBAAwB,EAAE,CACzB,YAAY,EAAE,UAAU,CAAC,cAAc,cAAc,EAAE,gBAAgB,CAAC,KACpE,IAAI,CAAC;IACV,wBAAwB,EAAE,CACzB,YAAY,EAAE,UAAU,CAAC,cAAc,cAAc,EAAE,gBAAgB,CAAC,KACpE,IAAI,CAAC;IACV,qBAAqB,EAAE,CACtB,YAAY,EAAE,UAAU,CAAC,cAAc,cAAc,EAAE,gBAAgB,CAAC,KACpE,IAAI,CAAC;IACV,qBAAqB,EAAE,CACtB,YAAY,EAAE,UAAU,CAAC,cAAc,cAAc,EAAE,gBAAgB,CAAC,KACpE,IAAI,CAAC;IACV,4BAA4B,EAAE,CAC7B,YAAY,EAAE,UAAU,CAAC,cAAc,cAAc,EAAE,gBAAgB,CAAC,KACpE,IAAI,CAAC;IACV,+BAA+B,EAAE,CAChC,YAAY,EAAE,UAAU,CAAC,cAAc,cAAc,EAAE,gBAAgB,CAAC,KACpE,IAAI,CAAC;CACV,GAAG,IAAI,CAOP"}
|
|
@@ -4,4 +4,5 @@ export function applyLoaderRuntimeSetup(params) {
|
|
|
4
4
|
params.ensureSessionAffinity(params.pluginConfig);
|
|
5
5
|
params.ensureRefreshGuardian(params.pluginConfig);
|
|
6
6
|
params.applyPreemptiveQuotaSettings(params.pluginConfig);
|
|
7
|
+
params.applyContextBudgetGuardSettings(params.pluginConfig);
|
|
7
8
|
}
|
|
@@ -34,5 +34,28 @@ export declare function chooseAccount(params: {
|
|
|
34
34
|
stickyBoostByAccount?: Record<number, number>;
|
|
35
35
|
pidOffsetEnabled?: boolean;
|
|
36
36
|
schedulingStrategy?: "hybrid" | "sequential";
|
|
37
|
+
/**
|
|
38
|
+
* Admit a pinned account that is only blocked by its own cooldown.
|
|
39
|
+
*
|
|
40
|
+
* Set by the proxy for the RETRY passes of one pinned request, never for
|
|
41
|
+
* the first pass. A cooldown exists to keep OTHER requests off a flaky
|
|
42
|
+
* account; a retry budget exists to give THIS request another attempt.
|
|
43
|
+
* Conflating them meant every transient branch cooled the pin down before
|
|
44
|
+
* the next selection pass and the budget could never be spent — a pinned
|
|
45
|
+
* request got exactly one upstream attempt under shipped defaults.
|
|
46
|
+
*
|
|
47
|
+
* Only the cooldown is waived. Rate limits, an open circuit, a disabled
|
|
48
|
+
* account, workspace and policy blocks all still reject the pin, and the
|
|
49
|
+
* cooldown itself stays on the account for everyone else and for the 503's
|
|
50
|
+
* `retry_after_ms`.
|
|
51
|
+
*
|
|
52
|
+
* One ordering note: `getAccountRuntimeSkipReason` reports the FIRST
|
|
53
|
+
* blocker it finds and checks the cooldown before the circuit, so an
|
|
54
|
+
* account that is both cooling down and circuit-open reads as a cooldown
|
|
55
|
+
* and is admitted here. That is safe: `consumeTokenWithReason` takes the
|
|
56
|
+
* breaker's admission slot immediately after selection and rejects it with
|
|
57
|
+
* `circuit-open`, which is also the more accurate skip reason to report.
|
|
58
|
+
*/
|
|
59
|
+
allowPinnedCooldown?: boolean;
|
|
37
60
|
}): ManagedAccount | null;
|
|
38
61
|
//# sourceMappingURL=rotation-account-selection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rotation-account-selection.d.ts","sourceRoot":"","sources":["../../../lib/runtime/rotation-account-selection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"rotation-account-selection.d.ts","sourceRoot":"","sources":["../../../lib/runtime/rotation-account-selection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAWnE;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE;IACrC,cAAc,EAAE,cAAc,CAAC;IAC/B,oBAAoB,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAClD,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,EAAE,WAAW,CAAC;IACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACtC,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAC;IACrC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,kBAAkB,CAAC,EAAE,QAAQ,GAAG,YAAY,CAAC;IAC7C;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC9B,GAAG,cAAc,GAAG,IAAI,CA0JxB"}
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a runtime skip reason is a cooldown, the one blocker a pinned
|
|
3
|
+
* retry may waive. `getManagedAccountRuntimeSkipReason` emits either the
|
|
4
|
+
* bare token or `cooling-down:<reason>`.
|
|
5
|
+
*/
|
|
6
|
+
function isCooldownReason(reason) {
|
|
7
|
+
return reason === "cooling-down" || reason.startsWith("cooling-down:");
|
|
8
|
+
}
|
|
1
9
|
/**
|
|
2
10
|
* `chooseAccount` is a SYNC selector that internally advances the rotation
|
|
3
11
|
* cursor (the session-affinity-preferred branch and the round-robin fallback
|
|
@@ -17,15 +25,16 @@
|
|
|
17
25
|
* `test/runtime-rotation-proxy.test.ts`.
|
|
18
26
|
*/
|
|
19
27
|
export function chooseAccount(params) {
|
|
20
|
-
const { accountManager, sessionAffinityStore, sessionKey, family, model, attemptedIndexes, now, policy, pinnedIndex, skipReasons, stickyBoostByAccount, pidOffsetEnabled, schedulingStrategy, } = params;
|
|
28
|
+
const { accountManager, sessionAffinityStore, sessionKey, family, model, attemptedIndexes, now, policy, pinnedIndex, skipReasons, stickyBoostByAccount, pidOffsetEnabled, schedulingStrategy, allowPinnedCooldown, } = params;
|
|
21
29
|
// Manual pin (from `codex-multi-auth switch <n>`) overrides every other
|
|
22
30
|
// selection signal. We do NOT call markSwitched here — the proxy must not
|
|
23
31
|
// clobber the pin set by the CLI. See issue #474.
|
|
24
32
|
if (typeof pinnedIndex === "number") {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
33
|
+
// A pin has no alternative account to rotate to. Re-evaluate its live
|
|
34
|
+
// blockers on every pass so a healthy account can use the caller's bounded
|
|
35
|
+
// retry budget; attemptedIndexes remains authoritative for unpinned pool
|
|
36
|
+
// selection below. The proxy also carries an absolute loop guard for retry
|
|
37
|
+
// branches that do not advance their transient-attempt counter.
|
|
29
38
|
if (pinnedIndex < 0 || pinnedIndex >= accountManager.getAccountCount()) {
|
|
30
39
|
skipReasons?.set(pinnedIndex, "missing");
|
|
31
40
|
return null;
|
|
@@ -40,7 +49,7 @@ export function chooseAccount(params) {
|
|
|
40
49
|
return null;
|
|
41
50
|
}
|
|
42
51
|
const reason = accountManager.getAccountRuntimeSkipReason(pinnedIndex, family, model);
|
|
43
|
-
if (reason) {
|
|
52
|
+
if (reason && !(allowPinnedCooldown === true && isCooldownReason(reason))) {
|
|
44
53
|
skipReasons?.set(pinnedIndex, reason);
|
|
45
54
|
return null;
|
|
46
55
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { AccountManager } from "../accounts.js";
|
|
2
|
+
import type { ContextBudgetGuard } from "../context-budget-guard.js";
|
|
2
3
|
import type { PreemptiveQuotaScheduler } from "../preemptive-quota-scheduler.js";
|
|
3
4
|
import type { RuntimeRotationProxyStatus } from "./rotation-server-types.js";
|
|
4
5
|
import type { SessionAffinityStore } from "../session-affinity.js";
|
|
@@ -29,6 +30,7 @@ export interface RotationProxyStateInit {
|
|
|
29
30
|
maxRequestBodyBytes: number;
|
|
30
31
|
quotaRemainingPercentThreshold: number;
|
|
31
32
|
preemptiveQuotaScheduler: PreemptiveQuotaScheduler;
|
|
33
|
+
contextBudgetGuard: ContextBudgetGuard;
|
|
32
34
|
sessionAffinityStore: SessionAffinityStore | null;
|
|
33
35
|
lastObservedAffinityGeneration: number;
|
|
34
36
|
/**
|
|
@@ -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;AAChD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAKjF,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;I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AAC;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"}
|
|
@@ -58,6 +58,17 @@ export interface RequestContext {
|
|
|
58
58
|
family: ModelFamily;
|
|
59
59
|
stream: boolean;
|
|
60
60
|
sessionKey: string | null;
|
|
61
|
+
/**
|
|
62
|
+
* `sessionKey` minus the `previous_response_id` fallback.
|
|
63
|
+
*
|
|
64
|
+
* `previous_response_id` changes on every turn, which is fine for session
|
|
65
|
+
* affinity (a fresh key just means "no pin yet") but wrong for anything
|
|
66
|
+
* that has to ACCUMULATE across turns: a per-turn key never finds what the
|
|
67
|
+
* previous turn stored, and leaves one dead map entry behind per request.
|
|
68
|
+
* Consumers that track state over a conversation use this instead, and
|
|
69
|
+
* no-op when it is null.
|
|
70
|
+
*/
|
|
71
|
+
stableSessionKey: string | null;
|
|
61
72
|
}
|
|
62
73
|
export type ExhaustionReason = "rate-limit" | "server-error" | "network-error" | "auth-failure" | "budget" | "deactivated" | "no-account";
|
|
63
74
|
export type RuntimeProxyHttpError = Error & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rotation-server-types.d.ts","sourceRoot":"","sources":["../../../lib/runtime/rotation-server-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,MAAM,WAAW,0BAA0B;IAC1C,IAAI,EAAE,MAAM,CAAC;IAC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,OAAO,CAAC;IACjB,MAAM,EAAE,KAAK,GAAG,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"rotation-server-types.d.ts","sourceRoot":"","sources":["../../../lib/runtime/rotation-server-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,MAAM,WAAW,0BAA0B;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,SAAS,EAAE,MAAM,0BAA0B,CAAC;IAC5C;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,MAAM,MAAM,CAAC;CACtC;AAED,MAAM,WAAW,0BAA0B;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC;AAED,MAAM,WAAW,2BAA2B;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,E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":3,"file":"runtime-rotation-proxy.d.ts","sourceRoot":"","sources":["../../lib/runtime-rotation-proxy.ts"],"names":[],"mappings":"AAGA,OAAO,EAIN,KAAK,cAAc,EACnB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"runtime-rotation-proxy.d.ts","sourceRoot":"","sources":["../../lib/runtime-rotation-proxy.ts"],"names":[],"mappings":"AAGA,OAAO,EAIN,KAAK,cAAc,EACnB,MAAM,eAAe,CAAC;AAkCvB,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAkDtE,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;AA8DtE,kFAAkF;AAClF,wBAAgB,qBAAqB,CACpC,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,WAAW,GAAG,OAAO,GAAG,cAAc,CAAC,GAAG;IACvE,gFAAgF;IAChF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB,EACD,MAAM,EAAE,WAAW,EACnB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GACnB,MAAM,CAmBR;AA8gBD;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CAC1C,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAA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