deepagents 1.3.1 → 1.4.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/dist/index.d.ts CHANGED
@@ -1,9 +1,17 @@
1
1
  import * as langchain0 from "langchain";
2
- import { AgentMiddleware, AgentMiddleware as AgentMiddleware$1, InterruptOnConfig, ReactAgent, StructuredTool } from "langchain";
3
- import { AnnotationRoot } from "@langchain/langgraph";
4
- import { StructuredTool as StructuredTool$1 } from "@langchain/core/tools";
5
- import { BaseLanguageModel, LanguageModelLike } from "@langchain/core/language_models/base";
2
+ import { AgentMiddleware, AgentMiddleware as AgentMiddleware$1, AgentTypeConfig, InterruptOnConfig, ReactAgent, StructuredTool, ToolMessage } from "langchain";
3
+ import * as _Command from "@langchain/langgraph";
4
+ import { AnnotationRoot, Command } from "@langchain/langgraph";
5
+ import { z } from "zod/v4";
6
+ import * as zod_v30 from "zod/v3";
7
+ import * as _messages from "@langchain/core/messages";
8
+ import * as zod0 from "zod";
9
+ import * as zod_v4_core0 from "zod/v4/core";
6
10
  import { BaseCheckpointSaver, BaseStore } from "@langchain/langgraph-checkpoint";
11
+ import * as _langchain_core_language_models_base0 from "@langchain/core/language_models/base";
12
+ import { BaseLanguageModel, LanguageModelLike } from "@langchain/core/language_models/base";
13
+ import * as _langchain_core_tools1 from "@langchain/core/tools";
14
+ import { StructuredTool as StructuredTool$1 } from "@langchain/core/tools";
7
15
  import { Runnable } from "@langchain/core/runnables";
8
16
  import { InteropZodObject } from "@langchain/core/utils/types";
9
17
 
@@ -91,6 +99,42 @@ interface EditResult {
91
99
  /** Metadata for the edit operation, attached to the ToolMessage */
92
100
  metadata?: Record<string, unknown>;
93
101
  }
102
+ /**
103
+ * Result of code execution.
104
+ * Simplified schema optimized for LLM consumption.
105
+ */
106
+ interface ExecuteResponse {
107
+ /** Combined stdout and stderr output of the executed command */
108
+ output: string;
109
+ /** The process exit code. 0 indicates success, non-zero indicates failure */
110
+ exitCode: number | null;
111
+ /** Whether the output was truncated due to backend limitations */
112
+ truncated: boolean;
113
+ }
114
+ /**
115
+ * Standardized error codes for file upload/download operations.
116
+ */
117
+ type FileOperationError = "file_not_found" | "permission_denied" | "is_directory" | "invalid_path";
118
+ /**
119
+ * Result of a single file download operation.
120
+ */
121
+ interface FileDownloadResponse {
122
+ /** The file path that was requested */
123
+ path: string;
124
+ /** File contents as Uint8Array on success, null on failure */
125
+ content: Uint8Array | null;
126
+ /** Standardized error code on failure, null on success */
127
+ error: FileOperationError | null;
128
+ }
129
+ /**
130
+ * Result of a single file upload operation.
131
+ */
132
+ interface FileUploadResponse {
133
+ /** The file path that was requested */
134
+ path: string;
135
+ /** Standardized error code on failure, null on success */
136
+ error: FileOperationError | null;
137
+ }
94
138
  /**
95
139
  * Protocol for pluggable memory backends (single, unified).
96
140
  *
@@ -166,7 +210,44 @@ interface BackendProtocol {
166
210
  * @returns EditResult with error, path, filesUpdate, and occurrences
167
211
  */
168
212
  edit(filePath: string, oldString: string, newString: string, replaceAll?: boolean): MaybePromise<EditResult>;
213
+ /**
214
+ * Upload multiple files.
215
+ *
216
+ * @param files - List of [path, content] tuples to upload
217
+ * @returns List of FileUploadResponse objects, one per input file
218
+ */
219
+ uploadFiles(files: Array<[string, Uint8Array]>): MaybePromise<FileUploadResponse[]>;
220
+ /**
221
+ * Download multiple files.
222
+ *
223
+ * @param paths - List of file paths to download
224
+ * @returns List of FileDownloadResponse objects, one per input path
225
+ */
226
+ downloadFiles(paths: string[]): MaybePromise<FileDownloadResponse[]>;
169
227
  }
228
+ /**
229
+ * Protocol for sandboxed backends with isolated runtime.
230
+ * Sandboxed backends run in isolated environments (e.g., containers)
231
+ * and communicate via defined interfaces.
232
+ */
233
+ interface SandboxBackendProtocol extends BackendProtocol {
234
+ /**
235
+ * Execute a command in the sandbox.
236
+ *
237
+ * @param command - Full shell command string to execute
238
+ * @returns ExecuteResponse with combined output, exit code, and truncation flag
239
+ */
240
+ execute(command: string): MaybePromise<ExecuteResponse>;
241
+ /** Unique identifier for the sandbox backend instance */
242
+ readonly id: string;
243
+ }
244
+ /**
245
+ * Type guard to check if a backend supports execution.
246
+ *
247
+ * @param backend - Backend instance to check
248
+ * @returns True if the backend implements SandboxBackendProtocol
249
+ */
250
+ declare function isSandboxBackend(backend: BackendProtocol): backend is SandboxBackendProtocol;
170
251
  /**
171
252
  * State and store container for backend initialization.
172
253
  *
@@ -219,7 +300,88 @@ interface FilesystemMiddlewareOptions {
219
300
  /**
220
301
  * Create filesystem middleware with all tools and features.
221
302
  */
