wave-agent-sdk 1.0.4 → 1.0.6

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 (194) hide show
  1. package/dist/agent.d.ts +23 -1
  2. package/dist/agent.js +34 -4
  3. package/dist/managers/aiManager.d.ts +36 -0
  4. package/dist/managers/aiManager.js +240 -8
  5. package/dist/managers/messageManager.d.ts +1 -3
  6. package/dist/managers/messageManager.js +19 -9
  7. package/dist/managers/slashCommandManager.js +28 -0
  8. package/dist/managers/subagentManager.d.ts +0 -2
  9. package/dist/services/session.js +2 -9
  10. package/dist/telemetry/instrumentation.d.ts +1 -1
  11. package/dist/telemetry/instrumentation.js +57 -28
  12. package/dist/tools/bashTool.js +16 -6
  13. package/dist/tools/grepTool.js +11 -3
  14. package/dist/types/index.d.ts +3 -0
  15. package/dist/types/messaging.d.ts +2 -0
  16. package/dist/utils/containerSetup.js +0 -3
  17. package/dist/utils/messageOperations.d.ts +10 -1
  18. package/dist/utils/messageOperations.js +19 -1
  19. package/dist/utils/notificationXml.js +5 -0
  20. package/dist/utils/ripgrep.d.ts +4 -4
  21. package/dist/utils/ripgrep.js +4 -27
  22. package/package.json +20 -8
  23. package/bin/rg +0 -79
  24. package/dist/managers/forkedAgentManager.d.ts +0 -50
  25. package/dist/managers/forkedAgentManager.js +0 -130
  26. package/scripts/install_ripgrep.js +0 -111
  27. package/scripts/postinstall.js +0 -38
  28. package/src/agent.ts +0 -1271
  29. package/src/constants/subagents.ts +0 -4
  30. package/src/constants/toolLimits.ts +0 -15
  31. package/src/constants/tools.ts +0 -24
  32. package/src/core/plugin.ts +0 -237
  33. package/src/core/session.ts +0 -9
  34. package/src/index.ts +0 -38
  35. package/src/managers/MemoryRuleManager.ts +0 -198
  36. package/src/managers/aiManager.ts +0 -2429
  37. package/src/managers/backgroundTaskManager.ts +0 -480
  38. package/src/managers/bangManager.ts +0 -119
  39. package/src/managers/cronManager.ts +0 -401
  40. package/src/managers/foregroundTaskManager.ts +0 -30
  41. package/src/managers/forkedAgentManager.ts +0 -216
  42. package/src/managers/hookManager.ts +0 -1089
  43. package/src/managers/liveConfigManager.ts +0 -445
  44. package/src/managers/lspManager.ts +0 -470
  45. package/src/managers/mcpManager.ts +0 -1010
  46. package/src/managers/messageManager.ts +0 -1180
  47. package/src/managers/messageQueue.ts +0 -157
  48. package/src/managers/permissionManager.ts +0 -1140
  49. package/src/managers/planManager.ts +0 -112
  50. package/src/managers/pluginManager.ts +0 -330
  51. package/src/managers/pluginScopeManager.ts +0 -124
  52. package/src/managers/reversionManager.ts +0 -178
  53. package/src/managers/skillManager.ts +0 -578
  54. package/src/managers/slashCommandManager.ts +0 -564
  55. package/src/managers/subagentManager.ts +0 -915
  56. package/src/managers/toolManager.ts +0 -489
  57. package/src/managers/workflowManager.ts +0 -493
  58. package/src/prompts/autoMemory.ts +0 -33
  59. package/src/prompts/autoMemoryExtraction.ts +0 -146
  60. package/src/prompts/index.ts +0 -506
  61. package/src/prompts/planModeReminders.ts +0 -126
  62. package/src/services/GitService.ts +0 -131
  63. package/src/services/MarketplaceService.ts +0 -1052
  64. package/src/services/MemoryRuleService.ts +0 -71
  65. package/src/services/aiService.ts +0 -919
  66. package/src/services/authService.ts +0 -565
  67. package/src/services/autoMemoryService.ts +0 -280
  68. package/src/services/configurationService.ts +0 -1520
  69. package/src/services/fileWatcher.ts +0 -319
  70. package/src/services/hook.ts +0 -348
  71. package/src/services/initializationService.ts +0 -357
  72. package/src/services/interactionService.ts +0 -229
  73. package/src/services/jsonlHandler.ts +0 -295
  74. package/src/services/memory.ts +0 -234
  75. package/src/services/pluginLoader.ts +0 -252
  76. package/src/services/remoteSettingsService.ts +0 -366
  77. package/src/services/reversionService.ts +0 -122
  78. package/src/services/session.ts +0 -922
  79. package/src/services/taskManager.ts +0 -321
  80. package/src/telemetry/events.ts +0 -65
  81. package/src/telemetry/instrumentation.ts +0 -499
  82. package/src/telemetry/sessionTracing.ts +0 -348
  83. package/src/tools/agentTool.ts +0 -322
  84. package/src/tools/askUserQuestion.ts +0 -160
  85. package/src/tools/bashTool.ts +0 -621
  86. package/src/tools/buildTool.ts +0 -61
  87. package/src/tools/cronCreateTool.ts +0 -161
  88. package/src/tools/cronDeleteTool.ts +0 -51
  89. package/src/tools/cronListTool.ts +0 -47
  90. package/src/tools/editTool.ts +0 -313
  91. package/src/tools/enterPlanMode.ts +0 -124
  92. package/src/tools/enterWorktreeTool.ts +0 -190
  93. package/src/tools/exitPlanMode.ts +0 -139
  94. package/src/tools/exitWorktreeTool.ts +0 -236
  95. package/src/tools/globTool.ts +0 -167
  96. package/src/tools/grepTool.ts +0 -399
  97. package/src/tools/lspTool.ts +0 -883
  98. package/src/tools/readTool.ts +0 -426
  99. package/src/tools/skillTool.ts +0 -248
  100. package/src/tools/taskManagementTools.ts +0 -574
  101. package/src/tools/taskStopTool.ts +0 -78
  102. package/src/tools/types.ts +0 -137
  103. package/src/tools/webFetchTool.ts +0 -373
  104. package/src/tools/workflowTool.ts +0 -205
  105. package/src/tools/writeTool.ts +0 -267
  106. package/src/types/agent.ts +0 -128
  107. package/src/types/auth.ts +0 -19
  108. package/src/types/commands.ts +0 -30
  109. package/src/types/config.ts +0 -43
  110. package/src/types/configuration.ts +0 -168
  111. package/src/types/core.ts +0 -105
  112. package/src/types/cron.ts +0 -13
  113. package/src/types/environment.ts +0 -106
  114. package/src/types/fileSearch.ts +0 -4
  115. package/src/types/history.ts +0 -7
  116. package/src/types/hooks.ts +0 -256
  117. package/src/types/index.ts +0 -41
  118. package/src/types/lsp.ts +0 -98
  119. package/src/types/marketplace.ts +0 -71
  120. package/src/types/mcp.ts +0 -43
  121. package/src/types/memoryRule.ts +0 -31
  122. package/src/types/messaging.ts +0 -114
  123. package/src/types/permissions.ts +0 -80
  124. package/src/types/plugins.ts +0 -39
  125. package/src/types/processes.ts +0 -99
  126. package/src/types/reversion.ts +0 -29
  127. package/src/types/session.ts +0 -12
  128. package/src/types/skills.ts +0 -108
  129. package/src/types/tasks.ts +0 -13
  130. package/src/types/telemetry.ts +0 -98
  131. package/src/types/tools.ts +0 -44
  132. package/src/types/workflow.ts +0 -6
  133. package/src/utils/abortUtils.ts +0 -118
  134. package/src/utils/atomicWrite.ts +0 -61
  135. package/src/utils/bashParser.ts +0 -899
  136. package/src/utils/cacheControlUtils.ts +0 -426
  137. package/src/utils/commandArgumentParser.ts +0 -161
  138. package/src/utils/commandPathResolver.ts +0 -88
  139. package/src/utils/configPaths.ts +0 -220
  140. package/src/utils/configValidator.ts +0 -100
  141. package/src/utils/constants.ts +0 -39
  142. package/src/utils/container.ts +0 -92
  143. package/src/utils/containerSetup.ts +0 -371
  144. package/src/utils/convertMessagesForAPI.ts +0 -326
  145. package/src/utils/cronTasks.ts +0 -128
  146. package/src/utils/cronTasksLock.ts +0 -182
  147. package/src/utils/cronToHuman.ts +0 -99
  148. package/src/utils/customCommands.ts +0 -95
  149. package/src/utils/editUtils.ts +0 -20
  150. package/src/utils/fileFormat.ts +0 -40
  151. package/src/utils/fileSearch.ts +0 -151
  152. package/src/utils/fileUtils.ts +0 -223
  153. package/src/utils/gitUtils.ts +0 -315
  154. package/src/utils/globalLogger.ts +0 -128
  155. package/src/utils/groupMessagesByApiRound.ts +0 -121
  156. package/src/utils/hookMatcher.ts +0 -176
  157. package/src/utils/markdownParser.ts +0 -317
  158. package/src/utils/mcpUtils.ts +0 -138
  159. package/src/utils/messageOperations.ts +0 -641
  160. package/src/utils/modelCapabilities.ts +0 -30
  161. package/src/utils/nameGenerator.ts +0 -99
  162. package/src/utils/notificationXml.ts +0 -57
  163. package/src/utils/openaiClient.ts +0 -251
  164. package/src/utils/parseCronExpression.ts +0 -78
  165. package/src/utils/path.ts +0 -72
  166. package/src/utils/pathEncoder.ts +0 -400
  167. package/src/utils/pathSafety.ts +0 -40
  168. package/src/utils/promptHistory.ts +0 -168
  169. package/src/utils/ripgrep.ts +0 -35
  170. package/src/utils/shellResolver.ts +0 -190
  171. package/src/utils/skillParser.ts +0 -246
  172. package/src/utils/stringUtils.ts +0 -156
  173. package/src/utils/subagentParser.ts +0 -279
  174. package/src/utils/taskReminder.ts +0 -96
  175. package/src/utils/tokenCalculation.ts +0 -43
  176. package/src/utils/tokenEstimate.ts +0 -34
  177. package/src/utils/toolResultStorage.ts +0 -117
  178. package/src/utils/worktreeSession.ts +0 -26
  179. package/src/utils/worktreeUtils.ts +0 -786
  180. package/src/workflow/budgetTracker.ts +0 -34
  181. package/src/workflow/concurrencyLimiter.ts +0 -47
  182. package/src/workflow/journal.ts +0 -95
  183. package/src/workflow/progressReporter.ts +0 -141
  184. package/src/workflow/runState.ts +0 -65
  185. package/src/workflow/scriptRuntime.ts +0 -274
  186. package/src/workflow/structuredOutput.ts +0 -123
  187. package/src/workflow/types.ts +0 -101
  188. package/src/workflow/workflowApis.ts +0 -410
  189. package/vendor/ripgrep/linux-aarch64/rg +0 -0
  190. package/vendor/ripgrep/linux-x86_64/rg +0 -0
  191. package/vendor/ripgrep/macos-aarch64/rg +0 -0
  192. package/vendor/ripgrep/macos-x86_64/rg +0 -0
  193. package/vendor/ripgrep/windows-aarch64/rg.exe +0 -0
  194. package/vendor/ripgrep/windows-x86_64/rg.exe +0 -0
