@nhtio/adk 1.20260607.2 → 1.20260609.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (501) hide show
  1. package/CHANGELOG.md +185 -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/color.cjs +3 -2
  90. package/batteries/tools/color.cjs.map +1 -1
  91. package/batteries/tools/color.mjs +3 -2
  92. package/batteries/tools/color.mjs.map +1 -1
  93. package/batteries/tools/comparison.cjs +4 -3
  94. package/batteries/tools/comparison.cjs.map +1 -1
  95. package/batteries/tools/comparison.mjs +4 -3
  96. package/batteries/tools/comparison.mjs.map +1 -1
  97. package/batteries/tools/data_structure.cjs +30 -10
  98. package/batteries/tools/data_structure.cjs.map +1 -1
  99. package/batteries/tools/data_structure.mjs +30 -10
  100. package/batteries/tools/data_structure.mjs.map +1 -1
  101. package/batteries/tools/datetime_extended.cjs +5 -10
  102. package/batteries/tools/datetime_extended.cjs.map +1 -1
  103. package/batteries/tools/datetime_extended.mjs +5 -10
  104. package/batteries/tools/datetime_extended.mjs.map +1 -1
  105. package/batteries/tools/datetime_math.cjs +2 -2
  106. package/batteries/tools/datetime_math.mjs +2 -2
  107. package/batteries/tools/encoding.cjs +13 -4
  108. package/batteries/tools/encoding.cjs.map +1 -1
  109. package/batteries/tools/encoding.mjs +13 -4
  110. package/batteries/tools/encoding.mjs.map +1 -1
  111. package/batteries/tools/formatting.cjs +4 -4
  112. package/batteries/tools/formatting.cjs.map +1 -1
  113. package/batteries/tools/formatting.mjs +4 -4
  114. package/batteries/tools/formatting.mjs.map +1 -1
  115. package/batteries/tools/geo_basics.cjs +2 -2
  116. package/batteries/tools/geo_basics.mjs +2 -2
  117. package/batteries/tools/index.d.ts +1 -0
  118. package/batteries/tools/math.cjs +10 -8
  119. package/batteries/tools/math.cjs.map +1 -1
  120. package/batteries/tools/math.mjs +10 -8
  121. package/batteries/tools/math.mjs.map +1 -1
  122. package/batteries/tools/memory.cjs +5 -5
  123. package/batteries/tools/memory.mjs +5 -5
  124. package/batteries/tools/parsing.cjs +9 -5
  125. package/batteries/tools/parsing.cjs.map +1 -1
  126. package/batteries/tools/parsing.mjs +9 -5
  127. package/batteries/tools/parsing.mjs.map +1 -1
  128. package/batteries/tools/retrievables.cjs +4 -4
  129. package/batteries/tools/retrievables.mjs +4 -4
  130. package/batteries/tools/searxng/exceptions.d.ts +21 -0
  131. package/batteries/tools/searxng/index.d.ts +150 -0
  132. package/batteries/tools/searxng.cjs +5 -0
  133. package/batteries/tools/searxng.mjs +2 -0
  134. package/batteries/tools/standing_instructions.cjs +4 -4
  135. package/batteries/tools/standing_instructions.mjs +4 -4
  136. package/batteries/tools/statistics.cjs +54 -43
  137. package/batteries/tools/statistics.cjs.map +1 -1
  138. package/batteries/tools/statistics.mjs +54 -43
  139. package/batteries/tools/statistics.mjs.map +1 -1
  140. package/batteries/tools/string_processing.cjs +5 -5
  141. package/batteries/tools/string_processing.cjs.map +1 -1
  142. package/batteries/tools/string_processing.mjs +5 -5
  143. package/batteries/tools/string_processing.mjs.map +1 -1
  144. package/batteries/tools/structured_data.cjs +8 -13
  145. package/batteries/tools/structured_data.cjs.map +1 -1
  146. package/batteries/tools/structured_data.mjs +8 -13
  147. package/batteries/tools/structured_data.mjs.map +1 -1
  148. package/batteries/tools/text_analysis.cjs +3 -3
  149. package/batteries/tools/text_analysis.mjs +3 -3
  150. package/batteries/tools/text_comparison.cjs +2 -2
  151. package/batteries/tools/text_comparison.mjs +2 -2
  152. package/batteries/tools/time.cjs +2 -2
  153. package/batteries/tools/time.mjs +2 -2
  154. package/batteries/tools/unit_conversion.cjs +10 -8
  155. package/batteries/tools/unit_conversion.cjs.map +1 -1
  156. package/batteries/tools/unit_conversion.mjs +10 -8
  157. package/batteries/tools/unit_conversion.mjs.map +1 -1
  158. package/batteries/tools.cjs +3 -0
  159. package/batteries/tools.mjs +2 -1
  160. package/batteries/vector/arangodb/index.d.ts +2 -0
  161. package/batteries/vector/arangodb.cjs +2 -1
  162. package/batteries/vector/arangodb.cjs.map +1 -1
  163. package/batteries/vector/arangodb.mjs +2 -1
  164. package/batteries/vector/arangodb.mjs.map +1 -1
  165. package/batteries/vector/builder.cjs +31 -0
  166. package/batteries/vector/builder.cjs.map +1 -1
  167. package/batteries/vector/builder.d.ts +58 -0
  168. package/batteries/vector/builder.mjs +31 -0
  169. package/batteries/vector/builder.mjs.map +1 -1
  170. package/batteries/vector/chroma/index.d.ts +4 -0
  171. package/batteries/vector/chroma.cjs +3 -0
  172. package/batteries/vector/chroma.cjs.map +1 -1
  173. package/batteries/vector/chroma.mjs +3 -0
  174. package/batteries/vector/chroma.mjs.map +1 -1
  175. package/batteries/vector/clickhouse/index.d.ts +2 -0
  176. package/batteries/vector/clickhouse.cjs +2 -1
  177. package/batteries/vector/clickhouse.cjs.map +1 -1
  178. package/batteries/vector/clickhouse.mjs +2 -1
  179. package/batteries/vector/clickhouse.mjs.map +1 -1
  180. package/batteries/vector/cloudflare/index.d.ts +2 -0
  181. package/batteries/vector/cloudflare.cjs +2 -1
  182. package/batteries/vector/cloudflare.cjs.map +1 -1
  183. package/batteries/vector/cloudflare.mjs +2 -1
  184. package/batteries/vector/cloudflare.mjs.map +1 -1
  185. package/batteries/vector/conformance/index.d.ts +22 -0
  186. package/batteries/vector/conformance.cjs +22 -0
  187. package/batteries/vector/conformance.cjs.map +1 -1
  188. package/batteries/vector/conformance.mjs +22 -0
  189. package/batteries/vector/conformance.mjs.map +1 -1
  190. package/batteries/vector/contract.cjs +22 -0
  191. package/batteries/vector/contract.cjs.map +1 -1
  192. package/batteries/vector/contract.d.ts +51 -0
  193. package/batteries/vector/contract.mjs +22 -0
  194. package/batteries/vector/contract.mjs.map +1 -1
  195. package/batteries/vector/couchbase/index.d.ts +2 -0
  196. package/batteries/vector/couchbase.cjs +2 -1
  197. package/batteries/vector/couchbase.cjs.map +1 -1
  198. package/batteries/vector/couchbase.mjs +2 -1
  199. package/batteries/vector/couchbase.mjs.map +1 -1
  200. package/batteries/vector/duckdb/index.d.ts +2 -0
  201. package/batteries/vector/duckdb.cjs +2 -1
  202. package/batteries/vector/duckdb.cjs.map +1 -1
  203. package/batteries/vector/duckdb.mjs +2 -1
  204. package/batteries/vector/duckdb.mjs.map +1 -1
  205. package/batteries/vector/elasticsearch/index.d.ts +2 -0
  206. package/batteries/vector/elasticsearch.cjs +2 -1
  207. package/batteries/vector/elasticsearch.cjs.map +1 -1
  208. package/batteries/vector/elasticsearch.mjs +2 -1
  209. package/batteries/vector/elasticsearch.mjs.map +1 -1
  210. package/batteries/vector/exceptions.cjs +1 -1
  211. package/batteries/vector/exceptions.mjs +1 -1
  212. package/batteries/vector/factory.cjs +6 -0
  213. package/batteries/vector/factory.cjs.map +1 -1
  214. package/batteries/vector/factory.d.ts +14 -0
  215. package/batteries/vector/factory.mjs +6 -0
  216. package/batteries/vector/factory.mjs.map +1 -1
  217. package/batteries/vector/filters.cjs +22 -1
  218. package/batteries/vector/filters.cjs.map +1 -1
  219. package/batteries/vector/filters.d.ts +38 -0
  220. package/batteries/vector/filters.mjs +22 -1
  221. package/batteries/vector/filters.mjs.map +1 -1
  222. package/batteries/vector/helpers.cjs +13 -0
  223. package/batteries/vector/helpers.cjs.map +1 -1
  224. package/batteries/vector/helpers.d.ts +14 -0
  225. package/batteries/vector/helpers.mjs +13 -0
  226. package/batteries/vector/helpers.mjs.map +1 -1
  227. package/batteries/vector/hnswlib/index.d.ts +2 -0
  228. package/batteries/vector/hnswlib.cjs +2 -1
  229. package/batteries/vector/hnswlib.cjs.map +1 -1
  230. package/batteries/vector/hnswlib.mjs +2 -1
  231. package/batteries/vector/hnswlib.mjs.map +1 -1
  232. package/batteries/vector/in_memory/index.d.ts +1 -0
  233. package/batteries/vector/in_memory.cjs +1 -0
  234. package/batteries/vector/in_memory.cjs.map +1 -1
  235. package/batteries/vector/in_memory.mjs +1 -0
  236. package/batteries/vector/in_memory.mjs.map +1 -1
  237. package/batteries/vector/lancedb/index.d.ts +2 -0
  238. package/batteries/vector/lancedb.cjs +2 -1
  239. package/batteries/vector/lancedb.cjs.map +1 -1
  240. package/batteries/vector/lancedb.mjs +2 -1
  241. package/batteries/vector/lancedb.mjs.map +1 -1
  242. package/batteries/vector/mariadb/index.d.ts +2 -0
  243. package/batteries/vector/mariadb.cjs +2 -1
  244. package/batteries/vector/mariadb.cjs.map +1 -1
  245. package/batteries/vector/mariadb.mjs +2 -1
  246. package/batteries/vector/mariadb.mjs.map +1 -1
  247. package/batteries/vector/meilisearch/index.d.ts +2 -0
  248. package/batteries/vector/meilisearch.cjs +2 -1
  249. package/batteries/vector/meilisearch.cjs.map +1 -1
  250. package/batteries/vector/meilisearch.mjs +2 -1
  251. package/batteries/vector/meilisearch.mjs.map +1 -1
  252. package/batteries/vector/migrate.cjs +18 -1
  253. package/batteries/vector/migrate.cjs.map +1 -1
  254. package/batteries/vector/migrate.d.ts +31 -0
  255. package/batteries/vector/migrate.mjs +18 -1
  256. package/batteries/vector/migrate.mjs.map +1 -1
  257. package/batteries/vector/milvus/index.d.ts +5 -0
  258. package/batteries/vector/milvus.cjs +4 -0
  259. package/batteries/vector/milvus.cjs.map +1 -1
  260. package/batteries/vector/milvus.mjs +4 -0
  261. package/batteries/vector/milvus.mjs.map +1 -1
  262. package/batteries/vector/mongodb/index.d.ts +2 -0
  263. package/batteries/vector/mongodb.cjs +2 -1
  264. package/batteries/vector/mongodb.cjs.map +1 -1
  265. package/batteries/vector/mongodb.mjs +2 -1
  266. package/batteries/vector/mongodb.mjs.map +1 -1
  267. package/batteries/vector/neo4j/index.d.ts +2 -0
  268. package/batteries/vector/neo4j.cjs +2 -1
  269. package/batteries/vector/neo4j.cjs.map +1 -1
  270. package/batteries/vector/neo4j.mjs +2 -1
  271. package/batteries/vector/neo4j.mjs.map +1 -1
  272. package/batteries/vector/opensearch/index.d.ts +2 -0
  273. package/batteries/vector/opensearch.cjs +2 -1
  274. package/batteries/vector/opensearch.cjs.map +1 -1
  275. package/batteries/vector/opensearch.mjs +2 -1
  276. package/batteries/vector/opensearch.mjs.map +1 -1
  277. package/batteries/vector/oracle23ai/index.d.ts +2 -0
  278. package/batteries/vector/oracle23ai.cjs +2 -1
  279. package/batteries/vector/oracle23ai.cjs.map +1 -1
  280. package/batteries/vector/oracle23ai.mjs +2 -1
  281. package/batteries/vector/oracle23ai.mjs.map +1 -1
  282. package/batteries/vector/orama/index.d.ts +1 -0
  283. package/batteries/vector/orama.cjs +1 -0
  284. package/batteries/vector/orama.cjs.map +1 -1
  285. package/batteries/vector/orama.mjs +1 -0
  286. package/batteries/vector/orama.mjs.map +1 -1
  287. package/batteries/vector/pgvector/index.d.ts +9 -2
  288. package/batteries/vector/pgvector.cjs +4 -0
  289. package/batteries/vector/pgvector.cjs.map +1 -1
  290. package/batteries/vector/pgvector.mjs +4 -0
  291. package/batteries/vector/pgvector.mjs.map +1 -1
  292. package/batteries/vector/pinecone/index.d.ts +5 -0
  293. package/batteries/vector/pinecone.cjs +3 -1
  294. package/batteries/vector/pinecone.cjs.map +1 -1
  295. package/batteries/vector/pinecone.mjs +3 -1
  296. package/batteries/vector/pinecone.mjs.map +1 -1
  297. package/batteries/vector/plan.d.ts +27 -0
  298. package/batteries/vector/qdrant/index.d.ts +5 -0
  299. package/batteries/vector/qdrant.cjs +4 -0
  300. package/batteries/vector/qdrant.cjs.map +1 -1
  301. package/batteries/vector/qdrant.mjs +4 -0
  302. package/batteries/vector/qdrant.mjs.map +1 -1
  303. package/batteries/vector/redis/index.d.ts +2 -0
  304. package/batteries/vector/redis.cjs +2 -1
  305. package/batteries/vector/redis.cjs.map +1 -1
  306. package/batteries/vector/redis.mjs +2 -1
  307. package/batteries/vector/redis.mjs.map +1 -1
  308. package/batteries/vector/retrievable.cjs +9 -1
  309. package/batteries/vector/retrievable.cjs.map +1 -1
  310. package/batteries/vector/retrievable.mjs +9 -1
  311. package/batteries/vector/retrievable.mjs.map +1 -1
  312. package/batteries/vector/retrievable_glue.d.ts +21 -0
  313. package/batteries/vector/s3vectors/index.d.ts +2 -0
  314. package/batteries/vector/s3vectors.cjs +2 -1
  315. package/batteries/vector/s3vectors.cjs.map +1 -1
  316. package/batteries/vector/s3vectors.mjs +2 -1
  317. package/batteries/vector/s3vectors.mjs.map +1 -1
  318. package/batteries/vector/schema.cjs +28 -0
  319. package/batteries/vector/schema.cjs.map +1 -1
  320. package/batteries/vector/schema.d.ts +39 -0
  321. package/batteries/vector/schema.mjs +28 -0
  322. package/batteries/vector/schema.mjs.map +1 -1
  323. package/batteries/vector/solr/index.d.ts +2 -0
  324. package/batteries/vector/solr.cjs +2 -1
  325. package/batteries/vector/solr.cjs.map +1 -1
  326. package/batteries/vector/solr.mjs +2 -1
  327. package/batteries/vector/solr.mjs.map +1 -1
  328. package/batteries/vector/sqlite_vec/index.d.ts +6 -3
  329. package/batteries/vector/sqlite_vec.cjs +2 -0
  330. package/batteries/vector/sqlite_vec.cjs.map +1 -1
  331. package/batteries/vector/sqlite_vec.mjs +2 -0
  332. package/batteries/vector/sqlite_vec.mjs.map +1 -1
  333. package/batteries/vector/surrealdb/index.d.ts +2 -0
  334. package/batteries/vector/surrealdb.cjs +2 -1
  335. package/batteries/vector/surrealdb.cjs.map +1 -1
  336. package/batteries/vector/surrealdb.mjs +2 -1
  337. package/batteries/vector/surrealdb.mjs.map +1 -1
  338. package/batteries/vector/types.d.ts +27 -0
  339. package/batteries/vector/typesense/index.d.ts +2 -0
  340. package/batteries/vector/typesense.cjs +2 -1
  341. package/batteries/vector/typesense.cjs.map +1 -1
  342. package/batteries/vector/typesense.mjs +2 -1
  343. package/batteries/vector/typesense.mjs.map +1 -1
  344. package/batteries/vector/validation.cjs +14 -0
  345. package/batteries/vector/validation.cjs.map +1 -1
  346. package/batteries/vector/validation.d.ts +14 -0
  347. package/batteries/vector/validation.mjs +14 -0
  348. package/batteries/vector/validation.mjs.map +1 -1
  349. package/batteries/vector/vector_store_constructor.cjs +1 -1
  350. package/batteries/vector/vector_store_constructor.cjs.map +1 -1
  351. package/batteries/vector/vector_store_constructor.d.ts +1 -1
  352. package/batteries/vector/vector_store_constructor.mjs +1 -1
  353. package/batteries/vector/vector_store_constructor.mjs.map +1 -1
  354. package/batteries/vector/vespa/index.d.ts +2 -0
  355. package/batteries/vector/vespa.cjs +2 -1
  356. package/batteries/vector/vespa.cjs.map +1 -1
  357. package/batteries/vector/vespa.mjs +2 -1
  358. package/batteries/vector/vespa.mjs.map +1 -1
  359. package/batteries/vector/weaviate/index.d.ts +2 -0
  360. package/batteries/vector/weaviate.cjs +2 -1
  361. package/batteries/vector/weaviate.cjs.map +1 -1
  362. package/batteries/vector/weaviate.mjs +2 -1
  363. package/batteries/vector/weaviate.mjs.map +1 -1
  364. package/batteries.cjs +46 -28
  365. package/batteries.mjs +10 -5
  366. package/{common-BT0nfCi9.mjs → common-DYDUi99O.mjs} +9 -9
  367. package/common-DYDUi99O.mjs.map +1 -0
  368. package/{common-Cj8TaQ9U.js → common-DZl3ADJs.js} +9 -9
  369. package/common-DZl3ADJs.js.map +1 -0
  370. package/common.cjs +7 -7
  371. package/common.d.ts +1 -1
  372. package/common.mjs +7 -7
  373. package/{dispatch_runner-DPcS7Y_M.mjs → dispatch_runner--ZhdDWRZ.mjs} +27 -5
  374. package/{dispatch_runner-DPcS7Y_M.mjs.map → dispatch_runner--ZhdDWRZ.mjs.map} +1 -1
  375. package/{dispatch_runner-BHBNupqp.js → dispatch_runner-nHDKkxye.js} +27 -5
  376. package/{dispatch_runner-BHBNupqp.js.map → dispatch_runner-nHDKkxye.js.map} +1 -1
  377. package/dispatch_runner.cjs +1 -1
  378. package/dispatch_runner.d.ts +1 -1
  379. package/dispatch_runner.mjs +1 -1
  380. package/eslint/rules/artifact_tool_forbids_artifact_constructor.cjs +1 -0
  381. package/eslint/rules/artifact_tool_forbids_artifact_constructor.cjs.map +1 -1
  382. package/eslint/rules/artifact_tool_forbids_artifact_constructor.d.ts +1 -0
  383. package/eslint/rules/artifact_tool_forbids_artifact_constructor.mjs +1 -0
  384. package/eslint/rules/artifact_tool_forbids_artifact_constructor.mjs.map +1 -1
  385. package/eslint/rules/no_model_in_tool_handler.cjs +1 -0
  386. package/eslint/rules/no_model_in_tool_handler.cjs.map +1 -1
  387. package/eslint/rules/no_model_in_tool_handler.d.ts +1 -0
  388. package/eslint/rules/no_model_in_tool_handler.mjs +1 -0
  389. package/eslint/rules/no_model_in_tool_handler.mjs.map +1 -1
  390. package/eslint/rules/require_validator_any_required.cjs +1 -0
  391. package/eslint/rules/require_validator_any_required.cjs.map +1 -1
  392. package/eslint/rules/require_validator_any_required.d.ts +1 -0
  393. package/eslint/rules/require_validator_any_required.mjs +1 -0
  394. package/eslint/rules/require_validator_any_required.mjs.map +1 -1
  395. package/eslint/rules/thought_payload_requires_replay_tag.cjs +1 -0
  396. package/eslint/rules/thought_payload_requires_replay_tag.cjs.map +1 -1
  397. package/eslint/rules/thought_payload_requires_replay_tag.d.ts +1 -0
  398. package/eslint/rules/thought_payload_requires_replay_tag.mjs +1 -0
  399. package/eslint/rules/thought_payload_requires_replay_tag.mjs.map +1 -1
  400. package/eslint/rules/token_encoding_requires_context_window.cjs +1 -0
  401. package/eslint/rules/token_encoding_requires_context_window.cjs.map +1 -1
  402. package/eslint/rules/token_encoding_requires_context_window.d.ts +1 -0
  403. package/eslint/rules/token_encoding_requires_context_window.mjs +1 -0
  404. package/eslint/rules/token_encoding_requires_context_window.mjs.map +1 -1
  405. package/eslint.cjs +1 -1
  406. package/eslint.mjs +1 -1
  407. package/{exceptions-BeWH2FwP.mjs → exceptions-BDhN0Xzr.mjs} +3 -2
  408. package/exceptions-BDhN0Xzr.mjs.map +1 -0
  409. package/{exceptions-CitH5wZI.js → exceptions-BRXrUKiW.js} +3 -2
  410. package/exceptions-BRXrUKiW.js.map +1 -0
  411. package/exceptions.cjs +2 -2
  412. package/exceptions.mjs +2 -2
  413. package/factories.cjs +1 -1
  414. package/factories.mjs +1 -1
  415. package/forge.cjs +4 -4
  416. package/forge.d.ts +1 -1
  417. package/forge.mjs +4 -4
  418. package/guards.cjs +9 -9
  419. package/guards.mjs +9 -9
  420. package/helpers-DSTFxTiC.js +497 -0
  421. package/helpers-DSTFxTiC.js.map +1 -0
  422. package/helpers-xhrQbMAG.mjs +306 -0
  423. package/helpers-xhrQbMAG.mjs.map +1 -0
  424. package/index.cjs +13 -13
  425. package/index.mjs +13 -13
  426. package/lib/classes/base_exception.d.ts +1 -0
  427. package/lib/classes/media.d.ts +10 -0
  428. package/lib/classes/retrievable.d.ts +1 -1
  429. package/lib/classes/spooled_json_artifact.d.ts +1 -1
  430. package/lib/classes/spooled_markdown_artifact.d.ts +1 -0
  431. package/lib/classes/tokenizable.d.ts +3 -0
  432. package/lib/classes/tool.d.ts +8 -0
  433. package/lib/classes/turn_gate.d.ts +6 -0
  434. package/lib/dispatch_runner.d.ts +4 -32
  435. package/lib/helpers/bignum.cjs +82 -0
  436. package/lib/helpers/bignum.cjs.map +1 -0
  437. package/lib/helpers/bignum.d.ts +52 -0
  438. package/lib/helpers/bignum.mjs +74 -0
  439. package/lib/helpers/bignum.mjs.map +1 -0
  440. package/lib/turn_runner.d.ts +1 -1
  441. package/lib/types/dispatch_runner.d.ts +83 -0
  442. package/lib/utils/exceptions.d.ts +1 -1
  443. package/lib/utils/retry.cjs.map +1 -1
  444. package/lib/utils/retry.d.ts +2 -0
  445. package/lib/utils/retry.mjs.map +1 -1
  446. package/mcp/adk-docs-corpus.json +1 -1
  447. package/package.json +264 -224
  448. package/{runtime-j92CNi5z.mjs → runtime-Bz5zA8wc.mjs} +2 -2
  449. package/{runtime-j92CNi5z.mjs.map → runtime-Bz5zA8wc.mjs.map} +1 -1
  450. package/{runtime-MFFcJrRv.js → runtime-DslE1aBw.js} +2 -2
  451. package/{runtime-MFFcJrRv.js.map → runtime-DslE1aBw.js.map} +1 -1
  452. package/searxng-Bkrwhwhw.js +269 -0
  453. package/searxng-Bkrwhwhw.js.map +1 -0
  454. package/searxng-CyA-nEu5.mjs +257 -0
  455. package/searxng-CyA-nEu5.mjs.map +1 -0
  456. package/skills/adk-assembly/SKILL.md +2 -2
  457. package/{spooled_artifact-CHoZgWwI.mjs → spooled_artifact-7eePq7JA.mjs} +5 -5
  458. package/{spooled_artifact-CHoZgWwI.mjs.map → spooled_artifact-7eePq7JA.mjs.map} +1 -1
  459. package/{spooled_artifact-BTq6Nzfy.js → spooled_artifact-DX8LLyUX.js} +5 -5
  460. package/{spooled_artifact-BTq6Nzfy.js.map → spooled_artifact-DX8LLyUX.js.map} +1 -1
  461. package/spooled_artifact.cjs +2 -2
  462. package/spooled_artifact.mjs +2 -2
  463. package/{spooled_markdown_artifact-CALSDxIx.js → spooled_markdown_artifact-ClX72lek.js} +4 -4
  464. package/spooled_markdown_artifact-ClX72lek.js.map +1 -0
  465. package/{spooled_markdown_artifact-Ci5UL7l4.mjs → spooled_markdown_artifact-wkrBF3oX.mjs} +4 -4
  466. package/spooled_markdown_artifact-wkrBF3oX.mjs.map +1 -0
  467. package/{thought-D34QQZZ9.mjs → thought-B_vxAiKU.mjs} +5 -5
  468. package/{thought-D34QQZZ9.mjs.map → thought-B_vxAiKU.mjs.map} +1 -1
  469. package/{thought-BbwhJ1wb.js → thought-DLwpF7MI.js} +5 -5
  470. package/{thought-BbwhJ1wb.js.map → thought-DLwpF7MI.js.map} +1 -1
  471. package/{tool-CVyZkFC7.js → tool-D5WGVIcI.js} +4 -4
  472. package/{tool-CVyZkFC7.js.map → tool-D5WGVIcI.js.map} +1 -1
  473. package/{tool-CMhaDRNd.mjs → tool-wMYMVl60.mjs} +4 -4
  474. package/{tool-CMhaDRNd.mjs.map → tool-wMYMVl60.mjs.map} +1 -1
  475. package/{tool_call-CV5qVNlb.mjs → tool_call-B4-_-vjG.mjs} +5 -5
  476. package/tool_call-B4-_-vjG.mjs.map +1 -0
  477. package/{tool_call-Db68hB7y.js → tool_call-DixVlW40.js} +5 -5
  478. package/tool_call-DixVlW40.js.map +1 -0
  479. package/{tool_registry-D1pSSlsd.mjs → tool_registry-791Vrjtf.mjs} +4 -3
  480. package/tool_registry-791Vrjtf.mjs.map +1 -0
  481. package/{tool_registry-DYUYqXvo.js → tool_registry-CKJPze3j.js} +4 -3
  482. package/tool_registry-CKJPze3j.js.map +1 -0
  483. package/{turn_runner-DqWHNP80.js → turn_runner-HXImLGIn.js} +7 -7
  484. package/turn_runner-HXImLGIn.js.map +1 -0
  485. package/{turn_runner-fg1Wc3dK.mjs → turn_runner-ZyYO-Kti.mjs} +7 -7
  486. package/turn_runner-ZyYO-Kti.mjs.map +1 -0
  487. package/turn_runner.cjs +1 -1
  488. package/turn_runner.mjs +1 -1
  489. package/types.d.ts +1 -1
  490. package/common-BT0nfCi9.mjs.map +0 -1
  491. package/common-Cj8TaQ9U.js.map +0 -1
  492. package/exceptions-BeWH2FwP.mjs.map +0 -1
  493. package/exceptions-CitH5wZI.js.map +0 -1
  494. package/spooled_markdown_artifact-CALSDxIx.js.map +0 -1
  495. package/spooled_markdown_artifact-Ci5UL7l4.mjs.map +0 -1
  496. package/tool_call-CV5qVNlb.mjs.map +0 -1
  497. package/tool_call-Db68hB7y.js.map +0 -1
  498. package/tool_registry-D1pSSlsd.mjs.map +0 -1
  499. package/tool_registry-DYUYqXvo.js.map +0 -1
  500. package/turn_runner-DqWHNP80.js.map +0 -1
  501. package/turn_runner-fg1Wc3dK.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.mjs","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, 'OllamaAdapter', OllamaAdapter)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+GA,IAAM,eACJ,WACkB;CAClB,IAAI;CACJ,KAAK,MAAM,SAAS,QAAQ;EAC1B,IAAI,CAAC,OAAO;EACZ,SAAS;GAAE,GAAI,UAAW,CAAC;GAAU,GAAG;EAAM;CAChD;CACA,OAAO;AACT;AAEA,IAAM,gBACJ,UACA,MACA,UACkC;CAClC,MAAM,SAAS;EAAC;EAA2C,QAAQ,CAAC;EAAG,SAAS,CAAC;CAAC;CAClF,MAAM,MAA+B,CAAC;CACtC,KAAK,MAAM,SAAS,QAClB,KAAK,MAAM,CAAC,GAAG,MAAM,OAAO,QAAQ,KAAK,GAAG;EAC1C,IAAI,MAAM,KAAA,GAAW;EACrB,IAAI,MAAM,aAAa,MAAM,aAAa,MAAM,WAAW,MAAM,WAAW;EAC5E,IAAI,KAAK;CACX;CAEF,MAAM,UAAU,YAAY,OAAO,KAAK,MAAM,EAAE,OAA6C,CAAC;CAC9F,IAAI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X,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,aAAa,OAAO,iBAAiB,aAAa;CAC3D;AACF"}
