@librechat/agents 4.2.12 → 4.2.14

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 (357) hide show
  1. package/dist/cjs/graphs/Graph.cjs +56 -6
  2. package/dist/cjs/graphs/Graph.cjs.map +1 -1
  3. package/dist/cjs/harness/providerText.cjs +1 -0
  4. package/dist/cjs/harness/providerText.cjs.map +1 -1
  5. package/dist/cjs/llm/anthropic/index.cjs +4 -3
  6. package/dist/cjs/llm/anthropic/index.cjs.map +1 -1
  7. package/dist/cjs/llm/anthropic/utils/container.cjs +37 -0
  8. package/dist/cjs/llm/anthropic/utils/container.cjs.map +1 -0
  9. package/dist/cjs/llm/anthropic/utils/message_inputs.cjs +25 -23
  10. package/dist/cjs/llm/anthropic/utils/message_inputs.cjs.map +1 -1
  11. package/dist/cjs/llm/anthropic/utils/message_outputs.cjs +15 -21
  12. package/dist/cjs/llm/anthropic/utils/message_outputs.cjs.map +1 -1
  13. package/dist/cjs/llm/anthropic/utils/stream_events.cjs +16 -14
  14. package/dist/cjs/llm/anthropic/utils/stream_events.cjs.map +1 -1
  15. package/dist/cjs/llm/bedrock/index.cjs +1 -1
  16. package/dist/cjs/llm/bedrock/index.cjs.map +1 -1
  17. package/dist/cjs/llm/bedrock/toolCache.cjs +1 -1
  18. package/dist/cjs/llm/bedrock/utils/message_inputs.cjs +19 -13
  19. package/dist/cjs/llm/bedrock/utils/message_inputs.cjs.map +1 -1
  20. package/dist/cjs/llm/google/utils/common.cjs +59 -13
  21. package/dist/cjs/llm/google/utils/common.cjs.map +1 -1
  22. package/dist/cjs/llm/google/utils/signatures.cjs +22 -14
  23. package/dist/cjs/llm/google/utils/signatures.cjs.map +1 -1
  24. package/dist/cjs/llm/init.cjs +12 -2
  25. package/dist/cjs/llm/init.cjs.map +1 -1
  26. package/dist/cjs/llm/invoke.cjs +122 -13
  27. package/dist/cjs/llm/invoke.cjs.map +1 -1
  28. package/dist/cjs/llm/openai/index.cjs +9 -3
  29. package/dist/cjs/llm/openai/index.cjs.map +1 -1
  30. package/dist/cjs/llm/openai/typedContent.cjs +94 -0
  31. package/dist/cjs/llm/openai/typedContent.cjs.map +1 -0
  32. package/dist/cjs/llm/openrouter/toolCache.cjs +1 -1
  33. package/dist/cjs/llm/prepareProviderRequest.cjs +81 -4
  34. package/dist/cjs/llm/prepareProviderRequest.cjs.map +1 -1
  35. package/dist/cjs/llm/providerTextBatch.cjs +128 -0
  36. package/dist/cjs/llm/providerTextBatch.cjs.map +1 -0
  37. package/dist/cjs/llm/providerTextBoundary.cjs +81 -12
  38. package/dist/cjs/llm/providerTextBoundary.cjs.map +1 -1
  39. package/dist/cjs/main.cjs +8 -3
  40. package/dist/cjs/messages/alternation.cjs +1 -1
  41. package/dist/cjs/messages/anthropicServerTools.cjs +20 -0
  42. package/dist/cjs/messages/anthropicServerTools.cjs.map +1 -0
  43. package/dist/cjs/messages/budget.cjs +1 -1
  44. package/dist/cjs/messages/core.cjs +3 -2
  45. package/dist/cjs/messages/core.cjs.map +1 -1
  46. package/dist/cjs/messages/format.cjs +2 -2
  47. package/dist/cjs/messages/index.cjs +1 -1
  48. package/dist/cjs/messages/prune.cjs +1 -1
  49. package/dist/cjs/messages/recency.cjs +1 -1
  50. package/dist/cjs/messages/toolResultTypes.cjs +21 -45
  51. package/dist/cjs/messages/toolResultTypes.cjs.map +1 -1
  52. package/dist/cjs/protection/providerText.cjs +60 -6
  53. package/dist/cjs/protection/providerText.cjs.map +1 -1
  54. package/dist/cjs/protection/providerTextAdmission.cjs +5 -0
  55. package/dist/cjs/protection/providerTextAdmission.cjs.map +1 -1
  56. package/dist/cjs/protection/toolResult.cjs +119 -0
  57. package/dist/cjs/protection/toolResult.cjs.map +1 -0
  58. package/dist/cjs/run.cjs +14 -3
  59. package/dist/cjs/run.cjs.map +1 -1
  60. package/dist/cjs/runtime/client.cjs +4 -0
  61. package/dist/cjs/runtime/client.cjs.map +1 -1
  62. package/dist/cjs/stream.cjs +10 -2
  63. package/dist/cjs/stream.cjs.map +1 -1
  64. package/dist/cjs/summarization/node.cjs +1 -1
  65. package/dist/cjs/tools/ToolNode.cjs +46 -13
  66. package/dist/cjs/tools/ToolNode.cjs.map +1 -1
  67. package/dist/cjs/tools/handlers.cjs +47 -1
  68. package/dist/cjs/tools/handlers.cjs.map +1 -1
  69. package/dist/cjs/tools/search/citations.cjs +194 -0
  70. package/dist/cjs/tools/search/citations.cjs.map +1 -0
  71. package/dist/cjs/tools/search/content.cjs +163 -42
  72. package/dist/cjs/tools/search/content.cjs.map +1 -1
  73. package/dist/cjs/tools/search/firecrawl.cjs +4 -9
  74. package/dist/cjs/tools/search/firecrawl.cjs.map +1 -1
  75. package/dist/cjs/tools/search/google.cjs +68 -0
  76. package/dist/cjs/tools/search/google.cjs.map +1 -0
  77. package/dist/cjs/tools/search/openai.cjs +80 -0
  78. package/dist/cjs/tools/search/openai.cjs.map +1 -0
  79. package/dist/cjs/tools/subagent/SubagentExecutor.cjs +4 -0
  80. package/dist/cjs/tools/subagent/SubagentExecutor.cjs.map +1 -1
  81. package/dist/cjs/utils/tokens.cjs +12 -2
  82. package/dist/cjs/utils/tokens.cjs.map +1 -1
  83. package/dist/esm/graphs/Graph.mjs +57 -7
  84. package/dist/esm/graphs/Graph.mjs.map +1 -1
  85. package/dist/esm/harness/providerText.mjs +1 -0
  86. package/dist/esm/harness/providerText.mjs.map +1 -1
  87. package/dist/esm/llm/anthropic/index.mjs +4 -3
  88. package/dist/esm/llm/anthropic/index.mjs.map +1 -1
  89. package/dist/esm/llm/anthropic/utils/container.mjs +37 -0
  90. package/dist/esm/llm/anthropic/utils/container.mjs.map +1 -0
  91. package/dist/esm/llm/anthropic/utils/message_inputs.mjs +25 -23
  92. package/dist/esm/llm/anthropic/utils/message_inputs.mjs.map +1 -1
  93. package/dist/esm/llm/anthropic/utils/message_outputs.mjs +15 -21
  94. package/dist/esm/llm/anthropic/utils/message_outputs.mjs.map +1 -1
  95. package/dist/esm/llm/anthropic/utils/stream_events.mjs +16 -14
  96. package/dist/esm/llm/anthropic/utils/stream_events.mjs.map +1 -1
  97. package/dist/esm/llm/bedrock/index.mjs +2 -2
  98. package/dist/esm/llm/bedrock/index.mjs.map +1 -1
  99. package/dist/esm/llm/bedrock/toolCache.mjs +1 -1
  100. package/dist/esm/llm/bedrock/utils/message_inputs.mjs +19 -14
  101. package/dist/esm/llm/bedrock/utils/message_inputs.mjs.map +1 -1
  102. package/dist/esm/llm/google/utils/common.mjs +59 -13
  103. package/dist/esm/llm/google/utils/common.mjs.map +1 -1
  104. package/dist/esm/llm/google/utils/signatures.mjs +22 -14
  105. package/dist/esm/llm/google/utils/signatures.mjs.map +1 -1
  106. package/dist/esm/llm/init.mjs +12 -2
  107. package/dist/esm/llm/init.mjs.map +1 -1
  108. package/dist/esm/llm/invoke.mjs +124 -15
  109. package/dist/esm/llm/invoke.mjs.map +1 -1
  110. package/dist/esm/llm/openai/index.mjs +9 -3
  111. package/dist/esm/llm/openai/index.mjs.map +1 -1
  112. package/dist/esm/llm/openai/typedContent.mjs +93 -0
  113. package/dist/esm/llm/openai/typedContent.mjs.map +1 -0
  114. package/dist/esm/llm/openrouter/toolCache.mjs +1 -1
  115. package/dist/esm/llm/prepareProviderRequest.mjs +81 -4
  116. package/dist/esm/llm/prepareProviderRequest.mjs.map +1 -1
  117. package/dist/esm/llm/providerTextBatch.mjs +128 -0
  118. package/dist/esm/llm/providerTextBatch.mjs.map +1 -0
  119. package/dist/esm/llm/providerTextBoundary.mjs +81 -12
  120. package/dist/esm/llm/providerTextBoundary.mjs.map +1 -1
  121. package/dist/esm/main.mjs +7 -6
  122. package/dist/esm/messages/alternation.mjs +1 -1
  123. package/dist/esm/messages/anthropicServerTools.mjs +18 -0
  124. package/dist/esm/messages/anthropicServerTools.mjs.map +1 -0
  125. package/dist/esm/messages/budget.mjs +1 -1
  126. package/dist/esm/messages/core.mjs +3 -2
  127. package/dist/esm/messages/core.mjs.map +1 -1
  128. package/dist/esm/messages/format.mjs +2 -2
  129. package/dist/esm/messages/index.mjs +1 -1
  130. package/dist/esm/messages/prune.mjs +1 -1
  131. package/dist/esm/messages/recency.mjs +1 -1
  132. package/dist/esm/messages/toolResultTypes.mjs +21 -45
  133. package/dist/esm/messages/toolResultTypes.mjs.map +1 -1
  134. package/dist/esm/protection/providerText.mjs +58 -7
  135. package/dist/esm/protection/providerText.mjs.map +1 -1
  136. package/dist/esm/protection/providerTextAdmission.mjs +5 -0
  137. package/dist/esm/protection/providerTextAdmission.mjs.map +1 -1
  138. package/dist/esm/protection/toolResult.mjs +114 -0
  139. package/dist/esm/protection/toolResult.mjs.map +1 -0
  140. package/dist/esm/run.mjs +14 -3
  141. package/dist/esm/run.mjs.map +1 -1
  142. package/dist/esm/runtime/client.mjs +4 -0
  143. package/dist/esm/runtime/client.mjs.map +1 -1
  144. package/dist/esm/stream.mjs +10 -2
  145. package/dist/esm/stream.mjs.map +1 -1
  146. package/dist/esm/summarization/node.mjs +1 -1
  147. package/dist/esm/tools/ToolNode.mjs +46 -13
  148. package/dist/esm/tools/ToolNode.mjs.map +1 -1
  149. package/dist/esm/tools/handlers.mjs +47 -2
  150. package/dist/esm/tools/handlers.mjs.map +1 -1
  151. package/dist/esm/tools/search/citations.mjs +190 -0
  152. package/dist/esm/tools/search/citations.mjs.map +1 -0
  153. package/dist/esm/tools/search/content.mjs +163 -42
  154. package/dist/esm/tools/search/content.mjs.map +1 -1
  155. package/dist/esm/tools/search/firecrawl.mjs +4 -9
  156. package/dist/esm/tools/search/firecrawl.mjs.map +1 -1
  157. package/dist/esm/tools/search/google.mjs +67 -0
  158. package/dist/esm/tools/search/google.mjs.map +1 -0
  159. package/dist/esm/tools/search/openai.mjs +80 -0
  160. package/dist/esm/tools/search/openai.mjs.map +1 -0
  161. package/dist/esm/tools/subagent/SubagentExecutor.mjs +4 -0
  162. package/dist/esm/tools/subagent/SubagentExecutor.mjs.map +1 -1
  163. package/dist/esm/utils/tokens.mjs +12 -2
  164. package/dist/esm/utils/tokens.mjs.map +1 -1
  165. package/dist/types/common/index.d.ts +2 -2
  166. package/dist/types/decisions/breaker.d.ts +2 -2
  167. package/dist/types/decisions/core.d.ts +13 -13
  168. package/dist/types/decisions/dialect.d.ts +1 -1
  169. package/dist/types/decisions/http.d.ts +2 -2
  170. package/dist/types/decisions/index.d.ts +5 -5
  171. package/dist/types/decisions/node.d.ts +2 -2
  172. package/dist/types/decisions/presets.d.ts +2 -2
  173. package/dist/types/decisions/probe.d.ts +1 -1
  174. package/dist/types/decisions/questions.d.ts +1 -1
  175. package/dist/types/decisions/structuredChat.d.ts +2 -2
  176. package/dist/types/decisions/transport.d.ts +1 -1
  177. package/dist/types/eventActor/EventActorExecutor.d.ts +1 -1
  178. package/dist/types/eventActor/index.d.ts +2 -2
  179. package/dist/types/graphs/Graph.d.ts +18 -2
  180. package/dist/types/graphs/MultiAgentGraph.d.ts +1 -1
  181. package/dist/types/graphs/applyGraphRuntimeConfig.d.ts +1 -1
  182. package/dist/types/graphs/graphFactory.d.ts +1 -1
  183. package/dist/types/graphs/index.d.ts +5 -5
  184. package/dist/types/harness/fileBindings.d.ts +2 -2
  185. package/dist/types/harness/fileService.d.ts +2 -2
  186. package/dist/types/harness/fileStream.d.ts +1 -1
  187. package/dist/types/harness/index.d.ts +15 -15
  188. package/dist/types/harness/model.d.ts +1 -1
  189. package/dist/types/harness/modelService.d.ts +2 -2
  190. package/dist/types/harness/modelStreamCallbacks.d.ts +1 -1
  191. package/dist/types/harness/providerText.d.ts +1 -1
  192. package/dist/types/hitl/index.d.ts +3 -3
  193. package/dist/types/hooks/HookRegistry.d.ts +1 -1
  194. package/dist/types/hooks/createToolPolicyHook.d.ts +1 -1
  195. package/dist/types/hooks/createWorkspacePolicyHook.d.ts +1 -1
  196. package/dist/types/hooks/executeHooks.d.ts +2 -2
  197. package/dist/types/hooks/index.d.ts +11 -11
  198. package/dist/types/index.d.ts +62 -60
  199. package/dist/types/langchain/index.d.ts +8 -8
  200. package/dist/types/llm/anthropic/utils/container.d.ts +4 -0
  201. package/dist/types/llm/anthropic/utils/message_inputs.d.ts +1 -1
  202. package/dist/types/llm/anthropic/utils/message_outputs.d.ts +1 -1
  203. package/dist/types/llm/anthropic/utils/stream_events.d.ts +1 -1
  204. package/dist/types/llm/bedrock/index.d.ts +2 -3
  205. package/dist/types/llm/bedrock/utils/harmony.d.ts +1 -1
  206. package/dist/types/llm/bedrock/utils/index.d.ts +2 -2
  207. package/dist/types/llm/bedrock/utils/message_inputs.d.ts +3 -12
  208. package/dist/types/llm/bedrock/utils/message_outputs.d.ts +1 -1
  209. package/dist/types/llm/google/index.d.ts +2 -2
  210. package/dist/types/llm/google/utils/common.d.ts +1 -1
  211. package/dist/types/llm/google/utils/tools.d.ts +1 -1
  212. package/dist/types/llm/openai/index.d.ts +1 -1
  213. package/dist/types/llm/openai/typedContent.d.ts +14 -0
  214. package/dist/types/llm/providerRegistry.d.ts +1 -1
  215. package/dist/types/llm/providerTextBatch.d.ts +26 -0
  216. package/dist/types/llm/providerTextBoundary.d.ts +7 -1
  217. package/dist/types/llm/providers.d.ts +1 -1
  218. package/dist/types/messages/anthropicServerTools.d.ts +13 -0
  219. package/dist/types/messages/contextPruning.d.ts +1 -1
  220. package/dist/types/messages/core.d.ts +4 -4
  221. package/dist/types/messages/format.d.ts +1 -1
  222. package/dist/types/messages/index.d.ts +21 -21
  223. package/dist/types/messages/prune.d.ts +1 -1
  224. package/dist/types/openai/index.d.ts +2 -2
  225. package/dist/types/openai/toolProjection.d.ts +1 -1
  226. package/dist/types/prompts/index.d.ts +2 -2
  227. package/dist/types/protection/providerText.d.ts +32 -2
  228. package/dist/types/protection/providerTextAdmission.d.ts +1 -0
  229. package/dist/types/protection/toolResult.d.ts +69 -0
  230. package/dist/types/provider-registration.d.ts +1 -1
  231. package/dist/types/rerank/bm25.d.ts +1 -1
  232. package/dist/types/rerank/core.d.ts +17 -17
  233. package/dist/types/rerank/crossEncoder.d.ts +3 -3
  234. package/dist/types/rerank/fallback.d.ts +1 -1
  235. package/dist/types/rerank/index.d.ts +2 -2
  236. package/dist/types/rerank/outcome.d.ts +2 -2
  237. package/dist/types/rerank/pin.d.ts +2 -2
  238. package/dist/types/rerank/search.d.ts +1 -1
  239. package/dist/types/rerank/systemone.d.ts +4 -4
  240. package/dist/types/rerank/types.d.ts +1 -1
  241. package/dist/types/run.d.ts +1 -0
  242. package/dist/types/runtime/admission.d.ts +1 -1
  243. package/dist/types/runtime/checkpoint.d.ts +1 -1
  244. package/dist/types/runtime/client.d.ts +2 -2
  245. package/dist/types/runtime/files.d.ts +3 -3
  246. package/dist/types/runtime/hostTools.d.ts +2 -2
  247. package/dist/types/runtime/index.d.ts +12 -12
  248. package/dist/types/runtime/model.d.ts +5 -5
  249. package/dist/types/runtime/policy.d.ts +3 -3
  250. package/dist/types/runtime/recovery/client.d.ts +3 -3
  251. package/dist/types/runtime/recovery/log.d.ts +2 -2
  252. package/dist/types/runtime/recovery/redis.d.ts +1 -1
  253. package/dist/types/runtime/recovery/server.d.ts +3 -3
  254. package/dist/types/runtime/resume.d.ts +1 -1
  255. package/dist/types/runtime/server.d.ts +3 -3
  256. package/dist/types/runtime/snapshot.d.ts +1 -1
  257. package/dist/types/runtime/types.d.ts +2 -2
  258. package/dist/types/session/AgentSession.d.ts +2 -2
  259. package/dist/types/session/JsonlSessionStore.d.ts +1 -1
  260. package/dist/types/session/deriveMessages.d.ts +1 -1
  261. package/dist/types/session/handlers.d.ts +1 -1
  262. package/dist/types/session/index.d.ts +7 -7
  263. package/dist/types/session/messageSerialization.d.ts +1 -1
  264. package/dist/types/session/sessionProjection.d.ts +3 -3
  265. package/dist/types/summarization/index.d.ts +2 -2
  266. package/dist/types/tools/BashProgrammaticToolCalling.d.ts +1 -1
  267. package/dist/types/tools/GitHubCompare.d.ts +6 -6
  268. package/dist/types/tools/ProgrammaticToolCalling.d.ts +1 -1
  269. package/dist/types/tools/ReadFile.d.ts +6 -6
  270. package/dist/types/tools/SkillTool.d.ts +6 -6
  271. package/dist/types/tools/ToolNode.d.ts +5 -1
  272. package/dist/types/tools/cloudflare/index.d.ts +4 -4
  273. package/dist/types/tools/handlers.d.ts +13 -0
  274. package/dist/types/tools/local/FileCheckpointer.d.ts +1 -1
  275. package/dist/types/tools/local/LocalExecutionEngine.d.ts +1 -1
  276. package/dist/types/tools/local/attachments.d.ts +1 -1
  277. package/dist/types/tools/local/index.d.ts +12 -12
  278. package/dist/types/tools/search/anthropic.d.ts +1 -1
  279. package/dist/types/tools/search/citations.d.ts +88 -0
  280. package/dist/types/tools/search/content.d.ts +38 -1
  281. package/dist/types/tools/search/crw-scraper.d.ts +1 -1
  282. package/dist/types/tools/search/crw-search.d.ts +1 -1
  283. package/dist/types/tools/search/firecrawl.d.ts +4 -2
  284. package/dist/types/tools/search/format.d.ts +1 -1
  285. package/dist/types/tools/search/google.d.ts +11 -0
  286. package/dist/types/tools/search/highlights.d.ts +1 -1
  287. package/dist/types/tools/search/index.d.ts +3 -3
  288. package/dist/types/tools/search/keenable-scraper.d.ts +1 -1
  289. package/dist/types/tools/search/keenable-search.d.ts +1 -1
  290. package/dist/types/tools/search/metrics.d.ts +1 -1
  291. package/dist/types/tools/search/openai.d.ts +3 -0
  292. package/dist/types/tools/search/rerankers.d.ts +1 -1
  293. package/dist/types/tools/search/schema.d.ts +6 -6
  294. package/dist/types/tools/search/search.d.ts +1 -1
  295. package/dist/types/tools/search/serper-scraper.d.ts +1 -1
  296. package/dist/types/tools/search/tavily-scraper.d.ts +1 -1
  297. package/dist/types/tools/search/tavily-search.d.ts +1 -1
  298. package/dist/types/tools/search/tool.d.ts +3 -3
  299. package/dist/types/tools/search/types.d.ts +26 -2
  300. package/dist/types/tools/search/utils.d.ts +3 -3
  301. package/dist/types/tools/subagent/SubagentExecutionRegistry.d.ts +1 -1
  302. package/dist/types/tools/subagent/SubagentExecutor.d.ts +6 -3
  303. package/dist/types/tools/subagent/diagnostics.d.ts +1 -1
  304. package/dist/types/tools/subagent/index.d.ts +7 -7
  305. package/dist/types/types/attachments.d.ts +1 -1
  306. package/dist/types/types/graph.d.ts +4 -1
  307. package/dist/types/types/index.d.ts +14 -14
  308. package/dist/types/types/llm.d.ts +2 -2
  309. package/dist/types/types/run.d.ts +3 -1
  310. package/dist/types/types/stream.d.ts +12 -0
  311. package/dist/types/types/subagentTasks.d.ts +2 -2
  312. package/dist/types/types/tools.d.ts +6 -3
  313. package/dist/types/utils/index.d.ts +10 -10
  314. package/dist/types/utils/tokens.d.ts +2 -0
  315. package/package.json +3 -2
  316. package/src/graphs/Graph.ts +125 -3
  317. package/src/harness/providerText.ts +1 -0
  318. package/src/index.ts +10 -0
  319. package/src/llm/anthropic/index.ts +11 -3
  320. package/src/llm/anthropic/utils/container.ts +63 -0
  321. package/src/llm/anthropic/utils/message_inputs.ts +57 -51
  322. package/src/llm/anthropic/utils/message_outputs.ts +12 -39
  323. package/src/llm/anthropic/utils/stream_events.ts +17 -12
  324. package/src/llm/bedrock/index.ts +7 -5
  325. package/src/llm/bedrock/utils/message_inputs.ts +28 -35
  326. package/src/llm/google/utils/common.ts +88 -36
  327. package/src/llm/google/utils/signatures.ts +52 -36
  328. package/src/llm/init.ts +35 -3
  329. package/src/llm/invoke.ts +160 -16
  330. package/src/llm/openai/index.ts +18 -5
  331. package/src/llm/openai/typedContent.ts +110 -0
  332. package/src/llm/prepareProviderRequest.ts +154 -4
  333. package/src/llm/providerTextBatch.ts +158 -0
  334. package/src/llm/providerTextBoundary.ts +119 -13
  335. package/src/messages/anthropicServerTools.ts +24 -0
  336. package/src/messages/core.ts +12 -11
  337. package/src/messages/toolResultTypes.ts +80 -88
  338. package/src/protection/providerText.ts +222 -46
  339. package/src/protection/providerTextAdmission.ts +6 -0
  340. package/src/protection/toolResult.ts +272 -0
  341. package/src/run.ts +37 -5
  342. package/src/runtime/client.ts +6 -0
  343. package/src/stream.ts +23 -2
  344. package/src/tools/ToolNode.ts +112 -17
  345. package/src/tools/handlers.ts +110 -5
  346. package/src/tools/search/citations.ts +375 -0
  347. package/src/tools/search/content.ts +282 -62
  348. package/src/tools/search/firecrawl.ts +13 -16
  349. package/src/tools/search/google.ts +122 -0
  350. package/src/tools/search/openai.ts +118 -0
  351. package/src/tools/search/types.ts +21 -0
  352. package/src/tools/subagent/SubagentExecutor.ts +6 -0
  353. package/src/types/graph.ts +3 -0
  354. package/src/types/run.ts +3 -0
  355. package/src/types/stream.ts +9 -0
  356. package/src/types/tools.ts +3 -0
  357. package/src/utils/tokens.ts +37 -2
