@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
@@ -1,4 +1,4 @@
1
- import { t as createException } from "./exceptions-BeWH2FwP.mjs";
1
+ import { t as createException } from "./exceptions-BDhN0Xzr.mjs";
2
2
  //#region src/lib/exceptions/runtime.ts
3
3
  /**
4
4
  * Thrown by {@link @nhtio/adk!TurnRunner} when the supplied config object fails schema validation at
@@ -347,4 +347,4 @@ var E_LLM_EXECUTION_EXECUTOR_ERROR = createException("E_LLM_EXECUTION_EXECUTOR_E
347
347
  //#endregion
348
348
  export { E_NOT_A_SPOOL_READER as C, E_TOOL_DOWNSTREAM_ERROR as D, E_TOOL_ALREADY_REGISTERED as E, E_TURN_GATE_ABORTED as O, E_NOT_A_MEDIA_READER as S, E_PIPELINE_SHORT_CIRCUITED as T, E_INVALID_TURN_GATE_RESOLUTION as _, E_INVALID_INITIAL_MEMORY_VALUE as a, E_LLM_EXECUTION_EXECUTOR_ERROR as b, E_INVALID_INITIAL_RETRIEVABLE_VALUE as c, E_INVALID_INITIAL_TOOL_VALUE as d, E_INVALID_INITIAL_TURN_GATE_VALUE as f, E_INVALID_TURN_CONTEXT as g, E_INVALID_TOOL_ARGS as h, E_INVALID_INITIAL_MEDIA_VALUE as i, E_TURN_GATE_TIMEOUT as k, E_INVALID_INITIAL_THOUGHT_VALUE as l, E_INVALID_LLM_EXECUTION_CONTEXT as m, E_INPUT_PIPELINE_ERROR as n, E_INVALID_INITIAL_MESSAGE_VALUE as o, E_INVALID_LLM_DISPATCH_INPUT as p, E_INVALID_INITIAL_IDENTITY_VALUE as r, E_INVALID_INITIAL_REGISTRY_VALUE as s, E_DISPATCH_PIPELINE_ERROR as t, E_INVALID_INITIAL_TOOL_CALL_VALUE as u, E_INVALID_TURN_RUNNER_CONFIG as v, E_OUTPUT_PIPELINE_ERROR as w, E_LLM_EXECUTION_GATE_NOT_SUPPORTED as x, E_LLM_EXECUTION_ALREADY_SIGNALLED as y };
349
349
 
350
- //# sourceMappingURL=runtime-j92CNi5z.mjs.map
350
+ //# sourceMappingURL=runtime-Bz5zA8wc.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-j92CNi5z.mjs","names":[],"sources":["../src/lib/exceptions/runtime.ts"],"sourcesContent":["import { createException } from '../utils/exceptions'\n\n/**\n * Thrown by {@link @nhtio/adk!TurnRunner} when the supplied config object fails schema validation at\n * construction time.\n *\n * @remarks\n * Marked fatal — a misconfigured runner must not be allowed to execute turns.\n *\n * The single printf argument carries the validator's field-level detail (e.g.\n * `\"storeMediaBytesCallback is required\"`) so a misconfiguration names the offending field\n * instead of failing opaquely. The underlying `ValidationError` is also attached on `cause`.\n *\n * @group Turn Runner Construction\n */\nexport const E_INVALID_TURN_RUNNER_CONFIG = createException<[string]>(\n 'E_INVALID_TURN_RUNNER_CONFIG',\n 'The turn runner cannot be instantiated with the provided configuration: %s',\n 'E_INVALID_TURN_RUNNER_CONFIG',\n 529,\n true\n)\n\n/**\n * Thrown by {@link @nhtio/adk!TurnRunner} when the {@link @nhtio/adk!TurnContext} supplied to `run` fails schema\n * validation.\n *\n * @remarks\n * Marked fatal — an invalid context indicates a programming error in the caller, not a\n * recoverable runtime condition. Thrown synchronously out of `run()` before `turnStart` is\n * emitted.\n *\n * @group Turn Input Validation\n */\nexport const E_INVALID_TURN_CONTEXT = createException(\n 'E_INVALID_TURN_CONTEXT',\n 'The turn runner received an invalid context object.',\n 'E_INVALID_TURN_CONTEXT',\n 529,\n true\n)\n\n/**\n * Emitted (via the `error` event) when a non-abort error propagates out of the input\n * middleware pipeline during {@link @nhtio/adk!TurnRunner.run}.\n *\n * @remarks\n * Not fatal — the turn runner emits this on the `error` event rather than throwing, so\n * registered listeners can handle or log the failure without crashing the pipeline. Dispatch\n * and output middleware are skipped; `turnEnd` still fires.\n *\n * @group Pipelines\n */\nexport const E_INPUT_PIPELINE_ERROR = createException(\n 'E_INPUT_PIPELINE_ERROR',\n 'An error occurred in the input pipeline.',\n 'E_INPUT_PIPELINE_ERROR',\n 500,\n false\n)\n\n/**\n * Emitted (via the `error` event) when a non-abort error propagates out of the output\n * middleware pipeline during {@link @nhtio/adk!TurnRunner.run}.\n *\n * @remarks\n * Not fatal — the turn runner emits this on the `error` event rather than throwing, so\n * registered listeners can handle or log the failure without crashing the pipeline. `turnEnd`\n * still fires.\n *\n * @group Pipelines\n */\nexport const E_OUTPUT_PIPELINE_ERROR = createException(\n 'E_OUTPUT_PIPELINE_ERROR',\n 'An error occurred in the output pipeline.',\n 'E_OUTPUT_PIPELINE_ERROR',\n 500,\n false\n)\n\n/**\n * Emitted (via the `error` event) when a middleware pipeline resolves without reaching its\n * terminal handler and without the turn being aborted. Indicates that some middleware\n * returned without calling `next` and without signalling a deliberate refusal via the turn's\n * abort controller.\n *\n * @remarks\n * Not fatal — the runner emits this on the `error` event so the failure is observable, then\n * proceeds to short-circuit the remainder of the turn the same way any other pipeline error\n * would. The constructor takes a single positional argument identifying the pipeline that\n * short-circuited: one of `'turn-input'`, `'turn-output'`, `'dispatch-input'`, or `'dispatch-output'`.\n *\n * Deliberate refusals should call `ctx.abort(reason)`, which sets the `'aborted'` outcome\n * instead of emitting this error.\n *\n * @warning\n * This is a **detection condition**, not a thrown exception. The runner constructs and emits\n * the code itself when it detects a missing `next()` on the unwind — nothing in user code\n * throws it. Upstream post-steps still run normally.\n *\n * @example\n * ```ts\n * throw new E_PIPELINE_SHORT_CIRCUITED(['turn-input'])\n * ```\n *\n * @group Pipelines\n */\nexport const E_PIPELINE_SHORT_CIRCUITED = createException<[string]>(\n 'E_PIPELINE_SHORT_CIRCUITED',\n \"The '%s' middleware pipeline short-circuited without calling next or aborting the turn.\",\n 'E_PIPELINE_SHORT_CIRCUITED',\n 500,\n false\n)\n\n/**\n * Thrown when a registry is initialised with a value that is defined but not a plain object.\n *\n * @remarks\n * Registries expect either `undefined` (empty start) or a plain object as their initial value.\n * Passing a primitive, array, class instance, or other non-object signals a programming error\n * in the caller.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_REGISTRY_VALUE = createException(\n 'E_INVALID_INITIAL_REGISTRY_VALUE',\n 'Attempted to initialize a registry with a defined non-object value.',\n 'E_INVALID_INITIAL_REGISTRY_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!Memory} is initialised with a value that fails schema validation.\n *\n * @remarks\n * `Memory` requires all fields — `id`, `content`, `confidence`, `importance`, `createdAt`,\n * `updatedAt` — to be present and of the correct type. Passing an incomplete or incorrectly\n * typed object signals a programming error in the caller, not a recoverable runtime condition.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_MEMORY_VALUE = createException(\n 'E_INVALID_INITIAL_MEMORY_VALUE',\n 'Attempted to initialize a memory with an invalid value.',\n 'E_INVALID_INITIAL_MEMORY_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!Retrievable} is initialised with a value that fails schema validation.\n *\n * @remarks\n * `Retrievable` requires `id`, `content`, `trustTier`, `createdAt`, and `updatedAt` to be present\n * and of the correct type, and `trustTier` must be one of `'first-party'`, `'third-party-public'`,\n * or `'third-party-private'`. The `trustTier` decision must be made consciously by the retrieval\n * middleware at construction time — there is no default. Passing an incomplete or incorrectly\n * typed object signals a programming error in the caller, not a recoverable runtime condition.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_RETRIEVABLE_VALUE = createException(\n 'E_INVALID_INITIAL_RETRIEVABLE_VALUE',\n 'Invalid initial value supplied to Retrievable constructor.',\n 'E_INVALID_INITIAL_RETRIEVABLE_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!Message} is initialised with a value that fails schema validation.\n *\n * @remarks\n * `Message` requires `id`, `role` (`user` or `assistant`), `content`, `createdAt`, and\n * `updatedAt` to be present and of the correct type. Passing an incomplete or incorrectly\n * typed object signals a programming error in the caller, not a recoverable runtime condition.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_MESSAGE_VALUE = createException(\n 'E_INVALID_INITIAL_MESSAGE_VALUE',\n 'Attempted to initialize a message with an invalid value.',\n 'E_INVALID_INITIAL_MESSAGE_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when an {@link @nhtio/adk!Identity} is initialised with a value that fails schema validation.\n *\n * @remarks\n * `Identity` requires both `identifier` (string or number) and `representation` (string or\n * {@link @nhtio/adk!Tokenizable}) to be present and of the correct type. Passing an incomplete or\n * incorrectly typed object signals a programming error in the caller.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_IDENTITY_VALUE = createException(\n 'E_INVALID_INITIAL_IDENTITY_VALUE',\n 'Attempted to initialize an identity with an invalid value.',\n 'E_INVALID_INITIAL_IDENTITY_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!Thought} is initialised with a value that fails schema validation.\n *\n * @remarks\n * `Thought` requires `id`, `content`, `createdAt`, and `updatedAt` to be present and of the\n * correct type. Passing an incomplete or incorrectly typed object signals a programming error\n * in the caller, not a recoverable runtime condition.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_THOUGHT_VALUE = createException(\n 'E_INVALID_INITIAL_THOUGHT_VALUE',\n 'Attempted to initialize a thought with an invalid value.',\n 'E_INVALID_INITIAL_THOUGHT_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!TurnGate} is constructed with a value that fails schema validation.\n *\n * @remarks\n * Fatal — bad construction arguments indicate a programming error in the caller.\n *\n * @group Gates\n */\nexport const E_INVALID_INITIAL_TURN_GATE_VALUE = createException(\n 'E_INVALID_INITIAL_TURN_GATE_VALUE',\n 'Attempted to initialize a turn gate with an invalid value.',\n 'E_INVALID_INITIAL_TURN_GATE_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown synchronously in the caller's context when {@link @nhtio/adk!TurnGate.resolve} is called with a\n * value that fails the gate's schema.\n *\n * @remarks\n * Fatal — passing the wrong type to `resolve()` is a programming error. The internal promise is\n * NOT settled when this is thrown; the gate remains open.\n *\n * @group Gates\n */\nexport const E_INVALID_TURN_GATE_RESOLUTION = createException(\n 'E_INVALID_TURN_GATE_RESOLUTION',\n 'The value supplied to TurnGate.resolve() failed schema validation.',\n 'E_INVALID_TURN_GATE_RESOLUTION',\n 500,\n true\n)\n\n/**\n * Thrown (as a rejection reason) when a {@link @nhtio/adk!TurnGate} times out before being resolved.\n *\n * @remarks\n * Not fatal — a timeout is a recoverable runtime condition; the caller may retry or surface it\n * to the user.\n *\n * @warning\n * A timeout does **not** cancel the external event or clear any remote queue. The gate closes\n * locally, but whatever external system was expected to call `gate.resolve()` may still fire\n * later. Orphaned external state must be handled by the caller.\n *\n * @group Gates\n */\nexport const E_TURN_GATE_TIMEOUT = createException(\n 'E_TURN_GATE_TIMEOUT',\n 'The turn gate timed out before being resolved.',\n 'E_TURN_GATE_TIMEOUT',\n 408,\n false\n)\n\n/**\n * Thrown (as a rejection reason) when a {@link @nhtio/adk!TurnGate} is aborted — either because the turn's\n * `AbortSignal` fired or because {@link @nhtio/adk!TurnGate.abort} was called directly.\n *\n * @remarks\n * Not fatal — abort is an intentional cancellation, not an error in the caller.\n *\n * @group Gates\n */\nexport const E_TURN_GATE_ABORTED = createException(\n 'E_TURN_GATE_ABORTED',\n 'The turn gate was aborted before being resolved.',\n 'E_TURN_GATE_ABORTED',\n 499,\n false\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!SpooledArtifact} is constructed with a value that does not implement the\n * {@link @nhtio/adk!SpoolReader} interface.\n *\n * @remarks\n * Validated at construction time via {@link @nhtio/adk!implementsSpoolReader}. Passing anything that lacks\n * `line`, `byteLength`, or `lineCount` as callable functions signals a programming error in the\n * caller.\n *\n * @group Artifacts\n */\nexport const E_NOT_A_SPOOL_READER = createException(\n 'E_NOT_A_SPOOL_READER',\n 'The provided value does not implement the SpoolReader interface.',\n 'E_NOT_A_SPOOL_READER',\n 500,\n true\n)\n\n/**\n * Thrown when a Media is constructed with a value that does not implement the MediaReader\n * interface.\n *\n * @remarks\n * Validated at construction time. Passing anything that lacks `stream` or `byteLength` as\n * callable functions signals a programming error in the caller.\n *\n * @group Artifacts\n */\nexport const E_NOT_A_MEDIA_READER = createException(\n 'E_NOT_A_MEDIA_READER',\n 'The provided value does not implement the MediaReader interface.',\n 'E_NOT_A_MEDIA_READER',\n 500,\n true\n)\n\n/**\n * Thrown when a Media is initialised with a value that fails schema validation.\n *\n * @remarks\n * Fatal — bad construction arguments indicate a programming error in the caller.\n *\n * @group Artifacts\n */\nexport const E_INVALID_INITIAL_MEDIA_VALUE = createException(\n 'E_INVALID_INITIAL_MEDIA_VALUE',\n 'Attempted to initialize a media with an invalid value.',\n 'E_INVALID_INITIAL_MEDIA_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!ToolCall} is initialised with a value that fails schema validation.\n *\n * @remarks\n * `ToolCall` requires `id`, `tool`, `args`, `checksum`, `isComplete`, `isError`, `createdAt`,\n * and `updatedAt` to be present and of the correct type. Passing an incomplete or incorrectly\n * typed object signals a programming error in the caller, not a recoverable runtime condition.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_TOOL_CALL_VALUE = createException(\n 'E_INVALID_INITIAL_TOOL_CALL_VALUE',\n 'Attempted to initialize a tool call with an invalid value.',\n 'E_INVALID_INITIAL_TOOL_CALL_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!Tool} is constructed with a value that fails schema validation.\n *\n * @remarks\n * Fatal — bad construction arguments indicate a programming error in the caller.\n *\n * @group Tools\n */\nexport const E_INVALID_INITIAL_TOOL_VALUE = createException(\n 'E_INVALID_INITIAL_TOOL_VALUE',\n 'Attempted to initialize a tool with an invalid value.',\n 'E_INVALID_INITIAL_TOOL_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown synchronously when {@link @nhtio/adk!Tool.validate} is called with arguments that fail the tool's\n * input schema.\n *\n * @remarks\n * Not fatal — an arg validation failure in the tool call loop is a caller mistake that can be\n * surfaced as an error response. The tool handler is NOT called when this is thrown.\n *\n * @group Tools\n */\nexport const E_INVALID_TOOL_ARGS = createException(\n 'E_INVALID_TOOL_ARGS',\n 'The arguments supplied to the tool failed input schema validation.',\n 'E_INVALID_TOOL_ARGS',\n 422,\n false\n)\n\n/**\n * Thrown (as a rejection reason) when a {@link @nhtio/adk!Tool}'s handler throws during execution.\n *\n * @remarks\n * Not fatal — a downstream tool failure is a recoverable runtime condition. The tool call loop\n * catches this error specifically to report the failure back to the model rather than crashing\n * the pipeline.\n *\n * @group Tools\n */\nexport const E_TOOL_DOWNSTREAM_ERROR = createException(\n 'E_TOOL_DOWNSTREAM_ERROR',\n 'The tool handler threw an error during execution.',\n 'E_TOOL_DOWNSTREAM_ERROR',\n 500,\n false\n)\n\n/**\n * Thrown when {@link @nhtio/adk!ToolRegistry.register} is called for a tool name that is already registered\n * and `overwrite` is not `true`.\n *\n * @remarks\n * Fatal — accidentally overwriting a registered tool indicates a programming error. Pass\n * `overwrite: true` to replace an existing tool intentionally.\n *\n * @group Tools\n */\nexport const E_TOOL_ALREADY_REGISTERED = createException(\n 'E_TOOL_ALREADY_REGISTERED',\n 'A tool with this name is already registered. Pass overwrite: true to replace it.',\n 'E_TOOL_ALREADY_REGISTERED',\n 409,\n true\n)\n\n/**\n * Thrown when {@link @nhtio/adk!DispatchContext} is constructed with a value that fails schema validation.\n *\n * @remarks\n * Fatal — bad construction arguments indicate a programming error in the caller.\n *\n * @group Dispatch\n */\nexport const E_INVALID_LLM_EXECUTION_CONTEXT = createException(\n 'E_INVALID_LLM_EXECUTION_CONTEXT',\n 'The LLM execution context cannot be instantiated with the provided value.',\n 'E_INVALID_LLM_EXECUTION_CONTEXT',\n 529,\n true\n)\n\n/**\n * Thrown (as a rejection reason) when {@link @nhtio/adk!DispatchContext.waitFor} is called on a\n * standalone context that was constructed without a `waitFor` function.\n *\n * @remarks\n * Not fatal — the caller can catch this and handle the case where gate suspension is not\n * supported for this execution context.\n *\n * @group Dispatch\n */\nexport const E_LLM_EXECUTION_GATE_NOT_SUPPORTED = createException(\n 'E_LLM_EXECUTION_GATE_NOT_SUPPORTED',\n 'waitFor was called on a standalone DispatchContext with no gate function provided.',\n 'E_LLM_EXECUTION_GATE_NOT_SUPPORTED',\n 501,\n false\n)\n\n/**\n * Thrown when {@link @nhtio/adk!DispatchContext.ack} or {@link @nhtio/adk!DispatchContext.nack} is called on a\n * context that has already been signalled.\n *\n * @remarks\n * Fatal — signalling twice is a programming error in the caller. The first signal wins; the\n * second call is rejected loudly so callers cannot accidentally race between ack and nack.\n *\n * @danger\n * Signalling is **not** silently idempotent. The first `ack()` or `nack()` wins; the second\n * throws immediately. Guard with `if (!ctx.isSignalled)` when more than one seam may signal.\n *\n * @group Dispatch\n */\nexport const E_LLM_EXECUTION_ALREADY_SIGNALLED = createException(\n 'E_LLM_EXECUTION_ALREADY_SIGNALLED',\n 'ack() or nack() was called on an DispatchContext that has already been signalled.',\n 'E_LLM_EXECUTION_ALREADY_SIGNALLED',\n 500,\n true\n)\n\n/**\n * Thrown when {@link @nhtio/adk!DispatchRunner.dispatch} receives an input that fails schema validation.\n *\n * @remarks\n * Fatal — invalid dispatch input indicates a programming error in the caller.\n *\n * @group Dispatch\n */\nexport const E_INVALID_LLM_DISPATCH_INPUT = createException(\n 'E_INVALID_LLM_DISPATCH_INPUT',\n 'The LLM execution runner received an invalid dispatch input.',\n 'E_INVALID_LLM_DISPATCH_INPUT',\n 529,\n true\n)\n\n/**\n * Emitted (via the observability `error` hook) and re-thrown when a non-abort error propagates\n * out of the input or output middleware pipeline during {@link @nhtio/adk!DispatchRunner.dispatch}.\n *\n * @remarks\n * Not fatal — pipeline errors are recoverable runtime conditions. `dispatch()` rejects with this\n * exception so callers can handle the failure via try/catch. Both `dispatchInputPipeline` and\n * `dispatchOutputPipeline` share this one code — the runner does not split input vs. output at\n * this layer.\n *\n * @group Pipelines\n */\nexport const E_DISPATCH_PIPELINE_ERROR = createException(\n 'E_DISPATCH_PIPELINE_ERROR',\n 'An error occurred in an LLM execution pipeline.',\n 'E_DISPATCH_PIPELINE_ERROR',\n 500,\n false\n)\n\n/**\n * Emitted (via the observability `error` hook) and re-thrown when the user-supplied executor\n * callback throws during {@link @nhtio/adk!DispatchRunner.dispatch}.\n *\n * @remarks\n * Not fatal — executor errors are recoverable runtime conditions. `dispatch()` rejects with this\n * exception so callers can handle the failure via try/catch.\n *\n * @group Dispatch\n */\nexport const E_LLM_EXECUTION_EXECUTOR_ERROR = createException(\n 'E_LLM_EXECUTION_EXECUTOR_ERROR',\n 'The LLM execution executor callback threw an error.',\n 'E_LLM_EXECUTION_EXECUTOR_ERROR',\n 500,\n false\n)\n"],"mappings":";;;;;;;;;;;;;;;AAeA,IAAa,+BAA+B,gBAC1C,gCACA,8EACA,gCACA,KACA,IACF;;;;;;;;;;;;AAaA,IAAa,yBAAyB,gBACpC,0BACA,uDACA,0BACA,KACA,IACF;;;;;;;;;;;;AAaA,IAAa,yBAAyB,gBACpC,0BACA,4CACA,0BACA,KACA,KACF;;;;;;;;;;;;AAaA,IAAa,0BAA0B,gBACrC,2BACA,6CACA,2BACA,KACA,KACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,IAAa,6BAA6B,gBACxC,8BACA,2FACA,8BACA,KACA,KACF;;;;;;;;;;;AAYA,IAAa,mCAAmC,gBAC9C,oCACA,uEACA,oCACA,KACA,IACF;;;;;;;;;;;AAYA,IAAa,iCAAiC,gBAC5C,kCACA,2DACA,kCACA,KACA,IACF;;;;;;;;;;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BA,IAAa,oCAAoC,gBAC/C,qCACA,qFACA,qCACA,KACA,IACF;;;;;;;;;AAUA,IAAa,+BAA+B,gBAC1C,gCACA,gEACA,gCACA,KACA,IACF;;;;;;;;;;;;;AAcA,IAAa,4BAA4B,gBACvC,6BACA,mDACA,6BACA,KACA,KACF;;;;;;;;;;;AAYA,IAAa,iCAAiC,gBAC5C,kCACA,uDACA,kCACA,KACA,KACF"}
1
+ {"version":3,"file":"runtime-Bz5zA8wc.mjs","names":[],"sources":["../src/lib/exceptions/runtime.ts"],"sourcesContent":["import { createException } from '../utils/exceptions'\n\n/**\n * Thrown by {@link @nhtio/adk!TurnRunner} when the supplied config object fails schema validation at\n * construction time.\n *\n * @remarks\n * Marked fatal — a misconfigured runner must not be allowed to execute turns.\n *\n * The single printf argument carries the validator's field-level detail (e.g.\n * `\"storeMediaBytesCallback is required\"`) so a misconfiguration names the offending field\n * instead of failing opaquely. The underlying `ValidationError` is also attached on `cause`.\n *\n * @group Turn Runner Construction\n */\nexport const E_INVALID_TURN_RUNNER_CONFIG = createException<[string]>(\n 'E_INVALID_TURN_RUNNER_CONFIG',\n 'The turn runner cannot be instantiated with the provided configuration: %s',\n 'E_INVALID_TURN_RUNNER_CONFIG',\n 529,\n true\n)\n\n/**\n * Thrown by {@link @nhtio/adk!TurnRunner} when the {@link @nhtio/adk!TurnContext} supplied to `run` fails schema\n * validation.\n *\n * @remarks\n * Marked fatal — an invalid context indicates a programming error in the caller, not a\n * recoverable runtime condition. Thrown synchronously out of `run()` before `turnStart` is\n * emitted.\n *\n * @group Turn Input Validation\n */\nexport const E_INVALID_TURN_CONTEXT = createException(\n 'E_INVALID_TURN_CONTEXT',\n 'The turn runner received an invalid context object.',\n 'E_INVALID_TURN_CONTEXT',\n 529,\n true\n)\n\n/**\n * Emitted (via the `error` event) when a non-abort error propagates out of the input\n * middleware pipeline during {@link @nhtio/adk!TurnRunner.run}.\n *\n * @remarks\n * Not fatal — the turn runner emits this on the `error` event rather than throwing, so\n * registered listeners can handle or log the failure without crashing the pipeline. Dispatch\n * and output middleware are skipped; `turnEnd` still fires.\n *\n * @group Pipelines\n */\nexport const E_INPUT_PIPELINE_ERROR = createException(\n 'E_INPUT_PIPELINE_ERROR',\n 'An error occurred in the input pipeline.',\n 'E_INPUT_PIPELINE_ERROR',\n 500,\n false\n)\n\n/**\n * Emitted (via the `error` event) when a non-abort error propagates out of the output\n * middleware pipeline during {@link @nhtio/adk!TurnRunner.run}.\n *\n * @remarks\n * Not fatal — the turn runner emits this on the `error` event rather than throwing, so\n * registered listeners can handle or log the failure without crashing the pipeline. `turnEnd`\n * still fires.\n *\n * @group Pipelines\n */\nexport const E_OUTPUT_PIPELINE_ERROR = createException(\n 'E_OUTPUT_PIPELINE_ERROR',\n 'An error occurred in the output pipeline.',\n 'E_OUTPUT_PIPELINE_ERROR',\n 500,\n false\n)\n\n/**\n * Emitted (via the `error` event) when a middleware pipeline resolves without reaching its\n * terminal handler and without the turn being aborted. Indicates that some middleware\n * returned without calling `next` and without signalling a deliberate refusal via the turn's\n * abort controller.\n *\n * @remarks\n * Not fatal — the runner emits this on the `error` event so the failure is observable, then\n * proceeds to short-circuit the remainder of the turn the same way any other pipeline error\n * would. The constructor takes a single positional argument identifying the pipeline that\n * short-circuited: one of `'turn-input'`, `'turn-output'`, `'dispatch-input'`, or `'dispatch-output'`.\n *\n * Deliberate refusals should call `ctx.abort(reason)`, which sets the `'aborted'` outcome\n * instead of emitting this error.\n *\n * @warning\n * This is a **detection condition**, not a thrown exception. The runner constructs and emits\n * the code itself when it detects a missing `next()` on the unwind — nothing in user code\n * throws it. Upstream post-steps still run normally.\n *\n * @example\n * ```ts\n * throw new E_PIPELINE_SHORT_CIRCUITED(['turn-input'])\n * ```\n *\n * @group Pipelines\n */\nexport const E_PIPELINE_SHORT_CIRCUITED = createException<[string]>(\n 'E_PIPELINE_SHORT_CIRCUITED',\n \"The '%s' middleware pipeline short-circuited without calling next or aborting the turn.\",\n 'E_PIPELINE_SHORT_CIRCUITED',\n 500,\n false\n)\n\n/**\n * Thrown when a registry is initialised with a value that is defined but not a plain object.\n *\n * @remarks\n * Registries expect either `undefined` (empty start) or a plain object as their initial value.\n * Passing a primitive, array, class instance, or other non-object signals a programming error\n * in the caller.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_REGISTRY_VALUE = createException(\n 'E_INVALID_INITIAL_REGISTRY_VALUE',\n 'Attempted to initialize a registry with a defined non-object value.',\n 'E_INVALID_INITIAL_REGISTRY_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!Memory} is initialised with a value that fails schema validation.\n *\n * @remarks\n * `Memory` requires all fields — `id`, `content`, `confidence`, `importance`, `createdAt`,\n * `updatedAt` — to be present and of the correct type. Passing an incomplete or incorrectly\n * typed object signals a programming error in the caller, not a recoverable runtime condition.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_MEMORY_VALUE = createException(\n 'E_INVALID_INITIAL_MEMORY_VALUE',\n 'Attempted to initialize a memory with an invalid value.',\n 'E_INVALID_INITIAL_MEMORY_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!Retrievable} is initialised with a value that fails schema validation.\n *\n * @remarks\n * `Retrievable` requires `id`, `content`, `trustTier`, `createdAt`, and `updatedAt` to be present\n * and of the correct type, and `trustTier` must be one of `'first-party'`, `'third-party-public'`,\n * or `'third-party-private'`. The `trustTier` decision must be made consciously by the retrieval\n * middleware at construction time — there is no default. Passing an incomplete or incorrectly\n * typed object signals a programming error in the caller, not a recoverable runtime condition.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_RETRIEVABLE_VALUE = createException(\n 'E_INVALID_INITIAL_RETRIEVABLE_VALUE',\n 'Invalid initial value supplied to Retrievable constructor.',\n 'E_INVALID_INITIAL_RETRIEVABLE_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!Message} is initialised with a value that fails schema validation.\n *\n * @remarks\n * `Message` requires `id`, `role` (`user` or `assistant`), `content`, `createdAt`, and\n * `updatedAt` to be present and of the correct type. Passing an incomplete or incorrectly\n * typed object signals a programming error in the caller, not a recoverable runtime condition.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_MESSAGE_VALUE = createException(\n 'E_INVALID_INITIAL_MESSAGE_VALUE',\n 'Attempted to initialize a message with an invalid value.',\n 'E_INVALID_INITIAL_MESSAGE_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when an {@link @nhtio/adk!Identity} is initialised with a value that fails schema validation.\n *\n * @remarks\n * `Identity` requires both `identifier` (string or number) and `representation` (string or\n * {@link @nhtio/adk!Tokenizable}) to be present and of the correct type. Passing an incomplete or\n * incorrectly typed object signals a programming error in the caller.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_IDENTITY_VALUE = createException(\n 'E_INVALID_INITIAL_IDENTITY_VALUE',\n 'Attempted to initialize an identity with an invalid value.',\n 'E_INVALID_INITIAL_IDENTITY_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!Thought} is initialised with a value that fails schema validation.\n *\n * @remarks\n * `Thought` requires `id`, `content`, `createdAt`, and `updatedAt` to be present and of the\n * correct type. Passing an incomplete or incorrectly typed object signals a programming error\n * in the caller, not a recoverable runtime condition.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_THOUGHT_VALUE = createException(\n 'E_INVALID_INITIAL_THOUGHT_VALUE',\n 'Attempted to initialize a thought with an invalid value.',\n 'E_INVALID_INITIAL_THOUGHT_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!TurnGate} is constructed with a value that fails schema validation.\n *\n * @remarks\n * Fatal — bad construction arguments indicate a programming error in the caller.\n *\n * @group Gates\n */\nexport const E_INVALID_INITIAL_TURN_GATE_VALUE = createException(\n 'E_INVALID_INITIAL_TURN_GATE_VALUE',\n 'Attempted to initialize a turn gate with an invalid value.',\n 'E_INVALID_INITIAL_TURN_GATE_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown synchronously in the caller's context when {@link @nhtio/adk!TurnGate.resolve} is called with a\n * value that fails the gate's schema.\n *\n * @remarks\n * Fatal — passing the wrong type to `resolve()` is a programming error. The internal promise is\n * NOT settled when this is thrown; the gate remains open.\n *\n * @group Gates\n */\nexport const E_INVALID_TURN_GATE_RESOLUTION = createException(\n 'E_INVALID_TURN_GATE_RESOLUTION',\n 'The value supplied to TurnGate.resolve() failed schema validation.',\n 'E_INVALID_TURN_GATE_RESOLUTION',\n 500,\n true\n)\n\n/**\n * Thrown (as a rejection reason) when a {@link @nhtio/adk!TurnGate} times out before being resolved.\n *\n * @remarks\n * Not fatal — a timeout is a recoverable runtime condition; the caller may retry or surface it\n * to the user.\n *\n * @warning\n * A timeout does **not** cancel the external event or clear any remote queue. The gate closes\n * locally, but whatever external system was expected to call `gate.resolve()` may still fire\n * later. Orphaned external state must be handled by the caller.\n *\n * @group Gates\n */\nexport const E_TURN_GATE_TIMEOUT = createException(\n 'E_TURN_GATE_TIMEOUT',\n 'The turn gate timed out before being resolved.',\n 'E_TURN_GATE_TIMEOUT',\n 408,\n false\n)\n\n/**\n * Thrown (as a rejection reason) when a {@link @nhtio/adk!TurnGate} is aborted — either because the turn's\n * `AbortSignal` fired or because {@link @nhtio/adk!TurnGate.abort} was called directly.\n *\n * @remarks\n * Not fatal — abort is an intentional cancellation, not an error in the caller.\n *\n * @group Gates\n */\nexport const E_TURN_GATE_ABORTED = createException(\n 'E_TURN_GATE_ABORTED',\n 'The turn gate was aborted before being resolved.',\n 'E_TURN_GATE_ABORTED',\n 499,\n false\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!SpooledArtifact} is constructed with a value that does not implement the\n * {@link @nhtio/adk!SpoolReader} interface.\n *\n * @remarks\n * Validated at construction time via {@link @nhtio/adk!implementsSpoolReader}. Passing anything that lacks\n * `line`, `byteLength`, or `lineCount` as callable functions signals a programming error in the\n * caller.\n *\n * @group Artifacts\n */\nexport const E_NOT_A_SPOOL_READER = createException(\n 'E_NOT_A_SPOOL_READER',\n 'The provided value does not implement the SpoolReader interface.',\n 'E_NOT_A_SPOOL_READER',\n 500,\n true\n)\n\n/**\n * Thrown when a Media is constructed with a value that does not implement the MediaReader\n * interface.\n *\n * @remarks\n * Validated at construction time. Passing anything that lacks `stream` or `byteLength` as\n * callable functions signals a programming error in the caller.\n *\n * @group Artifacts\n */\nexport const E_NOT_A_MEDIA_READER = createException(\n 'E_NOT_A_MEDIA_READER',\n 'The provided value does not implement the MediaReader interface.',\n 'E_NOT_A_MEDIA_READER',\n 500,\n true\n)\n\n/**\n * Thrown when a Media is initialised with a value that fails schema validation.\n *\n * @remarks\n * Fatal — bad construction arguments indicate a programming error in the caller.\n *\n * @group Artifacts\n */\nexport const E_INVALID_INITIAL_MEDIA_VALUE = createException(\n 'E_INVALID_INITIAL_MEDIA_VALUE',\n 'Attempted to initialize a media with an invalid value.',\n 'E_INVALID_INITIAL_MEDIA_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!ToolCall} is initialised with a value that fails schema validation.\n *\n * @remarks\n * `ToolCall` requires `id`, `tool`, `args`, `checksum`, `isComplete`, `isError`, `createdAt`,\n * and `updatedAt` to be present and of the correct type. Passing an incomplete or incorrectly\n * typed object signals a programming error in the caller, not a recoverable runtime condition.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_TOOL_CALL_VALUE = createException(\n 'E_INVALID_INITIAL_TOOL_CALL_VALUE',\n 'Attempted to initialize a tool call with an invalid value.',\n 'E_INVALID_INITIAL_TOOL_CALL_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!Tool} is constructed with a value that fails schema validation.\n *\n * @remarks\n * Fatal — bad construction arguments indicate a programming error in the caller.\n *\n * @group Tools\n */\nexport const E_INVALID_INITIAL_TOOL_VALUE = createException(\n 'E_INVALID_INITIAL_TOOL_VALUE',\n 'Attempted to initialize a tool with an invalid value.',\n 'E_INVALID_INITIAL_TOOL_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown synchronously when {@link @nhtio/adk!Tool.validate} is called with arguments that fail the tool's\n * input schema.\n *\n * @remarks\n * Not fatal — an arg validation failure in the tool call loop is a caller mistake that can be\n * surfaced as an error response. The tool handler is NOT called when this is thrown.\n *\n * @group Tools\n */\nexport const E_INVALID_TOOL_ARGS = createException(\n 'E_INVALID_TOOL_ARGS',\n 'The arguments supplied to the tool failed input schema validation.',\n 'E_INVALID_TOOL_ARGS',\n 422,\n false\n)\n\n/**\n * Thrown (as a rejection reason) when a {@link @nhtio/adk!Tool}'s handler throws during execution.\n *\n * @remarks\n * Not fatal — a downstream tool failure is a recoverable runtime condition. The tool call loop\n * catches this error specifically to report the failure back to the model rather than crashing\n * the pipeline.\n *\n * @group Tools\n */\nexport const E_TOOL_DOWNSTREAM_ERROR = createException(\n 'E_TOOL_DOWNSTREAM_ERROR',\n 'The tool handler threw an error during execution.',\n 'E_TOOL_DOWNSTREAM_ERROR',\n 500,\n false\n)\n\n/**\n * Thrown when {@link @nhtio/adk!ToolRegistry.register} is called for a tool name that is already registered\n * and `overwrite` is not `true`.\n *\n * @remarks\n * Fatal — accidentally overwriting a registered tool indicates a programming error. Pass\n * `overwrite: true` to replace an existing tool intentionally.\n *\n * @group Tools\n */\nexport const E_TOOL_ALREADY_REGISTERED = createException(\n 'E_TOOL_ALREADY_REGISTERED',\n 'A tool with this name is already registered. Pass overwrite: true to replace it.',\n 'E_TOOL_ALREADY_REGISTERED',\n 409,\n true\n)\n\n/**\n * Thrown when {@link @nhtio/adk!DispatchContext} is constructed with a value that fails schema validation.\n *\n * @remarks\n * Fatal — bad construction arguments indicate a programming error in the caller.\n *\n * @group Dispatch\n */\nexport const E_INVALID_LLM_EXECUTION_CONTEXT = createException(\n 'E_INVALID_LLM_EXECUTION_CONTEXT',\n 'The LLM execution context cannot be instantiated with the provided value.',\n 'E_INVALID_LLM_EXECUTION_CONTEXT',\n 529,\n true\n)\n\n/**\n * Thrown (as a rejection reason) when {@link @nhtio/adk!DispatchContext.waitFor} is called on a\n * standalone context that was constructed without a `waitFor` function.\n *\n * @remarks\n * Not fatal — the caller can catch this and handle the case where gate suspension is not\n * supported for this execution context.\n *\n * @group Dispatch\n */\nexport const E_LLM_EXECUTION_GATE_NOT_SUPPORTED = createException(\n 'E_LLM_EXECUTION_GATE_NOT_SUPPORTED',\n 'waitFor was called on a standalone DispatchContext with no gate function provided.',\n 'E_LLM_EXECUTION_GATE_NOT_SUPPORTED',\n 501,\n false\n)\n\n/**\n * Thrown when {@link @nhtio/adk!DispatchContext.ack} or {@link @nhtio/adk!DispatchContext.nack} is called on a\n * context that has already been signalled.\n *\n * @remarks\n * Fatal — signalling twice is a programming error in the caller. The first signal wins; the\n * second call is rejected loudly so callers cannot accidentally race between ack and nack.\n *\n * @danger\n * Signalling is **not** silently idempotent. The first `ack()` or `nack()` wins; the second\n * throws immediately. Guard with `if (!ctx.isSignalled)` when more than one seam may signal.\n *\n * @group Dispatch\n */\nexport const E_LLM_EXECUTION_ALREADY_SIGNALLED = createException(\n 'E_LLM_EXECUTION_ALREADY_SIGNALLED',\n 'ack() or nack() was called on an DispatchContext that has already been signalled.',\n 'E_LLM_EXECUTION_ALREADY_SIGNALLED',\n 500,\n true\n)\n\n/**\n * Thrown when {@link @nhtio/adk!DispatchRunner.dispatch} receives an input that fails schema validation.\n *\n * @remarks\n * Fatal — invalid dispatch input indicates a programming error in the caller.\n *\n * @group Dispatch\n */\nexport const E_INVALID_LLM_DISPATCH_INPUT = createException(\n 'E_INVALID_LLM_DISPATCH_INPUT',\n 'The LLM execution runner received an invalid dispatch input.',\n 'E_INVALID_LLM_DISPATCH_INPUT',\n 529,\n true\n)\n\n/**\n * Emitted (via the observability `error` hook) and re-thrown when a non-abort error propagates\n * out of the input or output middleware pipeline during {@link @nhtio/adk!DispatchRunner.dispatch}.\n *\n * @remarks\n * Not fatal — pipeline errors are recoverable runtime conditions. `dispatch()` rejects with this\n * exception so callers can handle the failure via try/catch. Both `dispatchInputPipeline` and\n * `dispatchOutputPipeline` share this one code — the runner does not split input vs. output at\n * this layer.\n *\n * @group Pipelines\n */\nexport const E_DISPATCH_PIPELINE_ERROR = createException(\n 'E_DISPATCH_PIPELINE_ERROR',\n 'An error occurred in an LLM execution pipeline.',\n 'E_DISPATCH_PIPELINE_ERROR',\n 500,\n false\n)\n\n/**\n * Emitted (via the observability `error` hook) and re-thrown when the user-supplied executor\n * callback throws during {@link @nhtio/adk!DispatchRunner.dispatch}.\n *\n * @remarks\n * Not fatal — executor errors are recoverable runtime conditions. `dispatch()` rejects with this\n * exception so callers can handle the failure via try/catch.\n *\n * @group Dispatch\n */\nexport const E_LLM_EXECUTION_EXECUTOR_ERROR = createException(\n 'E_LLM_EXECUTION_EXECUTOR_ERROR',\n 'The LLM execution executor callback threw an error.',\n 'E_LLM_EXECUTION_EXECUTOR_ERROR',\n 500,\n false\n)\n"],"mappings":";;;;;;;;;;;;;;;AAeA,IAAa,+BAA+B,gBAC1C,gCACA,8EACA,gCACA,KACA,IACF;;;;;;;;;;;;AAaA,IAAa,yBAAyB,gBACpC,0BACA,uDACA,0BACA,KACA,IACF;;;;;;;;;;;;AAaA,IAAa,yBAAyB,gBACpC,0BACA,4CACA,0BACA,KACA,KACF;;;;;;;;;;;;AAaA,IAAa,0BAA0B,gBACrC,2BACA,6CACA,2BACA,KACA,KACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,IAAa,6BAA6B,gBACxC,8BACA,2FACA,8BACA,KACA,KACF;;;;;;;;;;;AAYA,IAAa,mCAAmC,gBAC9C,oCACA,uEACA,oCACA,KACA,IACF;;;;;;;;;;;AAYA,IAAa,iCAAiC,gBAC5C,kCACA,2DACA,kCACA,KACA,IACF;;;;;;;;;;;;;AAcA,IAAa,sCAAsC,gBACjD,uCACA,8DACA,uCACA,KACA,IACF;;;;;;;;;;;AAYA,IAAa,kCAAkC,gBAC7C,mCACA,4DACA,mCACA,K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;;;;;;;;;;;;;AAcA,IAAa,4BAA4B,gBACvC,6BACA,mDACA,6BACA,KACA,KACF;;;;;;;;;;;AAYA,IAAa,iCAAiC,gBAC5C,kCACA,uDACA,kCACA,KACA,KACF"}
@@ -1,4 +1,4 @@
1
- const require_exceptions = require("./exceptions-CitH5wZI.js");
1
+ const require_exceptions = require("./exceptions-BRXrUKiW.js");
2
2
  //#region src/lib/exceptions/runtime.ts
