melchizedek-agents 0.19.0 → 1.0.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 (242) hide show
  1. package/.env.example +4 -5
  2. package/AGENT_SETUP.md +3 -3
  3. package/CHANGELOG.md +492 -76
  4. package/DOCUMENTATION.md +153 -132
  5. package/QUICKSTART.md +14 -10
  6. package/README.md +12 -15
  7. package/config/agents/examples/image_production.yaml +2 -2
  8. package/config/agents/syndicateSchema.yaml +55 -26
  9. package/dist/lib/a2a/app.d.ts +17 -12
  10. package/dist/lib/a2a/app.js +16 -6
  11. package/dist/lib/a2a/executor.d.ts +10 -14
  12. package/dist/lib/a2a/executor.js +10 -18
  13. package/dist/lib/a2a/remoteAgent.d.ts +5 -12
  14. package/dist/lib/a2a/remoteAgent.js +5 -12
  15. package/dist/lib/adkPeer.d.ts +63 -0
  16. package/dist/lib/adkPeer.js +240 -0
  17. package/dist/lib/compile.d.ts +109 -81
  18. package/dist/lib/compile.js +163 -111
  19. package/dist/lib/compileAdk.d.ts +7 -4
  20. package/dist/lib/compileAdk.js +22 -12
  21. package/dist/lib/compileNative.d.ts +63 -49
  22. package/dist/lib/compileNative.js +136 -78
  23. package/dist/lib/config.d.ts +6 -6
  24. package/dist/lib/config.js +6 -6
  25. package/dist/lib/doctor.d.ts +22 -1
  26. package/dist/lib/doctor.js +27 -2
  27. package/dist/lib/index.d.ts +14 -7
  28. package/dist/lib/index.js +11 -7
  29. package/dist/lib/loadSyndicate.d.ts +3 -3
  30. package/dist/lib/loadSyndicate.js +2 -2
  31. package/dist/lib/memory/erase.d.ts +1 -1
  32. package/dist/lib/memory/erase.js +1 -1
  33. package/dist/lib/memory/namespace.d.ts +12 -14
  34. package/dist/lib/memory/namespace.js +13 -14
  35. package/dist/lib/memory/providers.d.ts +4 -5
  36. package/dist/lib/memory/providers.js +12 -6
  37. package/dist/lib/memory/supabaseMemoryService.d.ts +9 -30
  38. package/dist/lib/memory/supabaseMemoryService.js +8 -30
  39. package/dist/lib/model.d.ts +6 -12
  40. package/dist/lib/model.js +6 -12
  41. package/dist/lib/models/adapterResolver.d.ts +21 -38
  42. package/dist/lib/models/adapterResolver.js +33 -40
  43. package/dist/lib/models/adkGeminiAdapter.js +2 -0
  44. package/dist/lib/models/adkShim.d.ts +1 -1
  45. package/dist/lib/models/adkShim.js +1 -1
  46. package/dist/lib/models/capabilities.js +13 -10
  47. package/dist/lib/models/chatCompletionsAdapter.d.ts +12 -33
  48. package/dist/lib/models/chatCompletionsAdapter.js +13 -18
  49. package/dist/lib/models/circuitBreaker.d.ts +5 -5
  50. package/dist/lib/models/circuitBreaker.js +5 -5
  51. package/dist/lib/models/claudeAdapter.d.ts +9 -26
  52. package/dist/lib/models/claudeAdapter.js +11 -15
  53. package/dist/lib/models/claudeLlm.js +2 -2
  54. package/dist/lib/models/claudeModels.d.ts +4 -4
  55. package/dist/lib/models/claudeModels.js +4 -4
  56. package/dist/lib/models/contract.d.ts +11 -11
  57. package/dist/lib/models/contract.js +6 -6
  58. package/dist/lib/models/errorResponse.d.ts +13 -20
  59. package/dist/lib/models/errorResponse.js +0 -12
  60. package/dist/lib/models/fallback.d.ts +1 -1
  61. package/dist/lib/models/fallback.js +1 -1
  62. package/dist/lib/models/fallbackAdapter.d.ts +7 -8
  63. package/dist/lib/models/gatewayAdapter.d.ts +1 -1
  64. package/dist/lib/models/gatewayAdapter.js +1 -1
  65. package/dist/lib/models/gatewayLlm.js +2 -2
  66. package/dist/lib/models/geminiAdapter.d.ts +11 -10
  67. package/dist/lib/models/geminiAdapter.js +37 -15
  68. package/dist/lib/models/geminiState.d.ts +29 -8
  69. package/dist/lib/models/geminiState.js +34 -8
  70. package/dist/lib/models/genaiMapping.d.ts +104 -38
  71. package/dist/lib/models/genaiMapping.js +146 -43
  72. package/dist/lib/models/gptAdapter.d.ts +11 -11
  73. package/dist/lib/models/gptAdapter.js +13 -13
  74. package/dist/lib/models/gptLlm.js +2 -2
  75. package/dist/lib/models/grokLlm.js +2 -2
  76. package/dist/lib/models/kimiAdapter.d.ts +6 -7
  77. package/dist/lib/models/kimiAdapter.js +6 -9
  78. package/dist/lib/models/kimiLlm.js +2 -2
  79. package/dist/lib/models/ollamaAdapter.d.ts +3 -3
  80. package/dist/lib/models/ollamaAdapter.js +3 -3
  81. package/dist/lib/models/ollamaLlm.js +2 -2
  82. package/dist/lib/models/providerMap.d.ts +6 -5
  83. package/dist/lib/models/providerMap.js +6 -5
  84. package/dist/lib/models/providerState.d.ts +3 -2
  85. package/dist/lib/models/providerState.js +3 -2
  86. package/dist/lib/models/reasoning.d.ts +1 -1
  87. package/dist/lib/models/registry.d.ts +26 -69
  88. package/dist/lib/models/registry.js +32 -140
  89. package/dist/lib/models/retry.d.ts +2 -2
  90. package/dist/lib/models/retry.js +2 -2
  91. package/dist/lib/models/schemaNormalize.d.ts +25 -55
  92. package/dist/lib/models/schemaNormalize.js +30 -100
  93. package/dist/lib/models/tracedGemini.d.ts +1 -1
  94. package/dist/lib/models/tracedGemini.js +1 -1
  95. package/dist/lib/observability/lineage.d.ts +3 -3
  96. package/dist/lib/observability/lineage.js +10 -10
  97. package/dist/lib/observability/supabaseSpanExporter.js +1 -1
  98. package/dist/lib/observability/tracer.d.ts +25 -23
  99. package/dist/lib/observability/tracer.js +26 -63
  100. package/dist/lib/persistence/supabaseProvider.d.ts +4 -3
  101. package/dist/lib/runtime/adkSessionBridge.d.ts +1 -1
  102. package/dist/lib/runtime/adkSessionBridge.js +1 -1
  103. package/dist/lib/runtime/approvals.d.ts +6 -1
  104. package/dist/lib/runtime/approvals.js +39 -8
  105. package/dist/lib/runtime/credentials.d.ts +4 -2
  106. package/dist/lib/runtime/credentials.js +6 -1
  107. package/dist/lib/runtime/events.d.ts +3 -4
  108. package/dist/lib/runtime/events.js +3 -4
  109. package/dist/lib/runtime/logging.d.ts +3 -8
  110. package/dist/lib/runtime/logging.js +3 -8
  111. package/dist/lib/runtime/memoryService.d.ts +4 -6
  112. package/dist/lib/runtime/memoryService.js +3 -5
  113. package/dist/lib/runtime/native/agentLoop.d.ts +24 -16
  114. package/dist/lib/runtime/native/agentLoop.js +67 -37
  115. package/dist/lib/runtime/native/compaction.d.ts +10 -11
  116. package/dist/lib/runtime/native/compaction.js +10 -11
  117. package/dist/lib/runtime/native/delegate.d.ts +64 -12
  118. package/dist/lib/runtime/native/delegate.js +101 -25
  119. package/dist/lib/runtime/native/history.d.ts +5 -6
  120. package/dist/lib/runtime/native/history.js +5 -6
  121. package/dist/lib/runtime/native/interrupts.d.ts +12 -9
  122. package/dist/lib/runtime/native/interrupts.js +29 -10
  123. package/dist/lib/runtime/native/request.d.ts +25 -25
  124. package/dist/lib/runtime/native/request.js +36 -25
  125. package/dist/lib/runtime/native/selfCorrection.d.ts +75 -17
  126. package/dist/lib/runtime/native/selfCorrection.js +93 -19
  127. package/dist/lib/runtime/native/step.d.ts +34 -26
  128. package/dist/lib/runtime/native/step.js +78 -32
  129. package/dist/lib/runtime/native/taskMode.d.ts +8 -8
  130. package/dist/lib/runtime/native/taskMode.js +8 -8
  131. package/dist/lib/runtime/native/telemetry.d.ts +11 -11
  132. package/dist/lib/runtime/native/telemetry.js +11 -11
  133. package/dist/lib/runtime/native/tempState.d.ts +4 -4
  134. package/dist/lib/runtime/native/tempState.js +4 -4
  135. package/dist/lib/runtime/nativeTurn.d.ts +29 -32
  136. package/dist/lib/runtime/nativeTurn.js +30 -41
  137. package/dist/lib/runtime/questions.d.ts +8 -9
  138. package/dist/lib/runtime/questions.js +1 -2
  139. package/dist/lib/runtime/runtimeFlag.d.ts +35 -13
  140. package/dist/lib/runtime/runtimeFlag.js +46 -16
  141. package/dist/lib/runtime/sessions.d.ts +10 -12
  142. package/dist/lib/runtime/sessions.js +10 -12
  143. package/dist/lib/runtime/syndicateTurn.d.ts +46 -42
  144. package/dist/lib/runtime/syndicateTurn.js +182 -150
  145. package/dist/lib/runtime/turnControl.d.ts +8 -8
  146. package/dist/lib/runtime/turnControl.js +8 -8
  147. package/dist/lib/runtime/valueDepth.d.ts +23 -0
  148. package/dist/lib/runtime/valueDepth.js +41 -0
  149. package/dist/lib/session/supabaseSessionService.d.ts +7 -21
  150. package/dist/lib/session/supabaseSessionService.js +7 -43
  151. package/dist/lib/session/transcript.d.ts +16 -26
  152. package/dist/lib/session/transcript.js +17 -55
  153. package/dist/lib/storage/postgres/sessionService.d.ts +6 -20
  154. package/dist/lib/storage/postgres/sessionService.js +6 -39
  155. package/dist/lib/syndicateSchema.d.ts +2 -0
  156. package/dist/lib/syndicateSchema.js +32 -10
  157. package/dist/lib/toolRegistry.d.ts +20 -14
  158. package/dist/lib/toolRegistry.js +76 -33
  159. package/dist/lib/tools/adkTool.d.ts +1 -1
  160. package/dist/lib/tools/adkTool.js +1 -1
  161. package/dist/lib/tools/auth.d.ts +1 -1
  162. package/dist/lib/tools/auth.js +1 -1
  163. package/dist/lib/tools/collectionsSearchTool.d.ts +1 -1
  164. package/dist/lib/tools/collectionsSearchTool.js +1 -1
  165. package/dist/lib/tools/examples.d.ts +2 -4
  166. package/dist/lib/tools/examples.js +2 -4
  167. package/dist/lib/tools/generateImageTool.d.ts +3 -3
  168. package/dist/lib/tools/generateImageTool.js +4 -5
  169. package/dist/lib/tools/inspectImageTool.d.ts +2 -2
  170. package/dist/lib/tools/inspectImageTool.js +3 -4
  171. package/dist/lib/tools/mcpToolFactory.d.ts +4 -24
  172. package/dist/lib/tools/mcpToolFactory.js +19 -9
  173. package/dist/lib/tools/memoryTools.d.ts +5 -6
  174. package/dist/lib/tools/memoryTools.js +5 -6
  175. package/dist/lib/tools/nativeTools.d.ts +9 -14
  176. package/dist/lib/tools/nativeTools.js +9 -14
  177. package/dist/lib/tools/openapiTools.d.ts +5 -7
  178. package/dist/lib/tools/openapiTools.js +6 -13
  179. package/dist/lib/tools/scienceTools.d.ts +3 -3
  180. package/dist/lib/tools/scienceTools.js +8 -10
  181. package/dist/lib/tools/skillToolset.d.ts +1 -2
  182. package/dist/lib/tools/skillToolset.js +1 -2
  183. package/dist/lib/tools/skills/executor.d.ts +1 -1
  184. package/dist/lib/tools/skills/executor.js +1 -1
  185. package/dist/lib/tools/skills/frontmatter.d.ts +2 -2
  186. package/dist/lib/tools/skills/frontmatter.js +2 -2
  187. package/dist/lib/tools/skills/tools.d.ts +8 -10
  188. package/dist/lib/tools/skills/tools.js +9 -11
  189. package/dist/lib/tools/tool.d.ts +24 -40
  190. package/dist/lib/tools/tool.js +24 -56
  191. package/dist/lib/tools/toolContract.d.ts +8 -13
  192. package/dist/lib/tools/toolContract.js +6 -17
  193. package/dist/lib/tools/urlContextTool.d.ts +1 -1
  194. package/dist/lib/tools/urlContextTool.js +1 -1
  195. package/dist/lib/tools/webExtractTool.d.ts +2 -2
  196. package/dist/lib/tools/webExtractTool.js +3 -4
  197. package/dist/lib/tools/webSearchTool.d.ts +1 -1
  198. package/dist/lib/tools/webSearchTool.js +1 -1
  199. package/dist/lib/tools/wikiTools.d.ts +2 -2
  200. package/dist/lib/tools/wikiTools.js +5 -6
  201. package/dist/lib/tools/xApiSearchTool.d.ts +2 -2
  202. package/dist/lib/tools/xApiSearchTool.js +3 -4
  203. package/dist/lib/tools/xSearchTool.d.ts +1 -1
  204. package/dist/lib/tools/xSearchTool.js +1 -1
  205. package/dist/lib/tools/xaiSearchParams.d.ts +2 -5
  206. package/dist/lib/tools/xaiSearchParams.js +2 -5
  207. package/dist/lib/wiki/agentRun.d.ts +10 -11
  208. package/dist/lib/wiki/agentRun.js +24 -41
  209. package/dist/lib/workflow/agentNode.d.ts +31 -5
  210. package/dist/lib/workflow/agentNode.js +101 -8
  211. package/dist/lib/workflow/graph.d.ts +13 -13
  212. package/dist/lib/workflow/graph.js +25 -15
  213. package/dist/lib/workflow/nodeEvents.d.ts +5 -5
  214. package/dist/lib/workflow/nodeEvents.js +5 -5
  215. package/dist/lib/workflow/pause.d.ts +5 -4
  216. package/dist/lib/workflow/pause.js +5 -4
  217. package/dist/lib/workflow/resume.d.ts +14 -13
  218. package/dist/lib/workflow/resume.js +17 -16
  219. package/dist/lib/workflow/route.d.ts +7 -7
  220. package/dist/lib/workflow/route.js +8 -8
  221. package/dist/lib/workflow/scheduler.d.ts +54 -9
  222. package/dist/lib/workflow/scheduler.js +75 -8
  223. package/dist/lib/workflow/toolNode.d.ts +18 -29
  224. package/dist/lib/workflow/toolNode.js +29 -35
  225. package/dist/lib/workflow/turn.d.ts +29 -20
  226. package/dist/lib/workflow/turn.js +111 -24
  227. package/dist/lib/workflow.d.ts +38 -42
  228. package/dist/lib/workflow.js +38 -150
  229. package/dist/lib/workflowConfig.d.ts +6 -10
  230. package/dist/lib/workflowConfig.js +2 -27
  231. package/dist/scripts/a2a_server.js +1 -2
  232. package/dist/scripts/assistant_worker.d.ts +2 -2
  233. package/dist/scripts/assistant_worker.js +8 -7
  234. package/dist/scripts/doctor.d.ts +3 -1
  235. package/dist/scripts/doctor.js +4 -2
  236. package/dist/scripts/syndicate_chat.js +14 -24
  237. package/package.json +3 -6
  238. package/skills/briefs/_shared.md +2 -2
  239. package/skills/briefs/melchizedek-author.md +2 -2
  240. package/skills/briefs/melchizedek-models.md +6 -6
  241. package/skills/melchizedek-author/SKILL.md +2 -2
  242. package/skills/melchizedek-models/SKILL.md +5 -5
