@nhtio/adk 1.20260604.0 → 1.20260607.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 (358) hide show
  1. package/CHANGELOG.md +261 -0
  2. package/adk-mcp.mjs +1 -1
  3. package/batteries/embeddings/openai/adapter.cjs +1 -1
  4. package/batteries/embeddings/openai/adapter.mjs +1 -1
  5. package/batteries/embeddings/webllm/adapter.cjs +1 -1
  6. package/batteries/embeddings/webllm/adapter.mjs +1 -1
  7. package/batteries/index.d.ts +1 -0
  8. package/batteries/llm/openai_chat_completions/adapter.cjs +6 -6
  9. package/batteries/llm/openai_chat_completions/adapter.cjs.map +1 -1
  10. package/batteries/llm/openai_chat_completions/adapter.mjs +6 -6
  11. package/batteries/llm/openai_chat_completions/adapter.mjs.map +1 -1
  12. package/batteries/llm/openai_chat_completions/helpers.cjs +2 -2
  13. package/batteries/llm/openai_chat_completions/helpers.mjs +2 -2
  14. package/batteries/llm/openai_chat_completions/validation.cjs +2 -2
  15. package/batteries/llm/openai_chat_completions/validation.cjs.map +1 -1
  16. package/batteries/llm/openai_chat_completions/validation.mjs +2 -2
  17. package/batteries/llm/openai_chat_completions/validation.mjs.map +1 -1
  18. package/batteries/llm/webllm_chat_completions/adapter.cjs +6 -6
  19. package/batteries/llm/webllm_chat_completions/adapter.cjs.map +1 -1
  20. package/batteries/llm/webllm_chat_completions/adapter.mjs +6 -6
  21. package/batteries/llm/webllm_chat_completions/adapter.mjs.map +1 -1
  22. package/batteries/llm/webllm_chat_completions/validation.cjs +2 -2
  23. package/batteries/llm/webllm_chat_completions/validation.cjs.map +1 -1
  24. package/batteries/llm/webllm_chat_completions/validation.mjs +2 -2
  25. package/batteries/llm/webllm_chat_completions/validation.mjs.map +1 -1
  26. package/batteries/storage/flydrive.cjs +1 -1
  27. package/batteries/storage/flydrive.mjs +2 -2
  28. package/batteries/storage/in_memory.cjs +1 -1
  29. package/batteries/storage/in_memory.mjs +1 -1
  30. package/batteries/storage/opfs.cjs +1 -1
  31. package/batteries/storage/opfs.mjs +1 -1
  32. package/batteries/tools/color.cjs +2 -2
  33. package/batteries/tools/color.mjs +2 -2
  34. package/batteries/tools/comparison.cjs +3 -3
  35. package/batteries/tools/comparison.mjs +3 -3
  36. package/batteries/tools/data_structure.cjs +3 -3
  37. package/batteries/tools/data_structure.mjs +3 -3
  38. package/batteries/tools/datetime_extended.cjs +2 -2
  39. package/batteries/tools/datetime_extended.mjs +2 -2
  40. package/batteries/tools/datetime_math.cjs +2 -2
  41. package/batteries/tools/datetime_math.mjs +2 -2
  42. package/batteries/tools/encoding.cjs +3 -3
  43. package/batteries/tools/encoding.mjs +3 -3
  44. package/batteries/tools/formatting.cjs +3 -3
  45. package/batteries/tools/formatting.mjs +3 -3
  46. package/batteries/tools/geo_basics.cjs +2 -2
  47. package/batteries/tools/geo_basics.mjs +2 -2
  48. package/batteries/tools/math/index.d.ts +16 -5
  49. package/batteries/tools/math.cjs +340 -22
  50. package/batteries/tools/math.cjs.map +1 -1
  51. package/batteries/tools/math.mjs +338 -21
  52. package/batteries/tools/math.mjs.map +1 -1
  53. package/batteries/tools/memory.cjs +5 -5
  54. package/batteries/tools/memory.mjs +5 -5
  55. package/batteries/tools/parsing.cjs +4 -4
  56. package/batteries/tools/parsing.mjs +4 -4
  57. package/batteries/tools/retrievables.cjs +4 -4
  58. package/batteries/tools/retrievables.mjs +4 -4
  59. package/batteries/tools/standing_instructions.cjs +4 -4
  60. package/batteries/tools/standing_instructions.mjs +4 -4
  61. package/batteries/tools/statistics.cjs +4 -4
  62. package/batteries/tools/statistics.mjs +4 -4
  63. package/batteries/tools/string_processing.cjs +3 -3
  64. package/batteries/tools/string_processing.mjs +3 -3
  65. package/batteries/tools/structured_data.cjs +3 -3
  66. package/batteries/tools/structured_data.mjs +3 -3
  67. package/batteries/tools/text_analysis.cjs +3 -3
  68. package/batteries/tools/text_analysis.mjs +3 -3
  69. package/batteries/tools/text_comparison.cjs +2 -2
  70. package/batteries/tools/text_comparison.mjs +2 -2
  71. package/batteries/tools/time.cjs +2 -2
  72. package/batteries/tools/time.mjs +2 -2
  73. package/batteries/tools/unit_conversion.cjs +2 -2
  74. package/batteries/tools/unit_conversion.mjs +2 -2
  75. package/batteries/vector/arangodb/index.d.ts +38 -0
  76. package/batteries/vector/arangodb.cjs +257 -0
  77. package/batteries/vector/arangodb.cjs.map +1 -0
  78. package/batteries/vector/arangodb.mjs +255 -0
  79. package/batteries/vector/arangodb.mjs.map +1 -0
  80. package/batteries/vector/builder.cjs +297 -0
  81. package/batteries/vector/builder.cjs.map +1 -0
  82. package/batteries/vector/builder.d.ts +87 -0
  83. package/batteries/vector/builder.mjs +294 -0
  84. package/batteries/vector/builder.mjs.map +1 -0
  85. package/batteries/vector/chroma/index.d.ts +32 -0
  86. package/batteries/vector/chroma.cjs +305 -0
  87. package/batteries/vector/chroma.cjs.map +1 -0
  88. package/batteries/vector/chroma.mjs +302 -0
  89. package/batteries/vector/chroma.mjs.map +1 -0
  90. package/batteries/vector/clickhouse/index.d.ts +39 -0
  91. package/batteries/vector/clickhouse.cjs +246 -0
  92. package/batteries/vector/clickhouse.cjs.map +1 -0
  93. package/batteries/vector/clickhouse.mjs +244 -0
  94. package/batteries/vector/clickhouse.mjs.map +1 -0
  95. package/batteries/vector/cloudflare/index.d.ts +43 -0
  96. package/batteries/vector/cloudflare.cjs +397 -0
  97. package/batteries/vector/cloudflare.cjs.map +1 -0
  98. package/batteries/vector/cloudflare.mjs +395 -0
  99. package/batteries/vector/cloudflare.mjs.map +1 -0
  100. package/batteries/vector/conformance/index.d.ts +15 -0
  101. package/batteries/vector/conformance.cjs +209 -0
  102. package/batteries/vector/conformance.cjs.map +1 -0
  103. package/batteries/vector/conformance.mjs +205 -0
  104. package/batteries/vector/conformance.mjs.map +1 -0
  105. package/batteries/vector/contract.cjs +42 -0
  106. package/batteries/vector/contract.cjs.map +1 -0
  107. package/batteries/vector/contract.d.ts +39 -0
  108. package/batteries/vector/contract.mjs +40 -0
  109. package/batteries/vector/contract.mjs.map +1 -0
  110. package/batteries/vector/couchbase/index.d.ts +49 -0
  111. package/batteries/vector/couchbase.cjs +401 -0
  112. package/batteries/vector/couchbase.cjs.map +1 -0
  113. package/batteries/vector/couchbase.mjs +399 -0
  114. package/batteries/vector/couchbase.mjs.map +1 -0
  115. package/batteries/vector/duckdb/index.d.ts +33 -0
  116. package/batteries/vector/duckdb.cjs +218 -0
  117. package/batteries/vector/duckdb.cjs.map +1 -0
  118. package/batteries/vector/duckdb.mjs +216 -0
  119. package/batteries/vector/duckdb.mjs.map +1 -0
  120. package/batteries/vector/elasticsearch/index.d.ts +43 -0
  121. package/batteries/vector/elasticsearch.cjs +306 -0
  122. package/batteries/vector/elasticsearch.cjs.map +1 -0
  123. package/batteries/vector/elasticsearch.mjs +303 -0
  124. package/batteries/vector/elasticsearch.mjs.map +1 -0
  125. package/batteries/vector/exceptions.cjs +126 -0
  126. package/batteries/vector/exceptions.cjs.map +1 -0
  127. package/batteries/vector/exceptions.d.ts +142 -0
  128. package/batteries/vector/exceptions.mjs +107 -0
  129. package/batteries/vector/exceptions.mjs.map +1 -0
  130. package/batteries/vector/factory.cjs +28 -0
  131. package/batteries/vector/factory.cjs.map +1 -0
  132. package/batteries/vector/factory.d.ts +38 -0
  133. package/batteries/vector/factory.mjs +25 -0
  134. package/batteries/vector/factory.mjs.map +1 -0
  135. package/batteries/vector/filters.cjs +107 -0
  136. package/batteries/vector/filters.cjs.map +1 -0
  137. package/batteries/vector/filters.d.ts +34 -0
  138. package/batteries/vector/filters.mjs +99 -0
  139. package/batteries/vector/filters.mjs.map +1 -0
  140. package/batteries/vector/helpers.cjs +23 -0
  141. package/batteries/vector/helpers.cjs.map +1 -0
  142. package/batteries/vector/helpers.d.ts +12 -0
  143. package/batteries/vector/helpers.mjs +17 -0
  144. package/batteries/vector/helpers.mjs.map +1 -0
  145. package/batteries/vector/hnswlib/index.d.ts +35 -0
  146. package/batteries/vector/hnswlib.cjs +237 -0
  147. package/batteries/vector/hnswlib.cjs.map +1 -0
  148. package/batteries/vector/hnswlib.mjs +235 -0
  149. package/batteries/vector/hnswlib.mjs.map +1 -0
  150. package/batteries/vector/in_memory/index.d.ts +23 -0
  151. package/batteries/vector/in_memory.cjs +178 -0
  152. package/batteries/vector/in_memory.cjs.map +1 -0
  153. package/batteries/vector/in_memory.mjs +176 -0
  154. package/batteries/vector/in_memory.mjs.map +1 -0
  155. package/batteries/vector/index.d.ts +18 -0
  156. package/batteries/vector/lancedb/index.d.ts +34 -0
  157. package/batteries/vector/lancedb.cjs +224 -0
  158. package/batteries/vector/lancedb.cjs.map +1 -0
  159. package/batteries/vector/lancedb.mjs +222 -0
  160. package/batteries/vector/lancedb.mjs.map +1 -0
  161. package/batteries/vector/mariadb/index.d.ts +39 -0
  162. package/batteries/vector/mariadb.cjs +228 -0
  163. package/batteries/vector/mariadb.cjs.map +1 -0
  164. package/batteries/vector/mariadb.mjs +226 -0
  165. package/batteries/vector/mariadb.mjs.map +1 -0
  166. package/batteries/vector/meilisearch/index.d.ts +36 -0
  167. package/batteries/vector/meilisearch.cjs +242 -0
  168. package/batteries/vector/meilisearch.cjs.map +1 -0
  169. package/batteries/vector/meilisearch.mjs +240 -0
  170. package/batteries/vector/meilisearch.mjs.map +1 -0
  171. package/batteries/vector/migrate.cjs +54 -0
  172. package/batteries/vector/migrate.cjs.map +1 -0
  173. package/batteries/vector/migrate.d.ts +30 -0
  174. package/batteries/vector/migrate.mjs +52 -0
  175. package/batteries/vector/migrate.mjs.map +1 -0
  176. package/batteries/vector/milvus/index.d.ts +35 -0
  177. package/batteries/vector/milvus.cjs +357 -0
  178. package/batteries/vector/milvus.cjs.map +1 -0
  179. package/batteries/vector/milvus.mjs +354 -0
  180. package/batteries/vector/milvus.mjs.map +1 -0
  181. package/batteries/vector/mongodb/index.d.ts +46 -0
  182. package/batteries/vector/mongodb.cjs +270 -0
  183. package/batteries/vector/mongodb.cjs.map +1 -0
  184. package/batteries/vector/mongodb.mjs +268 -0
  185. package/batteries/vector/mongodb.mjs.map +1 -0
  186. package/batteries/vector/neo4j/index.d.ts +38 -0
  187. package/batteries/vector/neo4j.cjs +231 -0
  188. package/batteries/vector/neo4j.cjs.map +1 -0
  189. package/batteries/vector/neo4j.mjs +229 -0
  190. package/batteries/vector/neo4j.mjs.map +1 -0
  191. package/batteries/vector/opensearch/index.d.ts +46 -0
  192. package/batteries/vector/opensearch.cjs +316 -0
  193. package/batteries/vector/opensearch.cjs.map +1 -0
  194. package/batteries/vector/opensearch.mjs +313 -0
  195. package/batteries/vector/opensearch.mjs.map +1 -0
  196. package/batteries/vector/oracle23ai/index.d.ts +45 -0
  197. package/batteries/vector/oracle23ai.cjs +340 -0
  198. package/batteries/vector/oracle23ai.cjs.map +1 -0
  199. package/batteries/vector/oracle23ai.mjs +338 -0
  200. package/batteries/vector/oracle23ai.mjs.map +1 -0
  201. package/batteries/vector/orama/index.d.ts +23 -0
  202. package/batteries/vector/orama.cjs +272 -0
  203. package/batteries/vector/orama.cjs.map +1 -0
  204. package/batteries/vector/orama.mjs +270 -0
  205. package/batteries/vector/orama.mjs.map +1 -0
  206. package/batteries/vector/pgvector/index.d.ts +43 -0
  207. package/batteries/vector/pgvector.cjs +411 -0
  208. package/batteries/vector/pgvector.cjs.map +1 -0
  209. package/batteries/vector/pgvector.mjs +408 -0
  210. package/batteries/vector/pgvector.mjs.map +1 -0
  211. package/batteries/vector/pinecone/index.d.ts +38 -0
  212. package/batteries/vector/pinecone.cjs +415 -0
  213. package/batteries/vector/pinecone.cjs.map +1 -0
  214. package/batteries/vector/pinecone.mjs +412 -0
  215. package/batteries/vector/pinecone.mjs.map +1 -0
  216. package/batteries/vector/plan.cjs +2 -0
  217. package/batteries/vector/plan.d.ts +65 -0
  218. package/batteries/vector/plan.mjs +0 -0
  219. package/batteries/vector/qdrant/index.d.ts +34 -0
  220. package/batteries/vector/qdrant.cjs +286 -0
  221. package/batteries/vector/qdrant.cjs.map +1 -0
  222. package/batteries/vector/qdrant.mjs +284 -0
  223. package/batteries/vector/qdrant.mjs.map +1 -0
  224. package/batteries/vector/redis/index.d.ts +44 -0
  225. package/batteries/vector/redis.cjs +391 -0
  226. package/batteries/vector/redis.cjs.map +1 -0
  227. package/batteries/vector/redis.mjs +388 -0
  228. package/batteries/vector/redis.mjs.map +1 -0
  229. package/batteries/vector/retrievable.cjs +69 -0
  230. package/batteries/vector/retrievable.cjs.map +1 -0
  231. package/batteries/vector/retrievable.mjs +67 -0
  232. package/batteries/vector/retrievable.mjs.map +1 -0
  233. package/batteries/vector/retrievable_glue.d.ts +24 -0
  234. package/batteries/vector/s3vectors/index.d.ts +52 -0
  235. package/batteries/vector/s3vectors.cjs +438 -0
  236. package/batteries/vector/s3vectors.cjs.map +1 -0
  237. package/batteries/vector/s3vectors.mjs +436 -0
  238. package/batteries/vector/s3vectors.mjs.map +1 -0
  239. package/batteries/vector/schema.cjs +96 -0
  240. package/batteries/vector/schema.cjs.map +1 -0
  241. package/batteries/vector/schema.d.ts +40 -0
  242. package/batteries/vector/schema.mjs +93 -0
  243. package/batteries/vector/schema.mjs.map +1 -0
  244. package/batteries/vector/solr/index.d.ts +36 -0
  245. package/batteries/vector/solr.cjs +230 -0
  246. package/batteries/vector/solr.cjs.map +1 -0
  247. package/batteries/vector/solr.mjs +228 -0
  248. package/batteries/vector/solr.mjs.map +1 -0
  249. package/batteries/vector/sqlite_vec/index.d.ts +30 -0
  250. package/batteries/vector/sqlite_vec.cjs +318 -0
  251. package/batteries/vector/sqlite_vec.cjs.map +1 -0
  252. package/batteries/vector/sqlite_vec.mjs +316 -0
  253. package/batteries/vector/sqlite_vec.mjs.map +1 -0
  254. package/batteries/vector/surrealdb/index.d.ts +37 -0
  255. package/batteries/vector/surrealdb.cjs +230 -0
  256. package/batteries/vector/surrealdb.cjs.map +1 -0
  257. package/batteries/vector/surrealdb.mjs +228 -0
  258. package/batteries/vector/surrealdb.mjs.map +1 -0
  259. package/batteries/vector/types.cjs +2 -0
  260. package/batteries/vector/types.d.ts +100 -0
  261. package/batteries/vector/types.mjs +0 -0
  262. package/batteries/vector/typesense/index.d.ts +38 -0
  263. package/batteries/vector/typesense.cjs +272 -0
  264. package/batteries/vector/typesense.cjs.map +1 -0
  265. package/batteries/vector/typesense.mjs +270 -0
  266. package/batteries/vector/typesense.mjs.map +1 -0
  267. package/batteries/vector/validation.cjs +90 -0
  268. package/batteries/vector/validation.cjs.map +1 -0
  269. package/batteries/vector/validation.d.ts +18 -0
  270. package/batteries/vector/validation.mjs +83 -0
  271. package/batteries/vector/validation.mjs.map +1 -0
  272. package/batteries/vector/vector_store_constructor.cjs +56 -0
  273. package/batteries/vector/vector_store_constructor.cjs.map +1 -0
  274. package/batteries/vector/vector_store_constructor.d.ts +30 -0
  275. package/batteries/vector/vector_store_constructor.mjs +53 -0
  276. package/batteries/vector/vector_store_constructor.mjs.map +1 -0
  277. package/batteries/vector/vespa/index.d.ts +39 -0
  278. package/batteries/vector/vespa.cjs +423 -0
  279. package/batteries/vector/vespa.cjs.map +1 -0
  280. package/batteries/vector/vespa.mjs +421 -0
  281. package/batteries/vector/vespa.mjs.map +1 -0
  282. package/batteries/vector/weaviate/index.d.ts +57 -0
  283. package/batteries/vector/weaviate.cjs +325 -0
  284. package/batteries/vector/weaviate.cjs.map +1 -0
  285. package/batteries/vector/weaviate.mjs +322 -0
  286. package/batteries/vector/weaviate.mjs.map +1 -0
  287. package/batteries/vector.cjs +63 -0
  288. package/batteries/vector.mjs +14 -0
  289. package/batteries.cjs +62 -0
  290. package/batteries.mjs +15 -1
  291. package/{chunk-kRvK8_k2.mjs → chunk-Bpcn9VDT.mjs} +5 -1
  292. package/{common-lMrnzoyn.mjs → common-BT0nfCi9.mjs} +8 -8
  293. package/{common-lMrnzoyn.mjs.map → common-BT0nfCi9.mjs.map} +1 -1
  294. package/{common-D_e5zYsG.js → common-Cj8TaQ9U.js} +8 -8
  295. package/{common-D_e5zYsG.js.map → common-Cj8TaQ9U.js.map} +1 -1
  296. package/common.cjs +7 -7
  297. package/common.mjs +7 -7
  298. package/{dispatch_runner-CpuyATj1.js → dispatch_runner-BHBNupqp.js} +2 -2
  299. package/dispatch_runner-BHBNupqp.js.map +1 -0
  300. package/{dispatch_runner-CDF3X0nv.mjs → dispatch_runner-DPcS7Y_M.mjs} +2 -2
  301. package/dispatch_runner-DPcS7Y_M.mjs.map +1 -0
  302. package/dispatch_runner.cjs +1 -1
  303. package/dispatch_runner.mjs +1 -1
  304. package/forge.cjs +4 -4
  305. package/forge.mjs +4 -4
  306. package/guards.cjs +8 -8
  307. package/guards.mjs +8 -8
  308. package/index.cjs +12 -12
  309. package/index.mjs +12 -12
  310. package/lib/classes/tool_registry.d.ts +70 -4
  311. package/mcp/adk-docs-corpus.json +1 -1
  312. package/package.json +424 -88
  313. package/skills/adk-assembly/SKILL.md +2 -2
  314. package/{spooled_artifact-B8gIIn9h.js → spooled_artifact-BTq6Nzfy.js} +4 -4
  315. package/spooled_artifact-BTq6Nzfy.js.map +1 -0
  316. package/{spooled_artifact-CWoKUDEm.mjs → spooled_artifact-CHoZgWwI.mjs} +4 -4
  317. package/spooled_artifact-CHoZgWwI.mjs.map +1 -0
  318. package/spooled_artifact.cjs +2 -2
  319. package/spooled_artifact.mjs +2 -2
  320. package/{spooled_markdown_artifact-DQX0RCdI.js → spooled_markdown_artifact-CALSDxIx.js} +3 -3
  321. package/{spooled_markdown_artifact-DQX0RCdI.js.map → spooled_markdown_artifact-CALSDxIx.js.map} +1 -1
  322. package/{spooled_markdown_artifact-CNle4jXN.mjs → spooled_markdown_artifact-Ci5UL7l4.mjs} +3 -3
  323. package/{spooled_markdown_artifact-CNle4jXN.mjs.map → spooled_markdown_artifact-Ci5UL7l4.mjs.map} +1 -1
  324. package/src/types/evaluatex.d.ts +31 -0
  325. package/{thought-BD6AkkOr.js → thought-BbwhJ1wb.js} +4 -4
  326. package/thought-BbwhJ1wb.js.map +1 -0
  327. package/{thought-B_P8LiB6.mjs → thought-D34QQZZ9.mjs} +4 -4
  328. package/thought-D34QQZZ9.mjs.map +1 -0
  329. package/{tool-CRZSUcdP.mjs → tool-CMhaDRNd.mjs} +3 -3
  330. package/tool-CMhaDRNd.mjs.map +1 -0
  331. package/{tool-CX9vNHAw.js → tool-CVyZkFC7.js} +3 -3
  332. package/tool-CVyZkFC7.js.map +1 -0
  333. package/{tool_call-BUeMuCc6.mjs → tool_call-CV5qVNlb.mjs} +3 -3
  334. package/{tool_call-BUeMuCc6.mjs.map → tool_call-CV5qVNlb.mjs.map} +1 -1
  335. package/{tool_call--7ti-frB.js → tool_call-Db68hB7y.js} +3 -3
  336. package/{tool_call--7ti-frB.js.map → tool_call-Db68hB7y.js.map} +1 -1
  337. package/{tool_registry-BGHg6KTq.mjs → tool_registry-D1pSSlsd.mjs} +109 -22
  338. package/tool_registry-D1pSSlsd.mjs.map +1 -0
  339. package/{tool_registry-CtCQ4Xoz.js → tool_registry-DYUYqXvo.js} +109 -22
  340. package/tool_registry-DYUYqXvo.js.map +1 -0
  341. package/{turn_runner-BJTtAORU.js → turn_runner-DqWHNP80.js} +5 -5
  342. package/turn_runner-DqWHNP80.js.map +1 -0
  343. package/{turn_runner-C02LZHjt.mjs → turn_runner-fg1Wc3dK.mjs} +5 -5
  344. package/turn_runner-fg1Wc3dK.mjs.map +1 -0
  345. package/turn_runner.cjs +1 -1
  346. package/turn_runner.mjs +1 -1
  347. package/dispatch_runner-CDF3X0nv.mjs.map +0 -1
  348. package/dispatch_runner-CpuyATj1.js.map +0 -1
  349. package/spooled_artifact-B8gIIn9h.js.map +0 -1
  350. package/spooled_artifact-CWoKUDEm.mjs.map +0 -1
  351. package/thought-BD6AkkOr.js.map +0 -1
  352. package/thought-B_P8LiB6.mjs.map +0 -1
  353. package/tool-CRZSUcdP.mjs.map +0 -1
  354. package/tool-CX9vNHAw.js.map +0 -1
  355. package/tool_registry-BGHg6KTq.mjs.map +0 -1
  356. package/tool_registry-CtCQ4Xoz.js.map +0 -1
  357. package/turn_runner-BJTtAORU.js.map +0 -1
  358. package/turn_runner-C02LZHjt.mjs.map +0 -1
