@nhtio/adk 1.20260612.0 → 1.20260624.1

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 (306) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/batteries/embeddings/openai/adapter.cjs +1 -1
  3. package/batteries/embeddings/openai/adapter.mjs +1 -1
  4. package/batteries/embeddings/webllm/adapter.cjs +1 -1
  5. package/batteries/embeddings/webllm/adapter.mjs +1 -1
  6. package/batteries/encoding/index.d.ts +70 -0
  7. package/batteries/encoding.cjs +135 -0
  8. package/batteries/encoding.cjs.map +1 -0
  9. package/batteries/encoding.mjs +129 -0
  10. package/batteries/encoding.mjs.map +1 -0
  11. package/batteries/llm/ollama/adapter.cjs +5 -5
  12. package/batteries/llm/ollama/adapter.mjs +5 -5
  13. package/batteries/llm/ollama/helpers.cjs +2 -2
  14. package/batteries/llm/ollama/helpers.mjs +2 -2
  15. package/batteries/llm/ollama/validation.cjs +1 -1
  16. package/batteries/llm/ollama/validation.mjs +1 -1
  17. package/batteries/llm/openai_chat_completions/adapter.cjs +5 -5
  18. package/batteries/llm/openai_chat_completions/adapter.mjs +5 -5
  19. package/batteries/llm/openai_chat_completions/helpers.cjs +2 -2
  20. package/batteries/llm/openai_chat_completions/helpers.mjs +2 -2
  21. package/batteries/llm/openai_chat_completions/validation.cjs +1 -1
  22. package/batteries/llm/openai_chat_completions/validation.mjs +1 -1
  23. package/batteries/llm/webllm_chat_completions/adapter.cjs +5 -5
  24. package/batteries/llm/webllm_chat_completions/adapter.mjs +5 -5
  25. package/batteries/llm/webllm_chat_completions/validation.cjs +1 -1
  26. package/batteries/llm/webllm_chat_completions/validation.mjs +1 -1
  27. package/batteries/media/contracts.cjs +1 -1
  28. package/batteries/media/contracts.mjs +1 -1
  29. package/batteries/media/engines/audio_decode.cjs +1 -1
  30. package/batteries/media/engines/audio_decode.mjs +1 -1
  31. package/batteries/media/engines/data.cjs +1 -1
  32. package/batteries/media/engines/data.mjs +1 -1
  33. package/batteries/media/engines/exceljs.cjs +1 -1
  34. package/batteries/media/engines/exceljs.mjs +1 -1
  35. package/batteries/media/engines/execa_executor.cjs +1 -1
  36. package/batteries/media/engines/execa_executor.mjs +1 -1
  37. package/batteries/media/engines/fs_workspace.cjs +1 -1
  38. package/batteries/media/engines/fs_workspace.mjs +1 -1
  39. package/batteries/media/engines/jimp.cjs +1 -1
  40. package/batteries/media/engines/jimp.mjs +1 -1
  41. package/batteries/media/engines/sharp.cjs +1 -1
  42. package/batteries/media/engines/sharp.mjs +1 -1
  43. package/batteries/media/engines/sheetjs.cjs +1 -1
  44. package/batteries/media/engines/sheetjs.mjs +1 -1
  45. package/batteries/media/engines/tesseract_js.cjs +1 -1
  46. package/batteries/media/engines/tesseract_js.mjs +1 -1
  47. package/batteries/media/engines/transformers_asr.cjs +1 -1
  48. package/batteries/media/engines/transformers_asr.mjs +1 -1
  49. package/batteries/media/forge.cjs +6 -6
  50. package/batteries/media/forge.mjs +6 -6
  51. package/batteries/media/lint.cjs +1 -1
  52. package/batteries/media/lint.mjs +1 -1
  53. package/batteries/media.cjs +2 -2
  54. package/batteries/media.mjs +2 -2
  55. package/batteries/storage/flydrive/index.d.ts +8 -1
  56. package/batteries/storage/flydrive.cjs +17 -1
  57. package/batteries/storage/flydrive.cjs.map +1 -1
  58. package/batteries/storage/flydrive.mjs +17 -2
  59. package/batteries/storage/flydrive.mjs.map +1 -1
  60. package/batteries/storage/in_memory/index.d.ts +7 -1
  61. package/batteries/storage/in_memory.cjs +13 -1
  62. package/batteries/storage/in_memory.cjs.map +1 -1
  63. package/batteries/storage/in_memory.mjs +13 -2
  64. package/batteries/storage/in_memory.mjs.map +1 -1
  65. package/batteries/storage/opfs/index.d.ts +19 -1
  66. package/batteries/storage/opfs.cjs +28 -3
  67. package/batteries/storage/opfs.cjs.map +1 -1
  68. package/batteries/storage/opfs.mjs +28 -4
  69. package/batteries/storage/opfs.mjs.map +1 -1
  70. package/batteries/storage.cjs +1 -0
  71. package/batteries/storage.mjs +2 -2
  72. package/batteries/tools/_shared.cjs +2 -2
  73. package/batteries/tools/_shared.mjs +2 -2
  74. package/batteries/tools/color.cjs +2 -2
  75. package/batteries/tools/color.mjs +2 -2
  76. package/batteries/tools/comparison.cjs +3 -3
  77. package/batteries/tools/comparison.mjs +3 -3
  78. package/batteries/tools/data_structure.cjs +3 -3
  79. package/batteries/tools/data_structure.mjs +3 -3
  80. package/batteries/tools/datetime_extended.cjs +2 -2
  81. package/batteries/tools/datetime_extended.mjs +2 -2
  82. package/batteries/tools/datetime_math.cjs +2 -2
  83. package/batteries/tools/datetime_math.mjs +2 -2
  84. package/batteries/tools/encoding.cjs +3 -3
  85. package/batteries/tools/encoding.mjs +3 -3
  86. package/batteries/tools/formatting.cjs +3 -3
  87. package/batteries/tools/formatting.mjs +3 -3
  88. package/batteries/tools/geo_basics.cjs +2 -2
  89. package/batteries/tools/geo_basics.mjs +2 -2
  90. package/batteries/tools/math.cjs +3 -3
  91. package/batteries/tools/math.mjs +3 -3
  92. package/batteries/tools/memory.cjs +5 -5
  93. package/batteries/tools/memory.mjs +5 -5
  94. package/batteries/tools/parsing.cjs +4 -4
  95. package/batteries/tools/parsing.mjs +4 -4
  96. package/batteries/tools/retrievables.cjs +4 -4
  97. package/batteries/tools/retrievables.mjs +4 -4
  98. package/batteries/tools/scrapper.cjs +1 -1
  99. package/batteries/tools/scrapper.mjs +1 -1
  100. package/batteries/tools/searxng.cjs +1 -1
  101. package/batteries/tools/searxng.mjs +1 -1
  102. package/batteries/tools/standing_instructions.cjs +4 -4
  103. package/batteries/tools/standing_instructions.mjs +4 -4
  104. package/batteries/tools/statistics.cjs +4 -4
  105. package/batteries/tools/statistics.mjs +4 -4
  106. package/batteries/tools/string_processing.cjs +3 -3
  107. package/batteries/tools/string_processing.mjs +3 -3
  108. package/batteries/tools/structured_data.cjs +3 -3
  109. package/batteries/tools/structured_data.mjs +3 -3
  110. package/batteries/tools/text_analysis.cjs +3 -3
  111. package/batteries/tools/text_analysis.mjs +3 -3
  112. package/batteries/tools/text_comparison.cjs +2 -2
  113. package/batteries/tools/text_comparison.mjs +2 -2
  114. package/batteries/tools/time.cjs +2 -2
  115. package/batteries/tools/time.mjs +2 -2
  116. package/batteries/tools/unit_conversion.cjs +2 -2
  117. package/batteries/tools/unit_conversion.mjs +2 -2
  118. package/batteries/tools/web_retrieval.cjs +1 -1
  119. package/batteries/tools/web_retrieval.mjs +1 -1
  120. package/batteries/tools.cjs +2 -2
  121. package/batteries/tools.mjs +2 -2
  122. package/batteries/vector/arangodb.cjs +1 -1
  123. package/batteries/vector/arangodb.mjs +1 -1
  124. package/batteries/vector/chroma.cjs +1 -1
  125. package/batteries/vector/chroma.mjs +1 -1
  126. package/batteries/vector/clickhouse.cjs +2 -2
  127. package/batteries/vector/clickhouse.mjs +2 -2
  128. package/batteries/vector/cloudflare.cjs +2 -2
  129. package/batteries/vector/cloudflare.mjs +2 -2
  130. package/batteries/vector/couchbase.cjs +2 -2
  131. package/batteries/vector/couchbase.mjs +2 -2
  132. package/batteries/vector/duckdb.cjs +2 -2
  133. package/batteries/vector/duckdb.mjs +2 -2
  134. package/batteries/vector/elasticsearch.cjs +2 -2
  135. package/batteries/vector/elasticsearch.mjs +2 -2
  136. package/batteries/vector/filters.cjs +1 -1
  137. package/batteries/vector/filters.mjs +1 -1
  138. package/batteries/vector/hnswlib.cjs +2 -2
  139. package/batteries/vector/hnswlib.mjs +2 -2
  140. package/batteries/vector/in_memory.cjs +1 -1
  141. package/batteries/vector/in_memory.mjs +1 -1
  142. package/batteries/vector/lancedb.cjs +2 -2
  143. package/batteries/vector/lancedb.mjs +2 -2
  144. package/batteries/vector/mariadb.cjs +2 -2
  145. package/batteries/vector/mariadb.mjs +2 -2
  146. package/batteries/vector/meilisearch.cjs +1 -1
  147. package/batteries/vector/meilisearch.mjs +1 -1
  148. package/batteries/vector/migrate.cjs +1 -1
  149. package/batteries/vector/migrate.mjs +1 -1
  150. package/batteries/vector/milvus.cjs +1 -1
  151. package/batteries/vector/milvus.mjs +1 -1
  152. package/batteries/vector/mongodb.cjs +1 -1
  153. package/batteries/vector/mongodb.mjs +1 -1
  154. package/batteries/vector/neo4j.cjs +1 -1
  155. package/batteries/vector/neo4j.mjs +1 -1
  156. package/batteries/vector/opensearch.cjs +2 -2
  157. package/batteries/vector/opensearch.mjs +2 -2
  158. package/batteries/vector/oracle23ai.cjs +2 -2
  159. package/batteries/vector/oracle23ai.mjs +2 -2
  160. package/batteries/vector/orama.cjs +1 -1
  161. package/batteries/vector/orama.mjs +1 -1
  162. package/batteries/vector/pgvector.cjs +1 -1
  163. package/batteries/vector/pgvector.mjs +1 -1
  164. package/batteries/vector/pinecone.cjs +2 -2
  165. package/batteries/vector/pinecone.mjs +2 -2
  166. package/batteries/vector/qdrant.cjs +1 -1
  167. package/batteries/vector/qdrant.mjs +1 -1
  168. package/batteries/vector/redis.cjs +2 -2
  169. package/batteries/vector/redis.mjs +2 -2
  170. package/batteries/vector/retrievable.cjs +1 -1
  171. package/batteries/vector/retrievable.mjs +1 -1
  172. package/batteries/vector/s3vectors.cjs +2 -2
  173. package/batteries/vector/s3vectors.mjs +2 -2
  174. package/batteries/vector/solr.cjs +1 -1
  175. package/batteries/vector/solr.mjs +1 -1
  176. package/batteries/vector/sqlite_vec.cjs +1 -1
  177. package/batteries/vector/sqlite_vec.mjs +1 -1
  178. package/batteries/vector/surrealdb.cjs +1 -1
  179. package/batteries/vector/surrealdb.mjs +1 -1
  180. package/batteries/vector/typesense.cjs +2 -2
  181. package/batteries/vector/typesense.mjs +2 -2
  182. package/batteries/vector/vespa.cjs +2 -2
  183. package/batteries/vector/vespa.mjs +2 -2
  184. package/batteries/vector/weaviate.cjs +2 -2
  185. package/batteries/vector/weaviate.mjs +2 -2
  186. package/batteries/vector.cjs +2 -2
  187. package/batteries/vector.mjs +2 -2
  188. package/batteries.cjs +11 -11
  189. package/batteries.mjs +11 -11
  190. package/{common-_77pbLLS.mjs → common-0CmrSKNb.mjs} +79 -10
  191. package/common-0CmrSKNb.mjs.map +1 -0
  192. package/{common-6WOPAB3-.js → common-CpcsEqPY.js} +90 -9
  193. package/common-CpcsEqPY.js.map +1 -0
  194. package/common.cjs +15 -7
  195. package/common.d.ts +17 -1
  196. package/common.mjs +8 -8
  197. package/{dispatch_runner-CwXLFXms.mjs → dispatch_runner-C2ZpFfw4.mjs} +3 -3
  198. package/{dispatch_runner-CwXLFXms.mjs.map → dispatch_runner-C2ZpFfw4.mjs.map} +1 -1
  199. package/{dispatch_runner-BP0WMfao.js → dispatch_runner-DMTkGHQI.js} +3 -3
  200. package/{dispatch_runner-BP0WMfao.js.map → dispatch_runner-DMTkGHQI.js.map} +1 -1
  201. package/dispatch_runner.cjs +1 -1
  202. package/dispatch_runner.mjs +1 -1
  203. package/eslint.cjs +1 -1
  204. package/eslint.mjs +1 -1
  205. package/exceptions.cjs +3 -1
  206. package/exceptions.d.ts +1 -1
  207. package/exceptions.mjs +2 -2
  208. package/forge.cjs +4 -4
  209. package/forge.mjs +4 -4
  210. package/guards.cjs +8 -8
  211. package/guards.mjs +8 -8
  212. package/index.cjs +13 -11
  213. package/index.cjs.map +1 -1
  214. package/index.d.ts +1 -1
  215. package/index.mjs +12 -12
  216. package/index.mjs.map +1 -1
  217. package/lib/classes/artifact_tool.d.ts +20 -0
  218. package/lib/classes/encodable.d.ts +19 -0
  219. package/lib/classes/identity.d.ts +20 -0
  220. package/lib/classes/media.d.ts +28 -0
  221. package/lib/classes/memory.d.ts +20 -0
  222. package/lib/classes/message.d.ts +24 -0
  223. package/lib/classes/registry.d.ts +20 -0
  224. package/lib/classes/retrievable.d.ts +21 -0
  225. package/lib/classes/spooled_artifact.d.ts +40 -0
  226. package/lib/classes/spooled_json_artifact.d.ts +22 -0
  227. package/lib/classes/spooled_markdown_artifact.d.ts +20 -0
  228. package/lib/classes/thought.d.ts +22 -0
  229. package/lib/classes/tokenizable.d.ts +20 -0
  230. package/lib/classes/tool.d.ts +34 -0
  231. package/lib/classes/tool_call.d.ts +23 -0
  232. package/lib/classes/tool_registry.d.ts +21 -0
  233. package/lib/contracts/media_reader.d.ts +18 -0
  234. package/lib/contracts/reader_descriptor.d.ts +39 -0
  235. package/lib/contracts/reader_resolvers.d.ts +82 -0
  236. package/lib/contracts/spool_reader.d.ts +16 -0
  237. package/lib/exceptions/runtime.d.ts +44 -0
  238. package/lib/helpers/base64.d.ts +34 -0
  239. package/lib/helpers/media_readers.d.ts +18 -0
  240. package/lib/utils/encoder_symbols.d.ts +25 -0
  241. package/mcp/adk-docs-corpus.json +1 -1
  242. package/package.json +140 -131
  243. package/{runtime-CyagS1pm.mjs → runtime-D2VRuySV.mjs} +42 -2
  244. package/{runtime-CyagS1pm.mjs.map → runtime-D2VRuySV.mjs.map} +1 -1
  245. package/{runtime-BiLlk2Ul.js → runtime-UzFb0eCc.js} +53 -1
  246. package/{runtime-BiLlk2Ul.js.map → runtime-UzFb0eCc.js.map} +1 -1
  247. package/{scrapper-E_XqhFva.js → scrapper-BUCxsVVi.js} +5 -5
  248. package/{scrapper-E_XqhFva.js.map → scrapper-BUCxsVVi.js.map} +1 -1
  249. package/{scrapper-BEkHTv7V.mjs → scrapper-CxmS0VaD.mjs} +5 -5
  250. package/{scrapper-BEkHTv7V.mjs.map → scrapper-CxmS0VaD.mjs.map} +1 -1
  251. package/{searxng-Bzvo_MCZ.js → searxng-CgxQluyF.js} +5 -5
  252. package/{searxng-Bzvo_MCZ.js.map → searxng-CgxQluyF.js.map} +1 -1
  253. package/{searxng-Bo85zPpQ.mjs → searxng-Dgh-4RpS.mjs} +5 -5
  254. package/{searxng-Bo85zPpQ.mjs.map → searxng-Dgh-4RpS.mjs.map} +1 -1
  255. package/server.json +2 -2
  256. package/skills/adk-assembly/SKILL.md +2 -2
  257. package/{spooled_artifact-xA7Te-kE.js → spooled_artifact-MbMz6NXX.js} +182 -4
  258. package/spooled_artifact-MbMz6NXX.js.map +1 -0
  259. package/{spooled_artifact-CmL5ci5Z.mjs → spooled_artifact-fgc1lutm.mjs} +160 -6
  260. package/spooled_artifact-fgc1lutm.mjs.map +1 -0
  261. package/spooled_artifact.cjs +2 -2
  262. package/spooled_artifact.mjs +2 -2
  263. package/{spooled_markdown_artifact-sEU_esW6.mjs → spooled_markdown_artifact-3sK6HFRw.mjs} +53 -3
  264. package/spooled_markdown_artifact-3sK6HFRw.mjs.map +1 -0
  265. package/{spooled_markdown_artifact-B3wDMxcb.js → spooled_markdown_artifact-Gj0ruiLJ.js} +53 -3
  266. package/spooled_markdown_artifact-Gj0ruiLJ.js.map +1 -0
  267. package/{thought-c4d-q-3R.js → thought-CU7PYkB1.js} +124 -4
  268. package/thought-CU7PYkB1.js.map +1 -0
  269. package/{thought-DXnh31HJ.mjs → thought-DmcfCRAw.mjs} +124 -4
  270. package/thought-DmcfCRAw.mjs.map +1 -0
  271. package/{tool-DerXDcez.js → tool-Bt6tmFXT.js} +53 -3
  272. package/tool-Bt6tmFXT.js.map +1 -0
  273. package/{tool-DnebtFed.mjs → tool-C_uxdxjp.mjs} +54 -4
  274. package/tool-C_uxdxjp.mjs.map +1 -0
  275. package/{tool_call-Bua8qpko.js → tool_call-BixyvnWZ.js} +155 -23
  276. package/tool_call-BixyvnWZ.js.map +1 -0
  277. package/{tool_call-D69JEDXJ.mjs → tool_call-pfvAsgkY.mjs} +144 -24
  278. package/tool_call-pfvAsgkY.mjs.map +1 -0
  279. package/{tool_registry-bWKC6jt1.js → tool_registry-CIIfbY_w.js} +124 -3
  280. package/tool_registry-CIIfbY_w.js.map +1 -0
  281. package/{tool_registry-QKQYr8Tp.mjs → tool_registry-FeMMz993.mjs} +113 -4
  282. package/tool_registry-FeMMz993.mjs.map +1 -0
  283. package/{turn_runner-Cg4xdghG.mjs → turn_runner-Brz6Sd0F.mjs} +5 -5
  284. package/{turn_runner-Cg4xdghG.mjs.map → turn_runner-Brz6Sd0F.mjs.map} +1 -1
  285. package/{turn_runner-CrpcyQbJ.js → turn_runner-DB-WWls8.js} +5 -5
  286. package/{turn_runner-CrpcyQbJ.js.map → turn_runner-DB-WWls8.js.map} +1 -1
  287. package/turn_runner.cjs +1 -1
  288. package/turn_runner.mjs +1 -1
  289. package/{validate-DKanpGpG.js → validate-B4RXgYJC.js} +2 -2
  290. package/{validate-DKanpGpG.js.map → validate-B4RXgYJC.js.map} +1 -1
  291. package/{validate-CHaqFmX6.mjs → validate-MBEmBzMl.mjs} +2 -2
  292. package/{validate-CHaqFmX6.mjs.map → validate-MBEmBzMl.mjs.map} +1 -1
  293. package/common-6WOPAB3-.js.map +0 -1
  294. package/common-_77pbLLS.mjs.map +0 -1
  295. package/spooled_artifact-CmL5ci5Z.mjs.map +0 -1
  296. package/spooled_artifact-xA7Te-kE.js.map +0 -1
  297. package/spooled_markdown_artifact-B3wDMxcb.js.map +0 -1
  298. package/spooled_markdown_artifact-sEU_esW6.mjs.map +0 -1
  299. package/thought-DXnh31HJ.mjs.map +0 -1
  300. package/thought-c4d-q-3R.js.map +0 -1
  301. package/tool-DerXDcez.js.map +0 -1
  302. package/tool-DnebtFed.mjs.map +0 -1
  303. package/tool_call-Bua8qpko.js.map +0 -1
  304. package/tool_call-D69JEDXJ.mjs.map +0 -1
  305. package/tool_registry-QKQYr8Tp.mjs.map +0 -1
  306. package/tool_registry-bWKC6jt1.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -15,6 +15,75 @@ you *when* you got it, not *what changed*: a `^` range will float across battery
