@nhtio/adk 1.20260924.0 → 1.20260928.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (317) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/artifact_methods-Cg0go7Q4.mjs +1 -0
  3. package/artifact_methods-CxeKTocm.cjs +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 +3 -3
  17. package/batteries/dev-tools.mjs +3 -3
  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/llm/anthropic_messages/adapter.cjs +6 -6
  27. package/batteries/llm/anthropic_messages/adapter.mjs +6 -6
  28. package/batteries/llm/anthropic_messages/count_tokens.cjs +1 -1
  29. package/batteries/llm/anthropic_messages/count_tokens.mjs +1 -1
  30. package/batteries/llm/anthropic_messages/helpers.cjs +3 -3
  31. package/batteries/llm/anthropic_messages/helpers.mjs +3 -3
  32. package/batteries/llm/anthropic_messages/validation.cjs +2 -2
  33. package/batteries/llm/anthropic_messages/validation.mjs +2 -2
  34. package/batteries/llm/anthropic_messages.cjs +2 -2
  35. package/batteries/llm/anthropic_messages.mjs +2 -2
  36. package/batteries/llm/bedrock_converse/adapter.cjs +162 -21
  37. package/batteries/llm/bedrock_converse/adapter.cjs.map +1 -1
  38. package/batteries/llm/bedrock_converse/adapter.mjs +162 -21
  39. package/batteries/llm/bedrock_converse/adapter.mjs.map +1 -1
  40. package/batteries/llm/bedrock_converse/helpers.cjs +1 -1
  41. package/batteries/llm/bedrock_converse/helpers.mjs +1 -1
  42. package/batteries/llm/bedrock_converse/validation.cjs +2 -2
  43. package/batteries/llm/bedrock_converse/validation.mjs +2 -2
  44. package/batteries/llm/bedrock_converse.cjs +2 -2
  45. package/batteries/llm/bedrock_converse.mjs +2 -2
  46. package/batteries/llm/claude_code_cli/adapter.cjs +66 -25
  47. package/batteries/llm/claude_code_cli/adapter.cjs.map +1 -1
  48. package/batteries/llm/claude_code_cli/adapter.mjs +66 -25
  49. package/batteries/llm/claude_code_cli/adapter.mjs.map +1 -1
  50. package/batteries/llm/claude_code_cli/helpers.cjs +3 -3
  51. package/batteries/llm/claude_code_cli/helpers.mjs +3 -3
  52. package/batteries/llm/claude_code_cli/line_queue.d.ts +39 -0
  53. package/batteries/llm/claude_code_cli/message_id_state.d.ts +48 -0
  54. package/batteries/llm/claude_code_cli/types.d.ts +76 -0
  55. package/batteries/llm/claude_code_cli/validation.cjs +5 -2
  56. package/batteries/llm/claude_code_cli/validation.cjs.map +1 -1
  57. package/batteries/llm/claude_code_cli/validation.mjs +5 -2
  58. package/batteries/llm/claude_code_cli/validation.mjs.map +1 -1
  59. package/batteries/llm/claude_code_cli/wire.cjs.map +1 -1
  60. package/batteries/llm/claude_code_cli/wire.d.ts +45 -1
  61. package/batteries/llm/claude_code_cli/wire.mjs.map +1 -1
  62. package/batteries/llm/claude_code_cli/wrapper.d.ts +5 -4
  63. package/batteries/llm/claude_code_cli.cjs +2 -2
  64. package/batteries/llm/claude_code_cli.mjs +2 -2
  65. package/batteries/llm/gemini_generate_content/adapter.cjs +160 -19
  66. package/batteries/llm/gemini_generate_content/adapter.cjs.map +1 -1
  67. package/batteries/llm/gemini_generate_content/adapter.mjs +160 -19
  68. package/batteries/llm/gemini_generate_content/adapter.mjs.map +1 -1
  69. package/batteries/llm/gemini_generate_content/helpers.cjs +1 -1
  70. package/batteries/llm/gemini_generate_content/helpers.mjs +1 -1
  71. package/batteries/llm/gemini_generate_content/validation.cjs +2 -2
  72. package/batteries/llm/gemini_generate_content/validation.mjs +2 -2
  73. package/batteries/llm/gemini_generate_content.cjs +1 -1
  74. package/batteries/llm/gemini_generate_content.mjs +1 -1
  75. package/batteries/llm/litert_lm/adapter.cjs +6 -6
  76. package/batteries/llm/litert_lm/adapter.mjs +6 -6
  77. package/batteries/llm/litert_lm/helpers.cjs +3 -3
  78. package/batteries/llm/litert_lm/helpers.mjs +3 -3
  79. package/batteries/llm/litert_lm/validation.cjs +2 -2
  80. package/batteries/llm/litert_lm/validation.mjs +2 -2
  81. package/batteries/llm/litert_lm.cjs +1 -1
  82. package/batteries/llm/litert_lm.mjs +1 -1
  83. package/batteries/llm/ollama/adapter.cjs +6 -6
  84. package/batteries/llm/ollama/adapter.mjs +6 -6
  85. package/batteries/llm/ollama/helpers.cjs +4 -4
  86. package/batteries/llm/ollama/helpers.mjs +4 -4
  87. package/batteries/llm/ollama/validation.cjs +2 -2
  88. package/batteries/llm/ollama/validation.mjs +2 -2
  89. package/batteries/llm/ollama.cjs +2 -2
  90. package/batteries/llm/ollama.mjs +2 -2
  91. package/batteries/llm/openai_chat_completions/adapter.cjs +6 -6
  92. package/batteries/llm/openai_chat_completions/adapter.mjs +6 -6
  93. package/batteries/llm/openai_chat_completions/helpers.cjs +4 -4
  94. package/batteries/llm/openai_chat_completions/helpers.mjs +4 -4
  95. package/batteries/llm/openai_chat_completions/validation.cjs +2 -2
  96. package/batteries/llm/openai_chat_completions/validation.mjs +2 -2
  97. package/batteries/llm/openai_chat_completions.cjs +2 -2
  98. package/batteries/llm/openai_chat_completions.mjs +2 -2
  99. package/batteries/llm/openai_responses/adapter.cjs +6 -6
  100. package/batteries/llm/openai_responses/adapter.mjs +6 -6
  101. package/batteries/llm/openai_responses/helpers.cjs +3 -3
  102. package/batteries/llm/openai_responses/helpers.mjs +3 -3
  103. package/batteries/llm/openai_responses/validation.cjs +2 -2
  104. package/batteries/llm/openai_responses/validation.mjs +2 -2
  105. package/batteries/llm/openai_responses.cjs +2 -2
  106. package/batteries/llm/openai_responses.mjs +2 -2
  107. package/batteries/llm/transformers_js/adapter.cjs +6 -6
  108. package/batteries/llm/transformers_js/adapter.mjs +6 -6
  109. package/batteries/llm/transformers_js/helpers.cjs +3 -3
  110. package/batteries/llm/transformers_js/helpers.mjs +3 -3
  111. package/batteries/llm/transformers_js/validation.cjs +2 -2
  112. package/batteries/llm/transformers_js/validation.mjs +2 -2
  113. package/batteries/llm/transformers_js.cjs +1 -1
  114. package/batteries/llm/transformers_js.mjs +1 -1
  115. package/batteries/llm/webllm_chat_completions/adapter.cjs +6 -6
  116. package/batteries/llm/webllm_chat_completions/adapter.mjs +6 -6
  117. package/batteries/llm/webllm_chat_completions/helpers.cjs +1 -1
  118. package/batteries/llm/webllm_chat_completions/helpers.mjs +1 -1
  119. package/batteries/llm/webllm_chat_completions/validation.cjs +2 -2
  120. package/batteries/llm/webllm_chat_completions/validation.mjs +2 -2
  121. package/batteries/llm/webllm_chat_completions.cjs +2 -2
  122. package/batteries/llm/webllm_chat_completions.mjs +2 -2
  123. package/batteries/llm.cjs +2 -2
  124. package/batteries/llm.mjs +2 -2
  125. package/batteries/media/forge.cjs +4 -4
  126. package/batteries/media/forge.mjs +4 -4
  127. package/batteries/media/lint.cjs +1 -1
  128. package/batteries/media/lint.mjs +1 -1
  129. package/batteries/orchestration/dispatch_reasoner.cjs +4 -4
  130. package/batteries/orchestration/dispatch_reasoner.mjs +4 -4
  131. package/batteries/orchestration/executor.cjs +2 -2
  132. package/batteries/orchestration/executor.mjs +2 -2
  133. package/batteries/orchestration/forge.cjs +4 -4
  134. package/batteries/orchestration/forge.mjs +4 -4
  135. package/batteries/orchestration/validation.cjs +2 -2
  136. package/batteries/orchestration/validation.mjs +2 -2
  137. package/batteries/orchestration.cjs +4 -4
  138. package/batteries/orchestration.mjs +4 -4
  139. package/batteries/sandbox/js.cjs +1 -1
  140. package/batteries/sandbox/js.mjs +1 -1
  141. package/batteries/sandbox/tools.cjs +1 -1
  142. package/batteries/sandbox/tools.mjs +1 -1
  143. package/batteries/sandbox.cjs +3 -3
  144. package/batteries/sandbox.mjs +3 -3
  145. package/batteries/skills.cjs +9 -9
  146. package/batteries/skills.mjs +9 -9
  147. package/batteries/tools/_shared.cjs +1 -1
  148. package/batteries/tools/_shared.mjs +1 -1
  149. package/batteries/tools/color.cjs +2 -2
  150. package/batteries/tools/color.mjs +2 -2
  151. package/batteries/tools/comparison.cjs +2 -2
  152. package/batteries/tools/comparison.mjs +2 -2
  153. package/batteries/tools/data_structure.cjs +2 -2
  154. package/batteries/tools/data_structure.mjs +2 -2
  155. package/batteries/tools/datetime_extended.cjs +3 -3
  156. package/batteries/tools/datetime_extended.mjs +3 -3
  157. package/batteries/tools/datetime_math.cjs +3 -3
  158. package/batteries/tools/datetime_math.mjs +3 -3
  159. package/batteries/tools/encoding.cjs +2 -2
  160. package/batteries/tools/encoding.mjs +2 -2
  161. package/batteries/tools/formatting.cjs +2 -2
  162. package/batteries/tools/formatting.mjs +2 -2
  163. package/batteries/tools/geo_basics.cjs +2 -2
  164. package/batteries/tools/geo_basics.mjs +2 -2
  165. package/batteries/tools/math.cjs +2 -2
  166. package/batteries/tools/math.mjs +2 -2
  167. package/batteries/tools/memory.cjs +5 -5
  168. package/batteries/tools/memory.mjs +5 -5
  169. package/batteries/tools/parsing.cjs +3 -3
  170. package/batteries/tools/parsing.mjs +3 -3
  171. package/batteries/tools/retrievables.cjs +5 -5
  172. package/batteries/tools/retrievables.mjs +5 -5
  173. package/batteries/tools/scrapper.cjs +1 -1
  174. package/batteries/tools/scrapper.mjs +1 -1
  175. package/batteries/tools/searxng.cjs +1 -1
  176. package/batteries/tools/searxng.mjs +1 -1
  177. package/batteries/tools/standing_instructions.cjs +3 -3
  178. package/batteries/tools/standing_instructions.mjs +3 -3
  179. package/batteries/tools/statistics.cjs +3 -3
  180. package/batteries/tools/statistics.mjs +3 -3
  181. package/batteries/tools/string_processing.cjs +2 -2
  182. package/batteries/tools/string_processing.mjs +2 -2
  183. package/batteries/tools/structured_data.cjs +2 -2
  184. package/batteries/tools/structured_data.mjs +2 -2
  185. package/batteries/tools/text_analysis.cjs +3 -3
  186. package/batteries/tools/text_analysis.mjs +3 -3
  187. package/batteries/tools/text_comparison.cjs +2 -2
  188. package/batteries/tools/text_comparison.mjs +2 -2
  189. package/batteries/tools/time.cjs +3 -3
  190. package/batteries/tools/time.mjs +3 -3
  191. package/batteries/tools/unit_conversion.cjs +2 -2
  192. package/batteries/tools/unit_conversion.mjs +2 -2
  193. package/batteries/tools.cjs +2 -2
  194. package/batteries/tools.mjs +2 -2
  195. package/batteries/validation.cjs +4 -4
  196. package/batteries/validation.mjs +4 -4
  197. package/batteries/vector/conformance.cjs +59 -0
  198. package/batteries/vector/conformance.cjs.map +1 -1
  199. package/batteries/vector/conformance.mjs +59 -0
  200. package/batteries/vector/conformance.mjs.map +1 -1
  201. package/batteries/vector/lancedb.cjs +1 -1
  202. package/batteries/vector/lancedb.cjs.map +1 -1
  203. package/batteries/vector/lancedb.mjs +1 -1
  204. package/batteries/vector/lancedb.mjs.map +1 -1
  205. package/batteries/vector/retrievable.cjs +1 -1
  206. package/batteries/vector/retrievable.mjs +1 -1
  207. package/batteries/vector/sqlite_vec/index.d.ts +1 -1
  208. package/batteries/vector/sqlite_vec.cjs +19 -30
  209. package/batteries/vector/sqlite_vec.cjs.map +1 -1
  210. package/batteries/vector/sqlite_vec.mjs +20 -31
  211. package/batteries/vector/sqlite_vec.mjs.map +1 -1
  212. package/batteries.cjs +4 -4
  213. package/batteries.mjs +4 -4
  214. package/{chat_common-B7fvGTKv.cjs → chat_common-CNayzS1V.cjs} +2 -2
  215. package/{chat_common-B7fvGTKv.cjs.map → chat_common-CNayzS1V.cjs.map} +1 -1
  216. package/{chat_common-CeoHwSsz.mjs → chat_common-DKw8FDol.mjs} +2 -2
  217. package/{chat_common-CeoHwSsz.mjs.map → chat_common-DKw8FDol.mjs.map} +1 -1
  218. package/claude-code-cli-wrapper.cjs +104 -22
  219. package/claude-code-cli-wrapper.cjs.map +1 -1
  220. package/claude-code-cli-wrapper.mjs +104 -22
  221. package/claude-code-cli-wrapper.mjs.map +1 -1
  222. package/{common-7gCR3zQu.cjs → common-CqetsItm.cjs} +7 -7
  223. package/{common-7gCR3zQu.cjs.map → common-CqetsItm.cjs.map} +1 -1
  224. package/{common-B5maOoF_.mjs → common-oI1niK9Z.mjs} +7 -7
  225. package/{common-B5maOoF_.mjs.map → common-oI1niK9Z.mjs.map} +1 -1
  226. package/common.cjs +7 -7
  227. package/common.mjs +7 -7
  228. package/{dispatch_runner-DO7jo_gl.mjs → dispatch_runner-BZDXUe0G.mjs} +5 -5
  229. package/{dispatch_runner-DO7jo_gl.mjs.map → dispatch_runner-BZDXUe0G.mjs.map} +1 -1
  230. package/{dispatch_runner-FlriTyoq.cjs → dispatch_runner-DDUxXJC3.cjs} +5 -5
  231. package/{dispatch_runner-FlriTyoq.cjs.map → dispatch_runner-DDUxXJC3.cjs.map} +1 -1
  232. package/dispatch_runner.cjs +1 -1
  233. package/dispatch_runner.mjs +1 -1
  234. package/{ecmascript-bgwVyZG1.mjs → ecmascript-B9Z2C24U.mjs} +3 -3
  235. package/{ecmascript-bgwVyZG1.mjs.map → ecmascript-B9Z2C24U.mjs.map} +1 -1
  236. package/{ecmascript-BydSB03Y.cjs → ecmascript-BYfmjg7y.cjs} +3 -3
  237. package/{ecmascript-BydSB03Y.cjs.map → ecmascript-BYfmjg7y.cjs.map} +1 -1
  238. package/eslint/rules.cjs +1 -1
  239. package/eslint/rules.mjs +1 -1
  240. package/eslint.cjs +2 -2
  241. package/eslint.mjs +2 -2
  242. package/exceptions.cjs +1 -1
  243. package/exceptions.mjs +1 -1
  244. package/forge.cjs +2 -2
  245. package/forge.mjs +2 -2
  246. package/guards.cjs +7 -7
  247. package/guards.mjs +7 -7
  248. package/{helpers-Dcp4CrOz.cjs → helpers-DPlh_7Bn.cjs} +3 -3
  249. package/{helpers-Dcp4CrOz.cjs.map → helpers-DPlh_7Bn.cjs.map} +1 -1
  250. package/{helpers-C1T0DV8Q.mjs → helpers-mbn_EsDV.mjs} +3 -3
  251. package/{helpers-C1T0DV8Q.mjs.map → helpers-mbn_EsDV.mjs.map} +1 -1
  252. package/index.cjs +11 -11
  253. package/index.mjs +11 -11
  254. package/mcp/adk-docs-corpus.json +2 -2
  255. package/package.json +425 -425
  256. package/{retrievable-BBwiACtw.cjs → retrievable-Bq-O3k6r.cjs} +3 -3
  257. package/{retrievable-BBwiACtw.cjs.map → retrievable-Bq-O3k6r.cjs.map} +1 -1
  258. package/{retrievable-CrGKx4sc.mjs → retrievable-CXTAUuuv.mjs} +3 -3
  259. package/{retrievable-CrGKx4sc.mjs.map → retrievable-CXTAUuuv.mjs.map} +1 -1
  260. package/{scrapper-BibKj8qE.cjs → scrapper-B8xG9lTD.cjs} +4 -4
  261. package/{scrapper-BibKj8qE.cjs.map → scrapper-B8xG9lTD.cjs.map} +1 -1
  262. package/{scrapper-_JzgbLG5.mjs → scrapper-DiQ5FfDL.mjs} +4 -4
  263. package/{scrapper-_JzgbLG5.mjs.map → scrapper-DiQ5FfDL.mjs.map} +1 -1
  264. package/{searxng-D-nA2gEI.mjs → searxng-BFTJ6rTE.mjs} +4 -4
  265. package/{searxng-D-nA2gEI.mjs.map → searxng-BFTJ6rTE.mjs.map} +1 -1
  266. package/{searxng-C6xrLW-v.cjs → searxng-EJhWRnIE.cjs} +4 -4
  267. package/{searxng-C6xrLW-v.cjs.map → searxng-EJhWRnIE.cjs.map} +1 -1
  268. package/server.json +2 -2
  269. package/skills/adk-assembly/SKILL.md +2 -2
  270. package/{spooled_artifact-BLgbGT8b.cjs → spooled_artifact---DmicFW.cjs} +384 -384
  271. package/spooled_artifact---DmicFW.cjs.map +1 -0
  272. package/{spooled_artifact-BkOe4-j-.mjs → spooled_artifact-Bw_7swIp.mjs} +385 -385
  273. package/spooled_artifact-Bw_7swIp.mjs.map +1 -0
  274. package/spooled_artifact.cjs +2 -2
  275. package/spooled_artifact.mjs +2 -2
  276. package/{spooled_markdown_artifact-8zdejfcJ.cjs → spooled_markdown_artifact-Rjzj-kyh.cjs} +3 -3
  277. package/{spooled_markdown_artifact-8zdejfcJ.cjs.map → spooled_markdown_artifact-Rjzj-kyh.cjs.map} +1 -1
  278. package/{spooled_markdown_artifact-Dnl-lCGv.mjs → spooled_markdown_artifact-vd6eNtIP.mjs} +3 -3
  279. package/{spooled_markdown_artifact-Dnl-lCGv.mjs.map → spooled_markdown_artifact-vd6eNtIP.mjs.map} +1 -1
  280. package/{thought-BrQt6HAb.mjs → thought-CxSaF6Xf.mjs} +3 -3
  281. package/{thought-BrQt6HAb.mjs.map → thought-CxSaF6Xf.mjs.map} +1 -1
  282. package/{thought-COeZTQ-B.cjs → thought-Dp3sMWW6.cjs} +3 -3
  283. package/{thought-COeZTQ-B.cjs.map → thought-Dp3sMWW6.cjs.map} +1 -1
  284. package/{tokenizable-DDIdXbJN.cjs → tokenizable-BcodRtoW.cjs} +29 -29
  285. package/{tokenizable-DDIdXbJN.cjs.map → tokenizable-BcodRtoW.cjs.map} +1 -1
  286. package/{tokenizable-xPXj1AQX.mjs → tokenizable-VB4Av8GF.mjs} +30 -30
  287. package/{tokenizable-xPXj1AQX.mjs.map → tokenizable-VB4Av8GF.mjs.map} +1 -1
  288. package/{tool_call-JbjeUpRK.cjs → tool_call-B9px4W9k.cjs} +4 -4
  289. package/{tool_call-JbjeUpRK.cjs.map → tool_call-B9px4W9k.cjs.map} +1 -1
  290. package/{tool_call-8crmZsO8.mjs → tool_call-Cfaj-6zK.mjs} +4 -4
  291. package/{tool_call-8crmZsO8.mjs.map → tool_call-Cfaj-6zK.mjs.map} +1 -1
  292. package/{tools-BC4NJqZD.mjs → tools-D0MBDh2R.mjs} +6 -6
  293. package/{tools-BC4NJqZD.mjs.map → tools-D0MBDh2R.mjs.map} +1 -1
  294. package/{tools-D4mdzi0a.cjs → tools-aNbi6JyA.cjs} +6 -6
  295. package/{tools-D4mdzi0a.cjs.map → tools-aNbi6JyA.cjs.map} +1 -1
  296. package/{toon-BA9Q7NHG.mjs → toon-BSTQnHed.mjs} +5 -5
  297. package/{toon-BA9Q7NHG.mjs.map → toon-BSTQnHed.mjs.map} +1 -1
  298. package/{toon-b-0pFKZ8.cjs → toon-DmLwZ6H1.cjs} +5 -5
  299. package/{toon-b-0pFKZ8.cjs.map → toon-DmLwZ6H1.cjs.map} +1 -1
  300. package/{turn_runner-BmVXcBZ2.mjs → turn_runner-BHHD6h77.mjs} +5 -5
  301. package/{turn_runner-BmVXcBZ2.mjs.map → turn_runner-BHHD6h77.mjs.map} +1 -1
  302. package/{turn_runner-DX-3s3ih.cjs → turn_runner-Dj7JsUTQ.cjs} +5 -5
  303. package/{turn_runner-DX-3s3ih.cjs.map → turn_runner-Dj7JsUTQ.cjs.map} +1 -1
  304. package/turn_runner.cjs +1 -1
  305. package/turn_runner.mjs +1 -1
  306. package/{xml-B1JIGLpU.mjs → xml-CYseDztH.mjs} +5 -5
  307. package/{xml-B1JIGLpU.mjs.map → xml-CYseDztH.mjs.map} +1 -1
  308. package/{xml-fvwTsoRv.cjs → xml-zJul8jMQ.cjs} +5 -5
  309. package/{xml-fvwTsoRv.cjs.map → xml-zJul8jMQ.cjs.map} +1 -1
  310. package/{yaml-1mP4uxdf.mjs → yaml-BPBoiOjx.mjs} +5 -5
  311. package/{yaml-1mP4uxdf.mjs.map → yaml-BPBoiOjx.mjs.map} +1 -1
  312. package/{yaml-DPUTumla.cjs → yaml-D0PzoRAr.cjs} +5 -5
  313. package/{yaml-DPUTumla.cjs.map → yaml-D0PzoRAr.cjs.map} +1 -1
  314. package/artifact_methods-7KatxCSd.cjs +0 -1
  315. package/artifact_methods-q52ETLwI.mjs +0 -1
  316. package/spooled_artifact-BLgbGT8b.cjs.map +0 -1
  317. package/spooled_artifact-BkOe4-j-.mjs.map +0 -1
