deepagents 1.4.1 → 1.5.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.cjs +736 -486
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +366 -164
- package/dist/index.d.ts +329 -127
- package/dist/index.js +736 -487
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as langchain9 from "langchain";
|
|
2
|
-
import { AgentMiddleware, AgentMiddleware as AgentMiddleware$1, AgentTypeConfig, InferMiddlewareStates, InterruptOnConfig, ReactAgent, ResponseFormat, StructuredTool, SystemMessage, ToolMessage } from "langchain";
|
|
2
|
+
import { AgentMiddleware, AgentMiddleware as AgentMiddleware$1, AgentTypeConfig, InferMiddlewareStates, InterruptOnConfig, ReactAgent, ResponseFormat, ResponseFormatUndefined, StructuredTool, SystemMessage, ToolMessage } from "langchain";
|
|
3
3
|
import * as _Command from "@langchain/langgraph";
|
|
4
4
|
import { AnnotationRoot, Command } from "@langchain/langgraph";
|
|
5
5
|
import { z } from "zod/v4";
|
|
@@ -7,6 +7,7 @@ import * as zod_v30 from "zod/v3";
|
|
|
7
7
|
import { z as z$1 } from "zod/v3";
|
|
8
8
|
import * as _messages from "@langchain/core/messages";
|
|
9
9
|
import * as zod0 from "zod";
|
|
10
|
+
import { z as z$2 } from "zod";
|
|
10
11
|
import * as zod_v4_core0 from "zod/v4/core";
|
|
11
12
|
import { BaseCheckpointSaver, BaseStore } from "@langchain/langgraph-checkpoint";
|
|
12
13
|
import * as _langchain_core_language_models_base0 from "@langchain/core/language_models/base";
|
|
@@ -163,17 +164,10 @@ interface BackendProtocol {
|
|
|
163
164
|
*
|
|
164
165
|
* @param filePath - Absolute file path
|
|
165
166
|
* @param offset - Line offset to start reading from (0-indexed), default 0
|
|
166
|
-
* @param limit - Maximum number of lines to read, default
|
|
167
|
+
* @param limit - Maximum number of lines to read, default 500
|
|
167
168
|
* @returns Formatted file content with line numbers, or error message
|
|
168
169
|
*/
|
|
169
170
|
read(filePath: string, offset?: number, limit?: number): MaybePromise<string>;
|
|
170
|
-
/**
|
|
171
|
-
* Read file content as raw FileData.
|
|
172
|
-
*
|
|
173
|
-
* @param filePath - Absolute file path
|
|
174
|
-
* @returns Raw file content as FileData
|
|
175
|
-
*/
|
|
176
|
-
readRaw(filePath: string): MaybePromise<FileData>;
|
|
177
171
|
/**
|
|
178
172
|
* Structured search results or error string for invalid input.
|
|
179
173
|
*
|
|
@@ -387,14 +381,17 @@ declare function createFilesystemMiddleware(options?: FilesystemMiddlewareOption
|
|
|
387
381
|
//#region src/middleware/subagents.d.ts
|
|
388
382
|
/**
|
|
389
383
|
* Type definitions for pre-compiled agents.
|
|
384
|
+
*
|
|
385
|
+
* @typeParam TRunnable - The type of the runnable (ReactAgent or Runnable).
|
|
386
|
+
* When using `createAgent`, this preserves the middleware types for type inference.
|
|
390
387
|
*/
|
|
391
|
-
interface CompiledSubAgent {
|
|
388
|
+
interface CompiledSubAgent<TRunnable extends ReactAgent | Runnable = ReactAgent | Runnable> {
|
|
392
389
|
/** The name of the agent */
|
|
393
390
|
name: string;
|
|
394
391
|
/** The description of the agent */
|
|
395
392
|
description: string;
|
|
396
393
|
/** The agent instance */
|
|
397
|
-
runnable:
|
|
394
|
+
runnable: TRunnable;
|
|
398
395
|
}
|
|
399
396
|
/**
|
|
400
397
|
* Type definitions for subagents
|
|
@@ -515,13 +512,6 @@ declare class StateBackend implements BackendProtocol {
|
|
|
515
512
|
* @returns Formatted file content with line numbers, or error message
|
|
516
513
|
*/
|
|
517
514
|
read(filePath: string, offset?: number, limit?: number): string;
|
|
518
|
-
/**
|
|
519
|
-
* Read file content as raw FileData.
|
|
520
|
-
*
|
|
521
|
-
* @param filePath - Absolute file path
|
|
522
|
-
* @returns Raw file content as FileData
|
|
523
|
-
*/
|
|
524
|
-
readRaw(filePath: string): FileData;
|
|
525
515
|
/**
|
|
526
516
|
* Create a new file with content.
|
|
527
517
|
* Returns WriteResult with filesUpdate to update LangGraph state.
|
|
@@ -561,6 +551,123 @@ declare class StateBackend implements BackendProtocol {
|
|
|
561
551
|
downloadFiles(paths: string[]): FileDownloadResponse[];
|
|
562
552
|
}
|
|
563
553
|
//#endregion
|
|
554
|
+
//#region src/middleware/memory.d.ts
|
|
555
|
+
/**
|
|
556
|
+
* Options for the memory middleware.
|
|
557
|
+
*/
|
|
558
|
+
interface MemoryMiddlewareOptions {
|
|
559
|
+
/**
|
|
560
|
+
* Backend instance or factory function for file operations.
|
|
561
|
+
* Use a factory for StateBackend since it requires runtime state.
|
|
562
|
+
*/
|
|
563
|
+
backend: BackendProtocol | BackendFactory | ((config: {
|
|
564
|
+
state: unknown;
|
|
565
|
+
store?: BaseStore;
|
|
566
|
+
}) => StateBackend);
|
|
567
|
+
/**
|
|
568
|
+
* List of memory file paths to load (e.g., ["~/.deepagents/AGENTS.md", "./.deepagents/AGENTS.md"]).
|
|
569
|
+
* Display names are automatically derived from the paths.
|
|
570
|
+
* Sources are loaded in order.
|
|
571
|
+
*/
|
|
572
|
+
sources: string[];
|
|
573
|
+
}
|
|
574
|
+
/**
|
|
575
|
+
* Create middleware for loading agent memory from AGENTS.md files.
|
|
576
|
+
*
|
|
577
|
+
* Loads memory content from configured sources and injects into the system prompt.
|
|
578
|
+
* Supports multiple sources that are combined together.
|
|
579
|
+
*
|
|
580
|
+
* @param options - Configuration options
|
|
581
|
+
* @returns AgentMiddleware for memory loading and injection
|
|
582
|
+
*
|
|
583
|
+
* @example
|
|
584
|
+
* ```typescript
|
|
585
|
+
* const middleware = createMemoryMiddleware({
|
|
586
|
+
* backend: new FilesystemBackend({ rootDir: "/" }),
|
|
587
|
+
* sources: [
|
|
588
|
+
* "~/.deepagents/AGENTS.md",
|
|
589
|
+
* "./.deepagents/AGENTS.md",
|
|
590
|
+
* ],
|
|
591
|
+
* });
|
|
592
|
+
* ```
|
|
593
|
+
*/
|
|
594
|
+
declare function createMemoryMiddleware(options: MemoryMiddlewareOptions): AgentMiddleware<z$2.ZodObject<{
|
|
595
|
+
memoryContents: z$2.ZodOptional<z$2.ZodRecord<z$2.ZodString, z$2.ZodString>>;
|
|
596
|
+
}, z$2.core.$strip>, undefined, unknown, readonly (_langchain_core_tools3.ClientTool | _langchain_core_tools3.ServerTool)[]>;
|
|
597
|
+
//#endregion
|
|
598
|
+
//#region src/middleware/skills.d.ts
|
|
599
|
+
declare const MAX_SKILL_FILE_SIZE: number;
|
|
600
|
+
declare const MAX_SKILL_NAME_LENGTH = 64;
|
|
601
|
+
declare const MAX_SKILL_DESCRIPTION_LENGTH = 1024;
|
|
602
|
+
/**
|
|
603
|
+
* Metadata for a skill per Agent Skills specification.
|
|
604
|
+
*/
|
|
605
|
+
interface SkillMetadata$1 {
|
|
606
|
+
/** Skill identifier (max 64 chars, lowercase alphanumeric and hyphens) */
|
|
607
|
+
name: string;
|
|
608
|
+
/** What the skill does (max 1024 chars) */
|
|
609
|
+
description: string;
|
|
610
|
+
/** Path to the SKILL.md file in the backend */
|
|
611
|
+
path: string;
|
|
612
|
+
/** License name or reference to bundled license file */
|
|
613
|
+
license?: string | null;
|
|
614
|
+
/** Environment requirements (max 500 chars) */
|
|
615
|
+
compatibility?: string | null;
|
|
616
|
+
/** Arbitrary key-value mapping for additional metadata */
|
|
617
|
+
metadata?: Record<string, string>;
|
|
618
|
+
/** List of pre-approved tools (experimental) */
|
|
619
|
+
allowedTools?: string[];
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* Options for the skills middleware.
|
|
623
|
+
*/
|
|
624
|
+
interface SkillsMiddlewareOptions {
|
|
625
|
+
/**
|
|
626
|
+
* Backend instance or factory function for file operations.
|
|
627
|
+
* Use a factory for StateBackend since it requires runtime state.
|
|
628
|
+
*/
|
|
629
|
+
backend: BackendProtocol | BackendFactory | ((config: {
|
|
630
|
+
state: unknown;
|
|
631
|
+
store?: BaseStore;
|
|
632
|
+
}) => StateBackend);
|
|
633
|
+
/**
|
|
634
|
+
* List of skill source paths to load (e.g., ["/skills/user/", "/skills/project/"]).
|
|
635
|
+
* Paths must use POSIX conventions (forward slashes).
|
|
636
|
+
* Later sources override earlier ones for skills with the same name (last one wins).
|
|
637
|
+
*/
|
|
638
|
+
sources: string[];
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Create backend-agnostic middleware for loading and exposing agent skills.
|
|
642
|
+
*
|
|
643
|
+
* This middleware loads skills from configurable backend sources and injects
|
|
644
|
+
* skill metadata into the system prompt. It implements the progressive disclosure
|
|
645
|
+
* pattern: skill names and descriptions are shown in the prompt, but the agent
|
|
646
|
+
* reads full SKILL.md content only when needed.
|
|
647
|
+
*
|
|
648
|
+
* @param options - Configuration options
|
|
649
|
+
* @returns AgentMiddleware for skills loading and injection
|
|
650
|
+
*
|
|
651
|
+
* @example
|
|
652
|
+
* ```typescript
|
|
653
|
+
* const middleware = createSkillsMiddleware({
|
|
654
|
+
* backend: new FilesystemBackend({ rootDir: "/" }),
|
|
655
|
+
* sources: ["/skills/user/", "/skills/project/"],
|
|
656
|
+
* });
|
|
657
|
+
* ```
|
|
658
|
+
*/
|
|
659
|
+
declare function createSkillsMiddleware(options: SkillsMiddlewareOptions): AgentMiddleware<z$2.ZodObject<{
|
|
660
|
+
skillsMetadata: z$2.ZodOptional<z$2.ZodArray<z$2.ZodObject<{
|
|
661
|
+
name: z$2.ZodString;
|
|
662
|
+
description: z$2.ZodString;
|
|
663
|
+
path: z$2.ZodString;
|
|
664
|
+
license: z$2.ZodOptional<z$2.ZodNullable<z$2.ZodString>>;
|
|
665
|
+
compatibility: z$2.ZodOptional<z$2.ZodNullable<z$2.ZodString>>;
|
|
666
|
+
metadata: z$2.ZodOptional<z$2.ZodRecord<z$2.ZodString, z$2.ZodString>>;
|
|
667
|
+
allowedTools: z$2.ZodOptional<z$2.ZodArray<z$2.ZodString>>;
|
|
668
|
+
}, z$2.core.$strip>>>;
|
|
669
|
+
}, z$2.core.$strip>, undefined, unknown, readonly (_langchain_core_tools3.ClientTool | _langchain_core_tools3.ServerTool)[]>;
|
|
670
|
+
//#endregion
|
|
564
671
|
//#region src/backends/store.d.ts
|
|
565
672
|
/**
|
|
566
673
|
* Backend that stores files in LangGraph's BaseStore (persistent).
|
|
@@ -629,13 +736,6 @@ declare class StoreBackend implements BackendProtocol {
|
|
|
629
736
|
* @returns Formatted file content with line numbers, or error message
|
|
630
737
|
*/
|
|
631
738
|
read(filePath: string, offset?: number, limit?: number): Promise<string>;
|
|
632
|
-
/**
|
|
633
|
-
* Read file content as raw FileData.
|
|
634
|
-
*
|
|
635
|
-
* @param filePath - Absolute file path
|
|
636
|
-
* @returns Raw file content as FileData
|
|
637
|
-
*/
|
|
638
|
-
readRaw(filePath: string): Promise<FileData>;
|
|
639
739
|
/**
|
|
640
740
|
* Create a new file with content.
|
|
641
741
|
* Returns WriteResult. External storage sets filesUpdate=null.
|
|
@@ -717,13 +817,6 @@ declare class FilesystemBackend implements BackendProtocol {
|
|
|
717
817
|
* @returns Formatted file content with line numbers, or error message
|
|
718
818
|
*/
|
|
719
819
|
read(filePath: string, offset?: number, limit?: number): Promise<string>;
|
|
720
|
-
/**
|
|
721
|
-
* Read file content as raw FileData.
|
|
722
|
-
*
|
|
723
|
-
* @param filePath - Absolute file path
|
|
724
|
-
* @returns Raw file content as FileData
|
|
725
|
-
*/
|
|
726
|
-
readRaw(filePath: string): Promise<FileData>;
|
|
727
820
|
/**
|
|
728
821
|
* Create a new file with content.
|
|
729
822
|
* Returns WriteResult. External storage sets filesUpdate=null.
|
|
@@ -807,13 +900,6 @@ declare class CompositeBackend implements BackendProtocol {
|
|
|
807
900
|
* @returns Formatted file content with line numbers, or error message
|
|
808
901
|
*/
|
|
809
902
|
read(filePath: string, offset?: number, limit?: number): Promise<string>;
|
|
810
|
-
/**
|
|
811
|
-
* Read file content as raw FileData.
|
|
812
|
-
*
|
|
813
|
-
* @param filePath - Absolute file path
|
|
814
|
-
* @returns Raw file content as FileData
|
|
815
|
-
*/
|
|
816
|
-
readRaw(filePath: string): Promise<FileData>;
|
|
817
903
|
/**
|
|
818
904
|
* Structured search results or error string for invalid input.
|
|
819
905
|
*/
|
|
@@ -909,13 +995,6 @@ declare abstract class BaseSandbox implements SandboxBackendProtocol {
|
|
|
909
995
|
* @returns Formatted file content with line numbers, or error message
|
|
910
996
|
*/
|
|
911
997
|
read(filePath: string, offset?: number, limit?: number): Promise<string>;
|
|
912
|
-
/**
|
|
913
|
-
* Read file content as raw FileData.
|
|
914
|
-
*
|
|
915
|
-
* @param filePath - Absolute file path
|
|
916
|
-
* @returns Raw file content as FileData
|
|
917
|
-
*/
|
|
918
|
-
readRaw(filePath: string): Promise<FileData>;
|
|
919
998
|
/**
|
|
920
999
|
* Structured search results or error string for invalid input.
|
|
921
1000
|
*/
|
|
@@ -935,6 +1014,7 @@ declare abstract class BaseSandbox implements SandboxBackendProtocol {
|
|
|
935
1014
|
}
|
|
936
1015
|
//#endregion
|
|
937
1016
|
//#region src/types.d.ts
|
|
1017
|
+
type AnyAnnotationRoot = AnnotationRoot<any>;
|
|
938
1018
|
/**
|
|
939
1019
|
* Helper type to extract middleware from a SubAgent definition
|
|
940
1020
|
* Handles both mutable and readonly middleware arrays
|
|
@@ -954,6 +1034,138 @@ type InferSubAgentMiddlewareStates<T extends readonly (SubAgent | CompiledSubAge
|
|
|
954
1034
|
* Combined state type including custom middleware and subagent middleware states
|
|
955
1035
|
*/
|
|
956
1036
|
type MergedDeepAgentState<TMiddleware extends readonly AgentMiddleware[], TSubagents extends readonly (SubAgent | CompiledSubAgent)[]> = InferMiddlewareStates<TMiddleware> & InferSubAgentMiddlewareStates<TSubagents>;
|
|
1037
|
+
/**
|
|
1038
|
+
* Type bag that extends AgentTypeConfig with subagent type information.
|
|
1039
|
+
*
|
|
1040
|
+
* This interface bundles all the generic type parameters used throughout the deep agent system
|
|
1041
|
+
* including subagent types for type-safe streaming and delegation.
|
|
1042
|
+
*
|
|
1043
|
+
* @typeParam TResponse - The structured response type when using `responseFormat`.
|
|
1044
|
+
* @typeParam TState - The custom state schema type.
|
|
1045
|
+
* @typeParam TContext - The context schema type.
|
|
1046
|
+
* @typeParam TMiddleware - The middleware array type.
|
|
1047
|
+
* @typeParam TTools - The combined tools type.
|
|
1048
|
+
* @typeParam TSubagents - The subagents array type for type-safe streaming.
|
|
1049
|
+
*
|
|
1050
|
+
* @example
|
|
1051
|
+
* ```typescript
|
|
1052
|
+
* const agent = createDeepAgent({
|
|
1053
|
+
* middleware: [ResearchMiddleware],
|
|
1054
|
+
* subagents: [
|
|
1055
|
+
* { name: "researcher", description: "...", middleware: [CounterMiddleware] }
|
|
1056
|
+
* ] as const,
|
|
1057
|
+
* });
|
|
1058
|
+
*
|
|
1059
|
+
* // Type inference for streaming
|
|
1060
|
+
* type Types = InferDeepAgentType<typeof agent, "Subagents">;
|
|
1061
|
+
* ```
|
|
1062
|
+
*/
|
|
1063
|
+
interface DeepAgentTypeConfig<TResponse extends Record<string, any> | ResponseFormatUndefined = Record<string, any> | ResponseFormatUndefined, TState extends AnyAnnotationRoot | InteropZodObject | undefined = AnyAnnotationRoot | InteropZodObject | undefined, TContext extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot | InteropZodObject, TMiddleware extends readonly AgentMiddleware[] = readonly AgentMiddleware[], TTools extends readonly (ClientTool | ServerTool)[] = readonly (ClientTool | ServerTool)[], TSubagents extends readonly (SubAgent | CompiledSubAgent)[] = readonly (SubAgent | CompiledSubAgent)[]> extends AgentTypeConfig<TResponse, TState, TContext, TMiddleware, TTools> {
|
|
1064
|
+
/** The subagents array type for type-safe streaming */
|
|
1065
|
+
Subagents: TSubagents;
|
|
1066
|
+
}
|
|
1067
|
+
/**
|
|
1068
|
+
* Default type configuration for deep agents.
|
|
1069
|
+
* Used when no explicit type parameters are provided.
|
|
1070
|
+
*/
|
|
1071
|
+
interface DefaultDeepAgentTypeConfig extends DeepAgentTypeConfig {
|
|
1072
|
+
Response: Record<string, any>;
|
|
1073
|
+
State: undefined;
|
|
1074
|
+
Context: AnyAnnotationRoot;
|
|
1075
|
+
Middleware: readonly AgentMiddleware[];
|
|
1076
|
+
Tools: readonly (ClientTool | ServerTool)[];
|
|
1077
|
+
Subagents: readonly (SubAgent | CompiledSubAgent)[];
|
|
1078
|
+
}
|
|
1079
|
+
/**
|
|
1080
|
+
* DeepAgent extends ReactAgent with additional subagent type information.
|
|
1081
|
+
*
|
|
1082
|
+
* This type wraps ReactAgent but includes the DeepAgentTypeConfig which
|
|
1083
|
+
* contains subagent types for type-safe streaming and delegation.
|
|
1084
|
+
*
|
|
1085
|
+
* @typeParam TTypes - The DeepAgentTypeConfig containing all type parameters
|
|
1086
|
+
*
|
|
1087
|
+
* @example
|
|
1088
|
+
* ```typescript
|
|
1089
|
+
* const agent: DeepAgent<DeepAgentTypeConfig<...>> = createDeepAgent({ ... });
|
|
1090
|
+
*
|
|
1091
|
+
* // Access subagent types for streaming
|
|
1092
|
+
* type Subagents = InferDeepAgentSubagents<typeof agent>;
|
|
1093
|
+
* ```
|
|
1094
|
+
*/
|
|
1095
|
+
type DeepAgent<TTypes extends DeepAgentTypeConfig = DeepAgentTypeConfig> = ReactAgent<TTypes> & {
|
|
1096
|
+
/** Type brand for DeepAgent type inference */
|
|
1097
|
+
readonly "~deepAgentTypes": TTypes;
|
|
1098
|
+
};
|
|
1099
|
+
/**
|
|
1100
|
+
* Helper type to resolve a DeepAgentTypeConfig from either:
|
|
1101
|
+
* - A DeepAgentTypeConfig directly
|
|
1102
|
+
* - A DeepAgent instance (using `typeof agent`)
|
|
1103
|
+
*
|
|
1104
|
+
* @example
|
|
1105
|
+
* ```typescript
|
|
1106
|
+
* const agent = createDeepAgent({ ... });
|
|
1107
|
+
* type Types = ResolveDeepAgentTypeConfig<typeof agent>;
|
|
1108
|
+
* ```
|
|
1109
|
+
*/
|
|
1110
|
+
type ResolveDeepAgentTypeConfig<T> = T extends {
|
|
1111
|
+
"~deepAgentTypes": infer Types;
|
|
1112
|
+
} ? Types extends DeepAgentTypeConfig ? Types : never : T extends DeepAgentTypeConfig ? T : never;
|
|
1113
|
+
/**
|
|
1114
|
+
* Helper type to extract any property from a DeepAgentTypeConfig or DeepAgent.
|
|
1115
|
+
*
|
|
1116
|
+
* @typeParam T - The DeepAgentTypeConfig or DeepAgent to extract from
|
|
1117
|
+
* @typeParam K - The property key to extract
|
|
1118
|
+
*
|
|
1119
|
+
* @example
|
|
1120
|
+
* ```typescript
|
|
1121
|
+
* const agent = createDeepAgent({ subagents: [...] });
|
|
1122
|
+
* type Subagents = InferDeepAgentType<typeof agent, "Subagents">;
|
|
1123
|
+
* ```
|
|
1124
|
+
*/
|
|
1125
|
+
type InferDeepAgentType<T, K extends keyof DeepAgentTypeConfig> = ResolveDeepAgentTypeConfig<T>[K];
|
|
1126
|
+
/**
|
|
1127
|
+
* Shorthand helper to extract the Subagents type from a DeepAgentTypeConfig or DeepAgent.
|
|
1128
|
+
*
|
|
1129
|
+
* @example
|
|
1130
|
+
* ```typescript
|
|
1131
|
+
* const agent = createDeepAgent({ subagents: [subagent1, subagent2] });
|
|
1132
|
+
* type Subagents = InferDeepAgentSubagents<typeof agent>;
|
|
1133
|
+
* ```
|
|
1134
|
+
*/
|
|
1135
|
+
type InferDeepAgentSubagents<T> = InferDeepAgentType<T, "Subagents">;
|
|
1136
|
+
/**
|
|
1137
|
+
* Helper type to extract a subagent by name from a DeepAgent.
|
|
1138
|
+
*
|
|
1139
|
+
* @typeParam T - The DeepAgent to extract from
|
|
1140
|
+
* @typeParam TName - The name of the subagent to extract
|
|
1141
|
+
*
|
|
1142
|
+
* @example
|
|
1143
|
+
* ```typescript
|
|
1144
|
+
* const agent = createDeepAgent({
|
|
1145
|
+
* subagents: [
|
|
1146
|
+
* { name: "researcher", description: "...", middleware: [ResearchMiddleware] }
|
|
1147
|
+
* ] as const,
|
|
1148
|
+
* });
|
|
1149
|
+
*
|
|
1150
|
+
* type ResearcherAgent = InferSubagentByName<typeof agent, "researcher">;
|
|
1151
|
+
* ```
|
|
1152
|
+
*/
|
|
1153
|
+
type InferSubagentByName<T, TName extends string> = InferDeepAgentSubagents<T> extends readonly (infer SA)[] ? SA extends {
|
|
1154
|
+
name: TName;
|
|
1155
|
+
} ? SA : never : never;
|
|
1156
|
+
/**
|
|
1157
|
+
* Helper type to extract the ReactAgent type from a subagent definition.
|
|
1158
|
+
* This is useful for type-safe streaming of subagent events.
|
|
1159
|
+
*
|
|
1160
|
+
* @typeParam TSubagent - The subagent definition
|
|
1161
|
+
*
|
|
1162
|
+
* @example
|
|
1163
|
+
* ```typescript
|
|
1164
|
+
* type SubagentMiddleware = ExtractSubAgentMiddleware<typeof subagent>;
|
|
1165
|
+
* type SubagentState = InferMiddlewareStates<SubagentMiddleware>;
|
|
1166
|
+
* ```
|
|
1167
|
+
*/
|
|
1168
|
+
type InferSubagentReactAgentType<TSubagent extends SubAgent | CompiledSubAgent> = TSubagent extends CompiledSubAgent ? TSubagent["runnable"] : TSubagent extends SubAgent ? ReactAgent<AgentTypeConfig<ResponseFormatUndefined, undefined, AnyAnnotationRoot, ExtractSubAgentMiddleware<TSubagent>, readonly []>> : never;
|
|
957
1169
|
/**
|
|
958
1170
|
* Configuration parameters for creating a Deep Agent
|
|
959
1171
|
* Matches Python's create_deep_agent parameters
|
|
@@ -996,6 +1208,44 @@ interface CreateDeepAgentParams<TResponse extends ResponseFormat = ResponseForma
|
|
|
996
1208
|
interruptOn?: Record<string, boolean | InterruptOnConfig>;
|
|
997
1209
|
/** The name of the agent */
|
|
998
1210
|
name?: string;
|
|
1211
|
+
/**
|
|
1212
|
+
* Optional list of memory file paths (AGENTS.md files) to load
|
|
1213
|
+
* (e.g., ["~/.deepagents/AGENTS.md", "./.deepagents/AGENTS.md"]).
|
|
1214
|
+
* Display names are automatically derived from paths.
|
|
1215
|
+
* Memory is loaded at agent startup and added into the system prompt.
|
|
1216
|
+
*/
|
|
1217
|
+
memory?: string[];
|
|
1218
|
+
/**
|
|
1219
|
+
* Optional list of skill source paths (e.g., `["/skills/user/", "/skills/project/"]`).
|
|
1220
|
+
*
|
|
1221
|
+
* Paths use POSIX conventions (forward slashes) and are relative to the backend's root.
|
|
1222
|
+
* Later sources override earlier ones for skills with the same name (last one wins).
|
|
1223
|
+
*
|
|
1224
|
+
* @example
|
|
1225
|
+
* ```typescript
|
|
1226
|
+
* // With FilesystemBackend - skills loaded from disk
|
|
1227
|
+
* const agent = await createDeepAgent({
|
|
1228
|
+
* backend: new FilesystemBackend({ rootDir: "/home/user/.deepagents" }),
|
|
1229
|
+
* skills: ["/skills/"],
|
|
1230
|
+
* });
|
|
1231
|
+
*
|
|
1232
|
+
* // With StateBackend - skills provided in state
|
|
1233
|
+
* const agent = await createDeepAgent({
|
|
1234
|
+
* skills: ["/skills/"],
|
|
1235
|
+
* });
|
|
1236
|
+
* const result = await agent.invoke({
|
|
1237
|
+
* messages: [...],
|
|
1238
|
+
* files: {
|
|
1239
|
+
* "/skills/my-skill/SKILL.md": {
|
|
1240
|
+
* content: ["---", "name: my-skill", "description: ...", "---", "# My Skill"],
|
|
1241
|
+
* created_at: new Date().toISOString(),
|
|
1242
|
+
* modified_at: new Date().toISOString(),
|
|
1243
|
+
* },
|
|
1244
|
+
* },
|
|
1245
|
+
* });
|
|
1246
|
+
* ```
|
|
1247
|
+
*/
|
|
1248
|
+
skills?: string[];
|
|
999
1249
|
}
|
|
1000
1250
|
//#endregion
|
|
1001
1251
|
//#region src/agent.d.ts
|
|
@@ -1030,7 +1280,7 @@ interface CreateDeepAgentParams<TResponse extends ResponseFormat = ResponseForma
|
|
|
1030
1280
|
* // result.research is properly typed as string
|
|
1031
1281
|
* ```
|
|
1032
1282
|
*/
|
|
1033
|
-
declare function createDeepAgent<TResponse extends ResponseFormat = ResponseFormat, 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>):
|
|
1283
|
+
declare function createDeepAgent<TResponse extends ResponseFormat = ResponseFormat, 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<TResponse, undefined, ContextSchema, readonly [AgentMiddleware<zod_v30.ZodObject<{
|
|
1034
1284
|
todos: zod_v30.ZodDefault<zod_v30.ZodArray<zod_v30.ZodObject<{
|
|
1035
1285
|
content: zod_v30.ZodString;
|
|
1036
1286
|
status: zod_v30.ZodEnum<["pending", "in_progress", "completed"]>;
|
|
@@ -1088,7 +1338,17 @@ declare function createDeepAgent<TResponse extends ResponseFormat = ResponseForm
|
|
|
1088
1338
|
status: "completed" | "in_progress" | "pending";
|
|
1089
1339
|
}[];
|
|
1090
1340
|
messages: _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>>[];
|
|
1091
|
-
}, string>, "write_todos">]>, AgentMiddleware<zod0.ZodObject<{
|
|
1341
|
+
}, string>, "write_todos">]>, ...(AgentMiddleware<zod0.ZodObject<{
|
|
1342
|
+
skillsMetadata: zod0.ZodOptional<zod0.ZodArray<zod0.ZodObject<{
|
|
1343
|
+
name: zod0.ZodString;
|
|
1344
|
+
description: zod0.ZodString;
|
|
1345
|
+
path: zod0.ZodString;
|
|
1346
|
+
license: zod0.ZodOptional<zod0.ZodNullable<zod0.ZodString>>;
|
|
1347
|
+
compatibility: zod0.ZodOptional<zod0.ZodNullable<zod0.ZodString>>;
|
|
1348
|
+
metadata: zod0.ZodOptional<zod0.ZodRecord<zod0.ZodString, zod0.ZodString>>;
|
|
1349
|
+
allowedTools: zod0.ZodOptional<zod0.ZodArray<zod0.ZodString>>;
|
|
1350
|
+
}, zod_v4_core0.$strip>>>;
|
|
1351
|
+
}, zod_v4_core0.$strip>, undefined, unknown, readonly (ClientTool | ServerTool)[]> | AgentMiddleware<zod0.ZodObject<{
|
|
1092
1352
|
files: zod0.ZodDefault<zod0.ZodRecord<zod0.ZodString, zod0.ZodObject<{
|
|
1093
1353
|
content: zod0.ZodArray<zod0.ZodString>;
|
|
1094
1354
|
created_at: zod0.ZodString;
|
|
@@ -1169,22 +1429,7 @@ declare function createDeepAgent<TResponse extends ResponseFormat = ResponseForm
|
|
|
1169
1429
|
command: string;
|
|
1170
1430
|
}, {
|
|
1171
1431
|
command: string;
|
|
1172
|
-
}, string, "execute">)[]
|
|
1173
|
-
description: zod_v30.ZodString;
|
|
1174
|
-
subagent_type: zod_v30.ZodString;
|
|
1175
|
-
}, "strip", zod_v30.ZodTypeAny, {
|
|
1176
|
-
description: string;
|
|
1177
|
-
subagent_type: string;
|
|
1178
|
-
}, {
|
|
1179
|
-
description: string;
|
|
1180
|
-
subagent_type: string;
|
|
1181
|
-
}>, {
|
|
1182
|
-
description: string;
|
|
1183
|
-
subagent_type: string;
|
|
1184
|
-
}, {
|
|
1185
|
-
description: string;
|
|
1186
|
-
subagent_type: string;
|
|
1187
|
-
}, string | _Command.Command<unknown, Record<string, unknown>, string>, "task">]>, AgentMiddleware<undefined, zod_v30.ZodObject<{
|
|
1432
|
+
}, string, "execute">)[]> | AgentMiddleware<undefined, zod_v30.ZodObject<{
|
|
1188
1433
|
trigger: zod_v30.ZodOptional<zod_v30.ZodUnion<[zod_v30.ZodEffects<zod_v30.ZodObject<{
|
|
1189
1434
|
fraction: zod_v30.ZodOptional<zod_v30.ZodNumber>;
|
|
1190
1435
|
tokens: zod_v30.ZodOptional<zod_v30.ZodNumber>;
|
|
@@ -1321,7 +1566,7 @@ declare function createDeepAgent<TResponse extends ResponseFormat = ResponseForm
|
|
|
1321
1566
|
maxTokensBeforeSummary?: number | undefined;
|
|
1322
1567
|
messagesToKeep?: number | undefined;
|
|
1323
1568
|
model?: _langchain_core_language_models_base0.BaseLanguageModel<any, _langchain_core_language_models_base0.BaseLanguageModelCallOptions> | undefined;
|
|
1324
|
-
}, readonly (ClientTool | ServerTool)[]
|
|
1569
|
+
}, readonly (ClientTool | ServerTool)[]> | AgentMiddleware<undefined, zod_v30.ZodObject<{
|
|
1325
1570
|
enableCaching: zod_v30.ZodOptional<zod_v30.ZodBoolean>;
|
|
1326
1571
|
ttl: zod_v30.ZodOptional<zod_v30.ZodEnum<["5m", "1h"]>>;
|
|
1327
1572
|
minMessagesToCache: zod_v30.ZodOptional<zod_v30.ZodNumber>;
|
|
@@ -1341,7 +1586,24 @@ declare function createDeepAgent<TResponse extends ResponseFormat = ResponseForm
|
|
|
1341
1586
|
ttl?: "1h" | "5m" | undefined;
|
|
1342
1587
|
minMessagesToCache?: number | undefined;
|
|
1343
1588
|
unsupportedModelBehavior?: "ignore" | "raise" | "warn" | undefined;
|
|
1344
|
-
}, readonly (ClientTool | ServerTool)[]
|
|
1589
|
+
}, readonly (ClientTool | ServerTool)[]> | AgentMiddleware<undefined, undefined, unknown, readonly (ClientTool | ServerTool)[]> | AgentMiddleware<undefined, undefined, unknown, readonly [langchain9.DynamicStructuredTool<zod_v30.ZodObject<{
|
|
1590
|
+
description: zod_v30.ZodString;
|
|
1591
|
+
subagent_type: zod_v30.ZodString;
|
|
1592
|
+
}, "strip", zod_v30.ZodTypeAny, {
|
|
1593
|
+
description: string;
|
|
1594
|
+
subagent_type: string;
|
|
1595
|
+
}, {
|
|
1596
|
+
description: string;
|
|
1597
|
+
subagent_type: string;
|
|
1598
|
+
}>, {
|
|
1599
|
+
description: string;
|
|
1600
|
+
subagent_type: string;
|
|
1601
|
+
}, {
|
|
1602
|
+
description: string;
|
|
1603
|
+
subagent_type: string;
|
|
1604
|
+
}, string | _Command.Command<unknown, Record<string, unknown>, string>, "task">]> | AgentMiddleware<zod0.ZodObject<{
|
|
1605
|
+
memoryContents: zod0.ZodOptional<zod0.ZodRecord<zod0.ZodString, zod0.ZodString>>;
|
|
1606
|
+
}, zod_v4_core0.$strip>, undefined, unknown, readonly (ClientTool | ServerTool)[]>)[], ...TMiddleware, ...FlattenSubAgentMiddleware<TSubagents>], TTools, TSubagents>>;
|
|
1345
1607
|
//#endregion
|
|
1346
1608
|
//#region src/config.d.ts
|
|
1347
1609
|
/**
|
|
@@ -1444,36 +1706,6 @@ declare function findProjectRoot(startPath?: string): string | null;
|
|
|
1444
1706
|
*/
|
|
1445
1707
|
declare function createSettings(options?: SettingsOptions): Settings;
|
|
1446
1708
|
//#endregion
|
|
1447
|
-
//#region src/middleware/skills.d.ts
|
|
1448
|
-
/**
|
|
1449
|
-
* Options for the skills middleware.
|
|
1450
|
-
*/
|
|
1451
|
-
interface SkillsMiddlewareOptions {
|
|
1452
|
-
/** Path to the user-level skills directory (per-agent) */
|
|
1453
|
-
skillsDir: string;
|
|
1454
|
-
/** The agent identifier for path references in prompts */
|
|
1455
|
-
assistantId: string;
|
|
1456
|
-
/** Optional path to project-level skills directory */
|
|
1457
|
-
projectSkillsDir?: string;
|
|
1458
|
-
}
|
|
1459
|
-
/**
|
|
1460
|
-
* Create middleware for loading and exposing agent skills.
|
|
1461
|
-
*
|
|
1462
|
-
* This middleware implements Anthropic's agent skills pattern:
|
|
1463
|
-
* - Loads skills metadata (name, description) from YAML frontmatter at session start
|
|
1464
|
-
* - Injects skills list into system prompt for discoverability
|
|
1465
|
-
* - Agent reads full SKILL.md content when a skill is relevant (progressive disclosure)
|
|
1466
|
-
*
|
|
1467
|
-
* Supports both user-level and project-level skills:
|
|
1468
|
-
* - User skills: ~/.deepagents/{AGENT_NAME}/skills/
|
|
1469
|
-
* - Project skills: {PROJECT_ROOT}/.deepagents/skills/
|
|
1470
|
-
* - Project skills override user skills with the same name
|
|
1471
|
-
*
|
|
1472
|
-
* @param options - Configuration options
|
|
1473
|
-
* @returns AgentMiddleware for skills loading and injection
|
|
1474
|
-
*/
|
|
1475
|
-
declare function createSkillsMiddleware(options: SkillsMiddlewareOptions): AgentMiddleware<any, undefined, unknown, readonly (_langchain_core_tools3.ClientTool | _langchain_core_tools3.ServerTool)[]>;
|
|
1476
|
-
//#endregion
|
|
1477
1709
|
//#region src/middleware/agent-memory.d.ts
|
|
1478
1710
|
/**
|
|
1479
1711
|
* Options for the agent memory middleware.
|
|
@@ -1499,36 +1731,6 @@ interface AgentMemoryMiddlewareOptions {
|
|
|
1499
1731
|
declare function createAgentMemoryMiddleware(options: AgentMemoryMiddlewareOptions): AgentMiddleware<any, undefined, unknown, readonly (_langchain_core_tools3.ClientTool | _langchain_core_tools3.ServerTool)[]>;
|
|
1500
1732
|
//#endregion
|
|
1501
1733
|
//#region src/skills/loader.d.ts
|
|
1502
|
-
/**
|
|
1503
|
-
* Skill loader for parsing and loading agent skills from SKILL.md files.
|
|
1504
|
-
*
|
|
1505
|
-
* This module implements Anthropic's agent skills pattern with YAML frontmatter parsing.
|
|
1506
|
-
* Each skill is a directory containing a SKILL.md file with:
|
|
1507
|
-
* - YAML frontmatter (name, description required)
|
|
1508
|
-
* - Markdown instructions for the agent
|
|
1509
|
-
* - Optional supporting files (scripts, configs, etc.)
|
|
1510
|
-
*
|
|
1511
|
-
* @example
|
|
1512
|
-
* ```markdown
|
|
1513
|
-
* ---
|
|
1514
|
-
* name: web-research
|
|
1515
|
-
* description: Structured approach to conducting thorough web research
|
|
1516
|
-
* ---
|
|
1517
|
-
*
|
|
1518
|
-
* # Web Research Skill
|
|
1519
|
-
*
|
|
1520
|
-
* ## When to Use
|
|
1521
|
-
* - User asks you to research a topic
|
|
1522
|
-
* ...
|
|
1523
|
-
* ```
|
|
1524
|
-
*
|
|
1525
|
-
* @see https://agentskills.io/specification
|
|
1526
|
-
*/
|
|
1527
|
-
/** Maximum size for SKILL.md files (10MB) */
|
|
1528
|
-
declare const MAX_SKILL_FILE_SIZE: number;
|
|
1529
|
-
/** Agent Skills spec constraints */
|
|
1530
|
-
declare const MAX_SKILL_NAME_LENGTH = 64;
|
|
1531
|
-
declare const MAX_SKILL_DESCRIPTION_LENGTH = 1024;
|
|
1532
1734
|
/**
|
|
1533
1735
|
* Metadata for a skill per Agent Skills spec.
|
|
1534
1736
|
* @see https://agentskills.io/specification
|
|
@@ -1580,5 +1782,5 @@ declare function parseSkillMetadata(skillMdPath: string, source: "user" | "proje
|
|
|
1580
1782
|
*/
|
|
1581
1783
|
declare function listSkills(options: ListSkillsOptions): SkillMetadata[];
|
|
1582
1784
|
//#endregion
|
|
1583
|
-
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 MergedDeepAgentState, 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 };
|
|
1785
|
+
export { type AgentMemoryMiddlewareOptions, type BackendFactory, type BackendProtocol, BaseSandbox, type CompiledSubAgent, CompositeBackend, type CreateDeepAgentParams, 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, 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 Settings, type SettingsOptions, type SkillMetadata$1 as SkillMetadata, type SkillsMiddlewareOptions, StateBackend, StoreBackend, type SubAgent, type SubAgentMiddlewareOptions, type WriteResult, createAgentMemoryMiddleware, createDeepAgent, createFilesystemMiddleware, createMemoryMiddleware, createPatchToolCallsMiddleware, createSettings, createSkillsMiddleware, createSubAgentMiddleware, findProjectRoot, isSandboxBackend, listSkills, parseSkillMetadata };
|
|
1584
1786
|
//# sourceMappingURL=index.d.ts.map
|