@librechat/agents 2.4.49 → 2.4.51

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@librechat/agents",
3
- "version": "2.4.49",
3
+ "version": "2.4.51",
4
4
  "main": "./dist/cjs/main.cjs",
5
5
  "module": "./dist/esm/main.mjs",
6
6
  "types": "./dist/types/index.d.ts",
@@ -75,14 +75,14 @@
75
75
  "@langchain/anthropic": "^0.3.23",
76
76
  "@langchain/aws": "^0.1.11",
77
77
  "@langchain/community": "^0.3.47",
78
- "@langchain/core": "^0.3.60",
78
+ "@langchain/core": "^0.3.62",
79
79
  "@langchain/deepseek": "^0.0.2",
80
80
  "@langchain/google-genai": "^0.2.13",
81
81
  "@langchain/google-vertexai": "^0.2.13",
82
82
  "@langchain/langgraph": "^0.3.4",
83
83
  "@langchain/mistralai": "^0.2.1",
84
84
  "@langchain/ollama": "^0.2.3",
85
- "@langchain/openai": "^0.5.14",
85
+ "@langchain/openai": "^0.5.16",
86
86
  "@langchain/xai": "^0.0.3",
87
87
  "cheerio": "^1.0.0",
88
88
  "dotenv": "^16.4.7",