@@ -1,5 +1,5 @@
1
- import { t as Tool } from "../../tool-CRZSUcdP.mjs";
2
- import "../../common-lMrnzoyn.mjs";
1
+ import { t as Tool } from "../../tool-CMhaDRNd.mjs";
2
+ import "../../common-BT0nfCi9.mjs";
3
3
  import { validator } from "@nhtio/validation";
4
4
  import { DateTime, IANAZone } from "luxon";
5
5
  import * as chrono from "chrono-node";
@@ -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-CX9vNHAw.js");
4
- require("../../common-D_e5zYsG.js");
3
+ const require_tool = require("../../tool-CVyZkFC7.js");
4
+ require("../../common-Cj8TaQ9U.js");
5
5
  let _nhtio_validation = require("@nhtio/validation");
6
6
  let luxon = require("luxon");
7
7
  //#region src/batteries/tools/datetime_math/index.ts
@@ -1,5 +1,5 @@
1
- import { t as Tool } from "../../tool-CRZSUcdP.mjs";
2
- import "../../common-lMrnzoyn.mjs";
1
+ import { t as Tool } from "../../tool-CMhaDRNd.mjs";
2
+ import "../../common-BT0nfCi9.mjs";
3
3
  import { validator } from "@nhtio/validation";
4
4
  import { DateTime, Duration, IANAZone } from "luxon";
