deepagents 1.6.2 → 1.7.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.cts CHANGED
@@ -1,17 +1,17 @@
1
1
  import * as zod_v30 from "zod/v3";
2
- import * as langchain9 from "langchain";
2
+ import * as langchain from "langchain";
3
3
  import { AgentMiddleware, AgentMiddleware as AgentMiddleware$1, AgentTypeConfig, InferMiddlewareStates, InterruptOnConfig, ReactAgent, ResponseFormat, ResponseFormatUndefined, StructuredTool, SystemMessage, ToolMessage } from "langchain";
4
- import * as _Command from "@langchain/langgraph";
4
+ import * as _langchain_langgraph0 from "@langchain/langgraph";
5
5
  import { AnnotationRoot, Command, ReducedValue, StateSchema } from "@langchain/langgraph";
6
6
  import { z } from "zod/v4";
7
7
  import { BaseCheckpointSaver, BaseStore } from "@langchain/langgraph-checkpoint";
8
8
  import * as _messages from "@langchain/core/messages";
9
- import * as zod0 from "zod";
9
+ import * as zod from "zod";
10
10
  import { z as z$1 } from "zod";
11
11
  import * as zod_v4_core0 from "zod/v4/core";
12
12
  import * as _langchain_core_language_models_base0 from "@langchain/core/language_models/base";
13
13
  import { BaseLanguageModel, LanguageModelLike } from "@langchain/core/language_models/base";
14
- import * as _langchain_core_tools1 from "@langchain/core/tools";
14
+ import * as _langchain_core_tools0 from "@langchain/core/tools";
15
15
  import { ClientTool, ServerTool, StructuredTool as StructuredTool$1 } from "@langchain/core/tools";
16
16
  import { Runnable } from "@langchain/core/runnables";
17
17
  import "@langchain/core/language_models/chat_models";
