@librechat/agents 2.4.321 → 3.0.0-rc1

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 (266) hide show
  1. package/dist/cjs/agents/AgentContext.cjs +218 -0
  2. package/dist/cjs/agents/AgentContext.cjs.map +1 -0
  3. package/dist/cjs/common/enum.cjs +14 -5
  4. package/dist/cjs/common/enum.cjs.map +1 -1
  5. package/dist/cjs/events.cjs +10 -6
  6. package/dist/cjs/events.cjs.map +1 -1
  7. package/dist/cjs/graphs/Graph.cjs +309 -212
  8. package/dist/cjs/graphs/Graph.cjs.map +1 -1
  9. package/dist/cjs/graphs/MultiAgentGraph.cjs +322 -0
  10. package/dist/cjs/graphs/MultiAgentGraph.cjs.map +1 -0
  11. package/dist/cjs/llm/anthropic/index.cjs +54 -9
  12. package/dist/cjs/llm/anthropic/index.cjs.map +1 -1
  13. package/dist/cjs/llm/anthropic/types.cjs.map +1 -1
  14. package/dist/cjs/llm/anthropic/utils/message_inputs.cjs +52 -6
  15. package/dist/cjs/llm/anthropic/utils/message_inputs.cjs.map +1 -1
  16. package/dist/cjs/llm/anthropic/utils/message_outputs.cjs +22 -2
  17. package/dist/cjs/llm/anthropic/utils/message_outputs.cjs.map +1 -1
  18. package/dist/cjs/llm/anthropic/utils/tools.cjs +29 -0
  19. package/dist/cjs/llm/anthropic/utils/tools.cjs.map +1 -0
  20. package/dist/cjs/llm/google/index.cjs +144 -0
  21. package/dist/cjs/llm/google/index.cjs.map +1 -0
  22. package/dist/cjs/llm/google/utils/common.cjs +477 -0
  23. package/dist/cjs/llm/google/utils/common.cjs.map +1 -0
  24. package/dist/cjs/llm/ollama/index.cjs +67 -0
  25. package/dist/cjs/llm/ollama/index.cjs.map +1 -0
  26. package/dist/cjs/llm/ollama/utils.cjs +158 -0
  27. package/dist/cjs/llm/ollama/utils.cjs.map +1 -0
  28. package/dist/cjs/llm/openai/index.cjs +389 -3
  29. package/dist/cjs/llm/openai/index.cjs.map +1 -1
  30. package/dist/cjs/llm/openai/utils/index.cjs +672 -0
  31. package/dist/cjs/llm/openai/utils/index.cjs.map +1 -0
  32. package/dist/cjs/llm/providers.cjs +15 -15
  33. package/dist/cjs/llm/providers.cjs.map +1 -1
  34. package/dist/cjs/llm/text.cjs +14 -3
  35. package/dist/cjs/llm/text.cjs.map +1 -1
  36. package/dist/cjs/llm/vertexai/index.cjs +330 -0
  37. package/dist/cjs/llm/vertexai/index.cjs.map +1 -0
  38. package/dist/cjs/main.cjs +11 -0
  39. package/dist/cjs/main.cjs.map +1 -1
  40. package/dist/cjs/run.cjs +120 -81
  41. package/dist/cjs/run.cjs.map +1 -1
  42. package/dist/cjs/stream.cjs +85 -51
  43. package/dist/cjs/stream.cjs.map +1 -1
  44. package/dist/cjs/tools/ToolNode.cjs +10 -4
  45. package/dist/cjs/tools/ToolNode.cjs.map +1 -1
  46. package/dist/cjs/tools/handlers.cjs +119 -13
  47. package/dist/cjs/tools/handlers.cjs.map +1 -1
  48. package/dist/cjs/tools/search/anthropic.cjs +40 -0
  49. package/dist/cjs/tools/search/anthropic.cjs.map +1 -0
  50. package/dist/cjs/tools/search/firecrawl.cjs +61 -13
  51. package/dist/cjs/tools/search/firecrawl.cjs.map +1 -1
  52. package/dist/cjs/tools/search/format.cjs +9 -3
  53. package/dist/cjs/tools/search/format.cjs.map +1 -1
  54. package/dist/cjs/tools/search/rerankers.cjs +35 -50
  55. package/dist/cjs/tools/search/rerankers.cjs.map +1 -1
  56. package/dist/cjs/tools/search/schema.cjs +70 -0
  57. package/dist/cjs/tools/search/schema.cjs.map +1 -0
  58. package/dist/cjs/tools/search/search.cjs +145 -38
  59. package/dist/cjs/tools/search/search.cjs.map +1 -1
  60. package/dist/cjs/tools/search/tool.cjs +165 -48
  61. package/dist/cjs/tools/search/tool.cjs.map +1 -1
  62. package/dist/cjs/tools/search/utils.cjs +34 -5
  63. package/dist/cjs/tools/search/utils.cjs.map +1 -1
  64. package/dist/cjs/utils/events.cjs +31 -0
  65. package/dist/cjs/utils/events.cjs.map +1 -0
  66. package/dist/cjs/utils/title.cjs +57 -21
  67. package/dist/cjs/utils/title.cjs.map +1 -1
  68. package/dist/cjs/utils/tokens.cjs +54 -7
  69. package/dist/cjs/utils/tokens.cjs.map +1 -1
  70. package/dist/esm/agents/AgentContext.mjs +216 -0
  71. package/dist/esm/agents/AgentContext.mjs.map +1 -0
  72. package/dist/esm/common/enum.mjs +15 -6
  73. package/dist/esm/common/enum.mjs.map +1 -1
  74. package/dist/esm/events.mjs +10 -6
  75. package/dist/esm/events.mjs.map +1 -1
  76. package/dist/esm/graphs/Graph.mjs +311 -214
  77. package/dist/esm/graphs/Graph.mjs.map +1 -1
  78. package/dist/esm/graphs/MultiAgentGraph.mjs +320 -0
  79. package/dist/esm/graphs/MultiAgentGraph.mjs.map +1 -0
  80. package/dist/esm/llm/anthropic/index.mjs +54 -9
  81. package/dist/esm/llm/anthropic/index.mjs.map +1 -1
  82. package/dist/esm/llm/anthropic/types.mjs.map +1 -1
  83. package/dist/esm/llm/anthropic/utils/message_inputs.mjs +52 -6
  84. package/dist/esm/llm/anthropic/utils/message_inputs.mjs.map +1 -1
  85. package/dist/esm/llm/anthropic/utils/message_outputs.mjs +22 -2
  86. package/dist/esm/llm/anthropic/utils/message_outputs.mjs.map +1 -1
  87. package/dist/esm/llm/anthropic/utils/tools.mjs +27 -0
  88. package/dist/esm/llm/anthropic/utils/tools.mjs.map +1 -0
  89. package/dist/esm/llm/google/index.mjs +142 -0
  90. package/dist/esm/llm/google/index.mjs.map +1 -0
  91. package/dist/esm/llm/google/utils/common.mjs +471 -0
  92. package/dist/esm/llm/google/utils/common.mjs.map +1 -0
  93. package/dist/esm/llm/ollama/index.mjs +65 -0
  94. package/dist/esm/llm/ollama/index.mjs.map +1 -0
  95. package/dist/esm/llm/ollama/utils.mjs +155 -0
  96. package/dist/esm/llm/ollama/utils.mjs.map +1 -0
  97. package/dist/esm/llm/openai/index.mjs +388 -4
  98. package/dist/esm/llm/openai/index.mjs.map +1 -1
  99. package/dist/esm/llm/openai/utils/index.mjs +666 -0
  100. package/dist/esm/llm/openai/utils/index.mjs.map +1 -0
  101. package/dist/esm/llm/providers.mjs +5 -5
  102. package/dist/esm/llm/providers.mjs.map +1 -1
  103. package/dist/esm/llm/text.mjs +14 -3
  104. package/dist/esm/llm/text.mjs.map +1 -1
  105. package/dist/esm/llm/vertexai/index.mjs +328 -0
  106. package/dist/esm/llm/vertexai/index.mjs.map +1 -0
  107. package/dist/esm/main.mjs +6 -5
  108. package/dist/esm/main.mjs.map +1 -1
  109. package/dist/esm/run.mjs +121 -83
  110. package/dist/esm/run.mjs.map +1 -1
  111. package/dist/esm/stream.mjs +87 -54
  112. package/dist/esm/stream.mjs.map +1 -1
  113. package/dist/esm/tools/ToolNode.mjs +10 -4
  114. package/dist/esm/tools/ToolNode.mjs.map +1 -1
  115. package/dist/esm/tools/handlers.mjs +119 -15
  116. package/dist/esm/tools/handlers.mjs.map +1 -1
  117. package/dist/esm/tools/search/anthropic.mjs +37 -0
  118. package/dist/esm/tools/search/anthropic.mjs.map +1 -0
  119. package/dist/esm/tools/search/firecrawl.mjs +61 -13
  120. package/dist/esm/tools/search/firecrawl.mjs.map +1 -1
  121. package/dist/esm/tools/search/format.mjs +10 -4
  122. package/dist/esm/tools/search/format.mjs.map +1 -1
  123. package/dist/esm/tools/search/rerankers.mjs +35 -50
  124. package/dist/esm/tools/search/rerankers.mjs.map +1 -1
  125. package/dist/esm/tools/search/schema.mjs +61 -0
  126. package/dist/esm/tools/search/schema.mjs.map +1 -0
  127. package/dist/esm/tools/search/search.mjs +146 -39
  128. package/dist/esm/tools/search/search.mjs.map +1 -1
  129. package/dist/esm/tools/search/tool.mjs +164 -47
  130. package/dist/esm/tools/search/tool.mjs.map +1 -1
  131. package/dist/esm/tools/search/utils.mjs +33 -6
  132. package/dist/esm/tools/search/utils.mjs.map +1 -1
  133. package/dist/esm/utils/events.mjs +29 -0
  134. package/dist/esm/utils/events.mjs.map +1 -0
  135. package/dist/esm/utils/title.mjs +57 -22
  136. package/dist/esm/utils/title.mjs.map +1 -1
  137. package/dist/esm/utils/tokens.mjs +54 -8
  138. package/dist/esm/utils/tokens.mjs.map +1 -1
  139. package/dist/types/agents/AgentContext.d.ts +91 -0
  140. package/dist/types/common/enum.d.ts +15 -6
  141. package/dist/types/events.d.ts +5 -4
  142. package/dist/types/graphs/Graph.d.ts +64 -67
  143. package/dist/types/graphs/MultiAgentGraph.d.ts +37 -0
  144. package/dist/types/graphs/index.d.ts +1 -0
  145. package/dist/types/llm/anthropic/index.d.ts +11 -0
  146. package/dist/types/llm/anthropic/types.d.ts +9 -3
  147. package/dist/types/llm/anthropic/utils/message_inputs.d.ts +1 -1
  148. package/dist/types/llm/anthropic/utils/output_parsers.d.ts +4 -4
  149. package/dist/types/llm/anthropic/utils/tools.d.ts +3 -0
  150. package/dist/types/llm/google/index.d.ts +13 -0
  151. package/dist/types/llm/google/types.d.ts +32 -0
  152. package/dist/types/llm/google/utils/common.d.ts +19 -0
  153. package/dist/types/llm/google/utils/tools.d.ts +10 -0
  154. package/dist/types/llm/google/utils/zod_to_genai_parameters.d.ts +14 -0
  155. package/dist/types/llm/ollama/index.d.ts +7 -0
  156. package/dist/types/llm/ollama/utils.d.ts +7 -0
  157. package/dist/types/llm/openai/index.d.ts +72 -3
  158. package/dist/types/llm/openai/types.d.ts +10 -0
  159. package/dist/types/llm/openai/utils/index.d.ts +20 -0
  160. package/dist/types/llm/text.d.ts +1 -1
  161. package/dist/types/llm/vertexai/index.d.ts +293 -0
  162. package/dist/types/messages/reducer.d.ts +9 -0
  163. package/dist/types/run.d.ts +19 -12
  164. package/dist/types/scripts/ant_web_search.d.ts +1 -0
  165. package/dist/types/scripts/args.d.ts +2 -1
  166. package/dist/types/scripts/handoff-test.d.ts +1 -0
  167. package/dist/types/scripts/multi-agent-conditional.d.ts +1 -0
  168. package/dist/types/scripts/multi-agent-parallel.d.ts +1 -0
  169. package/dist/types/scripts/multi-agent-sequence.d.ts +1 -0
  170. package/dist/types/scripts/multi-agent-test.d.ts +1 -0
  171. package/dist/types/stream.d.ts +10 -3
  172. package/dist/types/tools/CodeExecutor.d.ts +2 -2
  173. package/dist/types/tools/ToolNode.d.ts +1 -1
  174. package/dist/types/tools/handlers.d.ts +17 -4
  175. package/dist/types/tools/search/anthropic.d.ts +16 -0
  176. package/dist/types/tools/search/firecrawl.d.ts +16 -0
  177. package/dist/types/tools/search/rerankers.d.ts +8 -5
  178. package/dist/types/tools/search/schema.d.ts +16 -0
  179. package/dist/types/tools/search/tool.d.ts +13 -0
  180. package/dist/types/tools/search/types.d.ts +64 -9
  181. package/dist/types/tools/search/utils.d.ts +9 -2
  182. package/dist/types/types/graph.d.ts +95 -15
  183. package/dist/types/types/llm.d.ts +24 -10
  184. package/dist/types/types/run.d.ts +46 -8
  185. package/dist/types/types/stream.d.ts +16 -2
  186. package/dist/types/types/tools.d.ts +1 -1
  187. package/dist/types/utils/events.d.ts +6 -0
  188. package/dist/types/utils/title.d.ts +2 -1
  189. package/dist/types/utils/tokens.d.ts +24 -0
  190. package/package.json +35 -18
  191. package/src/agents/AgentContext.ts +315 -0
  192. package/src/common/enum.ts +14 -5
  193. package/src/events.ts +24 -13
  194. package/src/graphs/Graph.ts +495 -312
  195. package/src/graphs/MultiAgentGraph.ts +381 -0
  196. package/src/graphs/index.ts +2 -1
  197. package/src/llm/anthropic/Jacob_Lee_Resume_2023.pdf +0 -0
  198. package/src/llm/anthropic/index.ts +78 -13
  199. package/src/llm/anthropic/llm.spec.ts +491 -115
  200. package/src/llm/anthropic/types.ts +39 -3
  201. package/src/llm/anthropic/utils/message_inputs.ts +67 -11
  202. package/src/llm/anthropic/utils/message_outputs.ts +21 -2
  203. package/src/llm/anthropic/utils/output_parsers.ts +25 -6
  204. package/src/llm/anthropic/utils/tools.ts +29 -0
  205. package/src/llm/google/index.ts +218 -0
  206. package/src/llm/google/types.ts +43 -0
  207. package/src/llm/google/utils/common.ts +646 -0
  208. package/src/llm/google/utils/tools.ts +160 -0
  209. package/src/llm/google/utils/zod_to_genai_parameters.ts +86 -0
  210. package/src/llm/ollama/index.ts +89 -0
  211. package/src/llm/ollama/utils.ts +193 -0
  212. package/src/llm/openai/index.ts +600 -14
  213. package/src/llm/openai/types.ts +24 -0
  214. package/src/llm/openai/utils/index.ts +912 -0
  215. package/src/llm/openai/utils/isReasoningModel.test.ts +90 -0
  216. package/src/llm/providers.ts +10 -9
  217. package/src/llm/text.ts +26 -7
  218. package/src/llm/vertexai/index.ts +360 -0
  219. package/src/messages/reducer.ts +80 -0
  220. package/src/run.ts +181 -112
  221. package/src/scripts/ant_web_search.ts +158 -0
  222. package/src/scripts/args.ts +12 -8
  223. package/src/scripts/cli4.ts +29 -21
  224. package/src/scripts/cli5.ts +29 -21
  225. package/src/scripts/code_exec.ts +54 -23
  226. package/src/scripts/code_exec_files.ts +48 -17
  227. package/src/scripts/code_exec_simple.ts +46 -27
  228. package/src/scripts/handoff-test.ts +135 -0
  229. package/src/scripts/image.ts +52 -20
  230. package/src/scripts/multi-agent-conditional.ts +220 -0
  231. package/src/scripts/multi-agent-example-output.md +110 -0
  232. package/src/scripts/multi-agent-parallel.ts +337 -0
  233. package/src/scripts/multi-agent-sequence.ts +212 -0
  234. package/src/scripts/multi-agent-test.ts +186 -0
  235. package/src/scripts/search.ts +4 -12
  236. package/src/scripts/simple.ts +25 -10
  237. package/src/scripts/tools.ts +48 -18
  238. package/src/specs/anthropic.simple.test.ts +150 -34
  239. package/src/specs/azure.simple.test.ts +325 -0
  240. package/src/specs/openai.simple.test.ts +140 -33
  241. package/src/specs/openrouter.simple.test.ts +107 -0
  242. package/src/specs/prune.test.ts +4 -9
  243. package/src/specs/reasoning.test.ts +80 -44
  244. package/src/specs/token-memoization.test.ts +39 -0
  245. package/src/stream.test.ts +94 -0
  246. package/src/stream.ts +139 -60
  247. package/src/tools/ToolNode.ts +21 -7
  248. package/src/tools/handlers.ts +192 -18
  249. package/src/tools/search/anthropic.ts +51 -0
  250. package/src/tools/search/firecrawl.ts +78 -24
  251. package/src/tools/search/format.ts +10 -5
  252. package/src/tools/search/rerankers.ts +50 -62
  253. package/src/tools/search/schema.ts +63 -0
  254. package/src/tools/search/search.ts +167 -34
  255. package/src/tools/search/tool.ts +222 -46
  256. package/src/tools/search/types.ts +65 -10
  257. package/src/tools/search/utils.ts +37 -5
  258. package/src/types/graph.ts +272 -103
  259. package/src/types/llm.ts +25 -12
  260. package/src/types/run.ts +51 -13
  261. package/src/types/stream.ts +22 -1
  262. package/src/types/tools.ts +16 -10
  263. package/src/utils/events.ts +32 -0
  264. package/src/utils/llmConfig.ts +20 -8
  265. package/src/utils/title.ts +104 -30
  266. package/src/utils/tokens.ts +69 -10
