deepagents 1.4.2 → 1.5.1

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.cts CHANGED
@@ -1,8 +1,8 @@
1
1
  import * as zod_v30 from "zod/v3";
2
- import { z } from "zod/v3";
3
2
  import * as langchain9 from "langchain";
4
3
  import { AgentMiddleware, AgentMiddleware as AgentMiddleware$1, AgentTypeConfig, InferMiddlewareStates, InterruptOnConfig, ReactAgent, ResponseFormat, ResponseFormatUndefined, StructuredTool, SystemMessage, ToolMessage } from "langchain";
5
4
  import * as zod0 from "zod";
5
+ import { z } from "zod";
6
6
  import * as zod_v4_core0 from "zod/v4/core";
7
7
  import { BaseCheckpointSaver, BaseStore } from "@langchain/langgraph-checkpoint";
8
8
  import * as _langchain_core_language_models_base0 from "@langchain/core/language_models/base";
@@ -163,7 +163,7 @@ interface BackendProtocol {
163
163
  *
164
164
  * @param filePath - Absolute file path
165
165
  * @param offset - Line offset to start reading from (0-indexed), default 0
166
- * @param limit - Maximum number of lines to read, default 2000
166
+ * @param limit - Maximum number of lines to read, default 500
167
167
  * @returns Formatted file content with line numbers, or error message
168
168
  */
169
169
  read(filePath: string, offset?: number, limit?: number): MaybePromise<string>;
@@ -213,18 +213,20 @@ interface BackendProtocol {
213
213
  edit(filePath: string, oldString: string, newString: string, replaceAll?: boolean): MaybePromise<EditResult>;
214
214
  /**
215
215
  * Upload multiple files.
216
+ * Optional - backends that don't support file upload can omit this.
216
217
  *
217
218
  * @param files - List of [path, content] tuples to upload
218
219
  * @returns List of FileUploadResponse objects, one per input file
219
220
  */
220
- uploadFiles(files: Array<[string, Uint8Array]>): MaybePromise<FileUploadResponse[]>;
221
+ uploadFiles?(files: Array<[string, Uint8Array]>): MaybePromise<FileUploadResponse[]>;
221
222
  /**
222
223
  * Download multiple files.
224
+ * Optional - backends that don't support file download can omit this.
223
225
  *
224
226
  * @param paths - List of file paths to download
225
227
  * @returns List of FileDownloadResponse objects, one per input path
226
228
  */
227
- downloadFiles(paths: string[]): MaybePromise<FileDownloadResponse[]>;
229
+ downloadFiles?(paths: string[]): MaybePromise<FileDownloadResponse[]>;
228
230
  }
229
231
  /**
230
232
  * Protocol for sandboxed backends with isolated runtime.
@@ -442,16 +444,10 @@ interface SubAgentMiddlewareOptions {
442
444
  /**
443
445
  * Create subagent middleware with task tool
444
446
  */
445
- declare function createSubAgentMiddleware(options: SubAgentMiddlewareOptions): AgentMiddleware$1<undefined, undefined, unknown, readonly [langchain9.DynamicStructuredTool<z.ZodObject<{
446
- description: z.ZodString;
447
- subagent_type: z.ZodString;
448
- }, "strip", z.ZodTypeAny, {
449
- description: string;
450
- subagent_type: string;
451
- }, {
452
- description: string;
453
- subagent_type: string;
454
- }>, {
447
+ declare function createSubAgentMiddleware(options: SubAgentMiddlewareOptions): AgentMiddleware$1<undefined, undefined, unknown, readonly [langchain9.DynamicStructuredTool<z$1.ZodObject<{
448
+ description: z$1.ZodString;
449
+ subagent_type: z$1.ZodString;
450
+ }, z$1.core.$strip>, {
455
451
  description: string;
456
452
  subagent_type: string;
457
453
  }, {
@@ -564,6 +560,123 @@ declare class StateBackend implements BackendProtocol {
564
560
  downloadFiles(paths: string[]): FileDownloadResponse[];
565
561
  }
566
562
  //#endregion
563
+ //#region src/middleware/memory.d.ts
564
+ /**
565
+ * Options for the memory middleware.
566
+ */
567
+ interface MemoryMiddlewareOptions {
568
+ /**
569
+ * Backend instance or factory function for file operations.
570
+ * Use a factory for StateBackend since it requires runtime state.
571
+ */
572
+ backend: BackendProtocol | BackendFactory | ((config: {
573
+ state: unknown;
574
+ store?: BaseStore;
575
+ }) => StateBackend);
576
+ /**
577
+ * List of memory file paths to load (e.g., ["~/.deepagents/AGENTS.md", "./.deepagents/AGENTS.md"]).
578
+ * Display names are automatically derived from the paths.
579
+ * Sources are loaded in order.
580
+ */
581
+ sources: string[];
582
+ }
583
+ /**
584
+ * Create middleware for loading agent memory from AGENTS.md files.
585
+ *
586
+ * Loads memory content from configured sources and injects into the system prompt.
587
+ * Supports multiple sources that are combined together.
588
+ *
589
+ * @param options - Configuration options
590
+ * @returns AgentMiddleware for memory loading and injection
591
+ *
592
+ * @example
593
+ * ```typescript
594
+ * const middleware = createMemoryMiddleware({
595
+ * backend: new FilesystemBackend({ rootDir: "/" }),
596
+ * sources: [
597
+ * "~/.deepagents/AGENTS.md",
598
+ * "./.deepagents/AGENTS.md",
599
+ * ],
600
+ * });
601
+ * ```
602
+ */
603
+ declare function createMemoryMiddleware(options: MemoryMiddlewareOptions): AgentMiddleware<z.ZodObject<{
604
+ memoryContents: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
605
+ }, z.core.$strip>, undefined, unknown, readonly (_langchain_core_tools3.ClientTool | _langchain_core_tools3.ServerTool)[]>;
606
+ //#endregion
607
+ //#region src/middleware/skills.d.ts
608
+ declare const MAX_SKILL_FILE_SIZE: number;
609
+ declare const MAX_SKILL_NAME_LENGTH = 64;
610
+ declare const MAX_SKILL_DESCRIPTION_LENGTH = 1024;
611
+ /**
612
+ * Metadata for a skill per Agent Skills specification.
613
+ */
614
+ interface SkillMetadata$1 {
615
+ /** Skill identifier (max 64 chars, lowercase alphanumeric and hyphens) */
616
+ name: string;
617
+ /** What the skill does (max 1024 chars) */
618
+ description: string;
619
+ /** Path to the SKILL.md file in the backend */
620
+ path: string;
621
+ /** License name or reference to bundled license file */
622
+ license?: string | null;
623
+ /** Environment requirements (max 500 chars) */
624
+ compatibility?: string | null;
625
+ /** Arbitrary key-value mapping for additional metadata */
626
+ metadata?: Record<string, string>;
627
+ /** List of pre-approved tools (experimental) */
628
+ allowedTools?: string[];
629
+ }
630
+ /**
631
+ * Options for the skills middleware.
632
+ */
633
+ interface SkillsMiddlewareOptions {
634
+ /**
635
+ * Backend instance or factory function for file operations.
636
+ * Use a factory for StateBackend since it requires runtime state.
637
+ */
638
+ backend: BackendProtocol | BackendFactory | ((config: {
639
+ state: unknown;
640
+ store?: BaseStore;
641
+ }) => StateBackend);
642
+ /**
643
+ * List of skill source paths to load (e.g., ["/skills/user/", "/skills/project/"]).
644
+ * Paths must use POSIX conventions (forward slashes).
645
+ * Later sources override earlier ones for skills with the same name (last one wins).
646
+ */
647
+ sources: string[];
648
+ }
649
+ /**
650
+ * Create backend-agnostic middleware for loading and exposing agent skills.
651
+ *
652
+ * This middleware loads skills from configurable backend sources and injects
653
+ * skill metadata into the system prompt. It implements the progressive disclosure
654
+ * pattern: skill names and descriptions are shown in the prompt, but the agent
655
+ * reads full SKILL.md content only when needed.
656
+ *
657
+ * @param options - Configuration options
658
+ * @returns AgentMiddleware for skills loading and injection
659
+ *
660
+ * @example
661
+ * ```typescript
662
+ * const middleware = createSkillsMiddleware({
663
+ * backend: new FilesystemBackend({ rootDir: "/" }),
664
+ * sources: ["/skills/user/", "/skills/project/"],
665
+ * });
666
+ * ```
667
+ */
668
+ declare function createSkillsMiddleware(options: SkillsMiddlewareOptions): AgentMiddleware<z.ZodObject<{
669
+ skillsMetadata: z.ZodOptional<z.ZodArray<z.ZodObject<{
670
+ name: z.ZodString;
671
+ description: z.ZodString;
672
+ path: z.ZodString;
673
+ license: z.ZodOptional<z.ZodNullable<z.ZodString>>;
674
+ compatibility: z.ZodOptional<z.ZodNullable<z.ZodString>>;
675
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
676
+ allowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
677
+ }, z.core.$strip>>>;
678
+ }, z.core.$strip>, undefined, unknown, readonly (_langchain_core_tools3.ClientTool | _langchain_core_tools3.ServerTool)[]>;
679
+ //#endregion
567
680
  //#region src/backends/store.d.ts
568
681
  /**
569
682
  * Backend that stores files in LangGraph's BaseStore (persistent).
@@ -1132,6 +1245,44 @@ interface CreateDeepAgentParams<TResponse extends ResponseFormat = ResponseForma
1132
1245
  interruptOn?: Record<string, boolean | InterruptOnConfig>;
1133
1246
  /** The name of the agent */
1134
1247
  name?: string;
1248
+ /**
1249
+ * Optional list of memory file paths (AGENTS.md files) to load
1250
+ * (e.g., ["~/.deepagents/AGENTS.md", "./.deepagents/AGENTS.md"]).
1251
+ * Display names are automatically derived from paths.
1252
+ * Memory is loaded at agent startup and added into the system prompt.
1253
+ */
1254
+ memory?: string[];
1255
+ /**
1256
+ * Optional list of skill source paths (e.g., `["/skills/user/", "/skills/project/"]`).
1257
+ *
1258
+ * Paths use POSIX conventions (forward slashes) and are relative to the backend's root.
1259
+ * Later sources override earlier ones for skills with the same name (last one wins).
1260
+ *
1261
+ * @example
1262
+ * ```typescript
1263
+ * // With FilesystemBackend - skills loaded from disk
1264
+ * const agent = await createDeepAgent({
1265
+ * backend: new FilesystemBackend({ rootDir: "/home/user/.deepagents" }),
1266
+ * skills: ["/skills/"],
1267
+ * });
1268
+ *
1269
+ * // With StateBackend - skills provided in state
1270
+ * const agent = await createDeepAgent({
1271
+ * skills: ["/skills/"],
1272
+ * });
1273
+ * const result = await agent.invoke({
1274
+ * messages: [...],
1275
+ * files: {
1276
+ * "/skills/my-skill/SKILL.md": {
1277
+ * content: ["---", "name: my-skill", "description: ...", "---", "# My Skill"],
1278
+ * created_at: new Date().toISOString(),
1279
+ * modified_at: new Date().toISOString(),
1280
+ * },
1281
+ * },
1282
+ * });
1283
+ * ```
1284
+ */
1285
+ skills?: string[];
1135
1286
  }
1136
1287
  //#endregion
1137
1288
  //#region src/agent.d.ts
@@ -1224,7 +1375,17 @@ declare function createDeepAgent<TResponse extends ResponseFormat = ResponseForm
1224
1375
  status: "completed" | "in_progress" | "pending";
1225
1376
  }[];
1226
1377
  messages: _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>>[];
1227
- }, string>, "write_todos">]>, AgentMiddleware<zod0.ZodObject<{
1378
+ }, string>, "write_todos">]>, ...(AgentMiddleware<zod0.ZodObject<{
1379
+ skillsMetadata: zod0.ZodOptional<zod0.ZodArray<zod0.ZodObject<{
1380
+ name: zod0.ZodString;
1381
+ description: zod0.ZodString;
1382
+ path: zod0.ZodString;
1383
+ license: zod0.ZodOptional<zod0.ZodNullable<zod0.ZodString>>;
1384
+ compatibility: zod0.ZodOptional<zod0.ZodNullable<zod0.ZodString>>;
1385
+ metadata: zod0.ZodOptional<zod0.ZodRecord<zod0.ZodString, zod0.ZodString>>;
1386
+ allowedTools: zod0.ZodOptional<zod0.ZodArray<zod0.ZodString>>;
1387
+ }, zod_v4_core0.$strip>>>;
1388
+ }, zod_v4_core0.$strip>, undefined, unknown, readonly (ClientTool | ServerTool)[]> | AgentMiddleware<zod0.ZodObject<{
1228
1389
  files: zod0.ZodDefault<zod0.ZodRecord<zod0.ZodString, zod0.ZodObject<{
1229
1390
  content: zod0.ZodArray<zod0.ZodString>;
1230
1391
  created_at: zod0.ZodString;
@@ -1305,22 +1466,7 @@ declare function createDeepAgent<TResponse extends ResponseFormat = ResponseForm
1305
1466
  command: string;
1306
1467
  }, {
1307
1468
  command: string;
1308
- }, string, "execute">)[]>, AgentMiddleware<undefined, undefined, unknown, readonly [langchain9.DynamicStructuredTool<zod_v30.ZodObject<{
1309
- description: zod_v30.ZodString;
1310
- subagent_type: zod_v30.ZodString;
1311
- }, "strip", zod_v30.ZodTypeAny, {
1312
- description: string;
1313
- subagent_type: string;
1314
- }, {
1315
- description: string;
1316
- subagent_type: string;
1317
- }>, {
1318
- description: string;
1319
- subagent_type: string;
1320
- }, {
1321
- description: string;
1322
- subagent_type: string;
1323
- }, string | _Command.Command<unknown, Record<string, unknown>, string>, "task">]>, AgentMiddleware<undefined, zod_v30.ZodObject<{
1469
+ }, string, "execute">)[]> | AgentMiddleware<undefined, zod_v30.ZodObject<{
1324
1470
  trigger: zod_v30.ZodOptional<zod_v30.ZodUnion<[zod_v30.ZodEffects<zod_v30.ZodObject<{
1325
1471
  fraction: zod_v30.ZodOptional<zod_v30.ZodNumber>;
1326
1472
  tokens: zod_v30.ZodOptional<zod_v30.ZodNumber>;
@@ -1457,7 +1603,7 @@ declare function createDeepAgent<TResponse extends ResponseFormat = ResponseForm
1457
1603
  maxTokensBeforeSummary?: number | undefined;
1458
1604
  messagesToKeep?: number | undefined;
1459
1605
  model?: _langchain_core_language_models_base0.BaseLanguageModel<any, _langchain_core_language_models_base0.BaseLanguageModelCallOptions> | undefined;
1460
- }, readonly (ClientTool | ServerTool)[]>, AgentMiddleware<undefined, zod_v30.ZodObject<{
1606
+ }, readonly (ClientTool | ServerTool)[]> | AgentMiddleware<undefined, zod_v30.ZodObject<{
1461
1607
  enableCaching: zod_v30.ZodOptional<zod_v30.ZodBoolean>;
1462
1608
  ttl: zod_v30.ZodOptional<zod_v30.ZodEnum<["5m", "1h"]>>;
1463
1609
  minMessagesToCache: zod_v30.ZodOptional<zod_v30.ZodNumber>;
@@ -1477,7 +1623,18 @@ declare function createDeepAgent<TResponse extends ResponseFormat = ResponseForm
1477
1623
  ttl?: "1h" | "5m" | undefined;
1478
1624
  minMessagesToCache?: number | undefined;
1479
1625
  unsupportedModelBehavior?: "ignore" | "raise" | "warn" | undefined;
1480
- }, readonly (ClientTool | ServerTool)[]>, AgentMiddleware<undefined, undefined, unknown, readonly (ClientTool | ServerTool)[]>, ...TMiddleware, ...FlattenSubAgentMiddleware<TSubagents>], TTools, TSubagents>>;
1626
+ }, readonly (ClientTool | ServerTool)[]> | AgentMiddleware<undefined, undefined, unknown, readonly (ClientTool | ServerTool)[]> | AgentMiddleware<undefined, undefined, unknown, readonly [langchain9.DynamicStructuredTool<zod0.ZodObject<{
1627
+ description: zod0.ZodString;
1628
+ subagent_type: zod0.ZodString;
1629
+ }, zod_v4_core0.$strip>, {
1630
+ description: string;
1631
+ subagent_type: string;
1632
+ }, {
1633
+ description: string;
1634
+ subagent_type: string;
1635
+ }, string | _Command.Command<unknown, Record<string, unknown>, string>, "task">]> | AgentMiddleware<zod0.ZodObject<{
1636
+ memoryContents: zod0.ZodOptional<zod0.ZodRecord<zod0.ZodString, zod0.ZodString>>;
1637
+ }, zod_v4_core0.$strip>, undefined, unknown, readonly (ClientTool | ServerTool)[]>)[], ...TMiddleware, ...FlattenSubAgentMiddleware<TSubagents>], TTools, TSubagents>>;
1481
1638
  //#endregion