222
- declare function createFilesystemMiddleware(options?: FilesystemMiddlewareOptions): langchain0.AgentMiddleware<any, undefined, any>;
303
+ declare function createFilesystemMiddleware(options?: FilesystemMiddlewareOptions): AgentMiddleware<z.ZodObject<{
304
+ files: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
305
+ content: z.ZodArray<z.ZodString>;
306
+ created_at: z.ZodString;
307
+ modified_at: z.ZodString;
308
+ }, z.core.$strip>>>;
309
+ }, z.core.$strip>, undefined, unknown, (langchain0.DynamicStructuredTool<z.ZodObject<{
310
+ path: z.ZodDefault<z.ZodOptional<z.ZodString>>;
311
+ }, z.core.$strip>, {
312
+ path: string;
313
+ }, {
314
+ path?: string | undefined;
315
+ }, string, "ls"> | langchain0.DynamicStructuredTool<z.ZodObject<{
316
+ file_path: z.ZodString;
317
+ offset: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
318
+ limit: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
319
+ }, z.core.$strip>, {
320
+ file_path: string;
321
+ offset: number;
322
+ limit: number;
323
+ }, {
324
+ file_path: string;
325
+ offset?: unknown;
326
+ limit?: unknown;
327
+ }, string, "read_file"> | langchain0.DynamicStructuredTool<z.ZodObject<{
328
+ file_path: z.ZodString;
329
+ content: z.ZodString;
330
+ }, z.core.$strip>, {
331
+ file_path: string;
332
+ content: string;
333
+ }, {
334
+ file_path: string;
335
+ content: string;
336
+ }, string | ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>> | Command<unknown, {
337
+ files: Record<string, FileData>;
338
+ messages: ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>>[];
339
+ }, string>, "write_file"> | langchain0.DynamicStructuredTool<z.ZodObject<{
340
+ file_path: z.ZodString;
341
+ old_string: z.ZodString;
342
+ new_string: z.ZodString;
343
+ replace_all: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
344
+ }, z.core.$strip>, {
345
+ file_path: string;
346
+ old_string: string;
347
+ new_string: string;
348
+ replace_all: boolean;
349
+ }, {
350
+ file_path: string;
351
+ old_string: string;
352
+ new_string: string;
353
+ replace_all?: boolean | undefined;
354
+ }, string | ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>> | Command<unknown, {
355
+ files: Record<string, FileData>;
356
+ messages: ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>>[];
357
+ }, string>, "edit_file"> | langchain0.DynamicStructuredTool<z.ZodObject<{
358
+ pattern: z.ZodString;
359
+ path: z.ZodDefault<z.ZodOptional<z.ZodString>>;
360
+ }, z.core.$strip>, {
361
+ pattern: string;
362
+ path: string;
363
+ }, {
364
+ pattern: string;
365
+ path?: string | undefined;
366
+ }, string, "glob"> | langchain0.DynamicStructuredTool<z.ZodObject<{
367
+ pattern: z.ZodString;
368
+ path: z.ZodDefault<z.ZodOptional<z.ZodString>>;
369
+ glob: z.ZodNullable<z.ZodOptional<z.ZodString>>;
370
+ }, z.core.$strip>, {
371
+ pattern: string;
372
+ path: string;
373
+ glob?: string | null | undefined;
374
+ }, {
375
+ pattern: string;
376
+ path?: string | undefined;
377
+ glob?: string | null | undefined;
378
+ }, string, "grep"> | langchain0.DynamicStructuredTool<z.ZodObject<{
379
+ command: z.ZodString;
380
+ }, z.core.$strip>, {
381
+ command: string;
382
+ }, {
383
+ command: string;
384
+ }, string, "execute">)[]>;
223
385
  //#endregion
224
386
  //#region src/middleware/subagents.d.ts
225
387
  /**
@@ -231,7 +393,7 @@ interface CompiledSubAgent {
231
393
  /** The description of the agent */
232
394
  description: string;
233
395
  /** The agent instance */
234
- runnable: ReactAgent<any, any, any, any> | Runnable;
396
+ runnable: ReactAgent | Runnable;
235
397
  }
236
398
  /**
237
399
  * Type definitions for subagents
@@ -299,7 +461,7 @@ declare function createSubAgentMiddleware(options: SubAgentMiddlewareOptions): A
299
461
  * });
300
462
  * ```
301
463
  */
302
- declare function createPatchToolCallsMiddleware(): AgentMiddleware;
464
+ declare function createPatchToolCallsMiddleware(): AgentMiddleware<undefined, undefined, unknown, readonly (_langchain_core_tools1.ClientTool | _langchain_core_tools1.ServerTool)[]>;
303
465
  //#endregion
304
466
  //#region src/backends/state.d.ts
305
467
  /**
@@ -362,6 +524,25 @@ declare class StateBackend implements BackendProtocol {
362
524
  * Structured glob matching returning FileInfo objects.
363
525
  */
364
526
  globInfo(pattern: string, path?: string): FileInfo[];
527
+ /**
528
+ * Upload multiple files.
529
+ *
530
+ * Note: Since LangGraph state must be updated via Command objects,
531
+ * the caller must apply filesUpdate via Command after calling this method.
532
+ *
533
+ * @param files - List of [path, content] tuples to upload
534
+ * @returns List of FileUploadResponse objects, one per input file
535
+ */
536
+ uploadFiles(files: Array<[string, Uint8Array]>): FileUploadResponse[] & {
537
+ filesUpdate?: Record<string, FileData>;
538
+ };
539
+ /**
540
+ * Download multiple files.
541
+ *
542
+ * @param paths - List of file paths to download
543
+ * @returns List of FileDownloadResponse objects, one per input path
544
+ */
545
+ downloadFiles(paths: string[]): FileDownloadResponse[];
365
546
  }
366
547
  //#endregion
367
548
  //#region src/backends/store.d.ts
@@ -457,6 +638,20 @@ declare class StoreBackend implements BackendProtocol {
457
638
  * Structured glob matching returning FileInfo objects.
458
639
  */
459
640
  globInfo(pattern: string, path?: string): Promise<FileInfo[]>;
641
+ /**
642
+ * Upload multiple files.
643
+ *
644
+ * @param files - List of [path, content] tuples to upload
645
+ * @returns List of FileUploadResponse objects, one per input file
646
+ */
647
+ uploadFiles(files: Array<[string, Uint8Array]>): Promise<FileUploadResponse[]>;
648
+ /**
649
+ * Download multiple files.
650
+ *
651
+ * @param paths - List of file paths to download
652
+ * @returns List of FileDownloadResponse objects, one per input path
653
+ */
654
+ downloadFiles(paths: string[]): Promise<FileDownloadResponse[]>;
460
655
  }
