@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,16 @@
1
+ import type { AnthropicTextBlockParam, AnthropicWebSearchResultBlockParam } from '@/llm/anthropic/types';
2
+ import type { SearchResultData } from './types';
3
+ /**
4
+ * Coerces Anthropic web search results to the SearchResultData format
5
+ * @param results - Array of Anthropic web search results
6
+ * @param turn - The turn number to associate with these results
7
+ * @returns SearchResultData with minimal ProcessedOrganic items
8
+ */
9
+ export declare function coerceAnthropicSearchResults({ results, turn, }: {
10
+ results: (AnthropicTextBlockParam | AnthropicWebSearchResultBlockParam)[];
11
+ turn?: number;
12
+ }): SearchResultData;
13
+ /**
14
+ * Helper function to check if an object is an Anthropic web search result
15
+ */
16
+ export declare function isAnthropicWebSearchResult(obj: unknown): obj is AnthropicWebSearchResultBlockParam;
@@ -8,6 +8,22 @@ export declare class FirecrawlScraper {
8
8
  private apiUrl;
9
9
  private defaultFormats;
10
10
  private timeout;
11
+ private logger;
12
+ private includeTags?;
13
+ private excludeTags?;
14
+ private waitFor?;
15
+ private maxAge?;
16
+ private mobile?;
17
+ private skipTlsVerification?;
18
+ private blockAds?;
19
+ private removeBase64Images?;
20
+ private parsePDF?;
21
+ private storeInCache?;
22
+ private zeroDataRetention?;
23
+ private headers?;
24
+ private location?;
25
+ private onlyMainContent?;
26
+ private changeTrackingOptions?;
11
27
  constructor(config?: t.FirecrawlScraperConfig);
12
28
  /**
13
29
  * Scrape a single URL
@@ -1,25 +1,27 @@
1
1
  import type * as t from './types';
2
2
  export declare abstract class BaseReranker {
3
3
  protected apiKey: string | undefined;
4
- constructor();
4
+ protected logger: t.Logger;
5
+ constructor(logger?: t.Logger);
5
6
  abstract rerank(query: string, documents: string[], topK?: number): Promise<t.Highlight[]>;
6
7
  protected getDefaultRanking(documents: string[], topK: number): t.Highlight[];
7
- protected logDocumentSamples(documents: string[]): void;
8
8
  }
9
9
  export declare class JinaReranker extends BaseReranker {
10
- constructor({ apiKey }: {
10
+ constructor({ apiKey, logger, }: {
11
11
  apiKey?: string;
12
+ logger?: t.Logger;
12
13
  });
13
14
  rerank(query: string, documents: string[], topK?: number): Promise<t.Highlight[]>;
14
15
  }
15
16
  export declare class CohereReranker extends BaseReranker {
16
- constructor({ apiKey }: {
17
+ constructor({ apiKey, logger, }: {
17
18
  apiKey?: string;
19
+ logger?: t.Logger;
18
20
  });
19
21
  rerank(query: string, documents: string[], topK?: number): Promise<t.Highlight[]>;
20
22
  }
21
23
  export declare class InfinityReranker extends BaseReranker {
22
- constructor();
24
+ constructor(logger?: t.Logger);
23
25
  rerank(query: string, documents: string[], topK?: number): Promise<t.Highlight[]>;
24
26
  }
25
27
  /**
@@ -29,4 +31,5 @@ export declare const createReranker: (config: {
29
31
  rerankerType: t.RerankerType;
30
32
  jinaApiKey?: string;
31
33
  cohereApiKey?: string;
34
+ logger?: t.Logger;
32
35
  }) => BaseReranker | undefined;
@@ -0,0 +1,16 @@
1
+ import { z } from 'zod';
2
+ export declare enum DATE_RANGE {
3
+ PAST_HOUR = "h",
4
+ PAST_24_HOURS = "d",
5
+ PAST_WEEK = "w",
6
+ PAST_MONTH = "m",
7
+ PAST_YEAR = "y"
8
+ }
9
+ export declare const DEFAULT_QUERY_DESCRIPTION: string;
10
+ export declare const DEFAULT_COUNTRY_DESCRIPTION: string;
11
+ export declare const querySchema: z.ZodString;
12
+ export declare const dateSchema: z.ZodOptional<z.ZodNativeEnum<typeof DATE_RANGE>>;
13
+ export declare const countrySchema: z.ZodOptional<z.ZodString>;
14
+ export declare const imagesSchema: z.ZodOptional<z.ZodBoolean>;
15
+ export declare const videosSchema: z.ZodOptional<z.ZodBoolean>;
16
+ export declare const newsSchema: z.ZodOptional<z.ZodBoolean>;
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { DynamicStructuredTool } from '@langchain/core/tools';
3
3
  import type * as t from './types';
4
+ import { DATE_RANGE } from './schema';
4
5
  /**
5
6
  * Creates a search tool with a schema that dynamically includes the country field
6
7
  * only when the searchProvider is 'serper'.
@@ -10,11 +11,23 @@ import type * as t from './types';
10
11
  */
11
12
  export declare const createSearchTool: (config?: t.SearchToolConfig) => DynamicStructuredTool<z.ZodObject<{
12
13
  query: z.ZodString;
14
+ date: z.ZodOptional<z.ZodNativeEnum<typeof DATE_RANGE>>;
13
15
  country?: z.ZodOptional<z.ZodString>;
16
+ images: z.ZodOptional<z.ZodBoolean>;
17
+ videos: z.ZodOptional<z.ZodBoolean>;
18
+ news: z.ZodOptional<z.ZodBoolean>;
14
19
  }, "strip", z.ZodTypeAny, {
15
20
  query: string;
21
+ date?: DATE_RANGE | undefined;
22
+ images?: boolean | undefined;
23
+ videos?: boolean | undefined;
24
+ news?: boolean | undefined;
16
25
  country?: unknown;
17
26
  }, {
18
27
  query: string;
28
+ date?: DATE_RANGE | undefined;
29
+ images?: boolean | undefined;
30
+ videos?: boolean | undefined;
31
+ news?: boolean | undefined;
19
32
  country?: unknown;
20
33
  }>>;
@@ -1,6 +1,8 @@
1
1
  import { z } from 'zod';
2
+ import type { Logger as WinstonLogger } from 'winston';
2
3
  import type { RunnableConfig } from '@langchain/core/runnables';
3
4
  import type { BaseReranker } from './rerankers';
5
+ import { DATE_RANGE } from './schema';
4
6
  export type SearchProvider = 'serper' | 'searxng';
5
7
  export type RerankerType = 'infinity' | 'jina' | 'cohere' | 'none';
6
8
  export interface Highlight {
@@ -78,11 +80,12 @@ export interface ProcessSourcesConfig {
78
80
  strategies?: string[];
79
81
  filterContent?: boolean;
80
82
  reranker?: BaseReranker;
83
+ logger?: Logger;
81
84
  }
82
85
  export interface FirecrawlConfig {
83
86
  firecrawlApiKey?: string;
84
87
  firecrawlApiUrl?: string;
85
- firecrawlFormats?: string[];
88
+ firecrawlOptions?: FirecrawlScraperConfig;
86
89
  }
87
90
  export interface ScraperContentResult {
88
91
  content: string;
@@ -121,10 +124,15 @@ export interface CohereRerankerResponse {
121
124
  };
122
125
  };
123
126
  }
127
+ export type SafeSearchLevel = 0 | 1 | 2;
128
+ export type Logger = WinstonLogger;
124
129
  export interface SearchToolConfig extends SearchConfig, ProcessSourcesConfig, FirecrawlConfig {
130
+ logger?: Logger;
131
+ safeSearch?: SafeSearchLevel;
125
132
  jinaApiKey?: string;
126
133
  cohereApiKey?: string;
127
134
  rerankerType?: RerankerType;
135
+ scraperTimeout?: number;
128
136
  onSearchResults?: (results: SearchResult, runnableConfig?: RunnableConfig) => void;
129
137
  onGetHighlights?: (link: string) => void;
130
138
  }
@@ -139,14 +147,7 @@ export type UsedReferences = {
139
147
  reference: MediaReference;
140
148
  }[];
141
149
  /** Firecrawl */
142
- export interface FirecrawlScrapeOptions {
143
- formats?: string[];
144
- includeTags?: string[];
145
- excludeTags?: string[];
146
- headers?: Record<string, string>;
147
- waitFor?: number;
148
- timeout?: number;
149
- }
150
+ export type FirecrawlScrapeOptions = Omit<FirecrawlScraperConfig, 'apiKey' | 'apiUrl' | 'logger'>;
150
151
  export interface ScrapeMetadata {
151
152
  sourceURL?: string;
152
153
  url?: string;
@@ -217,11 +218,36 @@ export interface FirecrawlScraperConfig {
217
218
  apiUrl?: string;
218
219
  formats?: string[];
219
220
  timeout?: number;
221
+ logger?: Logger;
222
+ includeTags?: string[];
223
+ excludeTags?: string[];
224
+ waitFor?: number;
225
+ maxAge?: number;
226
+ mobile?: boolean;
227
+ skipTlsVerification?: boolean;
228
+ blockAds?: boolean;
229
+ removeBase64Images?: boolean;
230
+ parsePDF?: boolean;
231
+ storeInCache?: boolean;
232
+ zeroDataRetention?: boolean;
233
+ headers?: Record<string, string>;
234
+ location?: {
235
+ country?: string;
236
+ languages?: string[];
237
+ };
238
+ onlyMainContent?: boolean;
239
+ changeTrackingOptions?: object;
220
240
  }
221
241
  export type GetSourcesParams = {
222
242
  query: string;
243
+ date?: DATE_RANGE;
223
244
  country?: string;
224
245
  numResults?: number;
246
+ safeSearch?: SearchToolConfig['safeSearch'];
247
+ images?: boolean;
248
+ videos?: boolean;
249
+ news?: boolean;
250
+ type?: 'search' | 'images' | 'videos' | 'news';
225
251
  };
226
252
  /** Serper API */
227
253
  export interface VideoResult {
@@ -382,6 +408,13 @@ export interface SerperSearchInput {
382
408
  */
383
409
  autocorrect?: boolean;
384
410
  page?: number;
411
+ /**
412
+ * Date range for search results
413
+ * Options: "h" (past hour), "d" (past 24 hours), "w" (past week),
414
+ * "m" (past month), "y" (past year)
415
+ * `qdr:${DATE_RANGE}`
416
+ */
417
+ tbs?: string;
385
418
  }
386
419
  export type SerperResultData = {
387
420
  searchParameters: SerperSearchPayload;
@@ -486,21 +519,43 @@ export interface SearXNGResult {
486
519
  content?: string;
487
520
  publishedDate?: string;
488
521
  img_src?: string;
522
+ score?: number;
523
+ engine?: string;
524
+ category?: string;
525
+ thumbnail?: string;
526
+ priority?: string;
527
+ engines?: string[];
528
+ positions?: number[];
529
+ template?: string;
530
+ parsed_url?: string[];
489
531
  }
490
532
  export type ProcessSourcesFields = {
491
533
  result: SearchResult;
492
534
  numElements: number;
493
535
  query: string;
536
+ news: boolean;
494
537
  proMode: boolean;
495
538
  onGetHighlights: SearchToolConfig['onGetHighlights'];
496
539
  };
497
540
  export type SearchToolSchema = z.ZodObject<{
498
541
  query: z.ZodString;
542
+ date: z.ZodOptional<z.ZodNativeEnum<typeof DATE_RANGE>>;
499
543
  country?: z.ZodOptional<z.ZodString>;
544
+ images: z.ZodOptional<z.ZodBoolean>;
545
+ videos: z.ZodOptional<z.ZodBoolean>;
546
+ news: z.ZodOptional<z.ZodBoolean>;
500
547
  }, 'strip', z.ZodTypeAny, {
501
548
  query: string;
549
+ date?: DATE_RANGE;
502
550
  country?: unknown;
551
+ images?: boolean;
552
+ videos?: boolean;
553
+ news?: boolean;
503
554
  }, {
504
555
  query: string;
556
+ date?: DATE_RANGE;
505
557
  country?: unknown;
558
+ images?: boolean;
559
+ videos?: boolean;
560
+ news?: boolean;
506
561
  }>;
@@ -1,3 +1,10 @@
1
1
  import type * as t from './types';
2
- export declare const getDomainName: (link: string, metadata?: t.ScrapeMetadata) => string | undefined;
3
- export declare function getAttribution(link: string, metadata?: t.ScrapeMetadata): string | undefined;
2
+ /**
3
+ * Creates a default logger that maps to console methods
4
+ * Uses a singleton pattern to avoid creating multiple instances
5
+ * @returns A default logger that implements the Logger interface
6
+ */
7
+ export declare const createDefaultLogger: () => t.Logger;
8
+ export declare const fileExtRegex: RegExp;
9
+ export declare const getDomainName: (link: string, metadata?: t.ScrapeMetadata, logger?: t.Logger) => string | undefined;
10
+ export declare function getAttribution(link: string, metadata?: t.ScrapeMetadata, logger?: t.Logger): string | undefined;
@@ -1,25 +1,77 @@
1
- import type { StateGraphArgs, StateGraph, CompiledStateGraph } from '@langchain/langgraph';
2
- import type { BaseMessage, AIMessageChunk } from '@langchain/core/messages';
1
+ import type { START, StateType, UpdateType, StateGraph, StateGraphArgs, StateDefinition, CompiledStateGraph, BinaryOperatorAggregate } from '@langchain/langgraph';
2
+ import type { BindToolsInput } from '@langchain/core/language_models/chat_models';
3
+ import type { BaseMessage, AIMessageChunk, SystemMessage } from '@langchain/core/messages';
4
+ import type { RunnableConfig, Runnable } from '@langchain/core/runnables';
3
5
  import type { ChatGenerationChunk } from '@langchain/core/outputs';
4
- import type { RunnableConfig } from '@langchain/core/runnables';
5
- import type { ToolMap, GenericTool } from '@/types/tools';
6
+ import type { GoogleAIToolType } from '@langchain/google-common';
7
+ import type { ToolMap, ToolEndEvent, GenericTool } from '@/types/tools';
8
+ import type { Providers, Callback, GraphNodeKeys } from '@/common';
9
+ import type { StandardGraph, MultiAgentGraph } from '@/graphs';
6
10
  import type { ClientOptions } from '@/types/llm';
7
- import type { Providers } from '@/common';
8
- import type { Graph } from '@/graphs';
11
+ import type { RunStep, RunStepDeltaEvent, MessageDeltaEvent, ReasoningDeltaEvent } from '@/types/stream';
12
+ import type { TokenCounter } from '@/types/run';
13
+ /** Interface for bound model with stream and invoke methods */
14
+ export interface ChatModel {
15
+ stream?: (messages: BaseMessage[], config?: RunnableConfig) => Promise<AsyncIterable<AIMessageChunk>>;
16
+ invoke: (messages: BaseMessage[], config?: RunnableConfig) => Promise<AIMessageChunk>;
17
+ }
18
+ export type GraphNode = GraphNodeKeys | typeof START;
19
+ export type ClientCallback<T extends unknown[]> = (graph: StandardGraph, ...args: T) => void;
20
+ export type ClientCallbacks = {
21
+ [Callback.TOOL_ERROR]?: ClientCallback<[Error, string]>;
22
+ [Callback.TOOL_START]?: ClientCallback<unknown[]>;
23
+ [Callback.TOOL_END]?: ClientCallback<unknown[]>;
24
+ };
25
+ export type SystemCallbacks = {
26
+ [K in keyof ClientCallbacks]: ClientCallbacks[K] extends ClientCallback<infer Args> ? (...args: Args) => void : never;
27
+ };
9
28
  export type BaseGraphState = {
10
29
  messages: BaseMessage[];
11
30
  };
12
31
  export type IState = BaseGraphState;
13
32
  export interface EventHandler {
14
- handle(event: string, data: StreamEventData | ModelEndData, metadata?: Record<string, unknown>, graph?: Graph): void;
33
+ handle(event: string, data: StreamEventData | ModelEndData | RunStep | RunStepDeltaEvent | MessageDeltaEvent | ReasoningDeltaEvent | {
34
+ result: ToolEndEvent;
35
+ }, metadata?: Record<string, unknown>, graph?: StandardGraph | MultiAgentGraph): void | Promise<void>;
15
36
  }
16
37
  export type GraphStateChannels<T extends BaseGraphState> = StateGraphArgs<T>['channels'];
17
38
  export type Workflow<T extends BaseGraphState = BaseGraphState, U extends Partial<T> = Partial<T>, N extends string = string> = StateGraph<T, U, N>;
18
39
  export type CompiledWorkflow<T extends BaseGraphState = BaseGraphState, U extends Partial<T> = Partial<T>, N extends string = string> = CompiledStateGraph<T, U, N>;
40
+ export type CompiledStateWorkflow = CompiledStateGraph<StateType<{
41
+ messages: BinaryOperatorAggregate<BaseMessage[], BaseMessage[]>;
42
+ }>, UpdateType<{
43
+ messages: BinaryOperatorAggregate<BaseMessage[], BaseMessage[]>;
44
+ }>, string, {
45
+ messages: BinaryOperatorAggregate<BaseMessage[], BaseMessage[]>;
46
+ }, {
47
+ messages: BinaryOperatorAggregate<BaseMessage[], BaseMessage[]>;
48
+ }, StateDefinition>;
49
+ export type CompiledAgentWorfklow = CompiledStateGraph<{
50
+ messages: BaseMessage[];
51
+ }, {
52
+ messages?: BaseMessage[] | undefined;
53
+ }, '__start__' | `agent=${string}` | `tools=${string}`, {
54
+ messages: BinaryOperatorAggregate<BaseMessage[], BaseMessage[]>;
55
+ }, {
56
+ messages: BinaryOperatorAggregate<BaseMessage[], BaseMessage[]>;
57
+ }, StateDefinition, {
58
+ [x: `agent=${string}`]: Partial<BaseGraphState>;
59
+ [x: `tools=${string}`]: any;
60
+ }>;
61
+ export type SystemRunnable = Runnable<BaseMessage[], (BaseMessage | SystemMessage)[], RunnableConfig<Record<string, unknown>>> | undefined;
62
+ /**
63
+ * Optional compile options passed to workflow.compile().
64
+ * These are intentionally untyped to avoid coupling to library internals.
65
+ */
66
+ export type CompileOptions = {
67
+ checkpointer?: any;
68
+ interruptBefore?: string[];
69
+ interruptAfter?: string[];
70
+ };
19
71
  export type EventStreamCallbackHandlerInput = Parameters<CompiledWorkflow['streamEvents']>[2] extends Omit<infer T, 'autoClose'> ? T : never;
20
- export type StreamChunk = ChatGenerationChunk & {
72
+ export type StreamChunk = (ChatGenerationChunk & {
21
73
  message: AIMessageChunk;
22
- } | AIMessageChunk;
74
+ }) | AIMessageChunk;
23
75
  /**
24
76
  * Data associated with a StreamEvent.
25
77
  */
@@ -55,6 +107,10 @@ export type StreamEventData = {
55
107
  * Custom result from the runnable that generated the event.
56
108
  */
57
109
  result?: unknown;
110
+ /**
111
+ * Custom field to indicate the event was manually emitted, and may have been handled already
112
+ */
113
+ emitted?: boolean;
58
114
  };
59
115
  /**
60
116
  * A streaming event.
@@ -117,19 +173,43 @@ export type PartMetadata = {
117
173
  action?: boolean;
118
174
  output?: string;
119
175
  };
120
- export type ModelEndData = StreamEventData & {
176
+ export type ModelEndData = (StreamEventData & {
121
177
  output: AIMessageChunk | undefined;
122
- } | undefined;
178
+ }) | undefined;
179
+ export type GraphTools = GenericTool[] | BindToolsInput[] | GoogleAIToolType[];
123
180
  export type StandardGraphInput = {
124
181
  runId?: string;
182
+ signal?: AbortSignal;
183
+ agents: AgentInputs[];
184
+ tokenCounter?: TokenCounter;
185
+ indexTokenCountMap?: Record<string, number>;
186
+ };
187
+ export type GraphEdge = {
188
+ /** Use a list for multiple sources */
189
+ from: string | string[];
190
+ /** Use a list for multiple destinations */
191
+ to: string | string[];
192
+ description?: string;
193
+ /** Can return boolean or specific destination(s) */
194
+ condition?: (state: BaseGraphState) => boolean | string | string[];
195
+ /** 'handoff' creates tools for dynamic routing, 'direct' creates direct edges, which also allow parallel execution */
196
+ edgeType?: 'handoff' | 'direct';
197
+ /** Optional prompt to add when transitioning through this edge */
198
+ promptInstructions?: string | ((messages: BaseMessage[]) => string | undefined);
199
+ };
200
+ export type MultiAgentGraphInput = StandardGraphInput & {
201
+ edges: GraphEdge[];
202
+ };
203
+ export interface AgentInputs {
204
+ agentId: string;
125
205
  toolEnd?: boolean;
126
206
  toolMap?: ToolMap;
207
+ tools?: GraphTools;
127
208
  provider: Providers;
128
- signal?: AbortSignal;
129
209
  instructions?: string;
130
210
  streamBuffer?: number;
131
- tools?: GenericTool[];
132
- clientOptions: ClientOptions;
211
+ maxContextTokens?: number;
212
+ clientOptions?: ClientOptions;
133
213
  additional_instructions?: string;
134
214
  reasoningKey?: 'reasoning_content' | 'reasoning';
135
- };
215
+ }
@@ -1,27 +1,29 @@
1
1
  import { ChatOllama } from '@langchain/ollama';
2
- import { ChatAnthropic } from '@langchain/anthropic';
3
2
  import { ChatMistralAI } from '@langchain/mistralai';
4
3
  import { ChatBedrockConverse } from '@langchain/aws';
5
- import { ChatVertexAI } from '@langchain/google-vertexai';
6
- import { ChatGoogleGenerativeAI } from '@langchain/google-genai';
7
4
  import { BedrockChat } from '@langchain/community/chat_models/bedrock/web';
8
5
  import type { BindToolsInput, BaseChatModelParams } from '@langchain/core/language_models/chat_models';
9
6
  import type { OpenAIChatInput, ChatOpenAIFields, AzureOpenAIInput, ClientOptions as OAIClientOptions } from '@langchain/openai';
10
7
  import type { BedrockChatFields } from '@langchain/community/chat_models/bedrock/web';
11
8
  import type { GoogleGenerativeAIChatInput } from '@langchain/google-genai';
9
+ import type { GeminiGenerationConfig } from '@langchain/google-common';
12
10
  import type { ChatVertexAIInput } from '@langchain/google-vertexai';
13
11
  import type { ChatDeepSeekCallOptions } from '@langchain/deepseek';
14
12
  import type { ChatOpenRouterCallOptions } from '@/llm/openrouter';
15
13
  import type { ChatBedrockConverseInput } from '@langchain/aws';
16
14
  import type { ChatMistralAIInput } from '@langchain/mistralai';
15
+ import type { RequestOptions } from '@google/generative-ai';
17
16
  import type { StructuredTool } from '@langchain/core/tools';
18
17
  import type { AnthropicInput } from '@langchain/anthropic';
19
18
  import type { Runnable } from '@langchain/core/runnables';
20
19
  import type { ChatOllamaInput } from '@langchain/ollama';
21
20
  import type { OpenAI as OpenAIClient } from 'openai';
22
21
  import type { ChatXAIInput } from '@langchain/xai';
23
- import { ChatXAI, ChatOpenAI, ChatDeepSeek, AzureChatOpenAI } from '@/llm/openai';
22
+ import { AzureChatOpenAI, ChatDeepSeek, ChatOpenAI, ChatXAI } from '@/llm/openai';
23
+ import { CustomChatGoogleGenerativeAI } from '@/llm/google';
24
+ import { CustomAnthropic } from '@/llm/anthropic';
24
25
  import { ChatOpenRouter } from '@/llm/openrouter';
26
+ import { ChatVertexAI } from '@/llm/vertexai';
25
27
  import { Providers } from '@/common';
26
28
  export type AzureClientOptions = Partial<OpenAIChatInput> & Partial<AzureOpenAIInput> & {
27
29
  openAIApiKey?: string;
@@ -42,19 +44,31 @@ export type OpenAIClientOptions = ChatOpenAIFields;
42
44
  export type OllamaClientOptions = ChatOllamaInput;
43
45
  export type AnthropicClientOptions = AnthropicInput;
44
46
  export type MistralAIClientOptions = ChatMistralAIInput;
45
- export type VertexAIClientOptions = ChatVertexAIInput;
47
+ export type VertexAIClientOptions = ChatVertexAIInput & {
48
+ includeThoughts?: boolean;
49
+ };
46
50
  export type BedrockClientOptions = BedrockChatFields;
47
51
  export type BedrockAnthropicInput = ChatBedrockConverseInput & {
48
52
  additionalModelRequestFields?: ChatBedrockConverseInput['additionalModelRequestFields'] & AnthropicReasoning;
49
53
  };
50
54
  export type BedrockConverseClientOptions = ChatBedrockConverseInput;
51
- export type GoogleClientOptions = GoogleGenerativeAIChatInput;
55
+ export type GoogleClientOptions = GoogleGenerativeAIChatInput & {
56
+ customHeaders?: RequestOptions['customHeaders'];
57
+ thinkingConfig?: GeminiGenerationConfig['thinkingConfig'];
58
+ };
52
59
  export type DeepSeekClientOptions = ChatDeepSeekCallOptions;
53
60
  export type XAIClientOptions = ChatXAIInput;
54
61
  export type ClientOptions = OpenAIClientOptions | AzureClientOptions | OllamaClientOptions | AnthropicClientOptions | MistralAIClientOptions | VertexAIClientOptions | BedrockClientOptions | BedrockConverseClientOptions | GoogleClientOptions | DeepSeekClientOptions | XAIClientOptions;
55
- export type LLMConfig = {
62
+ export type SharedLLMConfig = {
56
63
  provider: Providers;
57
- } & ClientOptions;
64
+ };
65
+ export type LLMConfig = SharedLLMConfig & ClientOptions & {
66
+ /** Optional provider fallbacks in order of attempt */
67
+ fallbacks?: Array<{
68
+ provider: Providers;
69
+ clientOptions?: ClientOptions;
70
+ }>;
71
+ };
58
72
  export type ProviderOptionsMap = {
59
73
  [Providers.AZURE]: AzureClientOptions;
60
74
  [Providers.OPENAI]: OpenAIClientOptions;
@@ -77,13 +91,13 @@ export type ChatModelMap = {
77
91
  [Providers.AZURE]: AzureChatOpenAI;
78
92
  [Providers.DEEPSEEK]: ChatDeepSeek;
79
93
  [Providers.VERTEXAI]: ChatVertexAI;
80
- [Providers.ANTHROPIC]: ChatAnthropic;
94
+ [Providers.ANTHROPIC]: CustomAnthropic;
81
95
  [Providers.MISTRALAI]: ChatMistralAI;
82
96
  [Providers.MISTRAL]: ChatMistralAI;
83
97
  [Providers.OPENROUTER]: ChatOpenRouter;
84
98
  [Providers.BEDROCK_LEGACY]: BedrockChat;
85
99
  [Providers.BEDROCK]: ChatBedrockConverse;
86
- [Providers.GOOGLE]: ChatGoogleGenerativeAI;
100
+ [Providers.GOOGLE]: CustomChatGoogleGenerativeAI;
87
101
  };
88
102
  export type ChatModelConstructorMap = {
89
103
  [P in Providers]: new (config: ProviderOptionsMap[P]) => ChatModelMap[P];
@@ -3,26 +3,59 @@ import type { BaseMessage } from '@langchain/core/messages';
3
3
  import type { StructuredTool } from '@langchain/core/tools';
4
4
  import type { RunnableConfig } from '@langchain/core/runnables';
5
5
  import type { BaseCallbackHandler, CallbackHandlerMethods } from '@langchain/core/callbacks/base';
6
- import type * as graph from '@/graphs/Graph';
7
6
  import type * as s from '@/types/stream';
8
7
  import type * as e from '@/common/enum';
9
8
  import type * as g from '@/types/graph';
10
9
  import type * as l from '@/types/llm';
11
10
  export type ZodObjectAny = z.ZodObject<any, any, any, any>;
12
11
  export type BaseGraphConfig = {
13
- type?: 'standard';
14
12
  llmConfig: l.LLMConfig;
15
13
  provider?: e.Providers;
16
14
  clientOptions?: l.ClientOptions;
15
+ /** Optional compile options for workflow.compile() */
16
+ compileOptions?: g.CompileOptions;
17
17
  };
18
- export type StandardGraphConfig = BaseGraphConfig & Omit<g.StandardGraphInput, 'provider' | 'clientOptions'>;
18
+ export type LegacyGraphConfig = BaseGraphConfig & {
19
+ type?: 'standard';
20
+ } & Omit<g.StandardGraphInput, 'provider' | 'clientOptions' | 'agents'> & Omit<g.AgentInputs, 'provider' | 'clientOptions' | 'agentId'>;
21
+ export type SupervisedGraphConfig = BaseGraphConfig & {
22
+ type: 'supervised';
23
+ /** Enable supervised router; when false, fall back to standard loop */
24
+ routerEnabled?: boolean;
25
+ /** Table-driven routing policy per stage */
26
+ routingPolicies?: Array<{
27
+ stage: string;
28
+ agents?: string[];
29
+ model?: e.Providers;
30
+ parallel?: boolean;
31
+ /** Optional simple condition on content/tools */
32
+ when?: 'always' | 'has_tools' | 'no_tools' | {
33
+ includes?: string[];
34
+ excludes?: string[];
35
+ };
36
+ }>;
37
+ /** Opt-in feature flags */
38
+ featureFlags?: {
39
+ multi_model_routing?: boolean;
40
+ fan_out?: boolean;
41
+ fan_out_retries?: number;
42
+ fan_out_backoff_ms?: number;
43
+ fan_out_concurrency?: number;
44
+ };
45
+ /** Optional per-stage model configs */
46
+ models?: Record<string, l.LLMConfig>;
47
+ } & Omit<g.StandardGraphInput, 'provider' | 'clientOptions'>;
19
48
  export type RunTitleOptions = {
20
49
  inputText: string;
50
+ provider: e.Providers;
21
51
  contentParts: (s.MessageContentComplex | undefined)[];
22
52
  titlePrompt?: string;
23
53
  skipLanguage?: boolean;
24
54
  clientOptions?: l.ClientOptions;
25
55
  chainOptions?: Partial<RunnableConfig> | undefined;
56
+ omitOptions?: Set<string>;
57
+ titleMethod?: e.TitleMethod;
58
+ titlePromptTemplate?: string;
26
59
  };
27
60
  export interface AgentStateChannels {
28
61
  messages: BaseMessage[];
@@ -53,18 +86,23 @@ export type TaskManagerGraphConfig = {
53
86
  llmConfig: l.LLMConfig;
54
87
  };
55
88
  };
89
+ export type MultiAgentGraphConfig = {
90
+ type: 'multi-agent';
91
+ compileOptions?: g.CompileOptions;
92
+ agents: g.AgentInputs[];
93
+ edges: g.GraphEdge[];
94
+ };
56
95
  export type RunConfig = {
57
96
  runId: string;
58
- graphConfig: StandardGraphConfig | CollaborativeGraphConfig | TaskManagerGraphConfig;
97
+ graphConfig: LegacyGraphConfig | MultiAgentGraphConfig;
59
98
  customHandlers?: Record<string, g.EventHandler>;
60
99
  returnContent?: boolean;
100
+ tokenCounter?: TokenCounter;
101
+ indexTokenCountMap?: Record<string, number>;
61
102
  };
62
103
  export type ProvidedCallbacks = (BaseCallbackHandler | CallbackHandlerMethods)[] | undefined;
63
104
  export type TokenCounter = (message: BaseMessage) => number;
64
105
  export type EventStreamOptions = {
65
- callbacks?: graph.ClientCallbacks;
106
+ callbacks?: g.ClientCallbacks;
66
107
  keepContent?: boolean;
67
- maxContextTokens?: number;
68
- tokenCounter?: TokenCounter;
69
- indexTokenCountMap?: Record<string, number>;
70
108
  };
@@ -2,6 +2,8 @@ import type OpenAITypes from 'openai';
2
2
  import type { MessageContentImageUrl, MessageContentText, ToolMessage, BaseMessage } from '@langchain/core/messages';
3
3
  import type { ToolCall, ToolCallChunk } from '@langchain/core/messages/tool';
4
4
  import type { LLMResult, Generation } from '@langchain/core/outputs';
5
+ import type { AnthropicContentBlock } from '@/llm/anthropic/types';
6
+ import type { Command } from '@langchain/langgraph';
5
7
  import type { ToolEndEvent } from '@/types/tools';
6
8
  import { StepTypes, ContentTypes, GraphEvents } from '@/common/enum';
7
9
  export type HandleLLMEnd = (output: LLMResult, runId: string, parentRunId?: string, tags?: string[]) => void;
@@ -64,7 +66,7 @@ export type MessageCreationDetails = {
64
66
  };
65
67
  export type ToolEndData = {
66
68
  input: string | Record<string, unknown>;
67
- output?: ToolMessage;
69
+ output?: ToolMessage | Command;
68
70
  };
69
71
  export type ToolErrorData = {
70
72
  id: string;
@@ -191,6 +193,11 @@ export type ReasoningContentText = {
191
193
  type: ContentTypes.THINK;
192
194
  think: string;
193
195
  };
196
+ /** Vertex AI / Google Common - Reasoning Content Block Format */
197
+ export type GoogleReasoningContentText = {
198
+ type: ContentTypes.REASONING;
199
+ reasoning: string;
200
+ };
194
201
  /** Anthropic's Reasoning Content Block Format */
195
202
  export type ThinkingContentText = {
196
203
  type: ContentTypes.THINKING;
@@ -230,7 +237,14 @@ export type ToolCallContent = {
230
237
  type: ContentTypes.TOOL_CALL;
231
238
  tool_call?: ToolCallPart;
232
239
  };
233
- export type MessageContentComplex = (ThinkingContentText | AgentUpdate | ToolCallContent | ReasoningContentText | MessageContentText | MessageContentImageUrl | (Record<string, any> & {
240
+ export type ToolResultContent = {
241
+ content: string | Record<string, unknown> | Array<string | Record<string, unknown>> | AnthropicContentBlock[];
242
+ type: 'tool_result' | 'web_search_result' | 'web_search_tool_result';
243
+ tool_use_id?: string;
244
+ input?: string | Record<string, unknown>;
245
+ index?: number;
246
+ };
247
+ export type MessageContentComplex = (ToolResultContent | ThinkingContentText | AgentUpdate | ToolCallContent | ReasoningContentText | MessageContentText | MessageContentImageUrl | (Record<string, any> & {
234
248
  type?: 'text' | 'image_url' | 'think' | 'thinking' | string;
235
249
  }) | (Record<string, any> & {
236
250
  type?: never;
@@ -1,5 +1,5 @@
1
- import type { RunnableToolLike } from '@langchain/core/runnables';
2
1
  import type { StructuredToolInterface } from '@langchain/core/tools';
2
+ import type { RunnableToolLike } from '@langchain/core/runnables';
3
3
  import type { ToolCall } from '@langchain/core/messages/tool';
4
4
  import type { ToolErrorData } from './stream';
5
5
  import { EnvVar } from '@/common';