deepagents 1.6.3 → 1.7.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/README.md +58 -12
- package/dist/index.cjs +251 -76
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +344 -55
- package/dist/index.d.ts +345 -56
- package/dist/index.js +239 -70
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import * as zod_v30 from "zod/v3";
|
|
2
|
-
import * as
|
|
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
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
|
|
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
|
|
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,156 @@ 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
|
+
* Common error codes shared across all sandbox provider implementations.
|
|
350
|
+
*
|
|
351
|
+
* These represent the core error conditions that any sandbox provider may encounter.
|
|
352
|
+
* Provider-specific error codes should extend this type with additional codes.
|
|
353
|
+
*
|
|
354
|
+
* @example
|
|
355
|
+
* ```typescript
|
|
356
|
+
* // Provider-specific error code type extending the common codes:
|
|
357
|
+
* type MySandboxErrorCode = SandboxErrorCode | "CUSTOM_ERROR";
|
|
358
|
+
* ```
|
|
359
|
+
*/
|
|
360
|
+
type SandboxErrorCode = /** Sandbox has not been initialized - call initialize() first */"NOT_INITIALIZED" /** Sandbox is already initialized - cannot initialize twice */ | "ALREADY_INITIALIZED" /** Command execution timed out */ | "COMMAND_TIMEOUT" /** Command execution failed */ | "COMMAND_FAILED" /** File operation (read/write) failed */ | "FILE_OPERATION_FAILED";
|
|
361
|
+
declare const SANDBOX_ERROR_SYMBOL: unique symbol;
|
|
362
|
+
/**
|
|
363
|
+
* Custom error class for sandbox operations.
|
|
364
|
+
*
|
|
365
|
+
* @param message - Human-readable error description
|
|
366
|
+
* @param code - Structured error code for programmatic handling
|
|
367
|
+
* @returns SandboxError with message and code
|
|
368
|
+
*
|
|
369
|
+
* @example
|
|
370
|
+
* ```typescript
|
|
371
|
+
* try {
|
|
372
|
+
* await sandbox.execute("some command");
|
|
373
|
+
* } catch (error) {
|
|
374
|
+
* if (error instanceof SandboxError) {
|
|
375
|
+
* switch (error.code) {
|
|
376
|
+
* case "NOT_INITIALIZED":
|
|
377
|
+
* await sandbox.initialize();
|
|
378
|
+
* break;
|
|
379
|
+
* case "COMMAND_TIMEOUT":
|
|
380
|
+
* console.error("Command took too long");
|
|
381
|
+
* break;
|
|
382
|
+
* default:
|
|
383
|
+
* throw error;
|
|
384
|
+
* }
|
|
385
|
+
* }
|
|
386
|
+
* }
|
|
387
|
+
* ```
|
|
388
|
+
*/
|
|
389
|
+
declare class SandboxError extends Error {
|
|
390
|
+
readonly code: string;
|
|
391
|
+
readonly cause?: Error | undefined;
|
|
392
|
+
/** Symbol for identifying sandbox error instances */
|
|
393
|
+
[SANDBOX_ERROR_SYMBOL]: true;
|
|
394
|
+
/** Error name for instanceof checks and logging */
|
|
395
|
+
readonly name: string;
|
|
396
|
+
/**
|
|
397
|
+
* Creates a new SandboxError.
|
|
398
|
+
*
|
|
399
|
+
* @param message - Human-readable error description
|
|
400
|
+
* @param code - Structured error code for programmatic handling
|
|
401
|
+
*/
|
|
402
|
+
constructor(message: string, code: string, cause?: Error | undefined);
|
|
403
|
+
static isInstance(error: unknown): error is SandboxError;
|
|
404
|
+
}
|
|
255
405
|
/**
|
|
256
406
|
* State and store container for backend initialization.
|
|
257
407
|
*
|
|
@@ -314,13 +464,13 @@ interface FilesystemMiddlewareOptions {
|
|
|
314
464
|
*/
|
|
315
465
|
declare function createFilesystemMiddleware(options?: FilesystemMiddlewareOptions): AgentMiddleware<StateSchema<{
|
|
316
466
|
files: ReducedValue<FilesRecord | undefined, FilesRecordUpdate | undefined>;
|
|
317
|
-
}>, undefined, unknown, (
|
|
467
|
+
}>, undefined, unknown, (langchain.DynamicStructuredTool<z.ZodObject<{
|
|
318
468
|
path: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
319
469
|
}, z.core.$strip>, {
|
|
320
470
|
path: string;
|
|
321
471
|
}, {
|
|
322
472
|
path?: string | undefined;
|
|
323
|
-
}, string, "ls"> |
|
|
473
|
+
}, string, "ls"> | langchain.DynamicStructuredTool<z.ZodObject<{
|
|
324
474
|
file_path: z.ZodString;
|
|
325
475
|
offset: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
326
476
|
limit: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
|
|
@@ -332,7 +482,7 @@ declare function createFilesystemMiddleware(options?: FilesystemMiddlewareOption
|
|
|
332
482
|
file_path: string;
|
|
333
483
|
offset?: unknown;
|
|
334
484
|
limit?: unknown;
|
|
335
|
-
}, string, "read_file"> |
|
|
485
|
+
}, string, "read_file"> | langchain.DynamicStructuredTool<z.ZodObject<{
|
|
336
486
|
file_path: z.ZodString;
|
|
337
487
|
content: z.ZodString;
|
|
338
488
|
}, z.core.$strip>, {
|
|
@@ -344,7 +494,7 @@ declare function createFilesystemMiddleware(options?: FilesystemMiddlewareOption
|
|
|
344
494
|
}, string | ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>> | Command<unknown, {
|
|
345
495
|
files: Record<string, FileData>;
|
|
346
496
|
messages: ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>>[];
|
|
347
|
-
}, string>, "write_file"> |
|
|
497
|
+
}, string>, "write_file"> | langchain.DynamicStructuredTool<z.ZodObject<{
|
|
348
498
|
file_path: z.ZodString;
|
|
349
499
|
old_string: z.ZodString;
|
|
350
500
|
new_string: z.ZodString;
|
|
@@ -362,7 +512,7 @@ declare function createFilesystemMiddleware(options?: FilesystemMiddlewareOption
|
|
|
362
512
|
}, string | ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>> | Command<unknown, {
|
|
363
513
|
files: Record<string, FileData>;
|
|
364
514
|
messages: ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>>[];
|
|
365
|
-
}, string>, "edit_file"> |
|
|
515
|
+
}, string>, "edit_file"> | langchain.DynamicStructuredTool<z.ZodObject<{
|
|
366
516
|
pattern: z.ZodString;
|
|
367
517
|
path: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
368
518
|
}, z.core.$strip>, {
|
|
@@ -371,7 +521,7 @@ declare function createFilesystemMiddleware(options?: FilesystemMiddlewareOption
|
|
|
371
521
|
}, {
|
|
372
522
|
pattern: string;
|
|
373
523
|
path?: string | undefined;
|
|
374
|
-
}, string, "glob"> |
|
|
524
|
+
}, string, "glob"> | langchain.DynamicStructuredTool<z.ZodObject<{
|
|
375
525
|
pattern: z.ZodString;
|
|
376
526
|
path: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
377
527
|
glob: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
@@ -383,7 +533,7 @@ declare function createFilesystemMiddleware(options?: FilesystemMiddlewareOption
|
|
|
383
533
|
pattern: string;
|
|
384
534
|
path?: string | undefined;
|
|
385
535
|
glob?: string | null | undefined;
|
|
386
|
-
}, string, "grep"> |
|
|
536
|
+
}, string, "grep"> | langchain.DynamicStructuredTool<z.ZodObject<{
|
|
387
537
|
command: z.ZodString;
|
|
388
538
|
}, z.core.$strip>, {
|
|
389
539
|
command: string;
|
|
@@ -392,6 +542,30 @@ declare function createFilesystemMiddleware(options?: FilesystemMiddlewareOption
|
|
|
392
542
|
}, string, "execute">)[]>;
|
|
393
543
|
//#endregion
|
|
394
544
|
//#region src/middleware/subagents.d.ts
|
|
545
|
+
/**
|
|
546
|
+
* Default system prompt for subagents.
|
|
547
|
+
* Provides a minimal base prompt that can be extended by specific subagent configurations.
|
|
548
|
+
*/
|
|
549
|
+
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.";
|
|
550
|
+
/**
|
|
551
|
+
* Default description for the general-purpose subagent.
|
|
552
|
+
* This description is shown to the model when selecting which subagent to use.
|
|
553
|
+
*/
|
|
554
|
+
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.";
|
|
555
|
+
/**
|
|
556
|
+
* System prompt section that explains how to use the task tool for spawning subagents.
|
|
557
|
+
*
|
|
558
|
+
* This prompt is automatically appended to the main agent's system prompt when
|
|
559
|
+
* using `createSubAgentMiddleware`. It provides guidance on:
|
|
560
|
+
* - When to use the task tool
|
|
561
|
+
* - Subagent lifecycle (spawn → run → return → reconcile)
|
|
562
|
+
* - When NOT to use the task tool
|
|
563
|
+
* - Best practices for parallel task execution
|
|
564
|
+
*
|
|
565
|
+
* You can provide a custom `systemPrompt` to `createSubAgentMiddleware` to override
|
|
566
|
+
* or extend this default.
|
|
567
|
+
*/
|
|
568
|
+
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
569
|
/**
|
|
396
570
|
* Type definitions for pre-compiled agents.
|
|
397
571
|
*
|
|
@@ -407,24 +581,110 @@ interface CompiledSubAgent<TRunnable extends ReactAgent | Runnable = ReactAgent
|
|
|
407
581
|
runnable: TRunnable;
|
|
408
582
|
}
|
|
409
583
|
/**
|
|
410
|
-
*
|
|
584
|
+
* Specification for a subagent that can be dynamically created.
|
|
585
|
+
*
|
|
586
|
+
* When using `createDeepAgent`, subagents automatically receive a default middleware
|
|
587
|
+
* stack (todoListMiddleware, filesystemMiddleware, summarizationMiddleware, etc.) before
|
|
588
|
+
* any custom `middleware` specified in this spec.
|
|
589
|
+
*
|
|
590
|
+
* Required fields:
|
|
591
|
+
* - `name`: Identifier used to select this subagent in the task tool
|
|
592
|
+
* - `description`: Shown to the model for subagent selection
|
|
593
|
+
* - `systemPrompt`: The system prompt for the subagent
|
|
594
|
+
*
|
|
595
|
+
* Optional fields:
|
|
596
|
+
* - `model`: Override the default model for this subagent
|
|
597
|
+
* - `tools`: Override the default tools for this subagent
|
|
598
|
+
* - `middleware`: Additional middleware appended after defaults
|
|
599
|
+
* - `interruptOn`: Human-in-the-loop configuration for specific tools
|
|
600
|
+
* - `skills`: Skill source paths for SkillsMiddleware (e.g., `["/skills/user/", "/skills/project/"]`)
|
|
601
|
+
*
|
|
602
|
+
* @example
|
|
603
|
+
* ```typescript
|
|
604
|
+
* const researcher: SubAgent = {
|
|
605
|
+
* name: "researcher",
|
|
606
|
+
* description: "Research assistant for complex topics",
|
|
607
|
+
* systemPrompt: "You are a research assistant.",
|
|
608
|
+
* tools: [webSearchTool],
|
|
609
|
+
* skills: ["/skills/research/"],
|
|
610
|
+
* };
|
|
611
|
+
* ```
|
|
411
612
|
*/
|
|
412
613
|
interface SubAgent {
|
|
413
|
-
/**
|
|
614
|
+
/** Identifier used to select this subagent in the task tool */
|
|
414
615
|
name: string;
|
|
415
|
-
/**
|
|
616
|
+
/** Description shown to the model for subagent selection */
|
|
416
617
|
description: string;
|
|
417
618
|
/** The system prompt to use for the agent */
|
|
418
619
|
systemPrompt: string;
|
|
419
620
|
/** The tools to use for the agent (tool instances, not names). Defaults to defaultTools */
|
|
420
621
|
tools?: StructuredTool[];
|
|
421
|
-
/** The model for the agent. Defaults to
|
|
622
|
+
/** The model for the agent. Defaults to defaultModel */
|
|
422
623
|
model?: LanguageModelLike | string;
|
|
423
624
|
/** Additional middleware to append after default_middleware */
|
|
424
625
|
middleware?: readonly AgentMiddleware$1[];
|
|
425
|
-
/**
|
|
626
|
+
/** Human-in-the-loop configuration for specific tools. Requires a checkpointer. */
|
|
426
627
|
interruptOn?: Record<string, boolean | InterruptOnConfig>;
|
|
628
|
+
/**
|
|
629
|
+
* Skill source paths for SkillsMiddleware.
|
|
630
|
+
*
|
|
631
|
+
* List of paths to skill directories (e.g., `["/skills/user/", "/skills/project/"]`).
|
|
632
|
+
* When specified, the subagent will have its own SkillsMiddleware that loads skills
|
|
633
|
+
* from these paths. This allows subagents to have different skill sets than the main agent.
|
|
634
|
+
*
|
|
635
|
+
* Note: Custom subagents do NOT inherit skills from the main agent by default.
|
|
636
|
+
* Only the general-purpose subagent inherits the main agent's skills.
|
|
637
|
+
*
|
|
638
|
+
* @example
|
|
639
|
+
* ```typescript
|
|
640
|
+
* const researcher: SubAgent = {
|
|
641
|
+
* name: "researcher",
|
|
642
|
+
* description: "Research assistant",
|
|
643
|
+
* systemPrompt: "You are a researcher.",
|
|
644
|
+
* skills: ["/skills/research/", "/skills/web-search/"],
|
|
645
|
+
* };
|
|
646
|
+
* ```
|
|
647
|
+
*/
|
|
648
|
+
skills?: string[];
|
|
427
649
|
}
|
|
650
|
+
/**
|
|
651
|
+
* Base specification for the general-purpose subagent.
|
|
652
|
+
*
|
|
653
|
+
* This constant provides the default configuration for the general-purpose subagent
|
|
654
|
+
* that is automatically included when `generalPurposeAgent: true` (the default).
|
|
655
|
+
*
|
|
656
|
+
* The general-purpose subagent:
|
|
657
|
+
* - Has access to all tools from the main agent
|
|
658
|
+
* - Inherits skills from the main agent (when skills are configured)
|
|
659
|
+
* - Uses the same model as the main agent (by default)
|
|
660
|
+
* - Is ideal for delegating complex, multi-step tasks
|
|
661
|
+
*
|
|
662
|
+
* You can spread this constant and override specific properties when creating
|
|
663
|
+
* custom subagents that should behave similarly to the general-purpose agent:
|
|
664
|
+
*
|
|
665
|
+
* @example
|
|
666
|
+
* ```typescript
|
|
667
|
+
* import { GENERAL_PURPOSE_SUBAGENT, createDeepAgent } from "@anthropic/deepagents";
|
|
668
|
+
*
|
|
669
|
+
* // Use as-is (automatically included with generalPurposeAgent: true)
|
|
670
|
+
* const agent = createDeepAgent({ model: "claude-sonnet-4-5-20250929" });
|
|
671
|
+
*
|
|
672
|
+
* // Or create a custom variant with different tools
|
|
673
|
+
* const customGP: SubAgent = {
|
|
674
|
+
* ...GENERAL_PURPOSE_SUBAGENT,
|
|
675
|
+
* name: "research-gp",
|
|
676
|
+
* tools: [webSearchTool, readFileTool],
|
|
677
|
+
* };
|
|
678
|
+
*
|
|
679
|
+
* const agent = createDeepAgent({
|
|
680
|
+
* model: "claude-sonnet-4-5-20250929",
|
|
681
|
+
* subagents: [customGP],
|
|
682
|
+
* // Disable the default general-purpose agent since we're providing our own
|
|
683
|
+
* // (handled automatically when using createSubAgentMiddleware directly)
|
|
684
|
+
* });
|
|
685
|
+
* ```
|
|
686
|
+
*/
|
|
687
|
+
declare const GENERAL_PURPOSE_SUBAGENT: Pick<SubAgent, "name" | "description" | "systemPrompt">;
|
|
428
688
|
/**
|
|
429
689
|
* Options for creating subagent middleware
|
|
430
690
|
*/
|
|
@@ -433,8 +693,13 @@ interface SubAgentMiddlewareOptions {
|
|
|
433
693
|
defaultModel: LanguageModelLike | string;
|
|
434
694
|
/** The tools to use for the default general-purpose subagent */
|
|
435
695
|
defaultTools?: StructuredTool[];
|
|
436
|
-
/** Default middleware to apply to
|
|
696
|
+
/** Default middleware to apply to custom subagents (WITHOUT skills from main agent) */
|
|
437
697
|
defaultMiddleware?: AgentMiddleware$1[] | null;
|
|
698
|
+
/**
|
|
699
|
+
* Middleware specifically for the general-purpose subagent (includes skills from main agent).
|
|
700
|
+
* If not provided, falls back to defaultMiddleware.
|
|
701
|
+
*/
|
|
702
|
+
generalPurposeMiddleware?: AgentMiddleware$1[] | null;
|
|
438
703
|
/** The tool configs for the default general-purpose subagent */
|
|
439
704
|
defaultInterruptOn?: Record<string, boolean | InterruptOnConfig> | null;
|
|
440
705
|
/** A list of additional subagents to provide to the agent */
|
|
@@ -449,7 +714,7 @@ interface SubAgentMiddlewareOptions {
|
|
|
449
714
|
/**
|
|
450
715
|
* Create subagent middleware with task tool
|
|
451
716
|
*/
|
|
452
|
-
declare function createSubAgentMiddleware(options: SubAgentMiddlewareOptions): AgentMiddleware$1<undefined, undefined, unknown, readonly [
|
|
717
|
+
declare function createSubAgentMiddleware(options: SubAgentMiddlewareOptions): AgentMiddleware$1<undefined, undefined, unknown, readonly [langchain.DynamicStructuredTool<z.ZodObject<{
|
|
453
718
|
description: z.ZodString;
|
|
454
719
|
subagent_type: z.ZodString;
|
|
455
720
|
}, z.core.$strip>, {
|
|
@@ -487,7 +752,7 @@ declare function createSubAgentMiddleware(options: SubAgentMiddlewareOptions): A
|
|
|
487
752
|
* });
|
|
488
753
|
* ```
|
|
489
754
|
*/
|
|
490
|
-
declare function createPatchToolCallsMiddleware(): AgentMiddleware<undefined, undefined, unknown, readonly (
|
|
755
|
+
declare function createPatchToolCallsMiddleware(): AgentMiddleware<undefined, undefined, unknown, readonly (_langchain_core_tools0.ClientTool | _langchain_core_tools0.ServerTool)[]>;
|
|
491
756
|
//#endregion
|
|
492
757
|
//#region src/backends/state.d.ts
|
|
493
758
|
/**
|
|
@@ -618,7 +883,7 @@ declare function createMemoryMiddleware(options: MemoryMiddlewareOptions): Agent
|
|
|
618
883
|
*/
|
|
619
884
|
memoryContents: z$1.ZodOptional<z$1.ZodRecord<z$1.ZodString, z$1.ZodString>>;
|
|
620
885
|
files: _langchain_langgraph0.ReducedValue<FilesRecord | undefined, FilesRecordUpdate | undefined>;
|
|
621
|
-
}>, undefined, unknown, readonly (
|
|
886
|
+
}>, undefined, unknown, readonly (_langchain_core_tools0.ClientTool | _langchain_core_tools0.ServerTool)[]>;
|
|
622
887
|
//#endregion
|
|
623
888
|
//#region src/middleware/skills.d.ts
|
|
624
889
|
declare const MAX_SKILL_FILE_SIZE: number;
|
|
@@ -700,7 +965,7 @@ declare function createSkillsMiddleware(options: SkillsMiddlewareOptions): Agent
|
|
|
700
965
|
allowedTools?: string[] | undefined;
|
|
701
966
|
}[] | undefined>;
|
|
702
967
|
files: ReducedValue<FilesRecord | undefined, FilesRecordUpdate | undefined>;
|
|
703
|
-
}>, undefined, unknown, readonly (
|
|
968
|
+
}>, undefined, unknown, readonly (_langchain_core_tools0.ClientTool | _langchain_core_tools0.ServerTool)[]>;
|
|
704
969
|
//#endregion
|
|
705
970
|
//#region src/backends/store.d.ts
|
|
706
971
|
/**
|
|
@@ -876,18 +1141,37 @@ declare class FilesystemBackend implements BackendProtocol {
|
|
|
876
1141
|
*/
|
|
877
1142
|
edit(filePath: string, oldString: string, newString: string, replaceAll?: boolean): Promise<EditResult>;
|
|
878
1143
|
/**
|
|
879
|
-
*
|
|
1144
|
+
* Search for a literal text pattern in files.
|
|
1145
|
+
*
|
|
1146
|
+
* Uses ripgrep if available, falling back to substring search.
|
|
1147
|
+
*
|
|
1148
|
+
* @param pattern - Literal string to search for (NOT regex).
|
|
1149
|
+
* @param dirPath - Directory or file path to search in. Defaults to current directory.
|
|
1150
|
+
* @param glob - Optional glob pattern to filter which files to search.
|
|
1151
|
+
* @returns List of GrepMatch dicts containing path, line number, and matched text.
|
|
880
1152
|
*/
|
|
881
1153
|
grepRaw(pattern: string, dirPath?: string, glob?: string | null): Promise<GrepMatch[] | string>;
|
|
882
1154
|
/**
|
|
883
|
-
*
|
|
884
|
-
*
|
|
1155
|
+
* Search using ripgrep with fixed-string (literal) mode.
|
|
1156
|
+
*
|
|
1157
|
+
* @param pattern - Literal string to search for (unescaped).
|
|
1158
|
+
* @param baseFull - Resolved base path to search in.
|
|
1159
|
+
* @param includeGlob - Optional glob pattern to filter files.
|
|
1160
|
+
* @returns Dict mapping file paths to list of (line_number, line_text) tuples.
|
|
1161
|
+
* Returns null if ripgrep is unavailable or times out.
|
|
885
1162
|
*/
|
|
886
1163
|
private ripgrepSearch;
|
|
887
1164
|
/**
|
|
888
|
-
* Fallback
|
|
1165
|
+
* Fallback search using literal substring matching when ripgrep is unavailable.
|
|
1166
|
+
*
|
|
1167
|
+
* Recursively searches files, respecting maxFileSizeBytes limit.
|
|
1168
|
+
*
|
|
1169
|
+
* @param pattern - Literal string to search for.
|
|
1170
|
+
* @param baseFull - Resolved base path to search in.
|
|
1171
|
+
* @param includeGlob - Optional glob pattern to filter files by name.
|
|
1172
|
+
* @returns Dict mapping file paths to list of (line_number, line_text) tuples.
|
|
889
1173
|
*/
|
|
890
|
-
private
|
|
1174
|
+
private literalSearch;
|
|
891
1175
|
/**
|
|
892
1176
|
* Structured glob matching returning FileInfo objects.
|
|
893
1177
|
*/
|
|
@@ -1058,7 +1342,12 @@ declare abstract class BaseSandbox implements SandboxBackendProtocol {
|
|
|
1058
1342
|
*/
|
|
1059
1343
|
readRaw(filePath: string): Promise<FileData>;
|
|
1060
1344
|
/**
|
|
1061
|
-
*
|
|
1345
|
+
* Search for a literal text pattern in files.
|
|
1346
|
+
*
|
|
1347
|
+
* @param pattern - Literal string to search for (NOT regex).
|
|
1348
|
+
* @param path - Directory or file path to search in.
|
|
1349
|
+
* @param glob - Optional glob pattern to filter which files to search.
|
|
1350
|
+
* @returns List of GrepMatch dicts containing path, line number, and matched text.
|
|
1062
1351
|
*/
|
|
1063
1352
|
grepRaw(pattern: string, path?: string, glob?: string | null): Promise<GrepMatch[] | string>;
|
|
1064
1353
|
/**
|
|
@@ -1362,7 +1651,7 @@ declare function createDeepAgent<TResponse extends ResponseFormat = ResponseForm
|
|
|
1362
1651
|
content: string;
|
|
1363
1652
|
status: "completed" | "in_progress" | "pending";
|
|
1364
1653
|
}[] | undefined;
|
|
1365
|
-
}>, undefined, unknown, readonly [
|
|
1654
|
+
}>, undefined, unknown, readonly [langchain.DynamicStructuredTool<zod_v30.ZodObject<{
|
|
1366
1655
|
todos: zod_v30.ZodArray<zod_v30.ZodObject<{
|
|
1367
1656
|
content: zod_v30.ZodString;
|
|
1368
1657
|
status: zod_v30.ZodEnum<["pending", "in_progress", "completed"]>;
|
|
@@ -1401,16 +1690,16 @@ declare function createDeepAgent<TResponse extends ResponseFormat = ResponseForm
|
|
|
1401
1690
|
messages: _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>>[];
|
|
1402
1691
|
}, string>, "write_todos">]>, AgentMiddleware<_langchain_langgraph0.StateSchema<{
|
|
1403
1692
|
files: _langchain_langgraph0.ReducedValue<FilesRecord | undefined, FilesRecordUpdate | undefined>;
|
|
1404
|
-
}>, undefined, unknown, (
|
|
1405
|
-
path:
|
|
1693
|
+
}>, undefined, unknown, (langchain.DynamicStructuredTool<zod.ZodObject<{
|
|
1694
|
+
path: zod.ZodDefault<zod.ZodOptional<zod.ZodString>>;
|
|
1406
1695
|
}, zod_v4_core0.$strip>, {
|
|
1407
1696
|
path: string;
|
|
1408
1697
|
}, {
|
|
1409
1698
|
path?: string | undefined;
|
|
1410
|
-
}, string, "ls"> |
|
|
1411
|
-
file_path:
|
|
1412
|
-
offset:
|
|
1413
|
-
limit:
|
|
1699
|
+
}, string, "ls"> | langchain.DynamicStructuredTool<zod.ZodObject<{
|
|
1700
|
+
file_path: zod.ZodString;
|
|
1701
|
+
offset: zod.ZodDefault<zod.ZodOptional<zod.ZodCoercedNumber<unknown>>>;
|
|
1702
|
+
limit: zod.ZodDefault<zod.ZodOptional<zod.ZodCoercedNumber<unknown>>>;
|
|
1414
1703
|
}, zod_v4_core0.$strip>, {
|
|
1415
1704
|
file_path: string;
|
|
1416
1705
|
offset: number;
|
|
@@ -1419,9 +1708,9 @@ declare function createDeepAgent<TResponse extends ResponseFormat = ResponseForm
|
|
|
1419
1708
|
file_path: string;
|
|
1420
1709
|
offset?: unknown;
|
|
1421
1710
|
limit?: unknown;
|
|
1422
|
-
}, string, "read_file"> |
|
|
1423
|
-
file_path:
|
|
1424
|
-
content:
|
|
1711
|
+
}, string, "read_file"> | langchain.DynamicStructuredTool<zod.ZodObject<{
|
|
1712
|
+
file_path: zod.ZodString;
|
|
1713
|
+
content: zod.ZodString;
|
|
1425
1714
|
}, zod_v4_core0.$strip>, {
|
|
1426
1715
|
file_path: string;
|
|
1427
1716
|
content: string;
|
|
@@ -1431,11 +1720,11 @@ declare function createDeepAgent<TResponse extends ResponseFormat = ResponseForm
|
|
|
1431
1720
|
}, string | _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>> | _langchain_langgraph0.Command<unknown, {
|
|
1432
1721
|
files: Record<string, FileData>;
|
|
1433
1722
|
messages: _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>>[];
|
|
1434
|
-
}, string>, "write_file"> |
|
|
1435
|
-
file_path:
|
|
1436
|
-
old_string:
|
|
1437
|
-
new_string:
|
|
1438
|
-
replace_all:
|
|
1723
|
+
}, string>, "write_file"> | langchain.DynamicStructuredTool<zod.ZodObject<{
|
|
1724
|
+
file_path: zod.ZodString;
|
|
1725
|
+
old_string: zod.ZodString;
|
|
1726
|
+
new_string: zod.ZodString;
|
|
1727
|
+
replace_all: zod.ZodDefault<zod.ZodOptional<zod.ZodBoolean>>;
|
|
1439
1728
|
}, zod_v4_core0.$strip>, {
|
|
1440
1729
|
file_path: string;
|
|
1441
1730
|
old_string: string;
|
|
@@ -1449,19 +1738,19 @@ declare function createDeepAgent<TResponse extends ResponseFormat = ResponseForm
|
|
|
1449
1738
|
}, string | _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>> | _langchain_langgraph0.Command<unknown, {
|
|
1450
1739
|
files: Record<string, FileData>;
|
|
1451
1740
|
messages: _messages.ToolMessage<_messages.MessageStructure<_messages.MessageToolSet>>[];
|
|
1452
|
-
}, string>, "edit_file"> |
|
|
1453
|
-
pattern:
|
|
1454
|
-
path:
|
|
1741
|
+
}, string>, "edit_file"> | langchain.DynamicStructuredTool<zod.ZodObject<{
|
|
1742
|
+
pattern: zod.ZodString;
|
|
1743
|
+
path: zod.ZodDefault<zod.ZodOptional<zod.ZodString>>;
|
|
1455
1744
|
}, zod_v4_core0.$strip>, {
|
|
1456
1745
|
pattern: string;
|
|
1457
1746
|
path: string;
|
|
1458
1747
|
}, {
|
|
1459
1748
|
pattern: string;
|
|
1460
1749
|
path?: string | undefined;
|
|
1461
|
-
}, string, "glob"> |
|
|
1462
|
-
pattern:
|
|
1463
|
-
path:
|
|
1464
|
-
glob:
|
|
1750
|
+
}, string, "glob"> | langchain.DynamicStructuredTool<zod.ZodObject<{
|
|
1751
|
+
pattern: zod.ZodString;
|
|
1752
|
+
path: zod.ZodDefault<zod.ZodOptional<zod.ZodString>>;
|
|
1753
|
+
glob: zod.ZodNullable<zod.ZodOptional<zod.ZodString>>;
|
|
1465
1754
|
}, zod_v4_core0.$strip>, {
|
|
1466
1755
|
pattern: string;
|
|
1467
1756
|
path: string;
|
|
@@ -1470,15 +1759,15 @@ declare function createDeepAgent<TResponse extends ResponseFormat = ResponseForm
|
|
|
1470
1759
|
pattern: string;
|
|
1471
1760
|
path?: string | undefined;
|
|
1472
1761
|
glob?: string | null | undefined;
|
|
1473
|
-
}, string, "grep"> |
|
|
1474
|
-
command:
|
|
1762
|
+
}, string, "grep"> | langchain.DynamicStructuredTool<zod.ZodObject<{
|
|
1763
|
+
command: zod.ZodString;
|
|
1475
1764
|
}, zod_v4_core0.$strip>, {
|
|
1476
1765
|
command: string;
|
|
1477
1766
|
}, {
|
|
1478
1767
|
command: string;
|
|
1479
|
-
}, string, "execute">)[]>, AgentMiddleware<undefined, undefined, unknown, readonly [
|
|
1480
|
-
description:
|
|
1481
|
-
subagent_type:
|
|
1768
|
+
}, string, "execute">)[]>, AgentMiddleware<undefined, undefined, unknown, readonly [langchain.DynamicStructuredTool<zod.ZodObject<{
|
|
1769
|
+
description: zod.ZodString;
|
|
1770
|
+
subagent_type: zod.ZodString;
|
|
1482
1771
|
}, zod_v4_core0.$strip>, {
|
|
1483
1772
|
description: string;
|
|
1484
1773
|
subagent_type: string;
|
|
@@ -1795,7 +2084,7 @@ interface AgentMemoryMiddlewareOptions {
|
|
|
1795
2084
|
* @deprecated Use `createMemoryMiddleware` from `./memory.js` instead.
|
|
1796
2085
|
* This function uses direct filesystem access which limits portability.
|
|
1797
2086
|
*/
|
|
1798
|
-
declare function createAgentMemoryMiddleware(options: AgentMemoryMiddlewareOptions): AgentMiddleware<any, undefined, unknown, readonly (
|
|
2087
|
+
declare function createAgentMemoryMiddleware(options: AgentMemoryMiddlewareOptions): AgentMiddleware<any, undefined, unknown, readonly (_langchain_core_tools0.ClientTool | _langchain_core_tools0.ServerTool)[]>;
|
|
1799
2088
|
//#endregion
|
|
1800
2089
|
//#region src/skills/loader.d.ts
|
|
1801
2090
|
/**
|
|
@@ -1849,5 +2138,5 @@ declare function parseSkillMetadata(skillMdPath: string, source: "user" | "proje
|
|
|
1849
2138
|
*/
|
|
1850
2139
|
declare function listSkills(options: ListSkillsOptions): SkillMetadata[];
|
|
1851
2140
|
//#endregion
|
|
1852
|
-
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, filesValue, findProjectRoot, isSandboxBackend, listSkills, parseSkillMetadata };
|
|
2141
|
+
export { type AgentMemoryMiddlewareOptions, type BackendFactory, type BackendProtocol, BaseSandbox, type CompiledSubAgent, CompositeBackend, type CreateDeepAgentParams, DEFAULT_GENERAL_PURPOSE_DESCRIPTION, DEFAULT_SUBAGENT_PROMPT, type DeepAgent, type DeepAgentTypeConfig, type DefaultDeepAgentTypeConfig, type EditResult, type ExecuteResponse, type ExtractSubAgentMiddleware, type FileData, type FileDownloadResponse, type FileInfo, type FileOperationError, type FileUploadResponse, FilesystemBackend, type FilesystemMiddlewareOptions, type FlattenSubAgentMiddleware, GENERAL_PURPOSE_SUBAGENT, type GrepMatch, type InferDeepAgentSubagents, type InferDeepAgentType, type InferSubAgentMiddlewareStates, type InferSubagentByName, type InferSubagentReactAgentType, type ListSkillsOptions, type SkillMetadata as LoaderSkillMetadata, MAX_SKILL_DESCRIPTION_LENGTH, MAX_SKILL_FILE_SIZE, MAX_SKILL_NAME_LENGTH, type MaybePromise, type MemoryMiddlewareOptions, type MergedDeepAgentState, type ResolveDeepAgentTypeConfig, type SandboxBackendProtocol, type SandboxDeleteOptions, SandboxError, type SandboxErrorCode, type SandboxGetOrCreateOptions, type SandboxInfo, type SandboxListOptions, type SandboxListResponse, type Settings, type SettingsOptions, type SkillMetadata$1 as SkillMetadata, type SkillsMiddlewareOptions, StateBackend, StoreBackend, type SubAgent, type SubAgentMiddlewareOptions, TASK_SYSTEM_PROMPT, type WriteResult, createAgentMemoryMiddleware, createDeepAgent, createFilesystemMiddleware, createMemoryMiddleware, createPatchToolCallsMiddleware, createSettings, createSkillsMiddleware, createSubAgentMiddleware, filesValue, findProjectRoot, isSandboxBackend, listSkills, parseSkillMetadata };
|
|
1853
2142
|
//# sourceMappingURL=index.d.cts.map
|