@@ -4,11 +4,9 @@
4
4
  *
5
5
  * WHY this file exists:
6
6
  * Claude's translation reads a ModelRequest and yields ModelResponses, so
7
- * the native runtime (ADR 0045) can call it with no ADK in the path. On
8
- * the ADK path, ClaudeLlm (lib/models/claudeLlm.ts) is this adapter behind
9
- * the ADK shim (lib/models/adkShim.ts, ADR 0053): the shim charges the
10
- * turn and opens the llm.request span, and this adapter only decorates
11
- * that span with setLlmSpanAttribute.
7
+ * the native loop (ADR 0045) calls it directly: the loop charges the turn
8
+ * and opens the llm.request span (ADR 0053), and this adapter only
9
+ * decorates that span with setLlmSpanAttribute.
12
10
  *
13
11
  * THE MAPPING is the Anthropic table of wiki/models/model-contract.md;
14
12
  * wiki/models/claude-adapter.md records the choices made inside it:
@@ -22,15 +20,13 @@
22
20
  * the part they preceded as providerState (ADR 0046), and are replayed
23
21
  * before that part within the current turn's tool loop, for this model
24
22
  * only.
25
- * - A tool result's content is the JSON of the result in the shape the ADK
26
- * path stores it (`{ result }` for a value that is not an object,
27
- * `{ error }` for a failure), so both runtimes send the same bytes
28
- * (ADR 0055).
29
- * - ClaudeLlm adds `claudeReasoning`, the older reasoning spelling read as
30
- * ADR 0049 reads it, which this adapter reads in place of `reasoning`
31
- * (ClaudeModelRequest, ADR 0055). The native runtime never sets it.
23
+ * - A tool result's content is the JSON of the result in the shape the
24
+ * stored events keep it (`{ result }` for a value that is not an object,
25
+ * `{ error }` for a failure), the bytes ADK sent (ADR 0055).
26
+ * - Reasoning is the contract's `reasoning`, read by claudeReasoningOf
27
+ * (ADR 0049).
32
28
  * - `outputFormat: 'json'` sends nothing: the Messages API has no JSON
