@librechat/agents 3.1.88 → 3.1.90
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/dist/cjs/graphs/Graph.cjs +25 -1
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/cjs/hooks/executeHooks.cjs +14 -7
- package/dist/cjs/hooks/executeHooks.cjs.map +1 -1
- package/dist/cjs/llm/anthropic/index.cjs +8 -2
- package/dist/cjs/llm/anthropic/index.cjs.map +1 -1
- package/dist/cjs/llm/anthropic/utils/message_inputs.cjs +34 -0
- package/dist/cjs/llm/anthropic/utils/message_inputs.cjs.map +1 -1
- package/dist/cjs/main.cjs +9 -0
- package/dist/cjs/main.cjs.map +1 -1
- package/dist/cjs/stream.cjs +115 -8
- package/dist/cjs/stream.cjs.map +1 -1
- package/dist/cjs/tools/BashExecutor.cjs +10 -9
- package/dist/cjs/tools/BashExecutor.cjs.map +1 -1
- package/dist/cjs/tools/BashProgrammaticToolCalling.cjs +12 -8
- package/dist/cjs/tools/BashProgrammaticToolCalling.cjs.map +1 -1
- package/dist/cjs/tools/CodeExecutor.cjs +35 -11
- package/dist/cjs/tools/CodeExecutor.cjs.map +1 -1
- package/dist/cjs/tools/CodeSessionFileSummary.cjs +63 -0
- package/dist/cjs/tools/CodeSessionFileSummary.cjs.map +1 -0
- package/dist/cjs/tools/ProgrammaticToolCalling.cjs +16 -12
- package/dist/cjs/tools/ProgrammaticToolCalling.cjs.map +1 -1
- package/dist/cjs/tools/ToolNode.cjs +32 -12
- package/dist/cjs/tools/ToolNode.cjs.map +1 -1
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs +319 -29
- package/dist/cjs/tools/subagent/SubagentExecutor.cjs.map +1 -1
- package/dist/cjs/tools/toolOutputReferences.cjs +8 -0
- package/dist/cjs/tools/toolOutputReferences.cjs.map +1 -1
- package/dist/cjs/utils/events.cjs +3 -1
- package/dist/cjs/utils/events.cjs.map +1 -1
- package/dist/esm/graphs/Graph.mjs +25 -1
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/hooks/executeHooks.mjs +14 -7
- package/dist/esm/hooks/executeHooks.mjs.map +1 -1
- package/dist/esm/llm/anthropic/index.mjs +9 -3
- package/dist/esm/llm/anthropic/index.mjs.map +1 -1
- package/dist/esm/llm/anthropic/utils/message_inputs.mjs +33 -1
- package/dist/esm/llm/anthropic/utils/message_inputs.mjs.map +1 -1
- package/dist/esm/main.mjs +2 -1
- package/dist/esm/main.mjs.map +1 -1
- package/dist/esm/stream.mjs +115 -8
- package/dist/esm/stream.mjs.map +1 -1
- package/dist/esm/tools/BashExecutor.mjs +11 -10
- package/dist/esm/tools/BashExecutor.mjs.map +1 -1
- package/dist/esm/tools/BashProgrammaticToolCalling.mjs +13 -9
- package/dist/esm/tools/BashProgrammaticToolCalling.mjs.map +1 -1
- package/dist/esm/tools/CodeExecutor.mjs +29 -12
- package/dist/esm/tools/CodeExecutor.mjs.map +1 -1
- package/dist/esm/tools/CodeSessionFileSummary.mjs +60 -0
- package/dist/esm/tools/CodeSessionFileSummary.mjs.map +1 -0
- package/dist/esm/tools/ProgrammaticToolCalling.mjs +17 -13
- package/dist/esm/tools/ProgrammaticToolCalling.mjs.map +1 -1
- package/dist/esm/tools/ToolNode.mjs +32 -12
- package/dist/esm/tools/ToolNode.mjs.map +1 -1
- package/dist/esm/tools/subagent/SubagentExecutor.mjs +320 -31
- package/dist/esm/tools/subagent/SubagentExecutor.mjs.map +1 -1
- package/dist/esm/tools/toolOutputReferences.mjs +8 -1
- package/dist/esm/tools/toolOutputReferences.mjs.map +1 -1
- package/dist/esm/utils/events.mjs +3 -1
- package/dist/esm/utils/events.mjs.map +1 -1
- package/dist/types/graphs/Graph.d.ts +8 -0
- package/dist/types/llm/anthropic/index.d.ts +3 -1
- package/dist/types/llm/anthropic/utils/message_inputs.d.ts +4 -0
- package/dist/types/tools/BashExecutor.d.ts +3 -3
- package/dist/types/tools/CodeExecutor.d.ts +10 -3
- package/dist/types/tools/CodeSessionFileSummary.d.ts +3 -0
- package/dist/types/tools/ProgrammaticToolCalling.d.ts +4 -4
- package/dist/types/tools/subagent/SubagentExecutor.d.ts +8 -5
- package/dist/types/types/tools.d.ts +11 -3
- package/dist/types/utils/events.d.ts +1 -1
- package/package.json +1 -1
- package/src/__tests__/stream.eagerEventExecution.test.ts +1073 -221
- package/src/graphs/Graph.ts +27 -5
- package/src/hooks/__tests__/executeHooks.test.ts +38 -0
- package/src/hooks/executeHooks.ts +27 -7
- package/src/llm/anthropic/index.ts +27 -3
- package/src/llm/anthropic/llm.spec.ts +60 -1
- package/src/llm/anthropic/utils/message_inputs.ts +46 -0
- package/src/specs/subagent.test.ts +87 -1
- package/src/stream.ts +163 -12
- package/src/tools/BashExecutor.ts +21 -10
- package/src/tools/BashProgrammaticToolCalling.ts +21 -9
- package/src/tools/CodeExecutor.ts +55 -12
- package/src/tools/CodeSessionFileSummary.ts +80 -0
- package/src/tools/ProgrammaticToolCalling.ts +25 -12
- package/src/tools/ToolNode.ts +142 -116
- package/src/tools/__tests__/BashExecutor.test.ts +9 -0
- package/src/tools/__tests__/CodeApiAuthHeaders.test.ts +43 -0
- package/src/tools/__tests__/ProgrammaticToolCalling.test.ts +100 -16
- package/src/tools/__tests__/SubagentExecutor.test.ts +540 -6
- package/src/tools/__tests__/ToolNode.eagerEventExecution.test.ts +278 -14
- package/src/tools/__tests__/ToolNode.outputReferences.test.ts +52 -0
- package/src/tools/__tests__/subagentHooks.test.ts +237 -0
- package/src/tools/subagent/SubagentExecutor.ts +514 -36
- package/src/types/tools.ts +11 -3
- package/src/utils/events.ts +4 -2
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { DynamicStructuredTool } from '@langchain/core/tools';
|
|
2
2
|
import type * as t from '@/types';
|
|
3
3
|
import { Constants } from '@/common';
|
|
4
|
+
export { appendCodeSessionFileSummary, stripCodeSessionFileSummary, } from '@/tools/CodeSessionFileSummary';
|
|
4
5
|
export declare const getCodeBaseURL: () => string;
|
|
5
6
|
export declare const emptyOutputMessage = "stdout: Empty. Ensure you're writing output explicitly.\n";
|
|
7
|
+
export declare const CODE_ARTIFACT_PATH_GUIDANCE = "Persist handoff artifacts in `/mnt/data` with standard extensions (.json/.txt/.csv/.tsv/.log/.parquet/.png/.jpg/.pdf/.xlsx); failed executions do not register new files; `/tmp` and odd extensions are same-call scratch only, not later-call storage.";
|
|
8
|
+
export declare const BASH_SHELL_GUIDANCE = "Bash: multi-line files use heredoc/printf; run Python via python3 -c/heredoc, not bare Python.";
|
|
9
|
+
export declare const TMP_SCRATCH_OUTPUT_REMINDER = "Note: /tmp files are same-call scratch only and were not persisted; use /mnt/data for files needed later.";
|
|
10
|
+
export declare const FAILED_EXECUTION_FILE_REMINDER = "Note: any files written during this failed call were not registered for later calls; fix the error and rerun before relying on them.";
|
|
11
|
+
export declare function appendTmpScratchReminder(output: string, code: string): string;
|
|
12
|
+
export declare function appendFailedExecutionFileReminder(output: string, code: string): string;
|
|
6
13
|
export declare const CodeExecutionToolSchema: {
|
|
7
14
|
readonly type: "object";
|
|
8
15
|
readonly properties: {
|
|
@@ -13,7 +20,7 @@ export declare const CodeExecutionToolSchema: {
|
|
|
13
20
|
};
|
|
14
21
|
readonly code: {
|
|
15
22
|
readonly type: "string";
|
|
16
|
-
readonly description: "The complete, self-contained code to execute, without any truncation or minimization.\n- The environment is stateless; variables and imports don't persist between executions.\n-
|
|
23
|
+
readonly description: "The complete, self-contained code to execute, without any truncation or minimization.\n- The environment is stateless; variables and imports don't persist between executions.\n- Prior /mnt/data files are available and can be modified in place.\n- Persist handoff artifacts in `/mnt/data` with standard extensions (.json/.txt/.csv/.tsv/.log/.parquet/.png/.jpg/.pdf/.xlsx); failed executions do not register new files; `/tmp` and odd extensions are same-call scratch only, not later-call storage.\n- Input code **IS ALREADY** displayed to the user, so **DO NOT** repeat it in your response unless asked.\n- Output code **IS NOT** displayed to the user, so **DO** write all desired output explicitly.\n- IMPORTANT: You MUST explicitly print/output ALL results you want the user to see.\n- py: This is not a Jupyter notebook environment. Use `print()` for all outputs.\n- py: Matplotlib: Use `plt.savefig()` to save plots as files.\n- js: use the `console` or `process` methods for all outputs.\n- r: IMPORTANT: No X11 display available. ALL graphics MUST use Cairo library (library(Cairo)).\n- Other languages: use appropriate output functions.";
|
|
17
24
|
};
|
|
18
25
|
readonly args: {
|
|
19
26
|
readonly type: "array";
|
|
@@ -45,7 +52,7 @@ export declare const CodeExecutionToolDefinition: {
|
|
|
45
52
|
};
|
|
46
53
|
readonly code: {
|
|
47
54
|
readonly type: "string";
|
|
48
|
-
readonly description: "The complete, self-contained code to execute, without any truncation or minimization.\n- The environment is stateless; variables and imports don't persist between executions.\n-
|
|
55
|
+
readonly description: "The complete, self-contained code to execute, without any truncation or minimization.\n- The environment is stateless; variables and imports don't persist between executions.\n- Prior /mnt/data files are available and can be modified in place.\n- Persist handoff artifacts in `/mnt/data` with standard extensions (.json/.txt/.csv/.tsv/.log/.parquet/.png/.jpg/.pdf/.xlsx); failed executions do not register new files; `/tmp` and odd extensions are same-call scratch only, not later-call storage.\n- Input code **IS ALREADY** displayed to the user, so **DO NOT** repeat it in your response unless asked.\n- Output code **IS NOT** displayed to the user, so **DO** write all desired output explicitly.\n- IMPORTANT: You MUST explicitly print/output ALL results you want the user to see.\n- py: This is not a Jupyter notebook environment. Use `print()` for all outputs.\n- py: Matplotlib: Use `plt.savefig()` to save plots as files.\n- js: use the `console` or `process` methods for all outputs.\n- r: IMPORTANT: No X11 display available. ALL graphics MUST use Cairo library (library(Cairo)).\n- Other languages: use appropriate output functions.";
|
|
49
56
|
};
|
|
50
57
|
readonly args: {
|
|
51
58
|
readonly type: "array";
|
|
@@ -58,5 +65,5 @@ export declare const CodeExecutionToolDefinition: {
|
|
|
58
65
|
readonly required: readonly ["lang", "code"];
|
|
59
66
|
};
|
|
60
67
|
};
|
|
61
|
-
declare function createCodeExecutionTool(params?: t.CodeExecutionToolParams): DynamicStructuredTool;
|
|
68
|
+
declare function createCodeExecutionTool(params?: t.CodeExecutionToolParams | null): DynamicStructuredTool;
|
|
62
69
|
export { createCodeExecutionTool };
|
|
@@ -87,14 +87,14 @@ export declare function executeTools(toolCalls: t.PTCToolCall[], toolMap: t.Tool
|
|
|
87
87
|
/**
|
|
88
88
|
* Formats the completed response for the agent.
|
|
89
89
|
*
|
|
90
|
-
* Output
|
|
91
|
-
*
|
|
92
|
-
*
|
|
90
|
+
* Output includes stdout/stderr plus a compact session-file summary
|
|
91
|
+
* when artifacts were persisted. The artifact still carries every
|
|
92
|
+
* file so the host's session map stays in sync.
|
|
93
93
|
*
|
|
94
94
|
* @param response - The completed API response
|
|
95
95
|
* @returns Tuple of [formatted string, artifact]
|
|
96
96
|
*/
|
|
97
|
-
export declare function formatCompletedResponse(response: t.ProgrammaticExecutionResponse): [string, t.ProgrammaticExecutionArtifact];
|
|
97
|
+
export declare function formatCompletedResponse(response: t.ProgrammaticExecutionResponse, sourceCode?: string): [string, t.ProgrammaticExecutionArtifact];
|
|
98
98
|
/**
|
|
99
99
|
* Creates a Programmatic Tool Calling tool for complex multi-tool workflows.
|
|
100
100
|
*
|
|
@@ -16,11 +16,13 @@ export type SubagentExecuteParams = {
|
|
|
16
16
|
*/
|
|
17
17
|
parentToolCallId?: string;
|
|
18
18
|
/**
|
|
19
|
-
* Snapshot of the parent invocation's `config.configurable` at
|
|
20
|
-
* spawn-tool call site.
|
|
21
|
-
* `
|
|
22
|
-
* `
|
|
23
|
-
*
|
|
19
|
+
* Snapshot of the parent invocation's host `config.configurable` at
|
|
20
|
+
* the spawn-tool call site. Host-set fields (`requestBody`, `user`,
|
|
21
|
+
* `userMCPAuthMap`, etc.) propagate into the child workflow's
|
|
22
|
+
* `configurable` — fixing MCP body-placeholder substitution and
|
|
23
|
+
* per-user lookups for subagent tool calls. LangGraph runtime keys
|
|
24
|
+
* (`__pregel_*`, checkpoint bookkeeping) are intentionally not
|
|
25
|
+
* inherited; the child graph recreates its own runtime config.
|
|
24
26
|
*
|
|
25
27
|
* Inheritance details (verified empirically against LangGraph):
|
|
26
28
|
* - host-set keys propagate as-is into the child's tool dispatches;
|
|
@@ -120,6 +122,7 @@ export declare class SubagentExecutor {
|
|
|
120
122
|
*/
|
|
121
123
|
private createForwarderCallback;
|
|
122
124
|
}
|
|
125
|
+
export declare function sanitizeForwardedSubagentUpdateData(eventName: string, data: unknown): unknown;
|
|
123
126
|
/**
|
|
124
127
|
* Produces a short single-line label for an arbitrary forwarded child event.
|
|
125
128
|
* Used to populate {@link SubagentUpdateEvent.label} so the host UI can show
|
|
@@ -44,6 +44,13 @@ export type EagerEventToolExecution = {
|
|
|
44
44
|
args: Record<string, unknown>;
|
|
45
45
|
request: ToolCallRequest;
|
|
46
46
|
promise: Promise<EagerEventToolExecutionOutcome>;
|
|
47
|
+
/**
|
|
48
|
+
* True when the streaming eager path already emitted the user-visible
|
|
49
|
+
* ON_RUN_STEP_COMPLETED event for this call. ToolNode still consumes the
|
|
50
|
+
* result later to mutate graph state in provider-safe order, but skips
|
|
51
|
+
* duplicate completion emission.
|
|
52
|
+
*/
|
|
53
|
+
completionDispatched?: boolean;
|
|
47
54
|
};
|
|
48
55
|
export type EagerEventToolCallChunkState = {
|
|
49
56
|
id?: string;
|
|
@@ -160,6 +167,8 @@ export type ToolEndEvent = {
|
|
|
160
167
|
/** The content index of the tool call */
|
|
161
168
|
index: number;
|
|
162
169
|
type?: 'tool_call';
|
|
170
|
+
/** True when the stream eager path surfaced this completion before ToolNode finalized graph state. */
|
|
171
|
+
eager?: boolean;
|
|
163
172
|
};
|
|
164
173
|
/**
|
|
165
174
|
* Closed set of resource kinds for sandbox file caching. Defined as a
|
|
@@ -275,9 +284,8 @@ export type FileRef = {
|
|
|
275
284
|
* `true` when the codeapi sandbox echoed this entry as an unchanged
|
|
276
285
|
* passthrough of an input the caller already owns (skill files,
|
|
277
286
|
* downloaded inputs whose hash matched the baseline, inherited
|
|
278
|
-
* `.dirkeep` markers). The
|
|
279
|
-
*
|
|
280
|
-
* conflate infrastructure inputs with newly-produced outputs.
|
|
287
|
+
* `.dirkeep` markers). The host can use this flag to skip
|
|
288
|
+
* post-processing work for files the caller already owns.
|
|
281
289
|
*/
|
|
282
290
|
inherited?: true;
|
|
283
291
|
};
|
|
@@ -4,7 +4,7 @@ import type { AgentLogEvent } from '@/types/graph';
|
|
|
4
4
|
* Safely dispatches a custom event and properly awaits it to avoid
|
|
5
5
|
* race conditions where events are dispatched after run cleanup.
|
|
6
6
|
*/
|
|
7
|
-
export declare function safeDispatchCustomEvent(event: string, payload: unknown, config?: RunnableConfig): Promise<void>;
|
|
7
|
+
export declare function safeDispatchCustomEvent(event: string, payload: unknown, config?: RunnableConfig): Promise<boolean | void>;
|
|
8
8
|
/**
|
|
9
9
|
* Fire-and-forget diagnostic log event.
|
|
10
10
|
* Debug-level logs are gated behind AGENT_DEBUG_LOGGING=true to avoid
|