@qmediat.io/gemini-code-context-mcp 1.23.0 → 1.24.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 (76) hide show
  1. package/CHANGELOG.md +94 -1
  2. package/README.md +36 -227
  3. package/dist/auth/profile-loader.js +1 -1
  4. package/dist/auth/profile-loader.js.map +1 -1
  5. package/dist/cache/ttl-watcher.d.ts +29 -0
  6. package/dist/cache/ttl-watcher.d.ts.map +1 -1
  7. package/dist/cache/ttl-watcher.js +104 -43
  8. package/dist/cache/ttl-watcher.js.map +1 -1
  9. package/dist/gemini/client.d.ts +7 -0
  10. package/dist/gemini/client.d.ts.map +1 -1
  11. package/dist/gemini/client.js +8 -1
  12. package/dist/gemini/client.js.map +1 -1
  13. package/dist/gemini/long-decode.d.ts +153 -0
  14. package/dist/gemini/long-decode.d.ts.map +1 -0
  15. package/dist/gemini/long-decode.js +178 -0
  16. package/dist/gemini/long-decode.js.map +1 -0
  17. package/dist/gemini/model-registry.d.ts +2 -0
  18. package/dist/gemini/model-registry.d.ts.map +1 -1
  19. package/dist/gemini/model-registry.js +5 -2
  20. package/dist/gemini/model-registry.js.map +1 -1
  21. package/dist/gemini/models.d.ts.map +1 -1
  22. package/dist/gemini/models.js +1 -0
  23. package/dist/gemini/models.js.map +1 -1
  24. package/dist/gemini/retry.d.ts +8 -0
  25. package/dist/gemini/retry.d.ts.map +1 -1
  26. package/dist/gemini/retry.js +33 -1
  27. package/dist/gemini/retry.js.map +1 -1
  28. package/dist/tools/ask-agentic.tool.d.ts.map +1 -1
  29. package/dist/tools/ask-agentic.tool.js +10 -12
  30. package/dist/tools/ask-agentic.tool.js.map +1 -1
  31. package/dist/tools/ask.tool.d.ts.map +1 -1
  32. package/dist/tools/ask.tool.js +168 -379
  33. package/dist/tools/ask.tool.js.map +1 -1
  34. package/dist/tools/code.tool.d.ts +6 -0
  35. package/dist/tools/code.tool.d.ts.map +1 -1
  36. package/dist/tools/code.tool.js +146 -286
  37. package/dist/tools/code.tool.js.map +1 -1
  38. package/dist/tools/shared/abort-timeout.d.ts +6 -0
  39. package/dist/tools/shared/abort-timeout.d.ts.map +1 -1
  40. package/dist/tools/shared/abort-timeout.js +12 -0
  41. package/dist/tools/shared/abort-timeout.js.map +1 -1
  42. package/dist/tools/shared/call-ledger.d.ts +73 -0
  43. package/dist/tools/shared/call-ledger.d.ts.map +1 -0
  44. package/dist/tools/shared/call-ledger.js +115 -0
  45. package/dist/tools/shared/call-ledger.js.map +1 -0
  46. package/dist/tools/shared/context-decode.d.ts +77 -0
  47. package/dist/tools/shared/context-decode.d.ts.map +1 -0
  48. package/dist/tools/shared/context-decode.js +125 -0
  49. package/dist/tools/shared/context-decode.js.map +1 -0
  50. package/dist/tools/shared/continuation.d.ts +124 -0
  51. package/dist/tools/shared/continuation.d.ts.map +1 -0
  52. package/dist/tools/shared/continuation.js +302 -0
  53. package/dist/tools/shared/continuation.js.map +1 -0
  54. package/dist/tools/shared/dispatch-throttle.d.ts +43 -0
  55. package/dist/tools/shared/dispatch-throttle.d.ts.map +1 -0
  56. package/dist/tools/shared/dispatch-throttle.js +65 -0
  57. package/dist/tools/shared/dispatch-throttle.js.map +1 -0
  58. package/dist/tools/shared/settle-call.d.ts +63 -0
  59. package/dist/tools/shared/settle-call.d.ts.map +1 -0
  60. package/dist/tools/shared/settle-call.js +55 -0
  61. package/dist/tools/shared/settle-call.js.map +1 -0
  62. package/dist/tools/shared/stream-collector.d.ts +7 -0
  63. package/dist/tools/shared/stream-collector.d.ts.map +1 -1
  64. package/dist/tools/shared/stream-collector.js +5 -1
  65. package/dist/tools/shared/stream-collector.js.map +1 -1
  66. package/dist/tools/shared/thinking.d.ts +41 -11
  67. package/dist/tools/shared/thinking.d.ts.map +1 -1
  68. package/dist/tools/shared/thinking.js +62 -9
  69. package/dist/tools/shared/thinking.js.map +1 -1
  70. package/dist/types.d.ts +2 -0
  71. package/dist/types.d.ts.map +1 -1
  72. package/dist/utils/cost-estimator.d.ts +17 -0
  73. package/dist/utils/cost-estimator.d.ts.map +1 -1
  74. package/dist/utils/cost-estimator.js +15 -2
  75. package/dist/utils/cost-estimator.js.map +1 -1
  76. package/package.json +5 -3
