@qmediat.io/gemini-code-context-mcp 1.16.2 → 1.16.4

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 CHANGED
@@ -5,6 +5,106 @@ All notable changes to `@qmediat.io/gemini-code-context-mcp` will be documented
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.16.4] - 2026-09-23
9
+
10
+ ### Fixed
11
+
12
+ - **`latest-flash` resolved to an Interactions-API-only model and every call failed with HTTP 400.** Google's
13
+ `gemini-omni-*` family (`gemini-omni-flash-preview`, `gemini-omni-1.1-flash`) is served only by the Interactions
14
+ API, yet `ListModels` advertises `generateContent` for it, and the registry's version-descending sort places
15
+ `omni` ahead of every `gemini-N.M-flash`. The taxonomy now classifies `omni` as `agent` (not drop-in replaceable)
16
+ with an anchored rule, and `latest-flash` resolves to `gemini-flash-latest`
17
+ again (Google's rolling alias — `gemini-3.8-flash` on 2026-09-23). Regression tests cover both IDs. `gemini-pro-latest` and `gemini-flash-latest` (Google's rolling aliases) were
18
+ verified against the live API and are unaffected.
19
+
20
+ ### Changed
21
+
22
+ - `server.json` (MCP registry manifest) is bumped with the package, and the release workflow refuses a tag whose
23
+ manifest versions differ from `package.json`.
24
+ - `CONTRIBUTING.md` and the PR template asked for a changeset; the repository never had a `.changeset/` setup and
25
+ the CHANGELOG is the release record, so both now ask for a CHANGELOG entry.
26
+
27
+ ### Security
28
+
29
+ - Dependency refresh to close every open Dependabot advisory (69 alerts, 25 high — all transitive):
30
+ `@modelcontextprotocol/sdk` 1.30.0, `@google/genai` 1.52.0, `hono` 4.13.8, `fast-uri` 3.1.8, `qs` 6.16.0,
31
+ `body-parser` 2.3.0, `ip-address` 10.7.2, `protobufjs` 7.6.6, `ws` 8.21.3. `npm audit` reports 0 vulnerabilities.
32
+ The published floors are raised to the versions this release was tested with (`@modelcontextprotocol/sdk` ^1.30.0,
33
+ `@google/genai` ^1.52.0). The advisories are in transitive dependencies under caret ranges, so a project that
34
+ already has this package in its lockfile keeps its old tree until it runs `npm update` (or `npm audit fix`);
35
+ a fresh install gets the refreshed tree.
36
+ - CI and the release workflow refuse a build with a known high-severity advisory in the shipped dependency tree
37
+ (`npm audit --omit=dev --audit-level=high`; the dev toolchain stays covered by Dependabot alerts);
38
+ the CI token is read-only (`permissions: contents: read`).
39
+ - Dependabot security updates are enabled on the repository.
40
+ - `SECURITY.md`: the supported-versions table still described the pre-1.0 state; it now names the latest 1.x
41
+ release as the supported one and points to GitHub's private vulnerability reporting form first.
42
+
43
+ ## [1.16.3] - 2026-05-01
44
+
45
+ ### Fixed — `ask_agentic` streaming hotfix (combined: empty-text terminator + multi-chunk parts fragmentation, HOTFIX)
46
+
47
+ **v1.16.3 ships TWO related fixes for the v1.16.2 streaming regression**, folded into a single release because the second was discovered during end-to-end MCP smoke-test of the first.
48
+
49
+ #### Fix #1 — empty-text-terminator regression
50
+
51
+ **Reproduction:** v1.16.2 ask_agentic returned `(model returned empty response)` on every tool-using prompt against live Gemini Pro / Flash. Symptoms surfaced minutes after v1.16.2 published, on the first end-to-end smoke test from the global install.
52
+
53
+ **Root cause:** Gemini's actual stream protocol for tool-using turns emits TWO chunks:
54
+ - Chunk 1: `{ candidates: [{ content: { parts: [{ functionCall: {...} }] } }] }` (the actual tool call)
55
+ - Chunk 2: `{ candidates: [{ content: { parts: [{ text: '' }] }, finishReason: 'STOP' }] }` (terminator)
56
+
57
+ v1.16.2's `collectStream` gate required `parts.length > 0` to preserve a chunk's `lastCandidates`. Chunk 2 has `parts.length === 1` (one element with empty text + finishReason), so the gate ACCEPTED it and overwrote chunk 1's functionCall. The agentic loop then saw zero functionCallParts and routed to the final-text path, returning the empty string fallback.
58
+
59
+ #### Fix #2 — multi-chunk parts fragmentation (T35)
60
+
61
+ **Reproduction:** during end-to-end MCP smoke-test of Fix #1 against live Gemini Pro, single-FC prompts (Tests 1–4) all passed. Test 5 (multi-file prompt: "read package.json, server.json, CHANGELOG.md") failed with Gemini 400: `Function call default_api:read_file ... missing thought_signature, position 2`.
62
+
63
+ **Root cause:** Fix #1 used a content-bearing-parts gate over `lastCandidates = chunk.candidates` last-write-wins semantics. When Gemini emits PARALLEL `functionCall` Parts across separate chunks, each chunk's parts overwrite the prior chunk's. The Gemini-3 contract (https://ai.google.dev/gemini-api/docs/thought-signatures) mandates that the thought signature on the FIRST functionCall part be returned in the next-turn replay. Last-write-wins drops chunk-1's signature; iteration 2's `generateContent` sees a model turn whose first FC has no signature; Gemini 400s. Pre-existing fragility — masked by Fix #1's complete failure mode in v1.16.2 (no FCs ever made it through the loop, so multi-FC was never reached).
64
+
65
+ **Fix:** `collectStream` no longer gates or overwrites — it ACCUMULATES `parts` across every chunk verbatim. Empty-text terminator parts, parallel `functionCall` Parts, and standalone signature-bearing parts are all preserved exactly as Gemini emitted them. The candidate scaffold (`finishReason`, `safetyRatings`, `groundingMetadata`, `citationMetadata`) stays last-write-wins; on stream exit we synthesise the final `candidates` shape by overlaying the accumulated `parts` onto the last seen scaffold.
66
+
67
+ This also closes the documented `code` tool fragility (T35 secondary): `executableCode` in chunk 1 + `codeExecutionResult` in chunk 2 now both reach `code.tool.ts`'s extractor.
68
+
69
+ **Pre-existing in v1.16.2 only.** v1.16.1 and earlier used non-streaming `generateContent` for ask_agentic — never affected by either fix.
70
+
71
+ ### Why v1.16.2's review cycle missed Fix #1
72
+
73
+ The v1.16.2 PR went through the standard review cycle: 3-way Round-1 (gemini + grok + codex), 3-way Round-2 verification, Copilot review, all CI checks green. Gemini Round-1 specifically called out this CLASS of bug (terminator-only chunks dropping functionCall) and a fix was folded — but the fix targeted the SHAPE `parts: []` (empty array) and missed the empirical SHAPE `parts: [{ text: '' }]` (length-1 array with empty content). Unit tests pinned the `[]` shape but not the `[{ text: '' }]` shape because no one captured a raw stream from live Gemini before merging.
74
+
75
+ ### Why v1.16.3 hotfix-A's first MCP smoke pass missed Fix #2
76
+
77
+ A single-FC smoke (Test 1) was sufficient to confirm Fix #1 against live Gemini. Multi-FC parallel was filed as T35 (deferred-with-documentation) on the explicit reasoning "currently zero empirical reports". Tests 1–4 of the documented end-to-end smoke plan passed; Test 5 (multi-file) was the first empirical report — fold it in same release.
78
+
79
+ **Process update:** the new `test/integration/real-gemini.smoke.test.ts` (v1.15.3 P10) will be extended in a follow-up PR with env-gated streaming + tool-calling smokes for BOTH single-FC and parallel-multi-FC prompts. A pre-merge live smoke covering both would have caught Fix #2 in seconds.
80
+
81
+ ### Coverage
82
+
83
+ 773 tests pass (766 → 773 across the full release, including the R1 + R2 fold-cycle pins documented below — net +7 over v1.16.2). The 5 T35-specific regression pins cover the multi-chunk parts fragmentation cases: parallel-FC across 3 chunks pinning thoughtSignature on FC1, executableCode + codeExecutionResult cross-chunk, standalone signature on empty-text terminator, content.role synthesis, candidates-undefined preservation for naked-text streams.
84
+
85
+ ### R1 fold-cycle (4-way: GPT + Gemini + Grok + Copilot)
86
+
87
+ - **Fold A (GPT F1 / Gemini F1 / Grok F2 — 3-way consensus, /6step PARTIAL Medium):** synthesised candidates collapsed to single-element array, narrowing the pre-T35 `lastCandidates = chunk.candidates` contract. Per-index `Map<number, Part[]>` accumulation + `Map<number, Candidate>` scaffold tracking restore multi-candidate preservation for any future caller that sets `candidateCount > 1` (today none does — `code.tool.ts:727` already iterates ALL candidates so the type narrowing was a real regression-in-waiting).
88
+ - **Fold B (GPT F2 — TP Medium):** added `it('preserves multi-candidate streams (candidateCount>1) with per-index parts accumulation')` regression pin.
89
+ - **Fold D (Grok F1 — PARTIAL Low):** retitled the empty-text-terminator regression test to mention both the hotfix-A history and the T35 strengthening explicitly.
90
+ - **Fold G (Copilot — TP Medium):** reconciled CHANGELOG T36 status with `docs/FOLLOW-UP-PRS.md` (T36 is RESOLVED-BY-T35, not "remains tracked").
91
+ - **Fold H (Copilot — TP Low):** updated `ask-agentic.test.ts:2469` comment narrating "content-bearing gate" to describe the actual T35 accumulation behaviour.
92
+ - **Accept-deferred C (Grok F3 — TP Medium):** end-to-end multi-FC + thoughtSignature test through `askAgenticTool.execute`. Covered at the collector contract level by `stream-collector.test.ts:189`. Live-API integration smoke is the documented next-PR scope (see Fix #2 closing notes above).
93
+ - **Accept E (Grok F4 — Low):** test count "766 → 771" verified empirically post-R1 fold becomes 766 → 772; the "5 regression pins" wording in the original Coverage section refers to T35-specific pins — accurate at that scope.
94
+ - **Accept F (Grok F5 — Low):** Keep-a-Changelog Unreleased + per-version compare-link not added; project's prior versions (v1.0.0 → v1.16.2) follow the same convention of only emitting the `[1.0.0]` link.
95
+
96
+ ### R2 fold-cycle (3-way: GPT + Gemini + Grok)
97
+
98
+ - **Fold I (GPT R2 F1 / Gemini R2 F1 — 2-way HIGH consensus, /6step TP Medium):** the R1-fold per-index Maps were keyed by the loop variable `i` (array position) rather than `cand.index ?? i`. Per `@google/genai` SDK `Candidate.index` doc: "The 0-based index of this candidate in the list of generated responses. Useful for distinguishing between multiple candidates when candidate_count > 1." Sparse stream emission like `candidates: [{ index: 1, content: ... }]` (only index 1, not 0) would have cross-wired that part into bucket 0. Fixed: keys now use `cand.index ?? i`, and the synth `.sort()` is now load-bearing because Map insertion order can diverge from ordinal index under sparse emission.
99
+ - **Fold J (GPT R2 F2 / Grok R2 F1 — TP Low):** added `it('keys multi-candidate buckets by Candidate.index, not array position (R2 fold — sparse emission)')` regression pin that emits sparse + reverse-Map-insertion-order chunks and asserts ordinal output ordering with no cross-bucket bleed.
100
+ - **Accept K (Grok R2 F2 — Nit):** the `.sort()` on `Array.from(Map.entries())` was flagged as redundant under R1's keying (Map preserves insertion order from the ascending-i loop). After Fold I the sort BECOMES load-bearing for sparse emission, so it stays — comment added explaining why.
101
+
102
+ ### Notes
103
+
104
+ - Anyone on v1.16.2 with `ask_agentic` calls in production should upgrade IMMEDIATELY. Tool-calling iterations were silently failing on every prompt.
105
+ - T35 (true parts accumulation) — closed in this release. T36 (`toolCall` predicate completeness for future Gemini server-side tools) is also resolved by T35 in v1.16.3 — the accumulation contract preserves any Part shape verbatim (functionCall, toolCall, executableCode, codeExecutionResult, thoughtSignature) without per-shape gating. See `docs/FOLLOW-UP-PRS.md` "T36" for the full rationale.
106
+ - v1.6/v1.7 streaming refactor track still considered shipped — both fixes are defects in the v1.16.2 agentic-loop refactor, fixed in place.
107
+
8
108
  ## [1.16.2] - 2026-04-30
9
109
 
10
110
  ### Changed — `ask_agentic` loop streaming + heartbeat-aware `stallMs` watchdog (T33 TRIM)
@@ -1 +1 @@
1
- {"version":3,"file":"model-taxonomy.d.ts","sourceRoot":"","sources":["../../src/gemini/model-taxonomy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;GAIG;AACH,MAAM,MAAM,aAAa,GACrB,gBAAgB,GAChB,WAAW,GACX,WAAW,GACX,kBAAkB,GAClB,kBAAkB,GAClB,kBAAkB,GAClB,WAAW,GACX,OAAO,GACP,SAAS,CAAC;AAEd;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IACnC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,qBAAqB,EAAE,OAAO,CAAC;IACxC,iEAAiE;IACjE,QAAQ,CAAC,QAAQ,EAAE,SAAS,GAAG,UAAU,GAAG,QAAQ,GAAG,SAAS,CAAC;CAClE;AAoFD;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,aAAa,CAM9D;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe,CAAC,UAAU,CAAC,CAKvE;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE;IAAE,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAA;CAAE,GAClD,eAAe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,WAAW,EAAE;IAAE,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAA;CAAE,GAClD,eAAe,CAuBjB;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAElE;AAED;;;;;;GAMG;AACH,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,cAAc,EAAE,aAAa,CAAC;IACvC,QAAQ,CAAC,gBAAgB,EAAE,SAAS,aAAa,EAAE,CAAC;gBAExC,OAAO,EAAE;QACnB,OAAO,EAAE,MAAM,CAAC;QAChB,cAAc,EAAE,aAAa,CAAC;QAC9B,gBAAgB,EAAE,SAAS,aAAa,EAAE,CAAC;KAC5C;CAWF"}
@@ -57,6 +57,14 @@ const CATEGORY_RULES = [
57
57
  // admission as text-fast. `agent` category signals "not drop-in
58
58
  // replaceable with a text model" (flagged by GPT PR #22 review).
59
59
  { pattern: /(?:^|-)live(?:-|$)/i, category: 'agent', costTier: 'standard' },
60
+ // === Interactions API only (not `generateContent`) ===
61
+ // `gemini-omni-*` (`gemini-omni-flash-preview`, `gemini-omni-1.1-flash`) is
62
+ // served only by the Interactions API. `ListModels` still advertises
63
+ // `generateContent` for it, and a text prompt returns
64
+ // 400 "This model only supports Interactions API." Unclassified, the family
65
+ // sorts ahead of every `gemini-N.M-flash` (`o` > digits in the version-desc
66
+ // sort) and `latest-flash` resolves to it. Must classify before the flash rule.
67
+ { pattern: /(?:^|-)omni(?:-|$)/i, category: 'agent', costTier: 'standard' },
60
68
  // === Embeddings ===
61
69
  // Token-boundary anchoring: matches `text-embedding-004`,
62
70
  // `gemini-embedding-001` etc., rejects hypothetical `foo-embedding-like-helper`.
@@ -1 +1 @@
1
- {"version":3,"file":"model-taxonomy.js","sourceRoot":"","sources":["../../src/gemini/model-taxonomy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;G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C,KAAK,CAAC,CAAC;QACtD,KAAK,CACH,UAAU,OAAO,CAAC,OAAO,qBAAqB,OAAO,CAAC,cAAc,8BAA8B,QAAQ,4HAA4H,OAAO,CAAC,OAAO,mGAAmG,CACzV,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC;QACzC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;QAC7C,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC;QACjD,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,0BAA0B,CAAC,SAAS,CAAC,CAAC;IACpE,CAAC;CACF"}
package/dist/index.js CHANGED
File without changes
@@ -20,10 +20,30 @@
20
20
  * currently does, since it would only fire if Google changed the stream
21
21
  * protocol.)
22
22
  *
23
- * - **`candidates` last-write-wins**: finish reasons, safety ratings, and
24
- * groundingMetadata only become authoritative on the final chunk —
25
- * earlier chunks may report "STOP_REASON_UNSPECIFIED" mid-stream. We keep
26
- * the last non-empty `candidates` array.
23
+ * - **`candidates.content.parts` ACCUMULATES across chunks** (T35,
24
+ * v1.16.3): `parts` from every chunk are appended to a running array
25
+ * rather than overwritten. Required for multi-chunk function calling —
26
+ * Gemini emits parallel `functionCall` Parts across separate chunks,
27
+ * and the `thoughtSignature` mandated on the FIRST `functionCall` Part
28
+ * (Gemini 3 contract — see ai.google.dev/gemini-api/docs/thought-signatures)
29
+ * would be silently dropped by any last-write-wins gate. Empty-text
30
+ * terminator Parts are also preserved because Google's docs note that
31
+ * during streaming, a model response may carry a `thoughtSignature`
32
+ * in a part with an empty text string. Filtering them would discard
33
+ * load-bearing signature material.
34
+ *
35
+ * - **Candidate METADATA (`finishReason`, safetyRatings, groundingMetadata,
36
+ * citationMetadata) last-write-wins per-index**: only become
37
+ * authoritative on the final candidate-bearing chunk — earlier chunks
38
+ * may report "STOP_REASON_UNSPECIFIED" mid-stream. We retain the last
39
+ * CANDIDATE-BEARING chunk's scaffold per `cand.index` (a chunk emitting
40
+ * `candidates: []` does NOT clear earlier scaffolds — only chunks that
41
+ * emit a candidate at index i overwrite scaffold[i]). On exit we
42
+ * synthesise the final `candidates` array by overlaying each index's
43
+ * accumulated `parts` onto its retained scaffold. R1 (PR #59) made the
44
+ * scaffold tracking per-index via `Map<number, Candidate>`; R2 keys it
45
+ * by `cand.index ?? i` so sparse emission (`candidates: [{index: 1}]`)
46
+ * doesn't cross-wire into bucket 0.
27
47
  *
28
48
  * - **Thought chunks (`part.thought === true`)** are forwarded to
29
49
  * `onThoughtChunk` immediately as they arrive, but the callback fires
@@ -1 +1 @@
1
- {"version":3,"file":"stream-collector.d.ts","sourceRoot":"","sources":["../../../src/tools/shared/stream-collector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAK7D,MAAM,WAAW,sBAAsB;IACrC;qEACiE;IACjE,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;IAC9B;;sEAEkE;IAClE,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD;gFAC4E;IAC5E,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IACxC;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,IAAI,CAAC;CACvC;AAED,MAAM,WAAW,iBAAiB;IAChC,yCAAyC;IACzC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,uEAAuE;IACvE,QAAQ,CAAC,UAAU,EAAE,uBAAuB,CAAC,YAAY,CAAC,CAAC;IAC3D,6DAA6D;IAC7D,QAAQ,CAAC,aAAa,EAAE,uBAAuB,CAAC,eAAe,CAAC,CAAC;IACjE,4EAA4E;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IAC5E,QAAQ,CAAC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,mEAAmE;IACnE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,8EAA8E;IAC9E,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,MAAM,EAAE,cAAc,CAAC,uBAAuB,CAAC,EAC/C,IAAI,GAAE,sBAA2B,GAChC,OAAO,CAAC,iBAAiB,CAAC,CAmR5B"}
@@ -20,10 +20,30 @@
20
20
  * currently does, since it would only fire if Google changed the stream
21
21
  * protocol.)
22
22
  *
23
- * - **`candidates` last-write-wins**: finish reasons, safety ratings, and
24
- * groundingMetadata only become authoritative on the final chunk —
25
- * earlier chunks may report "STOP_REASON_UNSPECIFIED" mid-stream. We keep
26
- * the last non-empty `candidates` array.
23
+ * - **`candidates.content.parts` ACCUMULATES across chunks** (T35,
24
+ * v1.16.3): `parts` from every chunk are appended to a running array
25
+ * rather than overwritten. Required for multi-chunk function calling —
26
+ * Gemini emits parallel `functionCall` Parts across separate chunks,
27
+ * and the `thoughtSignature` mandated on the FIRST `functionCall` Part
28
+ * (Gemini 3 contract — see ai.google.dev/gemini-api/docs/thought-signatures)
29
+ * would be silently dropped by any last-write-wins gate. Empty-text
30
+ * terminator Parts are also preserved because Google's docs note that
31
+ * during streaming, a model response may carry a `thoughtSignature`
32
+ * in a part with an empty text string. Filtering them would discard
33
+ * load-bearing signature material.
34
+ *
35
+ * - **Candidate METADATA (`finishReason`, safetyRatings, groundingMetadata,
36
+ * citationMetadata) last-write-wins per-index**: only become
37
+ * authoritative on the final candidate-bearing chunk — earlier chunks
38
+ * may report "STOP_REASON_UNSPECIFIED" mid-stream. We retain the last
39
+ * CANDIDATE-BEARING chunk's scaffold per `cand.index` (a chunk emitting
40
+ * `candidates: []` does NOT clear earlier scaffolds — only chunks that
41
+ * emit a candidate at index i overwrite scaffold[i]). On exit we
42
+ * synthesise the final `candidates` array by overlaying each index's
43
+ * accumulated `parts` onto its retained scaffold. R1 (PR #59) made the
44
+ * scaffold tracking per-index via `Map<number, Candidate>`; R2 keys it
45
+ * by `cand.index ?? i` so sparse emission (`candidates: [{index: 1}]`)
46
+ * doesn't cross-wire into bucket 0.
27
47
  *
28
48
  * - **Thought chunks (`part.thought === true`)** are forwarded to
29
49
  * `onThoughtChunk` immediately as they arrive, but the callback fires
@@ -74,7 +94,26 @@ export async function collectStream(stream, opts = {}) {
74
94
  }
75
95
  const textChunks = [];
76
96
  const thoughtChunks = [];
77
- let lastCandidates;
97
+ // T35 (v1.16.3): accumulate parts from every chunk rather than picking the
98
+ // "best" chunk's parts. Multi-chunk function calls and standalone signature
99
+ // terminator Parts both depend on this — see file-level docstring.
100
+ //
101
+ // R1 fold (PR #59 — GPT F1 / Gemini F1 / Grok F2): per-candidate-index maps
102
+ // preserve the pre-T35 multi-candidate contract. Pre-T35 the synth was
103
+ // `lastCandidates = chunk.candidates` (full N-element array preserved).
104
+ // The initial T35 implementation collapsed to single-element synth which
105
+ // narrowed the type for any future caller that sets `candidateCount > 1`.
106
+ // Today no caller does, but `code.tool.ts:727` iterates ALL candidates
107
+ // (`for (const cand of candidates)`) so a future caller would silently
108
+ // lose candidates 1..N's parts/safety/grounding. Per-index maps keep the
109
+ // accumulation invariant for every emitted candidate.
110
+ const accumulatedPartsByIndex = new Map();
111
+ // Last seen candidate-scaffold per index — finishReason, safetyRatings,
112
+ // groundingMetadata, citationMetadata. We DON'T accumulate these (each is
113
+ // a standalone field where the latest authoritative value wins). On exit
114
+ // we overlay each index's accumulated parts onto its last scaffold to
115
+ // synthesise the returned `lastCandidates`.
116
+ const scaffoldsByIndex = new Map();
78
117
  let lastUsageMetadata;
79
118
  let chunkCount = 0;
80
119
  let firstChunkAt = null;
@@ -116,42 +155,95 @@ export async function collectStream(stream, opts = {}) {
116
155
  const chunkText = chunk.text ?? '';
117
156
  if (chunkText.length > 0)
118
157
  textChunks.push(chunkText);
119
- // Last candidates with non-empty parts wins.
158
+ // Accumulate parts across chunks (T35, v1.16.3).
159
+ //
160
+ // History — four iterations:
161
+ //
162
+ // **v1.7.0 → v1.16.1**: gate was `chunk.candidates.length > 0` (outer
163
+ // array length only) under last-write-wins semantics. Correct for the
164
+ // ask/code text-extraction path (which reads accumulated
165
+ // `response.text`, not `candidates[0].content.parts`). But v1.16.2's
166
+ // ask_agentic streaming migration was the first consumer that reads
167
+ // `candidates[0].content.parts` directly to extract `functionCall`
168
+ // Parts — last-write-wins is fragile here.
169
+ //
170
+ // **v1.16.2** (PR #58 Round-1 fold of gemini Finding #1): gate
171
+ // tightened to also require `parts.length > 0`. Closed the case
172
+ // `{ candidates: [{ content: { parts: [], finishReason: 'STOP' }}] }`
173
+ // — non-empty outer, empty inner.
174
+ //
175
+ // **v1.16.3 hotfix-A** (interim): gate strengthened further to require
176
+ // AT LEAST ONE content-bearing part. Closed the empirical Gemini
177
+ // empty-text-terminator pattern (`parts: [{ text: '' }]` after the
178
+ // functionCall chunk). But still last-write-wins — under multi-chunk
179
+ // function calling (parallel `functionCall` Parts across separate
180
+ // chunks, or `thoughtSignature` carried on a standalone empty-text
181
+ // terminator), earlier chunks were silently dropped, including the
182
+ // Gemini-3-mandated signature on the FIRST functionCall part.
183
+ // Empirically reproduced by Test 5 — multi-file ask_agentic prompt
184
+ // returned 400 "missing thought_signature, position 2" against live
185
+ // Gemini Pro on 2026-05-01.
120
186
  //
121
- // Pre-v1.16.2 the gate was `chunk.candidates.length > 0` (outer-array
122
- // check only). That correctly preserved finishReason / safety ratings
123
- // from final chunks for the v1.7.0 ask/code text-extraction path
124
- // (which reads accumulated `response.text`, not `candidates[0].parts`).
125
- // The v1.16.2 ask_agentic streaming migration is the first consumer
126
- // that reads `candidates[0].content.parts` directly — to extract
127
- // `functionCall` Parts on each loop iteration. If Gemini's stream
128
- // protocol ever emits a final terminator chunk shape like
129
- // `{ candidates: [{ content: { parts: [] }, finishReason: 'STOP' }] }`
130
- // — non-empty outer array but empty inner parts — the prior gate
131
- // would silently overwrite a previous chunk that carried the actual
132
- // `functionCall`, dropping the tool dispatch.
187
+ // **v1.16.3 (T35, this fix)**: ACCUMULATE parts across every chunk.
188
+ // Filtering is wrong by construction — Google's docs explicitly state
189
+ // (https://ai.google.dev/gemini-api/docs/thought-signatures):
190
+ // "During a model response not containing a FC with a streaming
191
+ // request, the model may return the thought signature in a part
192
+ // with an empty text content part. It is advisable to parse the
193
+ // entire request until the `finish_reason` is returned"
194
+ // and (function-calling docs):
195
+ // "Don't merge a Part containing a signature with one that does not.
196
+ // This breaks the positional context of the thought."
197
+ // Accumulating preserves every Part exactly as Gemini emitted it —
198
+ // signature attachments, parallel functionCall Parts, executableCode
199
+ // chunks followed by codeExecutionResult chunks, and so on.
133
200
  //
134
- // Defensive fix: gate also on `parts.length > 0`. The empirical
135
- // current-protocol behaviour (functionCall + finishReason emitted
136
- // together in one chunk) is preserved either way; this hardens
137
- // against a fragmentation pattern that future Gemini SDK versions
138
- // OR thinking-mode variants could legitimately introduce. Flagged
139
- // by gemini Round-1 review on PR #58 as a HIGH-severity defensive
140
- // gap.
201
+ // Side-effect on ask/code: `response.candidates[0].content.parts`
202
+ // now contains every emitted Part (including thought parts and any
203
+ // empty-text terminator parts). Neither tool reads parts directly
204
+ // for text extraction — both go through accumulated `response.text`
205
+ // — so behaviour is observably equivalent. ask_agentic's parts-iter
206
+ // (filter for `functionCall`, count thought parts) sees richer
207
+ // input but each filter handles the extra Part variants without
208
+ // change.
209
+ // Per-candidate-index accumulation. Today Gemini's streaming protocol
210
+ // emits candidateCount=1 by default (no caller in this codebase sets
211
+ // candidateCount>1 — verified by repo-wide grep). Per-index maps cost
212
+ // ~10 lines and preserve the pre-T35 contract for any future caller
213
+ // that does set candidateCount>1, matching `code.tool.ts:727`'s
214
+ // existing `for (const cand of candidates)` consumption pattern.
141
215
  //
142
- // Side-effect on ask/code: `lastCandidates.finishReason` may now come
143
- // from a non-final chunk if the final chunk has no parts. Neither
144
- // `ask` nor `code` reads finishReason off the CollectedResponse —
145
- // both extract via `response.text` (concatenated) — so this is
146
- // observably equivalent for them.
147
- if (chunk.candidates &&
148
- chunk.candidates.length > 0 &&
149
- (chunk.candidates[0]?.content?.parts?.length ?? 0) > 0) {
150
- lastCandidates = chunk.candidates;
216
+ // R2 fold (PR #59 — GPT R2 F1 / Gemini R2 F1, 2-way HIGH): key Maps by
217
+ // `cand.index ?? i` instead of array position alone. Per @google/genai
218
+ // SDK Candidate.index doc: "The 0-based index of this candidate in
219
+ // the list of generated responses. This is useful for distinguishing
220
+ // between multiple candidates when candidate_count > 1." Sparse stream
221
+ // emission like `candidates: [{ index: 1, content: ... }]` (only
222
+ // index 1, not 0) would otherwise cross-wire that part into bucket 0.
223
+ const candidates = chunk.candidates ?? [];
224
+ for (let i = 0; i < candidates.length; i++) {
225
+ const cand = candidates[i];
226
+ if (!cand)
227
+ continue;
228
+ const cIdx = cand.index ?? i;
229
+ const incomingParts = cand.content?.parts;
230
+ if (Array.isArray(incomingParts) && incomingParts.length > 0) {
231
+ let bucket = accumulatedPartsByIndex.get(cIdx);
232
+ if (!bucket) {
233
+ bucket = [];
234
+ accumulatedPartsByIndex.set(cIdx, bucket);
235
+ }
236
+ bucket.push(...incomingParts);
237
+ }
238
+ // Track the latest candidate scaffold for this index. finishReason,
239
+ // safety ratings, grounding, citation metadata — each chunk yields
240
+ // a fresh scaffold per index; finalisation overlays per-index
241
+ // accumulated parts onto each index's last seen scaffold.
242
+ scaffoldsByIndex.set(cIdx, cand);
151
243
  }
152
244
  // Thought-part extraction. `parts[i].thought === true` flags an
153
245
  // internal-reasoning chunk. Push to summary, throttle emit.
154
- const candidates = chunk.candidates ?? [];
246
+ // (Reuses `candidates` from the per-index accumulation block above.)
155
247
  for (const cand of candidates) {
156
248
  const parts = cand.content?.parts ?? [];
157
249
  for (const part of parts) {
@@ -216,6 +308,31 @@ export async function collectStream(stream, opts = {}) {
216
308
  }
217
309
  const text = textChunks.join('');
218
310
  const thoughtsSummary = thoughtChunks.length > 0 ? thoughtChunks.join('\n').slice(0, THOUGHTS_SUMMARY_MAX_CHARS) : null;
311
+ // Synthesize final candidates by overlaying each index's accumulated parts
312
+ // onto that index's last seen scaffold. When NO chunk yielded a candidate
313
+ // at all (e.g. text-only stream with naked `{ text: 'x' }` chunks),
314
+ // `lastCandidates` stays undefined — preserves the prior contract for the
315
+ // no-candidates path. When chunks emitted candidateCount>1, every emitted
316
+ // index gets a synthesised entry, sorted by ordinal index — matches
317
+ // pre-T35 `lastCandidates = chunk.candidates` semantics.
318
+ //
319
+ // The .sort() is load-bearing under R2 fold's `cand.index ?? i` keying:
320
+ // sparse emission (chunk 1 emits index 1 first, chunk 2 emits index 0)
321
+ // would yield Map insertion order [1, 0] without the sort, mis-ordering
322
+ // the final candidates array. Map preserves insertion order, so sort is
323
+ // the only guarantee of ordinal output ordering.
324
+ const lastCandidates = scaffoldsByIndex.size > 0
325
+ ? Array.from(scaffoldsByIndex.entries())
326
+ .sort(([a], [b]) => a - b)
327
+ .map(([i, scaffold]) => ({
328
+ ...scaffold,
329
+ content: {
330
+ ...(scaffold.content ?? {}),
331
+ role: scaffold.content?.role ?? 'model',
332
+ parts: accumulatedPartsByIndex.get(i) ?? [],
333
+ },
334
+ }))
335
+ : undefined;
219
336
  return {
220
337
  text,
221
338
  candidates: lastCandidates,
@@ -1 +1 @@
1
- {"version":3,"file":"stream-collector.js","sourceRoot":"","sources":["../../../src/tools/shared/stream-collector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAIH,MAAM,gCAAgC,GAAG,IAAI,CAAC;AAC9C,MAAM,0BAA0B,GAAG,IAAI,CAAC;AA2CxC;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAA+C,EAC/C,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,KAAK,CAAC,aAAa,EAAE,CAAC;gBACxB,iBAAiB,GAAG,KAAK,CAAC,aAAa,CAAC;YAC1C,CAAC;QACH,CAAC;QACD,wEAAwE;QACxE,YAAY,GAAG,KAAK,CAAC;IACvB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,sEAAsE;QACtE,oEAAoE;QACpE,4DAA4D;QAC5D,IAAI,MAAM,EAAE,OAAO,EAAE,CAAC;YACpB,MAAM,MAAM,CAAC,MAAM,YAAY,KAAK;gBAClC,CAAC,CAAC,MAAM,CAAC,MAAM;gBACf,CAAC,CAAC,IAAI,YAAY,CAAC,mBAAmB,EAAE,YAAY,CAAC,CAAC;QAC1D,CAAC;QACD,MAAM,GAAG,CAAC;IACZ,CAAC;YAAS,CAAC;QACT,uEAAuE;QACvE,oEAAoE;QACpE,sEAAsE;QACtE,qEAAqE;QACrE,kEAAkE;QAClE,uBAAuB;QACvB,IAAI,YAAY,EAAE,CAAC;YACjB,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC,SAAS,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;IAED,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACjC,MAAM,eAAe,GACnB,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,0BAA0B,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAElG,OAAO;QACL,IAAI;QACJ,UAAU,EAAE,cAAc;QAC1B,aAAa,EAAE,iBAAiB;QAChC,eAAe;QACf,UAAU;QACV,YAAY;QACZ,WAAW;KACZ,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"stream-collector.js","sourceRoot":"","sources":["../../../src/tools/shared/stream-collector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAC,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,0BAA0B,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAElG,2EAA2E;IAC3E,0EAA0E;IAC1E,oEAAoE;IACpE,0EAA0E;IAC1E,0EAA0E;IAC1E,oEAAoE;IACpE,yDAAyD;IACzD,EAAE;IACF,wEAAwE;IACxE,uEAAuE;IACvE,wEAAwE;IACxE,wEAAwE;IACxE,iDAAiD;IACjD,MAAM,cAAc,GAClB,gBAAgB,CAAC,IAAI,GAAG,CAAC;QACvB,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC;aACnC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;aACzB,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC;YACvB,GAAG,QAAQ;YACX,OAAO,EAAE;gBACP,GAAG,CAAC,QAAQ,CAAC,OAAO,IAAI,EAAE,CAAC;gBAC3B,IAAI,EAAE,QAAQ,CAAC,OAAO,EAAE,IAAI,IAAI,OAAO;gBACvC,KAAK,EAAE,uBAAuB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE;aAC5C;SACF,CAAC,CAAC;QACP,CAAC,CAAC,SAAS,CAAC;IAEhB,OAAO;QACL,IAAI;QACJ,UAAU,EAAE,cAAc;QAC1B,aAAa,EAAE,iBAAiB;QAChC,eAAe;QACf,UAAU;QACV,YAAY;QACZ,WAAW;KACZ,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qmediat.io/gemini-code-context-mcp",
3
- "version": "1.16.2",
3
+ "version": "1.16.4",
4
4
  "mcpName": "io.github.qmediat/gemini-code-context-mcp",
5
5
  "description": "MCP server that gives Claude Code persistent memory of your codebase, backed by Gemini's 2M-token context. Includes eager `ask`/`code` for cached repo Q&A and `ask_agentic` for agentic file access on repos that exceed the model's input-token limit.",
6
6
  "keywords": [
@@ -57,8 +57,8 @@
57
57
  "inspector": "npx @modelcontextprotocol/inspector node dist/index.js"
58
58
  },
59
59
  "dependencies": {
60
- "@google/genai": "^1.0.0",
61
- "@modelcontextprotocol/sdk": "^1.0.0",
60
+ "@google/genai": "^1.52.0",
61
+ "@modelcontextprotocol/sdk": "^1.30.0",
62
62
  "better-sqlite3": "^12.9.0",
63
63
  "zod": "^3.23.0",
64
64
  "zod-to-json-schema": "^3.24.0"