wave-agent-sdk 0.6.1 → 0.6.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.
Files changed (73) hide show
  1. package/dist/agent.d.ts +0 -5
  2. package/dist/agent.d.ts.map +1 -1
  3. package/dist/agent.js +3 -67
  4. package/dist/constants/subagents.d.ts +5 -0
  5. package/dist/constants/subagents.d.ts.map +1 -0
  6. package/dist/constants/subagents.js +4 -0
  7. package/dist/managers/aiManager.d.ts.map +1 -1
  8. package/dist/managers/aiManager.js +9 -25
  9. package/dist/managers/backgroundTaskManager.d.ts.map +1 -1
  10. package/dist/managers/backgroundTaskManager.js +4 -0
  11. package/dist/managers/messageManager.d.ts +0 -18
  12. package/dist/managers/messageManager.d.ts.map +1 -1
  13. package/dist/managers/messageManager.js +1 -36
  14. package/dist/managers/reversionManager.d.ts.map +1 -1
  15. package/dist/managers/reversionManager.js +23 -2
  16. package/dist/managers/slashCommandManager.js +1 -1
  17. package/dist/managers/subagentManager.d.ts +4 -14
  18. package/dist/managers/subagentManager.d.ts.map +1 -1
  19. package/dist/managers/subagentManager.js +35 -109
  20. package/dist/{constants/prompts.d.ts → prompts/index.d.ts} +4 -6
  21. package/dist/prompts/index.d.ts.map +1 -0
  22. package/dist/{constants/prompts.js → prompts/index.js} +124 -9
  23. package/dist/services/aiService.js +1 -1
  24. package/dist/services/taskManager.d.ts +5 -1
  25. package/dist/services/taskManager.d.ts.map +1 -1
  26. package/dist/services/taskManager.js +6 -0
  27. package/dist/tools/bashTool.d.ts.map +1 -1
  28. package/dist/tools/bashTool.js +6 -2
  29. package/dist/tools/exitPlanMode.js +1 -1
  30. package/dist/tools/taskManagementTools.d.ts.map +1 -1
  31. package/dist/tools/taskManagementTools.js +8 -0
  32. package/dist/tools/taskTool.d.ts.map +1 -1
  33. package/dist/tools/taskTool.js +32 -2
  34. package/dist/tools/types.d.ts +2 -0
  35. package/dist/tools/types.d.ts.map +1 -1
  36. package/dist/types/messaging.d.ts +1 -11
  37. package/dist/types/messaging.d.ts.map +1 -1
  38. package/dist/types/processes.d.ts +5 -0
  39. package/dist/types/processes.d.ts.map +1 -1
  40. package/dist/utils/builtinSubagents.d.ts.map +1 -1
  41. package/dist/utils/builtinSubagents.js +28 -50
  42. package/dist/utils/editUtils.d.ts.map +1 -1
  43. package/dist/utils/editUtils.js +2 -2
  44. package/dist/utils/gitUtils.d.ts +7 -0
  45. package/dist/utils/gitUtils.d.ts.map +1 -0
  46. package/dist/utils/gitUtils.js +24 -0
  47. package/dist/utils/messageOperations.d.ts +1 -23
  48. package/dist/utils/messageOperations.d.ts.map +1 -1
  49. package/dist/utils/messageOperations.js +0 -49
  50. package/package.json +1 -1
  51. package/src/agent.ts +3 -89
  52. package/src/constants/subagents.ts +4 -0
  53. package/src/managers/aiManager.ts +9 -25
  54. package/src/managers/backgroundTaskManager.ts +5 -0
  55. package/src/managers/messageManager.ts +0 -80
  56. package/src/managers/reversionManager.ts +26 -2
  57. package/src/managers/slashCommandManager.ts +1 -1
  58. package/src/managers/subagentManager.ts +42 -145
  59. package/src/{constants/prompts.ts → prompts/index.ts} +132 -12
  60. package/src/services/aiService.ts +1 -1
  61. package/src/services/taskManager.ts +8 -1
  62. package/src/tools/bashTool.ts +6 -2
  63. package/src/tools/exitPlanMode.ts +1 -1
  64. package/src/tools/taskManagementTools.ts +18 -0
  65. package/src/tools/taskTool.ts +39 -1
  66. package/src/tools/types.ts +2 -0
  67. package/src/types/messaging.ts +0 -12
  68. package/src/types/processes.ts +5 -0
  69. package/src/utils/builtinSubagents.ts +41 -51
  70. package/src/utils/editUtils.ts +2 -6
  71. package/src/utils/gitUtils.ts +24 -0
  72. package/src/utils/messageOperations.ts +1 -93
  73. package/dist/constants/prompts.d.ts.map +0 -1