@@ -1,308 +1,143 @@
1
1
  import { a as passesSchema, i as asyncValidateOrThrow, o as validateOrThrow, r as ValidationException } from "./exceptions-DRYLe-J4.mjs";
2
2
  import { n as isInstanceOf, r as isObject, t as isError } from "./guards-BEpY7lBI.mjs";
3
- import { C as E_INVALID_TOOL_ARGS, F as E_READER_NOT_DESCRIBABLE, L as E_TOOL_ALREADY_REGISTERED, M as E_NO_READER_RESOLVER, R as E_TOOL_DOWNSTREAM_ERROR, c as E_ARTIFACT_ID_COLLISION, h as E_INVALID_INITIAL_REGISTRY_VALUE, j as E_NOT_A_SPOOL_READER, n as TokenEncoding, o as DECODE_METHOD, r as Tokenizable, s as ENCODE_METHOD, y as E_INVALID_INITIAL_TOOL_VALUE } from "./tokenizable-xPXj1AQX.mjs";
4
- import { DateTime } from "luxon";
5
- import { sha256 } from "js-sha256";
3
+ import { A as E_NO_READER_RESOLVER, B as ENCODE_METHOD, F as E_TOOL_ALREADY_REGISTERED, I as E_TOOL_DOWNSTREAM_ERROR, N as E_READER_NOT_DESCRIBABLE, _ as E_INVALID_INITIAL_TOOL_VALUE, k as E_NOT_A_SPOOL_READER, n as TokenEncoding, o as E_ARTIFACT_ID_COLLISION, p as E_INVALID_INITIAL_REGISTRY_VALUE, r as Tokenizable, x as E_INVALID_TOOL_ARGS, z as DECODE_METHOD } from "./tokenizable-VB4Av8GF.mjs";
6
4
  import { decode, encode, validator } from "@nhtio/validation";
