@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
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
createLocalProgrammaticToolCallingTool,
|
|
5
5
|
} from './LocalProgrammaticToolCalling';
|
|
6
6
|
import {
|
|
7
|
+
CLOUDFLARE_CODING_TOOL_NAMES,
|
|
7
8
|
createCloudflareCodingToolBundle,
|
|
8
9
|
createCloudflareCodingTools,
|
|
9
10
|
createCloudflareExecutionTool,
|
|
@@ -30,6 +31,8 @@ import {
|
|
|
30
31
|
type ResolveLocalToolsResult = {
|
|
31
32
|
toolMap: t.ToolMap;
|
|
32
33
|
directToolNames: Set<string>;
|
|
34
|
+
/** Names whose toolMap entries were created or replaced by this resolver. */
|
|
35
|
+
localImplementationNames: Set<string>;
|
|
33
36
|
/**
|
|
34
37
|
* Set when `local.fileCheckpointing === true` AND the auto-bind
|
|
35
38
|
* coding suite is in use. ToolNode stashes this on the node and
|
|
@@ -81,6 +84,29 @@ export function isProgrammaticRunnerAutoBound(
|
|
|
81
84
|
return shouldUseLocalExecution(config);
|
|
82
85
|
}
|
|
83
86
|
|
|
87
|
+
/** Mirrors whether resolver policy creates or replaces this runner locally. */
|
|
88
|
+
export function isProgrammaticRunnerResolvedDirectly(
|
|
89
|
+
name: string,
|
|
90
|
+
config?: t.ToolExecutionConfig,
|
|
91
|
+
hasExplicitBinding: boolean = false
|
|
92
|
+
): boolean {
|
|
93
|
+
if (isProgrammaticRunnerAutoBound(name, config)) {
|
|
94
|
+
return true;
|
|
95
|
+
}
|
|
96
|
+
if (
|
|
97
|
+
!hasExplicitBinding ||
|
|
98
|
+
(name !== Constants.PROGRAMMATIC_TOOL_CALLING &&
|
|
99
|
+
name !== Constants.BASH_PROGRAMMATIC_TOOL_CALLING)
|
|
100
|
+
) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
return (
|
|
104
|
+
(shouldUseLocalExecution(config) ||
|
|
105
|
+
shouldUseCloudflareSandboxExecution(config)) &&
|
|
106
|
+
!shouldIncludeCodingTools(config)
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
84
110
|
function getCloudflareConfig(
|
|
85
111
|
config?: t.ToolExecutionConfig
|
|
86
112
|
): t.CloudflareSandboxExecutionConfig {
|
|
@@ -95,7 +121,12 @@ function getCloudflareConfig(
|
|
|
95
121
|
function getSelectedCloudflareCodingToolNames(
|
|
96
122
|
config: t.CloudflareSandboxExecutionConfig
|
|
97
123
|
): Set<string> {
|
|
98
|
-
|
|
124
|
+
const requestedNames = new Set(
|
|
125
|
+
config.codingToolNames ?? CLOUDFLARE_CODING_TOOL_NAMES
|
|
126
|
+
);
|
|
127
|
+
return new Set(
|
|
128
|
+
CLOUDFLARE_CODING_TOOL_NAMES.filter((name) => requestedNames.has(name))
|
|
129
|
+
);
|
|
99
130
|
}
|
|
100
131
|
|
|
101
132
|
function filterCloudflareCodingToolAllowlist(
|
|
@@ -340,6 +371,28 @@ export function resolveLocalToolRegistry(args: {
|
|
|
340
371
|
return registry;
|
|
341
372
|
}
|
|
342
373
|
|
|
374
|
+
/** Names that this execution config creates or replaces in the local tool map. */
|
|
375
|
+
export function resolveLocalImplementationNames(
|
|
376
|
+
toolNames: Iterable<string>,
|
|
377
|
+
toolExecution?: t.ToolExecutionConfig
|
|
378
|
+
): Set<string> {
|
|
379
|
+
if (
|
|
380
|
+
!shouldUseLocalExecution(toolExecution) &&
|
|
381
|
+
!shouldUseCloudflareSandboxExecution(toolExecution)
|
|
382
|
+
) {
|
|
383
|
+
return new Set();
|
|
384
|
+
}
|
|
385
|
+
if (shouldIncludeCodingTools(toolExecution)) {
|
|
386
|
+
return shouldUseCloudflareSandboxExecution(toolExecution)
|
|
387
|
+
? getSelectedCloudflareCodingToolNames(getCloudflareConfig(toolExecution))
|
|
388
|
+
: new Set(LOCAL_CODING_BUNDLE_NAMES);
|
|
389
|
+
}
|
|
390
|
+
const existingNames = new Set(toolNames);
|
|
391
|
+
return new Set(
|
|
392
|
+
[...CODE_EXECUTION_TOOLS].filter((name) => existingNames.has(name))
|
|
393
|
+
);
|
|
394
|
+
}
|
|
395
|
+
|
|
343
396
|
export function resolveLocalExecutionTools(args: {
|
|
344
397
|
toolMap: t.ToolMap;
|
|
345
398
|
toolExecution?: t.ToolExecutionConfig;
|
|
@@ -355,6 +408,10 @@ export function resolveLocalExecutionTools(args: {
|
|
|
355
408
|
fileCheckpointer?: t.LocalFileCheckpointer;
|
|
356
409
|
}): ResolveLocalToolsResult {
|
|
357
410
|
const directToolNames = new Set<string>();
|
|
411
|
+
const localImplementationNames = resolveLocalImplementationNames(
|
|
412
|
+
args.toolMap.keys(),
|
|
413
|
+
args.toolExecution
|
|
414
|
+
);
|
|
358
415
|
if (
|
|
359
416
|
!shouldUseLocalExecution(args.toolExecution) &&
|
|
360
417
|
!shouldUseCloudflareSandboxExecution(args.toolExecution)
|
|
@@ -362,6 +419,7 @@ export function resolveLocalExecutionTools(args: {
|
|
|
362
419
|
return {
|
|
363
420
|
toolMap: args.toolMap,
|
|
364
421
|
directToolNames,
|
|
422
|
+
localImplementationNames,
|
|
365
423
|
};
|
|
366
424
|
}
|
|
367
425
|
|
|
@@ -384,6 +442,7 @@ export function resolveLocalExecutionTools(args: {
|
|
|
384
442
|
fileCheckpointer = bundle.checkpointer;
|
|
385
443
|
for (const cloudflareTool of bundle.tools) {
|
|
386
444
|
toolMap.set(cloudflareTool.name, cloudflareTool);
|
|
445
|
+
localImplementationNames.add(cloudflareTool.name);
|
|
387
446
|
addDirectToolName(
|
|
388
447
|
directToolNames,
|
|
389
448
|
cloudflareTool.name,
|
|
@@ -395,6 +454,7 @@ export function resolveLocalExecutionTools(args: {
|
|
|
395
454
|
cloudflareConfig
|
|
396
455
|
)) {
|
|
397
456
|
toolMap.set(cloudflareTool.name, cloudflareTool);
|
|
457
|
+
localImplementationNames.add(cloudflareTool.name);
|
|
398
458
|
addDirectToolName(
|
|
399
459
|
directToolNames,
|
|
400
460
|
cloudflareTool.name,
|
|
@@ -418,10 +478,16 @@ export function resolveLocalExecutionTools(args: {
|
|
|
418
478
|
}
|
|
419
479
|
|
|
420
480
|
toolMap.set(name, cloudflareTool);
|
|
481
|
+
localImplementationNames.add(name);
|
|
421
482
|
addDirectToolName(directToolNames, name, args.toolRegistry);
|
|
422
483
|
}
|
|
423
484
|
|
|
424
|
-
return {
|
|
485
|
+
return {
|
|
486
|
+
toolMap,
|
|
487
|
+
directToolNames,
|
|
488
|
+
localImplementationNames,
|
|
489
|
+
fileCheckpointer,
|
|
490
|
+
};
|
|
425
491
|
}
|
|
426
492
|
|
|
427
493
|
const localConfig = args.toolExecution?.local ?? {};
|
|
@@ -443,6 +509,7 @@ export function resolveLocalExecutionTools(args: {
|
|
|
443
509
|
fileCheckpointer = bundle.checkpointer;
|
|
444
510
|
for (const localTool of bundle.tools) {
|
|
445
511
|
toolMap.set(localTool.name, localTool);
|
|
512
|
+
localImplementationNames.add(localTool.name);
|
|
446
513
|
addDirectToolName(
|
|
447
514
|
directToolNames,
|
|
448
515
|
localTool.name,
|
|
@@ -452,6 +519,7 @@ export function resolveLocalExecutionTools(args: {
|
|
|
452
519
|
} else {
|
|
453
520
|
for (const localTool of createLocalCodingTools(localConfig)) {
|
|
454
521
|
toolMap.set(localTool.name, localTool);
|
|
522
|
+
localImplementationNames.add(localTool.name);
|
|
455
523
|
addDirectToolName(
|
|
456
524
|
directToolNames,
|
|
457
525
|
localTool.name,
|
|
@@ -482,8 +550,14 @@ export function resolveLocalExecutionTools(args: {
|
|
|
482
550
|
}
|
|
483
551
|
|
|
484
552
|
toolMap.set(name, localTool);
|
|
553
|
+
localImplementationNames.add(name);
|
|
485
554
|
addDirectToolName(directToolNames, name, args.toolRegistry);
|
|
486
555
|
}
|
|
487
556
|
|
|
488
|
-
return {
|
|
557
|
+
return {
|
|
558
|
+
toolMap,
|
|
559
|
+
directToolNames,
|
|
560
|
+
localImplementationNames,
|
|
561
|
+
fileCheckpointer,
|
|
562
|
+
};
|
|
489
563
|
}
|
package/src/types/tools.ts
CHANGED
|
@@ -557,6 +557,19 @@ export type ToolCallRequest = {
|
|
|
557
557
|
runtimeSessionHint?: string;
|
|
558
558
|
};
|
|
559
559
|
|
|
560
|
+
/**
|
|
561
|
+
* Serializable view of the active tools grouped by their effective caller
|
|
562
|
+
* capabilities. Event-driven hosts use this snapshot to preserve the SDK's
|
|
563
|
+
* live deferred-tool discovery state without reimplementing its policy.
|
|
564
|
+
*/
|
|
565
|
+
export type CallerCapabilityProjectionSnapshot = {
|
|
566
|
+
version: 1;
|
|
567
|
+
directToolNames: string[];
|
|
568
|
+
codeExecutionToolNames: string[];
|
|
569
|
+
directOnlyToolNames: string[];
|
|
570
|
+
codeExecutionOnlyToolNames: string[];
|
|
571
|
+
};
|
|
572
|
+
|
|
560
573
|
/** Batch request containing ALL tool calls for a graph step */
|
|
561
574
|
export type ToolExecuteBatchRequest = {
|
|
562
575
|
/** All tool calls from the AIMessage */
|
|
@@ -565,6 +578,11 @@ export type ToolExecuteBatchRequest = {
|
|
|
565
578
|
userId?: string;
|
|
566
579
|
/** Agent ID for context */
|
|
567
580
|
agentId?: string;
|
|
581
|
+
/**
|
|
582
|
+
* SDK-owned snapshot of the active caller capability projection. Optional
|
|
583
|
+
* so older event handlers remain compatible with newer SDKs.
|
|
584
|
+
*/
|
|
585
|
+
callerCapabilityProjection?: CallerCapabilityProjectionSnapshot;
|
|
568
586
|
/** Runtime configurable from RunnableConfig (includes user, userMCPAuthMap, etc.) */
|
|
569
587
|
configurable?: Record<string, unknown>;
|
|
570
588
|
/** Runtime metadata from RunnableConfig (includes thread_id, run_id, provider, etc.) */
|