@@ -1,3 +1,4 @@
1
+ import { EXPLORE_SUBAGENT_TYPE } from "../constants/subagents.js";
1
2
  import { TASK_TOOL_NAME } from "../constants/tools.js";
2
3
  /**
3
4
  * Create a task tool plugin that uses the provided SubagentManager
@@ -51,7 +52,7 @@ export function createTaskTool(subagentManager) {
51
52
  prompt: () => `
52
53
  - When doing file search, prefer to use the ${TASK_TOOL_NAME} tool in order to reduce context usage.
53
54
  - You should proactively use the ${TASK_TOOL_NAME} tool with specialized agents when the task at hand matches the agent's description.
54
- - VERY IMPORTANT: When exploring the codebase to gather context or to answer a question that is not a needle query for a specific file/class/function, it is CRITICAL that you use the ${TASK_TOOL_NAME} tool with subagent_type=Explore instead of running search commands directly.`,
55
+ - VERY IMPORTANT: When exploring the codebase to gather context or to answer a question that is not a needle query for a specific file/class/function, it is CRITICAL that you use the ${TASK_TOOL_NAME} tool with subagent_type=${EXPLORE_SUBAGENT_TYPE} instead of running search commands directly.`,
55
56
  execute: async (args, context) => {
56
57
  return new Promise((resolve) => {
57
58
  (async () => {
@@ -98,12 +99,39 @@ export function createTaskTool(subagentManager) {
98
99
  shortResult: "Subagent not found",
99
100
  });
100
101
  }
102
+ // Set up callback to update shortResult with tool names, tool count and tokens
103
+ const updateShortResult = () => {
104
+ const messages = instance.messageManager.getMessages();
105
+ const tokens = instance.messageManager.getlatestTotalTokens();
106
+ const lastTools = instance.lastTools;
107
+ // Count tool blocks in messages
108
+ let toolCount = 0;
109
+ messages.forEach((msg) => {
110
+ msg.blocks.forEach((block) => {
111
+ if (block.type === "tool") {
112
+ toolCount++;
113
+ }
114
+ });
115
+ });
116
+ let shortResult = "";
117
+ if (lastTools.length > 0) {
118
+ shortResult += `${lastTools.join(", ")} `;
119
+ }
120
+ shortResult += `(${toolCount} tools`;
121
+ if (tokens > 0) {
122
+ shortResult += ` | ${tokens.toLocaleString()} tokens`;
123
+ }
124
+ shortResult += ")";
125
+ context.onShortResultUpdate?.(shortResult);
126
+ };
101
127
  // Create subagent instance and execute task
102
128
  const instance = await subagentManager.createInstance(configuration, {
103
129
  description,
104
130
  prompt,
105
131
  subagent_type,
106
- }, run_in_background);
132
+ }, run_in_background, updateShortResult);
133
+ // Initial update
134
+ updateShortResult();
107
135
  let isBackgrounded = false;
108
136
  // Register for backgrounding if not already in background
109
137
  if (!run_in_background && context.foregroundTaskManager) {
@@ -133,6 +161,8 @@ export function createTaskTool(subagentManager) {
133
161
  shortResult: `Task started in background: ${result}`,
134
162
  });
135
163
  }
164
+ // Cleanup subagent instance after task completion
165
+ subagentManager.cleanupInstance(instance.subagentId);
136
166
  return resolve({
137
167
  success: true,
138
168
  content: result,
@@ -50,5 +50,7 @@ export interface ToolContext {
50
50
  taskManager: import("../services/taskManager.js").TaskManager;
51
51
  /** Current session ID */
52
52
  sessionId?: string;
53
+ /** Callback to update the short result of the current tool block */
54
+ onShortResultUpdate?: (shortResult: string) => void;
53
55
  }
