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