@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
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,164 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [1.25.0] - 2026-11-17
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- `ask_agentic`: every phase of a pass now has a bound. A phase that could hang forever now ends with `TIMEOUT` after
|
|
15
|
+
its default: 600 s for each request's opening (until its first chunk; a request sent again after a network failure
|
|
16
|
+
gets the whole 600 s, and so does the backoff before it), 600 s for a stream that sends nothing (a `stall`), 120 s
|
|
17
|
+
without progress in an iteration's path resolution and tool batch — the executors report progress at every directory,
|
|
18
|
+
file and read, so a long healthy `grep` batch over a large workspace runs on — and 600 s for each request of the
|
|
19
|
+
forced-finalization pass (`rescueErrorCode: 'TIMEOUT'`). A default applies only where no knob bounds the phase:
|
|
20
|
+
`iterationTimeoutMs` (or `GEMINI_CODE_CONTEXT_AGENTIC_ITERATION_TIMEOUT_MS`) bounds every phase of an iteration,
|
|
21
|
+
`stallMs` (or `GEMINI_CODE_CONTEXT_AGENTIC_STALL_MS`) the gaps of a stream only. The TPM wait keeps the throttle's own
|
|
22
|
+
delay. Before, with neither knob set — and with only `stallMs` for everything but a stream's gaps — such a phase never
|
|
23
|
+
ended and held the pass's daily-budget and TPM reservations.
|
|
24
|
+
- `ask_agentic`: `iterationTimeoutMs` ends a tool batch at the bound, not when the batch returns; no queued tool call
|
|
25
|
+
starts once a bound fired, the executors get the abort signal, and a late result is dropped. A `TIMEOUT` is
|
|
26
|
+
`retryable: false` when tool calls still run 1 s after the bound (`toolCallsRunning` says how many).
|
|
27
|
+
- `ask`'s fallback to `ask_agentic` (`onWorkspaceTooLarge: 'fallback-to-agentic'`) forwards `stallMs` as the loop's
|
|
28
|
+
`stallMs`, no longer as a per-iteration wall clock: a healthy stream or a tool batch longer than `stallMs` answers.
|
|
29
|
+
With only `stallMs` set a pass has no wall clock — a stream that keeps sending ends at the model's output cap, a tool
|
|
30
|
+
batch that keeps reporting progress when its walk ends; a caller who wants a wall clock per iteration sets
|
|
31
|
+
`iterationTimeoutMs` (`timeoutMs` on `ask`).
|
|
32
|
+
`timeoutMs` still becomes `iterationTimeoutMs`. `iterTimeoutSource` is now always `'timeoutMs'` (the values
|
|
33
|
+
`'stallMs'` and `'min(timeoutMs,stallMs)'` are gone), and the result reports the forwarded `stallMs`.
|
|
34
|
+
- `ask_agentic`'s timeout messages no longer say "default disabled"; a bound that fired at its default names the
|
|
35
|
+
default and the knob that sets it.
|
|
36
|
+
|
|
37
|
+
### Added
|
|
38
|
+
|
|
39
|
+
- `ask_agentic`: a `TIMEOUT` result carries `timeoutPhase` (`tpm-wait`, `opening`, `stream`, `tools`) and
|
|
40
|
+
`timeoutSource` (`iterationTimeoutMs`, `stallMs`, `default`, or `external` — a timeout the SDK raised itself: the
|
|
41
|
+
message quotes it and names no bound of the call); `timeoutKind` keeps its two values (`stall` is a stream's gap
|
|
42
|
+
only). The forced-finalization pass's `AGENTIC_MAX_ITERATIONS` with `rescueErrorCode: 'TIMEOUT'` carries
|
|
43
|
+
`timeoutPhase` (`tpm-wait`, `finalization`) and `timeoutSource` too, and its message names the knob that raises the
|
|
44
|
+
bound. `ask`'s fallback lifts both to the top of its result, beside `timeoutKind`.
|
|
45
|
+
|
|
46
|
+
### Fixed
|
|
47
|
+
|
|
48
|
+
- `ask_agentic`: a tool batch longer than `stallMs` no longer ends the call as a false `stall`; the stall watchdog
|
|
49
|
+
watches the stream only.
|
|
50
|
+
- `ask_agentic`: a tool batch, or a path resolution at the `maxFilesRead` cap, that never returns no longer hangs the
|
|
51
|
+
call: it ends at `iterationTimeoutMs`, else after 120 s without progress, with the pass booked.
|
|
52
|
+
- `ask`'s fallback to `ask_agentic` uses `ask`'s knobs as `ask` resolved them — per call, else
|
|
53
|
+
`GEMINI_CODE_CONTEXT_ASK_TIMEOUT_MS` / `GEMINI_CODE_CONTEXT_ASK_STALL_MS` (the env vars were ignored) — stops `ask`'s
|
|
54
|
+
own timer at the hand-off, and its timeout messages name `timeoutMs` / `stallMs`, not `iterationTimeoutMs`. Where
|
|
55
|
+
`ask` set no knob of a kind, `GEMINI_CODE_CONTEXT_AGENTIC_ITERATION_TIMEOUT_MS` / `_STALL_MS` still bound the loop,
|
|
56
|
+
and the message names that variable, not an `ask` one that set nothing.
|
|
57
|
+
- `ask_agentic`: a 429 on a loop iteration seeds the throttle's retry hint once, not twice. `ask`, `code` and
|
|
58
|
+
`ask_agentic` seed the hint through one function, once per error.
|
|
59
|
+
- `ask_agentic`: a loop iteration whose response carries no `usageMetadata` is booked and released at its estimate
|
|
60
|
+
(50,000 input tokens), as the forced-finalization pass already was: it used to book 0 USD against the daily budget
|
|
61
|
+
and release its TPM reservation at 0 tokens, so later calls were throttled as if it had sent nothing.
|
|
62
|
+
- `ask_agentic` without a daily budget (`GEMINI_DAILY_BUDGET_USD` unset) writes a usage row for each pass that
|
|
63
|
+
reached the model, as `ask` and `code` do: `status` (`spentTodayUsd`) counted none of its spend.
|
|
64
|
+
- `ask_agentic`: a loop iteration whose model call completed and which then failed — a timeout in its tool batch, a
|
|
65
|
+
response that could not be read — is booked at what it billed; it used to book nothing against the daily budget.
|
|
66
|
+
The error result of a pass booked before it failed (the loop iteration's `TIMEOUT` or `UNKNOWN`, the forced pass's
|
|
67
|
+
`AGENTIC_MAX_ITERATIONS`) carries that pass's `cachedTokens`, `uncachedTokens`, `outputTokens`, `thinkingTokens`
|
|
68
|
+
and `costEstimateUsd`.
|
|
69
|
+
- `ask_agentic`: the message of an iteration `TIMEOUT` whose pass was booked says it is booked at the result's token
|
|
70
|
+
and cost fields; it used to say the request was booked 0 beside those fields.
|
|
71
|
+
- `ask_agentic`: a pass whose usage could not be read (the read threw after its model call completed) is booked at
|
|
72
|
+
its whole reservation — the input estimate plus the reserved output and thinking tokens; it used to be booked at
|
|
73
|
+
the input estimate alone.
|
|
74
|
+
- Docs and timeout messages: whether Google bills a request aborted after its stream opened is not measured; the server
|
|
75
|
+
books it 0, so for such a request the daily budget and the TPM window are not a bound. `docs/cost-model.md` names
|
|
76
|
+
this and the `ask_agentic` iteration's fixed 50,000-token estimate (*What the daily budget does not bound*); the
|
|
77
|
+
phrases "true upper bound" / "true cap" are gone.
|
|
78
|
+
- `ask` and `code`: an answer whose usage row cannot be written (a busy or failing database) is returned, and the
|
|
79
|
+
failed write is logged; the paid answer used to be lost behind an error.
|
|
80
|
+
|
|
81
|
+
### Security
|
|
82
|
+
|
|
83
|
+
- `ask_agentic`: `list_directory`, `find_files` and `grep` no longer show a file on the secret denylist that `read_file`
|
|
84
|
+
refuses — a basename such as `.env`, `.env.local`, `credentials.json`, `secrets.yaml` or `service-account.json`, or a
|
|
85
|
+
name ending in `.pem`, `.key` or another secret extension, in any case. Before, since these tools shipped with
|
|
86
|
+
`ask_agentic`, `list_directory` listed such files with their sizes, `find_files` listed those its source rules admit
|
|
87
|
+
(`credentials.json`, `secrets.json`, `secrets.yaml`, …), and `grep` returned their matching lines. The three tools and
|
|
88
|
+
`read_file` now read one denylist.
|
|
89
|
+
|
|
90
|
+
### Notes
|
|
91
|
+
|
|
92
|
+
- Minor release. `errorCode`, `timeoutKind` and every result field that existed keep their values and meaning. What an
|
|
93
|
+
existing caller can observe: an `ask_agentic` call that hung with no knob set now ends with `TIMEOUT` at a default; a
|
|
94
|
+
`TIMEOUT` can be `retryable: false` (tool calls of the iteration still run); on `ask`'s fallback `stallMs` no longer
|
|
95
|
+
ends a healthy iteration, and `iterTimeoutSource` no longer takes the values `'stallMs'` and
|
|
96
|
+
`'min(timeoutMs,stallMs)'`; `list_directory`, `find_files` and `grep` no longer show a file on the secret denylist.
|
|
97
|
+
|
|
98
|
+
## [1.24.0] - 2026-11-17
|
|
99
|
+
|
|
100
|
+
### Added
|
|
101
|
+
|
|
102
|
+
- **Long decode on Gemini 4** (`ask`, `code`): a `maxOutputTokens` above the per-request limit (65,536) is sent as
|
|
103
|
+
asked on Gemini 4 Argon, Carbon and Hydrogen, up to 1,048,576. A response that stops with
|
|
104
|
+
`finishReason: CONTINUATION` is continued with the same request and Google's continuation token until the model
|
|
105
|
+
stops or the cap is reached, at most `ceil(maxOutputTokens ÷ L)` requests (`L` the model's advertised per-request
|
|
106
|
+
limit: 65,536 on Hydrogen, 32,768 on Argon); the result is one answer with one thinking summary, its token fields
|
|
107
|
+
and `costEstimateUsd` summed over the requests, and `continuationHops` (`0` for a call that ended in one request).
|
|
108
|
+
Measured on gemini-4-hydrogen at `XHIGH`: review prompts of 99,712 and 153,906 tokens that stopped at 65,533
|
|
109
|
+
thinking tokens with no answer now answer in two requests (1.0485 and 1.3164 USD). Without `maxOutputTokens` a call
|
|
110
|
+
is one request, as before. Named limits: `ask_agentic` (its own loop, one model call per iteration) and the Vertex AI
|
|
111
|
+
backend are not covered — on a Vertex client the cap is clamped to the per-request limit whatever the shape of the
|
|
112
|
+
model id (a plain `gemini-4-…` id included). Each continuation request sends the prompt again plus everything decoded
|
|
113
|
+
before it, so a long decode is bounded by the model's input window as well: when the counted prompt leaves less room
|
|
114
|
+
than the cap, the decode runs to what the window leaves (never below one request) and the result names the cut in
|
|
115
|
+
`outputCapCutByInputWindow` (`from`, `to`, `inputTokenLimit`). A request that makes no progress —
|
|
116
|
+
it returns the continuation token it was sent with, or decodes nothing — ends the decode instead of being sent again
|
|
117
|
+
up to the request limit. A continuation request refused at its opening with 429 or 503 (nothing of it billed) is
|
|
118
|
+
sent again with the same token after Google's retry hint, once its TPM throttle reservation is taken again for the
|
|
119
|
+
minute it is sent in; one request's opening makes at most three SDK calls on `standard` (network retries and
|
|
120
|
+
reopenings together), one on `flex`.
|
|
121
|
+
`timeoutMs` (30 minutes at most) fits about 7 to 9 requests at the measured pace; when it fires the completed
|
|
122
|
+
requests are billed and reported. `stallMs` does not count the time before a continuation request's first chunk.
|
|
123
|
+
- `finishReason` and `truncated` on every `ask` and `code` result: `truncated: true` when the answer has text but
|
|
124
|
+
stopped at the output cap (`MAX_TOKENS`, or a long decode that ended on `CONTINUATION`) — the answer is cut. `code`
|
|
125
|
+
then leads its text with a `[truncated]` line: its edit list is incomplete and must not be applied as complete.
|
|
126
|
+
- `errorCode: OUTPUT_CAP` for a call that stops at the output cap with no answer (`MAX_TOKENS`, or a long decode cut
|
|
127
|
+
at its cap); the error carries the billed token fields, `costEstimateUsd`, `continuationHops` and `finishReason`,
|
|
128
|
+
and names the remedy for the cap that ran: raise `maxOutputTokens` below the model's per-request limit, ask above
|
|
129
|
+
the limit on a Gemini 4 model, raise it above the cap after a long decode, or lower the thinking level when the cap
|
|
130
|
+
is the most the model allows.
|
|
131
|
+
|
|
132
|
+
### Changed
|
|
133
|
+
|
|
134
|
+
- `@google/genai` 3.4 (from 1.52): its `FinishReason` has `CONTINUATION` and a candidate keeps its
|
|
135
|
+
`continuationToken`. Every request is sent with `automaticContinuation: false` (the SDK's default is on): `ask` and
|
|
136
|
+
`code` drive the continuation themselves so they can count the requests and bound them, and `ask_agentic` keeps one
|
|
137
|
+
request per model call.
|
|
138
|
+
- `GEMINI_DAILY_BUDGET_USD`: the reservation of a long decode adds the input every continuation request bills again
|
|
139
|
+
(the prompt plus what was decoded before it, plus 256 tokens a request for what the API bills beyond them), and its
|
|
140
|
+
output covers one request's decode past the cap where the cap is not a multiple of a request's decode; the formula
|
|
141
|
+
is in `docs/cost-model.md`. The reservation's prompt is the larger of the bytes ÷ 4 heuristic and the preflight's
|
|
142
|
+
count, and a decode that may take more than one request takes the exact `countTokens` count whatever
|
|
143
|
+
`preflightMode` asked for.
|
|
144
|
+
- `ask` / `code`: a call that fails after one or more of its requests completed (a continuation request that fails, a
|
|
145
|
+
timeout) keeps what those requests billed in the daily budget ledger and releases only the rest of its
|
|
146
|
+
reservation; the error carries their token fields, `costEstimateUsd` and `continuationHops`.
|
|
147
|
+
- `ask` / `code`: a context cache that expires after a request of a long decode completed ends the call with an error
|
|
148
|
+
and the completed requests billed — the decode is no longer restarted on a rebuilt cache, which billed every request
|
|
149
|
+
again under a reservation sized for one decode. A stale cache at the first request is still rebuilt and the call
|
|
150
|
+
sent once more. Before each request of a decode, the cache it reads is marked hot and, when it expires within 15
|
|
151
|
+
minutes, extended at once (the TTL watcher's own tick runs every 5 minutes).
|
|
152
|
+
- `ask` / `code`: each request of a long decode holds its own TPM throttle reservation (the prompt plus what was
|
|
153
|
+
decoded before it), settled at the input it reported.
|
|
154
|
+
- `ask` / `code`: a request that completed but reported no usage is booked in the daily budget ledger at the input it
|
|
155
|
+
was estimated to send — the rule `ask_agentic` already applied — instead of at 0 USD, which released the whole
|
|
156
|
+
reservation for billed work.
|
|
157
|
+
|
|
158
|
+
- Development only: `npm run check:supports` compares `server.json` (`version` and every `packages[].version`) and the
|
|
159
|
+
root of `package-lock.json` (`version`, and `packages[""].version` where the lockfile has that map) with
|
|
160
|
+
`package.json` too, beside the README heading, and prints every mismatch; both files are required. The release
|
|
161
|
+
workflow runs it instead of its own `server.json` step, which stays only for a tag older than the script.
|
|
162
|
+
`npm run check:addresses` (`scripts/check-addresses.mjs`, run by CI, `prepublishOnly` and by the release workflow)
|
|
163
|
+
fails on an email address outside `qmediat.io` in a tracked text file — a repository's fixture addresses are allowed
|
|
164
|
+
only in their own file — and exits 2 when a tracked file cannot be read. Every address-shaped text — a last label of
|
|
165
|
+
two or more letters — outside the allowed domains and their subdomains is reported, nothing is exempt by its shape,
|
|
166
|
+
and an exact per-file allowlist in the script holds what a file must show. Nothing in the published package changes.
|
|
167
|
+
|
|
10
168
|
## [1.23.1] - 2026-11-15
|
|
11
169
|
|
|
12
170
|
### Changed
|
|
@@ -1798,7 +1956,9 @@ Integration-test-surfaced and review-surfaced fixes landed before the v1.0.0 rel
|
|
|
1798
1956
|
- MIME type simplified to `text/plain` for all files.
|
|
1799
1957
|
- Unit test coverage gaps for cache-manager / files-uploader / ttl-watcher / profile-loader / parseEdits tracked in [`docs/FOLLOW-UP-PRS.md`](docs/FOLLOW-UP-PRS.md).
|
|
1800
1958
|
|
|
1801
|
-
[Unreleased]: https://github.com/qmediat/gemini-code-context-mcp/compare/v1.
|
|
1959
|
+
[Unreleased]: https://github.com/qmediat/gemini-code-context-mcp/compare/v1.25.0...HEAD
|
|
1960
|
+
[1.25.0]: https://github.com/qmediat/gemini-code-context-mcp/compare/v1.24.0...v1.25.0
|
|
1961
|
+
[1.24.0]: https://github.com/qmediat/gemini-code-context-mcp/compare/v1.23.1...v1.24.0
|
|
1802
1962
|
[1.23.1]: https://github.com/qmediat/gemini-code-context-mcp/compare/v1.23.0...v1.23.1
|
|
1803
1963
|
[1.23.0]: https://github.com/qmediat/gemini-code-context-mcp/compare/v1.22.1...v1.23.0
|
|
1804
1964
|
[1.22.1]: https://github.com/qmediat/gemini-code-context-mcp/compare/v1.22.0...v1.22.1
|
package/README.md
CHANGED
|
@@ -14,10 +14,39 @@ export declare class TtlWatcher {
|
|
|
14
14
|
private timer;
|
|
15
15
|
/** Re-entrancy guard: a slow `caches.update` round-trip must not overlap the next tick. */
|
|
16
16
|
private tickInProgress;
|
|
17
|
+
/** The refresh running for each cache name: the tick and every keep-alive of that cache join it. */
|
|
18
|
+
private readonly refreshing;
|
|
17
19
|
constructor(client: GoogleGenAI, manifest: ManifestDb);
|
|
18
20
|
start(): void;
|
|
19
21
|
stop(): void;
|
|
20
22
|
markHot(workspaceRoot: string, cacheId: string, ttlSeconds: number): void;
|
|
23
|
+
/**
|
|
24
|
+
* A request is about to be sent on the cache: mark it hot and, when it expires within the refresh window
|
|
25
|
+
* (15 minutes), extend it now instead of at the next tick — so a decode of many requests, each opened through here,
|
|
26
|
+
* never sends one on a cache that expires before the request ends (a request of a decode lasts minutes). The
|
|
27
|
+
* keep-alive is best-effort: a failed refresh, or a manifest that cannot be read or written, is logged and leaves
|
|
28
|
+
* the request to meet the cache as it is.
|
|
29
|
+
*
|
|
30
|
+
* `signal` is the calling request's: an aborted signal starts no refresh, and the wait ends with its abort reason the
|
|
31
|
+
* moment it fires — the only rejection of this method, so a slow or hanging refresh never holds a call past its
|
|
32
|
+
* timeout. The refresh itself carries no caller's signal: it is shared by every keep-alive of the cache and by the
|
|
33
|
+
* tick, so it runs to its end for the others when the call that started it leaves.
|
|
34
|
+
*/
|
|
35
|
+
keepAlive(workspaceRoot: string, cacheId: string, ttlSeconds: number, signal?: AbortSignal): Promise<void>;
|
|
36
|
+
private hotEntry;
|
|
21
37
|
private tick;
|
|
38
|
+
/**
|
|
39
|
+
* The one refresh of the entry's cache: the running one when there is one, else a new one. It never rejects — a
|
|
40
|
+
* failure of the refresh or of the manifest is logged here, for the tick and the keep-alive alike.
|
|
41
|
+
*/
|
|
42
|
+
private refresh;
|
|
43
|
+
/** Extends the entry's cache when it expires within the refresh window; drops an entry whose cache is gone. */
|
|
44
|
+
private refreshIfDue;
|
|
45
|
+
/**
|
|
46
|
+
* The expiry the API answered goes to the manifest row as it is NOW — read again after the round-trip, so a row
|
|
47
|
+
* rewritten meanwhile keeps its other fields, and a row that moved to another cache is left alone.
|
|
48
|
+
*/
|
|
49
|
+
private storeExpiry;
|
|
50
|
+
private updateFailed;
|
|
22
51
|
}
|
|
23
52
|
//# sourceMappingURL=ttl-watcher.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ttl-watcher.d.ts","sourceRoot":"","sources":["../../src/cache/ttl-watcher.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"ttl-watcher.d.ts","sourceRoot":"","sources":["../../src/cache/ttl-watcher.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAiB,WAAW,EAAE,MAAM,eAAe,CAAC;AAEhE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAoBpD,qBAAa,UAAU;IASnB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAT3B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAA+B;IACnD,OAAO,CAAC,KAAK,CAA+B;IAC5C,2FAA2F;IAC3F,OAAO,CAAC,cAAc,CAAS;IAC/B,oGAAoG;IACpG,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAoC;IAE/D,YACmB,MAAM,EAAE,WAAW,EACnB,QAAQ,EAAE,UAAU,EACnC;IAEJ,KAAK,IAAI,IAAI,CAOZ;IAED,IAAI,IAAI,IAAI,CAMX;IAED,OAAO,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAExE;IAED;;;;;;;;;;;OAWG;IACG,SAAS,CACb,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,MAAM,EAClB,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,IAAI,CAAC,CAIf;IAED,OAAO,CAAC,QAAQ;YAMF,IAAI;IAuBlB;;;OAGG;IACH,OAAO,CAAC,OAAO;IAYf,+GAA+G;YACjG,YAAY;IAuB1B;;;OAGG;IACH,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,YAAY;CAqBrB"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* with a new `ttl` value. We only refresh caches that were used in the last
|
|
6
6
|
* 10 minutes — cold workspaces are allowed to expire.
|
|
7
7
|
*/
|
|
8
|
+
import { abortable, throwIfAborted } from '../gemini/retry.js';
|
|
8
9
|
import { logger, safeForLog } from '../utils/logger.js';
|
|
9
10
|
const TICK_MS = 5 * 60 * 1000; // 5 minutes
|
|
10
11
|
const HOT_WINDOW_MS = 10 * 60 * 1000; // used in last 10 minutes
|
|
@@ -21,6 +22,8 @@ export class TtlWatcher {
|
|
|
21
22
|
timer = null;
|
|
22
23
|
/** Re-entrancy guard: a slow `caches.update` round-trip must not overlap the next tick. */
|
|
23
24
|
tickInProgress = false;
|
|
25
|
+
/** The refresh running for each cache name: the tick and every keep-alive of that cache join it. */
|
|
26
|
+
refreshing = new Map();
|
|
24
27
|
constructor(client, manifest) {
|
|
25
28
|
this.client = client;
|
|
26
29
|
this.manifest = manifest;
|
|
@@ -42,12 +45,29 @@ export class TtlWatcher {
|
|
|
42
45
|
this.hot.clear();
|
|
43
46
|
}
|
|
44
47
|
markHot(workspaceRoot, cacheId, ttlSeconds) {
|
|
45
|
-
this.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
this.hotEntry(workspaceRoot, cacheId, ttlSeconds);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* A request is about to be sent on the cache: mark it hot and, when it expires within the refresh window
|
|
52
|
+
* (15 minutes), extend it now instead of at the next tick — so a decode of many requests, each opened through here,
|
|
53
|
+
* never sends one on a cache that expires before the request ends (a request of a decode lasts minutes). The
|
|
54
|
+
* keep-alive is best-effort: a failed refresh, or a manifest that cannot be read or written, is logged and leaves
|
|
55
|
+
* the request to meet the cache as it is.
|
|
56
|
+
*
|
|
57
|
+
* `signal` is the calling request's: an aborted signal starts no refresh, and the wait ends with its abort reason the
|
|
58
|
+
* moment it fires — the only rejection of this method, so a slow or hanging refresh never holds a call past its
|
|
59
|
+
* timeout. The refresh itself carries no caller's signal: it is shared by every keep-alive of the cache and by the
|
|
60
|
+
* tick, so it runs to its end for the others when the call that started it leaves.
|
|
61
|
+
*/
|
|
62
|
+
async keepAlive(workspaceRoot, cacheId, ttlSeconds, signal) {
|
|
63
|
+
throwIfAborted(signal);
|
|
64
|
+
const entry = this.hotEntry(workspaceRoot, cacheId, ttlSeconds);
|
|
65
|
+
await abortable(this.refresh(entry, Date.now()), signal);
|
|
66
|
+
}
|
|
67
|
+
hotEntry(workspaceRoot, cacheId, ttlSeconds) {
|
|
68
|
+
const entry = { workspaceRoot, cacheId, lastUsed: Date.now(), ttlSeconds };
|
|
69
|
+
this.hot.set(workspaceRoot, entry);
|
|
70
|
+
return entry;
|
|
51
71
|
}
|
|
52
72
|
async tick() {
|
|
53
73
|
// Prevent overlap: if the previous tick is still running (slow Gemini
|
|
@@ -60,51 +80,92 @@ export class TtlWatcher {
|
|
|
60
80
|
this.tickInProgress = true;
|
|
61
81
|
try {
|
|
62
82
|
const now = Date.now();
|
|
63
|
-
for (const
|
|
83
|
+
for (const entry of [...this.hot.values()]) {
|
|
64
84
|
if (now - entry.lastUsed > HOT_WINDOW_MS) {
|
|
65
|
-
this.hot.delete(
|
|
85
|
+
this.hot.delete(entry.workspaceRoot);
|
|
66
86
|
continue;
|
|
67
87
|
}
|
|
68
|
-
|
|
69
|
-
if (!ws?.cacheId || ws.cacheId !== entry.cacheId) {
|
|
70
|
-
this.hot.delete(key);
|
|
71
|
-
continue;
|
|
72
|
-
}
|
|
73
|
-
if (ws.cacheExpiresAt !== null && ws.cacheExpiresAt - now > REFRESH_IF_EXPIRES_WITHIN_MS) {
|
|
74
|
-
continue; // plenty of time left
|
|
75
|
-
}
|
|
76
|
-
try {
|
|
77
|
-
await this.client.caches.update({
|
|
78
|
-
name: entry.cacheId,
|
|
79
|
-
config: { ttl: `${entry.ttlSeconds}s` },
|
|
80
|
-
});
|
|
81
|
-
const newExpires = now + entry.ttlSeconds * 1000;
|
|
82
|
-
this.manifest.upsertWorkspace({ ...ws, cacheExpiresAt: newExpires, updatedAt: now });
|
|
83
|
-
logger.debug(`refreshed TTL for ${safeForLog(entry.cacheId)}`);
|
|
84
|
-
}
|
|
85
|
-
catch (err) {
|
|
86
|
-
// Evict the entry when Gemini reports the cache is gone (deleted
|
|
87
|
-
// externally, admin quota action, etc). Without this, we'd retry
|
|
88
|
-
// the update every TICK_MS forever and log-spam the 404.
|
|
89
|
-
if (isNotFoundError(err)) {
|
|
90
|
-
logger.debug(`ttl refresh for ${entry.cacheId} returned not-found; dropping hot entry and nulling manifest cacheId`);
|
|
91
|
-
this.hot.delete(key);
|
|
92
|
-
this.manifest.upsertWorkspace({
|
|
93
|
-
...ws,
|
|
94
|
-
cacheId: null,
|
|
95
|
-
cacheExpiresAt: null,
|
|
96
|
-
updatedAt: now,
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
logger.debug(`ttl refresh failed for ${safeForLog(entry.cacheId)}: ${safeForLog(err)}`);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
88
|
+
await this.refresh(entry, now);
|
|
103
89
|
}
|
|
104
90
|
}
|
|
105
91
|
finally {
|
|
106
92
|
this.tickInProgress = false;
|
|
107
93
|
}
|
|
108
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* The one refresh of the entry's cache: the running one when there is one, else a new one. It never rejects — a
|
|
97
|
+
* failure of the refresh or of the manifest is logged here, for the tick and the keep-alive alike.
|
|
98
|
+
*/
|
|
99
|
+
refresh(entry, now) {
|
|
100
|
+
const running = this.refreshing.get(entry.cacheId);
|
|
101
|
+
if (running !== undefined)
|
|
102
|
+
return running;
|
|
103
|
+
const started = this.refreshIfDue(entry, now)
|
|
104
|
+
.catch((err) => {
|
|
105
|
+
logger.warn(`ttl refresh failed for ${safeForLog(entry.cacheId)}: ${safeForLog(err)}`);
|
|
106
|
+
})
|
|
107
|
+
.finally(() => this.refreshing.delete(entry.cacheId));
|
|
108
|
+
this.refreshing.set(entry.cacheId, started);
|
|
109
|
+
return started;
|
|
110
|
+
}
|
|
111
|
+
/** Extends the entry's cache when it expires within the refresh window; drops an entry whose cache is gone. */
|
|
112
|
+
async refreshIfDue(entry, now) {
|
|
113
|
+
const ws = this.manifest.getWorkspace(entry.workspaceRoot);
|
|
114
|
+
if (!ws?.cacheId || ws.cacheId !== entry.cacheId) {
|
|
115
|
+
this.hot.delete(entry.workspaceRoot);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (ws.cacheExpiresAt !== null && ws.cacheExpiresAt - now > REFRESH_IF_EXPIRES_WITHIN_MS) {
|
|
119
|
+
return; // plenty of time left
|
|
120
|
+
}
|
|
121
|
+
let answered;
|
|
122
|
+
try {
|
|
123
|
+
answered = await this.client.caches.update({
|
|
124
|
+
name: entry.cacheId,
|
|
125
|
+
config: { ttl: `${entry.ttlSeconds}s` },
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
catch (err) {
|
|
129
|
+
this.updateFailed(entry, err);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
this.storeExpiry(entry, expiryOf(answered, entry.ttlSeconds));
|
|
133
|
+
logger.debug(`refreshed TTL for ${safeForLog(entry.cacheId)}`);
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* The expiry the API answered goes to the manifest row as it is NOW — read again after the round-trip, so a row
|
|
137
|
+
* rewritten meanwhile keeps its other fields, and a row that moved to another cache is left alone.
|
|
138
|
+
*/
|
|
139
|
+
storeExpiry(entry, expiresAt) {
|
|
140
|
+
const current = this.manifest.getWorkspace(entry.workspaceRoot);
|
|
141
|
+
if (current?.cacheId !== entry.cacheId)
|
|
142
|
+
return;
|
|
143
|
+
this.manifest.upsertWorkspace({ ...current, cacheExpiresAt: expiresAt, updatedAt: Date.now() });
|
|
144
|
+
}
|
|
145
|
+
updateFailed(entry, err) {
|
|
146
|
+
// Evict the entry when Gemini reports the cache is gone (deleted
|
|
147
|
+
// externally, admin quota action, etc). Without this, we'd retry
|
|
148
|
+
// the update every TICK_MS forever and log-spam the 404.
|
|
149
|
+
if (!isNotFoundError(err)) {
|
|
150
|
+
logger.debug(`ttl refresh failed for ${safeForLog(entry.cacheId)}: ${safeForLog(err)}`);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
logger.debug(`ttl refresh for ${entry.cacheId} returned not-found; dropping hot entry and nulling manifest cacheId`);
|
|
154
|
+
this.hot.delete(entry.workspaceRoot);
|
|
155
|
+
const current = this.manifest.getWorkspace(entry.workspaceRoot);
|
|
156
|
+
if (current?.cacheId !== entry.cacheId)
|
|
157
|
+
return;
|
|
158
|
+
this.manifest.upsertWorkspace({
|
|
159
|
+
...current,
|
|
160
|
+
cacheId: null,
|
|
161
|
+
cacheExpiresAt: null,
|
|
162
|
+
updatedAt: Date.now(),
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/** The expiry `caches.update` answered; the requested TTL from now when the answer carries none. */
|
|
167
|
+
function expiryOf(answered, ttlSeconds) {
|
|
168
|
+
const parsed = answered.expireTime === undefined ? Number.NaN : Date.parse(answered.expireTime);
|
|
169
|
+
return Number.isFinite(parsed) ? parsed : Date.now() + ttlSeconds * 1000;
|
|
109
170
|
}
|
|
110
171
|
//# sourceMappingURL=ttl-watcher.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ttl-watcher.js","sourceRoot":"","sources":["../../src/cache/ttl-watcher.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"ttl-watcher.js","sourceRoot":"","sources":["../../src/cache/ttl-watcher.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAExD,MAAM,OAAO,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,YAAY;AAC3C,MAAM,aAAa,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,0BAA0B;AAChE,MAAM,4BAA4B,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AASpD,sFAAsF;AACtF,SAAS,eAAe,CAAC,GAAY;IACnC,MAAM,GAAG,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC7D,OAAO,2DAA2D,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC/E,CAAC;AAED,MAAM,OAAO,UAAU;IASF,MAAM;IACN,QAAQ;IATV,GAAG,GAAG,IAAI,GAAG,EAAoB,CAAC;IAC3C,KAAK,GAA0B,IAAI,CAAC;IAC5C,2FAA2F;IACnF,cAAc,GAAG,KAAK,CAAC;IAC/B,oGAAoG;IACnF,UAAU,GAAG,IAAI,GAAG,EAAyB,CAAC;IAE/D,YACmB,MAAmB,EACnB,QAAoB;sBADpB,MAAM;wBACN,QAAQ;IACxB,CAAC;IAEJ,KAAK;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AAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAChG,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,UAAU,GAAG,IAAI,CAAC;AAC3E,CAAC"}
|
package/dist/gemini/client.d.ts
CHANGED
|
@@ -3,5 +3,12 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { GoogleGenAI } from '@google/genai';
|
|
5
5
|
import type { AuthProfile } from '../types.js';
|
|
6
|
+
/**
|
|
7
|
+
* The Gemini Developer API version every request of an API-key client goes to. `@google/genai` defaults to the
|
|
8
|
+
* stable `v1`, which has no `cachedContents` resource (an explicit Context Cache answers 404 there); `v1beta`
|
|
9
|
+
* serves every surface this server calls — the Files API, `cachedContents`, `models`, `countTokens`,
|
|
10
|
+
* `generateContent` and its stream. Set in the constructor, it also wins over `GOOGLE_GENAI_API_VERSION`.
|
|
11
|
+
*/
|
|
12
|
+
export declare const GEMINI_API_VERSION = "v1beta";
|
|
6
13
|
export declare function createGeminiClient(profile: AuthProfile): GoogleGenAI;
|
|
7
14
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/gemini/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/gemini/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAc/C;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,WAAW,CAAC;AAE3C,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,WAAW,GAAG,WAAW,CAapE"}
|
package/dist/gemini/client.js
CHANGED
|
@@ -13,10 +13,17 @@ import { GoogleGenAI } from '@google/genai';
|
|
|
13
13
|
// handled at the tool layer by `isGemini429` + `parseRetryDelayMs` (see
|
|
14
14
|
// `src/tools/shared/throttle.ts`). Pre-response network failures are handled
|
|
15
15
|
// by `withNetworkRetry` in `src/gemini/retry.ts`.
|
|
16
|
+
/**
|
|
17
|
+
* The Gemini Developer API version every request of an API-key client goes to. `@google/genai` defaults to the
|
|
18
|
+
* stable `v1`, which has no `cachedContents` resource (an explicit Context Cache answers 404 there); `v1beta`
|
|
19
|
+
* serves every surface this server calls — the Files API, `cachedContents`, `models`, `countTokens`,
|
|
20
|
+
* `generateContent` and its stream. Set in the constructor, it also wins over `GOOGLE_GENAI_API_VERSION`.
|
|
21
|
+
*/
|
|
22
|
+
export const GEMINI_API_VERSION = 'v1beta';
|
|
16
23
|
export function createGeminiClient(profile) {
|
|
17
24
|
switch (profile.kind) {
|
|
18
25
|
case 'api-key':
|
|
19
|
-
return new GoogleGenAI({ apiKey: profile.apiKey });
|
|
26
|
+
return new GoogleGenAI({ apiKey: profile.apiKey, apiVersion: GEMINI_API_VERSION });
|
|
20
27
|
case 'vertex':
|
|
21
28
|
// Vertex path implicitly uses ADC (gcloud application-default credentials).
|
|
22
29
|
// Set GEMINI_USE_VERTEX=true + GOOGLE_CLOUD_PROJECT to route through here.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/gemini/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,+EAA+E;AAC/E,8EAA8E;AAC9E,8EAA8E;AAC9E,gFAAgF;AAChF,4EAA4E;AAC5E,4EAA4E;AAC5E,+EAA+E;AAC/E,0EAA0E;AAC1E,wEAAwE;AACxE,6EAA6E;AAC7E,kDAAkD;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/gemini/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,+EAA+E;AAC/E,8EAA8E;AAC9E,8EAA8E;AAC9E,gFAAgF;AAChF,4EAA4E;AAC5E,4EAA4E;AAC5E,+EAA+E;AAC/E,0EAA0E;AAC1E,wEAAwE;AACxE,6EAA6E;AAC7E,kDAAkD;AAElD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,QAAQ,CAAC;AAE3C,MAAM,UAAU,kBAAkB,CAAC,OAAoB;IACrD,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,SAAS;YACZ,OAAO,IAAI,WAAW,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,kBAAkB,EAAE,CAAC,CAAC;QACrF,KAAK,QAAQ;YACX,4EAA4E;YAC5E,2EAA2E;YAC3E,OAAO,IAAI,WAAW,CAAC;gBACrB,QAAQ,EAAE,IAAI;gBACd,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,QAAQ,EAAE,OAAO,CAAC,QAAQ;aAC3B,CAAC,CAAC;IACP,CAAC;AACH,CAAC"}
|