7
5
  import { dset } from "dset";
8
6
  import { klona } from "klona";
9
7
  import delve from "dlv";
10
- //#region src/lib/classes/tool_registry.ts
8
+ import { DateTime } from "luxon";
9
+ import { sha256 } from "js-sha256";
10
+ //#region src/lib/classes/registry.ts
11
11
  /**
12
- * A mutable, turn-scoped collection of {@link @nhtio/adk!Tool} instances.
12
+ * A controlled-mutation key-value store with dot-path access and deep-clone isolation.
13
13
  *
14
14
  * @remarks
15
- * Each `TurnRunner.run()` call constructs a fresh `ToolRegistry` from the runner's configured
16
- * baseline tools, so middleware edits are isolated to the current turn and cannot bleed across
17
- * concurrent or subsequent turns.
18
- *
19
- * `Tool` instances are immutable, so `all()` returns a fresh array without deep-cloning.
20
- *
21
- * `register()` throws {@link @nhtio/adk!E_TOOL_ALREADY_REGISTERED} if a tool with the same name is already
22
- * present — pass `overwrite: true` to replace it explicitly.
15
+ * The registry enforces a safe read/write contract: callers never hold a live reference into
16
+ * the internal store. Every value that enters (`set`) or leaves (`get`, `all`) is deep-cloned
17
+ * via `klona`, so mutations to a retrieved value cannot affect stored state and vice versa.
23
18
  *
24
- * Tools can be **hidden** — registered and callable, but excluded from the default tool list
25
- * rendered to the model. This is useful for discovery patterns where an agent has a tool that
26
- * enumerates available tools, and the model picks one to call by name in a subsequent iteration.
27
- * Hidden state is a property of the registry, not the tool: the same tool can be visible in one
28
- * registry and hidden in another. See {@link hide}, {@link visible}, {@link hidden}.
19
+ * Keys are dot-delimited paths (e.g. `"user.profile.name"`), resolved via `dlv` for reads and
20
+ * `dset` for writes; intermediate objects are created automatically on write.
29
21
  */