54
56
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EACnB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,0BAA0B,CAAC;IACnC,OAAO,EAAE,CACP,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,WAAW,KACjB,OAAO,CAAC,UAAU,CAAC,CAAC;IACzB,mBAAmB,CAAC,EAAE,CACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,EAAE,WAAW,KACjB,MAAM,CAAC;IACZ;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,WAAW,CAAC,EAAE,MAAM,CA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CAAC,EAAE,OAAO,2BAA2B,EAAE,UAAU,CAAC;IAC5D,iDAAiD;IACjD,UAAU,CAAC,EAAE,OAAO,iBAAiB,EAAE,WAAW,CAAC;IACnD,oDAAoD;IACpD,gBAAgB,CAAC,EAAE,OAAO,iCAAiC,EAAE,gBAAgB,CAAC;IAC9E,mDAAmD;IACnD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sDAAsD;IACtD,qBAAqB,CAAC,EAAE,OAAO,uBAAuB,EAAE,sBAAsB,CAAC;IAC/E,gDAAgD;IAChD,WAAW,EAAE,OAAO,4BAA4B,EAAE,WAAW,CAAC;IAC9D,yBAAyB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oEAAoE;IACpE,mBAAmB,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;CACrD"}
@@ -3,7 +3,6 @@
3
3
  * Dependencies: Core (Usage)
4
4
  */
5
5
  import type { Usage } from "./core.js";
