deepagents 1.7.5 → 1.8.0
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/README.md +10 -1
- package/dist/index.cjs +949 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +339 -152
- package/dist/index.d.ts +339 -152
- package/dist/index.js +943 -19
- package/dist/index.js.map +1 -1
- package/package.json +9 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as langchain from "langchain";
|
|
2
|
-
import { AgentMiddleware, AgentMiddleware as AgentMiddleware$1, AgentTypeConfig, HumanMessage, InferMiddlewareStates, InterruptOnConfig, ReactAgent, ResponseFormat, ResponseFormatUndefined, StructuredTool, SystemMessage, ToolMessage } from "langchain";
|
|
2
|
+
import { AgentMiddleware, AgentMiddleware as AgentMiddleware$1, AgentTypeConfig, HumanMessage, InferMiddlewareStates, InterruptOnConfig, ProviderStrategy, ReactAgent, ResponseFormat, ResponseFormatUndefined, StructuredTool, SystemMessage, ToolMessage, ToolStrategy } from "langchain";
|
|
3
3
|
import { Runnable } from "@langchain/core/runnables";
|
|
4
4
|
import * as _langchain_langgraph0 from "@langchain/langgraph";
|
|
5
5
|
import { AnnotationRoot, Command, ReducedValue, StateSchema } from "@langchain/langgraph";
|
|
@@ -10,11 +10,10 @@ import { z as z$1 } from "zod";
|
|
|
10
10
|
import * as zod_v30 from "zod/v3";
|
|
11
11
|
import { BaseCheckpointSaver, BaseStore } from "@langchain/langgraph-checkpoint";
|
|
12
12
|
import * as zod_v4_core0 from "zod/v4/core";
|
|
13
|
-
import * as _langchain_core_language_models_base0 from "@langchain/core/language_models/base";
|
|
14
|
-
import { BaseLanguageModel, LanguageModelLike } from "@langchain/core/language_models/base";
|
|
15
13
|
import * as _langchain_core_tools0 from "@langchain/core/tools";
|
|
16
14
|
import { ClientTool, ServerTool, StructuredTool as StructuredTool$1 } from "@langchain/core/tools";
|
|
17
|
-
import "@langchain/core/language_models/
|
|
15
|
+
import { BaseLanguageModel, LanguageModelLike } from "@langchain/core/language_models/base";
|
|
16
|
+
import { BaseChatModel } from "@langchain/core/language_models/chat_models";
|
|
18
17
|
import { InteropZodObject } from "@langchain/core/utils/types";
|
|
19
18
|
|
|
20
19
|
//#region src/backends/protocol.d.ts
|
|
@@ -484,13 +483,13 @@ declare function createFilesystemMiddleware(options?: FilesystemMiddlewareOption
|
|
|
484
483
|
limit?: unknown;
|
|
485
484
|
}, string, "read_file"> | langchain.DynamicStructuredTool<z.ZodObject<{
|
|
486
485
|
file_path: z.ZodString;
|
|
487
|
-
content: z.ZodString
|
|
486
|
+
content: z.ZodDefault<z.ZodString>;
|
|
488
487
|
}, z.core.$strip>, {
|
|
489
488
|
file_path: string;
|
|
490
489
|
content: string;
|
|
491
490
|
}, {
|
|
492
491
|
file_path: string;
|
|
493
|
-
content
|
|
492
|
+
content?: string | undefined;
|
|
494
493
|
}, string | ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>> | Command<unknown, {
|
|
495
494
|
files: Record<string, FileData>;
|
|
496
495
|
messages: ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>>[];
|
|
@@ -1009,6 +1008,122 @@ declare function createSkillsMiddleware(options: SkillsMiddlewareOptions): Agent
|
|
|
1009
1008
|
files: ReducedValue<FilesRecord | undefined, FilesRecordUpdate | undefined>;
|
|
1010
1009
|
}>, undefined, unknown, readonly (_langchain_core_tools0.ClientTool | _langchain_core_tools0.ServerTool)[]>;
|
|
1011
1010
|
//#endregion
|
|
1011
|
+
//#region src/middleware/summarization.d.ts
|
|
1012
|
+
/**
|
|
1013
|
+
* Context size specification for summarization triggers and retention policies.
|
|
1014
|
+
*/
|
|
1015
|
+
interface ContextSize {
|
|
1016
|
+
/** Type of context measurement */
|
|
1017
|
+
type: "messages" | "tokens" | "fraction";
|
|
1018
|
+
/** Threshold value */
|
|
1019
|
+
value: number;
|
|
1020
|
+
}
|
|
1021
|
+
/**
|
|
1022
|
+
* Settings for truncating large tool arguments in old messages.
|
|
1023
|
+
*/
|
|
1024
|
+
interface TruncateArgsSettings {
|
|
1025
|
+
/**
|
|
1026
|
+
* Threshold to trigger argument truncation.
|
|
1027
|
+
* If not provided, truncation is disabled.
|
|
1028
|
+
*/
|
|
1029
|
+
trigger?: ContextSize;
|
|
1030
|
+
/**
|
|
1031
|
+
* Context retention policy for message truncation.
|
|
1032
|
+
* Defaults to keeping last 20 messages.
|
|
1033
|
+
*/
|
|
1034
|
+
keep?: ContextSize;
|
|
1035
|
+
/**
|
|
1036
|
+
* Maximum character length for tool arguments before truncation.
|
|
1037
|
+
* Defaults to 2000.
|
|
1038
|
+
*/
|
|
1039
|
+
maxLength?: number;
|
|
1040
|
+
/**
|
|
1041
|
+
* Text to replace truncated arguments with.
|
|
1042
|
+
* Defaults to "...(argument truncated)".
|
|
1043
|
+
*/
|
|
1044
|
+
truncationText?: string;
|
|
1045
|
+
}
|
|
1046
|
+
/**
|
|
1047
|
+
* Options for the summarization middleware.
|
|
1048
|
+
*/
|
|
1049
|
+
interface SummarizationMiddlewareOptions {
|
|
1050
|
+
/**
|
|
1051
|
+
* The language model to use for generating summaries.
|
|
1052
|
+
* Can be a model string (e.g., "gpt-4o-mini") or a language model instance.
|
|
1053
|
+
*/
|
|
1054
|
+
model: string | BaseChatModel | BaseLanguageModel;
|
|
1055
|
+
/**
|
|
1056
|
+
* Backend instance or factory for persisting conversation history.
|
|
1057
|
+
*/
|
|
1058
|
+
backend: BackendProtocol | BackendFactory | ((config: {
|
|
1059
|
+
state: unknown;
|
|
1060
|
+
store?: BaseStore;
|
|
1061
|
+
}) => StateBackend);
|
|
1062
|
+
/**
|
|
1063
|
+
* Threshold(s) that trigger summarization.
|
|
1064
|
+
* Can be a single ContextSize or an array for multiple triggers.
|
|
1065
|
+
*/
|
|
1066
|
+
trigger?: ContextSize | ContextSize[];
|
|
1067
|
+
/**
|
|
1068
|
+
* Context retention policy after summarization.
|
|
1069
|
+
* Defaults to keeping last 20 messages.
|
|
1070
|
+
*/
|
|
1071
|
+
keep?: ContextSize;
|
|
1072
|
+
/**
|
|
1073
|
+
* Prompt template for generating summaries.
|
|
1074
|
+
*/
|
|
1075
|
+
summaryPrompt?: string;
|
|
1076
|
+
/**
|
|
1077
|
+
* Max tokens to include when generating summary.
|
|
1078
|
+
* Defaults to 4000.
|
|
1079
|
+
*/
|
|
1080
|
+
trimTokensToSummarize?: number;
|
|
1081
|
+
/**
|
|
1082
|
+
* Path prefix for storing conversation history.
|
|
1083
|
+
* Defaults to "/conversation_history".
|
|
1084
|
+
*/
|
|
1085
|
+
historyPathPrefix?: string;
|
|
1086
|
+
/**
|
|
1087
|
+
* Settings for truncating large tool arguments in old messages.
|
|
1088
|
+
* If not provided, argument truncation is disabled.
|
|
1089
|
+
*/
|
|
1090
|
+
truncateArgsSettings?: TruncateArgsSettings;
|
|
1091
|
+
}
|
|
1092
|
+
/**
|
|
1093
|
+
* Compute summarization defaults based on model profile.
|
|
1094
|
+
* Mirrors Python's `_compute_summarization_defaults`.
|
|
1095
|
+
*
|
|
1096
|
+
* If the model has a profile with `maxInputTokens`, uses fraction-based
|
|
1097
|
+
* settings. Otherwise, uses fixed token/message counts.
|
|
1098
|
+
*
|
|
1099
|
+
* @param resolvedModel - The resolved chat model instance.
|
|
1100
|
+
*/
|
|
1101
|
+
declare function computeSummarizationDefaults(resolvedModel: BaseChatModel): {
|
|
1102
|
+
trigger: ContextSize;
|
|
1103
|
+
keep: ContextSize;
|
|
1104
|
+
truncateArgsSettings: TruncateArgsSettings;
|
|
1105
|
+
};
|
|
1106
|
+
/**
|
|
1107
|
+
* Create summarization middleware with backend support for conversation history offloading.
|
|
1108
|
+
*
|
|
1109
|
+
* This middleware:
|
|
1110
|
+
* 1. Monitors conversation length against configured thresholds
|
|
1111
|
+
* 2. When triggered, offloads old messages to backend storage
|
|
1112
|
+
* 3. Generates a summary of offloaded messages
|
|
1113
|
+
* 4. Replaces old messages with the summary, preserving recent context
|
|
1114
|
+
*
|
|
1115
|
+
* @param options - Configuration options
|
|
1116
|
+
* @returns AgentMiddleware for summarization and history offloading
|
|
1117
|
+
*/
|
|
1118
|
+
declare function createSummarizationMiddleware(options: SummarizationMiddlewareOptions): AgentMiddleware<z$1.ZodObject<{
|
|
1119
|
+
_summarizationSessionId: z$1.ZodOptional<z$1.ZodString>;
|
|
1120
|
+
_summarizationEvent: z$1.ZodOptional<z$1.ZodObject<{
|
|
1121
|
+
cutoffIndex: z$1.ZodNumber;
|
|
1122
|
+
summaryMessage: z$1.ZodCustom<HumanMessage<_messages.MessageStructure<_messages.MessageToolSet>>, HumanMessage<_messages.MessageStructure<_messages.MessageToolSet>>>;
|
|
1123
|
+
filePath: z$1.ZodNullable<z$1.ZodString>;
|
|
1124
|
+
}, z$1.core.$strip>>;
|
|
1125
|
+
}, z$1.core.$strip>, undefined, unknown, readonly (ClientTool | ServerTool)[]>;
|
|
1126
|
+
//#endregion
|
|
1012
1127
|
//#region src/backends/store.d.ts
|
|
1013
1128
|
/**
|
|
1014
1129
|
* Backend that stores files in LangGraph's BaseStore (persistent).
|
|
@@ -1127,8 +1242,8 @@ declare class StoreBackend implements BackendProtocol {
|
|
|
1127
1242
|
* as plain text, and metadata (timestamps) are derived from filesystem stats.
|
|
1128
1243
|
*/
|
|
1129
1244
|
declare class FilesystemBackend implements BackendProtocol {
|
|
1130
|
-
|
|
1131
|
-
|
|
1245
|
+
protected cwd: string;
|
|
1246
|
+
protected virtualMode: boolean;
|
|
1132
1247
|
private maxFileSizeBytes;
|
|
1133
1248
|
constructor(options?: {
|
|
1134
1249
|
rootDir?: string;
|
|
@@ -1332,6 +1447,175 @@ declare class CompositeBackend implements BackendProtocol {
|
|
|
1332
1447
|
downloadFiles(paths: string[]): Promise<FileDownloadResponse[]>;
|
|
1333
1448
|
}
|
|
1334
1449
|
//#endregion
|
|
1450
|
+
//#region src/backends/local-shell.d.ts
|
|
1451
|
+
/**
|
|
1452
|
+
* Options for creating a LocalShellBackend instance.
|
|
1453
|
+
*/
|
|
1454
|
+
interface LocalShellBackendOptions {
|
|
1455
|
+
/**
|
|
1456
|
+
* Working directory for both filesystem operations and shell commands.
|
|
1457
|
+
* @defaultValue `process.cwd()`
|
|
1458
|
+
*/
|
|
1459
|
+
rootDir?: string;
|
|
1460
|
+
/**
|
|
1461
|
+
* Enable virtual path mode for filesystem operations.
|
|
1462
|
+
* When true, treats rootDir as a virtual root filesystem.
|
|
1463
|
+
* Does NOT restrict shell commands.
|
|
1464
|
+
* @defaultValue `false`
|
|
1465
|
+
*/
|
|
1466
|
+
virtualMode?: boolean;
|
|
1467
|
+
/**
|
|
1468
|
+
* Maximum time in seconds to wait for shell command execution.
|
|
1469
|
+
* Commands exceeding this timeout will be terminated.
|
|
1470
|
+
* @defaultValue `120`
|
|
1471
|
+
*/
|
|
1472
|
+
timeout?: number;
|
|
1473
|
+
/**
|
|
1474
|
+
* Maximum number of bytes to capture from command output.
|
|
1475
|
+
* Output exceeding this limit will be truncated.
|
|
1476
|
+
* @defaultValue `100_000`
|
|
1477
|
+
*/
|
|
1478
|
+
maxOutputBytes?: number;
|
|
1479
|
+
/**
|
|
1480
|
+
* Environment variables for shell commands. If undefined, starts with an empty
|
|
1481
|
+
* environment (unless inheritEnv is true).
|
|
1482
|
+
* @defaultValue `undefined`
|
|
1483
|
+
*/
|
|
1484
|
+
env?: Record<string, string>;
|
|
1485
|
+
/**
|
|
1486
|
+
* Whether to inherit the parent process's environment variables.
|
|
1487
|
+
* When false, only variables in env dict are available.
|
|
1488
|
+
* When true, inherits all process.env variables and applies env overrides.
|
|
1489
|
+
* @defaultValue `false`
|
|
1490
|
+
*/
|
|
1491
|
+
inheritEnv?: boolean;
|
|
1492
|
+
/**
|
|
1493
|
+
* Files to create on disk during `create()`.
|
|
1494
|
+
* Keys are file paths (resolved via the backend's path handling),
|
|
1495
|
+
* values are string content.
|
|
1496
|
+
* @defaultValue `undefined`
|
|
1497
|
+
*/
|
|
1498
|
+
initialFiles?: Record<string, string>;
|
|
1499
|
+
}
|
|
1500
|
+
/**
|
|
1501
|
+
* Filesystem backend with unrestricted local shell command execution.
|
|
1502
|
+
*
|
|
1503
|
+
* This backend extends FilesystemBackend to add shell command execution
|
|
1504
|
+
* capabilities. Commands are executed directly on the host system without any
|
|
1505
|
+
* sandboxing, process isolation, or security restrictions.
|
|
1506
|
+
*
|
|
1507
|
+
* **Security Warning:**
|
|
1508
|
+
* This backend grants agents BOTH direct filesystem access AND unrestricted
|
|
1509
|
+
* shell execution on your local machine. Use with extreme caution and only in
|
|
1510
|
+
* appropriate environments.
|
|
1511
|
+
*
|
|
1512
|
+
* **Appropriate use cases:**
|
|
1513
|
+
* - Local development CLIs (coding assistants, development tools)
|
|
1514
|
+
* - Personal development environments where you trust the agent's code
|
|
1515
|
+
* - CI/CD pipelines with proper secret management
|
|
1516
|
+
*
|
|
1517
|
+
* **Inappropriate use cases:**
|
|
1518
|
+
* - Production environments (e.g., web servers, APIs, multi-tenant systems)
|
|
1519
|
+
* - Processing untrusted user input or executing untrusted code
|
|
1520
|
+
*
|
|
1521
|
+
* Use StateBackend, StoreBackend, or extend BaseSandbox for production.
|
|
1522
|
+
*
|
|
1523
|
+
* @example
|
|
1524
|
+
* ```typescript
|
|
1525
|
+
* import { LocalShellBackend } from "@langchain/deepagents";
|
|
1526
|
+
*
|
|
1527
|
+
* // Create backend with explicit environment
|
|
1528
|
+
* const backend = new LocalShellBackend({
|
|
1529
|
+
* rootDir: "/home/user/project",
|
|
1530
|
+
* env: { PATH: "/usr/bin:/bin" },
|
|
1531
|
+
* });
|
|
1532
|
+
*
|
|
1533
|
+
* // Execute shell commands (runs directly on host)
|
|
1534
|
+
* const result = await backend.execute("ls -la");
|
|
1535
|
+
* console.log(result.output);
|
|
1536
|
+
* console.log(result.exitCode);
|
|
1537
|
+
*
|
|
1538
|
+
* // Use filesystem operations (inherited from FilesystemBackend)
|
|
1539
|
+
* const content = await backend.read("/README.md");
|
|
1540
|
+
* await backend.write("/output.txt", "Hello world");
|
|
1541
|
+
*
|
|
1542
|
+
* // Inherit all environment variables
|
|
1543
|
+
* const backend2 = new LocalShellBackend({
|
|
1544
|
+
* rootDir: "/home/user/project",
|
|
1545
|
+
* inheritEnv: true,
|
|
1546
|
+
* });
|
|
1547
|
+
* ```
|
|
1548
|
+
*/
|
|
1549
|
+
declare class LocalShellBackend extends FilesystemBackend implements SandboxBackendProtocol {
|
|
1550
|
+
#private;
|
|
1551
|
+
constructor(options?: LocalShellBackendOptions);
|
|
1552
|
+
/** Unique identifier for this backend instance (format: "local-{random_hex}"). */
|
|
1553
|
+
get id(): string;
|
|
1554
|
+
/** Whether the backend has been initialized and is ready to use. */
|
|
1555
|
+
get isInitialized(): boolean;
|
|
1556
|
+
/** Alias for `isInitialized`, matching the standard sandbox interface. */
|
|
1557
|
+
get isRunning(): boolean;
|
|
1558
|
+
/**
|
|
1559
|
+
* Initialize the backend by ensuring the rootDir exists.
|
|
1560
|
+
*
|
|
1561
|
+
* Creates the rootDir (and any parent directories) if it does not already
|
|
1562
|
+
* exist. Safe to call on an existing directory. Must be called before
|
|
1563
|
+
* `execute()`, or use the static `LocalShellBackend.create()` factory.
|
|
1564
|
+
*
|
|
1565
|
+
* @throws {SandboxError} If already initialized (`ALREADY_INITIALIZED`)
|
|
1566
|
+
*/
|
|
1567
|
+
initialize(): Promise<void>;
|
|
1568
|
+
/**
|
|
1569
|
+
* Mark the backend as no longer running.
|
|
1570
|
+
*
|
|
1571
|
+
* For local shell backends there is no remote resource to tear down,
|
|
1572
|
+
* so this simply flips the `isRunning` / `isInitialized` flag.
|
|
1573
|
+
*/
|
|
1574
|
+
close(): Promise<void>;
|
|
1575
|
+
/**
|
|
1576
|
+
* Read a file, adapting error messages to the standard sandbox format.
|
|
1577
|
+
*/
|
|
1578
|
+
read(filePath: string, offset?: number, limit?: number): Promise<string>;
|
|
1579
|
+
/**
|
|
1580
|
+
* Edit a file, adapting error messages to the standard sandbox format.
|
|
1581
|
+
*/
|
|
1582
|
+
edit(filePath: string, oldString: string, newString: string, replaceAll?: boolean): Promise<EditResult>;
|
|
1583
|
+
/**
|
|
1584
|
+
* List directory contents, returning paths relative to rootDir.
|
|
1585
|
+
*/
|
|
1586
|
+
lsInfo(dirPath: string): Promise<FileInfo[]>;
|
|
1587
|
+
/**
|
|
1588
|
+
* Glob matching that returns relative paths and includes directories.
|
|
1589
|
+
*/
|
|
1590
|
+
globInfo(pattern: string, searchPath?: string): Promise<FileInfo[]>;
|
|
1591
|
+
/**
|
|
1592
|
+
* Execute a shell command directly on the host system.
|
|
1593
|
+
*
|
|
1594
|
+
* Commands are executed directly on your host system using `spawn()`
|
|
1595
|
+
* with `shell: true`. There is NO sandboxing, isolation, or security
|
|
1596
|
+
* restrictions. The command runs with your user's full permissions.
|
|
1597
|
+
*
|
|
1598
|
+
* The command is executed using the system shell with the working directory
|
|
1599
|
+
* set to the backend's rootDir. Stdout and stderr are combined into a single
|
|
1600
|
+
* output stream, with stderr lines prefixed with `[stderr]`.
|
|
1601
|
+
*
|
|
1602
|
+
* @param command - Shell command string to execute
|
|
1603
|
+
* @returns ExecuteResponse containing output, exit code, and truncation flag
|
|
1604
|
+
*/
|
|
1605
|
+
execute(command: string): Promise<ExecuteResponse>;
|
|
1606
|
+
/**
|
|
1607
|
+
* Create and initialize a new LocalShellBackend in one step.
|
|
1608
|
+
*
|
|
1609
|
+
* This is the recommended way to create a backend when the rootDir may
|
|
1610
|
+
* not exist yet. It combines construction and initialization (ensuring
|
|
1611
|
+
* rootDir exists) into a single async operation.
|
|
1612
|
+
*
|
|
1613
|
+
* @param options - Configuration options for the backend
|
|
1614
|
+
* @returns An initialized and ready-to-use backend
|
|
1615
|
+
*/
|
|
1616
|
+
static create(options?: LocalShellBackendOptions): Promise<LocalShellBackend>;
|
|
1617
|
+
}
|
|
1618
|
+
//#endregion
|
|
1335
1619
|
//#region src/backends/sandbox.d.ts
|
|
1336
1620
|
/**
|
|
1337
1621
|
* Base sandbox implementation with execute() as the only abstract method.
|
|
@@ -1435,6 +1719,9 @@ declare abstract class BaseSandbox implements SandboxBackendProtocol {
|
|
|
1435
1719
|
//#endregion
|
|
1436
1720
|
//#region src/types.d.ts
|
|
1437
1721
|
type AnyAnnotationRoot = AnnotationRoot<any>;
|
|
1722
|
+
interface TypedToolStrategy<T = unknown> extends Array<ToolStrategy<any>> {
|
|
1723
|
+
_schemaType?: T;
|
|
1724
|
+
}
|
|
1438
1725
|
/**
|
|
1439
1726
|
* Helper type to extract middleware from a SubAgent definition
|
|
1440
1727
|
* Handles both mutable and readonly middleware arrays
|
|
@@ -1454,6 +1741,36 @@ type InferSubAgentMiddlewareStates<T extends readonly (SubAgent | CompiledSubAge
|
|
|
1454
1741
|
* Combined state type including custom middleware and subagent middleware states
|
|
1455
1742
|
*/
|
|
1456
1743
|
type MergedDeepAgentState<TMiddleware extends readonly AgentMiddleware[], TSubagents extends readonly (SubAgent | CompiledSubAgent)[]> = InferMiddlewareStates<TMiddleware> & InferSubAgentMiddlewareStates<TSubagents>;
|
|
1744
|
+
/**
|
|
1745
|
+
* Union of all response format types accepted by `createDeepAgent`.
|
|
1746
|
+
*
|
|
1747
|
+
* Matches the formats supported by LangChain's `createAgent`:
|
|
1748
|
+
* - `ToolStrategy<T>` — from `ToolStrategy.fromSchema(schema)`
|
|
1749
|
+
* - `ProviderStrategy<T>` — from `providerStrategy(schema)`
|
|
1750
|
+
* - `TypedToolStrategy<T>` — from `toolStrategy(schema)`
|
|
1751
|
+
* - `ResponseFormat` — the base union of the above single-strategy types
|
|
1752
|
+
*/
|
|
1753
|
+
type SupportedResponseFormat = ResponseFormat | TypedToolStrategy<any>;
|
|
1754
|
+
/**
|
|
1755
|
+
* Utility type to extract the parsed response type from a ResponseFormat strategy.
|
|
1756
|
+
*
|
|
1757
|
+
* Maps `ToolStrategy<T>`, `ProviderStrategy<T>`, and `TypedToolStrategy<T>` to `T`
|
|
1758
|
+
* (the parsed output type), so that `structuredResponse` is correctly typed as the
|
|
1759
|
+
* schema's inferred type rather than the strategy wrapper.
|
|
1760
|
+
*
|
|
1761
|
+
* When no `responseFormat` is provided (i.e. `T` defaults to the full
|
|
1762
|
+
* `SupportedResponseFormat` union), this resolves to `ResponseFormatUndefined` so
|
|
1763
|
+
* that `structuredResponse` is excluded from the agent's output state.
|
|
1764
|
+
*
|
|
1765
|
+
* @example
|
|
1766
|
+
* ```typescript
|
|
1767
|
+
* type T1 = InferStructuredResponse<ToolStrategy<{ city: string }>>; // { city: string }
|
|
1768
|
+
* type T2 = InferStructuredResponse<ProviderStrategy<{ answer: string }>>; // { answer: string }
|
|
1769
|
+
* type T3 = InferStructuredResponse<TypedToolStrategy<{ city: string }>>; // { city: string }
|
|
1770
|
+
* type T4 = InferStructuredResponse<SupportedResponseFormat>; // ResponseFormatUndefined (default/unset)
|
|
1771
|
+
* ```
|
|
1772
|
+
*/
|
|
1773
|
+
type InferStructuredResponse<T extends SupportedResponseFormat> = SupportedResponseFormat extends T ? ResponseFormatUndefined : T extends TypedToolStrategy<infer U> ? U : T extends ToolStrategy<infer U> ? U : T extends ProviderStrategy<infer U> ? U : ResponseFormatUndefined;
|
|
1457
1774
|
/**
|
|
1458
1775
|
* Type bag that extends AgentTypeConfig with subagent type information.
|
|
1459
1776
|
*
|
|
@@ -1595,7 +1912,7 @@ type InferSubagentReactAgentType<TSubagent extends SubAgent | CompiledSubAgent>
|
|
|
1595
1912
|
* @typeParam TSubagents - The subagents array type for extracting subagent middleware states
|
|
1596
1913
|
* @typeParam TTools - The tools array type
|
|
1597
1914
|
*/
|
|
1598
|
-
interface CreateDeepAgentParams<TResponse extends
|
|
1915
|
+
interface CreateDeepAgentParams<TResponse extends SupportedResponseFormat = SupportedResponseFormat, ContextSchema extends AnnotationRoot<any> | InteropZodObject = AnnotationRoot<any>, TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[], TSubagents extends readonly (SubAgent | CompiledSubAgent)[] = readonly (SubAgent | CompiledSubAgent)[], TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[]> {
|
|
1599
1916
|
/** The model to use (model name string or LanguageModelLike instance). Defaults to claude-sonnet-4-5-20250929 */
|
|
1600
1917
|
model?: BaseLanguageModel | string;
|
|
1601
1918
|
/** Tools the agent should have access to */
|
|
@@ -1675,7 +1992,7 @@ interface CreateDeepAgentParams<TResponse extends ResponseFormat = ResponseForma
|
|
|
1675
1992
|
* - Todo management (todoListMiddleware)
|
|
1676
1993
|
* - Filesystem tools (createFilesystemMiddleware)
|
|
1677
1994
|
* - Subagent delegation (createSubAgentMiddleware)
|
|
1678
|
-
* - Conversation summarization (
|
|
1995
|
+
* - Conversation summarization (createSummarizationMiddleware) with backend offloading
|
|
1679
1996
|
* - Prompt caching (anthropicPromptCachingMiddleware)
|
|
1680
1997
|
* - Tool call patching (createPatchToolCallsMiddleware)
|
|
1681
1998
|
* - Human-in-the-loop (humanInTheLoopMiddleware) - optional
|
|
@@ -1699,7 +2016,7 @@ interface CreateDeepAgentParams<TResponse extends ResponseFormat = ResponseForma
|
|
|
1699
2016
|
* // result.research is properly typed as string
|
|
1700
2017
|
* ```
|
|
1701
2018
|
*/
|
|
1702
|
-
declare function createDeepAgent<TResponse extends
|
|
2019
|
+
declare function createDeepAgent<TResponse extends SupportedResponseFormat = SupportedResponseFormat, ContextSchema extends InteropZodObject = InteropZodObject, const TMiddleware extends readonly AgentMiddleware[] = readonly [], const TSubagents extends readonly (SubAgent | CompiledSubAgent)[] = readonly [], const TTools extends readonly (ClientTool | ServerTool)[] = readonly []>(params?: CreateDeepAgentParams<TResponse, ContextSchema, TMiddleware, TSubagents, TTools>): DeepAgent<DeepAgentTypeConfig<InferStructuredResponse<TResponse>, undefined, ContextSchema, readonly [AgentMiddleware<zod_v30.ZodObject<{
|
|
1703
2020
|
todos: zod_v30.ZodDefault<zod_v30.ZodArray<zod_v30.ZodObject<{
|
|
1704
2021
|
content: zod_v30.ZodString;
|
|
1705
2022
|
status: zod_v30.ZodEnum<["pending", "in_progress", "completed"]>;
|
|
@@ -1779,13 +2096,13 @@ declare function createDeepAgent<TResponse extends ResponseFormat = ResponseForm
|
|
|
1779
2096
|
limit?: unknown;
|
|
1780
2097
|
}, string, "read_file"> | langchain.DynamicStructuredTool<zod.ZodObject<{
|
|
1781
2098
|
file_path: zod.ZodString;
|
|
1782
|
-
content: zod.ZodString
|
|
2099
|
+
content: zod.ZodDefault<zod.ZodString>;
|
|
1783
2100
|
}, zod_v4_core0.$strip>, {
|
|
1784
2101
|
file_path: string;
|
|
1785
2102
|
content: string;
|
|
1786
2103
|
}, {
|
|
1787
2104
|
file_path: string;
|
|
1788
|
-
content
|
|
2105
|
+
content?: string | undefined;
|
|
1789
2106
|
}, string | _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>> | _langchain_langgraph0.Command<unknown, {
|
|
1790
2107
|
files: Record<string, FileData>;
|
|
1791
2108
|
messages: _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>>[];
|
|
@@ -1843,144 +2160,14 @@ declare function createDeepAgent<TResponse extends ResponseFormat = ResponseForm
|
|
|
1843
2160
|
}, {
|
|
1844
2161
|
description: string;
|
|
1845
2162
|
subagent_type: string;
|
|
1846
|
-
}, string | _langchain_langgraph0.Command<unknown, Record<string, unknown>, string>, "task">]>, AgentMiddleware<
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
messages?: number | undefined;
|
|
1855
|
-
}, {
|
|
1856
|
-
fraction?: number | undefined;
|
|
1857
|
-
tokens?: number | undefined;
|
|
1858
|
-
messages?: number | undefined;
|
|
1859
|
-
}>, {
|
|
1860
|
-
fraction?: number | undefined;
|
|
1861
|
-
tokens?: number | undefined;
|
|
1862
|
-
messages?: number | undefined;
|
|
1863
|
-
}, {
|
|
1864
|
-
fraction?: number | undefined;
|
|
1865
|
-
tokens?: number | undefined;
|
|
1866
|
-
messages?: number | undefined;
|
|
1867
|
-
}>, zod_v30.ZodArray<zod_v30.ZodEffects<zod_v30.ZodObject<{
|
|
1868
|
-
fraction: zod_v30.ZodOptional<zod_v30.ZodNumber>;
|
|
1869
|
-
tokens: zod_v30.ZodOptional<zod_v30.ZodNumber>;
|
|
1870
|
-
messages: zod_v30.ZodOptional<zod_v30.ZodNumber>;
|
|
1871
|
-
}, "strip", zod_v30.ZodTypeAny, {
|
|
1872
|
-
fraction?: number | undefined;
|
|
1873
|
-
tokens?: number | undefined;
|
|
1874
|
-
messages?: number | undefined;
|
|
1875
|
-
}, {
|
|
1876
|
-
fraction?: number | undefined;
|
|
1877
|
-
tokens?: number | undefined;
|
|
1878
|
-
messages?: number | undefined;
|
|
1879
|
-
}>, {
|
|
1880
|
-
fraction?: number | undefined;
|
|
1881
|
-
tokens?: number | undefined;
|
|
1882
|
-
messages?: number | undefined;
|
|
1883
|
-
}, {
|
|
1884
|
-
fraction?: number | undefined;
|
|
1885
|
-
tokens?: number | undefined;
|
|
1886
|
-
messages?: number | undefined;
|
|
1887
|
-
}>, "many">]>>;
|
|
1888
|
-
keep: zod_v30.ZodOptional<zod_v30.ZodEffects<zod_v30.ZodObject<{
|
|
1889
|
-
fraction: zod_v30.ZodOptional<zod_v30.ZodNumber>;
|
|
1890
|
-
tokens: zod_v30.ZodOptional<zod_v30.ZodNumber>;
|
|
1891
|
-
messages: zod_v30.ZodOptional<zod_v30.ZodNumber>;
|
|
1892
|
-
}, "strip", zod_v30.ZodTypeAny, {
|
|
1893
|
-
fraction?: number | undefined;
|
|
1894
|
-
tokens?: number | undefined;
|
|
1895
|
-
messages?: number | undefined;
|
|
1896
|
-
}, {
|
|
1897
|
-
fraction?: number | undefined;
|
|
1898
|
-
tokens?: number | undefined;
|
|
1899
|
-
messages?: number | undefined;
|
|
1900
|
-
}>, {
|
|
1901
|
-
fraction?: number | undefined;
|
|
1902
|
-
tokens?: number | undefined;
|
|
1903
|
-
messages?: number | undefined;
|
|
1904
|
-
}, {
|
|
1905
|
-
fraction?: number | undefined;
|
|
1906
|
-
tokens?: number | undefined;
|
|
1907
|
-
messages?: number | undefined;
|
|
1908
|
-
}>>;
|
|
1909
|
-
tokenCounter: zod_v30.ZodOptional<zod_v30.ZodFunction<zod_v30.ZodTuple<[zod_v30.ZodArray<zod_v30.ZodType<_messages.BaseMessage<_messages.MessageStructure<_messages.MessageToolSet>, _messages.MessageType>, zod_v30.ZodTypeDef, _messages.BaseMessage<_messages.MessageStructure<_messages.MessageToolSet>, _messages.MessageType>>, "many">], zod_v30.ZodUnknown>, zod_v30.ZodUnion<[zod_v30.ZodNumber, zod_v30.ZodPromise<zod_v30.ZodNumber>]>>>;
|
|
1910
|
-
summaryPrompt: zod_v30.ZodDefault<zod_v30.ZodString>;
|
|
1911
|
-
trimTokensToSummarize: zod_v30.ZodOptional<zod_v30.ZodNumber>;
|
|
1912
|
-
summaryPrefix: zod_v30.ZodOptional<zod_v30.ZodString>;
|
|
1913
|
-
maxTokensBeforeSummary: zod_v30.ZodOptional<zod_v30.ZodNumber>;
|
|
1914
|
-
messagesToKeep: zod_v30.ZodOptional<zod_v30.ZodNumber>;
|
|
1915
|
-
} & {
|
|
1916
|
-
model: zod_v30.ZodOptional<zod_v30.ZodType<_langchain_core_language_models_base0.BaseLanguageModel<any, _langchain_core_language_models_base0.BaseLanguageModelCallOptions>, zod_v30.ZodTypeDef, _langchain_core_language_models_base0.BaseLanguageModel<any, _langchain_core_language_models_base0.BaseLanguageModelCallOptions>>>;
|
|
1917
|
-
}, "strip", zod_v30.ZodTypeAny, {
|
|
1918
|
-
trigger?: {
|
|
1919
|
-
fraction?: number | undefined;
|
|
1920
|
-
tokens?: number | undefined;
|
|
1921
|
-
messages?: number | undefined;
|
|
1922
|
-
}[] | {
|
|
1923
|
-
fraction?: number | undefined;
|
|
1924
|
-
tokens?: number | undefined;
|
|
1925
|
-
messages?: number | undefined;
|
|
1926
|
-
} | undefined;
|
|
1927
|
-
keep?: {
|
|
1928
|
-
fraction?: number | undefined;
|
|
1929
|
-
tokens?: number | undefined;
|
|
1930
|
-
messages?: number | undefined;
|
|
1931
|
-
} | undefined;
|
|
1932
|
-
tokenCounter?: ((args_0: _messages.BaseMessage<_messages.MessageStructure<_messages.MessageToolSet>, _messages.MessageType>[], ...args: unknown[]) => number | Promise<number>) | undefined;
|
|
1933
|
-
summaryPrompt: string;
|
|
1934
|
-
trimTokensToSummarize?: number | undefined;
|
|
1935
|
-
summaryPrefix?: string | undefined;
|
|
1936
|
-
maxTokensBeforeSummary?: number | undefined;
|
|
1937
|
-
messagesToKeep?: number | undefined;
|
|
1938
|
-
model?: _langchain_core_language_models_base0.BaseLanguageModel<any, _langchain_core_language_models_base0.BaseLanguageModelCallOptions> | undefined;
|
|
1939
|
-
}, {
|
|
1940
|
-
trigger?: {
|
|
1941
|
-
fraction?: number | undefined;
|
|
1942
|
-
tokens?: number | undefined;
|
|
1943
|
-
messages?: number | undefined;
|
|
1944
|
-
}[] | {
|
|
1945
|
-
fraction?: number | undefined;
|
|
1946
|
-
tokens?: number | undefined;
|
|
1947
|
-
messages?: number | undefined;
|
|
1948
|
-
} | undefined;
|
|
1949
|
-
keep?: {
|
|
1950
|
-
fraction?: number | undefined;
|
|
1951
|
-
tokens?: number | undefined;
|
|
1952
|
-
messages?: number | undefined;
|
|
1953
|
-
} | undefined;
|
|
1954
|
-
tokenCounter?: ((args_0: _messages.BaseMessage<_messages.MessageStructure<_messages.MessageToolSet>, _messages.MessageType>[], ...args: unknown[]) => number | Promise<number>) | undefined;
|
|
1955
|
-
summaryPrompt?: string | undefined;
|
|
1956
|
-
trimTokensToSummarize?: number | undefined;
|
|
1957
|
-
summaryPrefix?: string | undefined;
|
|
1958
|
-
maxTokensBeforeSummary?: number | undefined;
|
|
1959
|
-
messagesToKeep?: number | undefined;
|
|
1960
|
-
model?: _langchain_core_language_models_base0.BaseLanguageModel<any, _langchain_core_language_models_base0.BaseLanguageModelCallOptions> | undefined;
|
|
1961
|
-
}>, {
|
|
1962
|
-
trigger?: {
|
|
1963
|
-
fraction?: number | undefined;
|
|
1964
|
-
tokens?: number | undefined;
|
|
1965
|
-
messages?: number | undefined;
|
|
1966
|
-
}[] | {
|
|
1967
|
-
fraction?: number | undefined;
|
|
1968
|
-
tokens?: number | undefined;
|
|
1969
|
-
messages?: number | undefined;
|
|
1970
|
-
} | undefined;
|
|
1971
|
-
keep?: {
|
|
1972
|
-
fraction?: number | undefined;
|
|
1973
|
-
tokens?: number | undefined;
|
|
1974
|
-
messages?: number | undefined;
|
|
1975
|
-
} | undefined;
|
|
1976
|
-
tokenCounter?: ((args_0: _messages.BaseMessage<_messages.MessageStructure<_messages.MessageToolSet>, _messages.MessageType>[], ...args: unknown[]) => number | Promise<number>) | undefined;
|
|
1977
|
-
summaryPrompt: string;
|
|
1978
|
-
trimTokensToSummarize?: number | undefined;
|
|
1979
|
-
summaryPrefix?: string | undefined;
|
|
1980
|
-
maxTokensBeforeSummary?: number | undefined;
|
|
1981
|
-
messagesToKeep?: number | undefined;
|
|
1982
|
-
model?: _langchain_core_language_models_base0.BaseLanguageModel<any, _langchain_core_language_models_base0.BaseLanguageModelCallOptions> | undefined;
|
|
1983
|
-
}, readonly (ClientTool | ServerTool)[]>, AgentMiddleware<undefined, zod_v30.ZodObject<{
|
|
2163
|
+
}, string | _langchain_langgraph0.Command<unknown, Record<string, unknown>, string>, "task">]>, AgentMiddleware<zod.ZodObject<{
|
|
2164
|
+
_summarizationSessionId: zod.ZodOptional<zod.ZodString>;
|
|
2165
|
+
_summarizationEvent: zod.ZodOptional<zod.ZodObject<{
|
|
2166
|
+
cutoffIndex: zod.ZodNumber;
|
|
2167
|
+
summaryMessage: zod.ZodCustom<_messages.HumanMessage<_messages.MessageStructure<_messages.MessageToolSet>>, _messages.HumanMessage<_messages.MessageStructure<_messages.MessageToolSet>>>;
|
|
2168
|
+
filePath: zod.ZodNullable<zod.ZodString>;
|
|
2169
|
+
}, zod_v4_core0.$strip>>;
|
|
2170
|
+
}, zod_v4_core0.$strip>, undefined, unknown, readonly (ClientTool | ServerTool)[]>, AgentMiddleware<undefined, zod_v30.ZodObject<{
|
|
1984
2171
|
enableCaching: zod_v30.ZodOptional<zod_v30.ZodBoolean>;
|
|
1985
2172
|
ttl: zod_v30.ZodOptional<zod_v30.ZodEnum<["5m", "1h"]>>;
|
|
1986
2173
|
minMessagesToCache: zod_v30.ZodOptional<zod_v30.ZodNumber>;
|
|
@@ -2207,5 +2394,5 @@ declare function parseSkillMetadata(skillMdPath: string, source: "user" | "proje
|
|
|
2207
2394
|
*/
|
|
2208
2395
|
declare function listSkills(options: ListSkillsOptions): SkillMetadata[];
|
|
2209
2396
|
//#endregion
|
|
2210
|
-
export { type AgentMemoryMiddlewareOptions, type BackendFactory, type BackendProtocol, BaseSandbox, type CompiledSubAgent, CompositeBackend, type CreateDeepAgentParams, DEFAULT_GENERAL_PURPOSE_DESCRIPTION, DEFAULT_SUBAGENT_PROMPT, type DeepAgent, type DeepAgentTypeConfig, type DefaultDeepAgentTypeConfig, type EditResult, type ExecuteResponse, type ExtractSubAgentMiddleware, type FileData, type FileDownloadResponse, type FileInfo, type FileOperationError, type FileUploadResponse, FilesystemBackend, type FilesystemMiddlewareOptions, type FlattenSubAgentMiddleware, GENERAL_PURPOSE_SUBAGENT, type GrepMatch, type InferDeepAgentSubagents, type InferDeepAgentType, type InferSubAgentMiddlewareStates, type InferSubagentByName, type InferSubagentReactAgentType, type ListSkillsOptions, type SkillMetadata as LoaderSkillMetadata, MAX_SKILL_DESCRIPTION_LENGTH, MAX_SKILL_FILE_SIZE, MAX_SKILL_NAME_LENGTH, type MaybePromise, type MemoryMiddlewareOptions, type MergedDeepAgentState, type ResolveDeepAgentTypeConfig, type SandboxBackendProtocol, type SandboxDeleteOptions, SandboxError, type SandboxErrorCode, type SandboxGetOrCreateOptions, type SandboxInfo, type SandboxListOptions, type SandboxListResponse, type Settings, type SettingsOptions, type SkillMetadata$1 as SkillMetadata, type SkillsMiddlewareOptions, StateBackend, StoreBackend, type SubAgent, type SubAgentMiddlewareOptions, TASK_SYSTEM_PROMPT, type WriteResult, createAgentMemoryMiddleware, createDeepAgent, createFilesystemMiddleware, createMemoryMiddleware, createPatchToolCallsMiddleware, createSettings, createSkillsMiddleware, createSubAgentMiddleware, filesValue, findProjectRoot, isSandboxBackend, listSkills, parseSkillMetadata };
|
|
2397
|
+
export { type AgentMemoryMiddlewareOptions, type BackendFactory, type BackendProtocol, BaseSandbox, type CompiledSubAgent, CompositeBackend, type CreateDeepAgentParams, DEFAULT_GENERAL_PURPOSE_DESCRIPTION, DEFAULT_SUBAGENT_PROMPT, type DeepAgent, type DeepAgentTypeConfig, type DefaultDeepAgentTypeConfig, type EditResult, type ExecuteResponse, type ExtractSubAgentMiddleware, type FileData, type FileDownloadResponse, type FileInfo, type FileOperationError, type FileUploadResponse, FilesystemBackend, type FilesystemMiddlewareOptions, type FlattenSubAgentMiddleware, GENERAL_PURPOSE_SUBAGENT, type GrepMatch, type InferDeepAgentSubagents, type InferDeepAgentType, type InferStructuredResponse, type InferSubAgentMiddlewareStates, type InferSubagentByName, type InferSubagentReactAgentType, type ListSkillsOptions, type SkillMetadata as LoaderSkillMetadata, LocalShellBackend, type LocalShellBackendOptions, MAX_SKILL_DESCRIPTION_LENGTH, MAX_SKILL_FILE_SIZE, MAX_SKILL_NAME_LENGTH, type MaybePromise, type MemoryMiddlewareOptions, type MergedDeepAgentState, type ResolveDeepAgentTypeConfig, type SandboxBackendProtocol, type SandboxDeleteOptions, SandboxError, type SandboxErrorCode, type SandboxGetOrCreateOptions, type SandboxInfo, type SandboxListOptions, type SandboxListResponse, type Settings, type SettingsOptions, type SkillMetadata$1 as SkillMetadata, type SkillsMiddlewareOptions, StateBackend, StoreBackend, type SubAgent, type SubAgentMiddlewareOptions, type SupportedResponseFormat, TASK_SYSTEM_PROMPT, type WriteResult, computeSummarizationDefaults, createAgentMemoryMiddleware, createDeepAgent, createFilesystemMiddleware, createMemoryMiddleware, createPatchToolCallsMiddleware, createSettings, createSkillsMiddleware, createSubAgentMiddleware, createSummarizationMiddleware, filesValue, findProjectRoot, isSandboxBackend, listSkills, parseSkillMetadata };
|
|
2211
2398
|
//# sourceMappingURL=index.d.ts.map
|