5
5
  //#region src/batteries/tools/datetime_math/index.ts
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("../../chunk-Ble4zEEl.js");
3
- const require_tool_registry = require("../../tool_registry-CtCQ4Xoz.js");
4
- const require_tool = require("../../tool-CX9vNHAw.js");
5
- require("../../common-D_e5zYsG.js");
3
+ const require_tool_registry = require("../../tool_registry-DYUYqXvo.js");
4
+ const require_tool = require("../../tool-CVyZkFC7.js");
5
+ require("../../common-Cj8TaQ9U.js");
6
6
  require("../../guards.cjs");
7
7
  let _nhtio_validation = require("@nhtio/validation");
8
8
  //#region src/batteries/tools/encoding/index.ts
@@ -1,6 +1,6 @@
1
- import { o as isError } from "../../tool_registry-BGHg6KTq.mjs";
2
- import { t as Tool } from "../../tool-CRZSUcdP.mjs";
3
- import "../../common-lMrnzoyn.mjs";
1
+ import { o as isError } from "../../tool_registry-D1pSSlsd.mjs";
2
+ import { t as Tool } from "../../tool-CMhaDRNd.mjs";
3
+ import "../../common-BT0nfCi9.mjs";
4
4
  import "../../guards.mjs";
5
5
  import { validator } from "@nhtio/validation";
