@nhtio/adk 1.20260607.2 → 1.20260609.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 (521) hide show
  1. package/CHANGELOG.md +230 -0
  2. package/batteries/embeddings/openai/adapter.cjs +1 -1
  3. package/batteries/embeddings/openai/adapter.mjs +1 -1
  4. package/batteries/embeddings/openai/exceptions.cjs +1 -1
  5. package/batteries/embeddings/openai/exceptions.mjs +1 -1
  6. package/batteries/embeddings/openai/types.d.ts +7 -0
  7. package/batteries/embeddings/webllm/adapter.cjs +1 -1
  8. package/batteries/embeddings/webllm/adapter.mjs +1 -1
  9. package/batteries/embeddings/webllm/exceptions.cjs +1 -1
  10. package/batteries/embeddings/webllm/exceptions.mjs +1 -1
  11. package/batteries/llm/chat_common/helpers.d.ts +165 -0
  12. package/batteries/llm/chat_common/types.d.ts +309 -0
  13. package/batteries/llm/index.d.ts +5 -0
  14. package/batteries/llm/ollama/adapter.cjs +736 -0
  15. package/batteries/llm/ollama/adapter.cjs.map +1 -0
  16. package/batteries/llm/ollama/adapter.d.ts +64 -0
  17. package/batteries/llm/ollama/adapter.mjs +734 -0
  18. package/batteries/llm/ollama/adapter.mjs.map +1 -0
  19. package/batteries/llm/ollama/exceptions.cjs +105 -0
  20. package/batteries/llm/ollama/exceptions.cjs.map +1 -0
  21. package/batteries/llm/ollama/exceptions.d.ts +112 -0
  22. package/batteries/llm/ollama/exceptions.mjs +96 -0
  23. package/batteries/llm/ollama/exceptions.mjs.map +1 -0
  24. package/batteries/llm/ollama/helpers.cjs +487 -0
  25. package/batteries/llm/ollama/helpers.cjs.map +1 -0
  26. package/batteries/llm/ollama/helpers.d.ts +158 -0
  27. package/batteries/llm/ollama/helpers.mjs +450 -0
  28. package/batteries/llm/ollama/helpers.mjs.map +1 -0
  29. package/batteries/llm/ollama/index.d.ts +29 -0
  30. package/batteries/llm/ollama/types.cjs +2 -0
  31. package/batteries/llm/ollama/types.d.ts +334 -0
  32. package/batteries/llm/ollama/types.mjs +0 -0
  33. package/batteries/llm/ollama/validation.cjs +130 -0
  34. package/batteries/llm/ollama/validation.cjs.map +1 -0
  35. package/batteries/llm/ollama/validation.d.ts +31 -0
  36. package/batteries/llm/ollama/validation.mjs +127 -0
  37. package/batteries/llm/ollama/validation.mjs.map +1 -0
  38. package/batteries/llm/ollama.cjs +54 -0
  39. package/batteries/llm/ollama.mjs +6 -0
  40. package/batteries/llm/openai_chat_completions/adapter.cjs +36 -19
  41. package/batteries/llm/openai_chat_completions/adapter.cjs.map +1 -1
  42. package/batteries/llm/openai_chat_completions/adapter.mjs +23 -6
  43. package/batteries/llm/openai_chat_completions/adapter.mjs.map +1 -1
  44. package/batteries/llm/openai_chat_completions/exceptions.cjs +1 -1
  45. package/batteries/llm/openai_chat_completions/exceptions.mjs +1 -1
  46. package/batteries/llm/openai_chat_completions/helpers.cjs +80 -320
  47. package/batteries/llm/openai_chat_completions/helpers.cjs.map +1 -1
  48. package/batteries/llm/openai_chat_completions/helpers.d.ts +68 -144
  49. package/batteries/llm/openai_chat_completions/helpers.mjs +40 -280
  50. package/batteries/llm/openai_chat_completions/helpers.mjs.map +1 -1
  51. package/batteries/llm/openai_chat_completions/types.d.ts +273 -181
  52. package/batteries/llm/openai_chat_completions/validation.cjs +2 -2
  53. package/batteries/llm/openai_chat_completions/validation.cjs.map +1 -1
  54. package/batteries/llm/openai_chat_completions/validation.mjs +2 -2
  55. package/batteries/llm/openai_chat_completions/validation.mjs.map +1 -1
  56. package/batteries/llm/openai_chat_completions.cjs +29 -28
  57. package/batteries/llm/openai_chat_completions.mjs +2 -1
  58. package/batteries/llm/webllm_chat_completions/adapter.cjs +38 -19
  59. package/batteries/llm/webllm_chat_completions/adapter.cjs.map +1 -1
  60. package/batteries/llm/webllm_chat_completions/adapter.d.ts +18 -0
  61. package/batteries/llm/webllm_chat_completions/adapter.mjs +25 -6
  62. package/batteries/llm/webllm_chat_completions/adapter.mjs.map +1 -1
  63. package/batteries/llm/webllm_chat_completions/exceptions.cjs +1 -1
  64. package/batteries/llm/webllm_chat_completions/exceptions.mjs +1 -1
  65. package/batteries/llm/webllm_chat_completions/helpers.cjs +29 -28
  66. package/batteries/llm/webllm_chat_completions/helpers.mjs +2 -1
  67. package/batteries/llm/webllm_chat_completions/types.d.ts +21 -0
  68. package/batteries/llm/webllm_chat_completions/validation.cjs +13 -1
  69. package/batteries/llm/webllm_chat_completions/validation.cjs.map +1 -1
  70. package/batteries/llm/webllm_chat_completions/validation.d.ts +12 -0
  71. package/batteries/llm/webllm_chat_completions/validation.mjs +13 -1
  72. package/batteries/llm/webllm_chat_completions/validation.mjs.map +1 -1
  73. package/batteries/llm/webllm_chat_completions.cjs +29 -28
  74. package/batteries/llm/webllm_chat_completions.mjs +2 -1
  75. package/batteries/llm.cjs +44 -28
  76. package/batteries/llm.mjs +9 -4
  77. package/batteries/storage/flydrive.cjs +1 -1
  78. package/batteries/storage/flydrive.mjs +1 -1
  79. package/batteries/storage/in_memory/index.d.ts +1 -1
  80. package/batteries/storage/in_memory.cjs +2 -2
  81. package/batteries/storage/in_memory.cjs.map +1 -1
  82. package/batteries/storage/in_memory.mjs +2 -2
  83. package/batteries/storage/in_memory.mjs.map +1 -1
  84. package/batteries/storage/opfs/index.d.ts +19 -0
  85. package/batteries/storage/opfs.cjs +1 -1
  86. package/batteries/storage/opfs.cjs.map +1 -1
  87. package/batteries/storage/opfs.mjs +1 -1
  88. package/batteries/storage/opfs.mjs.map +1 -1
  89. package/batteries/tools/_shared/index.d.ts +121 -0
  90. package/batteries/tools/_shared.cjs +157 -0
  91. package/batteries/tools/_shared.cjs.map +1 -0
  92. package/batteries/tools/_shared.mjs +149 -0
  93. package/batteries/tools/_shared.mjs.map +1 -0
  94. package/batteries/tools/color.cjs +3 -2
  95. package/batteries/tools/color.cjs.map +1 -1
  96. package/batteries/tools/color.mjs +3 -2
  97. package/batteries/tools/color.mjs.map +1 -1
  98. package/batteries/tools/comparison.cjs +4 -3
  99. package/batteries/tools/comparison.cjs.map +1 -1
  100. package/batteries/tools/comparison.mjs +4 -3
  101. package/batteries/tools/comparison.mjs.map +1 -1
  102. package/batteries/tools/data_structure.cjs +30 -10
  103. package/batteries/tools/data_structure.cjs.map +1 -1
  104. package/batteries/tools/data_structure.mjs +30 -10
  105. package/batteries/tools/data_structure.mjs.map +1 -1
  106. package/batteries/tools/datetime_extended.cjs +5 -10
  107. package/batteries/tools/datetime_extended.cjs.map +1 -1
  108. package/batteries/tools/datetime_extended.mjs +5 -10
  109. package/batteries/tools/datetime_extended.mjs.map +1 -1
  110. package/batteries/tools/datetime_math.cjs +2 -2
  111. package/batteries/tools/datetime_math.mjs +2 -2
  112. package/batteries/tools/encoding.cjs +13 -4
  113. package/batteries/tools/encoding.cjs.map +1 -1
  114. package/batteries/tools/encoding.mjs +13 -4
  115. package/batteries/tools/encoding.mjs.map +1 -1
  116. package/batteries/tools/formatting.cjs +4 -4
  117. package/batteries/tools/formatting.cjs.map +1 -1
  118. package/batteries/tools/formatting.mjs +4 -4
  119. package/batteries/tools/formatting.mjs.map +1 -1
  120. package/batteries/tools/geo_basics.cjs +2 -2
  121. package/batteries/tools/geo_basics.mjs +2 -2
  122. package/batteries/tools/index.d.ts +3 -0
  123. package/batteries/tools/math.cjs +10 -8
  124. package/batteries/tools/math.cjs.map +1 -1
  125. package/batteries/tools/math.mjs +10 -8
  126. package/batteries/tools/math.mjs.map +1 -1
  127. package/batteries/tools/memory.cjs +5 -5
  128. package/batteries/tools/memory.mjs +5 -5
  129. package/batteries/tools/parsing.cjs +9 -5
  130. package/batteries/tools/parsing.cjs.map +1 -1
  131. package/batteries/tools/parsing.mjs +9 -5
  132. package/batteries/tools/parsing.mjs.map +1 -1
  133. package/batteries/tools/retrievables.cjs +4 -4
  134. package/batteries/tools/retrievables.mjs +4 -4
  135. package/batteries/tools/scrapper/exceptions.d.ts +21 -0
  136. package/batteries/tools/scrapper/index.d.ts +172 -0
  137. package/batteries/tools/scrapper/shared.d.ts +139 -0
  138. package/batteries/tools/scrapper.cjs +8 -0
  139. package/batteries/tools/scrapper.mjs +2 -0
  140. package/batteries/tools/searxng/exceptions.d.ts +21 -0
  141. package/batteries/tools/searxng/index.d.ts +177 -0
  142. package/batteries/tools/searxng.cjs +6 -0
  143. package/batteries/tools/searxng.mjs +2 -0
  144. package/batteries/tools/standing_instructions.cjs +4 -4
  145. package/batteries/tools/standing_instructions.mjs +4 -4
  146. package/batteries/tools/statistics.cjs +54 -43
  147. package/batteries/tools/statistics.cjs.map +1 -1
  148. package/batteries/tools/statistics.mjs +54 -43
  149. package/batteries/tools/statistics.mjs.map +1 -1
  150. package/batteries/tools/string_processing.cjs +5 -5
  151. package/batteries/tools/string_processing.cjs.map +1 -1
  152. package/batteries/tools/string_processing.mjs +5 -5
  153. package/batteries/tools/string_processing.mjs.map +1 -1
  154. package/batteries/tools/structured_data.cjs +8 -13
  155. package/batteries/tools/structured_data.cjs.map +1 -1
  156. package/batteries/tools/structured_data.mjs +8 -13
  157. package/batteries/tools/structured_data.mjs.map +1 -1
  158. package/batteries/tools/text_analysis.cjs +3 -3
  159. package/batteries/tools/text_analysis.mjs +3 -3
  160. package/batteries/tools/text_comparison.cjs +2 -2
  161. package/batteries/tools/text_comparison.mjs +2 -2
  162. package/batteries/tools/time.cjs +2 -2
  163. package/batteries/tools/time.mjs +2 -2
  164. package/batteries/tools/unit_conversion.cjs +10 -8
  165. package/batteries/tools/unit_conversion.cjs.map +1 -1
  166. package/batteries/tools/unit_conversion.mjs +10 -8
  167. package/batteries/tools/unit_conversion.mjs.map +1 -1
  168. package/batteries/tools/web_retrieval/index.d.ts +186 -0
  169. package/batteries/tools/web_retrieval.cjs +206 -0
  170. package/batteries/tools/web_retrieval.cjs.map +1 -0
  171. package/batteries/tools/web_retrieval.mjs +201 -0
  172. package/batteries/tools/web_retrieval.mjs.map +1 -0
  173. package/batteries/tools.cjs +15 -0
  174. package/batteries/tools.mjs +4 -1
  175. package/batteries/vector/arangodb/index.d.ts +2 -0
  176. package/batteries/vector/arangodb.cjs +2 -1
  177. package/batteries/vector/arangodb.cjs.map +1 -1
  178. package/batteries/vector/arangodb.mjs +2 -1
  179. package/batteries/vector/arangodb.mjs.map +1 -1
  180. package/batteries/vector/builder.cjs +31 -0
  181. package/batteries/vector/builder.cjs.map +1 -1
  182. package/batteries/vector/builder.d.ts +58 -0
  183. package/batteries/vector/builder.mjs +31 -0
  184. package/batteries/vector/builder.mjs.map +1 -1
  185. package/batteries/vector/chroma/index.d.ts +4 -0
  186. package/batteries/vector/chroma.cjs +3 -0
  187. package/batteries/vector/chroma.cjs.map +1 -1
  188. package/batteries/vector/chroma.mjs +3 -0
  189. package/batteries/vector/chroma.mjs.map +1 -1
  190. package/batteries/vector/clickhouse/index.d.ts +2 -0
  191. package/batteries/vector/clickhouse.cjs +2 -1
  192. package/batteries/vector/clickhouse.cjs.map +1 -1
  193. package/batteries/vector/clickhouse.mjs +2 -1
  194. package/batteries/vector/clickhouse.mjs.map +1 -1
  195. package/batteries/vector/cloudflare/index.d.ts +2 -0
  196. package/batteries/vector/cloudflare.cjs +2 -1
  197. package/batteries/vector/cloudflare.cjs.map +1 -1
  198. package/batteries/vector/cloudflare.mjs +2 -1
  199. package/batteries/vector/cloudflare.mjs.map +1 -1
  200. package/batteries/vector/conformance/index.d.ts +22 -0
  201. package/batteries/vector/conformance.cjs +22 -0
  202. package/batteries/vector/conformance.cjs.map +1 -1
  203. package/batteries/vector/conformance.mjs +22 -0
  204. package/batteries/vector/conformance.mjs.map +1 -1
  205. package/batteries/vector/contract.cjs +22 -0
  206. package/batteries/vector/contract.cjs.map +1 -1
  207. package/batteries/vector/contract.d.ts +51 -0
  208. package/batteries/vector/contract.mjs +22 -0
  209. package/batteries/vector/contract.mjs.map +1 -1
  210. package/batteries/vector/couchbase/index.d.ts +2 -0
  211. package/batteries/vector/couchbase.cjs +2 -1
  212. package/batteries/vector/couchbase.cjs.map +1 -1
  213. package/batteries/vector/couchbase.mjs +2 -1
  214. package/batteries/vector/couchbase.mjs.map +1 -1
  215. package/batteries/vector/duckdb/index.d.ts +2 -0
  216. package/batteries/vector/duckdb.cjs +2 -1
  217. package/batteries/vector/duckdb.cjs.map +1 -1
  218. package/batteries/vector/duckdb.mjs +2 -1
  219. package/batteries/vector/duckdb.mjs.map +1 -1
  220. package/batteries/vector/elasticsearch/index.d.ts +2 -0
  221. package/batteries/vector/elasticsearch.cjs +2 -1
  222. package/batteries/vector/elasticsearch.cjs.map +1 -1
  223. package/batteries/vector/elasticsearch.mjs +2 -1
  224. package/batteries/vector/elasticsearch.mjs.map +1 -1
  225. package/batteries/vector/exceptions.cjs +1 -1
  226. package/batteries/vector/exceptions.mjs +1 -1
  227. package/batteries/vector/factory.cjs +6 -0
  228. package/batteries/vector/factory.cjs.map +1 -1
  229. package/batteries/vector/factory.d.ts +14 -0
  230. package/batteries/vector/factory.mjs +6 -0
  231. package/batteries/vector/factory.mjs.map +1 -1
  232. package/batteries/vector/filters.cjs +22 -1
  233. package/batteries/vector/filters.cjs.map +1 -1
  234. package/batteries/vector/filters.d.ts +38 -0
  235. package/batteries/vector/filters.mjs +22 -1
  236. package/batteries/vector/filters.mjs.map +1 -1
  237. package/batteries/vector/helpers.cjs +13 -0
  238. package/batteries/vector/helpers.cjs.map +1 -1
  239. package/batteries/vector/helpers.d.ts +14 -0
  240. package/batteries/vector/helpers.mjs +13 -0
  241. package/batteries/vector/helpers.mjs.map +1 -1
  242. package/batteries/vector/hnswlib/index.d.ts +2 -0
  243. package/batteries/vector/hnswlib.cjs +2 -1
  244. package/batteries/vector/hnswlib.cjs.map +1 -1
  245. package/batteries/vector/hnswlib.mjs +2 -1
  246. package/batteries/vector/hnswlib.mjs.map +1 -1
  247. package/batteries/vector/in_memory/index.d.ts +1 -0
  248. package/batteries/vector/in_memory.cjs +1 -0
  249. package/batteries/vector/in_memory.cjs.map +1 -1
  250. package/batteries/vector/in_memory.mjs +1 -0
  251. package/batteries/vector/in_memory.mjs.map +1 -1
  252. package/batteries/vector/lancedb/index.d.ts +2 -0
  253. package/batteries/vector/lancedb.cjs +2 -1
  254. package/batteries/vector/lancedb.cjs.map +1 -1
  255. package/batteries/vector/lancedb.mjs +2 -1
  256. package/batteries/vector/lancedb.mjs.map +1 -1
  257. package/batteries/vector/mariadb/index.d.ts +2 -0
  258. package/batteries/vector/mariadb.cjs +2 -1
  259. package/batteries/vector/mariadb.cjs.map +1 -1
  260. package/batteries/vector/mariadb.mjs +2 -1
  261. package/batteries/vector/mariadb.mjs.map +1 -1
  262. package/batteries/vector/meilisearch/index.d.ts +2 -0
  263. package/batteries/vector/meilisearch.cjs +2 -1
  264. package/batteries/vector/meilisearch.cjs.map +1 -1
  265. package/batteries/vector/meilisearch.mjs +2 -1
  266. package/batteries/vector/meilisearch.mjs.map +1 -1
  267. package/batteries/vector/migrate.cjs +18 -1
  268. package/batteries/vector/migrate.cjs.map +1 -1
  269. package/batteries/vector/migrate.d.ts +31 -0
  270. package/batteries/vector/migrate.mjs +18 -1
  271. package/batteries/vector/migrate.mjs.map +1 -1
  272. package/batteries/vector/milvus/index.d.ts +5 -0
  273. package/batteries/vector/milvus.cjs +4 -0
  274. package/batteries/vector/milvus.cjs.map +1 -1
  275. package/batteries/vector/milvus.mjs +4 -0
  276. package/batteries/vector/milvus.mjs.map +1 -1
  277. package/batteries/vector/mongodb/index.d.ts +2 -0
  278. package/batteries/vector/mongodb.cjs +2 -1
  279. package/batteries/vector/mongodb.cjs.map +1 -1
  280. package/batteries/vector/mongodb.mjs +2 -1
  281. package/batteries/vector/mongodb.mjs.map +1 -1
  282. package/batteries/vector/neo4j/index.d.ts +2 -0
  283. package/batteries/vector/neo4j.cjs +2 -1
  284. package/batteries/vector/neo4j.cjs.map +1 -1
  285. package/batteries/vector/neo4j.mjs +2 -1
  286. package/batteries/vector/neo4j.mjs.map +1 -1
  287. package/batteries/vector/opensearch/index.d.ts +2 -0
  288. package/batteries/vector/opensearch.cjs +2 -1
  289. package/batteries/vector/opensearch.cjs.map +1 -1
  290. package/batteries/vector/opensearch.mjs +2 -1
  291. package/batteries/vector/opensearch.mjs.map +1 -1
  292. package/batteries/vector/oracle23ai/index.d.ts +2 -0
  293. package/batteries/vector/oracle23ai.cjs +2 -1
  294. package/batteries/vector/oracle23ai.cjs.map +1 -1
  295. package/batteries/vector/oracle23ai.mjs +2 -1
  296. package/batteries/vector/oracle23ai.mjs.map +1 -1
  297. package/batteries/vector/orama/index.d.ts +1 -0
  298. package/batteries/vector/orama.cjs +1 -0
  299. package/batteries/vector/orama.cjs.map +1 -1
  300. package/batteries/vector/orama.mjs +1 -0
  301. package/batteries/vector/orama.mjs.map +1 -1
  302. package/batteries/vector/pgvector/index.d.ts +9 -2
  303. package/batteries/vector/pgvector.cjs +4 -0
  304. package/batteries/vector/pgvector.cjs.map +1 -1
  305. package/batteries/vector/pgvector.mjs +4 -0
  306. package/batteries/vector/pgvector.mjs.map +1 -1
  307. package/batteries/vector/pinecone/index.d.ts +5 -0
  308. package/batteries/vector/pinecone.cjs +3 -1
  309. package/batteries/vector/pinecone.cjs.map +1 -1
  310. package/batteries/vector/pinecone.mjs +3 -1
  311. package/batteries/vector/pinecone.mjs.map +1 -1
  312. package/batteries/vector/plan.d.ts +27 -0
  313. package/batteries/vector/qdrant/index.d.ts +5 -0
  314. package/batteries/vector/qdrant.cjs +4 -0
  315. package/batteries/vector/qdrant.cjs.map +1 -1
  316. package/batteries/vector/qdrant.mjs +4 -0
  317. package/batteries/vector/qdrant.mjs.map +1 -1
  318. package/batteries/vector/redis/index.d.ts +2 -0
  319. package/batteries/vector/redis.cjs +2 -1
  320. package/batteries/vector/redis.cjs.map +1 -1
  321. package/batteries/vector/redis.mjs +2 -1
  322. package/batteries/vector/redis.mjs.map +1 -1
  323. package/batteries/vector/retrievable.cjs +9 -1
  324. package/batteries/vector/retrievable.cjs.map +1 -1
  325. package/batteries/vector/retrievable.mjs +9 -1
  326. package/batteries/vector/retrievable.mjs.map +1 -1
  327. package/batteries/vector/retrievable_glue.d.ts +21 -0
  328. package/batteries/vector/s3vectors/index.d.ts +2 -0
  329. package/batteries/vector/s3vectors.cjs +2 -1
  330. package/batteries/vector/s3vectors.cjs.map +1 -1
  331. package/batteries/vector/s3vectors.mjs +2 -1
  332. package/batteries/vector/s3vectors.mjs.map +1 -1
  333. package/batteries/vector/schema.cjs +28 -0
  334. package/batteries/vector/schema.cjs.map +1 -1
  335. package/batteries/vector/schema.d.ts +39 -0
  336. package/batteries/vector/schema.mjs +28 -0
  337. package/batteries/vector/schema.mjs.map +1 -1
  338. package/batteries/vector/solr/index.d.ts +2 -0
  339. package/batteries/vector/solr.cjs +2 -1
  340. package/batteries/vector/solr.cjs.map +1 -1
  341. package/batteries/vector/solr.mjs +2 -1
  342. package/batteries/vector/solr.mjs.map +1 -1
  343. package/batteries/vector/sqlite_vec/index.d.ts +6 -3
  344. package/batteries/vector/sqlite_vec.cjs +2 -0
  345. package/batteries/vector/sqlite_vec.cjs.map +1 -1
  346. package/batteries/vector/sqlite_vec.mjs +2 -0
  347. package/batteries/vector/sqlite_vec.mjs.map +1 -1
  348. package/batteries/vector/surrealdb/index.d.ts +2 -0
  349. package/batteries/vector/surrealdb.cjs +2 -1
  350. package/batteries/vector/surrealdb.cjs.map +1 -1
  351. package/batteries/vector/surrealdb.mjs +2 -1
  352. package/batteries/vector/surrealdb.mjs.map +1 -1
  353. package/batteries/vector/types.d.ts +27 -0
  354. package/batteries/vector/typesense/index.d.ts +2 -0
  355. package/batteries/vector/typesense.cjs +2 -1
  356. package/batteries/vector/typesense.cjs.map +1 -1
  357. package/batteries/vector/typesense.mjs +2 -1
  358. package/batteries/vector/typesense.mjs.map +1 -1
  359. package/batteries/vector/validation.cjs +14 -0
  360. package/batteries/vector/validation.cjs.map +1 -1
  361. package/batteries/vector/validation.d.ts +14 -0
  362. package/batteries/vector/validation.mjs +14 -0
  363. package/batteries/vector/validation.mjs.map +1 -1
  364. package/batteries/vector/vector_store_constructor.cjs +1 -1
  365. package/batteries/vector/vector_store_constructor.cjs.map +1 -1
  366. package/batteries/vector/vector_store_constructor.d.ts +1 -1
  367. package/batteries/vector/vector_store_constructor.mjs +1 -1
  368. package/batteries/vector/vector_store_constructor.mjs.map +1 -1
  369. package/batteries/vector/vespa/index.d.ts +2 -0
  370. package/batteries/vector/vespa.cjs +2 -1
  371. package/batteries/vector/vespa.cjs.map +1 -1
  372. package/batteries/vector/vespa.mjs +2 -1
  373. package/batteries/vector/vespa.mjs.map +1 -1
  374. package/batteries/vector/weaviate/index.d.ts +2 -0
  375. package/batteries/vector/weaviate.cjs +2 -1
  376. package/batteries/vector/weaviate.cjs.map +1 -1
  377. package/batteries/vector/weaviate.mjs +2 -1
  378. package/batteries/vector/weaviate.mjs.map +1 -1
  379. package/batteries.cjs +58 -28
  380. package/batteries.mjs +12 -5
  381. package/{common-BT0nfCi9.mjs → common-DYDUi99O.mjs} +9 -9
  382. package/common-DYDUi99O.mjs.map +1 -0
  383. package/{common-Cj8TaQ9U.js → common-DZl3ADJs.js} +9 -9
  384. package/common-DZl3ADJs.js.map +1 -0
  385. package/common.cjs +7 -7
  386. package/common.mjs +7 -7
  387. package/{dispatch_runner-DPcS7Y_M.mjs → dispatch_runner--ZhdDWRZ.mjs} +27 -5
  388. package/{dispatch_runner-DPcS7Y_M.mjs.map → dispatch_runner--ZhdDWRZ.mjs.map} +1 -1
  389. package/{dispatch_runner-BHBNupqp.js → dispatch_runner-nHDKkxye.js} +27 -5
  390. package/{dispatch_runner-BHBNupqp.js.map → dispatch_runner-nHDKkxye.js.map} +1 -1
  391. package/dispatch_runner.cjs +1 -1
  392. package/dispatch_runner.d.ts +1 -1
  393. package/dispatch_runner.mjs +1 -1
  394. package/eslint/rules/artifact_tool_forbids_artifact_constructor.cjs +1 -0
  395. package/eslint/rules/artifact_tool_forbids_artifact_constructor.cjs.map +1 -1
  396. package/eslint/rules/artifact_tool_forbids_artifact_constructor.d.ts +1 -0
  397. package/eslint/rules/artifact_tool_forbids_artifact_constructor.mjs +1 -0
  398. package/eslint/rules/artifact_tool_forbids_artifact_constructor.mjs.map +1 -1
  399. package/eslint/rules/no_model_in_tool_handler.cjs +1 -0
  400. package/eslint/rules/no_model_in_tool_handler.cjs.map +1 -1
  401. package/eslint/rules/no_model_in_tool_handler.d.ts +1 -0
  402. package/eslint/rules/no_model_in_tool_handler.mjs +1 -0
  403. package/eslint/rules/no_model_in_tool_handler.mjs.map +1 -1
  404. package/eslint/rules/require_validator_any_required.cjs +1 -0
  405. package/eslint/rules/require_validator_any_required.cjs.map +1 -1
  406. package/eslint/rules/require_validator_any_required.d.ts +1 -0
  407. package/eslint/rules/require_validator_any_required.mjs +1 -0
  408. package/eslint/rules/require_validator_any_required.mjs.map +1 -1
  409. package/eslint/rules/thought_payload_requires_replay_tag.cjs +1 -0
  410. package/eslint/rules/thought_payload_requires_replay_tag.cjs.map +1 -1
  411. package/eslint/rules/thought_payload_requires_replay_tag.d.ts +1 -0
  412. package/eslint/rules/thought_payload_requires_replay_tag.mjs +1 -0
  413. package/eslint/rules/thought_payload_requires_replay_tag.mjs.map +1 -1
  414. package/eslint/rules/token_encoding_requires_context_window.cjs +1 -0
  415. package/eslint/rules/token_encoding_requires_context_window.cjs.map +1 -1
  416. package/eslint/rules/token_encoding_requires_context_window.d.ts +1 -0
  417. package/eslint/rules/token_encoding_requires_context_window.mjs +1 -0
  418. package/eslint/rules/token_encoding_requires_context_window.mjs.map +1 -1
  419. package/eslint/rules.cjs +1 -1
  420. package/eslint/rules.mjs +1 -1
  421. package/eslint.cjs +2 -2
  422. package/eslint.mjs +2 -2
  423. package/{exceptions-BeWH2FwP.mjs → exceptions-BDhN0Xzr.mjs} +3 -2
  424. package/exceptions-BDhN0Xzr.mjs.map +1 -0
  425. package/{exceptions-CitH5wZI.js → exceptions-BRXrUKiW.js} +3 -2
  426. package/exceptions-BRXrUKiW.js.map +1 -0
  427. package/exceptions.cjs +2 -2
  428. package/exceptions.mjs +2 -2
  429. package/factories.cjs +1 -1
  430. package/factories.mjs +1 -1
  431. package/forge.cjs +4 -4
  432. package/forge.d.ts +1 -1
  433. package/forge.mjs +4 -4
  434. package/guards.cjs +9 -9
  435. package/guards.mjs +9 -9
  436. package/helpers-DSTFxTiC.js +497 -0
  437. package/helpers-DSTFxTiC.js.map +1 -0
  438. package/helpers-xhrQbMAG.mjs +306 -0
  439. package/helpers-xhrQbMAG.mjs.map +1 -0
  440. package/index.cjs +12 -12
  441. package/index.mjs +12 -12
  442. package/lib/classes/base_exception.d.ts +1 -0
  443. package/lib/classes/media.d.ts +10 -0
  444. package/lib/classes/retrievable.d.ts +1 -1
  445. package/lib/classes/spooled_json_artifact.d.ts +1 -1
  446. package/lib/classes/spooled_markdown_artifact.d.ts +1 -0
  447. package/lib/classes/tokenizable.d.ts +3 -0
  448. package/lib/classes/tool.d.ts +8 -0
  449. package/lib/classes/turn_gate.d.ts +6 -0
  450. package/lib/dispatch_runner.d.ts +4 -32
  451. package/lib/helpers/bignum.cjs +82 -0
  452. package/lib/helpers/bignum.cjs.map +1 -0
  453. package/lib/helpers/bignum.d.ts +52 -0
  454. package/lib/helpers/bignum.mjs +74 -0
  455. package/lib/helpers/bignum.mjs.map +1 -0
  456. package/lib/turn_runner.d.ts +1 -1
  457. package/lib/types/dispatch_runner.d.ts +83 -0
  458. package/lib/utils/exceptions.d.ts +1 -1
  459. package/lib/utils/retry.cjs.map +1 -1
  460. package/lib/utils/retry.d.ts +2 -0
  461. package/lib/utils/retry.mjs.map +1 -1
  462. package/mcp/adk-docs-corpus.json +1 -1
  463. package/package.json +259 -204
  464. package/{runtime-j92CNi5z.mjs → runtime-Bz5zA8wc.mjs} +2 -2
  465. package/{runtime-j92CNi5z.mjs.map → runtime-Bz5zA8wc.mjs.map} +1 -1
  466. package/{runtime-MFFcJrRv.js → runtime-DslE1aBw.js} +2 -2
  467. package/{runtime-MFFcJrRv.js.map → runtime-DslE1aBw.js.map} +1 -1
  468. package/scrapper-BHM1mCde.mjs +432 -0
  469. package/scrapper-BHM1mCde.mjs.map +1 -0
  470. package/scrapper-BeweWurk.js +462 -0
  471. package/scrapper-BeweWurk.js.map +1 -0
  472. package/searxng-BJFulNcK.mjs +247 -0
  473. package/searxng-BJFulNcK.mjs.map +1 -0
  474. package/searxng-B_D--V5q.js +265 -0
  475. package/searxng-B_D--V5q.js.map +1 -0
  476. package/skills/adk-assembly/SKILL.md +2 -2
  477. package/{spooled_artifact-CHoZgWwI.mjs → spooled_artifact-7eePq7JA.mjs} +5 -5
  478. package/{spooled_artifact-CHoZgWwI.mjs.map → spooled_artifact-7eePq7JA.mjs.map} +1 -1
  479. package/{spooled_artifact-BTq6Nzfy.js → spooled_artifact-DX8LLyUX.js} +5 -5
  480. package/{spooled_artifact-BTq6Nzfy.js.map → spooled_artifact-DX8LLyUX.js.map} +1 -1
  481. package/spooled_artifact.cjs +2 -2
  482. package/spooled_artifact.mjs +2 -2
  483. package/{spooled_markdown_artifact-CALSDxIx.js → spooled_markdown_artifact-ClX72lek.js} +4 -4
  484. package/spooled_markdown_artifact-ClX72lek.js.map +1 -0
  485. package/{spooled_markdown_artifact-Ci5UL7l4.mjs → spooled_markdown_artifact-wkrBF3oX.mjs} +4 -4
  486. package/spooled_markdown_artifact-wkrBF3oX.mjs.map +1 -0
  487. package/{thought-D34QQZZ9.mjs → thought-B_vxAiKU.mjs} +5 -5
  488. package/{thought-D34QQZZ9.mjs.map → thought-B_vxAiKU.mjs.map} +1 -1
  489. package/{thought-BbwhJ1wb.js → thought-DLwpF7MI.js} +5 -5
  490. package/{thought-BbwhJ1wb.js.map → thought-DLwpF7MI.js.map} +1 -1
  491. package/{tool-CVyZkFC7.js → tool-D5WGVIcI.js} +4 -4
  492. package/{tool-CVyZkFC7.js.map → tool-D5WGVIcI.js.map} +1 -1
  493. package/{tool-CMhaDRNd.mjs → tool-wMYMVl60.mjs} +4 -4
  494. package/{tool-CMhaDRNd.mjs.map → tool-wMYMVl60.mjs.map} +1 -1
  495. package/{tool_call-CV5qVNlb.mjs → tool_call-B4-_-vjG.mjs} +5 -5
  496. package/tool_call-B4-_-vjG.mjs.map +1 -0
  497. package/{tool_call-Db68hB7y.js → tool_call-DixVlW40.js} +5 -5
  498. package/tool_call-DixVlW40.js.map +1 -0
  499. package/{tool_registry-D1pSSlsd.mjs → tool_registry-791Vrjtf.mjs} +4 -3
  500. package/tool_registry-791Vrjtf.mjs.map +1 -0
  501. package/{tool_registry-DYUYqXvo.js → tool_registry-CKJPze3j.js} +4 -3
  502. package/tool_registry-CKJPze3j.js.map +1 -0
  503. package/{turn_runner-DqWHNP80.js → turn_runner-HXImLGIn.js} +7 -7
  504. package/turn_runner-HXImLGIn.js.map +1 -0
  505. package/{turn_runner-fg1Wc3dK.mjs → turn_runner-ZyYO-Kti.mjs} +7 -7
  506. package/turn_runner-ZyYO-Kti.mjs.map +1 -0
  507. package/turn_runner.cjs +1 -1
  508. package/turn_runner.mjs +1 -1
  509. package/types.d.ts +1 -1
  510. package/common-BT0nfCi9.mjs.map +0 -1
  511. package/common-Cj8TaQ9U.js.map +0 -1
  512. package/exceptions-BeWH2FwP.mjs.map +0 -1
  513. package/exceptions-CitH5wZI.js.map +0 -1
  514. package/spooled_markdown_artifact-CALSDxIx.js.map +0 -1
  515. package/spooled_markdown_artifact-Ci5UL7l4.mjs.map +0 -1
  516. package/tool_call-CV5qVNlb.mjs.map +0 -1
  517. package/tool_call-Db68hB7y.js.map +0 -1
  518. package/tool_registry-D1pSSlsd.mjs.map +0 -1
  519. package/tool_registry-DYUYqXvo.js.map +0 -1
  520. package/turn_runner-DqWHNP80.js.map +0 -1
  521. package/turn_runner-fg1Wc3dK.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.cjs","names":["#baseline"],"sources":["../../../../src/batteries/llm/ollama/adapter.ts"],"sourcesContent":["/**\n * Cross-environment executor adapter for the native Ollama `/api/chat` endpoint.\n *\n * @module @nhtio/adk/batteries/llm/ollama/adapter\n *\n * @remarks\n * Native Ollama LLM adapter targeting `/api/chat` (NOT the OpenAI-compat `/v1` layer — the\n * `openai_chat_completions` battery already covers `/v1`). Works against both LOCAL Ollama\n * (`http://localhost:11434`, no auth) and CLOUD Ollama (`https://ollama.com`, `Authorization:\n * Bearer <apiKey>`); the only difference is `baseURL` + the auth header. Native is HTTP-only — a\n * Unix-socket deployment is reached via a custom `fetch` or an external bridge, not an adapter\n * option.\n *\n * Structurally a sibling of the OpenAI Chat Completions adapter, with the native-wire divergences:\n *\n * - Request body: generation params are NESTED under `options`; `think` / `format` / `keep_alive`\n * are top-level native controls; ADK control fields are stripped before sending.\n * - Streaming: NDJSON (newline-delimited JSON objects), terminated in-band by `done: true` — there\n * is no SSE `data:` framing and no `[DONE]` sentinel. Whole `tool_calls` arrive per chunk (no\n * delta accumulation).\n * - Reasoning: the single native `message.thinking` field (no multi-field precedence dance).\n * - Tool calls: `arguments` is already a JSON OBJECT (no `JSON.parse`); native calls carry no `id`,\n * so the adapter synthesizes one (uuidv6) for correlation / checksum / spool keying. Tool-result\n * history messages use `tool_name` (the originating tool), not `tool_call_id`.\n * - Generation stats: the terminal `done: true` object's token counts + nanosecond durations +\n * `done_reason` are surfaced via `helpers.reportGenerationStats`.\n */\n\nimport { DateTime } from 'luxon'\nimport { sha256 } from 'js-sha256'\nimport { v6 as uuidv6 } from 'uuid'\nimport { validateOptions } from './validation'\nimport { isError, isInstanceOf, isObject } from '@nhtio/adk/guards'\nimport { canonicalStringify } from '../../../lib/utils/canonical_json'\nimport { InMemorySpoolStore } from '@nhtio/adk/batteries/storage/in_memory'\nimport {\n computeBackoff,\n sleepWithJitter,\n parseRetryAfter,\n linkAbortSignals,\n} from '../../../lib/utils/retry'\nimport {\n Tokenizable,\n ToolRegistry,\n ToolCall,\n Message,\n Thought,\n SpooledArtifact,\n Media,\n ArtifactTool,\n} from '@nhtio/adk/common'\nimport {\n E_INVALID_OLLAMA_OPTIONS,\n E_OLLAMA_CONTEXT_OVERFLOW,\n E_OLLAMA_HTTP_ERROR,\n E_OLLAMA_STREAM_ERROR,\n E_OLLAMA_STREAM_STALLED,\n E_OLLAMA_REQUEST_TIMEOUT,\n E_OLLAMA_INVALID_TOOL_CALL_ARGS,\n} from './exceptions'\nimport {\n defaultDescriptionToChatCompletionsJsonSchema,\n defaultRenderUntrustedContent,\n defaultRenderTrustedContent,\n defaultRenderStandingInstructions,\n defaultRenderMemories,\n defaultRenderRetrievables,\n defaultRenderRetrievableSafetyDirective,\n defaultRenderFirstPartyRetrievables,\n defaultRenderThirdPartyPublicRetrievables,\n defaultRenderThirdPartyPrivateRetrievables,\n defaultRenderThought,\n defaultFilterThoughts,\n defaultToolsToChatCompletionsTools,\n defaultRenderChatCompletionsSystemPrompt,\n defaultRenderOllamaTimelineMessage,\n defaultRenderOllamaToolCallResult,\n defaultBuildOllamaHistory,\n ollamaToolsFromTools,\n} from './helpers'\nimport type { DispatchContext } from '@nhtio/adk/types'\nimport type { Tool, Memory, TokenEncoding } from '@nhtio/adk/common'\nimport type {\n DispatchExecutorFn,\n DispatchExecutorHelpers,\n GenerationStats,\n} from '@nhtio/adk/dispatch_runner'\nimport type {\n OllamaAdapterOptions,\n OllamaHelpers,\n OllamaChatRequestBody,\n OllamaChatStreamChunk,\n OllamaChatResponse,\n OllamaToolCall,\n OllamaRuntimeOptions,\n} from './types'\n\n// ─── An assembled native tool call (id synthesized; args already an object) ───\n// NOTE: unlike the OpenAI adapter, the request body is assembled EXPLICITLY (model / messages /\n// stream / think / format / keep_alive / options / tools) rather than by spreading non-control\n// keys, because native generation params live nested under `options`, not at the top level. So\n// there is no ADK_CONTROL_KEYS strip-set here.\n\ninterface AssembledOllamaToolCall {\n id: string\n name: string\n args: Record<string, unknown>\n}\n\n// ─── Option merging ───────────────────────────────────────────────────────────\n\nconst mergeRecord = <T extends Record<string, unknown>>(\n layers: ReadonlyArray<T | undefined>\n): T | undefined => {\n let merged: T | undefined\n for (const layer of layers) {\n if (!layer) continue\n merged = { ...(merged ?? ({} as T)), ...layer }\n }\n return merged\n}\n\nconst mergeOptions = (\n baseline: OllamaAdapterOptions,\n exec: Partial<OllamaAdapterOptions> | undefined,\n stash: Partial<OllamaAdapterOptions> | undefined\n): Partial<OllamaAdapterOptions> => {\n const layers = [baseline as Partial<OllamaAdapterOptions>, exec ?? {}, stash ?? {}]\n const out: Record<string, unknown> = {}\n for (const layer of layers) {\n for (const [k, v] of Object.entries(layer)) {\n if (v === undefined) continue\n if (k === 'headers' || k === 'helpers' || k === 'retry' || k === 'options') continue\n out[k] = v\n }\n }\n const headers = mergeRecord(layers.map((l) => l.headers as Record<string, string> | undefined))\n if (headers !== undefined) out.headers = headers\n const helpers = mergeRecord(layers.map((l) => l.helpers as Record<string, unknown> | undefined))\n if (helpers !== undefined) out.helpers = helpers\n const retry = mergeRecord(layers.map((l) => l.retry as Record<string, unknown> | undefined))\n if (retry !== undefined) out.retry = retry\n // Nested runtime `options` merge key-by-key, like headers — a stash override that sets one\n // sampling param should not clear the others set in the constructor.\n const runtime = mergeRecord(layers.map((l) => l.options as Record<string, unknown> | undefined))\n if (runtime !== undefined) out.options = runtime\n return out as Partial<OllamaAdapterOptions>\n}\n\n// ─── Helper resolution ────────────────────────────────────────────────────────\n\nconst resolveHelpers = (overrides: Partial<OllamaHelpers> | undefined): OllamaHelpers => {\n const src = overrides ?? {}\n return {\n descriptionToChatCompletionsJsonSchema:\n src.descriptionToChatCompletionsJsonSchema ?? defaultDescriptionToChatCompletionsJsonSchema,\n renderUntrustedContent: src.renderUntrustedContent ?? defaultRenderUntrustedContent,\n renderTrustedContent: src.renderTrustedContent ?? defaultRenderTrustedContent,\n renderStandingInstructions: src.renderStandingInstructions ?? defaultRenderStandingInstructions,\n renderMemories: src.renderMemories ?? defaultRenderMemories,\n renderRetrievables: src.renderRetrievables ?? defaultRenderRetrievables,\n renderRetrievableSafetyDirective:\n src.renderRetrievableSafetyDirective ?? defaultRenderRetrievableSafetyDirective,\n renderFirstPartyRetrievables:\n src.renderFirstPartyRetrievables ?? defaultRenderFirstPartyRetrievables,\n renderThirdPartyPublicRetrievables:\n src.renderThirdPartyPublicRetrievables ?? defaultRenderThirdPartyPublicRetrievables,\n renderThirdPartyPrivateRetrievables:\n src.renderThirdPartyPrivateRetrievables ?? defaultRenderThirdPartyPrivateRetrievables,\n renderThought: src.renderThought ?? defaultRenderThought,\n filterThoughts: src.filterThoughts ?? defaultFilterThoughts,\n toolsToChatCompletionsTools:\n src.toolsToChatCompletionsTools ?? defaultToolsToChatCompletionsTools,\n renderChatCompletionsSystemPrompt:\n src.renderChatCompletionsSystemPrompt ?? defaultRenderChatCompletionsSystemPrompt,\n renderOllamaTimelineMessage:\n src.renderOllamaTimelineMessage ?? defaultRenderOllamaTimelineMessage,\n renderOllamaToolCallResult: src.renderOllamaToolCallResult ?? defaultRenderOllamaToolCallResult,\n buildOllamaHistory: src.buildOllamaHistory ?? defaultBuildOllamaHistory,\n }\n}\n\n// ─── ID / checksum / time helpers ─────────────────────────────────────────────\n\nconst computeChecksum = (tool: string, args: unknown): string =>\n sha256(canonicalStringify({ tool, args }))\n\nconst nowIso = (): string => DateTime.now().toISO() ?? new Date().toISOString()\n\nconst estimateTokensOf = async (\n value: { estimateTokens: (encoding: TokenEncoding) => number | Promise<number> },\n encoding: TokenEncoding\n): Promise<number> => Promise.resolve(value.estimateTokens(encoding))\n\n// ─── Generation-stats extraction ──────────────────────────────────────────────\n\nconst extractGenerationStats = (\n src: OllamaChatStreamChunk | OllamaChatResponse,\n model: string\n): GenerationStats => {\n const stats: GenerationStats = { provider: 'ollama', model: src.model ?? model, raw: { ...src } }\n if (typeof src.prompt_eval_count === 'number') stats.promptTokens = src.prompt_eval_count\n if (typeof src.eval_count === 'number') stats.completionTokens = src.eval_count\n if (typeof src.prompt_eval_count === 'number' && typeof src.eval_count === 'number') {\n stats.totalTokens = src.prompt_eval_count + src.eval_count\n }\n if (typeof src.total_duration === 'number') stats.totalDurationNs = src.total_duration\n if (typeof src.load_duration === 'number') stats.loadDurationNs = src.load_duration\n if (typeof src.prompt_eval_duration === 'number') {\n stats.promptEvalDurationNs = src.prompt_eval_duration\n }\n if (typeof src.eval_duration === 'number') stats.evalDurationNs = src.eval_duration\n if (typeof src.done_reason === 'string') stats.finishReason = src.done_reason\n return stats\n}\n\n// ─── Adapter class ────────────────────────────────────────────────────────────\n\n/**\n * Opinionated cross-environment LLM adapter for the native Ollama `/api/chat` wire shape.\n *\n * @remarks\n * Construction validates options eagerly via {@link validateOptions} and throws\n * {@link @nhtio/adk/batteries/llm/ollama!E_INVALID_OLLAMA_OPTIONS} on failure. The returned instance is reusable: call\n * {@link OllamaAdapter.executor} once per `DispatchRunner` configuration to obtain a\n * {@link @nhtio/adk!DispatchExecutorFn} bound to the baseline plus optional executor-scope\n * overrides. Per-iteration overrides live on `ctx.stash.ollama` and take highest precedence;\n * `headers`, `helpers`, `retry`, and the nested runtime `options` merge key-by-key across all three\n * layers, every other field is replaced wholesale at the highest layer that sets it.\n */\nexport class OllamaAdapter {\n /** Customary key for per-iteration overrides on `ctx.stash`. */\n public static readonly STASH_KEY = 'ollama' as const\n\n readonly #baseline: OllamaAdapterOptions\n\n /**\n * @param options - Constructor-baseline options. Re-validated on every iteration after\n * per-dispatch and per-iteration overrides are layered in.\n * @throws {@link @nhtio/adk/batteries/llm/ollama!E_INVALID_OLLAMA_OPTIONS} when `options` does not satisfy `ollamaOptionsSchema`.\n */\n constructor(options: unknown) {\n this.#baseline = validateOptions(options)\n }\n\n /**\n * Returns a {@link @nhtio/adk!DispatchExecutorFn} bound to this adapter's baseline plus optional\n * executor-scope overrides.\n *\n * @param overrides - Optional executor-scope overrides. Higher precedence than the baseline,\n * lower precedence than `ctx.stash[STASH_KEY]`.\n */\n executor(overrides?: Partial<OllamaAdapterOptions>): DispatchExecutorFn {\n const baseline = this.#baseline\n const adapterClass = OllamaAdapter\n return async (ctx: DispatchContext, helpers: DispatchExecutorHelpers): Promise<void> => {\n const localWarn = (msg: string): void => {\n helpers.log.warn({ kind: 'helper-warning', message: msg })\n }\n\n // ── Step 1: merge & validate ──────────────────────────────────────────\n const stashRaw = ctx.stash.get(adapterClass.STASH_KEY, {}) as unknown\n const stashOverrides =\n stashRaw && typeof stashRaw === 'object' ? (stashRaw as Partial<OllamaAdapterOptions>) : {}\n const merged = validateOptions(mergeOptions(baseline, overrides, stashOverrides))\n\n // Cross-field invariant: tokenEncoding non-null requires contextWindow.\n if (merged.tokenEncoding !== null && merged.contextWindow === undefined) {\n throw new E_INVALID_OLLAMA_OPTIONS([\n 'tokenEncoding is non-null but contextWindow is undefined',\n ])\n }\n\n // ── Step 2: resolve helpers ───────────────────────────────────────────\n const resolvedHelpers = resolveHelpers(merged.helpers)\n\n // ── Step 3: forge artifact-query tools ────────────────────────────────\n const uniqueCtors = new Set<typeof SpooledArtifact>()\n for (const tc of ctx.turnToolCalls) {\n const results = tc.results as unknown as { constructor?: unknown }\n const ctor = results?.constructor\n if (ctor && SpooledArtifact.isSpooledArtifactConstructor(ctor)) {\n uniqueCtors.add(ctor as unknown as typeof SpooledArtifact)\n }\n }\n const forgedRegistries: ToolRegistry[] = []\n for (const ctor of uniqueCtors) {\n const forgeFn = (ctor as unknown as { forgeTools?: (c: DispatchContext) => ToolRegistry })\n .forgeTools\n if (typeof forgeFn === 'function') {\n forgedRegistries.push(forgeFn.call(ctor, ctx))\n }\n }\n const mergedRegistry = ToolRegistry.merge([ctx.tools, ...forgedRegistries], {\n onCollision: 'replace',\n })\n mergedRegistry.bindContext(ctx)\n\n // ── Step 4: pre-render tool-call results ──────────────────────────────\n const renderedToolCallResults = new Map<string, string>()\n for (const tc of ctx.turnToolCalls) {\n const rendered = await resolvedHelpers.renderOllamaToolCallResult({\n toolCall: tc,\n results: tc.results as\n | Tokenizable\n | SpooledArtifact\n | SpooledArtifact[]\n | Media\n | Media[],\n tool: mergedRegistry.get(tc.tool) as Tool | ArtifactTool | undefined,\n renderUntrustedContent: resolvedHelpers.renderUntrustedContent,\n renderTrustedContent: resolvedHelpers.renderTrustedContent,\n unsupportedMediaPolicy: merged.unsupportedMediaPolicy ?? 'throw',\n warn: localWarn,\n })\n renderedToolCallResults.set(tc.id, rendered)\n }\n\n // ── Step 5: context window enforcement ────────────────────────────────\n if (merged.tokenEncoding !== null && merged.contextWindow !== undefined) {\n const encoding = merged.tokenEncoding as TokenEncoding\n let spTokens = await estimateTokensOf(ctx.systemPrompt, encoding)\n let siTokens = 0\n for (const si of ctx.standingInstructions) {\n siTokens += await estimateTokensOf(si, encoding)\n }\n let memTokens = 0\n for (const mem of ctx.turnMemories as Set<Memory>) {\n memTokens += await estimateTokensOf(mem.content, encoding)\n }\n let retTokens = 0\n for (const r of ctx.turnRetrievables) {\n retTokens += await estimateTokensOf(r.content, encoding)\n }\n let tlTokens = 0\n for (const msg of ctx.turnMessages) {\n if (msg.content !== undefined) {\n tlTokens += await estimateTokensOf(msg.content, encoding)\n }\n }\n for (const th of ctx.turnThoughts) {\n tlTokens += await estimateTokensOf(th.content, encoding)\n }\n for (const rendered of renderedToolCallResults.values()) {\n tlTokens += await estimateTokensOf(new Tokenizable(rendered), encoding)\n }\n const total = spTokens + siTokens + memTokens + retTokens + tlTokens\n const perBucketObj = {\n systemPrompt: spTokens,\n standingInstructions: siTokens,\n memories: memTokens,\n retrievables: retTokens,\n timeline: tlTokens,\n }\n helpers.log.debug({\n kind: 'context-window-usage',\n message: `Context window usage: ${total}/${merged.contextWindow} tokens`,\n payload: { total, limit: merged.contextWindow, encoding, perBucket: perBucketObj },\n })\n if (total > merged.contextWindow) {\n throw new E_OLLAMA_CONTEXT_OVERFLOW([\n total,\n merged.contextWindow,\n encoding,\n JSON.stringify(perBucketObj),\n ])\n }\n }\n\n // ── Step 6: build request body ────────────────────────────────────────\n const { messages: wireMessages, reasoningPayloads } =\n await resolvedHelpers.buildOllamaHistory({\n systemPrompt: ctx.systemPrompt,\n standingInstructions: ctx.standingInstructions,\n memories: ctx.turnMemories,\n retrievables: ctx.turnRetrievables,\n messages: ctx.turnMessages,\n thoughts: ctx.turnThoughts,\n toolCalls: ctx.turnToolCalls,\n tools: mergedRegistry,\n renderedToolCallResults,\n bucketOrder: merged.bucketOrder ?? [\n 'standingInstructions',\n 'memories',\n 'retrievables',\n 'timeline',\n ],\n selfIdentity: merged.selfIdentity ?? 'assistant',\n thoughtSurfacing: merged.thoughtSurfacing ?? 'all-self',\n replayCompatibility: merged.replayCompatibility ?? [],\n renderOllamaToolCallResult: resolvedHelpers.renderOllamaToolCallResult,\n renderChatCompletionsSystemPrompt: resolvedHelpers.renderChatCompletionsSystemPrompt,\n renderStandingInstructions: resolvedHelpers.renderStandingInstructions,\n renderMemories: resolvedHelpers.renderMemories,\n renderRetrievables: resolvedHelpers.renderRetrievables,\n renderRetrievableSafetyDirective: resolvedHelpers.renderRetrievableSafetyDirective,\n renderFirstPartyRetrievables: resolvedHelpers.renderFirstPartyRetrievables,\n renderThirdPartyPublicRetrievables: resolvedHelpers.renderThirdPartyPublicRetrievables,\n renderThirdPartyPrivateRetrievables: resolvedHelpers.renderThirdPartyPrivateRetrievables,\n renderOllamaTimelineMessage: resolvedHelpers.renderOllamaTimelineMessage,\n renderThought: resolvedHelpers.renderThought,\n filterThoughts: resolvedHelpers.filterThoughts,\n renderUntrustedContent: resolvedHelpers.renderUntrustedContent,\n renderTrustedContent: resolvedHelpers.renderTrustedContent,\n unsupportedMediaPolicy: merged.unsupportedMediaPolicy ?? 'throw',\n warn: localWarn,\n })\n\n const stream = merged.stream ?? true\n const body: OllamaChatRequestBody = {\n model: merged.model,\n messages: wireMessages,\n stream,\n }\n // Native top-level controls — included only when defined. `think` is conditional-presence:\n // omitted → absent; `false` → think:false; truthy/effort → verbatim.\n if (merged.think !== undefined) body.think = merged.think\n if (merged.format !== undefined) body.format = merged.format\n if (merged.keep_alive !== undefined) body.keep_alive = merged.keep_alive\n if (merged.options !== undefined) body.options = merged.options as OllamaRuntimeOptions\n const toolsArr = mergedRegistry.visible()\n if (toolsArr.length > 0) {\n body.tools = ollamaToolsFromTools(toolsArr, {\n descriptionToChatCompletionsJsonSchema:\n resolvedHelpers.descriptionToChatCompletionsJsonSchema,\n })\n }\n if (reasoningPayloads.length > 0) {\n body._adk_reasoning_payloads = reasoningPayloads\n }\n\n // ── Step 7: POST with retry / timeout loop ────────────────────────────\n const rawBase = merged.baseURL ?? 'http://localhost:11434'\n const baseURL = rawBase.endsWith('/') ? rawBase.slice(0, -1) : rawBase\n const url = `${baseURL}/api/chat`\n\n const headers: Record<string, string> = { 'Content-Type': 'application/json' }\n if (stream) headers['Accept'] = 'application/x-ndjson'\n if (merged.apiKey) headers['Authorization'] = `Bearer ${merged.apiKey}`\n if (merged.headers) Object.assign(headers, merged.headers)\n\n const retryCfg = {\n maxAttempts: merged.retry?.maxAttempts ?? 1,\n baseDelayMs: merged.retry?.baseDelayMs ?? 500,\n maxDelayMs: merged.retry?.maxDelayMs ?? 30_000,\n retriableStatuses: merged.retry?.retriableStatuses ?? [429, 502, 503, 504],\n honorRetryAfter: merged.retry?.honorRetryAfter ?? true,\n }\n\n const fetchFn = merged.fetch ?? globalThis.fetch\n const maxAttempts = retryCfg.maxAttempts\n\n let response: Response | undefined\n let attempt = 1\n let disposeLink: () => void = () => {}\n while (attempt <= maxAttempts) {\n if (ctx.abortSignal.aborted) return\n\n const internalController = new AbortController()\n let timeoutHandle: ReturnType<typeof setTimeout> | undefined\n const requestTimeoutMs = merged.requestTimeoutMs ?? 0\n if (requestTimeoutMs > 0) {\n timeoutHandle = setTimeout(() => internalController.abort(), requestTimeoutMs)\n }\n disposeLink()\n const { signal: linkedSignal, dispose: disposeCurrentLink } = linkAbortSignals([\n ctx.abortSignal,\n internalController.signal,\n ])\n disposeLink = disposeCurrentLink\n\n try {\n response = await fetchFn(url, {\n method: 'POST',\n headers,\n body: JSON.stringify(body),\n signal: linkedSignal,\n })\n } catch (err) {\n if (timeoutHandle !== undefined) clearTimeout(timeoutHandle)\n if (ctx.abortSignal.aborted) return\n if (internalController.signal.aborted) {\n helpers.log.warn({\n kind: 'request-timeout',\n message: `Request timed out after ${requestTimeoutMs}ms on attempt ${attempt}/${maxAttempts}`,\n payload: { requestTimeoutMs, attempt, maxAttempts },\n })\n if (attempt < maxAttempts) {\n const delay = computeBackoff(attempt, retryCfg)\n await sleepWithJitter(delay, ctx.abortSignal)\n attempt += 1\n continue\n }\n ctx.nack(new E_OLLAMA_REQUEST_TIMEOUT([requestTimeoutMs]))\n return\n }\n helpers.log.error({\n kind: 'transport-error',\n message: `Transport failure on attempt ${attempt}/${maxAttempts}: ${isError(err) ? err.message : String(err)}`,\n payload: { attempt, maxAttempts, detail: isError(err) ? err.message : String(err) },\n })\n ctx.nack(new E_OLLAMA_HTTP_ERROR([0, isError(err) ? err.message : String(err)]))\n return\n }\n\n if (timeoutHandle !== undefined) clearTimeout(timeoutHandle)\n\n if (!response.ok) {\n const status = response.status\n const retriable = retryCfg.retriableStatuses.includes(status)\n if (retriable && attempt < maxAttempts) {\n let delay = computeBackoff(attempt, retryCfg)\n if (retryCfg.honorRetryAfter !== false) {\n const ra = response.headers.get('Retry-After')\n if (ra) {\n const raMs = parseRetryAfter(ra)\n if (raMs > 0) delay = Math.min(Math.max(delay, raMs), retryCfg.maxDelayMs)\n }\n }\n helpers.log.warn({\n kind: 'retry-attempt',\n message: `HTTP ${status} on attempt ${attempt}/${maxAttempts}; retrying in ~${delay}ms`,\n payload: {\n reason: 'http-status',\n status,\n delayMs: delay,\n attempt: attempt + 1,\n maxAttempts,\n },\n })\n await sleepWithJitter(delay, ctx.abortSignal)\n attempt += 1\n continue\n }\n const errBody = await response.text().catch(() => '')\n helpers.log.error({\n kind: 'http-error',\n message: `HTTP ${status} (terminal): ${errBody.slice(0, 256)}`,\n payload: { status, body: errBody, attempt, maxAttempts, retriable },\n })\n ctx.nack(new E_OLLAMA_HTTP_ERROR([status, errBody]))\n return\n }\n\n break\n }\n\n if (!response) return\n\n const spoolStore = merged.spoolStore ?? new InMemorySpoolStore()\n const selfIdentity = merged.selfIdentity ?? 'assistant'\n\n // ── Inner helper: persist + execute one assembled tool call ───────────\n const executeAndPersistToolCall = async (call: AssembledOllamaToolCall): Promise<void> => {\n const tool = mergedRegistry.get(call.name)\n // Native /api/chat delivers `arguments` already parsed as an object. Validate it IS an\n // object (defensive against a non-conformant server/proxy emitting an array/null/primitive)\n // — there is no JSON.parse step. A non-object short-circuits to a persisted error ToolCall.\n let args: Record<string, unknown> = {}\n let parseError: InstanceType<typeof E_OLLAMA_INVALID_TOOL_CALL_ARGS> | undefined\n if (isObject(call.args)) {\n args = call.args\n } else {\n const receivedKind = Array.isArray(call.args)\n ? 'array'\n : call.args === null\n ? 'null'\n : typeof call.args\n parseError = new E_OLLAMA_INVALID_TOOL_CALL_ARGS([\n `must be a JSON object; received ${receivedKind}`,\n JSON.stringify(call.args),\n ])\n }\n const completedAt = nowIso()\n if (parseError !== undefined) {\n const results = new Tokenizable(parseError.message)\n helpers.reportToolCall(call.id, { tool: call.name, args })\n helpers.reportToolCall(call.id, { results, isError: true, isComplete: true })\n await ctx.storeToolCall(\n new ToolCall({\n id: call.id,\n tool: call.name,\n args,\n checksum: computeChecksum(call.name, args),\n isComplete: true,\n isError: true,\n results,\n createdAt: completedAt,\n updatedAt: completedAt,\n completedAt,\n })\n )\n return\n }\n if (!tool) {\n const available = mergedRegistry\n .all()\n .map((t) => t.name)\n .sort()\n const errText =\n available.length > 0\n ? `Tool not found: ${call.name}. Available tools: ${available.join(', ')}.`\n : `Tool not found: ${call.name}. No tools are available this turn.`\n const results = new Tokenizable(errText)\n helpers.reportToolCall(call.id, { tool: call.name, args })\n helpers.reportToolCall(call.id, { results, isError: true, isComplete: true })\n await ctx.storeToolCall(\n new ToolCall({\n id: call.id,\n tool: call.name,\n args,\n checksum: computeChecksum(call.name, args),\n isComplete: true,\n isError: true,\n results,\n createdAt: completedAt,\n updatedAt: completedAt,\n completedAt,\n })\n )\n return\n }\n helpers.reportToolCall(call.id, { tool: tool.name, args })\n const isArtifactTool = ArtifactTool.isArtifactTool(tool)\n let results: Tokenizable | SpooledArtifact | SpooledArtifact[] | Media | Media[] =\n new Tokenizable('')\n let toolHadError = false\n try {\n const raw = await tool.executor(ctx)(args)\n if (isArtifactTool) {\n if (Tokenizable.isTokenizable(raw)) {\n results = raw\n } else if (typeof raw === 'string') {\n results = new Tokenizable(raw)\n } else {\n throw new Error(\n `ArtifactTool \"${tool.name}\" returned a non-string/non-Tokenizable value`\n )\n }\n } else if (Media.isMedia(raw)) {\n results = raw\n } else if (Array.isArray(raw) && raw.length > 0 && raw.every((m) => Media.isMedia(m))) {\n results = raw as Media[]\n } else if (typeof raw === 'string' || isInstanceOf(raw, 'Uint8Array', Uint8Array)) {\n const reader = await spoolStore.write(call.id, raw as string | Uint8Array)\n const ArtifactCtor = (tool as Tool).artifactConstructor?.() ?? SpooledArtifact\n results = new ArtifactCtor(reader)\n } else {\n const reader = await spoolStore.write(call.id, String(raw))\n const ArtifactCtor = (tool as Tool).artifactConstructor?.() ?? SpooledArtifact\n results = new ArtifactCtor(reader)\n }\n } catch (err) {\n toolHadError = true\n let detailMsg = isError(err) ? err.message : String(err)\n if (\n isError(err) &&\n isError(err.cause) &&\n err.cause.message &&\n err.cause.message !== err.message\n ) {\n detailMsg = `${detailMsg} ${err.cause.message}`\n }\n results = new Tokenizable(detailMsg)\n }\n helpers.reportToolCall(call.id, { results, isError: toolHadError, isComplete: true })\n const completedAt2 = nowIso()\n await ctx.storeToolCall(\n new ToolCall({\n id: call.id,\n tool: tool.name,\n args,\n checksum: computeChecksum(tool.name, args),\n isComplete: true,\n isError: toolHadError,\n results,\n fromArtifactTool: isArtifactTool,\n createdAt: completedAt2,\n updatedAt: completedAt2,\n completedAt: completedAt2,\n })\n )\n }\n\n // ── Step 8: streaming path (NDJSON) ───────────────────────────────────\n if (stream) {\n if (!response.body) {\n ctx.nack(new E_OLLAMA_STREAM_ERROR(['response has no body']))\n return\n }\n const reader = response.body.getReader()\n const decoder = new TextDecoder()\n const streamId = uuidv6()\n\n let buffer = ''\n let idleTimer: ReturnType<typeof setTimeout> | undefined\n let stalled = false\n let partialMessageContent = ''\n let sawMessageDelta = false\n let partialThinking = ''\n let sawThinking = false\n let doneSeen = false\n const collectedToolCalls: AssembledOllamaToolCall[] = []\n const thoughtStreamId = `${streamId}:thought`\n\n const idleMs = merged.streamIdleTimeoutMs ?? 0\n const armIdleTimer = (): void => {\n if (idleMs <= 0) return\n if (idleTimer) clearTimeout(idleTimer)\n idleTimer = setTimeout(() => {\n stalled = true\n helpers.log.warn({\n kind: 'stream-idle-timeout',\n message: `NDJSON stream went idle for ${idleMs}ms; cancelling`,\n payload: { idleMs },\n })\n reader.cancel().catch(() => {})\n }, idleMs)\n }\n const clearIdleTimer = (): void => {\n if (idleTimer) {\n clearTimeout(idleTimer)\n idleTimer = undefined\n }\n }\n\n const drainAndPersist = async (\n statsSrc: OllamaChatStreamChunk | undefined\n ): Promise<void> => {\n if (sawMessageDelta) {\n helpers.reportMessage(streamId, '', { isComplete: true })\n await ctx.storeMessage(\n new Message({\n id: streamId,\n role: 'assistant',\n content: partialMessageContent,\n identity: selfIdentity,\n createdAt: nowIso(),\n updatedAt: nowIso(),\n })\n )\n }\n if (sawThinking) {\n helpers.reportThought(thoughtStreamId, '', { isComplete: true })\n await ctx.storeThought(\n new Thought({\n id: thoughtStreamId,\n content: partialThinking,\n identity: selfIdentity,\n createdAt: nowIso(),\n updatedAt: nowIso(),\n })\n )\n }\n if (statsSrc !== undefined) {\n helpers.reportGenerationStats(extractGenerationStats(statsSrc, merged.model))\n }\n if (collectedToolCalls.length === 0) {\n if (merged.autoAck) ctx.ack()\n return\n }\n for (const call of collectedToolCalls) {\n if (ctx.abortSignal.aborted) return\n await executeAndPersistToolCall(call)\n }\n }\n\n const handleChunk = (chunk: OllamaChatStreamChunk): void => {\n const m = chunk.message\n if (m) {\n if (typeof m.content === 'string' && m.content.length > 0) {\n sawMessageDelta = true\n partialMessageContent += m.content\n helpers.reportMessage(streamId, m.content)\n }\n if (typeof m.thinking === 'string' && m.thinking.length > 0) {\n sawThinking = true\n partialThinking += m.thinking\n helpers.reportThought(thoughtStreamId, m.thinking)\n }\n if (Array.isArray(m.tool_calls)) {\n for (const tc of m.tool_calls) {\n collectedToolCalls.push({\n id: uuidv6(),\n name: tc.function?.name ?? '',\n args: (tc.function?.arguments ?? {}) as Record<string, unknown>,\n })\n }\n }\n }\n }\n\n const parseLine = (line: string): OllamaChatStreamChunk | undefined => {\n const trimmed = line.trim()\n if (trimmed.length === 0) return undefined\n try {\n return JSON.parse(trimmed) as OllamaChatStreamChunk\n } catch {\n helpers.log.trace({\n kind: 'ndjson-parse-failure',\n message: 'Failed to parse NDJSON line as JSON; skipping',\n payload: { linePreview: trimmed.slice(0, 256) },\n })\n return undefined\n }\n }\n\n try {\n armIdleTimer()\n while (true) {\n const { done, value } = await reader.read()\n if (done) break\n armIdleTimer()\n if (ctx.abortSignal.aborted) {\n clearIdleTimer()\n return\n }\n buffer += decoder.decode(value, { stream: true })\n let nl = buffer.indexOf('\\n')\n while (nl !== -1) {\n const line = buffer.slice(0, nl)\n buffer = buffer.slice(nl + 1)\n const chunk = parseLine(line)\n if (chunk !== undefined) {\n handleChunk(chunk)\n if (chunk.done === true) {\n doneSeen = true\n clearIdleTimer()\n await drainAndPersist(chunk)\n return\n }\n }\n nl = buffer.indexOf('\\n')\n }\n }\n clearIdleTimer()\n if (stalled) {\n ctx.nack(new E_OLLAMA_STREAM_STALLED([idleMs]))\n return\n }\n // Flush any residual non-newline-terminated final line.\n if (!doneSeen && buffer.trim().length > 0) {\n const chunk = parseLine(buffer)\n buffer = ''\n if (chunk !== undefined) {\n handleChunk(chunk)\n if (chunk.done === true) {\n await drainAndPersist(chunk)\n return\n }\n }\n }\n if (!doneSeen) {\n helpers.log.warn({\n kind: 'ndjson-eof-without-done',\n message: 'NDJSON stream ended without a done:true chunk; draining accumulated state',\n })\n await drainAndPersist(undefined)\n }\n } catch (err) {\n clearIdleTimer()\n if (ctx.abortSignal.aborted) return\n if (stalled) {\n ctx.nack(new E_OLLAMA_STREAM_STALLED([idleMs]))\n return\n }\n helpers.log.error({\n kind: 'stream-error',\n message: `NDJSON stream failed: ${isError(err) ? err.message : String(err)}`,\n payload: { detail: isError(err) ? err.message : String(err) },\n })\n ctx.nack(new E_OLLAMA_STREAM_ERROR([isError(err) ? err.message : String(err)]))\n return\n }\n return\n }\n\n // ── Step 9: non-streaming path ────────────────────────────────────────\n let parsed: OllamaChatResponse\n try {\n parsed = (await response.json()) as OllamaChatResponse\n } catch (err) {\n ctx.nack(new E_OLLAMA_STREAM_ERROR([isError(err) ? err.message : String(err)]))\n return\n }\n const responseId = uuidv6()\n const msg = parsed.message\n\n if (msg && typeof msg.content === 'string' && msg.content.length > 0) {\n const messageId = `${responseId}:message`\n helpers.reportMessage(messageId, msg.content, { isComplete: true })\n await ctx.storeMessage(\n new Message({\n id: messageId,\n role: 'assistant',\n content: msg.content,\n identity: selfIdentity,\n createdAt: nowIso(),\n updatedAt: nowIso(),\n })\n )\n }\n if (msg && typeof msg.thinking === 'string' && msg.thinking.length > 0) {\n const thoughtId = `${responseId}:thought`\n helpers.reportThought(thoughtId, msg.thinking, { isComplete: true })\n await ctx.storeThought(\n new Thought({\n id: thoughtId,\n content: msg.thinking,\n identity: selfIdentity,\n createdAt: nowIso(),\n updatedAt: nowIso(),\n })\n )\n }\n\n helpers.reportGenerationStats(extractGenerationStats(parsed, merged.model))\n\n const rawCalls: OllamaToolCall[] = msg?.tool_calls ?? []\n if (rawCalls.length === 0) {\n if (merged.autoAck) ctx.ack()\n return\n }\n const calls: AssembledOllamaToolCall[] = rawCalls.map((tc) => ({\n id: uuidv6(),\n name: tc.function?.name ?? '',\n args: (tc.function?.arguments ?? {}) as Record<string, unknown>,\n }))\n for (const call of calls) {\n if (ctx.abortSignal.aborted) return\n await executeAndPersistToolCall(call)\n }\n }\n }\n\n /**\n * Returns `true` when `value` is an {@link OllamaAdapter} instance.\n */\n public static isOllamaAdapter(value: unknown): value is OllamaAdapter {\n return isInstanceOf(value, 'OllamaA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AA,KAAA,IAAW;IACX,MAAM,GAAG,UAAU,QAAQ;IAC3B,MAAO,GAAG,UAAU,aAAa,CAAC;GACpC,EAAE;GACF,KAAK,MAAM,QAAQ,OAAO;IACxB,IAAI,IAAI,YAAY,SAAS;IAC7B,MAAM,0BAA0B,IAAI;GACtC;EACF;CACF;;;;CAKA,OAAc,gBAAgB,OAAwC;EACpE,OAAO,sBAAA,aAAa,OAAO,iBAAiB,aAAa;CAC3D;AACF"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Cross-environment executor adapter for the native Ollama `/api/chat` endpoint.
