@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,6 +1,6 @@
1
- import { o as isError } from "../../tool_registry-D1pSSlsd.mjs";
2
- import { t as Tool } from "../../tool-CMhaDRNd.mjs";
3
- import "../../common-BT0nfCi9.mjs";
1
+ import { c as isObject, o as isError } from "../../tool_registry-791Vrjtf.mjs";
2
+ import { t as Tool } from "../../tool-wMYMVl60.mjs";
3
+ import "../../common-DYDUi99O.mjs";
4
4
  import "../../guards.mjs";
5
5
  import { validator } from "@nhtio/validation";
6
6
  //#region src/batteries/tools/structured_data/index.ts
@@ -49,29 +49,24 @@ var formatTableTool = new Tool({
49
49
  }
50
50
  if (!Array.isArray(rows)) return "Error: Input must be a JSON array.";
51
51
  if (rows.length === 0) return "Empty array — no data to display.";
52
+ if (!explicitColumns && !isObject(rows[0])) return "Error: Cannot infer columns — the first row is not an object. Provide \"columns\", or pass an array of objects.";
52
53
  const columns = explicitColumns ?? Object.keys(rows[0]);
54
+ const cell = (row, col) => isObject(row) ? row[col] : void 0;
53
55
  if (format === "csv") {
54
56
  const lines = [columns.map(csvEscape).join(",")];
55
- for (const row of rows) {
56
- const obj = row;
57
- lines.push(columns.map((col) => csvEscape(obj[col])).join(","));
58
- }
57
+ for (const row of rows) lines.push(columns.map((col) => csvEscape(cell(row, col))).join(","));
59
58
  return lines.join("\n");
60
59
  }
61
60
  if (format === "tsv") {
62
61
  const lines = [columns.map(tsvEscape).join(" ")];
63
- for (const row of rows) {
64
- const obj = row;
65
- lines.push(columns.map((col) => tsvEscape(obj[col])).join(" "));
66
- }
62
+ for (const row of rows) lines.push(columns.map((col) => tsvEscape(cell(row, col))).join(" "));
67
63
  return lines.join("\n");
68
64
  }
69
65
  return [
70
66
  "| " + columns.map(mdEscape).join(" | ") + " |",
71
67
  "| " + columns.map(() => "---").join(" | ") + " |",
72
68
  ...rows.map((row) => {
73
- const obj = row;
74
- return "| " + columns.map((col) => mdEscape(obj[col])).join(" | ") + " |";
69
+ return "| " + columns.map((col) => mdEscape(cell(row, col))).join(" | ") + " |";
75
70
  })
76
71
  ].join("\n");
77
72
  }