461
656
  //#endregion
462
657
  //#region src/backends/filesystem.d.ts
@@ -540,6 +735,20 @@ declare class FilesystemBackend implements BackendProtocol {
540
735
  * Structured glob matching returning FileInfo objects.
541
736
  */
542
737
  globInfo(pattern: string, searchPath?: string): Promise<FileInfo[]>;
738
+ /**
739
+ * Upload multiple files to the filesystem.
740
+ *
741
+ * @param files - List of [path, content] tuples to upload
742
+ * @returns List of FileUploadResponse objects, one per input file
743
+ */
744
+ uploadFiles(files: Array<[string, Uint8Array]>): Promise<FileUploadResponse[]>;
745
+ /**
746
+ * Download multiple files from the filesystem.
747
+ *
748
+ * @param paths - List of file paths to download
749
+ * @returns List of FileDownloadResponse objects, one per input path
750
+ */
751
+ downloadFiles(paths: string[]): Promise<FileDownloadResponse[]>;
543
752
  }
544
753
  //#endregion
545
754
  //#region src/backends/composite.d.ts
@@ -615,6 +824,98 @@ declare class CompositeBackend implements BackendProtocol {
615
824
  * @returns EditResult with path, occurrences, or error
616
825
  */
617
826
  edit(filePath: string, oldString: string, newString: string, replaceAll?: boolean): Promise<EditResult>;
827
+ /**
828
+ * Execute a command via the default backend.
829
+ * Execution is not path-specific, so it always delegates to the default backend.
830
+ *
831
+ * @param command - Full shell command string to execute
832
+ * @returns ExecuteResponse with combined output, exit code, and truncation flag
833
+ * @throws Error if the default backend doesn't support command execution
834
+ */
835
+ execute(command: string): Promise<ExecuteResponse>;
836
+ /**
837
+ * Upload multiple files, batching by backend for efficiency.
838
+ *
839
+ * @param files - List of [path, content] tuples to upload
840
+ * @returns List of FileUploadResponse objects, one per input file
841
+ */
842
+ uploadFiles(files: Array<[string, Uint8Array]>): Promise<FileUploadResponse[]>;
843
+ /**
844
+ * Download multiple files, batching by backend for efficiency.
845
+ *
846
+ * @param paths - List of file paths to download
847
+ * @returns List of FileDownloadResponse objects, one per input path
848
+ */
849
+ downloadFiles(paths: string[]): Promise<FileDownloadResponse[]>;
850
+ }
851
+ //#endregion
852
+ //#region src/backends/sandbox.d.ts
853
+ /**
854
+ * Base sandbox implementation with execute() as the only abstract method.
855
+ *
856
+ * This class provides default implementations for all SandboxBackendProtocol
857
+ * methods using shell commands executed via execute(). Concrete implementations
858
+ * only need to implement the execute() method.
859
+ *
860
+ * Requires Node.js 20+ on the sandbox host.
861
+ */
862
+ declare abstract class BaseSandbox implements SandboxBackendProtocol {
863
+ /** Unique identifier for the sandbox backend */
864
+ abstract readonly id: string;
865
+ /**
866
+ * Execute a command in the sandbox.
867
+ * This is the only method concrete implementations must provide.
868
+ */
869
+ abstract execute(command: string): MaybePromise<ExecuteResponse>;
870
+ /**
871
+ * Upload multiple files to the sandbox.
872
+ * Implementations must support partial success.
873
+ */
874
+ abstract uploadFiles(files: Array<[string, Uint8Array]>): MaybePromise<FileUploadResponse[]>;
875
+ /**
876
+ * Download multiple files from the sandbox.
877
+ * Implementations must support partial success.
878
+ */
879
+ abstract downloadFiles(paths: string[]): MaybePromise<FileDownloadResponse[]>;
880
+ /**
881
+ * List files and directories in the specified directory (non-recursive).
882
+ *
883
+ * @param path - Absolute path to directory
884
+ * @returns List of FileInfo objects for files and directories directly in the directory.
885
+ */
886
+ lsInfo(path: string): Promise<FileInfo[]>;
887
+ /**
888
+ * Read file content with line numbers.
889
+ *
890
+ * @param filePath - Absolute file path
891
+ * @param offset - Line offset to start reading from (0-indexed)
892
+ * @param limit - Maximum number of lines to read
893
+ * @returns Formatted file content with line numbers, or error message
894
+ */
895
+ read(filePath: string, offset?: number, limit?: number): Promise<string>;
896
+ /**
897
+ * Read file content as raw FileData.
898
+ *
899
+ * @param filePath - Absolute file path
900
+ * @returns Raw file content as FileData
901
+ */
902
+ readRaw(filePath: string): Promise<FileData>;
903
+ /**
904
+ * Structured search results or error string for invalid input.
905
+ */
906
+ grepRaw(pattern: string, path?: string, glob?: string | null): Promise<GrepMatch[] | string>;
907
+ /**
908
+ * Structured glob matching returning FileInfo objects.
909
+ */
910
+ globInfo(pattern: string, path?: string): Promise<FileInfo[]>;
911
+ /**
912
+ * Create a new file with content.
913
+ */
914
+ write(filePath: string, content: string): Promise<WriteResult>;
915
+ /**
916
+ * Edit a file by replacing string occurrences.
917
+ */
918
+ edit(filePath: string, oldString: string, newString: string, replaceAll?: boolean): Promise<EditResult>;
618
919
  }
619
920
  //#endregion
620
921
  //#region src/agent.d.ts
@@ -670,6 +971,540 @@ interface CreateDeepAgentParams<ContextSchema extends AnnotationRoot<any> | Inte
670
971
  * @param params Configuration parameters for the agent