15
15
  breaking changes, so pin an exact version if you need stability and read the entry before
16
16
  upgrading.
17
17
 
18
+ ## 2026-06-24
19
+
20
+ ### Added
21
+
22
+ - **Serialization: the ADK primitives now round-trip through [`@nhtio/encoder`](https://encoder.nht.io).**
23
+ Encode an entire conversation graph — `Message`s with nested `Identity`, `Tokenizable`, and `Media`;
24
+ `ToolCall`s with their results; `Memory`, `Thought`, `Retrievable`, `Registry` — to a string with
25
+ `encode()` and rebuild it (instances, not plain objects) with `decode()`. Every primitive implements
26
+ the encoder's custom-class contract via raw `Symbol.for()` keys, so **the contract adds zero
27
+ dependency to the core** — `@nhtio/encoder` is an optional peer, pulled in only by the new battery.
28
+ - **New opt-in battery `@nhtio/adk/batteries/encoding`.** Call `registerAdkEncodables()` once at startup,
29
+ before your first `decode()` — it registers every primitive with the decoder and auto-registers the
30
+ binding-free reader resolvers (in-memory, fetch). This is the only code that imports `@nhtio/encoder`.
31
+ - **Reader handles round-trip, not bytes.** `Media` and `SpooledArtifact` serialize the *handle* — a
32
+ tagged, re-openable locator — via a new optional `describe()` method on the `MediaReader` /
33
+ `SpoolReader` contracts. On decode, a tag→reader resolver registry (`registerMediaReaderResolver` /
34
+ `registerSpoolReaderResolver`) re-binds the handle to a live reader; for durable stores (flydrive,
35
+ OPFS) the consumer registers the resolver carrying the live `Disk`/root the locator cannot itself
36
+ carry. In-memory readers inline their buffer; the fetch reader captures its URL.
37
+ - **New exceptions** `E_READER_NOT_DESCRIBABLE` (encoding a primitive whose reader has no `describe()` —
38
+ e.g. a `fromWebFile`-backed `Media`) and `E_NO_READER_RESOLVER` (decoding a handle whose tag has no
39
+ registered resolver), both exported from `@nhtio/adk/exceptions`.
40
+
41
+ #### Not encodable, by design
42
+
43
+ - **`TurnGate`** wraps a live pending Promise + `AbortController` — there is no serialized form of "a
44
+ thing some caller is awaiting", so it deliberately does not implement the contract.
45
+ - **`Tool` handlers serialize by source text only.** A handler that closes over `ctx`, service clients,
46
+ or config loses those bindings on decode (the captured variables read back `undefined`); a `.bind()`-ed
47
+ or native handler cannot be serialized at all. `Tool.inputSchema` round-trips losslessly via
48
+ `@nhtio/validation`'s own `encode`/`decode`. Tools are rarely serialized; when they are, reconstruct
49
+ dependencies inside the handler body rather than closing over them.
50
+ - **`fromWebFile`-backed `Media`** is not encodable — a browser `Blob` has no re-openable locator and the
51
+ synchronous encoder cannot drain it. Persist to a media/spool store and wrap in a describable reader
52
+ first.
53
+
54
+ This release is **additive — no major bump** (per the `<major>.<YYYYMMDD>.<n>` scheme, the major moves
55
+ only on core-contract breaks). The symbol methods are new surface; the new optional `describe()` on the
56
+ reader contracts is backward-compatible (optional method, duck-typed schemas unchanged); no existing
57
+ primitive constructor or field changed.
58
+
59
+ ### Fixed
60
+
61
+ - **`Message` with empty `attachments` is no longer mis-rejected by its own serializer.** The
62
+ newly-added `Message` encode path emitted `attachments: []` for text-only messages, which the message
63
+ schema's "at least one of content/attachments, and a present `attachments` must be non-empty"
64
+ cross-field rule then rejected on `decode()`. The encode snapshot now omits `attachments` entirely when
65
+ empty. Only reachable via the new serialization path — no impact on existing construction.
66
+
67
+ ## 2026-06-23
68
+
69
+ ### Fixed
70
+
71
+ - **`Tokenizable` now caches the tiktoken encoder instead of rebuilding it per call**
72
+ (reported against `1.20260612.0` from a Node/AdonisJS host embedding the ADK). `js-tiktoken`'s
73
+ `getEncoding` has no internal cache — every call does `new Tiktoken(<ranks>)`, parsing the full
74
+ BPE rank table (~800 ms for `o200k_base`), which is ~1000× the cost of the `encode()` that
75
+ follows. The tiktoken backend was the one estimator that never got the lazy-singleton treatment
76
+ the Gemini and Llama backends already had, so a fresh encoder was constructed on **every**
77
+ `estimateTokens` invocation that missed the per-value memo. On a tool-heavy turn — where a
78
+ battery re-measures an accumulating dispatch context once per iteration — this rebuilt the BPE
79
+ table O(results × iterations) times, saturating a single-threaded host's event loop (CPU pegged,
80
+ RSS oscillating multi-GB under GC of the repeatedly-allocated vocabulary, co-tenant HTTP
81
+ starved). The encoder is now memoized in a module-level `Map<TokenEncoding, Tiktoken>`, mirroring
82
+ the existing Gemini/Llama singletons; construction drops to once per encoding per process.
83
+ Behaviour-preserving (`Tiktoken` instances are stateless and reusable), benefits every
84
+ tokenization path ADK-wide, and is the single highest-leverage change against the reported
85
+ event-loop starvation.
86
+
18
87
  ## 2026-06-12