6
6
  //#region src/batteries/tools/encoding/index.ts
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("../../chunk-Ble4zEEl.js");
3
- const require_tool_registry = require("../../tool_registry-CtCQ4Xoz.js");
4
- const require_tool = require("../../tool-CX9vNHAw.js");
5
- require("../../common-D_e5zYsG.js");
3
+ const require_tool_registry = require("../../tool_registry-DYUYqXvo.js");
4
+ const require_tool = require("../../tool-CVyZkFC7.js");
5
+ require("../../common-Cj8TaQ9U.js");
6
6
  require("../../guards.cjs");
7
7
  let _nhtio_validation = require("@nhtio/validation");
8
8
  //#region src/batteries/tools/formatting/index.ts
@@ -1,6 +1,6 @@
1
- import { o as isError } from "../../tool_registry-BGHg6KTq.mjs";
2
- import { t as Tool } from "../../tool-CRZSUcdP.mjs";
3
- import "../../common-lMrnzoyn.mjs";
1
+ import { o as isError } from "../../tool_registry-D1pSSlsd.mjs";
2
+ import { t as Tool } from "../../tool-CMhaDRNd.mjs";
3
+ import "../../common-BT0nfCi9.mjs";
4
4
  import "../../guards.mjs";
5
5
  import { validator } from "@nhtio/validation";