3
3
  /**
4
4
  * Thrown by {@link @nhtio/adk!TurnRunner} when the supplied config object fails schema validation at
@@ -520,4 +520,4 @@ Object.defineProperty(exports, "E_TURN_GATE_TIMEOUT", {
520
520
  }
521
521
  });
522
522
 
523
- //# sourceMappingURL=runtime-MFFcJrRv.js.map
523
+ //# sourceMappingURL=runtime-DslE1aBw.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-MFFcJrRv.js","names":[],"sources":["../src/lib/exceptions/runtime.ts"],"sourcesContent":["import { createException } from '../utils/exceptions'\n\n/**\n * Thrown by {@link @nhtio/adk!TurnRunner} when the supplied config object fails schema validation at\n * construction time.\n *\n * @remarks\n * Marked fatal — a misconfigured runner must not be allowed to execute turns.\n *\n * The single printf argument carries the validator's field-level detail (e.g.\n * `\"storeMediaBytesCallback is required\"`) so a misconfiguration names the offending field\n * instead of failing opaquely. The underlying `ValidationError` is also attached on `cause`.\n *\n * @group Turn Runner Construction\n */\nexport const E_INVALID_TURN_RUNNER_CONFIG = createException<[string]>(\n 'E_INVALID_TURN_RUNNER_CONFIG',\n 'The turn runner cannot be instantiated with the provided configuration: %s',\n 'E_INVALID_TURN_RUNNER_CONFIG',\n 529,\n true\n)\n\n/**\n * Thrown by {@link @nhtio/adk!TurnRunner} when the {@link @nhtio/adk!TurnContext} supplied to `run` fails schema\n * validation.\n *\n * @remarks\n * Marked fatal — an invalid context indicates a programming error in the caller, not a\n * recoverable runtime condition. Thrown synchronously out of `run()` before `turnStart` is\n * emitted.\n *\n * @group Turn Input Validation\n */\nexport const E_INVALID_TURN_CONTEXT = createException(\n 'E_INVALID_TURN_CONTEXT',\n 'The turn runner received an invalid context object.',\n 'E_INVALID_TURN_CONTEXT',\n 529,\n true\n)\n\n/**\n * Emitted (via the `error` event) when a non-abort error propagates out of the input\n * middleware pipeline during {@link @nhtio/adk!TurnRunner.run}.\n *\n * @remarks\n * Not fatal — the turn runner emits this on the `error` event rather than throwing, so\n * registered listeners can handle or log the failure without crashing the pipeline. Dispatch\n * and output middleware are skipped; `turnEnd` still fires.\n *\n * @group Pipelines\n */\nexport const E_INPUT_PIPELINE_ERROR = createException(\n 'E_INPUT_PIPELINE_ERROR',\n 'An error occurred in the input pipeline.',\n 'E_INPUT_PIPELINE_ERROR',\n 500,\n false\n)\n\n/**\n * Emitted (via the `error` event) when a non-abort error propagates out of the output\n * middleware pipeline during {@link @nhtio/adk!TurnRunner.run}.\n *\n * @remarks\n * Not fatal — the turn runner emits this on the `error` event rather than throwing, so\n * registered listeners can handle or log the failure without crashing the pipeline. `turnEnd`\n * still fires.\n *\n * @group Pipelines\n */\nexport const E_OUTPUT_PIPELINE_ERROR = createException(\n 'E_OUTPUT_PIPELINE_ERROR',\n 'An error occurred in the output pipeline.',\n 'E_OUTPUT_PIPELINE_ERROR',\n 500,\n false\n)\n\n/**\n * Emitted (via the `error` event) when a middleware pipeline resolves without reaching its\n * terminal handler and without the turn being aborted. Indicates that some middleware\n * returned without calling `next` and without signalling a deliberate refusal via the turn's\n * abort controller.\n *\n * @remarks\n * Not fatal — the runner emits this on the `error` event so the failure is observable, then\n * proceeds to short-circuit the remainder of the turn the same way any other pipeline error\n * would. The constructor takes a single positional argument identifying the pipeline that\n * short-circuited: one of `'turn-input'`, `'turn-output'`, `'dispatch-input'`, or `'dispatch-output'`.\n *\n * Deliberate refusals should call `ctx.abort(reason)`, which sets the `'aborted'` outcome\n * instead of emitting this error.\n *\n * @warning\n * This is a **detection condition**, not a thrown exception. The runner constructs and emits\n * the code itself when it detects a missing `next()` on the unwind — nothing in user code\n * throws it. Upstream post-steps still run normally.\n *\n * @example\n * ```ts\n * throw new E_PIPELINE_SHORT_CIRCUITED(['turn-input'])\n * ```\n *\n * @group Pipelines\n */\nexport const E_PIPELINE_SHORT_CIRCUITED = createException<[string]>(\n 'E_PIPELINE_SHORT_CIRCUITED',\n \"The '%s' middleware pipeline short-circuited without calling next or aborting the turn.\",\n 'E_PIPELINE_SHORT_CIRCUITED',\n 500,\n false\n)\n\n/**\n * Thrown when a registry is initialised with a value that is defined but not a plain object.\n *\n * @remarks\n * Registries expect either `undefined` (empty start) or a plain object as their initial value.\n * Passing a primitive, array, class instance, or other non-object signals a programming error\n * in the caller.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_REGISTRY_VALUE = createException(\n 'E_INVALID_INITIAL_REGISTRY_VALUE',\n 'Attempted to initialize a registry with a defined non-object value.',\n 'E_INVALID_INITIAL_REGISTRY_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!Memory} is initialised with a value that fails schema validation.\n *\n * @remarks\n * `Memory` requires all fields — `id`, `content`, `confidence`, `importance`, `createdAt`,\n * `updatedAt` — to be present and of the correct type. Passing an incomplete or incorrectly\n * typed object signals a programming error in the caller, not a recoverable runtime condition.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_MEMORY_VALUE = createException(\n 'E_INVALID_INITIAL_MEMORY_VALUE',\n 'Attempted to initialize a memory with an invalid value.',\n 'E_INVALID_INITIAL_MEMORY_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!Retrievable} is initialised with a value that fails schema validation.\n *\n * @remarks\n * `Retrievable` requires `id`, `content`, `trustTier`, `createdAt`, and `updatedAt` to be present\n * and of the correct type, and `trustTier` must be one of `'first-party'`, `'third-party-public'`,\n * or `'third-party-private'`. The `trustTier` decision must be made consciously by the retrieval\n * middleware at construction time — there is no default. Passing an incomplete or incorrectly\n * typed object signals a programming error in the caller, not a recoverable runtime condition.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_RETRIEVABLE_VALUE = createException(\n 'E_INVALID_INITIAL_RETRIEVABLE_VALUE',\n 'Invalid initial value supplied to Retrievable constructor.',\n 'E_INVALID_INITIAL_RETRIEVABLE_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!Message} is initialised with a value that fails schema validation.\n *\n * @remarks\n * `Message` requires `id`, `role` (`user` or `assistant`), `content`, `createdAt`, and\n * `updatedAt` to be present and of the correct type. Passing an incomplete or incorrectly\n * typed object signals a programming error in the caller, not a recoverable runtime condition.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_MESSAGE_VALUE = createException(\n 'E_INVALID_INITIAL_MESSAGE_VALUE',\n 'Attempted to initialize a message with an invalid value.',\n 'E_INVALID_INITIAL_MESSAGE_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when an {@link @nhtio/adk!Identity} is initialised with a value that fails schema validation.\n *\n * @remarks\n * `Identity` requires both `identifier` (string or number) and `representation` (string or\n * {@link @nhtio/adk!Tokenizable}) to be present and of the correct type. Passing an incomplete or\n * incorrectly typed object signals a programming error in the caller.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_IDENTITY_VALUE = createException(\n 'E_INVALID_INITIAL_IDENTITY_VALUE',\n 'Attempted to initialize an identity with an invalid value.',\n 'E_INVALID_INITIAL_IDENTITY_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!Thought} is initialised with a value that fails schema validation.\n *\n * @remarks\n * `Thought` requires `id`, `content`, `createdAt`, and `updatedAt` to be present and of the\n * correct type. Passing an incomplete or incorrectly typed object signals a programming error\n * in the caller, not a recoverable runtime condition.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_THOUGHT_VALUE = createException(\n 'E_INVALID_INITIAL_THOUGHT_VALUE',\n 'Attempted to initialize a thought with an invalid value.',\n 'E_INVALID_INITIAL_THOUGHT_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!TurnGate} is constructed with a value that fails schema validation.\n *\n * @remarks\n * Fatal — bad construction arguments indicate a programming error in the caller.\n *\n * @group Gates\n */\nexport const E_INVALID_INITIAL_TURN_GATE_VALUE = createException(\n 'E_INVALID_INITIAL_TURN_GATE_VALUE',\n 'Attempted to initialize a turn gate with an invalid value.',\n 'E_INVALID_INITIAL_TURN_GATE_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown synchronously in the caller's context when {@link @nhtio/adk!TurnGate.resolve} is called with a\n * value that fails the gate's schema.\n *\n * @remarks\n * Fatal — passing the wrong type to `resolve()` is a programming error. The internal promise is\n * NOT settled when this is thrown; the gate remains open.\n *\n * @group Gates\n */\nexport const E_INVALID_TURN_GATE_RESOLUTION = createException(\n 'E_INVALID_TURN_GATE_RESOLUTION',\n 'The value supplied to TurnGate.resolve() failed schema validation.',\n 'E_INVALID_TURN_GATE_RESOLUTION',\n 500,\n true\n)\n\n/**\n * Thrown (as a rejection reason) when a {@link @nhtio/adk!TurnGate} times out before being resolved.\n *\n * @remarks\n * Not fatal — a timeout is a recoverable runtime condition; the caller may retry or surface it\n * to the user.\n *\n * @warning\n * A timeout does **not** cancel the external event or clear any remote queue. The gate closes\n * locally, but whatever external system was expected to call `gate.resolve()` may still fire\n * later. Orphaned external state must be handled by the caller.\n *\n * @group Gates\n */\nexport const E_TURN_GATE_TIMEOUT = createException(\n 'E_TURN_GATE_TIMEOUT',\n 'The turn gate timed out before being resolved.',\n 'E_TURN_GATE_TIMEOUT',\n 408,\n false\n)\n\n/**\n * Thrown (as a rejection reason) when a {@link @nhtio/adk!TurnGate} is aborted — either because the turn's\n * `AbortSignal` fired or because {@link @nhtio/adk!TurnGate.abort} was called directly.\n *\n * @remarks\n * Not fatal — abort is an intentional cancellation, not an error in the caller.\n *\n * @group Gates\n */\nexport const E_TURN_GATE_ABORTED = createException(\n 'E_TURN_GATE_ABORTED',\n 'The turn gate was aborted before being resolved.',\n 'E_TURN_GATE_ABORTED',\n 499,\n false\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!SpooledArtifact} is constructed with a value that does not implement the\n * {@link @nhtio/adk!SpoolReader} interface.\n *\n * @remarks\n * Validated at construction time via {@link @nhtio/adk!implementsSpoolReader}. Passing anything that lacks\n * `line`, `byteLength`, or `lineCount` as callable functions signals a programming error in the\n * caller.\n *\n * @group Artifacts\n */\nexport const E_NOT_A_SPOOL_READER = createException(\n 'E_NOT_A_SPOOL_READER',\n 'The provided value does not implement the SpoolReader interface.',\n 'E_NOT_A_SPOOL_READER',\n 500,\n true\n)\n\n/**\n * Thrown when a Media is constructed with a value that does not implement the MediaReader\n * interface.\n *\n * @remarks\n * Validated at construction time. Passing anything that lacks `stream` or `byteLength` as\n * callable functions signals a programming error in the caller.\n *\n * @group Artifacts\n */\nexport const E_NOT_A_MEDIA_READER = createException(\n 'E_NOT_A_MEDIA_READER',\n 'The provided value does not implement the MediaReader interface.',\n 'E_NOT_A_MEDIA_READER',\n 500,\n true\n)\n\n/**\n * Thrown when a Media is initialised with a value that fails schema validation.\n *\n * @remarks\n * Fatal — bad construction arguments indicate a programming error in the caller.\n *\n * @group Artifacts\n */\nexport const E_INVALID_INITIAL_MEDIA_VALUE = createException(\n 'E_INVALID_INITIAL_MEDIA_VALUE',\n 'Attempted to initialize a media with an invalid value.',\n 'E_INVALID_INITIAL_MEDIA_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!ToolCall} is initialised with a value that fails schema validation.\n *\n * @remarks\n * `ToolCall` requires `id`, `tool`, `args`, `checksum`, `isComplete`, `isError`, `createdAt`,\n * and `updatedAt` to be present and of the correct type. Passing an incomplete or incorrectly\n * typed object signals a programming error in the caller, not a recoverable runtime condition.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_TOOL_CALL_VALUE = createException(\n 'E_INVALID_INITIAL_TOOL_CALL_VALUE',\n 'Attempted to initialize a tool call with an invalid value.',\n 'E_INVALID_INITIAL_TOOL_CALL_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!Tool} is constructed with a value that fails schema validation.\n *\n * @remarks\n * Fatal — bad construction arguments indicate a programming error in the caller.\n *\n * @group Tools\n */\nexport const E_INVALID_INITIAL_TOOL_VALUE = createException(\n 'E_INVALID_INITIAL_TOOL_VALUE',\n 'Attempted to initialize a tool with an invalid value.',\n 'E_INVALID_INITIAL_TOOL_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown synchronously when {@link @nhtio/adk!Tool.validate} is called with arguments that fail the tool's\n * input schema.\n *\n * @remarks\n * Not fatal — an arg validation failure in the tool call loop is a caller mistake that can be\n * surfaced as an error response. The tool handler is NOT called when this is thrown.\n *\n * @group Tools\n */\nexport const E_INVALID_TOOL_ARGS = createException(\n 'E_INVALID_TOOL_ARGS',\n 'The arguments supplied to the tool failed input schema validation.',\n 'E_INVALID_TOOL_ARGS',\n 422,\n false\n)\n\n/**\n * Thrown (as a rejection reason) when a {@link @nhtio/adk!Tool}'s handler throws during execution.\n *\n * @remarks\n * Not fatal — a downstream tool failure is a recoverable runtime condition. The tool call loop\n * catches this error specifically to report the failure back to the model rather than crashing\n * the pipeline.\n *\n * @group Tools\n */\nexport const E_TOOL_DOWNSTREAM_ERROR = createException(\n 'E_TOOL_DOWNSTREAM_ERROR',\n 'The tool handler threw an error during execution.',\n 'E_TOOL_DOWNSTREAM_ERROR',\n 500,\n false\n)\n\n/**\n * Thrown when {@link @nhtio/adk!ToolRegistry.register} is called for a tool name that is already registered\n * and `overwrite` is not `true`.\n *\n * @remarks\n * Fatal — accidentally overwriting a registered tool indicates a programming error. Pass\n * `overwrite: true` to replace an existing tool intentionally.\n *\n * @group Tools\n */\nexport const E_TOOL_ALREADY_REGISTERED = createException(\n 'E_TOOL_ALREADY_REGISTERED',\n 'A tool with this name is already registered. Pass overwrite: true to replace it.',\n 'E_TOOL_ALREADY_REGISTERED',\n 409,\n true\n)\n\n/**\n * Thrown when {@link @nhtio/adk!DispatchContext} is constructed with a value that fails schema validation.\n *\n * @remarks\n * Fatal — bad construction arguments indicate a programming error in the caller.\n *\n * @group Dispatch\n */\nexport const E_INVALID_LLM_EXECUTION_CONTEXT = createException(\n 'E_INVALID_LLM_EXECUTION_CONTEXT',\n 'The LLM execution context cannot be instantiated with the provided value.',\n 'E_INVALID_LLM_EXECUTION_CONTEXT',\n 529,\n true\n)\n\n/**\n * Thrown (as a rejection reason) when {@link @nhtio/adk!DispatchContext.waitFor} is called on a\n * standalone context that was constructed without a `waitFor` function.\n *\n * @remarks\n * Not fatal — the caller can catch this and handle the case where gate suspension is not\n * supported for this execution context.\n *\n * @group Dispatch\n */\nexport const E_LLM_EXECUTION_GATE_NOT_SUPPORTED = createException(\n 'E_LLM_EXECUTION_GATE_NOT_SUPPORTED',\n 'waitFor was called on a standalone DispatchContext with no gate function provided.',\n 'E_LLM_EXECUTION_GATE_NOT_SUPPORTED',\n 501,\n false\n)\n\n/**\n * Thrown when {@link @nhtio/adk!DispatchContext.ack} or {@link @nhtio/adk!DispatchContext.nack} is called on a\n * context that has already been signalled.\n *\n * @remarks\n * Fatal — signalling twice is a programming error in the caller. The first signal wins; the\n * second call is rejected loudly so callers cannot accidentally race between ack and nack.\n *\n * @danger\n * Signalling is **not** silently idempotent. The first `ack()` or `nack()` wins; the second\n * throws immediately. Guard with `if (!ctx.isSignalled)` when more than one seam may signal.\n *\n * @group Dispatch\n */\nexport const E_LLM_EXECUTION_ALREADY_SIGNALLED = createException(\n 'E_LLM_EXECUTION_ALREADY_SIGNALLED',\n 'ack() or nack() was called on an DispatchContext that has already been signalled.',\n 'E_LLM_EXECUTION_ALREADY_SIGNALLED',\n 500,\n true\n)\n\n/**\n * Thrown when {@link @nhtio/adk!DispatchRunner.dispatch} receives an input that fails schema validation.\n *\n * @remarks\n * Fatal — invalid dispatch input indicates a programming error in the caller.\n *\n * @group Dispatch\n */\nexport const E_INVALID_LLM_DISPATCH_INPUT = createException(\n 'E_INVALID_LLM_DISPATCH_INPUT',\n 'The LLM execution runner received an invalid dispatch input.',\n 'E_INVALID_LLM_DISPATCH_INPUT',\n 529,\n true\n)\n\n/**\n * Emitted (via the observability `error` hook) and re-thrown when a non-abort error propagates\n * out of the input or output middleware pipeline during {@link @nhtio/adk!DispatchRunner.dispatch}.\n *\n * @remarks\n * Not fatal — pipeline errors are recoverable runtime conditions. `dispatch()` rejects with this\n * exception so callers can handle the failure via try/catch. Both `dispatchInputPipeline` and\n * `dispatchOutputPipeline` share this one code — the runner does not split input vs. output at\n * this layer.\n *\n * @group Pipelines\n */\nexport const E_DISPATCH_PIPELINE_ERROR = createException(\n 'E_DISPATCH_PIPELINE_ERROR',\n 'An error occurred in an LLM execution pipeline.',\n 'E_DISPATCH_PIPELINE_ERROR',\n 500,\n false\n)\n\n/**\n * Emitted (via the observability `error` hook) and re-thrown when the user-supplied executor\n * callback throws during {@link @nhtio/adk!DispatchRunner.dispatch}.\n *\n * @remarks\n * Not fatal — executor errors are recoverable runtime conditions. `dispatch()` rejects with this\n * exception so callers can handle the failure via try/catch.\n *\n * @group Dispatch\n */\nexport const E_LLM_EXECUTION_EXECUTOR_ERROR = createException(\n 'E_LLM_EXECUTION_EXECUTOR_ERROR',\n 'The LLM execution executor callback threw an error.',\n 'E_LLM_EXECUTION_EXECUTOR_ERROR',\n 500,\n false\n)\n"],"mappings":";;;;;;;;;;;;;;;AAeA,IAAa,+BAA+B,mBAAA,gBAC1C,gCACA,8EACA,gCACA,KACA,IACF;;;;;;;;;;;;AAaA,IAAa,yBAAyB,mBAAA,gBACpC,0BACA,uDACA,0BACA,KACA,IACF;;;;;;;;;;;;AAaA,IAAa,yBAAyB,mBAAA,gBACpC,0BACA,4CACA,0BACA,KACA,KACF;;;;;;;;;;;;AAaA,IAAa,0BAA0B,mBAAA,gBACrC,2BACA,6CACA,2BACA,KACA,KACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,IAAa,6BAA6B,mBAAA,gBACxC,8BACA,2FACA,8BACA,KACA,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Aa,0BAA0B,mBAAA,gBACrC,2BACA,qDACA,2BACA,KACA,KACF;;;;;;;;;;;AAYA,IAAa,4BAA4B,mBAAA,gBACvC,6BACA,oFACA,6BACA,KACA,IACF;;;;;;;;;AAUA,IAAa,kCAAkC,mBAAA,gBAC7C,mCACA,6EACA,mCACA,KACA,IACF;;;;;;;;;;;AAYA,IAAa,qCAAqC,mBAAA,gBAChD,sCACA,sFACA,sCACA,KACA,KACF;;;;;;;;;;;;;;;AAgBA,IAAa,oCAAoC,mBAAA,gBAC/C,qCACA,qFACA,qCACA,KACA,IACF;;;;;;;;;AAUA,IAAa,+BAA+B,mBAAA,gBAC1C,gCACA,gEACA,gCACA,KACA,IACF;;;;;;;;;;;;;AAcA,IAAa,4BAA4B,mBAAA,gBACvC,6BACA,mDACA,6BACA,KACA,KACF;;;;;;;;;;;AAYA,IAAa,iCAAiC,mBAAA,gBAC5C,kCACA,uDACA,kCACA,KACA,KACF"}
1
+ {"version":3,"file":"runtime-DslE1aBw.js","names":[],"sources":["../src/lib/exceptions/runtime.ts"],"sourcesContent":["import { createException } from '../utils/exceptions'\n\n/**\n * Thrown by {@link @nhtio/adk!TurnRunner} when the supplied config object fails schema validation at\n * construction time.\n *\n * @remarks\n * Marked fatal — a misconfigured runner must not be allowed to execute turns.\n *\n * The single printf argument carries the validator's field-level detail (e.g.\n * `\"storeMediaBytesCallback is required\"`) so a misconfiguration names the offending field\n * instead of failing opaquely. The underlying `ValidationError` is also attached on `cause`.\n *\n * @group Turn Runner Construction\n */\nexport const E_INVALID_TURN_RUNNER_CONFIG = createException<[string]>(\n 'E_INVALID_TURN_RUNNER_CONFIG',\n 'The turn runner cannot be instantiated with the provided configuration: %s',\n 'E_INVALID_TURN_RUNNER_CONFIG',\n 529,\n true\n)\n\n/**\n * Thrown by {@link @nhtio/adk!TurnRunner} when the {@link @nhtio/adk!TurnContext} supplied to `run` fails schema\n * validation.\n *\n * @remarks\n * Marked fatal — an invalid context indicates a programming error in the caller, not a\n * recoverable runtime condition. Thrown synchronously out of `run()` before `turnStart` is\n * emitted.\n *\n * @group Turn Input Validation\n */\nexport const E_INVALID_TURN_CONTEXT = createException(\n 'E_INVALID_TURN_CONTEXT',\n 'The turn runner received an invalid context object.',\n 'E_INVALID_TURN_CONTEXT',\n 529,\n true\n)\n\n/**\n * Emitted (via the `error` event) when a non-abort error propagates out of the input\n * middleware pipeline during {@link @nhtio/adk!TurnRunner.run}.\n *\n * @remarks\n * Not fatal — the turn runner emits this on the `error` event rather than throwing, so\n * registered listeners can handle or log the failure without crashing the pipeline. Dispatch\n * and output middleware are skipped; `turnEnd` still fires.\n *\n * @group Pipelines\n */\nexport const E_INPUT_PIPELINE_ERROR = createException(\n 'E_INPUT_PIPELINE_ERROR',\n 'An error occurred in the input pipeline.',\n 'E_INPUT_PIPELINE_ERROR',\n 500,\n false\n)\n\n/**\n * Emitted (via the `error` event) when a non-abort error propagates out of the output\n * middleware pipeline during {@link @nhtio/adk!TurnRunner.run}.\n *\n * @remarks\n * Not fatal — the turn runner emits this on the `error` event rather than throwing, so\n * registered listeners can handle or log the failure without crashing the pipeline. `turnEnd`\n * still fires.\n *\n * @group Pipelines\n */\nexport const E_OUTPUT_PIPELINE_ERROR = createException(\n 'E_OUTPUT_PIPELINE_ERROR',\n 'An error occurred in the output pipeline.',\n 'E_OUTPUT_PIPELINE_ERROR',\n 500,\n false\n)\n\n/**\n * Emitted (via the `error` event) when a middleware pipeline resolves without reaching its\n * terminal handler and without the turn being aborted. Indicates that some middleware\n * returned without calling `next` and without signalling a deliberate refusal via the turn's\n * abort controller.\n *\n * @remarks\n * Not fatal — the runner emits this on the `error` event so the failure is observable, then\n * proceeds to short-circuit the remainder of the turn the same way any other pipeline error\n * would. The constructor takes a single positional argument identifying the pipeline that\n * short-circuited: one of `'turn-input'`, `'turn-output'`, `'dispatch-input'`, or `'dispatch-output'`.\n *\n * Deliberate refusals should call `ctx.abort(reason)`, which sets the `'aborted'` outcome\n * instead of emitting this error.\n *\n * @warning\n * This is a **detection condition**, not a thrown exception. The runner constructs and emits\n * the code itself when it detects a missing `next()` on the unwind — nothing in user code\n * throws it. Upstream post-steps still run normally.\n *\n * @example\n * ```ts\n * throw new E_PIPELINE_SHORT_CIRCUITED(['turn-input'])\n * ```\n *\n * @group Pipelines\n */\nexport const E_PIPELINE_SHORT_CIRCUITED = createException<[string]>(\n 'E_PIPELINE_SHORT_CIRCUITED',\n \"The '%s' middleware pipeline short-circuited without calling next or aborting the turn.\",\n 'E_PIPELINE_SHORT_CIRCUITED',\n 500,\n false\n)\n\n/**\n * Thrown when a registry is initialised with a value that is defined but not a plain object.\n *\n * @remarks\n * Registries expect either `undefined` (empty start) or a plain object as their initial value.\n * Passing a primitive, array, class instance, or other non-object signals a programming error\n * in the caller.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_REGISTRY_VALUE = createException(\n 'E_INVALID_INITIAL_REGISTRY_VALUE',\n 'Attempted to initialize a registry with a defined non-object value.',\n 'E_INVALID_INITIAL_REGISTRY_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!Memory} is initialised with a value that fails schema validation.\n *\n * @remarks\n * `Memory` requires all fields — `id`, `content`, `confidence`, `importance`, `createdAt`,\n * `updatedAt` — to be present and of the correct type. Passing an incomplete or incorrectly\n * typed object signals a programming error in the caller, not a recoverable runtime condition.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_MEMORY_VALUE = createException(\n 'E_INVALID_INITIAL_MEMORY_VALUE',\n 'Attempted to initialize a memory with an invalid value.',\n 'E_INVALID_INITIAL_MEMORY_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!Retrievable} is initialised with a value that fails schema validation.\n *\n * @remarks\n * `Retrievable` requires `id`, `content`, `trustTier`, `createdAt`, and `updatedAt` to be present\n * and of the correct type, and `trustTier` must be one of `'first-party'`, `'third-party-public'`,\n * or `'third-party-private'`. The `trustTier` decision must be made consciously by the retrieval\n * middleware at construction time — there is no default. Passing an incomplete or incorrectly\n * typed object signals a programming error in the caller, not a recoverable runtime condition.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_RETRIEVABLE_VALUE = createException(\n 'E_INVALID_INITIAL_RETRIEVABLE_VALUE',\n 'Invalid initial value supplied to Retrievable constructor.',\n 'E_INVALID_INITIAL_RETRIEVABLE_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!Message} is initialised with a value that fails schema validation.\n *\n * @remarks\n * `Message` requires `id`, `role` (`user` or `assistant`), `content`, `createdAt`, and\n * `updatedAt` to be present and of the correct type. Passing an incomplete or incorrectly\n * typed object signals a programming error in the caller, not a recoverable runtime condition.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_MESSAGE_VALUE = createException(\n 'E_INVALID_INITIAL_MESSAGE_VALUE',\n 'Attempted to initialize a message with an invalid value.',\n 'E_INVALID_INITIAL_MESSAGE_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when an {@link @nhtio/adk!Identity} is initialised with a value that fails schema validation.\n *\n * @remarks\n * `Identity` requires both `identifier` (string or number) and `representation` (string or\n * {@link @nhtio/adk!Tokenizable}) to be present and of the correct type. Passing an incomplete or\n * incorrectly typed object signals a programming error in the caller.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_IDENTITY_VALUE = createException(\n 'E_INVALID_INITIAL_IDENTITY_VALUE',\n 'Attempted to initialize an identity with an invalid value.',\n 'E_INVALID_INITIAL_IDENTITY_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!Thought} is initialised with a value that fails schema validation.\n *\n * @remarks\n * `Thought` requires `id`, `content`, `createdAt`, and `updatedAt` to be present and of the\n * correct type. Passing an incomplete or incorrectly typed object signals a programming error\n * in the caller, not a recoverable runtime condition.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_THOUGHT_VALUE = createException(\n 'E_INVALID_INITIAL_THOUGHT_VALUE',\n 'Attempted to initialize a thought with an invalid value.',\n 'E_INVALID_INITIAL_THOUGHT_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!TurnGate} is constructed with a value that fails schema validation.\n *\n * @remarks\n * Fatal — bad construction arguments indicate a programming error in the caller.\n *\n * @group Gates\n */\nexport const E_INVALID_INITIAL_TURN_GATE_VALUE = createException(\n 'E_INVALID_INITIAL_TURN_GATE_VALUE',\n 'Attempted to initialize a turn gate with an invalid value.',\n 'E_INVALID_INITIAL_TURN_GATE_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown synchronously in the caller's context when {@link @nhtio/adk!TurnGate.resolve} is called with a\n * value that fails the gate's schema.\n *\n * @remarks\n * Fatal — passing the wrong type to `resolve()` is a programming error. The internal promise is\n * NOT settled when this is thrown; the gate remains open.\n *\n * @group Gates\n */\nexport const E_INVALID_TURN_GATE_RESOLUTION = createException(\n 'E_INVALID_TURN_GATE_RESOLUTION',\n 'The value supplied to TurnGate.resolve() failed schema validation.',\n 'E_INVALID_TURN_GATE_RESOLUTION',\n 500,\n true\n)\n\n/**\n * Thrown (as a rejection reason) when a {@link @nhtio/adk!TurnGate} times out before being resolved.\n *\n * @remarks\n * Not fatal — a timeout is a recoverable runtime condition; the caller may retry or surface it\n * to the user.\n *\n * @warning\n * A timeout does **not** cancel the external event or clear any remote queue. The gate closes\n * locally, but whatever external system was expected to call `gate.resolve()` may still fire\n * later. Orphaned external state must be handled by the caller.\n *\n * @group Gates\n */\nexport const E_TURN_GATE_TIMEOUT = createException(\n 'E_TURN_GATE_TIMEOUT',\n 'The turn gate timed out before being resolved.',\n 'E_TURN_GATE_TIMEOUT',\n 408,\n false\n)\n\n/**\n * Thrown (as a rejection reason) when a {@link @nhtio/adk!TurnGate} is aborted — either because the turn's\n * `AbortSignal` fired or because {@link @nhtio/adk!TurnGate.abort} was called directly.\n *\n * @remarks\n * Not fatal — abort is an intentional cancellation, not an error in the caller.\n *\n * @group Gates\n */\nexport const E_TURN_GATE_ABORTED = createException(\n 'E_TURN_GATE_ABORTED',\n 'The turn gate was aborted before being resolved.',\n 'E_TURN_GATE_ABORTED',\n 499,\n false\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!SpooledArtifact} is constructed with a value that does not implement the\n * {@link @nhtio/adk!SpoolReader} interface.\n *\n * @remarks\n * Validated at construction time via {@link @nhtio/adk!implementsSpoolReader}. Passing anything that lacks\n * `line`, `byteLength`, or `lineCount` as callable functions signals a programming error in the\n * caller.\n *\n * @group Artifacts\n */\nexport const E_NOT_A_SPOOL_READER = createException(\n 'E_NOT_A_SPOOL_READER',\n 'The provided value does not implement the SpoolReader interface.',\n 'E_NOT_A_SPOOL_READER',\n 500,\n true\n)\n\n/**\n * Thrown when a Media is constructed with a value that does not implement the MediaReader\n * interface.\n *\n * @remarks\n * Validated at construction time. Passing anything that lacks `stream` or `byteLength` as\n * callable functions signals a programming error in the caller.\n *\n * @group Artifacts\n */\nexport const E_NOT_A_MEDIA_READER = createException(\n 'E_NOT_A_MEDIA_READER',\n 'The provided value does not implement the MediaReader interface.',\n 'E_NOT_A_MEDIA_READER',\n 500,\n true\n)\n\n/**\n * Thrown when a Media is initialised with a value that fails schema validation.\n *\n * @remarks\n * Fatal — bad construction arguments indicate a programming error in the caller.\n *\n * @group Artifacts\n */\nexport const E_INVALID_INITIAL_MEDIA_VALUE = createException(\n 'E_INVALID_INITIAL_MEDIA_VALUE',\n 'Attempted to initialize a media with an invalid value.',\n 'E_INVALID_INITIAL_MEDIA_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!ToolCall} is initialised with a value that fails schema validation.\n *\n * @remarks\n * `ToolCall` requires `id`, `tool`, `args`, `checksum`, `isComplete`, `isError`, `createdAt`,\n * and `updatedAt` to be present and of the correct type. Passing an incomplete or incorrectly\n * typed object signals a programming error in the caller, not a recoverable runtime condition.\n *\n * @group Primitive Validation\n */\nexport const E_INVALID_INITIAL_TOOL_CALL_VALUE = createException(\n 'E_INVALID_INITIAL_TOOL_CALL_VALUE',\n 'Attempted to initialize a tool call with an invalid value.',\n 'E_INVALID_INITIAL_TOOL_CALL_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown when a {@link @nhtio/adk!Tool} is constructed with a value that fails schema validation.\n *\n * @remarks\n * Fatal — bad construction arguments indicate a programming error in the caller.\n *\n * @group Tools\n */\nexport const E_INVALID_INITIAL_TOOL_VALUE = createException(\n 'E_INVALID_INITIAL_TOOL_VALUE',\n 'Attempted to initialize a tool with an invalid value.',\n 'E_INVALID_INITIAL_TOOL_VALUE',\n 500,\n true\n)\n\n/**\n * Thrown synchronously when {@link @nhtio/adk!Tool.validate} is called with arguments that fail the tool's\n * input schema.\n *\n * @remarks\n * Not fatal — an arg validation failure in the tool call loop is a caller mistake that can be\n * surfaced as an error response. The tool handler is NOT called when this is thrown.\n *\n * @group Tools\n */\nexport const E_INVALID_TOOL_ARGS = createException(\n 'E_INVALID_TOOL_ARGS',\n 'The arguments supplied to the tool failed input schema validation.',\n 'E_INVALID_TOOL_ARGS',\n 422,\n false\n)\n\n/**\n * Thrown (as a rejection reason) when a {@link @nhtio/adk!Tool}'s handler throws during execution.\n *\n * @remarks\n * Not fatal — a downstream tool failure is a recoverable runtime condition. The tool call loop\n * catches this error specifically to report the failure back to the model rather than crashing\n * the pipeline.\n *\n * @group Tools\n */\nexport const E_TOOL_DOWNSTREAM_ERROR = createException(\n 'E_TOOL_DOWNSTREAM_ERROR',\n 'The tool handler threw an error during execution.',\n 'E_TOOL_DOWNSTREAM_ERROR',\n 500,\n false\n)\n\n/**\n * Thrown when {@link @nhtio/adk!ToolRegistry.register} is called for a tool name that is already registered\n * and `overwrite` is not `true`.\n *\n * @remarks\n * Fatal — accidentally overwriting a registered tool indicates a programming error. Pass\n * `overwrite: true` to replace an existing tool intentionally.\n *\n * @group Tools\n */\nexport const E_TOOL_ALREADY_REGISTERED = createException(\n 'E_TOOL_ALREADY_REGISTERED',\n 'A tool with this name is already registered. Pass overwrite: true to replace it.',\n 'E_TOOL_ALREADY_REGISTERED',\n 409,\n true\n)\n\n/**\n * Thrown when {@link @nhtio/adk!DispatchContext} is constructed with a value that fails schema validation.\n *\n * @remarks\n * Fatal — bad construction arguments indicate a programming error in the caller.\n *\n * @group Dispatch\n */\nexport const E_INVALID_LLM_EXECUTION_CONTEXT = createException(\n 'E_INVALID_LLM_EXECUTION_CONTEXT',\n 'The LLM execution context cannot be instantiated with the provided value.',\n 'E_INVALID_LLM_EXECUTION_CONTEXT',\n 529,\n true\n)\n\n/**\n * Thrown (as a rejection reason) when {@link @nhtio/adk!DispatchContext.waitFor} is called on a\n * standalone context that was constructed without a `waitFor` function.\n *\n * @remarks\n * Not fatal — the caller can catch this and handle the case where gate suspension is not\n * supported for this execution context.\n *\n * @group Dispatch\n */\nexport const E_LLM_EXECUTION_GATE_NOT_SUPPORTED = createException(\n 'E_LLM_EXECUTION_GATE_NOT_SUPPORTED',\n 'waitFor was called on a standalone DispatchContext with no gate function provided.',\n 'E_LLM_EXECUTION_GATE_NOT_SUPPORTED',\n 501,\n false\n)\n\n/**\n * Thrown when {@link @nhtio/adk!DispatchContext.ack} or {@link @nhtio/adk!DispatchContext.nack} is called on a\n * context that has already been signalled.\n *\n * @remarks\n * Fatal — signalling twice is a programming error in the caller. The first signal wins; the\n * second call is rejected loudly so callers cannot accidentally race between ack and nack.\n *\n * @danger\n * Signalling is **not** silently idempotent. The first `ack()` or `nack()` wins; the second\n * throws immediately. Guard with `if (!ctx.isSignalled)` when more than one seam may signal.\n *\n * @group Dispatch\n */\nexport const E_LLM_EXECUTION_ALREADY_SIGNALLED = createException(\n 'E_LLM_EXECUTION_ALREADY_SIGNALLED',\n 'ack() or nack() was called on an DispatchContext that has already been signalled.',\n 'E_LLM_EXECUTION_ALREADY_SIGNALLED',\n 500,\n true\n)\n\n/**\n * Thrown when {@link @nhtio/adk!DispatchRunner.dispatch} receives an input that fails schema validation.\n *\n * @remarks\n * Fatal — invalid dispatch input indicates a programming error in the caller.\n *\n * @group Dispatch\n */\nexport const E_INVALID_LLM_DISPATCH_INPUT = createException(\n 'E_INVALID_LLM_DISPATCH_INPUT',\n 'The LLM execution runner received an invalid dispatch input.',\n 'E_INVALID_LLM_DISPATCH_INPUT',\n 529,\n true\n)\n\n/**\n * Emitted (via the observability `error` hook) and re-thrown when a non-abort error propagates\n * out of the input or output middleware pipeline during {@link @nhtio/adk!DispatchRunner.dispatch}.\n *\n * @remarks\n * Not fatal — pipeline errors are recoverable runtime conditions. `dispatch()` rejects with this\n * exception so callers can handle the failure via try/catch. Both `dispatchInputPipeline` and\n * `dispatchOutputPipeline` share this one code — the runner does not split input vs. output at\n * this layer.\n *\n * @group Pipelines\n */\nexport const E_DISPATCH_PIPELINE_ERROR = createException(\n 'E_DISPATCH_PIPELINE_ERROR',\n 'An error occurred in an LLM execution pipeline.',\n 'E_DISPATCH_PIPELINE_ERROR',\n 500,\n false\n)\n\n/**\n * Emitted (via the observability `error` hook) and re-thrown when the user-supplied executor\n * callback throws during {@link @nhtio/adk!DispatchRunner.dispatch}.\n *\n * @remarks\n * Not fatal — executor errors are recoverable runtime conditions. `dispatch()` rejects with this\n * exception so callers can handle the failure via try/catch.\n *\n * @group Dispatch\n */\nexport const E_LLM_EXECUTION_EXECUTOR_ERROR = createException(\n 'E_LLM_EXECUTION_EXECUTOR_ERROR',\n 'The LLM execution executor callback threw an error.',\n 'E_LLM_EXECUTION_EXECUTOR_ERROR',\n 500,\n false\n)\n"],"mappings":";;;;;;;;;;;;;;;AAeA,IAAa,+BAA+B,mBAAA,gBAC1C,gCACA,8EACA,gCACA,KACA,IACF;;;;;;;;;;;;AAaA,IAAa,yBAAyB,mBAAA,gBACpC,0BACA,uDACA,0BACA,KACA,IACF;;;;;;;;;;;;AAaA,IAAa,yBAAyB,mBAAA,gBACpC,0BACA,4CACA,0BACA,KACA,KACF;;;;;;;;;;;;AAaA,IAAa,0BAA0B,mBAAA,gBACrC,2BACA,6CACA,2BACA,KACA,KACF;;;;;;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;;AAYA,IAAa,sBAAsB,mBAAA,gBACjC,uBACA,sEACA,uBACA,KACA,KACF;;;;;;;;;;;AAYA,IAAa,0BAA0B,mBAAA,gBACrC,2BACA,qDACA,2BACA,KACA,KACF;;;;;;;;;;;AAYA,IAAa,4BAA4B,mBAAA,gBACvC,6BACA,oFACA,6BACA,KACA,IACF;;;;;;;;;AAUA,IAAa,kCAAkC,mBAAA,gBAC7C,mCACA,6EACA,mCACA,KACA,IACF;;;;;;;;;;;AAYA,IAAa,qCAAqC,mBAAA,gBAChD,sCACA,sFACA,sCACA,KACA,KACF;;;;;;;;;;;;;;;AAgBA,IAAa,oCAAoC,mBAAA,gBAC/C,qCACA,qFACA,qCACA,KACA,IACF;;;;;;;;;AAUA,IAAa,+BAA+B,mBAAA,gBAC1C,gCACA,gEACA,gCACA,KACA,IACF;;;;;;;;;;;;;AAcA,IAAa,4BAA4B,mBAAA,gBACvC,6BACA,mDACA,6BACA,KACA,KACF;;;;;;;;;;;AAYA,IAAa,iCAAiC,mBAAA,gBAC5C,kCACA,uDACA,kCACA,KACA,KACF"}
@@ -0,0 +1,269 @@
1
+ require("./chunk-Ble4zEEl.js");
2
+ const require_exceptions = require("./exceptions-BRXrUKiW.js");
3
+ const require_tool_registry = require("./tool_registry-CKJPze3j.js");
4
+ const require_tool = require("./tool-D5WGVIcI.js");
5
+ require("./common-DZl3ADJs.js");
6
+ const require_spooled_markdown_artifact = require("./spooled_markdown_artifact-ClX72lek.js");
7
+ require("./factories.cjs");
8
+ require("./guards.cjs");
9
+ let _nhtio_validation = require("@nhtio/validation");
10
+ let _nhtio_middleware = require("@nhtio/middleware");
11
+ //#region src/batteries/tools/searxng/exceptions.ts
12
+ /**
13
+ * Battery-scoped exception constructors for the SearXNG search tool.
14
+ *
15
+ * @remarks
16
+ * Battery-scoped exception classes owned by the SearXNG tool battery (not the ADK core). Minted
17
+ * via `createException` from `@nhtio/adk/factories` and re-exported from the battery's barrel
18
+ * (`@nhtio/adk/batteries/tools/searxng`). This file intentionally carries **no** `@module` tag:
19
+ * it is an internal sibling relative-imported by `index.ts`, so it does not mint its own
20
+ * `…/searxng/exceptions` entrypoint (whose `exceptions` leaf basename would collide with sibling
21
+ * batteries under the `vite-plugin-dts` rolled-up `.d.ts` rule).
22
+ */
23
+ /**
24
+ * Thrown when {@link createSearxngSearchTool} receives invalid configuration.
25
+ *
26
+ * @remarks
27
+ * Fatal: config bugs (missing or unparseable `instanceUrl`) fail loud at factory-call time
28
+ * rather than at the first search.
29
+ */
30
+ var E_INVALID_SEARXNG_CONFIG = require_exceptions.createException("E_INVALID_SEARXNG_CONFIG", "Invalid SearXNG tool config: %s", "E_INVALID_SEARXNG_CONFIG", 529, true);
31
+ //#endregion
32
+ //#region src/batteries/tools/searxng/index.ts
33
+ /**
34
+ * Factory for a configured SearXNG metasearch tool.
35
+ *
36
+ * @module @nhtio/adk/batteries/tools/searxng
37
+ *
38
+ * @remarks
39
+ * Unlike the other bundled tool categories — every one of which exports a ready-made,
40
+ * stateless `Tool` constant — the SearXNG battery exports a **factory**,
41
+ * {@link createSearxngSearchTool}. A search tool has to talk to a *specific* SearXNG instance,
42
+ * usually behind custom authentication, so it needs per-deployment configuration (a base URL
43
+ * and headers) that cannot be baked in at module load.
44
+ *
45
+ * Because this module exports a factory rather than a `Tool` instance, it MUST NOT be
46
+ * bulk-registered via `Object.values(batteries)`. Call the factory first, then register the
47
+ * returned tool: `new ToolRegistry([createSearxngSearchTool({ instanceUrl })])`.
48
+ *
49
+ * @see https://docs.searxng.org/dev/search_api.html
50
+ */
51
+ var DEFAULT_NAME = "searxng_search";
52
+ var DEFAULT_TIMEOUT = 1e4;
53
+ var DEFAULT_DESCRIPTION = "Search the web via a SearXNG metasearch instance. Returns aggregated results (title, url, snippet, source engine) plus any answers, infoboxes, and suggestions.";
54
+ /** Internal sentinel a short-circuiting input stage throws to unwind the pipeline immediately. */
55
+ var SHORT_CIRCUIT = Symbol("searxng.shortCircuit");
56
+ var isShortCircuit = (value) => require_tool_registry.isObject(value) && value[SHORT_CIRCUIT] === true;
57
+ /** Normalise a loose SearXNG result item into a {@link SearxngResult}. */
58
+ var normaliseResult = (raw) => {
59
+ const r = raw ?? {};
60
+ const out = {};
61
+ if (typeof r.title === "string") out.title = r.title;
62
+ if (typeof r.url === "string") out.url = r.url;
63
+ if (typeof r.content === "string") out.content = r.content;
64
+ if (typeof r.engine === "string") out.engine = r.engine;
65
+ if (typeof r.score === "number") out.score = r.score;
66
+ if (typeof r.publishedDate === "string") out.publishedDate = r.publishedDate;
67
+ return out;
68
+ };
69
+ /** Resolve the configured headers (static object or resolver) for a single request. */
70
+ var resolveHeaders = async (headers) => {
71
+ if (typeof headers === "function") return { ...await headers() };
72
+ return { ...headers ?? {} };
73
+ };
74
+ /**
75
+ * Create a configured SearXNG search {@link Tool}.
76
+ *
77
+ * @remarks
78
+ * The handler always requests `format=json`. Note that SearXNG ships with JSON output
79
+ * **disabled** by default (it is abused by bots); an instance that has not enabled
80
+ * `search.formats: [json]` in its `settings.yml` answers with HTTP 403, which the tool returns
81
+ * as a graceful `Error:` string naming the setting.
82
+ *
83
+ * @warning
84
+ * Do not trust the `number_of_results` field for a result count — SearXNG frequently reports `0`
85
+ * in JSON output even when `results` is non-empty. This is a long-standing upstream quirk, not a
86
+ * tool defect (see {@link https://github.com/searxng/searxng/issues/2987 | searxng#2987} and
87
+ * {@link https://github.com/searxng/searxng/issues/2457 | searxng#2457}). The tool passes the
88
+ * field through verbatim; use `results.length` as the authoritative count.
89
+ *
90
+ * @param config - The instance URL, optional custom headers, output-format policy, artifact
91
+ * type, and input/output middleware pipelines. See {@link SearxngToolConfig}.
92
+ * @returns A `Tool` ready to register in a `ToolRegistry`.
93
+ * @throws {@link E_INVALID_SEARXNG_CONFIG} when `instanceUrl` is missing or unparseable.
94
+ */
95
+ var createSearxngSearchTool = (config) => {
96
+ if (typeof config?.instanceUrl !== "string" || config.instanceUrl.trim() === "") throw new E_INVALID_SEARXNG_CONFIG(["instanceUrl is required"]);
97
+ try {
98
+ new URL(config.instanceUrl);
99
+ } catch {
100
+ throw new E_INVALID_SEARXNG_CONFIG([`instanceUrl is not a valid URL: ${config.instanceUrl}`]);
101
+ }
102
+ const instanceUrl = config.instanceUrl.replace(/\/+$/, "");
103
+ const timeout = config.timeout ?? DEFAULT_TIMEOUT;
104
+ const resultFormat = config.resultFormat ?? "either";
105
+ const toolName = config.name ?? DEFAULT_NAME;
106
+ const artifactConstructor = config.artifactConstructor ?? (() => require_spooled_markdown_artifact.SpooledJsonArtifact);
107
+ const inputMw = new _nhtio_middleware.Middleware();
108
+ for (const fn of config.inputPipeline ?? []) inputMw.add(fn);
109
+ const outputMw = new _nhtio_middleware.Middleware();
110
+ for (const fn of config.outputPipeline ?? []) outputMw.add(fn);
111
+ const hasInput = (config.inputPipeline ?? []).length > 0;
112
+ const hasOutput = (config.outputPipeline ?? []).length > 0;
113
+ const schemaShape = {
114
+ query: _nhtio_validation.validator.string().required().description("The search query."),
115
+ categories: _nhtio_validation.validator.string().optional().description("Comma-separated SearXNG categories (e.g. \"general,news\")."),
116
+ engines: _nhtio_validation.validator.string().optional().description("Comma-separated SearXNG engines (e.g. \"google,duckduckgo\")."),
117
+ language: _nhtio_validation.validator.string().optional().description("Language code (e.g. \"en\", \"de\")."),
118
+ pageno: _nhtio_validation.validator.number().min(1).default(1).description("Result page number (1-based)."),
119
+ time_range: _nhtio_validation.validator.string().valid("day", "month", "year").optional().description("Restrict results to a time range."),
120
+ safesearch: _nhtio_validation.validator.number().valid(0, 1, 2).optional().description("Safe-search level: 0 (off), 1 (moderate), 2 (strict).")
121
+ };
122
+ if (resultFormat === "either") schemaShape.format = _nhtio_validation.validator.string().valid("normalized", "raw").default("normalized").description("Output shape: \"normalized\" (trimmed) or \"raw\" (full SearXNG JSON).");
123
+ const inputSchema = _nhtio_validation.validator.object(schemaShape);
124
+ return new require_tool.Tool({
125
+ name: toolName,
126
+ description: config.description ?? DEFAULT_DESCRIPTION,
127
+ inputSchema,
128
+ artifactConstructor,
129
+ handler: async (args) => {
130
+ const a = args;
131
+ try {
132
+ const format = resultFormat === "either" ? a.format ?? "normalized" : resultFormat;
133
+ const headers = {
134
+ "Accept": "application/json",
135
+ "User-Agent": "adk-searxng-tool",
136
+ ...await resolveHeaders(config.headers)
137
+ };
138
+ const params = {};
139
+ if (a.categories) params.categories = a.categories;
140
+ if (a.engines) params.engines = a.engines;
141
+ if (a.language) params.language = a.language;
142
+ if (a.pageno && a.pageno !== 1) params.pageno = String(a.pageno);
143
+ if (a.time_range) params.time_range = a.time_range;
144
+ if (typeof a.safesearch === "number") params.safesearch = String(a.safesearch);
145
+ const stash = /* @__PURE__ */ new Map();
146
+ const requestCtx = {
147
+ toolName,
148
+ query: a.query,
149
+ params,
150
+ headers,
151
+ instanceUrl,
152
+ stash,
153
+ shortCircuit: (result) => {
154
+ throw {
155
+ [SHORT_CIRCUIT]: true,
156
+ result
157
+ };
158
+ }
159
+ };
160
+ if (hasInput) {
161
+ const short = await runInputPipeline(inputMw, requestCtx);
162
+ if (short !== void 0) return short;
163
+ }
164
+ const url = new URL("/search", instanceUrl + "/");
165
+ url.searchParams.set("q", requestCtx.query);
166
+ for (const [k, v] of Object.entries(requestCtx.params)) url.searchParams.set(k, v);
167
+ url.searchParams.set("format", "json");
168
+ const controller = new AbortController();
169
+ const timer = setTimeout(() => controller.abort(), timeout);
170
+ let response;
171
+ try {
172
+ response = await fetch(url, {
173
+ method: "GET",
174
+ headers: requestCtx.headers,
175
+ signal: controller.signal
176
+ });
177
+ } finally {
178
+ clearTimeout(timer);
179
+ }
180
+ if (!response.ok) {
181
+ if (response.status === 403) return "Error: SearXNG returned 403 Forbidden. The instance likely has the JSON output format disabled — enable it under \"search.formats: [json]\" in its settings.yml.";
182
+ return `Error: SearXNG returned HTTP ${response.status} ${response.statusText}.`;
183
+ }
184
+ const body = await response.json();
185
+ const responseCtx = {
186
+ toolName,
187
+ request: requestCtx,
188
+ raw: body,
189
+ results: Array.isArray(body.results) ? body.results.map(normaliseResult) : [],
190
+ format,
191
+ stash
192
+ };
193
+ if (hasOutput) await runOutputPipeline(outputMw, responseCtx);
194
+ if (typeof responseCtx.output === "string") return responseCtx.output;
195
+ if (responseCtx.format === "raw") return JSON.stringify(responseCtx.raw, null, 2);
196
+ return JSON.stringify(buildNormalisedPayload(responseCtx), null, 2);
197
+ } catch (err) {
198
+ if (isShortCircuit(err)) return err.result;
199
+ return `Error: ${require_tool_registry.isError(err) ? err.message : String(err)}`;
200
+ }
201
+ }
202
+ });
203
+ };
204
+ /** Assemble the trimmed normalised payload, dropping empty aggregate arrays. */
205
+ var buildNormalisedPayload = (ctx) => {
206
+ const raw = ctx.raw ?? {};
207
+ const payload = {
208
+ query: typeof raw.query === "string" ? raw.query : ctx.request.query,
209
+ results: ctx.results
210
+ };
211
+ if (typeof raw.number_of_results === "number") payload.number_of_results = raw.number_of_results;
212
+ for (const key of [
213
+ "answers",
214
+ "infoboxes",
215
+ "suggestions",
216
+ "corrections"
217
+ ]) {
218
+ const value = raw[key];
219
+ if (Array.isArray(value) && value.length > 0) payload[key] = value;
220
+ }
221
+ return payload;
222
+ };
223
+ /**
224
+ * Run the input pipeline. Returns the short-circuit string when a stage short-circuited, or
225
+ * `undefined` when the pipeline reached its terminal handler. A non-terminal pipeline (a stage
226
+ * that neither called `next()` nor short-circuited) is surfaced as a thrown Error so the handler
227
+ * converts it to an `Error:` string.
228
+ */
229
+ var runInputPipeline = async (mw, ctx) => {
230
+ let reached = false;
231
+ let shortResult;
232
+ let caught;
233
+ await mw.runner().errorHandler(async (error) => {
234
+ caught = error;
235
+ }).finalHandler(async () => {
236
+ reached = true;
237
+ }).run((fn, next) => Promise.resolve(fn(ctx, next)));
238
+ if (caught !== void 0) if (isShortCircuit(caught)) shortResult = caught.result;
239
+ else throw caught;
240
+ else if (!reached) throw new Error("SearXNG input pipeline did not call next() and did not short-circuit.");
241
+ return shortResult;
242
+ };
243
+ /** Run the output pipeline; rethrow any stage error to the handler's try/catch. */
244
+ var runOutputPipeline = async (mw, ctx) => {
245
+ let reached = false;
246
+ let caught;
247
+ await mw.runner().errorHandler(async (error) => {
248
+ caught = error;
249
+ }).finalHandler(async () => {
250
+ reached = true;
251
+ }).run((fn, next) => Promise.resolve(fn(ctx, next)));
252
+ if (caught !== void 0) throw caught;
253
+ if (!reached) throw new Error("SearXNG output pipeline did not call next().");
254
+ };
255
+ //#endregion
256
+ Object.defineProperty(exports, "E_INVALID_SEARXNG_CONFIG", {
257
+ enumerable: true,
258
+ get: function() {
259
+ return E_INVALID_SEARXNG_CONFIG;
260
+ }
261
+ });
262
+ Object.defineProperty(exports, "createSearxngSearchTool", {
263
+ enumerable: true,
264
+ get: function() {
265
+ return createSearxngSearchTool;
266
+ }
267
+ });
268
+
269
+ //# sourceMappingURL=searxng-Bkrwhwhw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"searxng-Bkrwhwhw.js","names":[],"sources":["../src/batteries/tools/searxng/exceptions.ts","../src/batteries/tools/searxng/index.ts"],"sourcesContent":["/**\n * Battery-scoped exception constructors for the SearXNG search tool.\n *\n * @remarks\n * Battery-scoped exception classes owned by the SearXNG tool battery (not the ADK core). Minted\n * via `createException` from `@nhtio/adk/factories` and re-exported from the battery's barrel\n * (`@nhtio/adk/batteries/tools/searxng`). This file intentionally carries **no** `@module` tag:\n * it is an internal sibling relative-imported by `index.ts`, so it does not mint its own\n * `…/searxng/exceptions` entrypoint (whose `exceptions` leaf basename would collide with sibling\n * batteries under the `vite-plugin-dts` rolled-up `.d.ts` rule).\n */\n\nimport { createException } from '@nhtio/adk/factories'\n\n/**\n * Thrown when {@link createSearxngSearchTool} receives invalid configuration.\n *\n * @remarks\n * Fatal: config bugs (missing or unparseable `instanceUrl`) fail loud at factory-call time\n * rather than at the first search.\n */\nexport const E_INVALID_SEARXNG_CONFIG = createException<[string]>(\n 'E_INVALID_SEARXNG_CONFIG',\n 'Invalid SearXNG tool config: %s',\n 'E_INVALID_SEARXNG_CONFIG',\n 529,\n true\n)\n","/**\n * Factory for a configured SearXNG metasearch tool.\n *\n * @module @nhtio/adk/batteries/tools/searxng\n *\n * @remarks\n * Unlike the other bundled tool categories — every one of which exports a ready-made,\n * stateless `Tool` constant — the SearXNG battery exports a **factory**,\n * {@link createSearxngSearchTool}. A search tool has to talk to a *specific* SearXNG instance,\n * usually behind custom authentication, so it needs per-deployment configuration (a base URL\n * and headers) that cannot be baked in at module load.\n *\n * Because this module exports a factory rather than a `Tool` instance, it MUST NOT be\n * bulk-registered via `Object.values(batteries)`. Call the factory first, then register the\n * returned tool: `new ToolRegistry([createSearxngSearchTool({ instanceUrl })])`.\n *\n * @see https://docs.searxng.org/dev/search_api.html\n */\n\nimport { validator } from '@nhtio/validation'\nimport { Middleware } from '@nhtio/middleware'\nimport { isError, isObject } from '@nhtio/adk/guards'\nimport { E_INVALID_SEARXNG_CONFIG } from './exceptions'\nimport { Tool, SpooledJsonArtifact, type ArtifactConstructorResolver } from '@nhtio/adk/common'\nimport type { Schema } from '@nhtio/validation'\nimport type { NextFn } from '@nhtio/middleware'\n\nexport { E_INVALID_SEARXNG_CONFIG } from './exceptions'\n\n/** A static set of request headers (used for custom authentication). */\nexport type SearxngHeaders = Record<string, string>\n\n/**\n * A resolver returning request headers, sync or async. Use this form when the auth token is\n * refreshable — the resolver runs on every search, so a fresh token can be minted per call.\n */\nexport type SearxngHeadersResolver = () => SearxngHeaders | Promise<SearxngHeaders>\n\n/** The output shape the tool serialises. `either` lets the model pick per call. */\nexport type SearxngResultFormat = 'normalized' | 'raw' | 'either'\n\n/**\n * A single normalised SearXNG result. SearXNG result items are deliberately untyped upstream,\n * so every field except a best-effort `title`/`url` is optional.\n */\nexport interface SearxngResult {\n /** Result title, when the source engine provided one. */\n title?: string\n /** Result URL, when the source engine provided one. */\n url?: string\n /** Snippet / summary text for the result. */\n content?: string\n /** The SearXNG engine that produced this result (e.g. `google`, `duckduckgo`). */\n engine?: string\n /** Relevance score as reported by SearXNG (higher is more relevant). */\n score?: number\n /** Publication date, when the source engine exposed one (ISO-ish string, engine-dependent). */\n publishedDate?: string\n}\n\n/**\n * Mutable context handed to each input-pipeline stage **before** the HTTP request is sent.\n *\n * @remarks\n * Stages mutate this in place (onion `(ctx, next)` style) to adjust the outgoing request —\n * inject or rotate auth headers, force a language, rewrite the query — or call\n * {@link SearxngRequestContext.shortCircuit} to skip the fetch entirely (e.g. a cache hit).\n */\nexport interface SearxngRequestContext {\n /** The tool's name (read-only). */\n readonly toolName: string\n /** The search query. Mutable. */\n query: string\n /** Extra SearXNG query parameters (`categories`, `engines`, `language`, …). Mutable. */\n params: Record<string, string>\n /** Resolved request headers. Mutable — inject, redact, or rotate auth here. */\n headers: SearxngHeaders\n /** The target instance base URL (read-only). */\n readonly instanceUrl: string\n /** Cross-stage scratch space; also carried onto the response context. */\n readonly stash: Map<string, unknown>\n /** Skip the fetch and return `result` verbatim as the tool's output. */\n shortCircuit(result: string): void\n}\n\n/**\n * Mutable context handed to each output-pipeline stage **after** the response JSON is parsed.\n *\n * @remarks\n * Stages reshape, redact, enrich, or re-rank {@link SearxngResponseContext.results}, mutate the\n * raw body, or set {@link SearxngResponseContext.output} to override the serialised string\n * verbatim (e.g. to render markdown that matches a markdown `artifactConstructor`).\n */\nexport interface SearxngResponseContext {\n /** The tool's name (read-only). */\n readonly toolName: string\n /** The request context as it was sent (post-input-pipeline). */\n readonly request: SearxngRequestContext\n /** The parsed SearXNG JSON body. Mutable (used when `format` is `raw`). */\n raw: unknown\n /** The normalised result list. Mutable — filter, redact, or re-rank. */\n results: SearxngResult[]\n /** The effective payload shape for this call. */\n format: 'normalized' | 'raw'\n /** When set, used verbatim as the tool's output (overrides serialisation). */\n output?: string\n /** Cross-stage scratch space; carried over from the request context. */\n readonly stash: Map<string, unknown>\n}\n\n/** An input-pipeline stage. Onion middleware over {@link SearxngRequestContext}. */\nexport type SearxngInputMiddlewareFn = (\n ctx: SearxngRequestContext,\n next: NextFn\n) => void | Promise<void>\n\n/** An output-pipeline stage. Onion middleware over {@link SearxngResponseContext}. */\nexport type SearxngOutputMiddlewareFn = (\n ctx: SearxngResponseContext,\n next: NextFn\n) => void | Promise<void>\n\n/** Configuration for {@link createSearxngSearchTool}. */\nexport interface SearxngToolConfig {\n /** Base URL of the SearXNG instance, e.g. `https://searx.example.org`. Required. */\n instanceUrl: string\n /** Custom request headers — a static object or a (sync/async) resolver for refreshable auth. */\n headers?: SearxngHeaders | SearxngHeadersResolver\n /** Request timeout in milliseconds. Default `10_000`. */\n timeout?: number\n /**\n * Output shape. `normalized`/`raw` pin the shape (the model cannot change it); `either`\n * (default) exposes a `format` argument so the model chooses per call.\n */\n resultFormat?: SearxngResultFormat\n /** Tool name. Default `searxng_search`. */\n name?: string\n /** Tool description override. */\n description?: string\n /**\n * Spool artifact constructor for the tool's output. Default `() => SpooledJsonArtifact`.\n * Pass `() => SpooledMarkdownArtifact` (paired with an output stage that renders markdown into\n * `ctx.output`) or `() => SpooledArtifact` for plain text.\n */\n artifactConstructor?: ArtifactConstructorResolver\n /** Stages run before the HTTP request. See {@link SearxngRequestContext}. */\n inputPipeline?: SearxngInputMiddlewareFn[]\n /** Stages run after the response is parsed. See {@link SearxngResponseContext}. */\n outputPipeline?: SearxngOutputMiddlewareFn[]\n}\n\nconst DEFAULT_NAME = 'searxng_search'\nconst DEFAULT_TIMEOUT = 10_000\nconst DEFAULT_DESCRIPTION =\n 'Search the web via a SearXNG metasearch instance. Returns aggregated results (title, url, ' +\n 'snippet, source engine) plus any answers, infoboxes, and suggestions.'\n\n/** Internal sentinel a short-circuiting input stage throws to unwind the pipeline immediately. */\nconst SHORT_CIRCUIT = Symbol('searxng.shortCircuit')\n\ninterface ShortCircuitSignal {\n [SHORT_CIRCUIT]: true\n result: string\n}\n\nconst isShortCircuit = (value: unknown): value is ShortCircuitSignal =>\n isObject(value) && (value as Record<symbol, unknown>)[SHORT_CIRCUIT] === true\n\n/** Normalise a loose SearXNG result item into a {@link SearxngResult}. */\nconst normaliseResult = (raw: unknown): SearxngResult => {\n const r = (raw ?? {}) as Record<string, unknown>\n const out: SearxngResult = {}\n if (typeof r.title === 'string') out.title = r.title\n if (typeof r.url === 'string') out.url = r.url\n if (typeof r.content === 'string') out.content = r.content\n if (typeof r.engine === 'string') out.engine = r.engine\n if (typeof r.score === 'number') out.score = r.score\n if (typeof r.publishedDate === 'string') out.publishedDate = r.publishedDate\n return out\n}\n\n/** Resolve the configured headers (static object or resolver) for a single request. */\nconst resolveHeaders = async (headers: SearxngToolConfig['headers']): Promise<SearxngHeaders> => {\n if (typeof headers === 'function') return { ...(await headers()) }\n return { ...(headers ?? {}) }\n}\n\n/**\n * Create a configured SearXNG search {@link Tool}.\n *\n * @remarks\n * The handler always requests `format=json`. Note that SearXNG ships with JSON output\n * **disabled** by default (it is abused by bots); an instance that has not enabled\n * `search.formats: [json]` in its `settings.yml` answers with HTTP 403, which the tool returns\n * as a graceful `Error:` string naming the setting.\n *\n * @warning\n * Do not trust the `number_of_results` field for a result count — SearXNG frequently reports `0`\n * in JSON output even when `results` is non-empty. This is a long-standing upstream quirk, not a\n * tool defect (see {@link https://github.com/searxng/searxng/issues/2987 | searxng#2987} and\n * {@link https://github.com/searxng/searxng/issues/2457 | searxng#2457}). The tool passes the\n * field through verbatim; use `results.length` as the authoritative count.\n *\n * @param config - The instance URL, optional custom headers, output-format policy, artifact\n * type, and input/output middleware pipelines. See {@link SearxngToolConfig}.\n * @returns A `Tool` ready to register in a `ToolRegistry`.\n * @throws {@link E_INVALID_SEARXNG_CONFIG} when `instanceUrl` is missing or unparseable.\n */\nexport const createSearxngSearchTool = (config: SearxngToolConfig): Tool => {\n if (typeof config?.instanceUrl !== 'string' || config.instanceUrl.trim() === '') {\n throw new E_INVALID_SEARXNG_CONFIG(['instanceUrl is required'])\n }\n try {\n // Parse-validate only; the normalised string below is what we actually use.\n new URL(config.instanceUrl)\n } catch {\n throw new E_INVALID_SEARXNG_CONFIG([`instanceUrl is not a valid URL: ${config.instanceUrl}`])\n }\n // Normalise away a trailing slash so `new URL('/search', base)` resolves cleanly.\n const instanceUrl = config.instanceUrl.replace(/\\/+$/, '')\n\n const timeout = config.timeout ?? DEFAULT_TIMEOUT\n const resultFormat: SearxngResultFormat = config.resultFormat ?? 'either'\n const toolName = config.name ?? DEFAULT_NAME\n const artifactConstructor: ArtifactConstructorResolver =\n config.artifactConstructor ?? (() => SpooledJsonArtifact)\n\n // Stages are fixed at factory time; build the Middleware shells once. A fresh `.runner()` is\n // minted per invocation inside the handler (runners are single-use).\n const inputMw = new Middleware<SearxngInputMiddlewareFn>()\n for (const fn of config.inputPipeline ?? []) inputMw.add(fn)\n const outputMw = new Middleware<SearxngOutputMiddlewareFn>()\n for (const fn of config.outputPipeline ?? []) outputMw.add(fn)\n const hasInput = (config.inputPipeline ?? []).length > 0\n const hasOutput = (config.outputPipeline ?? []).length > 0\n\n // Build the input schema, conditionally exposing `format` only when the factory is neutral.\n const schemaShape: Record<string, Schema> = {\n query: validator.string().required().description('The search query.'),\n categories: validator\n .string()\n .optional()\n .description('Comma-separated SearXNG categories (e.g. \"general,news\").'),\n engines: validator\n .string()\n .optional()\n .description('Comma-separated SearXNG engines (e.g. \"google,duckduckgo\").'),\n language: validator.string().optional().description('Language code (e.g. \"en\", \"de\").'),\n pageno: validator.number().min(1).default(1).description('Result page number (1-based).'),\n time_range: validator\n .string()\n .valid('day', 'month', 'year')\n .optional()\n .description('Restrict results to a time range.'),\n safesearch: validator\n .number()\n .valid(0, 1, 2)\n .optional()\n .description('Safe-search level: 0 (off), 1 (moderate), 2 (strict).'),\n }\n if (resultFormat === 'either') {\n schemaShape.format = validator\n .string()\n .valid('normalized', 'raw')\n .default('normalized')\n .description('Output shape: \"normalized\" (trimmed) or \"raw\" (full SearXNG JSON).')\n }\n const inputSchema = validator.object(schemaShape)\n\n return new Tool({\n name: toolName,\n description: config.description ?? DEFAULT_DESCRIPTION,\n inputSchema,\n artifactConstructor,\n handler: async (args) => {\n const a = args as {\n query: string\n categories?: string\n engines?: string\n language?: string\n pageno?: number\n time_range?: string\n safesearch?: number\n format?: 'normalized' | 'raw'\n }\n\n try {\n // 1. Effective output format: a pinned factory format wins; else the model's choice.\n const format: 'normalized' | 'raw' =\n resultFormat === 'either' ? (a.format ?? 'normalized') : resultFormat\n\n // 2. Resolve headers, merged over portable defaults (caller headers win).\n const headers: SearxngHeaders = {\n 'Accept': 'application/json',\n 'User-Agent': 'adk-searxng-tool',\n ...(await resolveHeaders(config.headers)),\n }\n\n // 3. Assemble the SearXNG query params from validated args.\n const params: Record<string, string> = {}\n if (a.categories) params.categories = a.categories\n if (a.engines) params.engines = a.engines\n if (a.language) params.language = a.language\n if (a.pageno && a.pageno !== 1) params.pageno = String(a.pageno)\n if (a.time_range) params.time_range = a.time_range\n if (typeof a.safesearch === 'number') params.safesearch = String(a.safesearch)\n\n const stash = new Map<string, unknown>()\n\n // 4. Run the input pipeline (fresh runner) over a mutable request context.\n const requestCtx: SearxngRequestContext = {\n toolName,\n query: a.query,\n params,\n headers,\n instanceUrl,\n stash,\n shortCircuit: (result: string) => {\n const signal: ShortCircuitSignal = { [SHORT_CIRCUIT]: true, result }\n throw signal\n },\n }\n\n if (hasInput) {\n const short = await runInputPipeline(inputMw, requestCtx)\n if (short !== undefined) return short\n }\n\n // 5. Build the request URL from the (possibly mutated) query + params.\n const url = new URL('/search', instanceUrl + '/')\n url.searchParams.set('q', requestCtx.query)\n for (const [k, v] of Object.entries(requestCtx.params)) url.searchParams.set(k, v)\n url.searchParams.set('format', 'json')\n\n // 6. Fetch with an AbortController timeout.\n const controller = new AbortController()\n const timer = setTimeout(() => controller.abort(), timeout)\n let response: Response\n try {\n response = await fetch(url, {\n method: 'GET',\n headers: requestCtx.headers,\n signal: controller.signal,\n })\n } finally {\n clearTimeout(timer)\n }\n\n if (!response.ok) {\n if (response.status === 403) {\n return (\n `Error: SearXNG returned 403 Forbidden. The instance likely has the JSON output ` +\n `format disabled — enable it under \"search.formats: [json]\" in its settings.yml.`\n )\n }\n return `Error: SearXNG returned HTTP ${response.status} ${response.statusText}.`\n }\n\n const body = (await response.json()) as Record<string, unknown>\n\n // 7. Run the output pipeline (fresh runner) over a mutable response context.\n const responseCtx: SearxngResponseContext = {\n toolName,\n request: requestCtx,\n raw: body,\n results: Array.isArray(body.results) ? body.results.map(normaliseResult) : [],\n format,\n stash,\n }\n\n if (hasOutput) await runOutputPipeline(outputMw, responseCtx)\n\n // 8. Serialise and return.\n if (typeof responseCtx.output === 'string') return responseCtx.output\n if (responseCtx.format === 'raw') return JSON.stringify(responseCtx.raw, null, 2)\n return JSON.stringify(buildNormalisedPayload(responseCtx), null, 2)\n } catch (err) {\n if (isShortCircuit(err)) return err.result\n return `Error: ${isError(err) ? err.message : String(err)}`\n }\n },\n })\n}\n\n/** Assemble the trimmed normalised payload, dropping empty aggregate arrays. */\nconst buildNormalisedPayload = (ctx: SearxngResponseContext): Record<string, unknown> => {\n const raw = (ctx.raw ?? {}) as Record<string, unknown>\n const payload: Record<string, unknown> = {\n query: typeof raw.query === 'string' ? raw.query : ctx.request.query,\n results: ctx.results,\n }\n // NOTE: SearXNG's `number_of_results` is frequently `0` in JSON output even when `results`\n // is non-empty — a long-standing upstream quirk, not a tool bug (see\n // https://github.com/searxng/searxng/issues/2987 and\n // https://github.com/searxng/searxng/issues/2457). We pass through whatever the instance\n // reports; treat `results.length` as the authoritative count, not this field.\n if (typeof raw.number_of_results === 'number') payload.number_of_results = raw.number_of_results\n for (const key of ['answers', 'infoboxes', 'suggestions', 'corrections'] as const) {\n const value = raw[key]\n if (Array.isArray(value) && value.length > 0) payload[key] = value\n }\n return payload\n}\n\n/**\n * Run the input pipeline. Returns the short-circuit string when a stage short-circuited, or\n * `undefined` when the pipeline reached its terminal handler. A non-terminal pipeline (a stage\n * that neither called `next()` nor short-circuited) is surfaced as a thrown Error so the handler\n * converts it to an `Error:` string.\n */\nconst runInputPipeline = async (\n mw: Middleware<SearxngInputMiddlewareFn>,\n ctx: SearxngRequestContext\n): Promise<string | undefined> => {\n let reached = false\n let shortResult: string | undefined\n let caught: unknown\n await mw\n .runner()\n .errorHandler(async (error: unknown) => {\n caught = error\n })\n .finalHandler(async () => {\n reached = true\n })\n .run((fn, next) => Promise.resolve(fn(ctx, next)))\n\n if (caught !== undefined) {\n if (isShortCircuit(caught)) {\n shortResult = caught.result\n } else {\n throw caught\n }\n } else if (!reached) {\n throw new Error('SearXNG input pipeline did not call next() and did not short-circuit.')\n }\n return shortResult\n}\n\n/** Run the output pipeline; rethrow any stage error to the handler's try/catch. */\nconst runOutputPipeline = async (\n mw: Middleware<SearxngOutputMiddlewareFn>,\n ctx: SearxngResponseContext\n): Promise<void> => {\n let reached = false\n let caught: unknown\n await mw\n .runner()\n .errorHandler(async (error: unknown) => {\n caught = error\n })\n .finalHandler(async () => {\n reached = true\n })\n .run((fn, next) => Promise.resolve(fn(ctx, next)))\n\n if (caught !== undefined) throw caught\n if (!reached) {\n throw new Error('SearXNG output pipeline did not call next().')\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBA,IAAa,2BAA2B,mBAAA,gBACtC,4BACA,mCACA,4BACA,KACA,IACF;;;;;;;;;;;;;;;;;;;;;AC4HA,IAAM,eAAe;AACrB,IAAM,kBAAkB;AACxB,IAAM,sBACJ;;AAIF,IAAM,gBAAgB,OAAO,sBAAsB;AAOnD,IAAM,kBAAkB,UACtB,sBAAA,SAAS,KAAK,KAAM,MAAkC,mBAAmB;;AAG3E,IAAM,mBAAmB,QAAgC;CACvD,MAAM,IAAK,OAAO,CAAC;CACnB,MAAM,MAAqB,CAAC;CAC5B,IAAI,OAAO,EAAE,UAAU,UAAU,IAAI,QAAQ,EAAE;CAC/C,IAAI,OAAO,EAAE,QAAQ,UAAU,IAAI,MAAM,EAAE;CAC3C,IAAI,OAAO,EAAE,YAAY,UAAU,IAAI,UAAU,EAAE;CACnD,IAAI,OAAO,EAAE,WAAW,UAAU,IAAI,SAAS,EAAE;CACjD,IAAI,OAAO,EAAE,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