deepagents 0.0.2 → 1.0.0-beta.2

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/package.json CHANGED
@@ -1,25 +1,10 @@
1
1
  {
2
2
  "name": "deepagents",
3
- "version": "0.0.2",
3
+ "version": "1.0.0-beta.2",
4
4
  "description": "Deep Agents - a library for building controllable AI agents with LangGraph",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "type": "module",
8
- "scripts": {
9
- "build": "yarn clean && tsc",
10
- "build:examples": "yarn clean && tsc -p examples.tsconfig.json",
11
- "build:watch": "tsc --watch",
12
- "dev": "tsc --watch",
13
- "clean": "rm -rf dist dist-examples || true",
14
- "typecheck": "tsc --noEmit",
15
- "lint": "eslint src/**/*.ts examples/**/*.ts",
16
- "lint:fix": "eslint src/**/*.ts examples/**/*.ts --fix",
17
- "format": "prettier --write \"src/**/*.{ts,js,json,md}\" \"examples/**/*.{ts,js,json,md}\"",
18
- "format:check": "prettier --check \"src/**/*.{ts,js,json,md}\" \"examples/**/*.{ts,js,json,md}\"",
19
- "prepublishOnly": "yarn build",
20
- "test": "echo \"Error: no test specified\" && exit 0",
21
- "start": "node dist/index.js"
22
- },
23
8
  "repository": {
24
9
  "type": "git",
25
10
  "url": "git+https://github.com/langchain-ai/deepagentsjs.git"
@@ -39,17 +24,20 @@
39
24
  },
40
25
  "homepage": "https://github.com/langchain-ai/deepagentsjs#readme",
41
26
  "dependencies": {
42
- "@langchain/anthropic": "^0.3.25",
43
- "@langchain/core": "^0.3.66",
44
- "@langchain/langgraph": "^0.4.6",
45
- "zod": "^3.25.32"
27
+ "@langchain/anthropic": "^1.0.0",
28
+ "@langchain/core": "^1.0.0",
29
+ "@langchain/langgraph": "^1.0.0",
30
+ "langchain": "^1.0.0",
31
+ "zod": "^4.1.11"
46
32
  },
47
33
  "devDependencies": {
48
34
  "@eslint/eslintrc": "^3.1.0",
49
35
  "@eslint/js": "^9.19.0",
36
+ "@langchain/openai": "^1.0.0",
50
37
  "@langchain/tavily": "^0.1.4",
51
- "@tsconfig/recommended": "^1.0.8",
38
+ "@tsconfig/recommended": "^1.0.10",
52
39
  "@types/node": "^22.13.5",
40
+ "@vitest/ui": "^2.1.8",
53
41
  "dotenv": "^17.2.1",
54
42
  "eslint": "^9.19.0",
55
43
  "eslint-config-prettier": "^8.8.0",
@@ -58,15 +46,27 @@
58
46
  "eslint-plugin-prettier": "^4.2.1",
59
47
  "globals": "^15.0.0",
60
48
  "prettier": "^3.6.2",
61
- "typescript": "^5",
62
- "typescript-eslint": "^8.22.0"
63
- },
64
- "resolutions": {
65
- "@langchain/langgraph": ">=0.2.53",
66
- "@langchain/core": ">=0.3.0"
49
+ "tsdown": "^0.15.12",
50
+ "tsx": "^4.20.5",
51
+ "typescript": "^5.9.2",
52
+ "typescript-eslint": "^8.22.0",
53
+ "vitest": "^2.1.8"
67
54
  },
68
55
  "files": [
69
56
  "dist/**/*"
70
57
  ],
71
- "packageManager": "yarn@1.22.22"
72
- }
58
+ "scripts": {
59
+ "build": "tsdown",
60
+ "dev": "tsc --watch",
61
+ "typecheck": "tsc --noEmit",
62
+ "lint": "eslint src/**/*.ts examples/**/*.ts",
63
+ "lint:fix": "eslint src/**/*.ts examples/**/*.ts --fix",
64
+ "format": "prettier --write \"src/**/*.{ts,js,json,md}\" \"examples/**/*.{ts,js,json,md}\"",
65
+ "format:check": "prettier --check \"src/**/*.{ts,js,json,md}\" \"examples/**/*.{ts,js,json,md}\"",
66
+ "test": "vitest run",
67
+ "test:watch": "vitest",
68
+ "test:ui": "vitest --ui",
69
+ "test:coverage": "vitest run --coverage",
70
+ "start": "node dist/index.js"
71
+ }
72
+ }
package/dist/graph.d.ts DELETED
@@ -1,128 +0,0 @@
1
- /**
2
- * Main createDeepAgent function for Deep Agents
3
- *
4
- * Main entry point for creating deep agents with TypeScript types for all parameters:
5
- * tools, instructions, model, subagents, and stateSchema. Combines built-in tools with
6
- * provided tools, creates task tool using createTaskTool(), and returns createReactAgent
7
- * with proper configuration. Ensures exact parameter matching and behavior with Python version.
8
- */
9
- import { InteropZodObject } from "@langchain/core/utils/types";
10
- import type { AnyAnnotationRoot, CreateDeepAgentParams } from "./types.js";
11
- import { z } from "zod";
12
- /**
13
- * Create a Deep Agent with TypeScript types for all parameters.
14
- * Combines built-in tools with provided tools, creates task tool using createTaskTool(),
15
- * and returns createReactAgent with proper configuration.
16
- * Ensures exact parameter matching and behavior with Python version.
17
- *
18
- */
19
- export declare function createDeepAgent<StateSchema extends z.ZodObject<any, any, any, any, any>, ContextSchema extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot>(params?: CreateDeepAgentParams<StateSchema, ContextSchema>): import("@langchain/langgraph").CompiledStateGraph<import("@langchain/langgraph").StateType<import("@langchain/langgraph/zod").InteropZodToStateDefinition<z.ZodObject<{
20
- messages: import("@langchain/langgraph/zod").ReducedZodChannel<z.ZodType<import("@langchain/core/messages").BaseMessage[], z.ZodTypeDef, import("@langchain/core/messages").BaseMessage[]>, import("@langchain/core/utils/types").InteropZodType<import("@langchain/langgraph").Messages>>;
21
- } & {
22
- todos: import("@langchain/langgraph/zod").ReducedZodChannel<z.ZodType<import("./types.js").Todo[], z.ZodTypeDef, import("./types.js").Todo[]>, import("@langchain/core/utils/types").InteropZodType<import("./types.js").Todo[] | null | undefined>>;
23
- files: import("@langchain/langgraph/zod").ReducedZodChannel<z.ZodType<Record<string, string>, z.ZodTypeDef, Record<string, string>>, import("@langchain/core/utils/types").InteropZodType<Record<string, string> | null | undefined>>;
24
- }, "strip", z.ZodTypeAny, {
25
- todos: import("./types.js").Todo[];
26
- files: Record<string, string>;
27
- messages: import("@langchain/core/messages").BaseMessage[];
28
- }, {
29
- todos: import("./types.js").Todo[];
30
- files: Record<string, string>;
31
- messages: import("@langchain/core/messages").BaseMessage[];
32
- }>, {
33
- messages: import("@langchain/langgraph/zod").ReducedZodChannel<z.ZodType<import("@langchain/core/messages").BaseMessage[], z.ZodTypeDef, import("@langchain/core/messages").BaseMessage[]>, import("@langchain/core/utils/types").InteropZodType<import("@langchain/langgraph").Messages>>;
34
- todos: import("@langchain/langgraph/zod").ReducedZodChannel<z.ZodType<import("./types.js").Todo[], z.ZodTypeDef, import("./types.js").Todo[]>, import("@langchain/core/utils/types").InteropZodType<import("./types.js").Todo[] | null | undefined>>;
35
- files: import("@langchain/langgraph/zod").ReducedZodChannel<z.ZodType<Record<string, string>, z.ZodTypeDef, Record<string, string>>, import("@langchain/core/utils/types").InteropZodType<Record<string, string> | null | undefined>>;
36
- }>> | import("@langchain/langgraph").StateType<import("@langchain/langgraph/zod").InteropZodToStateDefinition<z.ZodObject<{} & {
37
- [x: string]: any;
38
- }, "strip", z.ZodTypeAny, {
39
- [x: string]: any;
40
- }, {
41
- [x: string]: any;
42
- }>, {
43
- [x: string]: any;
44
- }>>, import("@langchain/langgraph").UpdateType<import("@langchain/langgraph/zod").InteropZodToStateDefinition<z.ZodObject<{
45
- messages: import("@langchain/langgraph/zod").ReducedZodChannel<z.ZodType<import("@langchain/core/messages").BaseMessage[], z.ZodTypeDef, import("@langchain/core/messages").BaseMessage[]>, import("@langchain/core/utils/types").InteropZodType<import("@langchain/langgraph").Messages>>;
46
- } & {
47
- todos: import("@langchain/langgraph/zod").ReducedZodChannel<z.ZodType<import("./types.js").Todo[], z.ZodTypeDef, import("./types.js").Todo[]>, import("@langchain/core/utils/types").InteropZodType<import("./types.js").Todo[] | null | undefined>>;
48
- files: import("@langchain/langgraph/zod").ReducedZodChannel<z.ZodType<Record<string, string>, z.ZodTypeDef, Record<string, string>>, import("@langchain/core/utils/types").InteropZodType<Record<string, string> | null | undefined>>;
49
- }, "strip", z.ZodTypeAny, {
50
- todos: import("./types.js").Todo[];
51
- files: Record<string, string>;
52
- messages: import("@langchain/core/messages").BaseMessage[];
53
- }, {
54
- todos: import("./types.js").Todo[];
55
- files: Record<string, string>;
56
- messages: import("@langchain/core/messages").BaseMessage[];
57
- }>, {
58
- messages: import("@langchain/langgraph/zod").ReducedZodChannel<z.ZodType<import("@langchain/core/messages").BaseMessage[], z.ZodTypeDef, import("@langchain/core/messages").BaseMessage[]>, import("@langchain/core/utils/types").InteropZodType<import("@langchain/langgraph").Messages>>;
59
- todos: import("@langchain/langgraph/zod").ReducedZodChannel<z.ZodType<import("./types.js").Todo[], z.ZodTypeDef, import("./types.js").Todo[]>, import("@langchain/core/utils/types").InteropZodType<import("./types.js").Todo[] | null | undefined>>;
60
- files: import("@langchain/langgraph/zod").ReducedZodChannel<z.ZodType<Record<string, string>, z.ZodTypeDef, Record<string, string>>, import("@langchain/core/utils/types").InteropZodType<Record<string, string> | null | undefined>>;
61
- }>> | import("@langchain/langgraph").UpdateType<import("@langchain/langgraph/zod").InteropZodToStateDefinition<z.ZodObject<{} & {
62
- [x: string]: any;
63
- }, "strip", z.ZodTypeAny, {
64
- [x: string]: any;
65
- }, {
66
- [x: string]: any;
67
- }>, {
68
- [x: string]: any;
69
- }>>, any, {
70
- messages: import("@langchain/langgraph").BinaryOperatorAggregate<import("@langchain/core/messages").BaseMessage[], import("@langchain/langgraph").Messages>;
71
- } & (import("@langchain/langgraph/zod").InteropZodToStateDefinition<z.ZodObject<{
72
- messages: import("@langchain/langgraph/zod").ReducedZodChannel<z.ZodType<import("@langchain/core/messages").BaseMessage[], z.ZodTypeDef, import("@langchain/core/messages").BaseMessage[]>, import("@langchain/core/utils/types").InteropZodType<import("@langchain/langgraph").Messages>>;
73
- } & {
74
- todos: import("@langchain/langgraph/zod").ReducedZodChannel<z.ZodType<import("./types.js").Todo[], z.ZodTypeDef, import("./types.js").Todo[]>, import("@langchain/core/utils/types").InteropZodType<import("./types.js").Todo[] | null | undefined>>;
75
- files: import("@langchain/langgraph/zod").ReducedZodChannel<z.ZodType<Record<string, string>, z.ZodTypeDef, Record<string, string>>, import("@langchain/core/utils/types").InteropZodType<Record<string, string> | null | undefined>>;
76
- }, "strip", z.ZodTypeAny, {
77
- todos: import("./types.js").Todo[];
78
- files: Record<string, string>;
79
- messages: import("@langchain/core/messages").BaseMessage[];
80
- }, {
81
- todos: import("./types.js").Todo[];
82
- files: Record<string, string>;
83
- messages: import("@langchain/core/messages").BaseMessage[];
84
- }>, {
85
- messages: import("@langchain/langgraph/zod").ReducedZodChannel<z.ZodType<import("@langchain/core/messages").BaseMessage[], z.ZodTypeDef, import("@langchain/core/messages").BaseMessage[]>, import("@langchain/core/utils/types").InteropZodType<import("@langchain/langgraph").Messages>>;
86
- todos: import("@langchain/langgraph/zod").ReducedZodChannel<z.ZodType<import("./types.js").Todo[], z.ZodTypeDef, import("./types.js").Todo[]>, import("@langchain/core/utils/types").InteropZodType<import("./types.js").Todo[] | null | undefined>>;
87
- files: import("@langchain/langgraph/zod").ReducedZodChannel<z.ZodType<Record<string, string>, z.ZodTypeDef, Record<string, string>>, import("@langchain/core/utils/types").InteropZodType<Record<string, string> | null | undefined>>;
88
- }> | import("@langchain/langgraph/zod").InteropZodToStateDefinition<z.ZodObject<{} & {
89
- [x: string]: any;
90
- }, "strip", z.ZodTypeAny, {
91
- [x: string]: any;
92
- }, {
93
- [x: string]: any;
94
- }>, {
95
- [x: string]: any;
96
- }>), {
97
- messages: import("@langchain/langgraph").BinaryOperatorAggregate<import("@langchain/core/messages").BaseMessage[], import("@langchain/langgraph").Messages>;
98
- structuredResponse: {
99
- (): import("@langchain/langgraph").LastValue<Record<string, any>>;
100
- (annotation: import("@langchain/langgraph").SingleReducer<Record<string, any>, Record<string, any>>): import("@langchain/langgraph").BinaryOperatorAggregate<Record<string, any>, Record<string, any>>;
101
- Root: <S extends import("@langchain/langgraph").StateDefinition>(sd: S) => import("@langchain/langgraph").AnnotationRoot<S>;
102
- };
103
- } & (import("@langchain/langgraph/zod").InteropZodToStateDefinition<z.ZodObject<{
104
- messages: import("@langchain/langgraph/zod").ReducedZodChannel<z.ZodType<import("@langchain/core/messages").BaseMessage[], z.ZodTypeDef, import("@langchain/core/messages").BaseMessage[]>, import("@langchain/core/utils/types").InteropZodType<import("@langchain/langgraph").Messages>>;
105
- } & {
106
- todos: import("@langchain/langgraph/zod").ReducedZodChannel<z.ZodType<import("./types.js").Todo[], z.ZodTypeDef, import("./types.js").Todo[]>, import("@langchain/core/utils/types").InteropZodType<import("./types.js").Todo[] | null | undefined>>;
107
- files: import("@langchain/langgraph/zod").ReducedZodChannel<z.ZodType<Record<string, string>, z.ZodTypeDef, Record<string, string>>, import("@langchain/core/utils/types").InteropZodType<Record<string, string> | null | undefined>>;
108
- }, "strip", z.ZodTypeAny, {
109
- todos: import("./types.js").Todo[];
110
- files: Record<string, string>;
111
- messages: import("@langchain/core/messages").BaseMessage[];
112
- }, {
113
- todos: import("./types.js").Todo[];
114
- files: Record<string, string>;
115
- messages: import("@langchain/core/messages").BaseMessage[];
116
- }>, {
117
- messages: import("@langchain/langgraph/zod").ReducedZodChannel<z.ZodType<import("@langchain/core/messages").BaseMessage[], z.ZodTypeDef, import("@langchain/core/messages").BaseMessage[]>, import("@langchain/core/utils/types").InteropZodType<import("@langchain/langgraph").Messages>>;
118
- todos: import("@langchain/langgraph/zod").ReducedZodChannel<z.ZodType<import("./types.js").Todo[], z.ZodTypeDef, import("./types.js").Todo[]>, import("@langchain/core/utils/types").InteropZodType<import("./types.js").Todo[] | null | undefined>>;
119
- files: import("@langchain/langgraph/zod").ReducedZodChannel<z.ZodType<Record<string, string>, z.ZodTypeDef, Record<string, string>>, import("@langchain/core/utils/types").InteropZodType<Record<string, string> | null | undefined>>;
120
- }> | import("@langchain/langgraph/zod").InteropZodToStateDefinition<z.ZodObject<{} & {
121
- [x: string]: any;
122
- }, "strip", z.ZodTypeAny, {
123
- [x: string]: any;
124
- }, {
125
- [x: string]: any;
126
- }>, {
127
- [x: string]: any;
128
- }>), import("@langchain/langgraph").StateDefinition, unknown>;
package/dist/graph.js DELETED
@@ -1,104 +0,0 @@
1
- /**
2
- * Main createDeepAgent function for Deep Agents
3
- *
4
- * Main entry point for creating deep agents with TypeScript types for all parameters:
5
- * tools, instructions, model, subagents, and stateSchema. Combines built-in tools with
6
- * provided tools, creates task tool using createTaskTool(), and returns createReactAgent
7
- * with proper configuration. Ensures exact parameter matching and behavior with Python version.
8
- */
9
- // import "@langchain/anthropic/zod";
10
- import { createReactAgent } from "@langchain/langgraph/prebuilt";
11
- import { createTaskTool } from "./subAgent.js";
12
- import { getDefaultModel } from "./model.js";
13
- import { writeTodos, readFile, writeFile, editFile, ls } from "./tools.js";
14
- import { DeepAgentState } from "./state.js";
15
- import { createInterruptHook } from "./interrupt.js";
16
- /**
17
- * Base prompt that provides instructions about available tools
18
- * Ported from Python implementation to ensure consistent behavior
19
- */
20
- const BASE_PROMPT = `You have access to a number of standard tools
21
-
22
- ## \`write_todos\`
23
-
24
- You have access to the \`write_todos\` tools to help you manage and plan tasks. Use these tools VERY frequently to ensure that you are tracking your tasks and giving the user visibility into your progress.
25
- These tools are also EXTREMELY helpful for planning tasks, and for breaking down larger complex tasks into smaller steps. If you do not use this tool when planning, you may forget to do important tasks - and that is unacceptable.
26
-
27
- It is critical that you mark todos as completed as soon as you are done with a task. Do not batch up multiple tasks before marking them as completed.
28
- ## \`task\`
29
-
30
- - When doing web search, prefer to use the \`task\` tool in order to reduce context usage.`;
31
- /**
32
- * Built-in tools that are always available in Deep Agents
33
- */
34
- const BUILTIN_TOOLS = [
35
- writeTodos,
36
- readFile,
37
- writeFile,
38
- editFile,
39
- ls,
40
- ];
41
- /**
42
- * Create a Deep Agent with TypeScript types for all parameters.
43
- * Combines built-in tools with provided tools, creates task tool using createTaskTool(),
44
- * and returns createReactAgent with proper configuration.
45
- * Ensures exact parameter matching and behavior with Python version.
46
- *
47
- */
48
- export function createDeepAgent(params = {}) {
49
- const { tools = [], instructions, model = getDefaultModel(), subagents = [], postModelHook, contextSchema, interruptConfig = {}, builtinTools, } = params;
50
- const stateSchema = params.stateSchema
51
- ? DeepAgentState.extend(params.stateSchema.shape)
52
- : DeepAgentState;
53
- // Filter built-in tools if builtinTools parameter is provided
54
- const selectedBuiltinTools = builtinTools
55
- ? BUILTIN_TOOLS.filter((tool) => builtinTools.some((bt) => bt === tool.name))
56
- : BUILTIN_TOOLS;
57
- // Combine built-in tools with provided tools
58
- const allTools = [...selectedBuiltinTools, ...tools];
59
- // Create task tool using createTaskTool() if subagents are provided
60
- if (subagents.length > 0) {
61
- // Create tools map for task tool creation
62
- const toolsMap = {};
63
- for (const tool of allTools) {
64
- if (tool.name) {
65
- toolsMap[tool.name] = tool;
66
- }
67
- }
68
- const taskTool = createTaskTool({
69
- subagents,
70
- tools: toolsMap,
71
- model,
72
- stateSchema,
73
- });
74
- allTools.push(taskTool);
75
- }
76
- // Combine instructions with base prompt like Python implementation
77
- const finalInstructions = instructions
78
- ? instructions + BASE_PROMPT
79
- : BASE_PROMPT;
80
- // Should never be the case that both are specified
81
- if (postModelHook && Object.keys(interruptConfig).length > 0) {
82
- throw new Error("Cannot specify both postModelHook and interruptConfig together. " +
83
- "Use either interruptConfig for tool interrupts or postModelHook for custom post-processing.");
84
- }
85
- let selectedPostModelHook;
86
- if (postModelHook !== undefined) {
87
- selectedPostModelHook = postModelHook;
88
- }
89
- else if (Object.keys(interruptConfig).length > 0) {
90
- selectedPostModelHook = createInterruptHook(interruptConfig);
91
- }
92
- else {
93
- selectedPostModelHook = undefined;
94
- }
95
- // Return createReactAgent with proper configuration
96
- return createReactAgent({
97
- llm: model,
98
- tools: allTools,
99
- stateSchema,
100
- messageModifier: finalInstructions,
101
- contextSchema,
102
- postModelHook: selectedPostModelHook,
103
- });
104
- }
@@ -1,2 +0,0 @@
1
- import type { DeepAgentStateType, ToolInterruptConfig } from "./types.js";
2
- export declare function createInterruptHook(toolConfigs: ToolInterruptConfig, messagePrefix?: string): (state: DeepAgentStateType) => Promise<Partial<DeepAgentStateType> | void>;
package/dist/interrupt.js DELETED
@@ -1,103 +0,0 @@
1
- import { interrupt } from "@langchain/langgraph";
2
- import { isAIMessage, AIMessage, ToolMessage } from "@langchain/core/messages";
3
- export function createInterruptHook(toolConfigs, messagePrefix = "Tool execution requires approval") {
4
- /**
5
- * Create a post model hook that handles interrupts using native LangGraph schemas.
6
- *
7
- * Args:
8
- * toolConfigs: Record mapping tool names to HumanInterruptConfig objects
9
- * messagePrefix: Optional message prefix for interrupt descriptions
10
- */
11
- Object.entries(toolConfigs).forEach(([tool, interruptConfig]) => {
12
- if (interruptConfig &&
13
- typeof interruptConfig === "object" &&
14
- interruptConfig.allow_ignore) {
15
- throw new Error(`For ${tool} we get allow_ignore = true - we currently don't support ignore.`);
16
- }
17
- });
18
- return async function interruptHook(state) {
19
- const messages = state.messages || [];
20
- if (!messages.length) {
21
- return;
22
- }
23
- const lastMessage = messages[messages.length - 1];
24
- if (!isAIMessage(lastMessage) ||
25
- !lastMessage.tool_calls ||
26
- !lastMessage.tool_calls.length) {
27
- return;
28
- }
29
- const interruptToolCalls = [];
30
- const autoApprovedToolCalls = [];
31
- for (const toolCall of lastMessage.tool_calls) {
32
- const toolName = toolCall.name;
33
- if (toolName in toolConfigs) {
34
- interruptToolCalls.push(toolCall);
35
- }
36
- else {
37
- autoApprovedToolCalls.push(toolCall);
38
- }
39
- }
40
- if (!interruptToolCalls.length) {
41
- return;
42
- }
43
- const approvedToolCalls = [...autoApprovedToolCalls];
44
- if (interruptToolCalls.length > 1) {
45
- throw new Error("Right now, interrupt hook only works when one tool requires interrupts");
46
- }
47
- const toolCall = interruptToolCalls[0];
48
- const toolName = toolCall.name;
49
- const toolArgs = toolCall.args;
50
- const description = `${messagePrefix}\n\nTool: ${toolName}\nArgs: ${JSON.stringify(toolArgs, null, 2)}`;
51
- const toolConfig = toolConfigs[toolName];
52
- const defaultToolConfig = {
53
- allow_accept: true,
54
- allow_edit: true,
55
- allow_respond: true,
56
- allow_ignore: false,
57
- };
58
- const request = {
59
- action_request: {
60
- action: toolName,
61
- args: toolArgs,
62
- },
63
- config: typeof toolConfig === "object" ? toolConfig : defaultToolConfig,
64
- description: description,
65
- };
66
- const res = await interrupt([request]);
67
- const responses = Array.isArray(res) ? res : [res];
68
- if (responses.length !== 1) {
69
- throw new Error(`Expected a list of one response, got ${responses}`);
70
- }
71
- const response = responses[0];
72
- if (response.type === "accept") {
73
- approvedToolCalls.push(toolCall);
74
- }
75
- else if (response.type === "edit") {
76
- const edited = response.args;
77
- const newToolCall = {
78
- name: edited.action,
79
- args: edited.args,
80
- id: toolCall.id,
81
- };
82
- approvedToolCalls.push(newToolCall);
83
- }
84
- else if (response.type === "response") {
85
- if (!toolCall.id) {
86
- throw new Error("Tool call must have an ID for response type");
87
- }
88
- const responseMessage = new ToolMessage({
89
- tool_call_id: toolCall.id,
90
- content: response.args,
91
- });
92
- return { messages: [responseMessage] };
93
- }
94
- else {
95
- throw new Error(`Unknown response type: ${response.type}`);
96
- }
97
- const updatedLastMessage = new AIMessage({
98
- ...lastMessage,
99
- tool_calls: approvedToolCalls,
100
- });
101
- return { messages: [updatedLastMessage] };
102
- };
103
- }
package/dist/model.d.ts DELETED
@@ -1,17 +0,0 @@
1
- /**
2
- * Model configuration for Deep Agents
3
- *
4
- * Default model configuration matching the Python implementation exactly.
5
- * Returns a ChatAnthropic instance configured with claude-sonnet-4-20250514 and maxTokens: 4096.
6
- */
7
- import { LanguageModelLike } from "./types.js";
8
- /**
9
- * Get the default model for Deep Agents
10
- *
11
- * Returns a ChatAnthropic instance configured exactly like the Python version:
12
- * - model: "claude-sonnet-4-20250514"
13
- * - maxTokens: 4096
14
- *
15
- * @returns ChatAnthropic instance with default configuration
16
- */
17
- export declare function getDefaultModel(): LanguageModelLike;
package/dist/model.js DELETED
@@ -1,22 +0,0 @@
1
- /**
2
- * Model configuration for Deep Agents
3
- *
4
- * Default model configuration matching the Python implementation exactly.
5
- * Returns a ChatAnthropic instance configured with claude-sonnet-4-20250514 and maxTokens: 4096.
6
- */
7
- import { ChatAnthropic } from "@langchain/anthropic";
8
- /**
9
- * Get the default model for Deep Agents
10
- *
11
- * Returns a ChatAnthropic instance configured exactly like the Python version:
12
- * - model: "claude-sonnet-4-20250514"
13
- * - maxTokens: 4096
14
- *
15
- * @returns ChatAnthropic instance with default configuration
16
- */
17
- export function getDefaultModel() {
18
- return new ChatAnthropic({
19
- model: "claude-sonnet-4-20250514",
20
- maxTokens: 4096,
21
- });
22
- }
package/dist/prompts.d.ts DELETED
@@ -1,31 +0,0 @@
1
- /**
2
- * Prompt constants for Deep Agents
3
- *
4
- * All prompt strings ported from Python implementation with exact string content and formatting
5
- * to ensure 1:1 compatibility with the Python version.
6
- */
7
- /**
8
- * Description for the write_todos tool
9
- * Ported exactly from Python WRITE_TODOS_DESCRIPTION
10
- */
11
- export declare const WRITE_TODOS_DESCRIPTION = "Use this tool to create and manage a structured task list for your current work session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user. It also helps the user understand the progress of the task and overall progress of their requests.\n\nWhen to Use This Tool\nUse this tool proactively in these scenarios:\n\nComplex multi-step tasks - When a task requires 3 or more distinct steps or actions\nNon-trivial and complex tasks - Tasks that require careful planning or multiple operations\nUser explicitly requests todo list - When the user directly asks you to use the todo list\nUser provides multiple tasks - When users provide a list of things to be done (numbered or comma-separated)\nAfter receiving new instructions - Immediately capture user requirements as todos\nWhen you start working on a task - Mark it as in_progress BEFORE beginning work. Ideally you should only have one todo as in_progress at a time\nAfter completing a task - Mark it as completed and add any new follow-up tasks discovered during implementation\nWhen NOT to Use This Tool\nSkip using this tool when:\n\nThere is only a single, straightforward task\nThe task is trivial and tracking it provides no organizational benefit\nThe task can be completed in less than 3 trivial steps\nThe task is purely conversational or informational\nNOTE that you should not use this tool if there is only one trivial task to do. In this case you are better off just doing the task directly.\n\nExamples of When to Use the Todo List\n<example>\nUser: I want to add a dark mode toggle to the application settings. Make sure you run the tests and build when you're done!\nAssistant: I'll help add a dark mode toggle to your application settings. Let me create a todo list to track this implementation.\n*Creates todo list with the following items:*\n1. Create dark mode toggle component in Settings page\n2. Add dark mode state management (context/store)\n3. Implement CSS-in-JS styles for dark theme\n4. Update existing components to support theme switching\n5. Run tests and build process, addressing any failures or errors that occur\n*Begins working on the first task*\n<reasoning>\nThe assistant used the todo list because:\n1. Adding dark mode is a multi-step feature requiring UI, state management, and styling changes\n2. The user explicitly requested tests and build be run afterward\n3. The assistant inferred that tests and build need to pass by adding \"Ensure tests and build succeed\" as the final task\n</reasoning>\n</example>\n<example>\nUser: Help me plan a comprehensive marketing campaign for our new product launch, including social media, email marketing, and press releases.\nAssistant: I'll help you plan a comprehensive marketing campaign for your product launch. Let me create a todo list to organize all the components.\n*Creates todo list with the following items:*\n1. Define target audience and key messaging\n2. Create social media content calendar and posting schedule\n3. Design email marketing sequence and automation flows\n4. Draft press release and identify media contacts\n5. Set up tracking and analytics for campaign performance\n6. Create visual assets and brand materials\n7. Coordinate launch timeline and deliverables\n*Begins working on the first task*\n<reasoning>\nThe assistant used the todo list because:\n1. Marketing campaign planning involves multiple distinct channels and activities\n2. Each component requires careful coordination and planning\n3. The systematic approach ensures all aspects of the launch are covered\n4. Progress tracking helps maintain timeline and deliverables\n</reasoning>\n</example>\n<example>\nUser: Help me rename the function getCwd to getCurrentWorkingDirectory across my project\nAssistant: Let me first search through your codebase to find all occurrences of 'getCwd'.\n*Uses search tools to locate all instances of getCwd in the codebase*\nAssistant: I've found 15 instances of 'getCwd' across 8 different files. Let me create a todo list to track these changes.\n*Creates todo list with specific items for each file that needs updating*\n<reasoning>\nThe assistant used the todo list because:\n1. First, the assistant searched to understand the scope of the task\n2. Upon finding multiple occurrences across different files, it determined this was a complex task with multiple steps\n3. The todo list helps ensure every instance is tracked and updated systematically\n4. This approach prevents missing any occurrences and maintains consistency\n</reasoning>\n</example>\n<example>\nUser: I need help organizing my home office: decluttering the desk, setting up a filing system, organizing digital files, and creating a daily workflow.\nAssistant: I'll help you organize your home office systematically. Let me create a todo list to track each area of organization.\n*Creates todo list with items like: 1) Sort and declutter desk items, 2) Set up physical filing system for documents, 3) Organize digital files and folders, 4) Create daily workflow and productivity systems, 5) Establish maintenance routines*\nLet's start with decluttering your desk space to create a clean foundation for the other organizational systems.\n<reasoning>\nThe assistant used the todo list because:\n1. The user provided multiple distinct organizational tasks\n2. Each area requires different approaches and careful planning\n3. Home organization benefits from systematic, step-by-step completion\n4. Progress tracking ensures all areas are addressed thoroughly\n</reasoning>\n</example>\nExamples of When NOT to Use the Todo List\n<example>\nUser: How do I print 'Hello World' in Python?\nAssistant: In Python, you can print \"Hello World\" with this simple code:\n\n```python\nprint(\"Hello World\")\n```\n\nThis will output the text \"Hello World\" to the console when executed.\n<reasoning>\nThe assistant did not use the todo list because this is a single, trivial task that can be completed in one step. There's no need to track multiple tasks or steps for such a straightforward request.\n</reasoning>\n</example>\n<example>\nUser: What's the best way to water houseplants?\nAssistant: The best way to water houseplants depends on the specific plant type, but here are some general guidelines:\n\nCheck soil moisture by inserting your finger about 1-2 inches into the soil\nWater thoroughly when the top inch feels dry, allowing water to drain from the bottom\nUse room temperature water and water in the morning when possible\nAvoid overwatering, which is more harmful than underwatering for most plants\n\nDifferent plants have different needs, so it's important to research your specific varieties for optimal care.\n\n<reasoning>\nThe assistant did not use the todo list because this is an informational request with no actual tasks to complete. The user is simply asking for advice and explanation, not for the assistant to perform multiple steps or activities.\n</reasoning>\n</example>\n<example>\nUser: Can you add a comment to the calculateTotal function to explain what it does?\nAssistant: Sure, let me add a comment to the calculateTotal function to explain what it does.\n* Uses the Edit tool to add a comment to the calculateTotal function *\n<reasoning>\nThe assistant did not use the todo list because this is a single, straightforward task confined to one location. Adding a comment doesn't require tracking multiple steps or systematic organization.\n</reasoning>\n</example>\n<example>\nUser: What time is it in Tokyo right now?\nAssistant: I'll check the current time in Tokyo for you.\n\n*Searches for current time in Tokyo*\n\nThe current time in Tokyo, Japan is [current time]. Tokyo is in the Japan Standard Time (JST) zone, which is UTC+9.\n\n<reasoning>\nThe assistant did not use the todo list because this is a single information lookup with immediate results. There are no multiple steps to track or organize, making the todo list unnecessary for this straightforward request.\n</reasoning>\n</example>\nTask States and Management\nTask States: Use these states to track progress:\n\npending: Task not yet started\nin_progress: Currently working on (limit to ONE task at a time)\ncompleted: Task finished successfully\nTask Management:\n\nUpdate task status in real-time as you work\nMark tasks complete IMMEDIATELY after finishing (don't batch completions)\nOnly have ONE task in_progress at any time\nComplete current tasks before starting new ones\nRemove tasks that are no longer relevant from the list entirely\nTask Completion Requirements:\n\nONLY mark a task as completed when you have FULLY accomplished it\nIf you encounter errors, blockers, or cannot finish, keep the task as in_progress\nWhen blocked, create a new task describing what needs to be resolved\nNever mark a task as completed if:\nThere are unresolved issues or errors\nWork is partial or incomplete\nYou encountered blockers that prevent completion\nYou couldn't find necessary resources or dependencies\nQuality standards haven't been met\nTask Breakdown:\n\nCreate specific, actionable items\nBreak complex tasks into smaller, manageable steps\nUse clear, descriptive task names\nWhen in doubt, use this tool. Being proactive with task management demonstrates attentiveness and ensures you complete all requirements successfully.";
12
- /**
13
- * Prefix for task tool description
14
- * Ported exactly from Python TASK_DESCRIPTION_PREFIX
15
- */
16
- export declare const TASK_DESCRIPTION_PREFIX = "Launch a new agent to handle complex, multi-step tasks autonomously.\n\nAvailable agent types and the tools they have access to:\n\ngeneral-purpose: 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. (Tools: *)\n{other_agents}\n";
17
- /**
18
- * Suffix for task tool description
19
- * Ported exactly from Python TASK_DESCRIPTION_SUFFIX
20
- */
21
- export declare const TASK_DESCRIPTION_SUFFIX = "When using the Task tool, you must specify a subagent_type parameter to select which agent type to use.\n\nWhen to use the Agent tool:\n\nWhen you are instructed to execute custom slash commands. Use the Agent tool with the slash command invocation as the entire prompt. The slash command can take arguments. For example: Task(description=\"Check the file\", prompt=\"/check-file path/to/file.py\")\nWhen NOT to use the Agent tool:\n\nIf you want to read a specific file path, use the Read or Glob tool instead of the Agent tool, to find the match more quickly\nIf you are searching for a specific term or definition within a known location, use the Glob tool instead, to find the match more quickly\nIf you are searching for content within a specific file or set of 2-3 files, use the Read tool instead of the Agent tool, to find the match more quickly\nOther tasks that are not related to the agent descriptions above\nUsage notes:\n\nLaunch multiple agents concurrently whenever possible, to maximize performance; to do that, use a single message with multiple tool uses\nWhen the agent is done, it will return a single message back to you. The result returned by the agent is not visible to the user. To show the user the result, you should send a text message back to the user with a concise summary of the result.\nEach agent invocation is stateless. You will not be able to send additional messages to the agent, nor will the agent be able to communicate with you outside of its final report. Therefore, your prompt should contain a highly detailed task description for the agent to perform autonomously and you should specify exactly what information the agent should return back to you in its final and only message to you.\nThe agent's outputs should generally be trusted\nClearly tell the agent whether you expect it to create content, perform analysis, or just do research (search, file reads, web fetches, etc.), since it is not aware of the user's intent\nIf the agent description mentions that it should be used proactively, then you should try your best to use it without the user having to ask for it first. Use your judgement.\nExample usage:\n\n<example_agent_descriptions>\n\"content-reviewer\": use this agent after you are done creating significant content or documents\n\"greeting-responder\": use this agent when to respond to user greetings with a friendly joke\n\"research-analyst\": use this agent to conduct thorough research on complex topics\n</example_agent_description>\n\n<example>\nuser: \"Please write a function that checks if a number is prime\"\nassistant: Sure let me write a function that checks if a number is prime\nassistant: First let me use the Write tool to write a function that checks if a number is prime\nassistant: I'm going to use the Write tool to write the following code:\n<code>\nfunction isPrime(n) {\n if (n <= 1) return false\n for (let i = 2; i * i <= n; i++) {\n if (n % i === 0) return false\n }\n return true\n}\n</code>\n<commentary>\nSince significant content was created and the task was completed, now use the content-reviewer agent to review the work\n</commentary>\nassistant: Now let me use the content-reviewer agent to review the code\nassistant: Uses the Task tool to launch with the content-reviewer agent\n</example>\n<example>\nuser: \"Can you help me research the environmental impact of different renewable energy sources and create a comprehensive report?\"\n<commentary>\nThis is a complex research task that would benefit from using the research-analyst agent to conduct thorough analysis\n</commentary>\nassistant: I'll help you research the environmental impact of renewable energy sources. Let me use the research-analyst agent to conduct comprehensive research on this topic.\nassistant: Uses the Task tool to launch with the research-analyst agent, providing detailed instructions about what research to conduct and what format the report should take\n</example>\n<example>\nuser: \"Hello\"\n<commentary>\nSince the user is greeting, use the greeting-responder agent to respond with a friendly joke\n</commentary>\nassistant: \"I'm going to use the Task tool to launch with the greeting-responder agent\"\n</example>";
22
- /**
23
- * Description for the edit_file tool
24
- * Ported exactly from Python EDIT_DESCRIPTION
25
- */
26
- export declare const EDIT_DESCRIPTION = "Performs exact string replacements in files.\nUsage:\n\nYou must use your Read tool at least once in the conversation before editing. This tool will error if you attempt an edit without reading the file.\nWhen editing text from Read tool output, ensure you preserve the exact indentation (tabs/spaces) as it appears AFTER the line number prefix. The line number prefix format is: spaces + line number + tab. Everything after that tab is the actual file content to match. Never include any part of the line number prefix in the old_string or new_string.\nALWAYS prefer editing existing files. NEVER write new files unless explicitly required.\nOnly use emojis if the user explicitly requests it. Avoid adding emojis to files unless asked.\nThe edit will FAIL if old_string is not unique in the file. Either provide a larger string with more surrounding context to make it unique or use replace_all to change every instance of old_string.\nUse replace_all for replacing and renaming strings across the file. This parameter is useful if you want to rename a variable for instance.";
27
- /**
28
- * Description for the read_file tool
29
- * Ported exactly from Python TOOL_DESCRIPTION
30
- */
31
- export declare const TOOL_DESCRIPTION = "Reads a file from the local filesystem. You can access any file directly by using this tool. Assume this tool is able to read all files on the machine. If the User provides a path to a file assume that path is valid. It is okay to read a file that does not exist; an error will be returned.\nUsage:\n\nThe file_path parameter must be an absolute path, not a relative path\nBy default, it reads up to 2000 lines starting from the beginning of the file\nYou can optionally specify a line offset and limit (especially handy for long files), but it's recommended to read the whole file by not providing these parameters\nAny lines longer than 2000 characters will be truncated\nResults are returned using cat -n format, with line numbers starting at 1\nYou have the capability to call multiple tools in a single response. It is always better to speculatively read multiple files as a batch that are potentially useful.\nIf you read a file that exists but has empty contents you will receive a system reminder warning in place of file contents.";