6
6
  //#region src/batteries/tools/formatting/index.ts
@@ -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-CX9vNHAw.js");
4
- require("../../common-D_e5zYsG.js");
3
+ const require_tool = require("../../tool-CVyZkFC7.js");
4
+ require("../../common-Cj8TaQ9U.js");
5
5
  let _nhtio_validation = require("@nhtio/validation");
6
6
  //#region src/batteries/tools/geo_basics/index.ts
7
7
  /**
@@ -1,5 +1,5 @@
1
- import { t as Tool } from "../../tool-CRZSUcdP.mjs";
2
- import "../../common-lMrnzoyn.mjs";
1
+ import { t as Tool } from "../../tool-CMhaDRNd.mjs";
2
+ import "../../common-BT0nfCi9.mjs";
3
3
  import { validator } from "@nhtio/validation";
4
4
  //#region src/batteries/tools/geo_basics/index.ts
5
5
  /**
@@ -24,13 +24,24 @@ import { Tool } from "../../../common";
24
24
  */
25
25
  export declare const calculateTool: Tool<import("../../../common").SpooledArtifact>;
26
26
  /**
27
- * Translates a LaTeX/KaTeX expression into mathjs syntax, evaluates it, and returns the result.
27
+ * Translates a LaTeX/KaTeX expression using evaluatex and returns the numeric result.
28
28
  *
29
29
  * @remarks
30
- * Translates common LaTeX constructs (`\frac{a}{b}`, `\sqrt{...}`, `\cdot`, `\times`, Greek
31
- * macros like `\pi`, `\left`/`\right` delimiters, `\text{...}`, subscripts, etc.) into their
32
- * mathjs equivalents before evaluation. Both the source and the translated mathjs expression
33
- * are subject to the 1000-character length cap.
30
+ * Uses the evaluatex library to parse and evaluate LaTeX expressions. Handles common constructs
31
+ * (`\frac{a}{b}`, `\sqrt{...}`, `\cdot`, `\times`, Greek macros like `\pi`, inverse trig,
32
+ * `\left`/`\right` delimiters, `\text{...}`, subscripts, etc.) with a proper parser rather than
33
+ * brittle regex.
34
+ *
35
+ * Also evaluates three calculus constructs **numerically** (mathjs has no symbolic integration, and
36
+ * its symbolic `derivative` is blocklisted here for safety):
37
+ * - Definite integrals — `\int_{a}^{b} f \,dx` via composite Simpson quadrature.
38
+ * - Derivatives at a point — `\frac{d}{dx} f \big|_{x=a}` via central finite difference.
39
+ * - Limits — `\lim_{x \to a} f` (including `a = \pm\infty`) via a two-sided numeric approach.
40
+ *
41
+ * Numeric results are rounded with `math.format(..., { precision: 12 })` and labelled
42
+ * `Result (numeric):` to flag that they are approximations. Constructs that cannot be evaluated
43
+ * numerically (indefinite integrals, derivatives without a point, infinite integration bounds,
44
+ * singular integrands, divergent limits) return a specific, guiding error string.
34
45
  *
35
46
  * Parse and evaluation errors are returned as error strings rather than thrown.
36
47
  */
@@ -1,11 +1,13 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- require("../../chunk-Ble4zEEl.js");
3
- const require_tool_registry = require("../../tool_registry-CtCQ4Xoz.js");
4
- const require_tool = require("../../tool-CX9vNHAw.js");
5
- require("../../common-D_e5zYsG.js");
2
+ const require_chunk = require("../../chunk-Ble4zEEl.js");
3
+ const require_tool_registry = require("../../tool_registry-DYUYqXvo.js");
4
+ const require_tool = require("../../tool-CVyZkFC7.js");
5
+ require("../../common-Cj8TaQ9U.js");
6
6
  require("../../guards.cjs");
7
7
  let _nhtio_validation = require("@nhtio/validation");
8
8
  let mathjs = require("mathjs");
9
+ let evaluatex = require("evaluatex");
10
+ evaluatex = require_chunk.__toESM(evaluatex);
9
11
  //#region src/batteries/tools/math/index.ts
10
12
  /**
11
13
  * Pre-constructed tools for safe arithmetic, expression evaluation, and numeric operations.
@@ -32,20 +34,110 @@ function validateExpression(expr) {
32
34
  if (expr.length > MAX_EXPRESSION_LENGTH) return `Expression too long (max ${MAX_EXPRESSION_LENGTH} characters).`;
33
35
  }
34
36
  /**
35
- * Convert common LaTeX/KaTeX notation to a mathjs-evaluable expression.
37
+ * EvaluateX scope providing constants and function aliases that evaluatex does not ship
38
+ * out-of-the-box, matching the capabilities that were previously provided by the mathjs
39
+ * translation layer.
36
40
  */
