@qmediat.io/gemini-code-context-mcp 1.0.3 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/CHANGELOG.md +94 -0
  2. package/dist/config.d.ts +12 -0
  3. package/dist/config.d.ts.map +1 -1
  4. package/dist/config.js +13 -1
  5. package/dist/config.js.map +1 -1
  6. package/dist/gemini/models.d.ts.map +1 -1
  7. package/dist/gemini/models.js +34 -25
  8. package/dist/gemini/models.js.map +1 -1
  9. package/dist/indexer/globs.d.ts.map +1 -1
  10. package/dist/indexer/globs.js +18 -0
  11. package/dist/indexer/globs.js.map +1 -1
  12. package/dist/indexer/workspace-validation.d.ts.map +1 -1
  13. package/dist/indexer/workspace-validation.js +33 -0
  14. package/dist/indexer/workspace-validation.js.map +1 -1
  15. package/dist/server.d.ts.map +1 -1
  16. package/dist/server.js +6 -0
  17. package/dist/server.js.map +1 -1
  18. package/dist/tools/ask.tool.d.ts +25 -1
  19. package/dist/tools/ask.tool.d.ts.map +1 -1
  20. package/dist/tools/ask.tool.js +215 -5
  21. package/dist/tools/ask.tool.js.map +1 -1
  22. package/dist/tools/code.tool.d.ts +24 -1
  23. package/dist/tools/code.tool.d.ts.map +1 -1
  24. package/dist/tools/code.tool.js +136 -17
  25. package/dist/tools/code.tool.js.map +1 -1
  26. package/dist/tools/registry.d.ts +24 -0
  27. package/dist/tools/registry.d.ts.map +1 -1
  28. package/dist/tools/registry.js +27 -1
  29. package/dist/tools/registry.js.map +1 -1
  30. package/dist/tools/shared/thinking.d.ts +63 -0
  31. package/dist/tools/shared/thinking.d.ts.map +1 -0
  32. package/dist/tools/shared/thinking.js +62 -0
  33. package/dist/tools/shared/thinking.js.map +1 -0
  34. package/dist/tools/shared/throttle.d.ts +121 -0
  35. package/dist/tools/shared/throttle.d.ts.map +1 -0
  36. package/dist/tools/shared/throttle.js +357 -0
  37. package/dist/tools/shared/throttle.js.map +1 -0
  38. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,100 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.3.0] — 2026-04-20
