@librechat/agents 3.6.9 → 3.6.11

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 (146) hide show
  1. package/dist/cjs/agents/AgentContext.cjs +99 -39
  2. package/dist/cjs/agents/AgentContext.cjs.map +1 -1
  3. package/dist/cjs/agents/projection.cjs +2 -2
  4. package/dist/cjs/agents/projection.cjs.map +1 -1
  5. package/dist/cjs/graphs/Graph.cjs +32 -21
  6. package/dist/cjs/graphs/Graph.cjs.map +1 -1
  7. package/dist/cjs/graphs/MultiAgentGraph.cjs +87 -16
  8. package/dist/cjs/graphs/MultiAgentGraph.cjs.map +1 -1
  9. package/dist/cjs/llm/openai/index.cjs +10 -0
  10. package/dist/cjs/llm/openai/index.cjs.map +1 -1
  11. package/dist/cjs/main.cjs +16 -0
  12. package/dist/cjs/messages/alternation.cjs +125 -20
  13. package/dist/cjs/messages/alternation.cjs.map +1 -1
  14. package/dist/cjs/messages/core.cjs +195 -18
  15. package/dist/cjs/messages/core.cjs.map +1 -1
  16. package/dist/cjs/messages/format.cjs +488 -118
  17. package/dist/cjs/messages/format.cjs.map +1 -1
  18. package/dist/cjs/messages/handoffCue.cjs +3 -2
  19. package/dist/cjs/messages/handoffCue.cjs.map +1 -1
  20. package/dist/cjs/messages/index.cjs +1 -0
  21. package/dist/cjs/messages/injected.cjs +5 -2
  22. package/dist/cjs/messages/injected.cjs.map +1 -1
  23. package/dist/cjs/messages/provenance.cjs +411 -0
  24. package/dist/cjs/messages/provenance.cjs.map +1 -0
  25. package/dist/cjs/messages/prune.cjs +18 -13
  26. package/dist/cjs/messages/prune.cjs.map +1 -1
  27. package/dist/cjs/messages/toolResultTypes.cjs +663 -0
  28. package/dist/cjs/messages/toolResultTypes.cjs.map +1 -0
  29. package/dist/cjs/run.cjs +7 -4
  30. package/dist/cjs/run.cjs.map +1 -1
  31. package/dist/cjs/stream.cjs +1 -0
  32. package/dist/cjs/stream.cjs.map +1 -1
  33. package/dist/cjs/tools/BashProgrammaticToolCalling.cjs +21 -4
  34. package/dist/cjs/tools/BashProgrammaticToolCalling.cjs.map +1 -1
  35. package/dist/cjs/tools/CallerCapabilities.cjs +79 -0
  36. package/dist/cjs/tools/CallerCapabilities.cjs.map +1 -0
  37. package/dist/cjs/tools/ProgrammaticCallerPolicy.cjs +34 -0
  38. package/dist/cjs/tools/ProgrammaticCallerPolicy.cjs.map +1 -0
  39. package/dist/cjs/tools/ProgrammaticToolCalling.cjs +21 -4
  40. package/dist/cjs/tools/ProgrammaticToolCalling.cjs.map +1 -1
  41. package/dist/cjs/tools/ToolNode.cjs +39 -21
  42. package/dist/cjs/tools/ToolNode.cjs.map +1 -1
  43. package/dist/cjs/tools/cloudflare/CloudflareProgrammaticToolCalling.cjs +12 -4
  44. package/dist/cjs/tools/cloudflare/CloudflareProgrammaticToolCalling.cjs.map +1 -1
  45. package/dist/cjs/tools/local/LocalProgrammaticToolCalling.cjs +13 -4
  46. package/dist/cjs/tools/local/LocalProgrammaticToolCalling.cjs.map +1 -1
  47. package/dist/cjs/tools/local/resolveLocalExecutionTools.cjs +73 -13
  48. package/dist/cjs/tools/local/resolveLocalExecutionTools.cjs.map +1 -1
  49. package/dist/cjs/tools/ptcTimeout.cjs.map +1 -1
  50. package/dist/cjs/utils/toolContent.cjs +2 -2
  51. package/dist/cjs/utils/toolContent.cjs.map +1 -1
  52. package/dist/esm/agents/AgentContext.mjs +99 -39
  53. package/dist/esm/agents/AgentContext.mjs.map +1 -1
  54. package/dist/esm/agents/projection.mjs +2 -2
  55. package/dist/esm/agents/projection.mjs.map +1 -1
  56. package/dist/esm/graphs/Graph.mjs +34 -23
  57. package/dist/esm/graphs/Graph.mjs.map +1 -1
  58. package/dist/esm/graphs/MultiAgentGraph.mjs +87 -16
  59. package/dist/esm/graphs/MultiAgentGraph.mjs.map +1 -1
  60. package/dist/esm/llm/openai/index.mjs +10 -0
  61. package/dist/esm/llm/openai/index.mjs.map +1 -1
  62. package/dist/esm/main.mjs +4 -3
  63. package/dist/esm/messages/alternation.mjs +125 -20
  64. package/dist/esm/messages/alternation.mjs.map +1 -1
  65. package/dist/esm/messages/core.mjs +196 -19
  66. package/dist/esm/messages/core.mjs.map +1 -1
  67. package/dist/esm/messages/format.mjs +488 -119
  68. package/dist/esm/messages/format.mjs.map +1 -1
  69. package/dist/esm/messages/handoffCue.mjs +3 -2
  70. package/dist/esm/messages/handoffCue.mjs.map +1 -1
  71. package/dist/esm/messages/index.mjs +1 -0
  72. package/dist/esm/messages/injected.mjs +5 -2
  73. package/dist/esm/messages/injected.mjs.map +1 -1
  74. package/dist/esm/messages/provenance.mjs +401 -0
  75. package/dist/esm/messages/provenance.mjs.map +1 -0
  76. package/dist/esm/messages/prune.mjs +18 -13
  77. package/dist/esm/messages/prune.mjs.map +1 -1
  78. package/dist/esm/messages/toolResultTypes.mjs +657 -0
  79. package/dist/esm/messages/toolResultTypes.mjs.map +1 -0
  80. package/dist/esm/run.mjs +7 -4
  81. package/dist/esm/run.mjs.map +1 -1
  82. package/dist/esm/stream.mjs +1 -0
  83. package/dist/esm/stream.mjs.map +1 -1
  84. package/dist/esm/tools/BashProgrammaticToolCalling.mjs +21 -4
  85. package/dist/esm/tools/BashProgrammaticToolCalling.mjs.map +1 -1
  86. package/dist/esm/tools/CallerCapabilities.mjs +73 -0
  87. package/dist/esm/tools/CallerCapabilities.mjs.map +1 -0
  88. package/dist/esm/tools/ProgrammaticCallerPolicy.mjs +32 -0
  89. package/dist/esm/tools/ProgrammaticCallerPolicy.mjs.map +1 -0
  90. package/dist/esm/tools/ProgrammaticToolCalling.mjs +21 -4
  91. package/dist/esm/tools/ProgrammaticToolCalling.mjs.map +1 -1
  92. package/dist/esm/tools/ToolNode.mjs +39 -21
  93. package/dist/esm/tools/ToolNode.mjs.map +1 -1
  94. package/dist/esm/tools/cloudflare/CloudflareProgrammaticToolCalling.mjs +14 -6
  95. package/dist/esm/tools/cloudflare/CloudflareProgrammaticToolCalling.mjs.map +1 -1
  96. package/dist/esm/tools/local/LocalProgrammaticToolCalling.mjs +15 -6
  97. package/dist/esm/tools/local/LocalProgrammaticToolCalling.mjs.map +1 -1
  98. package/dist/esm/tools/local/resolveLocalExecutionTools.mjs +72 -15
  99. package/dist/esm/tools/local/resolveLocalExecutionTools.mjs.map +1 -1
  100. package/dist/esm/tools/ptcTimeout.mjs.map +1 -1
  101. package/dist/esm/utils/toolContent.mjs +2 -2
  102. package/dist/esm/utils/toolContent.mjs.map +1 -1
  103. package/dist/types/agents/AgentContext.d.ts +19 -13
  104. package/dist/types/agents/projection.d.ts +3 -1
  105. package/dist/types/graphs/Graph.d.ts +1 -1
  106. package/dist/types/llm/openai/index.d.ts +20 -0
  107. package/dist/types/messages/format.d.ts +5 -0
  108. package/dist/types/messages/index.d.ts +1 -0
  109. package/dist/types/messages/provenance.d.ts +85 -0
  110. package/dist/types/messages/toolResultTypes.d.ts +33 -0
  111. package/dist/types/tools/CallerCapabilities.d.ts +25 -0
  112. package/dist/types/tools/ProgrammaticCallerPolicy.d.ts +20 -0
  113. package/dist/types/tools/ToolNode.d.ts +12 -7
  114. package/dist/types/tools/local/resolveLocalExecutionTools.d.ts +10 -0
  115. package/dist/types/tools/ptcTimeout.d.ts +8 -0
  116. package/dist/types/types/graph.d.ts +3 -1
  117. package/dist/types/types/tools.d.ts +30 -2
  118. package/package.json +1 -1
  119. package/src/agents/AgentContext.ts +253 -69
  120. package/src/agents/projection.ts +9 -1
  121. package/src/graphs/Graph.ts +62 -26
  122. package/src/graphs/MultiAgentGraph.ts +175 -33
  123. package/src/llm/openai/index.ts +43 -0
  124. package/src/messages/alternation.ts +217 -34
  125. package/src/messages/core.ts +358 -38
  126. package/src/messages/format.ts +958 -137
  127. package/src/messages/handoffCue.ts +7 -4
  128. package/src/messages/index.ts +1 -0
  129. package/src/messages/injected.ts +9 -6
  130. package/src/messages/provenance.ts +897 -0
  131. package/src/messages/prune.ts +28 -10
  132. package/src/messages/toolResultTypes.ts +1174 -0
  133. package/src/run.ts +9 -4
  134. package/src/stream.ts +6 -0
  135. package/src/tools/BashProgrammaticToolCalling.ts +46 -12
  136. package/src/tools/CallerCapabilities.ts +146 -0
  137. package/src/tools/ProgrammaticCallerPolicy.ts +97 -0
  138. package/src/tools/ProgrammaticToolCalling.ts +41 -7
  139. package/src/tools/ToolNode.ts +111 -50
  140. package/src/tools/cloudflare/CloudflareProgrammaticToolCalling.ts +24 -26
  141. package/src/tools/local/LocalProgrammaticToolCalling.ts +28 -23
  142. package/src/tools/local/resolveLocalExecutionTools.ts +209 -16
  143. package/src/tools/ptcTimeout.ts +6 -0
  144. package/src/types/graph.ts +3 -0
  145. package/src/types/tools.ts +32 -3
  146. package/src/utils/toolContent.ts +2 -2