6
- import type { SubagentConfiguration } from "../utils/subagentParser.js";
7
6
  export declare enum MessageSource {
8
7
  USER = "user",
9
8
  HOOK = "hook"
@@ -15,7 +14,7 @@ export interface Message {
15
14
  usage?: Usage;
16
15
  additionalFields?: Record<string, unknown>;
17
16
  }
18
- export type MessageBlock = TextBlock | ErrorBlock | ToolBlock | ImageBlock | CommandOutputBlock | CompressBlock | SubagentBlock | ReasoningBlock | FileHistoryBlock;
17
+ export type MessageBlock = TextBlock | ErrorBlock | ToolBlock | ImageBlock | CommandOutputBlock | CompressBlock | ReasoningBlock | FileHistoryBlock;
19
18
  export interface TextBlock {
20
19
  type: "text";
21
20
  content: string;
@@ -67,15 +66,6 @@ export interface CompressBlock {
67
66
  content: string;
68
67
  sessionId: string;
69
68
  }
70
- export interface SubagentBlock {
71
- type: "subagent";
72
- subagentId: string;
73
- subagentName: string;
74
- status: "active" | "completed" | "error" | "aborted";
75
- sessionId: string;
76
- configuration: SubagentConfiguration;
77
- runInBackground?: boolean;
78
- }
79
69
  export interface ReasoningBlock {
80
70
  type: "reasoning";
81
71
  content: string;
@@ -1 +1 @@
1
- {"version":3,"file":"messaging.d.ts","sourceRoot":"","sources":["../../src/types/messaging.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAExE,oBAAY,aAAa;IACvB,IAAI,SAAS;IACb,IAAI,SAAS;CACd;AAED,MAAM,WAAW,OAAO;IACtB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC5C;AAED,MAAM,MAAM,YAAY,GACpB,SAAS,GACT,UAAU,GACV,SAAS,GACT,UAAU,GACV,kBAAkB,GAClB,aAAa,GACb,aAAa,GACb,cAAc,GACd,gBAAgB,CAAC;AAErB,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,KAAK,CAAC;QAEb,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC,CA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G;IACH,KAAK,EAAE,OAAO,GAAG,WAAW,GAAG,SAAS,GAAG,KAAK,CAAC;IACjD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,gBAAgB,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,cAAc,CAAC;IACrB,SAAS,EAAE,OAAO,gBAAgB,EAAE,YAAY,EAAE,CAAC;CACpD"}
@@ -22,6 +22,11 @@ export interface BackgroundTaskBase {
22
22
  * This allows tasks to define their own cleanup/abortion logic.
23
23
  */
24
24
  onStop?: () => void | Promise<void>;
25
+ /**
26
+ * Optional subagent ID associated with this task.
27
+ * Used for cleanup when the task is stopped.
28
+ */
29
+ subagentId?: string;
25
30
  }
26
31
  export interface BackgroundShell extends BackgroundTaskBase {
27
32
  type: "shell";
@@ -1 +1 @@
1
- {"version":3,"file":"processes.d.ts","sourceRoot":"","sources":["../../src/types/processes.ts"],"names":[],"mappings":"AAAA;;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AM,GAAG,IAAI,CAAC;CAC5C"}
@@ -1 +1 @@
1
- {"version":3,"file":"builtinSubagents.d.ts","sourceRoot":"","sources":["../../src/utils/builtinSubagents.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAEjE;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,qBAAqB,EAAE,CAQ7D"}
1
+ {"version":3,"file":"builtinSubagents.d.ts","sourceRoot":"","sources":["../../src/utils/builtinSubagents.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAEjE;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,qBAAqB,EAAE,CAQ7D"}
@@ -1,5 +1,6 @@
1
- import { BASH_SUBAGENT_SYSTEM_PROMPT, GENERAL_PURPOSE_SYSTEM_PROMPT, PLAN_SUBAGENT_SYSTEM_PROMPT, } from "../constants/prompts.js";
2
- import { BASH_TOOL_NAME } from "../constants/tools.js";
1
+ import { BASH_SUBAGENT_TYPE, EXPLORE_SUBAGENT_TYPE, PLAN_SUBAGENT_TYPE, GENERAL_PURPOSE_SUBAGENT_TYPE, } from "../constants/subagents.js";
2
+ import { BASH_SUBAGENT_SYSTEM_PROMPT, GENERAL_PURPOSE_SYSTEM_PROMPT, PLAN_SUBAGENT_SYSTEM_PROMPT, EXPLORE_SUBAGENT_SYSTEM_PROMPT, } from "../prompts/index.js";
3
+ import { BASH_TOOL_NAME, GLOB_TOOL_NAME, GREP_TOOL_NAME, READ_TOOL_NAME, LS_TOOL_NAME, LSP_TOOL_NAME, } from "../constants/tools.js";
3
4
  /**
4
5
  * Get all built-in subagent configurations
5
6
  * Built-in subagents have priority 3 (lowest) and can be overridden by user/project configs
@@ -19,12 +20,12 @@ export function getBuiltinSubagents() {
19
20
  */
20
21
  function createBashSubagent() {
21
22
  return {
22
- name: "Bash",
23
+ name: BASH_SUBAGENT_TYPE,
23
24
  description: "Command execution specialist for running bash commands. Use this for git operations, command execution, and other terminal tasks.",
24
25
  systemPrompt: BASH_SUBAGENT_SYSTEM_PROMPT,
25
26
  tools: [BASH_TOOL_NAME],
26
27
  model: "inherit",
27
- filePath: "<builtin:Bash>",
28
+ filePath: `<builtin:${BASH_SUBAGENT_TYPE}>`,
28
29
  scope: "builtin",
29
30
  priority: 3,
30
31
  };
@@ -35,10 +36,10 @@ function createBashSubagent() {
35
36
  */
36
37
  function createGeneralPurposeSubagent() {
37
38
  return {
38
- name: "general-purpose",
39
+ name: GENERAL_PURPOSE_SUBAGENT_TYPE,
39
40
  description: "General-purpose agent for researching complex questions, searching for code, 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.",
40
41
  systemPrompt: GENERAL_PURPOSE_SYSTEM_PROMPT,
41
- filePath: "<builtin:general-purpose>",
42
+ filePath: `<builtin:${GENERAL_PURPOSE_SUBAGENT_TYPE}>`,
42
43
  scope: "builtin",
43
44
  priority: 3,
44
45
  };
@@ -48,52 +49,22 @@ function createGeneralPurposeSubagent() {
48
49
  * Specialized for codebase exploration and file search tasks
49
50
  */
50
51
  function createExploreSubagent() {
51
- const systemPrompt = `You are a file search specialist. You excel at thoroughly navigating and exploring codebases.
52
-
53
- === CRITICAL: READ-ONLY MODE - NO FILE MODIFICATIONS ===
54
- This is a READ-ONLY exploration task. You are STRICTLY PROHIBITED from:
55
- - Creating new files (no Write, touch, or file creation of any kind)
56
- - Modifying existing files (no Edit operations)
57
- - Deleting files (no rm or deletion)
58
- - Moving or copying files (no mv or cp)
59
- - Creating temporary files anywhere, including /tmp
60
- - Using redirect operators (>, >>, |) or heredocs to write to files
61
- - Running ANY commands that change system state
62
-
63
- Your role is EXCLUSIVELY to search and analyze existing code. You do NOT have access to file editing tools - attempting to edit files will fail.
64
-
65
- Your strengths:
66
- - Rapidly finding files using glob patterns
67
- - Searching code and text with powerful regex patterns
68
- - Reading and analyzing file contents
69
- - Using Language Server Protocol (LSP) for deep code intelligence (definitions, references, etc.)
70
-
71
- Guidelines:
72
- - Use Glob for broad file pattern matching
73
- - Use Grep for searching file contents with regex
74
- - Use Read when you know the specific file path you need to read
75
- - Use LSP for code intelligence features like finding definitions, references, implementations, and symbols. This is especially useful for understanding complex code relationships.
76
- - Use Bash ONLY for read-only operations (ls, git status, git log, git diff, find, cat, head, tail)
77
- - NEVER use Bash for: mkdir, touch, rm, cp, mv, git add, git commit, npm install, pip install, or any file creation/modification
78
- - Adapt your search approach based on the thoroughness level specified by the caller
79
- - Return file paths as absolute paths in your final response
80
- - For clear communication, avoid using emojis
81
- - Communicate your final report directly as a regular message - do NOT attempt to create files
82
-
83
- NOTE: You are meant to be a fast agent that returns output as quickly as possible. In order to achieve this you must:
84
- - Make efficient use of the tools that you have at your disposal: be smart about how you search for files and implementations
85
- - Wherever possible you should try to spawn multiple parallel tool calls for grepping and reading files
86
-
87
- Complete the user's search request efficiently and report your findings clearly.`;
88
52
  // Define allowed tools for read-only operations
89
- const allowedTools = ["Glob", "Grep", "Read", "Bash", "LS", "LSP"];
53
+ const allowedTools = [
54
+ GLOB_TOOL_NAME,
55
+ GREP_TOOL_NAME,
56
+ READ_TOOL_NAME,
57
+ BASH_TOOL_NAME,
58
+ LS_TOOL_NAME,
59
+ LSP_TOOL_NAME,
60
+ ];
90
61
  return {
91
- name: "Explore",
62
+ name: EXPLORE_SUBAGENT_TYPE,
92
63
  description: 'Fast agent specialized for exploring codebases. Use this when you need to quickly find files by patterns (eg. "src/components/**/*.tsx"), search code for keywords (eg. "API endpoints"), or answer questions about the codebase (eg. "how do API endpoints work?"). When calling this agent, specify the desired thoroughness level: "quick" for basic searches, "medium" for moderate exploration, or "very thorough" for comprehensive analysis across multiple locations and naming conventions.',
93
- systemPrompt,
64
+ systemPrompt: EXPLORE_SUBAGENT_SYSTEM_PROMPT,
94
65
  tools: allowedTools,
95
66
  model: "fastModel", // Special value that will use parent's fastModel
96
- filePath: "<builtin:Explore>",
67
+ filePath: `<builtin:${EXPLORE_SUBAGENT_TYPE}>`,
97
68
  scope: "builtin",
98
69
  priority: 3, // Lowest priority - can be overridden by user configs
99
70
  };
@@ -104,14 +75,21 @@ Complete the user's search request efficiently and report your findings clearly.
104
75
  */
105
76
  function createPlanSubagent() {
106
77
  // Define allowed tools for read-only operations
107
- const allowedTools = ["Glob", "Grep", "Read", "Bash", "LS", "LSP"];
78
+ const allowedTools = [
79
+ GLOB_TOOL_NAME,
80
+ GREP_TOOL_NAME,
81
+ READ_TOOL_NAME,
82
+ BASH_TOOL_NAME,
83
+ LS_TOOL_NAME,
84
+ LSP_TOOL_NAME,
85
+ ];
108
86
  return {
109
- name: "Plan",
87
+ name: PLAN_SUBAGENT_TYPE,
110
88
  description: "Software architect agent for designing implementation plans. Use this when you need to plan the implementation strategy for a task. Returns step-by-step plans, identifies critical files, and considers architectural trade-offs.",
111
89
  systemPrompt: PLAN_SUBAGENT_SYSTEM_PROMPT,
112
90
  tools: allowedTools,
113
91
  model: "inherit", // Uses parent agent's model
114
- filePath: "<builtin:Plan>",
92
+ filePath: `<builtin:${PLAN_SUBAGENT_TYPE}>`,
115
93
  scope: "builtin",
116
94
  priority: 3, // Lowest priority - can be overridden by user configs
117
95
  };
@@ -1 +1 @@
1
- {"version":3,"file":"editUtils.d.ts","sourceRoot":"","sources":["../../src/utils/editUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,GACnB,MAAM,CAwER"}
1
+ {"version":3,"file":"editUtils.d.ts","sourceRoot":"","sources":["../../src/utils/editUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,GACnB,MAAM,CAoER"}
@@ -60,8 +60,8 @@ export function analyzeEditMismatch(content, searchString) {
60
60
  reportLines.push(`${lineNum.toString().padStart(4)} | ${actualLine}`);
61
61
  }
62
62
  else {
63
- reportLines.push(`${lineNum.toString().padStart(4)} | - ${expectedLine} (expected)`);
64
- reportLines.push(`${lineNum.toString().padStart(4)} | + ${actualLine} (actual)`);
63
+ reportLines.push(`${lineNum.toString().padStart(4)} | - ${expectedLine}`);
64
+ reportLines.push(`${lineNum.toString().padStart(4)} | + ${actualLine}`);
65
65
  }
66
66
  }
67
67
  return reportLines.join("\n");
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Check if a directory is a git repository
3
+ * @param dirPath Directory path
4
+ * @returns "Yes" if it's a git repository, "No" otherwise
5
+ */
6
+ export declare function isGitRepository(dirPath: string): string;
7
+ //# sourceMappingURL=gitUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gitUtils.d.ts","sourceRoot":"","sources":["../../src/utils/gitUtils.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAevD"}
@@ -0,0 +1,24 @@
1
+ import * as path from "node:path";
2
+ import * as fsSync from "node:fs";
3
+ /**
4
+ * Check if a directory is a git repository
5
+ * @param dirPath Directory path
6
+ * @returns "Yes" if it's a git repository, "No" otherwise
7
+ */
8
+ export function isGitRepository(dirPath) {
9
+ try {
10
+ // Check if .git directory exists in current directory or any parent directory
11
+ let currentPath = path.resolve(dirPath);
12
+ while (currentPath !== path.dirname(currentPath)) {
13
+ const gitPath = path.join(currentPath, ".git");
14
+ if (fsSync.existsSync(gitPath)) {
15
+ return "Yes";
16
+ }
17
+ currentPath = path.dirname(currentPath);
18
+ }
19
+ return "No";
20
+ }
21
+ catch {
22
+ return "No";
23
+ }
24
+ }
@@ -1,6 +1,5 @@
1
1
  import type { Message, Usage } from "../types/index.js";
2
2
  import { MessageSource } from "../types/index.js";
3
- import type { SubagentConfiguration } from "./subagentParser.js";
4
3
  import { ChatCompletionMessageFunctionToolCall } from "openai/resources.js";
5
4
  export interface UserMessageParams {
6
5
  content: string;
@@ -17,7 +16,7 @@ export interface AddUserMessageParams extends UserMessageParams {
17
16
  export interface UpdateToolBlockParams {
18
17
  messages: Message[];
19
18
  id: string;
20
- parameters: string;
19
+ parameters?: string;
21
20
  result?: string;
22
21
  success?: boolean;
23
22
  error?: string;
@@ -71,27 +70,6 @@ export declare const addErrorBlockToMessage: ({ messages, error, }: AddErrorBloc
71
70
  export declare const addCommandOutputMessage: ({ messages, command, }: AddCommandOutputParams) => Message[];
72
71
  export declare const updateCommandOutputInMessage: ({ messages, command, output, }: UpdateCommandOutputParams) => Message[];
73
72
  export declare const completeCommandInMessage: ({ messages, command, exitCode, }: CompleteCommandParams) => Message[];
74
- export interface AddSubagentBlockParams {
75
- messages: Message[];
76
- subagentId: string;
77
- subagentName: string;
78
- status: "active" | "completed" | "error" | "aborted";
79
- sessionId: string;
80
- configuration: SubagentConfiguration;
81
- runInBackground?: boolean;
82
- }
83
- export interface UpdateSubagentBlockParams {
84
- messages: Message[];
85
- subagentId: string;
86
- status: "active" | "completed" | "error" | "aborted";
87
- sessionId?: string;
88
- }
89
- export declare const addSubagentBlockToMessage: ({ messages, subagentId, subagentName, status, sessionId, configuration, runInBackground, }: AddSubagentBlockParams) => Message[];
90
- export declare const updateSubagentBlockInMessage: (messages: Message[], subagentId: string, updates: Partial<{
91
- status: "active" | "completed" | "error" | "aborted";
92
- sessionId: string;
93
- runInBackground: boolean;
94
- }>) => Message[];
95
73
  /**
96
74
  * Removes the last user message from the messages array
97
75
  * Used for hook error handling when the user prompt needs to be erased
@@ -1 +1 @@
1
- {"version":3,"file":"messageOperations.d.ts","sourceRoot":"","sources":["../../src/utils/messageOperations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,E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M,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAI,WAAW,MAAM,KAAG,MAmCxD,CAAC;AAGF,eAAO,MAAM,wBAAwB,GAAI,8DAMtC,oBAAoB,KAAG,OAAO,EA2BhC,CAAC;AAGF,eAAO,MAAM,6BAA6B,GACxC,UAAU,OAAO,EAAE,EACnB,UAAU,MAAM,EAChB,YAAY,qCAAqC,EAAE,EACnD,QAAQ,KAAK,EACb,mBAAmB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KACzC,OAAO,EA+BT,CAAC;AAGF,eAAO,MAAM,wBAAwB,GAAI,iJActC,qBAAqB,KAAG,OAAO,EAiDjC,CAAC;AAGF,eAAO,MAAM,sBAAsB,GAAI,sBAGpC,mBAAmB,KAAG,OAAO,EA+B/B,CAAC;AAGF,eAAO,MAAM,uBAAuB,GAAI,wBAGrC,sBAAsB,KAAG,OAAO,EAelC,CAAC;AAGF,eAAO,MAAM,4BAA4B,GAAI,gCAI1C,yBAAyB,KAAG,OAAO,EAmBrC,CAAC;AAGF,eAAO,MAAM,wBAAwB,GAAI,kCAItC,qBAAqB,KAAG,OAAO,EAoBjC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAAI,UAAU,OAAO,EAAE,KAAG,OAAO,EAalE,CAAC"}
@@ -235,55 +235,6 @@ export const completeCommandInMessage = ({ messages, command, exitCode, }) => {
235
235
  }
236
236
  return newMessages;
237
237
  };
238
- export const addSubagentBlockToMessage = ({ messages, subagentId, subagentName, status, sessionId, configuration, runInBackground, }) => {
239
- const newMessages = [...messages];
240
- // Find the last assistant message or create one
241
- let lastAssistantMessage = newMessages[newMessages.length - 1];
242
- if (!lastAssistantMessage || lastAssistantMessage.role !== "assistant") {
243
- // Create new assistant message if the last message is not from assistant
244
- lastAssistantMessage = {
245
- id: `msg-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`,
246
- role: "assistant",
247
- blocks: [],
248
- };
249
- newMessages.push(lastAssistantMessage);
250
- }
251
- // Add subagent block
252
- lastAssistantMessage.blocks.push({
253
- type: "subagent",
254
- subagentId,
255
- subagentName,
256
- status,
257
- sessionId,
258
- configuration,
259
- runInBackground,
260
- });
261
- return newMessages;
262
- };
263
- export const updateSubagentBlockInMessage = (messages, subagentId, updates) => {
264
- const newMessages = [...messages];
265
- // Find and update the subagent block
266
- for (let i = newMessages.length - 1; i >= 0; i--) {
267
- const message = newMessages[i];
268
- if (message.role === "assistant") {
269
- for (const block of message.blocks) {
270
- if (block.type === "subagent" && block.subagentId === subagentId) {
271
- if (updates.status !== undefined) {
272
- block.status = updates.status;
273
- }
274
- if (updates.sessionId !== undefined) {
275
- block.sessionId = updates.sessionId;
276
- }
277
- if (updates.runInBackground !== undefined) {
278
- block.runInBackground = updates.runInBackground;
279
- }
280
- return newMessages;
281
- }
282
- }
283
- }
284
- }
285
- return newMessages;
286
- };
287
238
  /**
288
239
  * Removes the last user message from the messages array
289
240
  * Used for hook error handling when the user prompt needs to be erased
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wave-agent-sdk",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "SDK for building AI-powered development tools and agents",
5
5
  "keywords": [
6
6
  "ai",
package/src/agent.ts CHANGED
@@ -50,7 +50,6 @@ import {
50
50
  loadSessionFromJsonl,
51
51
  handleSessionRestoration,
52
52
  } from "./services/session.js";
53
- import type { SubagentConfiguration } from "./utils/subagentParser.js";
54
53
  import { setGlobalLogger } from "./utils/globalLogger.js";
55
54
  import { ConfigurationService } from "./services/configurationService.js";
56
55
  import * as fs from "fs/promises";
@@ -232,9 +231,6 @@ export class Agent {
232
231
  );
233
232
  callbacks.onSessionIdChange?.(sessionId);
234
233
  },
235
- onSubagentTaskStopRequested: (subagentId) => {
236
- this.backgroundTaskManager.stopTask(subagentId);
237
- },
238
234
  },
239
235
  workdir: this.workdir,
240
236
  logger: this.logger,
@@ -362,7 +358,6 @@ export class Agent {
362
358
  this.subagentManager = new SubagentManager({
363
359
  workdir: this.workdir,
364
360
  parentToolManager: this.toolManager,
365
- parentMessageManager: this.messageManager,
366
361
  callbacks: {
367
362
  onSubagentUserMessageAdded: callbacks.onSubagentUserMessageAdded,
368
363
  onSubagentAssistantMessageAdded:
@@ -812,9 +807,6 @@ export class Agent {
812
807
  // Rebuild usage array from restored messages
813
808
  this.rebuildUsageFromMessages(sessionToRestore?.messages || []);
814
809
 
815
- // After main session is restored, restore any associated subagent sessions
816
- await this.restoreSubagentSessions(sessionToRestore?.messages || []);
817
-
818
810
  if (sessionToRestore) {
819
811
  this.messageManager.initializeFromSession(sessionToRestore);
820
812
 
@@ -830,85 +822,6 @@ export class Agent {
830
822
  }
831
823
  }
832
824
 
833
- /**
834
- * Restore subagent sessions associated with the current main session
835
- * This method is called after the main session is restored to load any subagent sessions
836
- */
837
- private async restoreSubagentSessions(messages: Message[]): Promise<void> {
838
- try {
839
- // Only attempt to restore subagent sessions if we have messages (session was restored)
840
- if (messages.length === 0) {
841
- return;
842
- }
843
-
844
- // Extract sessionId -> subagentId mapping from SubagentBlocks
845
- const subagentBlockMap = new Map<
846
- string,
847
- { subagentId: string; configuration: SubagentConfiguration }
848
- >(); // sessionId -> { subagentId, configuration }
849
-
850
- for (const message of messages) {
851
- if (message.role === "assistant" && message.blocks) {
852
- for (const block of message.blocks) {
853
- if (
854
- block.type === "subagent" &&
855
- block.sessionId &&
856
- block.subagentId &&
857
- block.configuration
858
- ) {
859
- subagentBlockMap.set(block.sessionId, {
860
- subagentId: block.subagentId,
861
- configuration: block.configuration,
862
- });
863
- }
864
- }
865
- }
866
- }
867
-
868
- if (subagentBlockMap.size === 0) {
869
- return; // No subagent blocks found
870
- }
871
-
872
- // Load subagent sessions using sessionIds
873
- const subagentSessions = [];
874
- for (const [sessionId, blockData] of subagentBlockMap) {
875
- try {
876
- const sessionData = await loadSessionFromJsonl(
877
- sessionId,
878
- this.messageManager.getWorkdir(),
879
- "subagent",
880
- );
881
- if (sessionData) {
882
- subagentSessions.push({
883
- sessionData,
884
- subagentId: blockData.subagentId, // Use the subagentId from SubagentBlock
885
- configuration: blockData.configuration, // Include configuration
886
- });
887
- }
888
- } catch (error) {
889
- this.logger?.warn(
890
- `Failed to load subagent session ${sessionId}:`,
891
- error,
892
- );
893
- }
894
- }
895
-
896
- if (subagentSessions.length > 0) {
897
- this.logger?.debug(
898
- `Found ${subagentSessions.length} subagent sessions to restore`,
899
- );
900
-
901
- // Restore subagent sessions through the SubagentManager
902
- await this.subagentManager.restoreSubagentSessions(subagentSessions);
903
-
904
- this.logger?.debug("Subagent sessions restored successfully");
905
- }
906
- } catch (error) {
907
- this.logger?.warn("Failed to restore subagent sessions:", error);
908
- // Don't throw error to prevent app startup failure
909
- }
910
- }
911
-
912
825
  /**
913
826
  * Restore a session by ID, switching to the target session without destroying the Agent instance
914
827
  * @param sessionId - The ID of the session to restore
@@ -943,9 +856,8 @@ export class Agent {
943
856
  this.abortMessage(); // Abort any running operations
944
857
  this.subagentManager.cleanup(); // Clean up active subagents
945
858
 
946
- // 5. Rebuild usage and restore subagents (in correct order)
859
+ // 5. Rebuild usage (in correct order)
947
860
  this.rebuildUsageFromMessages(sessionData.messages);
948
- await this.restoreSubagentSessions(sessionData.messages);
949
861
 
950
862
  // 6. Initialize session state last
951
863
  this.messageManager.initializeFromSession(sessionData);
@@ -1240,6 +1152,8 @@ export class Agent {
1240
1152
  */
1241
1153
  public async truncateHistory(index: number): Promise<void> {
1242
1154
  await this.messageManager.truncateHistory(index, this.reversionManager);
1155
+ // After truncating history, the task list might have changed, so refresh it.
1156
+ await this.taskManager.refreshTasks();
1243
1157
  }
1244
1158
 
1245
1159
  /**
@@ -0,0 +1,4 @@
1
+ export const BASH_SUBAGENT_TYPE = "Bash";
2
+ export const EXPLORE_SUBAGENT_TYPE = "Explore";
3
+ export const PLAN_SUBAGENT_TYPE = "Plan";
4
+ export const GENERAL_PURPOSE_SUBAGENT_TYPE = "general-purpose";