37
- function latexToMathjs(latex) {
41
+ var EVALUATEX_SCOPE = {
42
+ pi: Math.PI,
43
+ e: Math.E,
44
+ infinity: Infinity,
45
+ alpha: void 0,
46
+ beta: void 0,
47
+ gamma: void 0,
48
+ delta: void 0,
49
+ epsilon: void 0,
50
+ theta: void 0,
51
+ lambda: void 0,
52
+ mu: void 0,
53
+ sigma: void 0,
54
+ tau: void 0,
55
+ phi: void 0,
56
+ omega: void 0,
57
+ ln: Math.log,
58
+ log10: (x) => Math.log(x) / Math.LN10,
59
+ log2: (x) => Math.log(x) / Math.LN2,
60
+ nthRoot: (x, n) => Math.pow(x, 1 / n),
61
+ det: (x) => x
62
+ };
63
+ /**
64
+ * Translate a LaTeX/KaTeX expression to evaluatex-compatible syntax and evaluate it.
65
+ *
66
+ * The translation is a lightweight pass over the LaTeX source that handles common constructs
67
+ * (frac, sqrt, trig, Greek macros, delimiters, etc.) and feeds the result to evaluatex with
68
+ * a pre-built scope providing constants and function aliases. This replaces the previous
69
+ * hand-rolled regex → mathjs pipeline.
70
+ */
71
+ function evaluateLatex(latex) {
38
72
  let expr = latex.trim();
39
73
  expr = expr.replace(/^\$\$?|\$\$?$/g, "");
40
74
  expr = expr.replace(/^\\[[(]|\\[\])]$/g, "");
41
- for (let i = 0; i < 10; i++) {
75
+ for (let i = 0; i < 20; i++) {
42
76
  const before = expr;
43
- expr = expr.replace(/\\frac\s*\{([^{}]*)\}\s*\{([^{}]*)\}/g, "(($1)/($2))");
77
+ expr = expr.replace(/\\frac\s*\{([^}]*)\}\s*\{([^}]*)\}/g, "($1)/($2)");
44
78
  if (expr === before) break;
45
79
  }
46
- expr = expr.replace(/\\sqrt\[([^\]]+)\]\s*\{([^{}]*)\}/g, "nthRoot($2, $1)");
47
- expr = expr.replace(/\\sqrt\s*\{([^{}]*)\}/g, "sqrt($1)");
48
- expr = expr.replace(/\\(sin|cos|tan|cot|sec|csc|arcsin|arccos|arctan|sinh|cosh|tanh|ln|log|exp|abs|det)/g, "$1");
80
+ expr = expr.replace(/\\sqrt\[([^\]]+)\]\s*\{([^}]*)\}/g, "nthRoot($2, $1)");
81
+ expr = expr.replace(/\\sqrt\s*\{([^}]*)\}/g, "sqrt($1)");
82
+ expr = expr.replace(/\\arcsin/g, "asin");
83
+ expr = expr.replace(/\\arccos/g, "acos");
84
+ expr = expr.replace(/\\arctan/g, "atan");
85
+ expr = expr.replace(/\\(sin|cos|tan|cot|sec|csc|sinh|cosh|tanh|ln|log|exp|abs|det)/g, "$1");
86
+ expr = expr.replace(/log_\{?(\w+)\}?\(/g, (_, base) => {
87
+ const baseLower = base.toLowerCase();
88
+ if (baseLower === "10") return "log10(";
89
+ if (baseLower === "2") return "log2(";
90
+ if (baseLower === "e") return "ln(";
91
+ return `ln(/ln(${base})`;
92
+ });
93
+ expr = expr.replace(/_\{[^}]*\}/g, "");
94
+ expr = expr.replace(/_\w/g, "");
95
+ expr = expr.replace(/\^{([^{}]*)}/g, "^($1)");
96
+ expr = expr.replace(/\\pi/g, "pi");
97
+ expr = expr.replace(/\\(alpha|beta|gamma|delta|epsilon|theta|lambda|mu|sigma|tau|phi|omega)/g, "$1");
98
+ expr = expr.replace(/\\cdot/g, "*");
99
+ expr = expr.replace(/\\times/g, "*");
100
+ expr = expr.replace(/\\div/g, "/");
101
+ expr = expr.replace(/\\infty/g, "infinity");
102
+ expr = expr.replace(/\\left\s*([([{|])/g, "$1");
103
+ expr = expr.replace(/\\right\s*([)\]}|])/g, "$1");
104
+ expr = expr.replace(/\\sum/g, "sum");
105
+ expr = expr.replace(/\\prod/g, "prod");
106
+ expr = expr.replace(/\\,/g, " ");
107
+ expr = expr.replace(/\\;/g, " ");
108
+ expr = expr.replace(/\\quad/g, " ");
109
+ expr = expr.replace(/\\qquad/g, " ");
110
+ expr = expr.replace(/\\text\{([^{}]*)\}/g, "");
111
+ expr = expr.replace(/(\d)([a-zA-Z(])/g, "$1*$2");
112
+ expr = expr.replace(/\)\s*\(/g, ")*(");
113
+ expr = expr.replace(/\s+/g, " ").trim();
114
+ const result = (0, evaluatex.default)(expr, EVALUATEX_SCOPE)();
115
+ if (typeof result !== "number" || !Number.isFinite(result)) throw new Error("Result is not finite");
116
+ return result;
117
+ }
118
+ /**
119
+ * Lightweight LaTeX-to-string translator for internal use by the numeric calculus path.
120
+ *
121
+ * This is the same translation pass as {@link evaluateLatex}, but returns the translated string
122
+ * (compatible with mathjs syntax) rather than evaluating it. Used by the calculus handlers to
123
+ * convert integrands, function bodies, and bound expressions before passing them to
124
+ * `math.evaluate` for specific-point evaluation.
125
+ */
126
+ function translateLatex(latex) {
127
+ let expr = latex.trim();
128
+ expr = expr.replace(/^\$\$?|\$\$?$/g, "");
129
+ expr = expr.replace(/^\\[[(]|\\[\])]$/g, "");
130
+ for (let i = 0; i < 20; i++) {
131
+ const before = expr;
132
+ expr = expr.replace(/\\frac\s*\{([^}]*)\}\s*\{([^}]*)\}/g, "($1)/($2)");
133
+ if (expr === before) break;
134
+ }
135
+ expr = expr.replace(/\\sqrt\[([^\]]+)\]\s*\{([^}]*)\}/g, "nthRoot($2, $1)");
136
+ expr = expr.replace(/\\sqrt\s*\{([^}]*)\}/g, "sqrt($1)");
137
+ expr = expr.replace(/\\arcsin/g, "asin");
138
+ expr = expr.replace(/\\arccos/g, "acos");
139
+ expr = expr.replace(/\\arctan/g, "atan");
140
+ expr = expr.replace(/\\(sin|cos|tan|cot|sec|csc|sinh|cosh|tanh|ln|log|exp|abs|det)/g, "$1");
49
141
  expr = expr.replace(/log_\{?(\w+)\}?\s*\(([^)]+)\)/g, "log($2, $1)");
50
142
  expr = expr.replace(/\^{([^{}]*)}/g, "^($1)");
51
143
  expr = expr.replace(/_\{[^{}]*\}/g, "");
@@ -70,6 +162,222 @@ function latexToMathjs(latex) {
70
162
  expr = expr.replace(/\s+/g, " ").trim();
71
163
  return expr;
72
164
  }