@@ -0,0 +1,105 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ require("../../../chunk-Ble4zEEl.js");
3
+ const require_exceptions = require("../../../exceptions-BRXrUKiW.js");
4
+ require("../../../factories.cjs");
5
+ //#region src/batteries/llm/ollama/exceptions.ts
6
+ /**
7
+ * Battery-scoped exception constructors for the native Ollama `/api/chat` adapter.
8
+ *
9
+ * @module @nhtio/adk/batteries/llm/ollama/exceptions
10
+ *
11
+ * @remarks
12
+ * Battery-scoped exception classes for the native Ollama adapter. These exceptions are owned by
13
+ * the battery (not the ADK core) and are minted via `createException` from `@nhtio/adk/factories`.
14
+ * Re-exported from the battery's barrel. They mirror the OpenAI Chat Completions battery's
15
+ * exception set (same status codes, same fatal/non-fatal split) with two deliberate divergences:
16
+ *
17
+ * - `E_OLLAMA_INVALID_TOOL_CALL_ARGS` — native `/api/chat` returns tool-call `arguments` as a JSON
18
+ * **object**, not a string, so there is no `JSON.parse` failure path. This fires only when the
19
+ * `arguments` value is present but is not a plain object (array / null / primitive — defensive
20
+ * against a non-conformant server or proxy).
21
+ * - `E_OLLAMA_UNSUPPORTED_MEDIA_MODALITY` — native `/api/chat` supports only base64 `images[]`, so
22
+ * its "unsupported" set is wider than the OpenAI battery's (audio, document, and video all fall
23
+ * through here under `unsupportedMediaPolicy: 'throw'`).
24
+ *
25
+ * Malformed NDJSON lines are NOT a distinct exception — they are swallowed and surfaced via
26
+ * `helpers.log.trace` (matching the OpenAI battery's `sse-parse-failure` policy); only a transport
27
+ * throw mid-stream raises `E_OLLAMA_STREAM_ERROR`.
28
+ */
29
+ /**
30
+ * Thrown when the resolved adapter options (constructor, executor overrides, or per-dispatch
31
+ * `stash.ollama`) fail validation against `ollamaOptionsSchema`.
32
+ */
33
+ var E_INVALID_OLLAMA_OPTIONS = require_exceptions.createException("E_INVALID_OLLAMA_OPTIONS", "Invalid Ollama adapter options: %s", "E_INVALID_OLLAMA_OPTIONS", 529, true);
34
+ /**
35
+ * Thrown when the total token weight of the resolved request exceeds `contextWindow`. Only raised
36
+ * when `tokenEncoding` is non-null. Carries `{ total, contextWindow, tokenEncoding, perBucket }` in
37
+ * the message so middleware can target shedding.
38
+ *
39
+ * @remarks
40
+ * This is the ADK-side token-budget guard and is independent of Ollama's server-side `num_ctx`
41
+ * (KV-cache size) runtime option; the adapter does not auto-sync the two.
42
+ */
43
+ var E_OLLAMA_CONTEXT_OVERFLOW = require_exceptions.createException("E_OLLAMA_CONTEXT_OVERFLOW", "Ollama request token weight (%d) exceeds context window (%d) under encoding %s. Per-bucket breakdown: %s", "E_OLLAMA_CONTEXT_OVERFLOW", 529, true);
44
+ /**
45
+ * Thrown when the upstream `/api/chat` endpoint returns a non-2xx response. Non-fatal — surfaced
46
+ * via `ctx.nack(...)` so middleware can decide retry / fail.
47
+ */
48
+ var E_OLLAMA_HTTP_ERROR = require_exceptions.createException("E_OLLAMA_HTTP_ERROR", "Ollama HTTP error %d: %s", "E_OLLAMA_HTTP_ERROR", 502, false);
49
+ /**
50
+ * Thrown when the NDJSON stream emits a transport-level failure mid-stream (the reader throws).
51
+ * Non-fatal — surfaced via `ctx.nack(...)`. A single malformed NDJSON line is NOT this error — it
52
+ * is swallowed + logged at `trace`.
53
+ */
54
+ var E_OLLAMA_STREAM_ERROR = require_exceptions.createException("E_OLLAMA_STREAM_ERROR", "Ollama stream error: %s", "E_OLLAMA_STREAM_ERROR", 502, false);
55
+ /**
56
+ * Thrown when the NDJSON stream goes silent for longer than `streamIdleTimeoutMs`. Non-fatal —
57
+ * surfaced via `ctx.nack(...)` so middleware can recover.
58
+ */
59
+ var E_OLLAMA_STREAM_STALLED = require_exceptions.createException("E_OLLAMA_STREAM_STALLED", "Ollama stream stalled (no chunk for %dms)", "E_OLLAMA_STREAM_STALLED", 504, false);
60
+ /**
61
+ * Thrown when the initial request handshake (TCP connect, TLS, response headers) does not complete
62
+ * before `requestTimeoutMs`. Non-fatal — surfaced via `ctx.nack(...)`. Eligible for retry on the
63
+ * same footing as a retriable 5xx.
64
+ */
65
+ var E_OLLAMA_REQUEST_TIMEOUT = require_exceptions.createException("E_OLLAMA_REQUEST_TIMEOUT", "Ollama request timed out after %dms (before response headers)", "E_OLLAMA_REQUEST_TIMEOUT", 504, false);
66
+ /**
67
+ * Raised when a tool-call's `arguments` value emitted by the model is present but is not a JSON
68
+ * object (e.g. an array, `null`, or a primitive).
69
+ *
70
+ * @remarks
71
+ * Non-fatal. Native `/api/chat` delivers `arguments` already parsed as an object, so — unlike the
72
+ * OpenAI battery — there is no JSON-parse failure mode; this fires only on the not-an-object case.
73
+ * The adapter does NOT throw it: it instantiates it inside `executeAndPersistToolCall`, pulls
74
+ * `.message` into a {@link @nhtio/adk!Tokenizable}, and persists a `ToolCall` record with
75
+ * `isError: true` so the model can self-correct on the next iteration.
76
+ *
77
+ * Printf args: `[reasonHeadline, rawArgs]`.
78
+ * - `reasonHeadline` — short reason such as `'must be a JSON object; received array'`.
79
+ * - `rawArgs` — `JSON.stringify(arguments)` of what the model sent, echoed back so it can see it.
80
+ */
81
+ var E_OLLAMA_INVALID_TOOL_CALL_ARGS = require_exceptions.createException("E_OLLAMA_INVALID_TOOL_CALL_ARGS", "Tool arguments %s. Raw value: %s", "E_OLLAMA_INVALID_TOOL_CALL_ARGS", 422, false);
82
+ /**
83
+ * Raised when a {@link @nhtio/adk!Media} instance whose modality cannot be natively represented in
84
+ * the Ollama `/api/chat` wire format reaches the adapter under `unsupportedMediaPolicy: 'throw'`.
85
+ *
86
+ * @remarks
87
+ * Native `/api/chat` supports only base64 `images[]` — it has no audio, document, or video
88
+ * representation — so this triggers for every non-image modality (a wider set than the OpenAI
89
+ * battery, which natively supports audio and document blocks). Consumers can opt out of the throw
90
+ * by switching to `'fallback-stash'` or `'synthetic-description'`.
91
+ *
92
+ * Printf args: `[kind, mimeType, filename]`.
93
+ */
94
+ var E_OLLAMA_UNSUPPORTED_MEDIA_MODALITY = require_exceptions.createException("E_OLLAMA_UNSUPPORTED_MEDIA_MODALITY", "Ollama /api/chat natively supports only images; media of kind %s (mime=%s, filename=%s) is unsupported. Configure adapter `unsupportedMediaPolicy` to `fallback-stash` or `synthetic-description` to handle this case.", "E_OLLAMA_UNSUPPORTED_MEDIA_MODALITY", 422, true);
95
+ //#endregion
96
+ exports.E_INVALID_OLLAMA_OPTIONS = E_INVALID_OLLAMA_OPTIONS;
97
+ exports.E_OLLAMA_CONTEXT_OVERFLOW = E_OLLAMA_CONTEXT_OVERFLOW;
98
+ exports.E_OLLAMA_HTTP_ERROR = E_OLLAMA_HTTP_ERROR;
99
+ exports.E_OLLAMA_INVALID_TOOL_CALL_ARGS = E_OLLAMA_INVALID_TOOL_CALL_ARGS;
100
+ exports.E_OLLAMA_REQUEST_TIMEOUT = E_OLLAMA_REQUEST_TIMEOUT;
101
+ exports.E_OLLAMA_STREAM_ERROR = E_OLLAMA_STREAM_ERROR;
102
+ exports.E_OLLAMA_STREAM_STALLED = E_OLLAMA_STREAM_STALLED;
103
+ exports.E_OLLAMA_UNSUPPORTED_MEDIA_MODALITY = E_OLLAMA_UNSUPPORTED_MEDIA_MODALITY;
104
+
105
+ //# sourceMappingURL=exceptions.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exceptions.cjs","names":[],"sources":["../../../../src/batteries/llm/ollama/exceptions.ts"],"sourcesContent":["/**\n * Battery-scoped exception constructors for the native Ollama `/api/chat` adapter.\n *\n * @module @nhtio/adk/batteries/llm/ollama/exceptions\n *\n * @remarks\n * Battery-scoped exception classes for the native Ollama adapter. These exceptions are owned by\n * the battery (not the ADK core) and are minted via `createException` from `@nhtio/adk/factories`.\n * Re-exported from the battery's barrel. They mirror the OpenAI Chat Completions battery's\n * exception set (same status codes, same fatal/non-fatal split) with two deliberate divergences:\n *\n * - `E_OLLAMA_INVALID_TOOL_CALL_ARGS` — native `/api/chat` returns tool-call `arguments` as a JSON\n * **object**, not a string, so there is no `JSON.parse` failure path. This fires only when the\n * `arguments` value is present but is not a plain object (array / null / primitive — defensive\n * against a non-conformant server or proxy).\n * - `E_OLLAMA_UNSUPPORTED_MEDIA_MODALITY` — native `/api/chat` supports only base64 `images[]`, so\n * its \"unsupported\" set is wider than the OpenAI battery's (audio, document, and video all fall\n * through here under `unsupportedMediaPolicy: 'throw'`).\n *\n * Malformed NDJSON lines are NOT a distinct exception — they are swallowed and surfaced via\n * `helpers.log.trace` (matching the OpenAI battery's `sse-parse-failure` policy); only a transport\n * throw mid-stream raises `E_OLLAMA_STREAM_ERROR`.\n */\n\nimport { createException } from '@nhtio/adk/factories'\n\n/**\n * Thrown when the resolved adapter options (constructor, executor overrides, or per-dispatch\n * `stash.ollama`) fail validation against `ollamaOptionsSchema`.\n */\nexport const E_INVALID_OLLAMA_OPTIONS = createException<[string]>(\n 'E_INVALID_OLLAMA_OPTIONS',\n 'Invalid Ollama adapter options: %s',\n 'E_INVALID_OLLAMA_OPTIONS',\n 529,\n true\n)\n\n/**\n * Thrown when the total token weight of the resolved request exceeds `contextWindow`. Only raised\n * when `tokenEncoding` is non-null. Carries `{ total, contextWindow, tokenEncoding, perBucket }` in\n * the message so middleware can target shedding.\n *\n * @remarks\n * This is the ADK-side token-budget guard and is independent of Ollama's server-side `num_ctx`\n * (KV-cache size) runtime option; the adapter does not auto-sync the two.\n */\nexport const E_OLLAMA_CONTEXT_OVERFLOW = createException<[number, number, string, string]>(\n 'E_OLLAMA_CONTEXT_OVERFLOW',\n 'Ollama request token weight (%d) exceeds context window (%d) under encoding %s. Per-bucket breakdown: %s',\n 'E_OLLAMA_CONTEXT_OVERFLOW',\n 529,\n true\n)\n\n/**\n * Thrown when the upstream `/api/chat` endpoint returns a non-2xx response. Non-fatal — surfaced\n * via `ctx.nack(...)` so middleware can decide retry / fail.\n */\nexport const E_OLLAMA_HTTP_ERROR = createException<[number, string]>(\n 'E_OLLAMA_HTTP_ERROR',\n 'Ollama HTTP error %d: %s',\n 'E_OLLAMA_HTTP_ERROR',\n 502,\n false\n)\n\n/**\n * Thrown when the NDJSON stream emits a transport-level failure mid-stream (the reader throws).\n * Non-fatal — surfaced via `ctx.nack(...)`. A single malformed NDJSON line is NOT this error — it\n * is swallowed + logged at `trace`.\n */\nexport const E_OLLAMA_STREAM_ERROR = createException<[string]>(\n 'E_OLLAMA_STREAM_ERROR',\n 'Ollama stream error: %s',\n 'E_OLLAMA_STREAM_ERROR',\n 502,\n false\n)\n\n/**\n * Thrown when the NDJSON stream goes silent for longer than `streamIdleTimeoutMs`. Non-fatal —\n * surfaced via `ctx.nack(...)` so middleware can recover.\n */\nexport const E_OLLAMA_STREAM_STALLED = createException<[number]>(\n 'E_OLLAMA_STREAM_STALLED',\n 'Ollama stream stalled (no chunk for %dms)',\n 'E_OLLAMA_STREAM_STALLED',\n 504,\n false\n)\n\n/**\n * Thrown when the initial request handshake (TCP connect, TLS, response headers) does not complete\n * before `requestTimeoutMs`. Non-fatal — surfaced via `ctx.nack(...)`. Eligible for retry on the\n * same footing as a retriable 5xx.\n */\nexport const E_OLLAMA_REQUEST_TIMEOUT = createException<[number]>(\n 'E_OLLAMA_REQUEST_TIMEOUT',\n 'Ollama request timed out after %dms (before response headers)',\n 'E_OLLAMA_REQUEST_TIMEOUT',\n 504,\n false\n)\n\n/**\n * Raised when a tool-call's `arguments` value emitted by the model is present but is not a JSON\n * object (e.g. an array, `null`, or a primitive).\n *\n * @remarks\n * Non-fatal. Native `/api/chat` delivers `arguments` already parsed as an object, so — unlike the\n * OpenAI battery — there is no JSON-parse failure mode; this fires only on the not-an-object case.\n * The adapter does NOT throw it: it instantiates it inside `executeAndPersistToolCall`, pulls\n * `.message` into a {@link @nhtio/adk!Tokenizable}, and persists a `ToolCall` record with\n * `isError: true` so the model can self-correct on the next iteration.\n *\n * Printf args: `[reasonHeadline, rawArgs]`.\n * - `reasonHeadline` — short reason such as `'must be a JSON object; received array'`.\n * - `rawArgs` — `JSON.stringify(arguments)` of what the model sent, echoed back so it can see it.\n */\nexport const E_OLLAMA_INVALID_TOOL_CALL_ARGS = createException<[string, string]>(\n 'E_OLLAMA_INVALID_TOOL_CALL_ARGS',\n 'Tool arguments %s. Raw value: %s',\n 'E_OLLAMA_INVALID_TOOL_CALL_ARGS',\n 422,\n false\n)\n\n/**\n * Raised when a {@link @nhtio/adk!Media} instance whose modality cannot be natively represented in\n * the Ollama `/api/chat` wire format reaches the adapter under `unsupportedMediaPolicy: 'throw'`.\n *\n * @remarks\n * Native `/api/chat` supports only base64 `images[]` — it has no audio, document, or video\n * representation — so this triggers for every non-image modality (a wider set than the OpenAI\n * battery, which natively supports audio and document blocks). Consumers can opt out of the throw\n * by switching to `'fallback-stash'` or `'synthetic-description'`.\n *\n * Printf args: `[kind, mimeType, filename]`.\n */\nexport const E_OLLAMA_UNSUPPORTED_MEDIA_MODALITY = createException<[string, string, string]>(\n 'E_OLLAMA_UNSUPPORTED_MEDIA_MODALITY',\n 'Ollama /api/chat natively supports only images; media of kind %s (mime=%s, filename=%s) is unsupported. Configure adapter `unsupportedMediaPolicy` to `fallback-stash` or `synthetic-description` to handle this case.',\n 'E_OLLAMA_UNSUPPORTED_MEDIA_MODALITY',\n 422,\n true\n)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,IAAa,2BAA2B,mBAAA,gBACtC,4BACA,sCACA,4BACA,KACA,IACF;;;;;;;;;;AAWA,IAAa,4BAA4B,mBAAA,gBACvC,6BACA,4GACA,6BACA,KACA,IACF;;;;;AAMA,IAAa,sBAAsB,mBAAA,gBACjC,uBACA,4BACA,uBACA,KACA,KACF;;;;;;AAOA,IAAa,wBAAwB,mBAAA,gBACnC,yBACA,2BACA,yBACA,KACA,KACF;;;;;AAMA,IAAa,0BAA0B,mBAAA,gBACrC,2BACA,6CACA,2BACA,KACA,KACF;;;;;;AAOA,IAAa,2BAA2B,mBAAA,gBACtC,4BACA,iEACA,4BACA,KACA,KACF;;;;;;;;;;;;;;;;AAiBA,IAAa,kCAAkC,mBAAA,gBAC7C,mCACA,oCACA,mCACA,KACA,KACF;;;;;;;;;;;;;AAcA,IAAa,sCAAsC,mBAAA,gBACjD,uCACA,0NACA,uCACA,KACA,IACF"}
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Battery-scoped exception constructors for the native Ollama `/api/chat` adapter.
3
+ *
4
+ * @module @nhtio/adk/batteries/llm/ollama/exceptions
5
+ *
6
+ * @remarks
7
+ * Battery-scoped exception classes for the native Ollama adapter. These exceptions are owned by
8
+ * the battery (not the ADK core) and are minted via `createException` from `@nhtio/adk/factories`.
9
+ * Re-exported from the battery's barrel. They mirror the OpenAI Chat Completions battery's
10
+ * exception set (same status codes, same fatal/non-fatal split) with two deliberate divergences:
11
+ *
12
+ * - `E_OLLAMA_INVALID_TOOL_CALL_ARGS` — native `/api/chat` returns tool-call `arguments` as a JSON
13
+ * **object**, not a string, so there is no `JSON.parse` failure path. This fires only when the
14
+ * `arguments` value is present but is not a plain object (array / null / primitive — defensive
15
+ * against a non-conformant server or proxy).
16
+ * - `E_OLLAMA_UNSUPPORTED_MEDIA_MODALITY` — native `/api/chat` supports only base64 `images[]`, so
17
+ * its "unsupported" set is wider than the OpenAI battery's (audio, document, and video all fall
18
+ * through here under `unsupportedMediaPolicy: 'throw'`).
19
+ *
20
+ * Malformed NDJSON lines are NOT a distinct exception — they are swallowed and surfaced via
21
+ * `helpers.log.trace` (matching the OpenAI battery's `sse-parse-failure` policy); only a transport
22
+ * throw mid-stream raises `E_OLLAMA_STREAM_ERROR`.
23
+ */
24
+ /**
25
+ * Thrown when the resolved adapter options (constructor, executor overrides, or per-dispatch
26
+ * `stash.ollama`) fail validation against `ollamaOptionsSchema`.
27
+ */
28
+ export declare const E_INVALID_OLLAMA_OPTIONS: import("../../../factories").CreatedException<[
29
+ string
30
+ ]>;
31
+ /**
32
+ * Thrown when the total token weight of the resolved request exceeds `contextWindow`. Only raised
33
+ * when `tokenEncoding` is non-null. Carries `{ total, contextWindow, tokenEncoding, perBucket }` in
34
+ * the message so middleware can target shedding.
35
+ *
36
+ * @remarks
37
+ * This is the ADK-side token-budget guard and is independent of Ollama's server-side `num_ctx`
38
+ * (KV-cache size) runtime option; the adapter does not auto-sync the two.
39
+ */
40
+ export declare const E_OLLAMA_CONTEXT_OVERFLOW: import("../../../factories").CreatedException<[
41
+ number,
42
+ number,
43
+ string,
44
+ string
45
+ ]>;
46
+ /**
47
+ * Thrown when the upstream `/api/chat` endpoint returns a non-2xx response. Non-fatal — surfaced
48
+ * via `ctx.nack(...)` so middleware can decide retry / fail.
49
+ */
50
+ export declare const E_OLLAMA_HTTP_ERROR: import("../../../factories").CreatedException<[
51
+ number,
52
+ string
53
+ ]>;
54
+ /**
55
+ * Thrown when the NDJSON stream emits a transport-level failure mid-stream (the reader throws).
56
+ * Non-fatal — surfaced via `ctx.nack(...)`. A single malformed NDJSON line is NOT this error — it
57
+ * is swallowed + logged at `trace`.
58
+ */
59
+ export declare const E_OLLAMA_STREAM_ERROR: import("../../../factories").CreatedException<[
60
+ string
61
+ ]>;
62
+ /**
63
+ * Thrown when the NDJSON stream goes silent for longer than `streamIdleTimeoutMs`. Non-fatal —
64
+ * surfaced via `ctx.nack(...)` so middleware can recover.
65
+ */
66
+ export declare const E_OLLAMA_STREAM_STALLED: import("../../../factories").CreatedException<[
67
+ number
68
+ ]>;
69
+ /**
70
+ * Thrown when the initial request handshake (TCP connect, TLS, response headers) does not complete
71
+ * before `requestTimeoutMs`. Non-fatal — surfaced via `ctx.nack(...)`. Eligible for retry on the
72
+ * same footing as a retriable 5xx.
73
+ */
74
+ export declare const E_OLLAMA_REQUEST_TIMEOUT: import("../../../factories").CreatedException<[
75
+ number
76
+ ]>;
77
+ /**
78
+ * Raised when a tool-call's `arguments` value emitted by the model is present but is not a JSON
79
+ * object (e.g. an array, `null`, or a primitive).
80
+ *
81
+ * @remarks
82
+ * Non-fatal. Native `/api/chat` delivers `arguments` already parsed as an object, so — unlike the
83
+ * OpenAI battery — there is no JSON-parse failure mode; this fires only on the not-an-object case.
84
+ * The adapter does NOT throw it: it instantiates it inside `executeAndPersistToolCall`, pulls
85
+ * `.message` into a {@link @nhtio/adk!Tokenizable}, and persists a `ToolCall` record with
86
+ * `isError: true` so the model can self-correct on the next iteration.
87
+ *
88
+ * Printf args: `[reasonHeadline, rawArgs]`.
89
+ * - `reasonHeadline` — short reason such as `'must be a JSON object; received array'`.
90
+ * - `rawArgs` — `JSON.stringify(arguments)` of what the model sent, echoed back so it can see it.
91
+ */
92
+ export declare const E_OLLAMA_INVALID_TOOL_CALL_ARGS: import("../../../factories").CreatedException<[
93
+ string,
94
+ string
95
+ ]>;
96
+ /**
97
+ * Raised when a {@link @nhtio/adk!Media} instance whose modality cannot be natively represented in
98
+ * the Ollama `/api/chat` wire format reaches the adapter under `unsupportedMediaPolicy: 'throw'`.
99
+ *
100
+ * @remarks
101
+ * Native `/api/chat` supports only base64 `images[]` — it has no audio, document, or video
102
+ * representation — so this triggers for every non-image modality (a wider set than the OpenAI
103
+ * battery, which natively supports audio and document blocks). Consumers can opt out of the throw
104
+ * by switching to `'fallback-stash'` or `'synthetic-description'`.
105
+ *
106
+ * Printf args: `[kind, mimeType, filename]`.
107
+ */
108
+ export declare const E_OLLAMA_UNSUPPORTED_MEDIA_MODALITY: import("../../../factories").CreatedException<[
109
+ string,
110
+ string,
111
+ string
112
+ ]>;
@@ -0,0 +1,96 @@
1
+ import { t as createException } from "../../../exceptions-BDhN0Xzr.mjs";
2
+ import "../../../factories.mjs";
3
+ //#region src/batteries/llm/ollama/exceptions.ts
4
+ /**
5
+ * Battery-scoped exception constructors for the native Ollama `/api/chat` adapter.
6
+ *
7
+ * @module @nhtio/adk/batteries/llm/ollama/exceptions
8
+ *
9
+ * @remarks
10
+ * Battery-scoped exception classes for the native Ollama adapter. These exceptions are owned by
11
+ * the battery (not the ADK core) and are minted via `createException` from `@nhtio/adk/factories`.
12
+ * Re-exported from the battery's barrel. They mirror the OpenAI Chat Completions battery's
13
+ * exception set (same status codes, same fatal/non-fatal split) with two deliberate divergences:
14
+ *
15
+ * - `E_OLLAMA_INVALID_TOOL_CALL_ARGS` — native `/api/chat` returns tool-call `arguments` as a JSON
16
+ * **object**, not a string, so there is no `JSON.parse` failure path. This fires only when the
17
+ * `arguments` value is present but is not a plain object (array / null / primitive — defensive
18
+ * against a non-conformant server or proxy).
19
+ * - `E_OLLAMA_UNSUPPORTED_MEDIA_MODALITY` — native `/api/chat` supports only base64 `images[]`, so
20
+ * its "unsupported" set is wider than the OpenAI battery's (audio, document, and video all fall
21
+ * through here under `unsupportedMediaPolicy: 'throw'`).
22
+ *
23
+ * Malformed NDJSON lines are NOT a distinct exception — they are swallowed and surfaced via
24
+ * `helpers.log.trace` (matching the OpenAI battery's `sse-parse-failure` policy); only a transport
25
+ * throw mid-stream raises `E_OLLAMA_STREAM_ERROR`.
26
+ */
27
+ /**
28
+ * Thrown when the resolved adapter options (constructor, executor overrides, or per-dispatch
29
+ * `stash.ollama`) fail validation against `ollamaOptionsSchema`.
30
+ */
31
+ var E_INVALID_OLLAMA_OPTIONS = createException("E_INVALID_OLLAMA_OPTIONS", "Invalid Ollama adapter options: %s", "E_INVALID_OLLAMA_OPTIONS", 529, true);
32
+ /**
33
+ * Thrown when the total token weight of the resolved request exceeds `contextWindow`. Only raised
34
+ * when `tokenEncoding` is non-null. Carries `{ total, contextWindow, tokenEncoding, perBucket }` in
35
+ * the message so middleware can target shedding.
36
+ *
37
+ * @remarks
38
+ * This is the ADK-side token-budget guard and is independent of Ollama's server-side `num_ctx`
39
+ * (KV-cache size) runtime option; the adapter does not auto-sync the two.
40
+ */
41
+ var E_OLLAMA_CONTEXT_OVERFLOW = createException("E_OLLAMA_CONTEXT_OVERFLOW", "Ollama request token weight (%d) exceeds context window (%d) under encoding %s. Per-bucket breakdown: %s", "E_OLLAMA_CONTEXT_OVERFLOW", 529, true);
42
+ /**
43
+ * Thrown when the upstream `/api/chat` endpoint returns a non-2xx response. Non-fatal — surfaced
44
+ * via `ctx.nack(...)` so middleware can decide retry / fail.
45
+ */
46
+ var E_OLLAMA_HTTP_ERROR = createException("E_OLLAMA_HTTP_ERROR", "Ollama HTTP error %d: %s", "E_OLLAMA_HTTP_ERROR", 502, false);
47
+ /**
48
+ * Thrown when the NDJSON stream emits a transport-level failure mid-stream (the reader throws).
49
+ * Non-fatal — surfaced via `ctx.nack(...)`. A single malformed NDJSON line is NOT this error — it
50
+ * is swallowed + logged at `trace`.
51
+ */
52
+ var E_OLLAMA_STREAM_ERROR = createException("E_OLLAMA_STREAM_ERROR", "Ollama stream error: %s", "E_OLLAMA_STREAM_ERROR", 502, false);
53
+ /**
54
+ * Thrown when the NDJSON stream goes silent for longer than `streamIdleTimeoutMs`. Non-fatal —
55
+ * surfaced via `ctx.nack(...)` so middleware can recover.
56
+ */
57
+ var E_OLLAMA_STREAM_STALLED = createException("E_OLLAMA_STREAM_STALLED", "Ollama stream stalled (no chunk for %dms)", "E_OLLAMA_STREAM_STALLED", 504, false);
58
+ /**
59
+ * Thrown when the initial request handshake (TCP connect, TLS, response headers) does not complete
60
+ * before `requestTimeoutMs`. Non-fatal — surfaced via `ctx.nack(...)`. Eligible for retry on the
61
+ * same footing as a retriable 5xx.
62
+ */
63
+ var E_OLLAMA_REQUEST_TIMEOUT = createException("E_OLLAMA_REQUEST_TIMEOUT", "Ollama request timed out after %dms (before response headers)", "E_OLLAMA_REQUEST_TIMEOUT", 504, false);
64
+ /**
65
+ * Raised when a tool-call's `arguments` value emitted by the model is present but is not a JSON
66
+ * object (e.g. an array, `null`, or a primitive).
67
+ *
68
+ * @remarks
69
+ * Non-fatal. Native `/api/chat` delivers `arguments` already parsed as an object, so — unlike the
70
+ * OpenAI battery — there is no JSON-parse failure mode; this fires only on the not-an-object case.
71
+ * The adapter does NOT throw it: it instantiates it inside `executeAndPersistToolCall`, pulls
72
+ * `.message` into a {@link @nhtio/adk!Tokenizable}, and persists a `ToolCall` record with
73
+ * `isError: true` so the model can self-correct on the next iteration.
74
+ *
75
+ * Printf args: `[reasonHeadline, rawArgs]`.
76
+ * - `reasonHeadline` — short reason such as `'must be a JSON object; received array'`.
77
+ * - `rawArgs` — `JSON.stringify(arguments)` of what the model sent, echoed back so it can see it.
78
+ */
79
+ var E_OLLAMA_INVALID_TOOL_CALL_ARGS = createException("E_OLLAMA_INVALID_TOOL_CALL_ARGS", "Tool arguments %s. Raw value: %s", "E_OLLAMA_INVALID_TOOL_CALL_ARGS", 422, false);
80
+ /**
81
+ * Raised when a {@link @nhtio/adk!Media} instance whose modality cannot be natively represented in
82
+ * the Ollama `/api/chat` wire format reaches the adapter under `unsupportedMediaPolicy: 'throw'`.
83
+ *
84
+ * @remarks
85
+ * Native `/api/chat` supports only base64 `images[]` — it has no audio, document, or video
86
+ * representation — so this triggers for every non-image modality (a wider set than the OpenAI
87
+ * battery, which natively supports audio and document blocks). Consumers can opt out of the throw
88
+ * by switching to `'fallback-stash'` or `'synthetic-description'`.
89
+ *
90
+ * Printf args: `[kind, mimeType, filename]`.
91
+ */
92
+ var E_OLLAMA_UNSUPPORTED_MEDIA_MODALITY = createException("E_OLLAMA_UNSUPPORTED_MEDIA_MODALITY", "Ollama /api/chat natively supports only images; media of kind %s (mime=%s, filename=%s) is unsupported. Configure adapter `unsupportedMediaPolicy` to `fallback-stash` or `synthetic-description` to handle this case.", "E_OLLAMA_UNSUPPORTED_MEDIA_MODALITY", 422, true);
93
+ //#endregion
94
+ export { E_INVALID_OLLAMA_OPTIONS, E_OLLAMA_CONTEXT_OVERFLOW, E_OLLAMA_HTTP_ERROR, E_OLLAMA_INVALID_TOOL_CALL_ARGS, E_OLLAMA_REQUEST_TIMEOUT, E_OLLAMA_STREAM_ERROR, E_OLLAMA_STREAM_STALLED, E_OLLAMA_UNSUPPORTED_MEDIA_MODALITY };
95
+
96
+ //# sourceMappingURL=exceptions.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exceptions.mjs","names":[],"sources":["../../../../src/batteries/llm/ollama/exceptions.ts"],"sourcesContent":["/**\n * Battery-scoped exception constructors for the native Ollama `/api/chat` adapter.\n *\n * @module @nhtio/adk/batteries/llm/ollama/exceptions\n *\n * @remarks\n * Battery-scoped exception classes for the native Ollama adapter. These exceptions are owned by\n * the battery (not the ADK core) and are minted via `createException` from `@nhtio/adk/factories`.\n * Re-exported from the battery's barrel. They mirror the OpenAI Chat Completions battery's\n * exception set (same status codes, same fatal/non-fatal split) with two deliberate divergences:\n *\n * - `E_OLLAMA_INVALID_TOOL_CALL_ARGS` — native `/api/chat` returns tool-call `arguments` as a JSON\n * **object**, not a string, so there is no `JSON.parse` failure path. This fires only when the\n * `arguments` value is present but is not a plain object (array / null / primitive — defensive\n * against a non-conformant server or proxy).\n * - `E_OLLAMA_UNSUPPORTED_MEDIA_MODALITY` — native `/api/chat` supports only base64 `images[]`, so\n * its \"unsupported\" set is wider than the OpenAI battery's (audio, document, and video all fall\n * through here under `unsupportedMediaPolicy: 'throw'`).\n *\n * Malformed NDJSON lines are NOT a distinct exception — they are swallowed and surfaced via\n * `helpers.log.trace` (matching the OpenAI battery's `sse-parse-failure` policy); only a transport\n * throw mid-stream raises `E_OLLAMA_STREAM_ERROR`.\n */\n\nimport { createException } from '@nhtio/adk/factories'\n\n/**\n * Thrown when the resolved adapter options (constructor, executor overrides, or per-dispatch\n * `stash.ollama`) fail validation against `ollamaOptionsSchema`.\n */\nexport const E_INVALID_OLLAMA_OPTIONS = createException<[string]>(\n 'E_INVALID_OLLAMA_OPTIONS',\n 'Invalid Ollama adapter options: %s',\n 'E_INVALID_OLLAMA_OPTIONS',\n 529,\n true\n)\n\n/**\n * Thrown when the total token weight of the resolved request exceeds `contextWindow`. Only raised\n * when `tokenEncoding` is non-null. Carries `{ total, contextWindow, tokenEncoding, perBucket }` in\n * the message so middleware can target shedding.\n *\n * @remarks\n * This is the ADK-side token-budget guard and is independent of Ollama's server-side `num_ctx`\n * (KV-cache size) runtime option; the adapter does not auto-sync the two.\n */\nexport const E_OLLAMA_CONTEXT_OVERFLOW = createException<[number, number, string, string]>(\n 'E_OLLAMA_CONTEXT_OVERFLOW',\n 'Ollama request token weight (%d) exceeds context window (%d) under encoding %s. Per-bucket breakdown: %s',\n 'E_OLLAMA_CONTEXT_OVERFLOW',\n 529,\n true\n)\n\n/**\n * Thrown when the upstream `/api/chat` endpoint returns a non-2xx response. Non-fatal — surfaced\n * via `ctx.nack(...)` so middleware can decide retry / fail.\n */\nexport const E_OLLAMA_HTTP_ERROR = createException<[number, string]>(\n 'E_OLLAMA_HTTP_ERROR',\n 'Ollama HTTP error %d: %s',\n 'E_OLLAMA_HTTP_ERROR',\n 502,\n false\n)\n\n/**\n * Thrown when the NDJSON stream emits a transport-level failure mid-stream (the reader throws).\n * Non-fatal — surfaced via `ctx.nack(...)`. A single malformed NDJSON line is NOT this error — it\n * is swallowed + logged at `trace`.\n */\nexport const E_OLLAMA_STREAM_ERROR = createException<[string]>(\n 'E_OLLAMA_STREAM_ERROR',\n 'Ollama stream error: %s',\n 'E_OLLAMA_STREAM_ERROR',\n 502,\n false\n)\n\n/**\n * Thrown when the NDJSON stream goes silent for longer than `streamIdleTimeoutMs`. Non-fatal —\n * surfaced via `ctx.nack(...)` so middleware can recover.\n */\nexport const E_OLLAMA_STREAM_STALLED = createException<[number]>(\n 'E_OLLAMA_STREAM_STALLED',\n 'Ollama stream stalled (no chunk for %dms)',\n 'E_OLLAMA_STREAM_STALLED',\n 504,\n false\n)\n\n/**\n * Thrown when the initial request handshake (TCP connect, TLS, response headers) does not complete\n * before `requestTimeoutMs`. Non-fatal — surfaced via `ctx.nack(...)`. Eligible for retry on the\n * same footing as a retriable 5xx.\n */\nexport const E_OLLAMA_REQUEST_TIMEOUT = createException<[number]>(\n 'E_OLLAMA_REQUEST_TIMEOUT',\n 'Ollama request timed out after %dms (before response headers)',\n 'E_OLLAMA_REQUEST_TIMEOUT',\n 504,\n false\n)\n\n/**\n * Raised when a tool-call's `arguments` value emitted by the model is present but is not a JSON\n * object (e.g. an array, `null`, or a primitive).\n *\n * @remarks\n * Non-fatal. Native `/api/chat` delivers `arguments` already parsed as an object, so — unlike the\n * OpenAI battery — there is no JSON-parse failure mode; this fires only on the not-an-object case.\n * The adapter does NOT throw it: it instantiates it inside `executeAndPersistToolCall`, pulls\n * `.message` into a {@link @nhtio/adk!Tokenizable}, and persists a `ToolCall` record with\n * `isError: true` so the model can self-correct on the next iteration.\n *\n * Printf args: `[reasonHeadline, rawArgs]`.\n * - `reasonHeadline` — short reason such as `'must be a JSON object; received array'`.\n * - `rawArgs` — `JSON.stringify(arguments)` of what the model sent, echoed back so it can see it.\n */\nexport const E_OLLAMA_INVALID_TOOL_CALL_ARGS = createException<[string, string]>(\n 'E_OLLAMA_INVALID_TOOL_CALL_ARGS',\n 'Tool arguments %s. Raw value: %s',\n 'E_OLLAMA_INVALID_TOOL_CALL_ARGS',\n 422,\n false\n)\n\n/**\n * Raised when a {@link @nhtio/adk!Media} instance whose modality cannot be natively represented in\n * the Ollama `/api/chat` wire format reaches the adapter under `unsupportedMediaPolicy: 'throw'`.\n *\n * @remarks\n * Native `/api/chat` supports only base64 `images[]` — it has no audio, document, or video\n * representation — so this triggers for every non-image modality (a wider set than the OpenAI\n * battery, which natively supports audio and document blocks). Consumers can opt out of the throw\n * by switching to `'fallback-stash'` or `'synthetic-description'`.\n *\n * Printf args: `[kind, mimeType, filename]`.\n */\nexport const E_OLLAMA_UNSUPPORTED_MEDIA_MODALITY = createException<[string, string, string]>(\n 'E_OLLAMA_UNSUPPORTED_MEDIA_MODALITY',\n 'Ollama /api/chat natively supports only images; media of kind %s (mime=%s, filename=%s) is unsupported. Configure adapter `unsupportedMediaPolicy` to `fallback-stash` or `synthetic-description` to handle this case.',\n 'E_OLLAMA_UNSUPPORTED_MEDIA_MODALITY',\n 422,\n true\n)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,IAAa,2BAA2B,gBACtC,4BACA,sCACA,4BACA,KACA,IACF;;;;;;;;;;AAWA,IAAa,4BAA4B,gBACvC,6BACA,4GACA,6BACA,KACA,IACF;;;;;AAMA,IAAa,sBAAsB,gBACjC,uBACA,4BACA,uBACA,KACA,KACF;;;;;;AAOA,IAAa,wBAAwB,gBACnC,yBACA,2BACA,yBACA,KACA,KACF;;;;;AAMA,IAAa,0BAA0B,gBACrC,2BACA,6CACA,2BACA,KACA,KACF;;;;;;AAOA,IAAa,2BAA2B,gBACtC,4BACA,iEACA,4BACA,KACA,KACF;;;;;;;;;;;;;;;;AAiBA,IAAa,kCAAkC,gBAC7C,mCACA,oCACA,mCACA,KACA,KACF;;;;;;;;;;;;;AAcA,IAAa,sCAAsC,gBACjD,uCACA,0NACA,uCACA,KACA,IACF"}