@@ -1,4 +1,4 @@
1
- import type { RuntimeJournal } from './journal';
1
+ import type { RuntimeJournal } from './journal.js';
2
2
  /** Operator-supplied client; no app singleton or credentials cross the runtime boundary. */
3
3
  export interface RuntimeJournalRedis {
4
4
  evalsha?(sha: string, numberOfKeys: number, ...args: Array<string | number>): Promise<unknown>;
@@ -1,8 +1,8 @@
1
1
  import { z } from 'zod';
2
2
  import type { WebSocket } from 'ws';
3
- import type { RuntimeJournal, RuntimeJournalState } from './journal';
4
- import type { SdkAgentIdentity } from '../identity';
5
- import { RecoverySocket } from './socket';
3
+ import type { RuntimeJournal, RuntimeJournalState } from './journal.js';
4
+ import type { SdkAgentIdentity } from '../identity.js';
5
+ import { RecoverySocket } from './socket.js';
6
6
  export interface RecoveryClaim {
7
7
  ownerId?: string;
8
8
  sessionId: string;
@@ -1,5 +1,5 @@
1
1
  import type { EventHandler, MessageContentComplex, RunStep } from '../index.js';
2
- import type { RemoteSdkSnapshot } from './types';
2
+ import type { RemoteSdkSnapshot } from './types.js';
3
3
  type ResumableRunStep = {
4
4
  id: string;
5
5
  index: number;
@@ -1,7 +1,7 @@
1
1
  import type { Server } from 'node:http';
2
- import type { RemoteSdkFactoryInput, RemoteSdkLimits, SdkRun } from './types';
3
- import type { RuntimeRecoveryOptions } from './recovery/server';
4
- import type { SdkAgentIdentity } from './identity';
2
+ import type { RemoteSdkFactoryInput, RemoteSdkLimits, SdkRun } from './types.js';
3
+ import type { RuntimeRecoveryOptions } from './recovery/server.js';
4
+ import type { SdkAgentIdentity } from './identity.js';
5
5
  export interface RemoteSdkServerOptions extends Partial<RemoteSdkLimits> {
6
6
  recovery?: RuntimeRecoveryOptions;
7
7
  runtimeId: string;
@@ -1,4 +1,4 @@
1
- import type { RemoteSdkSnapshot, RemoteSdkLimits } from './types';
1
+ import type { RemoteSdkSnapshot, RemoteSdkLimits } from './types.js';
2
2
  /** One bounded transfer per execution; chunks precede the terminal receipt in the ordered durable stream. */
3
3
  export declare function createSnapshotReceiver(maxBytes: number): {
4
4
  accept(data: unknown): null;
@@ -1,6 +1,6 @@
1
1
  import type { RunStep, AgentInputs, createHostFileService, HostFileBindings, HostFileDescriptor, HostFileServiceDescriptor, createHostProviderTextService, createHostModelService, HostModelDescriptor, HostChatModel, HostProviderTextDescriptor, HostToolDescriptor, HostToolBindings, Run, RunConfig, EventHandler, IState, HookEvent } from '../index.js';
2
- import type { HostModelLifecycle } from './admission';
3
- import type { SdkAgentIdentity } from './identity';
2
+ import type { HostModelLifecycle } from './admission.js';
3
+ import type { SdkAgentIdentity } from './identity.js';
4
4
  export interface RemoteSdkRecoveryOptions {
5
5
  /** Operator-allowlisted direct worker routes, keyed by stable owner identity. */
6
6
  routes?: Record<string, string>;
@@ -1,6 +1,6 @@
1
1
  import type { BaseCheckpointSaver } from '@langchain/langgraph';
2
- import type { AgentSessionConfig, AgentSessionCheckpointLookupOptions, AgentSessionCheckpointReference, AgentSessionInput, AgentSessionRunOptions, AgentSessionRunResult, AgentSessionStream, SessionBranchOptions, SessionCompactOptions, SessionForkOptions } from './types';
3
- import { JsonlSessionStore } from './JsonlSessionStore';
2
+ import type { AgentSessionConfig, AgentSessionCheckpointLookupOptions, AgentSessionCheckpointReference, AgentSessionInput, AgentSessionRunOptions, AgentSessionRunResult, AgentSessionStream, SessionBranchOptions, SessionCompactOptions, SessionForkOptions } from './types.js';
3
+ import { JsonlSessionStore } from './JsonlSessionStore.js';
4
4
  export declare class AgentSession {
5
5
  private runConfig;
6
6
  private store;
@@ -1,5 +1,5 @@
1
1
  import type { BaseMessage } from '@langchain/core/messages';
2
- import type { CreateSessionFileOptions, SessionBranchOptions, SessionEntry, SessionForkOptions, SessionHeader, SessionLabelEntry, SessionListItem, SessionMessageEntry, SessionCheckpointEntry, SessionCompactionEntry, SessionRunEventEntry, SessionSummaryEntry, SessionStateEntry, SessionFadingState, SessionTreeNode } from './types';
2
+ import type { CreateSessionFileOptions, SessionBranchOptions, SessionEntry, SessionForkOptions, SessionHeader, SessionLabelEntry, SessionListItem, SessionMessageEntry, SessionCheckpointEntry, SessionCompactionEntry, SessionRunEventEntry, SessionSummaryEntry, SessionStateEntry, SessionFadingState, SessionTreeNode } from './types.js';
3
3
  export declare class JsonlSessionStore {
4
4
  readonly path: string;
5
5
  readonly header: SessionHeader;
@@ -1,5 +1,5 @@
1
1
  import type { BaseMessage } from '@langchain/core/messages';
2
- import type { SessionEntry } from './types';
2
+ import type { SessionEntry } from './types.js';
3
3
  export interface DerivedSessionMessages {
4
4
  initialSummary?: {
5
5
  text: string;
@@ -1,4 +1,4 @@
1
- import type { AgentSessionHandlersResult, AgentSessionStreamEvent } from './types';
1
+ import type { AgentSessionHandlersResult, AgentSessionStreamEvent } from './types.js';
2
2
  import type * as t from '../types/index.js';
3
3
  export declare function createRunHandlers(params: {
4
4
  runId: string;
@@ -1,7 +1,7 @@
1
- export { AgentSession, createAgentSession } from './AgentSession';
2
- export { deriveMessages } from './deriveMessages';
3
- export { JsonlSessionStore, SessionManager } from './JsonlSessionStore';
4
- export { createRunHandlers } from './handlers';
5
- export { serializeMessage, deserializeMessage, extractTextFromContent, } from './messageSerialization';
6
- export type { AgentSessionConfig, AgentSessionCheckpointLookupOptions, AgentSessionCheckpointReference, AgentSessionCheckpointing, AgentSessionCheckpointingOptions, AgentSessionHandlersResult, AgentSessionInput, AgentSessionRunOptions, AgentSessionRunResult, AgentSessionStream, AgentSessionStreamEvent, AgentSessionUsage, CreateSessionFileOptions, JsonObject, JsonPrimitive, JsonValue, SerializedSessionMessage, SessionBranchOptions, SessionCompactOptions, SessionCheckpointEntry, SessionCompactionEntry, SessionEntry, SessionEntryBase, SessionEntryType, SessionForkOptions, SessionHeader, SessionLabelEntry, SessionListItem, SessionMessageEntry, SessionPosition, SessionRunEventEntry, SessionStateEntry, SessionSummaryEntry, SessionTreeNode, } from './types';
7
- export type { DerivedSessionMessages } from './deriveMessages';
1
+ export { AgentSession, createAgentSession } from './AgentSession.js';
2
+ export { deriveMessages } from './deriveMessages.js';
3
+ export { JsonlSessionStore, SessionManager } from './JsonlSessionStore.js';
4
+ export { createRunHandlers } from './handlers.js';
5
+ export { serializeMessage, deserializeMessage, extractTextFromContent, } from './messageSerialization.js';
6
+ export type { AgentSessionConfig, AgentSessionCheckpointLookupOptions, AgentSessionCheckpointReference, AgentSessionCheckpointing, AgentSessionCheckpointingOptions, AgentSessionHandlersResult, AgentSessionInput, AgentSessionRunOptions, AgentSessionRunResult, AgentSessionStream, AgentSessionStreamEvent, AgentSessionUsage, CreateSessionFileOptions, JsonObject, JsonPrimitive, JsonValue, SerializedSessionMessage, SessionBranchOptions, SessionCompactOptions, SessionCheckpointEntry, SessionCompactionEntry, SessionEntry, SessionEntryBase, SessionEntryType, SessionForkOptions, SessionHeader, SessionLabelEntry, SessionListItem, SessionMessageEntry, SessionPosition, SessionRunEventEntry, SessionStateEntry, SessionSummaryEntry, SessionTreeNode, } from './types.js';
7
+ export type { DerivedSessionMessages } from './deriveMessages.js';
@@ -1,5 +1,5 @@
1
1
  import { BaseMessage } from '@langchain/core/messages';
2
- import type { JsonValue, SerializedSessionMessage } from './types';
2
+ import type { JsonValue, SerializedSessionMessage } from './types.js';
3
3
  export declare function toJsonValue(value: unknown): JsonValue;
4
4
  export declare function serializeMessage(message: BaseMessage): SerializedSessionMessage;
5
5
  export declare function deserializeMessage(serialized: SerializedSessionMessage): BaseMessage;
@@ -1,6 +1,6 @@
1
- import type { DerivedSessionMessages } from './deriveMessages';
2
- import type { SessionEntry } from './types';
3
- import type { JsonlSessionStore } from './JsonlSessionStore';
1
+ import type { DerivedSessionMessages } from './deriveMessages.js';
2
+ import type { SessionEntry } from './types.js';
3
+ import type { JsonlSessionStore } from './JsonlSessionStore.js';
4
4
  /** Internal: only AgentSession's unexposed stores may reuse log topology. */
5
5
  export declare function initializeSessionProjection(store: JsonlSessionStore, entries: readonly SessionEntry[]): void;
6
6
  /** Forks share entry references, so exposing either disables the whole family. */
@@ -4,8 +4,8 @@ import type { SummarizationTrigger } from '../types/index.js';
4
4
  * default prompts stay out of it: LibreChat's manual flow deliberately words
5
5
  * its own, so exporting these would publish an API with no consumer.
6
6
  */
7
- export { buildSummarizationInstruction, buildSummaryCarrierText, separateSummarizationParameters, ManualSummarizationSkippedError, } from './shared';
8
- export type { ManualSummarizationSkipReason } from './shared';
7
+ export { buildSummarizationInstruction, buildSummaryCarrierText, separateSummarizationParameters, ManualSummarizationSkippedError, } from './shared.js';
8
+ export type { ManualSummarizationSkipReason } from './shared.js';
9
9
  /** For tests only. Resets the dedup set so warnings can be observed again. */
10
10
  export declare function _resetUnrecognizedTriggerWarnings(): void;
11
11
  /**
@@ -1,5 +1,5 @@
1
1
  import { DynamicStructuredTool } from '@langchain/core/tools';
2
- import type { ProgrammaticToolCallingJsonSchema } from './ptcTimeout';
2
+ import type { ProgrammaticToolCallingJsonSchema } from './ptcTimeout.js';
3
3
  import type * as t from '../types/index.js';
4
4
  import { Constants } from '../common/index.js';
5
5
  export declare function createBashProgrammaticToolCallingSchema(maxRunTimeoutMs?: number): ProgrammaticToolCallingJsonSchema;
@@ -7,13 +7,13 @@ export declare const GitHubCompareToolSchema: {
7
7
  readonly intent: {
8
8
  readonly type: "string" | "number" | "integer" | "float" | "boolean" | "array" | "object";
9
9
  readonly enum?: string[];
10
- readonly items?: import("..").JsonSchemaType;
11
- readonly properties?: Record<string, import("..").JsonSchemaType>;
10
+ readonly items?: import("../index.js").JsonSchemaType;
11
+ readonly properties?: Record<string, import("../index.js").JsonSchemaType>;
12
12
  readonly required?: string[];
13
13
  readonly description?: string;
14
14
  readonly pattern?: string;
15
15
  readonly maxLength?: number;
16
- readonly additionalProperties?: boolean | import("..").JsonSchemaType;
16
+ readonly additionalProperties?: boolean | import("../index.js").JsonSchemaType;
17
17
  };
18
18
  readonly owner: {
19
19
  readonly type: "string";
@@ -43,13 +43,13 @@ export declare const GitHubCompareToolDefinition: {
43
43
  readonly intent: {
44
44
  readonly type: "string" | "number" | "integer" | "float" | "boolean" | "array" | "object";
45
45
  readonly enum?: string[];
46
- readonly items?: import("..").JsonSchemaType;
47
- readonly properties?: Record<string, import("..").JsonSchemaType>;
46
+ readonly items?: import("../index.js").JsonSchemaType;
47
+ readonly properties?: Record<string, import("../index.js").JsonSchemaType>;
48
48
  readonly required?: string[];
49
49
  readonly description?: string;
50
50
  readonly pattern?: string;
51
51
  readonly maxLength?: number;
52
- readonly additionalProperties?: boolean | import("..").JsonSchemaType;
52
+ readonly additionalProperties?: boolean | import("../index.js").JsonSchemaType;
53
53
  };
54
54
  readonly owner: {
55
55
  readonly type: "string";
@@ -1,5 +1,5 @@
1
1
  import { DynamicStructuredTool } from '@langchain/core/tools';
2
- import type { ProgrammaticToolCallingJsonSchema } from './ptcTimeout';
2
+ import type { ProgrammaticToolCallingJsonSchema } from './ptcTimeout.js';
3
3
  import type * as t from '../types/index.js';
4
4
  import { Constants } from '../common/index.js';
5
5
  export declare function createProgrammaticToolCallingSchema(maxRunTimeoutMs?: number): ProgrammaticToolCallingJsonSchema;
@@ -7,13 +7,13 @@ export declare const ReadFileToolSchema: {
7
7
  readonly intent: {
8
8
  readonly type: "string" | "number" | "integer" | "float" | "boolean" | "array" | "object";
9
9
  readonly enum?: string[];
10
- readonly items?: import("..").JsonSchemaType;
11
- readonly properties?: Record<string, import("..").JsonSchemaType>;
10
+ readonly items?: import("../index.js").JsonSchemaType;
11
+ readonly properties?: Record<string, import("../index.js").JsonSchemaType>;
12
12
  readonly required?: string[];
13
13
  readonly description?: string;
14
14
  readonly pattern?: string;
15
15
  readonly maxLength?: number;
16
- readonly additionalProperties?: boolean | import("..").JsonSchemaType;
16
+ readonly additionalProperties?: boolean | import("../index.js").JsonSchemaType;
17
17
  };
18
18
  readonly path: {
19
19
  readonly type: "string";
@@ -31,13 +31,13 @@ export declare const ReadFileToolDefinition: {
31
31
  readonly intent: {
32
32
  readonly type: "string" | "number" | "integer" | "float" | "boolean" | "array" | "object";
33
33
  readonly enum?: string[];
34
- readonly items?: import("..").JsonSchemaType;
35
- readonly properties?: Record<string, import("..").JsonSchemaType>;
34
+ readonly items?: import("../index.js").JsonSchemaType;
35
+ readonly properties?: Record<string, import("../index.js").JsonSchemaType>;
36
36
  readonly required?: string[];
37
37
  readonly description?: string;
38
38
  readonly pattern?: string;
39
39
  readonly maxLength?: number;
40
- readonly additionalProperties?: boolean | import("..").JsonSchemaType;
40
+ readonly additionalProperties?: boolean | import("../index.js").JsonSchemaType;
41
41
  };
42
42
  readonly path: {
43
43
  readonly type: "string";
@@ -12,13 +12,13 @@ export declare const SkillToolSchema: {
12
12
  readonly intent: {
13
13
  readonly type: "string" | "number" | "integer" | "float" | "boolean" | "array" | "object";
14
14
  readonly enum?: string[];
15
- readonly items?: import("..").JsonSchemaType;
16
- readonly properties?: Record<string, import("..").JsonSchemaType>;
15
+ readonly items?: import("../index.js").JsonSchemaType;
16
+ readonly properties?: Record<string, import("../index.js").JsonSchemaType>;
17
17
  readonly required?: string[];
18
18
  readonly description?: string;
19
19
  readonly pattern?: string;
20
20
  readonly maxLength?: number;
21
- readonly additionalProperties?: boolean | import("..").JsonSchemaType;
21
+ readonly additionalProperties?: boolean | import("../index.js").JsonSchemaType;
22
22
  };
23
23
  readonly skillName: {
24
24
  readonly type: "string";
@@ -40,13 +40,13 @@ export declare const SkillToolDefinition: {
40
40
  readonly intent: {
41
41
  readonly type: "string" | "number" | "integer" | "float" | "boolean" | "array" | "object";
42
42
  readonly enum?: string[];
43
- readonly items?: import("..").JsonSchemaType;
44
- readonly properties?: Record<string, import("..").JsonSchemaType>;
43
+ readonly items?: import("../index.js").JsonSchemaType;
44
+ readonly properties?: Record<string, import("../index.js").JsonSchemaType>;
45
45
  readonly required?: string[];
46
46
  readonly description?: string;
47
47
  readonly pattern?: string;
48
48
  readonly maxLength?: number;
49
- readonly additionalProperties?: boolean | import("..").JsonSchemaType;
49
+ readonly additionalProperties?: boolean | import("../index.js").JsonSchemaType;
50
50
  };
51
51
  readonly skillName: {
52
52
  readonly type: "string";
@@ -102,6 +102,7 @@ export declare class ToolNode<T = any> extends RunnableCallable<T, T> {
102
102
  private agentLangfuse?;
103
103
  toolCallStepIds?: Map<string, string>;
104
104
  errorHandler?: t.ToolNodeConstructorParams['errorHandler'];
105
+ private toolResultGate?;
105
106
  /**
106
107
  * Fallback error-completion ownership for calls that reach `runTool`
107
108
  * outside a batch context (direct `runTool` use in tests / embedders).
@@ -230,7 +231,7 @@ export declare class ToolNode<T = any> extends RunnableCallable<T, T> {
230
231
  */
231
232
  private anonBatchCounter;
232
233
  private handoffRouting?;
233
- constructor({ handoffRouting, tools, toolMap, name, tags, trace, runLangfuse, agentLangfuse, errorHandler, toolCallStepIds, handleToolErrors, loadRuntimeTools, toolRegistry, toolDefinitions, getDiscoveredToolNames, sessions, codeSessionKey, eventDrivenMode, eagerEventToolExecution, eagerEventToolExecutions, eagerEventToolUsageCount, eagerEventToolSuppressions, agentId, executingAgentId, executionContext, executingAgentName, rootAgentId, rootAgentName, directToolNames, interruptingToolNames, codeSessionToolNames, maxContextTokens, maxToolResultChars, hookRegistry, humanInTheLoop, toolOutputReferences, toolOutputRegistry, toolExecution, fileCheckpointer, getBreakerSignal, getRunScope, preparedSubagents, restoreRunStepResumeState, createRunStepResumeState, onToolCallsClaimed, }: t.ToolNodeConstructorParams);
234
+ constructor({ handoffRouting, tools, toolMap, name, tags, trace, runLangfuse, agentLangfuse, errorHandler, toolCallStepIds, handleToolErrors, loadRuntimeTools, toolRegistry, toolDefinitions, getDiscoveredToolNames, sessions, codeSessionKey, eventDrivenMode, eagerEventToolExecution, eagerEventToolExecutions, eagerEventToolUsageCount, eagerEventToolSuppressions, agentId, executingAgentId, executionContext, executingAgentName, rootAgentId, rootAgentName, directToolNames, interruptingToolNames, codeSessionToolNames, maxContextTokens, maxToolResultChars, hookRegistry, humanInTheLoop, toolOutputReferences, toolOutputRegistry, toolResultProtection, toolExecution, fileCheckpointer, getBreakerSignal, getRunScope, preparedSubagents, restoreRunStepResumeState, createRunStepResumeState, onToolCallsClaimed, }: t.ToolNodeConstructorParams);
234
235
  invoke(input: any, options?: Partial<RunnableConfig>): Promise<any>;
235
236
  private withToolScope;
236
237
  /**
@@ -311,6 +312,9 @@ export declare class ToolNode<T = any> extends RunnableCallable<T, T> {
311
312
  * substitutions. Omit when no registration should occur.
312
313
  */
313
314
  protected runTool(call: ToolCall, config: RunnableConfig, batchContext?: RunToolBatchContext<T>): Promise<BaseMessage | Command>;
315
+ /** The gate when host result protection selects `toolName`. */
316
+ private protectedResultGate;
317
+ private inspectHostResults;
314
318
  private unresolvedReferenceMessage;
315
319
  /**
316
320
  * Runs a single in-process tool call with the same lifecycle hooks
@@ -1,4 +1,4 @@
1
- export * from './CloudflareBridgeRuntime';
2
- export * from './CloudflareProgrammaticToolCalling';
3
- export * from './CloudflareSandboxExecutionEngine';
4
- export * from './CloudflareSandboxTools';
1
+ export * from './CloudflareBridgeRuntime.js';
2
+ export * from './CloudflareProgrammaticToolCalling.js';
3
+ export * from './CloudflareSandboxExecutionEngine.js';
4
+ export * from './CloudflareSandboxTools.js';
@@ -1,4 +1,5 @@
1
1
  import type { ToolCall, ToolCallChunk } from '@langchain/core/messages/tool';
2
+ import type { NativeSearchCall } from './search/citations.js';
2
3
  import type { Graph, MultiAgentGraph, StandardGraph } from '../graphs/index.js';
3
4
  import type { AgentContext } from '../agents/AgentContext.js';
4
5
  import type * as t from '../types/index.js';
@@ -21,3 +22,15 @@ export declare function handleServerToolResult({ graph, content, metadata, agent
21
22
  metadata?: Record<string, unknown>;
22
23
  agentContext?: AgentContext;
23
24
  }): Promise<boolean>;
25
+ /**
26
+ * Settles the web search citations Gemini grounding and OpenAI `url_citation`
27
+ * attach to a finished model call. They arrive after the text they cite has
28
+ * streamed, so the sources reach TOOL_END handlers as one `web_search` turn
29
+ * (as Anthropic results do) and the cited spans are rewritten into
30
+ * `turnNsearchM` anchors through `edits` on the steps that hold the text.
31
+ */
32
+ export declare function handleNativeSearchCitations({ graph, call, metadata, }: {
33
+ graph: StandardGraph | MultiAgentGraph;
34
+ call: NativeSearchCall;
35
+ metadata?: Record<string, unknown>;
36
+ }): Promise<void>;
@@ -1,4 +1,4 @@
1
- import type { WorkspaceFS } from './workspaceFS';
1
+ import type { WorkspaceFS } from './workspaceFS.js';
2
2
  import type * as t from '../../types/index.js';
3
3
  /**
4
4
  * Per-Run snapshot store for write_file / edit_file. Captures the
@@ -1,4 +1,4 @@
1
- import type { WorkspaceFS } from './workspaceFS';
1
+ import type { WorkspaceFS } from './workspaceFS.js';
2
2
  import type * as t from '../../types/index.js';
3
3
  /** Produces a stable, non-plaintext key for environment-sensitive probes. */
4
4
  export declare function commandAvailabilityEnvCacheKey(env: NodeJS.ProcessEnv | undefined): string;
@@ -32,7 +32,7 @@
32
32
  * size; oversize attachments degrade to a stub describing the
33
33
  * refusal so the model isn't surprised.
34
34
  */
35
- import type { WorkspaceFS } from './workspaceFS';
35
+ import type { WorkspaceFS } from './workspaceFS.js';
36
36
  export type AttachmentMode = 'images-only' | 'images-and-pdf' | 'off';
37
37
  export type Attachment = {
38
38
  kind: 'image';
@@ -1,12 +1,12 @@
1
- export * from './CompileCheckTool';
2
- export * from './FileCheckpointer';
3
- export * from './LocalCodingTools';
4
- export * from './LocalExecutionEngine';
5
- export * from './LocalExecutionTools';
6
- export * from './LocalProgrammaticToolCalling';
7
- export * from './resolveLocalExecutionTools';
8
- export * from './attachments';
9
- export * from './bashAst';
10
- export * from './editStrategies';
11
- export * from './syntaxCheck';
12
- export * from './textEncoding';
1
+ export * from './CompileCheckTool.js';
2
+ export * from './FileCheckpointer.js';
3
+ export * from './LocalCodingTools.js';
4
+ export * from './LocalExecutionEngine.js';
5
+ export * from './LocalExecutionTools.js';
6
+ export * from './LocalProgrammaticToolCalling.js';
7
+ export * from './resolveLocalExecutionTools.js';
8
+ export * from './attachments.js';
9
+ export * from './bashAst.js';
10
+ export * from './editStrategies.js';
11
+ export * from './syntaxCheck.js';
12
+ export * from './textEncoding.js';
@@ -1,5 +1,5 @@
1
1
  import type { AnthropicTextBlockParam, AnthropicWebSearchResultBlockParam } from '../../llm/anthropic/types.js';
2
- import type { SearchResultData } from './types';
2
+ import type { SearchResultData } from './types.js';
3
3
  /**
4
4
  * Coerces Anthropic web search results to the SearchResultData format
5
5
  * @param results - Array of Anthropic web search results
@@ -0,0 +1,88 @@
1
+ import type { GoogleGroundingMetadata, SearchResultData, ProcessedOrganic } from './types.js';
2
+ import type * as t from '../../types/index.js';
3
+ export type SearchRef = {
4
+ turn: number;
5
+ index: number;
6
+ };
7
+ /** A span of a model call's text that cites `sources` (organic indices). */
8
+ export type CitationSpan = {
9
+ start: number;
10
+ end: number;
11
+ sources: number[];
12
+ };
13
+ export type NativeSearchResults = {
14
+ organic: ProcessedOrganic[];
15
+ spans: CitationSpan[];
16
+ queries?: string[];
17
+ };
18
+ export type UrlCitation = {
19
+ block?: number;
20
+ url: string;
21
+ title?: string;
22
+ start?: number;
23
+ end?: number;
24
+ };
25
+ export type NativeSearchCall = {
26
+ text: string;
27
+ /** Where each step's text starts, in `text` and in the step's content part. */
28
+ steps: {
29
+ id: string;
30
+ start: number;
31
+ base: number;
32
+ }[];
33
+ /** Offset in `text` where each provider text block starts. */
34
+ blocks: Map<number, number>;
35
+ citations: UrlCitation[];
36
+ grounding?: GoogleGroundingMetadata;
37
+ metadata?: Record<string, unknown>;
38
+ };
39
+ export declare function formatSearchAnchors(refs: readonly SearchRef[]): string;
40
+ /** Removes the markers {@link formatSearchAnchors} writes, so replayed text matches what the provider sent. */
41
+ export declare function stripSearchAnchors(text: string): string;
42
+ /** Applies non-overlapping edits by position; an edit outside the text or over an earlier one is skipped. */
43
+ export declare function applyTextEdits(text: string, edits: readonly t.TextEdit[]): string;
44
+ /** Converts a UTF-8 byte offset into a UTF-16 index of `text`; undefined when it falls inside a character. */
45
+ export declare function byteToCharOffset(text: string, bytes: number): number | undefined;
46
+ /**
47
+ * Run-scoped state that turns provider-native web search citations into the
48
+ * `turnNsearchM` anchors hosts already render for the SDK's own search tool.
49
+ */
50
+ export declare class SearchCitations {
51
+ /** Organic results by link, so a cited URL resolves to its turn and index. */
52
+ private sources;
53
+ /** Anchors for a cited block, written once the block ends. */
54
+ private pending;
55
+ /** Text and citation data of a model call still streaming, by agent lane. */
56
+ private calls;
57
+ /** Text length dispatched to each tracked step, to place late edits. */
58
+ private lengths;
59
+ /** Turns claimed by searches that never produce a tool call id. */
60
+ private claimed;
61
+ register(data: SearchResultData): void;
62
+ /** The turn for a search identified by a tool call id that joins `invokedToolIds`. */
63
+ turn(invoked: number): number;
64
+ /** Claims a turn for a search with no tool call id of its own. */
65
+ claimTurn(invoked: number): number;
66
+ /**
67
+ * Adds the anchors of a cited block before the first delta of the next
68
+ * block. Anthropic sends a block's citations before or after its text, and
69
+ * the anchor belongs after the text, so it waits for the block to end.
70
+ * Returns undefined when the content needs no change.
71
+ */
72
+ anchor(stepId: string, content: t.MessageContentComplex[], metadata?: Record<string, unknown>): t.MessageContentComplex[] | undefined;
73
+ /** Anchors still waiting on a step that is closing. */
74
+ release(stepId: string): {
75
+ text: string;
76
+ metadata?: Record<string, unknown>;
77
+ } | undefined;
78
+ /** Records a step's streamed text and url citations for edits made when the model call ends. */
79
+ track(lane: string, stepId: string, content: t.MessageContentComplex[], metadata?: Record<string, unknown>): void;
80
+ /** Keeps the latest grounding payload of a model call. */
81
+ ground(lane: string, grounding: GoogleGroundingMetadata, metadata?: Record<string, unknown>): void;
82
+ /** Hands over the finished model call of a lane. */
83
+ take(lane: string): NativeSearchCall | undefined;
84
+ /** Splits call-relative edits by the step that holds their text, in that step's offsets. */
85
+ locate(call: NativeSearchCall, edits: readonly t.TextEdit[]): Map<string, t.TextEdit[]>;
86
+ private open;
87
+ private resolve;
88
+ }
@@ -1,4 +1,41 @@
1
- import type { References } from './types';
1
+ import type { References, MediaReference } from './types.js';
2
+ type ReferenceType = 'image' | 'video' | 'iframe' | 'link';
3
+ interface ReferenceTarget {
4
+ type: ReferenceType;
5
+ idx: number;
6
+ }
7
+ /**
8
+ * Aho-Corasick automaton over `(` followed by every referenced URL, held in
9
+ * typed arrays: 18 bytes per node and no object per node. Nodes are numbered
10
+ * breadth first, so the children of `node` are the nodes from
11
+ * `firstChild[node]` up to `firstChild[node + 1]`, sorted by `code`.
12
+ */
13
+ export interface ReferenceMatcher {
14
+ firstChild: Int32Array;
15
+ code: Uint16Array;
16
+ depth: Int32Array;
17
+ fail: Int32Array;
18
+ /** Nearest node on the fail chain, itself included, that ends a URL, or -1. */
19
+ output: Int32Array;
20
+ targets: Map<number, ReferenceTarget>;
21
+ }
22
+ /**
23
+ * Largest automaton built for one page. Nodes are the distinct URL prefixes, at
24
+ * most the URL characters on the page: 2^21 of them measured 36 MiB and 0.15 s
25
+ * to build, about 100 times a long Wikipedia article. A page above the cap
26
+ * keeps its markdown as is.
27
+ */
28
+ export declare const MAX_MATCHER_NODES: number;
29
+ /**
30
+ * Indexes every referenced URL once, or returns `undefined` when the automaton
31
+ * would exceed `MAX_MATCHER_NODES`. A URL listed under several types keeps the
32
+ * first, in image, video, iframe, link order, which is the order the replacement
33
+ * has always preferred. Sorting the URLs gives the exact node count before
34
+ * anything is allocated, and lets each node take its children from one
35
+ * contiguous run of URLs.
36
+ */
37
+ export declare function buildMatcher(groups: ReadonlyArray<[ReferenceType, Map<string, MediaReference>]>): ReferenceMatcher | undefined;
2
38
  export declare function processContent(html: string, markdown: string): {
3
39
  markdown: string;
4
40
  } & References;
41
+ export {};
@@ -1,4 +1,4 @@
1
- import type * as t from './types';
1
+ import type * as t from './types.js';
2
2
  /**
3
3
  * fastCRW scraper. Firecrawl-compatible web scraper; single binary;
4
4
  * self-host or cloud. Posts to {base}/v1/scrape.
@@ -1,4 +1,4 @@
1
- import type * as t from './types';
1
+ import type * as t from './types.js';
2
2
  export declare const createCrwAPI: (apiKey?: string, apiUrl?: string, options?: t.CrwSearchOptions) => {
3
3
  getSources: (params: t.GetSourcesParams) => Promise<t.SearchResult>;
4
4
  };
@@ -1,7 +1,9 @@
1
- import type * as t from './types';
1
+ import type * as t from './types.js';
2
2
  /**
3
3
  * Firecrawl scraper implementation
4
- * Uses the Firecrawl API to scrape web pages
4
+ * Uses the Firecrawl API to scrape web pages. Without an API key, requests go
5
+ * out with no Authorization header, which a self-hosted instance running
6
+ * without authentication accepts.
5
7
  */
6
8
  export declare class FirecrawlScraper implements t.BaseScraper {
7
9
  private apiKey;
@@ -1,4 +1,4 @@
1
- import type * as t from './types';
1
+ import type * as t from './types.js';
2
2
  export declare const MISSING_SEARCH_RESULT_DATA_ERROR = "Search provider returned no result data";
3
3
  /** Resolves the per-search highlight budget from config, the
4
4
  * `SEARCH_MAX_LLM_OUTPUT_CHARS` env var, or the default (50,000 chars). */
@@ -0,0 +1,11 @@
1
+ import type { GoogleGroundingMetadata } from './types.js';
2
+ import type { NativeSearchResults } from './citations.js';
3
+ type GroundedChunk = {
4
+ additional_kwargs?: Record<string, unknown>;
5
+ response_metadata?: Record<string, unknown>;
6
+ };
7
+ /** Gemini API chunks carry it in `additional_kwargs`, Vertex AI chunks in `response_metadata`. */
8
+ export declare function getGoogleGroundingMetadata(chunk: GroundedChunk): GoogleGroundingMetadata | undefined;
9
+ /** Turns Gemini grounding into organic results and the spans each support cites. */
10
+ export declare function coerceGoogleGroundingResults(grounding: GoogleGroundingMetadata, text: string): NativeSearchResults | undefined;
11
+ export {};
@@ -1,4 +1,4 @@
1
- import type * as t from './types';
1
+ import type * as t from './types.js';
2
2
  /**
3
3
  * Expand highlights in search results using smart boundary detection.
4
4
  *
@@ -1,3 +1,3 @@
1
- export * from './tool';
2
- export * from './schema';
3
- export type * from './types';
1
+ export * from './tool.js';
2
+ export * from './schema.js';
3
+ export type * from './types.js';
@@ -1,4 +1,4 @@
1
- import type * as t from './types';
1
+ import type * as t from './types.js';
2
2
  export declare class KeenableScraper implements t.BaseScraper {
3
3
  private apiKey;
4
4
  private apiUrl;
@@ -1,4 +1,4 @@
1
- import type * as t from './types';
1
+ import type * as t from './types.js';
2
2
  export declare const createKeenableAPI: (apiKey?: string, apiUrl?: string, options?: t.KeenableSearchOptions) => {
3
3
  getSources: (params: t.GetSourcesParams) => Promise<t.SearchResult>;
4
4
  };
@@ -1,4 +1,4 @@
1
- import type * as t from './types';
1
+ import type * as t from './types.js';
2
2
  export declare const classifyFailure: (message?: string) => string;
3
3
  /**
4
4
  * Creates the counter set for one `web_search` call.
@@ -0,0 +1,3 @@
1
+ import type { NativeSearchResults, UrlCitation } from './citations.js';
2
+ /** Turns OpenAI `url_citation` annotations into organic results and the links they replace. */
3
+ export declare function coerceOpenAICitationResults(citations: readonly UrlCitation[], text: string, blocks: ReadonlyMap<number, number>): NativeSearchResults | undefined;
@@ -1,4 +1,4 @@
1
- import type * as t from './types';
1
+ import type * as t from './types.js';
2
2
  /**
3
3
  * Ranking used whenever no reranker scores the chunks: the candidates' own
4
4
  * order, capped at `topK`, with a neutral score.