@@ -135,7 +135,7 @@ export class StandardGraph extends Graph<t.BaseGraphState, GraphNode> {
135
135
  systemMessage: SystemMessage | undefined;
136
136
  messages: BaseMessage[] = [];
137
137
  runId: string | undefined;
138
- tools?: t.GenericTool[];
138
+ tools?: t.GraphTools;
139
139
  toolMap?: t.ToolMap;
140
140
  startIndex: number = 0;
141
141
  provider: Providers;
@@ -354,7 +354,7 @@ export class StandardGraph extends Graph<t.BaseGraphState, GraphNode> {
354
354
  | ToolNode<t.BaseGraphState> {
355
355
  // return new ToolNode<t.BaseGraphState>(this.tools);
356
356
  return new CustomToolNode<t.BaseGraphState>({
357
- tools: this.tools || [],
357
+ tools: (this.tools as t.GenericTool[] | undefined) || [],
358
358
  toolMap: this.toolMap,
359
359
  toolCallStepIds: this.toolCallStepIds,
360
360
  errorHandler: (data, metadata) =>
@@ -133,7 +133,7 @@ export class CustomChatGoogleGenerativeAI extends ChatGoogleGenerativeAI {
133
133
  this.useSystemInstruction
134
134
  );
135
135
  let actualPrompt = prompt;
136
- if (prompt[0].role === 'system') {
136
+ if (prompt?.[0].role === 'system') {
137
137
  const [systemInstruction] = prompt;
138
138
  /** @ts-ignore */
139
139
  this.client.systemInstruction = systemInstruction;
@@ -1,14 +1,15 @@
1
1
  import {
2
- EnhancedGenerateContentResponse,
3
- Content,
4
- Part,
5
- type FunctionDeclarationsTool as GoogleGenerativeAIFunctionDeclarationsTool,
6
- type FunctionDeclaration as GenerativeAIFunctionDeclaration,
7
2
  POSSIBLE_ROLES,
8
- FunctionCallPart,
9
- TextPart,
10
- FileDataPart,
11
- InlineDataPart,
3
+ type Part,
4
+ type Content,
5
+ type TextPart,
6
+ type FileDataPart,
7
+ type InlineDataPart,
8
+ type FunctionCallPart,
9
+ type GenerateContentCandidate,
10
+ type EnhancedGenerateContentResponse,
11
+ type FunctionDeclaration as GenerativeAIFunctionDeclaration,
12
+ type FunctionDeclarationsTool as GoogleGenerativeAIFunctionDeclarationsTool,
12
13
  } from '@google/generative-ai';
13
14
  import {
14
15
  AIMessageChunk,
@@ -412,9 +413,9 @@ export function convertBaseMessagesToContent(
412
413
  messages: BaseMessage[],
413
414
  isMultimodalModel: boolean,
414
415
  convertSystemMessageToHumanContent: boolean = false
415
- ): Content[] {
416
+ ): Content[] | undefined {
416
417
  return messages.reduce<{
417
- content: Content[];
418
+ content: Content[] | undefined;
418
419
  mergeWithPreviousContent: boolean;
419
420
  }>(
420
421
  (acc, message, index) => {
@@ -427,7 +428,7 @@ export function convertBaseMessagesToContent(
427
428
  }
428
429
  const role = convertAuthorToRole(author);
429
430
 
430
- const prevContent = acc.content[acc.content.length];
431
+ const prevContent = acc.content?.[acc.content.length];
431
432
  if (
432
433
  !acc.mergeWithPreviousContent &&
433
434
  prevContent &&
@@ -445,7 +446,7 @@ export function convertBaseMessagesToContent(
445
446
  );
446
447
 
447
448
  if (acc.mergeWithPreviousContent) {
448
- const prevContent = acc.content[acc.content.length - 1];
449
+ const prevContent = acc.content?.[acc.content.length - 1];
449
450
  if (!prevContent) {
450
451
  throw new Error(
451
452
  'There was a problem parsing your system message. Please try a prompt without one.'
@@ -473,7 +474,7 @@ export function convertBaseMessagesToContent(
473
474
  return {
474
475
  mergeWithPreviousContent:
475
476
  author === 'system' && !convertSystemMessageToHumanContent,
476
- content: [...acc.content, content],
477
+ content: [...(acc.content ?? []), content],
477
478
  };
478
479
  },
479
480
  { content: [], mergeWithPreviousContent: false }
@@ -491,12 +492,15 @@ export function convertResponseContentToChatGenerationChunk(
491
492
  return null;
492
493
  }
493
494
  const functionCalls = response.functionCalls();
494
- const [candidate] = response.candidates;
495
- const { content: candidateContent, ...generationInfo } = candidate;
495
+ const [candidate] = response.candidates as [
496
+ Partial<GenerateContentCandidate> | undefined,
497
+ ];
498
+ const { content: candidateContent, ...generationInfo } = candidate ?? {};
496
499
  let content: MessageContent | undefined;
497
500
  // Checks if some parts do not have text. If false, it means that the content is a string.
498
501
  const reasoningParts: string[] = [];
499
502
  if (
503
+ candidateContent != null &&
500
504
  Array.isArray(candidateContent.parts) &&
501
505
  candidateContent.parts.every((p) => 'text' in p)
502
506
  ) {
@@ -510,7 +514,7 @@ export function convertResponseContentToChatGenerationChunk(
510
514
  textParts.push(part.text ?? '');
511
515
  }
512
516
  content = textParts.join('');
513
- } else if (Array.isArray(candidateContent.parts)) {
517
+ } else if (candidateContent && Array.isArray(candidateContent.parts)) {
514
518
  content = candidateContent.parts.map((p) => {
515
519
  if ('text' in p && 'thought' in p && p.thought === true) {
516
520
  reasoningParts.push(p.text ?? '');
@@ -565,10 +569,14 @@ export function convertResponseContentToChatGenerationChunk(
565
569
  additional_kwargs.reasoning = reasoningParts.join('');
566
570
  }
567
571
 
572
+ if (candidate?.groundingMetadata) {
573
+ additional_kwargs.groundingMetadata = candidate.groundingMetadata;
574
+ }
575
+
568
576
  return new ChatGenerationChunk({
569
577
  text,
570
578
  message: new AIMessageChunk({
571
- content: content || '',
579
+ content: content,
572
580
  name: !candidateContent ? undefined : candidateContent.role,
573
581
  tool_call_chunks: toolCallChunks,
574
582
  // Each chunk can have unique "generationInfo", and merging strategy is unclear,
@@ -1,11 +1,7 @@
1
1
  import { AzureOpenAI as AzureOpenAIClient } from 'openai';
2
2
  import { ChatXAI as OriginalChatXAI } from '@langchain/xai';
3
3
  import { ChatDeepSeek as OriginalChatDeepSeek } from '@langchain/deepseek';
4
- import {
5
- isOpenAITool,
6
- ToolDefinition,
7
- BaseLanguageModelInput,
8
- } from '@langchain/core/language_models/base';
4
+ import { ToolDefinition } from '@langchain/core/language_models/base';
9
5
  import {
10
6
  getEndpoint,
11
7
  OpenAIClient,
@@ -18,8 +14,7 @@ import { isLangChainTool } from '@langchain/core/utils/function_calling';
18
14
  import { CallbackManagerForLLMRun } from '@langchain/core/callbacks/manager';
19
15
  import type { BindToolsInput } from '@langchain/core/language_models/chat_models';
20
16
  import type { OpenAIEndpointConfig } from '@langchain/openai/dist/utils/azure';
21
- import type { AIMessageChunk, BaseMessage } from '@langchain/core/messages';
22
- import type { Runnable } from '@langchain/core/runnables';
17
+ import type { BaseMessage } from '@langchain/core/messages';
23
18
  import type * as t from '@langchain/openai';
24
19
  import {
25
20
  _convertMessagesToOpenAIResponsesParams,
@@ -27,14 +22,6 @@ import {
27
22
  type ResponseReturnStreamEvents,
28
23
  } from './utils';
29
24
 
30
- type ResponsesCreateParams = Parameters<OpenAIClient.Responses['create']>[0];
31
- type ResponsesTool = Exclude<ResponsesCreateParams['tools'], undefined>[number];
32
-
33
- type ChatOpenAIToolType =
34
- | BindToolsInput
35
- | OpenAIClient.ChatCompletionTool
36
- | ResponsesTool;
37
-
38
25
  type HeaderValue = string | undefined | null;
39
26
  export type HeadersLike =
40
27
  | Headers
@@ -133,29 +120,6 @@ export function _convertToOpenAITool(
133
120
 
134
121
  return toolDef;
135
122
  }
136
-
137
- function _convertChatOpenAIToolTypeToOpenAITool(
138
- tool: ChatOpenAIToolType,
139
- fields?: {
140
- strict?: boolean;
141
- }
142
- ): OpenAIClient.ChatCompletionTool {
143
- if (isOpenAITool(tool)) {
144
- if (fields?.strict !== undefined) {
145
- return {
146
- ...tool,
147
- function: {
148
- ...tool.function,
149
- strict: fields.strict,
150
- },
151
- };
152
- }
153
-
154
- return tool;
155
- }
156
- return _convertToOpenAITool(tool, fields);
157
- }
158
-
159
123
  export class CustomOpenAIClient extends OpenAIClient {
160
124
  abortHandler?: () => void;
161
125
  async fetchWithTimeout(
@@ -227,33 +191,10 @@ export class CustomAzureOpenAIClient extends AzureOpenAIClient {
227
191
  }
228
192
  }
229
193
 
230
- function isBuiltInTool(tool: ChatOpenAIToolType): tool is ResponsesTool {
231
- return 'type' in tool && tool.type !== 'function';
232
- }
233
-
234
194
  export class ChatOpenAI extends OriginalChatOpenAI<t.ChatOpenAICallOptions> {
235
195
  public get exposedClient(): CustomOpenAIClient {
236
196
  return this.client;
237
197
  }
238
- override bindTools(
239
- tools: ChatOpenAIToolType[],
240
- kwargs?: Partial<t.ChatOpenAICallOptions>
241
- ): Runnable<BaseLanguageModelInput, AIMessageChunk, t.ChatOpenAICallOptions> {
242
- let strict: boolean | undefined;
243
- if (kwargs?.strict !== undefined) {
244
- strict = kwargs.strict;
245
- } else if (this.supportsStrictToolCalling !== undefined) {
246
- strict = this.supportsStrictToolCalling;
247
- }
248
- return this.withConfig({
249
- tools: tools.map((tool) =>
250
- isBuiltInTool(tool)
251
- ? tool
252
- : _convertChatOpenAIToolTypeToOpenAITool(tool, { strict })
253
- ),
254
- ...kwargs,
255
- } as Partial<t.ChatOpenAICallOptions>);
256
- }
257
198
  protected _getClientOptions(
258
199
  options?: OpenAICoreRequestOptions
259
200
  ): OpenAICoreRequestOptions {
@@ -324,25 +265,6 @@ export class ChatOpenAI extends OriginalChatOpenAI<t.ChatOpenAICallOptions> {
324
265
  }
325
266
 
326
267
  export class AzureChatOpenAI extends OriginalAzureChatOpenAI {
327
- override bindTools(
328
- tools: ChatOpenAIToolType[],
329
- kwargs?: Partial<t.ChatOpenAICallOptions>
330
- ): Runnable<BaseLanguageModelInput, AIMessageChunk, t.ChatOpenAICallOptions> {
331
- let strict: boolean | undefined;
332
- if (kwargs?.strict !== undefined) {
333
- strict = kwargs.strict;
334
- } else if (this.supportsStrictToolCalling !== undefined) {
335
- strict = this.supportsStrictToolCalling;
336
- }
337
- return this.withConfig({
338
- tools: tools.map((tool) =>
339
- isBuiltInTool(tool)
340
- ? tool
341
- : _convertChatOpenAIToolTypeToOpenAITool(tool, { strict })
342
- ),
343
- ...kwargs,
344
- } as Partial<t.ChatOpenAICallOptions>);
345
- }
346
268
  public get exposedClient(): CustomOpenAIClient {
347
269
  return this.client;
348
270
  }
package/src/run.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  // src/run.ts
2
2
  import { zodToJsonSchema } from 'zod-to-json-schema';
3
3
  import { PromptTemplate } from '@langchain/core/prompts';
4
- import { AzureChatOpenAI, ChatOpenAI } from '@langchain/openai';
5
4
  import { SystemMessage } from '@langchain/core/messages';
5
+ import { AzureChatOpenAI, ChatOpenAI } from '@langchain/openai';
6
6
  import type {
7
7
  BaseMessage,
8
8
  MessageContentComplex,
@@ -147,15 +147,18 @@ export class Run<T extends t.BaseGraphState> {
147
147
  (streamOptions?.indexTokenCountMap
148
148
  ? await createTokenCounter()
149
149
  : undefined);
150
+ const tools = this.Graph.tools as
151
+ | Array<t.GenericTool | undefined>
152
+ | undefined;
150
153
  const toolTokens = tokenCounter
151
- ? (this.Graph.tools?.reduce((acc, tool) => {
154
+ ? (tools?.reduce((acc, tool) => {
152
155
  if (!(tool as Partial<t.GenericTool>).schema) {
153
156
  return acc;
154
157
  }
155
158
 
156
159
  const jsonSchema = zodToJsonSchema(
157
- (tool.schema as t.ZodObjectAny).describe(tool.description ?? ''),
158
- tool.name
160
+ (tool?.schema as t.ZodObjectAny).describe(tool?.description ?? ''),
161
+ tool?.name ?? ''
159
162
  );
160
163
  return (
161
164
  acc + tokenCounter(new SystemMessage(JSON.stringify(jsonSchema)))
@@ -25,7 +25,7 @@ import { Run } from '@/run';
25
25
 
26
26
  const provider = Providers.ANTHROPIC;
27
27
  describe(`${capitalizeFirstLetter(provider)} Streaming Tests`, () => {
28
- jest.setTimeout(30000);
28
+ jest.setTimeout(60000);
29
29
  let run: Run<t.IState>;
30
30
  let runningHistory: BaseMessage[];
31
31
  let collectedUsage: UsageMetadata[];
@@ -1,7 +1,13 @@
1
1
  // src/types/graph.ts
2
- import type { StateGraphArgs, StateGraph, CompiledStateGraph } from '@langchain/langgraph';
2
+ import type {
3
+ StateGraphArgs,
4
+ StateGraph,
5
+ CompiledStateGraph,
6
+ } from '@langchain/langgraph';
7
+ import type { BindToolsInput } from '@langchain/core/language_models/chat_models';
3
8
  import type { BaseMessage, AIMessageChunk } from '@langchain/core/messages';
4
9
  import type { ChatGenerationChunk } from '@langchain/core/outputs';
10
+ import type { GoogleAIToolType } from '@langchain/google-common';
5
11
  import type { RunnableConfig } from '@langchain/core/runnables';
6
12
  import type { ToolMap, GenericTool } from '@/types/tools';
7
13
  import type { ClientOptions } from '@/types/llm';
@@ -22,56 +28,78 @@ export type IState = BaseGraphState;
22
28
  // }
23
29
 
24
30
  export interface EventHandler {
25
- handle(event: string, data: StreamEventData | ModelEndData, metadata?: Record<string, unknown>, graph?: Graph): void;
31
+ handle(
32
+ event: string,
33
+ data: StreamEventData | ModelEndData,
34
+ metadata?: Record<string, unknown>,
35
+ graph?: Graph
36
+ ): void;
26
37
  }
27
38
 
28
- export type GraphStateChannels<T extends BaseGraphState> = StateGraphArgs<T>['channels'];
39
+ export type GraphStateChannels<T extends BaseGraphState> =
40
+ StateGraphArgs<T>['channels'];
29
41
 
30
- export type Workflow<T extends BaseGraphState = BaseGraphState, U extends Partial<T> = Partial<T>, N extends string = string> = StateGraph<T, U, N>;
42
+ export type Workflow<
43
+ T extends BaseGraphState = BaseGraphState,
44
+ U extends Partial<T> = Partial<T>,
45
+ N extends string = string,
46
+ > = StateGraph<T, U, N>;
31
47
 
32
- export type CompiledWorkflow<T extends BaseGraphState = BaseGraphState, U extends Partial<T> = Partial<T>, N extends string = string> = CompiledStateGraph<T, U, N>;
48
+ export type CompiledWorkflow<
49
+ T extends BaseGraphState = BaseGraphState,
50
+ U extends Partial<T> = Partial<T>,
51
+ N extends string = string,
52
+ > = CompiledStateGraph<T, U, N>;
33
53
 
34
- export type EventStreamCallbackHandlerInput = Parameters<CompiledWorkflow['streamEvents']>[2] extends Omit<infer T, 'autoClose'> ? T : never;
54
+ export type EventStreamCallbackHandlerInput =
55
+ Parameters<CompiledWorkflow['streamEvents']>[2] extends Omit<
56
+ infer T,
57
+ 'autoClose'
58
+ >
59
+ ? T
60
+ : never;
35
61
 
36
- export type StreamChunk = ChatGenerationChunk & {
37
- message: AIMessageChunk;
38
- } | AIMessageChunk;
62
+ export type StreamChunk =
63
+ | (ChatGenerationChunk & {
64
+ message: AIMessageChunk;
65
+ })
66
+ | AIMessageChunk;
39
67
 
40
68
  /**
41
69
  * Data associated with a StreamEvent.
42
70
  */
43
71
  export type StreamEventData = {
44
- /**
45
- * The input passed to the runnable that generated the event.
46
- * Inputs will sometimes be available at the *START* of the runnable, and
47
- * sometimes at the *END* of the runnable.
48
- * If a runnable is able to stream its inputs, then its input by definition
49
- * won't be known until the *END* of the runnable when it has finished streaming
50
- * its inputs.
51
- */
52
- input?: unknown;
53
- /**
54
- * The output of the runnable that generated the event.
55
- * Outputs will only be available at the *END* of the runnable.
56
- * For most runnables, this field can be inferred from the `chunk` field,
57
- * though there might be some exceptions for special cased runnables (e.g., like
58
- * chat models), which may return more information.
59
- */
60
- output?: unknown;
61
- /**
62
- * A streaming chunk from the output that generated the event.
63
- * chunks support addition in general, and adding them up should result
64
- * in the output of the runnable that generated the event.
65
- */
66
- chunk?: StreamChunk;
67
- /**
68
- * Runnable config for invoking other runnables within handlers.
69
- */
70
- config?: RunnableConfig;
71
- /**
72
- * Custom result from the runnable that generated the event.
73
- */
74
- result?: unknown;
72
+ /**
73
+ * The input passed to the runnable that generated the event.
74
+ * Inputs will sometimes be available at the *START* of the runnable, and
75
+ * sometimes at the *END* of the runnable.
76
+ * If a runnable is able to stream its inputs, then its input by definition
77
+ * won't be known until the *END* of the runnable when it has finished streaming
78
+ * its inputs.
79
+ */
80
+ input?: unknown;
81
+ /**
82
+ * The output of the runnable that generated the event.
83
+ * Outputs will only be available at the *END* of the runnable.
84
+ * For most runnables, this field can be inferred from the `chunk` field,
85
+ * though there might be some exceptions for special cased runnables (e.g., like
86
+ * chat models), which may return more information.
87
+ */
88
+ output?: unknown;
89
+ /**
90
+ * A streaming chunk from the output that generated the event.
91
+ * chunks support addition in general, and adding them up should result
92
+ * in the output of the runnable that generated the event.
93
+ */
94
+ chunk?: StreamChunk;
95
+ /**
96
+ * Runnable config for invoking other runnables within handlers.
97
+ */
98
+ config?: RunnableConfig;
99
+ /**
100
+ * Custom result from the runnable that generated the event.
101
+ */
102
+ result?: unknown;
75
103
  };
76
104
 
77
105
  /**
@@ -80,54 +108,54 @@ export type StreamEventData = {
80
108
  * Schema of a streaming event which is produced from the streamEvents method.
81
109
  */
82
110
  export type StreamEvent = {
83
- /**
84
- * Event names are of the format: on_[runnable_type]_(start|stream|end).
85
- *
86
- * Runnable types are one of:
87
- * - llm - used by non chat models
88
- * - chat_model - used by chat models
89
- * - prompt -- e.g., ChatPromptTemplate
90
- * - tool -- LangChain tools
91
- * - chain - most Runnables are of this type
92
- *
93
- * Further, the events are categorized as one of:
94
- * - start - when the runnable starts
95
- * - stream - when the runnable is streaming
96
- * - end - when the runnable ends
97
- *
98
- * start, stream and end are associated with slightly different `data` payload.
99
- *
100
- * Please see the documentation for `EventData` for more details.
101
- */
102
- event: string;
103
- /** The name of the runnable that generated the event. */
104
- name: string;
105
- /**
106
- * An randomly generated ID to keep track of the execution of the given runnable.
107
- *
108
- * Each child runnable that gets invoked as part of the execution of a parent runnable
109
- * is assigned its own unique ID.
110
- */
111
- run_id: string;
112
- /**
113
- * Tags associated with the runnable that generated this event.
114
- * Tags are always inherited from parent runnables.
115
- */
116
- tags?: string[];
117
- /** Metadata associated with the runnable that generated this event. */
118
- metadata: Record<string, unknown>;
119
- /**
120
- * Event data.
121
- *
122
- * The contents of the event data depend on the event type.
123
- */
124
- data: StreamEventData;
111
+ /**
112
+ * Event names are of the format: on_[runnable_type]_(start|stream|end).
113
+ *
114
+ * Runnable types are one of:
115
+ * - llm - used by non chat models
116
+ * - chat_model - used by chat models
117
+ * - prompt -- e.g., ChatPromptTemplate
118
+ * - tool -- LangChain tools
119
+ * - chain - most Runnables are of this type
120
+ *
121
+ * Further, the events are categorized as one of:
122
+ * - start - when the runnable starts
123
+ * - stream - when the runnable is streaming
124
+ * - end - when the runnable ends
125
+ *
126
+ * start, stream and end are associated with slightly different `data` payload.
127
+ *
128
+ * Please see the documentation for `EventData` for more details.
129
+ */
130
+ event: string;
131
+ /** The name of the runnable that generated the event. */
132
+ name: string;
133
+ /**
134
+ * An randomly generated ID to keep track of the execution of the given runnable.
135
+ *
136
+ * Each child runnable that gets invoked as part of the execution of a parent runnable
137
+ * is assigned its own unique ID.
138
+ */
139
+ run_id: string;
140
+ /**
141
+ * Tags associated with the runnable that generated this event.
142
+ * Tags are always inherited from parent runnables.
143
+ */
144
+ tags?: string[];
145
+ /** Metadata associated with the runnable that generated this event. */
146
+ metadata: Record<string, unknown>;
147
+ /**
148
+ * Event data.
149
+ *
150
+ * The contents of the event data depend on the event type.
151
+ */
152
+ data: StreamEventData;
125
153
  };
126
154
 
127
155
  export type GraphConfig = {
128
- provider: string;
129
- thread_id?: string;
130
- run_id?: string;
156
+ provider: string;
157
+ thread_id?: string;
158
+ run_id?: string;
131
159
  };
132
160
 
133
161
  export type PartMetadata = {
@@ -138,8 +166,10 @@ export type PartMetadata = {
138
166
  output?: string;
139
167
  };
140
168
 
141
- export type ModelEndData = StreamEventData & { output: AIMessageChunk | undefined } | undefined;
142
-
169
+ export type ModelEndData =
170
+ | (StreamEventData & { output: AIMessageChunk | undefined })
171
+ | undefined;
172
+ export type GraphTools = GenericTool[] | BindToolsInput[] | GoogleAIToolType[];
143
173
  export type StandardGraphInput = {
144
174
  runId?: string;
145
175
  toolEnd?: boolean;
@@ -148,8 +178,8 @@ export type StandardGraphInput = {
148
178
  signal?: AbortSignal;
149
179
  instructions?: string;
150
180
  streamBuffer?: number;
151
- tools?: GenericTool[];
152
181
  clientOptions: ClientOptions;
153
182
  additional_instructions?: string;
154
183
  reasoningKey?: 'reasoning_content' | 'reasoning';
155
- };
184
+ tools?: GraphTools;
185
+ };
@@ -1,6 +1,6 @@
1
1
  // src/types/tools.ts
2
- import type { RunnableToolLike } from '@langchain/core/runnables';
3
2
  import type { StructuredToolInterface } from '@langchain/core/tools';
3
+ import type { RunnableToolLike } from '@langchain/core/runnables';
4
4
  import type { ToolCall } from '@langchain/core/messages/tool';
5
5
  import type { ToolErrorData } from './stream';
6
6
  import { EnvVar } from '@/common';
@@ -13,9 +13,10 @@ export type CustomToolCall = {
13
13
  id?: string;
14
14
  type?: 'tool_call';
15
15
  output?: string;
16
- }
16
+ };
17
17
 
18
18
  export type GenericTool = StructuredToolInterface | RunnableToolLike;
19
+
19
20
  export type ToolMap = Map<string, GenericTool>;
20
21
  export type ToolRefs = {
21
22
  tools: GenericTool[];
@@ -30,7 +31,10 @@ export type ToolNodeOptions = {
30
31
  handleToolErrors?: boolean;
31
32
  loadRuntimeTools?: ToolRefGenerator;
32
33
  toolCallStepIds?: Map<string, string>;
33
- errorHandler?: (data: ToolErrorData, metadata?: Record<string, unknown>) => void
34
+ errorHandler?: (
35
+ data: ToolErrorData,
36
+ metadata?: Record<string, unknown>
37
+ ) => void;
34
38
  };
35
39
 
36
40
  export type ToolNodeConstructorParams = ToolRefs & ToolNodeOptions;
@@ -50,13 +54,15 @@ export type CodeEnvFile = {
50
54
  session_id: string;
51
55
  };
52
56
 
53
- export type CodeExecutionToolParams = undefined | {
54
- session_id?: string;
55
- user_id?: string;
56
- apiKey?: string;
57
- files?: CodeEnvFile[];
58
- [EnvVar.CODE_API_KEY]?: string;
59
- }
57
+ export type CodeExecutionToolParams =
58
+ | undefined
59
+ | {
60
+ session_id?: string;
61
+ user_id?: string;
62
+ apiKey?: string;
63
+ files?: CodeEnvFile[];
64
+ [EnvVar.CODE_API_KEY]?: string;
65
+ };
60
66
 
61
67
  export type FileRef = {
62
68
  id: string;