@@ -1,574 +0,0 @@
1
- import { ToolPlugin, ToolContext, ToolResult } from "./types.js";
2
- import { Task, TaskStatus } from "../types/tasks.js";
3
- import {
4
- TASK_CREATE_TOOL_NAME,
5
- TASK_GET_TOOL_NAME,
6
- TASK_UPDATE_TOOL_NAME,
7
- TASK_LIST_TOOL_NAME,
8
- } from "../constants/tools.js";
9
-
10
- /**
11
- * Helper to record and commit a reversion snapshot for a task file.
12
- */
13
- async function recordSnapshot(
14
- context: ToolContext,
15
- taskManager: { getTaskPath: (id: string) => string },
16
- taskId: string,
17
- operation: "create" | "modify" | "delete",
18
- ): Promise<string | undefined> {
19
- if (!context.reversionManager || !context.messageId) return undefined;
20
- const snapshotId = await context.reversionManager.recordSnapshot(
21
- context.messageId,
22
- taskManager.getTaskPath(taskId),
23
- operation,
24
- );
25
- await context.reversionManager.commitSnapshot(snapshotId);
26
- return snapshotId;
27
- }
28
-
29
- /**
30
- * Helper to update a target task's blocks/blockedBy array and record a reversion snapshot.
31
- */
32
- async function updateTaskField(
33
- context: ToolContext,
34
- taskManager: {
35
- getTaskPath: (id: string) => string;
36
- updateTask: (task: Task) => Promise<void>;
37
- },
38
- targetTask: Task,
39
- field: "blocks" | "blockedBy",
40
- value: string[],
41
- ): Promise<void> {
42
- await recordSnapshot(context, taskManager, targetTask.id, "modify");
43
- await taskManager.updateTask({ ...targetTask, [field]: value });
44
- }
45
-
46
- export const taskCreateTool: ToolPlugin = {
47
- name: TASK_CREATE_TOOL_NAME,
48
- config: {
49
- type: "function",
50
- function: {
51
- name: TASK_CREATE_TOOL_NAME,
52
- description: "Create a new task in the task list",
53
- parameters: {
54
- type: "object",
55
- properties: {
56
- subject: {
57
- type: "string",
58
- description: "A brief title for the task",
59
- },
60
- description: {
61
- type: "string",
62
- description: "What needs to be done",
63
- },
64
- activeForm: {
65
- type: "string",
66
- description:
67
- 'Present continuous form shown in spinner when in_progress (e.g., "Running tests")',
68
- },
69
- metadata: {
70
- type: "object",
71
- description: "Arbitrary metadata to attach to the task",
72
- },
73
- },
74
- required: ["subject", "description"],
75
- },
76
- },
77
- },
78
- prompt:
79
- () => `Use this tool to create a structured task list for your current coding session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user.
80
- It also helps the user understand the progress of the task and overall progress of their requests.
81
-
82
- ## When to Use This Tool
83
-
84
- Use this tool proactively in these scenarios:
85
-
86
- - Complex multi-step tasks - When a task requires 3 or more distinct steps or actions
87
- - Non-trivial and complex tasks - Tasks that require careful planning or multiple operations
88
- - Plan mode - When using plan mode, create a task list to track the work
89
- - User explicitly requests todo list - When the user directly asks you to use the todo list
90
- - User provides multiple tasks - When users provide a list of things to be done (numbered or comma-separated)
91
- - After receiving new instructions - Immediately capture user requirements as tasks
92
- - When you start working on a task - Mark it as in_progress BEFORE beginning work
93
- - After completing a task - Mark it as completed and add any new follow-up tasks discovered during implementation
94
-
95
- ## When NOT to Use This Tool
96
-
97
- Skip using this tool when:
98
- - There is only a single, straightforward task
99
- - The task is trivial and tracking it provides no organizational benefit
100
- - The task can be completed in less than 3 trivial steps
101
- - The task is purely conversational or informational
102
-
103
- NOTE 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.
104
-
105
- ## Task Fields
106
-
107
- - **subject**: A brief, actionable title in imperative form (e.g., "Fix authentication bug in login flow")
108
- - **description**: What needs to be done, including context and acceptance criteria
109
- - **activeForm**: Present continuous form shown in spinner when task is in_progress (e.g., "Fixing authentication bug"). This is displayed to the user while you work on the task.
110
-
111
- **IMPORTANT**: Always provide activeForm when creating tasks. The subject should be imperative ("Run tests") while activeForm should be present continuous ("Running tests"). All tasks are created with status \`pending\`.
112
-
113
- ## Tips
114
-
115
- - Create tasks with clear, specific subjects that describe the outcome
116
- - Include enough detail in the description for another agent to understand and complete the task
117
- - After creating tasks, use TaskUpdate to set up dependencies (blocks/blockedBy) if needed
118
- - Check TaskList first to avoid creating duplicate tasks`,
119
- execute: async (args, context: ToolContext): Promise<ToolResult> => {
120
- const taskManager = context.taskManager;
121
-
122
- const task: Omit<Task, "id"> = {
123
- subject: args.subject as string,
124
- description: args.description as string,
125
- status: "pending",
126
- activeForm: args.activeForm as string,
127
- owner: undefined,
128
- blocks: [],
129
- blockedBy: [],
130
- metadata: (args.metadata as Record<string, unknown>) || {},
131
- };
132
-
133
- const taskId = await taskManager.createTask(task);
134
- await recordSnapshot(context, taskManager, taskId, "create");
135
-
136
- return {
137
- success: true,
138
- content: `Task #${taskId} created successfully: ${task.subject}`,
139
- shortResult: `Created task ${taskId}: ${task.subject}`,
140
- };
141
- },
142
- };
143
-
144
- export const taskGetTool: ToolPlugin = {
145
- name: TASK_GET_TOOL_NAME,
146
- config: {
147
- type: "function",
148
- function: {
149
- name: TASK_GET_TOOL_NAME,
150
- description: "Get a task by ID from the task list",
151
- parameters: {
152
- type: "object",
153
- properties: {
154
- taskId: {
155
- type: "string",
156
- description: "The ID of the task to retrieve",
157
- },
158
- },
159
- required: ["taskId"],
160
- },
161
- },
162
- },
163
- prompt: () => `Use this tool to retrieve a task by its ID from the task list.
164
-
165
- ## When to Use This Tool
166
-
167
- - When you need the full description and context before starting work on a task
168
- - To understand task dependencies (what it blocks, what blocks it)
169
- - After being assigned a task, to get complete requirements
170
-
171
- ## Output
172
-
173
- Returns full task details:
174
- - **subject**: Task title
175
- - **description**: Detailed requirements and context
176
- - **status**: 'pending', 'in_progress', or 'completed'
177
- - **blocks**: Tasks waiting on this one to complete
178
- - **blockedBy**: Tasks that must complete before this one can start
179
-
180
- ## Tips
181
-
182
- - After fetching a task, verify its blockedBy list is empty before beginning work.
183
- - Use TaskList to see all tasks in summary form.`,
184
- execute: async (args, context: ToolContext): Promise<ToolResult> => {
185
- const taskManager = context.taskManager;
186
- const taskId = args.taskId as string;
187
-
188
- const task = await taskManager.getTask(taskId);
189
- if (!task) {
190
- return {
191
- success: false,
192
- content: `Task not found`,
193
- };
194
- }
195
-
196
- // Format like Claude Code: structured text instead of raw JSON
197
- const lines = [
198
- `Task #${task.id}: ${task.subject}`,
199
- `Status: ${task.status}`,
200
- `Description: ${task.description}`,
201
- ];
202
- if (task.blockedBy.length > 0) {
203
- lines.push(
204
- `Blocked by: ${task.blockedBy.map((id) => `#${id}`).join(", ")}`,
205
- );
206
- }
207
- if (task.blocks.length > 0) {
208
- lines.push(`Blocks: ${task.blocks.map((id) => `#${id}`).join(", ")}`);
209
- }
210
-
211
- return {
212
- success: true,
213
- content: lines.join("\n"),
214
- };
215
- },
216
- };
217
-
218
- export const taskUpdateTool: ToolPlugin = {
219
- name: TASK_UPDATE_TOOL_NAME,
220
- config: {
221
- type: "function",
222
- function: {
223
- name: TASK_UPDATE_TOOL_NAME,
224
- description: "Update a task in the task list",
225
- parameters: {
226
- type: "object",
227
- properties: {
228
- taskId: {
229
- type: "string",
230
- description: "The ID of the task to update",
231
- },
232
- subject: {
233
- type: "string",
234
- description: "New subject for the task",
235
- },
236
- description: {
237
- type: "string",
238
- description: "New description for the task",
239
- },
240
- activeForm: {
241
- type: "string",
242
- description:
243
- 'Present continuous form shown in spinner when in_progress (e.g., "Running tests")',
244
- },
245
- status: {
246
- type: "string",
247
- enum: ["pending", "in_progress", "completed", "deleted"],
248
- description: "New status for the task",
249
- },
250
- addBlocks: {
251
- type: "array",
252
- items: { type: "string" },
253
- description: "Task IDs that this task blocks",
254
- },
255
- addBlockedBy: {
256
- type: "array",
257
- items: { type: "string" },
258
- description: "Task IDs that block this task",
259
- },
260
- owner: {
261
- type: "string",
262
- description: "New owner for the task",
263
- },
264
- metadata: {
265
- type: "object",
266
- description:
267
- "Metadata keys to merge into the task. Set a key to null to delete it.",
268
- },
269
- },
270
- required: ["taskId"],
271
- },
272
- },
273
- },
274
- prompt: () => `Use this tool to update a task in the task list.
275
-
276
- ## When to Use This Tool
277
-
278
- **Mark tasks as resolved:**
279
- - When you have completed the work described in a task
280
- - When a task is no longer needed or has been superseded
281
- - IMPORTANT: Always mark your assigned tasks as resolved when you finish them
282
- - After resolving, call TaskList to find your next task
283
-
284
- - ONLY mark a task as completed when you have FULLY accomplished it
285
- - If you encounter errors, blockers, or cannot finish, keep the task as in_progress
286
- - When blocked, create a new task describing what needs to be resolved
287
- - Never mark a task as completed if:
288
- - Tests are failing
289
- - Implementation is partial
290
- - You encountered unresolved errors
291
- - You couldn't find necessary files or dependencies
292
-
293
- **Delete tasks:**
294
- - When a task is no longer relevant or was created in error
295
- - Setting status to \`deleted\` permanently removes the task
296
-
297
- **Update task details:**
298
- - When requirements change or become clearer
299
- - When establishing dependencies between tasks
300
-
301
- ## Fields You Can Update
302
-
303
- - **status**: The task status (see Status Workflow below)
304
- - **subject**: Change the task title (imperative form, e.g., "Run tests")
305
- - **description**: Change the task description
306
- - **activeForm**: Present continuous form shown in spinner when in_progress (e.g., "Running tests")
307
- - **owner**: Change the task owner (agent name)
308
- - **metadata**: Merge metadata keys into the task (set a key to null to delete it)
309
- - **addBlocks**: Mark tasks that cannot start until this one completes
310
- - **addBlockedBy**: Mark tasks that must complete before this one can start
311
-
312
- ## Status Workflow
313
-
314
- Status progresses: \`pending\` → \`in_progress\` → \`completed\`
315
-
316
- Use \`deleted\` to permanently remove a task.
317
-
318
- ## Staleness
319
-
320
- Make sure to read a task's latest state using \`TaskGet\` before updating it.
321
-
322
- ## Examples
323
-
324
- Mark task as in progress when starting work:
325
- \`\`\`json
326
- {"taskId": "1", "status": "in_progress"}
327
- \`\`\`
328
-
329
- Mark task as completed after finishing work:
330
- \`\`\`json
331
- {"taskId": "1", "status": "completed"}
332
- \`\`\`
333
-
334
- Delete a task:
335
- \`\`\`json
336
- {"taskId": "1", "status": "deleted"}
337
- \`\`\`
338
-
339
- Claim a task by setting owner:
340
- \`\`\`json
341
- {"taskId": "1", "owner": "my-name"}
342
- \`\`\`
343
-
344
- Set up task dependencies:
345
- \`\`\`json
346
- {"taskId": "2", "addBlockedBy": ["1"]}
347
- \`\`\`
348
- `,
349
- execute: async (args, context: ToolContext): Promise<ToolResult> => {
350
- const taskManager = context.taskManager;
351
- const taskId = args.taskId as string;
352
-
353
- const existingTask = await taskManager.getTask(taskId);
354
- if (!existingTask) {
355
- return {
356
- success: false,
357
- content: `Task #${taskId} not found`,
358
- };
359
- }
360
-
361
- // Handle deletion — just delete the task file (like Claude Code)
362
- if (args.status === "deleted") {
363
- await recordSnapshot(context, taskManager, taskId, "delete");
364
- await taskManager.deleteTask(taskId);
365
-
366
- return {
367
- success: true,
368
- content: `Task #${taskId} deleted`,
369
- shortResult: `Deleted task ${taskId}`,
370
- };
371
- }
372
-
373
- // Build updates object — only include changed fields
374
- const updatedFields: string[] = [];
375
- const updates: {
376
- subject?: string;
377
- description?: string;
378
- activeForm?: string;
379
- status?: TaskStatus;
380
- owner?: string;
381
- metadata?: Record<string, unknown>;
382
- } = {};
383
-
384
- if (args.subject !== undefined && args.subject !== existingTask.subject) {
385
- updates.subject = args.subject as string;
386
- updatedFields.push("subject");
387
- }
388
- if (
389
- args.description !== undefined &&
390
- args.description !== existingTask.description
391
- ) {
392
- updates.description = args.description as string;
393
- updatedFields.push("description");
394
- }
395
- if (
396
- args.activeForm !== undefined &&
397
- args.activeForm !== existingTask.activeForm
398
- ) {
399
- updates.activeForm = args.activeForm as string;
400
- updatedFields.push("activeForm");
401
- }
402
- if (args.owner !== undefined && args.owner !== existingTask.owner) {
403
- updates.owner = args.owner as string;
404
- updatedFields.push("owner");
405
- }
406
- if (args.status !== undefined && args.status !== existingTask.status) {
407
- updates.status = args.status as TaskStatus;
408
- updatedFields.push("status");
409
- }
410
-
411
- // Merge metadata (null values delete keys)
412
- if (args.metadata !== undefined) {
413
- const merged = { ...(existingTask.metadata ?? {}) };
414
- for (const [key, value] of Object.entries(
415
- args.metadata as Record<string, unknown>,
416
- )) {
417
- if (value === null) {
418
- delete merged[key];
419
- } else {
420
- merged[key] = value;
421
- }
422
- }
423
- updates.metadata = merged;
424
- updatedFields.push("metadata");
425
- }
426
-
427
- // Apply basic field updates
428
- if (Object.keys(updates).length > 0) {
429
- await recordSnapshot(context, taskManager, taskId, "modify");
430
- await taskManager.updateTask({ ...existingTask, ...updates });
431
- }
432
-
433
- // Add blocks: update this task's blocks + reciprocal blockedBy on targets
434
- if (args.addBlocks !== undefined) {
435
- const blocksToAdd = (args.addBlocks as string[]).filter(
436
- (id) => !existingTask.blocks.includes(id),
437
- );
438
- if (blocksToAdd.length > 0) {
439
- await recordSnapshot(context, taskManager, taskId, "modify");
440
- await taskManager.updateTask({
441
- ...existingTask,
442
- ...updates,
443
- blocks: [...existingTask.blocks, ...blocksToAdd],
444
- });
445
- updatedFields.push("blocks");
446
-
447
- for (const targetId of blocksToAdd) {
448
- const targetTask = await taskManager.getTask(targetId);
449
- if (targetTask && !targetTask.blockedBy.includes(taskId)) {
450
- await updateTaskField(
451
- context,
452
- taskManager,
453
- targetTask,
454
- "blockedBy",
455
- [...targetTask.blockedBy, taskId],
456
- );
457
- }
458
- }
459
- }
460
- }
461
-
462
- // Add blockedBy: update this task's blockedBy + reciprocal blocks on targets
463
- if (args.addBlockedBy !== undefined) {
464
- const blockedByToAdd = (args.addBlockedBy as string[]).filter(
465
- (id) => !existingTask.blockedBy.includes(id),
466
- );
467
- if (blockedByToAdd.length > 0) {
468
- await recordSnapshot(context, taskManager, taskId, "modify");
469
- await taskManager.updateTask({
470
- ...existingTask,
471
- ...updates,
472
- blockedBy: [...existingTask.blockedBy, ...blockedByToAdd],
473
- });
474
- updatedFields.push("blockedBy");
475
-
476
- for (const targetId of blockedByToAdd) {
477
- const targetTask = await taskManager.getTask(targetId);
478
- if (targetTask && !targetTask.blocks.includes(taskId)) {
479
- await updateTaskField(context, taskManager, targetTask, "blocks", [
480
- ...targetTask.blocks,
481
- taskId,
482
- ]);
483
- }
484
- }
485
- }
486
- }
487
-
488
- let content = `Updated task #${taskId} ${updatedFields.join(", ")}`;
489
- if (updates.status === "completed") {
490
- content += `\n\nTask completed. Call TaskList now to find your next available task or see if your work unblocked others.`;
491
- }
492
-
493
- return {
494
- success: true,
495
- content,
496
- shortResult: `Updated task ${taskId}`,
497
- };
498
- },
499
- };
500
-
501
- export const taskListTool: ToolPlugin = {
502
- name: TASK_LIST_TOOL_NAME,
503
- config: {
504
- type: "function",
505
- function: {
506
- name: TASK_LIST_TOOL_NAME,
507
- description: "List all tasks in the task list",
508
- parameters: {
509
- type: "object",
510
- properties: {},
511
- },
512
- },
513
- },
514
- prompt: () => `Use this tool to list all tasks in the task list.
515
-
516
- ## When to Use This Tool
517
-
518
- - To see what tasks are available to work on (status: 'pending', no owner, not blocked)
519
- - To check overall progress on the project
520
- - To find tasks that are blocked and need dependencies resolved
521
- - After completing a task, to check for newly unblocked work or claim the next available task
522
- - **Prefer working on tasks in ID order** (lowest ID first) when multiple tasks are available, as earlier tasks often set up context for later ones
523
-
524
- ## Output
525
-
526
- Returns a summary of each task:
527
- - **id**: Task identifier (use with TaskGet, TaskUpdate)
528
- - **subject**: Brief description of the task
529
- - **status**: 'pending', 'in_progress', or 'completed'
530
- - **owner**: Agent ID if assigned, empty if available
531
- - **blockedBy**: List of open task IDs that must be resolved first (tasks with blockedBy cannot be claimed until dependencies resolve)
532
-
533
- Use TaskGet with a specific task ID to view full details including description and comments.`,
534
- execute: async (_args, context: ToolContext): Promise<ToolResult> => {
535
- const taskManager = context.taskManager;
536
-
537
- // Filter out internal metadata tasks (like Claude Code)
538
- const allTasks = (await taskManager.listTasks()).filter(
539
- (t) => !(t.metadata as Record<string, unknown>)?._internal,
540
- );
541
-
542
- if (allTasks.length === 0) {
543
- return {
544
- success: true,
545
- content: "No tasks found",
546
- };
547
- }
548
-
549
- // Sort by ID numerically
550
- allTasks.sort((a, b) => parseInt(a.id, 10) - parseInt(b.id, 10));
551
-
552
- // Filter resolved blockers from blockedBy
553
- const completedIds = new Set(
554
- allTasks.filter((t) => t.status === "completed").map((t) => t.id),
555
- );
556
-
557
- const content = allTasks
558
- .map((t) => {
559
- const blockedBy = t.blockedBy.filter((id) => !completedIds.has(id));
560
- const owner = t.owner ? ` (${t.owner})` : "";
561
- const blocked =
562
- blockedBy.length > 0
563
- ? ` [blocked by ${blockedBy.map((id) => `#${id}`).join(", ")}]`
564
- : "";
565
- return `#${t.id} [${t.status}] ${t.subject}${owner}${blocked}`;
566
- })
567
- .join("\n");
568
-
569
- return {
570
- success: true,
571
- content,
572
- };
573
- },
574
- };
@@ -1,78 +0,0 @@
1
- import { TASK_STOP_TOOL_NAME } from "../constants/tools.js";
2
- import { ToolContext, ToolPlugin, ToolResult } from "./types.js";
3
-
4
- export const taskStopTool: ToolPlugin = {
5
- name: TASK_STOP_TOOL_NAME,
6
- config: {
7
- type: "function",
8
- function: {
9
- name: TASK_STOP_TOOL_NAME,
10
- description: "Stop a running background task by ID",
11
- parameters: {
12
- type: "object",
13
- properties: {
14
- task_id: {
15
- type: "string",
16
- description: "The ID of the background task to stop",
17
- },
18
- },
19
- required: ["task_id"],
20
- },
21
- },
22
- },
23
- prompt: () => `
24
- - Stops a running background task by its ID
25
- - Takes a task_id parameter identifying the task to stop
26
- - Returns a success or failure status
27
- - Use this tool when you need to terminate a long-running task
28
- `,
29
- execute: async (
30
- args: Record<string, unknown>,
31
- context: ToolContext,
32
- ): Promise<ToolResult> => {
33
- const taskId = args.task_id as string;
34
-
35
- if (!taskId || typeof taskId !== "string") {
36
- return {
37
- success: false,
38
- content: "",
39
- error: "task_id parameter is required and must be a string",
40
- };
41
- }
42
-
43
- const backgroundTaskManager = context?.backgroundTaskManager;
44
- if (!backgroundTaskManager) {
45
- return {
46
- success: false,
47
- content: "",
48
- error: "Background task manager not available",
49
- };
50
- }
51
-
52
- const stopped = backgroundTaskManager.stopTask(taskId);
53
- if (stopped) {
54
- return {
55
- success: true,
56
- content: `Task ${taskId} has been stopped`,
57
- shortResult: `Stopped ${taskId}`,
58
- };
59
- } else {
60
- const task = backgroundTaskManager.getTask(taskId);
61
- if (!task) {
62
- return {
63
- success: false,
64
- content: "",
65
- error: `Task with ID ${taskId} not found`,
66
- };
67
- }
68
- return {
69
- success: false,
70
- content: "",
71
- error: `Failed to stop task ${taskId} (status: ${task.status})`,
72
- };
73
- }
74
- },
75
- formatCompactParams: (params: Record<string, unknown>) => {
76
- return params.task_id as string;
77
- },
78
- };