@nhtio/adk 0.1.0-master-2a4e1bd2 → 0.1.0-master-cd595e6f

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 (413) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/artifact_methods-CJDQ5Lv-.mjs +1 -0
  3. package/artifact_methods-D6k_82r3.js +1 -0
  4. package/batteries/artifacts/ecmascript.cjs +1 -1
  5. package/batteries/artifacts/ecmascript.mjs +1 -1
  6. package/batteries/artifacts/toon.cjs +1 -1
  7. package/batteries/artifacts/toon.mjs +1 -1
  8. package/batteries/artifacts/xml.cjs +1 -1
  9. package/batteries/artifacts/xml.mjs +1 -1
  10. package/batteries/artifacts/yaml.cjs +1 -1
  11. package/batteries/artifacts/yaml.mjs +1 -1
  12. package/batteries/artifacts.cjs +4 -4
  13. package/batteries/artifacts.mjs +4 -4
  14. package/batteries/dev-tools/forge.cjs +3 -3
  15. package/batteries/dev-tools/forge.mjs +3 -3
  16. package/batteries/dev-tools.cjs +2 -2
  17. package/batteries/dev-tools.mjs +2 -2
  18. package/batteries/encoding.cjs +7 -7
  19. package/batteries/encoding.mjs +7 -7
  20. package/batteries/generation/gemini/adapter.cjs +1 -1
  21. package/batteries/generation/gemini/adapter.mjs +1 -1
  22. package/batteries/generation/local_diffusion/adapter.cjs +1 -1
  23. package/batteries/generation/local_diffusion/adapter.mjs +1 -1
  24. package/batteries/generation/openai/adapter.cjs +1 -1
  25. package/batteries/generation/openai/adapter.mjs +1 -1
  26. package/batteries/isolation/browser.d.ts +1 -1
  27. package/batteries/isolation/child_process/transport.d.ts +2 -2
  28. package/batteries/isolation/child_process.cjs +4 -4
  29. package/batteries/isolation/child_process.cjs.map +1 -1
  30. package/batteries/isolation/child_process.mjs +4 -4
  31. package/batteries/isolation/child_process.mjs.map +1 -1
  32. package/batteries/isolation/codec.d.ts +2 -2
  33. package/batteries/isolation/crash_policy.d.ts +1 -1
  34. package/batteries/isolation/isolate_function.d.ts +2 -2
  35. package/batteries/isolation/protocol.d.ts +4 -4
  36. package/batteries/isolation/serve.d.ts +2 -2
  37. package/batteries/isolation/types.d.ts +4 -4
  38. package/batteries/isolation.cjs +1 -1
  39. package/batteries/isolation.mjs +1 -1
  40. package/batteries/llm/anthropic_messages/adapter.cjs +6 -6
  41. package/batteries/llm/anthropic_messages/adapter.cjs.map +1 -1
  42. package/batteries/llm/anthropic_messages/adapter.mjs +6 -6
  43. package/batteries/llm/anthropic_messages/adapter.mjs.map +1 -1
  44. package/batteries/llm/anthropic_messages/count_tokens.cjs +1 -1
  45. package/batteries/llm/anthropic_messages/count_tokens.mjs +1 -1
  46. package/batteries/llm/anthropic_messages/helpers.cjs +3 -3
  47. package/batteries/llm/anthropic_messages/helpers.mjs +3 -3
  48. package/batteries/llm/anthropic_messages/types.d.ts +2 -2
  49. package/batteries/llm/anthropic_messages/validation.cjs +3 -3
  50. package/batteries/llm/anthropic_messages/validation.cjs.map +1 -1
  51. package/batteries/llm/anthropic_messages/validation.mjs +3 -3
  52. package/batteries/llm/anthropic_messages/validation.mjs.map +1 -1
  53. package/batteries/llm/anthropic_messages.cjs +2 -2
  54. package/batteries/llm/anthropic_messages.mjs +2 -2
  55. package/batteries/llm/bedrock_converse/adapter.cjs +29 -7
  56. package/batteries/llm/bedrock_converse/adapter.cjs.map +1 -1
  57. package/batteries/llm/bedrock_converse/adapter.mjs +30 -8
  58. package/batteries/llm/bedrock_converse/adapter.mjs.map +1 -1
  59. package/batteries/llm/bedrock_converse/exceptions.cjs +3 -0
  60. package/batteries/llm/bedrock_converse/exceptions.cjs.map +1 -1
  61. package/batteries/llm/bedrock_converse/exceptions.d.ts +6 -0
  62. package/batteries/llm/bedrock_converse/exceptions.mjs +3 -1
  63. package/batteries/llm/bedrock_converse/exceptions.mjs.map +1 -1
  64. package/batteries/llm/bedrock_converse/helpers.cjs +1 -1
  65. package/batteries/llm/bedrock_converse/helpers.mjs +1 -1
  66. package/batteries/llm/bedrock_converse/types.d.ts +6 -2
  67. package/batteries/llm/bedrock_converse/validation.cjs +7 -1
  68. package/batteries/llm/bedrock_converse/validation.cjs.map +1 -1
  69. package/batteries/llm/bedrock_converse/validation.mjs +7 -1
  70. package/batteries/llm/bedrock_converse/validation.mjs.map +1 -1
  71. package/batteries/llm/bedrock_converse.cjs +2 -2
  72. package/batteries/llm/bedrock_converse.mjs +2 -2
  73. package/batteries/llm/claude_code_cli/adapter.cjs +6 -6
  74. package/batteries/llm/claude_code_cli/adapter.cjs.map +1 -1
  75. package/batteries/llm/claude_code_cli/adapter.mjs +6 -6
  76. package/batteries/llm/claude_code_cli/adapter.mjs.map +1 -1
  77. package/batteries/llm/claude_code_cli/helpers.cjs +3 -3
  78. package/batteries/llm/claude_code_cli/helpers.mjs +3 -3
  79. package/batteries/llm/claude_code_cli/types.d.ts +3 -2
  80. package/batteries/llm/claude_code_cli/validation.cjs +3 -3
  81. package/batteries/llm/claude_code_cli/validation.cjs.map +1 -1
  82. package/batteries/llm/claude_code_cli/validation.mjs +3 -3
  83. package/batteries/llm/claude_code_cli/validation.mjs.map +1 -1
  84. package/batteries/llm/claude_code_cli.cjs +1 -1
  85. package/batteries/llm/claude_code_cli.mjs +1 -1
  86. package/batteries/llm/gemini_generate_content/adapter.cjs +29 -7
  87. package/batteries/llm/gemini_generate_content/adapter.cjs.map +1 -1
  88. package/batteries/llm/gemini_generate_content/adapter.mjs +30 -8
  89. package/batteries/llm/gemini_generate_content/adapter.mjs.map +1 -1
  90. package/batteries/llm/gemini_generate_content/exceptions.cjs +3 -0
  91. package/batteries/llm/gemini_generate_content/exceptions.cjs.map +1 -1
  92. package/batteries/llm/gemini_generate_content/exceptions.d.ts +6 -0
  93. package/batteries/llm/gemini_generate_content/exceptions.mjs +3 -1
  94. package/batteries/llm/gemini_generate_content/exceptions.mjs.map +1 -1
  95. package/batteries/llm/gemini_generate_content/helpers.cjs +1 -1
  96. package/batteries/llm/gemini_generate_content/helpers.mjs +1 -1
  97. package/batteries/llm/gemini_generate_content/types.d.ts +7 -3
  98. package/batteries/llm/gemini_generate_content/validation.cjs +11 -2
  99. package/batteries/llm/gemini_generate_content/validation.cjs.map +1 -1
  100. package/batteries/llm/gemini_generate_content/validation.mjs +11 -2
  101. package/batteries/llm/gemini_generate_content/validation.mjs.map +1 -1
  102. package/batteries/llm/gemini_generate_content.cjs +1 -1
  103. package/batteries/llm/gemini_generate_content.mjs +1 -1
  104. package/batteries/llm/litert_lm/adapter.cjs +6 -6
  105. package/batteries/llm/litert_lm/adapter.cjs.map +1 -1
  106. package/batteries/llm/litert_lm/adapter.mjs +6 -6
  107. package/batteries/llm/litert_lm/adapter.mjs.map +1 -1
  108. package/batteries/llm/litert_lm/helpers.cjs +3 -3
  109. package/batteries/llm/litert_lm/helpers.mjs +3 -3
  110. package/batteries/llm/litert_lm/types.d.ts +2 -2
  111. package/batteries/llm/litert_lm/validation.cjs +3 -3
  112. package/batteries/llm/litert_lm/validation.cjs.map +1 -1
  113. package/batteries/llm/litert_lm/validation.mjs +3 -3
  114. package/batteries/llm/litert_lm/validation.mjs.map +1 -1
  115. package/batteries/llm/litert_lm.cjs +1 -1
  116. package/batteries/llm/litert_lm.mjs +1 -1
  117. package/batteries/llm/ollama/adapter.cjs +6 -6
  118. package/batteries/llm/ollama/adapter.cjs.map +1 -1
  119. package/batteries/llm/ollama/adapter.mjs +6 -6
  120. package/batteries/llm/ollama/adapter.mjs.map +1 -1
  121. package/batteries/llm/ollama/helpers.cjs +4 -4
  122. package/batteries/llm/ollama/helpers.mjs +4 -4
  123. package/batteries/llm/ollama/types.d.ts +2 -2
  124. package/batteries/llm/ollama/validation.cjs +3 -3
  125. package/batteries/llm/ollama/validation.cjs.map +1 -1
  126. package/batteries/llm/ollama/validation.mjs +3 -3
  127. package/batteries/llm/ollama/validation.mjs.map +1 -1
  128. package/batteries/llm/ollama.cjs +2 -2
  129. package/batteries/llm/ollama.mjs +2 -2
  130. package/batteries/llm/openai_chat_completions/adapter.cjs +6 -6
  131. package/batteries/llm/openai_chat_completions/adapter.cjs.map +1 -1
  132. package/batteries/llm/openai_chat_completions/adapter.mjs +6 -6
  133. package/batteries/llm/openai_chat_completions/adapter.mjs.map +1 -1
  134. package/batteries/llm/openai_chat_completions/helpers.cjs +4 -4
  135. package/batteries/llm/openai_chat_completions/helpers.mjs +4 -4
  136. package/batteries/llm/openai_chat_completions/types.d.ts +2 -2
  137. package/batteries/llm/openai_chat_completions/validation.cjs +3 -3
  138. package/batteries/llm/openai_chat_completions/validation.cjs.map +1 -1
  139. package/batteries/llm/openai_chat_completions/validation.mjs +3 -3
  140. package/batteries/llm/openai_chat_completions/validation.mjs.map +1 -1
  141. package/batteries/llm/openai_chat_completions.cjs +2 -2
  142. package/batteries/llm/openai_chat_completions.mjs +2 -2
  143. package/batteries/llm/openai_responses/adapter.cjs +6 -6
  144. package/batteries/llm/openai_responses/adapter.cjs.map +1 -1
  145. package/batteries/llm/openai_responses/adapter.mjs +6 -6
  146. package/batteries/llm/openai_responses/adapter.mjs.map +1 -1
  147. package/batteries/llm/openai_responses/helpers.cjs +3 -3
  148. package/batteries/llm/openai_responses/helpers.mjs +3 -3
  149. package/batteries/llm/openai_responses/types.d.ts +2 -2
  150. package/batteries/llm/openai_responses/validation.cjs +3 -3
  151. package/batteries/llm/openai_responses/validation.cjs.map +1 -1
  152. package/batteries/llm/openai_responses/validation.mjs +3 -3
  153. package/batteries/llm/openai_responses/validation.mjs.map +1 -1
  154. package/batteries/llm/openai_responses.cjs +2 -2
  155. package/batteries/llm/openai_responses.mjs +2 -2
  156. package/batteries/llm/transformers_js/adapter.cjs +6 -6
  157. package/batteries/llm/transformers_js/adapter.cjs.map +1 -1
  158. package/batteries/llm/transformers_js/adapter.mjs +6 -6
  159. package/batteries/llm/transformers_js/adapter.mjs.map +1 -1
  160. package/batteries/llm/transformers_js/helpers.cjs +3 -3
  161. package/batteries/llm/transformers_js/helpers.mjs +3 -3
  162. package/batteries/llm/transformers_js/types.d.ts +2 -2
  163. package/batteries/llm/transformers_js/validation.cjs +3 -3
  164. package/batteries/llm/transformers_js/validation.cjs.map +1 -1
  165. package/batteries/llm/transformers_js/validation.mjs +3 -3
  166. package/batteries/llm/transformers_js/validation.mjs.map +1 -1
  167. package/batteries/llm/transformers_js.cjs +1 -1
  168. package/batteries/llm/transformers_js.mjs +1 -1
  169. package/batteries/llm/webllm_chat_completions/adapter.cjs +6 -6
  170. package/batteries/llm/webllm_chat_completions/adapter.cjs.map +1 -1
  171. package/batteries/llm/webllm_chat_completions/adapter.mjs +6 -6
  172. package/batteries/llm/webllm_chat_completions/adapter.mjs.map +1 -1
  173. package/batteries/llm/webllm_chat_completions/helpers.cjs +1 -1
  174. package/batteries/llm/webllm_chat_completions/helpers.mjs +1 -1
  175. package/batteries/llm/webllm_chat_completions/validation.cjs +3 -3
  176. package/batteries/llm/webllm_chat_completions/validation.cjs.map +1 -1
  177. package/batteries/llm/webllm_chat_completions/validation.mjs +3 -3
  178. package/batteries/llm/webllm_chat_completions/validation.mjs.map +1 -1
  179. package/batteries/llm/webllm_chat_completions.cjs +2 -2
  180. package/batteries/llm/webllm_chat_completions.mjs +2 -2
  181. package/batteries/llm.cjs +2 -2
  182. package/batteries/llm.mjs +2 -2
  183. package/batteries/media/builder.d.ts +3 -0
  184. package/batteries/media/contracts.cjs.map +1 -1
  185. package/batteries/media/contracts.d.ts +40 -1
  186. package/batteries/media/contracts.mjs.map +1 -1
  187. package/batteries/media/engines/sharp.cjs +36 -2
  188. package/batteries/media/engines/sharp.cjs.map +1 -1
  189. package/batteries/media/engines/sharp.mjs +36 -2
  190. package/batteries/media/engines/sharp.mjs.map +1 -1
  191. package/batteries/media/forge.cjs +5 -5
  192. package/batteries/media/forge.mjs +5 -5
  193. package/batteries/media/index.d.ts +1 -1
  194. package/batteries/media/lint.cjs +3 -2
  195. package/batteries/media/lint.cjs.map +1 -1
  196. package/batteries/media/lint.mjs +3 -2
  197. package/batteries/media/lint.mjs.map +1 -1
  198. package/batteries/media.cjs +66 -2
  199. package/batteries/media.cjs.map +1 -1
  200. package/batteries/media.mjs +66 -2
  201. package/batteries/media.mjs.map +1 -1
  202. package/batteries/orchestration/conformance.cjs +123 -74
  203. package/batteries/orchestration/conformance.cjs.map +1 -1
  204. package/batteries/orchestration/conformance.d.ts +10 -8
  205. package/batteries/orchestration/conformance.mjs +54 -5
  206. package/batteries/orchestration/conformance.mjs.map +1 -1
  207. package/batteries/orchestration/dispatch_reasoner.cjs +4 -4
  208. package/batteries/orchestration/dispatch_reasoner.mjs +4 -4
  209. package/batteries/orchestration/executor.cjs +2 -2
  210. package/batteries/orchestration/executor.mjs +2 -2
  211. package/batteries/orchestration/forge.cjs +4 -4
  212. package/batteries/orchestration/forge.mjs +4 -4
  213. package/batteries/orchestration/validation.cjs +2 -2
  214. package/batteries/orchestration/validation.mjs +2 -2
  215. package/batteries/orchestration.cjs +4 -4
  216. package/batteries/orchestration.mjs +4 -4
  217. package/batteries/sandbox/contracts/policy_enforcer.d.ts +13 -1
  218. package/batteries/sandbox/js/compartment.d.ts +7 -2
  219. package/batteries/sandbox/js/exceptions.d.ts +4 -0
  220. package/batteries/sandbox/js/runner.d.ts +1 -1
  221. package/batteries/sandbox/js/service.d.ts +1 -1
  222. package/batteries/sandbox/js/ses_contracts.d.ts +4 -3
  223. package/batteries/sandbox/js.cjs +17 -8
  224. package/batteries/sandbox/js.cjs.map +1 -1
  225. package/batteries/sandbox/js.mjs +17 -9
  226. package/batteries/sandbox/js.mjs.map +1 -1
  227. package/batteries/sandbox/manager.d.ts +4 -3
  228. package/batteries/sandbox/node/srt_enforcer.d.ts +1 -1
  229. package/batteries/sandbox/node.cjs +36 -12
  230. package/batteries/sandbox/node.cjs.map +1 -1
  231. package/batteries/sandbox/node.mjs +36 -12
  232. package/batteries/sandbox/node.mjs.map +1 -1
  233. package/batteries/sandbox/tools.cjs +1 -1
  234. package/batteries/sandbox/tools.mjs +1 -1
  235. package/batteries/sandbox/types.d.ts +10 -1
  236. package/batteries/sandbox.cjs +27 -9
  237. package/batteries/sandbox.cjs.map +1 -1
  238. package/batteries/sandbox.mjs +28 -11
  239. package/batteries/sandbox.mjs.map +1 -1
  240. package/batteries/skills.cjs +9 -9
  241. package/batteries/skills.mjs +9 -9
  242. package/batteries/tools/_shared.cjs +1 -1
  243. package/batteries/tools/_shared.mjs +1 -1
  244. package/batteries/tools/color.cjs +2 -2
  245. package/batteries/tools/color.mjs +2 -2
  246. package/batteries/tools/comparison.cjs +2 -2
  247. package/batteries/tools/comparison.mjs +2 -2
  248. package/batteries/tools/data_structure.cjs +2 -2
  249. package/batteries/tools/data_structure.mjs +2 -2
  250. package/batteries/tools/datetime_extended.cjs +3 -3
  251. package/batteries/tools/datetime_extended.mjs +3 -3
  252. package/batteries/tools/datetime_math.cjs +3 -3
  253. package/batteries/tools/datetime_math.mjs +3 -3
  254. package/batteries/tools/encoding.cjs +2 -2
  255. package/batteries/tools/encoding.mjs +2 -2
  256. package/batteries/tools/formatting.cjs +2 -2
  257. package/batteries/tools/formatting.mjs +2 -2
  258. package/batteries/tools/geo_basics.cjs +2 -2
  259. package/batteries/tools/geo_basics.mjs +2 -2
  260. package/batteries/tools/math.cjs +2 -2
  261. package/batteries/tools/math.mjs +2 -2
  262. package/batteries/tools/memory.cjs +5 -5
  263. package/batteries/tools/memory.mjs +5 -5
  264. package/batteries/tools/parsing.cjs +3 -3
  265. package/batteries/tools/parsing.mjs +3 -3
  266. package/batteries/tools/retrievables.cjs +5 -5
  267. package/batteries/tools/retrievables.mjs +5 -5
  268. package/batteries/tools/scrapper.cjs +1 -1
  269. package/batteries/tools/scrapper.mjs +1 -1
  270. package/batteries/tools/searxng.cjs +1 -1
  271. package/batteries/tools/searxng.mjs +1 -1
  272. package/batteries/tools/standing_instructions.cjs +3 -3
  273. package/batteries/tools/standing_instructions.mjs +3 -3
  274. package/batteries/tools/statistics.cjs +3 -3
  275. package/batteries/tools/statistics.mjs +3 -3
  276. package/batteries/tools/string_processing.cjs +2 -2
  277. package/batteries/tools/string_processing.mjs +2 -2
  278. package/batteries/tools/structured_data.cjs +2 -2
  279. package/batteries/tools/structured_data.mjs +2 -2
  280. package/batteries/tools/text_analysis.cjs +3 -3
  281. package/batteries/tools/text_analysis.mjs +3 -3
  282. package/batteries/tools/text_comparison.cjs +2 -2
  283. package/batteries/tools/text_comparison.mjs +2 -2
  284. package/batteries/tools/time.cjs +3 -3
  285. package/batteries/tools/time.mjs +3 -3
  286. package/batteries/tools/unit_conversion.cjs +2 -2
  287. package/batteries/tools/unit_conversion.mjs +2 -2
  288. package/batteries/tools.cjs +2 -2
  289. package/batteries/tools.mjs +2 -2
  290. package/batteries/validation.cjs +5 -5
  291. package/batteries/validation.mjs +5 -5
  292. package/batteries/vector/conformance/index.d.ts +11 -16
  293. package/batteries/vector/conformance.cjs +107 -36
  294. package/batteries/vector/conformance.cjs.map +1 -1
  295. package/batteries/vector/conformance.mjs +84 -13
  296. package/batteries/vector/conformance.mjs.map +1 -1
  297. package/batteries/vector/retrievable.cjs +1 -1
  298. package/batteries/vector/retrievable.mjs +1 -1
  299. package/batteries.cjs +5 -5
  300. package/batteries.mjs +5 -5
  301. package/{chat_common-DbbIESdo.mjs → chat_common-CmKV5Dz4.mjs} +2 -2
  302. package/{chat_common-DbbIESdo.mjs.map → chat_common-CmKV5Dz4.mjs.map} +1 -1
  303. package/{chat_common-B3O3zz-i.js → chat_common-Dpan9moo.js} +2 -2
  304. package/{chat_common-B3O3zz-i.js.map → chat_common-Dpan9moo.js.map} +1 -1
  305. package/{common-v9Jo9M5k.mjs → common-BpdHIpQE.mjs} +7 -7
  306. package/{common-v9Jo9M5k.mjs.map → common-BpdHIpQE.mjs.map} +1 -1
  307. package/{common-BV3HGeLj.js → common-H44Ik9ou.js} +7 -7
  308. package/{common-BV3HGeLj.js.map → common-H44Ik9ou.js.map} +1 -1
  309. package/common.cjs +7 -7
  310. package/common.mjs +7 -7
  311. package/{dispatch_runner-CbNyqSMy.mjs → dispatch_runner-BZDXUe0G.mjs} +5 -5
  312. package/{dispatch_runner-CbNyqSMy.mjs.map → dispatch_runner-BZDXUe0G.mjs.map} +1 -1
  313. package/{dispatch_runner-Bl3Xwebu.js → dispatch_runner-CKhm-scw.js} +5 -5
  314. package/{dispatch_runner-Bl3Xwebu.js.map → dispatch_runner-CKhm-scw.js.map} +1 -1
  315. package/dispatch_runner.cjs +1 -1
  316. package/dispatch_runner.mjs +1 -1
  317. package/{ecmascript-BSnvyY8T.js → ecmascript-CCtgamDh.js} +3 -3
  318. package/{ecmascript-BSnvyY8T.js.map → ecmascript-CCtgamDh.js.map} +1 -1
  319. package/{ecmascript-CZ7_YKfZ.mjs → ecmascript-DcmUQ9Jx.mjs} +3 -3
  320. package/{ecmascript-CZ7_YKfZ.mjs.map → ecmascript-DcmUQ9Jx.mjs.map} +1 -1
  321. package/eslint.cjs +1 -1
  322. package/eslint.mjs +1 -1
  323. package/exceptions.cjs +1 -1
  324. package/exceptions.mjs +1 -1
  325. package/forge.cjs +2 -2
  326. package/forge.mjs +2 -2
  327. package/guards.cjs +7 -7
  328. package/guards.mjs +7 -7
  329. package/{helpers-CDmLDBq5.mjs → helpers-BH7HTtkD.mjs} +3 -3
  330. package/{helpers-CDmLDBq5.mjs.map → helpers-BH7HTtkD.mjs.map} +1 -1
  331. package/{helpers-Tvvwpx1M.js → helpers-CEjjkXso.js} +3 -3
  332. package/{helpers-Tvvwpx1M.js.map → helpers-CEjjkXso.js.map} +1 -1
  333. package/index.cjs +10 -10
  334. package/index.mjs +10 -10
  335. package/{isolation-BQCTQYZ_.js → isolation-7Jrcucgc.js} +11 -11
  336. package/isolation-7Jrcucgc.js.map +1 -0
  337. package/{isolation-7xbkc12r.mjs → isolation-CO0NiK8R.mjs} +11 -11
  338. package/isolation-CO0NiK8R.mjs.map +1 -0
  339. package/lib/classes/tokenizable.d.ts +2 -3
  340. package/mcp/adk-docs-corpus.json +2 -2
  341. package/package.json +469 -469
  342. package/{retrievable-C5dXuDhD.js → retrievable-BTwjmPnl.js} +3 -3
  343. package/{retrievable-C5dXuDhD.js.map → retrievable-BTwjmPnl.js.map} +1 -1
  344. package/{retrievable-gl_TIHnX.mjs → retrievable-CXTAUuuv.mjs} +3 -3
  345. package/{retrievable-gl_TIHnX.mjs.map → retrievable-CXTAUuuv.mjs.map} +1 -1
  346. package/{scrapper-DD6-_2u-.js → scrapper-CJexXXK-.js} +4 -4
  347. package/{scrapper-DD6-_2u-.js.map → scrapper-CJexXXK-.js.map} +1 -1
  348. package/{scrapper-u_orpxIB.mjs → scrapper-DiQ5FfDL.mjs} +4 -4
  349. package/{scrapper-u_orpxIB.mjs.map → scrapper-DiQ5FfDL.mjs.map} +1 -1
  350. package/{searxng-fVdJUCK2.mjs → searxng-BFTJ6rTE.mjs} +4 -4
  351. package/{searxng-fVdJUCK2.mjs.map → searxng-BFTJ6rTE.mjs.map} +1 -1
  352. package/{searxng-C7GK0Nrz.js → searxng-DzlGZG4V.js} +4 -4
  353. package/{searxng-C7GK0Nrz.js.map → searxng-DzlGZG4V.js.map} +1 -1
  354. package/server.json +2 -2
  355. package/skills/adk-assembly/SKILL.md +2 -2
  356. package/{spooled_artifact-DriNQRj7.js → spooled_artifact-BpcesRBv.js} +384 -384
  357. package/spooled_artifact-BpcesRBv.js.map +1 -0
  358. package/{spooled_artifact-BkueYJhR.mjs → spooled_artifact-Bw_7swIp.mjs} +385 -385
  359. package/spooled_artifact-Bw_7swIp.mjs.map +1 -0
  360. package/spooled_artifact.cjs +2 -2
  361. package/spooled_artifact.mjs +2 -2
  362. package/{spooled_markdown_artifact-CfHRZUkl.mjs → spooled_markdown_artifact-vd6eNtIP.mjs} +3 -3
  363. package/{spooled_markdown_artifact-CfHRZUkl.mjs.map → spooled_markdown_artifact-vd6eNtIP.mjs.map} +1 -1
  364. package/{spooled_markdown_artifact-C_VkCDhF.js → spooled_markdown_artifact-wJPnE8Ij.js} +3 -3
  365. package/{spooled_markdown_artifact-C_VkCDhF.js.map → spooled_markdown_artifact-wJPnE8Ij.js.map} +1 -1
  366. package/{thought-B8JAi3-W.mjs → thought-BE1KGEhV.mjs} +3 -3
  367. package/{thought-B8JAi3-W.mjs.map → thought-BE1KGEhV.mjs.map} +1 -1
  368. package/{thought--fRgOwTP.js → thought-bS7O9O5H.js} +3 -3
  369. package/{thought--fRgOwTP.js.map → thought-bS7O9O5H.js.map} +1 -1
  370. package/{tokenizable-CWW7iSrD.js → tokenizable-BMZuGWRd.js} +35 -29
  371. package/tokenizable-BMZuGWRd.js.map +1 -0
  372. package/{tokenizable-DLMP68ZV.mjs → tokenizable-VB4Av8GF.mjs} +36 -30
  373. package/tokenizable-VB4Av8GF.mjs.map +1 -0
  374. package/{tool_call-CPjyvkm4.mjs → tool_call-Cfaj-6zK.mjs} +4 -4
  375. package/{tool_call-CPjyvkm4.mjs.map → tool_call-Cfaj-6zK.mjs.map} +1 -1
  376. package/{tool_call-DgqVwL5n.js → tool_call-Fs_Uh5wQ.js} +4 -4
  377. package/{tool_call-DgqVwL5n.js.map → tool_call-Fs_Uh5wQ.js.map} +1 -1
  378. package/{tools-BmLzkvNr.mjs → tools-B3_8C78Q.mjs} +6 -6
  379. package/{tools-BmLzkvNr.mjs.map → tools-B3_8C78Q.mjs.map} +1 -1
  380. package/{tools-DmcIe2Cb.js → tools-CqOcmHR8.js} +6 -6
  381. package/{tools-DmcIe2Cb.js.map → tools-CqOcmHR8.js.map} +1 -1
  382. package/{toon-BvTQsKdN.mjs → toon-BSlr88px.mjs} +5 -5
  383. package/{toon-BvTQsKdN.mjs.map → toon-BSlr88px.mjs.map} +1 -1
  384. package/{toon-B05eKx-q.js → toon-D71tkyI3.js} +5 -5
  385. package/{toon-B05eKx-q.js.map → toon-D71tkyI3.js.map} +1 -1
  386. package/{turn_runner-DEGCvfVZ.mjs → turn_runner-BHHD6h77.mjs} +5 -5
  387. package/{turn_runner-DEGCvfVZ.mjs.map → turn_runner-BHHD6h77.mjs.map} +1 -1
  388. package/{turn_runner-DT8TseR4.js → turn_runner-DhLI7OTH.js} +5 -5
  389. package/{turn_runner-DT8TseR4.js.map → turn_runner-DhLI7OTH.js.map} +1 -1
  390. package/turn_runner.cjs +1 -1
  391. package/turn_runner.mjs +1 -1
  392. package/types-D6X_aUIb.mjs.map +1 -1
  393. package/types-DrSosVaM.js.map +1 -1
  394. package/{validate-lzy9nG_E.mjs → validate-Bi7FGjoq.mjs} +13 -1
  395. package/{validate-lzy9nG_E.mjs.map → validate-Bi7FGjoq.mjs.map} +1 -1
  396. package/{validate-CdOS7S2u.js → validate-CkQI-48O.js} +13 -1
  397. package/{validate-CdOS7S2u.js.map → validate-CkQI-48O.js.map} +1 -1
  398. package/{xml-DDTIMpY3.js → xml-BeNvlifb.js} +5 -5
  399. package/{xml-DDTIMpY3.js.map → xml-BeNvlifb.js.map} +1 -1
  400. package/{xml-VhJ4NrMB.mjs → xml-vyCZZiF_.mjs} +5 -5
  401. package/{xml-VhJ4NrMB.mjs.map → xml-vyCZZiF_.mjs.map} +1 -1
  402. package/{yaml-Cx16IYJq.js → yaml-DhLLa2cj.js} +5 -5
  403. package/{yaml-Cx16IYJq.js.map → yaml-DhLLa2cj.js.map} +1 -1
  404. package/{yaml-Du4wFGzL.mjs → yaml-Dtz0Bd7J.mjs} +5 -5
  405. package/{yaml-Du4wFGzL.mjs.map → yaml-Dtz0Bd7J.mjs.map} +1 -1
  406. package/artifact_methods-BMCahBLn.mjs +0 -1
  407. package/artifact_methods-f_bSy4kX.js +0 -1
  408. package/isolation-7xbkc12r.mjs.map +0 -1
  409. package/isolation-BQCTQYZ_.js.map +0 -1
  410. package/spooled_artifact-BkueYJhR.mjs.map +0 -1
  411. package/spooled_artifact-DriNQRj7.js.map +0 -1
  412. package/tokenizable-CWW7iSrD.js.map +0 -1
  413. package/tokenizable-DLMP68ZV.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.mjs","names":["#baseline"],"sources":["../../../../src/batteries/llm/gemini_generate_content/adapter.ts"],"sourcesContent":["/**\n * Cross-environment executor adapter for Google's native Gemini `generateContent` endpoint.\n *\n * @module @nhtio/adk/batteries/llm/gemini_generate_content/adapter\n *\n * @remarks\n * Targets `POST {baseURL}/models/{model}:generateContent` (and `:streamGenerateContent` when\n * `stream` is set) — Gemini's OWN wire format, not an OpenAI-compatible façade in front of it.\n *\n * That distinction is the reason this battery exists. Pointing `openai_chat_completions` at a\n * Gemini-compatible gateway means some translator, not the ADK, decides how your primitives become\n * `contents[]` — including whether a `thoughtSignature` is stamped, whether consecutive same-role\n * turns get merged, and how a tool result is correlated to its call. For ordinary use that is fine.\n * For anything that needs to reason about what the VENDOR actually received — an ordering guard, a\n * wire-shape audit, a bug report against Google — the translation has to be ours and observable.\n * See the validation battery's \"Which API surface a rule applies to\" guide.\n *\n * Options layer exactly as the other batteries: constructor baseline → `executor()` overrides →\n * per-iteration `ctx.stash.geminiGenerateContent`, re-validated each iteration.\n */\n\nimport { DateTime } from 'luxon'\nimport { sha256 } from 'js-sha256'\nimport { v6 as uuidv6 } from 'uuid'\nimport { validateOptions } from './validation'\nimport { normalizeToolName } from '../chat_common/helpers'\nimport { isError, isObject, isInstanceOf } from '@nhtio/adk/guards'\nimport { resolveToolCallParser } from '../chat_common/tool_parsers'\nimport { canonicalStringify } from '../../../lib/utils/canonical_json'\nimport { ArtifactTool, Media, Message, Thought, Tokenizable, ToolCall } from '@nhtio/adk/common'\nimport {\n E_GEMINI_INVALID_TOOL_CALL_ARGS,\n E_GEMINI_MISSING_THOUGHT_SIGNATURE,\n E_GEMINI_REQUEST_FAILED,\n E_GEMINI_STREAM_ERROR,\n} from './exceptions'\nimport {\n DEFAULT_GEMINI_BUCKET_ORDER,\n buildGeminiRequest,\n extractGeminiGeneration,\n mediaToGeminiInlineData,\n renderGeminiToolResult,\n toolsToGeminiTools,\n} from './helpers'\nimport {\n descriptionToChatCompletionsJsonSchema,\n filterThoughts,\n renderChatCompletionsSystemPrompt,\n renderFirstPartyRetrievables,\n renderMemories,\n renderRetrievableSafetyDirective,\n renderRetrievables,\n renderStandingInstructions,\n renderThirdPartyPrivateRetrievables,\n renderThirdPartyPublicRetrievables,\n renderThought,\n renderTrustedContent,\n renderUntrustedContent,\n} from '../chat_common/helpers'\nimport type { DispatchContext } from '@nhtio/adk/types'\nimport type { SpooledArtifact, Tool } from '@nhtio/adk/common'\nimport type { DispatchExecutorFn, DispatchExecutorHelpers } from '@nhtio/adk/types'\nimport type {\n GeminiGenerateContentAdapterOptions,\n GeminiGenerateContentHelpers,\n GeminiGenerateContentResponse,\n} from './types'\n\nconst nowIso = (): string => DateTime.now().toISO() ?? new Date().toISOString()\n\nconst DEFAULT_BASE_URL = 'https://generativelanguage.googleapis.com/v1beta'\n/**\n * Google's documented portable sentinel for replaying tool history that did not originate from a\n * Gemini reasoning session. See the option's TSDoc for why this is the default.\n */\nconst DEFAULT_SENTINEL = 'skip_thought_signature_validator'\n\nconst computeChecksum = (tool: string, args: Record<string, unknown>): string =>\n sha256(`${tool}:${canonicalStringify(args)}`)\n\n/** Merge the three option layers, later winning. */\nconst mergeOptions = (\n ...layers: Array<Partial<GeminiGenerateContentAdapterOptions> | undefined>\n): Partial<GeminiGenerateContentAdapterOptions> => {\n const out: Record<string, unknown> = {}\n for (const layer of layers) {\n if (!layer) continue\n for (const [k, v] of Object.entries(layer)) if (v !== undefined) out[k] = v\n }\n return out as Partial<GeminiGenerateContentAdapterOptions>\n}\n\n/** Fill every injectable helper, preferring the caller's override. */\nconst resolveHelpers = (\n overrides: Partial<GeminiGenerateContentHelpers> | undefined\n): GeminiGenerateContentHelpers => {\n const src = (overrides ?? {}) as Record<string, unknown>\n const pick = <T>(key: string, fallback: T): T => (src[key] as T | undefined) ?? fallback\n return {\n descriptionToChatCompletionsJsonSchema: pick(\n 'descriptionToChatCompletionsJsonSchema',\n descriptionToChatCompletionsJsonSchema\n ),\n renderUntrustedContent: pick('renderUntrustedContent', renderUntrustedContent),\n renderTrustedContent: pick('renderTrustedContent', renderTrustedContent),\n renderStandingInstructions: pick('renderStandingInstructions', renderStandingInstructions),\n renderMemories: pick('renderMemories', renderMemories),\n renderRetrievables: pick('renderRetrievables', renderRetrievables),\n renderRetrievableSafetyDirective: pick(\n 'renderRetrievableSafetyDirective',\n renderRetrievableSafetyDirective\n ),\n renderFirstPartyRetrievables: pick(\n 'renderFirstPartyRetrievables',\n renderFirstPartyRetrievables\n ),\n renderThirdPartyPublicRetrievables: pick(\n 'renderThirdPartyPublicRetrievables',\n renderThirdPartyPublicRetrievables\n ),\n renderThirdPartyPrivateRetrievables: pick(\n 'renderThirdPartyPrivateRetrievables',\n renderThirdPartyPrivateRetrievables\n ),\n renderThought: pick('renderThought', renderThought),\n filterThoughts: pick('filterThoughts', filterThoughts),\n renderChatCompletionsSystemPrompt: pick(\n 'renderChatCompletionsSystemPrompt',\n renderChatCompletionsSystemPrompt\n ),\n toolsToGeminiTools: pick('toolsToGeminiTools', toolsToGeminiTools),\n renderGeminiToolResult: pick('renderGeminiToolResult', renderGeminiToolResult),\n buildGeminiRequest: pick('buildGeminiRequest', buildGeminiRequest),\n } as GeminiGenerateContentHelpers\n}\n\n/**\n * Native Gemini `generateContent` executor adapter.\n *\n * @example\n * ```ts\n * const adapter = new GeminiGenerateContentAdapter({\n * model: 'gemini-2.5-flash-lite',\n * apiKey: process.env.GEMINI_API_KEY,\n * })\n * const runner = new TurnRunner({ executorCallback: adapter.executor(), ... })\n * ```\n */\nexport class GeminiGenerateContentAdapter {\n /** Per-iteration override key on `ctx.stash`. */\n public static readonly STASH_KEY = 'geminiGenerateContent' as const\n\n readonly #baseline: GeminiGenerateContentAdapterOptions\n\n /**\n * @param options - Constructor-baseline options, re-validated每 iteration after overrides merge.\n * @throws {@link E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS} when `options` is invalid.\n */\n constructor(options: unknown) {\n this.#baseline = validateOptions(options)\n }\n\n /** Narrowing guard for cross-realm instances. */\n public static isGeminiGenerateContentAdapter(\n value: unknown\n ): value is GeminiGenerateContentAdapter {\n return isInstanceOf(value, 'GeminiGenerateContentAdapter', GeminiGenerateContentAdapter)\n }\n\n /**\n * Build a {@link DispatchExecutorFn} bound to the baseline plus optional executor-scope overrides.\n *\n * @param overrides - Higher precedence than the baseline, lower than `ctx.stash`.\n */\n executor(overrides?: Partial<GeminiGenerateContentAdapterOptions>): DispatchExecutorFn {\n const baseline = this.#baseline\n const adapterClass = GeminiGenerateContentAdapter\n return async (ctx: DispatchContext, helpers: DispatchExecutorHelpers): Promise<void> => {\n const warn = (message: string): void => {\n helpers.log.warn({ kind: 'helper-warning', message })\n }\n\n // ── merge & validate ────────────────────────────────────────────────\n const stashRaw = ctx.stash.get(adapterClass.STASH_KEY, {}) as unknown\n const stashOverrides = isObject(stashRaw)\n ? (stashRaw as Partial<GeminiGenerateContentAdapterOptions>)\n : {}\n const merged = validateOptions(mergeOptions(baseline, overrides, stashOverrides))\n const resolved = resolveHelpers(merged.helpers)\n const selfIdentity = 'assistant'\n const dispatchStreamId = uuidv6()\n\n // ── pre-render tool results ─────────────────────────────────────────\n // Gemini wants an OBJECT in functionResponse.response, so results are rendered ahead of\n // assembly and keyed by the live ToolCall instance. Keying by id lets a duplicate id\n // overwrite an earlier result before assembly.\n const renderedToolCallResults = new Map<ToolCall, Record<string, unknown>>()\n for (const tc of ctx.turnToolCalls) {\n renderedToolCallResults.set(\n tc,\n await resolved.renderGeminiToolResult({\n toolCall: tc,\n results: tc.results as never,\n tool: ctx.tools.get(tc.tool) as Tool | ArtifactTool | undefined,\n renderUntrustedContent: resolved.renderUntrustedContent,\n renderTrustedContent: resolved.renderTrustedContent,\n unsupportedMediaPolicy: merged.unsupportedMediaPolicy ?? 'throw',\n warn,\n })\n )\n }\n\n // ── assemble ────────────────────────────────────────────────────────\n const request = await resolved.buildGeminiRequest({\n systemPrompt: ctx.systemPrompt,\n standingInstructions: ctx.standingInstructions,\n memories: ctx.turnMemories,\n retrievables: ctx.turnRetrievables,\n messages: ctx.turnMessages,\n thoughts: ctx.turnThoughts,\n toolCalls: ctx.turnToolCalls,\n tools: ctx.tools,\n renderedToolCallResults,\n bucketOrder: merged.bucketOrder ?? (DEFAULT_GEMINI_BUCKET_ORDER as never),\n selfIdentity,\n thoughtSurfacing: merged.thoughtSurfacing ?? 'all-self',\n replayCompatibility: [],\n thoughtSignatureSentinel:\n merged.thoughtSignatureSentinel === undefined\n ? DEFAULT_SENTINEL\n : merged.thoughtSignatureSentinel,\n helpers: resolved,\n decodeMedia: mediaToGeminiInlineData,\n unsupportedMediaPolicy: merged.unsupportedMediaPolicy,\n warn,\n })\n\n const generationConfig = {\n ...(merged.maxOutputTokens !== undefined\n ? { maxOutputTokens: merged.maxOutputTokens }\n : {}),\n ...(merged.temperature !== undefined ? { temperature: merged.temperature } : {}),\n ...(merged.topP !== undefined ? { topP: merged.topP } : {}),\n ...(merged.topK !== undefined ? { topK: merged.topK } : {}),\n ...(merged.stopSequences ? { stopSequences: merged.stopSequences } : {}),\n ...(merged.thinkingConfig ? { thinkingConfig: merged.thinkingConfig } : {}),\n }\n const body = {\n ...request,\n ...(Object.keys(generationConfig).length > 0 ? { generationConfig } : {}),\n ...(merged.toolConfig ? { toolConfig: merged.toolConfig } : {}),\n ...(merged.safetySettings ? { safetySettings: merged.safetySettings } : {}),\n }\n\n // Prompt-assembled tap: the EXACT body about to be POSTed. An ADK-control key — stripped\n // from the wire request, never sent. Observer errors are swallowed so a tap can never\n // corrupt a generation.\n if (merged.onPromptAssembled) {\n try {\n merged.onPromptAssembled({\n battery: 'gemini_generate_content',\n kind: 'request-body',\n messages: body.contents,\n tools: body.tools,\n requestBody: body,\n streamed: merged.stream === true,\n streamId: dispatchStreamId,\n })\n } catch {\n /* observer errors are non-fatal */\n }\n }\n\n // ── dispatch ────────────────────────────────────────────────────────\n const base = (merged.baseURL ?? DEFAULT_BASE_URL).replace(/\\/$/, '')\n const action = merged.stream === true ? 'streamGenerateContent' : 'generateContent'\n const url = `${base}/models/${merged.model}:${action}`\n const headers: Record<string, string> = { 'Content-Type': 'application/json' }\n if (merged.apiKey) {\n // Google's own endpoint wants x-goog-api-key; several gateways in front of it accept only\n // Authorization, hence the switch rather than sending both.\n if (merged.useBearerAuth === true) headers.Authorization = `Bearer ${merged.apiKey}`\n else headers['x-goog-api-key'] = merged.apiKey\n }\n\n const doFetch = merged.fetch ?? globalThis.fetch\n let parsed: GeminiGenerateContentResponse\n try {\n const res = await doFetch(url, {\n method: 'POST',\n headers,\n body: JSON.stringify(body),\n signal: merged.timeoutMs ? AbortSignal.timeout(merged.timeoutMs) : ctx.abortSignal,\n })\n const text = await res.text()\n if (!res.ok) {\n // Classify the vendor's own signature rejection separately — it is actionable, and\n // Gemini's generic INVALID_ARGUMENT body gives a caller nothing to act on.\n if (/thought_signature|thoughtSignature/i.test(text)) {\n ctx.nack(new E_GEMINI_MISSING_THOUGHT_SIGNATURE([text.slice(0, 400)]))\n return\n }\n ctx.nack(new E_GEMINI_REQUEST_FAILED([res.status, text.slice(0, 400)]))\n return\n }\n parsed = JSON.parse(text) as GeminiGenerateContentResponse\n } catch (err) {\n ctx.nack(new E_GEMINI_STREAM_ERROR([isError(err) ? err.message : String(err)]))\n return\n }\n\n // ── interpret ───────────────────────────────────────────────────────\n const { text, reasoning, functionCalls, finishReason } = extractGeminiGeneration(parsed)\n const responseId = uuidv6()\n\n if (text.length > 0) {\n const messageId = `${responseId}:message`\n helpers.reportMessage(messageId, text, { isComplete: true })\n await ctx.storeMessage(\n new Message({\n id: messageId,\n role: 'assistant',\n content: text,\n identity: selfIdentity,\n createdAt: nowIso(),\n updatedAt: nowIso(),\n })\n )\n }\n if (reasoning.length > 0) {\n const thoughtId = `${responseId}:thought`\n helpers.reportThought(thoughtId, reasoning, { isComplete: true })\n await ctx.storeThought(\n new Thought({\n id: thoughtId,\n content: reasoning,\n identity: selfIdentity,\n createdAt: nowIso(),\n updatedAt: nowIso(),\n })\n )\n }\n\n // Fallback recovery: only consulted when the provider returned NO structured calls, so a\n // native functionCall always wins over a parsed one.\n let calls = functionCalls.map((c) => ({ id: uuidv6(), name: c.name, args: c.args }))\n if (calls.length === 0 && merged.localToolCallParser !== undefined && text.length > 0) {\n const parser = resolveToolCallParser(merged.localToolCallParser)\n // The parser returns { calls, cleanedText } — not an iterable of calls — and the\n // second argument carries the tool names actually offered this turn so a parser can\n // reject a hallucinated name rather than manufacture a call for it.\n const recovered = parser(text, { toolNames: ctx.tools.all().map((t) => t.name) })\n for (const call of recovered.calls) {\n calls.push({\n id: uuidv6(),\n name: call.name,\n args: (call.arguments ?? {}) as Record<string, unknown>,\n })\n }\n }\n\n if (merged.onRawGeneration) {\n try {\n merged.onRawGeneration({\n rawText: text,\n cleanedText: text,\n reasoning: reasoning.length > 0 ? [reasoning] : [],\n toolCalls: calls.map((c) => ({ name: c.name, arguments: c.args as never })),\n streamed: merged.stream === true,\n streamId: dispatchStreamId,\n })\n } catch {\n /* observer errors are non-fatal */\n }\n }\n\n if (calls.length === 0) {\n // `finishReason` is recorded for the caller; an empty generation is NOT an error here —\n // it is a real vendor outcome and the runner decides what to do with it.\n helpers.log.trace({\n kind: 'gemini-finish',\n message: `generation ended with finishReason=${finishReason ?? 'unknown'} and no function calls`,\n payload: { finishReason: finishReason ?? 'unknown' },\n })\n ctx.ack()\n return\n }\n\n for (const call of calls) {\n if (ctx.abortSignal.aborted) return\n const toolName = normalizeToolName(call.name)\n const tool = ctx.tools.get(toolName) as Tool | ArtifactTool | undefined\n const completedAt = nowIso()\n\n if (!isObject(call.args)) {\n const results = new Tokenizable(\n new E_GEMINI_INVALID_TOOL_CALL_ARGS([JSON.stringify(call.args)]).message\n )\n helpers.reportToolCall(call.id, { tool: toolName, args: {} })\n helpers.reportToolCall(call.id, { results, isError: true, isComplete: true })\n await ctx.storeToolCall(\n new ToolCall({\n id: call.id,\n tool: toolName,\n args: {},\n checksum: computeChecksum(toolName, {}),\n isComplete: true,\n isError: true,\n results,\n createdAt: completedAt,\n updatedAt: completedAt,\n completedAt,\n })\n )\n continue\n }\n\n if (!tool) {\n const available = ctx.tools\n .all()\n .map((t) => t.name)\n .sort()\n const results = new Tokenizable(\n available.length > 0\n ? `Tool not found: ${toolName}. Available tools: ${available.join(', ')}.`\n : `Tool not found: ${toolName}. No tools are available this turn.`\n )\n helpers.reportToolCall(call.id, { tool: toolName, args: call.args })\n helpers.reportToolCall(call.id, { results, isError: true, isComplete: true })\n await ctx.storeToolCall(\n new ToolCall({\n id: call.id,\n tool: toolName,\n args: call.args,\n checksum: computeChecksum(toolName, call.args),\n isComplete: true,\n isError: true,\n results,\n createdAt: completedAt,\n updatedAt: completedAt,\n completedAt,\n })\n )\n continue\n }\n\n helpers.reportToolCall(call.id, { tool: tool.name, args: call.args })\n let results: Tokenizable | SpooledArtifact | SpooledArtifact[] | Media | Media[] =\n new Tokenizable('')\n let isToolError = false\n try {\n const raw = await tool.executor(ctx)(call.args)\n results = Tokenizable.isTokenizable(raw)\n ? raw\n : new Tokenizable(typeof raw === 'string' ? raw : JSON.stringify(raw ?? ''))\n } catch (err) {\n isToolError = true\n results = new Tokenizable(isError(err) ? err.message : String(err))\n }\n const finishedAt = nowIso()\n helpers.reportToolCall(call.id, { results, isError: isToolError, isComplete: true })\n await ctx.storeToolCall(\n new ToolCall({\n id: call.id,\n tool: tool.name,\n args: call.args,\n checksum: computeChecksum(tool.name, call.args),\n isComplete: true,\n isError: isToolError,\n results,\n createdAt: finishedAt,\n updatedAt: finishedAt,\n completedAt: finishedAt,\n })\n )\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEA,IAAM,eAAuB,SAAS,IAAI,EAAE,MAAM,sBAAK,IAAI,KAAK,GAAE,YAAY;AAE9E,IAAM,mBAAmB;;;;;AAKzB,IAAM,mBAAmB;AAEzB,IAAM,mBAAmB,MAAc,SACrC,OAAO,GAAG,KAAK,GAAG,mBAAmB,IAAI,GAAG;;AAG9C,IAAM,gBACJ,GAAG,WAC8C;CACjD,MAAM,MAA+B,CAAC;CACtC,KAAK,MAAM,SAAS,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AAC,CACH;GACF;EACF;CACF;AACF"}