19
88
 
20
89
  ### Added
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("../../../chunk-Cek0wNdY.js");
3
- const require_tool_registry = require("../../../tool_registry-bWKC6jt1.js");
3
+ const require_tool_registry = require("../../../tool_registry-CIIfbY_w.js");
4
4
  require("../../../guards.cjs");
5
5
  const require_lib_utils_retry = require("../../../lib/utils/retry.cjs");
6
6
  const require_batteries_embeddings_openai_exceptions = require("./exceptions.cjs");
@@ -1,4 +1,4 @@
1
- import { o as isError } from "../../../tool_registry-QKQYr8Tp.mjs";
1
+ import { c as isError } from "../../../tool_registry-FeMMz993.mjs";
2
2
  import "../../../guards.mjs";
3
3
  import { computeBackoff, parseRetryAfter, sleepWithJitter } from "../../../lib/utils/retry.mjs";
4
4
  import { E_OPENAI_EMBEDDINGS_HTTP_ERROR, E_OPENAI_EMBEDDINGS_MALFORMED_RESPONSE, E_OPENAI_EMBEDDINGS_REQUEST_TIMEOUT } from "./exceptions.mjs";
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("../../../chunk-Cek0wNdY.js");
3
- const require_tool_registry = require("../../../tool_registry-bWKC6jt1.js");
3
+ const require_tool_registry = require("../../../tool_registry-CIIfbY_w.js");
4
4
  require("../../../guards.cjs");
5
5
  const require_batteries_embeddings_openai_helpers = require("../openai/helpers.cjs");
6
6
  const require_batteries_embeddings_webllm_exceptions = require("./exceptions.cjs");
@@ -1,4 +1,4 @@
1
- import { o as isError } from "../../../tool_registry-QKQYr8Tp.mjs";
1
+ import { c as isError } from "../../../tool_registry-FeMMz993.mjs";
2
2
  import "../../../guards.mjs";
3
3
  import { applyEmbeddingPrefix } from "../openai/helpers.mjs";