33
- * mode without a schema, and ClaudeLlm never sent one for
29
+ * mode without a schema, and ADK's Claude path never sent one for
34
30
  * `responseMimeType` alone (ADR 0061). The prompt asks for the JSON.
35
31
  *
36
32
  * THE ADAPTER RULES (contract.ts header) as this adapter keeps them:
@@ -150,7 +146,7 @@ export function anthropicTools(request) {
150
146
  tools.push(WEB_SEARCH_TOOL);
151
147
  return tools;
152
148
  }
153
- /** A tool result's content: the JSON of the result in the shape the ADK path stores it. */
149
+ /** A tool result's content: the JSON of the result in the shape the stored events keep it (ADR 0055). */
154
150
  function toolResultBlock(part) {
155
151
  const response = part.isError ? { error: part.result } : isPlainObject(part.result) ? part.result : { result: part.result };
156
152
  return {
@@ -278,7 +274,7 @@ export class ClaudeAdapter {
278
274
  async #build(request, model, endpoint) {
279
275
  // ── The request surface this model takes (ADR 0049) ──────────────────────
280
276
  const gen = claudeGeneration(model);
281
- const reasoning = request.claudeReasoning ?? claudeReasoningOf(request.reasoning);
277
+ const reasoning = claudeReasoningOf(request.reasoning);
282
278
  // Adaptive generations: thinking, effort and drop_block from the table.
283
279
  // Budget generations keep the budget path below.
284
280
  const plan = gen.thinking === 'adaptive' ? adaptiveThinkingFor(gen, reasoning) : undefined;
@@ -33,7 +33,7 @@
33
33
  * replayed within the tool loop, structured output, images, web search) is
34
34
  * described in its header and in wiki/models/claude-adapter.md.
35
35
  */
36
- import { LLMRegistry } from '@google/adk';
36
+ import { requireAdk } from '../adkPeer.js';
37
37
  import { AdkShim } from './adkShim.js';
38
38
  import { ClaudeAdapter, anthropicTools } from './claudeAdapter.js';
39
39
  import { claudeReasoningFromConfig } from './claudeModels.js';
@@ -83,5 +83,5 @@ export class ClaudeLlm extends AdkShim {
83
83
  * message about which provider is active.
84
84
  */
85
85
  export function registerClaudeLlm() {
86
- LLMRegistry.register(ClaudeLlm);
86
+ requireAdk("Registering a model class with ADK's LLMRegistry").LLMRegistry.register(ClaudeLlm);
87
87
  }
@@ -20,8 +20,8 @@
20
20
  *
21
21
  * How hard a request asks Claude to think reaches the table as one
22
22
  * `ClaudeReasoning`: from the contract's `reasoning` (claudeReasoningOf),
23
- * or, on the ADK path, from the agent's generateContentConfig as ADR 0049
24
- * reads it (claudeReasoningFromConfig, ADR 0055).
23
+ * or from the agent's generateContentConfig as ADR 0049 reads it
24
+ * (claudeReasoningFromConfig, ADR 0055).
25
25
  */
26
26
  import type { ReasoningSetting } from './contract.ts';
27
27
  import type { Platform } from './endpoints.ts';
@@ -83,8 +83,8 @@ export declare function claudeReasoningOf(setting: ReasoningSetting | undefined)
83
83
  * The older spelling in an agent's generateContentConfig, read as ADR 0049
84
84
  * reads it: the effort word first (`xhigh` and `max` pass through,
85
85
  * `minimal` is `low`), else the thinking budget rounded up to a level; and
86
- * the thinking budget as given, which is all the budget rows read. The ADK
87
- * path's ClaudeLlm hands the adapter this (ADR 0055).
86
+ * the thinking budget as given, which is all the budget rows read
87
+ * (ADR 0055).
88
88
  */
89
89
  export declare function claudeReasoningFromConfig(cfg: Record<string, any>): ClaudeReasoning;
90
90
  /** The beta that lets a request set `thinking.block_binding`. */
@@ -20,8 +20,8 @@
20
20
  *
21
21
  * How hard a request asks Claude to think reaches the table as one
22
22
  * `ClaudeReasoning`: from the contract's `reasoning` (claudeReasoningOf),
23
- * or, on the ADK path, from the agent's generateContentConfig as ADR 0049
24
- * reads it (claudeReasoningFromConfig, ADR 0055).
23
+ * or from the agent's generateContentConfig as ADR 0049 reads it
24
+ * (claudeReasoningFromConfig, ADR 0055).
25
25
  */
26
26
  import { REASONING_BUDGETS } from './reasoning.js';
27
27
  const BUDGET = {
@@ -163,8 +163,8 @@ export function claudeReasoningOf(setting) {
163
163
  * The older spelling in an agent's generateContentConfig, read as ADR 0049
164
164
  * reads it: the effort word first (`xhigh` and `max` pass through,
165
165
  * `minimal` is `low`), else the thinking budget rounded up to a level; and
166
- * the thinking budget as given, which is all the budget rows read. The ADK
167
- * path's ClaudeLlm hands the adapter this (ADR 0055).
166
+ * the thinking budget as given, which is all the budget rows read
167
+ * (ADR 0055).
168
168
  */
169
169
  export function claudeReasoningFromConfig(cfg) {
170
170
  const effort = requestedEffort(cfg);
@@ -4,12 +4,12 @@
4
4
  * implements and the native runtime calls (ADR 0045, ADR 0048).
5
5
  *
6
6
  * WHY this file exists:
7
- * The ADK runtime speaks @google/genai `Content`, which is Gemini's wire
8
- * format. It has no slot for another provider's reasoning state, spells
9
- * schemas in Gemini's uppercase dialect, carries server-side tools as
10
- * sentinel tool objects, and surfaces failures as a throw on one path and
11
- * a yielded `errorCode` on another. The native runtime owns its loop, so it
12
- * owns this format instead. Each adapter translates it to its provider's
7
+ * ADK spoke @google/genai `Content`, which is Gemini's wire format. It
8
+ * has no slot for another provider's reasoning state, spells schemas in
9
+ * Gemini's uppercase dialect, carried server-side tools as sentinel tool
10
+ * objects, and surfaced failures as a throw on one path and a yielded
11
+ * `errorCode` on another. The native runtime owns its loop, so it owns
12
+ * this format instead. Each adapter translates it to its provider's
13
13
  * wire; wiki/models/model-contract.md is the field-by-field spec, with the
14
14
  * mapping for every provider.
15
15
  *
@@ -290,9 +290,9 @@ type SetupErrorCode = 'MISSING_API_KEY' | 'ENDPOINT_MISCONFIGURED' | 'SDK_NOT_IN
290
290
  /** The chat-completions failures, under the provider's id (the gateway names the upstream provider). */
291
291
  type ChatErrorCode = `${'MOONSHOT' | 'OLLAMA' | 'GEMINI' | 'ANTHROPIC' | 'OPENAI' | 'XAI'}_${'MAX_TOKENS' | 'EMPTY_RESPONSE' | 'UNREACHABLE'}` | 'MOONSHOT_MISSING_KEY' | 'MOONSHOT_HTTP_ERROR' | 'OLLAMA_HTTP_ERROR' | 'GATEWAY_NOT_CONFIGURED' | 'GATEWAY_KEY_MISSING' | 'GATEWAY_HTTP_ERROR';
292
292
  /**
293
- * Gemini's codes: ADK's adapter reports a candidate's finish reason, or the
294
- * prompt's block reason, as the code itself. GEMINI_ERROR is a failed call,
295
- * which ADK throws and the contract reports.
293
+ * Gemini's codes: a candidate's finish reason, or the prompt's block reason,
294
+ * is the code itself, as ADK's adapter reported it. GEMINI_ERROR is a failed
295
+ * call, which ADK threw and the contract reports.
296
296
  */
297
297
  type GeminiErrorCode = 'GEMINI_ERROR' | 'MAX_TOKENS' | 'SAFETY' | 'RECITATION' | 'LANGUAGE' | 'OTHER' | 'BLOCKLIST' | 'PROHIBITED_CONTENT' | 'SPII' | 'MALFORMED_FUNCTION_CALL' | 'IMAGE_SAFETY' | 'UNEXPECTED_TOOL_CALL' | 'TOO_MANY_TOOL_CALLS' | 'IMAGE_PROHIBITED_CONTENT' | 'NO_IMAGE' | 'IMAGE_RECITATION' | 'IMAGE_OTHER' | 'MODEL_ARMOR' | 'JAILBREAK' | 'UNKNOWN_ERROR';
298
298
  /**
@@ -302,8 +302,8 @@ type GeminiErrorCode = 'GEMINI_ERROR' | 'MAX_TOKENS' | 'SAFETY' | 'RECITATION' |
302
302
  */
303
303
  type TurnControlErrorCode = 'STEP_LIMIT' | 'DEADLINE_EXCEEDED' | 'CANCELED';
304
304
  /**
305
- * The codes the engine's adapters report, kept verbatim from what they emit
306
- * under ADK so a caller matching on a code keeps working. An adapter the
305
+ * The codes the engine's adapters report, kept verbatim from what they
306
+ * emitted under ADK so a caller matching on a code keeps working. An adapter the
307
307
  * engine does not ship may report its own; the engine's adapters use only
308
308
  * these, and adding one is a change to wiki/models/model-contract.md.
309
309
  */
@@ -4,12 +4,12 @@
4
4
  * implements and the native runtime calls (ADR 0045, ADR 0048).
5
5
  *
6
6
  * WHY this file exists:
7
- * The ADK runtime speaks @google/genai `Content`, which is Gemini's wire
8
- * format. It has no slot for another provider's reasoning state, spells
9
- * schemas in Gemini's uppercase dialect, carries server-side tools as
10
- * sentinel tool objects, and surfaces failures as a throw on one path and
11
- * a yielded `errorCode` on another. The native runtime owns its loop, so it
12
- * owns this format instead. Each adapter translates it to its provider's
7
+ * ADK spoke @google/genai `Content`, which is Gemini's wire format. It
8
+ * has no slot for another provider's reasoning state, spells schemas in
9
+ * Gemini's uppercase dialect, carried server-side tools as sentinel tool
10
+ * objects, and surfaced failures as a throw on one path and a yielded
11
+ * `errorCode` on another. The native runtime owns its loop, so it owns
12
+ * this format instead. Each adapter translates it to its provider's
13
13
  * wire; wiki/models/model-contract.md is the field-by-field spec, with the
14
14
  * mapping for every provider.
15
15
  *
@@ -1,16 +1,17 @@
1
1
  /**
2
- * lib/models/errorResponse.ts — an ADK adapter's error response, saying
3
- * whether another attempt or another model may succeed.
2
+ * lib/models/errorResponse.ts — what a failed provider call says about
3
+ * trying again, and the genai-shaped error response that carries it.
4
4
  *
5
- * WHY: every adapter but Gemini reports a failed provider call as a yielded
6
- * LlmResponse carrying `errorCode`, never a throw. FallbackLlm
7
- * (lib/models/fallback.ts, ADR 0044) must tell a provider-side failure from
8
- * the request's own error without parsing a message, so an adapter's catch
9
- * site builds that response here, with the retry policy's verdict in its
10
- * customMetadata (Claude, GPT and Grok, and the chat-completions base for
11
- * Kimi, Ollama and the gateway). A
12
- * response without the verdict is read as not retryable: passed on, never
13
- * redirected.
5
+ * WHY: an adapter reports a failed provider call as a final response with
6
+ * `error`, never a throw, and the fallback (FallbackAdapter,
7
+ * lib/models/fallbackAdapter.ts, ADR 0044) must tell a provider-side
8
+ * failure from the request's own error without parsing a message. The
9
+ * adapters' catch sites (Claude, GPT and Grok, and the chat-completions base
10
+ * for Kimi, Ollama and the gateway) take the verdict and the scrubbed text
11
+ * from here (errorDecision, statusDecision, errorText). A genai-shaped
12
+ * LlmResponse (lib/models/genaiMapping.ts) carries the same verdict in its
13
+ * customMetadata (withRetryVerdict). A response without the verdict is read
14
+ * as not retryable: passed on, never redirected.
14
15
  *
15
16
  * 'error.retryable' true when lib/models/retry.ts classifies the failure
16
17
  * retryable (408/409/425/429/5xx, a connection reset);
@@ -22,7 +23,7 @@
22
23
  * leaves the adapter, so an error never carries a key into a session, the
23
24
  * ledger or a log.
24
25
  */
25
- import type { LlmResponse } from '@google/adk';
26
+ import type { LlmResponse } from './genaiMapping.ts';
26
27
  import type { RetryDecision } from './retry.ts';
27
28
  /** customMetadata key: whether another attempt or model may succeed. */
28
29
  export declare const ERROR_RETRYABLE_KEY = "error.retryable";
@@ -40,11 +41,3 @@ export declare function statusDecision(status: number): RetryDecision;
40
41
  * the adapter's own; customMetadata it already carries is kept.
41
42
  */
42
43
  export declare function withRetryVerdict(response: LlmResponse, decision: RetryDecision): LlmResponse;
43
- /**
44
- * The error response for a caught provider error: `errorCode`, the message
45
- * (the error's own text unless the adapter words it), and the verdict from
46
- * classifyError.
47
- */
48
- export declare function providerErrorResponse(err: unknown, errorCode: string, errorMessage?: string): LlmResponse;
49
- /** True when a response is an error its adapter marked retryable: a provider-side failure. */
50
- export declare function isRetryableErrorResponse(response: LlmResponse): boolean;
@@ -34,15 +34,3 @@ export function withRetryVerdict(response, decision) {
34
34
  },
35
35
  };
36
36
  }
37
- /**
38
- * The error response for a caught provider error: `errorCode`, the message
39
- * (the error's own text unless the adapter words it), and the verdict from
40
- * classifyError.
41
- */
42
- export function providerErrorResponse(err, errorCode, errorMessage = errorText(err)) {
43
- return withRetryVerdict({ errorCode, errorMessage }, errorDecision(err));
44
- }
45
- /** True when a response is an error its adapter marked retryable: a provider-side failure. */
46
- export function isRetryableErrorResponse(response) {
47
- return !!response.errorCode && response.customMetadata?.[ERROR_RETRYABLE_KEY] === true;
48
- }
@@ -31,7 +31,7 @@
31
31
  * closes it. Its state is lib/models/circuitBreaker.ts, which the
32
32
  * contract-level wrapper (lib/models/fallbackAdapter.ts) shares.
33
33
  */
34
- import { BaseLlm } from '@google/adk';
34
+ import { BaseLlm } from '../adkPeer.ts';
35
35
  import type { BaseLlmConnection, LlmRequest, LlmResponse } from '@google/adk';
36
36
  export { circuitOpen, resetCircuits } from './circuitBreaker.ts';
37
37
  /** A provider-side failure: worth counting against the provider and worth a fallback. A cancellation never is. */
@@ -31,7 +31,7 @@
31
31
  * closes it. Its state is lib/models/circuitBreaker.ts, which the
32
32
  * contract-level wrapper (lib/models/fallbackAdapter.ts) shares.
33
33
  */
34
- import { BaseLlm } from '@google/adk';
34
+ import { BaseLlm } from '../adkPeer.js';
35
35
  import { errorDecision, errorText, isRetryableErrorResponse } from './errorResponse.js';
36
36
  import { providerForModel } from './providerMap.js';
37
37
  import { circuitOpen, recordFailure, recordSuccess } from './circuitBreaker.js';
@@ -2,11 +2,10 @@
2
2
  * lib/models/fallbackAdapter.ts — `fallback_model:` and the per-provider
3
3
  * circuit breaker (ADR 0044) on the engine's own model contract (ADR 0048).
4
4
  *
5
- * WHY: FallbackLlm (lib/models/fallback.ts) wraps two ADK BaseLlm adapters
6
- * and reads a failure from a throw. On the contract a failure is a final
7
- * response with `error` set, never a throw, and `error.retryable` already
8
- * says whether another model may succeed. This wrapper is the same rule set
9
- * read from that: one ModelAdapter around a primary and a fallback adapter.
5
+ * WHY: on the contract a failure is a final response with `error` set,
6
+ * never a throw, and `error.retryable` already says whether another model
7
+ * may succeed. This wrapper is ADR 0044's rule set read from that: one
8
+ * ModelAdapter around a primary and a fallback adapter.
10
9
  *
11
10
  * THE RULES (ADR 0044, unchanged):
12
11
  * - Only a provider-side failure counts and redirects: `error.retryable`
@@ -19,9 +18,9 @@
19
18
  * was yielded and the failed final holds no parts. A call that failed
20
19
  * midway is passed on, never replayed on another model.
21
20
  * - The breaker (lib/models/circuitBreaker.ts) is keyed on the primary's
22
- * `provider` and shared with FallbackLlm, so a provider tripped on one
23
- * path is skipped on the other. While it is open the primary is not
24
- * called. A success closes it; the fallback's own outcome is not counted.
21
+ * `provider` and shared by every wrapped agent in the process, so a
22
+ * provider tripped for one agent is skipped for the others. While it is
23
+ * open the primary is not called. A success closes it; the fallback's own outcome is not counted.
25
24
  *
26
25
  * THE FALLBACK'S REQUEST: the caller's request with `model` rewritten to the
27
26
  * fallback's id. `reasoning` goes unchanged, and the fallback adapter maps it
@@ -8,7 +8,7 @@
8
8
  * (lib/models/gateway.ts owns that decision). It extends the
9
9
  * chat-completions base (lib/models/chatCompletionsAdapter.ts) the way
10
10
  * Ollama does, because chat completions is the one dialect every gateway
11
- * serves. Under ADK it runs behind GatewayLlm (lib/models/gatewayLlm.ts).
11
+ * serves.
12
12
  *
13
13
  * WHAT STAYS TRUE THROUGH THE GATEWAY:
14
14
  * - Attribution. `provider` is the YAML id's provider (anthropic, openai,
@@ -8,7 +8,7 @@
8
8
  * (lib/models/gateway.ts owns that decision). It extends the
9
9
  * chat-completions base (lib/models/chatCompletionsAdapter.ts) the way
10
10
  * Ollama does, because chat completions is the one dialect every gateway
11
- * serves. Under ADK it runs behind GatewayLlm (lib/models/gatewayLlm.ts).
11
+ * serves.
12
12
  *
13
13
  * WHAT STAYS TRUE THROUGH THE GATEWAY:
14
14
  * - Attribution. `provider` is the YAML id's provider (anthropic, openai,
@@ -16,7 +16,7 @@
16
16
  * carry the SAME supportedModels instances as the direct adapter it stands
17
17
  * in for (see gatewayClassFor below, and its use in registry.ts).
18
18
  */
19
- import { LLMRegistry } from '@google/adk';
19
+ import { requireAdk } from '../adkPeer.js';
20
20
  import { GatewayAdapter } from './gatewayAdapter.js';
21
21
  import { OpenAiCompatibleLlm } from './openAiCompatibleLlm.js';
22
22
  export class GatewayLlm extends OpenAiCompatibleLlm {
@@ -40,5 +40,5 @@ export function gatewayClassFor(patterns) {
40
40
  }
41
41
  /** Registers a gateway stand-in for the given patterns. */
42
42
  export function registerGatewayLlm(patterns) {
43
- LLMRegistry.register(gatewayClassFor(patterns));
43
+ requireAdk("Registering a model class with ADK's LLMRegistry").LLMRegistry.register(gatewayClassFor(patterns));
44
44
  }
@@ -3,12 +3,11 @@
3
3
  * contract (lib/models/contract.ts, ADR 0048), on @google/genai directly.
4
4
  *
5
5
  * WHY this file exists:
6
- * Gemini runs today through ADK's own Gemini class, wrapped as
7
- * TracedGemini (lib/models/tracedGemini.ts). The native runtime (ADR 0045)
8
- * needs Gemini as a contract ModelAdapter that shapes its own requests,
9
- * aggregates its own stream and reports its own failures, with no ADK in
10
- * the path. This is that adapter. resolveAdapter (lib/models/registry.ts)
11
- * returns it only when asked (GEMINI_ADAPTER=engine) until gate G3.
6
+ * The native loop (ADR 0045) needs Gemini as a contract ModelAdapter that
7
+ * shapes its own requests, aggregates its own stream and reports its own
8
+ * failures. This is that adapter, and the only Gemini adapter:
9
+ * resolveAdapter (lib/models/adapterResolver.ts) returns it for every
10
+ * Gemini id (ADR 0100, ADR 0107).
12
11
  *
13
12
  * THE MAPPING is the Gemini table of wiki/models/model-contract.md;
14
13
  * wiki/models/gemini-adapter.md records the choices made inside it:
@@ -49,7 +48,7 @@
49
48
  import type { GenerateContentParameters, GenerateContentResponse, GoogleGenAIOptions, Part as WirePart } from '@google/genai';
50
49
  import type { ModelAdapter, ModelRequest, ModelResponse } from './contract.ts';
51
50
  import type { ProviderEndpoint } from './endpoints.ts';
52
- import { GEMINI_PROVIDER, THOUGHT_SIGNATURE_KIND } from './geminiState.ts';
51
+ import { CARRIED_PARTS_KIND, GEMINI_PROVIDER, PLACEHOLDER_THOUGHT_SIGNATURE, THOUGHT_SIGNATURE_KIND } from './geminiState.ts';
53
52
  /**
54
53
  * The provider id this adapter reports and writes its state under, and the
55
54
  * providerState kind for a Gemini thought signature (ADR 0046). Defined once
@@ -64,9 +63,11 @@ export declare const ENGINE_CALL_ID_PREFIX = "adk-";
64
63
  /**
65
64
  * The providerState kind for Gemini parts the contract has no type for
66
65
  * (code execution and server-side tool invocations), carried whole on the
67
- * next output part (ADR 0065). The payload is a `CarriedParts`.
66
+ * next output part (ADR 0065). The payload is a `CarriedParts`. Defined in
67
+ * lib/models/geminiState.ts, so the genai mapping writes them back out as
68
+ * the parts they were when an event is stored (ADR 0100).
68
69
  */
69
- export declare const CARRIED_PARTS_KIND = "carried_parts";
70
+ export { CARRIED_PARTS_KIND };
70
71
  /** The payload of a `carried_parts` state. */
71
72
  export interface CarriedParts {
72
73
  /** The genai parts that came before the output part, as Gemini sent them. */
@@ -82,7 +83,7 @@ export interface CarriedParts {
82
83
  * (default PLACEHOLDER_SIGNATURES_BY_DEFAULT, off) until the G3 live run
83
84
  * confirms it (ADR 0065).
84
85
  */
85
- export declare const PLACEHOLDER_THOUGHT_SIGNATURE = "skip_thought_signature_validator";
86
+ export { PLACEHOLDER_THOUGHT_SIGNATURE };
86
87
  /** Off: no placeholder signature is sent unless the adapter is built to send it. */
87
88
  export declare const PLACEHOLDER_SIGNATURES_BY_DEFAULT = false;
88
89
  /** The part of the @google/genai client this adapter calls. `GoogleGenAI` satisfies it. */
@@ -3,12 +3,11 @@
3
3
  * contract (lib/models/contract.ts, ADR 0048), on @google/genai directly.
4
4
  *
5
5
  * WHY this file exists:
6
- * Gemini runs today through ADK's own Gemini class, wrapped as
7
- * TracedGemini (lib/models/tracedGemini.ts). The native runtime (ADR 0045)
8
- * needs Gemini as a contract ModelAdapter that shapes its own requests,
9
- * aggregates its own stream and reports its own failures, with no ADK in
10
- * the path. This is that adapter. resolveAdapter (lib/models/registry.ts)
11
- * returns it only when asked (GEMINI_ADAPTER=engine) until gate G3.
6
+ * The native loop (ADR 0045) needs Gemini as a contract ModelAdapter that
7
+ * shapes its own requests, aggregates its own stream and reports its own
8
+ * failures. This is that adapter, and the only Gemini adapter:
9
+ * resolveAdapter (lib/models/adapterResolver.ts) returns it for every
10
+ * Gemini id (ADR 0100, ADR 0107).
12
11
  *
13
12
  * THE MAPPING is the Gemini table of wiki/models/model-contract.md;
14
13
  * wiki/models/gemini-adapter.md records the choices made inside it:
@@ -48,7 +47,7 @@
48
47
  */
49
48
  import { FunctionCallingConfigMode, GoogleGenAI } from '@google/genai';
50
49
  import { endpointFromEnv, endpointProblems, platformModel } from './endpoints.js';
51
- import { GEMINI_PROVIDER, MINTED_CALL_ID_PREFIX, THOUGHT_SIGNATURE_KIND } from './geminiState.js';
50
+ import { CARRIED_PARTS_KIND, GEMINI_PROVIDER, GENAI_PART_KIND, MINTED_CALL_ID_PREFIX, PLACEHOLDER_THOUGHT_SIGNATURE, THOUGHT_SIGNATURE_KIND, isCarriedWirePart, } from './geminiState.js';
52
51
  import { currentTurnStart, providerStateOf } from './providerState.js';
53
52
  import { classifyError, errorStatus, retryUntilFirstYield } from './retry.js';
54
53
  import { reasoningConfig } from './reasoning.js';
@@ -67,9 +66,11 @@ export const ENGINE_CALL_ID_PREFIX = 'adk-';
67
66
  /**
68
67
  * The providerState kind for Gemini parts the contract has no type for
69
68
  * (code execution and server-side tool invocations), carried whole on the
70
- * next output part (ADR 0065). The payload is a `CarriedParts`.
69
+ * next output part (ADR 0065). The payload is a `CarriedParts`. Defined in
70
+ * lib/models/geminiState.ts, so the genai mapping writes them back out as
71
+ * the parts they were when an event is stored (ADR 0100).
71
72
  */
72
- export const CARRIED_PARTS_KIND = 'carried_parts';
73
+ export { CARRIED_PARTS_KIND };
73
74
  /**
74
75
  * The thought signature Gemini documents for a function call that has no
75
76
  * real one: a call another provider or model made earlier in the current
@@ -78,7 +79,7 @@ export const CARRIED_PARTS_KIND = 'carried_parts';
78
79
  * (default PLACEHOLDER_SIGNATURES_BY_DEFAULT, off) until the G3 live run
79
80
  * confirms it (ADR 0065).
80
81
  */
81
- export const PLACEHOLDER_THOUGHT_SIGNATURE = 'skip_thought_signature_validator';
82
+ export { PLACEHOLDER_THOUGHT_SIGNATURE };
82
83
  /** Off: no placeholder signature is sent unless the adapter is built to send it. */
83
84
  export const PLACEHOLDER_SIGNATURES_BY_DEFAULT = false;
84
85
  const defaultClientFactory = (options) => new GoogleGenAI(options);
@@ -100,8 +101,8 @@ export class GeminiAdapter {
100
101
  this.#placeholderSignatures = options.placeholderSignatures ?? PLACEHOLDER_SIGNATURES_BY_DEFAULT;
101
102
  }
102
103
  async *generate(request) {
103
- // The request's signal alone: the caller (the ADK shim, the native loop)
104
- // passes the turn's (ADR 0053).
104
+ // The request's signal alone: the caller (the native loop) passes the
105
+ // turn's (ADR 0053).
105
106
  const signal = request.signal;
106
107
  const model = request.model || this.model;
107
108
  const reply = new ReplyBuilder(model, request.messages.length);
@@ -275,8 +276,8 @@ function buildRequest(request, options) {
275
276
  const native = tools.length > (declared ? 1 : 0);
276
277
  let toolConfig = toolConfigFor(request);
277
278
  // Native tools beside function declarations: the response carries the
278
- // server-side invocations, as the ADK path asks on every Gemini agent
279
- // (lib/compile.ts). The SDK refuses the flag for Vertex AI.
279
+ // server-side invocations, as ADK asked on every Gemini agent. The SDK
280
+ // refuses the flag for Vertex AI.
280
281
  if (declared && native && options.geminiApi)
281
282
  toolConfig = { ...toolConfig, includeServerSideToolInvocations: true };
282
283
  if (toolConfig)
@@ -330,6 +331,18 @@ function assistantToWire(message, replay, model) {
330
331
  carried = signature ?? carried;
331
332
  continue;
332
333
  }
334
+ // A carried part read back from a stored event (the mapping's genai_part):
335
+ // itself, verbatim, within its turn; outside it, nothing (ADR 0065, ADR 0100).
336
+ const stored = storedCarriedPart(part);
337
+ if (stored) {
338
+ if (!replay)
339
+ continue;
340
+ if (carried && !stored.thoughtSignature)
341
+ stored.thoughtSignature = carried;
342
+ carried = undefined;
343
+ out.push(stored);
344
+ continue;
345
+ }
333
346
  const before = replay ? carriedPartsOf(part, model) : [];
334
347
  if (before.length && carried) {
335
348
  if (!before[0].thoughtSignature)
@@ -381,6 +394,15 @@ function carriedPartsOf(part, model) {
381
394
  return own && typeof thoughtSignature === 'string' && thoughtSignature ? { ...rest, thoughtSignature } : { ...rest };
382
395
  });
383
396
  }
397
+ /**
398
+ * A copy of the code execution or server-side invocation part a stored
399
+ * event held, as the genai mapping reads it back (`genai_part` state on its
400
+ * text projection), or undefined for any other part.
401
+ */
402
+ function storedCarriedPart(part) {
403
+ const payload = providerStateOf(part, GEMINI_PROVIDER, GENAI_PART_KIND)?.payload;
404
+ return isPlainObject(payload) && isCarriedWirePart(payload) ? { ...payload } : undefined;
405
+ }
384
406
  /**
385
407
  * Gemini 3 rejects a current-turn step whose first function call has no
386
408
  * signature (a call another provider or model made). With placeholder
@@ -456,7 +478,7 @@ function finishReasonOf(reason) {
456
478
  * turn: code execution, and a server-side tool invocation.
457
479
  */
458
480
  function isCarried(part) {
459
- return part.executableCode !== undefined || part.codeExecutionResult !== undefined || part.toolCall !== undefined || part.toolResponse !== undefined;
481
+ return isCarriedWirePart(part);
460
482
  }
461
483
  /**
462
484
  * Folds Gemini's responses (one, or a stream's chunks) into the contract's
@@ -3,20 +3,41 @@
3
3
  * written under (ADR 0046), and the prefix of a call id the genai mapping
4
4
  * mints, in one place.
5
5
  *
6
- * WHY: three modules write or replay a Gemini `thoughtSignature` as
7
- * `providerState`: the genai mapping (lib/models/genaiMapping.ts), the
8
- * engine's own Gemini adapter (lib/models/geminiAdapter.ts) and the wrapper
9
- * over ADK's Gemini (lib/models/adkGeminiAdapter.ts). A reader replays only
10
- * the provider and kind it wrote (`providerStateOf`), so the three must spell
11
- * them the same. Each re-exports these names where they were exported before.
6
+ * WHY: two modules write or replay a Gemini `thoughtSignature` as
7
+ * `providerState`: the genai mapping (lib/models/genaiMapping.ts) and the
8
+ * engine's Gemini adapter (lib/models/geminiAdapter.ts). A reader replays
9
+ * only the provider and kind it wrote (`providerStateOf`), so the two must
10
+ * spell them the same. Each re-exports these names where they were exported
11
+ * before.
12
12
  *
13
- * A leaf with no imports, so the Gemini adapter takes the ids without the
14
- * mapping, whose import graph names ADK's types.
13
+ * A leaf with no imports, so a module takes the ids without the mapping and
14
+ * its @google/genai import graph.
15
15
  */
16
16
  /** The provider id the Gemini adapters report, and write their state under (lib/models/providerMap.ts). */
17
17
  export declare const GEMINI_PROVIDER = "gemini";
18
18
  /** The providerState kind for a Gemini thought signature; the payload is the signature. */
19
19
  export declare const THOUGHT_SIGNATURE_KIND = "thought_signature";
20
+ /**
21
+ * The thought signature Gemini documents for a function call that has no
22
+ * real one. Gemini 3 rejects a current-turn function call without a
23
+ * signature; this value passes its validator (ADR 0065).
24
+ */
25
+ export declare const PLACEHOLDER_THOUGHT_SIGNATURE = "skip_thought_signature_validator";
26
+ /**
27
+ * The providerState kind the Gemini adapter writes for the Gemini parts the
28
+ * contract has no type for (code execution, server-side invocations),
29
+ * carried whole on the next output part (ADR 0065). The payload is
30
+ * `{ before: <the genai parts>, signature?: <the part's own signature> }`.
31
+ * The genai mapping writes them back out as the parts they were (ADR 0100).
32
+ */
33
+ export declare const CARRIED_PARTS_KIND = "carried_parts";
34
+ /**
35
+ * The providerState kind the genai mapping writes for a genai part the
36
+ * contract cannot hold exactly; the payload is the part, verbatim.
37
+ */
38
+ export declare const GENAI_PART_KIND = "genai_part";
39
+ /** A Gemini part the contract has no type for and Gemini wants back within the turn: code execution, a server-side invocation. */
40
+ export declare function isCarriedWirePart(part: unknown): boolean;
20
41
  /**
21
42
  * The prefix of an id the genai mapping (lib/models/genaiMapping.ts) made
22
43
  * for a call or result that had none. Such an id never goes on the wire: the
@@ -3,20 +3,46 @@
3
3
  * written under (ADR 0046), and the prefix of a call id the genai mapping
4
4
  * mints, in one place.
5
5
  *
6
- * WHY: three modules write or replay a Gemini `thoughtSignature` as
7
- * `providerState`: the genai mapping (lib/models/genaiMapping.ts), the
8
- * engine's own Gemini adapter (lib/models/geminiAdapter.ts) and the wrapper
9
- * over ADK's Gemini (lib/models/adkGeminiAdapter.ts). A reader replays only
10
- * the provider and kind it wrote (`providerStateOf`), so the three must spell
11
- * them the same. Each re-exports these names where they were exported before.
6
+ * WHY: two modules write or replay a Gemini `thoughtSignature` as
7
+ * `providerState`: the genai mapping (lib/models/genaiMapping.ts) and the
8
+ * engine's Gemini adapter (lib/models/geminiAdapter.ts). A reader replays
9
+ * only the provider and kind it wrote (`providerStateOf`), so the two must
10
+ * spell them the same. Each re-exports these names where they were exported
11
+ * before.
12
12
  *
13
- * A leaf with no imports, so the Gemini adapter takes the ids without the
14
- * mapping, whose import graph names ADK's types.
13
+ * A leaf with no imports, so a module takes the ids without the mapping and
14
+ * its @google/genai import graph.
15
15
  */
16
16
  /** The provider id the Gemini adapters report, and write their state under (lib/models/providerMap.ts). */
17
17
  export const GEMINI_PROVIDER = 'gemini';
18
18
  /** The providerState kind for a Gemini thought signature; the payload is the signature. */
19
19
  export const THOUGHT_SIGNATURE_KIND = 'thought_signature';
20
+ /**
21
+ * The thought signature Gemini documents for a function call that has no
22
+ * real one. Gemini 3 rejects a current-turn function call without a
23
+ * signature; this value passes its validator (ADR 0065).
24
+ */
25
+ export const PLACEHOLDER_THOUGHT_SIGNATURE = 'skip_thought_signature_validator';
26
+ /**
27
+ * The providerState kind the Gemini adapter writes for the Gemini parts the
28
+ * contract has no type for (code execution, server-side invocations),
29
+ * carried whole on the next output part (ADR 0065). The payload is
30
+ * `{ before: <the genai parts>, signature?: <the part's own signature> }`.
31
+ * The genai mapping writes them back out as the parts they were (ADR 0100).
32
+ */
33
+ export const CARRIED_PARTS_KIND = 'carried_parts';
34
+ /**
35
+ * The providerState kind the genai mapping writes for a genai part the
36
+ * contract cannot hold exactly; the payload is the part, verbatim.
37
+ */
38
+ export const GENAI_PART_KIND = 'genai_part';
39
+ /** A Gemini part the contract has no type for and Gemini wants back within the turn: code execution, a server-side invocation. */
40
+ export function isCarriedWirePart(part) {
41
+ if (typeof part !== 'object' || part === null)
42
+ return false;
43
+ const p = part;
44
+ return p.executableCode !== undefined || p.codeExecutionResult !== undefined || p.toolCall !== undefined || p.toolResponse !== undefined;
45
+ }
20
46
  /**
21
47
  * The prefix of an id the genai mapping (lib/models/genaiMapping.ts) made
22
48
  * for a call or result that had none. Such an id never goes on the wire: the