@@ -0,0 +1,124 @@
1
+ /**
2
+ * One decode over one or more requests (Gemini 4 long decode, `src/gemini/long-decode.ts`).
3
+ *
4
+ * A request that stops with `finishReason: CONTINUATION` and a continuation token is followed by the same request
5
+ * with `continuationToken` set to the latest token — the payload is never changed and the text decoded so far is
6
+ * never appended to it. Every request is sent with `automaticContinuation: false`, so the SDK hands each request's
7
+ * end back here: this loop counts the requests, stops at the cap the budget reservation assumed, and
8
+ * never re-sends a request that already streamed (billed) work.
9
+ *
10
+ * The requests share the caller's abort signal and chunk callback, so `timeoutMs` covers the whole decode and the
11
+ * stall watchdog every gap between two chunks of a request; the caller's `afterRequest` hook pauses the watchdog
12
+ * between requests, as before the first. A request that made no progress (the same token again, nothing decoded)
13
+ * is not continued. The result is ONE response: the text and thought summary of every request in order, the usage
14
+ * summed over the requests (each one bills its own input again), the last request's finish reason.
15
+ */
16
+ import { type GenerateContentConfig, type GenerateContentParameters, type GenerateContentResponse, type GoogleGenAI } from '@google/genai';
17
+ import { type CollectedResponse, type StreamCollectorOptions } from './stream-collector.js';
18
+ /** The long-decode sentences of the `maxOutputTokens` description of `ask` and `code`. */
19
+ export declare const LONG_DECODE_CAP_DESCRIPTION = "On a model with long decode (Gemini 4: Argon, Carbon, Hydrogen) a value above its per-request limit is sent up to 1,048,576: a response that reaches the per-request limit continues in further requests until the model stops or the cap is reached, and the result's `continuationHops` counts them. Each continuation request bills the prompt again plus everything decoded before it, so a long decode costs more than one request; the budget reservation counts that input too. Use it when a high thinking level leaves no room for the answer (`errorCode: 'OUTPUT_CAP'`, thinking tokens count against the cap). An answer cut at the cap comes back with `truncated: true` and its `finishReason`.";
20
+ /** One request's stream, as the SDK opens it. */
21
+ type DecodeStream = AsyncGenerator<GenerateContentResponse>;
22
+ /** Opens one request of the decode: the first with no token, each continuation with the latest one. */
23
+ export type OpenDecodeRequest = (continuationToken: string | undefined) => Promise<DecodeStream>;
24
+ /** Where the decode stops at the latest: `OutputCap.maxRequests` requests, `OutputCap.effective` decoded tokens. */
25
+ export interface DecodeLimits {
26
+ readonly maxRequests: number;
27
+ readonly cap: number;
28
+ }
29
+ export interface DecodedResponse extends CollectedResponse {
30
+ /** The requests after the first one: 0 for a call that ended in one request. */
31
+ readonly continuationHops: number;
32
+ }
33
+ /** One decode as `ask` and `code` run it: the request, how its opening is retried, and the decode's limits. */
34
+ export interface DecodeCall {
35
+ readonly client: GoogleGenAI;
36
+ readonly model: string;
37
+ readonly contents: GenerateContentParameters['contents'];
38
+ /** The request config; `automaticContinuation: false` is set on it here, the abort signal is the collector's. */
39
+ readonly config: GenerateContentConfig;
40
+ /**
41
+ * SDK calls that OPEN each request (a failure before any response), network retries and reopenings after a refusal
42
+ * together; a stream that opened is never re-sent.
43
+ */
44
+ readonly openAttempts: number;
45
+ /** The log prefix of a retried opening (`ask`, `code (stale-cache retry)`). */
46
+ readonly label: string;
47
+ readonly limits: DecodeLimits;
48
+ /** The abort signal (required: it reaches every request), the thought and chunk callbacks. */
49
+ readonly collector: StreamCollectorOptions & {
50
+ readonly signal: AbortSignal;
51
+ };
52
+ /** Called each time a request's stream opened: from then on its work is billed. */
53
+ readonly onRequestOpened: () => void;
54
+ /** The call's record of its requests, kept across its decodes and its failures. */
55
+ readonly completed: CompletedRequests;
56
+ /** What the caller does between the requests (`DecodeHooks`, its `completed` is the one above). */
57
+ readonly hooks?: Omit<DecodeHooks, 'completed'>;
58
+ /**
59
+ * A refused continuation request is about to be reopened, its wait over: what the request holds for the window it
60
+ * is sent in (the per-minute reservation) is taken again. A rejection ends the decode before the reopening.
61
+ */
62
+ readonly beforeReopen?: () => Promise<void>;
63
+ }
64
+ /** What runs between the requests of a decode. */
65
+ export interface DecodeHooks {
66
+ /**
67
+ * The input the decode's first request is estimated to send: a request that reports no usage is billed at it, plus
68
+ * the tokens decoded before the request (`billedInputTokens`).
69
+ */
70
+ readonly firstRequestInput?: number;
71
+ /** The call's record of its requests: each one that streamed to its end goes in at once. */
72
+ readonly completed?: CompletedRequests;
73
+ /** A request streamed to its end, with the usage it reported. */
74
+ readonly afterRequest?: (usage: DecodeUsage | undefined) => void;
75
+ /**
76
+ * A continuation request is about to open, with the input it sends: the first request's prompt plus every token
77
+ * decoded so far. It may wait (the per-minute window); a rejection ends the decode before the request is sent.
78
+ */
79
+ readonly beforeContinuation?: (inputTokens: number) => Promise<void>;
80
+ }
81
+ /** The usage a request reports for itself. */
82
+ export type DecodeUsage = NonNullable<GenerateContentResponse['usageMetadata']>;
83
+ /**
84
+ * Every request of one call that streamed to its end. Each one is billed whatever becomes of the call — an answer,
85
+ * a later request that fails, a stale-cache retry that starts a new decode — so the call settles its ledger from
86
+ * here, never from the answer alone. A request that reported no input is billed at the input it was estimated to
87
+ * send (`billedInputTokens`).
88
+ */
89
+ export declare class CompletedRequests {
90
+ private readonly billed;
91
+ private total;
92
+ private completedInDecode;
93
+ private sentInDecode;
94
+ /** A new decode of the call starts: its requests are counted from zero. */
95
+ beginDecode(): void;
96
+ /** A request of the latest decode went to the API (its stream opened or the API refused it). */
97
+ sent(): void;
98
+ /** A request streamed to its end with `usage`; `inputEstimate` is the input it was estimated to send. */
99
+ record(usage: DecodeUsage | undefined, inputEstimate: number): void;
100
+ /** The requests of the call that completed, over all its decodes. */
101
+ get count(): number;
102
+ /** The requests of the latest decode that completed. */
103
+ get completedInLatestDecode(): number;
104
+ /**
105
+ * The continuation requests the latest decode sent: every request that went to the API, but the first — whether
106
+ * the decode answered, failed in a request, or stopped before the next request was sent.
107
+ */
108
+ continuationHops(): number;
109
+ /** Each counter summed over the completed requests that have it; `undefined` before any request completed. */
110
+ usage(): DecodeUsage | undefined;
111
+ }
112
+ /**
113
+ * Run the decode: each request opens through `withNetworkRetry` (only the opening is retried — a mid-stream
114
+ * failure would bill the work again), a continuation request refused at its opening is reopened with the same token
115
+ * (`reopenRefused`), and the requests are collected into one response.
116
+ */
117
+ export declare function runDecode(call: DecodeCall): Promise<DecodedResponse>;
118
+ /**
119
+ * Collect the decode: one request, plus a continuation request after each one that stopped with CONTINUATION.
120
+ * Each request that streamed to its end goes into `completed` at once: a later request's failure leaves it there.
121
+ */
122
+ export declare function collectDecode(open: OpenDecodeRequest, limits: DecodeLimits, opts: StreamCollectorOptions, hooks?: DecodeHooks): Promise<DecodedResponse>;
123
+ export {};
124
+ //# sourceMappingURL=continuation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"continuation.d.ts","sourceRoot":"","sources":["../../../src/tools/shared/continuation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,yBAAyB,EAC9B,KAAK,uBAAuB,EAC5B,KAAK,WAAW,EAEjB,MAAM,eAAe,CAAC;AAKvB,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,EAG5B,MAAM,uBAAuB,CAAC;AAG/B,0FAA0F;AAC1F,eAAO,MAAM,2BAA2B,krBACyoB,CAAC;AAElrB,iDAAiD;AACjD,KAAK,YAAY,GAAG,cAAc,CAAC,uBAAuB,CAAC,CAAC;AAE5D,uGAAuG;AACvG,MAAM,MAAM,iBAAiB,GAAG,CAAC,iBAAiB,EAAE,MAAM,GAAG,SAAS,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;AAEjG,oHAAoH;AACpH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,eAAgB,SAAQ,iBAAiB;IACxD,gFAAgF;IAChF,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;CACnC;AAED,+GAA+G;AAC/G,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,MAAM,EAAE,WAAW,CA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AAe,CAAC,CAAC,CAAC;AAEhF;;;;;GAKG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAC5C,OAAO,CAAC,KAAK,CAAK;IAClB,OAAO,CAAC,iBAAiB,CAAK;IAC9B,OAAO,CAAC,YAAY,CAAK;IAEzB,2EAA2E;IAC3E,WAAW,IAAI,IAAI,CAGlB;IAED,gGAAgG;IAChG,IAAI,IAAI,IAAI,CAEX;IAED,yGAAyG;IACzG,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,SAAS,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI,CAKlE;IAED,qEAAqE;IACrE,IAAI,KAAK,IAAI,MAAM,CAElB;IAED,wDAAwD;IACxD,IAAI,uBAAuB,IAAI,MAAM,CAEpC;IAED;;;OAGG;IACH,gBAAgB,IAAI,MAAM,CAEzB;IAED,8GAA8G;IAC9G,KAAK,IAAI,WAAW,GAAG,SAAS,CAE/B;CACF;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,eAAe,CAAC,CAmBpE;AAkHD;;;GAGG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,iBAAiB,EACvB,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,sBAAsB,EAC5B,KAAK,GAAE,WAAgB,GACtB,OAAO,CAAC,eAAe,CAAC,CAgB1B"}
@@ -0,0 +1,302 @@
1
+ /**
2
+ * One decode over one or more requests (Gemini 4 long decode, `src/gemini/long-decode.ts`).
3
+ *
4
+ * A request that stops with `finishReason: CONTINUATION` and a continuation token is followed by the same request
5
+ * with `continuationToken` set to the latest token — the payload is never changed and the text decoded so far is
6
+ * never appended to it. Every request is sent with `automaticContinuation: false`, so the SDK hands each request's
7
+ * end back here: this loop counts the requests, stops at the cap the budget reservation assumed, and
8
+ * never re-sends a request that already streamed (billed) work.
9
+ *
10
+ * The requests share the caller's abort signal and chunk callback, so `timeoutMs` covers the whole decode and the
11
+ * stall watchdog every gap between two chunks of a request; the caller's `afterRequest` hook pauses the watchdog
12
+ * between requests, as before the first. A request that made no progress (the same token again, nothing decoded)
13
+ * is not continued. The result is ONE response: the text and thought summary of every request in order, the usage
14
+ * summed over the requests (each one bills its own input again), the last request's finish reason.
15
+ */
16
+ import { FinishReason, } from '@google/genai';
17
+ import { abortableSleep, withNetworkRetry } from '../../gemini/retry.js';
18
+ import { logger } from '../../utils/logger.js';
19
+ import { billedInputTokens } from './call-ledger.js';
20
+ import { statusOf } from './service-tier.js';
21
+ import { THOUGHTS_SUMMARY_MAX_CHARS, collectStream, } from './stream-collector.js';
22
+ import { isGemini429, parseRetryDelayMs } from './throttle.js';
23
+ /** The long-decode sentences of the `maxOutputTokens` description of `ask` and `code`. */
24
+ export const LONG_DECODE_CAP_DESCRIPTION = "On a model with long decode (Gemini 4: Argon, Carbon, Hydrogen) a value above its per-request limit is sent up to 1,048,576: a response that reaches the per-request limit continues in further requests until the model stops or the cap is reached, and the result's `continuationHops` counts them. Each continuation request bills the prompt again plus everything decoded before it, so a long decode costs more than one request; the budget reservation counts that input too. Use it when a high thinking level leaves no room for the answer (`errorCode: 'OUTPUT_CAP'`, thinking tokens count against the cap). An answer cut at the cap comes back with `truncated: true` and its `finishReason`.";
25
+ /**
26
+ * Every request of one call that streamed to its end. Each one is billed whatever becomes of the call — an answer,
27
+ * a later request that fails, a stale-cache retry that starts a new decode — so the call settles its ledger from
28
+ * here, never from the answer alone. A request that reported no input is billed at the input it was estimated to
29
+ * send (`billedInputTokens`).
30
+ */
31
+ export class CompletedRequests {
32
+ billed = [];
33
+ total = 0;
34
+ completedInDecode = 0;
35
+ sentInDecode = 0;
36
+ /** A new decode of the call starts: its requests are counted from zero. */
37
+ beginDecode() {
38
+ this.completedInDecode = 0;
39
+ this.sentInDecode = 0;
40
+ }
41
+ /** A request of the latest decode went to the API (its stream opened or the API refused it). */
42
+ sent() {
43
+ this.sentInDecode += 1;
44
+ }
45
+ /** A request streamed to its end with `usage`; `inputEstimate` is the input it was estimated to send. */
46
+ record(usage, inputEstimate) {
47
+ const promptTokenCount = billedInputTokens(usage?.promptTokenCount, inputEstimate);
48
+ this.billed.push({ ...usage, promptTokenCount });
49
+ this.total += 1;
50
+ this.completedInDecode += 1;
51
+ }
52
+ /** The requests of the call that completed, over all its decodes. */
53
+ get count() {
54
+ return this.total;
55
+ }
56
+ /** The requests of the latest decode that completed. */
57
+ get completedInLatestDecode() {
58
+ return this.completedInDecode;
59
+ }
60
+ /**
61
+ * The continuation requests the latest decode sent: every request that went to the API, but the first — whether
62
+ * the decode answered, failed in a request, or stopped before the next request was sent.
63
+ */
64
+ continuationHops() {
65
+ return Math.max(0, this.sentInDecode - 1);
66
+ }
67
+ /** Each counter summed over the completed requests that have it; `undefined` before any request completed. */
68
+ usage() {
69
+ return sumUsage(this.billed);
70
+ }
71
+ }
72
+ /**
73
+ * Run the decode: each request opens through `withNetworkRetry` (only the opening is retried — a mid-stream
74
+ * failure would bill the work again), a continuation request refused at its opening is reopened with the same token
75
+ * (`reopenRefused`), and the requests are collected into one response.
76
+ */
77
+ export function runDecode(call) {
78
+ const open = async (continuationToken) => {
79
+ const budget = new OpeningBudget(call.openAttempts);
80
+ const send = () => sendRequest(call, continuationToken, budget);
81
+ try {
82
+ const stream = continuationToken === undefined ? await send() : await reopenRefused(send, call, budget);
83
+ call.onRequestOpened();
84
+ return stream;
85
+ }
86
+ finally {
87
+ // Counted once per request, however many attempts its opening took; a request never sent is not counted.
88
+ if (budget.spent > 0)
89
+ call.completed.sent();
90
+ }
91
+ };
92
+ call.completed.beginDecode();
93
+ return collectDecode(open, call.limits, call.collector, {
94
+ ...call.hooks,
95
+ completed: call.completed,
96
+ });
97
+ }
98
+ /**
99
+ * The SDK calls one request's opening may still make: the network retries of every attempt and the reopenings after a
100
+ * refusal draw on the same `openAttempts`.
101
+ */
102
+ class OpeningBudget {
103
+ attempts;
104
+ used = 0;
105
+ constructor(attempts) {
106
+ this.attempts = attempts;
107
+ }
108
+ spend() {
109
+ this.used += 1;
110
+ }
111
+ get spent() {
112
+ return this.used;
113
+ }
114
+ get remaining() {
115
+ return Math.max(0, this.attempts - this.used);
116
+ }
117
+ }
118
+ /** Open one request with the calls `budget` has left; each call that goes to the SDK is spent from it. */
119
+ function sendRequest(call, continuationToken, budget) {
120
+ const signal = call.collector.signal;
121
+ return withNetworkRetry(() => {
122
+ budget.spend();
123
+ return call.client.models.generateContentStream({
124
+ model: call.model,
125
+ contents: call.contents,
126
+ config: {
127
+ ...call.config,
128
+ automaticContinuation: false,
129
+ ...(continuationToken !== undefined ? { continuationToken } : {}),
130
+ abortSignal: signal,
131
+ },
132
+ });
133
+ }, {
134
+ attempts: budget.remaining,
135
+ signal,
136
+ onRetry: (attempt, err) => logRetry(call.label, attempt, err),
137
+ });
138
+ }
139
+ function logRetry(label, attempt, err) {
140
+ logger.warn(`${label}: retrying generateContent after transient network failure (attempt ${attempt}): ${err instanceof Error ? err.message : String(err)}`);
141
+ }
142
+ /**
143
+ * The statuses a request is refused with at its opening, before any of it is billed: a quota (429) and an
144
+ * overloaded server (503).
145
+ */
146
+ const REFUSED_AT_OPENING = new Set([429, 503]);
147
+ /** The wait before the first reopening when Google sent no retry hint; each further one waits three times longer. */
148
+ const REOPEN_BASE_WAIT_MS = 2_000;
149
+ /**
150
+ * Open a continuation request; a 429 or 503 at its opening (nothing of it billed yet) waits Google's retry hint, else
151
+ * the base wait, takes its per-minute reservation again (`beforeReopen`) and reopens with the same token — while the
152
+ * request's opening budget lasts (`openAttempts` SDK calls, network retries included), every wait abortable by the
153
+ * call's signal (`timeoutMs`). A refused first request is not reopened: nothing of the call is billed yet, and the
154
+ * caller sees the 429 / 503 as before.
155
+ */
156
+ async function reopenRefused(send, call, budget) {
157
+ for (let attempt = 1;; attempt += 1) {
158
+ try {
159
+ return await send();
160
+ }
161
+ catch (err) {
162
+ const status = statusOf(err);
163
+ if (status === undefined || !REFUSED_AT_OPENING.has(status) || budget.remaining === 0)
164
+ throw err;
165
+ const waitMs = (isGemini429(err) ? parseRetryDelayMs(err.message) : null) ?? reopenWaitMs(attempt);
166
+ logger.warn(`${call.label}: continuation request refused at its opening (HTTP ${status}); reopening with the same token in ${waitMs} ms (attempt ${attempt})`);
167
+ await abortableSleep(waitMs, call.collector.signal);
168
+ await call.beforeReopen?.();
169
+ }
170
+ }
171
+ }
172
+ function reopenWaitMs(attempt) {
173
+ return REOPEN_BASE_WAIT_MS * 3 ** (attempt - 1);
174
+ }
175
+ /** The usage counters a request reports for itself and the decode sums. */
176
+ const USAGE_COUNTERS = [
177
+ 'promptTokenCount',
178
+ 'cachedContentTokenCount',
179
+ 'candidatesTokenCount',
180
+ 'thoughtsTokenCount',
181
+ 'toolUsePromptTokenCount',
182
+ 'totalTokenCount',
183
+ ];
184
+ /**
185
+ * Collect the decode: one request, plus a continuation request after each one that stopped with CONTINUATION.
186
+ * Each request that streamed to its end goes into `completed` at once: a later request's failure leaves it there.
187
+ */
188
+ export async function collectDecode(open, limits, opts, hooks = {}) {
189
+ const requests = [];
190
+ const firstInput = hooks.firstRequestInput ?? 0;
191
+ let input = firstInput;
192
+ let token;
193
+ for (;;) {
194
+ const collected = await collectStream(await open(token), opts);
195
+ hooks.completed?.record(collected.usageMetadata, input);
196
+ hooks.afterRequest?.(collected.usageMetadata);
197
+ requests.push(collected);
198
+ const next = nextContinuationToken(requests, token, limits);
199
+ if (next === undefined)
200
+ return mergeRequests(requests);
201
+ input = continuationInput(requests, firstInput);
202
+ await hooks.beforeContinuation?.(input);
203
+ token = next;
204
+ }
205
+ }
206
+ /**
207
+ * The token to continue with, or `undefined` when the decode is over, has reached its limits, or made no progress
208
+ * in its last request.
209
+ */
210
+ function nextContinuationToken(requests, openedWith, limits) {
211
+ const last = requests[requests.length - 1];
212
+ if (last === undefined || last.continuationToken === null)
213
+ return undefined;
214
+ if (last.candidates?.[0]?.finishReason !== FinishReason.CONTINUATION)
215
+ return undefined;
216
+ if (requests.length >= limits.maxRequests)
217
+ return undefined;
218
+ if (decodedTokens(requests) >= limits.cap)
219
+ return undefined;
220
+ if (!madeProgress(last, openedWith))
221
+ return undefined;
222
+ return last.continuationToken;
223
+ }
224
+ /**
225
+ * A request that stopped with CONTINUATION moved the decode on: it returned a token other than the one it was opened
226
+ * with and decoded at least one token. Replaying the same token, or a request that decoded nothing, would only bill
227
+ * the whole input again for the same stop.
228
+ */
229
+ function madeProgress(request, openedWith) {
230
+ const decoded = decodedTokens([request]);
231
+ if (request.continuationToken !== openedWith && decoded > 0)
232
+ return true;
233
+ logger.warn(`long decode: a request stopped with CONTINUATION ${decoded > 0 ? 'and returned the token it was opened with' : 'having decoded no token'}; the decode stops there`);
234
+ return false;
235
+ }
236
+ /**
237
+ * The input a continuation request sends: the first request's prompt (its estimate when it reported none) plus every
238
+ * token decoded so far.
239
+ */
240
+ function continuationInput(requests, firstInput) {
241
+ const prompt = billedInputTokens(requests[0]?.usageMetadata?.promptTokenCount, firstInput);
242
+ return prompt + decodedTokens(requests);
243
+ }
244
+ /** The tokens the requests decoded so far: thinking and answer. */
245
+ function decodedTokens(requests) {
246
+ let total = 0;
247
+ for (const r of requests) {
248
+ total +=
249
+ (r.usageMetadata?.thoughtsTokenCount ?? 0) + (r.usageMetadata?.candidatesTokenCount ?? 0);
250
+ }
251
+ return total;
252
+ }
253
+ function mergeRequests(requests) {
254
+ const first = requests[0];
255
+ const last = requests[requests.length - 1];
256
+ if (first === undefined || last === undefined)
257
+ throw new Error('collectDecode: no request was collected');
258
+ if (requests.length === 1)
259
+ return { ...first, continuationHops: 0 };
260
+ const thoughts = requests.flatMap((r) => (r.thoughtsSummary === null ? [] : [r.thoughtsSummary]));
261
+ return {
262
+ text: requests.map((r) => r.text).join(''),
263
+ candidates: mergeCandidates(requests),
264
+ usageMetadata: sumUsage(reportedUsage(requests)),
265
+ thoughtsSummary: thoughts.length > 0 ? thoughts.join('\n').slice(0, THOUGHTS_SUMMARY_MAX_CHARS) : null,
266
+ chunkCount: requests.reduce((n, r) => n + r.chunkCount, 0),
267
+ firstChunkAt: first.firstChunkAt,
268
+ lastChunkAt: last.lastChunkAt,
269
+ continuationToken: last.continuationToken,
270
+ continuationHops: requests.length - 1,
271
+ };
272
+ }
273
+ /** The last request's candidates (its finish reason and metadata), each with the parts of every request. */
274
+ function mergeCandidates(requests) {
275
+ const last = requests[requests.length - 1]?.candidates;
276
+ if (last === undefined)
277
+ return undefined;
278
+ return last.map((cand, i) => {
279
+ const index = cand.index ?? i;
280
+ const parts = requests.flatMap((r) => r.candidates?.find((c, j) => (c.index ?? j) === index)?.content?.parts ?? []);
281
+ return {
282
+ ...cand,
283
+ content: { ...(cand.content ?? {}), role: cand.content?.role ?? 'model', parts },
284
+ };
285
+ });
286
+ }
287
+ function reportedUsage(requests) {
288
+ return requests.flatMap((r) => (r.usageMetadata === undefined ? [] : [r.usageMetadata]));
289
+ }
290
+ /** Each counter summed over the usages reported; `undefined` when none was. */
291
+ function sumUsage(reported) {
292
+ if (reported.length === 0)
293
+ return undefined;
294
+ const sum = {};
295
+ for (const counter of USAGE_COUNTERS) {
296
+ const values = reported.flatMap((u) => (typeof u[counter] === 'number' ? [u[counter]] : []));
297
+ if (values.length > 0)
298
+ sum[counter] = values.reduce((a, b) => a + b, 0);
299
+ }
300
+ return sum;
301
+ }
302
+ //# sourceMappingURL=continuation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"continuation.js","sourceRoot":"","sources":["../../../src/tools/shared/continuation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,YAAY,GAMb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7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EAA+E;AAC/E,SAAS,QAAQ,CAAC,QAAgC;IAChD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC5C,MAAM,GAAG,GAAgB,EAAE,CAAC;IAC5B,KAAK,MAAM,OAAO,IAAI,cAAc,EAAE,CAAC;QACrC,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC7F,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;YAAE,GAAG,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1E,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The per-minute input throttle of one `ask` / `code` call (`GEMINI_CODE_CONTEXT_TPM_THROTTLE_LIMIT`).
3
+ *
4
+ * Each request of the call's decode holds its own reservation, made just before the request is sent and settled
5
+ * when it ends at the input it reported — so every request of a long decode, each of which sends the prompt again
6
+ * plus everything decoded before it, is counted in the window of the minute it was sent in. At most one reservation
7
+ * is held at a time; the call's failure path drops it.
8
+ */
9
+ import type { TpmThrottle } from './throttle.js';
10
+ export interface DispatchThrottleOptions {
11
+ readonly throttle: TpmThrottle;
12
+ /** `false` when the throttle is off (a limit of 0 or less): nothing is reserved. */
13
+ readonly enabled: boolean;
14
+ /** The call's abort signal: a wait for the window ends with it (`timeoutMs`). */
15
+ readonly signal: AbortSignal;
16
+ /** Says a wait for the window on the call's progress channel. */
17
+ readonly emit: (message: string) => void;
18
+ }
19
+ export declare class DispatchThrottle {
20
+ private readonly opts;
21
+ private releaseId;
22
+ private heldModel;
23
+ private heldTokens;
24
+ constructor(opts: DispatchThrottleOptions);
25
+ /**
26
+ * Reserve the input of the next request of `model`, waiting out the window when it is full. A reservation still
27
+ * held (a request that was never sent) is dropped first.
28
+ */
29
+ reserve(model: string, inputTokens: number): Promise<void>;
30
+ /**
31
+ * The request held is sent later than its reservation planned (a reopening after a refusal and its wait): it is
32
+ * reserved again for the window it is sent in now. Nothing is held: nothing to renew.
33
+ */
34
+ renew(): Promise<void>;
35
+ /**
36
+ * The request ended: its reservation settles at the input it reported (cached and uncached alike count against
37
+ * the per-minute quota), or at the reserved estimate when it reported none.
38
+ */
39
+ settle(promptTokens: number | undefined): void;
40
+ /** The call failed: the reservation it holds is dropped. */
41
+ cancel(): void;
42
+ }
43
+ //# sourceMappingURL=dispatch-throttle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatch-throttle.d.ts","sourceRoot":"","sources":["../../../src/tools/shared/dispatch-throttle.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/B,oFAAoF;IACpF,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,iFAAiF;IACjF,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,iEAAiE;IACjE,QAAQ,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1C;AAKD,qBAAa,gBAAgB;IAKf,OAAO,CAAC,QAAQ,CAAC,IAAI;IAJjC,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,SAAS,CAAM;IACvB,OAAO,CAAC,UAAU,CAAK;IAEvB,YAA6B,IAAI,EAAE,uBAAuB,EAAI;IAE9D;;;OAGG;IACG,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAU/D;IAED;;;OAGG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAG3B;IAED;;;OAGG;IACH,MAAM,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAI7C;IAED,4DAA4D;IAC5D,MAAM,IAAI,IAAI,CAIb;CACF"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * The per-minute input throttle of one `ask` / `code` call (`GEMINI_CODE_CONTEXT_TPM_THROTTLE_LIMIT`).
3
+ *
4
+ * Each request of the call's decode holds its own reservation, made just before the request is sent and settled
5
+ * when it ends at the input it reported — so every request of a long decode, each of which sends the prompt again
6
+ * plus everything decoded before it, is counted in the window of the minute it was sent in. At most one reservation
7
+ * is held at a time; the call's failure path drops it.
8
+ */
9
+ import { abortableSleep } from '../../gemini/retry.js';
10
+ import { billedInputTokens } from './call-ledger.js';
11
+ /** No reservation held. */
12
+ const NONE = -1;
13
+ export class DispatchThrottle {
14
+ opts;
15
+ releaseId = NONE;
16
+ heldModel = '';
17
+ heldTokens = 0;
18
+ constructor(opts) {
19
+ this.opts = opts;
20
+ }
21
+ /**
22
+ * Reserve the input of the next request of `model`, waiting out the window when it is full. A reservation still
23
+ * held (a request that was never sent) is dropped first.
24
+ */
25
+ async reserve(model, inputTokens) {
26
+ if (!this.opts.enabled)
27
+ return;
28
+ this.cancel();
29
+ const reservation = this.opts.throttle.reserve(model, inputTokens);
30
+ this.releaseId = reservation.releaseId;
31
+ this.heldModel = model;
32
+ this.heldTokens = inputTokens;
33
+ if (reservation.delayMs <= 0)
34
+ return;
35
+ this.opts.emit(`throttle: waiting ${Math.ceil(reservation.delayMs / 1000)}s for TPM window…`);
36
+ await abortableSleep(reservation.delayMs, this.opts.signal);
37
+ }
38
+ /**
39
+ * The request held is sent later than its reservation planned (a reopening after a refusal and its wait): it is
40
+ * reserved again for the window it is sent in now. Nothing is held: nothing to renew.
41
+ */
42
+ async renew() {
43
+ if (this.releaseId === NONE)
44
+ return;
45
+ await this.reserve(this.heldModel, this.heldTokens);
46
+ }
47
+ /**
48
+ * The request ended: its reservation settles at the input it reported (cached and uncached alike count against
49
+ * the per-minute quota), or at the reserved estimate when it reported none.
50
+ */
51
+ settle(promptTokens) {
52
+ if (this.releaseId === NONE)
53
+ return;
54
+ this.opts.throttle.release(this.releaseId, billedInputTokens(promptTokens, this.heldTokens));
55
+ this.releaseId = NONE;
56
+ }
57
+ /** The call failed: the reservation it holds is dropped. */
58
+ cancel() {
59
+ if (this.releaseId === NONE)
60
+ return;
61
+ this.opts.throttle.cancel(this.releaseId);
62
+ this.releaseId = NONE;
63
+ }
64
+ }
65
+ //# sourceMappingURL=dispatch-throttle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatch-throttle.js","sourceRoot":"","sources":["../../../src/tools/shared/dispatch-throttle.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAarD,2BAA2B;AAC3B,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC;AAEhB,MAAM,OAAO,gBAAgB;IAKE,IAAI;IAJzB,SAAS,GAAG,IAAI,CAAC;IACjB,SAAS,GAAG,EAAE,CAAC;IACf,UAAU,GAAG,CAAC,CAAC;IAEvB,YAA6B,IAA6B;oBAA7B,IAAI;IAA4B,CAAC;IAE9D;;;OAGG;IACH,KAAK,CAAC,OAAO,CAAC,KAAa,EAAE,WAAmB;QAC9C,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAO;QAC/B,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QACnE,IAAI,CAAC,SAAS,GAAG,WAAW,CAAC,SAAS,CAAC;QACvC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,WAAW,CAAC;QAC9B,IAAI,WAAW,CAAC,OAAO,IAAI,CAAC;YAAE,OAAO;QACrC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,qBAAqB,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,GAAG,IAAI,CAAC,mBAAmB,CAAC,CAAC;QAC9F,MAAM,cAAc,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC9D,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,KAAK;QACT,IAAI,IAAI,CAAC,SAAS,KAAK,IAAI;YAAE,OAAO;QACpC,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IACtD,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,YAAgC;QACrC,IAAI,IAAI,CAAC,SAAS,KAAK,IAAI;YAAE,OAAO;QACpC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,iBAAiB,CAAC,YAAY,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;QAC7F,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;IAED,4DAA4D;IAC5D,MAAM;QACJ,IAAI,IAAI,CAAC,SAAS,KAAK,IAAI;YAAE,OAAO;QACpC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC1C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACxB,CAAC;CACF"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * How an `ask` / `code` call settles — the one place both tools do it, so they book the same way and return the same
3
+ * fields.
4
+ *
5
+ * - An answer: the ledger books every completed request at what it billed; a stop at the output cap with no text is
6
+ * an `OUTPUT_CAP` error with the usage, the model, the tier and the finish reason.
7
+ * - A failure: a 429's retry hint seeds the per-minute throttle, the ledger keeps what the completed requests billed
8
+ * and releases the rest (all of it when none completed), and the request's per-minute reservation is dropped.
9
+ */
10
+ import type { InputWindowCut } from '../../gemini/long-decode.js';
11
+ import type { ManifestDb } from '../../manifest/db.js';
12
+ import { type FailedCall, type LedgerEntry, type UsageFields } from './call-ledger.js';
13
+ import type { CompletedRequests, DecodedResponse } from './continuation.js';
14
+ import type { DispatchThrottle } from './dispatch-throttle.js';
15
+ import { type AnswerFinish, type CapThatRan } from './thinking.js';
16
+ import { type TpmThrottle } from './throttle.js';
17
+ /** A call whose decode answered. */
18
+ export interface AnsweredCall {
19
+ readonly manifest: ManifestDb;
20
+ readonly reservationId: number | null;
21
+ /** The booking: the tool, the model, the tier, the caching mode that ran. */
22
+ readonly entry: LedgerEntry;
23
+ readonly completed: CompletedRequests;
24
+ readonly response: DecodedResponse;
25
+ /** The cap the decode ran under. */
26
+ readonly cap: CapThatRan;
27
+ /** The cut the model's input window made to the caller's cap; `null`: none. */
28
+ readonly cut: InputWindowCut | null;
29
+ readonly durationMs: number;
30
+ }
31
+ /** A stop at the output cap with no answer: the message (without the tool's prefix) and the result's fields. */
32
+ export interface OutputCapStop {
33
+ readonly message: string;
34
+ readonly fields: Readonly<Record<string, unknown>>;
35
+ }
36
+ export interface SettledAnswer {
37
+ /** What the call billed, for the result. */
38
+ readonly usage: UsageFields;
39
+ readonly finish: AnswerFinish;
40
+ /** The input-window cut as a result field (`outputCapCutByInputWindow`), or nothing. */
41
+ readonly cutFields: Readonly<Record<string, unknown>>;
42
+ /** Set when the call stopped at the cap before writing an answer: the caller returns it as an error. */
43
+ readonly outputCapStop: OutputCapStop | null;
44
+ }
45
+ /** Book the answered call at what its requests billed, and say whether it stopped at the cap with no answer. */
46
+ export declare function settleAnswer(call: AnsweredCall): SettledAnswer;
47
+ /** A call that failed, with what its failure path settles. */
48
+ export interface FailedCallSettlement {
49
+ readonly manifest: ManifestDb;
50
+ readonly failed: FailedCall;
51
+ readonly err: unknown;
52
+ /** The resolved model a 429's retry hint is recorded for; `null` before the model was resolved. */
53
+ readonly model: string | null;
54
+ readonly throttle: Pick<TpmThrottle, 'recordRetryHint'>;
55
+ readonly dispatch: DispatchThrottle;
56
+ }
57
+ /**
58
+ * Settle a failed call; its usage when completed requests were billed, else `null`. The retry hint is read only from
59
+ * a real `ApiError` with status 429 (`isGemini429`): text a prompt can echo never reaches the throttle. A ledger write
60
+ * that throws is logged by `settleFailedCall` and never replaces the call's own error.
61
+ */
62
+ export declare function settleFailure(settlement: FailedCallSettlement): UsageFields | null;
63
+ //# sourceMappingURL=settle-call.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settle-call.d.ts","sourceRoot":"","sources":["../../../src/tools/shared/settle-call.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EACL,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,WAAW,EAKjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,UAAU,EAIhB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,WAAW,EAAkC,MAAM,eAAe,CAAC;AAEjF,oCAAoC;AACpC,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC9B,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,6EAA6E;IAC7E,QAAQ,CAAC,KAAK,EAA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