4
4
  import { E_INVALID_WEBLLM_EMBEDDINGS_OPTIONS, E_WEBLLM_EMBEDDINGS_ENGINE_ERROR } from "./exceptions.mjs";
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Opt-in serialization battery: make the ADK primitives round-trip through `@nhtio/encoder`.
3
+ *
4
+ * @module @nhtio/adk/batteries/encoding
5
+ *
6
+ * @remarks
7
+ * The ADK primitives already carry the `@nhtio/encoder` custom-class contract — they implement the
8
+ * `Symbol.for('@nhtio/encoder:toEncoded' | ':fromEncoded')` methods with **zero dependency** on the
9
+ * encoder. That half works whether or not `@nhtio/encoder` is installed. This battery wires up the
10
+ * *other* half — the part that genuinely needs the encoder — and nothing else imports it:
11
+ *
12
+ * 1. `registerAdkEncodables()` — tells the decoder how to map each `custom:<ClassName>` wire tag back to
13
+ * its constructor. Call it **once, before your first `decode()`**. Without it, `encode()` still works
14
+ * but `decode()` throws on every ADK primitive.
15
+ * 2. Auto-registers the **in-memory** and **fetch** reader resolvers (they carry no live binding, so they
16
+ * need nothing from you). Durable-store resolvers — flydrive `Disk`, OPFS root — you register yourself
17
+ * with {@link registerSpoolReaderResolver} / {@link registerMediaReaderResolver}, because only you hold
18
+ * the live binding the serialised locator cannot carry.
19
+ *
20
+ * ::: what this battery does NOT do
21
+ * It serialises the **conversation graph**, not your storage. It does not persist anything — it turns a
22
+ * live object tree into a string and back. It does not conjure live bindings: a reader handle decodes to
23
+ * a working reader only if you registered a resolver for its tag. It does not make closures portable: a
24
+ * {@link @nhtio/adk!Tool} handler serialises by source text only (see {@link @nhtio/adk!Tool}). And it
25
+ * cannot serialise a {@link @nhtio/adk!TurnGate} — a live pending Promise has no serialised form.
26
+ * :::
27
+ *
28
+ * @example Register once at startup, then encode/decode freely.
29
+ * ```typescript
30
+ * import { encode, decode } from '@nhtio/encoder'
31
+ * import { registerAdkEncodables } from '@nhtio/adk/batteries/encoding'
32
+ *
33
+ * registerAdkEncodables()
34
+ *
35
+ * const wire = encode(message) // a Message with nested Identity / Tokenizable / Media
36
+ * const restored = decode<Message>(wire) // instanceof Message, nested primitives intact
37
+ * ```
38
+ *
39
+ * @example Durable-store media/artifacts need a resolver carrying the live binding.
40
+ * ```typescript
41
+ * import { Disk } from 'flydrive'
42
+ * import { FlydriveSpoolReader } from '@nhtio/adk/batteries/storage/flydrive'
43
+ * import { registerAdkEncodables, registerSpoolReaderResolver } from '@nhtio/adk/batteries/encoding'
44
+ *
45
+ * registerAdkEncodables()
46
+ * const disk = new Disk(myDriver)
47
+ * registerSpoolReaderResolver('spool:flydrive', (locator) => {
48
+ * const { key, streamThresholdBytes } = locator as { key: string; streamThresholdBytes?: number }
49
+ * return new FlydriveSpoolReader(disk, key, { streamThresholdBytes })
50
+ * })
51
+ * ```
52
+ */
53
+ /**
54
+ * Re-export the resolver-registration functions so consumers wire durable-store bindings from one place.
55
+ */
56
+ export { registerMediaReaderResolver, registerSpoolReaderResolver, resolveMediaReader, resolveSpoolReader, } from "../../common";
57
+ export type { ReaderDescriptor, LocatorValue, MediaReaderResolver, SpoolReaderResolver, } from "../../common";
58
+ /**
59
+ * Register every ADK primitive with the `@nhtio/encoder` decoder, and auto-register the binding-free
60
+ * reader resolvers (in-memory, fetch).
61
+ *
62
+ * @remarks
63
+ * Idempotent — safe to call more than once (re-registering a class is a no-op overwrite). Call it once at
64
+ * application startup, before the first `decode()`. Encoding never needs this; only decoding does,
65
+ * because the decoder must map a `custom:<ClassName>` tag back to a constructor.
66
+ *
67
+ * Durable-store reader resolvers (flydrive, OPFS) are NOT registered here — they need the live `Disk` /
68
+ * OPFS root only you hold. Register them yourself with {@link registerSpoolReaderResolver}.
69
+ */
70
+ export declare const registerAdkEncodables: () => void;
@@ -0,0 +1,135 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("../chunk-Cek0wNdY.js");
3
+ const require_tool_registry = require("../tool_registry-CIIfbY_w.js");
4
+ const require_thought = require("../thought-CU7PYkB1.js");
5
+ const require_tool = require("../tool-Bt6tmFXT.js");
6
+ const require_spooled_artifact = require("../spooled_artifact-MbMz6NXX.js");
7
+ const require_common = require("../common-CpcsEqPY.js");
8
+ const require_tool_call = require("../tool_call-BixyvnWZ.js");
9
+ const require_spooled_markdown_artifact = require("../spooled_markdown_artifact-Gj0ruiLJ.js");
10
+ require("../index.cjs");
11
+ const require_batteries_storage_in_memory = require("./storage/in_memory.cjs");
12
+ let _nhtio_encoder = require("@nhtio/encoder");
13
+ //#region src/batteries/encoding/index.ts
14
+ /**
15
+ * Opt-in serialization battery: make the ADK primitives round-trip through `@nhtio/encoder`.
16
+ *
17
+ * @module @nhtio/adk/batteries/encoding
18
+ *
19
+ * @remarks
20
+ * The ADK primitives already carry the `@nhtio/encoder` custom-class contract — they implement the
21
+ * `Symbol.for('@nhtio/encoder:toEncoded' | ':fromEncoded')` methods with **zero dependency** on the
22
+ * encoder. That half works whether or not `@nhtio/encoder` is installed. This battery wires up the
23
+ * *other* half — the part that genuinely needs the encoder — and nothing else imports it:
24
+ *
25
+ * 1. `registerAdkEncodables()` — tells the decoder how to map each `custom:<ClassName>` wire tag back to
26
+ * its constructor. Call it **once, before your first `decode()`**. Without it, `encode()` still works
27
+ * but `decode()` throws on every ADK primitive.
28
+ * 2. Auto-registers the **in-memory** and **fetch** reader resolvers (they carry no live binding, so they
29
+ * need nothing from you). Durable-store resolvers — flydrive `Disk`, OPFS root — you register yourself
30
+ * with {@link registerSpoolReaderResolver} / {@link registerMediaReaderResolver}, because only you hold
31
+ * the live binding the serialised locator cannot carry.
32
+ *
33
+ * ::: what this battery does NOT do
34
+ * It serialises the **conversation graph**, not your storage. It does not persist anything — it turns a
35
+ * live object tree into a string and back. It does not conjure live bindings: a reader handle decodes to
36
+ * a working reader only if you registered a resolver for its tag. It does not make closures portable: a
37
+ * {@link @nhtio/adk!Tool} handler serialises by source text only (see {@link @nhtio/adk!Tool}). And it
38
+ * cannot serialise a {@link @nhtio/adk!TurnGate} — a live pending Promise has no serialised form.
39
+ * :::
40
+ *
41
+ * @example Register once at startup, then encode/decode freely.
42
+ * ```typescript
43
+ * import { encode, decode } from '@nhtio/encoder'
44
+ * import { registerAdkEncodables } from '@nhtio/adk/batteries/encoding'
45
+ *
46
+ * registerAdkEncodables()
47
+ *
48
+ * const wire = encode(message) // a Message with nested Identity / Tokenizable / Media
49
+ * const restored = decode<Message>(wire) // instanceof Message, nested primitives intact
50
+ * ```
51
+ *
52
+ * @example Durable-store media/artifacts need a resolver carrying the live binding.
53
+ * ```typescript
54
+ * import { Disk } from 'flydrive'
55
+ * import { FlydriveSpoolReader } from '@nhtio/adk/batteries/storage/flydrive'
56
+ * import { registerAdkEncodables, registerSpoolReaderResolver } from '@nhtio/adk/batteries/encoding'
57
+ *
58
+ * registerAdkEncodables()
59
+ * const disk = new Disk(myDriver)
60
+ * registerSpoolReaderResolver('spool:flydrive', (locator) => {
61
+ * const { key, streamThresholdBytes } = locator as { key: string; streamThresholdBytes?: number }
62
+ * return new FlydriveSpoolReader(disk, key, { streamThresholdBytes })
63
+ * })
64
+ * ```
65
+ */
66
+ /**
67
+ * Every ADK primitive that opts in to the `@nhtio/encoder` custom-class contract.
68
+ *
69
+ * @remarks
70
+ * `TurnGate` is intentionally absent — it wraps a live pending Promise and `AbortController` that cannot
71
+ * survive serialisation. Each entry must expose a static `[DECODE_METHOD]`, which `registerClass`
72
+ * requires.
73
+ */
74
+ var ENCODABLE_CLASSES = [
75
+ require_tool_registry.Tokenizable,
76
+ require_tool_registry.Registry,
77
+ require_thought.Identity,
78
+ require_thought.Memory,
79
+ require_thought.Message,
80
+ require_common.Retrievable,
81
+ require_thought.Thought,
82
+ require_tool_call.ToolCall,
83
+ require_tool.Tool,
84
+ require_spooled_artifact.ArtifactTool,
85
+ require_tool_registry.ToolRegistry,
86
+ require_spooled_artifact.SpooledArtifact,
87
+ require_spooled_markdown_artifact.SpooledJsonArtifact,
88
+ require_spooled_markdown_artifact.SpooledMarkdownArtifact,
89
+ require_tool_call.Media
90
+ ];
91
+ var autoResolversRegistered = false;
92
+ /**
93
+ * Auto-register the resolvers that need no live binding: in-memory (bytes inlined in the locator) and
94
+ * fetch (URL re-issued on read). Idempotent.
95
+ */
96
+ var registerBindingFreeResolvers = () => {
97
+ if (autoResolversRegistered) return;
98
+ autoResolversRegistered = true;
99
+ require_spooled_artifact.registerMediaReaderResolver(require_common.MEDIA_READER_TAG_IN_MEMORY, (locator) => {
100
+ const { bytesBase64 } = locator;
101
+ return require_common.inMemoryMediaReader(require_tool_call.decodeBase64(bytesBase64));
102
+ });
103
+ require_spooled_artifact.registerMediaReaderResolver(require_common.MEDIA_READER_TAG_FETCH, (locator) => {
104
+ const { url, init } = locator;
105
+ return require_common.fromFetch(url, init);
106
+ });
107
+ require_spooled_artifact.registerSpoolReaderResolver(require_batteries_storage_in_memory.SPOOL_READER_TAG_IN_MEMORY, (locator) => {
108
+ const { content } = locator;
109
+ return new require_batteries_storage_in_memory.InMemorySpoolReader(content);
110
+ });
111
+ };
112
+ /**
113
+ * Register every ADK primitive with the `@nhtio/encoder` decoder, and auto-register the binding-free
114
+ * reader resolvers (in-memory, fetch).
115
+ *
116
+ * @remarks
117
+ * Idempotent — safe to call more than once (re-registering a class is a no-op overwrite). Call it once at
118
+ * application startup, before the first `decode()`. Encoding never needs this; only decoding does,
119
+ * because the decoder must map a `custom:<ClassName>` tag back to a constructor.
120
+ *
121
+ * Durable-store reader resolvers (flydrive, OPFS) are NOT registered here — they need the live `Disk` /
122
+ * OPFS root only you hold. Register them yourself with {@link registerSpoolReaderResolver}.
123
+ */
124
+ var registerAdkEncodables = () => {
125
+ for (const ctor of ENCODABLE_CLASSES) (0, _nhtio_encoder.registerClass)(ctor);
126
+ registerBindingFreeResolvers();
127
+ };
128
+ //#endregion
129
+ exports.registerAdkEncodables = registerAdkEncodables;
130
+ exports.registerMediaReaderResolver = require_spooled_artifact.registerMediaReaderResolver;
131
+ exports.registerSpoolReaderResolver = require_spooled_artifact.registerSpoolReaderResolver;
132
+ exports.resolveMediaReader = require_spooled_artifact.resolveMediaReader;
133
+ exports.resolveSpoolReader = require_spooled_artifact.resolveSpoolReader;
134
+
135
+ //# sourceMappingURL=encoding.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encoding.cjs","names":[],"sources":["../../src/batteries/encoding/index.ts"],"sourcesContent":["/**\n * Opt-in serialization battery: make the ADK primitives round-trip through `@nhtio/encoder`.\n *\n * @module @nhtio/adk/batteries/encoding\n *\n * @remarks\n * The ADK primitives already carry the `@nhtio/encoder` custom-class contract — they implement the\n * `Symbol.for('@nhtio/encoder:toEncoded' | ':fromEncoded')` methods with **zero dependency** on the\n * encoder. That half works whether or not `@nhtio/encoder` is installed. This battery wires up the\n * *other* half — the part that genuinely needs the encoder — and nothing else imports it:\n *\n * 1. `registerAdkEncodables()` — tells the decoder how to map each `custom:<ClassName>` wire tag back to\n * its constructor. Call it **once, before your first `decode()`**. Without it, `encode()` still works\n * but `decode()` throws on every ADK primitive.\n * 2. Auto-registers the **in-memory** and **fetch** reader resolvers (they carry no live binding, so they\n * need nothing from you). Durable-store resolvers — flydrive `Disk`, OPFS root — you register yourself\n * with {@link registerSpoolReaderResolver} / {@link registerMediaReaderResolver}, because only you hold\n * the live binding the serialised locator cannot carry.\n *\n * ::: what this battery does NOT do\n * It serialises the **conversation graph**, not your storage. It does not persist anything — it turns a\n * live object tree into a string and back. It does not conjure live bindings: a reader handle decodes to\n * a working reader only if you registered a resolver for its tag. It does not make closures portable: a\n * {@link @nhtio/adk!Tool} handler serialises by source text only (see {@link @nhtio/adk!Tool}). And it\n * cannot serialise a {@link @nhtio/adk!TurnGate} — a live pending Promise has no serialised form.\n * :::\n *\n * @example Register once at startup, then encode/decode freely.\n * ```typescript\n * import { encode, decode } from '@nhtio/encoder'\n * import { registerAdkEncodables } from '@nhtio/adk/batteries/encoding'\n *\n * registerAdkEncodables()\n *\n * const wire = encode(message) // a Message with nested Identity / Tokenizable / Media\n * const restored = decode<Message>(wire) // instanceof Message, nested primitives intact\n * ```\n *\n * @example Durable-store media/artifacts need a resolver carrying the live binding.\n * ```typescript\n * import { Disk } from 'flydrive'\n * import { FlydriveSpoolReader } from '@nhtio/adk/batteries/storage/flydrive'\n * import { registerAdkEncodables, registerSpoolReaderResolver } from '@nhtio/adk/batteries/encoding'\n *\n * registerAdkEncodables()\n * const disk = new Disk(myDriver)\n * registerSpoolReaderResolver('spool:flydrive', (locator) => {\n * const { key, streamThresholdBytes } = locator as { key: string; streamThresholdBytes?: number }\n * return new FlydriveSpoolReader(disk, key, { streamThresholdBytes })\n * })\n * ```\n */\n\nimport { registerClass } from '@nhtio/encoder'\nimport {\n InMemorySpoolReader,\n SPOOL_READER_TAG_IN_MEMORY,\n} from '@nhtio/adk/batteries/storage/in_memory'\nimport {\n registerMediaReaderResolver,\n registerSpoolReaderResolver,\n inMemoryMediaReader,\n fromFetch,\n decodeBase64,\n MEDIA_READER_TAG_IN_MEMORY,\n MEDIA_READER_TAG_FETCH,\n} from '@nhtio/adk/common'\nimport {\n Tokenizable,\n Registry,\n Identity,\n Memory,\n Message,\n Retrievable,\n Thought,\n ToolCall,\n Tool,\n ArtifactTool,\n ToolRegistry,\n SpooledArtifact,\n SpooledJsonArtifact,\n SpooledMarkdownArtifact,\n Media,\n} from '@nhtio/adk'\nimport type { LocatorValue } from '@nhtio/adk/common'\n\n/**\n * Re-export the resolver-registration functions so consumers wire durable-store bindings from one place.\n */\nexport {\n registerMediaReaderResolver,\n registerSpoolReaderResolver,\n resolveMediaReader,\n resolveSpoolReader,\n} from '@nhtio/adk/common'\nexport type {\n ReaderDescriptor,\n LocatorValue,\n MediaReaderResolver,\n SpoolReaderResolver,\n} from '@nhtio/adk/common'\n\n/**\n * Every ADK primitive that opts in to the `@nhtio/encoder` custom-class contract.\n *\n * @remarks\n * `TurnGate` is intentionally absent — it wraps a live pending Promise and `AbortController` that cannot\n * survive serialisation. Each entry must expose a static `[DECODE_METHOD]`, which `registerClass`\n * requires.\n */\nconst ENCODABLE_CLASSES = [\n Tokenizable,\n Registry,\n Identity,\n Memory,\n Message,\n Retrievable,\n Thought,\n ToolCall,\n Tool,\n ArtifactTool,\n ToolRegistry,\n SpooledArtifact,\n SpooledJsonArtifact,\n SpooledMarkdownArtifact,\n Media,\n] as const\n\nlet autoResolversRegistered = false\n\n/**\n * Auto-register the resolvers that need no live binding: in-memory (bytes inlined in the locator) and\n * fetch (URL re-issued on read). Idempotent.\n */\nconst registerBindingFreeResolvers = (): void => {\n if (autoResolversRegistered) return\n autoResolversRegistered = true\n\n registerMediaReaderResolver(MEDIA_READER_TAG_IN_MEMORY, (locator: LocatorValue) => {\n const { bytesBase64 } = locator as { bytesBase64: string }\n return inMemoryMediaReader(decodeBase64(bytesBase64))\n })\n\n registerMediaReaderResolver(MEDIA_READER_TAG_FETCH, (locator: LocatorValue) => {\n const { url, init } = locator as unknown as { url: string; init?: RequestInit }\n return fromFetch(url, init)\n })\n\n registerSpoolReaderResolver(SPOOL_READER_TAG_IN_MEMORY, (locator: LocatorValue) => {\n const { content } = locator as { content: string }\n return new InMemorySpoolReader(content)\n })\n}\n\n/**\n * Register every ADK primitive with the `@nhtio/encoder` decoder, and auto-register the binding-free\n * reader resolvers (in-memory, fetch).\n *\n * @remarks\n * Idempotent — safe to call more than once (re-registering a class is a no-op overwrite). Call it once at\n * application startup, before the first `decode()`. Encoding never needs this; only decoding does,\n * because the decoder must map a `custom:<ClassName>` tag back to a constructor.\n *\n * Durable-store reader resolvers (flydrive, OPFS) are NOT registered here — they need the live `Disk` /\n * OPFS root only you hold. Register them yourself with {@link registerSpoolReaderResolver}.\n */\nexport const registerAdkEncodables = (): void => {\n for (const ctor of ENCODABLE_CLASSES) {\n // The ADK primitives implement the contract via raw `Symbol.for()` keys (zero-dep \"Option B\"), so\n // their static `[DECODE_METHOD]` is keyed by a symbol nominally distinct from the encoder's own\n // `unique symbol` — identical at runtime (`Symbol.for('@nhtio/encoder:fromEncoded')`), but not\n // structurally assignable to `DecodableConstructor` at the type level. The cast bridges that gap.\n registerClass(ctor as unknown as Parameters<typeof registerClass>[0])\n }\n registerBindingFreeResolvers()\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8GA,IAAM,oBAAoB;CACxB,sBAAA;CACA,sBAAA;CACA,gBAAA;CACA,gBAAA;CACA,gBAAA;CACA,eAAA;CACA,gBAAA;CACA,kBAAA;CACA,aAAA;CACA,yBAAA;CACA,sBAAA;CACA,yBAAA;CACA,kCAAA;CACA,kCAAA;CACA,kBAAA;AACF;AAEA,IAAI,0BAA0B;;;;;AAM9B,IAAM,qCAA2C;CAC/C,IAAI,yBAAyB;CAC7B,0BAA0B;CAE1B,yBAAA,4BAA4B,eAAA,6BAA6B,YAA0B;EACjF,MAAM,EAAE,gBAAgB;EACxB,OAAO,eAAA,oBAAoB,kBAAA,aAAa,WAAW,CAAC;CACtD,CAAC;CAED,yBAAA,4BAA4B,eAAA,yBAAyB,YAA0B;EAC7E,MAAM,EAAE,KAAK,SAAS;EACtB,OAAO,eAAA,UAAU,KAAK,IAAI;CAC5B,CAAC;CAED,yBAAA,4BAA4B,oCAAA,6BAA6B,YAA0B;EACjF,MAAM,EAAE,YAAY;EACpB,OAAO,IAAI,oCAAA,oBAAoB,OAAO;CACxC,CAAC;AACH;;;;;;;;;;;;;AAcA,IAAa,8BAAoC;CAC/C,KAAK,MAAM,QAAQ,mBAKjB,CAAA,GAAA,eAAA,eAAc,IAAsD;CAEtE,6BAA6B;AAC/B"}
@@ -0,0 +1,129 @@
1
+ import { a as Tokenizable, r as Registry, t as ToolRegistry } from "../tool_registry-FeMMz993.mjs";
2
+ import { i as Identity, n as Message, r as Memory, t as Thought } from "../thought-DmcfCRAw.mjs";
3
+ import { t as Tool } from "../tool-C_uxdxjp.mjs";
4
+ import { a as resolveMediaReader, c as ArtifactTool, i as registerSpoolReaderResolver, o as resolveSpoolReader, r as registerMediaReaderResolver, t as SpooledArtifact } from "../spooled_artifact-fgc1lutm.mjs";
5
+ import { a as inMemoryMediaReader, c as Retrievable, n as MEDIA_READER_TAG_IN_MEMORY, r as fromFetch, t as MEDIA_READER_TAG_FETCH } from "../common-0CmrSKNb.mjs";
6
+ import { n as Media, o as decodeBase64, t as ToolCall } from "../tool_call-pfvAsgkY.mjs";
7
+ import { n as SpooledJsonArtifact, t as SpooledMarkdownArtifact } from "../spooled_markdown_artifact-3sK6HFRw.mjs";
8
+ import "../index.mjs";
9
+ import { InMemorySpoolReader, SPOOL_READER_TAG_IN_MEMORY } from "./storage/in_memory.mjs";
10
+ import { registerClass } from "@nhtio/encoder";
11
+ //#region src/batteries/encoding/index.ts
12
+ /**
13
+ * Opt-in serialization battery: make the ADK primitives round-trip through `@nhtio/encoder`.
14
+ *
15
+ * @module @nhtio/adk/batteries/encoding
16
+ *
17
+ * @remarks
18
+ * The ADK primitives already carry the `@nhtio/encoder` custom-class contract — they implement the
19
+ * `Symbol.for('@nhtio/encoder:toEncoded' | ':fromEncoded')` methods with **zero dependency** on the
20
+ * encoder. That half works whether or not `@nhtio/encoder` is installed. This battery wires up the
21
+ * *other* half — the part that genuinely needs the encoder — and nothing else imports it:
22
+ *
23
+ * 1. `registerAdkEncodables()` — tells the decoder how to map each `custom:<ClassName>` wire tag back to
24
+ * its constructor. Call it **once, before your first `decode()`**. Without it, `encode()` still works
25
+ * but `decode()` throws on every ADK primitive.
26
+ * 2. Auto-registers the **in-memory** and **fetch** reader resolvers (they carry no live binding, so they
27
+ * need nothing from you). Durable-store resolvers — flydrive `Disk`, OPFS root — you register yourself
28
+ * with {@link registerSpoolReaderResolver} / {@link registerMediaReaderResolver}, because only you hold
29
+ * the live binding the serialised locator cannot carry.
30
+ *
31
+ * ::: what this battery does NOT do
32
+ * It serialises the **conversation graph**, not your storage. It does not persist anything — it turns a
33
+ * live object tree into a string and back. It does not conjure live bindings: a reader handle decodes to
34
+ * a working reader only if you registered a resolver for its tag. It does not make closures portable: a
35
+ * {@link @nhtio/adk!Tool} handler serialises by source text only (see {@link @nhtio/adk!Tool}). And it
36
+ * cannot serialise a {@link @nhtio/adk!TurnGate} — a live pending Promise has no serialised form.
37
+ * :::
38
+ *
39
+ * @example Register once at startup, then encode/decode freely.
40
+ * ```typescript
41
+ * import { encode, decode } from '@nhtio/encoder'
42
+ * import { registerAdkEncodables } from '@nhtio/adk/batteries/encoding'
43
+ *
44
+ * registerAdkEncodables()
45
+ *
46
+ * const wire = encode(message) // a Message with nested Identity / Tokenizable / Media
47
+ * const restored = decode<Message>(wire) // instanceof Message, nested primitives intact
48
+ * ```
49
+ *
50
+ * @example Durable-store media/artifacts need a resolver carrying the live binding.
51
+ * ```typescript
52
+ * import { Disk } from 'flydrive'
53
+ * import { FlydriveSpoolReader } from '@nhtio/adk/batteries/storage/flydrive'
54
+ * import { registerAdkEncodables, registerSpoolReaderResolver } from '@nhtio/adk/batteries/encoding'
55
+ *
56
+ * registerAdkEncodables()
57
+ * const disk = new Disk(myDriver)
58
+ * registerSpoolReaderResolver('spool:flydrive', (locator) => {
59
+ * const { key, streamThresholdBytes } = locator as { key: string; streamThresholdBytes?: number }
60
+ * return new FlydriveSpoolReader(disk, key, { streamThresholdBytes })
61
+ * })
62
+ * ```
63
+ */
64
+ /**
65
+ * Every ADK primitive that opts in to the `@nhtio/encoder` custom-class contract.
66
+ *
67
+ * @remarks
68
+ * `TurnGate` is intentionally absent — it wraps a live pending Promise and `AbortController` that cannot
69
+ * survive serialisation. Each entry must expose a static `[DECODE_METHOD]`, which `registerClass`
70
+ * requires.
71
+ */
72
+ var ENCODABLE_CLASSES = [
73
+ Tokenizable,
74
+ Registry,
75
+ Identity,
76
+ Memory,
77
+ Message,
78
+ Retrievable,
79
+ Thought,
80
+ ToolCall,
81
+ Tool,
82
+ ArtifactTool,
83
+ ToolRegistry,
84
+ SpooledArtifact,
85
+ SpooledJsonArtifact,
86
+ SpooledMarkdownArtifact,
87
+ Media
88
+ ];
89
+ var autoResolversRegistered = false;
90
+ /**
91
+ * Auto-register the resolvers that need no live binding: in-memory (bytes inlined in the locator) and
92
+ * fetch (URL re-issued on read). Idempotent.
93
+ */
94
+ var registerBindingFreeResolvers = () => {
95
+ if (autoResolversRegistered) return;
96
+ autoResolversRegistered = true;
97
+ registerMediaReaderResolver(MEDIA_READER_TAG_IN_MEMORY, (locator) => {
98
+ const { bytesBase64 } = locator;
99
+ return inMemoryMediaReader(decodeBase64(bytesBase64));
100
+ });
101
+ registerMediaReaderResolver(MEDIA_READER_TAG_FETCH, (locator) => {
102
+ const { url, init } = locator;
103
+ return fromFetch(url, init);
104
+ });
105
+ registerSpoolReaderResolver(SPOOL_READER_TAG_IN_MEMORY, (locator) => {
106
+ const { content } = locator;
107
+ return new InMemorySpoolReader(content);
108
+ });
109
+ };
110
+ /**
111
+ * Register every ADK primitive with the `@nhtio/encoder` decoder, and auto-register the binding-free
112
+ * reader resolvers (in-memory, fetch).
113
+ *
114
+ * @remarks
115
+ * Idempotent — safe to call more than once (re-registering a class is a no-op overwrite). Call it once at
116
+ * application startup, before the first `decode()`. Encoding never needs this; only decoding does,
117
+ * because the decoder must map a `custom:<ClassName>` tag back to a constructor.
118
+ *
119
+ * Durable-store reader resolvers (flydrive, OPFS) are NOT registered here — they need the live `Disk` /
120
+ * OPFS root only you hold. Register them yourself with {@link registerSpoolReaderResolver}.
121
+ */
122
+ var registerAdkEncodables = () => {
123
+ for (const ctor of ENCODABLE_CLASSES) registerClass(ctor);
124
+ registerBindingFreeResolvers();
125
+ };
126
+ //#endregion
127
+ export { registerAdkEncodables, registerMediaReaderResolver, registerSpoolReaderResolver, resolveMediaReader, resolveSpoolReader };
128
+
129
+ //# sourceMappingURL=encoding.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"encoding.mjs","names":[],"sources":["../../src/batteries/encoding/index.ts"],"sourcesContent":["/**\n * Opt-in serialization battery: make the ADK primitives round-trip through `@nhtio/encoder`.\n *\n * @module @nhtio/adk/batteries/encoding\n *\n * @remarks\n * The ADK primitives already carry the `@nhtio/encoder` custom-class contract — they implement the\n * `Symbol.for('@nhtio/encoder:toEncoded' | ':fromEncoded')` methods with **zero dependency** on the\n * encoder. That half works whether or not `@nhtio/encoder` is installed. This battery wires up the\n * *other* half — the part that genuinely needs the encoder — and nothing else imports it:\n *\n * 1. `registerAdkEncodables()` — tells the decoder how to map each `custom:<ClassName>` wire tag back to\n * its constructor. Call it **once, before your first `decode()`**. Without it, `encode()` still works\n * but `decode()` throws on every ADK primitive.\n * 2. Auto-registers the **in-memory** and **fetch** reader resolvers (they carry no live binding, so they\n * need nothing from you). Durable-store resolvers — flydrive `Disk`, OPFS root — you register yourself\n * with {@link registerSpoolReaderResolver} / {@link registerMediaReaderResolver}, because only you hold\n * the live binding the serialised locator cannot carry.\n *\n * ::: what this battery does NOT do\n * It serialises the **conversation graph**, not your storage. It does not persist anything — it turns a\n * live object tree into a string and back. It does not conjure live bindings: a reader handle decodes to\n * a working reader only if you registered a resolver for its tag. It does not make closures portable: a\n * {@link @nhtio/adk!Tool} handler serialises by source text only (see {@link @nhtio/adk!Tool}). And it\n * cannot serialise a {@link @nhtio/adk!TurnGate} — a live pending Promise has no serialised form.\n * :::\n *\n * @example Register once at startup, then encode/decode freely.\n * ```typescript\n * import { encode, decode } from '@nhtio/encoder'\n * import { registerAdkEncodables } from '@nhtio/adk/batteries/encoding'\n *\n * registerAdkEncodables()\n *\n * const wire = encode(message) // a Message with nested Identity / Tokenizable / Media\n * const restored = decode<Message>(wire) // instanceof Message, nested primitives intact\n * ```\n *\n * @example Durable-store media/artifacts need a resolver carrying the live binding.\n * ```typescript\n * import { Disk } from 'flydrive'\n * import { FlydriveSpoolReader } from '@nhtio/adk/batteries/storage/flydrive'\n * import { registerAdkEncodables, registerSpoolReaderResolver } from '@nhtio/adk/batteries/encoding'\n *\n * registerAdkEncodables()\n * const disk = new Disk(myDriver)\n * registerSpoolReaderResolver('spool:flydrive', (locator) => {\n * const { key, streamThresholdBytes } = locator as { key: string; streamThresholdBytes?: number }\n * return new FlydriveSpoolReader(disk, key, { streamThresholdBytes })\n * })\n * ```\n */\n\nimport { registerClass } from '@nhtio/encoder'\nimport {\n InMemorySpoolReader,\n SPOOL_READER_TAG_IN_MEMORY,\n} from '@nhtio/adk/batteries/storage/in_memory'\nimport {\n registerMediaReaderResolver,\n registerSpoolReaderResolver,\n inMemoryMediaReader,\n fromFetch,\n decodeBase64,\n MEDIA_READER_TAG_IN_MEMORY,\n MEDIA_READER_TAG_FETCH,\n} from '@nhtio/adk/common'\nimport {\n Tokenizable,\n Registry,\n Identity,\n Memory,\n Message,\n Retrievable,\n Thought,\n ToolCall,\n Tool,\n ArtifactTool,\n ToolRegistry,\n SpooledArtifact,\n SpooledJsonArtifact,\n SpooledMarkdownArtifact,\n Media,\n} from '@nhtio/adk'\nimport type { LocatorValue } from '@nhtio/adk/common'\n\n/**\n * Re-export the resolver-registration functions so consumers wire durable-store bindings from one place.\n */\nexport {\n registerMediaReaderResolver,\n registerSpoolReaderResolver,\n resolveMediaReader,\n resolveSpoolReader,\n} from '@nhtio/adk/common'\nexport type {\n ReaderDescriptor,\n LocatorValue,\n MediaReaderResolver,\n SpoolReaderResolver,\n} from '@nhtio/adk/common'\n\n/**\n * Every ADK primitive that opts in to the `@nhtio/encoder` custom-class contract.\n *\n * @remarks\n * `TurnGate` is intentionally absent — it wraps a live pending Promise and `AbortController` that cannot\n * survive serialisation. Each entry must expose a static `[DECODE_METHOD]`, which `registerClass`\n * requires.\n */\nconst ENCODABLE_CLASSES = [\n Tokenizable,\n Registry,\n Identity,\n Memory,\n Message,\n Retrievable,\n Thought,\n ToolCall,\n Tool,\n ArtifactTool,\n ToolRegistry,\n SpooledArtifact,\n SpooledJsonArtifact,\n SpooledMarkdownArtifact,\n Media,\n] as const\n\nlet autoResolversRegistered = false\n\n/**\n * Auto-register the resolvers that need no live binding: in-memory (bytes inlined in the locator) and\n * fetch (URL re-issued on read). Idempotent.\n */\nconst registerBindingFreeResolvers = (): void => {\n if (autoResolversRegistered) return\n autoResolversRegistered = true\n\n registerMediaReaderResolver(MEDIA_READER_TAG_IN_MEMORY, (locator: LocatorValue) => {\n const { bytesBase64 } = locator as { bytesBase64: string }\n return inMemoryMediaReader(decodeBase64(bytesBase64))\n })\n\n registerMediaReaderResolver(MEDIA_READER_TAG_FETCH, (locator: LocatorValue) => {\n const { url, init } = locator as unknown as { url: string; init?: RequestInit }\n return fromFetch(url, init)\n })\n\n registerSpoolReaderResolver(SPOOL_READER_TAG_IN_MEMORY, (locator: LocatorValue) => {\n const { content } = locator as { content: string }\n return new InMemorySpoolReader(content)\n })\n}\n\n/**\n * Register every ADK primitive with the `@nhtio/encoder` decoder, and auto-register the binding-free\n * reader resolvers (in-memory, fetch).\n *\n * @remarks\n * Idempotent — safe to call more than once (re-registering a class is a no-op overwrite). Call it once at\n * application startup, before the first `decode()`. Encoding never needs this; only decoding does,\n * because the decoder must map a `custom:<ClassName>` tag back to a constructor.\n *\n * Durable-store reader resolvers (flydrive, OPFS) are NOT registered here — they need the live `Disk` /\n * OPFS root only you hold. Register them yourself with {@link registerSpoolReaderResolver}.\n */\nexport const registerAdkEncodables = (): void => {\n for (const ctor of ENCODABLE_CLASSES) {\n // The ADK primitives implement the contract via raw `Symbol.for()` keys (zero-dep \"Option B\"), so\n // their static `[DECODE_METHOD]` is keyed by a symbol nominally distinct from the encoder's own\n // `unique symbol` — identical at runtime (`Symbol.for('@nhtio/encoder:fromEncoded')`), but not\n // structurally assignable to `DecodableConstructor` at the type level. The cast bridges that gap.\n registerClass(ctor as unknown as Parameters<typeof registerClass>[0])\n }\n registerBindingFreeResolvers()\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8GA,IAAM,oBAAoB;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,IAAI,0BAA0B;;;;;AAM9B,IAAM,qCAA2C;CAC/C,IAAI,yBAAyB;CAC7B,0BAA0B;CAE1B,4BAA4B,6BAA6B,YAA0B;EACjF,MAAM,EAAE,gBAAgB;EACxB,OAAO,oBAAoB,aAAa,WAAW,CAAC;CACtD,CAAC;CAED,4BAA4B,yBAAyB,YAA0B;EAC7E,MAAM,EAAE,KAAK,SAAS;EACtB,OAAO,UAAU,KAAK,IAAI;CAC5B,CAAC;CAED,4BAA4B,6BAA6B,YAA0B;EACjF,MAAM,EAAE,YAAY;EACpB,OAAO,IAAI,oBAAoB,OAAO;CACxC,CAAC;AACH;;;;;;;;;;;;;AAcA,IAAa,8BAAoC;CAC/C,KAAK,MAAM,QAAQ,mBAKjB,cAAc,IAAsD;CAEtE,6BAA6B;AAC/B"}
@@ -1,10 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("../../../chunk-Cek0wNdY.js");
3
- const require_tool_registry = require("../../../tool_registry-bWKC6jt1.js");
4
- const require_thought = require("../../../thought-c4d-q-3R.js");
5
- const require_spooled_artifact = require("../../../spooled_artifact-xA7Te-kE.js");
6
- require("../../../common-6WOPAB3-.js");
7
- const require_tool_call = require("../../../tool_call-Bua8qpko.js");
3
+ const require_tool_registry = require("../../../tool_registry-CIIfbY_w.js");
4
+ const require_thought = require("../../../thought-CU7PYkB1.js");
5
+ const require_spooled_artifact = require("../../../spooled_artifact-MbMz6NXX.js");
6
+ require("../../../common-CpcsEqPY.js");
7
+ const require_tool_call = require("../../../tool_call-BixyvnWZ.js");
8
8
  require("../../../guards.cjs");