1
+ {"version":3,"file":"adapter.mjs","names":["#baseline"],"sources":["../../../../src/batteries/llm/gemini_generate_content/adapter.ts"],"sourcesContent":["/**\n * Cross-environment executor adapter for Google's native Gemini `generateContent` endpoint.\n *\n * @module @nhtio/adk/batteries/llm/gemini_generate_content/adapter\n *\n * @remarks\n * Targets `POST {baseURL}/models/{model}:generateContent` (and `:streamGenerateContent` when\n * `stream` is set) — Gemini's OWN wire format, not an OpenAI-compatible façade in front of it.\n *\n * That distinction is the reason this battery exists. Pointing `openai_chat_completions` at a\n * Gemini-compatible gateway means some translator, not the ADK, decides how your primitives become\n * `contents[]` — including whether a `thoughtSignature` is stamped, whether consecutive same-role\n * turns get merged, and how a tool result is correlated to its call. For ordinary use that is fine.\n * For anything that needs to reason about what the VENDOR actually received — an ordering guard, a\n * wire-shape audit, a bug report against Google — the translation has to be ours and observable.\n * See the validation battery's \"Which API surface a rule applies to\" guide.\n *\n * Options layer exactly as the other batteries: constructor baseline → `executor()` overrides →\n * per-iteration `ctx.stash.geminiGenerateContent`, re-validated each iteration.\n */\n\nimport { DateTime } from 'luxon'\nimport { sha256 } from 'js-sha256'\nimport { v6 as uuidv6 } from 'uuid'\nimport { validateOptions } from './validation'\nimport { normalizeToolName } from '../chat_common/helpers'\nimport { isError, isObject, isInstanceOf } from '@nhtio/adk/guards'\nimport { resolveToolCallParser } from '../chat_common/tool_parsers'\nimport { canonicalStringify } from '../../../lib/utils/canonical_json'\nimport { ArtifactTool, Media, Message, Thought, Tokenizable, ToolCall } from '@nhtio/adk/common'\nimport {\n DEFAULT_GEMINI_BUCKET_ORDER,\n buildGeminiRequest,\n extractGeminiGeneration,\n mediaToGeminiInlineData,\n renderGeminiToolResult,\n toolsToGeminiTools,\n} from './helpers'\nimport {\n E_GEMINI_GENERATE_CONTENT_CONTEXT_OVERFLOW,\n E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS,\n E_GEMINI_INVALID_TOOL_CALL_ARGS,\n E_GEMINI_MISSING_THOUGHT_SIGNATURE,\n E_GEMINI_REQUEST_FAILED,\n E_GEMINI_STREAM_ERROR,\n} from './exceptions'\nimport {\n descriptionToChatCompletionsJsonSchema,\n filterThoughts,\n renderChatCompletionsSystemPrompt,\n renderFirstPartyRetrievables,\n renderMemories,\n renderRetrievableSafetyDirective,\n renderRetrievables,\n renderStandingInstructions,\n renderThirdPartyPrivateRetrievables,\n renderThirdPartyPublicRetrievables,\n renderThought,\n renderTrustedContent,\n renderUntrustedContent,\n} from '../chat_common/helpers'\nimport type { DispatchContext } from '@nhtio/adk/types'\nimport type { Memory, SpooledArtifact, Tool } from '@nhtio/adk/common'\nimport type { TokenEncoding, TokenEncodingId } from '@nhtio/adk/types'\nimport type { DispatchExecutorFn, DispatchExecutorHelpers } from '@nhtio/adk/types'\nimport type {\n GeminiGenerateContentAdapterOptions,\n GeminiGenerateContentHelpers,\n GeminiGenerateContentResponse,\n} from './types'\n\nconst nowIso = (): string => DateTime.now().toISO() ?? new Date().toISOString()\n\nconst DEFAULT_BASE_URL = 'https://generativelanguage.googleapis.com/v1beta'\n/**\n * Google's documented portable sentinel for replaying tool history that did not originate from a\n * Gemini reasoning session. See the option's TSDoc for why this is the default.\n */\nconst DEFAULT_SENTINEL = 'skip_thought_signature_validator'\n\nconst estimateTokensOf = async (\n value: { estimateTokens: (encoding: TokenEncoding) => number | Promise<number> },\n encoding: TokenEncodingId\n): Promise<number> => Promise.resolve(value.estimateTokens(encoding as TokenEncoding))\n\nconst computeChecksum = (tool: string, args: Record<string, unknown>): string =>\n sha256(`${tool}:${canonicalStringify(args)}`)\n\n/** Merge the three option layers, later winning. */\nconst mergeOptions = (\n ...layers: Array<Partial<GeminiGenerateContentAdapterOptions> | undefined>\n): Partial<GeminiGenerateContentAdapterOptions> => {\n const out: Record<string, unknown> = {}\n for (const layer of layers) {\n if (!layer) continue\n for (const [k, v] of Object.entries(layer)) if (v !== undefined) out[k] = v\n }\n return out as Partial<GeminiGenerateContentAdapterOptions>\n}\n\n/** Fill every injectable helper, preferring the caller's override. */\nconst resolveHelpers = (\n overrides: Partial<GeminiGenerateContentHelpers> | undefined\n): GeminiGenerateContentHelpers => {\n const src = (overrides ?? {}) as Record<string, unknown>\n const pick = <T>(key: string, fallback: T): T => (src[key] as T | undefined) ?? fallback\n return {\n descriptionToChatCompletionsJsonSchema: pick(\n 'descriptionToChatCompletionsJsonSchema',\n descriptionToChatCompletionsJsonSchema\n ),\n renderUntrustedContent: pick('renderUntrustedContent', renderUntrustedContent),\n renderTrustedContent: pick('renderTrustedContent', renderTrustedContent),\n renderStandingInstructions: pick('renderStandingInstructions', renderStandingInstructions),\n renderMemories: pick('renderMemories', renderMemories),\n renderRetrievables: pick('renderRetrievables', renderRetrievables),\n renderRetrievableSafetyDirective: pick(\n 'renderRetrievableSafetyDirective',\n renderRetrievableSafetyDirective\n ),\n renderFirstPartyRetrievables: pick(\n 'renderFirstPartyRetrievables',\n renderFirstPartyRetrievables\n ),\n renderThirdPartyPublicRetrievables: pick(\n 'renderThirdPartyPublicRetrievables',\n renderThirdPartyPublicRetrievables\n ),\n renderThirdPartyPrivateRetrievables: pick(\n 'renderThirdPartyPrivateRetrievables',\n renderThirdPartyPrivateRetrievables\n ),\n renderThought: pick('renderThought', renderThought),\n filterThoughts: pick('filterThoughts', filterThoughts),\n renderChatCompletionsSystemPrompt: pick(\n 'renderChatCompletionsSystemPrompt',\n renderChatCompletionsSystemPrompt\n ),\n toolsToGeminiTools: pick('toolsToGeminiTools', toolsToGeminiTools),\n renderGeminiToolResult: pick('renderGeminiToolResult', renderGeminiToolResult),\n buildGeminiRequest: pick('buildGeminiRequest', buildGeminiRequest),\n } as GeminiGenerateContentHelpers\n}\n\n/**\n * Native Gemini `generateContent` executor adapter.\n *\n * @example\n * ```ts\n * const adapter = new GeminiGenerateContentAdapter({\n * model: 'gemini-2.5-flash-lite',\n * apiKey: process.env.GEMINI_API_KEY,\n * })\n * const runner = new TurnRunner({ executorCallback: adapter.executor(), ... })\n * ```\n */\nexport class GeminiGenerateContentAdapter {\n /** Per-iteration override key on `ctx.stash`. */\n public static readonly STASH_KEY = 'geminiGenerateContent' as const\n\n readonly #baseline: GeminiGenerateContentAdapterOptions\n\n /**\n * @param options - Constructor-baseline options, re-validated每 iteration after overrides merge.\n * @throws {@link E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS} when `options` is invalid.\n */\n constructor(options: unknown) {\n this.#baseline = validateOptions(options)\n }\n\n /** Narrowing guard for cross-realm instances. */\n public static isGeminiGenerateContentAdapter(\n value: unknown\n ): value is GeminiGenerateContentAdapter {\n return isInstanceOf(value, 'GeminiGenerateContentAdapter', GeminiGenerateContentAdapter)\n }\n\n /**\n * Build a {@link DispatchExecutorFn} bound to the baseline plus optional executor-scope overrides.\n *\n * @param overrides - Higher precedence than the baseline, lower than `ctx.stash`.\n */\n executor(overrides?: Partial<GeminiGenerateContentAdapterOptions>): DispatchExecutorFn {\n const baseline = this.#baseline\n const adapterClass = GeminiGenerateContentAdapter\n return async (ctx: DispatchContext, helpers: DispatchExecutorHelpers): Promise<void> => {\n const warn = (message: string): void => {\n helpers.log.warn({ kind: 'helper-warning', message })\n }\n\n // ── merge & validate ────────────────────────────────────────────────\n const stashRaw = ctx.stash.get(adapterClass.STASH_KEY, {}) as unknown\n const stashOverrides = isObject(stashRaw)\n ? (stashRaw as Partial<GeminiGenerateContentAdapterOptions>)\n : {}\n const merged = validateOptions(mergeOptions(baseline, overrides, stashOverrides))\n if (\n merged.tokenEncoding !== undefined &&\n merged.tokenEncoding !== null &&\n merged.contextWindow === undefined\n ) {\n throw new E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS([\n 'tokenEncoding is non-null but contextWindow is undefined',\n ])\n }\n const resolved = resolveHelpers(merged.helpers)\n const selfIdentity = 'assistant'\n const dispatchStreamId = uuidv6()\n\n // ── pre-render tool results ─────────────────────────────────────────\n // Gemini wants an OBJECT in functionResponse.response, so results are rendered ahead of\n // assembly and keyed by the live ToolCall instance. Keying by id lets a duplicate id\n // overwrite an earlier result before assembly.\n const renderedToolCallResults = new Map<ToolCall, Record<string, unknown>>()\n for (const tc of ctx.turnToolCalls) {\n renderedToolCallResults.set(\n tc,\n await resolved.renderGeminiToolResult({\n toolCall: tc,\n results: tc.results as never,\n tool: ctx.tools.get(tc.tool) as Tool | ArtifactTool | undefined,\n renderUntrustedContent: resolved.renderUntrustedContent,\n renderTrustedContent: resolved.renderTrustedContent,\n unsupportedMediaPolicy: merged.unsupportedMediaPolicy ?? 'throw',\n warn,\n })\n )\n }\n\n // ── context window enforcement ───────────────────────────────────────\n if (\n merged.tokenEncoding !== undefined &&\n merged.tokenEncoding !== null &&\n merged.contextWindow !== undefined\n ) {\n const encoding = merged.tokenEncoding\n let total = await estimateTokensOf(ctx.systemPrompt, encoding)\n for (const value of ctx.standingInstructions)\n total += await estimateTokensOf(value, encoding)\n for (const memory of ctx.turnMemories as Set<Memory>) {\n total += await estimateTokensOf(memory.content, encoding)\n }\n for (const retrievable of ctx.turnRetrievables) {\n total += await estimateTokensOf(\n retrievable.inline\n ? (retrievable.content as any)\n : new Tokenizable(`[Reference available: ${retrievable.id}]`),\n encoding\n )\n }\n for (const message of ctx.turnMessages) {\n if (message.content !== undefined)\n total += await estimateTokensOf(message.content, encoding)\n }\n for (const thought of ctx.turnThoughts)\n total += await estimateTokensOf(thought.content, encoding)\n for (const result of renderedToolCallResults.values()) {\n total += await estimateTokensOf(new Tokenizable(JSON.stringify(result)), encoding)\n }\n const tools = ctx.tools.visible()\n // Tool DECLARATIONS: the Gemini wire ships tools as an array, which the PROVIDER\n // serializes server-side into the model's own format. Tally the tokens of the wire\n // tools JSON (`JSON.stringify`) as an honest FLOOR — a truthful lower bound. We add\n // a highly conservative 50% margin to cover JSON structural overhead and nested formatting.\n if (tools.length > 0) {\n const toolTokens = await estimateTokensOf(\n new Tokenizable(JSON.stringify(resolved.toolsToGeminiTools(tools))),\n encoding\n )\n total += Math.ceil(toolTokens * 1.5)\n }\n if (total + (merged.maxOutputTokens ?? 0) > merged.contextWindow) {\n throw new E_GEMINI_GENERATE_CONTENT_CONTEXT_OVERFLOW([\n total + (merged.maxOutputTokens ?? 0),\n merged.contextWindow,\n encoding,\n ])\n }\n }\n\n // ── assemble ────────────────────────────────────────────────────────\n const request = await resolved.buildGeminiRequest({\n systemPrompt: ctx.systemPrompt,\n standingInstructions: ctx.standingInstructions,\n memories: ctx.turnMemories,\n retrievables: ctx.turnRetrievables,\n messages: ctx.turnMessages,\n thoughts: ctx.turnThoughts,\n toolCalls: ctx.turnToolCalls,\n tools: ctx.tools,\n renderedToolCallResults,\n bucketOrder: merged.bucketOrder ?? (DEFAULT_GEMINI_BUCKET_ORDER as never),\n selfIdentity,\n thoughtSurfacing: merged.thoughtSurfacing ?? 'all-self',\n replayCompatibility: [],\n thoughtSignatureSentinel:\n merged.thoughtSignatureSentinel === undefined\n ? DEFAULT_SENTINEL\n : merged.thoughtSignatureSentinel,\n helpers: resolved,\n decodeMedia: mediaToGeminiInlineData,\n unsupportedMediaPolicy: merged.unsupportedMediaPolicy,\n warn,\n })\n\n const generationConfig = {\n ...(merged.maxOutputTokens !== undefined\n ? { maxOutputTokens: merged.maxOutputTokens }\n : {}),\n ...(merged.temperature !== undefined ? { temperature: merged.temperature } : {}),\n ...(merged.topP !== undefined ? { topP: merged.topP } : {}),\n ...(merged.topK !== undefined ? { topK: merged.topK } : {}),\n ...(merged.stopSequences ? { stopSequences: merged.stopSequences } : {}),\n ...(merged.thinkingConfig ? { thinkingConfig: merged.thinkingConfig } : {}),\n }\n const body = {\n ...request,\n ...(Object.keys(generationConfig).length > 0 ? { generationConfig } : {}),\n ...(merged.toolConfig ? { toolConfig: merged.toolConfig } : {}),\n ...(merged.safetySettings ? { safetySettings: merged.safetySettings } : {}),\n }\n\n // Prompt-assembled tap: the EXACT body about to be POSTed. An ADK-control key — stripped\n // from the wire request, never sent. Observer errors are swallowed so a tap can never\n // corrupt a generation.\n if (merged.onPromptAssembled) {\n try {\n merged.onPromptAssembled({\n battery: 'gemini_generate_content',\n kind: 'request-body',\n messages: body.contents,\n tools: body.tools,\n requestBody: body,\n streamed: merged.stream === true,\n streamId: dispatchStreamId,\n })\n } catch {\n /* observer errors are non-fatal */\n }\n }\n\n // ── dispatch ────────────────────────────────────────────────────────\n const base = (merged.baseURL ?? DEFAULT_BASE_URL).replace(/\\/$/, '')\n const action = merged.stream === true ? 'streamGenerateContent' : 'generateContent'\n const url = `${base}/models/${merged.model}:${action}`\n const headers: Record<string, string> = { 'Content-Type': 'application/json' }\n if (merged.apiKey) {\n // Google's own endpoint wants x-goog-api-key; several gateways in front of it accept only\n // Authorization, hence the switch rather than sending both.\n if (merged.useBearerAuth === true) headers.Authorization = `Bearer ${merged.apiKey}`\n else headers['x-goog-api-key'] = merged.apiKey\n }\n\n const doFetch = merged.fetch ?? globalThis.fetch\n let parsed: GeminiGenerateContentResponse\n try {\n const res = await doFetch(url, {\n method: 'POST',\n headers,\n body: JSON.stringify(body),\n signal: merged.timeoutMs ? AbortSignal.timeout(merged.timeoutMs) : ctx.abortSignal,\n })\n const text = await res.text()\n if (!res.ok) {\n // Classify the vendor's own signature rejection separately — it is actionable, and\n // Gemini's generic INVALID_ARGUMENT body gives a caller nothing to act on.\n if (/thought_signature|thoughtSignature/i.test(text)) {\n ctx.nack(new E_GEMINI_MISSING_THOUGHT_SIGNATURE([text.slice(0, 400)]))\n return\n }\n ctx.nack(new E_GEMINI_REQUEST_FAILED([res.status, text.slice(0, 400)]))\n return\n }\n parsed = JSON.parse(text) as GeminiGenerateContentResponse\n } catch (err) {\n ctx.nack(new E_GEMINI_STREAM_ERROR([isError(err) ? err.message : String(err)]))\n return\n }\n\n // ── interpret ───────────────────────────────────────────────────────\n const { text, reasoning, functionCalls, finishReason } = extractGeminiGeneration(parsed)\n const responseId = uuidv6()\n\n if (text.length > 0) {\n const messageId = `${responseId}:message`\n helpers.reportMessage(messageId, text, { isComplete: true })\n await ctx.storeMessage(\n new Message({\n id: messageId,\n role: 'assistant',\n content: text,\n identity: selfIdentity,\n createdAt: nowIso(),\n updatedAt: nowIso(),\n })\n )\n }\n if (reasoning.length > 0) {\n const thoughtId = `${responseId}:thought`\n helpers.reportThought(thoughtId, reasoning, { isComplete: true })\n await ctx.storeThought(\n new Thought({\n id: thoughtId,\n content: reasoning,\n identity: selfIdentity,\n createdAt: nowIso(),\n updatedAt: nowIso(),\n })\n )\n }\n\n // Fallback recovery: only consulted when the provider returned NO structured calls, so a\n // native functionCall always wins over a parsed one.\n let calls = functionCalls.map((c) => ({ id: uuidv6(), name: c.name, args: c.args }))\n if (calls.length === 0 && merged.localToolCallParser !== undefined && text.length > 0) {\n const parser = resolveToolCallParser(merged.localToolCallParser)\n // The parser returns { calls, cleanedText } — not an iterable of calls — and the\n // second argument carries the tool names actually offered this turn so a parser can\n // reject a hallucinated name rather than manufacture a call for it.\n const recovered = parser(text, { toolNames: ctx.tools.all().map((t) => t.name) })\n for (const call of recovered.calls) {\n calls.push({\n id: uuidv6(),\n name: call.name,\n args: (call.arguments ?? {}) as Record<string, unknown>,\n })\n }\n }\n\n if (merged.onRawGeneration) {\n try {\n merged.onRawGeneration({\n rawText: text,\n cleanedText: text,\n reasoning: reasoning.length > 0 ? [reasoning] : [],\n toolCalls: calls.map((c) => ({ name: c.name, arguments: c.args as never })),\n streamed: merged.stream === true,\n streamId: dispatchStreamId,\n })\n } catch {\n /* observer errors are non-fatal */\n }\n }\n\n if (calls.length === 0) {\n // `finishReason` is recorded for the caller; an empty generation is NOT an error here —\n // it is a real vendor outcome and the runner decides what to do with it.\n helpers.log.trace({\n kind: 'gemini-finish',\n message: `generation ended with finishReason=${finishReason ?? 'unknown'} and no function calls`,\n payload: { finishReason: finishReason ?? 'unknown' },\n })\n if (merged.autoAck) ctx.ack()\n return\n }\n\n for (const call of calls) {\n if (ctx.abortSignal.aborted) return\n const toolName = normalizeToolName(call.name)\n const tool = ctx.tools.get(toolName) as Tool | ArtifactTool | undefined\n const completedAt = nowIso()\n\n if (!isObject(call.args)) {\n const results = new Tokenizable(\n new E_GEMINI_INVALID_TOOL_CALL_ARGS([JSON.stringify(call.args)]).message\n )\n helpers.reportToolCall(call.id, { tool: toolName, args: {} })\n helpers.reportToolCall(call.id, { results, isError: true, isComplete: true })\n await ctx.storeToolCall(\n new ToolCall({\n id: call.id,\n tool: toolName,\n args: {},\n checksum: computeChecksum(toolName, {}),\n isComplete: true,\n isError: true,\n results,\n createdAt: completedAt,\n updatedAt: completedAt,\n completedAt,\n })\n )\n continue\n }\n\n if (!tool) {\n const available = ctx.tools\n .all()\n .map((t) => t.name)\n .sort()\n const results = new Tokenizable(\n available.length > 0\n ? `Tool not found: ${toolName}. Available tools: ${available.join(', ')}.`\n : `Tool not found: ${toolName}. No tools are available this turn.`\n )\n helpers.reportToolCall(call.id, { tool: toolName, args: call.args })\n helpers.reportToolCall(call.id, { results, isError: true, isComplete: true })\n await ctx.storeToolCall(\n new ToolCall({\n id: call.id,\n tool: toolName,\n args: call.args,\n checksum: computeChecksum(toolName, call.args),\n isComplete: true,\n isError: true,\n results,\n createdAt: completedAt,\n updatedAt: completedAt,\n completedAt,\n })\n )\n continue\n }\n\n helpers.reportToolCall(call.id, { tool: tool.name, args: call.args })\n let results: Tokenizable | SpooledArtifact | SpooledArtifact[] | Media | Media[] =\n new Tokenizable('')\n let isToolError = false\n try {\n const raw = await tool.executor(ctx)(call.args)\n results = Tokenizable.isTokenizable(raw)\n ? raw\n : new Tokenizable(typeof raw === 'string' ? raw : JSON.stringify(raw ?? ''))\n } catch (err) {\n isToolError = true\n results = new Tokenizable(isError(err) ? err.message : String(err))\n }\n const finishedAt = nowIso()\n helpers.reportToolCall(call.id, { results, isError: isToolError, isComplete: true })\n await ctx.storeToolCall(\n new ToolCall({\n id: call.id,\n tool: tool.name,\n args: call.args,\n checksum: computeChecksum(tool.name, call.args),\n isComplete: true,\n isError: isToolError,\n results,\n createdAt: finishedAt,\n updatedAt: finishedAt,\n completedAt: finished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,KAAK,UAAU,OAAO,EAAE,CAAC;IAC/E,SAAS,KAAK;KACZ,cAAc;KACd,UAAU,IAAI,YAAY,QAAQ,GAAG,IAAI,IAAI,UAAU,OAAO,GAAG,CAAC;IACpE;IACA,MAAM,aAAa,OAAO;IAC1B,QAAQ,eAAe,KAAK,IAAI;KAAE;KAAS,SAAS;KAAa,YAAY;IAAK,CAAC;IACnF,MAAM,IAAI,cACR,IAAI,SAAS;KACX,IAAI,KAAK;KACT,MAAM,KAAK;KACX,MAAM,KAAK;KACX,UAAU,gBAAgB,KAAK,MAAM,KAAK,IAAI;KAC9C,YAAY;KACZ,SAAS;KACT;KACA,WAAW;KACX,WAAW;KACX,aAAa;IACf,CAAC,CACH;GACF;EACF;CACF;AACF"}
@@ -17,6 +17,8 @@ require("../../../factories.cjs");
17
17
  */
18
18
  /** Resolved options (constructor, executor overrides, or `stash.geminiGenerateContent`) failed validation. */
19
19
  var E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS = require_exceptions.createException("E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS", "Invalid Gemini generateContent adapter options: %s", "E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS", 529, true);
20
+ /** Context token weight exceeded the configured window. */
21
+ var E_GEMINI_GENERATE_CONTENT_CONTEXT_OVERFLOW = require_exceptions.createException("E_GEMINI_GENERATE_CONTENT_CONTEXT_OVERFLOW", "Gemini generateContent request token weight (%d) exceeds context window (%d) under encoding %s", "E_GEMINI_GENERATE_CONTENT_CONTEXT_OVERFLOW", 529, true);
20
22
  /** The provider returned a non-2xx status. */
21
23
  var E_GEMINI_REQUEST_FAILED = require_exceptions.createException("E_GEMINI_REQUEST_FAILED", "Gemini generateContent request failed with status %s: %s", "E_GEMINI_REQUEST_FAILED", 502, false);
22
24
  /**
@@ -34,6 +36,7 @@ var E_GEMINI_STREAM_ERROR = require_exceptions.createException("E_GEMINI_STREAM_
34
36
  /** A `functionCall` part carried an `args` value that is not a plain object. */
35
37
  var E_GEMINI_INVALID_TOOL_CALL_ARGS = require_exceptions.createException("E_GEMINI_INVALID_TOOL_CALL_ARGS", "Gemini functionCall args are not a plain object: %s", "E_GEMINI_INVALID_TOOL_CALL_ARGS", 422, false);
36
38
  //#endregion
39
+ exports.E_GEMINI_GENERATE_CONTENT_CONTEXT_OVERFLOW = E_GEMINI_GENERATE_CONTENT_CONTEXT_OVERFLOW;
37
40
  exports.E_GEMINI_INVALID_TOOL_CALL_ARGS = E_GEMINI_INVALID_TOOL_CALL_ARGS;
38
41
  exports.E_GEMINI_MISSING_THOUGHT_SIGNATURE = E_GEMINI_MISSING_THOUGHT_SIGNATURE;
39
42
  exports.E_GEMINI_REQUEST_FAILED = E_GEMINI_REQUEST_FAILED;
@@ -1 +1 @@
1
- {"version":3,"file":"exceptions.cjs","names":[],"sources":["../../../../src/batteries/llm/gemini_generate_content/exceptions.ts"],"sourcesContent":["/**\n * Battery-scoped exception constructors for the native Gemini `generateContent` adapter.\n *\n * @module @nhtio/adk/batteries/llm/gemini_generate_content/exceptions\n *\n * @remarks\n * Owned by the battery, not the ADK core, and minted via `createException` from\n * `@nhtio/adk/factories`. The set mirrors the other chat batteries with one Gemini-specific\n * addition: {@link E_GEMINI_MISSING_THOUGHT_SIGNATURE}, which classifies the vendor's own hard\n * rejection of unsigned historical function calls so a caller can tell it apart from a generic\n * invalid-request — Gemini's error body is otherwise an opaque `INVALID_ARGUMENT`.\n */\n\nimport { createException } from '@nhtio/adk/factories'\n\n/** Resolved options (constructor, executor overrides, or `stash.geminiGenerateContent`) failed validation. */\nexport const E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS = createException<[string]>(\n 'E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS',\n 'Invalid Gemini generateContent adapter options: %s',\n 'E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS',\n 529,\n true\n)\n\n/** The provider returned a non-2xx status. */\nexport const E_GEMINI_REQUEST_FAILED = createException<[number, string]>(\n 'E_GEMINI_REQUEST_FAILED',\n 'Gemini generateContent request failed with status %s: %s',\n 'E_GEMINI_REQUEST_FAILED',\n 502,\n false\n)\n\n/**\n * Gemini rejected the request because a historical `functionCall` part carried no\n * `thoughtSignature`.\n *\n * @remarks\n * Distinguished from a generic invalid-request because it is ACTIONABLE: the caller either replays\n * a genuine signature, or opts into the documented sentinel via\n * `thoughtSignatureSentinel`. Gemini 3+ enforces this; 2.5 treats it as advisory.\n */\nexport const E_GEMINI_MISSING_THOUGHT_SIGNATURE = createException<[string]>(\n 'E_GEMINI_MISSING_THOUGHT_SIGNATURE',\n 'Gemini rejected a historical functionCall with no thoughtSignature: %s',\n 'E_GEMINI_MISSING_THOUGHT_SIGNATURE',\n 400,\n false\n)\n\n/** A transport error or malformed frame killed the stream mid-generation. */\nexport const E_GEMINI_STREAM_ERROR = createException<[string]>(\n 'E_GEMINI_STREAM_ERROR',\n 'Gemini generateContent stream error: %s',\n 'E_GEMINI_STREAM_ERROR',\n 502,\n false\n)\n\n/** A `functionCall` part carried an `args` value that is not a plain object. */\nexport const E_GEMINI_INVALID_TOOL_CALL_ARGS = createException<[string]>(\n 'E_GEMINI_INVALID_TOOL_CALL_ARGS',\n 'Gemini functionCall args are not a plain object: %s',\n 'E_GEMINI_INVALID_TOOL_CALL_ARGS',\n 422,\n false\n)\n"],"mappings":";;;;;;;;;;;;;;;;;;AAgBA,IAAa,4CAA4C,mBAAA,gBACvD,6CACA,sDACA,6CACA,KACA,IACF;;AAGA,IAAa,0BAA0B,mBAAA,gBACrC,2BACA,4DACA,2BACA,KACA,KACF;;;;;;;;;;AAWA,IAAa,qCAAqC,mBAAA,gBAChD,sCACA,0EACA,sCACA,KACA,KACF;;AAGA,IAAa,wBAAwB,mBAAA,gBACnC,yBACA,2CACA,yBACA,KACA,KACF;;AAGA,IAAa,kCAAkC,mBAAA,gBAC7C,mCACA,uDACA,mCACA,KACA,KACF"}
1
+ {"version":3,"file":"exceptions.cjs","names":[],"sources":["../../../../src/batteries/llm/gemini_generate_content/exceptions.ts"],"sourcesContent":["/**\n * Battery-scoped exception constructors for the native Gemini `generateContent` adapter.\n *\n * @module @nhtio/adk/batteries/llm/gemini_generate_content/exceptions\n *\n * @remarks\n * Owned by the battery, not the ADK core, and minted via `createException` from\n * `@nhtio/adk/factories`. The set mirrors the other chat batteries with one Gemini-specific\n * addition: {@link E_GEMINI_MISSING_THOUGHT_SIGNATURE}, which classifies the vendor's own hard\n * rejection of unsigned historical function calls so a caller can tell it apart from a generic\n * invalid-request — Gemini's error body is otherwise an opaque `INVALID_ARGUMENT`.\n */\n\nimport { createException } from '@nhtio/adk/factories'\n\n/** Resolved options (constructor, executor overrides, or `stash.geminiGenerateContent`) failed validation. */\nexport const E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS = createException<[string]>(\n 'E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS',\n 'Invalid Gemini generateContent adapter options: %s',\n 'E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS',\n 529,\n true\n)\n\n/** Context token weight exceeded the configured window. */\nexport const E_GEMINI_GENERATE_CONTENT_CONTEXT_OVERFLOW = createException<[number, number, string]>(\n 'E_GEMINI_GENERATE_CONTENT_CONTEXT_OVERFLOW',\n 'Gemini generateContent request token weight (%d) exceeds context window (%d) under encoding %s',\n 'E_GEMINI_GENERATE_CONTENT_CONTEXT_OVERFLOW',\n 529,\n true\n)\n\n/** The provider returned a non-2xx status. */\nexport const E_GEMINI_REQUEST_FAILED = createException<[number, string]>(\n 'E_GEMINI_REQUEST_FAILED',\n 'Gemini generateContent request failed with status %s: %s',\n 'E_GEMINI_REQUEST_FAILED',\n 502,\n false\n)\n\n/**\n * Gemini rejected the request because a historical `functionCall` part carried no\n * `thoughtSignature`.\n *\n * @remarks\n * Distinguished from a generic invalid-request because it is ACTIONABLE: the caller either replays\n * a genuine signature, or opts into the documented sentinel via\n * `thoughtSignatureSentinel`. Gemini 3+ enforces this; 2.5 treats it as advisory.\n */\nexport const E_GEMINI_MISSING_THOUGHT_SIGNATURE = createException<[string]>(\n 'E_GEMINI_MISSING_THOUGHT_SIGNATURE',\n 'Gemini rejected a historical functionCall with no thoughtSignature: %s',\n 'E_GEMINI_MISSING_THOUGHT_SIGNATURE',\n 400,\n false\n)\n\n/** A transport error or malformed frame killed the stream mid-generation. */\nexport const E_GEMINI_STREAM_ERROR = createException<[string]>(\n 'E_GEMINI_STREAM_ERROR',\n 'Gemini generateContent stream error: %s',\n 'E_GEMINI_STREAM_ERROR',\n 502,\n false\n)\n\n/** A `functionCall` part carried an `args` value that is not a plain object. */\nexport const E_GEMINI_INVALID_TOOL_CALL_ARGS = createException<[string]>(\n 'E_GEMINI_INVALID_TOOL_CALL_ARGS',\n 'Gemini functionCall args are not a plain object: %s',\n 'E_GEMINI_INVALID_TOOL_CALL_ARGS',\n 422,\n false\n)\n"],"mappings":";;;;;;;;;;;;;;;;;;AAgBA,IAAa,4CAA4C,mBAAA,gBACvD,6CACA,sDACA,6CACA,KACA,IACF;;AAGA,IAAa,6CAA6C,mBAAA,gBACxD,8CACA,kGACA,8CACA,KACA,IACF;;AAGA,IAAa,0BAA0B,mBAAA,gBACrC,2BACA,4DACA,2BACA,KACA,KACF;;;;;;;;;;AAWA,IAAa,qCAAqC,mBAAA,gBAChD,sCACA,0EACA,sCACA,KACA,KACF;;AAGA,IAAa,wBAAwB,mBAAA,gBACnC,yBACA,2CACA,yBACA,KACA,KACF;;AAGA,IAAa,kCAAkC,mBAAA,gBAC7C,mCACA,uDACA,mCACA,KACA,KACF"}
@@ -14,6 +14,12 @@
14
14
  export declare const E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS: import("../../../factories").CreatedException<[
15
15
  string
16
16
  ]>;
17
+ /** Context token weight exceeded the configured window. */
18
+ export declare const E_GEMINI_GENERATE_CONTENT_CONTEXT_OVERFLOW: import("../../../factories").CreatedException<[
19
+ number,
20
+ number,
21
+ string
22
+ ]>;
17
23
  /** The provider returned a non-2xx status. */
18
24
  export declare const E_GEMINI_REQUEST_FAILED: import("../../../factories").CreatedException<[
19
25
  number,
@@ -15,6 +15,8 @@ import "../../../factories.mjs";
15
15
  */
16
16
  /** Resolved options (constructor, executor overrides, or `stash.geminiGenerateContent`) failed validation. */
17
17
  var E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS = createException("E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS", "Invalid Gemini generateContent adapter options: %s", "E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS", 529, true);
18
+ /** Context token weight exceeded the configured window. */
19
+ var E_GEMINI_GENERATE_CONTENT_CONTEXT_OVERFLOW = createException("E_GEMINI_GENERATE_CONTENT_CONTEXT_OVERFLOW", "Gemini generateContent request token weight (%d) exceeds context window (%d) under encoding %s", "E_GEMINI_GENERATE_CONTENT_CONTEXT_OVERFLOW", 529, true);
18
20
  /** The provider returned a non-2xx status. */
19
21
  var E_GEMINI_REQUEST_FAILED = createException("E_GEMINI_REQUEST_FAILED", "Gemini generateContent request failed with status %s: %s", "E_GEMINI_REQUEST_FAILED", 502, false);
20
22
  /**
@@ -32,6 +34,6 @@ var E_GEMINI_STREAM_ERROR = createException("E_GEMINI_STREAM_ERROR", "Gemini gen
32
34
  /** A `functionCall` part carried an `args` value that is not a plain object. */
33
35
  var E_GEMINI_INVALID_TOOL_CALL_ARGS = createException("E_GEMINI_INVALID_TOOL_CALL_ARGS", "Gemini functionCall args are not a plain object: %s", "E_GEMINI_INVALID_TOOL_CALL_ARGS", 422, false);
34
36
  //#endregion
35
- export { E_GEMINI_INVALID_TOOL_CALL_ARGS, E_GEMINI_MISSING_THOUGHT_SIGNATURE, E_GEMINI_REQUEST_FAILED, E_GEMINI_STREAM_ERROR, E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS };
37
+ export { E_GEMINI_GENERATE_CONTENT_CONTEXT_OVERFLOW, E_GEMINI_INVALID_TOOL_CALL_ARGS, E_GEMINI_MISSING_THOUGHT_SIGNATURE, E_GEMINI_REQUEST_FAILED, E_GEMINI_STREAM_ERROR, E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS };
36
38
 
37
39
  //# sourceMappingURL=exceptions.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"exceptions.mjs","names":[],"sources":["../../../../src/batteries/llm/gemini_generate_content/exceptions.ts"],"sourcesContent":["/**\n * Battery-scoped exception constructors for the native Gemini `generateContent` adapter.\n *\n * @module @nhtio/adk/batteries/llm/gemini_generate_content/exceptions\n *\n * @remarks\n * Owned by the battery, not the ADK core, and minted via `createException` from\n * `@nhtio/adk/factories`. The set mirrors the other chat batteries with one Gemini-specific\n * addition: {@link E_GEMINI_MISSING_THOUGHT_SIGNATURE}, which classifies the vendor's own hard\n * rejection of unsigned historical function calls so a caller can tell it apart from a generic\n * invalid-request — Gemini's error body is otherwise an opaque `INVALID_ARGUMENT`.\n */\n\nimport { createException } from '@nhtio/adk/factories'\n\n/** Resolved options (constructor, executor overrides, or `stash.geminiGenerateContent`) failed validation. */\nexport const E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS = createException<[string]>(\n 'E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS',\n 'Invalid Gemini generateContent adapter options: %s',\n 'E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS',\n 529,\n true\n)\n\n/** The provider returned a non-2xx status. */\nexport const E_GEMINI_REQUEST_FAILED = createException<[number, string]>(\n 'E_GEMINI_REQUEST_FAILED',\n 'Gemini generateContent request failed with status %s: %s',\n 'E_GEMINI_REQUEST_FAILED',\n 502,\n false\n)\n\n/**\n * Gemini rejected the request because a historical `functionCall` part carried no\n * `thoughtSignature`.\n *\n * @remarks\n * Distinguished from a generic invalid-request because it is ACTIONABLE: the caller either replays\n * a genuine signature, or opts into the documented sentinel via\n * `thoughtSignatureSentinel`. Gemini 3+ enforces this; 2.5 treats it as advisory.\n */\nexport const E_GEMINI_MISSING_THOUGHT_SIGNATURE = createException<[string]>(\n 'E_GEMINI_MISSING_THOUGHT_SIGNATURE',\n 'Gemini rejected a historical functionCall with no thoughtSignature: %s',\n 'E_GEMINI_MISSING_THOUGHT_SIGNATURE',\n 400,\n false\n)\n\n/** A transport error or malformed frame killed the stream mid-generation. */\nexport const E_GEMINI_STREAM_ERROR = createException<[string]>(\n 'E_GEMINI_STREAM_ERROR',\n 'Gemini generateContent stream error: %s',\n 'E_GEMINI_STREAM_ERROR',\n 502,\n false\n)\n\n/** A `functionCall` part carried an `args` value that is not a plain object. */\nexport const E_GEMINI_INVALID_TOOL_CALL_ARGS = createException<[string]>(\n 'E_GEMINI_INVALID_TOOL_CALL_ARGS',\n 'Gemini functionCall args are not a plain object: %s',\n 'E_GEMINI_INVALID_TOOL_CALL_ARGS',\n 422,\n false\n)\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,IAAa,4CAA4C,gBACvD,6CACA,sDACA,6CACA,KACA,IACF;;AAGA,IAAa,0BAA0B,gBACrC,2BACA,4DACA,2BACA,KACA,KACF;;;;;;;;;;AAWA,IAAa,qCAAqC,gBAChD,sCACA,0EACA,sCACA,KACA,KACF;;AAGA,IAAa,wBAAwB,gBACnC,yBACA,2CACA,yBACA,KACA,KACF;;AAGA,IAAa,kCAAkC,gBAC7C,mCACA,uDACA,mCACA,KACA,KACF"}
1
+ {"version":3,"file":"exceptions.mjs","names":[],"sources":["../../../../src/batteries/llm/gemini_generate_content/exceptions.ts"],"sourcesContent":["/**\n * Battery-scoped exception constructors for the native Gemini `generateContent` adapter.\n *\n * @module @nhtio/adk/batteries/llm/gemini_generate_content/exceptions\n *\n * @remarks\n * Owned by the battery, not the ADK core, and minted via `createException` from\n * `@nhtio/adk/factories`. The set mirrors the other chat batteries with one Gemini-specific\n * addition: {@link E_GEMINI_MISSING_THOUGHT_SIGNATURE}, which classifies the vendor's own hard\n * rejection of unsigned historical function calls so a caller can tell it apart from a generic\n * invalid-request — Gemini's error body is otherwise an opaque `INVALID_ARGUMENT`.\n */\n\nimport { createException } from '@nhtio/adk/factories'\n\n/** Resolved options (constructor, executor overrides, or `stash.geminiGenerateContent`) failed validation. */\nexport const E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS = createException<[string]>(\n 'E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS',\n 'Invalid Gemini generateContent adapter options: %s',\n 'E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS',\n 529,\n true\n)\n\n/** Context token weight exceeded the configured window. */\nexport const E_GEMINI_GENERATE_CONTENT_CONTEXT_OVERFLOW = createException<[number, number, string]>(\n 'E_GEMINI_GENERATE_CONTENT_CONTEXT_OVERFLOW',\n 'Gemini generateContent request token weight (%d) exceeds context window (%d) under encoding %s',\n 'E_GEMINI_GENERATE_CONTENT_CONTEXT_OVERFLOW',\n 529,\n true\n)\n\n/** The provider returned a non-2xx status. */\nexport const E_GEMINI_REQUEST_FAILED = createException<[number, string]>(\n 'E_GEMINI_REQUEST_FAILED',\n 'Gemini generateContent request failed with status %s: %s',\n 'E_GEMINI_REQUEST_FAILED',\n 502,\n false\n)\n\n/**\n * Gemini rejected the request because a historical `functionCall` part carried no\n * `thoughtSignature`.\n *\n * @remarks\n * Distinguished from a generic invalid-request because it is ACTIONABLE: the caller either replays\n * a genuine signature, or opts into the documented sentinel via\n * `thoughtSignatureSentinel`. Gemini 3+ enforces this; 2.5 treats it as advisory.\n */\nexport const E_GEMINI_MISSING_THOUGHT_SIGNATURE = createException<[string]>(\n 'E_GEMINI_MISSING_THOUGHT_SIGNATURE',\n 'Gemini rejected a historical functionCall with no thoughtSignature: %s',\n 'E_GEMINI_MISSING_THOUGHT_SIGNATURE',\n 400,\n false\n)\n\n/** A transport error or malformed frame killed the stream mid-generation. */\nexport const E_GEMINI_STREAM_ERROR = createException<[string]>(\n 'E_GEMINI_STREAM_ERROR',\n 'Gemini generateContent stream error: %s',\n 'E_GEMINI_STREAM_ERROR',\n 502,\n false\n)\n\n/** A `functionCall` part carried an `args` value that is not a plain object. */\nexport const E_GEMINI_INVALID_TOOL_CALL_ARGS = createException<[string]>(\n 'E_GEMINI_INVALID_TOOL_CALL_ARGS',\n 'Gemini functionCall args are not a plain object: %s',\n 'E_GEMINI_INVALID_TOOL_CALL_ARGS',\n 422,\n false\n)\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,IAAa,4CAA4C,gBACvD,6CACA,sDACA,6CACA,KACA,IACF;;AAGA,IAAa,6CAA6C,gBACxD,8CACA,kGACA,8CACA,KACA,IACF;;AAGA,IAAa,0BAA0B,gBACrC,2BACA,4DACA,2BACA,KACA,KACF;;;;;;;;;;AAWA,IAAa,qCAAqC,gBAChD,sCACA,0EACA,sCACA,KACA,KACF;;AAGA,IAAa,wBAAwB,gBACnC,yBACA,2CACA,yBACA,KACA,KACF;;AAGA,IAAa,kCAAkC,gBAC7C,mCACA,uDACA,mCACA,KACA,KACF"}
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("../../../chunk-Cek0wNdY.js");
3
3
  const require_guards = require("../../../guards-05Uq3J4M.js");
4
4
  require("../../../guards.cjs");
5
- const require_helpers = require("../../../helpers-Tvvwpx1M.js");
5
+ const require_helpers = require("../../../helpers-CEjjkXso.js");
6
6
  //#region src/batteries/llm/gemini_generate_content/helpers.ts
7
7
  /**
8
8
  * Translation helpers for the native Gemini `generateContent` battery.
@@ -1,6 +1,6 @@
1
1
  import { r as isObject } from "../../../guards-BEpY7lBI.mjs";
2
2
  import "../../../guards.mjs";
3
- import { A as renderMemories, C as looksLikeSpooledArtifact, D as renderArtifactHandleBody, E as normalizeToolName, F as renderThirdPartyPrivateRetrievables, I as renderThirdPartyPublicRetrievables, L as renderThought, M as renderRetrievableSafetyDirective, N as renderRetrievables, O as renderChatCompletionsSystemPrompt, P as renderStandingInstructions, R as renderTrustedContent, T as neutraliseDeveloperRulesTag, U as sanitizeMimeType, _ as defaultRenderUntrustedContent, a as defaultRenderArtifactHandleBody, c as defaultRenderMemories, d as defaultRenderRetrievables, f as defaultRenderStandingInstructions, g as defaultRenderTrustedContent, h as defaultRenderThought, i as defaultFilterThoughts, j as renderRetrievableHandleBody, k as renderFirstPartyRetrievables, l as defaultRenderRetrievableHandleBody, m as defaultRenderThirdPartyPublicRetrievables, o as defaultRenderChatCompletionsSystemPrompt, p as defaultRenderThirdPartyPrivateRetrievables, r as defaultDescriptionToChatCompletionsJsonSchema, s as defaultRenderFirstPartyRetrievables, u as defaultRenderRetrievableSafetyDirective, x as filterThoughts, y as descriptionToChatCompletionsJsonSchema, z as renderUntrustedContent } from "../../../helpers-CDmLDBq5.mjs";
3
+ import { A as renderMemories, C as looksLikeSpooledArtifact, D as renderArtifactHandleBody, E as normalizeToolName, F as renderThirdPartyPrivateRetrievables, I as renderThirdPartyPublicRetrievables, L as renderThought, M as renderRetrievableSafetyDirective, N as renderRetrievables, O as renderChatCompletionsSystemPrompt, P as renderStandingInstructions, R as renderTrustedContent, T as neutraliseDeveloperRulesTag, U as sanitizeMimeType, _ as defaultRenderUntrustedContent, a as defaultRenderArtifactHandleBody, c as defaultRenderMemories, d as defaultRenderRetrievables, f as defaultRenderStandingInstructions, g as defaultRenderTrustedContent, h as defaultRenderThought, i as defaultFilterThoughts, j as renderRetrievableHandleBody, k as renderFirstPartyRetrievables, l as defaultRenderRetrievableHandleBody, m as defaultRenderThirdPartyPublicRetrievables, o as defaultRenderChatCompletionsSystemPrompt, p as defaultRenderThirdPartyPrivateRetrievables, r as defaultDescriptionToChatCompletionsJsonSchema, s as defaultRenderFirstPartyRetrievables, u as defaultRenderRetrievableSafetyDirective, x as filterThoughts, y as descriptionToChatCompletionsJsonSchema, z as renderUntrustedContent } from "../../../helpers-BH7HTtkD.mjs";
4
4
  //#region src/batteries/llm/gemini_generate_content/helpers.ts
5
5
  /**
6
6
  * Translation helpers for the native Gemini `generateContent` battery.
@@ -28,7 +28,7 @@
28
28
  * `../chat_common/types` submodule and are re-exported so consumers of this battery get a
29
29
  * self-contained type surface.
30
30
  */
31
- import type { TokenEncoding } from "../../../common";
31
+ import type { TokenEncodingId } from "../../../types";
32
32
  import type { DispatchContext } from "../../../types";
33
33
  import type { SpooledArtifact, Media, SpoolStore } from "../../../common";
34
34
  import type { ToolCallParserName, ToolCallParserFn } from "../chat_common/tool_parsers";
@@ -341,8 +341,12 @@ export interface GeminiGenerateContentAdapterOptions {
341
341
  retry?: ChatCompletionsRetryConfig;
342
342
  /** Injectable `fetch`, for tests or a custom transport. */
343
343
  fetch?: typeof globalThis.fetch;
344
- /** Encoding used for token accounting. */
345
- tokenEncoding?: TokenEncoding;
344
+ /** Encoding used for token accounting; `null` explicitly disables token accounting. */
345
+ tokenEncoding?: TokenEncodingId | null;
346
+ /** Maximum token weight allowed for the assembled context. */
347
+ contextWindow?: number;
348
+ /** Whether to acknowledge tool-call-free generations; defaults to true. */
349
+ autoAck?: boolean;
346
350
  /** Spool store backing artifact-handle results. */
347
351
  spoolStore?: SpoolStore;
348
352
  /** Order of context buckets in the system instruction. */
@@ -1,5 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("../../../chunk-Cek0wNdY.js");
3
+ const require_tokenizable = require("../../../tokenizable-BMZuGWRd.js");
4
+ require("../../../common-H44Ik9ou.js");
3
5
  const require_batteries_llm_gemini_generate_content_exceptions = require("./exceptions.cjs");
4
6
  let _nhtio_validation = require("@nhtio/validation");
5
7
  //#region src/batteries/llm/gemini_generate_content/validation.ts
@@ -9,12 +11,16 @@ let _nhtio_validation = require("@nhtio/validation");
9
11
  * @module @nhtio/adk/batteries/llm/gemini_generate_content/validation
10
12
  */
11
13
  /** Schema for {@link GeminiGenerateContentAdapterOptions}. */
14
+ var tokenEncodingSchema = _nhtio_validation.validator.alternatives(_nhtio_validation.validator.string().min(1).description(`Known encodings: ${require_tokenizable.TokenEncoding.join(", ")}`), _nhtio_validation.validator.any().valid(null).optional()).default(null);
15
+ /** Schema for {@link GeminiGenerateContentAdapterOptions}. */
12
16
  var geminiGenerateContentOptionsSchema = _nhtio_validation.validator.object({
13
17
  model: _nhtio_validation.validator.string().min(1).required(),
14
18
  apiKey: _nhtio_validation.validator.string().optional(),
15
19
  useBearerAuth: _nhtio_validation.validator.boolean().optional(),
16
20
  baseURL: _nhtio_validation.validator.string().optional(),
17
21
  stream: _nhtio_validation.validator.boolean().optional(),
22
+ contextWindow: _nhtio_validation.validator.number().integer().min(1).optional(),
23
+ autoAck: _nhtio_validation.validator.boolean().default(true),
18
24
  maxOutputTokens: _nhtio_validation.validator.number().integer().positive().optional(),
19
25
  temperature: _nhtio_validation.validator.number().min(0).max(2).optional(),
20
26
  topP: _nhtio_validation.validator.number().min(0).max(1).optional(),
@@ -42,11 +48,14 @@ var geminiGenerateContentOptionsSchema = _nhtio_validation.validator.object({
42
48
  honorRetryAfter: _nhtio_validation.validator.boolean().optional()
43
49
  }).optional(),
44
50
  fetch: _nhtio_validation.validator.function().optional(),
45
- tokenEncoding: _nhtio_validation.validator.any().optional(),
51
+ tokenEncoding: tokenEncodingSchema,
46
52
  spoolStore: _nhtio_validation.validator.any().optional(),
47
53
  bucketOrder: _nhtio_validation.validator.any().optional(),
48
54
  thoughtSurfacing: _nhtio_validation.validator.string().valid("all-self", "latest-self", "all").optional(),
49
- unsupportedMediaPolicy: _nhtio_validation.validator.string().optional(),
55
+ unsupportedMediaPolicy: _nhtio_validation.validator.alternatives(_nhtio_validation.validator.string().valid("throw", "fallback-stash", "synthetic-description"), _nhtio_validation.validator.object({
56
+ mode: _nhtio_validation.validator.string().valid("fallback-stash").required(),
57
+ stashKeys: _nhtio_validation.validator.array().items(_nhtio_validation.validator.string().min(1)).required()
58
+ }).unknown(false)).default("throw"),
50
59
  localToolCallParser: _nhtio_validation.validator.any().optional(),
51
60
  onRawGeneration: _nhtio_validation.validator.function().optional(),
52
61
  onPromptAssembled: _nhtio_validation.validator.function().optional(),
@@ -1 +1 @@
1
- {"version":3,"file":"validation.cjs","names":[],"sources":["../../../../src/batteries/llm/gemini_generate_content/validation.ts"],"sourcesContent":["/**\n * Runtime option validation for the native Gemini `generateContent` battery.\n *\n * @module @nhtio/adk/batteries/llm/gemini_generate_content/validation\n */\n\nimport { validator } from '@nhtio/validation'\nimport { E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS } from './exceptions'\nimport type { GeminiGenerateContentAdapterOptions } from './types'\n\n/** Schema for {@link GeminiGenerateContentAdapterOptions}. */\nexport const geminiGenerateContentOptionsSchema = validator.object({\n model: validator.string().min(1).required(),\n apiKey: validator.string().optional(),\n useBearerAuth: validator.boolean().optional(),\n baseURL: validator.string().optional(),\n stream: validator.boolean().optional(),\n maxOutputTokens: validator.number().integer().positive().optional(),\n temperature: validator.number().min(0).max(2).optional(),\n topP: validator.number().min(0).max(1).optional(),\n topK: validator.number().integer().positive().optional(),\n stopSequences: validator.array().items(validator.string()).optional(),\n thinkingConfig: validator\n .object({\n thinkingBudget: validator.number().integer().optional(),\n includeThoughts: validator.boolean().optional(),\n })\n .optional(),\n safetySettings: validator\n .array()\n .items(\n validator.object({\n category: validator.string().required(),\n threshold: validator.string().required(),\n })\n )\n .optional(),\n toolConfig: validator\n .object({\n functionCallingConfig: validator\n .object({\n mode: validator.string().valid('AUTO', 'ANY', 'NONE').required(),\n allowedFunctionNames: validator.array().items(validator.string()).optional(),\n })\n .required(),\n })\n .optional(),\n // `false` opts out of the sentinel entirely and surfaces Gemini's own rejection instead.\n thoughtSignatureSentinel: validator\n .alternatives(validator.string().min(1), validator.boolean().valid(false))\n .optional(),\n timeoutMs: validator.number().integer().positive().optional(),\n retry: validator\n .object({\n maxAttempts: validator.number().integer().positive().optional(),\n baseDelayMs: validator.number().integer().positive().optional(),\n maxDelayMs: validator.number().integer().positive().optional(),\n retriableStatuses: validator.array().items(validator.number()).optional(),\n honorRetryAfter: validator.boolean().optional(),\n })\n .optional(),\n fetch: validator.function().optional(),\n tokenEncoding: validator.any().optional(),\n spoolStore: validator.any().optional(),\n bucketOrder: validator.any().optional(),\n thoughtSurfacing: validator.string().valid('all-self', 'latest-self', 'all').optional(),\n unsupportedMediaPolicy: validator.string().optional(),\n localToolCallParser: validator.any().optional(),\n onRawGeneration: validator.function().optional(),\n onPromptAssembled: validator.function().optional(),\n helpers: validator.object().unknown(true).optional(),\n forgeToolsFilter: validator.function().optional(),\n})\n\n/**\n * Validate and normalise adapter options.\n *\n * @throws {@link E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS} when validation fails.\n */\nexport const validateOptions = (input: unknown): GeminiGenerateContentAdapterOptions => {\n const { error, value } = geminiGenerateContentOptionsSchema.validate(input, {\n allowUnknown: false,\n stripUnknown: false,\n })\n if (error) {\n throw new E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS([\n error.details.map((detail: { message: string }) => detail.message).join(' '),\n ])\n }\n return value as GeminiGenerateContentAdapterOptions\n}\n"],"mappings":";;;;;;;;;;;AAWA,IAAa,qCAAqC,kBAAA,UAAU,OAAO;CACjE,OAAO,kBAAA,UAAU,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS;CAC1C,QAAQ,kBAAA,UAAU,OAAO,EAAE,SAAS;CACpC,eAAe,kBAAA,UAAU,QAAQ,EAAE,SAAS;CAC5C,SAAS,kBAAA,UAAU,OAAO,EAAE,SAAS;CACrC,QAAQ,kBAAA,UAAU,QAAQ,EAAE,SAAS;CACrC,iBAAiB,kBAAA,UAAU,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS;CAClE,aAAa,kBAAA,UAAU,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,SAAS;CACvD,MAAM,kBAAA,UAAU,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,EAAE,SAAS;CAChD,MAAM,kBAAA,UAAU,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS;CACvD,eAAe,kBAAA,UAAU,MAAM,EAAE,MAAM,kBAAA,UAAU,OAAO,CAAC,EAAE,SAAS;CACpE,gBAAgB,kBAAA,UACb,OAAO;EACN,gBAAgB,kBAAA,UAAU,OAAO,EAAE,QAAQ,EAAE,SAAS;EACt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;CACrC,aAAa,kBAAA,UAAU,IAAI,EAAE,SAAS;CACtC,kBAAkB,kBAAA,UAAU,OAAO,EAAE,MAAM,YAAY,eAAe,KAAK,EAAE,SAAS;CACtF,wBAAwB,kBAAA,UAAU,OAAO,EAAE,SAAS;CACpD,qBAAqB,kBAAA,UAAU,IAAI,EAAE,SAAS;CAC9C,iBAAiB,kBAAA,UAAU,SAAS,EAAE,SAAS;CAC/C,mBAAmB,kBAAA,UAAU,SAAS,EAAE,SAAS;CACjD,SAAS,kBAAA,UAAU,OAAO,EAAE,QAAQ,IAAI,EAAE,SAAS;CACnD,kBAAkB,kBAAA,UAAU,SAAS,EAAE,SAAS;AAClD,CAAC;;;;;;AAOD,IAAa,mBAAmB,UAAwD;CACtF,MAAM,EAAE,OAAO,UAAU,mCAAmC,SAAS,OAAO;EAC1E,cAAc;EACd,cAAc;CAChB,CAAC;CACD,IAAI,OACF,MAAM,IAAI,yDAAA,0CAA0C,CAClD,MAAM,QAAQ,KAAK,WAAgC,OAAO,OAAO,EAAE,KAAK,GAAG,CAC7E,CAAC;CAEH,OAAO;AACT"}
1
+ {"version":3,"file":"validation.cjs","names":[],"sources":["../../../../src/batteries/llm/gemini_generate_content/validation.ts"],"sourcesContent":["/**\n * Runtime option validation for the native Gemini `generateContent` battery.\n *\n * @module @nhtio/adk/batteries/llm/gemini_generate_content/validation\n */\n\nimport { validator } from '@nhtio/validation'\nimport { TokenEncoding } from '@nhtio/adk/common'\nimport { E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS } from './exceptions'\nimport type { GeminiGenerateContentAdapterOptions } from './types'\n\n/** Schema for {@link GeminiGenerateContentAdapterOptions}. */\nconst tokenEncodingSchema = validator\n .alternatives(\n // Known values are suggestions from the canonical list, not a whitelist: consumers may provide\n // a custom or newer tokenizer name. The field accepts any non-empty string, explicit null, or\n // absent (undefined = \"no token counting\"). `.optional()` preserves the null/undefined\n // disposition required by adk/require-validator-any-required.\n validator\n .string()\n .min(1)\n .description(`Known encodings: ${TokenEncoding.join(', ')}`),\n validator.any().valid(null).optional()\n )\n .default(null)\n\n/** Schema for {@link GeminiGenerateContentAdapterOptions}. */\nexport const geminiGenerateContentOptionsSchema = validator.object({\n model: validator.string().min(1).required(),\n apiKey: validator.string().optional(),\n useBearerAuth: validator.boolean().optional(),\n baseURL: validator.string().optional(),\n stream: validator.boolean().optional(),\n contextWindow: validator.number().integer().min(1).optional(),\n autoAck: validator.boolean().default(true),\n maxOutputTokens: validator.number().integer().positive().optional(),\n temperature: validator.number().min(0).max(2).optional(),\n topP: validator.number().min(0).max(1).optional(),\n topK: validator.number().integer().positive().optional(),\n stopSequences: validator.array().items(validator.string()).optional(),\n thinkingConfig: validator\n .object({\n thinkingBudget: validator.number().integer().optional(),\n includeThoughts: validator.boolean().optional(),\n })\n .optional(),\n safetySettings: validator\n .array()\n .items(\n validator.object({\n category: validator.string().required(),\n threshold: validator.string().required(),\n })\n )\n .optional(),\n toolConfig: validator\n .object({\n functionCallingConfig: validator\n .object({\n mode: validator.string().valid('AUTO', 'ANY', 'NONE').required(),\n allowedFunctionNames: validator.array().items(validator.string()).optional(),\n })\n .required(),\n })\n .optional(),\n // `false` opts out of the sentinel entirely and surfaces Gemini's own rejection instead.\n thoughtSignatureSentinel: validator\n .alternatives(validator.string().min(1), validator.boolean().valid(false))\n .optional(),\n timeoutMs: validator.number().integer().positive().optional(),\n retry: validator\n .object({\n maxAttempts: validator.number().integer().positive().optional(),\n baseDelayMs: validator.number().integer().positive().optional(),\n maxDelayMs: validator.number().integer().positive().optional(),\n retriableStatuses: validator.array().items(validator.number()).optional(),\n honorRetryAfter: validator.boolean().optional(),\n })\n .optional(),\n fetch: validator.function().optional(),\n tokenEncoding: tokenEncodingSchema,\n spoolStore: validator.any().optional(),\n bucketOrder: validator.any().optional(),\n thoughtSurfacing: validator.string().valid('all-self', 'latest-self', 'all').optional(),\n unsupportedMediaPolicy: validator\n .alternatives(\n validator.string().valid('throw', 'fallback-stash', 'synthetic-description'),\n validator\n .object({\n mode: validator.string().valid('fallback-stash').required(),\n stashKeys: validator.array().items(validator.string().min(1)).required(),\n })\n .unknown(false)\n )\n .default('throw'),\n localToolCallParser: validator.any().optional(),\n onRawGeneration: validator.function().optional(),\n onPromptAssembled: validator.function().optional(),\n helpers: validator.object().unknown(true).optional(),\n forgeToolsFilter: validator.function().optional(),\n})\n\n/**\n * Validate and normalise adapter options.\n *\n * @throws {@link E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS} when validation fails.\n */\nexport const validateOptions = (input: unknown): GeminiGenerateContentAdapterOptions => {\n const { error, value } = geminiGenerateContentOptionsSchema.validate(input, {\n allowUnknown: false,\n stripUnknown: false,\n })\n if (error) {\n throw new E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS([\n error.details.map((detail: { message: string }) => detail.message).join(' '),\n ])\n }\n return value as GeminiGenerateContentAdapterOptions\n}\n"],"mappings":";;;;;;;;;;;;;AAYA,IAAM,sBAAsB,kBAAA,UACzB,aAKC,kBAAA,UACG,OAAO,EACP,IAAI,CAAC,EACL,YAAY,oBAAoB,oBAAA,cAAc,KAAK,IAAI,GAAG,GAC7D,kBAAA,UAAU,IAAI,EAAE,MAAM,IAAI,EAAE,SAAS,CACvC,EACC,QAAQ,IAAI;;AAGf,IAAa,qCAAqC,kBAAA,UAAU,OAAO;CACjE,OAAO,kBAAA,UAAU,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS;CAC1C,QAAQ,kBAAA,UAAU,OAAO,EAAE,SAAS;CACpC,eAAe,kBAAA,UAAU,QAAQ,EAAE,SAAS;CAC5C,SAAS,kBAAA,UAAU,OAAO,EAAE,SAAS;CACrC,QAAQ,kBAAA,UAAU,QAAQ,EAAE,SAAS;CACrC,eAAe,kBAAA,UAAU,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,SAAS;CAC5D,SAAS,kBAAA,UAAU,QAAQ,EAAE,QAAQ,IAAI;CACzC,iBAAiB,kBAAA,UAAU,OAAO,EAAE,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D,IAAI,OACF,MAAM,IAAI,yDAAA,0CAA0C,CAClD,MAAM,QAAQ,KAAK,WAAgC,OAAO,OAAO,EAAE,KAAK,GAAG,CAC7E,CAAC;CAEH,OAAO;AACT"}
@@ -1,3 +1,5 @@
1
+ import { n as TokenEncoding } from "../../../tokenizable-VB4Av8GF.mjs";
2
+ import "../../../common-BpdHIpQE.mjs";
1
3
  import { E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS } from "./exceptions.mjs";
2
4
  import { validator } from "@nhtio/validation";
3
5
  //#region src/batteries/llm/gemini_generate_content/validation.ts
@@ -7,12 +9,16 @@ import { validator } from "@nhtio/validation";
7
9
  * @module @nhtio/adk/batteries/llm/gemini_generate_content/validation
8
10
  */
9
11
  /** Schema for {@link GeminiGenerateContentAdapterOptions}. */
12
+ var tokenEncodingSchema = validator.alternatives(validator.string().min(1).description(`Known encodings: ${TokenEncoding.join(", ")}`), validator.any().valid(null).optional()).default(null);
13
+ /** Schema for {@link GeminiGenerateContentAdapterOptions}. */
10
14
  var geminiGenerateContentOptionsSchema = validator.object({
11
15
  model: validator.string().min(1).required(),
12
16
  apiKey: validator.string().optional(),
13
17
  useBearerAuth: validator.boolean().optional(),
14
18
  baseURL: validator.string().optional(),
15
19
  stream: validator.boolean().optional(),
20
+ contextWindow: validator.number().integer().min(1).optional(),
21
+ autoAck: validator.boolean().default(true),
16
22
  maxOutputTokens: validator.number().integer().positive().optional(),
17
23
  temperature: validator.number().min(0).max(2).optional(),
18
24
  topP: validator.number().min(0).max(1).optional(),
@@ -40,11 +46,14 @@ var geminiGenerateContentOptionsSchema = validator.object({
40
46
  honorRetryAfter: validator.boolean().optional()
41
47
  }).optional(),
42
48
  fetch: validator.function().optional(),
43
- tokenEncoding: validator.any().optional(),
49
+ tokenEncoding: tokenEncodingSchema,
44
50
  spoolStore: validator.any().optional(),
45
51
  bucketOrder: validator.any().optional(),
46
52
  thoughtSurfacing: validator.string().valid("all-self", "latest-self", "all").optional(),
47
- unsupportedMediaPolicy: validator.string().optional(),
53
+ unsupportedMediaPolicy: validator.alternatives(validator.string().valid("throw", "fallback-stash", "synthetic-description"), validator.object({
54
+ mode: validator.string().valid("fallback-stash").required(),
55
+ stashKeys: validator.array().items(validator.string().min(1)).required()
56
+ }).unknown(false)).default("throw"),
48
57
  localToolCallParser: validator.any().optional(),
49
58
  onRawGeneration: validator.function().optional(),
50
59
  onPromptAssembled: validator.function().optional(),
@@ -1 +1 @@
1
- {"version":3,"file":"validation.mjs","names":[],"sources":["../../../../src/batteries/llm/gemini_generate_content/validation.ts"],"sourcesContent":["/**\n * Runtime option validation for the native Gemini `generateContent` battery.\n *\n * @module @nhtio/adk/batteries/llm/gemini_generate_content/validation\n */\n\nimport { validator } from '@nhtio/validation'\nimport { E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS } from './exceptions'\nimport type { GeminiGenerateContentAdapterOptions } from './types'\n\n/** Schema for {@link GeminiGenerateContentAdapterOptions}. */\nexport const geminiGenerateContentOptionsSchema = validator.object({\n model: validator.string().min(1).required(),\n apiKey: validator.string().optional(),\n useBearerAuth: validator.boolean().optional(),\n baseURL: validator.string().optional(),\n stream: validator.boolean().optional(),\n maxOutputTokens: validator.number().integer().positive().optional(),\n temperature: validator.number().min(0).max(2).optional(),\n topP: validator.number().min(0).max(1).optional(),\n topK: validator.number().integer().positive().optional(),\n stopSequences: validator.array().items(validator.string()).optional(),\n thinkingConfig: validator\n .object({\n thinkingBudget: validator.number().integer().optional(),\n includeThoughts: validator.boolean().optional(),\n })\n .optional(),\n safetySettings: validator\n .array()\n .items(\n validator.object({\n category: validator.string().required(),\n threshold: validator.string().required(),\n })\n )\n .optional(),\n toolConfig: validator\n .object({\n functionCallingConfig: validator\n .object({\n mode: validator.string().valid('AUTO', 'ANY', 'NONE').required(),\n allowedFunctionNames: validator.array().items(validator.string()).optional(),\n })\n .required(),\n })\n .optional(),\n // `false` opts out of the sentinel entirely and surfaces Gemini's own rejection instead.\n thoughtSignatureSentinel: validator\n .alternatives(validator.string().min(1), validator.boolean().valid(false))\n .optional(),\n timeoutMs: validator.number().integer().positive().optional(),\n retry: validator\n .object({\n maxAttempts: validator.number().integer().positive().optional(),\n baseDelayMs: validator.number().integer().positive().optional(),\n maxDelayMs: validator.number().integer().positive().optional(),\n retriableStatuses: validator.array().items(validator.number()).optional(),\n honorRetryAfter: validator.boolean().optional(),\n })\n .optional(),\n fetch: validator.function().optional(),\n tokenEncoding: validator.any().optional(),\n spoolStore: validator.any().optional(),\n bucketOrder: validator.any().optional(),\n thoughtSurfacing: validator.string().valid('all-self', 'latest-self', 'all').optional(),\n unsupportedMediaPolicy: validator.string().optional(),\n localToolCallParser: validator.any().optional(),\n onRawGeneration: validator.function().optional(),\n onPromptAssembled: validator.function().optional(),\n helpers: validator.object().unknown(true).optional(),\n forgeToolsFilter: validator.function().optional(),\n})\n\n/**\n * Validate and normalise adapter options.\n *\n * @throws {@link E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS} when validation fails.\n */\nexport const validateOptions = (input: unknown): GeminiGenerateContentAdapterOptions => {\n const { error, value } = geminiGenerateContentOptionsSchema.validate(input, {\n allowUnknown: false,\n stripUnknown: false,\n })\n if (error) {\n throw new E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS([\n error.details.map((detail: { message: string }) => detail.message).join(' '),\n ])\n }\n return value as GeminiGenerateContentAdapterOptions\n}\n"],"mappings":";;;;;;;;;AAWA,IAAa,qCAAqC,UAAU,OAAO;CACjE,OAAO,UAAU,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS;CAC1C,QAAQ,UAAU,OAAO,EAAE,SAAS;CACpC,eAAe,UAAU,QAAQ,EAAE,SAAS;CAC5C,SAAS,UAAU,OAAO,EAAE,SAAS;CACrC,QAAQ,UAAU,QAAQ,EAAE,SAAS;CACrC,iBAAiB,UAAU,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS;CAClE,aAAa,UAAU,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,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CAAC,EACA,SAAS;CACZ,OAAO,UAAU,SAAS,EAAE,SAAS;CACrC,eAAe,UAAU,IAAI,EAAE,SAAS;CACxC,YAAY,UAAU,IAAI,EAAE,SAAS;CACrC,aAAa,UAAU,IAAI,EAAE,SAAS;CACtC,kBAAkB,UAAU,OAAO,EAAE,MAAM,YAAY,eAAe,KAAK,EAAE,SAAS;CACtF,wBAAwB,UAAU,OAAO,EAAE,SAAS;CACpD,qBAAqB,UAAU,IAAI,EAAE,SAAS;CAC9C,iBAAiB,UAAU,SAAS,EAAE,SAAS;CAC/C,mBAAmB,UAAU,SAAS,EAAE,SAAS;CACjD,SAAS,UAAU,OAAO,EAAE,QAAQ,IAAI,EAAE,SAAS;CACnD,kBAAkB,UAAU,SAAS,EAAE,SAAS;AAClD,CAAC;;;;;;AAOD,IAAa,mBAAmB,UAAwD;CACtF,MAAM,EAAE,OAAO,UAAU,mCAAmC,SAAS,OAAO;EAC1E,cAAc;EACd,cAAc;CAChB,CAAC;CACD,IAAI,OACF,MAAM,IAAI,0CAA0C,CAClD,MAAM,QAAQ,KAAK,WAAgC,OAAO,OAAO,EAAE,KAAK,GAAG,CAC7E,CAAC;CAEH,OAAO;AACT"}
1
+ {"version":3,"file":"validation.mjs","names":[],"sources":["../../../../src/batteries/llm/gemini_generate_content/validation.ts"],"sourcesContent":["/**\n * Runtime option validation for the native Gemini `generateContent` battery.\n *\n * @module @nhtio/adk/batteries/llm/gemini_generate_content/validation\n */\n\nimport { validator } from '@nhtio/validation'\nimport { TokenEncoding } from '@nhtio/adk/common'\nimport { E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS } from './exceptions'\nimport type { GeminiGenerateContentAdapterOptions } from './types'\n\n/** Schema for {@link GeminiGenerateContentAdapterOptions}. */\nconst tokenEncodingSchema = validator\n .alternatives(\n // Known values are suggestions from the canonical list, not a whitelist: consumers may provide\n // a custom or newer tokenizer name. The field accepts any non-empty string, explicit null, or\n // absent (undefined = \"no token counting\"). `.optional()` preserves the null/undefined\n // disposition required by adk/require-validator-any-required.\n validator\n .string()\n .min(1)\n .description(`Known encodings: ${TokenEncoding.join(', ')}`),\n validator.any().valid(null).optional()\n )\n .default(null)\n\n/** Schema for {@link GeminiGenerateContentAdapterOptions}. */\nexport const geminiGenerateContentOptionsSchema = validator.object({\n model: validator.string().min(1).required(),\n apiKey: validator.string().optional(),\n useBearerAuth: validator.boolean().optional(),\n baseURL: validator.string().optional(),\n stream: validator.boolean().optional(),\n contextWindow: validator.number().integer().min(1).optional(),\n autoAck: validator.boolean().default(true),\n maxOutputTokens: validator.number().integer().positive().optional(),\n temperature: validator.number().min(0).max(2).optional(),\n topP: validator.number().min(0).max(1).optional(),\n topK: validator.number().integer().positive().optional(),\n stopSequences: validator.array().items(validator.string()).optional(),\n thinkingConfig: validator\n .object({\n thinkingBudget: validator.number().integer().optional(),\n includeThoughts: validator.boolean().optional(),\n })\n .optional(),\n safetySettings: validator\n .array()\n .items(\n validator.object({\n category: validator.string().required(),\n threshold: validator.string().required(),\n })\n )\n .optional(),\n toolConfig: validator\n .object({\n functionCallingConfig: validator\n .object({\n mode: validator.string().valid('AUTO', 'ANY', 'NONE').required(),\n allowedFunctionNames: validator.array().items(validator.string()).optional(),\n })\n .required(),\n })\n .optional(),\n // `false` opts out of the sentinel entirely and surfaces Gemini's own rejection instead.\n thoughtSignatureSentinel: validator\n .alternatives(validator.string().min(1), validator.boolean().valid(false))\n .optional(),\n timeoutMs: validator.number().integer().positive().optional(),\n retry: validator\n .object({\n maxAttempts: validator.number().integer().positive().optional(),\n baseDelayMs: validator.number().integer().positive().optional(),\n maxDelayMs: validator.number().integer().positive().optional(),\n retriableStatuses: validator.array().items(validator.number()).optional(),\n honorRetryAfter: validator.boolean().optional(),\n })\n .optional(),\n fetch: validator.function().optional(),\n tokenEncoding: tokenEncodingSchema,\n spoolStore: validator.any().optional(),\n bucketOrder: validator.any().optional(),\n thoughtSurfacing: validator.string().valid('all-self', 'latest-self', 'all').optional(),\n unsupportedMediaPolicy: validator\n .alternatives(\n validator.string().valid('throw', 'fallback-stash', 'synthetic-description'),\n validator\n .object({\n mode: validator.string().valid('fallback-stash').required(),\n stashKeys: validator.array().items(validator.string().min(1)).required(),\n })\n .unknown(false)\n )\n .default('throw'),\n localToolCallParser: validator.any().optional(),\n onRawGeneration: validator.function().optional(),\n onPromptAssembled: validator.function().optional(),\n helpers: validator.object().unknown(true).optional(),\n forgeToolsFilter: validator.function().optional(),\n})\n\n/**\n * Validate and normalise adapter options.\n *\n * @throws {@link E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS} when validation fails.\n */\nexport const validateOptions = (input: unknown): GeminiGenerateContentAdapterOptions => {\n const { error, value } = geminiGenerateContentOptionsSchema.validate(input, {\n allowUnknown: false,\n stripUnknown: false,\n })\n if (error) {\n throw new E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS([\n error.details.map((detail: { message: string }) => detail.message).join(' '),\n ])\n }\n return value as GeminiGenerateContentAdapterOptions\n}\n"],"mappings":";;;;;;;;;;;AAYA,IAAM,sBAAsB,UACzB,aAKC,UACG,OAAO,EACP,IAAI,CAAC,EACL,YAAY,oBAAoB,cAAc,KAAK,IAAI,GAAG,GAC7D,UAAU,IAAI,EAAE,MAAM,IAAI,EAAE,SAAS,CACvC,EACC,QAAQ,IAAI;;AAGf,IAAa,qCAAqC,UAAU,OAAO;CACjE,OAAO,UAAU,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS;CAC1C,QAAQ,UAAU,OAAO,EAAE,SAAS;CACpC,eAAe,UAAU,QAAQ,EAAE,SAAS;CAC5C,SAAS,UAAU,OAAO,EAAE,SAAS;CACrC,QAAQ,UAAU,QAAQ,EAAE,SAAS;CACrC,eAAe,UAAU,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,EAAE,SAAS;CAC5D,SAAS,UAAU,QAAQ,EAAE,QAAQ,IAAI;CACzC,iBAAiB,UAAU,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS;CAClE,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S;EACxE,iBAAiB,UAAU,QAAQ,EAAE,SAAS;CAChD,CAAC,EACA,SAAS;CACZ,OAAO,UAAU,SAAS,EAAE,SAAS;CACrC,eAAe;CACf,YAAY,UAAU,IAAI,EAAE,SAAS;CACrC,aAAa,UAAU,IAAI,EAAE,SAAS;CACtC,kBAAkB,UAAU,OAAO,EAAE,MAAM,YAAY,eAAe,KAAK,EAAE,SAAS;CACtF,wBAAwB,UACrB,aACC,UAAU,OAAO,EAAE,MAAM,SAAS,kBAAkB,uBAAuB,GAC3E,UACG,OAAO;EACN,MAAM,UAAU,OAAO,EAAE,MAAM,gBAAgB,EAAE,SAAS;EAC1D,WAAW,UAAU,MAAM,EAAE,MAAM,UAAU,OAAO,EAAE,IAAI,CAAC,CAAC,EAAE,SAAS;CACzE,CAAC,EACA,QAAQ,KAAK,CAClB,EACC,QAAQ,OAAO;CAClB,qBAAqB,UAAU,IAAI,EAAE,SAAS;CAC9C,iBAAiB,UAAU,SAAS,EAAE,SAAS;CAC/C,mBAAmB,UAAU,SAAS,EAAE,SAAS;CACjD,SAAS,UAAU,OAAO,EAAE,QAAQ,IAAI,EAAE,SAAS;CACnD,kBAAkB,UAAU,SAAS,EAAE,SAAS;AAClD,CAAC;;;;;;AAOD,IAAa,mBAAmB,UAAwD;CACtF,MAAM,EAAE,OAAO,UAAU,mCAAmC,SAAS,OAAO;EAC1E,cAAc;EACd,cAAc;CAChB,CAAC;CACD,IAAI,OACF,MAAM,IAAI,0CAA0C,CAClD,MAAM,QAAQ,KAAK,WAAgC,OAAO,OAAO,EAAE,KAAK,GAAG,CAC7E,CAAC;CAEH,OAAO;AACT"}
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("../../chunk-Cek0wNdY.js");
3
- const require_helpers = require("../../helpers-Tvvwpx1M.js");
3
+ const require_helpers = require("../../helpers-CEjjkXso.js");
4
4
  const require_batteries_llm_gemini_generate_content_exceptions = require("./gemini_generate_content/exceptions.cjs");
5
5
  const require_batteries_llm_gemini_generate_content_validation = require("./gemini_generate_content/validation.cjs");
6
6
  const require_batteries_llm_gemini_generate_content_helpers = require("./gemini_generate_content/helpers.cjs");
@@ -1,4 +1,4 @@
1
- import { A as renderMemories, D as renderArtifactHandleBody, F as renderThirdPartyPrivateRetrievables, I as renderThirdPartyPublicRetrievables, L as renderThought, M as renderRetrievableSafetyDirective, N as renderRetrievables, O as renderChatCompletionsSystemPrompt, P as renderStandingInstructions, R as renderTrustedContent, _ as defaultRenderUntrustedContent, a as defaultRenderArtifactHandleBody, c as defaultRenderMemories, d as defaultRenderRetrievables, f as defaultRenderStandingInstructions, g as defaultRenderTrustedContent, h as defaultRenderThought, i as defaultFilterThoughts, j as renderRetrievableHandleBody, k as renderFirstPartyRetrievables, l as defaultRenderRetrievableHandleBody, m as defaultRenderThirdPartyPublicRetrievables, o as defaultRenderChatCompletionsSystemPrompt, p as defaultRenderThirdPartyPrivateRetrievables, r as defaultDescriptionToChatCompletionsJsonSchema, s as defaultRenderFirstPartyRetrievables, u as defaultRenderRetrievableSafetyDirective, x as filterThoughts, y as descriptionToChatCompletionsJsonSchema, z as renderUntrustedContent } from "../../helpers-CDmLDBq5.mjs";
1
+ import { A as renderMemories, D as renderArtifactHandleBody, F as renderThirdPartyPrivateRetrievables, I as renderThirdPartyPublicRetrievables, L as renderThought, M as renderRetrievableSafetyDirective, N as renderRetrievables, O as renderChatCompletionsSystemPrompt, P as renderStandingInstructions, R as renderTrustedContent, _ as defaultRenderUntrustedContent, a as defaultRenderArtifactHandleBody, c as defaultRenderMemories, d as defaultRenderRetrievables, f as defaultRenderStandingInstructions, g as defaultRenderTrustedContent, h as defaultRenderThought, i as defaultFilterThoughts, j as renderRetrievableHandleBody, k as renderFirstPartyRetrievables, l as defaultRenderRetrievableHandleBody, m as defaultRenderThirdPartyPublicRetrievables, o as defaultRenderChatCompletionsSystemPrompt, p as defaultRenderThirdPartyPrivateRetrievables, r as defaultDescriptionToChatCompletionsJsonSchema, s as defaultRenderFirstPartyRetrievables, u as defaultRenderRetrievableSafetyDirective, x as filterThoughts, y as descriptionToChatCompletionsJsonSchema, z as renderUntrustedContent } from "../../helpers-BH7HTtkD.mjs";
2
2
  import { E_GEMINI_INVALID_TOOL_CALL_ARGS, E_GEMINI_MISSING_THOUGHT_SIGNATURE, E_GEMINI_REQUEST_FAILED, E_GEMINI_STREAM_ERROR, E_INVALID_GEMINI_GENERATE_CONTENT_OPTIONS } from "./gemini_generate_content/exceptions.mjs";
3
3
  import { geminiGenerateContentOptionsSchema, validateOptions } from "./gemini_generate_content/validation.mjs";
4
4
  import { DEFAULT_GEMINI_BUCKET_ORDER, buildGeminiRequest, defaultBuildGeminiRequest, defaultExtractGeminiGeneration, defaultMediaToGeminiInlineData, defaultRenderGeminiToolResult, defaultSanitizeGeminiSchema, defaultToolsToGeminiTools, extractGeminiGeneration, mediaToGeminiInlineData, renderGeminiToolResult, sanitizeGeminiSchema, toolsToGeminiTools } from "./gemini_generate_content/helpers.mjs";
@@ -1,15 +1,15 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("../../../chunk-Cek0wNdY.js");
3
3
  const require_guards = require("../../../guards-05Uq3J4M.js");
4
- const require_tokenizable = require("../../../tokenizable-CWW7iSrD.js");
5
- const require_spooled_artifact = require("../../../spooled_artifact-DriNQRj7.js");
6
- const require_thought = require("../../../thought--fRgOwTP.js");
7
- const require_tool_call = require("../../../tool_call-DgqVwL5n.js");
8
- require("../../../common-BV3HGeLj.js");
4
+ const require_tokenizable = require("../../../tokenizable-BMZuGWRd.js");
5
+ const require_spooled_artifact = require("../../../spooled_artifact-BpcesRBv.js");
6
+ const require_thought = require("../../../thought-bS7O9O5H.js");
7
+ const require_tool_call = require("../../../tool_call-Fs_Uh5wQ.js");
8
+ require("../../../common-H44Ik9ou.js");
9
9
  require("../../../guards.cjs");
10
10
  const require_tool_parsers = require("../../../tool_parsers-csSBFWob.js");
11
11
  const require_batteries_storage_in_memory = require("../../storage/in_memory.cjs");
12
- const require_helpers = require("../../../helpers-Tvvwpx1M.js");
12
+ const require_helpers = require("../../../helpers-CEjjkXso.js");
13
13
  const require_gpu_budget = require("../../../gpu_budget-BBIUyLoj.js");
14
14
  const require_lifecycle = require("../../../lifecycle-vYQJ2rmf.js");
15
15
  const require_batteries_llm_chat_common_exceptions = require("../chat_common/exceptions.cjs");