@@ -252,6 +252,214 @@ interface SandboxBackendProtocol extends BackendProtocol {
252
252
  * @returns True if the backend implements SandboxBackendProtocol
253
253
  */
254
254
  declare function isSandboxBackend(backend: BackendProtocol): backend is SandboxBackendProtocol;
255
+ /**
256
+ * Metadata for a single sandbox instance.
257
+ *
258
+ * This lightweight structure is returned from list operations and provides
259
+ * basic information about a sandbox without requiring a full connection.
260
+ *
261
+ * @typeParam MetadataT - Type of the metadata field. Providers can define
262
+ * their own interface for type-safe metadata access.
263
+ *
264
+ * @example
265
+ * ```typescript
266
+ * // Using default metadata type
267
+ * const info: SandboxInfo = {
268
+ * sandboxId: "sb_abc123",
269
+ * metadata: { status: "running", createdAt: "2024-01-15T10:30:00Z" },
270
+ * };
271
+ *
272
+ * // Using typed metadata
273
+ * interface MyMetadata {
274
+ * status: "running" | "stopped";
275
+ * createdAt: string;
276
+ * }
277
+ * const typedInfo: SandboxInfo<MyMetadata> = {
278
+ * sandboxId: "sb_abc123",
279
+ * metadata: { status: "running", createdAt: "2024-01-15T10:30:00Z" },
280
+ * };
281
+ * ```
282
+ */
283
+ interface SandboxInfo<MetadataT = Record<string, unknown>> {
284
+ /** Unique identifier for the sandbox instance */
285
+ sandboxId: string;
286
+ /** Optional provider-specific metadata (e.g., creation time, status, template) */
287
+ metadata?: MetadataT;
288
+ }
289
+ /**
290
+ * Paginated response from a sandbox list operation.
291
+ *
292
+ * This structure supports cursor-based pagination for efficiently browsing
293
+ * large collections of sandboxes.
294
+ *
295
+ * @typeParam MetadataT - Type of the metadata field in SandboxInfo items.
296
+ *
297
+ * @example
298
+ * ```typescript
299
+ * const response: SandboxListResponse = {
300
+ * items: [
301
+ * { sandboxId: "sb_001", metadata: { status: "running" } },
302
+ * { sandboxId: "sb_002", metadata: { status: "stopped" } },
303
+ * ],
304
+ * cursor: "eyJvZmZzZXQiOjEwMH0=",
305
+ * };
306
+ *
307
+ * // Fetch next page
308
+ * const nextResponse = await provider.list({ cursor: response.cursor });
309
+ * ```
310
+ */
311
+ interface SandboxListResponse<MetadataT = Record<string, unknown>> {
312
+ /** List of sandbox metadata objects for the current page */
313
+ items: SandboxInfo<MetadataT>[];
314
+ /**
315
+ * Opaque continuation token for retrieving the next page.
316
+ * null indicates no more pages available.
317
+ */
318
+ cursor: string | null;
319
+ }
320
+ /**
321
+ * Options for listing sandboxes.
322
+ */
323
+ interface SandboxListOptions {
324
+ /**
325
+ * Continuation token from a previous list() call.
326
+ * Pass undefined to start from the beginning.
327
+ */
328
+ cursor?: string;
329
+ }
330
+ /**
331
+ * Options for getting or creating a sandbox.
332
+ */
333
+ interface SandboxGetOrCreateOptions {
334
+ /**
335
+ * Unique identifier of an existing sandbox to retrieve.
336
+ * If undefined, creates a new sandbox instance.
337
+ * If provided but the sandbox doesn't exist, an error will be thrown.
338
+ */
339
+ sandboxId?: string;
340
+ }
341
+ /**
342
+ * Options for deleting a sandbox.
343
+ */
344
+ interface SandboxDeleteOptions {
345
+ /** Unique identifier of the sandbox to delete */
346
+ sandboxId: string;
347
+ }
348
+ /**
349
+ * Abstract interface for sandbox provider implementations.
350
+ *
351
+ * Defines the lifecycle management interface for sandbox providers. Implementations
352
+ * should integrate with their respective SDKs to provide standardized sandbox
353
+ * lifecycle operations (list, getOrCreate, delete).
354
+ *
355
+ * This interface separates lifecycle management from sandbox execution:
356
+ * - `SandboxProvider` handles lifecycle (list, create, delete)
357
+ * - `SandboxBackendProtocol` handles execution (execute, file operations)
358
+ *
359
+ * @typeParam MetadataT - Type of the metadata field in sandbox listings.
360
+ * Providers can define their own interface for type-safe metadata access.
361
+ *
362
+ * @example
363
+ * ```typescript
364
+ * interface MyMetadata {
365
+ * status: "running" | "stopped";
366
+ * template: string;
367
+ * }
368
+ *
369
+ * class MySandboxProvider implements SandboxProvider<MyMetadata> {
370
+ * async list(options?: SandboxListOptions): Promise<SandboxListResponse<MyMetadata>> {
371
+ * // Query provider API
372
+ * return { items: [...], cursor: null };
373
+ * }
374
+ *
375
+ * async getOrCreate(options?: SandboxGetOrCreateOptions): Promise<SandboxBackendProtocol> {
376
+ * if (options?.sandboxId) {
377
+ * return this.get(options.sandboxId);
378
+ * }
379
+ * return this.create();
380
+ * }
381
+ *
382
+ * async delete(options: SandboxDeleteOptions): Promise<void> {
383
+ * // Idempotent - no error if already deleted
384
+ * await this.client.delete(options.sandboxId);
385
+ * }
386
+ * }
387
+ *
388
+ * // Usage
389
+ * const provider = new MySandboxProvider();
390
+ * const sandbox = await provider.getOrCreate();
391
+ * const result = await sandbox.execute("echo hello");
392
+ * await provider.delete({ sandboxId: sandbox.id });
393
+ * ```
394
+ */
395
+ interface SandboxProvider<MetadataT = Record<string, unknown>> {
396
+ /**
397
+ * List available sandboxes with optional pagination.
398
+ *
399
+ * @param options - Optional list options including cursor for pagination
400
+ * @returns Paginated list of sandbox metadata
401
+ *
402
+ * @example
403
+ * ```typescript
404
+ * // First page
405
+ * const response = await provider.list();
406
+ * for (const sandbox of response.items) {
407
+ * console.log(sandbox.sandboxId);
408
+ * }
409
+ *
410
+ * // Next page if available
411
+ * if (response.cursor) {
412
+ * const nextPage = await provider.list({ cursor: response.cursor });
413
+ * }
414
+ * ```
415
+ */
416
+ list(options?: SandboxListOptions): Promise<SandboxListResponse<MetadataT>>;
417
+ /**
418
+ * Get an existing sandbox or create a new one.
419
+ *
420
+ * If sandboxId is provided, retrieves the existing sandbox. If the sandbox
421
+ * doesn't exist, throws an error (does NOT create a new one).
422
+ *
423
+ * If sandboxId is undefined, creates a new sandbox instance.
424
+ *
425
+ * @param options - Optional options including sandboxId to retrieve
426
+ * @returns A sandbox instance implementing SandboxBackendProtocol
427
+ * @throws Error if sandboxId is provided but the sandbox doesn't exist
428
+ *
429
+ * @example
430
+ * ```typescript
431
+ * // Create a new sandbox
432
+ * const sandbox = await provider.getOrCreate();
433
+ * console.log(sandbox.id); // "sb_new123"
434
+ *
435
+ * // Reconnect to existing sandbox
436
+ * const existing = await provider.getOrCreate({ sandboxId: "sb_new123" });
437
+ *
438
+ * // Use the sandbox
439
+ * const result = await sandbox.execute("node --version");
440
+ * ```
441
+ */
442
+ getOrCreate(options?: SandboxGetOrCreateOptions): Promise<SandboxBackendProtocol>;
443
+ /**
444
+ * Delete a sandbox instance.
445
+ *
446
+ * This permanently destroys the sandbox and all its associated data.
447
+ * The operation is idempotent - calling delete on a non-existent sandbox
448
+ * should succeed without raising an error.
449
+ *
450
+ * @param options - Options including the sandboxId to delete
451
+ *
452
+ * @example
453
+ * ```typescript
454
+ * // Simple deletion
455
+ * await provider.delete({ sandboxId: "sb_123" });
456
+ *
457
+ * // Safe to call multiple times (idempotent)
458
+ * await provider.delete({ sandboxId: "sb_123" }); // No error
459
+ * ```
460
+ */
461
+ delete(options: SandboxDeleteOptions): Promise<void>;
462
+ }
255
463
  /**
256
464
  * State and store container for backend initialization.
257
465
  *
@@ -314,13 +522,13 @@ interface FilesystemMiddlewareOptions {
314
522
  */
315
523
  declare function createFilesystemMiddleware(options?: FilesystemMiddlewareOptions): AgentMiddleware<StateSchema<{
316
524
  files: ReducedValue<FilesRecord | undefined, FilesRecordUpdate | undefined>;
317
- }>, undefined, unknown, (langchain9.DynamicStructuredTool<z.ZodObject<{
525
+ }>, undefined, unknown, (langchain.DynamicStructuredTool<z.ZodObject<{
318
526
  path: z.ZodDefault<z.ZodOptional<z.ZodString>>;
319
527
  }, z.core.$strip>, {
320
528
  path: string;
321
529
  }, {
322
530
  path?: string | undefined;
323
- }, string, "ls"> | langchain9.DynamicStructuredTool<z.ZodObject<{
531
+ }, string, "ls"> | langchain.DynamicStructuredTool<z.ZodObject<{
324
532
  file_path: z.ZodString;
325
533
  offset: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
326
534
  limit: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
@@ -332,7 +540,7 @@ declare function createFilesystemMiddleware(options?: FilesystemMiddlewareOption
332
540
  file_path: string;
333
541
  offset?: unknown;
334
542
  limit?: unknown;
335
- }, string, "read_file"> | langchain9.DynamicStructuredTool<z.ZodObject<{
543
+ }, string, "read_file"> | langchain.DynamicStructuredTool<z.ZodObject<{
336
544
  file_path: z.ZodString;
337
545
  content: z.ZodString;
338
546
  }, z.core.$strip>, {
@@ -344,7 +552,7 @@ declare function createFilesystemMiddleware(options?: FilesystemMiddlewareOption
344
552
  }, string | ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>> | Command<unknown, {
345
553
  files: Record<string, FileData>;
346
554
  messages: ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>>[];
347
- }, string>, "write_file"> | langchain9.DynamicStructuredTool<z.ZodObject<{
555
+ }, string>, "write_file"> | langchain.DynamicStructuredTool<z.ZodObject<{
348
556
  file_path: z.ZodString;
349
557
  old_string: z.ZodString;
350
558
  new_string: z.ZodString;
@@ -362,7 +570,7 @@ declare function createFilesystemMiddleware(options?: FilesystemMiddlewareOption
362
570
  }, string | ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>> | Command<unknown, {
363
571
  files: Record<string, FileData>;
364
572
  messages: ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>>[];
365
- }, string>, "edit_file"> | langchain9.DynamicStructuredTool<z.ZodObject<{
573
+ }, string>, "edit_file"> | langchain.DynamicStructuredTool<z.ZodObject<{
366
574
  pattern: z.ZodString;
367
575
  path: z.ZodDefault<z.ZodOptional<z.ZodString>>;
368
576
  }, z.core.$strip>, {
@@ -371,7 +579,7 @@ declare function createFilesystemMiddleware(options?: FilesystemMiddlewareOption
371
579
  }, {
372
580
  pattern: string;
373
581
  path?: string | undefined;
374
- }, string, "glob"> | langchain9.DynamicStructuredTool<z.ZodObject<{
582
+ }, string, "glob"> | langchain.DynamicStructuredTool<z.ZodObject<{
375
583
  pattern: z.ZodString;
376
584
  path: z.ZodDefault<z.ZodOptional<z.ZodString>>;
377
585
  glob: z.ZodNullable<z.ZodOptional<z.ZodString>>;
@@ -383,7 +591,7 @@ declare function createFilesystemMiddleware(options?: FilesystemMiddlewareOption
383
591
  pattern: string;
384
592
  path?: string | undefined;
385
593
  glob?: string | null | undefined;
386
- }, string, "grep"> | langchain9.DynamicStructuredTool<z.ZodObject<{
594
+ }, string, "grep"> | langchain.DynamicStructuredTool<z.ZodObject<{
387
595
  command: z.ZodString;
388
596
  }, z.core.$strip>, {
389
597
  command: string;
@@ -392,6 +600,30 @@ declare function createFilesystemMiddleware(options?: FilesystemMiddlewareOption
392
600
  }, string, "execute">)[]>;
393
601
  //#endregion
394
602
  //#region src/middleware/subagents.d.ts
603
+ /**
604
+ * Default system prompt for subagents.
605
+ * Provides a minimal base prompt that can be extended by specific subagent configurations.
606
+ */
607
+ declare const DEFAULT_SUBAGENT_PROMPT = "In order to complete the objective that the user asks of you, you have access to a number of standard tools.";
608
+ /**
609
+ * Default description for the general-purpose subagent.
610
+ * This description is shown to the model when selecting which subagent to use.
611
+ */
612
+ declare const DEFAULT_GENERAL_PURPOSE_DESCRIPTION = "General-purpose agent for researching complex questions, searching for files and content, and executing multi-step tasks. When you are searching for a keyword or file and are not confident that you will find the right match in the first few tries use this agent to perform the search for you. This agent has access to all tools as the main agent.";
613
+ /**
614
+ * System prompt section that explains how to use the task tool for spawning subagents.
615
+ *
616
+ * This prompt is automatically appended to the main agent's system prompt when
617
+ * using `createSubAgentMiddleware`. It provides guidance on:
618
+ * - When to use the task tool
619
+ * - Subagent lifecycle (spawn → run → return → reconcile)
620
+ * - When NOT to use the task tool
621
+ * - Best practices for parallel task execution
622
+ *
623
+ * You can provide a custom `systemPrompt` to `createSubAgentMiddleware` to override
624
+ * or extend this default.
625
+ */
626
+ declare const TASK_SYSTEM_PROMPT = "## `task` (subagent spawner)\n\nYou have access to a `task` tool to launch short-lived subagents that handle isolated tasks. These agents are ephemeral \u2014 they live only for the duration of the task and return a single result.\n\nWhen to use the task tool:\n- When a task is complex and multi-step, and can be fully delegated in isolation\n- When a task is independent of other tasks and can run in parallel\n- When a task requires focused reasoning or heavy token/context usage that would bloat the orchestrator thread\n- When sandboxing improves reliability (e.g. code execution, structured searches, data formatting)\n- When you only care about the output of the subagent, and not the intermediate steps (ex. performing a lot of research and then returned a synthesized report, performing a series of computations or lookups to achieve a concise, relevant answer.)\n\nSubagent lifecycle:\n1. **Spawn** \u2192 Provide clear role, instructions, and expected output\n2. **Run** \u2192 The subagent completes the task autonomously\n3. **Return** \u2192 The subagent provides a single structured result\n4. **Reconcile** \u2192 Incorporate or synthesize the result into the main thread\n\nWhen NOT to use the task tool:\n- If you need to see the intermediate reasoning or steps after the subagent has completed (the task tool hides them)\n- If the task is trivial (a few tool calls or simple lookup)\n- If delegating does not reduce token usage, complexity, or context switching\n- If splitting would add latency without benefit\n\n## Important Task Tool Usage Notes to Remember\n- Whenever possible, parallelize the work that you do. This is true for both tool_calls, and for tasks. Whenever you have independent steps to complete - make tool_calls, or kick off tasks (subagents) in parallel to accomplish them faster. This saves time for the user, which is incredibly important.\n- Remember to use the `task` tool to silo independent tasks within a multi-part objective.\n- You should use the `task` tool whenever you have a complex task that will take multiple steps, and is independent from other tasks that the agent needs to complete. These agents are highly competent and efficient.";
395
627
  /**
396
628
  * Type definitions for pre-compiled agents.
397
629
  *
@@ -407,24 +639,110 @@ interface CompiledSubAgent<TRunnable extends ReactAgent | Runnable = ReactAgent
407
639
  runnable: TRunnable;
408
640
  }
409
641
  /**
410
- * Type definitions for subagents
642
+ * Specification for a subagent that can be dynamically created.
643
+ *
644
+ * When using `createDeepAgent`, subagents automatically receive a default middleware
645
+ * stack (todoListMiddleware, filesystemMiddleware, summarizationMiddleware, etc.) before
646
+ * any custom `middleware` specified in this spec.
647
+ *
648
+ * Required fields:
649
+ * - `name`: Identifier used to select this subagent in the task tool
650
+ * - `description`: Shown to the model for subagent selection
651
+ * - `systemPrompt`: The system prompt for the subagent
652
+ *
653
+ * Optional fields:
654
+ * - `model`: Override the default model for this subagent
655
+ * - `tools`: Override the default tools for this subagent
656
+ * - `middleware`: Additional middleware appended after defaults
657
+ * - `interruptOn`: Human-in-the-loop configuration for specific tools
658
+ * - `skills`: Skill source paths for SkillsMiddleware (e.g., `["/skills/user/", "/skills/project/"]`)
659
+ *
660
+ * @example
661
+ * ```typescript
662
+ * const researcher: SubAgent = {
663
+ * name: "researcher",
664
+ * description: "Research assistant for complex topics",
665
+ * systemPrompt: "You are a research assistant.",
666
+ * tools: [webSearchTool],
667
+ * skills: ["/skills/research/"],
668
+ * };
669
+ * ```
411
670
  */
412
671
  interface SubAgent {
413
- /** The name of the agent */
672
+ /** Identifier used to select this subagent in the task tool */
414
673
  name: string;
415
- /** The description of the agent */
674
+ /** Description shown to the model for subagent selection */
416
675
  description: string;
417
676
  /** The system prompt to use for the agent */
418
677
  systemPrompt: string;
419
678
  /** The tools to use for the agent (tool instances, not names). Defaults to defaultTools */
420
679
  tools?: StructuredTool[];
421
- /** The model for the agent. Defaults to default_model */
680
+ /** The model for the agent. Defaults to defaultModel */
422
681
  model?: LanguageModelLike | string;
423
682
  /** Additional middleware to append after default_middleware */
424
683
  middleware?: readonly AgentMiddleware$1[];
425
- /** The tool configs to use for the agent */
684
+ /** Human-in-the-loop configuration for specific tools. Requires a checkpointer. */
426
685
  interruptOn?: Record<string, boolean | InterruptOnConfig>;
686
+ /**
687
+ * Skill source paths for SkillsMiddleware.
688
+ *
689
+ * List of paths to skill directories (e.g., `["/skills/user/", "/skills/project/"]`).
690
+ * When specified, the subagent will have its own SkillsMiddleware that loads skills
691
+ * from these paths. This allows subagents to have different skill sets than the main agent.
692
+ *
693
+ * Note: Custom subagents do NOT inherit skills from the main agent by default.
694
+ * Only the general-purpose subagent inherits the main agent's skills.
695
+ *
696
+ * @example
697
+ * ```typescript
698
+ * const researcher: SubAgent = {
699
+ * name: "researcher",
700
+ * description: "Research assistant",
701
+ * systemPrompt: "You are a researcher.",
702
+ * skills: ["/skills/research/", "/skills/web-search/"],
703
+ * };
704
+ * ```
705
+ */
706
+ skills?: string[];
427
707
  }
708
+ /**
709
+ * Base specification for the general-purpose subagent.
710
+ *
711
+ * This constant provides the default configuration for the general-purpose subagent
712
+ * that is automatically included when `generalPurposeAgent: true` (the default).
713
+ *
714
+ * The general-purpose subagent:
715
+ * - Has access to all tools from the main agent
716
+ * - Inherits skills from the main agent (when skills are configured)
717
+ * - Uses the same model as the main agent (by default)
718
+ * - Is ideal for delegating complex, multi-step tasks
719
+ *
720
+ * You can spread this constant and override specific properties when creating
721
+ * custom subagents that should behave similarly to the general-purpose agent:
722
+ *
723
+ * @example
724
+ * ```typescript
725
+ * import { GENERAL_PURPOSE_SUBAGENT, createDeepAgent } from "@anthropic/deepagents";
726
+ *
727
+ * // Use as-is (automatically included with generalPurposeAgent: true)
728
+ * const agent = createDeepAgent({ model: "claude-sonnet-4-5-20250929" });
729
+ *
730
+ * // Or create a custom variant with different tools
731
+ * const customGP: SubAgent = {
732
+ * ...GENERAL_PURPOSE_SUBAGENT,
733
+ * name: "research-gp",
734
+ * tools: [webSearchTool, readFileTool],
735
+ * };
736
+ *
737
+ * const agent = createDeepAgent({
738
+ * model: "claude-sonnet-4-5-20250929",
739
+ * subagents: [customGP],
740
+ * // Disable the default general-purpose agent since we're providing our own
741
+ * // (handled automatically when using createSubAgentMiddleware directly)
742
+ * });
743
+ * ```
744
+ */
745
+ declare const GENERAL_PURPOSE_SUBAGENT: Pick<SubAgent, "name" | "description" | "systemPrompt">;
428
746
  /**
429
747
  * Options for creating subagent middleware
430
748
  */
@@ -433,8 +751,13 @@ interface SubAgentMiddlewareOptions {
433
751
  defaultModel: LanguageModelLike | string;
434
752
  /** The tools to use for the default general-purpose subagent */
435
753
  defaultTools?: StructuredTool[];
436
- /** Default middleware to apply to all subagents */
754
+ /** Default middleware to apply to custom subagents (WITHOUT skills from main agent) */
437
755
  defaultMiddleware?: AgentMiddleware$1[] | null;
756
+ /**
757
+ * Middleware specifically for the general-purpose subagent (includes skills from main agent).
758
+ * If not provided, falls back to defaultMiddleware.
759
+ */
760
+ generalPurposeMiddleware?: AgentMiddleware$1[] | null;
438
761
  /** The tool configs for the default general-purpose subagent */
439
762
  defaultInterruptOn?: Record<string, boolean | InterruptOnConfig> | null;
440
763
  /** A list of additional subagents to provide to the agent */
@@ -449,7 +772,7 @@ interface SubAgentMiddlewareOptions {
449
772
  /**
450
773
  * Create subagent middleware with task tool
451
774
  */
452
- declare function createSubAgentMiddleware(options: SubAgentMiddlewareOptions): AgentMiddleware$1<undefined, undefined, unknown, readonly [langchain9.DynamicStructuredTool<z.ZodObject<{
775
+ declare function createSubAgentMiddleware(options: SubAgentMiddlewareOptions): AgentMiddleware$1<undefined, undefined, unknown, readonly [langchain.DynamicStructuredTool<z.ZodObject<{
453
776
  description: z.ZodString;
454
777
  subagent_type: z.ZodString;
455
778
  }, z.core.$strip>, {
@@ -487,7 +810,7 @@ declare function createSubAgentMiddleware(options: SubAgentMiddlewareOptions): A
487
810
  * });
488
811
  * ```
489
812
  */
490
- declare function createPatchToolCallsMiddleware(): AgentMiddleware<undefined, undefined, unknown, readonly (_langchain_core_tools1.ClientTool | _langchain_core_tools1.ServerTool)[]>;
813
+ declare function createPatchToolCallsMiddleware(): AgentMiddleware<undefined, undefined, unknown, readonly (_langchain_core_tools0.ClientTool | _langchain_core_tools0.ServerTool)[]>;
491
814
  //#endregion
492
815
  //#region src/backends/state.d.ts
493
816
  /**
@@ -617,8 +940,8 @@ declare function createMemoryMiddleware(options: MemoryMiddlewareOptions): Agent
617
940
  * Marked as private so it's not included in the final agent state.
618
941
  */
619
942
  memoryContents: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
620
- files: ReducedValue<FilesRecord | undefined, FilesRecordUpdate | undefined>;
621
- }>, undefined, unknown, readonly (_langchain_core_tools1.ClientTool | _langchain_core_tools1.ServerTool)[]>;
943
+ files: _langchain_langgraph0.ReducedValue<FilesRecord | undefined, FilesRecordUpdate | undefined>;
944
+ }>, undefined, unknown, readonly (_langchain_core_tools0.ClientTool | _langchain_core_tools0.ServerTool)[]>;
622
945
  //#endregion
623
946
  //#region src/middleware/skills.d.ts
624
947
  declare const MAX_SKILL_FILE_SIZE: number;
@@ -700,7 +1023,7 @@ declare function createSkillsMiddleware(options: SkillsMiddlewareOptions): Agent
700
1023
  allowedTools?: string[] | undefined;
701
1024
  }[] | undefined>;
702
1025
  files: ReducedValue<FilesRecord | undefined, FilesRecordUpdate | undefined>;
703
- }>, undefined, unknown, readonly (_langchain_core_tools1.ClientTool | _langchain_core_tools1.ServerTool)[]>;
1026
+ }>, undefined, unknown, readonly (_langchain_core_tools0.ClientTool | _langchain_core_tools0.ServerTool)[]>;
704
1027
  //#endregion
705
1028
  //#region src/backends/store.d.ts
706
1029
  /**
@@ -876,18 +1199,37 @@ declare class FilesystemBackend implements BackendProtocol {
876
1199
  */
877
1200
  edit(filePath: string, oldString: string, newString: string, replaceAll?: boolean): Promise<EditResult>;
878
1201
  /**
879
- * Structured search results or error string for invalid input.
1202
+ * Search for a literal text pattern in files.
1203
+ *
1204
+ * Uses ripgrep if available, falling back to substring search.
1205
+ *
1206
+ * @param pattern - Literal string to search for (NOT regex).
1207
+ * @param dirPath - Directory or file path to search in. Defaults to current directory.
1208
+ * @param glob - Optional glob pattern to filter which files to search.
1209
+ * @returns List of GrepMatch dicts containing path, line number, and matched text.
880
1210
  */
881
1211
  grepRaw(pattern: string, dirPath?: string, glob?: string | null): Promise<GrepMatch[] | string>;
882
1212
  /**
883
- * Try to use ripgrep for fast searching.
884
- * Returns null if ripgrep is not available or fails.
1213
+ * Search using ripgrep with fixed-string (literal) mode.
1214
+ *
1215
+ * @param pattern - Literal string to search for (unescaped).
1216
+ * @param baseFull - Resolved base path to search in.
1217
+ * @param includeGlob - Optional glob pattern to filter files.
1218
+ * @returns Dict mapping file paths to list of (line_number, line_text) tuples.
1219
+ * Returns null if ripgrep is unavailable or times out.
885
1220
  */
886
1221
  private ripgrepSearch;
887
1222
  /**
888
- * Fallback regex search implementation.
1223
+ * Fallback search using literal substring matching when ripgrep is unavailable.
1224
+ *
1225
+ * Recursively searches files, respecting maxFileSizeBytes limit.
1226
+ *
1227
+ * @param pattern - Literal string to search for.
1228
+ * @param baseFull - Resolved base path to search in.
1229
+ * @param includeGlob - Optional glob pattern to filter files by name.
1230
+ * @returns Dict mapping file paths to list of (line_number, line_text) tuples.
889
1231
  */
890
- private pythonSearch;
1232
+ private literalSearch;
891
1233
  /**
892
1234
  * Structured glob matching returning FileInfo objects.
893
1235
  */
@@ -1058,7 +1400,12 @@ declare abstract class BaseSandbox implements SandboxBackendProtocol {
1058
1400
  */
1059
1401
  readRaw(filePath: string): Promise<FileData>;
1060
1402
  /**
1061
- * Structured search results or error string for invalid input.
1403
+ * Search for a literal text pattern in files.
1404
+ *
1405
+ * @param pattern - Literal string to search for (NOT regex).
1406
+ * @param path - Directory or file path to search in.
1407
+ * @param glob - Optional glob pattern to filter which files to search.
1408
+ * @returns List of GrepMatch dicts containing path, line number, and matched text.
1062
1409
  */
1063
1410
  grepRaw(pattern: string, path?: string, glob?: string | null): Promise<GrepMatch[] | string>;
1064
1411
  /**
@@ -1362,7 +1709,7 @@ declare function createDeepAgent<TResponse extends ResponseFormat = ResponseForm
1362
1709
  content: string;
1363
1710
  status: "completed" | "in_progress" | "pending";
1364
1711
  }[] | undefined;
1365
- }>, undefined, unknown, readonly [langchain9.DynamicStructuredTool<zod_v30.ZodObject<{
1712
+ }>, undefined, unknown, readonly [langchain.DynamicStructuredTool<zod_v30.ZodObject<{
1366
1713
  todos: zod_v30.ZodArray<zod_v30.ZodObject<{
1367
1714
  content: zod_v30.ZodString;
1368
1715
  status: zod_v30.ZodEnum<["pending", "in_progress", "completed"]>;
@@ -1393,24 +1740,24 @@ declare function createDeepAgent<TResponse extends ResponseFormat = ResponseForm
1393
1740
  content: string;
1394
1741
  status: "completed" | "in_progress" | "pending";
1395
1742
  }[];
1396
- }, _Command.Command<unknown, {
1743
+ }, _langchain_langgraph0.Command<unknown, {
1397
1744
  todos: {
1398
1745
  content: string;
1399
1746
  status: "completed" | "in_progress" | "pending";
1400
1747
  }[];
1401
1748
  messages: _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>>[];
1402
- }, string>, "write_todos">]>, AgentMiddleware<_Command.StateSchema<{
1403
- files: _Command.ReducedValue<FilesRecord | undefined, FilesRecordUpdate | undefined>;
1404
- }>, undefined, unknown, (langchain9.DynamicStructuredTool<zod0.ZodObject<{
1405
- path: zod0.ZodDefault<zod0.ZodOptional<zod0.ZodString>>;
1749
+ }, string>, "write_todos">]>, AgentMiddleware<_langchain_langgraph0.StateSchema<{
1750
+ files: _langchain_langgraph0.ReducedValue<FilesRecord | undefined, FilesRecordUpdate | undefined>;
1751
+ }>, undefined, unknown, (langchain.DynamicStructuredTool<zod.ZodObject<{
1752
+ path: zod.ZodDefault<zod.ZodOptional<zod.ZodString>>;
1406
1753
  }, zod_v4_core0.$strip>, {
1407
1754
  path: string;
1408
1755
  }, {
1409
1756
  path?: string | undefined;
1410
- }, string, "ls"> | langchain9.DynamicStructuredTool<zod0.ZodObject<{
1411
- file_path: zod0.ZodString;
1412
- offset: zod0.ZodDefault<zod0.ZodOptional<zod0.ZodCoercedNumber<unknown>>>;
1413
- limit: zod0.ZodDefault<zod0.ZodOptional<zod0.ZodCoercedNumber<unknown>>>;
1757
+ }, string, "ls"> | langchain.DynamicStructuredTool<zod.ZodObject<{
1758
+ file_path: zod.ZodString;
1759
+ offset: zod.ZodDefault<zod.ZodOptional<zod.ZodCoercedNumber<unknown>>>;
1760
+ limit: zod.ZodDefault<zod.ZodOptional<zod.ZodCoercedNumber<unknown>>>;
1414
1761
  }, zod_v4_core0.$strip>, {
1415
1762
  file_path: string;
1416
1763
  offset: number;
@@ -1419,23 +1766,23 @@ declare function createDeepAgent<TResponse extends ResponseFormat = ResponseForm
1419
1766
  file_path: string;
1420
1767
  offset?: unknown;
1421
1768
  limit?: unknown;
1422
- }, string, "read_file"> | langchain9.DynamicStructuredTool<zod0.ZodObject<{
1423
- file_path: zod0.ZodString;
1424
- content: zod0.ZodString;
1769
+ }, string, "read_file"> | langchain.DynamicStructuredTool<zod.ZodObject<{
1770
+ file_path: zod.ZodString;
1771
+ content: zod.ZodString;
1425
1772
  }, zod_v4_core0.$strip>, {
1426
1773
  file_path: string;
1427
1774
  content: string;
1428
1775
  }, {
1429
1776
  file_path: string;
1430
1777
  content: string;
1431
- }, string | _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>> | _Command.Command<unknown, {
1778
+ }, string | _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>> | _langchain_langgraph0.Command<unknown, {
1432
1779
  files: Record<string, FileData>;
1433
1780
  messages: _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>>[];
1434
- }, string>, "write_file"> | langchain9.DynamicStructuredTool<zod0.ZodObject<{
1435
- file_path: zod0.ZodString;
1436
- old_string: zod0.ZodString;
1437
- new_string: zod0.ZodString;
1438
- replace_all: zod0.ZodDefault<zod0.ZodOptional<zod0.ZodBoolean>>;
1781
+ }, string>, "write_file"> | langchain.DynamicStructuredTool<zod.ZodObject<{
1782
+ file_path: zod.ZodString;
1783
+ old_string: zod.ZodString;
1784
+ new_string: zod.ZodString;
1785
+ replace_all: zod.ZodDefault<zod.ZodOptional<zod.ZodBoolean>>;
1439
1786
  }, zod_v4_core0.$strip>, {
1440
1787
  file_path: string;
1441
1788
  old_string: string;
@@ -1446,22 +1793,22 @@ declare function createDeepAgent<TResponse extends ResponseFormat = ResponseForm
1446
1793
  old_string: string;
1447
1794
  new_string: string;
1448
1795
  replace_all?: boolean | undefined;
1449
- }, string | _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>> | _Command.Command<unknown, {
1796
+ }, string | _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>> | _langchain_langgraph0.Command<unknown, {
1450
1797
  files: Record<string, FileData>;
1451
1798
  messages: _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>>[];
1452
- }, string>, "edit_file"> | langchain9.DynamicStructuredTool<zod0.ZodObject<{
1453
- pattern: zod0.ZodString;
1454
- path: zod0.ZodDefault<zod0.ZodOptional<zod0.ZodString>>;
1799
+ }, string>, "edit_file"> | langchain.DynamicStructuredTool<zod.ZodObject<{
1800
+ pattern: zod.ZodString;
1801
+ path: zod.ZodDefault<zod.ZodOptional<zod.ZodString>>;
1455
1802
  }, zod_v4_core0.$strip>, {
1456
1803
  pattern: string;
1457
1804
  path: string;
1458
1805
  }, {
1459
1806
  pattern: string;
1460
1807
  path?: string | undefined;
1461
- }, string, "glob"> | langchain9.DynamicStructuredTool<zod0.ZodObject<{
1462
- pattern: zod0.ZodString;
1463
- path: zod0.ZodDefault<zod0.ZodOptional<zod0.ZodString>>;
1464
- glob: zod0.ZodNullable<zod0.ZodOptional<zod0.ZodString>>;
1808
+ }, string, "glob"> | langchain.DynamicStructuredTool<zod.ZodObject<{
1809
+ pattern: zod.ZodString;
1810
+ path: zod.ZodDefault<zod.ZodOptional<zod.ZodString>>;
1811
+ glob: zod.ZodNullable<zod.ZodOptional<zod.ZodString>>;
1465
1812
  }, zod_v4_core0.$strip>, {
1466
1813
  pattern: string;
1467
1814
  path: string;
@@ -1470,22 +1817,22 @@ declare function createDeepAgent<TResponse extends ResponseFormat = ResponseForm
1470
1817
  pattern: string;
1471
1818
  path?: string | undefined;
1472
1819
  glob?: string | null | undefined;
1473
- }, string, "grep"> | langchain9.DynamicStructuredTool<zod0.ZodObject<{
1474
- command: zod0.ZodString;
1820
+ }, string, "grep"> | langchain.DynamicStructuredTool<zod.ZodObject<{
1821
+ command: zod.ZodString;
1475
1822
  }, zod_v4_core0.$strip>, {
1476
1823
  command: string;
1477
1824
  }, {
1478
1825
  command: string;
1479
- }, string, "execute">)[]>, AgentMiddleware<undefined, undefined, unknown, readonly [langchain9.DynamicStructuredTool<zod0.ZodObject<{
1480
- description: zod0.ZodString;
1481
- subagent_type: zod0.ZodString;
1826
+ }, string, "execute">)[]>, AgentMiddleware<undefined, undefined, unknown, readonly [langchain.DynamicStructuredTool<zod.ZodObject<{
1827
+ description: zod.ZodString;
1828
+ subagent_type: zod.ZodString;
1482
1829
  }, zod_v4_core0.$strip>, {
1483
1830
  description: string;
1484
1831
  subagent_type: string;
1485
1832
  }, {
1486
1833
  description: string;
1487
1834
  subagent_type: string;
1488
- }, string | _Command.Command<unknown, Record<string, unknown>, string>, "task">]>, AgentMiddleware<undefined, zod_v30.ZodObject<{
1835
+ }, string | _langchain_langgraph0.Command<unknown, Record<string, unknown>, string>, "task">]>, AgentMiddleware<undefined, zod_v30.ZodObject<{
1489
1836
  trigger: zod_v30.ZodOptional<zod_v30.ZodUnion<[zod_v30.ZodEffects<zod_v30.ZodObject<{
1490
1837
  fraction: zod_v30.ZodOptional<zod_v30.ZodNumber>;
1491
1838
  tokens: zod_v30.ZodOptional<zod_v30.ZodNumber>;
@@ -1745,6 +2092,31 @@ declare function findProjectRoot(startPath?: string): string | null;
1745
2092
  */
1746
2093
  declare function createSettings(options?: SettingsOptions): Settings;
1747
2094
  //#endregion
2095
+ //#region src/values.d.ts
2096
+ /**
2097
+ * Shared ReducedValue for file data state management.
2098
+ *
2099
+ * This provides a reusable pattern for managing file state with automatic
2100
+ * merging of concurrent updates from parallel subagents. Files can be updated
2101
+ * or deleted (using null values) and the reducer handles the merge logic.
2102
+ *
2103
+ * Similar to LangGraph's messagesValue, this encapsulates the common pattern
2104
+ * of managing files in agent state so you don't have to manually configure
2105
+ * the ReducedValue each time.
2106
+ *
2107
+ * @example
2108
+ * ```typescript
2109
+ * import { filesValue } from "@anthropic/deepagents";
2110
+ * import { StateSchema } from "@langchain/langgraph";
2111
+ *
2112
+ * const MyStateSchema = new StateSchema({
2113
+ * files: filesValue,
2114
+ * // ... other state fields
2115
+ * });
2116
+ * ```
2117
+ */
2118
+ declare const filesValue: ReducedValue<FilesRecord | undefined, FilesRecordUpdate | undefined>;
2119
+ //#endregion
1748
2120
  //#region src/middleware/agent-memory.d.ts
1749
2121
  /**
1750
2122
  * Options for the agent memory middleware.
@@ -1770,7 +2142,7 @@ interface AgentMemoryMiddlewareOptions {
1770
2142
  * @deprecated Use `createMemoryMiddleware` from `./memory.js` instead.
1771
2143
  * This function uses direct filesystem access which limits portability.
1772
2144
  */
1773
- declare function createAgentMemoryMiddleware(options: AgentMemoryMiddlewareOptions): AgentMiddleware<any, undefined, unknown, readonly (_langchain_core_tools1.ClientTool | _langchain_core_tools1.ServerTool)[]>;
2145
+ declare function createAgentMemoryMiddleware(options: AgentMemoryMiddlewareOptions): AgentMiddleware<any, undefined, unknown, readonly (_langchain_core_tools0.ClientTool | _langchain_core_tools0.ServerTool)[]>;
1774
2146
  //#endregion
1775
2147
  //#region src/skills/loader.d.ts
1776
2148
  /**
@@ -1824,5 +2196,5 @@ declare function parseSkillMetadata(skillMdPath: string, source: "user" | "proje
1824
2196
  */
1825
2197
  declare function listSkills(options: ListSkillsOptions): SkillMetadata[];
1826
2198
  //#endregion
1827
- 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 };
2199
+ export { type AgentMemoryMiddlewareOptions, type BackendFactory, type BackendProtocol, BaseSandbox, type CompiledSubAgent, CompositeBackend, type CreateDeepAgentParams, DEFAULT_GENERAL_PURPOSE_DESCRIPTION, DEFAULT_SUBAGENT_PROMPT, type DeepAgent, type DeepAgentTypeConfig, type DefaultDeepAgentTypeConfig, type EditResult, type ExecuteResponse, type ExtractSubAgentMiddleware, type FileData, type FileDownloadResponse, type FileInfo, type FileOperationError, type FileUploadResponse, FilesystemBackend, type FilesystemMiddlewareOptions, type FlattenSubAgentMiddleware, GENERAL_PURPOSE_SUBAGENT, type GrepMatch, type InferDeepAgentSubagents, type InferDeepAgentType, type InferSubAgentMiddlewareStates, type InferSubagentByName, type InferSubagentReactAgentType, type ListSkillsOptions, type SkillMetadata as LoaderSkillMetadata, MAX_SKILL_DESCRIPTION_LENGTH, MAX_SKILL_FILE_SIZE, MAX_SKILL_NAME_LENGTH, type MaybePromise, type MemoryMiddlewareOptions, type MergedDeepAgentState, type ResolveDeepAgentTypeConfig, type SandboxBackendProtocol, type SandboxDeleteOptions, type SandboxGetOrCreateOptions, type SandboxInfo, type SandboxListOptions, type SandboxListResponse, type SandboxProvider, type Settings, type SettingsOptions, type SkillMetadata$1 as SkillMetadata, type SkillsMiddlewareOptions, StateBackend, StoreBackend, type SubAgent, type SubAgentMiddlewareOptions, TASK_SYSTEM_PROMPT, type WriteResult, createAgentMemoryMiddleware, createDeepAgent, createFilesystemMiddleware, createMemoryMiddleware, createPatchToolCallsMiddleware, createSettings, createSkillsMiddleware, createSubAgentMiddleware, filesValue, findProjectRoot, isSandboxBackend, listSkills, parseSkillMetadata };
1828
2200
  //# sourceMappingURL=index.d.cts.map