671
972
  * @returns ReactAgent instance ready for invocation
672
973
  */
673
- declare function createDeepAgent<ContextSchema extends AnnotationRoot<any> | InteropZodObject = AnnotationRoot<any>>(params?: CreateDeepAgentParams<ContextSchema>): ReactAgent<any, any, ContextSchema, any>;
974
+ declare function createDeepAgent<ContextSchema extends InteropZodObject = InteropZodObject>(params?: CreateDeepAgentParams<ContextSchema>): ReactAgent<AgentTypeConfig<Record<string, any>, undefined, ContextSchema, (AgentMiddleware<any, any, any, readonly (_langchain_core_tools1.ClientTool | _langchain_core_tools1.ServerTool)[]> | AgentMiddleware<zod_v30.ZodObject<{
975
+ todos: zod_v30.ZodDefault<zod_v30.ZodArray<zod_v30.ZodObject<{
976
+ content: zod_v30.ZodString;
977
+ status: zod_v30.ZodEnum<["pending", "in_progress", "completed"]>;
978
+ }, "strip", zod_v30.ZodTypeAny, {
979
+ content: string;
980
+ status: "completed" | "in_progress" | "pending";
981
+ }, {
982
+ content: string;
983
+ status: "completed" | "in_progress" | "pending";
984
+ }>, "many">>;
985
+ }, "strip", zod_v30.ZodTypeAny, {
986
+ todos: {
987
+ content: string;
988
+ status: "completed" | "in_progress" | "pending";
989
+ }[];
990
+ }, {
991
+ todos?: {
992
+ content: string;
993
+ status: "completed" | "in_progress" | "pending";
994
+ }[] | undefined;
995
+ }>, undefined, unknown, readonly [_langchain_core_tools1.DynamicStructuredTool<zod_v30.ZodObject<{
996
+ todos: zod_v30.ZodArray<zod_v30.ZodObject<{
997
+ content: zod_v30.ZodString;
998
+ status: zod_v30.ZodEnum<["pending", "in_progress", "completed"]>;
999
+ }, "strip", zod_v30.ZodTypeAny, {
1000
+ content: string;
1001
+ status: "completed" | "in_progress" | "pending";
1002
+ }, {
1003
+ content: string;
1004
+ status: "completed" | "in_progress" | "pending";
1005
+ }>, "many">;
1006
+ }, "strip", zod_v30.ZodTypeAny, {
1007
+ todos: {
1008
+ content: string;
1009
+ status: "completed" | "in_progress" | "pending";
1010
+ }[];
1011
+ }, {
1012
+ todos: {
1013
+ content: string;
1014
+ status: "completed" | "in_progress" | "pending";
1015
+ }[];
1016
+ }>, {
1017
+ todos: {
1018
+ content: string;
1019
+ status: "completed" | "in_progress" | "pending";
1020
+ }[];
1021
+ }, {
1022
+ todos: {
1023
+ content: string;
1024
+ status: "completed" | "in_progress" | "pending";
1025
+ }[];
1026
+ }, _Command.Command<unknown, {
1027
+ todos: {
1028
+ content: string;
1029
+ status: "completed" | "in_progress" | "pending";
1030
+ }[];
1031
+ messages: _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>>[];
1032
+ }, string>, "write_todos">]> | AgentMiddleware<zod0.ZodObject<{
1033
+ files: zod0.ZodDefault<zod0.ZodRecord<zod0.ZodString, zod0.ZodObject<{
1034
+ content: zod0.ZodArray<zod0.ZodString>;
1035
+ created_at: zod0.ZodString;
1036
+ modified_at: zod0.ZodString;
1037
+ }, zod_v4_core0.$strip>>>;
1038
+ }, zod_v4_core0.$strip>, undefined, unknown, (_langchain_core_tools1.DynamicStructuredTool<zod0.ZodObject<{
1039
+ path: zod0.ZodDefault<zod0.ZodOptional<zod0.ZodString>>;
1040
+ }, zod_v4_core0.$strip>, {
1041
+ path: string;
1042
+ }, {
1043
+ path?: string | undefined;
1044
+ }, string, "ls"> | _langchain_core_tools1.DynamicStructuredTool<zod0.ZodObject<{
1045
+ file_path: zod0.ZodString;
1046
+ offset: zod0.ZodDefault<zod0.ZodOptional<zod0.ZodCoercedNumber<unknown>>>;
1047
+ limit: zod0.ZodDefault<zod0.ZodOptional<zod0.ZodCoercedNumber<unknown>>>;
1048
+ }, zod_v4_core0.$strip>, {
1049
+ file_path: string;
1050
+ offset: number;
1051
+ limit: number;
1052
+ }, {
1053
+ file_path: string;
1054
+ offset?: unknown;
1055
+ limit?: unknown;
1056
+ }, string, "read_file"> | _langchain_core_tools1.DynamicStructuredTool<zod0.ZodObject<{
1057
+ file_path: zod0.ZodString;
1058
+ content: zod0.ZodString;
1059
+ }, zod_v4_core0.$strip>, {
1060
+ file_path: string;
1061
+ content: string;
1062
+ }, {
1063
+ file_path: string;
1064
+ content: string;
1065
+ }, string | _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>> | _Command.Command<unknown, {
1066
+ files: Record<string, FileData>;
1067
+ messages: _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>>[];
1068
+ }, string>, "write_file"> | _langchain_core_tools1.DynamicStructuredTool<zod0.ZodObject<{
1069
+ file_path: zod0.ZodString;
1070
+ old_string: zod0.ZodString;
1071
+ new_string: zod0.ZodString;
1072
+ replace_all: zod0.ZodDefault<zod0.ZodOptional<zod0.ZodBoolean>>;
1073
+ }, zod_v4_core0.$strip>, {
1074
+ file_path: string;
1075
+ old_string: string;
1076
+ new_string: string;
1077
+ replace_all: boolean;
1078
+ }, {
1079
+ file_path: string;
1080
+ old_string: string;
1081
+ new_string: string;
1082
+ replace_all?: boolean | undefined;
1083
+ }, string | _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>> | _Command.Command<unknown, {
1084
+ files: Record<string, FileData>;
1085
+ messages: _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>>[];
1086
+ }, string>, "edit_file"> | _langchain_core_tools1.DynamicStructuredTool<zod0.ZodObject<{
1087
+ pattern: zod0.ZodString;
1088
+ path: zod0.ZodDefault<zod0.ZodOptional<zod0.ZodString>>;
1089
+ }, zod_v4_core0.$strip>, {
1090
+ pattern: string;
1091
+ path: string;
1092
+ }, {
1093
+ pattern: string;
1094
+ path?: string | undefined;
1095
+ }, string, "glob"> | _langchain_core_tools1.DynamicStructuredTool<zod0.ZodObject<{
1096
+ pattern: zod0.ZodString;
1097
+ path: zod0.ZodDefault<zod0.ZodOptional<zod0.ZodString>>;
1098
+ glob: zod0.ZodNullable<zod0.ZodOptional<zod0.ZodString>>;
1099
+ }, zod_v4_core0.$strip>, {
1100
+ pattern: string;
1101
+ path: string;
1102
+ glob?: string | null | undefined;
1103
+ }, {
1104
+ pattern: string;
1105
+ path?: string | undefined;
1106
+ glob?: string | null | undefined;
1107
+ }, string, "grep"> | _langchain_core_tools1.DynamicStructuredTool<zod0.ZodObject<{
1108
+ command: zod0.ZodString;
1109
+ }, zod_v4_core0.$strip>, {
1110
+ command: string;
1111
+ }, {
1112
+ command: string;
1113
+ }, string, "execute">)[]> | AgentMiddleware<undefined, zod_v30.ZodObject<{
1114
+ trigger: zod_v30.ZodOptional<zod_v30.ZodUnion<[zod_v30.ZodEffects<zod_v30.ZodObject<{
1115
+ fraction: zod_v30.ZodOptional<zod_v30.ZodNumber>;
1116
+ tokens: zod_v30.ZodOptional<zod_v30.ZodNumber>;
1117
+ messages: zod_v30.ZodOptional<zod_v30.ZodNumber>;
1118
+ }, "strip", zod_v30.ZodTypeAny, {
1119
+ fraction?: number | undefined;
1120
+ tokens?: number | undefined;
1121
+ messages?: number | undefined;
1122
+ }, {
1123
+ fraction?: number | undefined;
1124
+ tokens?: number | undefined;
1125
+ messages?: number | undefined;
1126
+ }>, {
1127
+ fraction?: number | undefined;
1128
+ tokens?: number | undefined;
1129
+ messages?: number | undefined;
1130
+ }, {
1131
+ fraction?: number | undefined;
1132
+ tokens?: number | undefined;
1133
+ messages?: number | undefined;
1134
+ }>, zod_v30.ZodArray<zod_v30.ZodEffects<zod_v30.ZodObject<{
1135
+ fraction: zod_v30.ZodOptional<zod_v30.ZodNumber>;
1136
+ tokens: zod_v30.ZodOptional<zod_v30.ZodNumber>;
1137
+ messages: zod_v30.ZodOptional<zod_v30.ZodNumber>;
1138
+ }, "strip", zod_v30.ZodTypeAny, {
1139
+ fraction?: number | undefined;
1140
+ tokens?: number | undefined;
1141
+ messages?: number | undefined;
1142
+ }, {
1143
+ fraction?: number | undefined;
1144
+ tokens?: number | undefined;
1145
+ messages?: number | undefined;
1146
+ }>, {
1147
+ fraction?: number | undefined;
1148
+ tokens?: number | undefined;
1149
+ messages?: number | undefined;
1150
+ }, {
1151
+ fraction?: number | undefined;
1152
+ tokens?: number | undefined;
1153
+ messages?: number | undefined;
1154
+ }>, "many">]>>;
1155
+ keep: zod_v30.ZodOptional<zod_v30.ZodEffects<zod_v30.ZodObject<{
1156
+ fraction: zod_v30.ZodOptional<zod_v30.ZodNumber>;
1157
+ tokens: zod_v30.ZodOptional<zod_v30.ZodNumber>;
1158
+ messages: zod_v30.ZodOptional<zod_v30.ZodNumber>;
1159
+ }, "strip", zod_v30.ZodTypeAny, {
1160
+ fraction?: number | undefined;
1161
+ tokens?: number | undefined;
1162
+ messages?: number | undefined;
1163
+ }, {
1164
+ fraction?: number | undefined;
1165
+ tokens?: number | undefined;
1166
+ messages?: number | undefined;
1167
+ }>, {
1168
+ fraction?: number | undefined;
1169
+ tokens?: number | undefined;
1170
+ messages?: number | undefined;
1171
+ }, {
1172
+ fraction?: number | undefined;
1173
+ tokens?: number | undefined;
1174
+ messages?: number | undefined;
1175
+ }>>;
1176
+ 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>]>>>;
1177
+ summaryPrompt: zod_v30.ZodDefault<zod_v30.ZodString>;
1178
+ trimTokensToSummarize: zod_v30.ZodOptional<zod_v30.ZodNumber>;
1179
+ summaryPrefix: zod_v30.ZodOptional<zod_v30.ZodString>;
1180
+ maxTokensBeforeSummary: zod_v30.ZodOptional<zod_v30.ZodNumber>;
1181
+ messagesToKeep: zod_v30.ZodOptional<zod_v30.ZodNumber>;
1182
+ } & {
1183
+ model: zod_v30.ZodOptional<zod_v30.ZodType<BaseLanguageModel<any, _langchain_core_language_models_base0.BaseLanguageModelCallOptions>, zod_v30.ZodTypeDef, BaseLanguageModel<any, _langchain_core_language_models_base0.BaseLanguageModelCallOptions>>>;
1184
+ }, "strip", zod_v30.ZodTypeAny, {
1185
+ trigger?: {
1186
+ fraction?: number | undefined;
1187
+ tokens?: number | undefined;
1188
+ messages?: number | undefined;
1189
+ }[] | {
1190
+ fraction?: number | undefined;
1191
+ tokens?: number | undefined;
1192
+ messages?: number | undefined;
1193
+ } | undefined;
1194
+ keep?: {
1195
+ fraction?: number | undefined;
1196
+ tokens?: number | undefined;
1197
+ messages?: number | undefined;
1198
+ } | undefined;
1199
+ tokenCounter?: ((args_0: _messages.BaseMessage<_messages.MessageStructure<_messages.MessageToolSet>, _messages.MessageType>[], ...args: unknown[]) => number | Promise<number>) | undefined;
1200
+ summaryPrompt: string;
1201
+ trimTokensToSummarize?: number | undefined;
1202
+ summaryPrefix?: string | undefined;
1203
+ maxTokensBeforeSummary?: number | undefined;
1204
+ messagesToKeep?: number | undefined;
1205
+ model?: BaseLanguageModel<any, _langchain_core_language_models_base0.BaseLanguageModelCallOptions> | undefined;
1206
+ }, {
1207
+ trigger?: {
1208
+ fraction?: number | undefined;
1209
+ tokens?: number | undefined;
1210
+ messages?: number | undefined;
1211
+ }[] | {
1212
+ fraction?: number | undefined;
1213
+ tokens?: number | undefined;
1214
+ messages?: number | undefined;
1215
+ } | undefined;
1216
+ keep?: {
1217
+ fraction?: number | undefined;
1218
+ tokens?: number | undefined;
1219
+ messages?: number | undefined;
1220
+ } | undefined;
1221
+ tokenCounter?: ((args_0: _messages.BaseMessage<_messages.MessageStructure<_messages.MessageToolSet>, _messages.MessageType>[], ...args: unknown[]) => number | Promise<number>) | undefined;
1222
+ summaryPrompt?: string | undefined;
1223
+ trimTokensToSummarize?: number | undefined;
1224
+ summaryPrefix?: string | undefined;
1225
+ maxTokensBeforeSummary?: number | undefined;
1226
+ messagesToKeep?: number | undefined;
1227
+ model?: BaseLanguageModel<any, _langchain_core_language_models_base0.BaseLanguageModelCallOptions> | undefined;
1228
+ }>, {
1229
+ trigger?: {
1230
+ fraction?: number | undefined;
1231
+ tokens?: number | undefined;
1232
+ messages?: number | undefined;
1233
+ }[] | {
1234
+ fraction?: number | undefined;
1235
+ tokens?: number | undefined;
1236
+ messages?: number | undefined;
1237
+ } | undefined;
1238
+ keep?: {
1239
+ fraction?: number | undefined;
1240
+ tokens?: number | undefined;
1241
+ messages?: number | undefined;
1242
+ } | undefined;
1243
+ tokenCounter?: ((args_0: _messages.BaseMessage<_messages.MessageStructure<_messages.MessageToolSet>, _messages.MessageType>[], ...args: unknown[]) => number | Promise<number>) | undefined;
1244
+ summaryPrompt: string;
1245
+ trimTokensToSummarize?: number | undefined;
1246
+ summaryPrefix?: string | undefined;
1247
+ maxTokensBeforeSummary?: number | undefined;
1248
+ messagesToKeep?: number | undefined;
1249
+ model?: BaseLanguageModel<any, _langchain_core_language_models_base0.BaseLanguageModelCallOptions> | undefined;
1250
+ }, readonly (_langchain_core_tools1.ClientTool | _langchain_core_tools1.ServerTool)[]> | AgentMiddleware<undefined, zod_v30.ZodObject<{
1251
+ enableCaching: zod_v30.ZodOptional<zod_v30.ZodBoolean>;
1252
+ ttl: zod_v30.ZodOptional<zod_v30.ZodEnum<["5m", "1h"]>>;
1253
+ minMessagesToCache: zod_v30.ZodOptional<zod_v30.ZodNumber>;
1254
+ unsupportedModelBehavior: zod_v30.ZodOptional<zod_v30.ZodEnum<["ignore", "warn", "raise"]>>;
1255
+ }, "strip", zod_v30.ZodTypeAny, {
1256
+ enableCaching?: boolean | undefined;
1257
+ ttl?: "1h" | "5m" | undefined;
1258
+ minMessagesToCache?: number | undefined;
1259
+ unsupportedModelBehavior?: "ignore" | "raise" | "warn" | undefined;
1260
+ }, {
1261
+ enableCaching?: boolean | undefined;
1262
+ ttl?: "1h" | "5m" | undefined;
1263
+ minMessagesToCache?: number | undefined;
1264
+ unsupportedModelBehavior?: "ignore" | "raise" | "warn" | undefined;
1265
+ }>, {
1266
+ enableCaching?: boolean | undefined;
1267
+ ttl?: "1h" | "5m" | undefined;
1268
+ minMessagesToCache?: number | undefined;
1269
+ unsupportedModelBehavior?: "ignore" | "raise" | "warn" | undefined;
1270
+ }, readonly (_langchain_core_tools1.ClientTool | _langchain_core_tools1.ServerTool)[]> | AgentMiddleware<undefined, undefined, unknown, readonly (_langchain_core_tools1.ClientTool | _langchain_core_tools1.ServerTool)[]>)[], readonly StructuredTool$1<_langchain_core_tools1.ToolSchemaBase, any, any, any>[]>>;
1271
+ //#endregion
1272
+ //#region src/config.d.ts
1273
+ /**
1274
+ * Configuration and settings for deepagents.
1275
+ *
1276
+ * Provides project detection, path management, and environment configuration
1277
+ * for skills and agent memory middleware.
1278
+ */
1279
+ /**
1280
+ * Options for creating a Settings instance.
1281
+ */
1282
+ interface SettingsOptions {
1283
+ /** Starting directory for project detection (defaults to cwd) */
1284
+ startPath?: string;
1285
+ }
1286
+ /**
1287
+ * Settings interface for project detection and path management.
1288
+ *
1289
+ * Provides access to:
1290
+ * - Project root detection (via .git directory)
1291
+ * - User-level deepagents directory (~/.deepagents)
1292
+ * - Agent-specific directories and files
1293
+ * - Skills directories (user and project level)
1294
+ */
1295
+ interface Settings {
1296
+ /** Detected project root directory, or null if not in a git project */
1297
+ readonly projectRoot: string | null;
1298
+ /** Base user-level .deepagents directory (~/.deepagents) */
1299
+ readonly userDeepagentsDir: string;
1300
+ /** Check if currently in a git project */
1301
+ readonly hasProject: boolean;
1302
+ /**
1303
+ * Get the agent directory path.
1304
+ * @param agentName - Name of the agent
1305
+ * @returns Path to ~/.deepagents/{agentName}
1306
+ * @throws Error if agent name is invalid
1307
+ */
1308
+ getAgentDir(agentName: string): string;
1309
+ /**
1310
+ * Ensure agent directory exists and return path.
1311
+ * @param agentName - Name of the agent
1312
+ * @returns Path to ~/.deepagents/{agentName}
1313
+ * @throws Error if agent name is invalid
1314
+ */
1315
+ ensureAgentDir(agentName: string): string;
1316
+ /**
1317
+ * Get user-level agent.md path for a specific agent.
1318
+ * @param agentName - Name of the agent
1319
+ * @returns Path to ~/.deepagents/{agentName}/agent.md
1320
+ */
1321
+ getUserAgentMdPath(agentName: string): string;
1322
+ /**
1323
+ * Get project-level agent.md path.
1324
+ * @returns Path to {projectRoot}/.deepagents/agent.md, or null if not in a project
1325
+ */
1326
+ getProjectAgentMdPath(): string | null;
1327
+ /**
1328
+ * Get user-level skills directory path for a specific agent.
1329
+ * @param agentName - Name of the agent
1330
+ * @returns Path to ~/.deepagents/{agentName}/skills/
1331
+ */
1332
+ getUserSkillsDir(agentName: string): string;
1333
+ /**
1334
+ * Ensure user-level skills directory exists and return path.
1335
+ * @param agentName - Name of the agent
1336
+ * @returns Path to ~/.deepagents/{agentName}/skills/
1337
+ */
1338
+ ensureUserSkillsDir(agentName: string): string;
1339
+ /**
1340
+ * Get project-level skills directory path.
1341
+ * @returns Path to {projectRoot}/.deepagents/skills/, or null if not in a project
1342
+ */
1343
+ getProjectSkillsDir(): string | null;
1344
+ /**
1345
+ * Ensure project-level skills directory exists and return path.
1346
+ * @returns Path to {projectRoot}/.deepagents/skills/, or null if not in a project
1347
+ */
1348
+ ensureProjectSkillsDir(): string | null;
1349
+ /**
1350
+ * Ensure project .deepagents directory exists.
1351
+ * @returns Path to {projectRoot}/.deepagents/, or null if not in a project
1352
+ */
1353
+ ensureProjectDeepagentsDir(): string | null;
1354
+ }
1355
+ /**
1356
+ * Find the project root by looking for .git directory.
1357
+ *
1358
+ * Walks up the directory tree from startPath (or cwd) looking for a .git
1359
+ * directory, which indicates the project root.
1360
+ *
1361
+ * @param startPath - Directory to start searching from. Defaults to current working directory.
1362
+ * @returns Path to the project root if found, null otherwise.
1363
+ */
1364
+ declare function findProjectRoot(startPath?: string): string | null;
1365
+ /**
1366
+ * Create a Settings instance with detected environment.
1367
+ *
1368
+ * @param options - Configuration options
1369
+ * @returns Settings instance with project detection and path management
1370
+ */
1371
+ declare function createSettings(options?: SettingsOptions): Settings;
1372
+ //#endregion
1373
+ //#region src/middleware/skills.d.ts
1374
+ /**
1375
+ * Options for the skills middleware.
1376
+ */
1377
+ interface SkillsMiddlewareOptions {
1378
+ /** Path to the user-level skills directory (per-agent) */
1379
+ skillsDir: string;
1380
+ /** The agent identifier for path references in prompts */
1381
+ assistantId: string;
1382
+ /** Optional path to project-level skills directory */
1383
+ projectSkillsDir?: string;
1384
+ }
1385
+ /**
1386
+ * Create middleware for loading and exposing agent skills.
1387
+ *
1388
+ * This middleware implements Anthropic's agent skills pattern:
1389
+ * - Loads skills metadata (name, description) from YAML frontmatter at session start
1390
+ * - Injects skills list into system prompt for discoverability
1391
+ * - Agent reads full SKILL.md content when a skill is relevant (progressive disclosure)
1392
+ *
1393
+ * Supports both user-level and project-level skills:
1394
+ * - User skills: ~/.deepagents/{AGENT_NAME}/skills/
1395
+ * - Project skills: {PROJECT_ROOT}/.deepagents/skills/
1396
+ * - Project skills override user skills with the same name
1397
+ *
1398
+ * @param options - Configuration options
1399
+ * @returns AgentMiddleware for skills loading and injection
1400
+ */
1401
+ declare function createSkillsMiddleware(options: SkillsMiddlewareOptions): AgentMiddleware;
1402
+ //#endregion
1403
+ //#region src/middleware/agent-memory.d.ts
1404
+ /**
1405
+ * Options for the agent memory middleware.
1406
+ */
1407
+ interface AgentMemoryMiddlewareOptions {
1408
+ /** Settings instance with project detection and paths */
1409
+ settings: Settings;
1410
+ /** The agent identifier */
1411
+ assistantId: string;
1412
+ /** Optional custom template for injecting agent memory into system prompt */
1413
+ systemPromptTemplate?: string;
1414
+ }
1415
+ /**
1416
+ * Create middleware for loading agent-specific long-term memory.
1417
+ *
1418
+ * This middleware loads the agent's long-term memory from a file (agent.md)
1419
+ * and injects it into the system prompt. The memory is loaded once at the
1420
+ * start of the conversation and stored in state.
1421
+ *
1422
+ * @param options - Configuration options
1423
+ * @returns AgentMiddleware for memory loading and injection
1424
+ */
1425
+ declare function createAgentMemoryMiddleware(options: AgentMemoryMiddlewareOptions): AgentMiddleware<any, undefined, unknown, readonly (_langchain_core_tools1.ClientTool | _langchain_core_tools1.ServerTool)[]>;
1426
+ //#endregion
1427
+ //#region src/skills/loader.d.ts
1428
+ /**
1429
+ * Skill loader for parsing and loading agent skills from SKILL.md files.
1430
+ *
1431
+ * This module implements Anthropic's agent skills pattern with YAML frontmatter parsing.
1432
+ * Each skill is a directory containing a SKILL.md file with:
1433
+ * - YAML frontmatter (name, description required)
1434
+ * - Markdown instructions for the agent
1435
+ * - Optional supporting files (scripts, configs, etc.)
1436
+ *
1437
+ * @example
1438
+ * ```markdown
1439
+ * ---
1440
+ * name: web-research
1441
+ * description: Structured approach to conducting thorough web research
1442
+ * ---
1443
+ *
1444
+ * # Web Research Skill
1445
+ *
1446
+ * ## When to Use
1447
+ * - User asks you to research a topic
1448
+ * ...
1449
+ * ```
1450
+ *
1451
+ * @see https://agentskills.io/specification
1452
+ */
1453
+ /** Maximum size for SKILL.md files (10MB) */
1454
+ declare const MAX_SKILL_FILE_SIZE: number;
1455
+ /** Agent Skills spec constraints */
1456
+ declare const MAX_SKILL_NAME_LENGTH = 64;
1457
+ declare const MAX_SKILL_DESCRIPTION_LENGTH = 1024;
1458
+ /**
1459
+ * Metadata for a skill per Agent Skills spec.
1460
+ * @see https://agentskills.io/specification
1461
+ */
1462
+ interface SkillMetadata {
1463
+ /** Name of the skill (max 64 chars, lowercase alphanumeric and hyphens) */
1464
+ name: string;
1465
+ /** Description of what the skill does (max 1024 chars) */
1466
+ description: string;
1467
+ /** Absolute path to the SKILL.md file */
1468
+ path: string;
1469
+ /** Source of the skill ('user' or 'project') */
1470
+ source: "user" | "project";
1471
+ /** Optional: License name or reference to bundled license file */
1472
+ license?: string;
1473
+ /** Optional: Environment requirements (max 500 chars) */
1474
+ compatibility?: string;
1475
+ /** Optional: Arbitrary key-value mapping for additional metadata */
1476
+ metadata?: Record<string, string>;
1477
+ /** Optional: Space-delimited list of pre-approved tools */
1478
+ allowedTools?: string;
1479
+ }
1480
+ /**
1481
+ * Options for listing skills.
1482
+ */
1483
+ interface ListSkillsOptions {
1484
+ /** Path to user-level skills directory */
1485
+ userSkillsDir?: string | null;
1486
+ /** Path to project-level skills directory */
1487
+ projectSkillsDir?: string | null;
1488
+ }
1489
+ /**
1490
+ * Parse YAML frontmatter from a SKILL.md file per Agent Skills spec.
1491
+ *
1492
+ * @param skillMdPath - Path to the SKILL.md file
1493
+ * @param source - Source of the skill ('user' or 'project')
1494
+ * @returns SkillMetadata with all fields, or null if parsing fails
1495
+ */
1496
+ declare function parseSkillMetadata(skillMdPath: string, source: "user" | "project"): SkillMetadata | null;
1497
+ /**
1498
+ * List skills from user and/or project directories.
1499
+ *
1500
+ * When both directories are provided, project skills with the same name as
1501
+ * user skills will override them.
1502
+ *
1503
+ * @param options - Options specifying which directories to search
1504
+ * @returns Merged list of skill metadata from both sources, with project skills
1505
+ * taking precedence over user skills when names conflict
1506
+ */
1507
+ declare function listSkills(options: ListSkillsOptions): SkillMetadata[];
674
1508
  //#endregion