9
9
  const require_lib_utils_retry = require("../../../lib/utils/retry.cjs");
10
10
  const require_batteries_storage_in_memory = require("../../storage/in_memory.cjs");
@@ -1,8 +1,8 @@
1
- import { a as Tokenizable, c as isObject, n as canonicalStringify, o as isError, s as isInstanceOf, t as ToolRegistry } from "../../../tool_registry-QKQYr8Tp.mjs";
2
- import { n as Message, t as Thought } from "../../../thought-DXnh31HJ.mjs";
3
- import { i as ArtifactTool, t as SpooledArtifact } from "../../../spooled_artifact-CmL5ci5Z.mjs";
4
- import "../../../common-_77pbLLS.mjs";
5
- import { n as Media, t as ToolCall } from "../../../tool_call-D69JEDXJ.mjs";
1
+ import { a as Tokenizable, c as isError, l as isInstanceOf, n as canonicalStringify, t as ToolRegistry, u as isObject } from "../../../tool_registry-FeMMz993.mjs";
2
+ import { n as Message, t as Thought } from "../../../thought-DmcfCRAw.mjs";
3
+ import { c as ArtifactTool, t as SpooledArtifact } from "../../../spooled_artifact-fgc1lutm.mjs";
4
+ import "../../../common-0CmrSKNb.mjs";
5
+ import { n as Media, t as ToolCall } from "../../../tool_call-pfvAsgkY.mjs";
6
6
  import "../../../guards.mjs";