@@ -0,0 +1,19 @@
1
+ import { POSSIBLE_ROLES, type Part, type Content, type EnhancedGenerateContentResponse, type FunctionDeclarationsTool as GoogleGenerativeAIFunctionDeclarationsTool } from '@google/generative-ai';
2
+ import { BaseMessage, UsageMetadata } from '@langchain/core/messages';
3
+ import { ChatGenerationChunk } from '@langchain/core/outputs';
4
+ import { GoogleGenerativeAIToolType } from '../types';
5
+ export declare function getMessageAuthor(message: BaseMessage): string;
6
+ /**
7
+ * Maps a message type to a Google Generative AI chat author.
8
+ * @param message The message to map.
9
+ * @param model The model to use for mapping.
10
+ * @returns The message type mapped to a Google Generative AI chat author.
11
+ */
12
+ export declare function convertAuthorToRole(author: string): (typeof POSSIBLE_ROLES)[number];
13
+ export declare function convertMessageContentToParts(message: BaseMessage, isMultimodalModel: boolean, previousMessages: BaseMessage[]): Part[];
14
+ export declare function convertBaseMessagesToContent(messages: BaseMessage[], isMultimodalModel: boolean, convertSystemMessageToHumanContent?: boolean): Content[] | undefined;
15
+ export declare function convertResponseContentToChatGenerationChunk(response: EnhancedGenerateContentResponse, extra: {
16
+ usageMetadata?: UsageMetadata | undefined;
17
+ index: number;
18
+ }): ChatGenerationChunk | null;
19
+ export declare function convertToGenerativeAITools(tools: GoogleGenerativeAIToolType[]): GoogleGenerativeAIFunctionDeclarationsTool[];
@@ -0,0 +1,10 @@
1
+ import { Tool as GenerativeAITool, ToolConfig } from '@google/generative-ai';
2
+ import { ToolChoice } from '@langchain/core/language_models/chat_models';
3
+ import { GoogleGenerativeAIToolType } from '../types';
4
+ export declare function convertToolsToGenAI(tools: GoogleGenerativeAIToolType[], extra?: {
5
+ toolChoice?: ToolChoice;
6
+ allowedFunctionNames?: string[];
7
+ }): {
8
+ tools: GenerativeAITool[];
9
+ toolConfig?: ToolConfig;
10
+ };
@@ -0,0 +1,14 @@
1
+ import { type FunctionDeclarationSchema as GenerativeAIFunctionDeclarationSchema, type SchemaType as FunctionDeclarationSchemaType } from '@google/generative-ai';
2
+ import { InteropZodType } from '@langchain/core/utils/types';
3
+ import { type JsonSchema7Type } from '@langchain/core/utils/json_schema';
4
+ export interface GenerativeAIJsonSchema extends Record<string, unknown> {
5
+ properties?: Record<string, GenerativeAIJsonSchema>;
6
+ type: FunctionDeclarationSchemaType;
7
+ }
8
+ export interface GenerativeAIJsonSchemaDirty extends GenerativeAIJsonSchema {
9
+ properties?: Record<string, GenerativeAIJsonSchemaDirty>;
10
+ additionalProperties?: boolean;
11
+ }
12
+ export declare function removeAdditionalProperties(obj: Record<string, any>): GenerativeAIJsonSchema;
13
+ export declare function schemaToGenerativeAIParameters<RunOutput extends Record<string, any> = Record<string, any>>(schema: InteropZodType<RunOutput> | JsonSchema7Type): GenerativeAIFunctionDeclarationSchema;
14
+ export declare function jsonSchemaToGeminiParameters(schema: Record<string, any>): GenerativeAIFunctionDeclarationSchema;
@@ -0,0 +1,7 @@
1
+ import { ChatGenerationChunk } from '@langchain/core/outputs';
2
+ import { ChatOllama as BaseChatOllama } from '@langchain/ollama';
3
+ import { CallbackManagerForLLMRun } from '@langchain/core/callbacks/manager';
4
+ import type { BaseMessage } from '@langchain/core/messages';
5
+ export declare class ChatOllama extends BaseChatOllama {
6
+ _streamResponseChunks(messages: BaseMessage[], options: this['ParsedCallOptions'], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;
7
+ }
@@ -0,0 +1,7 @@
1
+ import { AIMessageChunk, BaseMessage, UsageMetadata } from '@langchain/core/messages';
2
+ import type { Message as OllamaMessage } from 'ollama';
3
+ export declare function convertOllamaMessagesToLangChain(messages: OllamaMessage, extra?: {
4
+ responseMetadata?: Record<string, any>;
5
+ usageMetadata?: UsageMetadata;
6
+ }): AIMessageChunk;
7
+ export declare function convertToOllamaMessages(messages: BaseMessage[]): OllamaMessage[];
@@ -1,9 +1,35 @@
1
1
  import { AzureOpenAI as AzureOpenAIClient } from 'openai';
2
2
  import { ChatXAI as OriginalChatXAI } from '@langchain/xai';
3
+ import { ChatGenerationChunk } from '@langchain/core/outputs';
3
4
  import { ChatDeepSeek as OriginalChatDeepSeek } from '@langchain/deepseek';
5
+ import { CallbackManagerForLLMRun } from '@langchain/core/callbacks/manager';
4
6
  import { OpenAIClient, ChatOpenAI as OriginalChatOpenAI, AzureChatOpenAI as OriginalAzureChatOpenAI } from '@langchain/openai';
5
- import type { OpenAICoreRequestOptions } from 'node_modules/@langchain/deepseek/node_modules/@langchain/openai';
7
+ import type { HeaderValue, HeadersLike } from './types';
8
+ import type { BindToolsInput } from '@langchain/core/language_models/chat_models';
9
+ import type { BaseMessage } from '@langchain/core/messages';
10
+ import type { ChatXAIInput } from '@langchain/xai';
6
11
  import type * as t from '@langchain/openai';
12
+ export declare function isHeaders(headers: unknown): headers is Headers;
13
+ export declare function normalizeHeaders(headers: HeadersLike): Record<string, HeaderValue | readonly HeaderValue[]>;
14
+ type OpenAICoreRequestOptions = OpenAIClient.RequestOptions;
15
+ /**
16
+ * Formats a tool in either OpenAI format, or LangChain structured tool format
17
+ * into an OpenAI tool format. If the tool is already in OpenAI format, return without
18
+ * any changes. If it is in LangChain structured tool format, convert it to OpenAI tool format
19
+ * using OpenAI's `zodFunction` util, falling back to `convertToOpenAIFunction` if the parameters
20
+ * returned from the `zodFunction` util are not defined.
21
+ *
22
+ * @param {BindToolsInput} tool The tool to convert to an OpenAI tool.
23
+ * @param {Object} [fields] Additional fields to add to the OpenAI tool.
24
+ * @returns {ToolDefinition} The inputted tool in OpenAI tool format.
25
+ */
26
+ export declare function _convertToOpenAITool(tool: BindToolsInput, fields?: {
27
+ /**
28
+ * If `true`, model output is guaranteed to exactly match the JSON Schema
29
+ * provided in the function definition.
30
+ */
31
+ strict?: boolean;
32
+ }): OpenAIClient.ChatCompletionTool;
7
33
  export declare class CustomOpenAIClient extends OpenAIClient {
8
34
  abortHandler?: () => void;
9
35
  fetchWithTimeout(url: RequestInfo, init: RequestInit | undefined, ms: number, controller: AbortController): Promise<Response>;
@@ -12,19 +38,62 @@ export declare class CustomAzureOpenAIClient extends AzureOpenAIClient {
12
38
  abortHandler?: () => void;
13
39
  fetchWithTimeout(url: RequestInfo, init: RequestInit | undefined, ms: number, controller: AbortController): Promise<Response>;
14
40
  }
41
+ /** @ts-expect-error We are intentionally overriding `getReasoningParams` */
15
42
  export declare class ChatOpenAI extends OriginalChatOpenAI<t.ChatOpenAICallOptions> {
16
43
  get exposedClient(): CustomOpenAIClient;
17
- protected _getClientOptions(options?: t.OpenAICoreRequestOptions): t.OpenAICoreRequestOptions;
44
+ protected _getClientOptions(options?: OpenAICoreRequestOptions): OpenAICoreRequestOptions;
45
+ /**
46
+ * Returns backwards compatible reasoning parameters from constructor params and call options
47
+ * @internal
48
+ */
49
+ getReasoningParams(options?: this['ParsedCallOptions']): OpenAIClient.Reasoning | undefined;
50
+ protected _getReasoningParams(options?: this['ParsedCallOptions']): OpenAIClient.Reasoning | undefined;
51
+ _streamResponseChunks(messages: BaseMessage[], options: this['ParsedCallOptions'], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;
52
+ _streamResponseChunks2(messages: BaseMessage[], options: this['ParsedCallOptions'], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;
18
53
  }
54
+ /** @ts-expect-error We are intentionally overriding `getReasoningParams` */
19
55
  export declare class AzureChatOpenAI extends OriginalAzureChatOpenAI {
20
56
  get exposedClient(): CustomOpenAIClient;
21
- protected _getClientOptions(options: t.OpenAICoreRequestOptions | undefined): t.OpenAICoreRequestOptions;
57
+ /**
58
+ * Returns backwards compatible reasoning parameters from constructor params and call options
59
+ * @internal
60
+ */
61
+ getReasoningParams(options?: this['ParsedCallOptions']): OpenAIClient.Reasoning | undefined;
62
+ protected _getReasoningParams(options?: this['ParsedCallOptions']): OpenAIClient.Reasoning | undefined;
63
+ protected _getClientOptions(options: OpenAICoreRequestOptions | undefined): OpenAICoreRequestOptions;
64
+ _streamResponseChunks(messages: BaseMessage[], options: this['ParsedCallOptions'], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;
22
65
  }
23
66
  export declare class ChatDeepSeek extends OriginalChatDeepSeek {
24
67
  get exposedClient(): CustomOpenAIClient;
25
68
  protected _getClientOptions(options?: OpenAICoreRequestOptions): OpenAICoreRequestOptions;
26
69
  }
70
+ /** xAI-specific usage metadata type */
71
+ export interface XAIUsageMetadata extends OpenAIClient.Completions.CompletionUsage {
72
+ prompt_tokens_details?: {
73
+ audio_tokens?: number;
74
+ cached_tokens?: number;
75
+ text_tokens?: number;
76
+ image_tokens?: number;
77
+ };
78
+ completion_tokens_details?: {
79
+ audio_tokens?: number;
80
+ reasoning_tokens?: number;
81
+ accepted_prediction_tokens?: number;
82
+ rejected_prediction_tokens?: number;
83
+ };
84
+ num_sources_used?: number;
85
+ }
27
86
  export declare class ChatXAI extends OriginalChatXAI {
87
+ constructor(fields?: Partial<ChatXAIInput> & {
88
+ configuration?: {
89
+ baseURL?: string;
90
+ };
91
+ clientConfig?: {
92
+ baseURL?: string;
93
+ };
94
+ });
28
95
  get exposedClient(): CustomOpenAIClient;
29
96
  protected _getClientOptions(options?: OpenAICoreRequestOptions): OpenAICoreRequestOptions;
97
+ _streamResponseChunks(messages: BaseMessage[], options: this['ParsedCallOptions'], runManager?: CallbackManagerForLLMRun): AsyncGenerator<ChatGenerationChunk>;
30
98
  }
99
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { OpenAICallOptions } from '@langchain/openai';
2
+ export interface OpenAIChatCallOptions extends OpenAICallOptions {
3
+ promptIndex?: number;
4
+ }
5
+ export type OpenAIRoleEnum = 'system' | 'developer' | 'assistant' | 'user' | 'function' | 'tool';
6
+ export type HeaderValue = string | undefined | null;
7
+ export type HeadersLike = Headers | readonly HeaderValue[][] | Record<string, HeaderValue | readonly HeaderValue[]> | undefined | null | {
8
+ values: Headers;
9
+ [key: string]: unknown;
10
+ };
@@ -0,0 +1,20 @@
1
+ import { type OpenAI as OpenAIClient } from 'openai';
2
+ import { type BaseMessage } from '@langchain/core/messages';
3
+ import { ChatGenerationChunk } from '@langchain/core/outputs';
4
+ import type { OpenAICallOptions, OpenAIChatInput } from '@langchain/openai';
5
+ export type { OpenAICallOptions, OpenAIChatInput };
6
+ type ExtractAsyncIterableType<T> = T extends AsyncIterable<infer U> ? U : never;
7
+ type ExcludeNonController<T> = T extends {
8
+ controller: unknown;
9
+ } ? T : never;
10
+ type ResponsesCreate = OpenAIClient.Responses['create'];
11
+ type ResponsesInputItem = OpenAIClient.Responses.ResponseInputItem;
12
+ type ResponsesCreateStream = ExcludeNonController<Awaited<ReturnType<ResponsesCreate>>>;
13
+ export type ResponseReturnStreamEvents = ExtractAsyncIterableType<ResponsesCreateStream>;
14
+ type OpenAIRoleEnum = 'system' | 'developer' | 'assistant' | 'user' | 'function' | 'tool';
15
+ type OpenAICompletionParam = OpenAIClient.Chat.Completions.ChatCompletionMessageParam;
16
+ export declare function messageToOpenAIRole(message: BaseMessage): OpenAIRoleEnum;
17
+ export declare function _convertMessagesToOpenAIParams(messages: BaseMessage[], model?: string): OpenAICompletionParam[];
18
+ export declare function _convertMessagesToOpenAIResponsesParams(messages: BaseMessage[], model?: string, zdrEnabled?: boolean): ResponsesInputItem[];
19
+ export declare function isReasoningModel(model?: string): boolean;
20
+ export declare function _convertOpenAIResponsesDeltaToBaseMessageChunk(chunk: ResponseReturnStreamEvents): ChatGenerationChunk | null;
@@ -17,5 +17,5 @@ export declare class TextStream {
17
17
  private randomInt;
18
18
  private static readonly BOUNDARIES;
19
19
  private findFirstWordBoundary;
20
- generateText(progressCallback?: ProgressCallback): AsyncGenerator<string, void, unknown>;
20
+ generateText(signal?: AbortSignal, progressCallback?: ProgressCallback): AsyncGenerator<string, void, unknown>;
21
21
  }
@@ -0,0 +1,293 @@
1
+ import { ChatGoogle } from '@langchain/google-gauth';
2
+ import type { GoogleAIModelRequestParams, GoogleAbstractedClient } from '@langchain/google-common';
3
+ import type { VertexAIClientOptions } from '@/types';
4
+ /**
5
+ * Integration with Google Vertex AI chat models.
6
+ *
7
+ * Setup:
8
+ * Install `@langchain/google-vertexai` and set your stringified
9
+ * Vertex AI credentials as an environment variable named `GOOGLE_APPLICATION_CREDENTIALS`.
10
+ *
11
+ * ```bash
12
+ * npm install @langchain/google-vertexai
13
+ * export GOOGLE_APPLICATION_CREDENTIALS="path/to/credentials"
14
+ * ```
15
+ *
16
+ * ## [Constructor args](https://api.js.langchain.com/classes/_langchain_google_vertexai.index.ChatVertexAI.html#constructor.new_ChatVertexAI)
17
+ *
18
+ * ## [Runtime args](https://api.js.langchain.com/interfaces/langchain_google_common_types.GoogleAIBaseLanguageModelCallOptions.html)
19
+ *
20
+ * Runtime args can be passed as the second argument to any of the base runnable methods `.invoke`. `.stream`, `.batch`, etc.
21
+ * They can also be passed via `.withConfig`, or the second arg in `.bindTools`, like shown in the examples below:
22
+ *
23
+ * ```typescript
24
+ * // When calling `.withConfig`, call options should be passed via the first argument
25
+ * const llmWithArgsBound = llm.withConfig({
26
+ * stop: ["\n"],
27
+ * tools: [...],
28
+ * });
29
+ *
30
+ * // When calling `.bindTools`, call options should be passed via the second argument
31
+ * const llmWithTools = llm.bindTools(
32
+ * [...],
33
+ * {
34
+ * tool_choice: "auto",
35
+ * }
36
+ * );
37
+ * ```
38
+ *
39
+ * ## Examples
40
+ *
41
+ * <details open>
42
+ * <summary><strong>Instantiate</strong></summary>
43
+ *
44
+ * ```typescript
45
+ * import { ChatVertexAI } from '@langchain/google-vertexai';
46
+ *
47
+ * const llm = new ChatVertexAI({
48
+ * model: "gemini-1.5-pro",
49
+ * temperature: 0,
50
+ * // other params...
51
+ * });
52
+ * ```
53
+ * </details>
54
+ *
55
+ * <br />
56
+ *
57
+ * <details>
58
+ * <summary><strong>Invoking</strong></summary>
59
+ *
60
+ * ```typescript
61
+ * const input = `Translate "I love programming" into French.`;
62
+ *
63
+ * // Models also accept a list of chat messages or a formatted prompt
64
+ * const result = await llm.invoke(input);
65
+ * console.log(result);
66
+ * ```
67
+ *
68
+ * ```txt
69
+ * AIMessageChunk {
70
+ * "content": "\"J'adore programmer\" \n\nHere's why this is the best translation:\n\n* **J'adore** means \"I love\" and conveys a strong passion.\n* **Programmer** is the French verb for \"to program.\"\n\nThis translation is natural and idiomatic in French. \n",
71
+ * "additional_kwargs": {},
72
+ * "response_metadata": {},
73
+ * "tool_calls": [],
74
+ * "tool_call_chunks": [],
75
+ * "invalid_tool_calls": [],
76
+ * "usage_metadata": {
77
+ * "input_tokens": 9,
78
+ * "output_tokens": 63,
79
+ * "total_tokens": 72
80
+ * }
81
+ * }
82
+ * ```
83
+ * </details>
84
+ *
85
+ * <br />
86
+ *
87
+ * <details>
88
+ * <summary><strong>Streaming Chunks</strong></summary>
89
+ *
90
+ * ```typescript
91
+ * for await (const chunk of await llm.stream(input)) {
92
+ * console.log(chunk);
93
+ * }
94
+ * ```
95
+ *
96
+ * ```txt
97
+ * AIMessageChunk {
98
+ * "content": "\"",
99
+ * "additional_kwargs": {},
100
+ * "response_metadata": {},
101
+ * "tool_calls": [],
102
+ * "tool_call_chunks": [],
103
+ * "invalid_tool_calls": []
104
+ * }
105
+ * AIMessageChunk {
106
+ * "content": "J'adore programmer\" \n",
107
+ * "additional_kwargs": {},
108
+ * "response_metadata": {},
109
+ * "tool_calls": [],
110
+ * "tool_call_chunks": [],
111
+ * "invalid_tool_calls": []
112
+ * }
113
+ * AIMessageChunk {
114
+ * "content": "",
115
+ * "additional_kwargs": {},
116
+ * "response_metadata": {},
117
+ * "tool_calls": [],
118
+ * "tool_call_chunks": [],
119
+ * "invalid_tool_calls": []
120
+ * }
121
+ * AIMessageChunk {
122
+ * "content": "",
123
+ * "additional_kwargs": {},
124
+ * "response_metadata": {
125
+ * "finishReason": "stop"
126
+ * },
127
+ * "tool_calls": [],
128
+ * "tool_call_chunks": [],
129
+ * "invalid_tool_calls": [],
130
+ * "usage_metadata": {
131
+ * "input_tokens": 9,
132
+ * "output_tokens": 8,
133
+ * "total_tokens": 17
134
+ * }
135
+ * }
136
+ * ```
137
+ * </details>
138
+ *
139
+ * <br />
140
+ *
141
+ * <details>
142
+ * <summary><strong>Aggregate Streamed Chunks</strong></summary>
143
+ *
144
+ * ```typescript
145
+ * import { AIMessageChunk } from '@langchain/core/messages';
146
+ * import { concat } from '@langchain/core/utils/stream';
147
+ *
148
+ * const stream = await llm.stream(input);
149
+ * let full: AIMessageChunk | undefined;
150
+ * for await (const chunk of stream) {
151
+ * full = !full ? chunk : concat(full, chunk);
152
+ * }
153
+ * console.log(full);
154
+ * ```
155
+ *
156
+ * ```txt
157
+ * AIMessageChunk {
158
+ * "content": "\"J'adore programmer\" \n",
159
+ * "additional_kwargs": {},
160
+ * "response_metadata": {
161
+ * "finishReason": "stop"
162
+ * },
163
+ * "tool_calls": [],
164
+ * "tool_call_chunks": [],
165
+ * "invalid_tool_calls": [],
166
+ * "usage_metadata": {
167
+ * "input_tokens": 9,
168
+ * "output_tokens": 8,
169
+ * "total_tokens": 17
170
+ * }
171
+ * }
172
+ * ```
173
+ * </details>
174
+ *
175
+ * <br />
176
+ *
177
+ * <details>
178
+ * <summary><strong>Bind tools</strong></summary>
179
+ *
180
+ * ```typescript
181
+ * import { z } from 'zod';
182
+ *
183
+ * const GetWeather = {
184
+ * name: "GetWeather",
185
+ * description: "Get the current weather in a given location",
186
+ * schema: z.object({
187
+ * location: z.string().describe("The city and state, e.g. San Francisco, CA")
188
+ * }),
189
+ * }
190
+ *
191
+ * const GetPopulation = {
192
+ * name: "GetPopulation",
193
+ * description: "Get the current population in a given location",
194
+ * schema: z.object({
195
+ * location: z.string().describe("The city and state, e.g. San Francisco, CA")
196
+ * }),
197
+ * }
198
+ *
199
+ * const llmWithTools = llm.bindTools([GetWeather, GetPopulation]);
200
+ * const aiMsg = await llmWithTools.invoke(
201
+ * "Which city is hotter today and which is bigger: LA or NY?"
202
+ * );
203
+ * console.log(aiMsg.tool_calls);
204
+ * ```
205
+ *
206
+ * ```txt
207
+ * [
208
+ * {
209
+ * name: 'GetPopulation',
210
+ * args: { location: 'New York City, NY' },
211
+ * id: '33c1c1f47e2f492799c77d2800a43912',
212
+ * type: 'tool_call'
213
+ * }
214
+ * ]
215
+ * ```
216
+ * </details>
217
+ *
218
+ * <br />
219
+ *
220
+ * <details>
221
+ * <summary><strong>Structured Output</strong></summary>
222
+ *
223
+ * ```typescript
224
+ * import { z } from 'zod';
225
+ *
226
+ * const Joke = z.object({
227
+ * setup: z.string().describe("The setup of the joke"),
228
+ * punchline: z.string().describe("The punchline to the joke"),
229
+ * rating: z.number().optional().describe("How funny the joke is, from 1 to 10")
230
+ * }).describe('Joke to tell user.');
231
+ *
232
+ * const structuredLlm = llm.withStructuredOutput(Joke, { name: "Joke" });
233
+ * const jokeResult = await structuredLlm.invoke("Tell me a joke about cats");
234
+ * console.log(jokeResult);
235
+ * ```
236
+ *
237
+ * ```txt
238
+ * {
239
+ * setup: 'What do you call a cat that loves to bowl?',
240
+ * punchline: 'An alley cat!'
241
+ * }
242
+ * ```
243
+ * </details>
244
+ *
245
+ * <br />
246
+ *
247
+ * <details>
248
+ * <summary><strong>Usage Metadata</strong></summary>
249
+ *
250
+ * ```typescript
251
+ * const aiMsgForMetadata = await llm.invoke(input);
252
+ * console.log(aiMsgForMetadata.usage_metadata);
253
+ * ```
254
+ *
255
+ * ```txt
256
+ * { input_tokens: 9, output_tokens: 8, total_tokens: 17 }
257
+ * ```
258
+ * </details>
259
+ *
260
+ * <br />
261
+ *
262
+ * <details>
263
+ * <summary><strong>Stream Usage Metadata</strong></summary>
264
+ *
265
+ * ```typescript
266
+ * const streamForMetadata = await llm.stream(
267
+ * input,
268
+ * {
269
+ * streamUsage: true
270
+ * }
271
+ * );
272
+ * let fullForMetadata: AIMessageChunk | undefined;
273
+ * for await (const chunk of streamForMetadata) {
274
+ * fullForMetadata = !fullForMetadata ? chunk : concat(fullForMetadata, chunk);
275
+ * }
276
+ * console.log(fullForMetadata?.usage_metadata);
277
+ * ```
278
+ *
279
+ * ```txt
280
+ * { input_tokens: 9, output_tokens: 8, total_tokens: 17 }
281
+ * ```
282
+ * </details>
283
+ *
284
+ * <br />
285
+ */
286
+ export declare class ChatVertexAI extends ChatGoogle {
287
+ lc_namespace: string[];
288
+ dynamicThinkingBudget: boolean;
289
+ static lc_name(): 'ChatVertexAI';
290
+ constructor(fields?: VertexAIClientOptions);
291
+ invocationParams(options?: this['ParsedCallOptions'] | undefined): GoogleAIModelRequestParams;
292
+ buildConnection(fields: VertexAIClientOptions, client: GoogleAbstractedClient): void;
293
+ }
@@ -0,0 +1,9 @@
1
+ import { BaseMessage, BaseMessageLike } from '@langchain/core/messages';
2
+ export declare const REMOVE_ALL_MESSAGES = "__remove_all__";
3
+ export type Messages = Array<BaseMessage | BaseMessageLike> | BaseMessage | BaseMessageLike;
4
+ /**
5
+ * Prebuilt reducer that combines returned messages.
6
+ * Can handle standard messages and special modifiers like {@link RemoveMessage}
7
+ * instances.
8
+ */
9
+ export declare function messagesStateReducer(left: Messages, right: Messages): BaseMessage[];
@@ -1,28 +1,35 @@
1
1
  import type { BaseMessage, MessageContentComplex } from '@langchain/core/messages';
2
- import type { ClientCallbacks, SystemCallbacks } from '@/graphs/Graph';
3
2
  import type { RunnableConfig } from '@langchain/core/runnables';
4
3
  import type * as t from '@/types';
5
- import { Providers } from '@/common';
4
+ import { MultiAgentGraph } from '@/graphs/MultiAgentGraph';
6
5
  import { StandardGraph } from '@/graphs/Graph';
7
- export declare class Run<T extends t.BaseGraphState> {
8
- graphRunnable?: t.CompiledWorkflow<T, Partial<T>, string>;
9
- private handlerRegistry;
6
+ export declare const defaultOmitOptions: Set<string>;
7
+ export declare class Run<_T extends t.BaseGraphState> {
10
8
  id: string;
11
- Graph: StandardGraph | undefined;
12
- provider: Providers | undefined;
9
+ private tokenCounter?;
10
+ private handlerRegistry;
11
+ private indexTokenCountMap?;
12
+ graphRunnable?: t.CompiledStateWorkflow;
13
+ Graph: StandardGraph | MultiAgentGraph | undefined;
13
14
  returnContent: boolean;
14
15
  private constructor();
15
- private createStandardGraph;
16
+ private createLegacyGraph;
17
+ private createMultiAgentGraph;
16
18
  static create<T extends t.BaseGraphState>(config: t.RunConfig): Promise<Run<T>>;
17
19
  getRunMessages(): BaseMessage[] | undefined;
20
+ /**
21
+ * Creates a custom event callback handler that intercepts custom events
22
+ * and processes them through our handler registry instead of EventStreamCallbackHandler
23
+ */
24
+ private createCustomEventCallback;
18
25
  processStream(inputs: t.IState, config: Partial<RunnableConfig> & {
19
26
  version: 'v1' | 'v2';
20
27
  run_id?: string;
21
28
  }, streamOptions?: t.EventStreamOptions): Promise<MessageContentComplex[] | undefined>;
22
29
  private createSystemCallback;
23
- getCallbacks(clientCallbacks: ClientCallbacks): SystemCallbacks;
24
- generateTitle({ inputText, contentParts, titlePrompt, clientOptions, chainOptions, skipLanguage, }: t.RunTitleOptions): Promise<{
25
- language: string;
26
- title: string;
30
+ getCallbacks(clientCallbacks: t.ClientCallbacks): t.SystemCallbacks;
31
+ generateTitle({ provider, inputText, contentParts, titlePrompt, clientOptions, chainOptions, skipLanguage, titleMethod, titlePromptTemplate, }: t.RunTitleOptions): Promise<{
32
+ language?: string;
33
+ title?: string;
27
34
  }>;
28
35
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,7 @@
1
+ import { Providers } from '@/common';
1
2
  export declare function getArgs(): Promise<{
2
3
  userName: string;
3
4
  location: string;
4
- provider: string;
5
+ provider: Providers;
5
6
  currentDate: string;
6
7
  }>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,8 +1,15 @@
1
1
  import type { AIMessageChunk } from '@langchain/core/messages';
2
- import type { Graph } from '@/graphs';
2
+ import type { AgentContext } from '@/agents/AgentContext';
3
+ import type { StandardGraph } from '@/graphs';
3
4
  import type * as t from '@/types';
5
+ import { Providers } from '@/common';
6
+ export declare function getChunkContent({ chunk, provider, reasoningKey, }: {
7
+ chunk?: Partial<AIMessageChunk>;
8
+ provider?: Providers;
9
+ reasoningKey: 'reasoning_content' | 'reasoning';
10
+ }): string | t.MessageContentComplex[] | undefined;
4
11
  export declare class ChatModelStreamHandler implements t.EventHandler {
5
- handle(event: string, data: t.StreamEventData, metadata?: Record<string, unknown>, graph?: Graph): void;
6
- handleReasoning(chunk: Partial<AIMessageChunk>, graph: Graph): void;
12
+ handle(event: string, data: t.StreamEventData, metadata?: Record<string, unknown>, graph?: StandardGraph): Promise<void>;
13
+ handleReasoning(chunk: Partial<AIMessageChunk>, agentContext: AgentContext): void;
7
14
  }
8
15
  export declare function createContentAggregator(): t.ContentAggregatorResult;
@@ -10,12 +10,12 @@ declare const CodeExecutionToolSchema: z.ZodObject<{
10
10
  args: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
11
11
  }, "strip", z.ZodTypeAny, {
12
12
  code: string;
13
- lang: "r" | "py" | "js" | "ts" | "c" | "cpp" | "java" | "php" | "rs" | "go" | "d" | "f90";
13
+ lang: "r" | "d" | "py" | "js" | "ts" | "c" | "cpp" | "java" | "php" | "rs" | "go" | "f90";
14
14
  args?: string[] | undefined;
15
15
  session_id?: string | undefined;
16
16
  }, {
17
17
  code: string;
18
- lang: "r" | "py" | "js" | "ts" | "c" | "cpp" | "java" | "php" | "rs" | "go" | "d" | "f90";
18
+ lang: "r" | "d" | "py" | "js" | "ts" | "c" | "cpp" | "java" | "php" | "rs" | "go" | "f90";
19
19
  args?: string[] | undefined;
20
20
  session_id?: string | undefined;
21
21
  }>;
@@ -19,4 +19,4 @@ export declare class ToolNode<T = any> extends RunnableCallable<T, T> {
19
19
  getToolUsageCounts(): ReadonlyMap<string, number>;
20
20
  protected run(input: any, config: RunnableConfig): Promise<T>;
21
21
  }
22
- export declare function toolsCondition(state: BaseMessage[] | typeof MessagesAnnotation.State): 'tools' | typeof END;
22
+ export declare function toolsCondition<T extends string>(state: BaseMessage[] | typeof MessagesAnnotation.State, toolNode: T, invokedToolIds?: Set<string>): T | typeof END;
@@ -1,8 +1,21 @@
1
1
  import type { ToolCall, ToolCallChunk } from '@langchain/core/messages/tool';
2
- import type { Graph } from '@/graphs';
2
+ import type { MultiAgentGraph, StandardGraph } from '@/graphs';
3
+ import type { AgentContext } from '@/agents/AgentContext';
4
+ import type * as t from '@/types';
3
5
  export declare function handleToolCallChunks({ graph, stepKey, toolCallChunks, }: {
4
- graph: Graph;
6
+ graph: StandardGraph | MultiAgentGraph;
5
7
  stepKey: string;
6
8
  toolCallChunks: ToolCallChunk[];
7
- }): void;
8
- export declare const handleToolCalls: (toolCalls?: ToolCall[], metadata?: Record<string, unknown>, graph?: Graph) => void;
9
+ }): Promise<void>;
10
+ export declare const handleToolCalls: (toolCalls?: ToolCall[], metadata?: Record<string, unknown>, graph?: StandardGraph | MultiAgentGraph) => Promise<void>;
11
+ export declare const toolResultTypes: Set<string>;
12
+ /**
13
+ * Handles the result of a server tool call; in other words, a provider's built-in tool.
14
+ * As of 2025-07-06, only Anthropic handles server tool calls with this pattern.
15
+ */
16
+ export declare function handleServerToolResult({ graph, content, metadata, agentContext, }: {
17
+ graph: StandardGraph | MultiAgentGraph;
18
+ content?: string | t.MessageContentComplex[];
19
+ metadata?: Record<string, unknown>;
20
+ agentContext?: AgentContext;
21
+ }): Promise<boolean>;