165
+ /** A tagged error whose message is surfaced to the model verbatim (caught by {@link tryCalculus}). */
166
+ var CalculusError = class extends Error {};
167
+ /** Evaluate a mathjs expression at a single point, guarding against non-finite results. */
168
+ function evalAt(expr, varName, x) {
169
+ const y = math.evaluate(expr, { [varName]: x });
170
+ if (typeof y !== "number" || !Number.isFinite(y)) throw new CalculusError("NON_FINITE");
171
+ return y;
172
+ }
173
+ /** Composite Simpson's rule over a finite interval. Throws {@link CalculusError} on a singularity. */
174
+ function simpson(fn, a, b, n = 1e3) {
175
+ if (n % 2 === 1) n++;
176
+ const h = (b - a) / n;
177
+ let sum = fn(a) + fn(b);
178
+ for (let i = 1; i < n; i++) sum += (i % 2 === 1 ? 4 : 2) * fn(a + i * h);
179
+ const result = h / 3 * sum;
180
+ if (!Number.isFinite(result)) throw new CalculusError("NON_FINITE");
181
+ return result;
182
+ }
183
+ /** Round numeric output to 12 significant digits, collapsing floating-point noise. */
184
+ function formatNumeric(n) {
185
+ if (Math.abs(n) < 1e-9) return "0";
186
+ return math.format(n, { precision: 12 });
187
+ }
188
+ /**
189
+ * Reads a single `_`/`^` script starting at `i`, supporting braced (`_{0}`, `^{\pi}`), command
190
+ * (`^\pi`), and bare-token (`_0`, `^1`) forms. Returns the mark, its raw-LaTeX value, and the next
191
+ * index, or `null` when there is no script at `i`.
192
+ */
193
+ function readScript(s, i) {
194
+ while (s[i] === " ") i++;
195
+ const mark = s[i];
196
+ if (mark !== "_" && mark !== "^") return null;
197
+ i++;
198
+ while (s[i] === " ") i++;
199
+ if (s[i] === "{") {
200
+ let depth = 0;
201
+ const start = ++i;
202
+ for (; i < s.length; i++) if (s[i] === "{") depth++;
203
+ else if (s[i] === "}") {
204
+ if (depth === 0) break;
205
+ depth--;
206
+ }
207
+ return {
208
+ mark,
209
+ val: s.slice(start, i),
210
+ next: i + 1
211
+ };
212
+ }
213
+ if (s[i] === "\\") {
214
+ const m = /^\\[a-zA-Z]+/.exec(s.slice(i));
215
+ if (!m) return null;
216
+ return {
217
+ mark,
218
+ val: m[0],
219
+ next: i + m[0].length
220
+ };
221
+ }
222
+ const m = /^[A-Za-z0-9.]+/.exec(s.slice(i));
223
+ if (!m) return null;
224
+ return {
225
+ mark,
226
+ val: m[0],
227
+ next: i + m[0].length
228
+ };
229
+ }
230
+ /** Translate a raw-LaTeX bound/target fragment and evaluate it to a finite number. */
231
+ function evalBound(latex) {
232
+ const trimmed = latex.trim();
233
+ if (/\\infty/.test(trimmed)) throw new CalculusError("INFINITE_BOUND");
234
+ const mathjsExpr = translateLatex(trimmed);
235
+ const value = math.evaluate(mathjsExpr);
236
+ if (typeof value !== "number" || !Number.isFinite(value)) throw new CalculusError("BAD_BOUND");
237
+ return value;
238
+ }
239
+ /** Evaluate a definite integral `\int_{a}^{b} f \,dx` by Simpson quadrature. */
240
+ function evalIntegral(s) {
241
+ const m = /\\int(?:\\limits)?/.exec(s);
242
+ if (!m) throw new CalculusError("NOT_INTEGRAL");
243
+ let i = m.index + m[0].length;
244
+ const scripts = {
245
+ "_": void 0,
246
+ "^": void 0
247
+ };
248
+ for (let k = 0; k < 2; k++) {
249
+ const sc = readScript(s, i);
250
+ if (!sc) break;
251
+ scripts[sc.mark] = sc.val;
252
+ i = sc.next;
253
+ }
254
+ if (scripts._ === void 0 || scripts["^"] === void 0) throw new CalculusError("INDEFINITE");
255
+ const rest = s.slice(i);
256
+ const diff = /\\?,?\s*\bd\s*([a-zA-Z])\s*$/.exec(rest);
257
+ if (!diff) throw new CalculusError("NO_DIFFERENTIAL");
258
+ const variable = diff[1];
259
+ const integrandLatex = rest.slice(0, diff.index);
260
+ if (integrandLatex.trim().length === 0) throw new CalculusError("NO_INTEGRAND");
261
+ const a = evalBound(scripts._);
262
+ const b = evalBound(scripts["^"]);
263
+ const integrand = translateLatex(integrandLatex);
264
+ const fn = (x) => evalAt(integrand, variable, x);
265
+ let result;
266
+ if (a === b) result = 0;
267
+ else if (a < b) result = simpson(fn, a, b);
268
+ else result = -simpson(fn, b, a);
269
+ return `Converted: ∫(${integrand}) d${variable} from ${formatNumeric(a)} to ${formatNumeric(b)}\nResult (numeric): ${formatNumeric(result)}`;
270
+ }
271
+ /** Evaluate a derivative `\frac{d}{dx} f \big|_{x=a}` at a point via central finite difference. */
272
+ function evalDerivative(s) {
273
+ let variable;
274
+ let body = s;
275
+ const fracOp = /\\frac\s*\{\s*d\s*\}\s*\{\s*d\s*([a-zA-Z])\s*\}/.exec(s);
276
+ if (fracOp) {
277
+ variable = fracOp[1];
278
+ body = s.slice(fracOp.index + fracOp[0].length);
279
+ } else {
280
+ const bareOp = /(?:^|[^a-zA-Z])d\s*\/\s*d([a-zA-Z])/.exec(s);
281
+ if (bareOp) {
282
+ variable = bareOp[1];
283
+ body = s.slice(bareOp.index + bareOp[0].length);
284
+ }
285
+ }
286
+ if (!variable) throw new CalculusError("NOT_DERIVATIVE");
287
+ body = body.replace(/\\left\.?/g, "").replace(/\\right\.?/g, "");
288
+ const bar = /\\?(?:Big|big|bigg|Bigg)?\s*\|\s*_\s*\{?\s*([a-zA-Z])\s*=\s*([^}]+?)\s*\}?\s*$/.exec(body);
289
+ if (!bar) throw new CalculusError("NO_POINT");
290
+ const point = evalBound(bar[2]);
291
+ let fnLatex = body.slice(0, bar.index).trim();
292
+ fnLatex = fnLatex.replace(/^\\?\(([\s\S]*)\\?\)$/, "$1").replace(/^\[([\s\S]*)\]$/, "$1").trim();
293
+ if (fnLatex.length === 0) throw new CalculusError("NO_FUNCTION");
294
+ const expr = translateLatex(fnLatex);
295
+ const h = 1e-6;
296
+ const fn = (x) => evalAt(expr, variable, x);
297
+ const result = (fn(point + h) - fn(point - h)) / (2 * h);
298
+ if (!Number.isFinite(result)) throw new CalculusError("NON_FINITE");
299
+ return `Converted: d/d${variable}(${expr}) at ${variable}=${formatNumeric(point)}\nResult (numeric): ${formatNumeric(result)}`;
300
+ }
301
+ /** Evaluate a limit `\lim_{x \to a} f(x)` by a two-sided numeric approach. */
302
+ function evalLimit(s) {
303
+ const head = /\\lim\s*_\s*\{\s*([a-zA-Z])\s*\\to\s*([\s\S]+?)\s*\}/.exec(s);
304
+ if (!head) throw new CalculusError("NOT_LIMIT");
305
+ const variable = head[1];
306
+ let targetLatex = head[2].trim();
307
+ const bodyLatex = s.slice(head.index + head[0].length).trim();
308
+ if (bodyLatex.length === 0) throw new CalculusError("NO_FUNCTION");
309
+ let side = "both";
310
+ const oneSided = /\^\s*\{?\s*([+-])\s*\}?\s*$/.exec(targetLatex);
311
+ if (oneSided) {
312
+ side = oneSided[1] === "+" ? "plus" : "minus";
313
+ targetLatex = targetLatex.slice(0, oneSided.index).trim();
314
+ }
315
+ const expr = translateLatex(bodyLatex);
316
+ const fn = (x) => evalAt(expr, variable, x);
317
+ const eps = 1e-6;
318
+ let result;
319
+ let targetLabel;
320
+ if (/^-\s*\\infty$/.test(targetLatex)) {
321
+ result = fn(-1e8);
322
+ targetLabel = "-∞";
323
+ } else if (/^\\infty$/.test(targetLatex)) {
324
+ result = fn(1e8);
325
+ targetLabel = "∞";
326
+ } else {
327
+ const target = evalBound(targetLatex);
328
+ targetLabel = formatNumeric(target);
329
+ if (side === "plus") result = fn(target + eps);
330
+ else if (side === "minus") result = fn(target - eps);
331
+ else {
332
+ const lo = fn(target - eps);
333
+ const hi = fn(target + eps);
334
+ const avg = (lo + hi) / 2;
335
+ if (Math.abs(hi - lo) > .001 * Math.max(1, Math.abs(avg))) throw new CalculusError("LIMIT_MISMATCH");
336
+ result = avg;
337
+ }
338
+ }
339
+ if (!Number.isFinite(result)) throw new CalculusError("LIMIT_UNBOUNDED");
340
+ const nearest = Math.round(result);
341
+ if (Math.abs(result - nearest) < 1e-6) result = nearest;
342
+ return `Converted: lim ${variable}→${targetLabel} of (${expr})\nResult (numeric): ${formatNumeric(result)}`;
343
+ }
344
+ /** Human-readable, model-actionable message for each {@link CalculusError} tag. */
345
+ function calculusErrorMessage(tag) {
346
+ switch (tag) {
347
+ case "INDEFINITE": return "Cannot evaluate an indefinite integral numerically. Provide bounds, e.g. \\int_{0}^{1} x dx.";
348
+ case "NO_DIFFERENTIAL": return "Could not find the integration variable. Expected a trailing differential like 'dx'.";
349
+ case "NO_INTEGRAND": return "The integral has no integrand to evaluate.";
350
+ case "INFINITE_BOUND": return "Infinite integration bounds are not supported. Provide finite numeric bounds, e.g. \\int_{0}^{1} f dx.";
351
+ case "BAD_BOUND": return "Could not evaluate the integration bounds to numbers.";
352
+ case "NO_POINT": return "Cannot evaluate a derivative numerically without a point. Specify where, e.g. \\frac{d}{dx}(x^2)\\Big|_{x=3}.";
353
+ case "NO_FUNCTION": return "Could not find the function to evaluate.";
354
+ case "LIMIT_MISMATCH": return "The limit may not exist (left and right values disagree).";
355
+ case "LIMIT_UNBOUNDED": return "The limit appears to diverge (function is unbounded near the target).";
356
+ case "NON_FINITE": return "The expression is not finite over the requested range (possible singularity); cannot evaluate numerically.";
357
+ default: return "Could not evaluate the calculus expression.";
358
+ }
359
+ }
360
+ /**
361
+ * Detects a calculus construct in raw LaTeX and routes it to the matching numeric handler. Returns
362
+ * the result/error string, or `null` when the input is not a calculus expression (so the caller
363
+ * falls through to the scalar evaluation path unchanged).
364
+ */
365
+ function tryCalculus(latex) {
366
+ let s = latex.trim();
367
+ s = s.replace(/^\$\$?|\$\$?$/g, "");
368
+ s = s.replace(/^\\[[(]|\\[\])]$/g, "").trim();
369
+ let handler;
370
+ if (/\\int/.test(s)) handler = evalIntegral;
371
+ else if (/\\lim/.test(s)) handler = evalLimit;
372
+ else if (/\\frac\s*\{\s*d\s*\}\s*\{\s*d\s*[a-zA-Z]\s*\}/.test(s) || /(?:^|[^a-zA-Z])d\s*\/\s*d[a-zA-Z]/.test(s)) handler = evalDerivative;
373
+ if (!handler) return null;
374
+ try {
375
+ return handler(s);
376
+ } catch (err) {
377
+ if (require_tool_registry.isInstanceOf(err, "CalculusError", CalculusError)) return `Error: ${calculusErrorMessage(err.message)}`;
378
+ return `Error: ${require_tool_registry.isError(err) ? err.message : String(err)}`;
379
+ }
380
+ }
73
381
  /**
74
382
  * Evaluates a mathjs-syntax expression and returns the numeric result alongside the KaTeX
75
383
  * representation of the parsed expression.
@@ -101,29 +409,39 @@ var calculateTool = new require_tool.Tool({
101
409
  }
102
410
  });
103
411
  /**
104
- * Translates a LaTeX/KaTeX expression into mathjs syntax, evaluates it, and returns the result.
412
+ * Translates a LaTeX/KaTeX expression using evaluatex and returns the numeric result.
105
413
  *
106
414
  * @remarks
107
- * Translates common LaTeX constructs (`\frac{a}{b}`, `\sqrt{...}`, `\cdot`, `\times`, Greek
108
- * macros like `\pi`, `\left`/`\right` delimiters, `\text{...}`, subscripts, etc.) into their
109
- * mathjs equivalents before evaluation. Both the source and the translated mathjs expression
110
- * are subject to the 1000-character length cap.
415
+ * Uses the evaluatex library to parse and evaluate LaTeX expressions. Handles common constructs
416
+ * (`\frac{a}{b}`, `\sqrt{...}`, `\cdot`, `\times`, Greek macros like `\pi`, inverse trig,
417
+ * `\left`/`\right` delimiters, `\text{...}`, subscripts, etc.) with a proper parser rather than
418
+ * brittle regex.
419
+ *
420
+ * Also evaluates three calculus constructs **numerically** (mathjs has no symbolic integration, and
421
+ * its symbolic `derivative` is blocklisted here for safety):
422
+ * - Definite integrals — `\int_{a}^{b} f \,dx` via composite Simpson quadrature.
423
+ * - Derivatives at a point — `\frac{d}{dx} f \big|_{x=a}` via central finite difference.
424
+ * - Limits — `\lim_{x \to a} f` (including `a = \pm\infty`) via a two-sided numeric approach.
425
+ *
426
+ * Numeric results are rounded with `math.format(..., { precision: 12 })` and labelled
427
+ * `Result (numeric):` to flag that they are approximations. Constructs that cannot be evaluated
428
+ * numerically (indefinite integrals, derivatives without a point, infinite integration bounds,
429
+ * singular integrands, divergent limits) return a specific, guiding error string.
111
430
  *
112
431
  * Parse and evaluation errors are returned as error strings rather than thrown.
113
432
  */
