@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.
Files changed (96) hide show
  1. package/dist/cjs/graphs/Graph.cjs +25 -1
  2. package/dist/cjs/graphs/Graph.cjs.map +1 -1
  3. package/dist/cjs/hooks/executeHooks.cjs +14 -7
  4. package/dist/cjs/hooks/executeHooks.cjs.map +1 -1
  5. package/dist/cjs/llm/anthropic/index.cjs +8 -2
  6. package/dist/cjs/llm/anthropic/index.cjs.map +1 -1
  7. package/dist/cjs/llm/anthropic/utils/message_inputs.cjs +34 -0
  8. package/dist/cjs/llm/anthropic/utils/message_inputs.cjs.map +1 -1
  9. package/dist/cjs/main.cjs +9 -0
  10. package/dist/cjs/main.cjs.map +1 -1
  11. package/dist/cjs/stream.cjs +115 -8
  12. package/dist/cjs/stream.cjs.map +1 -1
  13. package/dist/cjs/tools/BashExecutor.cjs +10 -9
  14. package/dist/cjs/tools/BashExecutor.cjs.map +1 -1
  15. package/dist/cjs/tools/BashProgrammaticToolCalling.cjs +12 -8
  16. package/dist/cjs/tools/BashProgrammaticToolCalling.cjs.map +1 -1
  17. package/dist/cjs/tools/CodeExecutor.cjs +35 -11
  18. package/dist/cjs/tools/CodeExecutor.cjs.map +1 -1
  19. package/dist/cjs/tools/CodeSessionFileSummary.cjs +63 -0
  20. package/dist/cjs/tools/CodeSessionFileSummary.cjs.map +1 -0
  21. package/dist/cjs/tools/ProgrammaticToolCalling.cjs +16 -12
  22. package/dist/cjs/tools/ProgrammaticToolCalling.cjs.map +1 -1
  23. package/dist/cjs/tools/ToolNode.cjs +32 -12
  24. package/dist/cjs/tools/ToolNode.cjs.map +1 -1
  25. package/dist/cjs/tools/subagent/SubagentExecutor.cjs +319 -29
  26. package/dist/cjs/tools/subagent/SubagentExecutor.cjs.map +1 -1
  27. package/dist/cjs/tools/toolOutputReferences.cjs +8 -0
  28. package/dist/cjs/tools/toolOutputReferences.cjs.map +1 -1
  29. package/dist/cjs/utils/events.cjs +3 -1
  30. package/dist/cjs/utils/events.cjs.map +1 -1
  31. package/dist/esm/graphs/Graph.mjs +25 -1
  32. package/dist/esm/graphs/Graph.mjs.map +1 -1
  33. package/dist/esm/hooks/executeHooks.mjs +14 -7
  34. package/dist/esm/hooks/executeHooks.mjs.map +1 -1
  35. package/dist/esm/llm/anthropic/index.mjs +9 -3
  36. package/dist/esm/llm/anthropic/index.mjs.map +1 -1
  37. package/dist/esm/llm/anthropic/utils/message_inputs.mjs +33 -1
  38. package/dist/esm/llm/anthropic/utils/message_inputs.mjs.map +1 -1
  39. package/dist/esm/main.mjs +2 -1
  40. package/dist/esm/main.mjs.map +1 -1
  41. package/dist/esm/stream.mjs +115 -8
  42. package/dist/esm/stream.mjs.map +1 -1
  43. package/dist/esm/tools/BashExecutor.mjs +11 -10
  44. package/dist/esm/tools/BashExecutor.mjs.map +1 -1
  45. package/dist/esm/tools/BashProgrammaticToolCalling.mjs +13 -9
  46. package/dist/esm/tools/BashProgrammaticToolCalling.mjs.map +1 -1
  47. package/dist/esm/tools/CodeExecutor.mjs +29 -12
  48. package/dist/esm/tools/CodeExecutor.mjs.map +1 -1
  49. package/dist/esm/tools/CodeSessionFileSummary.mjs +60 -0
  50. package/dist/esm/tools/CodeSessionFileSummary.mjs.map +1 -0
  51. package/dist/esm/tools/ProgrammaticToolCalling.mjs +17 -13
  52. package/dist/esm/tools/ProgrammaticToolCalling.mjs.map +1 -1
  53. package/dist/esm/tools/ToolNode.mjs +32 -12
  54. package/dist/esm/tools/ToolNode.mjs.map +1 -1
  55. package/dist/esm/tools/subagent/SubagentExecutor.mjs +320 -31
  56. package/dist/esm/tools/subagent/SubagentExecutor.mjs.map +1 -1
  57. package/dist/esm/tools/toolOutputReferences.mjs +8 -1
  58. package/dist/esm/tools/toolOutputReferences.mjs.map +1 -1
  59. package/dist/esm/utils/events.mjs +3 -1
  60. package/dist/esm/utils/events.mjs.map +1 -1
  61. package/dist/types/graphs/Graph.d.ts +8 -0
  62. package/dist/types/llm/anthropic/index.d.ts +3 -1
  63. package/dist/types/llm/anthropic/utils/message_inputs.d.ts +4 -0
  64. package/dist/types/tools/BashExecutor.d.ts +3 -3
  65. package/dist/types/tools/CodeExecutor.d.ts +10 -3
  66. package/dist/types/tools/CodeSessionFileSummary.d.ts +3 -0
  67. package/dist/types/tools/ProgrammaticToolCalling.d.ts +4 -4
  68. package/dist/types/tools/subagent/SubagentExecutor.d.ts +8 -5
  69. package/dist/types/types/tools.d.ts +11 -3
  70. package/dist/types/utils/events.d.ts +1 -1
  71. package/package.json +1 -1
  72. package/src/__tests__/stream.eagerEventExecution.test.ts +1073 -221
  73. package/src/graphs/Graph.ts +27 -5
  74. package/src/hooks/__tests__/executeHooks.test.ts +38 -0
  75. package/src/hooks/executeHooks.ts +27 -7
  76. package/src/llm/anthropic/index.ts +27 -3
  77. package/src/llm/anthropic/llm.spec.ts +60 -1
  78. package/src/llm/anthropic/utils/message_inputs.ts +46 -0
  79. package/src/specs/subagent.test.ts +87 -1
  80. package/src/stream.ts +163 -12
  81. package/src/tools/BashExecutor.ts +21 -10
  82. package/src/tools/BashProgrammaticToolCalling.ts +21 -9
  83. package/src/tools/CodeExecutor.ts +55 -12
  84. package/src/tools/CodeSessionFileSummary.ts +80 -0
  85. package/src/tools/ProgrammaticToolCalling.ts +25 -12
  86. package/src/tools/ToolNode.ts +142 -116
  87. package/src/tools/__tests__/BashExecutor.test.ts +9 -0
  88. package/src/tools/__tests__/CodeApiAuthHeaders.test.ts +43 -0
  89. package/src/tools/__tests__/ProgrammaticToolCalling.test.ts +100 -16
  90. package/src/tools/__tests__/SubagentExecutor.test.ts +540 -6
  91. package/src/tools/__tests__/ToolNode.eagerEventExecution.test.ts +278 -14
  92. package/src/tools/__tests__/ToolNode.outputReferences.test.ts +52 -0
  93. package/src/tools/__tests__/subagentHooks.test.ts +237 -0
  94. package/src/tools/subagent/SubagentExecutor.ts +514 -36
  95. package/src/types/tools.ts +11 -3
  96. 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- Generated files from previous executions are automatically available in \"/mnt/data/\".\n- Files from previous executions are automatically available and can be modified in place.\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.";
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- Generated files from previous executions are automatically available in \"/mnt/data/\".\n- Files from previous executions are automatically available and can be modified in place.\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.";
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 };
@@ -0,0 +1,3 @@
1
+ import type * as t from '@/types';
2
+ export declare function stripCodeSessionFileSummary(output: string): string;
3
+ export declare function appendCodeSessionFileSummary(output: string, files: t.FileRefs | undefined): string;
@@ -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 is stdout/stderr only see `CodeExecutor.ts`. The
91
- * artifact still carries every file so the host's session map
92
- * stays in sync; the LLM doesn't see them in the tool result text.
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 the
20
- * spawn-tool call site. Inherited verbatim into the child workflow's
21
- * `configurable` so host-set fields (`requestBody`, `user`,
22
- * `userMCPAuthMap`, etc.) propagate — fixing MCP body-placeholder
23
- * substitution and per-user lookups for subagent tool calls.
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 tool-result formatter renders these as
279
- * "Available files" rather than "Generated files" so the LLM doesn't
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@librechat/agents",
3
- "version": "3.1.88",
3
+ "version": "3.1.90",
4
4
  "main": "./dist/cjs/main.cjs",
5
5
  "module": "./dist/esm/main.mjs",
6
6
  "types": "./dist/types/index.d.ts",