30
- var ToolRegistry = class ToolRegistry {
31
- #tools;
32
- #hidden;
33
- /**
34
- * Returns `true` if `value` is a {@link ToolRegistry} instance.
35
- *
36
- * @param value - The value to test.
37
- * @returns `true` when `value` is a {@link ToolRegistry} instance.
38
- */
39
- static isToolRegistry(value) {
40
- return isInstanceOf(value, "ToolRegistry", ToolRegistry);
41
- }
42
- /**
43
- * @param tools - Optional initial tools. Insertion order is preserved. Duplicate names throw
44
- * {@link @nhtio/adk!E_TOOL_ALREADY_REGISTERED} — ensure each tool has a unique name.
45
- * @throws {@link @nhtio/adk!E_TOOL_ALREADY_REGISTERED} when two tools in `tools` share a name.
46
- */
47
- constructor(tools) {
48
- this.#tools = /* @__PURE__ */ new Map();
49
- this.#hidden = /* @__PURE__ */ new Set();
50
- for (const tool of tools ?? []) this.register(tool);
51
- }
22
+ var Registry = class Registry {
23
+ #store;
52
24
  /**
53
- * Adds a tool to the registry.
54
- *
55
- * @param tool - The tool to register.
56
- * @param overwrite - When `true`, silently replaces an existing tool with the same name.
57
- * Defaults to `false`.
58
- * @throws {@link @nhtio/adk!E_TOOL_ALREADY_REGISTERED} when a tool with the same name is already registered
59
- * and `overwrite` is not `true`.
25
+ * @param initial - Optional plain object to seed the registry. Deep-cloned on construction.
26
+ * @throws {@link @nhtio/adk!E_INVALID_INITIAL_REGISTRY_VALUE} when `initial` is defined but not a plain object.
60
27
  */
61
- register(tool, overwrite) {
62
- if (this.#tools.has(tool.name) && !overwrite) throw new E_TOOL_ALREADY_REGISTERED();
63
- this.#tools.set(tool.name, tool);
28
+ constructor(initial) {
29
+ if ("undefined" !== typeof initial && !isObject(initial)) throw new E_INVALID_INITIAL_REGISTRY_VALUE();
30
+ this.#store = initial ? klona(initial) : {};
64
31
  }
65
32
  /**
66
- * Removes the tool with the given name from the registry.
33
+ * Returns `true` if `value` is a {@link Registry} instance.
67
34
  *
68
35
  * @remarks
69
- * Also removes the name from the hidden set if present. No-ops if no tool with that name is
70
- * registered.
71
- *
72
- * @param name - The name of the tool to remove.
73
- */
74
- unregister(name) {
75
- this.#tools.delete(name);
76
- this.#hidden.delete(name);
77
- }
78
- /**
79
- * Returns the tool registered under `name`, or `undefined` if not present.
80
- *
81
- * @param name - The tool name to look up.
82
- */
83
- get(name) {
84
- return this.#tools.get(name);
85
- }
86
- /**
87
- * Returns `true` if a tool with the given name is registered.
36
+ * Uses {@link @nhtio/adk!isInstanceOf} for cross-realm safety.
88
37
  *
89
- * @param name - The tool name to test.
38
+ * @param value - The value to test.
39
+ * @returns `true` when `value` is a {@link Registry} instance.
90
40
  */
91
- has(name) {
92
- return this.#tools.has(name);
41
+ static isRegistry(value) {
42
+ return isInstanceOf(value, "Registry", Registry);
93
43
  }
94
44
  /**
95
- * Returns a fresh array of all registered tools in insertion order.
45
+ * Retrieves the value at `key`, returning `defaultValue` if the path is absent.
96
46
  *
97
47
  * @remarks
98
- * Includes both visible and hidden tools. Use {@link visible} to get only non-hidden tools, or
99
- * {@link hidden} to get only hidden tools.
48
+ * The returned value is a deep clone — mutating it will not affect the stored state.
100
49
  *
101
- * Since {@link @nhtio/adk!Tool} instances are immutable, no deep-cloning is needed.
50
+ * @typeParam T - Expected type of the value at `key`.
51
+ * @param key - Dot-delimited path into the store (e.g. `"user.name"`).
52
+ * @param defaultValue - Fallback returned when the path resolves to `undefined`.
53
+ * @returns A deep clone of the stored value cast to `T`, or `defaultValue` when the path is absent.
102
54
  */
103
- all() {
104
- return Array.from(this.#tools.values());
55
+ get(key, defaultValue) {
56
+ const value = delve(klona(this.#store), key);
57
+ return "undefined" === typeof value ? defaultValue : value;
105
58
  }
106
59
  /**
107
- * Returns a fresh array of registered tools that are **not** hidden, in insertion order.
60
+ * Sets the value at `key`, creating intermediate objects as needed.
108
61
  *
109
62
  * @remarks
110
- * This is the accessor LLM batteries should use when building the tool list for the model.
111
- * Hidden tools are still callable (they resolve via {@link get}) but are excluded from the
112
- * rendered tool definitions.
113
- */
114
- visible() {
115
- return this.all().filter((t) => !this.#hidden.has(t.name));
116
- }
117
- /**
118
- * Returns a fresh array of registered tools that **are** hidden, in insertion order.
63
+ * The stored value is isolated from the caller — mutating `value` after this call will not
64
+ * affect what is held in the registry.
119
65
  *
120
- * @remarks
121
- * The converse of {@link visible}. Useful for discovery tools that enumerate all available
122
- * tools, and for propagating hidden state across {@link merge}.
66
+ * @param key - Dot-delimited path into the store (e.g. `"user.name"`).
67
+ * @param value - Value to store at the path.
123
68
  */
124
- hidden() {
125
- return this.all().filter((t) => this.#hidden.has(t.name));
69
+ set(key, value) {
70
+ dset(this.#store, key, value);
126
71
  }
127
72
  /**
128
- * Marks one or more registered tools as hidden.
73
+ * Returns `true` if the registry has a value at `key`, `false` otherwise.
129
74
  *
130
75
  * @remarks
131
- * Hidden tools remain registered and callable via {@link get}, but are excluded from
132
- * {@link visible} (and therefore from the LLM tool list). No-ops for any name that is not
133
- * currently registered — the end result (the tool is not visible) matches the intent.
76
+ * A key resolving to `undefined` is treated as absent — same convention as {@link Registry.get}'s
77
+ * `defaultValue` fallback. No clone is performed; this is a pure existence check.
134
78
  *
135
- * @param names - One or more tool names to hide.
79
+ * @param key - Dot-delimited path into the store (e.g. `"user.name"`).
80
+ * @returns `true` when the path resolves to a value other than `undefined`.
136
81
  */
137
- hide(...names) {
138
- for (const name of names) this.#hidden.add(name);
82
+ has(key) {
83
+ return "undefined" !== typeof delve(this.#store, key);
139
84
  }
140
85
  /**
141
- * Unmarks one or more tools as hidden, making them visible again.
86
+ * Returns all leaf dot-paths present in the registry.
142
87
  *
143
88
  * @remarks
144
- * No-ops for any name that is not currently hidden.
89
+ * The store is deep-cloned before traversal. Plain objects are walked recursively with path
90
+ * segments joined by dots; arrays, primitives, `null`, and class instances are treated as leaves.
145
91
  *
146
- * @param names - One or more tool names to unhide.
92
+ * @returns A string array of dot-delimited paths to leaf values in the store.
147
93
  */
148
- unhide(...names) {
149
- for (const name of names) this.#hidden.delete(name);
94
+ keys() {
95
+ const store = klona(this.#store);
96
+ const keys = [];
97
+ const isPlainRecord = (value) => {
98
+ if (!isObject(value)) return false;
99
+ const prototype = Object.getPrototypeOf(value);
100
+ return prototype === Object.prototype || prototype === null;
101
+ };
102
+ const walk = (value, segments) => {
103
+ if (!isPlainRecord(value)) {
104
+ if (segments.length > 0) keys.push(segments.join("."));
105
+ return;
106
+ }
107
+ for (const [segment, child] of Object.entries(value)) walk(child, [...segments, segment]);
108
+ };
109
+ walk(store, []);
110
+ return keys;
150
111
  }
151
112
  /**
152
- * Replaces the entire hidden set with the given tool names.
153
- *
154
- * @remarks
155
- * Any previously hidden tool not in `names` becomes visible. Names that are not registered are
156
- * silently ignored — they are added to the set but have no effect until a tool with that name
157
- * is registered.
113
+ * Returns a deep clone of the entire store contents.
158
114
  *
159
- * @param names - The complete set of tool names to hide.
160
- */
161
- setHidden(...names) {
162
- this.#hidden = new Set(names);
163
- }
164
- /**
165
- * Unhides every tool in the registry.
115
+ * @returns A plain object snapshot of all stored key-value pairs.
166
116
  */
167
- clearHidden() {
168
- this.#hidden.clear();
117
+ all() {
118
+ return klona(this.#store);
169
119
  }
170
120
  /**
171
- * Removes every tool whose {@link @nhtio/adk!Tool.ephemeral} flag is `true`.
121
+ * Serialise this Registry into an `@nhtio/encoder` snapshot.
172
122
  *
173
123
  * @remarks
174
- * Also removes pruned tool names from the hidden set. Synchronous and idempotent — calling it
175
- * twice in a row is a no-op the second time. The canonical caller is
176
- * {@link ToolRegistry.bindContext}, which schedules this method to run at
177
- * {@link @nhtio/adk!DispatchContext.ack}. Non-ephemeral tools are left untouched.
124
+ * The snapshot is a deep clone of the store ({@link Registry.all}). Leaf values that are themselves
125
+ * registered encodable instances round-trip; anything the encoder cannot serialise throws at encode
126
+ * time (standard encoder behaviour). Round-trips via {@link Registry.[DECODE_METHOD]}.
127
+ *
128
+ * @returns A deep-cloned plain-object snapshot of the store.
178
129
  */
179
- pruneEphemeral() {
180
- for (const [name, tool] of this.#tools) if (tool.ephemeral) {
181
- this.#tools.delete(name);
182
- this.#hidden.delete(name);
183
- }
130
+ [ENCODE_METHOD]() {
131
+ return this.all();
184
132
  }
185
133
  /**
186
- * Binds this registry to a {@link @nhtio/adk!DispatchContext} so that {@link pruneEphemeral} runs
187
- * automatically when the context is acked.
188
- *
189
- * @remarks
190
- * The handler does NOT fire on {@link @nhtio/adk!DispatchContext.nack} — failed executor runs leave
191
- * any forged tools in place so the consumer can inspect what was registered when debugging the
192
- * failure. Subscriptions are short-lived and die with the context regardless.
193
- *
194
- * ARTIFACT READERS ARE FORGED BY THE CORE. As of the core-forge change, the `DispatchRunner` forges
195
- * artifact-reader tools from prior-turn `SpooledArtifact` results into `ctx.tools` (and calls
196
- * `ctx.tools.bindContext(ctx)`) once per iteration, BEFORE the input pipeline — so a battery executor no
197
- * longer forges or binds; it reads the already-forged `ctx.tools` for both representation (rendering the
198
- * tool declarations) and resolution (looking up an incoming call by name). The lifecycle is unchanged:
199
- * ephemeral readers are still pruned on `ack`, and the core re-forges each iteration (prune-then-forge) so
200
- * the `callId` enum never goes stale.
201
- *
202
- * `bindContext` remains the public seam for a CUSTOM consumer that forges its own ephemeral tools outside
203
- * the core path. If you forge into a long-lived registry yourself, bind it (or prune manually) or the
204
- * ephemeral tools accumulate and later `forgeTools(ctx)` calls see a stale `callId` enum. The pattern for a
205
- * hand-rolled forge is:
206
- *
207
- * ```ts
208
- * // Custom forge (the core already does this for artifact readers on ctx.tools):
209
- * const forged = SpooledArtifact.forgeTools(ctx)
210
- * for (const tool of forged.all()) ctx.tools.register(tool, true)
211
- * ctx.tools.bindContext(ctx) // prune the ephemeral readers when the dispatch acks
212
- * ```
213
- *
214
- * @param ctx - The execution context whose `ack` event should trigger pruning.
215
- * @returns An unsubscribe function — calling it before `ctx.ack()` prevents pruning. Rarely
216
- * useful outside of tests.
134
+ * Reconstruct a {@link Registry} from a {@link Registry.[ENCODE_METHOD]} snapshot.
217
135
  *
218
- * @see {@link @nhtio/adk!SpooledArtifact.forgeTools}
219
- * @see {@link @nhtio/adk!DispatchContext.onAck}
136
+ * @param data - The store snapshot produced by {@link Registry.[ENCODE_METHOD]}.
137
+ * @returns A fresh {@link Registry} seeded with the snapshot.
220
138
  */
221
- bindContext(ctx) {
222
- return ctx.onAck(() => this.pruneEphemeral());
223
- }
224
- /**
225
- * Combines multiple {@link ToolRegistry} instances into a fresh registry without mutating any
226
- * input.
227
- *
228
- * @remarks
229
- * Iteration is left-to-right across `registries` and then in each registry's insertion order.
230
- * Collisions are resolved by consulting the **incoming** tool's {@link @nhtio/adk!Tool.onCollision} first:
231
- *
232
- * - `'replace'` (per-tool): the incoming tool wins, replacing the existing entry.
233
- * - `'keep'` (per-tool): the existing entry wins; the incoming tool is dropped.
234
- * - `'throw'` (per-tool, the default): fall back to the merge-level `options.onCollision`.
235
- *
236
- * The merge-level `options.onCollision` defaults to `'throw'`, which mirrors {@link register}.
237
- *
238
- * The result is a brand-new registry; no input is mutated and no event subscription is
239
- * propagated. Each `Tool`'s `ephemeral` flag carries through unchanged — the flag lives on the
240
- * tool, not the registry, so `bindContext(ctx)` on the merged registry will prune the forged
241
- * tools as expected.
242
- *
243
- * Hidden state is also propagated: a tool that is hidden in any source registry remains hidden
244
- * in the merged result, provided it survives collision resolution.
245
- *
246
- * @param registries - Registries to merge, in priority order (left-to-right insertion).
247
- * @param options - Merge-level collision policy. Defaults to `{ onCollision: 'throw' }`.
248
- * @returns A fresh {@link ToolRegistry} containing the resolved union of all inputs.
249
- * @throws {@link @nhtio/adk!E_TOOL_ALREADY_REGISTERED} when the resolved collision policy is `'throw'`
250
- * and a collision occurs.
251
- */
252
- static merge(registries, options) {
253
- const policy = options?.onCollision ?? "throw";
254
- const merged = new ToolRegistry();
255
- for (const registry of registries) {
256
- for (const tool of registry.all()) {
257
- if (!merged.get(tool.name)) {
258
- merged.register(tool);
259
- continue;
260
- }
261
- const incomingPolicy = tool.onCollision;
262
- if (incomingPolicy === "replace") {
263
- merged.register(tool, true);
264
- continue;
265
- }
266
- if (incomingPolicy === "keep") continue;
267
- if (policy === "replace") {
268
- merged.register(tool, true);
269
- continue;
270
- }
271
- if (policy === "keep") continue;
272
- throw new E_TOOL_ALREADY_REGISTERED();
273
- }
274
- for (const tool of registry.hidden()) if (merged.has(tool.name)) merged.hide(tool.name);
275
- }
276
- return merged;
277
- }
278
- /**
279
- * Serialise this ToolRegistry into an `@nhtio/encoder` snapshot.
280
- *
281
- * @remarks
282
- * Emits the live {@link @nhtio/adk!Tool} instances (the encoder recurses into each — so every tool's
283
- * handler-closure caveat from {@link Tool.[ENCODE_METHOD]} applies) plus the hidden-set names. Both
284
- * {@link @nhtio/adk!Tool} and {@link @nhtio/adk!ArtifactTool} entries round-trip to their correct
285
- * subtype. Round-trips via {@link ToolRegistry.[DECODE_METHOD]}.
286
- *
287
- * @returns A `{ tools, hidden }` snapshot.
288
- */
289
- [ENCODE_METHOD]() {
290
- return {
291
- tools: this.all(),
292
- hidden: this.hidden().map((tool) => tool.name)
293
- };
294
- }
295
- /**
296
- * Reconstruct a {@link ToolRegistry} from a {@link ToolRegistry.[ENCODE_METHOD]} snapshot.
297
- *
298
- * @param data - The snapshot produced by {@link ToolRegistry.[ENCODE_METHOD]}.
299
- * @returns A fresh {@link ToolRegistry} with the same tools and hidden set.
300
- */
301
- static [DECODE_METHOD](data) {
302
- const snapshot = data;
303
- const registry = new ToolRegistry(snapshot.tools);
304
- registry.setHidden(...snapshot.hidden);
305
- return registry;
139
+ static [DECODE_METHOD](data) {
140
+ return new Registry(data);
306
141
  }
307
142
  };
308
143
  //#endregion
@@ -331,140 +166,6 @@ function canonicalStringify(value) {
331
166
  return "{" + Object.keys(obj).sort().map((k) => JSON.stringify(k) + ":" + canonicalStringify(obj[k])).join(",") + "}";
332
167
  }
333
168
  //#endregion
334
- //#region src/lib/classes/registry.ts
335
- /**
336
- * A controlled-mutation key-value store with dot-path access and deep-clone isolation.
337
- *
338
- * @remarks
339
- * The registry enforces a safe read/write contract: callers never hold a live reference into
340
- * the internal store. Every value that enters (`set`) or leaves (`get`, `all`) is deep-cloned
341
- * via `klona`, so mutations to a retrieved value cannot affect stored state and vice versa.
342
- *
343
- * Keys are dot-delimited paths (e.g. `"user.profile.name"`), resolved via `dlv` for reads and
344
- * `dset` for writes; intermediate objects are created automatically on write.
345
- */
346
- var Registry = class Registry {
347
- #store;
348
- /**
349
- * @param initial - Optional plain object to seed the registry. Deep-cloned on construction.
350
- * @throws {@link @nhtio/adk!E_INVALID_INITIAL_REGISTRY_VALUE} when `initial` is defined but not a plain object.
351
- */
352
- constructor(initial) {
353
- if ("undefined" !== typeof initial && !isObject(initial)) throw new E_INVALID_INITIAL_REGISTRY_VALUE();
354
- this.#store = initial ? klona(initial) : {};
355
- }
356
- /**
357
- * Returns `true` if `value` is a {@link Registry} instance.
358
- *
359
- * @remarks
360
- * Uses {@link @nhtio/adk!isInstanceOf} for cross-realm safety.
361
- *
362
- * @param value - The value to test.
363
- * @returns `true` when `value` is a {@link Registry} instance.
364
- */
365
- static isRegistry(value) {
366
- return isInstanceOf(value, "Registry", Registry);
367
- }
368
- /**
369
- * Retrieves the value at `key`, returning `defaultValue` if the path is absent.
370
- *
371
- * @remarks
372
- * The returned value is a deep clone — mutating it will not affect the stored state.
373
- *
374
- * @typeParam T - Expected type of the value at `key`.
375
- * @param key - Dot-delimited path into the store (e.g. `"user.name"`).
376
- * @param defaultValue - Fallback returned when the path resolves to `undefined`.
377
- * @returns A deep clone of the stored value cast to `T`, or `defaultValue` when the path is absent.
378
- */
379
- get(key, defaultValue) {
380
- const value = delve(klona(this.#store), key);
381
- return "undefined" === typeof value ? defaultValue : value;
382
- }
383
- /**
384
- * Sets the value at `key`, creating intermediate objects as needed.
385
- *
386
- * @remarks
387
- * The stored value is isolated from the caller — mutating `value` after this call will not
388
- * affect what is held in the registry.
389
- *
390
- * @param key - Dot-delimited path into the store (e.g. `"user.name"`).
391
- * @param value - Value to store at the path.
392
- */
393
- set(key, value) {
394
- dset(this.#store, key, value);
395
- }
396
- /**
397
- * Returns `true` if the registry has a value at `key`, `false` otherwise.
398
- *
399
- * @remarks
400
- * A key resolving to `undefined` is treated as absent — same convention as {@link Registry.get}'s
401
- * `defaultValue` fallback. No clone is performed; this is a pure existence check.
402
- *
403
- * @param key - Dot-delimited path into the store (e.g. `"user.name"`).
404
- * @returns `true` when the path resolves to a value other than `undefined`.
405
- */
406
- has(key) {
407
- return "undefined" !== typeof delve(this.#store, key);
408
- }
409
- /**
410
- * Returns all leaf dot-paths present in the registry.
411
- *
412
- * @remarks
413
- * The store is deep-cloned before traversal. Plain objects are walked recursively with path
414
- * segments joined by dots; arrays, primitives, `null`, and class instances are treated as leaves.
415
- *
416
- * @returns A string array of dot-delimited paths to leaf values in the store.
417
- */
418
- keys() {
419
- const store = klona(this.#store);
420
- const keys = [];
421
- const isPlainRecord = (value) => {
422
- if (!isObject(value)) return false;
423
- const prototype = Object.getPrototypeOf(value);
424
- return prototype === Object.prototype || prototype === null;
425
- };
426
- const walk = (value, segments) => {
427
- if (!isPlainRecord(value)) {
428
- if (segments.length > 0) keys.push(segments.join("."));
429
- return;
430
- }
431
- for (const [segment, child] of Object.entries(value)) walk(child, [...segments, segment]);
432
- };
433
- walk(store, []);
434
- return keys;
435
- }
436
- /**
437
- * Returns a deep clone of the entire store contents.
438
- *
439
- * @returns A plain object snapshot of all stored key-value pairs.
440
- */
441
- all() {
442
- return klona(this.#store);
443
- }
444
- /**
445
- * Serialise this Registry into an `@nhtio/encoder` snapshot.
446
- *
447
- * @remarks
448
- * The snapshot is a deep clone of the store ({@link Registry.all}). Leaf values that are themselves
449
- * registered encodable instances round-trip; anything the encoder cannot serialise throws at encode
450
- * time (standard encoder behaviour). Round-trips via {@link Registry.[DECODE_METHOD]}.
451
- *
452
- * @returns A deep-cloned plain-object snapshot of the store.
453
- */
454
- [ENCODE_METHOD]() {
455
- return this.all();
456
- }
457
- /**
458
- * Reconstruct a {@link Registry} from a {@link Registry.[ENCODE_METHOD]} snapshot.
459
- *
460
- * @param data - The store snapshot produced by {@link Registry.[ENCODE_METHOD]}.
461
- * @returns A fresh {@link Registry} seeded with the snapshot.
462
- */
463
- static [DECODE_METHOD](data) {
464
- return new Registry(data);
465
- }
466
- };
467
- //#endregion
468
169
  //#region src/lib/contracts/spooled_artifact_constructor.ts
469
170
  var ARTIFACT_METHODS = [
470
171
  "head",
@@ -933,6 +634,305 @@ var ArtifactTool = class ArtifactTool extends Tool {
933
634
  }
934
635
  };
935
636
  //#endregion
637
+ //#region src/lib/classes/tool_registry.ts
638
+ /**
639
+ * A mutable, turn-scoped collection of {@link @nhtio/adk!Tool} instances.
640
+ *
641
+ * @remarks
642
+ * Each `TurnRunner.run()` call constructs a fresh `ToolRegistry` from the runner's configured
643
+ * baseline tools, so middleware edits are isolated to the current turn and cannot bleed across
644
+ * concurrent or subsequent turns.
645
+ *
646
+ * `Tool` instances are immutable, so `all()` returns a fresh array without deep-cloning.
647
+ *
648
+ * `register()` throws {@link @nhtio/adk!E_TOOL_ALREADY_REGISTERED} if a tool with the same name is already
649
+ * present — pass `overwrite: true` to replace it explicitly.
650
+ *
651
+ * Tools can be **hidden** — registered and callable, but excluded from the default tool list
652
+ * rendered to the model. This is useful for discovery patterns where an agent has a tool that
653
+ * enumerates available tools, and the model picks one to call by name in a subsequent iteration.
654
+ * Hidden state is a property of the registry, not the tool: the same tool can be visible in one
655
+ * registry and hidden in another. See {@link hide}, {@link visible}, {@link hidden}.
656
+ */
657
+ var ToolRegistry = class ToolRegistry {
658
+ #tools;
659
+ #hidden;
660
+ /**
661
+ * Returns `true` if `value` is a {@link ToolRegistry} instance.
662
+ *
663
+ * @param value - The value to test.
664
+ * @returns `true` when `value` is a {@link ToolRegistry} instance.
665
+ */
666
+ static isToolRegistry(value) {
667
+ return isInstanceOf(value, "ToolRegistry", ToolRegistry);
668
+ }
669
+ /**
670
+ * @param tools - Optional initial tools. Insertion order is preserved. Duplicate names throw
671
+ * {@link @nhtio/adk!E_TOOL_ALREADY_REGISTERED} — ensure each tool has a unique name.
672
+ * @throws {@link @nhtio/adk!E_TOOL_ALREADY_REGISTERED} when two tools in `tools` share a name.
673
+ */
674
+ constructor(tools) {
675
+ this.#tools = /* @__PURE__ */ new Map();
676
+ this.#hidden = /* @__PURE__ */ new Set();
677
+ for (const tool of tools ?? []) this.register(tool);
678
+ }
679
+ /**
680
+ * Adds a tool to the registry.
681
+ *
682
+ * @param tool - The tool to register.
683
+ * @param overwrite - When `true`, silently replaces an existing tool with the same name.
684
+ * Defaults to `false`.
685
+ * @throws {@link @nhtio/adk!E_TOOL_ALREADY_REGISTERED} when a tool with the same name is already registered
686
+ * and `overwrite` is not `true`.
687
+ */
688
+ register(tool, overwrite) {
689
+ if (this.#tools.has(tool.name) && !overwrite) throw new E_TOOL_ALREADY_REGISTERED();
690
+ this.#tools.set(tool.name, tool);
691
+ }
692
+ /**
693
+ * Removes the tool with the given name from the registry.
694
+ *
695
+ * @remarks
696
+ * Also removes the name from the hidden set if present. No-ops if no tool with that name is
697
+ * registered.
698
+ *
699
+ * @param name - The name of the tool to remove.
700
+ */
701
+ unregister(name) {
702
+ this.#tools.delete(name);
703
+ this.#hidden.delete(name);
704
+ }
705
+ /**
706
+ * Returns the tool registered under `name`, or `undefined` if not present.
707
+ *
708
+ * @param name - The tool name to look up.
709
+ */
710
+ get(name) {
711
+ return this.#tools.get(name);
712
+ }
713
+ /**
714
+ * Returns `true` if a tool with the given name is registered.
715
+ *
716
+ * @param name - The tool name to test.
717
+ */
718
+ has(name) {
719
+ return this.#tools.has(name);
720
+ }
721
+ /**
722
+ * Returns a fresh array of all registered tools in insertion order.
723
+ *
724
+ * @remarks
725
+ * Includes both visible and hidden tools. Use {@link visible} to get only non-hidden tools, or
726
+ * {@link hidden} to get only hidden tools.
727
+ *
728
+ * Since {@link @nhtio/adk!Tool} instances are immutable, no deep-cloning is needed.
729
+ */
730
+ all() {
731
+ return Array.from(this.#tools.values());
732
+ }
733
+ /**
734
+ * Returns a fresh array of registered tools that are **not** hidden, in insertion order.
735
+ *
736
+ * @remarks
737
+ * This is the accessor LLM batteries should use when building the tool list for the model.
738
+ * Hidden tools are still callable (they resolve via {@link get}) but are excluded from the
739
+ * rendered tool definitions.
740
+ */
741
+ visible() {
742
+ return this.all().filter((t) => !this.#hidden.has(t.name));
743
+ }
744
+ /**
745
+ * Returns a fresh array of registered tools that **are** hidden, in insertion order.
746
+ *
747
+ * @remarks
748
+ * The converse of {@link visible}. Useful for discovery tools that enumerate all available
749
+ * tools, and for propagating hidden state across {@link merge}.
750
+ */
751
+ hidden() {
752
+ return this.all().filter((t) => this.#hidden.has(t.name));
753
+ }
754
+ /**
755
+ * Marks one or more registered tools as hidden.
756
+ *
757
+ * @remarks
758
+ * Hidden tools remain registered and callable via {@link get}, but are excluded from
759
+ * {@link visible} (and therefore from the LLM tool list). No-ops for any name that is not
760
+ * currently registered — the end result (the tool is not visible) matches the intent.
761
+ *
762
+ * @param names - One or more tool names to hide.
763
+ */
764
+ hide(...names) {
765
+ for (const name of names) this.#hidden.add(name);
766
+ }
767
+ /**
768
+ * Unmarks one or more tools as hidden, making them visible again.
769
+ *
770
+ * @remarks
771
+ * No-ops for any name that is not currently hidden.
772
+ *
773
+ * @param names - One or more tool names to unhide.
774
+ */
775
+ unhide(...names) {
776
+ for (const name of names) this.#hidden.delete(name);
777
+ }
778
+ /**
779
+ * Replaces the entire hidden set with the given tool names.
780
+ *
781
+ * @remarks
782
+ * Any previously hidden tool not in `names` becomes visible. Names that are not registered are
783
+ * silently ignored — they are added to the set but have no effect until a tool with that name
784
+ * is registered.
785
+ *
786
+ * @param names - The complete set of tool names to hide.
787
+ */
788
+ setHidden(...names) {
789
+ this.#hidden = new Set(names);
790
+ }
791
+ /**
792
+ * Unhides every tool in the registry.
793
+ */
794
+ clearHidden() {
795
+ this.#hidden.clear();
796
+ }
797
+ /**
798
+ * Removes every tool whose {@link @nhtio/adk!Tool.ephemeral} flag is `true`.
799
+ *
800
+ * @remarks
801
+ * Also removes pruned tool names from the hidden set. Synchronous and idempotent — calling it
802
+ * twice in a row is a no-op the second time. The canonical caller is
803
+ * {@link ToolRegistry.bindContext}, which schedules this method to run at
804
+ * {@link @nhtio/adk!DispatchContext.ack}. Non-ephemeral tools are left untouched.
805
+ */
806
+ pruneEphemeral() {
807
+ for (const [name, tool] of this.#tools) if (tool.ephemeral) {
808
+ this.#tools.delete(name);
809
+ this.#hidden.delete(name);
810
+ }
811
+ }
812
+ /**
813
+ * Binds this registry to a {@link @nhtio/adk!DispatchContext} so that {@link pruneEphemeral} runs
814
+ * automatically when the context is acked.
815
+ *
816
+ * @remarks
817
+ * The handler does NOT fire on {@link @nhtio/adk!DispatchContext.nack} — failed executor runs leave
818
+ * any forged tools in place so the consumer can inspect what was registered when debugging the
819
+ * failure. Subscriptions are short-lived and die with the context regardless.
820
+ *
821
+ * ARTIFACT READERS ARE FORGED BY THE CORE. As of the core-forge change, the `DispatchRunner` forges
822
+ * artifact-reader tools from prior-turn `SpooledArtifact` results into `ctx.tools` (and calls
823
+ * `ctx.tools.bindContext(ctx)`) once per iteration, BEFORE the input pipeline — so a battery executor no
824
+ * longer forges or binds; it reads the already-forged `ctx.tools` for both representation (rendering the
825
+ * tool declarations) and resolution (looking up an incoming call by name). The lifecycle is unchanged:
826
+ * ephemeral readers are still pruned on `ack`, and the core re-forges each iteration (prune-then-forge) so
827
+ * the `callId` enum never goes stale.
828
+ *
829
+ * `bindContext` remains the public seam for a CUSTOM consumer that forges its own ephemeral tools outside
830
+ * the core path. If you forge into a long-lived registry yourself, bind it (or prune manually) or the
831
+ * ephemeral tools accumulate and later `forgeTools(ctx)` calls see a stale `callId` enum. The pattern for a
832
+ * hand-rolled forge is:
833
+ *
834
+ * ```ts
835
+ * // Custom forge (the core already does this for artifact readers on ctx.tools):
836
+ * const forged = SpooledArtifact.forgeTools(ctx)
837
+ * for (const tool of forged.all()) ctx.tools.register(tool, true)
838
+ * ctx.tools.bindContext(ctx) // prune the ephemeral readers when the dispatch acks
839
+ * ```
840
+ *
841
+ * @param ctx - The execution context whose `ack` event should trigger pruning.
842
+ * @returns An unsubscribe function — calling it before `ctx.ack()` prevents pruning. Rarely
843
+ * useful outside of tests.
844
+ *
845
+ * @see {@link @nhtio/adk!SpooledArtifact.forgeTools}
846
+ * @see {@link @nhtio/adk!DispatchContext.onAck}
847
+ */
848
+ bindContext(ctx) {
849
+ return ctx.onAck(() => this.pruneEphemeral());
850
+ }
851
+ /**
852
+ * Combines multiple {@link ToolRegistry} instances into a fresh registry without mutating any
853
+ * input.
854
+ *
855
+ * @remarks
856
+ * Iteration is left-to-right across `registries` and then in each registry's insertion order.
857
+ * Collisions are resolved by consulting the **incoming** tool's {@link @nhtio/adk!Tool.onCollision} first:
858
+ *
859
+ * - `'replace'` (per-tool): the incoming tool wins, replacing the existing entry.
860
+ * - `'keep'` (per-tool): the existing entry wins; the incoming tool is dropped.
861
+ * - `'throw'` (per-tool, the default): fall back to the merge-level `options.onCollision`.
862
+ *
863
+ * The merge-level `options.onCollision` defaults to `'throw'`, which mirrors {@link register}.
864
+ *
865
+ * The result is a brand-new registry; no input is mutated and no event subscription is
866
+ * propagated. Each `Tool`'s `ephemeral` flag carries through unchanged — the flag lives on the
867
+ * tool, not the registry, so `bindContext(ctx)` on the merged registry will prune the forged
868
+ * tools as expected.
869
+ *
870
+ * Hidden state is also propagated: a tool that is hidden in any source registry remains hidden
871
+ * in the merged result, provided it survives collision resolution.
872
+ *
873
+ * @param registries - Registries to merge, in priority order (left-to-right insertion).
874
+ * @param options - Merge-level collision policy. Defaults to `{ onCollision: 'throw' }`.
875
+ * @returns A fresh {@link ToolRegistry} containing the resolved union of all inputs.
876
+ * @throws {@link @nhtio/adk!E_TOOL_ALREADY_REGISTERED} when the resolved collision policy is `'throw'`
877
+ * and a collision occurs.
878
+ */
879
+ static merge(registries, options) {
880
+ const policy = options?.onCollision ?? "throw";
881
+ const merged = new ToolRegistry();
882
+ for (const registry of registries) {
883
+ for (const tool of registry.all()) {
884
+ if (!merged.get(tool.name)) {
885
+ merged.register(tool);
886
+ continue;
887
+ }
888
+ const incomingPolicy = tool.onCollision;
889
+ if (incomingPolicy === "replace") {
890
+ merged.register(tool, true);
891
+ continue;
892
+ }
893
+ if (incomingPolicy === "keep") continue;
894
+ if (policy === "replace") {
895
+ merged.register(tool, true);
896
+ continue;
897
+ }
898
+ if (policy === "keep") continue;
899
+ throw new E_TOOL_ALREADY_REGISTERED();
900
+ }
901
+ for (const tool of registry.hidden()) if (merged.has(tool.name)) merged.hide(tool.name);
902
+ }
903
+ return merged;
904
+ }
905
+ /**
906
+ * Serialise this ToolRegistry into an `@nhtio/encoder` snapshot.
907
+ *
908
+ * @remarks
909
+ * Emits the live {@link @nhtio/adk!Tool} instances (the encoder recurses into each — so every tool's
910
+ * handler-closure caveat from {@link Tool.[ENCODE_METHOD]} applies) plus the hidden-set names. Both
911
+ * {@link @nhtio/adk!Tool} and {@link @nhtio/adk!ArtifactTool} entries round-trip to their correct
912
+ * subtype. Round-trips via {@link ToolRegistry.[DECODE_METHOD]}.
913
+ *
914
+ * @returns A `{ tools, hidden }` snapshot.
915
+ */
916
+ [ENCODE_METHOD]() {
917
+ return {
918
+ tools: this.all(),
919
+ hidden: this.hidden().map((tool) => tool.name)
920
+ };
921
+ }
922
+ /**
923
+ * Reconstruct a {@link ToolRegistry} from a {@link ToolRegistry.[ENCODE_METHOD]} snapshot.
924
+ *
925
+ * @param data - The snapshot produced by {@link ToolRegistry.[ENCODE_METHOD]}.
926
+ * @returns A fresh {@link ToolRegistry} with the same tools and hidden set.
927
+ */
928
+ static [DECODE_METHOD](data) {
929
+ const snapshot = data;
930
+ const registry = new ToolRegistry(snapshot.tools);
931
+ registry.setHidden(...snapshot.hidden);
932
+ return registry;
933
+ }
934
+ };
935
+ //#endregion
936
936
  //#region src/lib/contracts/spool_reader.ts
937
937
  /**
938
938
  * Validator schema used to validate a {@link SpoolReader} value.
@@ -1628,6 +1628,6 @@ var SpooledArtifact = class SpooledArtifact {
1628
1628
  }
1629
1629
  };
1630
1630
  //#endregion
1631
- export { resolveArtifactById as a, resolveMediaReader as c, ArtifactTool as d, Tool as f, ToolRegistry as g, canonicalStringify as h, effectiveToolMethods as i, resolveSpoolReader as l, Registry as m, collectArtifactCompatibleIds as n, registerMediaReaderResolver as o, artifactConstructorResolverSchema as p, defaultSerialise as r, registerSpoolReaderResolver as s, SpooledArtifact as t, implementsSpoolReader as u };
1631
+ export { resolveArtifactById as a, resolveMediaReader as c, ToolRegistry as d, ArtifactTool as f, Registry as g, canonicalStringify as h, effectiveToolMethods as i, resolveSpoolReader as l, artifactConstructorResolverSchema as m, collectArtifactCompatibleIds as n, registerMediaReaderResolver as o, Tool as p, defaultSerialise as r, registerSpoolReaderResolver as s, SpooledArtifact as t, implementsSpoolReader as u };
1632
1632
 
1633
- //# sourceMappingURL=spooled_artifact-BkOe4-j-.mjs.map
1633
+ //# sourceMappingURL=spooled_artifact-Bw_7swIp.mjs.map