11
+
12
+ Reviewer-workflow unblock release. Two fixes that turn the MCP from "works on the happy path" into "actually usable for back-to-back `/coderev`-style pipelines": a client-side TPM (tokens-per-minute) throttle preflight, and a wire-format fix that lets MCP sub-agents extract tool output text.
13
+
14
+ Without these, a second `ask` or `code` call against a workspace with ~100k cached tokens hit Gemini's Tier 1 paid quota of 100_000 input tokens/minute and 429'd the call after Google had already billed for it (per `@google/genai` SDK: "AbortSignal is a client-only operation … you will still be charged"). And any sub-agent orchestration that made decisions on tool response text silently saw empty output, because Claude Code (and other MCP hosts) consume only `structuredContent` when present — `content[0].text` was invisible on the sub-agent path, even though the main conversation UI rendered it fine.
15
+
16
+ ### Added
17
+
18
+ - **`GEMINI_CODE_CONTEXT_TPM_THROTTLE_LIMIT` env var** (default `80_000`, `0` disables). Client-side tokens-per-minute ceiling per resolved model. `ask` and `code` now call `throttle.reserve(model, estimatedInputTokens)` after the daily-budget reservation but BEFORE `generateContent`; if the call would push the rolling 60-second window past the cap, the tool sleeps (emitting a `throttle: waiting Ns for TPM window…` progress message) before issuing the request. Default leaves ~20% headroom under the observed Tier 1 paid limit of 100_000 tokens/min for Gemini 3 Pro. Raise it on higher tiers, lower on shared quota pools, or set `0` to disable entirely (relies on Gemini's 429 behaviour alone). Cached tokens count toward this limit — empirically confirmed.
19
+ - **`src/tools/shared/throttle.ts`** — new shared module implementing the `reserve` / `release` / `cancel` reservation lifecycle. The primary API is reservation-based, not a read-only `shouldDelay` peek, because MCP's async `CallToolRequestSchema` handler dispatches concurrent tool calls — a peek-only API lets two callers observe the same pre-peek window and both proceed, collectively overshooting the cap. `reserve` inserts a provisional `WindowEntry` immediately at `now + delayMs` so concurrent reserves see each other's footprint. Multi-entry eviction math iterates oldest-first until remaining sum + estimate ≤ limit, then waits for the last-evicted entry to age out (the naïve "wait for just the oldest" implementation under-delays whenever ≥2 large entries remain in-window). Backward clock handled via a throttle-level `lastObservedNowMs` floor (using `entry.tsMs` for the clamp breaks multi-entry math when a future-dated provisional exists). Tests in `test/unit/throttle.test.ts` (33 cases, fake timers).
20
+ - **`RESPONSE_TEXT_KEY` constant** exported from `src/tools/registry.ts` — canonical key (`"responseText"`) under which MCP clients consuming `structuredContent` can reliably find the tool's primary narrative response. Consumers can `import { RESPONSE_TEXT_KEY }` rather than hard-coding the string.
21
+
22
+ ### Fixed
23
+
24
+ - **Sub-agent tool-result extraction via `structuredContent.responseText`.** `textResult()` and `errorResult()` now always emit `structuredContent` with a `responseText` field mirroring the narrative string. The primary `content: [{type:'text', text}]` path stays for MCP spec compliance and for hosts (Claude Code's main conversation UI) that render it — duplicating a few-KB string across both surfaces costs effectively nothing vs losing the whole response on sub-agent paths that read only `structuredContent`. Before this fix, three reviewer-agent runs of `/coderev` against PR #17 returned "API success but text not surfaced" because Gemini generated the review text and we billed for it, but every downstream consumer (`reindex`, `clear`, `status`, `ask`, `code`) whose response shape included `structuredContent` shadowed `content[].text` on the sub-agent tool-result parser. 8 tests in `test/unit/registry-text-result.test.ts` lock in the invariant (both success and error paths, mirror-equality, caller-override semantics).
25
+ - **Error responses now surface detail to sub-agents.** `errorResult(message)` additionally sets `structuredContent.responseText = message` so orchestrations that make decisions on error text (e.g. "did the tool say `daily budget cap exceeded` vs `Gemini 500`?") can extract it. `isError: true` still signals failure; `responseText` carries detail. Parallel to the success-path fix.
26
+
27
+ ### Changed
28
+
29
+ - **`ToolContext` gained a `throttle: TpmThrottle` field.** Per-server-process singleton instantiated in `runServer()` from `config.tpmThrottleLimit`. No caller-visible change — consumers that build a `ToolContext` directly (internal tests only) must add the field.
30
+
31
+ ### Reviewer notes (not a code change)
32
+
33
+ - **Phase 1 of this PR was rewritten in response to a 3-way code review.** The original throttle design was a peek-only `shouldDelay` API with single-entry-eviction math. Grok (`grok-4.20-beta-0309-reasoning`) flagged two HIGH findings in `/coderev` + `/6step` analysis: (1) multi-entry eviction under-delays when ≥2 large entries remain in-window; (2) TOCTOU race between `shouldDelay` and `record` across the `await sleep()` + `await generateContent()` boundary. Both fixed before the module ever integrated with `ask`/`code`.
34
+ - **A second round of review on the integrated PR (Copilot + GPT `gpt-5.3-codex` + Grok + Gemini `gemini-3.1-pro-preview`) surfaced four more correctness fixes shipped in this release:**
35
+ - **Sorted-array invariant** (Copilot + Grok + Gemini — HIGH). `reserve` previously used `push` to append; a `delayMs = 0` reservation arriving after a future-dated provisional (hint-driven or eviction-driven delay) produced a smaller `tsMs` than the provisional, leaving the array unsorted. `prune`'s head-only fast-path silently skipped expired entries buried mid-array (empirically demonstrated: `reserve(79999)` returned `delayMs=46000` when the correct answer was `0`). Fixed via binary-search `insertSortedByTsMs`. Three regression tests lock it in.
36
+ - **Reserve timing pre-prepareContext** (GPT + Grok — MEDIUM). `reserve` was called BEFORE `prepareContext`, so on cold-cache calls (30–60s upload + `caches.create`) the reservation's `tsMs` aged out of our window before Gemini's per-minute quota counter caught up. Gap of ~30–60s where our throttle said "clear" but Gemini's didn't. Fixed by moving `reserve` to immediately before `generateContent`. Trade-off: two concurrent cold-cache callers both finish `prepareContext` before one backs off at `reserve` — mostly idempotent via file-hash dedup, minor upload duplication.
37
+ - **Retry-hint extend-only** (Gemini — MEDIUM). `recordRetryHint` used to blindly overwrite any existing hint. A shorter hint replacing a longer one let the next reserve compute a smaller `tsMs` than entries appended under the longer hint — same ordering break as the sorted-insert fix, different trigger. `recordRetryHint` now keeps the longer expiry when both exist.
38
+ - **Release lifecycle** (GPT — LOW). `release` previously left the reservation id in `reservationIndex`, so a late `cancel` on an already-released id silently removed an accounted entry from the window. `release` now deletes the id at the end, making double-`release` and `cancel`-after-`release` safe no-ops.
39
+ - **Randomised jitter** (Gemini — LOW). The `JITTER_MS` constant was 2_000 ms — every concurrent waiter evicting the same entry computed an identical wait and woke at the same millisecond, re-creating the thundering herd the jitter was meant to avoid. Now randomised in `[1_000, 3_000]` ms via `computeJitterMs()`.
40
+ - 7 new regression tests (40 total, up from 33) covering each of the above paths.
41
+ - Disputed severity on the wire-format `structuredContent` always-emit (Grok CRITICAL / Gemini acceptable / GPT nit / self-review LOW). No observable MCP-host break was constructed; shipping as-is with the additive-only semantics called out in `### Fixed` above.
42
+ - **Retry-hint parsing from Gemini 429 response bodies (`retryInfo.retryDelay`) is a follow-up (T22a).** The throttle module exposes `recordRetryHint(model, retryDelayMs)` but this PR does NOT wire it up from the `ask`/`code` catch blocks — the preflight `reserve` path delivers ~95% of the value, and parsing the retry hint out of `@google/genai`'s error message text is unstructured and brittle without a dedicated harness.
43
+ - **A third round of review (same 4 reviewers, commit `c097ad9`) surfaced one more correctness fix and four cosmetic cleanups — all shipped in this release:**
44
+ - **Stale-cache retry re-reservation** (GPT — MEDIUM). The round-2 fix moved `reserve` to after `prepareContext` for first dispatch, but the stale-cache retry branch was still reusing the original reservation — whose `tsMs` was stamped before the first (failed) dispatch. After the ~15s rebuild, the retry's tokens hit Gemini's quota counter at a time our window already had tagged as "expired soon". 15s gap re-introduced. Fixed by extracting `reserveForDispatch()` helper and calling `cancel + reserveForDispatch` inside the stale-cache retry branch before the second `generateContent`. Symmetric in `ask.tool.ts` and `code.tool.ts`. New throttle-level regression test locks it in.
45
+ - **`shouldDelay` pure vs jittered split** (Gemini — LOW). Previously `shouldDelay` inherited the random jitter from `computeWindowDelay`, so diagnostic polling saw bouncing values for unchanged state. Split into `computeWindowDelayPure` (used by `shouldDelay`) and `computeWindowDelay` (used by `reserve`, applies jitter only when actual waiting is needed).
46
+ - **`computeJitterMs()` range now `[1000, 3000]` inclusive** (Copilot — NIT). Previous formula `Math.floor(Math.random() * (MAX - MIN))` capped at 2999; `+ 1` in the multiplier width makes `JITTER_MAX_MS` reachable. Docstring + test comment aligned.
47
+ - **Explicit shorter-hint no-op assertion** (Grok — NIT). Added a direct `expect(r2.delayMs).toBeGreaterThan(5_000)` to the existing downgrade test so the extend-only semantics are guarded by a boolean invariant, not just an implicit delay range.
48
+ - Deferred to follow-ups (T22b, T23a — see `docs/FOLLOW-UP-PRS.md`): ask/code integration tests + `ToolResult.structuredContent` type narrowing. Both are LOW/NIT; no blockers.
49
+ - Disputed-severity items held as-shipped: wire-format `textResult` always-emit `structuredContent` (Grok CRITICAL vs 3-of-4 acceptable — no observable MCP-host break, ship additive-only with CHANGELOG callout); reserve-after-prepareContext cold-cache duplication (Grok CRITICAL vs documented trade-off — `prepareContext` coalesces via per-workspace mutex, so real duplication is minor).
50
+ - FPs confirmed by `/6step`: forward NTP leaps (Grok agrees FP), early-validation cancel leak (`-1` sentinel covers all paths), `sanitizeTokens` daily-budget path (scan + Zod + reserve-internal sanitize suffice), `finally` around cancel (no unguarded `return` between reserve and release).
51
+ - 41 throttle tests total (up from 40 in round-2) — new stale-cache-retry regression. 185 total PR tests (up from 184). Lint + typecheck + build all green.
52
+
53
+ ## [1.2.0] — 2026-04-20
54
+
55
+ Reasoning-control release. Two big additions + one security fix. The `ask` and `code` tools now support Google's full Gemini 3 reasoning surface: discrete-tier `thinkingLevel` (MINIMAL/LOW/MEDIUM/HIGH, Google's recommended knob on 3.x) alongside the existing `thinkingBudget` integer. The two knobs are mutually exclusive at the schema boundary (Gemini rejects the combination with 400 anyway). `ask` also gets dynamic-thinking by default — omitting both fields makes the model use its native default path (HIGH on Gemini 3 Pro) rather than the "legacy" explicit-budget path Google flags as "may result in unexpected performance". And the model-alias resolver now rejects non-text-gen `pro` families (nano-banana image-gen, lyria music-gen, deep-research agent, customtools variant) that were sneaking in under the `latest-pro` alias and routing text requests through the image-tier quota bucket.
56
+
57
+ Security-critical fix: `validateWorkspacePath` now refuses the user's home directory as a workspace. Previously, a tool call omitting the `workspace` argument fell through to `process.cwd() === $HOME` (the canonical MCP launch pattern sets cwd to home) and passed the cwd-ancestry check — so the scanner would recursively walk `Desktop`, `Documents`, `Downloads`, `.Trash`, and upload matched files to the Gemini Files API. Home is now explicitly rejected with an actionable error, and `DEFAULT_EXCLUDE_DIRS` expanded with home-level user directories as defense in depth.
58
+
59
+ ### Security
60
+
61
+ - **`validateWorkspacePath` now refuses the user's home directory as a workspace.** The canonical MCP launch pattern sets `cwd: $HOME` (to sidestep an `npx`-in-same-repo conflict documented in the README). Before this fix, an `ask`/`code`/`reindex` call that omitted the `workspace` argument fell through to `process.cwd() === $HOME` and PASSED the existing cwd-ancestry check — so the scanner would recursively walk `Desktop`, `Documents`, `Downloads`, `.Trash`, and everything else under `$HOME`, uploading matched files to the Gemini Files API. The guard now canonicalises both `workspaceRoot` and `os.homedir()` via `realpathSync` and refuses any path whose canonical form equals the canonical home directory — regardless of whether home happens to contain a `.git` or other workspace marker, and regardless of symlink bypass attempts. Error message tells the caller explicitly to pass `workspace` with a real project root. Orthogonal defense in depth: `DEFAULT_EXCLUDE_DIRS` now excludes `.Trash`, `Trash` (Linux), `Library` (macOS), `Downloads`, `Desktop`, `Documents`, `Movies`, `Music`, `Pictures`, `Videos`, and `Public` — so even an edge-case path that bypasses the root guard can't exfiltrate those directories' contents. 4 regression tests added under `test/unit/workspace-validation.test.ts` → "refuses the user's home directory as a workspace".
62
+
63
+ ### Added
64
+
65
+ - **`code({ thinkingLevel })` parameter** — T21 ships `thinkingLevel` (`MINIMAL` / `LOW` / `MEDIUM` / `HIGH`) on the `code` tool, matching the `ask` surface from v1.2. Google's recommended reasoning knob on Gemini 3 (ai.google.dev/gemini-api/docs/gemini-3); `thinkingBudget` remains the legacy/Gemini-2.5 path, and the two are mutually exclusive (Zod `.refine()` refuses both-set at the schema root with the same cross-field error ask uses). `code` keeps its pre-existing `thinkingBudget` default of 16_384 — coding tasks benefit from strong reasoning out of the box, and changing that default would be a behavioural break for existing callers.
66
+ - **`src/tools/shared/thinking.ts`** — new shared module hosting `THINKING_LEVELS` and `THINKING_LEVEL_RESERVE`, moved out of `ask.tool.ts`. Single source of truth for both tools. When Google publishes per-tier token budgets (or ships a new level), one edit propagates to `ask` + `code` and any future reasoning-capable tool we add (e.g. when T19/T20 land).
67
+
68
+ ### Changed
69
+
70
+ - **`code`'s structured metadata now echoes `thinkingLevel`** (null when the caller used `thinkingBudget` instead), alongside the existing `thinkingBudget` field. Callers can audit which path the request took — mirrors `ask`'s metadata shape.
71
+
72
+ ### Fixed (post-review on PR #17)
73
+
74
+ - **`code` metadata `thinkingBudget` now reports `null` on the `thinkingLevel` path** (was `0`). Three reviewers flagged this: GPT, Copilot, and self-review all noted that `0` is the wire sentinel for "thinking disabled" and emitting it for a level-path call misleads audit / dashboard consumers who aggregate by `thinkingBudget === 0`. The fix mirrors `ask`'s behaviour — when `usingThinkingLevel` is true, the metadata field is `null`, consistent with the `thinkingLevel` sibling field's null-when-unused convention.
75
+ - **Tier-reserve defensive clamp against `maxOutputTokens - 1024`** — fixed-value tier reserves (MINIMAL=512, LOW=2048, MEDIUM=4096) now clamp against the dynamic output headroom before being passed into `estimatePreCallCostUsd`. No impact on today's Gemini model lineup (all current text-gen models have `outputTokenLimit ≥ 8_192`), but prevents a future small-cap model from producing an over-reserved budget estimate that could false-reject calls on `GEMINI_DAILY_BUDGET_USD`. PR #17 self-review F2.
76
+
77
+ ### Reviewer notes (PR #17, not a code change)
78
+
79
+ - **Grok flag "unsafe `input.thinkingLevel as ThinkingLevel` cast" — confirmed FALSE POSITIVE by three exploit attempts in `/6step` analysis.** The cast preserves the literal string all the way to Gemini's wire. If `@google/genai` renames an enum member in a future release, TypeScript rejects the cast at `tsc` time (string-enum value mismatch); if Google silently changes the backend enum encoding (e.g. string → numeric), Gemini returns a 400 with a clear message. No scenario produces silent `undefined`. The rationale is documented in an inline comment at `src/tools/code.tool.ts:303-307` — kept as-is. This is the SAFER pattern vs runtime `ThinkingLevel[key]` lookup, which the `ask` tool adopted in v1.2 for the same reason.
80
+
81
+ ### Changed (post-review polish on PR #16, `ask({ thinkingLevel })`)
82
+
83
+ - **Tier-aware cost-estimate reservations for `thinkingLevel`** — `MINIMAL` now reserves 512 thinking tokens, `LOW` 2_048, `MEDIUM` 4_096, `HIGH` the full `maxOutputTokens - 1024` dynamic cap. Replaces the previous always-worst-case behaviour that could false-reject long sequences of `MINIMAL`/`LOW` calls against `GEMINI_DAILY_BUDGET_USD` when the real spend was ≤1% of the reservation. Values are heuristic upper bounds (Google does not publish per-tier budgets). Exported as `THINKING_LEVEL_RESERVE` from `src/tools/ask.tool.ts` for testing and future reuse in `code.tool.ts` (tracked as T21).
84
+ - **`thinkingLevel` send-path uses a string cast, not an enum bracket lookup** — passing `input.thinkingLevel as ThinkingLevel` survives a future `@google/genai` enum-member rename: Gemini will 400 the literal string with a clear error instead of our code silently serialising `undefined`. Equivalent runtime behaviour on the current pinned `1.50.1`.
85
+ - **Mutual-exclusion error attaches at schema root** — `.refine()` now emits `path: []` (root-level) rather than `path: ['thinkingLevel']`, so MCP clients rendering per-field errors don't misattribute the cross-field violation to one of the two fields.
86
+ - **Single source of truth for `thinkingLevel` detection** — extracted `const usingThinkingLevel` to replace three identical `input.thinkingLevel !== undefined` checks (cost estimate, emitter, thinkingConfig build). Prevents future drift between the three branches.
87
+ - **Explicit `ThinkingConfig` type annotation on the built config** — catches a hypothetical future SDK field-shape change at `tsc` time rather than at runtime.
88
+
89
+ ### Fixed
90
+
91
+ - **Model-alias resolution no longer picks up Google's non-text-gen `pro` families.** `nano-banana-pro-preview` (image generation) and `lyria-3-pro-preview` (music generation) both share the `pro` substring our `latest-pro` / `latest-pro-thinking` aliases matched on, and the live registry returns them *before* `gemini-pro-latest`. Pre-fix: `.find()` grabbed banana first, so every `ask`/`code` call resolved to an image-gen model — image-tier pricing (~10× text rates), 128k input cap, and hitting the `gemini-3-pro-image` quota after three calls. The exclude list now filters `banana`, `lyria`, `research` (Deep Research is a specialised agent, not a drop-in conversational model), and `customtools` (variant that errors without a `tools` param) across all four aliases. Existing `image`/`tts`/`vision`/`audio` filters kept. Extracted into a single `NON_TEXT_GEN_MARKERS` source of truth so future Google families land in one edit.
92
+
93
+ ### Added
94
+
95
+ - **`ask({ thinkingBudget })` parameter** — optional integer in `[-1, 65_536]`. OMIT it (the default) to let each model use its native thinking tier — the recommended path, and the only one Google supports without caveats on Gemini 3 (which defaults to HIGH dynamic thinking on Pro). Pass an explicit value only when you need a specific cap: `-1` = legacy dynamic (Gemini 2.5 and older), `0` = disable thinking (rejected by Gemini 3 Pro), positive integer = fixed cap. Per Google's Gemini 3 guide, explicit `thinkingBudget` is "legacy" on the 3 family and "may result in unexpected performance"; our implementation therefore omits the field on the wire when the caller didn't supply one, sidestepping empirical hangs we reproduced on Gemini 3 Pro + cached content at low positive budgets (see `docs/KNOWN-DEFICITS.md`). Mirrors the knob `code` already exposed; closes the gap where `ask` had no way to control thinking at all.
96
+ - **Thinking summary surfaced on the MCP response** — `ask` always sets `includeThoughts: true` on the Gemini request, so when the model emits parts flagged `thought: true` we include a trimmed (~1.2 KB) `thinkingSummary` field in structured metadata. Works with or without an explicit `thinkingBudget`.
97
+ - **`ask({ thinkingLevel })` parameter** — discrete reasoning tier (`MINIMAL` | `LOW` | `MEDIUM` | `HIGH`) matching Gemini 3's native `thinking_level` API (ai.google.dev/gemini-api/docs/gemini-3). This is **Google's recommended knob** on the Gemini 3 family; `thinkingBudget` is the legacy escape hatch for Gemini 2.5 compatibility. The two parameters are **mutually exclusive** — Gemini rejects requests that set both with `400 ("cannot use both thinking_level and the legacy thinking_budget parameter")`, so we refuse the combination at the schema boundary with a clear Zod error. Callers now have three ways to control reasoning: omit both (model-native default, recommended), set `thinkingLevel` (discrete tier for Gemini 3), or set `thinkingBudget` (fine-grained cap for Gemini 2.5 or cost-bounded sessions). The `thinkingLevel` field is surfaced in structured metadata alongside `thinkingBudget` so callers can audit which path was taken. Unsupported values on a given model (e.g. `MINIMAL` on Gemini 3 Pro, any level on Gemini 2.5) are rejected by Gemini at request time — we deliberately do not hard-code per-model validation so the MCP surface stays stable across model rollouts.
98
+
99
+ ### Changed
100
+
101
+ - **Default model is now `latest-pro-thinking`** (was `latest-pro`). The alias resolver already preferred the newest Pro-class model with `supportsThinking: true`, but the server default didn't opt into it — so `ask` landed on non-thinking models unless callers passed `model: "latest-pro-thinking"` explicitly. New default means `ask` and `code` both reason at full strength out of the box. Override via `GEMINI_CODE_CONTEXT_DEFAULT_MODEL=latest-pro` if you need the non-thinking variant, or set a flash alias for cost-sensitive workloads.
102
+ - **Budget reservation is thinking-aware** — `ask` now passes `thinkingTokens` into `estimatePreCallCostUsd`, mirroring `code`. Because Gemini 3 Pro always spends thinking tokens (cannot be disabled per Google's docs), reservations for callers who omit `thinkingBudget` still reserve the full `maxOutputTokens - 1024` as reasoning headroom — so `GEMINI_DAILY_BUDGET_USD` stays a TRUE upper bound regardless of which thinking tier the model picks. Without this, a high-thinking call could silently overshoot the cap; now it fails fast with the standard budget-cap message.
103
+
10
104
  ## [1.0.3] — 2026-04-19
11
105
 
12
106
  Security + cost-correctness release. Closes a HIGH-severity prompt-injection vector that let a malicious MCP client exfiltrate local files via the `workspace` argument, and a MEDIUM-severity TOCTOU race that let concurrent tool calls collectively overshoot `GEMINI_DAILY_BUDGET_USD`. Also bundles drift-guards and hardening surfaced by a full 3-way code review (GPT, Gemini, Grok) plus three Copilot review rounds. No breaking changes — all existing workspace paths under the MCP host's cwd continue to work without any config.
package/dist/config.d.ts CHANGED
@@ -20,6 +20,18 @@ export interface Config {
20
20
  maxFileSizeBytes: number;
21
21
  /** Opt-in anonymous usage telemetry (count per tool, no payloads). */
22
22
  telemetryEnabled: boolean;
23
+ /**
24
+ * Client-side TPM (tokens-per-minute) throttle ceiling, per resolved model.
25
+ * `0` disables the throttle entirely; positive integer caps how many input
26
+ * tokens (cached + uncached) we'll let fly to Gemini inside any 60-second
27
+ * window before delaying the next call. Default `80_000` leaves ~20%
28
+ * headroom under Gemini's observed Tier 1 paid limit of 100_000 tokens/min
29
+ * for Gemini 3 Pro; raise if your key is on a higher tier, lower if you
30
+ * share a quota pool with another app. See `src/tools/shared/throttle.ts`
31
+ * for the reservation protocol and `docs/FOLLOW-UP-PRS.md` T22 for the
32
+ * full rationale.
33
+ */
34
+ tpmThrottleLimit: number;
23
35
  }
24
36
  export declare function loadConfig(): Config;
25
37
  //# sourceMappingURL=config.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,KAAK,YAAY,EAAe,MAAM,0BAA0B,CAAC;AAE1E,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,YAAY,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB;;;;;OAKG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB,uDAAuD;IACvD,oBAAoB,EAAE,MAAM,CAAC;IAC7B,2CAA2C;IAC3C,gBAAgB,EAAE,MAAM,CAAC;IACzB,sEAAsE;IACtE,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAgBD,wBAAgB,UAAU,IAAI,MAAM,CAqBnC"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,KAAK,YAAY,EAAe,MAAM,0BAA0B,CAAC;AAE1E,MAAM,WAAW,MAAM;IACrB,IAAI,EAAE,YAAY,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB;;;;;OAKG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB,uDAAuD;IACvD,oBAAoB,EAAE,MAAM,CAAC;IAC7B,2CAA2C;IAC3C,gBAAgB,EAAE,MAAM,CAAC;IACzB,sEAAsE;IACtE,gBAAgB,EAAE,OAAO,CAAC;IAC1B;;;;;;;;;;OAUG;IACH,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAgBD,wBAAgB,UAAU,IAAI,MAAM,CAkCnC"}
package/dist/config.js CHANGED
@@ -18,8 +18,19 @@ function readFloatEnv(name, fallback) {
18
18
  }
19
19
  export function loadConfig() {
20
20
  const auth = resolveAuth();
21
- const defaultModel = process.env.GEMINI_CODE_CONTEXT_DEFAULT_MODEL ?? auth.defaultModel ?? 'latest-pro';
21
+ // Default alias resolves to the newest Pro-class model that advertises
22
+ // `supportsThinking: true`. This gives `ask`/`code` the strongest available
23
+ // reasoning out of the box — users trading quality for cost can override via
24
+ // `GEMINI_CODE_CONTEXT_DEFAULT_MODEL=latest-pro` (or a literal model ID).
25
+ const defaultModel = process.env.GEMINI_CODE_CONTEXT_DEFAULT_MODEL ?? auth.defaultModel ?? 'latest-pro-thinking';
22
26
  const dailyBudget = readFloatEnv('GEMINI_DAILY_BUDGET_USD', auth.dailyBudgetUsd ?? Number.POSITIVE_INFINITY);
27
+ // TPM throttle: clamp to a non-negative integer. Negative / non-finite
28
+ // env values (`-1`, `"foo"`) fall back to the 80k default rather than
29
+ // silently disabling the throttle — operator intent when setting an
30
+ // invalid value is almost certainly "use the default", not "turn it off"
31
+ // (which has its own explicit `0` sentinel).
32
+ const tpmThrottleRaw = readIntEnv('GEMINI_CODE_CONTEXT_TPM_THROTTLE_LIMIT', 80_000);
33
+ const tpmThrottleLimit = tpmThrottleRaw >= 0 ? tpmThrottleRaw : 80_000;
23
34
  return {
24
35
  auth,
25
36
  defaultModel,
@@ -29,6 +40,7 @@ export function loadConfig() {
29
40
  maxFilesPerWorkspace: readIntEnv('GEMINI_CODE_CONTEXT_MAX_FILES', 2000),
30
41
  maxFileSizeBytes: readIntEnv('GEMINI_CODE_CONTEXT_MAX_FILE_SIZE', 1_000_000),
31
42
  telemetryEnabled: process.env.GEMINI_CODE_CONTEXT_TELEMETRY === 'true',
43
+ tpmThrottleLimit,
32
44
  };
33
45
  }
34
46
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AA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,41 @@
8
8
  */
9
9
  import { logger } from '../utils/logger.js';
10
10
  import { listAvailableModels } from './model-registry.js';
11
+ /**
12
+ * Substrings in a model ID that disqualify it as a general-purpose text-gen
13
+ * target for our `ask` / `code` tools. The list covers:
14
+ *
15
+ * - Modality add-ons that share `pro`/`flash` tokens with text models
16
+ * (`image`, `tts`, `vision`, `audio`) — these fail on arbitrary prompts.
17
+ * - Non-text-gen Gemini families whose IDs happen to contain `pro`:
18
+ * `banana` (Google's "nano-banana" image-gen family), `lyria` (music
19
+ * generation), `research` (Deep Research — a specialised agent, not a
20
+ * drop-in conversational model), and `customtools` (variant that requires
21
+ * a `tools` param on every call and returns errors without one).
22
+ *
23
+ * Maintained as a single source of truth so every alias filters consistently.
24
+ * When Google ships a new non-text-gen family under a `pro`/`flash` name,
25
+ * add the disambiguating substring here — no per-alias edits needed.
26
+ */
27
+ const NON_TEXT_GEN_MARKERS = [
28
+ 'image',
29
+ 'tts',
30
+ 'vision',
31
+ 'audio',
32
+ 'banana',
33
+ 'lyria',
34
+ 'research',
35
+ 'customtools',
36
+ ];
37
+ function isTextGenModel(m) {
38
+ return !NON_TEXT_GEN_MARKERS.some((marker) => m.id.includes(marker));
39
+ }
11
40
  const ALIASES = {
12
- 'latest-pro': (models) => models.find((m) => m.id.includes('pro') &&
13
- !m.id.includes('image') &&
14
- !m.id.includes('tts') &&
15
- !m.id.includes('vision') &&
16
- !m.id.includes('audio')),
17
- 'latest-pro-thinking': (models) => models.find((m) => m.id.includes('pro') &&
18
- m.supportsThinking &&
19
- !m.id.includes('image') &&
20
- !m.id.includes('tts')) ??
21
- models.find((m) => m.id.includes('pro') &&
22
- !m.id.includes('image') &&
23
- !m.id.includes('tts') &&
24
- !m.id.includes('vision') &&
25
- !m.id.includes('audio')),
26
- 'latest-flash': (models) => models.find((m) => m.id.includes('flash') &&
27
- !m.id.includes('image') &&
28
- !m.id.includes('tts') &&
29
- !m.id.includes('lite') &&
30
- !m.id.includes('vision') &&
31
- !m.id.includes('audio')),
32
- 'latest-lite': (models) => models.find((m) => m.id.includes('lite') &&
33
- !m.id.includes('image') &&
34
- !m.id.includes('tts') &&
35
- !m.id.includes('vision') &&
36
- !m.id.includes('audio')),
41
+ 'latest-pro': (models) => models.find((m) => m.id.includes('pro') && isTextGenModel(m)),
42
+ 'latest-pro-thinking': (models) => models.find((m) => m.id.includes('pro') && m.supportsThinking && isTextGenModel(m)) ??
43
+ models.find((m) => m.id.includes('pro') && isTextGenModel(m)),
44
+ 'latest-flash': (models) => models.find((m) => m.id.includes('flash') && !m.id.includes('lite') && isTextGenModel(m)),
45
+ 'latest-lite': (models) => models.find((m) => m.id.includes('lite') && isTextGenModel(m)),
37
46
  };
38
47
  export function isAlias(value) {
39
48
  return value in ALIASES;
@@ -1 +1 @@
1
- {"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/gemini/models.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAkB,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1E,MAAM,OAAO,GAAG;IACd,YAAY,EAAE,CAAC,MAAmB,EAAyB,EAAE,CAC3D,MAAM,CAAC,IAAI,CACT,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC;QACpB,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC;QACvB,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC;QACrB,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACxB,CAAC,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAC1B;IACH,qBAAqB,EAAE,CAAC,MAAmB,EAAyB,EAAE,CACpE,MAAM,CAAC,IAAI,CACT,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC,CAAC,EAAE,C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A;CAAO,GACjF,WAAW,CAgBb;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAO5E;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAgB5E"}
@@ -165,6 +165,24 @@ export const DEFAULT_EXCLUDE_DIRS = [
165
165
  '.config/gcloud',
166
166
  '.config/azure',
167
167
  'Keychains', // macOS: `Library/Keychains`
168
+ // Home-level user directories — defense in depth. If a caller somehow
169
+ // ends up scanning `$HOME` despite `validateWorkspacePath`'s home-reject
170
+ // (e.g. a symlinked sibling that points back at home, or a future MCP
171
+ // host pattern we haven't seen), these are the top offenders: privacy-
172
+ // hostile, massive, and guaranteed not to be part of any legitimate
173
+ // codebase. Refusing them blunts the blast radius even in the edge cases
174
+ // where the root guard doesn't fire.
175
+ '.Trash', // macOS: Finder trash — large, privacy-sensitive
176
+ 'Trash', // Linux variants: `~/.local/share/Trash/files`
177
+ 'Library', // macOS: app support / caches / prefs — huge, not a codebase
178
+ 'Downloads',
179
+ 'Desktop',
180
+ 'Documents',
181
+ 'Movies', // macOS
182
+ 'Music', // macOS / Linux
183
+ 'Pictures',
184
+ 'Videos',
185
+ 'Public', // macOS
168
186
  ];
169
187
  /** Files excluded by full relpath suffix (supports either `node_modules` prefix or literal suffix). */
170
188
  export const DEFAULT_EXCLUDE_FILE_NAMES = [
@@ -1 +1 @@
1
- {"version":3,"file":"globs.js","sourceRoot":"","sources":["../../src/indexer/globs.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,yEAAyE;AACzE,MAAM,CAAC,MAAM,0BAA0B,GAAsB;IAC3D,UAAU;IACV,KAAK;IACL,MAAM;IACN,KAAK;IACL,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO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AED,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,iBAAiB,EAAE,CAAC;QAC3C,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACxB,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC;gBAAE,OAAO,IAAI,CAAC;QAC1C,CAAC;aAAM,IAAI,QAAQ,KAAK,GAAG,EAAE,CAAC;YAC5B,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
1
+ {"version":3,"file":"globs.js","sourceRoot":"","sources":["../../src/indexer/globs.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,yEAAyE;AACzE,MAAM,CAAC,MAAM,0BAA0B,GAAsB;IAC3D,UAAU;IACV,KAAK;IACL,MAAM;IACN,KAAK;IACL,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,OAAO;IACP,OAAO;IACP,OAAO;IACP,SAAS;IACT,MAAM;IACN,QAAQ;IACR,UAAU;IACV,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,OAAO;IACP,KAAK;IACL,MAAM;IACN,QAAQ;IACR,KAAK;IACL,KAAK;IACL,QAAQ;IACR,IAAI;IACJ,KAAK;IACL,MAAM;IACN,KAAK;IACL,MAAM;IACN,IAAI;IACJ,IAAI;IACJ,MAAM;IACN,KAAK;IACL,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,OAAO;IACP,KAAK;IACL,MAAM;IACN,MAAM;IACN,MAAM;IACN,gBAAgB;IAChB,OAAO;IACP,QAAQ;IACR,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,cAAc;IACd,MAAM;IACN,gBAAgB;IAChB,KAAK;IACL,OAAO;IACP,MAAM;IACN,OAAO;IACP,MAAM;IACN,MAAM;IACN,MAAM;IACN,YAAY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OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"workspace-validation.d.ts","sourceRoot":"","sources":["../../src/indexer/workspace-validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAKH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAqCrC,CAAC;AAEX,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,OAAO,EAAE,MAAM;CAI5B;AAYD;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CA2EjE"}
1
+ {"version":3,"file":"workspace-validation.d.ts","sourceRoot":"","sources":["../../src/indexer/workspace-validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAMH;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAqCrC,CAAC;AAEX,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,OAAO,EAAE,MAAM;CAI5B;AAYD;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CA6GjE"}
@@ -24,6 +24,7 @@
24
24
  * and prompt-injection paths, not every conceivable abuse.
25
25
  */
26
26
  import { existsSync, realpathSync, statSync } from 'node:fs';
27
+ import { homedir } from 'node:os';
27
28
  import { isAbsolute, join, sep as pathSep, relative } from 'node:path';
28
29
  /**
29
30
  * Files / dirs at a path root that strongly suggest it's a real codebase.
@@ -157,6 +158,38 @@ export function validateWorkspacePath(workspaceRoot) {
157
158
  catch {
158
159
  canonicalCwd = process.cwd();
159
160
  }
161
+ // Refuse the user's home directory as a workspace even when it happens to
162
+ // BE the MCP host's cwd. The canonical MCP launch pattern (this project's
163
+ // own README recommends it, and `~/.claude.json` installs use it) sets
164
+ // `cwd: $HOME` specifically to sidestep an npx-in-same-repo conflict —
165
+ // a side-effect is that an `ask`/`code`/`reindex` call with `workspace`
166
+ // omitted falls through to `process.cwd() === $HOME` and then passes the
167
+ // cwd-ancestry check here, scanning everything under `$HOME` (Desktop,
168
+ // Documents, Downloads, .Trash, etc.) and uploading matched files to the
169
+ // Gemini Files API.
170
+ //
171
+ // No legitimate caller wants `$HOME` as a "project root" — it has no
172
+ // single-codebase structure, the scan cost scales with years of
173
+ // accumulated personal files, and exposure is privacy-hostile. Reject
174
+ // explicitly with a message that tells the caller what to do instead
175
+ // (pass `workspace` with a real project path).
176
+ //
177
+ // This check fires BEFORE the cwd-ancestry test because the point is to
178
+ // reject even when the path would otherwise pass. The marker-root escape
179
+ // below still applies to OTHER paths that happen to equal home via
180
+ // `HOME=/` shenanigans — but `$HOME` itself is refused unconditionally.
181
+ let canonicalHome = null;
182
+ try {
183
+ canonicalHome = realpathSync(homedir());
184
+ }
185
+ catch {
186
+ // If we can't resolve home (unlikely — process has no HOME env?), fall
187
+ // through and let the normal cwd / marker checks decide. Not a security
188
+ // hole — attacker can't make our process forget home to bypass.
189
+ }
190
+ if (canonicalHome !== null && canonical === canonicalHome) {
191
+ throw new WorkspaceValidationError(`Refusing to scan '${workspaceRoot}' — it resolves to the user's home directory ('${canonical}'). This is almost certainly a misconfiguration: the MCP server's cwd is $HOME (standard launch pattern) and no explicit 'workspace' argument was passed, so the tool would recursively index Desktop, Documents, Downloads, .Trash, and every other directory under home. Pass 'workspace' explicitly to the tool with a real project root (a path containing .git, package.json, Cargo.toml, go.mod, pyproject.toml, etc.).`);
192
+ }
160
193
  if (isUnderCwd(canonical, canonicalCwd))
161
194
  return;
162
195
  for (const marker of WORKSPACE_MARKERS) {
@@ -1 +1 @@
1
- {"version":3,"file":"workspace-validation.js","sourceRoot":"","sources":["../../src/indexer/workspace-validation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,U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OAAO;IACT,CAAC;IAED,MAAM,MAAM,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxD,MAAM,IAAI,wBAAwB,CAChC,qBAAqB,aAAa,IAAI,SAAS,KAAK,aAAa,CAAC,CAAC,CAAC,kBAAkB,SAAS,IAAI,CAAC,CAAC,CAAC,EAAE,iFAAiF;QACvL,IAAI,MAAM,wEAAwE,CACrF,CAAC;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;GAEG;AA2CH,wBAAsB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CAsG/C"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;GAEG;AA4CH,wBAAsB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC,CA2G/C"}
package/dist/server.js CHANGED
@@ -10,6 +10,7 @@ import { createGeminiClient } from './gemini/client.js';
10
10
  import { ManifestDb } from './manifest/db.js';
11
11
  import { TOOLS } from './tools/index.js';
12
12
  import { buildToolInputSchema, errorResult, } from './tools/registry.js';
13
+ import { createTpmThrottle } from './tools/shared/throttle.js';
13
14
  import { logger } from './utils/logger.js';
14
15
  import { readFileSync } from 'node:fs';
15
16
  import { dirname as pathDirname, join as pathJoin } from 'node:path';
@@ -45,6 +46,10 @@ export async function runServer() {
45
46
  const client = createGeminiClient(config.auth.profile);
46
47
  const ttlWatcher = new TtlWatcher(client, manifest);
47
48
  ttlWatcher.start();
49
+ // Singleton throttle shared across every tool invocation. State is in-memory
50
+ // only — a server restart clears the window (acceptable: startup is rare and
51
+ // a first 429 re-seeds `recordRetryHint`). `tpmThrottleLimit === 0` disables.
52
+ const throttle = createTpmThrottle(config.tpmThrottleLimit);
48
53
  const server = new Server({ name: SERVER_NAME, version: SERVER_VERSION }, {
49
54
  capabilities: {
50
55
  tools: { listChanged: false },
@@ -79,6 +84,7 @@ export async function runServer() {
79
84
  manifest,
80
85
  ttlWatcher,
81
86
  progressToken,
87
+ throttle,
82
88
  };
83
89
  try {
84
90
  const result = await tool.execute(parse.data, ctx);
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EAErB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAGL,oBAAoB,EACpB,WAAW,GACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,WAAW,GAAG,qCAAqC,CAAC;AAC1D;;;;GAIG;AACH,MAAM,cAAc,GAAG,CAAC,GAAW,EAAE;IACnC,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,WAAW,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QACzD,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,EAAE,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OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,EAAE;QAC1B,KAAK,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC1B,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE;QAC3B,KAAK,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC;IAEH,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,MAAM,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;AAC9C,CAAC"}
@@ -7,13 +7,15 @@
7
7
  */
8
8
  import { z } from 'zod';
9
9
  import { type ToolDefinition } from './registry.js';
10
- export declare const askInputSchema: z.ZodObject<{
10
+ export declare const askInputSchema: z.ZodEffects<z.ZodObject<{
11
11
  prompt: z.ZodString;
12
12
  workspace: z.ZodOptional<z.ZodString>;
13
13
  model: z.ZodOptional<z.ZodString>;
14
14
  includeGlobs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
15
15
  excludeGlobs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
16
16
  noCache: z.ZodOptional<z.ZodBoolean>;
17
+ thinkingBudget: z.ZodOptional<z.ZodNumber>;
18
+ thinkingLevel: z.ZodOptional<z.ZodEnum<["MINIMAL", "LOW", "MEDIUM", "HIGH"]>>;
17
19
  }, "strip", z.ZodTypeAny, {
18
20
  prompt: string;
19
21
  model?: string | undefined;
@@ -21,6 +23,8 @@ export declare const askInputSchema: z.ZodObject<{
21
23
  includeGlobs?: string[] | undefined;
22
24
  excludeGlobs?: string[] | undefined;
23
25
  noCache?: boolean | undefined;
26
+ thinkingBudget?: number | undefined;
27
+ thinkingLevel?: "MINIMAL" | "LOW" | "MEDIUM" | "HIGH" | undefined;
24
28
  }, {
25
29
  prompt: string;
26
30
  model?: string | undefined;
@@ -28,6 +32,26 @@ export declare const askInputSchema: z.ZodObject<{
28
32
  includeGlobs?: string[] | undefined;
29
33
  excludeGlobs?: string[] | undefined;
30
34
  noCache?: boolean | undefined;
35
+ thinkingBudget?: number | undefined;
36
+ thinkingLevel?: "MINIMAL" | "LOW" | "MEDIUM" | "HIGH" | undefined;
37
+ }>, {
38
+ prompt: string;
39
+ model?: string | undefined;
40
+ workspace?: string | undefined;
41
+ includeGlobs?: string[] | undefined;
42
+ excludeGlobs?: string[] | undefined;
43
+ noCache?: boolean | undefined;
44
+ thinkingBudget?: number | undefined;
45
+ thinkingLevel?: "MINIMAL" | "LOW" | "MEDIUM" | "HIGH" | undefined;
46
+ }, {
47
+ prompt: string;
48
+ model?: string | undefined;
49
+ workspace?: string | undefined;
50
+ includeGlobs?: string[] | undefined;
51
+ excludeGlobs?: string[] | undefined;
52
+ noCache?: boolean | undefined;
53
+ thinkingBudget?: number | undefined;
54
+ thinkingLevel?: "MINIMAL" | "LOW" | "MEDIUM" | "HIGH" | undefined;
31
55
  }>;
32
56
  export type AskInput = z.infer<typeof askInputSchema>;
33
57
  export declare const askTool: ToolDefinition<AskInput>;
@@ -1 +1 @@
1
- {"version":3,"file":"ask.tool.d.ts","sourceRoot":"","sources":["../../src/tools/ask.tool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB,OAAO,EAAE,KAAK,cAAc,EAA2B,MAAM,eAAe,CAAC;AAgB7E,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;EAqBzB,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAEtD,eAAO,MAAM,OAAO,EAAE,cAAc,CAAC,QAAQ,CAuS5C,CAAC"}
1
+ {"version":3,"file":"ask.tool.d.ts","sourceRoot":"","sources":["../../src/tools/ask.tool.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAWH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB,OAAO,EAAE,KAAK,cAAc,EAA2B,MAAM,eAAe,CAAC;AAmC7E,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8CvB,CAAC;AAEL,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAEtD,eAAO,MAAM,OAAO,EAAE,cAAc,CAAC,QAAQ,CAme5C,CAAC"}