1482
1639
  //#region src/config.d.ts
1483
1640
  /**
@@ -1580,36 +1737,6 @@ declare function findProjectRoot(startPath?: string): string | null;
1580
1737
  */
1581
1738
  declare function createSettings(options?: SettingsOptions): Settings;
1582
1739
  //#endregion
1583
- //#region src/middleware/skills.d.ts
1584
- /**
1585
- * Options for the skills middleware.
1586
- */
1587
- interface SkillsMiddlewareOptions {
1588
- /** Path to the user-level skills directory (per-agent) */
1589
- skillsDir: string;
1590
- /** The agent identifier for path references in prompts */
1591
- assistantId: string;
1592
- /** Optional path to project-level skills directory */
1593
- projectSkillsDir?: string;
1594
- }
1595
- /**
1596
- * Create middleware for loading and exposing agent skills.
1597
- *
1598
- * This middleware implements Anthropic's agent skills pattern:
1599
- * - Loads skills metadata (name, description) from YAML frontmatter at session start
1600
- * - Injects skills list into system prompt for discoverability
1601
- * - Agent reads full SKILL.md content when a skill is relevant (progressive disclosure)
1602
- *
1603
- * Supports both user-level and project-level skills:
1604
- * - User skills: ~/.deepagents/{AGENT_NAME}/skills/
1605
- * - Project skills: {PROJECT_ROOT}/.deepagents/skills/
1606
- * - Project skills override user skills with the same name
1607
- *
1608
- * @param options - Configuration options
1609
- * @returns AgentMiddleware for skills loading and injection
1610
- */
1611
- declare function createSkillsMiddleware(options: SkillsMiddlewareOptions): AgentMiddleware<any, undefined, unknown, readonly (_langchain_core_tools3.ClientTool | _langchain_core_tools3.ServerTool)[]>;
1612
- //#endregion
1613
1740
  //#region src/middleware/agent-memory.d.ts