7
7
  import { computeBackoff, linkAbortSignals, parseRetryAfter, sleepWithJitter } from "../../../lib/utils/retry.mjs";
8
8
  import { InMemorySpoolStore } from "../../storage/in_memory.mjs";
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("../../../chunk-Cek0wNdY.js");
3
- require("../../../common-6WOPAB3-.js");
4
- const require_tool_call = require("../../../tool_call-Bua8qpko.js");
3
+ require("../../../common-CpcsEqPY.js");
4
+ const require_tool_call = require("../../../tool_call-BixyvnWZ.js");
5
5
  require("../../../guards.cjs");
6
6
  const require_helpers = require("../../../helpers-1okZzNCa.js");
7
7
  const require_batteries_llm_ollama_exceptions = require("./exceptions.cjs");
@@ -1,5 +1,5 @@
1
- import "../../../common-_77pbLLS.mjs";
2
- import { n as Media } from "../../../tool_call-D69JEDXJ.mjs";
1
+ import "../../../common-0CmrSKNb.mjs";
2
+ import { n as Media } from "../../../tool_call-pfvAsgkY.mjs";
3
3
  import "../../../guards.mjs";
4
4
  import { A as retrievableToAttrs, C as renderRetrievables, D as renderThought, E as renderThirdPartyPublicRetrievables, M as toolsToChatCompletionsTools, O as renderTrustedContent, S as renderRetrievableSafetyDirective, T as renderThirdPartyPrivateRetrievables, _ as filterThoughts, a as defaultRenderMemories, b as renderFirstPartyRetrievables, c as defaultRenderStandingInstructions, d as defaultRenderThought, f as defaultRenderTrustedContent, g as escapeXmlAttribute, h as descriptionToChatCompletionsJsonSchema, i as defaultRenderFirstPartyRetrievables, k as renderUntrustedContent, l as defaultRenderThirdPartyPrivateRetrievables, m as defaultToolsToChatCompletionsTools, n as defaultFilterThoughts, o as defaultRenderRetrievableSafetyDirective, p as defaultRenderUntrustedContent, r as defaultRenderChatCompletionsSystemPrompt, s as defaultRenderRetrievables, t as defaultDescriptionToChatCompletionsJsonSchema, u as defaultRenderThirdPartyPublicRetrievables, v as memoryToAttrs, w as renderStandingInstructions, x as renderMemories, y as renderChatCompletionsSystemPrompt } from "../../../helpers-BCyDAn_R.mjs";