3
+ *
4
+ * @module @nhtio/adk/batteries/llm/ollama/adapter
5
+ *
6
+ * @remarks
7
+ * Native Ollama LLM adapter targeting `/api/chat` (NOT the OpenAI-compat `/v1` layer — the
8
+ * `openai_chat_completions` battery already covers `/v1`). Works against both LOCAL Ollama
9
+ * (`http://localhost:11434`, no auth) and CLOUD Ollama (`https://ollama.com`, `Authorization:
10
+ * Bearer <apiKey>`); the only difference is `baseURL` + the auth header. Native is HTTP-only — a
11
+ * Unix-socket deployment is reached via a custom `fetch` or an external bridge, not an adapter
12
+ * option.
13
+ *
14
+ * Structurally a sibling of the OpenAI Chat Completions adapter, with the native-wire divergences:
15
+ *
16
+ * - Request body: generation params are NESTED under `options`; `think` / `format` / `keep_alive`
17
+ * are top-level native controls; ADK control fields are stripped before sending.
18
+ * - Streaming: NDJSON (newline-delimited JSON objects), terminated in-band by `done: true` — there
19
+ * is no SSE `data:` framing and no `[DONE]` sentinel. Whole `tool_calls` arrive per chunk (no
20
+ * delta accumulation).
21
+ * - Reasoning: the single native `message.thinking` field (no multi-field precedence dance).
22
+ * - Tool calls: `arguments` is already a JSON OBJECT (no `JSON.parse`); native calls carry no `id`,
23
+ * so the adapter synthesizes one (uuidv6) for correlation / checksum / spool keying. Tool-result
24
+ * history messages use `tool_name` (the originating tool), not `tool_call_id`.
25
+ * - Generation stats: the terminal `done: true` object's token counts + nanosecond durations +
26
+ * `done_reason` are surfaced via `helpers.reportGenerationStats`.
27
+ */
28
+ import type { DispatchExecutorFn } from "../../../dispatch_runner";
29
+ import type { OllamaAdapterOptions } from "./types";
30
+ /**
31
+ * Opinionated cross-environment LLM adapter for the native Ollama `/api/chat` wire shape.
32
+ *
33
+ * @remarks
34
+ * Construction validates options eagerly via {@link validateOptions} and throws
35
+ * {@link @nhtio/adk/batteries/llm/ollama!E_INVALID_OLLAMA_OPTIONS} on failure. The returned instance is reusable: call
36
+ * {@link OllamaAdapter.executor} once per `DispatchRunner` configuration to obtain a
37
+ * {@link @nhtio/adk!DispatchExecutorFn} bound to the baseline plus optional executor-scope
38
+ * overrides. Per-iteration overrides live on `ctx.stash.ollama` and take highest precedence;
39
+ * `headers`, `helpers`, `retry`, and the nested runtime `options` merge key-by-key across all three
40
+ * layers, every other field is replaced wholesale at the highest layer that sets it.
41
+ */
42
+ export declare class OllamaAdapter {
43
+ #private;
44
+ /** Customary key for per-iteration overrides on `ctx.stash`. */
45
+ static readonly STASH_KEY: "ollama";
46
+ /**
47
+ * @param options - Constructor-baseline options. Re-validated on every iteration after
48
+ * per-dispatch and per-iteration overrides are layered in.
49
+ * @throws {@link @nhtio/adk/batteries/llm/ollama!E_INVALID_OLLAMA_OPTIONS} when `options` does not satisfy `ollamaOptionsSchema`.
50
+ */
51
+ constructor(options: unknown);
52
+ /**
53
+ * Returns a {@link @nhtio/adk!DispatchExecutorFn} bound to this adapter's baseline plus optional
54
+ * executor-scope overrides.
55
+ *
56
+ * @param overrides - Optional executor-scope overrides. Higher precedence than the baseline,
57
+ * lower precedence than `ctx.stash[STASH_KEY]`.
58
+ */
59
+ executor(overrides?: Partial<OllamaAdapterOptions>): DispatchExecutorFn;
60
+ /**
61
+ * Returns `true` when `value` is an {@link OllamaAdapter} instance.
62
+ */
63
+ static isOllamaAdapter(value: unknown): value is OllamaAdapter;
64
+ }