@@ -45,6 +45,26 @@ export declare function shouldIncludeEncryptedReasoning(model: string, params: {
45
45
  export declare function getCacheWriteTokens(message: BaseMessage): number | undefined;
46
46
  export declare function attachCacheWriteUsage(message: BaseMessage): void;
47
47
  export declare function attachCacheWriteMetadata(response: OpenAIClient.Responses.Response): OpenAIClient.Responses.Response;
48
+ type ResponsesAnnotationsBoundaryEvent = {
49
+ type: OpenAIClient.Responses.ResponseStreamEvent['type'];
50
+ response?: {
51
+ output?: Array<{
52
+ type: string;
53
+ content?: Array<{
54
+ type: string;
55
+ annotations?: object[] | null;
56
+ }>;
57
+ }>;
58
+ };
59
+ };
60
+ /**
61
+ * The Responses API spec declares `annotations` required on `output_text`
62
+ * content parts, but some OpenAI-compatible gateways omit the field on the
63
+ * terminal `response.completed`/`response.incomplete` events. LangChain's
64
+ * converter calls `part.annotations.map(...)` unconditionally, so a missing
65
+ * field crashes the whole stream. Default it to `[]` before conversion.
66
+ */
67
+ export declare function ensureResponsesOutputAnnotations(event: ResponsesAnnotationsBoundaryEvent): void;
48
68
  /**
49
69
  * Classifies a generation chunk for the smoothing engine:
50
70
  * - splittable: plain visible text (string content equal to `chunk.text`, no
@@ -158,6 +158,11 @@ export declare function shiftIndexTokenCountMap(indexTokenCountMap: Record<numbe
158
158
  * the provider wire.
159
159
  */
160
160
  export declare function isSyntheticProviderContextMessage(message: BaseMessage): boolean;
161
+ /** Compacts a folded provider-context message without retaining source claims
162
+ * for bytes whose mapping cannot survive the lossy compaction. The unsourced
163
+ * user/tool parts intentionally make security consumers inspect the exact
164
+ * compacted wire under both external trust domains. */
165
+ export declare function compactSyntheticProviderContextMessage(message: HumanMessage, maxChars: number): HumanMessage;
161
166
  /**
162
167
  * Ensures compatibility when switching from a non-thinking agent to a thinking-enabled agent.
163
168
  * Converts AI messages with tool calls (that lack thinking/reasoning blocks) into buffer strings,
@@ -15,3 +15,4 @@ export * from './contextPruningSettings';
15
15
  export * from './reducer';
16
16
  export * from './recency';
17
17
  export * from './assistantPhase';
18
+ export * from './provenance';
@@ -0,0 +1,85 @@
1
+ import type { BaseMessage } from '@langchain/core/messages';
2
+ export declare const PROVIDER_MESSAGE_PROVENANCE_VERSION: 1;
3
+ /** Recommended consumer trust bounds. Producers preserve complete lineage
4
+ * above these limits; security-sensitive consumers must reject oversized
5
+ * envelopes and take their fail-closed path rather than truncate attribution. */
6
+ export declare const PROVIDER_MESSAGE_PROVENANCE_LIMITS: Readonly<{
7
+ readonly maxParts: 256;
8
+ readonly maxIndicesPerPart: 256;
9
+ readonly maxTotalIndexRefs: 4096;
10
+ readonly maxSourceMessageIds: 256;
11
+ readonly maxSourceMessageIdLength: 512;
12
+ readonly maxSourceContentPartIndex: 4095;
13
+ }>;
14
+ /** Authorship of one logical contribution to a provider-bound message. */
15
+ export type ProviderMessageAttribution = 'user' | 'model' | 'tool' | 'synthetic';
16
+ /**
17
+ * Lineage for one logical contribution to a provider-bound message.
18
+ * `sourceContentPartIndices` index the persisted source message's `content`
19
+ * array before formatting, filtering, or summary-boundary slicing.
20
+ */
21
+ export interface ProviderMessageProvenancePart {
22
+ readonly attribution: ProviderMessageAttribution;
23
+ readonly sourceMessageId?: string;
24
+ readonly sourceContentPartIndices?: readonly number[];
25
+ }
26
+ /** Stable, versioned provenance carried in `BaseMessage.additional_kwargs`. */
27
+ export interface ProviderMessageProvenance {
28
+ readonly version: typeof PROVIDER_MESSAGE_PROVENANCE_VERSION;
29
+ readonly parts: readonly ProviderMessageProvenancePart[];
30
+ }
31
+ /** Inert marker used only when a derived message must retain invalidity. */
32
+ export interface InvalidProviderMessageProvenance {
33
+ readonly version: typeof PROVIDER_MESSAGE_PROVENANCE_VERSION;
34
+ readonly parts: null;
35
+ }
36
+ /** Distinguishes absent metadata from an explicitly malformed envelope. */
37
+ export type ProviderMessageProvenanceState = {
38
+ readonly status: 'absent';
39
+ } | {
40
+ readonly status: 'invalid';
41
+ } | {
42
+ readonly status: 'valid';
43
+ readonly provenance: ProviderMessageProvenance;
44
+ };
45
+ /** Distinguishes absent lineage from validated ids and malformed metadata. */
46
+ export type ProviderSourceMessageIdsState = {
47
+ readonly status: 'absent';
48
+ } | {
49
+ readonly status: 'invalid';
50
+ } | {
51
+ readonly status: 'valid';
52
+ readonly sourceMessageIds: readonly string[];
53
+ };
54
+ /** Typed subset of `additional_kwargs` exposed at provider callbacks. */
55
+ export interface ProviderMessageProvenanceAdditionalKwargs {
56
+ readonly provenance?: ProviderMessageProvenance | InvalidProviderMessageProvenance;
57
+ readonly sourceMessageId?: string;
58
+ readonly sourceMessageIds?: readonly string[];
59
+ }
60
+ /** Returns explicitly stamped provenance without inferring from message role. */
61
+ export declare function getProviderMessageProvenance(message: BaseMessage): ProviderMessageProvenance | undefined;
62
+ /** Safely preserves the semantic difference between absent and invalid input. */
63
+ export declare function inspectProviderMessageProvenance(message: BaseMessage): ProviderMessageProvenanceState;
64
+ /** Safely distinguishes missing source lineage from malformed metadata. */
65
+ export declare function inspectProviderSourceMessageIds(message: BaseMessage): ProviderSourceMessageIdsState;
66
+ /** True when indexed contributions uniquely cover every current content part. */
67
+ export declare function hasBijectiveProviderContentPartMapping(parts: readonly ProviderMessageProvenancePart[], contentPartCount: number): boolean;
68
+ /**
69
+ * Returns every explicit persisted source id in stable content order.
70
+ * Typed parts, plural lineage, and the legacy singular id are unioned in that
71
+ * precedence order; duplicates are removed without reordering.
72
+ */
73
+ export declare function getProviderSourceMessageIds(message: BaseMessage): string[];
74
+ /** Replaces typed provenance and synchronizes its stable plural source ids. */
75
+ export declare function setProviderMessageProvenance(message: BaseMessage, parts: readonly ProviderMessageProvenancePart[]): void;
76
+ /** Publishes the canonical fail-closed marker for malformed provenance. */
77
+ export declare function setInvalidProviderMessageProvenance(message: BaseMessage): void;
78
+ /** Marks a provider-visible runtime message as host-generated context. */
79
+ export declare function stampSyntheticProviderMessage<T extends BaseMessage>(message: T): T;
80
+ /**
81
+ * Adds one logical lineage contribution, migrating legacy ids on first use.
82
+ * This compatibility helper rebuilds validated public metadata; hot formatters
83
+ * should accumulate locally and call `setProviderMessageProvenance` once.
84
+ */
85
+ export declare function appendProviderMessageProvenance(message: BaseMessage, part: ProviderMessageProvenancePart): void;
@@ -0,0 +1,33 @@
1
+ export type ProviderToolCallKind = 'tool' | 'server' | 'anthropic-server' | 'mcp' | 'google' | 'bedrock';
2
+ export interface ProviderToolCallPartDescriptor {
3
+ readonly callId: string;
4
+ readonly kind: ProviderToolCallKind;
5
+ readonly name?: string;
6
+ readonly sourceType: string;
7
+ }
8
+ export interface ProviderToolResultPartDescriptor {
9
+ readonly type: string;
10
+ readonly compatibleCallKinds: readonly ProviderToolCallKind[];
11
+ readonly toolCallId?: string;
12
+ readonly expectedToolNames?: readonly string[];
13
+ readonly requiresPreviousExecutableCode?: boolean;
14
+ readonly allowHumanMessagePairing?: boolean;
15
+ }
16
+ export interface ProviderToolCallIndexEntry {
17
+ readonly descriptor: ProviderToolCallPartDescriptor;
18
+ secondarySourceType?: string;
19
+ }
20
+ export type ProviderToolCallIndex = Map<string, ProviderToolCallIndexEntry | null>;
21
+ export declare const PROVIDER_TOOL_RESULT_MAX_ARRAY_ENTRIES = 256;
22
+ export declare const PROVIDER_TOOL_RESULT_MAX_VALIDATION_ENTRIES = 4096;
23
+ export declare const PROVIDER_TOOL_PAIRING_MAX_IDENTIFIER_CHARS = 512;
24
+ export declare const PROVIDER_TOOL_PAIRING_MAX_OUTER_PARTS = 4096;
25
+ export declare function getBoundedProviderPairingArray(value: unknown): readonly unknown[] | undefined;
26
+ export declare function getBoundedProviderPairingArrayProperty(value: unknown, key: string): readonly unknown[] | undefined;
27
+ export declare function isBoundedProviderPairingString(value: unknown, allowEmpty?: boolean): value is string;
28
+ export declare function hasStructurallyValidAnthropicWebSearchResultContent(part: unknown): boolean;
29
+ export declare function getProviderToolResultPartDescriptor(part: unknown): ProviderToolResultPartDescriptor | undefined;
30
+ export declare function getProviderAIMessageToolCallDescriptor(toolCall: unknown): ProviderToolCallPartDescriptor | undefined;
31
+ export declare function getProviderToolCallPartDescriptor(part: unknown): ProviderToolCallPartDescriptor | undefined;
32
+ export declare function appendProviderToolCallDescriptor(index: ProviderToolCallIndex, descriptor: ProviderToolCallPartDescriptor): void;
33
+ export declare function consumeProviderToolResultPair(descriptor: ProviderToolResultPartDescriptor, calls: ProviderToolCallIndex, previousPart?: unknown): boolean;
@@ -0,0 +1,25 @@
1
+ import type * as t from '@/types';
2
+ export type CallerCapabilityProjection = {
3
+ directTools: t.LCTool[];
4
+ codeExecutionTools: t.LCTool[];
5
+ directOnlyTools: t.LCTool[];
6
+ codeExecutionOnlyTools: t.LCTool[];
7
+ };
8
+ /**
9
+ * Combines event schemas with runtime capability metadata. Matching runtime
10
+ * entries override caller/defer policy without replacing the event schema;
11
+ * runtime-only definitions are appended intact.
12
+ */
13
+ export declare function mergeCallerCapabilityDefinitions(toolDefs: Iterable<t.LCTool> | null | undefined, overrides: Iterable<t.LCTool> | null | undefined): t.LCTool[];
14
+ /**
15
+ * Applies runtime caller metadata to schema-only event definitions without
16
+ * adding registry-only tools or replacing their model-facing schemas.
17
+ */
18
+ export declare function applyCallerCapabilityDefinitionOverrides(toolDefs: Iterable<t.LCTool>, overrides: Iterable<t.LCTool> | null | undefined): t.LCTool[];
19
+ /** Converts the live projection into the versioned event transport shape. */
20
+ export declare function createCallerCapabilityProjectionSnapshot(projection: CallerCapabilityProjection): t.CallerCapabilityProjectionSnapshot;
21
+ export declare function getAllowedCallers(toolDef: t.LCTool): readonly t.AllowedCaller[];
22
+ export declare function allowsToolCaller(toolDef: t.LCTool, caller: t.AllowedCaller): boolean;
23
+ export declare function isProgrammaticControlTool(name: string): boolean;
24
+ export declare function isToolDefinitionActive(toolDef: t.LCTool, discoveredToolNames: ReadonlySet<string>): boolean;
25
+ export declare function resolveCallerCapabilityProjection(toolDefs: Iterable<t.LCTool>, isActive?: (toolDef: t.LCTool) => boolean): CallerCapabilityProjection;
@@ -0,0 +1,20 @@
1
+ import type * as t from '@/types';
2
+ export type ProgrammaticInvocationParams = {
3
+ code: string;
4
+ tool_manifest?: string[];
5
+ timeout?: number;
6
+ lang?: string;
7
+ runtime?: string;
8
+ language?: string;
9
+ };
10
+ export declare function resolveProgrammaticToolDefinitions(context: Partial<t.ProgrammaticCache> & {
11
+ tools?: t.LCTool[];
12
+ }): t.LCTool[] | undefined;
13
+ export declare function projectProgrammaticToolMap(toolMap: t.ToolMap, selectedToolDefs: readonly t.LCTool[]): t.ToolMap;
14
+ export declare function assertDisallowedToolUsage(disallowedNames: ReadonlySet<string>, programmaticToolName: string): void;
15
+ export declare function selectProgrammaticTools(args: {
16
+ requestedToolNames?: string[];
17
+ allowedToolDefs?: t.LCTool[];
18
+ disallowedToolDefs?: t.LCTool[];
19
+ programmaticToolName: string;
20
+ }): t.LCTool[];
@@ -122,8 +122,12 @@ export declare class ToolNode<T = any> extends RunnableCallable<T, T> {
122
122
  private settledInterruptingResults;
123
123
  /** Tool registry for filtering (lazy computation of programmatic maps) */
124
124
  private toolRegistry?;
125
- /** Cached programmatic tools (computed once on first PTC call) */
126
- private programmaticCache?;
125
+ /** Schema-only definitions used when event mode has no runtime registry. */
126
+ private toolDefinitions?;
127
+ /** Tool-map entries created or replaced by the local execution resolver. */
128
+ private localImplementationNames;
129
+ /** Reads deferred-tool discovery state from the owning agent context. */
130
+ private getDiscoveredToolNames?;
127
131
  /** Reference to Graph's sessions map for automatic session injection */
128
132
  private sessions?;
129
133
  /** Partition within `sessions` owned by this agent's execution profile. */
@@ -213,7 +217,7 @@ export declare class ToolNode<T = any> extends RunnableCallable<T, T> {
213
217
  * other's in-flight state.
214
218
  */
215
219
  private anonBatchCounter;
216
- constructor({ tools, toolMap, name, tags, trace, runLangfuse, agentLangfuse, errorHandler, toolCallStepIds, handleToolErrors, loadRuntimeTools, toolRegistry, sessions, codeSessionKey, eventDrivenMode, eagerEventToolExecution, eagerEventToolExecutions, eagerEventToolUsageCount, eagerEventToolSuppressions, agentId, executingAgentId, directToolNames, interruptingToolNames, codeSessionToolNames, maxContextTokens, maxToolResultChars, hookRegistry, humanInTheLoop, toolOutputReferences, toolOutputRegistry, toolExecution, fileCheckpointer, getBreakerSignal, getRunScope, restoreRunStepResumeState, createRunStepResumeState, }: t.ToolNodeConstructorParams);
220
+ constructor({ tools, toolMap, name, tags, trace, runLangfuse, agentLangfuse, errorHandler, toolCallStepIds, handleToolErrors, loadRuntimeTools, toolRegistry, toolDefinitions, getDiscoveredToolNames, sessions, codeSessionKey, eventDrivenMode, eagerEventToolExecution, eagerEventToolExecutions, eagerEventToolUsageCount, eagerEventToolSuppressions, agentId, executingAgentId, directToolNames, interruptingToolNames, codeSessionToolNames, maxContextTokens, maxToolResultChars, hookRegistry, humanInTheLoop, toolOutputReferences, toolOutputRegistry, toolExecution, fileCheckpointer, getBreakerSignal, getRunScope, restoreRunStepResumeState, createRunStepResumeState, }: t.ToolNodeConstructorParams);
217
221
  invoke(input: any, options?: Partial<RunnableConfig>): Promise<any>;
218
222
  /**
219
223
  * Returns the run-scoped tool output registry, or `undefined` when
@@ -257,10 +261,11 @@ export declare class ToolNode<T = any> extends RunnableCallable<T, T> {
257
261
  * they reuse a ToolNode across batches outside of a Graph.
258
262
  */
259
263
  clearDirectPathTurns(): void;
260
- /**
261
- * Returns cached programmatic tools, computing once on first access.
262
- * Single iteration builds both toolMap and toolDefs simultaneously.
263
- */
264
+ /** Returns the live caller projection used by direct and event execution. */
265
+ private getCallerCapabilityProjection;
266
+ /** Serializes the live caller projection for event-driven hosts. */
267
+ private getCallerCapabilityProjectionSnapshot;
268
+ /** Returns active tools projected by their effective caller capabilities. */
264
269
  private getProgrammaticTools;
265
270
  /**
266
271
  * Returns a snapshot of the current tool usage counts.
@@ -2,6 +2,8 @@ import type * as t from '@/types';
2
2
  type ResolveLocalToolsResult = {
3
3
  toolMap: t.ToolMap;
4
4
  directToolNames: Set<string>;
5
+ /** Names whose toolMap entries were created or replaced by this resolver. */
6
+ localImplementationNames: Set<string>;
5
7
  /**
6
8
  * Set when `local.fileCheckpointing === true` AND the auto-bind
7
9
  * coding suite is in use. ToolNode stashes this on the node and
@@ -14,17 +16,25 @@ type ResolveLocalToolsResult = {
14
16
  */
15
17
  fileCheckpointer?: t.LocalFileCheckpointer;
16
18
  };
19
+ export declare function isProgrammaticRunnerAutoBound(name: string, config?: t.ToolExecutionConfig): boolean;
20
+ /** Mirrors whether resolver policy creates or replaces this runner locally. */
21
+ export declare function isProgrammaticRunnerResolvedDirectly(name: string, config?: t.ToolExecutionConfig, hasExplicitBinding?: boolean): boolean;
17
22
  export declare function resolveLocalToolsForBinding(args: {
18
23
  tools?: t.GraphTools;
19
24
  toolExecution?: t.ToolExecutionConfig;
25
+ toolRegistry?: t.LCToolRegistry;
26
+ discoveredToolNames?: ReadonlySet<string>;
20
27
  }): t.GraphTools | undefined;
21
28
  export declare function resolveLocalToolRegistry(args: {
22
29
  toolRegistry?: t.LCToolRegistry;
23
30
  toolExecution?: t.ToolExecutionConfig;
24
31
  }): t.LCToolRegistry | undefined;
32
+ /** Names that this execution config creates or replaces in the local tool map. */
33
+ export declare function resolveLocalImplementationNames(toolNames: Iterable<string>, toolExecution?: t.ToolExecutionConfig): Set<string>;
25
34
  export declare function resolveLocalExecutionTools(args: {
26
35
  toolMap: t.ToolMap;
27
36
  toolExecution?: t.ToolExecutionConfig;
37
+ toolRegistry?: t.LCToolRegistry;
28
38
  /**
29
39
  * Caller-provided checkpointer that overrides the bundle's
30
40
  * auto-created one. The Graph layer threads a single per-Run
@@ -18,6 +18,14 @@ export type ProgrammaticToolCallingJsonSchema = {
18
18
  minLength: number;
19
19
  description: string;
20
20
  };
21
+ tool_manifest: {
22
+ type: 'array';
23
+ items: {
24
+ type: 'string';
25
+ };
26
+ uniqueItems: true;
27
+ description: string;
28
+ };
21
29
  timeout: TimeoutSchema;
22
30
  };
23
31
  required: readonly ['code'];
@@ -6,7 +6,7 @@ import type { ChatGenerationChunk } from '@langchain/core/outputs';
6
6
  import type { GoogleAIToolType } from '@langchain/google-common';
7
7
  import type { SummarizationNodeInput, SummarizeCompleteEvent, SummarizationConfig, SummarizeStartEvent, SummarizeDeltaEvent } from '@/types/summarize';
8
8
  import type { RunStep, RunStepDeltaEvent, RunStepResumeState, RunStepClosedEvent, MessageDeltaEvent, ReasoningDeltaEvent } from '@/types/stream';
9
- import type { ToolMap, ToolSessionMap, ToolEndEvent, GenericTool, LCTool, ToolExecuteBatchRequest } from '@/types/tools';
9
+ import type { ToolMap, ToolSessionMap, ToolEndEvent, GenericTool, LCTool, ToolExecutionConfig, ToolExecuteBatchRequest } from '@/types/tools';
10
10
  import type { TokenCounter, StreamLimits, StreamPreemption, TokenBudgetBreakdown } from '@/types/run';
11
11
  import type { Providers, Callback, GraphNodeKeys } from '@/common';
12
12
  import type { SubagentTaskConfig } from '@/types/subagentTasks';
@@ -225,6 +225,8 @@ export type StandardGraphInput = {
225
225
  runId?: string;
226
226
  signal?: AbortSignal;
227
227
  agents: AgentInputs[];
228
+ /** Execution backend used to resolve the effective tool registry. */
229
+ toolExecution?: ToolExecutionConfig;
228
230
  langfuse?: LangfuseConfig;
229
231
  tokenCounter?: TokenCounter;
230
232
  indexTokenCountMap?: Record<string, number>;
@@ -1,9 +1,9 @@
1
- import type { StructuredToolInterface } from '@langchain/core/tools';
2
1
  import type { RunnableConfig, RunnableToolLike } from '@langchain/core/runnables';
2
+ import type { StructuredToolInterface } from '@langchain/core/tools';
3
3
  import type { ToolCall } from '@langchain/core/messages/tool';
4
+ import type { MessageContentComplex, RunStepResumeState, ToolErrorData } from './stream';
4
5
  import type { ToolOutputReferenceRegistry } from '@/tools/toolOutputReferences';
5
6
  import type { RunBreakerScope } from '@/llm/streamLimits';
6
- import type { MessageContentComplex, RunStepResumeState, ToolErrorData } from './stream';
7
7
  import type { HumanInTheLoopConfig } from './hitl';
8
8
  import type { LangfuseConfig } from './graph';
9
9
  import type { HookRegistry } from '@/hooks';
@@ -116,6 +116,8 @@ export type ToolNodeOptions = {
116
116
  errorHandler?: (data: ToolErrorData, metadata?: Record<string, unknown>) => Promise<boolean | void>;
117
117
  /** Tool registry for lazy computation of programmatic tools and tool search */
118
118
  toolRegistry?: LCToolRegistry;
119
+ /** Returns the owning agent's currently discovered deferred tool names. */
120
+ getDiscoveredToolNames?: () => readonly string[];
119
121
  /** Reference to Graph's sessions map for automatic session injection */
120
122
  sessions?: ToolSessionMap;
121
123
  /** Partition within `sessions` used by this agent's code tools. */
@@ -511,6 +513,18 @@ export type ToolCallRequest = {
511
513
  */
512
514
  runtimeSessionHint?: string;
513
515
  };
516
+ /**
517
+ * Serializable view of the active tools grouped by their effective caller
518
+ * capabilities. Event-driven hosts use this snapshot to preserve the SDK's
519
+ * live deferred-tool discovery state without reimplementing its policy.
520
+ */
521
+ export type CallerCapabilityProjectionSnapshot = {
522
+ version: 1;
523
+ directToolNames: string[];
524
+ codeExecutionToolNames: string[];
525
+ directOnlyToolNames: string[];
526
+ codeExecutionOnlyToolNames: string[];
527
+ };
514
528
  /** Batch request containing ALL tool calls for a graph step */
515
529
  export type ToolExecuteBatchRequest = {
516
530
  /** All tool calls from the AIMessage */
@@ -519,6 +533,11 @@ export type ToolExecuteBatchRequest = {
519
533
  userId?: string;
520
534
  /** Agent ID for context */
521
535
  agentId?: string;
536
+ /**
537
+ * SDK-owned snapshot of the active caller capability projection. Optional
538
+ * so older event handlers remain compatible with newer SDKs.
539
+ */
540
+ callerCapabilityProjection?: CallerCapabilityProjectionSnapshot;
522
541
  /** Runtime configurable from RunnableConfig (includes user, userMCPAuthMap, etc.) */
523
542
  configurable?: Record<string, unknown>;
524
543
  /** Runtime metadata from RunnableConfig (includes thread_id, run_id, provider, etc.) */
@@ -1084,6 +1103,15 @@ export type ToolExecutionConfig = {
1084
1103
  export type ProgrammaticCache = {
1085
1104
  toolMap: ToolMap;
1086
1105
  toolDefs: LCTool[];
1106
+ /** Actual outer runner name used for caller-policy diagnostics. */
1107
+ programmaticToolName?: string;
1108
+ /**
1109
+ * Known tools that cannot be invoked from programmatic execution. Kept
1110
+ * separate from `toolDefs` so the Programmatic Tool Manifest can be
1111
+ * validated before the execution runtime starts without exposing their
1112
+ * schemas to that runtime.
1113
+ */
1114
+ disallowedToolDefs?: LCTool[];
1087
1115
  /**
1088
1116
  * Hook context plumbed through by ToolNode for the local
1089
1117
  * programmatic-tool path so the in-process bridge can run
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@librechat/agents",
3
- "version": "3.6.9",
3
+ "version": "3.6.11",
4
4
  "reova": {
5
5
  "enabled": true,
6
6
  "endpoint": "https://telemetry.reo.dev/data"