5
5
  import { E_OLLAMA_UNSUPPORTED_MEDIA_MODALITY } from "./exceptions.mjs";
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("../../../chunk-Cek0wNdY.js");
3
- const require_common = require("../../../common-6WOPAB3-.js");
3
+ const require_common = require("../../../common-CpcsEqPY.js");
4
4
  require("../../../guards.cjs");
5
5
  const require_batteries_llm_ollama_exceptions = require("./exceptions.cjs");
6
6
  let _nhtio_validation = require("@nhtio/validation");
@@ -1,4 +1,4 @@
1
- import { i as byteStoreSchema } from "../../../common-_77pbLLS.mjs";
1
+ import { o as byteStoreSchema } from "../../../common-0CmrSKNb.mjs";
2
2
  import "../../../guards.mjs";
3
3
  import { E_INVALID_OLLAMA_OPTIONS } from "./exceptions.mjs";
4
4
  import { validator } from "@nhtio/validation";
@@ -1,10 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("../../../chunk-Cek0wNdY.js");
3
- const require_tool_registry = require("../../../tool_registry-bWKC6jt1.js");
4
- const require_thought = require("../../../thought-c4d-q-3R.js");
5
- const require_spooled_artifact = require("../../../spooled_artifact-xA7Te-kE.js");
6
- require("../../../common-6WOPAB3-.js");
7
- const require_tool_call = require("../../../tool_call-Bua8qpko.js");
3
+ const require_tool_registry = require("../../../tool_registry-CIIfbY_w.js");
4
+ const require_thought = require("../../../thought-CU7PYkB1.js");
5
+ const require_spooled_artifact = require("../../../spooled_artifact-MbMz6NXX.js");
6
+ require("../../../common-CpcsEqPY.js");
7
+ const require_tool_call = require("../../../tool_call-BixyvnWZ.js");
8
8
  require("../../../guards.cjs");