1614
1741
  /**
1615
1742
  * Options for the agent memory middleware.
@@ -1635,36 +1762,6 @@ interface AgentMemoryMiddlewareOptions {
1635
1762
  declare function createAgentMemoryMiddleware(options: AgentMemoryMiddlewareOptions): AgentMiddleware<any, undefined, unknown, readonly (_langchain_core_tools3.ClientTool | _langchain_core_tools3.ServerTool)[]>;
1636
1763
  //#endregion
1637
1764
  //#region src/skills/loader.d.ts
1638
- /**
1639
- * Skill loader for parsing and loading agent skills from SKILL.md files.
1640
- *
1641
- * This module implements Anthropic's agent skills pattern with YAML frontmatter parsing.
1642
- * Each skill is a directory containing a SKILL.md file with:
1643
- * - YAML frontmatter (name, description required)
1644
- * - Markdown instructions for the agent
1645
- * - Optional supporting files (scripts, configs, etc.)
1646
- *
1647
- * @example
1648
- * ```markdown
1649
- * ---
1650
- * name: web-research
1651
- * description: Structured approach to conducting thorough web research
1652
- * ---
1653
- *
1654
- * # Web Research Skill
1655
- *
1656
- * ## When to Use
1657
- * - User asks you to research a topic
1658
- * ...
1659
- * ```
1660
- *
1661
- * @see https://agentskills.io/specification
1662
- */
1663
- /** Maximum size for SKILL.md files (10MB) */
1664
- declare const MAX_SKILL_FILE_SIZE: number;
1665
- /** Agent Skills spec constraints */
1666
- declare const MAX_SKILL_NAME_LENGTH = 64;
1667
- declare const MAX_SKILL_DESCRIPTION_LENGTH = 1024;
1668
1765
  /**
1669
1766
  * Metadata for a skill per Agent Skills spec.
1670
1767
  * @see https://agentskills.io/specification
@@ -1716,5 +1813,5 @@ declare function parseSkillMetadata(skillMdPath: string, source: "user" | "proje
1716
1813
  */
1717
1814
  declare function listSkills(options: ListSkillsOptions): SkillMetadata[];
1718
1815
  //#endregion
1719
- 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, MAX_SKILL_DESCRIPTION_LENGTH, MAX_SKILL_FILE_SIZE, MAX_SKILL_NAME_LENGTH, type MaybePromise, type MergedDeepAgentState, type ResolveDeepAgentTypeConfig, 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 };
1816
+ 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 };
1720
1817
  //# sourceMappingURL=index.d.cts.map