@@ -1 +1 @@
1
- {"version":3,"file":"structured_data.mjs","names":[],"sources":["../../../src/batteries/tools/structured_data/index.ts"],"sourcesContent":["/**\n * Pre-constructed tools for transforming arrays and objects into tables and tabular text.\n *\n * @module @nhtio/adk/batteries/tools/structured_data\n *\n * @remarks\n * Pre-constructed bundled tools for the `structured_data` category. Import individually, the whole\n * category, or import every tool via `@nhtio/adk/batteries`.\n */\n\nimport { Tool } from '@nhtio/adk/common'\nimport { isError } from '@nhtio/adk/guards'\nimport { validator } from '@nhtio/validation'\n\nfunction csvEscape(value: unknown): string {\n const str = value === null || value === undefined ? '' : String(value)\n if (str.includes(',') || str.includes('\"') || str.includes('\\n') || str.includes('\\r')) {\n return '\"' + str.replace(/\"/g, '\"\"') + '\"'\n }\n return str\n}\n\nfunction tsvEscape(value: unknown): string {\n const str = value === null || value === undefined ? '' : String(value)\n return str.replace(/\\t/g, ' ').replace(/\\r?\\n/g, ' ')\n}\n\nfunction mdEscape(value: unknown): string {\n return String(value === null || value === undefined ? '' : value)\n .replace(/\\|/g, '\\\\|')\n .replace(/\\r?\\n/g, ' ')\n}\n\n/**\n * Convert a JSON array of objects into a formatted table.\n *\n * @remarks\n * Supports `markdown`, `csv`, and `tsv` output. Columns default to the keys of the first row;\n * supply `columns` to control which keys appear and in what order.\n */\nexport const formatTableTool = new Tool({\n name: 'format_table',\n description:\n 'Convert a JSON array of objects into a formatted table. Supports Markdown, CSV, and TSV output.',\n inputSchema: validator.object({\n data: validator.string().required().description('JSON array of objects as a string'),\n format: validator\n .string()\n .valid('markdown', 'csv', 'tsv')\n .required()\n .description('Output format'),\n columns: validator\n .array()\n .items(validator.string())\n .optional()\n .description(\n 'Column keys to include, in order. If omitted, all keys from the first row are used.'\n ),\n }),\n handler: async (args) => {\n const {\n data,\n format,\n columns: explicitColumns,\n } = args as {\n data: string\n format: 'markdown' | 'csv' | 'tsv'\n columns?: string[]\n }\n\n let rows: unknown[]\n try {\n rows = JSON.parse(data)\n } catch {\n return 'Error: Invalid JSON input.'\n }\n\n if (!Array.isArray(rows)) return 'Error: Input must be a JSON array.'\n if (rows.length === 0) return 'Empty array — no data to display.'\n\n const columns = explicitColumns ?? Object.keys(rows[0] as Record<string, unknown>)\n\n if (format === 'csv') {\n const lines = [columns.map(csvEscape).join(',')]\n for (const row of rows) {\n const obj = row as Record<string, unknown>\n lines.push(columns.map((col) => csvEscape(obj[col])).join(','))\n }\n return lines.join('\\n')\n }\n\n if (format === 'tsv') {\n const lines = [columns.map(tsvEscape).join('\\t')]\n for (const row of rows) {\n const obj = row as Record<string, unknown>\n lines.push(columns.map((col) => tsvEscape(obj[col])).join('\\t'))\n }\n return lines.join('\\n')\n }\n\n const header = '| ' + columns.map(mdEscape).join(' | ') + ' |'\n const separator = '| ' + columns.map(() => '---').join(' | ') + ' |'\n const dataRows = rows.map((row) => {\n const obj = row as Record<string, unknown>\n return '| ' + columns.map((col) => mdEscape(obj[col])).join(' | ') + ' |'\n })\n return [header, separator, ...dataRows].join('\\n')\n },\n})\n\n/**\n * Pretty-print or minify a JSON string.\n *\n * @remarks\n * Validates the input as JSON, then re-serialises it with the requested indentation. `indent` is\n * clamped to the range [0, 8]; `0` produces minified output.\n */\nexport const jsonFormatTool = new Tool({\n name: 'json_format',\n description: 'Pretty-print or minify a JSON string. Validates JSON and normalises whitespace.',\n inputSchema: validator.object({\n data: validator.string().required().description('JSON string to format'),\n indent: validator\n .number()\n .default(2)\n .description('Indentation spaces (0 = minify, default: 2). Max: 8.'),\n }),\n handler: async (args) => {\n const { data, indent } = args as { data: string; indent: number }\n try {\n const parsed = JSON.parse(data)\n return JSON.stringify(parsed, null, Math.max(0, Math.min(8, Math.floor(indent))))\n } catch (err) {\n return `Error: Invalid JSON — ${isError(err) ? err.message : String(err)}`\n }\n },\n})\n\nconst FORMAT_PATTERNS: Record<string, { pattern: RegExp; label: string }> = {\n email: {\n pattern: /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/,\n label: 'email address',\n },\n uuid: {\n pattern: /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,\n label: 'UUID (v1–v5)',\n },\n ipv4: {\n pattern: /^((25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)$/,\n label: 'IPv4 address',\n },\n iso_date: {\n pattern: /^\\d{4}-\\d{2}-\\d{2}$/,\n label: 'ISO 8601 date (YYYY-MM-DD)',\n },\n iso_datetime: {\n pattern: /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})?$/,\n label: 'ISO 8601 datetime',\n },\n hex_color: {\n pattern: /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/,\n label: 'CSS hex color',\n },\n phone_e164: {\n pattern: /^\\+[1-9]\\d{1,14}$/,\n label: 'E.164 phone number',\n },\n semver: {\n pattern: /^\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z-.]+)?(\\+[0-9A-Za-z-.]+)?$/,\n label: 'Semantic Version (SemVer)',\n },\n integer: {\n pattern: /^-?\\d+$/,\n label: 'integer',\n },\n decimal: {\n pattern: /^-?\\d+(\\.\\d+)?$/,\n label: 'decimal number',\n },\n alphanumeric: {\n pattern: /^[a-zA-Z0-9]+$/,\n label: 'alphanumeric string',\n },\n slug: {\n pattern: /^[a-z0-9]+(-[a-z0-9]+)*$/,\n label: 'URL slug',\n },\n hex: {\n pattern: /^(0x)?[0-9a-fA-F]+$/,\n label: 'hexadecimal string',\n },\n base64: {\n pattern: /^[A-Za-z0-9+/]*={0,2}$/,\n label: 'base64-encoded string',\n },\n}\n\n/**\n * Check whether a string matches a known format.\n *\n * @remarks\n * Supported formats: `email`, `uuid` (v1–v5), `ipv4`, `iso_date`, `iso_datetime`, `hex_color`,\n * `phone_e164`, `semver`, `integer`, `decimal`, `alphanumeric`, `slug`, `hex`, `base64`.\n */\nexport const validateFormatTool = new Tool({\n name: 'validate_format',\n description:\n 'Check whether a string matches a known format (email, UUID, ISO date, hex colour, phone number, semver, slug, etc.).',\n inputSchema: validator.object({\n value: validator.string().required().description('The string to validate'),\n format: validator\n .string()\n .valid(...Object.keys(FORMAT_PATTERNS))\n .required()\n .description(\n `Format to validate against. One of: ${Object.keys(FORMAT_PATTERNS).join(', ')}`\n ),\n }),\n handler: async (args) => {\n const { value, format } = args as { value: string; format: string }\n const def = FORMAT_PATTERNS[format]\n if (!def) {\n return `Error: Unknown format \"${format}\". Supported: ${Object.keys(FORMAT_PATTERNS).join(', ')}`\n }\n const valid = def.pattern.test(value)\n return valid\n ? `Valid: \"${value}\" is a valid ${def.label}.`\n : `Invalid: \"${value}\" is not a valid ${def.label}.`\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;AAcA,SAAS,UAAU,OAAwB;CACzC,MAAM,MAAM,UAAU,QAAQ,UAAU,KAAA,IAAY,KAAK,OAAO,KAAK;CACrE,IAAI,IAAI,SAAS,GAAG,KAAK,IAAI,SAAS,IAAG,KAAK,IAAI,SAAS,IAAI,KAAK,IAAI,SAAS,IAAI,GACnF,OAAO,OAAM,IAAI,QAAQ,MAAM,MAAI,IAAI;CAEzC,OAAO;AACT;AAEA,SAAS,UAAU,OAAwB;CA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A,WAAW;EACT,SAAS;EACT,OAAO;CACT;CACA,YAAY;EACV,SAAS;EACT,OAAO;CACT;CACA,QAAQ;EACN,SAAS;EACT,OAAO;CACT;CACA,SAAS;EACP,SAAS;EACT,OAAO;CACT;CACA,SAAS;EACP,SAAS;EACT,OAAO;CACT;CACA,cAAc;EACZ,SAAS;EACT,OAAO;CACT;CACA,MAAM;EACJ,SAAS;EACT,OAAO;CACT;CACA,KAAK;EACH,SAAS;EACT,OAAO;CACT;CACA,QAAQ;EACN,SAAS;EACT,OAAO;CACT;AACF;;;;;;;;AASA,IAAa,qBAAqB,IAAI,KAAK;CACzC,MAAM;CACN,aACE;CACF,aAAa,UAAU,OAAO;EAC5B,OAAO,UAAU,OAAO,EAAE,SAAS,EAAE,YAAY,wBAAwB;EACzE,QAAQ,UACL,OAAO,EACP,MAAM,GAAG,OAAO,KAAK,eAAe,CAAC,EACrC,SAAS,EACT,YACC,uCAAuC,OAAO,KAAK,eAAe,EAAE,KAAK,IAAI,GAC/E;CACJ,CAAC;CACD,SAAS,OAAO,SAAS;EACvB,MAAM,EAAE,OAAO,WAAW;EAC1B,MAAM,MAAM,gBAAgB;EAC5B,IAAI,CAAC,KACH,OAAO,0BAA0B,OAAO,gBAAgB,OAAO,KAAK,eAAe,EAAE,KAAK,IAAI;EAGhG,OADc,IAAI,QAAQ,KAAK,KACxB,IACH,WAAW,MAAM,eAAe,IAAI,MAAM,KAC1C,aAAa,MAAM,mBAAmB,IAAI,MAAM;CACtD;AACF,CAAC"}
1
+ {"version":3,"file":"structured_data.mjs","names":[],"sources":["../../../src/batteries/tools/structured_data/index.ts"],"sourcesContent":["/**\n * Pre-constructed tools for transforming arrays and objects into tables and tabular text.\n *\n * @module @nhtio/adk/batteries/tools/structured_data\n *\n * @remarks\n * Pre-constructed bundled tools for the `structured_data` category. Import individually, the whole\n * category, or import every tool via `@nhtio/adk/batteries`.\n */\n\nimport { Tool } from '@nhtio/adk/common'\nimport { validator } from '@nhtio/validation'\nimport { isError, isObject } from '@nhtio/adk/guards'\n\nfunction csvEscape(value: unknown): string {\n const str = value === null || value === undefined ? '' : String(value)\n if (str.includes(',') || str.includes('\"') || str.includes('\\n') || str.includes('\\r')) {\n return '\"' + str.replace(/\"/g, '\"\"') + '\"'\n }\n return str\n}\n\nfunction tsvEscape(value: unknown): string {\n const str = value === null || value === undefined ? '' : String(value)\n return str.replace(/\\t/g, ' ').replace(/\\r?\\n/g, ' ')\n}\n\nfunction mdEscape(value: unknown): string {\n return String(value === null || value === undefined ? '' : value)\n .replace(/\\|/g, '\\\\|')\n .replace(/\\r?\\n/g, ' ')\n}\n\n/**\n * Convert a JSON array of objects into a formatted table.\n *\n * @remarks\n * Supports `markdown`, `csv`, and `tsv` output. Columns default to the keys of the first row;\n * supply `columns` to control which keys appear and in what order.\n */\nexport const formatTableTool = new Tool({\n name: 'format_table',\n description:\n 'Convert a JSON array of objects into a formatted table. Supports Markdown, CSV, and TSV output.',\n inputSchema: validator.object({\n data: validator.string().required().description('JSON array of objects as a string'),\n format: validator\n .string()\n .valid('markdown', 'csv', 'tsv')\n .required()\n .description('Output format'),\n columns: validator\n .array()\n .items(validator.string())\n .optional()\n .description(\n 'Column keys to include, in order. If omitted, all keys from the first row are used.'\n ),\n }),\n handler: async (args) => {\n const {\n data,\n format,\n columns: explicitColumns,\n } = args as {\n data: string\n format: 'markdown' | 'csv' | 'tsv'\n columns?: string[]\n }\n\n let rows: unknown[]\n try {\n rows = JSON.parse(data)\n } catch {\n return 'Error: Invalid JSON input.'\n }\n\n if (!Array.isArray(rows)) return 'Error: Input must be a JSON array.'\n if (rows.length === 0) return 'Empty array — no data to display.'\n\n // Columns default to the first row's keys, but only an object row has keys. If columns aren't\n // given and the first row isn't an object, there's nothing to tabulate — error clearly rather\n // than throwing on `Object.keys(null)`.\n if (!explicitColumns && !isObject(rows[0])) {\n return 'Error: Cannot infer columns — the first row is not an object. Provide \"columns\", or pass an array of objects.'\n }\n const columns = explicitColumns ?? Object.keys(rows[0] as Record<string, unknown>)\n\n // Read a cell safely: a null/primitive row has no properties, so it yields empty cells rather\n // than throwing on `row[col]`.\n const cell = (row: unknown, col: string): unknown =>\n isObject(row) ? (row as Record<string, unknown>)[col] : undefined\n\n if (format === 'csv') {\n const lines = [columns.map(csvEscape).join(',')]\n for (const row of rows) {\n lines.push(columns.map((col) => csvEscape(cell(row, col))).join(','))\n }\n return lines.join('\\n')\n }\n\n if (format === 'tsv') {\n const lines = [columns.map(tsvEscape).join('\\t')]\n for (const row of rows) {\n lines.push(columns.map((col) => tsvEscape(cell(row, col))).join('\\t'))\n }\n return lines.join('\\n')\n }\n\n const header = '| ' + columns.map(mdEscape).join(' | ') + ' |'\n const separator = '| ' + columns.map(() => '---').join(' | ') + ' |'\n const dataRows = rows.map((row) => {\n return '| ' + columns.map((col) => mdEscape(cell(row, col))).join(' | ') + ' |'\n })\n return [header, separator, ...dataRows].join('\\n')\n },\n})\n\n/**\n * Pretty-print or minify a JSON string.\n *\n * @remarks\n * Validates the input as JSON, then re-serialises it with the requested indentation. `indent` is\n * clamped to the range [0, 8]; `0` produces minified output.\n */\nexport const jsonFormatTool = new Tool({\n name: 'json_format',\n description: 'Pretty-print or minify a JSON string. Validates JSON and normalises whitespace.',\n inputSchema: validator.object({\n data: validator.string().required().description('JSON string to format'),\n indent: validator\n .number()\n .default(2)\n .description('Indentation spaces (0 = minify, default: 2). Max: 8.'),\n }),\n handler: async (args) => {\n const { data, indent } = args as { data: string; indent: number }\n try {\n const parsed = JSON.parse(data)\n return JSON.stringify(parsed, null, Math.max(0, Math.min(8, Math.floor(indent))))\n } catch (err) {\n return `Error: Invalid JSON — ${isError(err) ? err.message : String(err)}`\n }\n },\n})\n\nconst FORMAT_PATTERNS: Record<string, { pattern: RegExp; label: string }> = {\n email: {\n pattern: /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/,\n label: 'email address',\n },\n uuid: {\n pattern: /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i,\n label: 'UUID (v1–v5)',\n },\n ipv4: {\n pattern: /^((25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)$/,\n label: 'IPv4 address',\n },\n iso_date: {\n pattern: /^\\d{4}-\\d{2}-\\d{2}$/,\n label: 'ISO 8601 date (YYYY-MM-DD)',\n },\n iso_datetime: {\n pattern: /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:\\d{2})?$/,\n label: 'ISO 8601 datetime',\n },\n hex_color: {\n pattern: /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/,\n label: 'CSS hex color',\n },\n phone_e164: {\n pattern: /^\\+[1-9]\\d{1,14}$/,\n label: 'E.164 phone number',\n },\n semver: {\n pattern: /^\\d+\\.\\d+\\.\\d+(-[0-9A-Za-z-.]+)?(\\+[0-9A-Za-z-.]+)?$/,\n label: 'Semantic Version (SemVer)',\n },\n integer: {\n pattern: /^-?\\d+$/,\n label: 'integer',\n },\n decimal: {\n pattern: /^-?\\d+(\\.\\d+)?$/,\n label: 'decimal number',\n },\n alphanumeric: {\n pattern: /^[a-zA-Z0-9]+$/,\n label: 'alphanumeric string',\n },\n slug: {\n pattern: /^[a-z0-9]+(-[a-z0-9]+)*$/,\n label: 'URL slug',\n },\n hex: {\n pattern: /^(0x)?[0-9a-fA-F]+$/,\n label: 'hexadecimal string',\n },\n base64: {\n pattern: /^[A-Za-z0-9+/]*={0,2}$/,\n label: 'base64-encoded string',\n },\n}\n\n/**\n * Check whether a string matches a known format.\n *\n * @remarks\n * Supported formats: `email`, `uuid` (v1–v5), `ipv4`, `iso_date`, `iso_datetime`, `hex_color`,\n * `phone_e164`, `semver`, `integer`, `decimal`, `alphanumeric`, `slug`, `hex`, `base64`.\n */\nexport const validateFormatTool = new Tool({\n name: 'validate_format',\n description:\n 'Check whether a string matches a known format (email, UUID, ISO date, hex colour, phone number, semver, slug, etc.).',\n inputSchema: validator.object({\n value: validator.string().required().description('The string to validate'),\n format: validator\n .string()\n .valid(...Object.keys(FORMAT_PATTERNS))\n .required()\n .description(\n `Format to validate against. One of: ${Object.keys(FORMAT_PATTERNS).join(', ')}`\n ),\n }),\n handler: async (args) => {\n const { value, format } = args as { value: string; format: string }\n const def = FORMAT_PATTERNS[format]\n if (!def) {\n return `Error: Unknown format \"${format}\". Supported: ${Object.keys(FORMAT_PATTERNS).join(', ')}`\n }\n const valid = def.pattern.test(value)\n return valid\n ? `Valid: \"${value}\" is a valid ${def.label}.`\n : `Invalid: \"${value}\" is not a valid ${def.label}.`\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;AAcA,SAAS,UAAU,OAAwB;CACzC,MAAM,MAAM,UAAU,QAAQ,UAAU,KAAA,IAAY,KAAK,OAAO,KAAK;CACrE,IAAI,IAAI,SAAS,GAAG,KAAK,IAAI,SAAS,IAAG,KAAK,IAAI,SAAS,IAAI,KAAK,IAAI,SAAS,IAAI,GACnF,OAAO,OAAM,IAAI,QAAQ,MAAM,MAAI,IAAI;CAEzC,OAAO;AACT;AAEA,SAAS,UAAU,OAAwB;CAEzC,QADY,UAAU,QAAQ,UAAU,KAAA,IAAY,KAAK,OAAO,KAAK,GAC1D,QAAQ,OAAO,GAAG,EAAE,QAAQ,UAAU,GAAG;AACtD;AAEA,SAAS,SAAS,OAAwB;CACxC,OAAO,OAAO,UAAU,QAAQ,UAAU,KAAA,IAAY,KAAK,KAAK,EAC7D,QAAQ,OAAO,KAAK,EACpB,QAAQ,UAAU,GAAG;AAC1B;;;;;;;;AASA,IAAa,kBAAkB,IAAI,KAAK;CACtC,MAAM;CACN,aACE;CACF,aAAa,UAAU,OAAO;EAC5B,MAAM,UAAU,OAAO,EAAE,SAAS,EAAE,YAAY,mCAAmC;EACnF,QAAQ,UACL,OAAO,EACP,MAAM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;;;;;;;;AASA,IAAa,qBAAqB,IAAI,KAAK;CACzC,MAAM;CACN,aACE;CACF,aAAa,UAAU,OAAO;EAC5B,OAAO,UAAU,OAAO,EAAE,SAAS,EAAE,YAAY,wBAAwB;EACzE,QAAQ,UACL,OAAO,EACP,MAAM,GAAG,OAAO,KAAK,eAAe,CAAC,EACrC,SAAS,EACT,YACC,uCAAuC,OAAO,KAAK,eAAe,EAAE,KAAK,IAAI,GAC/E;CACJ,CAAC;CACD,SAAS,OAAO,SAAS;EACvB,MAAM,EAAE,OAAO,WAAW;EAC1B,MAAM,MAAM,gBAAgB;EAC5B,IAAI,CAAC,KACH,OAAO,0BAA0B,OAAO,gBAAgB,OAAO,KAAK,eAAe,EAAE,KAAK,IAAI;EAGhG,OADc,IAAI,QAAQ,KAAK,KACxB,IACH,WAAW,MAAM,eAAe,IAAI,MAAM,KAC1C,aAAa,MAAM,mBAAmB,IAAI,MAAM;CACtD;AACF,CAAC"}
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("../../chunk-Ble4zEEl.js");
3
- const require_tool = require("../../tool-CVyZkFC7.js");
4
- require("../../common-Cj8TaQ9U.js");
5
- const require_spooled_markdown_artifact = require("../../spooled_markdown_artifact-CALSDxIx.js");
3
+ const require_tool = require("../../tool-D5WGVIcI.js");
4
+ require("../../common-DZl3ADJs.js");
5
+ const require_spooled_markdown_artifact = require("../../spooled_markdown_artifact-ClX72lek.js");
6
6
  let _nhtio_validation = require("@nhtio/validation");
7
7
  //#region src/batteries/tools/text_analysis/index.ts
8
8
  /**
@@ -1,6 +1,6 @@
1
- import { t as Tool } from "../../tool-CMhaDRNd.mjs";
2
- import "../../common-BT0nfCi9.mjs";
3
- import { n as SpooledJsonArtifact } from "../../spooled_markdown_artifact-Ci5UL7l4.mjs";
1
+ import { t as Tool } from "../../tool-wMYMVl60.mjs";
2
+ import "../../common-DYDUi99O.mjs";
3
+ import { n as SpooledJsonArtifact } from "../../spooled_markdown_artifact-wkrBF3oX.mjs";
4
4
  import { validator } from "@nhtio/validation";
5
5
  //#region src/batteries/tools/text_analysis/index.ts
6
6
  /**
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("../../chunk-Ble4zEEl.js");
3
- const require_tool = require("../../tool-CVyZkFC7.js");
4
- require("../../common-Cj8TaQ9U.js");
3
+ const require_tool = require("../../tool-D5WGVIcI.js");
4
+ require("../../common-DZl3ADJs.js");
5
5
  let _nhtio_validation = require("@nhtio/validation");
6
6
  let diff = require("diff");
7
7
  let fastest_levenshtein = require("fastest-levenshtein");
@@ -1,5 +1,5 @@
1
- import { t as Tool } from "../../tool-CMhaDRNd.mjs";
2
- import "../../common-BT0nfCi9.mjs";
1
+ import { t as Tool } from "../../tool-wMYMVl60.mjs";
2
+ import "../../common-DYDUi99O.mjs";
3
3
  import { validator } from "@nhtio/validation";
4
4
  import { diffLines, diffWords } from "diff";
5
5
  import { distance } from "fastest-levenshtein";
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("../../chunk-Ble4zEEl.js");
3
- const require_tool = require("../../tool-CVyZkFC7.js");
4
- require("../../common-Cj8TaQ9U.js");
3
+ const require_tool = require("../../tool-D5WGVIcI.js");
4
+ require("../../common-DZl3ADJs.js");
5
5
  let _nhtio_validation = require("@nhtio/validation");
6
6
  let luxon = require("luxon");
7
7
  //#region src/batteries/tools/time/index.ts
@@ -1,5 +1,5 @@
1
- import { t as Tool } from "../../tool-CMhaDRNd.mjs";
2
- import "../../common-BT0nfCi9.mjs";
1
+ import { t as Tool } from "../../tool-wMYMVl60.mjs";
2
+ import "../../common-DYDUi99O.mjs";
3
3
  import { validator } from "@nhtio/validation";
4
4
  import { DateTime, IANAZone } from "luxon";
5
5
  //#region src/batteries/tools/time/index.ts
@@ -1,7 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("../../chunk-Ble4zEEl.js");
3
- const require_tool = require("../../tool-CVyZkFC7.js");
4
- require("../../common-Cj8TaQ9U.js");
3
+ const require_tool = require("../../tool-D5WGVIcI.js");
4
+ require("../../common-DZl3ADJs.js");
5
+ const require_lib_helpers_bignum = require("../../lib/helpers/bignum.cjs");
5
6
  let _nhtio_validation = require("@nhtio/validation");
6
7
  //#region src/batteries/tools/unit_conversion/index.ts
7
8
  /**
@@ -425,15 +426,17 @@ var convertUnitTool = new require_tool.Tool({
425
426
  inputSchema: _nhtio_validation.validator.object({
426
427
  value: _nhtio_validation.validator.number().required().description("Numeric value to convert"),
427
428
  from: _nhtio_validation.validator.string().required().description(`Source unit key. Supported keys: ${ALL_UNIT_KEYS}`),
428
- to: _nhtio_validation.validator.string().required().description("Target unit key (must be in the same category as source)")
429
+ to: _nhtio_validation.validator.string().required().description("Target unit key (must be in the same category as source)"),
430
+ precision: _nhtio_validation.validator.number().default(8).description(`Significant digits in the result (default: 8).`)
429
431
  }),
430
432
  handler: async (args) => {
431
- const { value, from, to } = args;
433
+ const { value, from, to, precision } = args;
432
434
  if (TEMP_UNITS.has(from) || TEMP_UNITS.has(to)) {
433
435
  if (!TEMP_UNITS.has(from)) return `Error: "${from}" is not a temperature unit. Use C, F, or K.`;
434
436
  if (!TEMP_UNITS.has(to)) return `Error: "${to}" is not a temperature unit. Use C, F, or K.`;
435
- const result = fromKelvin(toKelvin(value, from), to);
436
- const rounded = Number.parseFloat(result.toPrecision(10));
437
+ const kelvin = toKelvin(value, from);
438
+ if (kelvin < -1e-9) return `Error: ${value}${TEMP_LABELS[from]} is below absolute zero (0 K); not a physical temperature.`;
439
+ const rounded = require_lib_helpers_bignum.formatBig(fromKelvin(kelvin, to), precision);
437
440
  return `${value}${TEMP_LABELS[from]} = ${rounded}${TEMP_LABELS[to]}`;
438
441
  }
439
442
  const fromDef = UNITS[from];
@@ -441,8 +444,7 @@ var convertUnitTool = new require_tool.Tool({
441
444
  if (!fromDef) return `Error: Unknown unit "${from}". Supported: ${ALL_UNIT_KEYS}`;
442
445
  if (!toDef) return `Error: Unknown unit "${to}". Supported: ${ALL_UNIT_KEYS}`;
443
446
  if (fromDef.category !== toDef.category) return `Error: Cannot convert "${from}" (${fromDef.category}) to "${to}" (${toDef.category}) — different categories.`;
444
- const result = value * fromDef.factor / toDef.factor;
445
- const rounded = Number.parseFloat(result.toPrecision(10));
447
+ const rounded = require_lib_helpers_bignum.formatBig(require_lib_helpers_bignum.bigScale(value, fromDef.factor, toDef.factor), precision);
446
448
  return `${value} ${fromDef.label} = ${rounded} ${toDef.label}`;
447
449
  }
448
450
  });
@@ -1 +1 @@
1
- {"version":3,"file":"unit_conversion.cjs","names":[],"sources":["../../../src/batteries/tools/unit_conversion/index.ts"],"sourcesContent":["/**\n * Pre-constructed tools for converting values across common measurement units.\n *\n * @module @nhtio/adk/batteries/tools/unit_conversion\n *\n * @remarks\n * Pre-constructed bundled tools for the `unit_conversion` category. Import individually, the whole\n * category, or import every tool via `@nhtio/adk/batteries`.\n */\n\nimport { Tool } from '@nhtio/adk/common'\nimport { validator } from '@nhtio/validation'\n\ntype UnitDef = { category: string; factor: number; label: string }\n\nconst UNITS: Record<string, UnitDef> = {\n // Length (base: metre)\n m: { category: 'length', factor: 1, label: 'metres' },\n km: { category: 'length', factor: 1000, label: 'kilometres' },\n cm: { category: 'length', factor: 0.01, label: 'centimetres' },\n mm: { category: 'length', factor: 0.001, label: 'millimetres' },\n mi: { category: 'length', factor: 1609.344, label: 'miles' },\n ft: { category: 'length', factor: 0.3048, label: 'feet' },\n in: { category: 'length', factor: 0.0254, label: 'inches' },\n yd: { category: 'length', factor: 0.9144, label: 'yards' },\n nmi: { category: 'length', factor: 1852, label: 'nautical miles' },\n\n // Mass (base: gram)\n g: { category: 'mass', factor: 1, label: 'grams' },\n kg: { category: 'mass', factor: 1000, label: 'kilograms' },\n mg: { category: 'mass', factor: 0.001, label: 'milligrams' },\n t: { category: 'mass', factor: 1_000_000, label: 'metric tons' },\n lb: { category: 'mass', factor: 453.59237, label: 'pounds' },\n oz: { category: 'mass', factor: 28.349523125, label: 'ounces' },\n st: { category: 'mass', factor: 6350.29318, label: 'stone' },\n\n // Volume (base: litre)\n L: { category: 'volume', factor: 1, label: 'litres' },\n mL: { category: 'volume', factor: 0.001, label: 'millilitres' },\n m3: { category: 'volume', factor: 1000, label: 'cubic metres' },\n cm3: { category: 'volume', factor: 0.001, label: 'cubic centimetres' },\n gal: { category: 'volume', factor: 3.785411784, label: 'US gallons' },\n qt: { category: 'volume', factor: 0.946352946, label: 'US quarts' },\n pt: { category: 'volume', factor: 0.473176473, label: 'US pints' },\n cup: { category: 'volume', factor: 0.2365882365, label: 'US cups' },\n floz: { category: 'volume', factor: 0.029573529562, label: 'US fluid ounces' },\n tbsp: { category: 'volume', factor: 0.014786764781, label: 'tablespoons' },\n tsp: { category: 'volume', factor: 0.0049289215938, label: 'teaspoons' },\n\n // Speed (base: m/s)\n m_s: { category: 'speed', factor: 1, label: 'm/s' },\n km_h: { category: 'speed', factor: 1 / 3.6, label: 'km/h' },\n mph: { category: 'speed', factor: 0.44704, label: 'mph' },\n kn: { category: 'speed', factor: 0.514444, label: 'knots' },\n ft_s: { category: 'speed', factor: 0.3048, label: 'ft/s' },\n\n // Area (base: m²)\n m2: { category: 'area', factor: 1, label: 'm²' },\n km2: { category: 'area', factor: 1_000_000, label: 'km²' },\n cm2: { category: 'area', factor: 0.0001, label: 'cm²' },\n mm2: { category: 'area', factor: 0.000001, label: 'mm²' },\n ft2: { category: 'area', factor: 0.09290304, label: 'sq ft' },\n in2: { category: 'area', factor: 0.00064516, label: 'sq in' },\n yd2: { category: 'area', factor: 0.83612736, label: 'sq yd' },\n acre: { category: 'area', factor: 4046.8564224, label: 'acres' },\n ha: { category: 'area', factor: 10_000, label: 'hectares' },\n\n // Data storage (base: bit)\n bit: { category: 'data', factor: 1, label: 'bits' },\n B: { category: 'data', factor: 8, label: 'bytes' },\n KB: { category: 'data', factor: 8_000, label: 'kilobytes' },\n MB: { category: 'data', factor: 8_000_000, label: 'megabytes' },\n GB: { category: 'data', factor: 8_000_000_000, label: 'gigabytes' },\n TB: { category: 'data', factor: 8_000_000_000_000, label: 'terabytes' },\n KiB: { category: 'data', factor: 8 * 1024, label: 'kibibytes' },\n MiB: { category: 'data', factor: 8 * 1024 ** 2, label: 'mebibytes' },\n GiB: { category: 'data', factor: 8 * 1024 ** 3, label: 'gibibytes' },\n TiB: { category: 'data', factor: 8 * 1024 ** 4, label: 'tebibytes' },\n\n // Time (base: second)\n ms: { category: 'time', factor: 0.001, label: 'milliseconds' },\n s: { category: 'time', factor: 1, label: 'seconds' },\n min: { category: 'time', factor: 60, label: 'minutes' },\n h: { category: 'time', factor: 3600, label: 'hours' },\n d: { category: 'time', factor: 86400, label: 'days' },\n wk: { category: 'time', factor: 604800, label: 'weeks' },\n\n // Energy (base: joule)\n J: { category: 'energy', factor: 1, label: 'joules' },\n kJ: { category: 'energy', factor: 1000, label: 'kilojoules' },\n cal: { category: 'energy', factor: 4.184, label: 'calories' },\n kcal: { category: 'energy', factor: 4184, label: 'kilocalories' },\n Wh: { category: 'energy', factor: 3600, label: 'watt-hours' },\n kWh: { category: 'energy', factor: 3_600_000, label: 'kilowatt-hours' },\n BTU: { category: 'energy', factor: 1055.05585, label: 'BTU' },\n\n // Pressure (base: pascal)\n Pa: { category: 'pressure', factor: 1, label: 'pascals' },\n kPa: { category: 'pressure', factor: 1000, label: 'kilopascals' },\n MPa: { category: 'pressure', factor: 1_000_000, label: 'megapascals' },\n bar: { category: 'pressure', factor: 100_000, label: 'bar' },\n psi: { category: 'pressure', factor: 6894.757, label: 'psi' },\n atm: { category: 'pressure', factor: 101325, label: 'atm' },\n mmHg: { category: 'pressure', factor: 133.322, label: 'mmHg' },\n\n // Angle (base: radian)\n rad: { category: 'angle', factor: 1, label: 'radians' },\n deg: { category: 'angle', factor: Math.PI / 180, label: 'degrees' },\n grad: { category: 'angle', factor: Math.PI / 200, label: 'gradians' },\n}\n\nconst TEMP_UNITS = new Set(['C', 'F', 'K'])\ntype TempUnit = 'C' | 'F' | 'K'\nconst TEMP_LABELS: Record<TempUnit, string> = { C: '°C', F: '°F', K: 'K' }\n\nfunction toKelvin(value: number, unit: TempUnit): number {\n if (unit === 'C') return value + 273.15\n if (unit === 'F') return (value - 32) * (5 / 9) + 273.15\n return value\n}\n\nfunction fromKelvin(kelvin: number, unit: TempUnit): number {\n if (unit === 'C') return kelvin - 273.15\n if (unit === 'F') return (kelvin - 273.15) * (9 / 5) + 32\n return kelvin\n}\n\nconst ALL_UNIT_KEYS = [...Object.keys(UNITS), 'C', 'F', 'K'].join(', ')\n\n/**\n * Convert a numeric value between units of the same physical category.\n *\n * @remarks\n * Supported categories: length, mass, volume, temperature, speed, area, data, time, energy,\n * pressure, angle. Uses static conversion tables — no external data required. Temperature is\n * handled specially via a Kelvin intermediate to preserve precision across `C`/`F`/`K`.\n */\nexport const convertUnitTool = new Tool({\n name: 'convert_unit',\n description:\n 'Convert a numeric value between units of the same category (length, mass, volume, temperature, speed, area, data, time, energy, pressure, angle). Uses static lookup tables — no external data required.',\n inputSchema: validator.object({\n value: validator.number().required().description('Numeric value to convert'),\n from: validator\n .string()\n .required()\n .description(`Source unit key. Supported keys: ${ALL_UNIT_KEYS}`),\n to: validator\n .string()\n .required()\n .description('Target unit key (must be in the same category as source)'),\n }),\n handler: async (args) => {\n const { value, from, to } = args as { value: number; from: string; to: string }\n\n if (TEMP_UNITS.has(from) || TEMP_UNITS.has(to)) {\n if (!TEMP_UNITS.has(from))\n return `Error: \"${from}\" is not a temperature unit. Use C, F, or K.`\n if (!TEMP_UNITS.has(to)) return `Error: \"${to}\" is not a temperature unit. Use C, F, or K.`\n const result = fromKelvin(toKelvin(value, from as TempUnit), to as TempUnit)\n const rounded = Number.parseFloat(result.toPrecision(10))\n return `${value}${TEMP_LABELS[from as TempUnit]} = ${rounded}${TEMP_LABELS[to as TempUnit]}`\n }\n\n const fromDef = UNITS[from]\n const toDef = UNITS[to]\n if (!fromDef) return `Error: Unknown unit \"${from}\". Supported: ${ALL_UNIT_KEYS}`\n if (!toDef) return `Error: Unknown unit \"${to}\". Supported: ${ALL_UNIT_KEYS}`\n if (fromDef.category !== toDef.category) {\n return `Error: Cannot convert \"${from}\" (${fromDef.category}) to \"${to}\" (${toDef.category}) — different categories.`\n }\n\n const inBase = value * fromDef.factor\n const result = inBase / toDef.factor\n const rounded = Number.parseFloat(result.toPrecision(10))\n return `${value} ${fromDef.label} = ${rounded} ${toDef.label}`\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;AAeA,IAAM,QAAiC;CAErC,GAAG;EAAE,UAAU;EAAU,QAAQ;EAAG,OAAO;CAAS;CACpD,IAAI;EAAE,UAAU;EAAU,QAAQ;EAAM,OAAO;CAAa;CAC5D,IAAI;EAAE,UAAU;EAAU,QAAQ;EAAM,OAAO;CAAc;CAC7D,IAAI;EAAE,UAAU;EAAU,QAAQ;EAAO,OAAO;CAAc;CAC9D,IAAI;EAAE,UAAU;EAAU,QAAQ;EAAU,OAAO;CAAQ;CAC3D,IAAI;EAAE,UAAU;EAAU,QAAQ;EAAQ,OAAO;CAAO;CACxD,IAAI;EAAE,UAAU;EAAU,QAAQ;EAAQ,OAAO;CAAS;CAC1D,IAAI;EAAE,UAAU;EAAU,QAAQ;EAAQ,OAAO;CAAQ;CACzD,KAAK;EAAE,UAAU;EAAU,QAAQ;EAAM,OAAO;CAAiB;CAGjE,GAAG;EAAE,UAAU;EAAQ,QAAQ;EAAG,OAAO;CAAQ;CACjD,IAAI;EAAE,UAAU;EAAQ,QAAQ;EAAM,OAAO;CAAY;CACzD,IAAI;EAAE,UAAU;EAAQ,QAAQ;EAAO,OAAO;CAAa;CAC3D,GAAG;EAAE,UAAU;EAAQ,QAAQ;EAAW,OAAO;CAAc;CAC/D,IAAI;EAAE,UAAU;EAAQ,QAAQ;EAAW,OAAO;CAAS;CAC3D,IAAI;EAAE,UAAU;EAAQ,QAAQ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AG,KAAK,MAAM,SAAS;EAI7F,MAAM,SADS,QAAQ,QAAQ,SACP,MAAM;EAC9B,MAAM,UAAU,OAAO,WAAW,OAAO,YAAY,EAAE,CAAC;EACxD,OAAO,GAAG,MAAM,GAAG,QAAQ,MAAM,KAAK,QAAQ,GAAG,MAAM;CACzD;AACF,CAAC"}
1
+ {"version":3,"file":"unit_conversion.cjs","names":[],"sources":["../../../src/batteries/tools/unit_conversion/index.ts"],"sourcesContent":["/**\n * Pre-constructed tools for converting values across common measurement units.\n *\n * @module @nhtio/adk/batteries/tools/unit_conversion\n *\n * @remarks\n * Pre-constructed bundled tools for the `unit_conversion` category. Import individually, the whole\n * category, or import every tool via `@nhtio/adk/batteries`.\n */\n\nimport { Tool } from '@nhtio/adk/common'\nimport { validator } from '@nhtio/validation'\nimport { bigScale, formatBig, DEFAULT_PRECISION } from '@nhtio/adk/lib/helpers/bignum'\n\ntype UnitDef = { category: string; factor: number; label: string }\n\nconst UNITS: Record<string, UnitDef> = {\n // Length (base: metre)\n m: { category: 'length', factor: 1, label: 'metres' },\n km: { category: 'length', factor: 1000, label: 'kilometres' },\n cm: { category: 'length', factor: 0.01, label: 'centimetres' },\n mm: { category: 'length', factor: 0.001, label: 'millimetres' },\n mi: { category: 'length', factor: 1609.344, label: 'miles' },\n ft: { category: 'length', factor: 0.3048, label: 'feet' },\n in: { category: 'length', factor: 0.0254, label: 'inches' },\n yd: { category: 'length', factor: 0.9144, label: 'yards' },\n nmi: { category: 'length', factor: 1852, label: 'nautical miles' },\n\n // Mass (base: gram)\n g: { category: 'mass', factor: 1, label: 'grams' },\n kg: { category: 'mass', factor: 1000, label: 'kilograms' },\n mg: { category: 'mass', factor: 0.001, label: 'milligrams' },\n t: { category: 'mass', factor: 1_000_000, label: 'metric tons' },\n lb: { category: 'mass', factor: 453.59237, label: 'pounds' },\n oz: { category: 'mass', factor: 28.349523125, label: 'ounces' },\n st: { category: 'mass', factor: 6350.29318, label: 'stone' },\n\n // Volume (base: litre)\n L: { category: 'volume', factor: 1, label: 'litres' },\n mL: { category: 'volume', factor: 0.001, label: 'millilitres' },\n m3: { category: 'volume', factor: 1000, label: 'cubic metres' },\n cm3: { category: 'volume', factor: 0.001, label: 'cubic centimetres' },\n gal: { category: 'volume', factor: 3.785411784, label: 'US gallons' },\n qt: { category: 'volume', factor: 0.946352946, label: 'US quarts' },\n pt: { category: 'volume', factor: 0.473176473, label: 'US pints' },\n cup: { category: 'volume', factor: 0.2365882365, label: 'US cups' },\n floz: { category: 'volume', factor: 0.029573529562, label: 'US fluid ounces' },\n tbsp: { category: 'volume', factor: 0.014786764781, label: 'tablespoons' },\n tsp: { category: 'volume', factor: 0.0049289215938, label: 'teaspoons' },\n\n // Speed (base: m/s)\n m_s: { category: 'speed', factor: 1, label: 'm/s' },\n km_h: { category: 'speed', factor: 1 / 3.6, label: 'km/h' },\n mph: { category: 'speed', factor: 0.44704, label: 'mph' },\n kn: { category: 'speed', factor: 0.514444, label: 'knots' },\n ft_s: { category: 'speed', factor: 0.3048, label: 'ft/s' },\n\n // Area (base: m²)\n m2: { category: 'area', factor: 1, label: 'm²' },\n km2: { category: 'area', factor: 1_000_000, label: 'km²' },\n cm2: { category: 'area', factor: 0.0001, label: 'cm²' },\n mm2: { category: 'area', factor: 0.000001, label: 'mm²' },\n ft2: { category: 'area', factor: 0.09290304, label: 'sq ft' },\n in2: { category: 'area', factor: 0.00064516, label: 'sq in' },\n yd2: { category: 'area', factor: 0.83612736, label: 'sq yd' },\n acre: { category: 'area', factor: 4046.8564224, label: 'acres' },\n ha: { category: 'area', factor: 10_000, label: 'hectares' },\n\n // Data storage (base: bit)\n bit: { category: 'data', factor: 1, label: 'bits' },\n B: { category: 'data', factor: 8, label: 'bytes' },\n KB: { category: 'data', factor: 8_000, label: 'kilobytes' },\n MB: { category: 'data', factor: 8_000_000, label: 'megabytes' },\n GB: { category: 'data', factor: 8_000_000_000, label: 'gigabytes' },\n TB: { category: 'data', factor: 8_000_000_000_000, label: 'terabytes' },\n KiB: { category: 'data', factor: 8 * 1024, label: 'kibibytes' },\n MiB: { category: 'data', factor: 8 * 1024 ** 2, label: 'mebibytes' },\n GiB: { category: 'data', factor: 8 * 1024 ** 3, label: 'gibibytes' },\n TiB: { category: 'data', factor: 8 * 1024 ** 4, label: 'tebibytes' },\n\n // Time (base: second)\n ms: { category: 'time', factor: 0.001, label: 'milliseconds' },\n s: { category: 'time', factor: 1, label: 'seconds' },\n min: { category: 'time', factor: 60, label: 'minutes' },\n h: { category: 'time', factor: 3600, label: 'hours' },\n d: { category: 'time', factor: 86400, label: 'days' },\n wk: { category: 'time', factor: 604800, label: 'weeks' },\n\n // Energy (base: joule)\n J: { category: 'energy', factor: 1, label: 'joules' },\n kJ: { category: 'energy', factor: 1000, label: 'kilojoules' },\n cal: { category: 'energy', factor: 4.184, label: 'calories' },\n kcal: { category: 'energy', factor: 4184, label: 'kilocalories' },\n Wh: { category: 'energy', factor: 3600, label: 'watt-hours' },\n kWh: { category: 'energy', factor: 3_600_000, label: 'kilowatt-hours' },\n BTU: { category: 'energy', factor: 1055.05585, label: 'BTU' },\n\n // Pressure (base: pascal)\n Pa: { category: 'pressure', factor: 1, label: 'pascals' },\n kPa: { category: 'pressure', factor: 1000, label: 'kilopascals' },\n MPa: { category: 'pressure', factor: 1_000_000, label: 'megapascals' },\n bar: { category: 'pressure', factor: 100_000, label: 'bar' },\n psi: { category: 'pressure', factor: 6894.757, label: 'psi' },\n atm: { category: 'pressure', factor: 101325, label: 'atm' },\n mmHg: { category: 'pressure', factor: 133.322, label: 'mmHg' },\n\n // Angle (base: radian)\n rad: { category: 'angle', factor: 1, label: 'radians' },\n deg: { category: 'angle', factor: Math.PI / 180, label: 'degrees' },\n grad: { category: 'angle', factor: Math.PI / 200, label: 'gradians' },\n}\n\nconst TEMP_UNITS = new Set(['C', 'F', 'K'])\ntype TempUnit = 'C' | 'F' | 'K'\nconst TEMP_LABELS: Record<TempUnit, string> = { C: '°C', F: '°F', K: 'K' }\n\nfunction toKelvin(value: number, unit: TempUnit): number {\n if (unit === 'C') return value + 273.15\n if (unit === 'F') return (value - 32) * (5 / 9) + 273.15\n return value\n}\n\nfunction fromKelvin(kelvin: number, unit: TempUnit): number {\n if (unit === 'C') return kelvin - 273.15\n if (unit === 'F') return (kelvin - 273.15) * (9 / 5) + 32\n return kelvin\n}\n\nconst ALL_UNIT_KEYS = [...Object.keys(UNITS), 'C', 'F', 'K'].join(', ')\n\n/**\n * Convert a numeric value between units of the same physical category.\n *\n * @remarks\n * Supported categories: length, mass, volume, temperature, speed, area, data, time, energy,\n * pressure, angle. Uses static conversion tables — no external data required. Temperature is\n * handled specially via a Kelvin intermediate to preserve precision across `C`/`F`/`K`.\n */\nexport const convertUnitTool = new Tool({\n name: 'convert_unit',\n description:\n 'Convert a numeric value between units of the same category (length, mass, volume, temperature, speed, area, data, time, energy, pressure, angle). Uses static lookup tables — no external data required.',\n inputSchema: validator.object({\n value: validator.number().required().description('Numeric value to convert'),\n from: validator\n .string()\n .required()\n .description(`Source unit key. Supported keys: ${ALL_UNIT_KEYS}`),\n to: validator\n .string()\n .required()\n .description('Target unit key (must be in the same category as source)'),\n precision: validator\n .number()\n .default(DEFAULT_PRECISION)\n .description(`Significant digits in the result (default: ${DEFAULT_PRECISION}).`),\n }),\n handler: async (args) => {\n const { value, from, to, precision } = args as {\n value: number\n from: string\n to: string\n precision: number\n }\n\n if (TEMP_UNITS.has(from) || TEMP_UNITS.has(to)) {\n if (!TEMP_UNITS.has(from))\n return `Error: \"${from}\" is not a temperature unit. Use C, F, or K.`\n if (!TEMP_UNITS.has(to)) return `Error: \"${to}\" is not a temperature unit. Use C, F, or K.`\n // Temperatures are small bounded values (schema rejects |value| > 2^53), so float64 math\n // is exact enough; only the display precision changes.\n const kelvin = toKelvin(value, from as TempUnit)\n // Reject physically impossible temperatures below absolute zero (0 K) rather than silently\n // returning a nonsensical value like \"-1 K = -274.15 °C\". A tiny epsilon absorbs float noise.\n if (kelvin < -1e-9) {\n return `Error: ${value}${TEMP_LABELS[from as TempUnit]} is below absolute zero (0 K); not a physical temperature.`\n }\n const result = fromKelvin(kelvin, to as TempUnit)\n const rounded = formatBig(result, precision)\n return `${value}${TEMP_LABELS[from as TempUnit]} = ${rounded}${TEMP_LABELS[to as TempUnit]}`\n }\n\n const fromDef = UNITS[from]\n const toDef = UNITS[to]\n if (!fromDef) return `Error: Unknown unit \"${from}\". Supported: ${ALL_UNIT_KEYS}`\n if (!toDef) return `Error: Unknown unit \"${to}\". Supported: ${ALL_UNIT_KEYS}`\n if (fromDef.category !== toDef.category) {\n return `Error: Cannot convert \"${from}\" (${fromDef.category}) to \"${to}\" (${toDef.category}) — different categories.`\n }\n\n // `value * fromFactor / toFactor` in BigNumber so huge ratios (e.g. TB→bit) don't overflow to\n // Infinity, tiny ratios (e.g. in→km) don't underflow to 0, and safe integers keep full digits.\n const result = bigScale(value, fromDef.factor, toDef.factor)\n const rounded = formatBig(result, precision)\n return `${value} ${fromDef.label} = ${rounded} ${toDef.label}`\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,IAAM,QAAiC;CAErC,GAAG;EAAE,UAAU;EAAU,QAAQ;EAAG,OAAO;CAAS;CACpD,IAAI;EAAE,UAAU;EAAU,QAAQ;EAAM,OAAO;CAAa;CAC5D,IAAI;EAAE,UAAU;EAAU,QAAQ;EAAM,OAAO;CAAc;CAC7D,IAAI;EAAE,UAAU;EAAU,QAAQ;EAAO,OAAO;CAAc;CAC9D,IAAI;EAAE,UAAU;EAAU,QAAQ;EAAU,OAAO;CAAQ;CAC3D,IAAI;EAAE,UAAU;EAAU,QAAQ;EAAQ,OAAO;CAAO;CACxD,IAAI;EAAE,UAAU;EAAU,QAAQ;EAAQ,OAAO;CAAS;CAC1D,IAAI;EAAE,UAAU;EAAU,QAAQ;EAAQ,OAAO;CAAQ;CACzD,KAAK;EAAE,UAAU;EAAU,QAAQ;EAAM,OAAO;CAAiB;CAGjE,GAAG;EAAE,UAAU;EAAQ,QAA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OACX,OAAO,UAAU,QAAQ,YAAY,MAAkB;GAGzD,MAAM,UAAU,2BAAA,UADD,WAAW,QAAQ,EACR,GAAQ,SAAS;GAC3C,OAAO,GAAG,QAAQ,YAAY,MAAkB,KAAK,UAAU,YAAY;EAC7E;EAEA,MAAM,UAAU,MAAM;EACtB,MAAM,QAAQ,MAAM;EACpB,IAAI,CAAC,SAAS,OAAO,wBAAwB,KAAK,gBAAgB;EAClE,IAAI,CAAC,OAAO,OAAO,wBAAwB,GAAG,gBAAgB;EAC9D,IAAI,QAAQ,aAAa,MAAM,UAC7B,OAAO,0BAA0B,KAAK,KAAK,QAAQ,SAAS,QAAQ,GAAG,KAAK,MAAM,SAAS;EAM7F,MAAM,UAAU,2BAAA,UADD,2BAAA,SAAS,OAAO,QAAQ,QAAQ,MAAM,MAC3B,GAAQ,SAAS;EAC3C,OAAO,GAAG,MAAM,GAAG,QAAQ,MAAM,KAAK,QAAQ,GAAG,MAAM;CACzD;AACF,CAAC"}
@@ -1,5 +1,6 @@
1
- import { t as Tool } from "../../tool-CMhaDRNd.mjs";
2
- import "../../common-BT0nfCi9.mjs";
1
+ import { t as Tool } from "../../tool-wMYMVl60.mjs";
2
+ import "../../common-DYDUi99O.mjs";
3
+ import { bigScale, formatBig } from "../../lib/helpers/bignum.mjs";
3
4
  import { validator } from "@nhtio/validation";
4
5
  //#region src/batteries/tools/unit_conversion/index.ts
5
6
  /**
@@ -423,15 +424,17 @@ var convertUnitTool = new Tool({
423
424
  inputSchema: validator.object({
424
425
  value: validator.number().required().description("Numeric value to convert"),
425
426
  from: validator.string().required().description(`Source unit key. Supported keys: ${ALL_UNIT_KEYS}`),
426
- to: validator.string().required().description("Target unit key (must be in the same category as source)")
427
+ to: validator.string().required().description("Target unit key (must be in the same category as source)"),
428
+ precision: validator.number().default(8).description(`Significant digits in the result (default: 8).`)
427
429
  }),
428
430
  handler: async (args) => {
429
- const { value, from, to } = args;
431
+ const { value, from, to, precision } = args;
430
432
  if (TEMP_UNITS.has(from) || TEMP_UNITS.has(to)) {
431
433
  if (!TEMP_UNITS.has(from)) return `Error: "${from}" is not a temperature unit. Use C, F, or K.`;
432
434
  if (!TEMP_UNITS.has(to)) return `Error: "${to}" is not a temperature unit. Use C, F, or K.`;
433
- const result = fromKelvin(toKelvin(value, from), to);
434
- const rounded = Number.parseFloat(result.toPrecision(10));
435
+ const kelvin = toKelvin(value, from);
436
+ if (kelvin < -1e-9) return `Error: ${value}${TEMP_LABELS[from]} is below absolute zero (0 K); not a physical temperature.`;
437
+ const rounded = formatBig(fromKelvin(kelvin, to), precision);
435
438
  return `${value}${TEMP_LABELS[from]} = ${rounded}${TEMP_LABELS[to]}`;
436
439
  }
437
440
  const fromDef = UNITS[from];
@@ -439,8 +442,7 @@ var convertUnitTool = new Tool({
439
442
  if (!fromDef) return `Error: Unknown unit "${from}". Supported: ${ALL_UNIT_KEYS}`;
440
443
  if (!toDef) return `Error: Unknown unit "${to}". Supported: ${ALL_UNIT_KEYS}`;
441
444
  if (fromDef.category !== toDef.category) return `Error: Cannot convert "${from}" (${fromDef.category}) to "${to}" (${toDef.category}) — different categories.`;
442
- const result = value * fromDef.factor / toDef.factor;
443
- const rounded = Number.parseFloat(result.toPrecision(10));
445
+ const rounded = formatBig(bigScale(value, fromDef.factor, toDef.factor), precision);
444
446
  return `${value} ${fromDef.label} = ${rounded} ${toDef.label}`;
445
447
  }
446
448
  });
@@ -1 +1 @@
1
- {"version":3,"file":"unit_conversion.mjs","names":[],"sources":["../../../src/batteries/tools/unit_conversion/index.ts"],"sourcesContent":["/**\n * Pre-constructed tools for converting values across common measurement units.\n *\n * @module @nhtio/adk/batteries/tools/unit_conversion\n *\n * @remarks\n * Pre-constructed bundled tools for the `unit_conversion` category. Import individually, the whole\n * category, or import every tool via `@nhtio/adk/batteries`.\n */\n\nimport { Tool } from '@nhtio/adk/common'\nimport { validator } from '@nhtio/validation'\n\ntype UnitDef = { category: string; factor: number; label: string }\n\nconst UNITS: Record<string, UnitDef> = {\n // Length (base: metre)\n m: { category: 'length', factor: 1, label: 'metres' },\n km: { category: 'length', factor: 1000, label: 'kilometres' },\n cm: { category: 'length', factor: 0.01, label: 'centimetres' },\n mm: { category: 'length', factor: 0.001, label: 'millimetres' },\n mi: { category: 'length', factor: 1609.344, label: 'miles' },\n ft: { category: 'length', factor: 0.3048, label: 'feet' },\n in: { category: 'length', factor: 0.0254, label: 'inches' },\n yd: { category: 'length', factor: 0.9144, label: 'yards' },\n nmi: { category: 'length', factor: 1852, label: 'nautical miles' },\n\n // Mass (base: gram)\n g: { category: 'mass', factor: 1, label: 'grams' },\n kg: { category: 'mass', factor: 1000, label: 'kilograms' },\n mg: { category: 'mass', factor: 0.001, label: 'milligrams' },\n t: { category: 'mass', factor: 1_000_000, label: 'metric tons' },\n lb: { category: 'mass', factor: 453.59237, label: 'pounds' },\n oz: { category: 'mass', factor: 28.349523125, label: 'ounces' },\n st: { category: 'mass', factor: 6350.29318, label: 'stone' },\n\n // Volume (base: litre)\n L: { category: 'volume', factor: 1, label: 'litres' },\n mL: { category: 'volume', factor: 0.001, label: 'millilitres' },\n m3: { category: 'volume', factor: 1000, label: 'cubic metres' },\n cm3: { category: 'volume', factor: 0.001, label: 'cubic centimetres' },\n gal: { category: 'volume', factor: 3.785411784, label: 'US gallons' },\n qt: { category: 'volume', factor: 0.946352946, label: 'US quarts' },\n pt: { category: 'volume', factor: 0.473176473, label: 'US pints' },\n cup: { category: 'volume', factor: 0.2365882365, label: 'US cups' },\n floz: { category: 'volume', factor: 0.029573529562, label: 'US fluid ounces' },\n tbsp: { category: 'volume', factor: 0.014786764781, label: 'tablespoons' },\n tsp: { category: 'volume', factor: 0.0049289215938, label: 'teaspoons' },\n\n // Speed (base: m/s)\n m_s: { category: 'speed', factor: 1, label: 'm/s' },\n km_h: { category: 'speed', factor: 1 / 3.6, label: 'km/h' },\n mph: { category: 'speed', factor: 0.44704, label: 'mph' },\n kn: { category: 'speed', factor: 0.514444, label: 'knots' },\n ft_s: { category: 'speed', factor: 0.3048, label: 'ft/s' },\n\n // Area (base: m²)\n m2: { category: 'area', factor: 1, label: 'm²' },\n km2: { category: 'area', factor: 1_000_000, label: 'km²' },\n cm2: { category: 'area', factor: 0.0001, label: 'cm²' },\n mm2: { category: 'area', factor: 0.000001, label: 'mm²' },\n ft2: { category: 'area', factor: 0.09290304, label: 'sq ft' },\n in2: { category: 'area', factor: 0.00064516, label: 'sq in' },\n yd2: { category: 'area', factor: 0.83612736, label: 'sq yd' },\n acre: { category: 'area', factor: 4046.8564224, label: 'acres' },\n ha: { category: 'area', factor: 10_000, label: 'hectares' },\n\n // Data storage (base: bit)\n bit: { category: 'data', factor: 1, label: 'bits' },\n B: { category: 'data', factor: 8, label: 'bytes' },\n KB: { category: 'data', factor: 8_000, label: 'kilobytes' },\n MB: { category: 'data', factor: 8_000_000, label: 'megabytes' },\n GB: { category: 'data', factor: 8_000_000_000, label: 'gigabytes' },\n TB: { category: 'data', factor: 8_000_000_000_000, label: 'terabytes' },\n KiB: { category: 'data', factor: 8 * 1024, label: 'kibibytes' },\n MiB: { category: 'data', factor: 8 * 1024 ** 2, label: 'mebibytes' },\n GiB: { category: 'data', factor: 8 * 1024 ** 3, label: 'gibibytes' },\n TiB: { category: 'data', factor: 8 * 1024 ** 4, label: 'tebibytes' },\n\n // Time (base: second)\n ms: { category: 'time', factor: 0.001, label: 'milliseconds' },\n s: { category: 'time', factor: 1, label: 'seconds' },\n min: { category: 'time', factor: 60, label: 'minutes' },\n h: { category: 'time', factor: 3600, label: 'hours' },\n d: { category: 'time', factor: 86400, label: 'days' },\n wk: { category: 'time', factor: 604800, label: 'weeks' },\n\n // Energy (base: joule)\n J: { category: 'energy', factor: 1, label: 'joules' },\n kJ: { category: 'energy', factor: 1000, label: 'kilojoules' },\n cal: { category: 'energy', factor: 4.184, label: 'calories' },\n kcal: { category: 'energy', factor: 4184, label: 'kilocalories' },\n Wh: { category: 'energy', factor: 3600, label: 'watt-hours' },\n kWh: { category: 'energy', factor: 3_600_000, label: 'kilowatt-hours' },\n BTU: { category: 'energy', factor: 1055.05585, label: 'BTU' },\n\n // Pressure (base: pascal)\n Pa: { category: 'pressure', factor: 1, label: 'pascals' },\n kPa: { category: 'pressure', factor: 1000, label: 'kilopascals' },\n MPa: { category: 'pressure', factor: 1_000_000, label: 'megapascals' },\n bar: { category: 'pressure', factor: 100_000, label: 'bar' },\n psi: { category: 'pressure', factor: 6894.757, label: 'psi' },\n atm: { category: 'pressure', factor: 101325, label: 'atm' },\n mmHg: { category: 'pressure', factor: 133.322, label: 'mmHg' },\n\n // Angle (base: radian)\n rad: { category: 'angle', factor: 1, label: 'radians' },\n deg: { category: 'angle', factor: Math.PI / 180, label: 'degrees' },\n grad: { category: 'angle', factor: Math.PI / 200, label: 'gradians' },\n}\n\nconst TEMP_UNITS = new Set(['C', 'F', 'K'])\ntype TempUnit = 'C' | 'F' | 'K'\nconst TEMP_LABELS: Record<TempUnit, string> = { C: '°C', F: '°F', K: 'K' }\n\nfunction toKelvin(value: number, unit: TempUnit): number {\n if (unit === 'C') return value + 273.15\n if (unit === 'F') return (value - 32) * (5 / 9) + 273.15\n return value\n}\n\nfunction fromKelvin(kelvin: number, unit: TempUnit): number {\n if (unit === 'C') return kelvin - 273.15\n if (unit === 'F') return (kelvin - 273.15) * (9 / 5) + 32\n return kelvin\n}\n\nconst ALL_UNIT_KEYS = [...Object.keys(UNITS), 'C', 'F', 'K'].join(', ')\n\n/**\n * Convert a numeric value between units of the same physical category.\n *\n * @remarks\n * Supported categories: length, mass, volume, temperature, speed, area, data, time, energy,\n * pressure, angle. Uses static conversion tables — no external data required. Temperature is\n * handled specially via a Kelvin intermediate to preserve precision across `C`/`F`/`K`.\n */\nexport const convertUnitTool = new Tool({\n name: 'convert_unit',\n description:\n 'Convert a numeric value between units of the same category (length, mass, volume, temperature, speed, area, data, time, energy, pressure, angle). Uses static lookup tables — no external data required.',\n inputSchema: validator.object({\n value: validator.number().required().description('Numeric value to convert'),\n from: validator\n .string()\n .required()\n .description(`Source unit key. Supported keys: ${ALL_UNIT_KEYS}`),\n to: validator\n .string()\n .required()\n .description('Target unit key (must be in the same category as source)'),\n }),\n handler: async (args) => {\n const { value, from, to } = args as { value: number; from: string; to: string }\n\n if (TEMP_UNITS.has(from) || TEMP_UNITS.has(to)) {\n if (!TEMP_UNITS.has(from))\n return `Error: \"${from}\" is not a temperature unit. Use C, F, or K.`\n if (!TEMP_UNITS.has(to)) return `Error: \"${to}\" is not a temperature unit. Use C, F, or K.`\n const result = fromKelvin(toKelvin(value, from as TempUnit), to as TempUnit)\n const rounded = Number.parseFloat(result.toPrecision(10))\n return `${value}${TEMP_LABELS[from as TempUnit]} = ${rounded}${TEMP_LABELS[to as TempUnit]}`\n }\n\n const fromDef = UNITS[from]\n const toDef = UNITS[to]\n if (!fromDef) return `Error: Unknown unit \"${from}\". Supported: ${ALL_UNIT_KEYS}`\n if (!toDef) return `Error: Unknown unit \"${to}\". Supported: ${ALL_UNIT_KEYS}`\n if (fromDef.category !== toDef.category) {\n return `Error: Cannot convert \"${from}\" (${fromDef.category}) to \"${to}\" (${toDef.category}) — different categories.`\n }\n\n const inBase = value * fromDef.factor\n const result = inBase / toDef.factor\n const rounded = Number.parseFloat(result.toPrecision(10))\n return `${value} ${fromDef.label} = ${rounded} ${toDef.label}`\n },\n})\n"],"mappings":";;;;;;;;;;;;;AAeA,IAAM,QAAiC;CAErC,GAAG;EAAE,UAAU;EAAU,QAAQ;EAAG,OAAO;CAAS;CACpD,IAAI;EAAE,UAAU;EAAU,QAAQ;EAAM,OAAO;CAAa;CAC5D,IAAI;EAAE,UAAU;EAAU,QAAQ;EAAM,OAAO;CAAc;CAC7D,IAAI;EAAE,UAAU;EAAU,QAAQ;EAAO,OAAO;CAAc;CAC9D,IAAI;EAAE,UAAU;EAAU,QAAQ;EAAU,OAAO;CAAQ;CAC3D,IAAI;EAAE,UAAU;EAAU,QAAQ;EAAQ,OAAO;CAAO;CACxD,IAAI;EAAE,UAAU;EAAU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,WAAW,GAAG;GAC9C,MAAM,SAAS,WAAW,SAAS,OAAO,IAAgB,GAAG,EAAc;GAC3E,MAAM,UAAU,OAAO,WAAW,OAAO,YAAY,EAAE,CAAC;GACxD,OAAO,GAAG,QAAQ,YAAY,MAAkB,KAAK,UAAU,YAAY;EAC7E;EAEA,MAAM,UAAU,MAAM;EACtB,MAAM,QAAQ,MAAM;EACpB,IAAI,CAAC,SAAS,OAAO,wBAAwB,KAAK,gBAAgB;EAClE,IAAI,CAAC,OAAO,OAAO,wBAAwB,GAAG,gBAAgB;EAC9D,IAAI,QAAQ,aAAa,MAAM,UAC7B,OAAO,0BAA0B,KAAK,KAAK,QAAQ,SAAS,QAAQ,GAAG,KAAK,MAAM,SAAS;EAI7F,MAAM,SADS,QAAQ,QAAQ,SACP,MAAM;EAC9B,MAAM,UAAU,OAAO,WAAW,OAAO,YAAY,EAAE,CAAC;EACxD,OAAO,GAAG,MAAM,GAAG,QAAQ,MAAM,KAAK,QAAQ,GAAG,MAAM;CACzD;AACF,CAAC"}
1
+ {"version":3,"file":"unit_conversion.mjs","names":[],"sources":["../../../src/batteries/tools/unit_conversion/index.ts"],"sourcesContent":["/**\n * Pre-constructed tools for converting values across common measurement units.\n *\n * @module @nhtio/adk/batteries/tools/unit_conversion\n *\n * @remarks\n * Pre-constructed bundled tools for the `unit_conversion` category. Import individually, the whole\n * category, or import every tool via `@nhtio/adk/batteries`.\n */\n\nimport { Tool } from '@nhtio/adk/common'\nimport { validator } from '@nhtio/validation'\nimport { bigScale, formatBig, DEFAULT_PRECISION } from '@nhtio/adk/lib/helpers/bignum'\n\ntype UnitDef = { category: string; factor: number; label: string }\n\nconst UNITS: Record<string, UnitDef> = {\n // Length (base: metre)\n m: { category: 'length', factor: 1, label: 'metres' },\n km: { category: 'length', factor: 1000, label: 'kilometres' },\n cm: { category: 'length', factor: 0.01, label: 'centimetres' },\n mm: { category: 'length', factor: 0.001, label: 'millimetres' },\n mi: { category: 'length', factor: 1609.344, label: 'miles' },\n ft: { category: 'length', factor: 0.3048, label: 'feet' },\n in: { category: 'length', factor: 0.0254, label: 'inches' },\n yd: { category: 'length', factor: 0.9144, label: 'yards' },\n nmi: { category: 'length', factor: 1852, label: 'nautical miles' },\n\n // Mass (base: gram)\n g: { category: 'mass', factor: 1, label: 'grams' },\n kg: { category: 'mass', factor: 1000, label: 'kilograms' },\n mg: { category: 'mass', factor: 0.001, label: 'milligrams' },\n t: { category: 'mass', factor: 1_000_000, label: 'metric tons' },\n lb: { category: 'mass', factor: 453.59237, label: 'pounds' },\n oz: { category: 'mass', factor: 28.349523125, label: 'ounces' },\n st: { category: 'mass', factor: 6350.29318, label: 'stone' },\n\n // Volume (base: litre)\n L: { category: 'volume', factor: 1, label: 'litres' },\n mL: { category: 'volume', factor: 0.001, label: 'millilitres' },\n m3: { category: 'volume', factor: 1000, label: 'cubic metres' },\n cm3: { category: 'volume', factor: 0.001, label: 'cubic centimetres' },\n gal: { category: 'volume', factor: 3.785411784, label: 'US gallons' },\n qt: { category: 'volume', factor: 0.946352946, label: 'US quarts' },\n pt: { category: 'volume', factor: 0.473176473, label: 'US pints' },\n cup: { category: 'volume', factor: 0.2365882365, label: 'US cups' },\n floz: { category: 'volume', factor: 0.029573529562, label: 'US fluid ounces' },\n tbsp: { category: 'volume', factor: 0.014786764781, label: 'tablespoons' },\n tsp: { category: 'volume', factor: 0.0049289215938, label: 'teaspoons' },\n\n // Speed (base: m/s)\n m_s: { category: 'speed', factor: 1, label: 'm/s' },\n km_h: { category: 'speed', factor: 1 / 3.6, label: 'km/h' },\n mph: { category: 'speed', factor: 0.44704, label: 'mph' },\n kn: { category: 'speed', factor: 0.514444, label: 'knots' },\n ft_s: { category: 'speed', factor: 0.3048, label: 'ft/s' },\n\n // Area (base: m²)\n m2: { category: 'area', factor: 1, label: 'm²' },\n km2: { category: 'area', factor: 1_000_000, label: 'km²' },\n cm2: { category: 'area', factor: 0.0001, label: 'cm²' },\n mm2: { category: 'area', factor: 0.000001, label: 'mm²' },\n ft2: { category: 'area', factor: 0.09290304, label: 'sq ft' },\n in2: { category: 'area', factor: 0.00064516, label: 'sq in' },\n yd2: { category: 'area', factor: 0.83612736, label: 'sq yd' },\n acre: { category: 'area', factor: 4046.8564224, label: 'acres' },\n ha: { category: 'area', factor: 10_000, label: 'hectares' },\n\n // Data storage (base: bit)\n bit: { category: 'data', factor: 1, label: 'bits' },\n B: { category: 'data', factor: 8, label: 'bytes' },\n KB: { category: 'data', factor: 8_000, label: 'kilobytes' },\n MB: { category: 'data', factor: 8_000_000, label: 'megabytes' },\n GB: { category: 'data', factor: 8_000_000_000, label: 'gigabytes' },\n TB: { category: 'data', factor: 8_000_000_000_000, label: 'terabytes' },\n KiB: { category: 'data', factor: 8 * 1024, label: 'kibibytes' },\n MiB: { category: 'data', factor: 8 * 1024 ** 2, label: 'mebibytes' },\n GiB: { category: 'data', factor: 8 * 1024 ** 3, label: 'gibibytes' },\n TiB: { category: 'data', factor: 8 * 1024 ** 4, label: 'tebibytes' },\n\n // Time (base: second)\n ms: { category: 'time', factor: 0.001, label: 'milliseconds' },\n s: { category: 'time', factor: 1, label: 'seconds' },\n min: { category: 'time', factor: 60, label: 'minutes' },\n h: { category: 'time', factor: 3600, label: 'hours' },\n d: { category: 'time', factor: 86400, label: 'days' },\n wk: { category: 'time', factor: 604800, label: 'weeks' },\n\n // Energy (base: joule)\n J: { category: 'energy', factor: 1, label: 'joules' },\n kJ: { category: 'energy', factor: 1000, label: 'kilojoules' },\n cal: { category: 'energy', factor: 4.184, label: 'calories' },\n kcal: { category: 'energy', factor: 4184, label: 'kilocalories' },\n Wh: { category: 'energy', factor: 3600, label: 'watt-hours' },\n kWh: { category: 'energy', factor: 3_600_000, label: 'kilowatt-hours' },\n BTU: { category: 'energy', factor: 1055.05585, label: 'BTU' },\n\n // Pressure (base: pascal)\n Pa: { category: 'pressure', factor: 1, label: 'pascals' },\n kPa: { category: 'pressure', factor: 1000, label: 'kilopascals' },\n MPa: { category: 'pressure', factor: 1_000_000, label: 'megapascals' },\n bar: { category: 'pressure', factor: 100_000, label: 'bar' },\n psi: { category: 'pressure', factor: 6894.757, label: 'psi' },\n atm: { category: 'pressure', factor: 101325, label: 'atm' },\n mmHg: { category: 'pressure', factor: 133.322, label: 'mmHg' },\n\n // Angle (base: radian)\n rad: { category: 'angle', factor: 1, label: 'radians' },\n deg: { category: 'angle', factor: Math.PI / 180, label: 'degrees' },\n grad: { category: 'angle', factor: Math.PI / 200, label: 'gradians' },\n}\n\nconst TEMP_UNITS = new Set(['C', 'F', 'K'])\ntype TempUnit = 'C' | 'F' | 'K'\nconst TEMP_LABELS: Record<TempUnit, string> = { C: '°C', F: '°F', K: 'K' }\n\nfunction toKelvin(value: number, unit: TempUnit): number {\n if (unit === 'C') return value + 273.15\n if (unit === 'F') return (value - 32) * (5 / 9) + 273.15\n return value\n}\n\nfunction fromKelvin(kelvin: number, unit: TempUnit): number {\n if (unit === 'C') return kelvin - 273.15\n if (unit === 'F') return (kelvin - 273.15) * (9 / 5) + 32\n return kelvin\n}\n\nconst ALL_UNIT_KEYS = [...Object.keys(UNITS), 'C', 'F', 'K'].join(', ')\n\n/**\n * Convert a numeric value between units of the same physical category.\n *\n * @remarks\n * Supported categories: length, mass, volume, temperature, speed, area, data, time, energy,\n * pressure, angle. Uses static conversion tables — no external data required. Temperature is\n * handled specially via a Kelvin intermediate to preserve precision across `C`/`F`/`K`.\n */\nexport const convertUnitTool = new Tool({\n name: 'convert_unit',\n description:\n 'Convert a numeric value between units of the same category (length, mass, volume, temperature, speed, area, data, time, energy, pressure, angle). Uses static lookup tables — no external data required.',\n inputSchema: validator.object({\n value: validator.number().required().description('Numeric value to convert'),\n from: validator\n .string()\n .required()\n .description(`Source unit key. Supported keys: ${ALL_UNIT_KEYS}`),\n to: validator\n .string()\n .required()\n .description('Target unit key (must be in the same category as source)'),\n precision: validator\n .number()\n .default(DEFAULT_PRECISION)\n .description(`Significant digits in the result (default: ${DEFAULT_PRECISION}).`),\n }),\n handler: async (args) => {\n const { value, from, to, precision } = args as {\n value: number\n from: string\n to: string\n precision: number\n }\n\n if (TEMP_UNITS.has(from) || TEMP_UNITS.has(to)) {\n if (!TEMP_UNITS.has(from))\n return `Error: \"${from}\" is not a temperature unit. Use C, F, or K.`\n if (!TEMP_UNITS.has(to)) return `Error: \"${to}\" is not a temperature unit. Use C, F, or K.`\n // Temperatures are small bounded values (schema rejects |value| > 2^53), so float64 math\n // is exact enough; only the display precision changes.\n const kelvin = toKelvin(value, from as TempUnit)\n // Reject physically impossible temperatures below absolute zero (0 K) rather than silently\n // returning a nonsensical value like \"-1 K = -274.15 °C\". A tiny epsilon absorbs float noise.\n if (kelvin < -1e-9) {\n return `Error: ${value}${TEMP_LABELS[from as TempUnit]} is below absolute zero (0 K); not a physical temperature.`\n }\n const result = fromKelvin(kelvin, to as TempUnit)\n const rounded = formatBig(result, precision)\n return `${value}${TEMP_LABELS[from as TempUnit]} = ${rounded}${TEMP_LABELS[to as TempUnit]}`\n }\n\n const fromDef = UNITS[from]\n const toDef = UNITS[to]\n if (!fromDef) return `Error: Unknown unit \"${from}\". Supported: ${ALL_UNIT_KEYS}`\n if (!toDef) return `Error: Unknown unit \"${to}\". Supported: ${ALL_UNIT_KEYS}`\n if (fromDef.category !== toDef.category) {\n return `Error: Cannot convert \"${from}\" (${fromDef.category}) to \"${to}\" (${toDef.category}) — different categories.`\n }\n\n // `value * fromFactor / toFactor` in BigNumber so huge ratios (e.g. TB→bit) don't overflow to\n // Infinity, tiny ratios (e.g. in→km) don't underflow to 0, and safe integers keep full digits.\n const result = bigScale(value, fromDef.factor, toDef.factor)\n const rounded = formatBig(result, precision)\n return `${value} ${fromDef.label} = ${rounded} ${toDef.label}`\n },\n})\n"],"mappings":";;;;;;;;;;;;;;AAgBA,IAAM,QAAiC;CAErC,GAAG;EAAE,UAAU;EAAU,QAAQ;EAAG,OAAO;CAAS;CACpD,IAAI;EAAE,UAAU;EAAU,QAAQ;EAAM,OAAO;CAAa;CAC5D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,0DAA0D;EACzE,WAAW,UACR,OAAO,EACP,QAAA,CAAyB,EACzB,YAAY,gDAAmE;CACpF,CAAC;CACD,SAAS,OAAO,SAAS;EACvB,MAAM,EAAE,OAAO,MAAM,IAAI,cAAc;EAOvC,IAAI,WAAW,IAAI,IAAI,KAAK,WAAW,IAAI,EAAE,GAAG;GAC9C,IAAI,CAAC,WAAW,IAAI,IAAI,GACtB,OAAO,WAAW,KAAK;GACzB,IAAI,CAAC,WAAW,IAAI,EAAE,GAAG,OAAO,WAAW,GAAG;GAG9C,MAAM,SAAS,SAAS,OAAO,IAAgB;GAG/C,IAAI,SAAS,OACX,OAAO,UAAU,QAAQ,YAAY,MAAkB;GAGzD,MAAM,UAAU,UADD,WAAW,QAAQ,EACR,GAAQ,SAAS;GAC3C,OAAO,GAAG,QAAQ,YAAY,MAAkB,KAAK,UAAU,YAAY;EAC7E;EAEA,MAAM,UAAU,MAAM;EACtB,MAAM,QAAQ,MAAM;EACpB,IAAI,CAAC,SAAS,OAAO,wBAAwB,KAAK,gBAAgB;EAClE,IAAI,CAAC,OAAO,OAAO,wBAAwB,GAAG,gBAAgB;EAC9D,IAAI,QAAQ,aAAa,MAAM,UAC7B,OAAO,0BAA0B,KAAK,KAAK,QAAQ,SAAS,QAAQ,GAAG,KAAK,MAAM,SAAS;EAM7F,MAAM,UAAU,UADD,SAAS,OAAO,QAAQ,QAAQ,MAAM,MAC3B,GAAQ,SAAS;EAC3C,OAAO,GAAG,MAAM,GAAG,QAAQ,MAAM,KAAK,QAAQ,GAAG,MAAM;CACzD;AACF,CAAC"}
@@ -12,6 +12,7 @@ const require_batteries_tools_math = require("./tools/math.cjs");
12
12
  const require_batteries_tools_memory = require("./tools/memory.cjs");
13
13
  const require_batteries_tools_parsing = require("./tools/parsing.cjs");
14
14
  const require_batteries_tools_retrievables = require("./tools/retrievables.cjs");
15
+ const require_searxng = require("../searxng-Bkrwhwhw.js");
15
16
  const require_batteries_tools_standing_instructions = require("./tools/standing_instructions.cjs");
16
17
  const require_batteries_tools_statistics = require("./tools/statistics.cjs");
17
18
  const require_batteries_tools_string_processing = require("./tools/string_processing.cjs");
@@ -20,6 +21,7 @@ const require_batteries_tools_text_analysis = require("./tools/text_analysis.cjs
20
21
  const require_batteries_tools_text_comparison = require("./tools/text_comparison.cjs");
21
22
  const require_batteries_tools_time = require("./tools/time.cjs");
22
23
  const require_batteries_tools_unit_conversion = require("./tools/unit_conversion.cjs");
24
+ exports.E_INVALID_SEARXNG_CONFIG = require_searxng.E_INVALID_SEARXNG_CONFIG;
23
25
  exports.addStandingInstructionTool = require_batteries_tools_standing_instructions.addStandingInstructionTool;
24
26
  exports.calculateTool = require_batteries_tools_math.calculateTool;
25
27
  exports.colorAdjustTool = require_batteries_tools_color.colorAdjustTool;
@@ -29,6 +31,7 @@ exports.compareRecordsTool = require_batteries_tools_comparison.compareRecordsTo
29
31
  exports.compareValuesTool = require_batteries_tools_comparison.compareValuesTool;
30
32
  exports.convertTimeTool = require_batteries_tools_time.convertTimeTool;
31
33
  exports.convertUnitTool = require_batteries_tools_unit_conversion.convertUnitTool;
34
+ exports.createSearxngSearchTool = require_searxng.createSearxngSearchTool;
32
35
  exports.dateAddTool = require_batteries_tools_datetime_math.dateAddTool;
33
36
  exports.dateBusinessDaysTool = require_batteries_tools_datetime_extended.dateBusinessDaysTool;
34
37
  exports.dateCalendarInfoTool = require_batteries_tools_datetime_extended.dateCalendarInfoTool;
@@ -10,6 +10,7 @@ import { calculateTool, evaluateKatexTool } from "./tools/math.mjs";
10
10
  import { deleteMemoryTool, listMemoriesTool, memoryTools, storeMemoryTool, updateMemoryTool } from "./tools/memory.mjs";
11
11
  import { detectDelimiterTool, parseCsvTool, parseKvTool, parseYamlTool } from "./tools/parsing.mjs";
12
12
  import { deleteRetrievableTool, listRetrievablesTool, retrievableTools, storeRetrievableTool, updateRetrievableTool } from "./tools/retrievables.mjs";
13
+ import { n as E_INVALID_SEARXNG_CONFIG, t as createSearxngSearchTool } from "../searxng-CyA-nEu5.mjs";
13
14
  import { addStandingInstructionTool, listStandingInstructionsTool, removeStandingInstructionTool, standingInstructionTools } from "./tools/standing_instructions.mjs";
14
15
  import { statsCorrelateTool, statsDescribeTool, statsHistogramTool, statsTransformTool } from "./tools/statistics.mjs";
15
16
  import { stringExtractTool, stringTransformTool } from "./tools/string_processing.mjs";
@@ -18,4 +19,4 @@ import { textAnalyzeTool, textLinesTool } from "./tools/text_analysis.mjs";
18
19
  import { stringSimilarityTool, textDiffTool } from "./tools/text_comparison.mjs";
19
20
  import { convertTimeTool, getCurrentTimeTool } from "./tools/time.mjs";
20
21
  import { convertUnitTool } from "./tools/unit_conversion.mjs";
21
- export { addStandingInstructionTool, calculateTool, colorAdjustTool, colorContrastTool, colorSchemeTool, compareRecordsTool, compareValuesTool, convertTimeTool, convertUnitTool, dateAddTool, dateBusinessDaysTool, dateCalendarInfoTool, dateDiffTool, dateNthWeekdayTool, dateParseTool, datePeriodTool, deleteMemoryTool, deleteRetrievableTool, detectDelimiterTool, durationFormatTool, encodeTextTool, evaluateKatexTool, formatListTool, formatNumberTool, formatTableTool, geoBboxContainsTool, geoDistanceTool, geoWithinRadiusTool, getCurrentTimeTool, jsonFormatTool, jsonTransformTool, listMemoriesTool, listRetrievablesTool, listStandingInstructionsTool, memoryTools, parseCsvTool, parseKvTool, parseYamlTool, removeStandingInstructionTool, retrievableTools, setOperationsTool, standingInstructionTools, statsCorrelateTool, statsDescribeTool, statsHistogramTool, statsTransformTool, storeMemoryTool, storeRetrievableTool, stringExtractTool, stringSimilarityTool, stringTransformTool, textAnalyzeTool, textDiffTool, textEscapeTool, textLinesTool, unicodeNormalizeTool, updateMemoryTool, updateRetrievableTool, validateFormatTool };
22
+ export { E_INVALID_SEARXNG_CONFIG, addStandingInstructionTool, calculateTool, colorAdjustTool, colorContrastTool, colorSchemeTool, compareRecordsTool, compareValuesTool, convertTimeTool, convertUnitTool, createSearxngSearchTool, dateAddTool, dateBusinessDaysTool, dateCalendarInfoTool, dateDiffTool, dateNthWeekdayTool, dateParseTool, datePeriodTool, deleteMemoryTool, deleteRetrievableTool, detectDelimiterTool, durationFormatTool, encodeTextTool, evaluateKatexTool, formatListTool, formatNumberTool, formatTableTool, geoBboxContainsTool, geoDistanceTool, geoWithinRadiusTool, getCurrentTimeTool, jsonFormatTool, jsonTransformTool, listMemoriesTool, listRetrievablesTool, listStandingInstructionsTool, memoryTools, parseCsvTool, parseKvTool, parseYamlTool, removeStandingInstructionTool, retrievableTools, setOperationsTool, standingInstructionTools, statsCorrelateTool, statsDescribeTool, statsHistogramTool, statsTransformTool, storeMemoryTool, storeRetrievableTool, stringExtractTool, stringSimilarityTool, stringTransformTool, textAnalyzeTool, textDiffTool, textEscapeTool, textLinesTool, unicodeNormalizeTool, updateMemoryTool, updateRetrievableTool, validateFormatTool };
@@ -13,6 +13,7 @@ import { BaseVectorStore } from "../contract";
13
13
  import type { SearchPlan, UpsertPlan, DeletePlan, CollectionSpec } from "../plan";
14
14
  import type { VectorMatch, VectorStoreCapabilities, BaseVectorStoreOptions } from "../types";
15
15
  export interface ArangoDBVectorStoreOptions extends BaseVectorStoreOptions {
16
+ /** Connection and authentication parameters for the backend. */
16
17
  connection: {
17
18
  url: string;
18
19
  username?: string;
@@ -24,6 +25,7 @@ export interface ArangoDBVectorStoreOptions extends BaseVectorStoreOptions {
24
25
  export declare class ArangoDBVectorStore extends BaseVectorStore {
25
26
  #private;
26
27
  readonly capabilities: VectorStoreCapabilities;
28
+ /** Static availability probe: whether this adapter's runtime driver can load in the current environment. */
27
29
  static isAvailable(): boolean;
28
30
  isAvailable(): boolean;
29
31
  connect(): Promise<void>;
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("../../chunk-Ble4zEEl.js");
3
- const require_tool_registry = require("../../tool_registry-DYUYqXvo.js");
3
+ const require_tool_registry = require("../../tool_registry-CKJPze3j.js");
4
4
  require("../../guards.cjs");
5
5
  const require_batteries_vector_filters = require("./filters.cjs");
6
6
  const require_batteries_vector_exceptions = require("./exceptions.cjs");
@@ -45,6 +45,7 @@ var ArangoDBVectorStore = class extends require_batteries_vector_contract.BaseVe
45
45
  get #opts() {
46
46
  return this.options;
47
47
  }
48
+ /** Static availability probe: whether this adapter's runtime driver can load in the current environment. */
48
49
  static isAvailable() {
49
50
  return typeof process !== "undefined";
50
51
  }
@@ -1 +1 @@
1
- {"version":3,"file":"arangodb.cjs","names":["#opts","#db","#aql","#ensure","#dims","#indexed","#ensureVectorIndex","#parseMeta","#project"],"sources":["../../../src/batteries/vector/arangodb/index.ts"],"sourcesContent":["/**\n * @module @nhtio/adk/batteries/vector/arangodb\n *\n * ArangoDB adapter (experimental vector index, 3.12.4+). Each collection is an ArangoDB\n * document collection keyed by `_key`; a `vector` index on `vec` enables KNN via\n * `APPROX_NEAR_COSINE` / `APPROX_NEAR_L2`. Metadata is a JSON string attribute filtered with\n * the neutral filter tree's JS reference evaluator for exact cross-adapter parity.\n *\n * Driver: `arangojs` (pure JS). Requires the server started with\n * `--experimental-vector-index=true`. All values are passed as AQL bind parameters.\n */\n\nimport { evaluateFilter } from '../filters'\nimport { BaseVectorStore } from '../contract'\nimport { validateRecords } from '../validation'\nimport { isInstanceOf } from '@nhtio/adk/guards'\nimport {\n E_VECTOR_STORE_DRIVER_UNAVAILABLE,\n E_VECTOR_STORE_CONNECTION_FAILED,\n E_VECTOR_STORE_COLLECTION_FAILED,\n E_VECTOR_STORE_UPSERT_FAILED,\n E_VECTOR_STORE_SEARCH_FAILED,\n E_VECTOR_STORE_DELETE_FAILED,\n E_VECTOR_STORE_DIMENSION_MISMATCH,\n E_VECTOR_STORE_UNSUPPORTED_OPERATION,\n} from '../exceptions'\nimport type { SearchPlan, UpsertPlan, DeletePlan, CollectionSpec } from '../plan'\nimport type {\n VectorMatch,\n VectorStoreCapabilities,\n BaseVectorStoreOptions,\n VectorMetadata,\n} from '../types'\n\nexport interface ArangoDBVectorStoreOptions extends BaseVectorStoreOptions {\n connection: {\n url: string\n username?: string\n password?: string\n database?: string\n nLists?: number\n }\n}\n\nconst getArango = async () => {\n try {\n const mod = await import('arangojs')\n return mod\n } catch {\n throw new E_VECTOR_STORE_DRIVER_UNAVAILABLE(['arangojs'])\n }\n}\n\nexport class ArangoDBVectorStore extends BaseVectorStore {\n readonly capabilities: VectorStoreCapabilities = {\n transactions: false,\n namedVectors: false,\n rename: false,\n rawSql: false,\n builtInEncoding: false,\n // Document writes are synchronous (visible on resolve). The option is a no-op.\n consistency: { configurable: false, default: 'strong', modes: ['strong'] },\n }\n\n #db: any | null = null\n #aql: any | null = null\n #dims: Map<string, number> = new Map()\n // ArangoDB's IVF vector index can't be created on an empty collection (\"not ready\") and\n // needs nLists <= doc count. We therefore create the index lazily after the first upsert.\n #indexed: Set<string> = new Set()\n\n get #opts(): ArangoDBVectorStoreOptions {\n return this.options as ArangoDBVectorStoreOptions\n }\n\n static isAvailable(): boolean {\n return typeof process !== 'undefined'\n }\n isAvailable(): boolean {\n return typeof process !== 'undefined'\n }\n\n async connect(): Promise<void> {\n if (this.#db) return\n const arango = await getArango()\n this.#aql = arango.aql\n const c = this.#opts.connection\n const dbName = c.database ?? 'vector'\n try {\n const auth = c.username ? { username: c.username, password: c.password ?? '' } : undefined\n const sys = new arango.Database({ url: c.url, auth })\n const exists = await sys.listDatabases().then((dbs: string[]) => dbs.includes(dbName))\n if (!exists) {\n await sys.createDatabase(dbName)\n }\n this.#db = new arango.Database({ url: c.url, databaseName: dbName, auth })\n } catch (err) {\n throw new E_VECTOR_STORE_CONNECTION_FAILED([String(err)])\n }\n }\n\n async close(): Promise<void> {\n this.#db = null\n this.#aql = null\n }\n\n async #ensure(): Promise<any> {\n if (!this.#db) await this.connect()\n return this.#db!\n }\n\n async createCollection(spec: CollectionSpec, ifNotExists: boolean): Promise<void> {\n const db = await this.#ensure()\n this.#dims.set(spec.collection, spec.vector.dimensions)\n try {\n const col = db.collection(spec.collection)\n const exists = await col.exists()\n if (exists && !ifNotExists) {\n await col.drop()\n this.#indexed.delete(spec.collection)\n }\n if (!(await col.exists())) {\n await col.create()\n this.#indexed.delete(spec.collection)\n }\n // The vector index is created lazily on first upsert (see #ensureVectorIndex): ArangoDB\n // rejects creating it on an empty collection (\"vector index not ready\").\n } catch (err) {\n throw new E_VECTOR_STORE_COLLECTION_FAILED(['createCollection', String(err)])\n }\n }\n\n // Create the IVF vector index once the collection has data (idempotent per collection).\n async #ensureVectorIndex(collection: string): Promise<void> {\n if (this.#indexed.has(collection)) return\n const db = await this.#ensure()\n const col = db.collection(collection)\n const metric = this.#opts.metric ?? 'cosine'\n const dim = this.#dims.get(collection) ?? this.#opts.dimensions\n if (dim === undefined) return\n try {\n await col.ensureIndex({\n type: 'vector',\n fields: ['vec'],\n params: {\n metric: metric === 'euclidean' ? 'l2' : 'cosine',\n dimension: dim,\n nLists: this.#opts.connection.nLists ?? 1,\n },\n })\n this.#indexed.add(collection)\n } catch {\n // If it still isn't ready (too few docs), leave it; executeSearch falls back to a\n // brute-force AQL scan so correctness holds regardless of the index.\n }\n }\n\n async dropCollection(collection: string, ifExists: boolean): Promise<void> {\n const db = await this.#ensure()\n try {\n const col = db.collection(collection)\n if (await col.exists()) {\n await col.drop()\n } else if (!ifExists) {\n throw new Error('collection not found: ' + collection)\n }\n this.#dims.delete(collection)\n } catch (err) {\n throw new E_VECTOR_STORE_COLLECTION_FAILED(['dropCollection', String(err)])\n }\n }\n\n async hasCollection(collection: string): Promise<boolean> {\n const db = await this.#ensure()\n try {\n return await db.collection(collection).exists()\n } catch {\n return false\n }\n }\n\n async renameCollection(_from: string, _to: string): Promise<void> {\n throw new E_VECTOR_STORE_UNSUPPORTED_OPERATION(['renameCollection', 'arangodb'])\n }\n\n async executeUpsert(plan: UpsertPlan): Promise<void> {\n if (plan.records.length === 0) return\n validateRecords(plan.records)\n const db = await this.#ensure()\n const expected = this.#opts.dimensions ?? this.#dims.get(plan.collection)\n try {\n const col = db.collection(plan.collection)\n for (const r of plan.records) {\n let vector = r.vector\n if (!vector && r.document) {\n const [v] = await this.encode([r.document], 'document')\n vector = v\n }\n if (!vector) {\n throw new E_VECTOR_STORE_UPSERT_FAILED(['Record missing vector and document'])\n }\n if (expected !== undefined && vector.length !== expected) {\n throw new E_VECTOR_STORE_DIMENSION_MISMATCH([expected, vector.length])\n }\n const doc = {\n _key: r.id,\n vec: vector,\n document: r.document ?? '',\n metadata: r.metadata ? JSON.stringify(r.metadata) : '{}',\n }\n await col.save(doc, { overwriteMode: 'replace' })\n }\n // Now that the collection has data, ensure the IVF vector index exists.\n await this.#ensureVectorIndex(plan.collection)\n } catch (err) {\n if (\n isInstanceOf(err, 'E_VECTOR_STORE_DIMENSION_MISMATCH', E_VECTOR_STORE_DIMENSION_MISMATCH) ||\n isInstanceOf(err, 'E_VECTOR_STORE_UPSERT_FAILED', E_VECTOR_STORE_UPSERT_FAILED)\n ) {\n throw err\n }\n throw new E_VECTOR_STORE_UPSERT_FAILED([String(err)])\n }\n }\n\n async executeSearch(plan: SearchPlan): Promise<VectorMatch[]> {\n const db = await this.#ensure()\n const aql = this.#aql\n const metric = this.#opts.metric ?? 'cosine'\n let queryVector: number[] | undefined\n if (plan.near) {\n if ('vector' in plan.near) {\n queryVector = plan.near.vector\n } else if ('serverText' in plan.near) {\n const [v] = await this.encode([plan.near.serverText], 'query')\n queryVector = v\n } else if ('id' in plan.near) {\n const col = db.collection(plan.collection)\n try {\n const doc = await col.document(plan.near.id)\n queryVector = doc.vec as number[]\n } catch {\n throw new E_VECTOR_STORE_SEARCH_FAILED(['Referenced id not found: ' + plan.near.id])\n }\n }\n }\n\n const offset = plan.offset ?? 0\n try {\n let rows: any[]\n if (queryVector) {\n // Use the exact AQL distance functions (COSINE_SIMILARITY / L2_DISTANCE) rather than the\n // APPROX_NEAR_* index functions: they need no index, are always correct, and avoid\n // ArangoDB's IVF \"not ready\" / nLists-vs-doc-count constraints. The IVF index is still\n // created lazily on upsert for production-scale ANN; here correctness comes first.\n const useL2 = metric === 'euclidean'\n const fn = useL2 ? 'L2_DISTANCE' : 'COSINE_SIMILARITY'\n const dir = useL2 ? 'ASC' : 'DESC'\n const k = plan.filter ? 100000 : plan.topK + offset\n const query =\n `FOR d IN @@col ` +\n `LET __score = ${fn}(d.vec, @qv) ` +\n `SORT __score ${dir} LIMIT @k ` +\n `RETURN { id: d._key, vec: d.vec, document: d.document, metadata: d.metadata, score: __score }`\n const cursor = await db.query(query, {\n '@col': plan.collection,\n 'qv': queryVector,\n k,\n })\n rows = await cursor.all()\n const filtered = plan.filter\n ? rows.filter((row) => evaluateFilter(plan.filter!, this.#parseMeta(row.metadata)))\n : rows\n return filtered\n .slice(offset, offset + plan.topK)\n .map((row) => this.#project(row, plan, true))\n } else {\n const cursor = await db.query(\n aql`FOR d IN ${db.collection(plan.collection)} RETURN { id: d._key, vec: d.vec, document: d.document, metadata: d.metadata }`\n )\n rows = await cursor.all()\n const filtered = plan.filter\n ? rows.filter((row) => evaluateFilter(plan.filter!, this.#parseMeta(row.metadata)))\n : rows\n return filtered\n .slice(offset, offset + plan.topK)\n .map((row) => this.#project(row, plan, false))\n }\n } catch (err) {\n throw new E_VECTOR_STORE_SEARCH_FAILED([String(err)])\n }\n }\n\n #parseMeta(val: unknown): VectorMetadata {\n if (typeof val === 'string') {\n try {\n return JSON.parse(val) as VectorMetadata\n } catch {\n return {}\n }\n }\n if (val && typeof val === 'object') return val as VectorMetadata\n return {}\n }\n\n #project(row: any, plan: SearchPlan, isKnn: boolean): VectorMatch {\n const proj = plan.projection\n const out: VectorMatch = {}\n if (proj.id) out.id = row.id as string\n if (proj.vector && Array.isArray(row.vec)) out.vector = (row.vec as number[]).map(Number)\n if (proj.document) out.document = (row.document ?? undefined) as string | undefined\n if (proj.metadata) out.metadata = this.#parseMeta(row.metadata)\n if (isKnn && row.score !== undefined && row.score !== null) {\n // APPROX_NEAR_COSINE returns cosine similarity in [0,1]; L2 returns a distance.\n const m = this.#opts.metric ?? 'cosine'\n out.score = m === 'euclidean' ? 1 / (1 + Number(row.score)) : Number(row.score)\n }\n return out\n }\n\n async executeDelete(plan: DeletePlan): Promise<void> {\n const db = await this.#ensure()\n const aql = this.#aql\n try {\n const col = db.collection(plan.collection)\n if (plan.ids && plan.ids.length > 0) {\n await col.removeAll(plan.ids).catch(async () => {\n for (const id of plan.ids!) await col.remove(id).catch(() => undefined)\n })\n } else if (plan.filter) {\n const cursor = await db.query(\n aql`FOR d IN ${col} RETURN { id: d._key, metadata: d.metadata }`\n )\n const rows = await cursor.all()\n const targets = rows\n .filter((row: any) => evaluateFilter(plan.filter!, this.#parseMeta(row.metadata)))\n .map((row: any) => row.id as string)\n if (targets.length > 0) {\n await col.removeAll(targets).catch(async () => {\n for (const id of targets) await col.remove(id).catch(() => undefined)\n })\n }\n } else {\n await col.truncate()\n }\n } catch (err) {\n throw new E_VECTOR_STORE_DELETE_FAILED([String(err)])\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA4CA,IAAM,YAAY,YAAY;CAC5B,IAAI;EAEF,OAAO,MADW,OAAO;CAE3B,QAAQ;EACN,MAAM,IAAI,oCAAA,kCAAkC,CAAC,UAAU,CAAC;CAC1D;AACF;AAEA,IAAa,sBAAb,cAAyC,kCAAA,gBAAgB;CACvD,eAAiD;EAC/C,cAAc;EACd,cAAc;EACd,QAAQ;EACR,QAAQ;EACR,iBAAiB;EAEjB,aAAa;GAAE,cAAc;GAAO,SAAS;GAAU,OAAO,CAAC,QAAQ;EAAE;CAC3E;CAEA,MAAkB;CAClB,OAAmB;CACnB,wBAA6B,IAAI,IAAI;CAGrC,2BAAwB,IAAI,IAAI;CAEhC,IAAIA,QAAoC;EACtC,OAAO,KAAK;CACd;CAEA,OAAO,cAAuB;EAC5B,OAAO,OAAO,YAAY;CAC5B;CACA,cAAuB;EACrB,OAAO,OAAO,YAAY;CAC5B;CAEA,MAAM,UAAyB;EAC7B,IAAI,KAAKC,KAAK;EACd,MAAM,SAAS,MAAM,UAAU;EAC/B,KAAKC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AAC,CAAC,EAChF,KAAK,QAAa,IAAI,EAAY;IACrC,IAAI,QAAQ,SAAS,GACnB,MAAM,IAAI,UAAU,OAAO,EAAE,MAAM,YAAY;KAC7C,KAAK,MAAM,MAAM,SAAS,MAAM,IAAI,OAAO,EAAE,EAAE,YAAY,KAAA,CAAS;IACtE,CAAC;GAEL,OACE,MAAM,IAAI,SAAS;EAEvB,SAAS,KAAK;GACZ,MAAM,IAAI,oCAAA,6BAA6B,CAAC,OAAO,GAAG,CAAC,CAAC;EACtD;CACF;AACF"}
1
+ {"version":3,"file":"arangodb.cjs","names":["#opts","#db","#aql","#ensure","#dims","#indexed","#ensureVectorIndex","#parseMeta","#project"],"sources":["../../../src/batteries/vector/arangodb/index.ts"],"sourcesContent":["/**\n * @module @nhtio/adk/batteries/vector/arangodb\n *\n * ArangoDB adapter (experimental vector index, 3.12.4+). Each collection is an ArangoDB\n * document collection keyed by `_key`; a `vector` index on `vec` enables KNN via\n * `APPROX_NEAR_COSINE` / `APPROX_NEAR_L2`. Metadata is a JSON string attribute filtered with\n * the neutral filter tree's JS reference evaluator for exact cross-adapter parity.\n *\n * Driver: `arangojs` (pure JS). Requires the server started with\n * `--experimental-vector-index=true`. All values are passed as AQL bind parameters.\n */\n\nimport { evaluateFilter } from '../filters'\nimport { BaseVectorStore } from '../contract'\nimport { validateRecords } from '../validation'\nimport { isInstanceOf } from '@nhtio/adk/guards'\nimport {\n E_VECTOR_STORE_DRIVER_UNAVAILABLE,\n E_VECTOR_STORE_CONNECTION_FAILED,\n E_VECTOR_STORE_COLLECTION_FAILED,\n E_VECTOR_STORE_UPSERT_FAILED,\n E_VECTOR_STORE_SEARCH_FAILED,\n E_VECTOR_STORE_DELETE_FAILED,\n E_VECTOR_STORE_DIMENSION_MISMATCH,\n E_VECTOR_STORE_UNSUPPORTED_OPERATION,\n} from '../exceptions'\nimport type { SearchPlan, UpsertPlan, DeletePlan, CollectionSpec } from '../plan'\nimport type {\n VectorMatch,\n VectorStoreCapabilities,\n BaseVectorStoreOptions,\n VectorMetadata,\n} from '../types'\n\nexport interface ArangoDBVectorStoreOptions extends BaseVectorStoreOptions {\n /** Connection and authentication parameters for the backend. */\n connection: {\n url: string\n username?: string\n password?: string\n database?: string\n nLists?: number\n }\n}\n\nconst getArango = async () => {\n try {\n const mod = await import('arangojs')\n return mod\n } catch {\n throw new E_VECTOR_STORE_DRIVER_UNAVAILABLE(['arangojs'])\n }\n}\n\nexport class ArangoDBVectorStore extends BaseVectorStore {\n readonly capabilities: VectorStoreCapabilities = {\n transactions: false,\n namedVectors: false,\n rename: false,\n rawSql: false,\n builtInEncoding: false,\n // Document writes are synchronous (visible on resolve). The option is a no-op.\n consistency: { configurable: false, default: 'strong', modes: ['strong'] },\n }\n\n #db: any | null = null\n #aql: any | null = null\n #dims: Map<string, number> = new Map()\n // ArangoDB's IVF vector index can't be created on an empty collection (\"not ready\") and\n // needs nLists <= doc count. We therefore create the index lazily after the first upsert.\n #indexed: Set<string> = new Set()\n\n get #opts(): ArangoDBVectorStoreOptions {\n return this.options as ArangoDBVectorStoreOptions\n }\n\n /** Static availability probe: whether this adapter's runtime driver can load in the current environment. */\n static isAvailable(): boolean {\n return typeof process !== 'undefined'\n }\n isAvailable(): boolean {\n return typeof process !== 'undefined'\n }\n\n async connect(): Promise<void> {\n if (this.#db) return\n const arango = await getArango()\n this.#aql = arango.aql\n const c = this.#opts.connection\n const dbName = c.database ?? 'vector'\n try {\n const auth = c.username ? { username: c.username, password: c.password ?? '' } : undefined\n const sys = new arango.Database({ url: c.url, auth })\n const exists = await sys.listDatabases().then((dbs: string[]) => dbs.includes(dbName))\n if (!exists) {\n await sys.createDatabase(dbName)\n }\n this.#db = new arango.Database({ url: c.url, databaseName: dbName, auth })\n } catch (err) {\n throw new E_VECTOR_STORE_CONNECTION_FAILED([String(err)])\n }\n }\n\n async close(): Promise<void> {\n this.#db = null\n this.#aql = null\n }\n\n async #ensure(): Promise<any> {\n if (!this.#db) await this.connect()\n return this.#db!\n }\n\n async createCollection(spec: CollectionSpec, ifNotExists: boolean): Promise<void> {\n const db = await this.#ensure()\n this.#dims.set(spec.collection, spec.vector.dimensions)\n try {\n const col = db.collection(spec.collection)\n const exists = await col.exists()\n if (exists && !ifNotExists) {\n await col.drop()\n this.#indexed.delete(spec.collection)\n }\n if (!(await col.exists())) {\n await col.create()\n this.#indexed.delete(spec.collection)\n }\n // The vector index is created lazily on first upsert (see #ensureVectorIndex): ArangoDB\n // rejects creating it on an empty collection (\"vector index not ready\").\n } catch (err) {\n throw new E_VECTOR_STORE_COLLECTION_FAILED(['createCollection', String(err)])\n }\n }\n\n // Create the IVF vector index once the collection has data (idempotent per collection).\n async #ensureVectorIndex(collection: string): Promise<void> {\n if (this.#indexed.has(collection)) return\n const db = await this.#ensure()\n const col = db.collection(collection)\n const metric = this.#opts.metric ?? 'cosine'\n const dim = this.#dims.get(collection) ?? this.#opts.dimensions\n if (dim === undefined) return\n try {\n await col.ensureIndex({\n type: 'vector',\n fields: ['vec'],\n params: {\n metric: metric === 'euclidean' ? 'l2' : 'cosine',\n dimension: dim,\n nLists: this.#opts.connection.nLists ?? 1,\n },\n })\n this.#indexed.add(collection)\n } catch {\n // If it still isn't ready (too few docs), leave it; executeSearch falls back to a\n // brute-force AQL scan so correctness holds regardless of the index.\n }\n }\n\n async dropCollection(collection: string, ifExists: boolean): Promise<void> {\n const db = await this.#ensure()\n try {\n const col = db.collection(collection)\n if (await col.exists()) {\n await col.drop()\n } else if (!ifExists) {\n throw new Error('collection not found: ' + collection)\n }\n this.#dims.delete(collection)\n } catch (err) {\n throw new E_VECTOR_STORE_COLLECTION_FAILED(['dropCollection', String(err)])\n }\n }\n\n async hasCollection(collection: string): Promise<boolean> {\n const db = await this.#ensure()\n try {\n return await db.collection(collection).exists()\n } catch {\n return false\n }\n }\n\n async renameCollection(_from: string, _to: string): Promise<void> {\n throw new E_VECTOR_STORE_UNSUPPORTED_OPERATION(['renameCollection', 'arangodb'])\n }\n\n async executeUpsert(plan: UpsertPlan): Promise<void> {\n if (plan.records.length === 0) return\n validateRecords(plan.records)\n const db = await this.#ensure()\n const expected = this.#opts.dimensions ?? this.#dims.get(plan.collection)\n try {\n const col = db.collection(plan.collection)\n for (const r of plan.records) {\n let vector = r.vector\n if (!vector && r.document) {\n const [v] = await this.encode([r.document], 'document')\n vector = v\n }\n if (!vector) {\n throw new E_VECTOR_STORE_UPSERT_FAILED(['Record missing vector and document'])\n }\n if (expected !== undefined && vector.length !== expected) {\n throw new E_VECTOR_STORE_DIMENSION_MISMATCH([expected, vector.length])\n }\n const doc = {\n _key: r.id,\n vec: vector,\n document: r.document ?? '',\n metadata: r.metadata ? JSON.stringify(r.metadata) : '{}',\n }\n await col.save(doc, { overwriteMode: 'replace' })\n }\n // Now that the collection has data, ensure the IVF vector index exists.\n await this.#ensureVectorIndex(plan.collection)\n } catch (err) {\n if (\n isInstanceOf(err, 'E_VECTOR_STORE_DIMENSION_MISMATCH', E_VECTOR_STORE_DIMENSION_MISMATCH) ||\n isInstanceOf(err, 'E_VECTOR_STORE_UPSERT_FAILED', E_VECTOR_STORE_UPSERT_FAILED)\n ) {\n throw err\n }\n throw new E_VECTOR_STORE_UPSERT_FAILED([String(err)])\n }\n }\n\n async executeSearch(plan: SearchPlan): Promise<VectorMatch[]> {\n const db = await this.#ensure()\n const aql = this.#aql\n const metric = this.#opts.metric ?? 'cosine'\n let queryVector: number[] | undefined\n if (plan.near) {\n if ('vector' in plan.near) {\n queryVector = plan.near.vector\n } else if ('serverText' in plan.near) {\n const [v] = await this.encode([plan.near.serverText], 'query')\n queryVector = v\n } else if ('id' in plan.near) {\n const col = db.collection(plan.collection)\n try {\n const doc = await col.document(plan.near.id)\n queryVector = doc.vec as number[]\n } catch {\n throw new E_VECTOR_STORE_SEARCH_FAILED(['Referenced id not found: ' + plan.near.id])\n }\n }\n }\n\n const offset = plan.offset ?? 0\n try {\n let rows: any[]\n if (queryVector) {\n // Use the exact AQL distance functions (COSINE_SIMILARITY / L2_DISTANCE) rather than the\n // APPROX_NEAR_* index functions: they need no index, are always correct, and avoid\n // ArangoDB's IVF \"not ready\" / nLists-vs-doc-count constraints. The IVF index is still\n // created lazily on upsert for production-scale ANN; here correctness comes first.\n const useL2 = metric === 'euclidean'\n const fn = useL2 ? 'L2_DISTANCE' : 'COSINE_SIMILARITY'\n const dir = useL2 ? 'ASC' : 'DESC'\n const k = plan.filter ? 100000 : plan.topK + offset\n const query =\n `FOR d IN @@col ` +\n `LET __score = ${fn}(d.vec, @qv) ` +\n `SORT __score ${dir} LIMIT @k ` +\n `RETURN { id: d._key, vec: d.vec, document: d.document, metadata: d.metadata, score: __score }`\n const cursor = await db.query(query, {\n '@col': plan.collection,\n 'qv': queryVector,\n k,\n })\n rows = await cursor.all()\n const filtered = plan.filter\n ? rows.filter((row) => evaluateFilter(plan.filter!, this.#parseMeta(row.metadata)))\n : rows\n return filtered\n .slice(offset, offset + plan.topK)\n .map((row) => this.#project(row, plan, true))\n } else {\n const cursor = await db.query(\n aql`FOR d IN ${db.collection(plan.collection)} RETURN { id: d._key, vec: d.vec, document: d.document, metadata: d.metadata }`\n )\n rows = await cursor.all()\n const filtered = plan.filter\n ? rows.filter((row) => evaluateFilter(plan.filter!, this.#parseMeta(row.metadata)))\n : rows\n return filtered\n .slice(offset, offset + plan.topK)\n .map((row) => this.#project(row, plan, false))\n }\n } catch (err) {\n throw new E_VECTOR_STORE_SEARCH_FAILED([String(err)])\n }\n }\n\n #parseMeta(val: unknown): VectorMetadata {\n if (typeof val === 'string') {\n try {\n return JSON.parse(val) as VectorMetadata\n } catch {\n return {}\n }\n }\n if (val && typeof val === 'object') return val as VectorMetadata\n return {}\n }\n\n #project(row: any, plan: SearchPlan, isKnn: boolean): VectorMatch {\n const proj = plan.projection\n const out: VectorMatch = {}\n if (proj.id) out.id = row.id as string\n if (proj.vector && Array.isArray(row.vec)) out.vector = (row.vec as number[]).map(Number)\n if (proj.document) out.document = (row.document ?? undefined) as string | undefined\n if (proj.metadata) out.metadata = this.#parseMeta(row.metadata)\n if (isKnn && row.score !== undefined && row.score !== null) {\n // APPROX_NEAR_COSINE returns cosine similarity in [0,1]; L2 returns a distance.\n const m = this.#opts.metric ?? 'cosine'\n out.score = m === 'euclidean' ? 1 / (1 + Number(row.score)) : Number(row.score)\n }\n return out\n }\n\n async executeDelete(plan: DeletePlan): Promise<void> {\n const db = await this.#ensure()\n const aql = this.#aql\n try {\n const col = db.collection(plan.collection)\n if (plan.ids && plan.ids.length > 0) {\n await col.removeAll(plan.ids).catch(async () => {\n for (const id of plan.ids!) await col.remove(id).catch(() => undefined)\n })\n } else if (plan.filter) {\n const cursor = await db.query(\n aql`FOR d IN ${col} RETURN { id: d._key, metadata: d.metadata }`\n )\n const rows = await cursor.all()\n const targets = rows\n .filter((row: any) => evaluateFilter(plan.filter!, this.#parseMeta(row.metadata)))\n .map((row: any) => row.id as string)\n if (targets.length > 0) {\n await col.removeAll(targets).catch(async () => {\n for (const id of targets) await col.remove(id).catch(() => undefined)\n })\n }\n } else {\n await col.truncate()\n }\n } catch (err) {\n throw new E_VECTOR_STORE_DELETE_FAILED([String(err)])\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA6CA,IAAM,YAAY,YAAY;CAC5B,IAAI;EAEF,OAAO,MADW,OAAO;CAE3B,QAAQ;EACN,MAAM,IAAI,oCAAA,kCAAkC,CAAC,UAAU,CAAC;CAC1D;AACF;AAEA,IAAa,sBAAb,cAAyC,kCAAA,gBAAgB;CACvD,eAAiD;EAC/C,cAAc;EACd,cAAc;EACd,QAAQ;EACR,QAAQ;EACR,iBAAiB;EAEjB,aAAa;GAAE,cAAc;GAAO,SAAS;GAAU,OAAO,CAAC,QAAQ;EAAE;CAC3E;CAEA,MAAkB;CAClB,OAAmB;CACnB,wBAA6B,IAAI,IAAI;CAGrC,2BAAwB,IAAI,IAAI;CAEhC,IAAIA,QAAoC;EACtC,OAAO,KAAK;CACd;;CAGA,OAAO,cAAuB;EAC5B,OAAO,OA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,MAAM,WAAU,OADG,MAHE,GAAG,MACtB,GAAG,YAAY,IAAI,6CACrB,GAC0B,IAAI,GAE3B,QAAQ,QAAa,iCAAA,eAAe,KAAK,QAAS,KAAKK,WAAW,IAAI,QAAQ,CAAC,CAAC,EAChF,KAAK,QAAa,IAAI,EAAY;IACrC,IAAI,QAAQ,SAAS,GACnB,MAAM,IAAI,UAAU,OAAO,EAAE,MAAM,YAAY;KAC7C,KAAK,MAAM,MAAM,SAAS,MAAM,IAAI,OAAO,EAAE,EAAE,YAAY,KAAA,CAAS;IACtE,CAAC;GAEL,OACE,MAAM,IAAI,SAAS;EAEvB,SAAS,KAAK;GACZ,MAAM,IAAI,oCAAA,6BAA6B,CAAC,OAAO,GAAG,CAAC,CAAC;EACtD;CACF;AACF"}
@@ -1,4 +1,4 @@
1
- import { s as isInstanceOf } from "../../tool_registry-D1pSSlsd.mjs";
1
+ import { s as isInstanceOf } from "../../tool_registry-791Vrjtf.mjs";
2
2
  import "../../guards.mjs";
3
3
  import { evaluateFilter } from "./filters.mjs";
4
4
  import { E_VECTOR_STORE_COLLECTION_FAILED, E_VECTOR_STORE_CONNECTION_FAILED, E_VECTOR_STORE_DELETE_FAILED, E_VECTOR_STORE_DIMENSION_MISMATCH, E_VECTOR_STORE_DRIVER_UNAVAILABLE, E_VECTOR_STORE_SEARCH_FAILED, E_VECTOR_STORE_UNSUPPORTED_OPERATION, E_VECTOR_STORE_UPSERT_FAILED } from "./exceptions.mjs";
@@ -43,6 +43,7 @@ var ArangoDBVectorStore = class extends BaseVectorStore {
43
43
  get #opts() {
44
44
  return this.options;
45
45
  }
46
+ /** Static availability probe: whether this adapter's runtime driver can load in the current environment. */
46
47
  static isAvailable() {
47
48
  return typeof process !== "undefined";
48
49
  }