9
9
  const require_lib_utils_retry = require("../../../lib/utils/retry.cjs");
10
10
  const require_batteries_llm_openai_chat_completions_exceptions = require("./exceptions.cjs");
@@ -1,8 +1,8 @@
1
- import { a as Tokenizable, c as isObject, n as canonicalStringify, o as isError, s as isInstanceOf, t as ToolRegistry } from "../../../tool_registry-QKQYr8Tp.mjs";
2
- import { n as Message, t as Thought } from "../../../thought-DXnh31HJ.mjs";
3
- import { i as ArtifactTool, t as SpooledArtifact } from "../../../spooled_artifact-CmL5ci5Z.mjs";
4
- import "../../../common-_77pbLLS.mjs";
5
- import { n as Media, t as ToolCall } from "../../../tool_call-D69JEDXJ.mjs";
1
+ import { a as Tokenizable, c as isError, l as isInstanceOf, n as canonicalStringify, t as ToolRegistry, u as isObject } from "../../../tool_registry-FeMMz993.mjs";
2
+ import { n as Message, t as Thought } from "../../../thought-DmcfCRAw.mjs";
3
+ import { c as ArtifactTool, t as SpooledArtifact } from "../../../spooled_artifact-fgc1lutm.mjs";
4
+ import "../../../common-0CmrSKNb.mjs";
5
+ import { n as Media, t as ToolCall } from "../../../tool_call-pfvAsgkY.mjs";
6
6
  import "../../../guards.mjs";
7
7
  import { computeBackoff, linkAbortSignals, parseRetryAfter, sleepWithJitter } from "../../../lib/utils/retry.mjs";
8
8
  import { E_INVALID_OPENAI_CHAT_COMPLETIONS_OPTIONS, E_OPENAI_CHAT_COMPLETIONS_CONTEXT_OVERFLOW, E_OPENAI_CHAT_COMPLETIONS_HTTP_ERROR, E_OPENAI_CHAT_COMPLETIONS_INVALID_TOOL_CALL_ARGS, E_OPENAI_CHAT_COMPLETIONS_REQUEST_TIMEOUT, E_OPENAI_CHAT_COMPLETIONS_STREAM_ERROR, E_OPENAI_CHAT_COMPLETIONS_STREAM_STALLED } from "./exceptions.mjs";
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("../../../chunk-Cek0wNdY.js");
3
- require("../../../common-6WOPAB3-.js");
4
- const require_tool_call = require("../../../tool_call-Bua8qpko.js");
3
+ require("../../../common-CpcsEqPY.js");
4
+ const require_tool_call = require("../../../tool_call-BixyvnWZ.js");
5
5
  require("../../../guards.cjs");
6
6
  const require_batteries_llm_openai_chat_completions_exceptions = require("./exceptions.cjs");
7
7
  const require_helpers = require("../../../helpers-1okZzNCa.js");
@@ -1,5 +1,5 @@
1
- import "../../../common-_77pbLLS.mjs";
2
- import { n as Media } from "../../../tool_call-D69JEDXJ.mjs";
1
+ import "../../../common-0CmrSKNb.mjs";
2
+ import { n as Media } from "../../../tool_call-pfvAsgkY.mjs";
3
3
  import "../../../guards.mjs";
4
4
  import { E_UNSUPPORTED_MEDIA_MODALITY } from "./exceptions.mjs";
5
5
  import { A as retrievableToAttrs, C as renderRetrievables, D as renderThought, E as renderThirdPartyPublicRetrievables, M as toolsToChatCompletionsTools, O as renderTrustedContent, S as renderRetrievableSafetyDirective, T as renderThirdPartyPrivateRetrievables, _ as filterThoughts, a as defaultRenderMemories, b as renderFirstPartyRetrievables, c as defaultRenderStandingInstructions, d as defaultRenderThought, f as defaultRenderTrustedContent, g as escapeXmlAttribute, h as descriptionToChatCompletionsJsonSchema, i as defaultRenderFirstPartyRetrievables, j as sanitiseNameField, k as renderUntrustedContent, l as defaultRenderThirdPartyPrivateRetrievables, m as defaultToolsToChatCompletionsTools, n as defaultFilterThoughts, o as defaultRenderRetrievableSafetyDirective, p as defaultRenderUntrustedContent, r as defaultRenderChatCompletionsSystemPrompt, s as defaultRenderRetrievables, t as defaultDescriptionToChatCompletionsJsonSchema, u as defaultRenderThirdPartyPublicRetrievables, v as memoryToAttrs, w as renderStandingInstructions, x as renderMemories, y as renderChatCompletionsSystemPrompt } from "../../../helpers-BCyDAn_R.mjs";
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("../../../chunk-Cek0wNdY.js");
3
- const require_common = require("../../../common-6WOPAB3-.js");
3
+ const require_common = require("../../../common-CpcsEqPY.js");
4
4
  require("../../../guards.cjs");
5
5
  const require_batteries_llm_openai_chat_completions_exceptions = require("./exceptions.cjs");
6
6
  let _nhtio_validation = require("@nhtio/validation");