675
- export { type BackendFactory, type BackendProtocol, type CompiledSubAgent, CompositeBackend, type CreateDeepAgentParams, type EditResult, type FileData, type FileInfo, FilesystemBackend, type FilesystemMiddlewareOptions, type GrepMatch, StateBackend, StoreBackend, type SubAgent, type SubAgentMiddlewareOptions, type WriteResult, createDeepAgent, createFilesystemMiddleware, createPatchToolCallsMiddleware, createSubAgentMiddleware };
1509
+ export { type AgentMemoryMiddlewareOptions, type BackendFactory, type BackendProtocol, BaseSandbox, type CompiledSubAgent, CompositeBackend, type CreateDeepAgentParams, type EditResult, type ExecuteResponse, type FileData, type FileDownloadResponse, type FileInfo, type FileOperationError, type FileUploadResponse, FilesystemBackend, type FilesystemMiddlewareOptions, type GrepMatch, type ListSkillsOptions, MAX_SKILL_DESCRIPTION_LENGTH, MAX_SKILL_FILE_SIZE, MAX_SKILL_NAME_LENGTH, type MaybePromise, type SandboxBackendProtocol, type Settings, type SettingsOptions, type SkillMetadata, type SkillsMiddlewareOptions, StateBackend, StoreBackend, type SubAgent, type SubAgentMiddlewareOptions, type WriteResult, createAgentMemoryMiddleware, createDeepAgent, createFilesystemMiddleware, createPatchToolCallsMiddleware, createSettings, createSkillsMiddleware, createSubAgentMiddleware, findProjectRoot, isSandboxBackend, listSkills, parseSkillMetadata };
1510
+ //# sourceMappingURL=index.d.ts.map