@nhtio/adk 0.1.0-master-f0aa531d

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 (297) hide show
  1. package/LICENSE.md +9 -0
  2. package/README.md +3 -0
  3. package/batteries/index.d.ts +28 -0
  4. package/batteries/llm/index.d.ts +11 -0
  5. package/batteries/llm/openai_chat_completions/adapter.cjs +916 -0
  6. package/batteries/llm/openai_chat_completions/adapter.cjs.map +1 -0
  7. package/batteries/llm/openai_chat_completions/adapter.d.ts +101 -0
  8. package/batteries/llm/openai_chat_completions/adapter.mjs +914 -0
  9. package/batteries/llm/openai_chat_completions/adapter.mjs.map +1 -0
  10. package/batteries/llm/openai_chat_completions/exceptions.cjs +89 -0
  11. package/batteries/llm/openai_chat_completions/exceptions.cjs.map +1 -0
  12. package/batteries/llm/openai_chat_completions/exceptions.d.ts +97 -0
  13. package/batteries/llm/openai_chat_completions/exceptions.mjs +81 -0
  14. package/batteries/llm/openai_chat_completions/exceptions.mjs.map +1 -0
  15. package/batteries/llm/openai_chat_completions/helpers.cjs +819 -0
  16. package/batteries/llm/openai_chat_completions/helpers.cjs.map +1 -0
  17. package/batteries/llm/openai_chat_completions/helpers.d.ts +233 -0
  18. package/batteries/llm/openai_chat_completions/helpers.mjs +783 -0
  19. package/batteries/llm/openai_chat_completions/helpers.mjs.map +1 -0
  20. package/batteries/llm/openai_chat_completions/index.d.ts +27 -0
  21. package/batteries/llm/openai_chat_completions/types.cjs +1 -0
  22. package/batteries/llm/openai_chat_completions/types.d.ts +524 -0
  23. package/batteries/llm/openai_chat_completions/types.mjs +0 -0
  24. package/batteries/llm/openai_chat_completions/validation.cjs +190 -0
  25. package/batteries/llm/openai_chat_completions/validation.cjs.map +1 -0
  26. package/batteries/llm/openai_chat_completions/validation.d.ts +31 -0
  27. package/batteries/llm/openai_chat_completions/validation.mjs +187 -0
  28. package/batteries/llm/openai_chat_completions/validation.mjs.map +1 -0
  29. package/batteries/llm/openai_chat_completions.cjs +51 -0
  30. package/batteries/llm/openai_chat_completions.mjs +5 -0
  31. package/batteries/llm/webllm_chat_completions/adapter.cjs +658 -0
  32. package/batteries/llm/webllm_chat_completions/adapter.cjs.map +1 -0
  33. package/batteries/llm/webllm_chat_completions/adapter.d.ts +103 -0
  34. package/batteries/llm/webllm_chat_completions/adapter.mjs +656 -0
  35. package/batteries/llm/webllm_chat_completions/adapter.mjs.map +1 -0
  36. package/batteries/llm/webllm_chat_completions/exceptions.cjs +70 -0
  37. package/batteries/llm/webllm_chat_completions/exceptions.cjs.map +1 -0
  38. package/batteries/llm/webllm_chat_completions/exceptions.d.ts +74 -0
  39. package/batteries/llm/webllm_chat_completions/exceptions.mjs +65 -0
  40. package/batteries/llm/webllm_chat_completions/exceptions.mjs.map +1 -0
  41. package/batteries/llm/webllm_chat_completions/helpers.cjs +38 -0
  42. package/batteries/llm/webllm_chat_completions/helpers.d.ts +6 -0
  43. package/batteries/llm/webllm_chat_completions/helpers.mjs +2 -0
  44. package/batteries/llm/webllm_chat_completions/index.d.ts +25 -0
  45. package/batteries/llm/webllm_chat_completions/types.d.ts +31 -0
  46. package/batteries/llm/webllm_chat_completions/validation.cjs +115 -0
  47. package/batteries/llm/webllm_chat_completions/validation.cjs.map +1 -0
  48. package/batteries/llm/webllm_chat_completions/validation.d.ts +8 -0
  49. package/batteries/llm/webllm_chat_completions/validation.mjs +112 -0
  50. package/batteries/llm/webllm_chat_completions/validation.mjs.map +1 -0
  51. package/batteries/llm/webllm_chat_completions.cjs +50 -0
  52. package/batteries/llm/webllm_chat_completions.mjs +6 -0
  53. package/batteries/llm.cjs +63 -0
  54. package/batteries/llm.mjs +10 -0
  55. package/batteries/storage/flydrive/index.d.ts +167 -0
  56. package/batteries/storage/flydrive.cjs +249 -0
  57. package/batteries/storage/flydrive.cjs.map +1 -0
  58. package/batteries/storage/flydrive.mjs +249 -0
  59. package/batteries/storage/flydrive.mjs.map +1 -0
  60. package/batteries/storage/in_memory/index.d.ts +106 -0
  61. package/batteries/storage/in_memory.cjs +121 -0
  62. package/batteries/storage/in_memory.cjs.map +1 -0
  63. package/batteries/storage/in_memory.mjs +119 -0
  64. package/batteries/storage/in_memory.mjs.map +1 -0
  65. package/batteries/storage/index.d.ts +18 -0
  66. package/batteries/storage/opfs/index.d.ts +299 -0
  67. package/batteries/storage/opfs.cjs +368 -0
  68. package/batteries/storage/opfs.cjs.map +1 -0
  69. package/batteries/storage/opfs.mjs +366 -0
  70. package/batteries/storage/opfs.mjs.map +1 -0
  71. package/batteries/storage.cjs +4 -0
  72. package/batteries/storage.mjs +2 -0
  73. package/batteries/tools/color/index.d.ts +37 -0
  74. package/batteries/tools/color.cjs +659 -0
  75. package/batteries/tools/color.cjs.map +1 -0
  76. package/batteries/tools/color.mjs +655 -0
  77. package/batteries/tools/color.mjs.map +1 -0
  78. package/batteries/tools/comparison/index.d.ts +29 -0
  79. package/batteries/tools/comparison.cjs +171 -0
  80. package/batteries/tools/comparison.cjs.map +1 -0
  81. package/batteries/tools/comparison.mjs +168 -0
  82. package/batteries/tools/comparison.mjs.map +1 -0
  83. package/batteries/tools/data_structure/index.d.ts +30 -0
  84. package/batteries/tools/data_structure.cjs +270 -0
  85. package/batteries/tools/data_structure.cjs.map +1 -0
  86. package/batteries/tools/data_structure.mjs +267 -0
  87. package/batteries/tools/data_structure.mjs.map +1 -0
  88. package/batteries/tools/datetime_extended/index.d.ts +51 -0
  89. package/batteries/tools/datetime_extended.cjs +309 -0
  90. package/batteries/tools/datetime_extended.cjs.map +1 -0
  91. package/batteries/tools/datetime_extended.mjs +302 -0
  92. package/batteries/tools/datetime_extended.mjs.map +1 -0
  93. package/batteries/tools/datetime_math/index.d.ts +36 -0
  94. package/batteries/tools/datetime_math.cjs +175 -0
  95. package/batteries/tools/datetime_math.cjs.map +1 -0
  96. package/batteries/tools/datetime_math.mjs +171 -0
  97. package/batteries/tools/datetime_math.mjs.map +1 -0
  98. package/batteries/tools/encoding/index.d.ts +36 -0
  99. package/batteries/tools/encoding.cjs +156 -0
  100. package/batteries/tools/encoding.cjs.map +1 -0
  101. package/batteries/tools/encoding.mjs +152 -0
  102. package/batteries/tools/encoding.mjs.map +1 -0
  103. package/batteries/tools/formatting/index.d.ts +28 -0
  104. package/batteries/tools/formatting.cjs +120 -0
  105. package/batteries/tools/formatting.cjs.map +1 -0
  106. package/batteries/tools/formatting.mjs +117 -0
  107. package/batteries/tools/formatting.mjs.map +1 -0
  108. package/batteries/tools/geo_basics/index.d.ts +33 -0
  109. package/batteries/tools/geo_basics.cjs +136 -0
  110. package/batteries/tools/geo_basics.cjs.map +1 -0
  111. package/batteries/tools/geo_basics.mjs +132 -0
  112. package/batteries/tools/geo_basics.mjs.map +1 -0
  113. package/batteries/tools/index.d.ts +32 -0
  114. package/batteries/tools/math/index.d.ts +37 -0
  115. package/batteries/tools/math.cjs +136 -0
  116. package/batteries/tools/math.cjs.map +1 -0
  117. package/batteries/tools/math.mjs +133 -0
  118. package/batteries/tools/math.mjs.map +1 -0
  119. package/batteries/tools/memory/index.d.ts +73 -0
  120. package/batteries/tools/memory.cjs +193 -0
  121. package/batteries/tools/memory.cjs.map +1 -0
  122. package/batteries/tools/memory.mjs +187 -0
  123. package/batteries/tools/memory.mjs.map +1 -0
  124. package/batteries/tools/parsing/index.d.ts +47 -0
  125. package/batteries/tools/parsing.cjs +191 -0
  126. package/batteries/tools/parsing.cjs.map +1 -0
  127. package/batteries/tools/parsing.mjs +185 -0
  128. package/batteries/tools/parsing.mjs.map +1 -0
  129. package/batteries/tools/retrievables/index.d.ts +81 -0
  130. package/batteries/tools/retrievables.cjs +215 -0
  131. package/batteries/tools/retrievables.cjs.map +1 -0
  132. package/batteries/tools/retrievables.mjs +209 -0
  133. package/batteries/tools/retrievables.mjs.map +1 -0
  134. package/batteries/tools/standing_instructions/index.d.ts +64 -0
  135. package/batteries/tools/standing_instructions.cjs +126 -0
  136. package/batteries/tools/standing_instructions.cjs.map +1 -0
  137. package/batteries/tools/standing_instructions.mjs +121 -0
  138. package/batteries/tools/standing_instructions.mjs.map +1 -0
  139. package/batteries/tools/statistics/index.d.ts +46 -0
  140. package/batteries/tools/statistics.cjs +253 -0
  141. package/batteries/tools/statistics.cjs.map +1 -0
  142. package/batteries/tools/statistics.mjs +248 -0
  143. package/batteries/tools/statistics.mjs.map +1 -0
  144. package/batteries/tools/string_processing/index.d.ts +29 -0
  145. package/batteries/tools/string_processing.cjs +154 -0
  146. package/batteries/tools/string_processing.cjs.map +1 -0
  147. package/batteries/tools/string_processing.mjs +151 -0
  148. package/batteries/tools/string_processing.mjs.map +1 -0
  149. package/batteries/tools/structured_data/index.d.ts +34 -0
  150. package/batteries/tools/structured_data.cjs +189 -0
  151. package/batteries/tools/structured_data.cjs.map +1 -0
  152. package/batteries/tools/structured_data.mjs +185 -0
  153. package/batteries/tools/structured_data.mjs.map +1 -0
  154. package/batteries/tools/text_analysis/index.d.ts +31 -0
  155. package/batteries/tools/text_analysis.cjs +120 -0
  156. package/batteries/tools/text_analysis.cjs.map +1 -0
  157. package/batteries/tools/text_analysis.mjs +117 -0
  158. package/batteries/tools/text_analysis.mjs.map +1 -0
  159. package/batteries/tools/text_comparison/index.d.ts +28 -0
  160. package/batteries/tools/text_comparison.cjs +96 -0
  161. package/batteries/tools/text_comparison.cjs.map +1 -0
  162. package/batteries/tools/text_comparison.mjs +93 -0
  163. package/batteries/tools/text_comparison.mjs.map +1 -0
  164. package/batteries/tools/time/index.d.ts +27 -0
  165. package/batteries/tools/time.cjs +63 -0
  166. package/batteries/tools/time.cjs.map +1 -0
  167. package/batteries/tools/time.mjs +60 -0
  168. package/batteries/tools/time.mjs.map +1 -0
  169. package/batteries/tools/unit_conversion/index.d.ts +19 -0
  170. package/batteries/tools/unit_conversion.cjs +452 -0
  171. package/batteries/tools/unit_conversion.cjs.map +1 -0
  172. package/batteries/tools/unit_conversion.mjs +450 -0
  173. package/batteries/tools/unit_conversion.mjs.map +1 -0
  174. package/batteries/tools.cjs +80 -0
  175. package/batteries/tools.mjs +21 -0
  176. package/batteries.cjs +142 -0
  177. package/batteries.mjs +30 -0
  178. package/chunk-KmRHZBOW.js +35 -0
  179. package/common-DeZaonK1.mjs +208 -0
  180. package/common-DeZaonK1.mjs.map +1 -0
  181. package/common-Od8edUXU.js +232 -0
  182. package/common-Od8edUXU.js.map +1 -0
  183. package/common.cjs +31 -0
  184. package/common.d.ts +108 -0
  185. package/common.mjs +8 -0
  186. package/dispatch_runner-9j6bXHL3.mjs +1609 -0
  187. package/dispatch_runner-9j6bXHL3.mjs.map +1 -0
  188. package/dispatch_runner-CsoH0nld.js +1627 -0
  189. package/dispatch_runner-CsoH0nld.js.map +1 -0
  190. package/dispatch_runner.cjs +3 -0
  191. package/dispatch_runner.d.ts +17 -0
  192. package/dispatch_runner.mjs +2 -0
  193. package/exceptions-D5YrO9Vm.js +280 -0
  194. package/exceptions-D5YrO9Vm.js.map +1 -0
  195. package/exceptions-NrzIHw_R.mjs +244 -0
  196. package/exceptions-NrzIHw_R.mjs.map +1 -0
  197. package/exceptions.cjs +33 -0
  198. package/exceptions.d.ts +52 -0
  199. package/exceptions.mjs +3 -0
  200. package/factories.cjs +4 -0
  201. package/factories.d.ts +39 -0
  202. package/factories.mjs +2 -0
  203. package/forge.cjs +9 -0
  204. package/forge.d.ts +49 -0
  205. package/forge.mjs +5 -0
  206. package/guards.cjs +96 -0
  207. package/guards.cjs.map +1 -0
  208. package/guards.d.ts +83 -0
  209. package/guards.mjs +72 -0
  210. package/guards.mjs.map +1 -0
  211. package/index.cjs +107 -0
  212. package/index.cjs.map +1 -0
  213. package/index.d.ts +18 -0
  214. package/index.mjs +31 -0
  215. package/index.mjs.map +1 -0
  216. package/lib/classes/artifact_tool.d.ts +129 -0
  217. package/lib/classes/base_exception.d.ts +83 -0
  218. package/lib/classes/identity.d.ts +71 -0
  219. package/lib/classes/media.d.ts +326 -0
  220. package/lib/classes/memory.d.ts +72 -0
  221. package/lib/classes/message.d.ts +137 -0
  222. package/lib/classes/registry.d.ts +79 -0
  223. package/lib/classes/retrievable.d.ts +100 -0
  224. package/lib/classes/spooled_artifact.d.ts +296 -0
  225. package/lib/classes/spooled_json_artifact.d.ts +158 -0
  226. package/lib/classes/spooled_markdown_artifact.d.ts +202 -0
  227. package/lib/classes/thought.d.ts +142 -0
  228. package/lib/classes/tokenizable.d.ts +124 -0
  229. package/lib/classes/tool.d.ts +228 -0
  230. package/lib/classes/tool_call.d.ts +190 -0
  231. package/lib/classes/tool_registry.d.ts +159 -0
  232. package/lib/classes/turn_gate.d.ts +109 -0
  233. package/lib/contracts/dispatch_context.d.ts +345 -0
  234. package/lib/contracts/media_reader.d.ts +60 -0
  235. package/lib/contracts/spool_reader.d.ts +80 -0
  236. package/lib/contracts/spooled_artifact_constructor.d.ts +38 -0
  237. package/lib/contracts/turn_runner_config.d.ts +101 -0
  238. package/lib/contracts/turn_runner_context.d.ts +267 -0
  239. package/lib/dispatch_runner.d.ts +98 -0
  240. package/lib/exceptions/runtime.d.ts +370 -0
  241. package/lib/helpers/media_readers.d.ts +39 -0
  242. package/lib/turn_runner.d.ts +144 -0
  243. package/lib/types/dispatch_context.d.ts +233 -0
  244. package/lib/types/dispatch_runner.d.ts +387 -0
  245. package/lib/types/turn_runner.d.ts +322 -0
  246. package/lib/utils/canonical_json.d.ts +18 -0
  247. package/lib/utils/exceptions.d.ts +78 -0
  248. package/lib/utils/guards.d.ts +32 -0
  249. package/lib/utils/validation.d.ts +77 -0
  250. package/package.json +334 -0
  251. package/runtime-BJVkrGQe.js +519 -0
  252. package/runtime-BJVkrGQe.js.map +1 -0
  253. package/runtime-CrEPIFgr.mjs +346 -0
  254. package/runtime-CrEPIFgr.mjs.map +1 -0
  255. package/skills/adk-assembly/SKILL.md +109 -0
  256. package/skills/adk-assembly/references/assembly-contract.md +66 -0
  257. package/skills/adk-assembly/references/executors-tools-pipelines-events.md +113 -0
  258. package/skills/adk-assembly/references/first-integration.md +93 -0
  259. package/skills/adk-assembly/references/storage-and-context.md +102 -0
  260. package/spooled_artifact-C5ZtGxuJ.mjs +544 -0
  261. package/spooled_artifact-C5ZtGxuJ.mjs.map +1 -0
  262. package/spooled_artifact-Cm9Te22K.js +568 -0
  263. package/spooled_artifact-Cm9Te22K.js.map +1 -0
  264. package/spooled_artifact.cjs +7 -0
  265. package/spooled_artifact.d.ts +40 -0
  266. package/spooled_artifact.mjs +3 -0
  267. package/spooled_markdown_artifact-BpUJol0W.mjs +771 -0
  268. package/spooled_markdown_artifact-BpUJol0W.mjs.map +1 -0
  269. package/spooled_markdown_artifact-RRB113sy.js +786 -0
  270. package/spooled_markdown_artifact-RRB113sy.js.map +1 -0
  271. package/thought-CDb457b4.mjs +470 -0
  272. package/thought-CDb457b4.mjs.map +1 -0
  273. package/thought-DuN2PgdO.js +494 -0
  274. package/thought-DuN2PgdO.js.map +1 -0
  275. package/tool-COSeH8I6.js +302 -0
  276. package/tool-COSeH8I6.js.map +1 -0
  277. package/tool-D2WB1EA1.mjs +296 -0
  278. package/tool-D2WB1EA1.mjs.map +1 -0
  279. package/tool_call-BKyyxGaZ.mjs +578 -0
  280. package/tool_call-BKyyxGaZ.mjs.map +1 -0
  281. package/tool_call-DFgzcVcU.js +608 -0
  282. package/tool_call-DFgzcVcU.js.map +1 -0
  283. package/tool_registry-Dkfprsck.js +641 -0
  284. package/tool_registry-Dkfprsck.js.map +1 -0
  285. package/tool_registry-DqLOyGyG.mjs +592 -0
  286. package/tool_registry-DqLOyGyG.mjs.map +1 -0
  287. package/turn_runner-CMm2BHdX.js +615 -0
  288. package/turn_runner-CMm2BHdX.js.map +1 -0
  289. package/turn_runner-y7eyEcJH.mjs +603 -0
  290. package/turn_runner-y7eyEcJH.mjs.map +1 -0
  291. package/turn_runner.cjs +3 -0
  292. package/turn_runner.d.ts +21 -0
  293. package/turn_runner.mjs +2 -0
  294. package/types.cjs +1 -0
  295. package/types.d.ts +56 -0
  296. package/types.mjs +0 -0
  297. package/vite-env.d.ts +23 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool_registry-DqLOyGyG.mjs","names":["#value","#cache","#store","#tools"],"sources":["../src/lib/utils/guards.ts","../src/lib/classes/tokenizable.ts","../src/lib/classes/registry.ts","../src/lib/utils/canonical_json.ts","../src/lib/classes/tool_registry.ts"],"sourcesContent":["import { passesSchema } from './validation'\nimport { validator } from '@nhtio/validation'\n\n/**\n * Returns `true` if `value` is an instance of the class identified by `type` (and optionally `ctor`).\n *\n * @remarks\n * Performs three checks in order: `instanceof ctor`, `Symbol.hasInstance`, then constructor-name\n * comparison. The constructor-name fallback handles cross-realm cases where `instanceof` fails.\n *\n * @typeParam T - The expected instance type.\n * @param value - The value to test.\n * @param type - The constructor name to compare against when `instanceof` is unavailable.\n * @param ctor - Optional constructor to use for `instanceof` and `Symbol.hasInstance` checks.\n * @returns `true` when `value` is an instance of the class described by `type`/`ctor`.\n */\nexport const isInstanceOf = <T>(\n value: unknown,\n type: string,\n ctor?: new (...args: any[]) => T\n): value is T => {\n // eslint-disable-next-line adk/use-is-instance-of -- this IS the implementation of isInstanceOf\n if ('undefined' !== typeof ctor && value instanceof ctor) return true\n /* istanbul ignore next 4 */\n if (\n 'undefined' !== typeof ctor &&\n typeof ctor[Symbol.hasInstance] === 'function' &&\n ctor[Symbol.hasInstance](value)\n )\n /* istanbul ignore next */\n return true\n // eslint-disable-next-line adk/prefer-is-object -- this guard is the building block isObject depends on (no circular usage)\n if ('object' === typeof value && null !== value) {\n const valueWithConstructor = value as { constructor?: Function }\n const constructorName = valueWithConstructor.constructor?.name\n return constructorName === type\n }\n return false\n}\n\nconst errorSchema = validator\n .any()\n .custom((value, helpers) => {\n if (isInstanceOf(value, 'Error', Error)) {\n return value\n }\n return helpers.error('any.invalid')\n })\n .required()\n\n/**\n * Returns `true` if `value` is an `Error` instance or satisfies the `Error` duck-type shape.\n *\n * @remarks\n * Returns `false` for `undefined` and `null` — the `Error` contract requires an actual instance.\n *\n * @param value - The value to test.\n * @returns `true` when `value` conforms to the `Error` shape.\n */\nexport const isError = (value: unknown): value is Error => {\n return passesSchema(errorSchema, value)\n}\n\n/**\n * Type guard to check if a value is a plain object (not null, not array)\n * @param value - The value to check\n * @returns True if the value is a plain object, false otherwise\n */\nexport const isObject = (value: unknown): value is { [key: string]: unknown } => {\n // eslint-disable-next-line adk/prefer-is-object -- this IS the implementation of isObject\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n","import { getEncoding } from 'js-tiktoken'\nimport { validator } from '@nhtio/validation'\nimport { isInstanceOf } from '../utils/guards'\nimport { LlamaTokenizer } from 'llama-tokenizer-js'\nimport { fromPreTrained as geminiFromPreTrained } from '@lenml/tokenizer-gemini'\nimport type { Tiktoken } from 'js-tiktoken'\n\n/**\n * The set of supported token encoding identifiers.\n *\n * @remarks\n * Each value maps to a specific estimation backend:\n * - `gpt2`, `r50k_base`, `p50k_base`, `p50k_edit`, `cl100k_base`, `o200k_base` — exact counts\n * via `js-tiktoken` (OpenAI / tiktoken-compatible models).\n * - `gemini` — exact counts via `@lenml/tokenizer-gemini`, which embeds Gemini's actual\n * SentencePiece vocabulary locally with no API call required.\n * - `llama2` — exact counts via `llama-tokenizer-js` (Llama 1 and 2). Llama 3+ uses a\n * different vocabulary and should use the `llama3` identifier once a suitable sync backend\n * is available.\n * - `claude` — heuristic approximation using Anthropic's published ~3.5 chars/token ratio.\n * No local tokenizer is available for Claude 3+ models; the Anthropic SDK's\n * `messages.countTokens()` API is the only exact path but requires a network call.\n *\n * When adding a new encoding, add a case to {@link Tokenizable.estimateTokens}.\n */\nexport const TokenEncoding = [\n 'gpt2',\n 'r50k_base',\n 'p50k_base',\n 'p50k_edit',\n 'cl100k_base',\n 'o200k_base',\n 'gemini',\n 'llama2',\n 'claude',\n] as const\n\n/**\n * Union of all recognised token encoding identifier strings.\n *\n * @remarks\n * Derived from {@link TokenEncoding} so the type and the runtime array stay in sync\n * automatically when new encodings are added.\n */\nexport type TokenEncoding = (typeof TokenEncoding)[number]\n\n/**\n * Backing schema for {@link Tokenizable.schema}.\n *\n * @remarks\n * Accepts a plain `string` or an existing {@link Tokenizable} instance. Strings pass through\n * unchanged; {@link Tokenizable} instances are accepted via {@link Tokenizable.isTokenizable}\n * to remain cross-realm safe.\n */\nconst stringOrTokenizableSchema = validator.alternatives(\n validator.string(),\n validator.custom((value, helpers) => {\n if (Tokenizable.isTokenizable(value)) {\n return value\n }\n return helpers.error('any.invalid')\n })\n)\n\n// Lazily-initialised singletons — tokenizers are expensive to load so we defer\n// until first use and reuse across all Tokenizable instances thereafter.\nlet geminiTokenizerInstance: ReturnType<typeof geminiFromPreTrained> | undefined\nlet llamaTokenizerInstance: InstanceType<typeof LlamaTokenizer> | undefined\n\nconst getGeminiTokenizer = () => {\n if (!geminiTokenizerInstance) {\n geminiTokenizerInstance = geminiFromPreTrained()\n }\n return geminiTokenizerInstance\n}\n\nconst getLlamaTokenizer = () => {\n if (!llamaTokenizerInstance) {\n llamaTokenizerInstance = new LlamaTokenizer()\n }\n return llamaTokenizerInstance\n}\n\n/**\n * A mutable string with a built-in token counter.\n *\n * @remarks\n * The wrapped string can be read via the standard coercion protocol and updated at any time via\n * {@link Tokenizable.set}. Token counts are computed lazily on first access per encoding and\n * cached until the value changes, avoiding redundant encoder invocations when the same content\n * is measured multiple times across a pipeline.\n *\n * Estimation is dispatched by encoding identifier — see {@link TokenEncoding} for the full list\n * of supported backends and their accuracy characteristics. Unrecognised encodings fall back to\n * a `ceil(length / 4)` character heuristic.\n *\n * The class implements the standard JS value-coercion protocol (`toString`, `valueOf`,\n * `toJSON`, `toLocaleString`, `Symbol.for('nodejs.util.inspect.custom')`) so instances behave\n * transparently as strings in most contexts.\n */\nexport class Tokenizable {\n public static TokenEncoding = TokenEncoding\n\n /**\n * Validator schema that accepts a plain `string` or a {@link Tokenizable} instance.\n *\n * @remarks\n * Reusable fragment for any schema that wants to accept either form — for example,\n * `systemPrompt` and each item in `standingInstructions` in `turnContextSchema`.\n */\n public static schema = stringOrTokenizableSchema\n\n declare toJSON: () => string\n declare toString: () => string\n declare valueOf: () => string\n declare toLocaleString: () => string\n declare set: (value: string) => void\n declare estimateTokens: (encoding: TokenEncoding) => number\n\n #value: string\n #cache: Map<TokenEncoding, number> = new Map()\n\n /**\n * @param value - The initial string value to wrap.\n */\n constructor(value: string) {\n this.#value = value\n\n const estimateTokensWithTiktoken = (encoding: TokenEncoding): number => {\n try {\n const enc: Tiktoken = getEncoding(encoding as any)\n return enc.encode(this.#value, []).length\n } catch {\n return Number.POSITIVE_INFINITY\n }\n }\n\n const estimateTokensWithGemini = (): number => {\n try {\n return getGeminiTokenizer().encode(this.#value).length\n } catch {\n return Number.POSITIVE_INFINITY\n }\n }\n\n const estimateTokensWithLlama2 = (): number => {\n try {\n return getLlamaTokenizer().encode(this.#value, false).length\n } catch {\n return Number.POSITIVE_INFINITY\n }\n }\n\n const estimateTokensWithClaudeHeuristic = (): number => {\n try {\n return Math.ceil(this.#value.length / 3.5)\n } catch {\n return Number.POSITIVE_INFINITY\n }\n }\n\n Object.defineProperties(this, {\n toJSON: {\n value: () => this.#value,\n enumerable: false,\n configurable: false,\n writable: false,\n },\n toString: {\n value: () => this.#value,\n enumerable: false,\n configurable: false,\n writable: false,\n },\n valueOf: {\n value: () => this.#value,\n enumerable: false,\n configurable: false,\n writable: false,\n },\n toLocaleString: {\n value: () => this.#value,\n enumerable: false,\n configurable: false,\n writable: false,\n },\n [Symbol.for('nodejs.util.inspect.custom')]: {\n value: () => this.#value,\n enumerable: false,\n configurable: false,\n writable: false,\n },\n set: {\n value: (next: string) => {\n this.#value = next\n this.#cache.clear()\n },\n enumerable: false,\n configurable: false,\n writable: false,\n },\n estimateTokens: {\n value: (encoding: TokenEncoding): number => {\n if (this.#cache.has(encoding)) {\n return this.#cache.get(encoding)!\n }\n\n let estimate: number\n switch (encoding) {\n case 'gpt2':\n case 'r50k_base':\n case 'p50k_base':\n case 'p50k_edit':\n case 'cl100k_base':\n case 'o200k_base':\n estimate = estimateTokensWithTiktoken(encoding)\n break\n case 'gemini':\n estimate = estimateTokensWithGemini()\n break\n case 'llama2':\n estimate = estimateTokensWithLlama2()\n break\n case 'claude':\n estimate = estimateTokensWithClaudeHeuristic()\n break\n }\n if (estimate === Number.POSITIVE_INFINITY) {\n estimate = Math.ceil(this.#value.length / 4)\n } else {\n this.#cache.set(encoding, estimate)\n }\n return estimate\n },\n enumerable: false,\n configurable: false,\n writable: false,\n },\n })\n }\n\n /**\n * Convenience overload for one-off token counting without managing a {@link Tokenizable} instance.\n *\n * @remarks\n * Creates a temporary instance and immediately discards it — no caching benefit. Use the\n * instance method when you need to count the same value under multiple encodings or when the\n * value may change over time.\n *\n * @param value - The string to count tokens for.\n * @param encoding - The encoding identifier to use for counting.\n * @returns The estimated number of tokens.\n */\n public static estimateTokens(value: string, encoding: TokenEncoding): number {\n const temp = new Tokenizable(value)\n return temp.estimateTokens(encoding)\n }\n\n /**\n * Returns `true` if `value` is a {@link Tokenizable} instance.\n *\n * @remarks\n * Uses {@link @nhtio/adk!isInstanceOf} for cross-realm safety — `instanceof` would fail for instances\n * created in a different module copy or VM context.\n *\n * @param value - The value to test.\n * @returns `true` when `value` is a {@link Tokenizable} instance.\n */\n public static isTokenizable(value: unknown): value is Tokenizable {\n return isInstanceOf(value, 'Tokenizable', Tokenizable)\n }\n}\n\n/**\n * Returns `true` if `value` is a {@link Tokenizable} instance.\n *\n * @remarks\n * Module-level convenience alias for {@link Tokenizable.isTokenizable}. Prefer this form when\n * you need a standalone type guard without importing the full class.\n *\n * Uses {@link @nhtio/adk!isInstanceOf} for cross-realm safety — `instanceof` would fail for instances\n * created in a different module copy or VM context.\n *\n * @param value - The value to test.\n * @returns `true` when `value` is a {@link Tokenizable} instance.\n */\nexport const isTokenizable = (value: unknown): value is Tokenizable => {\n return isInstanceOf(value, 'Tokenizable', Tokenizable)\n}\n","import { dset } from 'dset'\nimport { klona } from 'klona'\nimport { default as delve } from 'dlv'\nimport { isInstanceOf, isObject } from '../utils/guards'\nimport { E_INVALID_INITIAL_REGISTRY_VALUE } from '../exceptions/runtime'\n\n/**\n * A controlled-mutation key-value store with dot-path access and deep-clone isolation.\n *\n * @remarks\n * The registry enforces a safe read/write contract: callers never hold a live reference into\n * the internal store. Every value that enters (`set`) or leaves (`get`, `all`) is deep-cloned\n * via `klona`, so mutations to a retrieved value cannot affect stored state and vice versa.\n *\n * Keys are dot-delimited paths (e.g. `\"user.profile.name\"`), resolved via `dlv` for reads and\n * `dset` for writes; intermediate objects are created automatically on write.\n */\nexport class Registry {\n #store: Record<string, unknown>\n\n /**\n * @param initial - Optional plain object to seed the registry. Deep-cloned on construction.\n * @throws {@link @nhtio/adk!E_INVALID_INITIAL_REGISTRY_VALUE} when `initial` is defined but not a plain object.\n */\n constructor(initial?: Record<string, unknown>) {\n if ('undefined' !== typeof initial && !isObject(initial)) {\n throw new E_INVALID_INITIAL_REGISTRY_VALUE()\n }\n this.#store = initial ? klona(initial) : {}\n }\n\n /**\n * Returns `true` if `value` is a {@link Registry} instance.\n *\n * @remarks\n * Uses {@link @nhtio/adk!isInstanceOf} for cross-realm safety.\n *\n * @param value - The value to test.\n * @returns `true` when `value` is a {@link Registry} instance.\n */\n public static isRegistry(value: unknown): value is Registry {\n return isInstanceOf(value, 'Registry', Registry)\n }\n\n /**\n * Retrieves the value at `key`, returning `defaultValue` if the path is absent.\n *\n * @remarks\n * The returned value is a deep clone — mutating it will not affect the stored state.\n *\n * @typeParam T - Expected type of the value at `key`.\n * @param key - Dot-delimited path into the store (e.g. `\"user.name\"`).\n * @param defaultValue - Fallback returned when the path resolves to `undefined`.\n * @returns A deep clone of the stored value cast to `T`, or `defaultValue` when the path is absent.\n */\n get<T = unknown>(key: string, defaultValue?: T): T {\n const cloned = klona(this.#store)\n const value = delve(cloned, key)\n return 'undefined' === typeof value ? (defaultValue as T) : (value as T)\n }\n\n /**\n * Sets the value at `key`, creating intermediate objects as needed.\n *\n * @remarks\n * The stored value is isolated from the caller — mutating `value` after this call will not\n * affect what is held in the registry.\n *\n * @param key - Dot-delimited path into the store (e.g. `\"user.name\"`).\n * @param value - Value to store at the path.\n */\n set(key: string, value: unknown): void {\n dset(this.#store, key, value)\n }\n\n /**\n * Returns `true` if the registry has a value at `key`, `false` otherwise.\n *\n * @remarks\n * A key resolving to `undefined` is treated as absent — same convention as {@link Registry.get}'s\n * `defaultValue` fallback. No clone is performed; this is a pure existence check.\n *\n * @param key - Dot-delimited path into the store (e.g. `\"user.name\"`).\n * @returns `true` when the path resolves to a value other than `undefined`.\n */\n has(key: string): boolean {\n return 'undefined' !== typeof delve(this.#store, key)\n }\n\n /**\n * Returns all leaf dot-paths present in the registry.\n *\n * @remarks\n * The store is deep-cloned before traversal. Plain objects are walked recursively with path\n * segments joined by dots; arrays, primitives, `null`, and class instances are treated as leaves.\n *\n * @returns A string array of dot-delimited paths to leaf values in the store.\n */\n keys(): string[] {\n const store = klona(this.#store)\n const keys: string[] = []\n\n const isPlainRecord = (value: unknown): value is Record<string, unknown> => {\n if (!isObject(value)) return false\n const prototype = Object.getPrototypeOf(value)\n return prototype === Object.prototype || prototype === null\n }\n\n const walk = (value: unknown, segments: string[]): void => {\n if (!isPlainRecord(value)) {\n if (segments.length > 0) keys.push(segments.join('.'))\n return\n }\n\n for (const [segment, child] of Object.entries(value)) {\n walk(child, [...segments, segment])\n }\n }\n\n walk(store, [])\n return keys\n }\n\n /**\n * Returns a deep clone of the entire store contents.\n *\n * @returns A plain object snapshot of all stored key-value pairs.\n */\n all(): Record<string, unknown> {\n return klona(this.#store)\n }\n}\n","/**\n * Canonical `JSON.stringify` that sorts object keys recursively so that semantically-equal\n * objects produce identical strings.\n *\n * @remarks\n * Used wherever the ADK derives a stable identity from a structured value — for example,\n * `Tool.executor` computing the `callId` for `ToolExecutionStart`/`End` events, and the\n * `reportToolCall` executor helper computing the `checksum` field on `TurnToolCallContent`.\n * Both code paths hash `canonicalStringify({ tool, args })` so that argument key order does not\n * affect the resulting identifier.\n *\n * Arrays are serialised in their declared order (order is meaningful for an array). Object keys\n * are sorted with `Array.prototype.sort()`'s default lexicographic comparator.\n *\n * @param value - The value to serialise.\n * @returns A canonical JSON string representation of `value`.\n */\nexport function canonicalStringify(value: unknown): string {\n if (value === null || typeof value !== 'object') return JSON.stringify(value)\n if (Array.isArray(value)) return '[' + value.map((v) => canonicalStringify(v)).join(',') + ']'\n const obj = value as Record<string, unknown>\n const keys = Object.keys(obj).sort()\n return '{' + keys.map((k) => JSON.stringify(k) + ':' + canonicalStringify(obj[k])).join(',') + '}'\n}\n","import { isInstanceOf } from '../utils/guards'\nimport { E_TOOL_ALREADY_REGISTERED } from '../exceptions/runtime'\nimport type { Tool } from './tool'\nimport type { DispatchContext } from '../contracts/dispatch_context'\n\n/**\n * Options accepted by {@link ToolRegistry.merge}.\n */\nexport interface MergeOptions {\n /**\n * What to do when two registries contain a tool with the same name AND neither tool's own\n * `onCollision` resolves the collision.\n *\n * @remarks\n * - `'throw'` (default): raise {@link @nhtio/adk!E_TOOL_ALREADY_REGISTERED} on the first unresolved\n * collision. Mirrors the default behaviour of {@link ToolRegistry.register} and surfaces\n * accidental name shadowing immediately.\n * - `'replace'`: the later registry's tool wins.\n * - `'keep'`: the earlier registry's tool wins; later occurrences are dropped.\n *\n * Per-tool {@link @nhtio/adk!Tool.onCollision} takes precedence: if the incoming tool declares\n * `'replace'` or `'keep'`, that policy wins regardless of this option. Only when the incoming\n * tool's policy is `'throw'` (the default) does this fallback apply.\n *\n * @defaultValue `'throw'`\n */\n onCollision?: 'throw' | 'replace' | 'keep'\n}\n\n/**\n * A mutable, turn-scoped collection of {@link @nhtio/adk!Tool} instances.\n *\n * @remarks\n * Each `TurnRunner.run()` call constructs a fresh `ToolRegistry` from the runner's configured\n * baseline tools, so middleware edits are isolated to the current turn and cannot bleed across\n * concurrent or subsequent turns.\n *\n * `Tool` instances are immutable, so `all()` returns a fresh array without deep-cloning.\n *\n * `register()` throws {@link @nhtio/adk!E_TOOL_ALREADY_REGISTERED} if a tool with the same name is already\n * present — pass `overwrite: true` to replace it explicitly.\n */\nexport class ToolRegistry {\n #tools: Map<string, Tool>\n\n /**\n * Returns `true` if `value` is a {@link ToolRegistry} instance.\n *\n * @param value - The value to test.\n * @returns `true` when `value` is a {@link ToolRegistry} instance.\n */\n public static isToolRegistry(value: unknown): value is ToolRegistry {\n return isInstanceOf(value, 'ToolRegistry', ToolRegistry)\n }\n\n /**\n * @param tools - Optional initial tools. Insertion order is preserved. Duplicate names throw\n * {@link @nhtio/adk!E_TOOL_ALREADY_REGISTERED} — ensure each tool has a unique name.\n * @throws {@link @nhtio/adk!E_TOOL_ALREADY_REGISTERED} when two tools in `tools` share a name.\n */\n constructor(tools?: Tool[]) {\n this.#tools = new Map()\n for (const tool of tools ?? []) {\n this.register(tool)\n }\n }\n\n /**\n * Adds a tool to the registry.\n *\n * @param tool - The tool to register.\n * @param overwrite - When `true`, silently replaces an existing tool with the same name.\n * Defaults to `false`.\n * @throws {@link @nhtio/adk!E_TOOL_ALREADY_REGISTERED} when a tool with the same name is already registered\n * and `overwrite` is not `true`.\n */\n register(tool: Tool, overwrite?: boolean): void {\n if (this.#tools.has(tool.name) && !overwrite) {\n throw new E_TOOL_ALREADY_REGISTERED()\n }\n this.#tools.set(tool.name, tool)\n }\n\n /**\n * Removes the tool with the given name from the registry.\n *\n * @remarks\n * No-ops if no tool with that name is registered.\n *\n * @param name - The name of the tool to remove.\n */\n unregister(name: string): void {\n this.#tools.delete(name)\n }\n\n /**\n * Returns the tool registered under `name`, or `undefined` if not present.\n *\n * @param name - The tool name to look up.\n */\n get(name: string): Tool | undefined {\n return this.#tools.get(name)\n }\n\n /**\n * Returns `true` if a tool with the given name is registered.\n *\n * @param name - The tool name to test.\n */\n has(name: string): boolean {\n return this.#tools.has(name)\n }\n\n /**\n * Returns a fresh array of all registered tools in insertion order.\n *\n * @remarks\n * Since {@link @nhtio/adk!Tool} instances are immutable, no deep-cloning is needed.\n */\n all(): Tool[] {\n return Array.from(this.#tools.values())\n }\n\n /**\n * Removes every tool whose {@link @nhtio/adk!Tool.ephemeral} flag is `true`.\n *\n * @remarks\n * Synchronous and idempotent — calling it twice in a row is a no-op the second time. The\n * canonical caller is {@link ToolRegistry.bindContext}, which schedules this method to run\n * at {@link @nhtio/adk!DispatchContext.ack}. Non-ephemeral tools are left untouched.\n */\n pruneEphemeral(): void {\n for (const [name, tool] of this.#tools) {\n if (tool.ephemeral) {\n this.#tools.delete(name)\n }\n }\n }\n\n /**\n * Binds this registry to a {@link @nhtio/adk!DispatchContext} so that {@link pruneEphemeral} runs\n * automatically when the context is acked.\n *\n * @remarks\n * The handler does NOT fire on {@link @nhtio/adk!DispatchContext.nack} — failed executor runs leave\n * any forged tools in place so the consumer can inspect what was registered when debugging the\n * failure. Subscriptions are short-lived and die with the context regardless.\n *\n * Forgetting this call after merging in `Subclass.forgeTools(ctx)` output means ephemeral tools\n * accumulate across executor invocations, and subsequent `forgeTools(ctx)` calls in later\n * iterations will see a stale `callId` enum that excludes new tool calls. The plan-documented\n * pattern is:\n *\n * ```ts\n * const executor: DispatchExecutorFn = async (ctx) => {\n * const forged = SpooledArtifact.forgeTools(ctx)\n * const merged = ToolRegistry.merge([main, forged])\n * main.bindContext(ctx)\n * const result = await llm.invoke({ tools: merged.all(), ... })\n * ctx.ack()\n * }\n * ```\n *\n * @param ctx - The execution context whose `ack` event should trigger pruning.\n * @returns An unsubscribe function — calling it before `ctx.ack()` prevents pruning. Rarely\n * useful outside of tests.\n *\n * @see {@link @nhtio/adk!SpooledArtifact.forgeTools}\n * @see {@link @nhtio/adk!DispatchContext.onAck}\n */\n bindContext(ctx: DispatchContext): () => void {\n return ctx.onAck(() => this.pruneEphemeral())\n }\n\n /**\n * Combines multiple {@link ToolRegistry} instances into a fresh registry without mutating any\n * input.\n *\n * @remarks\n * Iteration is left-to-right across `registries` and then in each registry's insertion order.\n * Collisions are resolved by consulting the **incoming** tool's {@link @nhtio/adk!Tool.onCollision} first:\n *\n * - `'replace'` (per-tool): the incoming tool wins, replacing the existing entry.\n * - `'keep'` (per-tool): the existing entry wins; the incoming tool is dropped.\n * - `'throw'` (per-tool, the default): fall back to the merge-level `options.onCollision`.\n *\n * The merge-level `options.onCollision` defaults to `'throw'`, which mirrors {@link register}.\n *\n * The result is a brand-new registry; no input is mutated and no event subscription is\n * propagated. Each `Tool`'s `ephemeral` flag carries through unchanged — the flag lives on the\n * tool, not the registry, so `bindContext(ctx)` on the merged registry will prune the forged\n * tools as expected.\n *\n * @param registries - Registries to merge, in priority order (left-to-right insertion).\n * @param options - Merge-level collision policy. Defaults to `{ onCollision: 'throw' }`.\n * @returns A fresh {@link ToolRegistry} containing the resolved union of all inputs.\n * @throws {@link @nhtio/adk!E_TOOL_ALREADY_REGISTERED} when the resolved collision policy is `'throw'`\n * and a collision occurs.\n */\n static merge(registries: ToolRegistry[], options?: MergeOptions): ToolRegistry {\n const policy = options?.onCollision ?? 'throw'\n const merged = new ToolRegistry()\n for (const registry of registries) {\n for (const tool of registry.all()) {\n const existing = merged.get(tool.name)\n if (!existing) {\n merged.register(tool)\n continue\n }\n const incomingPolicy = tool.onCollision\n if (incomingPolicy === 'replace') {\n merged.register(tool, true)\n continue\n }\n if (incomingPolicy === 'keep') {\n continue\n }\n // Incoming policy is 'throw' — fall back to the merge-level option.\n if (policy === 'replace') {\n merged.register(tool, true)\n continue\n }\n if (policy === 'keep') {\n continue\n }\n throw new E_TOOL_ALREADY_REGISTERED()\n }\n }\n return merged\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAgBA,IAAa,gBACX,OACA,MACA,SACe;CAEf,IAAI,gBAAgB,OAAO,QAAQ,iBAAiB,MAAM,OAAO;;CAEjE,IACE,gBAAgB,OAAO,QACvB,OAAO,KAAK,OAAO,iBAAiB,cACpC,KAAK,OAAO,aAAa,KAAK;;CAG9B,OAAO;CAET,IAAI,aAAa,OAAO,SAAS,SAAS,OAGxC,OADwB,MAAqB,aAAa,SAC/B;CAE7B,OAAO;AACT;AAEA,IAAM,cAAc,UACjB,IAA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