@librechat/agents 3.6.10 → 3.6.12
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/agents/AgentContext.cjs +63 -10
- package/dist/cjs/agents/AgentContext.cjs.map +1 -1
- package/dist/cjs/graphs/Graph.cjs +48 -119
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/cjs/llm/contextPressureMeter.cjs +132 -0
- package/dist/cjs/llm/contextPressureMeter.cjs.map +1 -0
- package/dist/cjs/llm/invoke.cjs +46 -75
- package/dist/cjs/llm/invoke.cjs.map +1 -1
- package/dist/cjs/llm/prepareProviderRequest.cjs +108 -0
- package/dist/cjs/llm/prepareProviderRequest.cjs.map +1 -0
- package/dist/cjs/main.cjs +4 -0
- package/dist/cjs/messages/content.cjs +5 -4
- package/dist/cjs/messages/content.cjs.map +1 -1
- package/dist/cjs/stream.cjs +1 -0
- package/dist/cjs/stream.cjs.map +1 -1
- package/dist/cjs/tools/CallerCapabilities.cjs +31 -0
- package/dist/cjs/tools/CallerCapabilities.cjs.map +1 -1
- package/dist/cjs/tools/ToolNode.cjs +23 -6
- package/dist/cjs/tools/ToolNode.cjs.map +1 -1
- package/dist/cjs/tools/local/resolveLocalExecutionTools.cjs +26 -2
- package/dist/cjs/tools/local/resolveLocalExecutionTools.cjs.map +1 -1
- package/dist/esm/agents/AgentContext.mjs +65 -12
- package/dist/esm/agents/AgentContext.mjs.map +1 -1
- package/dist/esm/graphs/Graph.mjs +51 -122
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/llm/contextPressureMeter.mjs +132 -0
- package/dist/esm/llm/contextPressureMeter.mjs.map +1 -0
- package/dist/esm/llm/invoke.mjs +48 -75
- package/dist/esm/llm/invoke.mjs.map +1 -1
- package/dist/esm/llm/prepareProviderRequest.mjs +105 -0
- package/dist/esm/llm/prepareProviderRequest.mjs.map +1 -0
- package/dist/esm/main.mjs +3 -2
- package/dist/esm/messages/content.mjs +5 -4
- package/dist/esm/messages/content.mjs.map +1 -1
- package/dist/esm/stream.mjs +1 -0
- package/dist/esm/stream.mjs.map +1 -1
- package/dist/esm/tools/CallerCapabilities.mjs +29 -1
- package/dist/esm/tools/CallerCapabilities.mjs.map +1 -1
- package/dist/esm/tools/ToolNode.mjs +24 -7
- package/dist/esm/tools/ToolNode.mjs.map +1 -1
- package/dist/esm/tools/local/resolveLocalExecutionTools.mjs +26 -4
- package/dist/esm/tools/local/resolveLocalExecutionTools.mjs.map +1 -1
- package/dist/types/agents/AgentContext.d.ts +11 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/llm/contextPressureMeter.d.ts +30 -0
- package/dist/types/llm/invoke.d.ts +31 -33
- package/dist/types/llm/prepareProviderRequest.d.ts +55 -0
- package/dist/types/tools/CallerCapabilities.d.ts +13 -0
- package/dist/types/tools/ToolNode.d.ts +9 -1
- package/dist/types/tools/local/resolveLocalExecutionTools.d.ts +6 -0
- package/dist/types/types/tools.d.ts +17 -0
- package/package.json +1 -1
- package/src/agents/AgentContext.ts +157 -15
- package/src/graphs/Graph.ts +75 -279
- package/src/index.ts +8 -0
- package/src/llm/contextPressureMeter.ts +284 -0
- package/src/llm/invoke.ts +136 -296
- package/src/llm/prepareProviderRequest.ts +357 -0
- package/src/messages/content.ts +3 -3
- package/src/stream.ts +6 -0
- package/src/tools/CallerCapabilities.ts +68 -0
- package/src/tools/ToolNode.ts +47 -4
- package/src/tools/local/resolveLocalExecutionTools.ts +77 -3
- package/src/types/tools.ts +18 -0
|
@@ -3,7 +3,7 @@ import "../../common/index.mjs";
|
|
|
3
3
|
import { createLocalBashProgrammaticToolCallingTool, createLocalProgrammaticToolCallingTool } from "./LocalProgrammaticToolCalling.mjs";
|
|
4
4
|
import { createLocalBashExecutionTool, createLocalCodeExecutionTool } from "./LocalExecutionTools.mjs";
|
|
5
5
|
import { createLocalCodingToolBundle, createLocalCodingToolDefinitions, createLocalCodingTools } from "./LocalCodingTools.mjs";
|
|
6
|
-
import { createCloudflareCodingToolBundle, createCloudflareCodingTools, createCloudflareExecutionTool } from "../cloudflare/CloudflareSandboxTools.mjs";
|
|
6
|
+
import { CLOUDFLARE_CODING_TOOL_NAMES, createCloudflareCodingToolBundle, createCloudflareCodingTools, createCloudflareExecutionTool } from "../cloudflare/CloudflareSandboxTools.mjs";
|
|
7
7
|
import "../cloudflare/index.mjs";
|
|
8
8
|
import { allowsToolCaller, isToolDefinitionActive } from "../CallerCapabilities.mjs";
|
|
9
9
|
//#region src/tools/local/resolveLocalExecutionTools.ts
|
|
@@ -21,12 +21,18 @@ function isProgrammaticRunnerAutoBound(name, config) {
|
|
|
21
21
|
if (shouldUseCloudflareSandboxExecution(config)) return getSelectedCloudflareCodingToolNames(getCloudflareConfig(config)).has(name);
|
|
22
22
|
return shouldUseLocalExecution(config);
|
|
23
23
|
}
|
|
24
|
+
function isProgrammaticRunnerResolvedDirectly(name, config, hasExplicitBinding = false) {
|
|
25
|
+
if (isProgrammaticRunnerAutoBound(name, config)) return true;
|
|
26
|
+
if (!hasExplicitBinding || name !== "run_tools_with_code" && name !== "run_tools_with_bash") return false;
|
|
27
|
+
return (shouldUseLocalExecution(config) || shouldUseCloudflareSandboxExecution(config)) && !shouldIncludeCodingTools(config);
|
|
28
|
+
}
|
|
24
29
|
function getCloudflareConfig(config) {
|
|
25
30
|
if (config?.cloudflare == null) throw new Error("toolExecution.cloudflare is required when engine is \"cloudflare-sandbox\".");
|
|
26
31
|
return config.cloudflare;
|
|
27
32
|
}
|
|
28
33
|
function getSelectedCloudflareCodingToolNames(config) {
|
|
29
|
-
|
|
34
|
+
const requestedNames = new Set(config.codingToolNames ?? CLOUDFLARE_CODING_TOOL_NAMES);
|
|
35
|
+
return new Set(CLOUDFLARE_CODING_TOOL_NAMES.filter((name) => requestedNames.has(name)));
|
|
30
36
|
}
|
|
31
37
|
function filterCloudflareCodingToolAllowlist(tools, selectedNames) {
|
|
32
38
|
const existingTools = tools ?? [];
|
|
@@ -124,11 +130,19 @@ function resolveLocalToolRegistry(args) {
|
|
|
124
130
|
}
|
|
125
131
|
return registry;
|
|
126
132
|
}
|
|
133
|
+
function resolveLocalImplementationNames(toolNames, toolExecution) {
|
|
134
|
+
if (!shouldUseLocalExecution(toolExecution) && !shouldUseCloudflareSandboxExecution(toolExecution)) return /* @__PURE__ */ new Set();
|
|
135
|
+
if (shouldIncludeCodingTools(toolExecution)) return shouldUseCloudflareSandboxExecution(toolExecution) ? getSelectedCloudflareCodingToolNames(getCloudflareConfig(toolExecution)) : new Set(LOCAL_CODING_BUNDLE_NAMES);
|
|
136
|
+
const existingNames = new Set(toolNames);
|
|
137
|
+
return new Set([...CODE_EXECUTION_TOOLS].filter((name) => existingNames.has(name)));
|
|
138
|
+
}
|
|
127
139
|
function resolveLocalExecutionTools(args) {
|
|
128
140
|
const directToolNames = /* @__PURE__ */ new Set();
|
|
141
|
+
const localImplementationNames = resolveLocalImplementationNames(args.toolMap.keys(), args.toolExecution);
|
|
129
142
|
if (!shouldUseLocalExecution(args.toolExecution) && !shouldUseCloudflareSandboxExecution(args.toolExecution)) return {
|
|
130
143
|
toolMap: args.toolMap,
|
|
131
|
-
directToolNames
|
|
144
|
+
directToolNames,
|
|
145
|
+
localImplementationNames
|
|
132
146
|
};
|
|
133
147
|
const toolMap = new Map(args.toolMap);
|
|
134
148
|
let fileCheckpointer;
|
|
@@ -141,10 +155,12 @@ function resolveLocalExecutionTools(args) {
|
|
|
141
155
|
fileCheckpointer = bundle.checkpointer;
|
|
142
156
|
for (const cloudflareTool of bundle.tools) {
|
|
143
157
|
toolMap.set(cloudflareTool.name, cloudflareTool);
|
|
158
|
+
localImplementationNames.add(cloudflareTool.name);
|
|
144
159
|
addDirectToolName(directToolNames, cloudflareTool.name, args.toolRegistry);
|
|
145
160
|
}
|
|
146
161
|
} else for (const cloudflareTool of createCloudflareCodingTools(cloudflareConfig)) {
|
|
147
162
|
toolMap.set(cloudflareTool.name, cloudflareTool);
|
|
163
|
+
localImplementationNames.add(cloudflareTool.name);
|
|
148
164
|
addDirectToolName(directToolNames, cloudflareTool.name, args.toolRegistry);
|
|
149
165
|
}
|
|
150
166
|
}
|
|
@@ -155,11 +171,13 @@ function resolveLocalExecutionTools(args) {
|
|
|
155
171
|
const cloudflareTool = createCloudflareExecutionTool(name, cloudflareConfig);
|
|
156
172
|
if (cloudflareTool == null) continue;
|
|
157
173
|
toolMap.set(name, cloudflareTool);
|
|
174
|
+
localImplementationNames.add(name);
|
|
158
175
|
addDirectToolName(directToolNames, name, args.toolRegistry);
|
|
159
176
|
}
|
|
160
177
|
return {
|
|
161
178
|
toolMap,
|
|
162
179
|
directToolNames,
|
|
180
|
+
localImplementationNames,
|
|
163
181
|
fileCheckpointer
|
|
164
182
|
};
|
|
165
183
|
}
|
|
@@ -169,10 +187,12 @@ function resolveLocalExecutionTools(args) {
|
|
|
169
187
|
fileCheckpointer = bundle.checkpointer;
|
|
170
188
|
for (const localTool of bundle.tools) {
|
|
171
189
|
toolMap.set(localTool.name, localTool);
|
|
190
|
+
localImplementationNames.add(localTool.name);
|
|
172
191
|
addDirectToolName(directToolNames, localTool.name, args.toolRegistry);
|
|
173
192
|
}
|
|
174
193
|
} else for (const localTool of createLocalCodingTools(localConfig)) {
|
|
175
194
|
toolMap.set(localTool.name, localTool);
|
|
195
|
+
localImplementationNames.add(localTool.name);
|
|
176
196
|
addDirectToolName(directToolNames, localTool.name, args.toolRegistry);
|
|
177
197
|
}
|
|
178
198
|
const includeCodingTools = shouldIncludeCodingTools(args.toolExecution);
|
|
@@ -182,15 +202,17 @@ function resolveLocalExecutionTools(args) {
|
|
|
182
202
|
const localTool = createLocalExecutionTool(name, localConfig);
|
|
183
203
|
if (localTool == null) continue;
|
|
184
204
|
toolMap.set(name, localTool);
|
|
205
|
+
localImplementationNames.add(name);
|
|
185
206
|
addDirectToolName(directToolNames, name, args.toolRegistry);
|
|
186
207
|
}
|
|
187
208
|
return {
|
|
188
209
|
toolMap,
|
|
189
210
|
directToolNames,
|
|
211
|
+
localImplementationNames,
|
|
190
212
|
fileCheckpointer
|
|
191
213
|
};
|
|
192
214
|
}
|
|
193
215
|
//#endregion
|
|
194
|
-
export { isProgrammaticRunnerAutoBound, resolveLocalExecutionTools, resolveLocalToolRegistry, resolveLocalToolsForBinding };
|
|
216
|
+
export { isProgrammaticRunnerAutoBound, isProgrammaticRunnerResolvedDirectly, resolveLocalExecutionTools, resolveLocalImplementationNames, resolveLocalToolRegistry, resolveLocalToolsForBinding };
|
|
195
217
|
|
|
196
218
|
//# sourceMappingURL=resolveLocalExecutionTools.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveLocalExecutionTools.mjs","names":[],"sources":["../../../../src/tools/local/resolveLocalExecutionTools.ts"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"resolveLocalExecutionTools.mjs","names":[],"sources":["../../../../src/tools/local/resolveLocalExecutionTools.ts"],"mappings":";;;;;;;;;AAgDA,SAAS,wBAAwB,QAAyC;CACxE,OAAO,QAAQ,WAAW;AAC5B;AAEA,SAAS,oCACP,QACS;CACT,OAAO,QAAQ,WAAW;AAC5B;AAEA,SAAS,yBAAyB,QAAyC;CACzE,OACG,wBAAwB,MAAM,KAC7B,QAAQ,OAAO,uBAAuB,SACvC,oCAAoC,MAAM,KACzC,QAAQ,YAAY,uBAAuB;AAEjD;AAEA,SAAgB,8BACd,MACA,QACS;CACT,IACE,CAAC,yBAAyB,MAAM,KAC/B,SAAA,yBACC,SAAA,uBAEF,OAAO;CAET,IAAI,oCAAoC,MAAM,GAC5C,OAAO,qCACL,oBAAoB,MAAM,CAC5B,CAAC,CAAC,IAAI,IAAI;CAEZ,OAAO,wBAAwB,MAAM;AACvC;AAGA,SAAgB,qCACd,MACA,QACA,qBAA8B,OACrB;CACT,IAAI,8BAA8B,MAAM,MAAM,GAC5C,OAAO;CAET,IACE,CAAC,sBACA,SAAA,yBACC,SAAA,uBAEF,OAAO;CAET,QACG,wBAAw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EACrC,yBAAyB,IAAI,UAAU,IAAI;EAC3C,kBACE,iBACA,UAAU,MACV,KAAK,YACP;CACF;CAcJ,MAAM,qBAAqB,yBAAyB,KAAK,aAAa;CACtE,KAAK,MAAM,QAAQ,sBAAsB;EACvC,IAAI,oBAAoB;EACxB,IAAI,CAAC,QAAQ,IAAI,IAAI,GAAG;EAExB,MAAM,YAAY,yBAAyB,MAAM,WAAW;EAC5D,IAAI,aAAa,MACf;EAGF,QAAQ,IAAI,MAAM,SAAS;EAC3B,yBAAyB,IAAI,IAAI;EACjC,kBAAkB,iBAAiB,MAAM,KAAK,YAAY;CAC5D;CAEA,OAAO;EACL;EACA;EACA;EACA;CACF;AACF"}
|
|
@@ -221,7 +221,12 @@ export declare class AgentContext {
|
|
|
221
221
|
});
|
|
222
222
|
/** Builds the caller boundary and schemas for programmatic-only tools. */
|
|
223
223
|
private buildProgrammaticOnlyToolsInstructions;
|
|
224
|
+
private buildProgrammaticToolGroupInstructions;
|
|
224
225
|
private getProgrammaticToolInstructionTargets;
|
|
226
|
+
/** Whether ToolNode executes this runner in-process instead of via an event. */
|
|
227
|
+
private isProgrammaticRunnerDirectlyBound;
|
|
228
|
+
/** Mirrors ToolNode's executable implementation gate for direct runners. */
|
|
229
|
+
private getDirectProgrammaticCapabilityProjection;
|
|
225
230
|
private hasBoundTool;
|
|
226
231
|
/**
|
|
227
232
|
* Gets the system runnable, creating it lazily if needed.
|
|
@@ -297,6 +302,8 @@ export declare class AgentContext {
|
|
|
297
302
|
* token counts.
|
|
298
303
|
*/
|
|
299
304
|
updateTokenMapWithInstructions(baseTokenMap: Record<string, number>): void;
|
|
305
|
+
/** Event definitions with matching runtime caller/defer metadata applied. */
|
|
306
|
+
getEffectiveToolDefinitions(): t.LCTool[] | undefined;
|
|
300
307
|
/** Active tool definitions for token accounting (excludes deferred-and-undiscovered entries). */
|
|
301
308
|
private getActiveToolDefinitions;
|
|
302
309
|
/**
|
|
@@ -451,6 +458,10 @@ export declare class AgentContext {
|
|
|
451
458
|
markTokensStale(): void;
|
|
452
459
|
/** Returns a snapshot of the deferred tools discovered in this context. */
|
|
453
460
|
getDiscoveredTools(): string[];
|
|
461
|
+
/** Returns the live projection shared by prompt and event execution. */
|
|
462
|
+
private getCallerCapabilityProjection;
|
|
463
|
+
/** Returns the SDK-owned active caller projection for event-driven hosts. */
|
|
464
|
+
getCallerCapabilityProjectionSnapshot(): t.CallerCapabilityProjectionSnapshot;
|
|
454
465
|
/**
|
|
455
466
|
* Marks tools as discovered via tool search.
|
|
456
467
|
* Discovered tools will be included in the next model binding.
|
package/dist/types/index.d.ts
CHANGED
|
@@ -48,6 +48,8 @@ export type { SmoothItem, SmoothPiece } from './llm/stream/smoother';
|
|
|
48
48
|
export { FakeChatModel, createFakeStreamingLLM } from './llm/fake';
|
|
49
49
|
export { initializeModel } from './llm/init';
|
|
50
50
|
export { attemptInvoke, tryFallbackProviders } from './llm/invoke';
|
|
51
|
+
export { prepareProviderRequest } from './llm/prepareProviderRequest';
|
|
52
|
+
export type { PreparedProviderRequest, PrepareProviderRequestParams, ProviderMessageProjectionMode, ProviderPayloadMeasurement, ProviderRequestContext, } from './llm/prepareProviderRequest';
|
|
51
53
|
export { canSealPreempt } from './llm/preempt';
|
|
52
54
|
export { isThinkingEnabled, getMaxOutputTokensKey } from './llm/request';
|
|
53
55
|
export { DEFAULT_MAX_TOOL_CALL_ARG_BYTES, StreamLimitExceededError, resolveStreamLimits, } from './llm/streamLimits';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { BaseMessage } from '@langchain/core/messages';
|
|
2
|
+
import type { ProviderPayloadMeasurement } from '@/llm/prepareProviderRequest';
|
|
3
|
+
import type * as t from '@/types';
|
|
4
|
+
interface ContextPressureUsage {
|
|
5
|
+
contextBudget?: number;
|
|
6
|
+
effectiveInstructionTokens?: number;
|
|
7
|
+
remainingContextTokens?: number;
|
|
8
|
+
calibrationRatio?: number;
|
|
9
|
+
}
|
|
10
|
+
interface ContextPressureMeterParams {
|
|
11
|
+
tokenCounter?: t.TokenCounter;
|
|
12
|
+
sourceMessages: BaseMessage[];
|
|
13
|
+
retainedMessages: BaseMessage[];
|
|
14
|
+
indexTokenCountMap: Record<string, number | undefined>;
|
|
15
|
+
contextUsage?: ContextPressureUsage | null;
|
|
16
|
+
instructionTokens: number;
|
|
17
|
+
calibrationRatio: number;
|
|
18
|
+
}
|
|
19
|
+
interface ProviderPayloadMeasureOptions {
|
|
20
|
+
contextBudget?: number;
|
|
21
|
+
forceRawRecount?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface ContextPressureMeter {
|
|
24
|
+
trackProjection(before: BaseMessage[], after: BaseMessage[]): BaseMessage[];
|
|
25
|
+
trackClone(source: BaseMessage, clone: BaseMessage): void;
|
|
26
|
+
measure(messages: BaseMessage[], options?: ProviderPayloadMeasureOptions): ProviderPayloadMeasurement;
|
|
27
|
+
}
|
|
28
|
+
/** Measures repeated provider projections while tokenizing each message object once. */
|
|
29
|
+
export declare function createContextPressureMeter({ tokenCounter, sourceMessages, retainedMessages, indexTokenCountMap, contextUsage, instructionTokens, calibrationRatio, }: ContextPressureMeterParams): ContextPressureMeter;
|
|
30
|
+
export {};
|
|
@@ -2,18 +2,21 @@ import { AIMessageChunk } from '@langchain/core/messages';
|
|
|
2
2
|
import type { RunnableConfig } from '@langchain/core/runnables';
|
|
3
3
|
import type { BaseMessage } from '@langchain/core/messages';
|
|
4
4
|
import type { ToolOutputReferenceRegistry } from '@/tools/toolOutputReferences';
|
|
5
|
+
import type { PreparedProviderRequest } from '@/llm/prepareProviderRequest';
|
|
5
6
|
import type { StreamLimitState } from '@/llm/streamLimits';
|
|
6
7
|
import type { ContextOverflowContext } from '@/utils/errors';
|
|
7
8
|
import type * as t from '@/types';
|
|
8
9
|
import { ChatModelStreamHandler } from '@/stream';
|
|
9
10
|
import { Providers } from '@/common';
|
|
11
|
+
export { projectMessagesForProvider, resolveServingModelId, usesNativeOpenAIResponses, } from '@/llm/prepareProviderRequest';
|
|
12
|
+
export type { PreparedProviderRequest, PrepareProviderRequestParams, ProviderMessageProjectionMode, ProviderPayloadMeasurement, ProviderRequestContext, } from '@/llm/prepareProviderRequest';
|
|
10
13
|
/**
|
|
11
14
|
* Context passed to `attemptInvoke`. Matches the subset of Graph that
|
|
12
15
|
* `ChatModelStreamHandler.handle` needs *plus* the explicit
|
|
13
|
-
* `getOrCreateToolOutputRegistry()` accessor
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
16
|
+
* `getOrCreateToolOutputRegistry()` accessor used while preparing a
|
|
17
|
+
* provider request. Raw callers prepare inside `attemptInvoke`; Graph
|
|
18
|
+
* callers prepare before final payload measurement and pass the exact
|
|
19
|
+
* artifact through.
|
|
17
20
|
*
|
|
18
21
|
* The intersection is intentional: `Parameters<...>[3]` resolves
|
|
19
22
|
* indirectly through the stream handler's signature (which returns
|
|
@@ -46,26 +49,6 @@ export type InvokeContext = NonNullable<Parameters<ChatModelStreamHandler['handl
|
|
|
46
49
|
* limits key each model attempt separately.
|
|
47
50
|
*/
|
|
48
51
|
export type OnChunk = (chunk: AIMessageChunk, metadata?: Record<string, unknown>) => void | Promise<void>;
|
|
49
|
-
export declare function usesNativeOpenAIResponses(model: t.ChatModel, provider: Providers, callOptions?: unknown): boolean;
|
|
50
|
-
/**
|
|
51
|
-
* Produces the exact provider-facing message representation before a model
|
|
52
|
-
* adapter serializes it. This is shared by invocation and Graph's final budget
|
|
53
|
-
* guard so structured tool output cannot grow after the payload was measured.
|
|
54
|
-
*/
|
|
55
|
-
export declare function projectMessagesForProvider({ model, messages, provider, maxToolResultChars, callOptions, }: {
|
|
56
|
-
model: t.ChatModel;
|
|
57
|
-
messages: BaseMessage[];
|
|
58
|
-
provider: Providers;
|
|
59
|
-
maxToolResultChars?: number;
|
|
60
|
-
callOptions?: unknown;
|
|
61
|
-
}): BaseMessage[];
|
|
62
|
-
/**
|
|
63
|
-
* The serving model's id, read through the same wrapper stack
|
|
64
|
-
* `collectModelCallbackSources` walks — `bindTools` returns a
|
|
65
|
-
* `RunnableBinding` and a system runnable pipes a `RunnableSequence`, and
|
|
66
|
-
* neither exposes the chat model's `model` at the top level.
|
|
67
|
-
*/
|
|
68
|
-
export declare function resolveServingModelId(model: unknown): string | undefined;
|
|
69
52
|
/**
|
|
70
53
|
* Invokes a chat model with the given messages, handling both streaming and
|
|
71
54
|
* non-streaming paths.
|
|
@@ -75,10 +58,7 @@ export declare function resolveServingModelId(model: unknown): string | undefine
|
|
|
75
58
|
* Pass an `onChunk` callback to override this with custom chunk processing
|
|
76
59
|
* (e.g. summarization delta events).
|
|
77
60
|
*/
|
|
78
|
-
interface
|
|
79
|
-
model: t.ChatModel;
|
|
80
|
-
messages: BaseMessage[];
|
|
81
|
-
provider: Providers;
|
|
61
|
+
interface AttemptInvokeCommonParams {
|
|
82
62
|
context?: InvokeContext;
|
|
83
63
|
onChunk?: OnChunk;
|
|
84
64
|
/** Accounting owner for callers that deliberately pass no `context`
|
|
@@ -86,6 +66,17 @@ interface AttemptInvokeParams {
|
|
|
86
66
|
* for charge claims. */
|
|
87
67
|
streamLimitState?: StreamLimitState;
|
|
88
68
|
}
|
|
69
|
+
type AttemptInvokeParams = AttemptInvokeCommonParams & ({
|
|
70
|
+
request: PreparedProviderRequest;
|
|
71
|
+
model?: never;
|
|
72
|
+
messages?: never;
|
|
73
|
+
provider?: never;
|
|
74
|
+
} | {
|
|
75
|
+
request?: never;
|
|
76
|
+
model: t.ChatModel;
|
|
77
|
+
messages: BaseMessage[];
|
|
78
|
+
provider: Providers;
|
|
79
|
+
});
|
|
89
80
|
/**
|
|
90
81
|
* One model attempt. Stamps the attempt identity into callback metadata
|
|
91
82
|
* (see the generation-key notes in `streamLimits.ts`), leases the attempt's
|
|
@@ -122,7 +113,7 @@ export declare function getFallbackOverflowCandidates(error: unknown): FallbackO
|
|
|
122
113
|
* behind a later unrelated error would surface a dead end instead. Ordinary
|
|
123
114
|
* failures still throw last-error-wins.
|
|
124
115
|
*/
|
|
125
|
-
export declare function tryFallbackProviders({ fallbacks, tools, messages, config, primaryError, context, onChunk, streamLimitState, overflowContext, prepareProviderMessages, }: {
|
|
116
|
+
export declare function tryFallbackProviders({ fallbacks, tools, messages, config, primaryError, context, onChunk, streamLimitState, overflowContext, prepareProviderRequest: prepareFallbackRequest, prepareProviderMessages, }: {
|
|
126
117
|
fallbacks: t.FallbackConfig[];
|
|
127
118
|
tools?: t.GraphTools;
|
|
128
119
|
messages: BaseMessage[];
|
|
@@ -141,10 +132,18 @@ export declare function tryFallbackProviders({ fallbacks, tools, messages, confi
|
|
|
141
132
|
*/
|
|
142
133
|
overflowContext?: ContextOverflowContext;
|
|
143
134
|
/**
|
|
144
|
-
* Optional
|
|
145
|
-
*
|
|
146
|
-
* the fallback request is measured and sent.
|
|
135
|
+
* Optional exact-payload preparation used by Graph. The returned request is
|
|
136
|
+
* measured and sent without another provider projection.
|
|
147
137
|
*/
|
|
138
|
+
prepareProviderRequest?: (input: {
|
|
139
|
+
model: t.ChatModel;
|
|
140
|
+
messages: BaseMessage[];
|
|
141
|
+
provider: Providers;
|
|
142
|
+
clientOptions?: t.ClientOptions;
|
|
143
|
+
maxContextTokens?: number;
|
|
144
|
+
config?: RunnableConfig;
|
|
145
|
+
}) => PreparedProviderRequest | Promise<PreparedProviderRequest>;
|
|
146
|
+
/** @deprecated Return a `PreparedProviderRequest` instead. */
|
|
148
147
|
prepareProviderMessages?: (input: {
|
|
149
148
|
model: t.ChatModel;
|
|
150
149
|
messages: BaseMessage[];
|
|
@@ -154,4 +153,3 @@ export declare function tryFallbackProviders({ fallbacks, tools, messages, confi
|
|
|
154
153
|
config?: RunnableConfig;
|
|
155
154
|
}) => BaseMessage[] | Promise<BaseMessage[]>;
|
|
156
155
|
}): Promise<Partial<t.BaseGraphState> | undefined>;
|
|
157
|
-
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { RunnableConfig } from '@langchain/core/runnables';
|
|
2
|
+
import type { BaseMessage } from '@langchain/core/messages';
|
|
3
|
+
import type { ToolOutputReferenceRegistry } from '@/tools/toolOutputReferences';
|
|
4
|
+
import type * as t from '@/types';
|
|
5
|
+
import { Providers } from '@/common';
|
|
6
|
+
declare const preparedProviderRequestBrand: unique symbol;
|
|
7
|
+
export type ProviderMessageProjectionMode = 'chat-messages' | 'openai-responses';
|
|
8
|
+
export interface ProviderPayloadMeasurement {
|
|
9
|
+
readonly fits: boolean;
|
|
10
|
+
readonly projectedMessageTokens?: number;
|
|
11
|
+
readonly availableMessageTokens?: number;
|
|
12
|
+
readonly contextBudget?: number;
|
|
13
|
+
readonly effectiveInstructionTokens?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface PreparedProviderRequest {
|
|
16
|
+
readonly model: t.ChatModel;
|
|
17
|
+
readonly modelId?: string;
|
|
18
|
+
readonly provider: Providers;
|
|
19
|
+
readonly projectionMode: ProviderMessageProjectionMode;
|
|
20
|
+
readonly messages: BaseMessage[];
|
|
21
|
+
readonly measurement?: ProviderPayloadMeasurement;
|
|
22
|
+
readonly [preparedProviderRequestBrand]: true;
|
|
23
|
+
}
|
|
24
|
+
export interface ProviderRequestContext {
|
|
25
|
+
getOrCreateToolOutputRegistry?(): ToolOutputReferenceRegistry | undefined;
|
|
26
|
+
isRunProducedMessage?(message: BaseMessage): boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface PrepareProviderRequestParams {
|
|
29
|
+
model: t.ChatModel;
|
|
30
|
+
messages: BaseMessage[];
|
|
31
|
+
provider: Providers;
|
|
32
|
+
context?: ProviderRequestContext;
|
|
33
|
+
config?: RunnableConfig;
|
|
34
|
+
maxToolResultChars?: number;
|
|
35
|
+
measure?: (messages: BaseMessage[]) => ProviderPayloadMeasurement;
|
|
36
|
+
}
|
|
37
|
+
export declare function usesNativeOpenAIResponses(model: t.ChatModel, provider: Providers, callOptions?: unknown): boolean;
|
|
38
|
+
interface ProjectMessagesForProviderParams {
|
|
39
|
+
model: t.ChatModel;
|
|
40
|
+
messages: BaseMessage[];
|
|
41
|
+
provider: Providers;
|
|
42
|
+
maxToolResultChars?: number;
|
|
43
|
+
callOptions?: unknown;
|
|
44
|
+
}
|
|
45
|
+
/** Produces the provider-facing representation before adapter serialization. */
|
|
46
|
+
export declare function projectMessagesForProvider(params: ProjectMessagesForProviderParams): BaseMessage[];
|
|
47
|
+
/** Reads the serving model id through LangChain binding/sequence wrappers. */
|
|
48
|
+
export declare function resolveServingModelId(model: unknown): string | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Finalizes one provider request and measures the exact message array that
|
|
51
|
+
* will be passed to LangChain. Source messages remain untouched.
|
|
52
|
+
*/
|
|
53
|
+
export declare function prepareProviderRequest({ model, messages, provider, context, config, maxToolResultChars, measure, }: PrepareProviderRequestParams): PreparedProviderRequest;
|
|
54
|
+
export declare function assertPreparedProviderRequestFor(request: PreparedProviderRequest, model: t.ChatModel, provider: Providers, config?: RunnableConfig): void;
|
|
55
|
+
export {};
|
|
@@ -5,6 +5,19 @@ export type CallerCapabilityProjection = {
|
|
|
5
5
|
directOnlyTools: t.LCTool[];
|
|
6
6
|
codeExecutionOnlyTools: t.LCTool[];
|
|
7
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;
|
|
8
21
|
export declare function getAllowedCallers(toolDef: t.LCTool): readonly t.AllowedCaller[];
|
|
9
22
|
export declare function allowsToolCaller(toolDef: t.LCTool, caller: t.AllowedCaller): boolean;
|
|
10
23
|
export declare function isProgrammaticControlTool(name: string): boolean;
|
|
@@ -122,6 +122,10 @@ 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
|
+
/** 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;
|
|
125
129
|
/** Reads deferred-tool discovery state from the owning agent context. */
|
|
126
130
|
private getDiscoveredToolNames?;
|
|
127
131
|
/** Reference to Graph's sessions map for automatic session injection */
|
|
@@ -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, 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);
|
|
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,6 +261,10 @@ 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;
|
|
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;
|
|
260
268
|
/** Returns active tools projected by their effective caller capabilities. */
|
|
261
269
|
private getProgrammaticTools;
|
|
262
270
|
/**
|
|
@@ -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
|
|
@@ -15,6 +17,8 @@ type ResolveLocalToolsResult = {
|
|
|
15
17
|
fileCheckpointer?: t.LocalFileCheckpointer;
|
|
16
18
|
};
|
|
17
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;
|
|
18
22
|
export declare function resolveLocalToolsForBinding(args: {
|
|
19
23
|
tools?: t.GraphTools;
|
|
20
24
|
toolExecution?: t.ToolExecutionConfig;
|
|
@@ -25,6 +29,8 @@ export declare function resolveLocalToolRegistry(args: {
|
|
|
25
29
|
toolRegistry?: t.LCToolRegistry;
|
|
26
30
|
toolExecution?: t.ToolExecutionConfig;
|
|
27
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>;
|
|
28
34
|
export declare function resolveLocalExecutionTools(args: {
|
|
29
35
|
toolMap: t.ToolMap;
|
|
30
36
|
toolExecution?: t.ToolExecutionConfig;
|
|
@@ -513,6 +513,18 @@ export type ToolCallRequest = {
|
|
|
513
513
|
*/
|
|
514
514
|
runtimeSessionHint?: string;
|
|
515
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
|
+
};
|
|
516
528
|
/** Batch request containing ALL tool calls for a graph step */
|
|
517
529
|
export type ToolExecuteBatchRequest = {
|
|
518
530
|
/** All tool calls from the AIMessage */
|
|
@@ -521,6 +533,11 @@ export type ToolExecuteBatchRequest = {
|
|
|
521
533
|
userId?: string;
|
|
522
534
|
/** Agent ID for context */
|
|
523
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;
|
|
524
541
|
/** Runtime configurable from RunnableConfig (includes user, userMCPAuthMap, etc.) */
|
|
525
542
|
configurable?: Record<string, unknown>;
|
|
526
543
|
/** Runtime metadata from RunnableConfig (includes thread_id, run_id, provider, etc.) */
|