@qmediat.io/gemini-code-context-mcp 1.23.1 → 1.25.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/CHANGELOG.md +161 -1
- package/README.md +1 -1
- package/dist/cache/ttl-watcher.d.ts +29 -0
- package/dist/cache/ttl-watcher.d.ts.map +1 -1
- package/dist/cache/ttl-watcher.js +104 -43
- package/dist/cache/ttl-watcher.js.map +1 -1
- package/dist/gemini/client.d.ts +7 -0
- package/dist/gemini/client.d.ts.map +1 -1
- package/dist/gemini/client.js +8 -1
- package/dist/gemini/client.js.map +1 -1
- package/dist/gemini/long-decode.d.ts +153 -0
- package/dist/gemini/long-decode.d.ts.map +1 -0
- package/dist/gemini/long-decode.js +178 -0
- package/dist/gemini/long-decode.js.map +1 -0
- package/dist/gemini/model-registry.d.ts +2 -0
- package/dist/gemini/model-registry.d.ts.map +1 -1
- package/dist/gemini/model-registry.js +5 -2
- package/dist/gemini/model-registry.js.map +1 -1
- package/dist/gemini/models.d.ts.map +1 -1
- package/dist/gemini/models.js +1 -0
- package/dist/gemini/models.js.map +1 -1
- package/dist/gemini/retry.d.ts +8 -0
- package/dist/gemini/retry.d.ts.map +1 -1
- package/dist/gemini/retry.js +33 -1
- package/dist/gemini/retry.js.map +1 -1
- package/dist/tools/agentic/dispatch.d.ts +68 -0
- package/dist/tools/agentic/dispatch.d.ts.map +1 -0
- package/dist/tools/agentic/dispatch.js +167 -0
- package/dist/tools/agentic/dispatch.js.map +1 -0
- package/dist/tools/agentic/input.d.ts +28 -0
- package/dist/tools/agentic/input.d.ts.map +1 -0
- package/dist/tools/agentic/input.js +66 -0
- package/dist/tools/agentic/input.js.map +1 -0
- package/dist/tools/agentic/instructions.d.ts +46 -0
- package/dist/tools/agentic/instructions.d.ts.map +1 -0
- package/dist/tools/agentic/instructions.js +170 -0
- package/dist/tools/agentic/instructions.js.map +1 -0
- package/dist/tools/agentic/iteration.d.ts +81 -0
- package/dist/tools/agentic/iteration.d.ts.map +1 -0
- package/dist/tools/agentic/iteration.js +317 -0
- package/dist/tools/agentic/iteration.js.map +1 -0
- package/dist/tools/agentic/ledger.d.ts +64 -0
- package/dist/tools/agentic/ledger.d.ts.map +1 -0
- package/dist/tools/agentic/ledger.js +110 -0
- package/dist/tools/agentic/ledger.js.map +1 -0
- package/dist/tools/agentic/loop.d.ts +10 -0
- package/dist/tools/agentic/loop.d.ts.map +1 -0
- package/dist/tools/agentic/loop.js +179 -0
- package/dist/tools/agentic/loop.js.map +1 -0
- package/dist/tools/agentic/no-progress.d.ts +90 -0
- package/dist/tools/agentic/no-progress.d.ts.map +1 -0
- package/dist/tools/agentic/no-progress.js +107 -0
- package/dist/tools/agentic/no-progress.js.map +1 -0
- package/dist/tools/agentic/pass-clock.d.ts +85 -0
- package/dist/tools/agentic/pass-clock.d.ts.map +1 -0
- package/dist/tools/agentic/pass-clock.js +162 -0
- package/dist/tools/agentic/pass-clock.js.map +1 -0
- package/dist/tools/agentic/phase-defaults.d.ts +29 -0
- package/dist/tools/agentic/phase-defaults.d.ts.map +1 -0
- package/dist/tools/agentic/phase-defaults.js +23 -0
- package/dist/tools/agentic/phase-defaults.js.map +1 -0
- package/dist/tools/agentic/rescue.d.ts +69 -0
- package/dist/tools/agentic/rescue.d.ts.map +1 -0
- package/dist/tools/agentic/rescue.js +203 -0
- package/dist/tools/agentic/rescue.js.map +1 -0
- package/dist/tools/agentic/response.d.ts +16 -0
- package/dist/tools/agentic/response.d.ts.map +1 -0
- package/dist/tools/agentic/response.js +25 -0
- package/dist/tools/agentic/response.js.map +1 -0
- package/dist/tools/agentic/results.d.ts +76 -0
- package/dist/tools/agentic/results.d.ts.map +1 -0
- package/dist/tools/agentic/results.js +228 -0
- package/dist/tools/agentic/results.js.map +1 -0
- package/dist/tools/agentic/run.d.ts +130 -0
- package/dist/tools/agentic/run.d.ts.map +1 -0
- package/dist/tools/agentic/run.js +131 -0
- package/dist/tools/agentic/run.js.map +1 -0
- package/dist/tools/agentic/sandbox.d.ts +13 -2
- package/dist/tools/agentic/sandbox.d.ts.map +1 -1
- package/dist/tools/agentic/sandbox.js +127 -111
- package/dist/tools/agentic/sandbox.js.map +1 -1
- package/dist/tools/agentic/workspace-tools.d.ts +30 -27
- package/dist/tools/agentic/workspace-tools.d.ts.map +1 -1
- package/dist/tools/agentic/workspace-tools.js +324 -385
- package/dist/tools/agentic/workspace-tools.js.map +1 -1
- package/dist/tools/ask-agentic-fallback.d.ts +33 -0
- package/dist/tools/ask-agentic-fallback.d.ts.map +1 -0
- package/dist/tools/ask-agentic-fallback.js +113 -0
- package/dist/tools/ask-agentic-fallback.js.map +1 -0
- package/dist/tools/ask-agentic.tool.d.ts +11 -44
- package/dist/tools/ask-agentic.tool.d.ts.map +1 -1
- package/dist/tools/ask-agentic.tool.js +143 -1618
- package/dist/tools/ask-agentic.tool.js.map +1 -1
- package/dist/tools/ask.tool.d.ts.map +1 -1
- package/dist/tools/ask.tool.js +195 -555
- package/dist/tools/ask.tool.js.map +1 -1
- package/dist/tools/code.tool.d.ts +6 -0
- package/dist/tools/code.tool.d.ts.map +1 -1
- package/dist/tools/code.tool.js +155 -306
- package/dist/tools/code.tool.js.map +1 -1
- package/dist/tools/shared/abort-timeout.d.ts +48 -4
- package/dist/tools/shared/abort-timeout.d.ts.map +1 -1
- package/dist/tools/shared/abort-timeout.js +116 -95
- package/dist/tools/shared/abort-timeout.js.map +1 -1
- package/dist/tools/shared/call-ledger.d.ts +88 -0
- package/dist/tools/shared/call-ledger.d.ts.map +1 -0
- package/dist/tools/shared/call-ledger.js +133 -0
- package/dist/tools/shared/call-ledger.js.map +1 -0
- package/dist/tools/shared/context-decode.d.ts +77 -0
- package/dist/tools/shared/context-decode.d.ts.map +1 -0
- package/dist/tools/shared/context-decode.js +125 -0
- package/dist/tools/shared/context-decode.js.map +1 -0
- package/dist/tools/shared/continuation.d.ts +124 -0
- package/dist/tools/shared/continuation.d.ts.map +1 -0
- package/dist/tools/shared/continuation.js +302 -0
- package/dist/tools/shared/continuation.js.map +1 -0
- package/dist/tools/shared/dispatch-throttle.d.ts +43 -0
- package/dist/tools/shared/dispatch-throttle.d.ts.map +1 -0
- package/dist/tools/shared/dispatch-throttle.js +65 -0
- package/dist/tools/shared/dispatch-throttle.js.map +1 -0
- package/dist/tools/shared/question-fields.d.ts +10 -0
- package/dist/tools/shared/question-fields.d.ts.map +1 -0
- package/dist/tools/shared/question-fields.js +13 -0
- package/dist/tools/shared/question-fields.js.map +1 -0
- package/dist/tools/shared/settle-call.d.ts +68 -0
- package/dist/tools/shared/settle-call.d.ts.map +1 -0
- package/dist/tools/shared/settle-call.js +59 -0
- package/dist/tools/shared/settle-call.js.map +1 -0
- package/dist/tools/shared/stream-collector.d.ts +7 -0
- package/dist/tools/shared/stream-collector.d.ts.map +1 -1
- package/dist/tools/shared/stream-collector.js +5 -1
- package/dist/tools/shared/stream-collector.js.map +1 -1
- package/dist/tools/shared/thinking.d.ts +41 -11
- package/dist/tools/shared/thinking.d.ts.map +1 -1
- package/dist/tools/shared/thinking.js +62 -9
- package/dist/tools/shared/thinking.js.map +1 -1
- package/dist/tools/shared/throttle.d.ts +7 -0
- package/dist/tools/shared/throttle.d.ts.map +1 -1
- package/dist/tools/shared/throttle.js +18 -0
- package/dist/tools/shared/throttle.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/cost-estimator.d.ts +17 -0
- package/dist/utils/cost-estimator.d.ts.map +1 -1
- package/dist/utils/cost-estimator.js +15 -2
- package/dist/utils/cost-estimator.js.map +1 -1
- package/package.json +4 -3
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Long decode — the facts of Gemini 4's continuation protocol and the output cap a call runs under.
|
|
3
|
+
*
|
|
4
|
+
* Google's reference (docs.cloud.google.com/vertex-ai/generative-ai/docs/model-reference/gemini): on a Gemini 4
|
|
5
|
+
* model a response that reaches the per-request decode limit stops with `finishReason: CONTINUATION` and a
|
|
6
|
+
* `continuationToken`; the ORIGINAL request sent again with `continuationToken` set to the latest token continues
|
|
7
|
+
* it, up to 1 048 576 decoded tokens in total. Thinking tokens count against the decode, and every request bills
|
|
8
|
+
* its whole input again: the prompt plus everything decoded before it.
|
|
9
|
+
*/
|
|
10
|
+
import type { PreflightInput } from './token-counter.js';
|
|
11
|
+
/** The most a Gemini 4 decode can produce over all its requests. */
|
|
12
|
+
export declare const LONG_DECODE_TOTAL_TOKENS = 1048576;
|
|
13
|
+
/** The most one streaming request decodes before it stops with `CONTINUATION` (a non-streaming one: 32 768). */
|
|
14
|
+
export declare const LONG_DECODE_STREAM_REQUEST_TOKENS = 65536;
|
|
15
|
+
/** The API a client was built for: the Gemini Developer API (an API key) or Vertex AI. */
|
|
16
|
+
export type ApiBackend = 'developer' | 'vertex';
|
|
17
|
+
/**
|
|
18
|
+
* The total a decode of `modelId` may reach through continuation, or `null` for a model without long decode. Long
|
|
19
|
+
* decode runs on the Gemini Developer API only: on Vertex AI every model is clamped to its per-request limit,
|
|
20
|
+
* whatever the shape of its id. The model registry carries it beside the advertised input and output limits.
|
|
21
|
+
*/
|
|
22
|
+
export declare function longDecodeTokenLimitOf(modelId: string, backend: ApiBackend): number | null;
|
|
23
|
+
/**
|
|
24
|
+
* Input a continuation request bills beyond the prompt and the tokens decoded before it. Measured on
|
|
25
|
+
* gemini-4-hydrogen in two runs: +125 tokens (99 712-token prompt, request 2 billed 165 373) and +89; reserved at
|
|
26
|
+
* twice the larger, rounded up.
|
|
27
|
+
*/
|
|
28
|
+
export declare const CONTINUATION_REQUEST_OVERHEAD_TOKENS = 256;
|
|
29
|
+
/** The output cap of one call: what goes on the wire and how many requests the decode may take. */
|
|
30
|
+
export interface OutputCap {
|
|
31
|
+
/**
|
|
32
|
+
* `maxOutputTokens` on the wire; `undefined` sends none and the model applies its own default. A cap the input window
|
|
33
|
+
* cut to one request sends the cut value (`boundByInputWindow`).
|
|
34
|
+
*/
|
|
35
|
+
readonly wire: number | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* The most the call decodes: the wire cap, else the model's per-request limit (its default) — less when the
|
|
38
|
+
* model's input window bounds a long decode (`boundByInputWindow`).
|
|
39
|
+
*/
|
|
40
|
+
readonly effective: number;
|
|
41
|
+
/** The model's advertised per-request output limit. */
|
|
42
|
+
readonly perRequest: number;
|
|
43
|
+
/**
|
|
44
|
+
* The most a caller may ask for: the long-decode total on a model with long decode, else `perRequest`; for a prompt
|
|
45
|
+
* the input window bounds, what that window leaves.
|
|
46
|
+
*/
|
|
47
|
+
readonly ceiling: number;
|
|
48
|
+
/** The requests the decode may take: 1 unless the cap is above the per-request limit on a long-decode model. */
|
|
49
|
+
readonly maxRequests: number;
|
|
50
|
+
}
|
|
51
|
+
export interface OutputCapInputs {
|
|
52
|
+
/** The caller's `maxOutputTokens`, if any. */
|
|
53
|
+
readonly requested: number | undefined;
|
|
54
|
+
/** `GEMINI_CODE_CONTEXT_FORCE_MAX_OUTPUT`: send the per-request limit when the caller sets no cap. */
|
|
55
|
+
readonly forceMax: boolean;
|
|
56
|
+
readonly outputTokenLimit: number | null;
|
|
57
|
+
/** `ResolvedModel.longDecodeTokenLimit`; `undefined` reads as none. */
|
|
58
|
+
readonly longDecodeTokenLimit: number | null | undefined;
|
|
59
|
+
/** The per-request limit assumed when the model advertises none. */
|
|
60
|
+
readonly fallbackLimit: number;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The caller's cap is clamped to the model's per-request limit, or — on a model with long decode — to its long
|
|
64
|
+
* decode total. Without a caller's cap nothing goes on the wire (one request, the model's default), unless the
|
|
65
|
+
* operator forces the per-request limit.
|
|
66
|
+
*/
|
|
67
|
+
export declare function resolveOutputCap(inputs: OutputCapInputs): OutputCap;
|
|
68
|
+
/** A long decode's cap cut so that no continuation request's input passes the model's input window. */
|
|
69
|
+
export interface InputWindowCut {
|
|
70
|
+
/** The cap before the cut: the caller's, clamped to the model's limits. */
|
|
71
|
+
readonly from: number;
|
|
72
|
+
/** The cap the decode runs under. */
|
|
73
|
+
readonly to: number;
|
|
74
|
+
/** The model's input window that cut it. */
|
|
75
|
+
readonly inputTokenLimit: number;
|
|
76
|
+
}
|
|
77
|
+
/** The cap a decode runs under, and the cut the input window made to it (`null`: none). */
|
|
78
|
+
export interface BoundedOutputCap {
|
|
79
|
+
readonly cap: OutputCap;
|
|
80
|
+
readonly cut: InputWindowCut | null;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The cap of a long decode bounded by the model's input window W. Request k sends the prompt P again plus every token
|
|
84
|
+
* decoded before it, and the client opens no further request once the decoded tokens reached the cap: under a cap of
|
|
85
|
+
* at most W − P − O no request's input passes W. The premise — the API refuses a continuation request whose prompt
|
|
86
|
+
* plus decoded tokens pass W — is assumed, not measured: the repository holds a measurement of what a continuation
|
|
87
|
+
* request bills, none of a refusal at the window (docs/FOLLOW-UP-PRS.md T41).
|
|
88
|
+
*
|
|
89
|
+
* The cap is never cut below one request's limit — the first request sends the prompt alone, which the preflight
|
|
90
|
+
* bounds. A cut that leaves several requests keeps the caller's `wire`: the client stops the decode at `effective`,
|
|
91
|
+
* after `maxRequests`. A cut that leaves one request sends the cut value as `maxOutputTokens`, so the server holds it
|
|
92
|
+
* (a stop at it is `MAX_TOKENS`) — one streaming request would otherwise decode past it. Without a counted prompt or
|
|
93
|
+
* an advertised window nothing is cut.
|
|
94
|
+
*/
|
|
95
|
+
export declare function boundByInputWindow(cap: OutputCap, promptTokens: number | undefined, inputTokenLimit: number | null): BoundedOutputCap;
|
|
96
|
+
/** The progress and log line of a cut cap. */
|
|
97
|
+
export declare function describeInputWindowCut(cut: InputWindowCut): string;
|
|
98
|
+
/** What `capThatRuns` bounds: the cap a tool resolved, the prompt's count and the model's input window. */
|
|
99
|
+
export interface CapToBound {
|
|
100
|
+
/** The tool's name, which prefixes the note of a cut. */
|
|
101
|
+
readonly tool: string;
|
|
102
|
+
readonly cap: OutputCap;
|
|
103
|
+
/** The preflight's count of the prompt, when it ran. */
|
|
104
|
+
readonly promptTokens: number | undefined;
|
|
105
|
+
readonly inputTokenLimit: number | null;
|
|
106
|
+
/** The call's progress channel. */
|
|
107
|
+
readonly emit: (message: string) => void;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The cap a call's decode runs under: a long decode never sends a continuation request past the model's input
|
|
111
|
+
* window (`boundByInputWindow`). A cut is said on the call's progress channel and in the log.
|
|
112
|
+
*/
|
|
113
|
+
export declare function capThatRuns(call: CapToBound): BoundedOutputCap;
|
|
114
|
+
/** The answer the output cap keeps beside a thinking budget: Gemini requires `thinkingBudget < maxOutputTokens`. */
|
|
115
|
+
export declare const ANSWER_RESERVE_TOKENS = 1024;
|
|
116
|
+
/**
|
|
117
|
+
* The refusal of a caller's positive `thinkingBudget` that leaves less than the answer reserve under the caller's own
|
|
118
|
+
* `maxOutputTokens` (`cap`: what that cap became under the model's limits) — refused, never clamped to 0, which
|
|
119
|
+
* Gemini 3 Pro answers with a 400 that hides the cause. `null` when it fits, or the caller set either one not.
|
|
120
|
+
*/
|
|
121
|
+
export declare function thinkingBudgetRefusal(budget: number | undefined, requestedCap: number | undefined, cap: number): string | null;
|
|
122
|
+
/** The preflight's count modes (`preflightMode` of `ask` and `code`). */
|
|
123
|
+
export type PreflightMode = NonNullable<PreflightInput['preflightMode']>;
|
|
124
|
+
/**
|
|
125
|
+
* The count mode the preflight runs in. A decode that may take more than one request bills its prompt once per
|
|
126
|
+
* request, so the budget reservation takes the exact count (`countTokens`) whatever mode was asked for; a
|
|
127
|
+
* one-request call keeps the caller's mode.
|
|
128
|
+
*/
|
|
129
|
+
export declare function preflightModeFor(requested: PreflightMode | undefined, cap: OutputCap): PreflightMode | undefined;
|
|
130
|
+
/** The requests a decode of `cap` tokens may take when each request decodes up to `perRequest` tokens. */
|
|
131
|
+
export declare function maxDecodeRequests(cap: number, perRequest: number): number;
|
|
132
|
+
/**
|
|
133
|
+
* The input tokens the continuation requests bill again, at most, for a prompt of `promptTokens` tokens:
|
|
134
|
+
*
|
|
135
|
+
* R = ceil(C / L) requests (the client stops there; L = the per-request limit)
|
|
136
|
+
* M = max(L, 65 536) the most one streaming request decodes
|
|
137
|
+
* O = CONTINUATION_REQUEST_OVERHEAD_TOKENS what a continuation request bills beyond the two terms below
|
|
138
|
+
* re-billed input = Σ_{k=1..R−1} (P + min(k·M, C) + O)
|
|
139
|
+
*
|
|
140
|
+
* Request k sends the prompt P again plus the tokens decoded before it, which are at most k·M and below the cap C
|
|
141
|
+
* (the client opens no request once the decoded tokens reached C). The first request's prompt is not part of this
|
|
142
|
+
* sum.
|
|
143
|
+
*/
|
|
144
|
+
export declare function continuationInputTokens(promptTokens: number, cap: number, perRequest: number): number;
|
|
145
|
+
/**
|
|
146
|
+
* The most a decode of cap C produces (thinking and answer). One request honours `maxOutputTokens` = C. Over several
|
|
147
|
+
* requests C stays the bound only while Google holds `maxOutputTokens` over the whole chain, which the client cannot
|
|
148
|
+
* check: it stops after a request ends, once the decoded tokens reached C, so a server that holds the cap per
|
|
149
|
+
* request lets the last request run up to one request's decode past it — at most C + M − 1, and never more than
|
|
150
|
+
* R requests of M.
|
|
151
|
+
*/
|
|
152
|
+
export declare function decodedTokensBound(cap: number, perRequest: number): number;
|
|
153
|
+
//# sourceMappingURL=long-decode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"long-decode.d.ts","sourceRoot":"","sources":["../../src/gemini/long-decode.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,oEAAoE;AACpE,eAAO,MAAM,wBAAwB,UAAY,CAAC;AAElD,gHAAgH;AAChH,eAAO,MAAM,iCAAiC,QAAS,CAAC;AAKxD,0FAA0F;AAC1F,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,QAAQ,CAAC;AAEhD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EA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AU,EAAE,MAAM,GAAG,MAAM,CAGzE;AAOD;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,GACjB,MAAM,CASR;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAK1E"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Long decode — the facts of Gemini 4's continuation protocol and the output cap a call runs under.
|
|
3
|
+
*
|
|
4
|
+
* Google's reference (docs.cloud.google.com/vertex-ai/generative-ai/docs/model-reference/gemini): on a Gemini 4
|
|
5
|
+
* model a response that reaches the per-request decode limit stops with `finishReason: CONTINUATION` and a
|
|
6
|
+
* `continuationToken`; the ORIGINAL request sent again with `continuationToken` set to the latest token continues
|
|
7
|
+
* it, up to 1 048 576 decoded tokens in total. Thinking tokens count against the decode, and every request bills
|
|
8
|
+
* its whole input again: the prompt plus everything decoded before it.
|
|
9
|
+
*/
|
|
10
|
+
import { logger } from '../utils/logger.js';
|
|
11
|
+
import { categorizeModel, isTextGenCategory } from './model-taxonomy.js';
|
|
12
|
+
/** The most a Gemini 4 decode can produce over all its requests. */
|
|
13
|
+
export const LONG_DECODE_TOTAL_TOKENS = 1_048_576;
|
|
14
|
+
/** The most one streaming request decodes before it stops with `CONTINUATION` (a non-streaming one: 32 768). */
|
|
15
|
+
export const LONG_DECODE_STREAM_REQUEST_TOKENS = 65_536;
|
|
16
|
+
/** A text model of the Gemini 4 family (`gemini-4-<codename>`, `gemini-4.1-<codename>`, their `-preview` twins). */
|
|
17
|
+
const GEMINI_4_ID = /^gemini-4(?:\.\d+)?-/i;
|
|
18
|
+
/**
|
|
19
|
+
* The total a decode of `modelId` may reach through continuation, or `null` for a model without long decode. Long
|
|
20
|
+
* decode runs on the Gemini Developer API only: on Vertex AI every model is clamped to its per-request limit,
|
|
21
|
+
* whatever the shape of its id. The model registry carries it beside the advertised input and output limits.
|
|
22
|
+
*/
|
|
23
|
+
export function longDecodeTokenLimitOf(modelId, backend) {
|
|
24
|
+
if (backend !== 'developer' || !GEMINI_4_ID.test(modelId))
|
|
25
|
+
return null;
|
|
26
|
+
return isTextGenCategory(categorizeModel(modelId)) ? LONG_DECODE_TOTAL_TOKENS : null;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Input a continuation request bills beyond the prompt and the tokens decoded before it. Measured on
|
|
30
|
+
* gemini-4-hydrogen in two runs: +125 tokens (99 712-token prompt, request 2 billed 165 373) and +89; reserved at
|
|
31
|
+
* twice the larger, rounded up.
|
|
32
|
+
*/
|
|
33
|
+
export const CONTINUATION_REQUEST_OVERHEAD_TOKENS = 256;
|
|
34
|
+
/**
|
|
35
|
+
* The caller's cap is clamped to the model's per-request limit, or — on a model with long decode — to its long
|
|
36
|
+
* decode total. Without a caller's cap nothing goes on the wire (one request, the model's default), unless the
|
|
37
|
+
* operator forces the per-request limit.
|
|
38
|
+
*/
|
|
39
|
+
export function resolveOutputCap(inputs) {
|
|
40
|
+
const perRequest = typeof inputs.outputTokenLimit === 'number' && inputs.outputTokenLimit > 0
|
|
41
|
+
? inputs.outputTokenLimit
|
|
42
|
+
: inputs.fallbackLimit;
|
|
43
|
+
const ceiling = Math.max(perRequest, inputs.longDecodeTokenLimit ?? 0);
|
|
44
|
+
const wire = inputs.requested !== undefined
|
|
45
|
+
? Math.min(inputs.requested, ceiling)
|
|
46
|
+
: inputs.forceMax
|
|
47
|
+
? perRequest
|
|
48
|
+
: undefined;
|
|
49
|
+
const effective = wire ?? perRequest;
|
|
50
|
+
return {
|
|
51
|
+
wire,
|
|
52
|
+
effective,
|
|
53
|
+
perRequest,
|
|
54
|
+
ceiling,
|
|
55
|
+
maxRequests: maxDecodeRequests(effective, perRequest),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The cap of a long decode bounded by the model's input window W. Request k sends the prompt P again plus every token
|
|
60
|
+
* decoded before it, and the client opens no further request once the decoded tokens reached the cap: under a cap of
|
|
61
|
+
* at most W − P − O no request's input passes W. The premise — the API refuses a continuation request whose prompt
|
|
62
|
+
* plus decoded tokens pass W — is assumed, not measured: the repository holds a measurement of what a continuation
|
|
63
|
+
* request bills, none of a refusal at the window (docs/FOLLOW-UP-PRS.md T41).
|
|
64
|
+
*
|
|
65
|
+
* The cap is never cut below one request's limit — the first request sends the prompt alone, which the preflight
|
|
66
|
+
* bounds. A cut that leaves several requests keeps the caller's `wire`: the client stops the decode at `effective`,
|
|
67
|
+
* after `maxRequests`. A cut that leaves one request sends the cut value as `maxOutputTokens`, so the server holds it
|
|
68
|
+
* (a stop at it is `MAX_TOKENS`) — one streaming request would otherwise decode past it. Without a counted prompt or
|
|
69
|
+
* an advertised window nothing is cut.
|
|
70
|
+
*/
|
|
71
|
+
export function boundByInputWindow(cap, promptTokens, inputTokenLimit) {
|
|
72
|
+
if (cap.maxRequests <= 1 || promptTokens === undefined || inputTokenLimit === null) {
|
|
73
|
+
return { cap, cut: null };
|
|
74
|
+
}
|
|
75
|
+
const room = inputTokenLimit - promptTokens - CONTINUATION_REQUEST_OVERHEAD_TOKENS;
|
|
76
|
+
const most = Math.min(cap.ceiling, Math.max(room, cap.perRequest));
|
|
77
|
+
if (cap.effective <= most)
|
|
78
|
+
return { cap, cut: null };
|
|
79
|
+
const maxRequests = maxDecodeRequests(most, cap.perRequest);
|
|
80
|
+
return {
|
|
81
|
+
cap: {
|
|
82
|
+
wire: maxRequests === 1 ? most : cap.wire,
|
|
83
|
+
effective: most,
|
|
84
|
+
perRequest: cap.perRequest,
|
|
85
|
+
ceiling: most,
|
|
86
|
+
maxRequests,
|
|
87
|
+
},
|
|
88
|
+
cut: { from: cap.effective, to: most, inputTokenLimit },
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/** The progress and log line of a cut cap. */
|
|
92
|
+
export function describeInputWindowCut(cut) {
|
|
93
|
+
const n = (v) => v.toLocaleString('en-US');
|
|
94
|
+
return `maxOutputTokens cut from ${n(cut.from)} to ${n(cut.to)}: each continuation request sends the prompt again plus everything decoded before it, and the model's ${n(cut.inputTokenLimit)}-token input window holds no more`;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The cap a call's decode runs under: a long decode never sends a continuation request past the model's input
|
|
98
|
+
* window (`boundByInputWindow`). A cut is said on the call's progress channel and in the log.
|
|
99
|
+
*/
|
|
100
|
+
export function capThatRuns(call) {
|
|
101
|
+
const bounded = boundByInputWindow(call.cap, call.promptTokens, call.inputTokenLimit);
|
|
102
|
+
if (bounded.cut === null)
|
|
103
|
+
return bounded;
|
|
104
|
+
const note = `${call.tool}: ${describeInputWindowCut(bounded.cut)}`;
|
|
105
|
+
call.emit(note);
|
|
106
|
+
logger.warn(note);
|
|
107
|
+
return bounded;
|
|
108
|
+
}
|
|
109
|
+
/** The answer the output cap keeps beside a thinking budget: Gemini requires `thinkingBudget < maxOutputTokens`. */
|
|
110
|
+
export const ANSWER_RESERVE_TOKENS = 1_024;
|
|
111
|
+
/**
|
|
112
|
+
* The refusal of a caller's positive `thinkingBudget` that leaves less than the answer reserve under the caller's own
|
|
113
|
+
* `maxOutputTokens` (`cap`: what that cap became under the model's limits) — refused, never clamped to 0, which
|
|
114
|
+
* Gemini 3 Pro answers with a 400 that hides the cause. `null` when it fits, or the caller set either one not.
|
|
115
|
+
*/
|
|
116
|
+
export function thinkingBudgetRefusal(budget, requestedCap, cap) {
|
|
117
|
+
if (budget === undefined || budget <= 0 || requestedCap === undefined)
|
|
118
|
+
return null;
|
|
119
|
+
const least = budget + ANSWER_RESERVE_TOKENS;
|
|
120
|
+
if (cap >= least)
|
|
121
|
+
return null;
|
|
122
|
+
return `thinkingBudget (${budget}) + ${ANSWER_RESERVE_TOKENS}-token answer reserve exceeds maxOutputTokens (${cap}). Raise \`maxOutputTokens\` to at least ${least}, or lower \`thinkingBudget\`.`;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* The count mode the preflight runs in. A decode that may take more than one request bills its prompt once per
|
|
126
|
+
* request, so the budget reservation takes the exact count (`countTokens`) whatever mode was asked for; a
|
|
127
|
+
* one-request call keeps the caller's mode.
|
|
128
|
+
*/
|
|
129
|
+
export function preflightModeFor(requested, cap) {
|
|
130
|
+
return cap.maxRequests > 1 ? 'exact' : requested;
|
|
131
|
+
}
|
|
132
|
+
/** The requests a decode of `cap` tokens may take when each request decodes up to `perRequest` tokens. */
|
|
133
|
+
export function maxDecodeRequests(cap, perRequest) {
|
|
134
|
+
if (perRequest <= 0)
|
|
135
|
+
return 1;
|
|
136
|
+
return Math.max(1, Math.ceil(cap / perRequest));
|
|
137
|
+
}
|
|
138
|
+
/** The most one streaming request of a model with per-request limit `perRequest` decodes (M). */
|
|
139
|
+
function streamRequestTokens(perRequest) {
|
|
140
|
+
return Math.max(perRequest, LONG_DECODE_STREAM_REQUEST_TOKENS);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The input tokens the continuation requests bill again, at most, for a prompt of `promptTokens` tokens:
|
|
144
|
+
*
|
|
145
|
+
* R = ceil(C / L) requests (the client stops there; L = the per-request limit)
|
|
146
|
+
* M = max(L, 65 536) the most one streaming request decodes
|
|
147
|
+
* O = CONTINUATION_REQUEST_OVERHEAD_TOKENS what a continuation request bills beyond the two terms below
|
|
148
|
+
* re-billed input = Σ_{k=1..R−1} (P + min(k·M, C) + O)
|
|
149
|
+
*
|
|
150
|
+
* Request k sends the prompt P again plus the tokens decoded before it, which are at most k·M and below the cap C
|
|
151
|
+
* (the client opens no request once the decoded tokens reached C). The first request's prompt is not part of this
|
|
152
|
+
* sum.
|
|
153
|
+
*/
|
|
154
|
+
export function continuationInputTokens(promptTokens, cap, perRequest) {
|
|
155
|
+
const requests = maxDecodeRequests(cap, perRequest);
|
|
156
|
+
const perRequestCeiling = streamRequestTokens(perRequest);
|
|
157
|
+
let total = 0;
|
|
158
|
+
for (let k = 1; k < requests; k++) {
|
|
159
|
+
total +=
|
|
160
|
+
promptTokens + Math.min(k * perRequestCeiling, cap) + CONTINUATION_REQUEST_OVERHEAD_TOKENS;
|
|
161
|
+
}
|
|
162
|
+
return total;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* The most a decode of cap C produces (thinking and answer). One request honours `maxOutputTokens` = C. Over several
|
|
166
|
+
* requests C stays the bound only while Google holds `maxOutputTokens` over the whole chain, which the client cannot
|
|
167
|
+
* check: it stops after a request ends, once the decoded tokens reached C, so a server that holds the cap per
|
|
168
|
+
* request lets the last request run up to one request's decode past it — at most C + M − 1, and never more than
|
|
169
|
+
* R requests of M.
|
|
170
|
+
*/
|
|
171
|
+
export function decodedTokensBound(cap, perRequest) {
|
|
172
|
+
const requests = maxDecodeRequests(cap, perRequest);
|
|
173
|
+
if (requests === 1)
|
|
174
|
+
return cap;
|
|
175
|
+
const perRequestCeiling = streamRequestTokens(perRequest);
|
|
176
|
+
return Math.min(requests * perRequestCeiling, cap + perRequestCeiling - 1);
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=long-decode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"long-decode.js","sourceRoot":"","sources":["../../src/gemini/long-decode.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGzE,oEAAoE;AACpE,MAAM,CAAC,MAAM,wBAAwB,GAAG,SAAS,CAAC;AAElD,gHAAgH;AAChH,MAAM,CAAC,MAAM,iCAAiC,GAAG,MAAM,CAAC;AAExD,oHAAoH;AACpH,MAAM,WAAW,GAAG,uBAAuB,CAAC;AAK5C;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAe,EAAE,OAAmB;IACzE,IAAI,OAAO,KA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;AACjG,SAAS,mBAAmB,CAAC,UAAkB;IAC7C,OAAO,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,iCAAiC,CAAC,CAAC;AACjE,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,uBAAuB,CACrC,YAAoB,EACpB,GAAW,EACX,UAAkB;IAElB,MAAM,QAAQ,GAAG,iBAAiB,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IACpD,MAAM,iBAAiB,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC1D,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC;QAClC,KAAK;YACH,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,iBAAiB,EAAE,GAAG,CAAC,GAAG,oCAAoC,CAAC;IAC/F,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAW,EAAE,UAAkB;IAChE,MAAM,QAAQ,GAAG,iBAAiB,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IACpD,IAAI,QAAQ,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IAC/B,MAAM,iBAAiB,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC1D,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ,GAAG,iBAAiB,EAAE,GAAG,GAAG,iBAAiB,GAAG,CAAC,CAAC,CAAC;AAC7E,CAAC"}
|
|
@@ -13,6 +13,8 @@ export interface ModelInfo {
|
|
|
13
13
|
displayName: string;
|
|
14
14
|
inputTokenLimit: number | null;
|
|
15
15
|
outputTokenLimit: number | null;
|
|
16
|
+
/** The total a decode may reach through continuation requests (Gemini 4: 1 048 576); `null` without long decode. */
|
|
17
|
+
longDecodeTokenLimit: number | null;
|
|
16
18
|
supportsThinking: boolean;
|
|
17
19
|
/** Inferred from input limit ≥ 100k — a heuristic for context-cache eligibility. */
|
|
18
20
|
supportsLongContext: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-registry.d.ts","sourceRoot":"","sources":["../../src/gemini/model-registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAS,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"model-registry.d.ts","sourceRoot":"","sources":["../../src/gemini/model-registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAS,MAAM,eAAe,CAAC;AA6FxD,MAAM,WAAW,SAAS;IACxB,yDAAyD;IACzD,EAAE,EAAE,MAAM,CAAC;IACX,2EAA2E;IAC3E,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,oHAAoH;IACpH,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,gBAAgB,EAAE,OAAO,CAAC;IAC1B,oFAAoF;IACpF,mBAAmB,EAAE,OAAO,CAAC;IAC7B;;;OAGG;IACH,eAAe,EAAE,OAAO,CAAC;CAC1B;AA+BD,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,WAAW,EACnB,EAAE,KAAK,EAAE,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GAClC,OAAO,CAAC,SAAS,EAAE,CAAC,CAqBtB;AAED,iEAAiE;AACjE,wBAAgB,oBAAoB,IAAI,IAAI,CAG3C"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* tool call can force a refresh if the user upgrades their API tier mid-session.
|
|
6
6
|
*/
|
|
7
7
|
import { logger } from '../utils/logger.js';
|
|
8
|
+
import { longDecodeTokenLimitOf } from './long-decode.js';
|
|
8
9
|
import { categorizeModel, codenameRank, costTierOf, } from './model-taxonomy.js';
|
|
9
10
|
/**
|
|
10
11
|
* Google's unversioned `-latest` ids (`gemini-pro-latest`, `gemini-flash-latest`,
|
|
@@ -81,7 +82,7 @@ function normalizeId(raw) {
|
|
|
81
82
|
return '';
|
|
82
83
|
return raw.replace(/^models\//, '').trim();
|
|
83
84
|
}
|
|
84
|
-
function toModelInfo(model) {
|
|
85
|
+
function toModelInfo(model, backend) {
|
|
85
86
|
const id = normalizeId(model.name);
|
|
86
87
|
if (id.length === 0)
|
|
87
88
|
return null;
|
|
@@ -93,6 +94,7 @@ function toModelInfo(model) {
|
|
|
93
94
|
displayName: model.displayName ?? id,
|
|
94
95
|
inputTokenLimit: inputLimit,
|
|
95
96
|
outputTokenLimit: outputLimit,
|
|
97
|
+
longDecodeTokenLimit: longDecodeTokenLimitOf(id, backend),
|
|
96
98
|
supportsThinking: model.thinking === true,
|
|
97
99
|
supportsLongContext: inputLimit !== null && inputLimit >= 100_000,
|
|
98
100
|
supportsCaching: model.supportedActions?.includes('createCachedContent') ?? true,
|
|
@@ -106,9 +108,10 @@ export async function listAvailableModels(client, { force } = {}) {
|
|
|
106
108
|
if (!force && cached && now - cachedAt < TTL_MS)
|
|
107
109
|
return cached;
|
|
108
110
|
const pager = await client.models.list();
|
|
111
|
+
const backend = client.vertexai === true ? 'vertex' : 'developer';
|
|
109
112
|
const out = [];
|
|
110
113
|
for await (const model of pager) {
|
|
111
|
-
const info = toModelInfo(model);
|
|
114
|
+
const info = toModelInfo(model, backend);
|
|
112
115
|
if (info)
|
|
113
116
|
out.push(info);
|
|
114
117
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-registry.js","sourceRoot":"","sources":["../../src/gemini/model-registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAGL,eAAe,EACf,YAAY,EACZ,UAAU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","sourceRoot":"","sources":["../../src/gemini/models.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,aAAa,EAInB,MAAM,qBAAqB,CAAC;AAkD7B,QAAA,MAAM,OAAO;;iBAET,kBAAkB;iBAClB,WAAW,EAAE,sCAAsC;;;iBAGnD,kBAAkB;iBAClB,gBAAgB,UAAU,eAAe;iBACzC,WAAW,EAAE,4DAA4D;;;iBAGzE,kBAAkB;iBAClB,WAAW,EAAE,yCAAyC;;;iBAGtD,kBAAkB;iBAClB,WAAW,EAAE,0CAA0C;;;iBAGvD,kBAAkB;iBAClB,gBAAgB,UAAU,eAAe;iBACzC,WAAW,EAAE,yDAAyD;;CAE5B,CAAC;AAE/C,MAAM,MAAM,KAAK,GAAG,MAAM,OAAO,OAAO,CAAC;AAEzC,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,KAAK,CAErD;AAmCD;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;CACtD;AAED,wBAAsB,YAAY,CAChC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,aAAa,CAAC,
|
|
1
|
+
{"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../../src/gemini/models.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAGjD,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,aAAa,EAInB,MAAM,qBAAqB,CAAC;AAkD7B,QAAA,MAAM,OAAO;;iBAET,kBAAkB;iBAClB,WAAW,EAAE,sCAAsC;;;iBAGnD,kBAAkB;iBAClB,gBAAgB,UAAU,eAAe;iBACzC,WAAW,EAAE,4DAA4D;;;iBAGzE,kBAAkB;iBAClB,WAAW,EAAE,yCAAyC;;;iBAGtD,kBAAkB;iBAClB,WAAW,EAAE,0CAA0C;;;iBAGvD,kBAAkB;iBAClB,gBAAgB,UAAU,eAAe;iBACzC,WAAW,EAAE,yDAAyD;;CAE5B,CAAC;AAE/C,MAAM,MAAM,KAAK,GAAG,MAAM,OAAO,OAAO,CAAC;AAEzC,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,KAAK,CAErD;AAmCD;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,SAAS,aAAa,EAAE,CAAC;CACtD;AAED,wBAAsB,YAAY,CAChC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,aAAa,CAAC,CA2DxB;AAaD,wBAAgB,WAAW,IAAI,SAAS,KAAK,EAAE,CAE9C;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG;IAC3C,QAAQ,CAAC,kBAAkB,EAAE,SAAS,aAAa,EAAE,CAAC;IACtD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACnC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;CAClC,CAQA"}
|
package/dist/gemini/models.js
CHANGED
|
@@ -102,6 +102,7 @@ export async function resolveModel(requested, client, options = {}) {
|
|
|
102
102
|
fallbackApplied,
|
|
103
103
|
inputTokenLimit: picked.inputTokenLimit,
|
|
104
104
|
outputTokenLimit: picked.outputTokenLimit,
|
|
105
|
+
longDecodeTokenLimit: picked.longDecodeTokenLimit,
|
|
105
106
|
category: picked.category,
|
|
106
107
|
capabilities: picked.capabilities,
|
|
107
108
|
supportsCaching: picked.supportsCaching,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/gemini/models.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAkB,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAGL,0BAA0B,EAC1B,eAAe,EACf,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAE7B;;;;;;;;;;;;;;;GAeG;AACH,MAAM,oBAAoB,GAAG;IAC3B,OAAO;IACP,KAAK;IACL,QAAQ;IACR,OAAO;IACP,UAAU;IACV,aAAa;CACL,CAAC;AAEX,SAAS,mBAAmB,CAAC,OAAe;IAC1C,OAAO,oBAAoB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;AACzE,CAAC;AAqBD,MAAM,OAAO,GAAG;IACd,YAAY,EAAE;QACZ,kBAAkB,EAAE,CAAC,gBAAgB,CAAC;QACtC,WAAW,EAAE,sCAAsC;KACpD;IACD,qBAAqB,EAAE;QACrB,kBAAkB,EAAE,CAAC,gBAAgB,CAAC;QACtC,gBAAgB,EAAE,CAAC,KAAsB,EAAE,EAAE,CAAC,KAAK,CAAC,gBAAgB;QACpE,WAAW,EAAE,4DAA4D;KAC1E;IACD,cAAc,EAAE;QACd,kBAAkB,EAAE,CAAC,WAAW,CAAC;QACjC,WAAW,EAAE,yCAAyC;KACvD;IACD,aAAa,EAAE;QACb,kBAAkB,EAAE,CAAC,WAAW,CAAC;QACjC,WAAW,EAAE,0CAA0C;KACxD;IACD,e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,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5D,CAAC;IACD,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;SACzC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;SAC3B,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;IACtC,OAAO,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAY,CAAC;AACzC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,KAAY;IAMxC,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC5B,OAAO;QACL,kBAAkB,EAAE,CAAC,GAAG,IAAI,CAAC,kBAAkB,CAAC;QAChD,WAAW,EAAE,IAAI,CAAC,WAAW;QAC7B,gBAAgB,EAAE,KAAK,KAAK,qBAAqB;QACjD,cAAc,EAAE,KAAK,KAAK,eAAe;KAC1C,CAAC;AACJ,CAAC"}
|
package/dist/gemini/retry.d.ts
CHANGED
|
@@ -72,6 +72,14 @@ export declare function isTransientNetworkError(err: unknown): boolean;
|
|
|
72
72
|
* error shape they would have seen without retry wrapping.
|
|
73
73
|
*/
|
|
74
74
|
export declare function withNetworkRetry<T>(fn: () => Promise<T>, options?: NetworkRetryOptions): Promise<T>;
|
|
75
|
+
/** Throws the signal's reason (or synthesised AbortError) if aborted. */
|
|
76
|
+
export declare function throwIfAborted(signal: AbortSignal | undefined): void;
|
|
77
|
+
/**
|
|
78
|
+
* `work`'s outcome, or a rejection with the abort reason as soon as `signal` fires — whichever comes first. The
|
|
79
|
+
* caller is released at the abort even when `work` itself never settles; `work` runs on, its late outcome ignored
|
|
80
|
+
* (a late rejection is handled, never unhandled).
|
|
81
|
+
*/
|
|
82
|
+
export declare function abortable<T>(work: Promise<T>, signal: AbortSignal | undefined): Promise<T>;
|
|
75
83
|
/**
|
|
76
84
|
* `setTimeout(resolve, ms)` that also rejects with the abort reason when
|
|
77
85
|
* `signal` fires. Without abort awareness, a 9s backoff sleep — or worse, a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/gemini/retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,MAAM,WAAW,mBAAmB;IAClC,+EAA+E;IAC/E,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,kFAAkF;IAClF,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,mFAAmF;IACnF,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3D;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAUD;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAuB7D;AAED;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EACtC,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,CAAC,CAAC,CAsCZ;
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../../src/gemini/retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,MAAM,WAAW,mBAAmB;IAClC,+EAA+E;IAC/E,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,kFAAkF;IAClF,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,mFAAmF;IACnF,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3D;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAUD;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAuB7D;AAED;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CAAC,CAAC,EACtC,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,CAAC,CAAC,CAsCZ;AAED,yEAAyE;AACzE,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,IAAI,CAEpE;AAQD;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC,CA2B1F;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAwBzF"}
|
package/dist/gemini/retry.js
CHANGED
|
@@ -117,7 +117,7 @@ export async function withNetworkRetry(fn, options = {}) {
|
|
|
117
117
|
throw lastErr;
|
|
118
118
|
}
|
|
119
119
|
/** Throws the signal's reason (or synthesised AbortError) if aborted. */
|
|
120
|
-
function throwIfAborted(signal) {
|
|
120
|
+
export function throwIfAborted(signal) {
|
|
121
121
|
if (signal?.aborted)
|
|
122
122
|
throwAbortReason(signal);
|
|
123
123
|
}
|
|
@@ -127,6 +127,38 @@ function throwAbortReason(signal) {
|
|
|
127
127
|
throw reason;
|
|
128
128
|
throw new DOMException('Operation aborted', 'AbortError');
|
|
129
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* `work`'s outcome, or a rejection with the abort reason as soon as `signal` fires — whichever comes first. The
|
|
132
|
+
* caller is released at the abort even when `work` itself never settles; `work` runs on, its late outcome ignored
|
|
133
|
+
* (a late rejection is handled, never unhandled).
|
|
134
|
+
*/
|
|
135
|
+
export function abortable(work, signal) {
|
|
136
|
+
if (signal === undefined)
|
|
137
|
+
return work;
|
|
138
|
+
return new Promise((resolve, reject) => {
|
|
139
|
+
const onAbort = () => {
|
|
140
|
+
try {
|
|
141
|
+
throwAbortReason(signal);
|
|
142
|
+
}
|
|
143
|
+
catch (err) {
|
|
144
|
+
reject(err);
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
if (signal.aborted) {
|
|
148
|
+
onAbort();
|
|
149
|
+
work.catch(() => undefined);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
153
|
+
work.then((value) => {
|
|
154
|
+
signal.removeEventListener('abort', onAbort);
|
|
155
|
+
resolve(value);
|
|
156
|
+
}, (err) => {
|
|
157
|
+
signal.removeEventListener('abort', onAbort);
|
|
158
|
+
reject(err);
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
}
|
|
130
162
|
/**
|
|
131
163
|
* `setTimeout(resolve, ms)` that also rejects with the abort reason when
|
|
132
164
|
* `signal` fires. Without abort awareness, a 9s backoff sleep — or worse, a
|
package/dist/gemini/retry.js.map
CH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,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC7C,MAAM,CAAC,GAAG,CAAC,CAAC;QACd,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,cAAc,CAAC,EAAU,EAAE,MAA+B;IACxE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;YACpB,IAAI,CAAC;gBACH,gBAAgB,CAAC,MAAM,CAAC,CAAC;YAC3B,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,CAAC,GAAG,CAAC,CAAC;YACd,CAAC;YACD,OAAO;QACT,CAAC;QACD,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YAC5B,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC9C,OAAO,EAAE,CAAC;QACZ,CAAC,EAAE,EAAE,CAAC,CAAC;QACP,MAAM,OAAO,GAAG,GAAG,EAAE;YACnB,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,IAAI,CAAC;gBACH,IAAI,MAAM;oBAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;YACvC,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,CAAC,GAAG,CAAC,CAAC;YACd,CAAC;QACH,CAAC,CAAC;QACF,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool executor dispatcher — takes a FunctionCall, routes to the right
|
|
3
|
+
* executor, maps `SandboxError` → `response.error` (recoverable signal), and
|
|
4
|
+
* runs one iteration's calls in parallel under the concurrency cap. Every
|
|
5
|
+
* executor gets the pass's watch (its abort signal, its progress report); once
|
|
6
|
+
* the signal fired, no queued call starts.
|
|
7
|
+
*/
|
|
8
|
+
import type { MatchConfig } from '../../indexer/globs.js';
|
|
9
|
+
import { type ToolWatch } from './workspace-tools.js';
|
|
10
|
+
/** Read + clamp the tool-execution concurrency at dispatch time.
|
|
11
|
+
*
|
|
12
|
+
* Why a function not a top-level const: env vars can change between calls
|
|
13
|
+
* within a long-lived MCP-server process (operator ctrl-Cs and re-launches
|
|
14
|
+
* with a different value mid-session). Resolving per-call keeps behaviour
|
|
15
|
+
* predictable. Cost: one env-read per iter; negligible vs the
|
|
16
|
+
* `generateContent` round-trip dominating wall-clock.
|
|
17
|
+
*
|
|
18
|
+
* Clamps numeric inputs to `[1, 50]`. Only NaN / unset / empty falls back
|
|
19
|
+
* to default. 50 cap prevents pathological "concurrency: 99999" misconfig
|
|
20
|
+
* from spawning ~unbounded `read_file` Promise chains. 0 / negative inputs
|
|
21
|
+
* clamp UP to 1 (= serial dispatch) — operators setting `0` or `-3` mean
|
|
22
|
+
* "minimise parallelism", not "use the default" (the v1.15.1 PR-Round-1
|
|
23
|
+
* 2-of-2 cross-reviewer correction: gemini-cli F2 + grok F1 flagged that
|
|
24
|
+
* silently mapping operator-supplied `0` back to 10× was the opposite of
|
|
25
|
+
* intent and a confusing UX on resource-constrained CI / Windows hosts).
|
|
26
|
+
*
|
|
27
|
+
* Exported for unit testing — not part of the public MCP surface. */
|
|
28
|
+
export declare function resolveToolExecutionConcurrency(): number;
|
|
29
|
+
/** One function call as the model issued it. */
|
|
30
|
+
export interface ToolCall {
|
|
31
|
+
name: string;
|
|
32
|
+
args: Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
export interface DispatchedToolResult {
|
|
35
|
+
name: string;
|
|
36
|
+
/** What the model receives as the call's `functionResponse.response`: the executor's answer, or `{ error }`. */
|
|
37
|
+
response: Record<string, unknown>;
|
|
38
|
+
/** `true` when the call failed (an unknown tool, or an executor that threw): a failed `read_file` is never
|
|
39
|
+
* recorded as a file read (`recordRead`). */
|
|
40
|
+
isError: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Run one function call. SandboxError and anything else that happens in the
|
|
44
|
+
* executor surfaces as recoverable `response.error` so the model can try a
|
|
45
|
+
* different path. Hard failures (e.g. filesystem I/O errors) follow the same
|
|
46
|
+
* path — the worst case is we waste one iteration. An unknown function name
|
|
47
|
+
* returns an error response rather than throwing: the model may recover by
|
|
48
|
+
* picking a valid tool.
|
|
49
|
+
*/
|
|
50
|
+
export declare function dispatchToolCall(workspaceRoot: string, name: string, args: Record<string, unknown>, matchConfig: MatchConfig, watch?: ToolWatch): Promise<DispatchedToolResult>;
|
|
51
|
+
/** One iteration's tool calls as they run. */
|
|
52
|
+
export interface ToolBatch {
|
|
53
|
+
/** Every worker finished: each call it took settled, and it takes no more. Holds each call's result by position; a
|
|
54
|
+
* call never started (the signal fired first) has none. */
|
|
55
|
+
readonly settled: Promise<DispatchedToolResult[]>;
|
|
56
|
+
/** The executors started and not yet settled. */
|
|
57
|
+
running(): number;
|
|
58
|
+
/** The calls no worker took. */
|
|
59
|
+
neverStarted(): number;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Run up to `concurrency` dispatches in parallel, preserving call order. A worker takes the next call only while the
|
|
63
|
+
* watch's signal has not fired, so no queued call starts after it; a running executor gets the watch.
|
|
64
|
+
*/
|
|
65
|
+
export declare function startToolBatch(workspaceRoot: string, calls: readonly ToolCall[], concurrency: number, matchConfig: MatchConfig, watch: ToolWatch & {
|
|
66
|
+
readonly signal: AbortSignal;
|
|
67
|
+
}): ToolBatch;
|
|
68
|
+
//# sourceMappingURL=dispatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../../src/tools/agentic/dispatch.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAA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