114
433
  var evaluateKatexTool = new require_tool.Tool({
115
434
  name: "evaluate_katex",
116
- description: "Evaluate a KaTeX/LaTeX math expression and return the numeric result.",
117
- inputSchema: _nhtio_validation.validator.object({ katex: _nhtio_validation.validator.string().required().description("LaTeX expression, e.g. \"\\frac{1}{2} + \\sqrt{9}\"") }),
435
+ description: "Evaluate a KaTeX/LaTeX math expression and return the numeric result. Supports arithmetic, trig, logs, roots, and numeric calculus: definite integrals (\\int_{a}^{b} f dx), derivatives at a point (\\frac{d}{dx} f|_{x=a}), and limits (\\lim_{x \\to a} f).",
436
+ inputSchema: _nhtio_validation.validator.object({ katex: _nhtio_validation.validator.string().required().description("LaTeX expression, e.g. \"\\frac{1}{2} + \\sqrt{9}\" or \"\\int_{0}^{1} x^2 dx\"") }),
118
437
  handler: async (args) => {
119
438
  const { katex } = args;
120
439
  const lengthError = validateExpression(katex);
121
440
  if (lengthError) return lengthError;
122
441
  try {
123
- const mathjsExpr = latexToMathjs(katex);
124
- const translatedLengthError = validateExpression(mathjsExpr);
125
- if (translatedLengthError) return translatedLengthError;
126
- return `Converted: ${mathjsExpr}\nResult: ${math.evaluate(mathjsExpr)}`;
442
+ const calculus = tryCalculus(katex);
443
+ if (calculus !== null) return calculus;
444
+ return `Result: ${evaluateLatex(katex)}`;
127
445
  } catch (err) {
128
446
  return `Error: ${require_tool_registry.isError(err) ? err.message : String(err)}`;
129
447
  }