@librechat/agents-types 2.2.5 → 2.2.7
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 +1 -1
- package/stream.ts +41 -2
- package/tools.ts +3 -6
package/package.json
CHANGED
package/stream.ts
CHANGED
@@ -93,6 +93,11 @@ export type MessageCreationDetails = {
|
|
93
93
|
};
|
94
94
|
|
95
95
|
export type ToolEndData = { input: string | Record<string, unknown>, output?: ToolMessage };
|
96
|
+
export type ToolErrorData = {
|
97
|
+
id: string,
|
98
|
+
name: string,
|
99
|
+
error?: Error,
|
100
|
+
} & Pick<ToolEndData, 'input'>;
|
96
101
|
export type ToolEndCallback = (data: ToolEndData, metadata?: Record<string, unknown>) => void;
|
97
102
|
|
98
103
|
export type ProcessedToolCall = {
|
@@ -240,8 +245,35 @@ export type BedrockReasoningContentText = {
|
|
240
245
|
reasoningText: { text?: string; signature?: string; }
|
241
246
|
};
|
242
247
|
|
248
|
+
/**
|
249
|
+
* A call to a tool.
|
250
|
+
*/
|
251
|
+
export type ToolCallPart = {
|
252
|
+
/** Type ("tool_call") according to Assistants Tool Call Structure */
|
253
|
+
type: ContentTypes.TOOL_CALL;
|
254
|
+
/** The name of the tool to be called */
|
255
|
+
name: string;
|
256
|
+
/** The arguments to the tool call */
|
257
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
258
|
+
args?: string | Record<string, any>;
|
259
|
+
|
260
|
+
/** If provided, an identifier associated with the tool call */
|
261
|
+
id?: string;
|
262
|
+
/** If provided, the output of the tool call */
|
263
|
+
output?: string;
|
264
|
+
/** Auth URL */
|
265
|
+
auth?: string;
|
266
|
+
/** Expiration time */
|
267
|
+
expires_at?: number;
|
268
|
+
};
|
269
|
+
|
270
|
+
export type ToolCallContent = {
|
271
|
+
type: ContentTypes.TOOL_CALL;
|
272
|
+
tool_call?: ToolCallPart;
|
273
|
+
};
|
274
|
+
|
243
275
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
244
|
-
export type MessageContentComplex = (ThinkingContentText | AgentUpdate | ReasoningContentText | MessageContentText | MessageContentImageUrl | (Record<string, any> & {
|
276
|
+
export type MessageContentComplex = (ThinkingContentText | AgentUpdate | ToolCallContent | ReasoningContentText | MessageContentText | MessageContentImageUrl | (Record<string, any> & {
|
245
277
|
type?: 'text' | 'image_url' | 'think' | 'thinking' | string;
|
246
278
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
247
279
|
}) | (Record<string, any> & {
|
@@ -249,7 +281,14 @@ export type MessageContentComplex = (ThinkingContentText | AgentUpdate | Reasoni
|
|
249
281
|
})) & {
|
250
282
|
tool_call_ids?: string[];
|
251
283
|
};
|
252
|
-
|
284
|
+
|
285
|
+
export interface TMessage {
|
286
|
+
role?: string;
|
287
|
+
content?: MessageContentComplex[] | string;
|
288
|
+
[key: string]: any;
|
289
|
+
}
|
290
|
+
|
291
|
+
export type TPayload = Array<Partial<TMessage>>;
|
253
292
|
|
254
293
|
export type CustomChunk = Partial<OpenAITypes.ChatCompletionChunk> & {
|
255
294
|
choices?: Partial<Array<Partial<OpenAITypes.Chat.Completions.ChatCompletionChunk.Choice> & {
|
package/tools.ts
CHANGED
@@ -2,7 +2,8 @@
|
|
2
2
|
import type { RunnableToolLike } from '@langchain/core/runnables';
|
3
3
|
import type { StructuredToolInterface } from '@langchain/core/tools';
|
4
4
|
import type { ToolCall } from '@langchain/core/messages/tool';
|
5
|
-
import {
|
5
|
+
import type { ToolErrorData } from './stream';
|
6
|
+
import { EnvVar } from '@/common';
|
6
7
|
|
7
8
|
/** Replacement type for `import type { ToolCall } from '@langchain/core/messages/tool'` in order to have stringified args typed */
|
8
9
|
export type CustomToolCall = {
|
@@ -29,6 +30,7 @@ export type ToolNodeOptions = {
|
|
29
30
|
handleToolErrors?: boolean;
|
30
31
|
loadRuntimeTools?: ToolRefGenerator;
|
31
32
|
toolCallStepIds?: Map<string, string>;
|
33
|
+
errorHandler?: (data: ToolErrorData, metadata?: Record<string, unknown>) => void
|
32
34
|
};
|
33
35
|
|
34
36
|
export type ToolNodeConstructorParams = ToolRefs & ToolNodeOptions;
|
@@ -42,11 +44,6 @@ export type ToolEndEvent = {
|
|
42
44
|
index: number;
|
43
45
|
};
|
44
46
|
|
45
|
-
export type ToolCallContent = {
|
46
|
-
type: ContentTypes.TOOL_CALL;
|
47
|
-
tool_call: ToolCall;
|
48
|
-
};
|
49
|
-
|
50
47
|
export type CodeEnvFile = {
|
51
48
|
id: string;
|
52
49
|
name: string;
|