wave-agent-sdk 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/dist/agent.d.ts +7 -2
  2. package/dist/agent.d.ts.map +1 -1
  3. package/dist/agent.js +58 -74
  4. package/dist/constants/prompts.d.ts +18 -14
  5. package/dist/constants/prompts.d.ts.map +1 -1
  6. package/dist/constants/prompts.js +134 -54
  7. package/dist/constants/tools.d.ts +4 -1
  8. package/dist/constants/tools.d.ts.map +1 -1
  9. package/dist/constants/tools.js +4 -1
  10. package/dist/index.d.ts +1 -0
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +1 -0
  13. package/dist/managers/aiManager.d.ts +2 -5
  14. package/dist/managers/aiManager.d.ts.map +1 -1
  15. package/dist/managers/aiManager.js +59 -48
  16. package/dist/managers/backgroundTaskManager.d.ts.map +1 -1
  17. package/dist/managers/backgroundTaskManager.js +59 -53
  18. package/dist/managers/foregroundTaskManager.d.ts.map +1 -1
  19. package/dist/managers/foregroundTaskManager.js +3 -2
  20. package/dist/managers/mcpManager.d.ts.map +1 -1
  21. package/dist/managers/messageManager.d.ts +7 -3
  22. package/dist/managers/messageManager.d.ts.map +1 -1
  23. package/dist/managers/messageManager.js +28 -24
  24. package/dist/managers/permissionManager.d.ts.map +1 -1
  25. package/dist/managers/permissionManager.js +25 -15
  26. package/dist/managers/planManager.d.ts +1 -1
  27. package/dist/managers/planManager.d.ts.map +1 -1
  28. package/dist/managers/planManager.js +2 -2
  29. package/dist/managers/subagentManager.d.ts +4 -0
  30. package/dist/managers/subagentManager.d.ts.map +1 -1
  31. package/dist/managers/subagentManager.js +22 -14
  32. package/dist/managers/toolManager.d.ts +11 -0
  33. package/dist/managers/toolManager.d.ts.map +1 -1
  34. package/dist/managers/toolManager.js +20 -2
  35. package/dist/services/aiService.d.ts +0 -1
  36. package/dist/services/aiService.d.ts.map +1 -1
  37. package/dist/services/aiService.js +4 -140
  38. package/dist/services/memory.d.ts +0 -3
  39. package/dist/services/memory.d.ts.map +1 -1
  40. package/dist/services/memory.js +0 -59
  41. package/dist/services/session.d.ts +3 -1
  42. package/dist/services/session.d.ts.map +1 -1
  43. package/dist/services/session.js +16 -1
  44. package/dist/services/taskManager.d.ts +21 -0
  45. package/dist/services/taskManager.d.ts.map +1 -0
  46. package/dist/services/taskManager.js +158 -0
  47. package/dist/tools/askUserQuestion.d.ts.map +1 -1
  48. package/dist/tools/askUserQuestion.js +39 -25
  49. package/dist/tools/bashTool.d.ts.map +1 -1
  50. package/dist/tools/bashTool.js +7 -9
  51. package/dist/tools/editTool.d.ts.map +1 -1
  52. package/dist/tools/editTool.js +2 -1
  53. package/dist/tools/exitPlanMode.d.ts.map +1 -1
  54. package/dist/tools/exitPlanMode.js +25 -1
  55. package/dist/tools/globTool.d.ts.map +1 -1
  56. package/dist/tools/globTool.js +8 -2
  57. package/dist/tools/grepTool.d.ts.map +1 -1
  58. package/dist/tools/grepTool.js +17 -6
  59. package/dist/tools/lsTool.d.ts.map +1 -1
  60. package/dist/tools/lsTool.js +3 -1
  61. package/dist/tools/readTool.d.ts.map +1 -1
  62. package/dist/tools/readTool.js +16 -1
  63. package/dist/tools/taskManagementTools.d.ts +6 -0
  64. package/dist/tools/taskManagementTools.d.ts.map +1 -0
  65. package/dist/tools/taskManagementTools.js +453 -0
  66. package/dist/tools/taskOutputTool.d.ts.map +1 -1
  67. package/dist/tools/taskOutputTool.js +32 -8
  68. package/dist/tools/taskStopTool.d.ts.map +1 -1
  69. package/dist/tools/taskStopTool.js +7 -1
  70. package/dist/tools/taskTool.d.ts.map +1 -1
  71. package/dist/tools/taskTool.js +6 -1
  72. package/dist/tools/types.d.ts +9 -0
  73. package/dist/tools/types.d.ts.map +1 -1
  74. package/dist/tools/writeTool.d.ts.map +1 -1
  75. package/dist/tools/writeTool.js +9 -1
  76. package/dist/types/index.d.ts +1 -0
  77. package/dist/types/index.d.ts.map +1 -1
  78. package/dist/types/index.js +1 -0
  79. package/dist/types/messaging.d.ts +2 -8
  80. package/dist/types/messaging.d.ts.map +1 -1
  81. package/dist/types/processes.d.ts +11 -6
  82. package/dist/types/processes.d.ts.map +1 -1
  83. package/dist/types/tasks.d.ts +13 -0
  84. package/dist/types/tasks.d.ts.map +1 -0
  85. package/dist/types/tasks.js +1 -0
  86. package/dist/types/tools.d.ts +4 -1
  87. package/dist/types/tools.d.ts.map +1 -1
  88. package/dist/utils/builtinSubagents.d.ts.map +1 -1
  89. package/dist/utils/builtinSubagents.js +38 -1
  90. package/dist/utils/cacheControlUtils.d.ts.map +1 -1
  91. package/dist/utils/cacheControlUtils.js +18 -12
  92. package/dist/utils/constants.d.ts +0 -4
  93. package/dist/utils/constants.d.ts.map +1 -1
  94. package/dist/utils/constants.js +0 -4
  95. package/dist/utils/convertMessagesForAPI.js +2 -2
  96. package/dist/utils/messageOperations.d.ts +2 -30
  97. package/dist/utils/messageOperations.d.ts.map +1 -1
  98. package/dist/utils/messageOperations.js +4 -79
  99. package/dist/utils/nameGenerator.d.ts +1 -1
  100. package/dist/utils/nameGenerator.d.ts.map +1 -1
  101. package/dist/utils/nameGenerator.js +19 -3
  102. package/package.json +1 -1
  103. package/src/agent.ts +79 -84
  104. package/src/constants/prompts.ts +161 -65
  105. package/src/constants/tools.ts +4 -1
  106. package/src/index.ts +1 -0
  107. package/src/managers/aiManager.ts +79 -70
  108. package/src/managers/backgroundTaskManager.ts +53 -54
  109. package/src/managers/foregroundTaskManager.ts +3 -2
  110. package/src/managers/mcpManager.ts +6 -3
  111. package/src/managers/messageManager.ts +37 -26
  112. package/src/managers/permissionManager.ts +32 -21
  113. package/src/managers/planManager.ts +2 -2
  114. package/src/managers/subagentManager.ts +33 -14
  115. package/src/managers/toolManager.ts +32 -2
  116. package/src/services/aiService.ts +3 -145
  117. package/src/services/memory.ts +0 -72
  118. package/src/services/session.ts +21 -0
  119. package/src/services/taskManager.ts +188 -0
  120. package/src/tools/askUserQuestion.ts +51 -29
  121. package/src/tools/bashTool.ts +9 -15
  122. package/src/tools/editTool.ts +3 -1
  123. package/src/tools/exitPlanMode.ts +26 -2
  124. package/src/tools/globTool.ts +10 -2
  125. package/src/tools/grepTool.ts +17 -6
  126. package/src/tools/lsTool.ts +3 -1
  127. package/src/tools/readTool.ts +17 -1
  128. package/src/tools/taskManagementTools.ts +498 -0
  129. package/src/tools/taskOutputTool.ts +34 -12
  130. package/src/tools/taskStopTool.ts +7 -1
  131. package/src/tools/taskTool.ts +7 -1
  132. package/src/tools/types.ts +10 -0
  133. package/src/tools/writeTool.ts +9 -2
  134. package/src/types/index.ts +1 -0
  135. package/src/types/messaging.ts +1 -9
  136. package/src/types/processes.ts +13 -7
  137. package/src/types/tasks.ts +13 -0
  138. package/src/types/tools.ts +4 -1
  139. package/src/utils/builtinSubagents.ts +47 -1
  140. package/src/utils/cacheControlUtils.ts +26 -18
  141. package/src/utils/constants.ts +0 -5
  142. package/src/utils/convertMessagesForAPI.ts +2 -2
  143. package/src/utils/messageOperations.ts +5 -116
  144. package/src/utils/nameGenerator.ts +20 -3
  145. package/dist/tools/todoWriteTool.d.ts +0 -6
  146. package/dist/tools/todoWriteTool.d.ts.map +0 -1
  147. package/dist/tools/todoWriteTool.js +0 -220
  148. package/src/tools/todoWriteTool.ts +0 -257
@@ -0,0 +1,453 @@
1
+ import { TASK_CREATE_TOOL_NAME, TASK_GET_TOOL_NAME, TASK_UPDATE_TOOL_NAME, TASK_LIST_TOOL_NAME, } from "../constants/tools.js";
2
+ export const taskCreateTool = {
3
+ name: TASK_CREATE_TOOL_NAME,
4
+ config: {
5
+ type: "function",
6
+ function: {
7
+ name: TASK_CREATE_TOOL_NAME,
8
+ description: "Create a new task in the task list",
9
+ parameters: {
10
+ type: "object",
11
+ properties: {
12
+ subject: {
13
+ type: "string",
14
+ description: "A brief title for the task",
15
+ },
16
+ description: {
17
+ type: "string",
18
+ description: "A detailed description of what needs to be done",
19
+ },
20
+ status: {
21
+ type: "string",
22
+ enum: ["pending", "in_progress", "completed", "deleted"],
23
+ description: "Initial status of the task. Defaults to 'pending'.",
24
+ },
25
+ activeForm: {
26
+ type: "string",
27
+ description: 'Present continuous form shown in spinner when in_progress (e.g., "Running tests")',
28
+ },
29
+ owner: {
30
+ type: "string",
31
+ description: "Optional owner of the task.",
32
+ },
33
+ blocks: {
34
+ type: "array",
35
+ items: { type: "string" },
36
+ description: "List of task IDs that this task blocks.",
37
+ },
38
+ blockedBy: {
39
+ type: "array",
40
+ items: { type: "string" },
41
+ description: "List of task IDs that block this task.",
42
+ },
43
+ metadata: {
44
+ type: "object",
45
+ description: "Arbitrary metadata to attach to the task",
46
+ },
47
+ },
48
+ required: ["subject", "description"],
49
+ },
50
+ },
51
+ },
52
+ prompt: () => `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.
53
+ It also helps the user understand the progress of the task and overall progress of their requests.
54
+
55
+ ## When to Use This Tool
56
+
57
+ Use this tool proactively in these scenarios:
58
+
59
+ - Complex multi-step tasks - When a task requires 3 or more distinct steps or actions
60
+ - Non-trivial and complex tasks - Tasks that require careful planning or multiple operations
61
+ - Plan mode - When using plan mode, create a task list to track the work
62
+ - User explicitly requests todo list - When the user directly asks you to use the todo list
63
+ - User provides multiple tasks - When users provide a list of things to be done (numbered or comma-separated)
64
+ - After receiving new instructions - Immediately capture user requirements as tasks
65
+ - When you start working on a task - Mark it as in_progress BEFORE beginning work
66
+ - After completing a task - Mark it as completed and add any new follow-up tasks discovered during implementation
67
+
68
+ ## When NOT to Use This Tool
69
+
70
+ Skip using this tool when:
71
+ - There is only a single, straightforward task
72
+ - The task is trivial and tracking it provides no organizational benefit
73
+ - The task can be completed in less than 3 trivial steps
74
+ - The task is purely conversational or informational
75
+
76
+ 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.
77
+
78
+ ## Task Fields
79
+
80
+ - **subject**: A brief, actionable title in imperative form (e.g., "Fix authentication bug in login flow")
81
+ - **description**: Detailed description of what needs to be done, including context and acceptance criteria
82
+ - **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.
83
+
84
+ **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\`.
85
+
86
+ ## Tips
87
+
88
+ - Create tasks with clear, specific subjects that describe the outcome
89
+ - Include enough detail in the description for another agent to understand and complete the task
90
+ - After creating tasks, use TaskUpdate to set up dependencies (blocks/blockedBy) if needed
91
+ - Check TaskList first to avoid creating duplicate tasks`,
92
+ execute: async (args, context) => {
93
+ const taskManager = context.taskManager;
94
+ const task = {
95
+ subject: args.subject,
96
+ description: args.description,
97
+ status: args.status || "pending",
98
+ activeForm: args.activeForm,
99
+ owner: args.owner,
100
+ blocks: args.blocks || [],
101
+ blockedBy: args.blockedBy || [],
102
+ metadata: args.metadata || {},
103
+ };
104
+ const taskId = await taskManager.createTask(task);
105
+ return {
106
+ success: true,
107
+ content: `Task created with ID: ${taskId}`,
108
+ shortResult: `Created task ${taskId}: ${task.subject}`,
109
+ };
110
+ },
111
+ };
112
+ export const taskGetTool = {
113
+ name: TASK_GET_TOOL_NAME,
114
+ config: {
115
+ type: "function",
116
+ function: {
117
+ name: TASK_GET_TOOL_NAME,
118
+ description: "Get a task by ID from the task list",
119
+ parameters: {
120
+ type: "object",
121
+ properties: {
122
+ taskId: {
123
+ type: "string",
124
+ description: "The ID of the task to retrieve",
125
+ },
126
+ },
127
+ required: ["taskId"],
128
+ },
129
+ },
130
+ },
131
+ prompt: () => `Use this tool to retrieve a task by its ID from the task list.
132
+
133
+ ## When to Use This Tool
134
+
135
+ - When you need the full description and context before starting work on a task
136
+ - To understand task dependencies (what it blocks, what blocks it)
137
+ - After being assigned a task, to get complete requirements
138
+
139
+ ## Output
140
+
141
+ Returns full task details:
142
+ - **subject**: Task title
143
+ - **description**: Detailed requirements and context
144
+ - **status**: 'pending', 'in_progress', or 'completed'
145
+ - **blocks**: Tasks waiting on this one to complete
146
+ - **blockedBy**: Tasks that must complete before this one can start
147
+
148
+ ## Tips
149
+
150
+ - After fetching a task, verify its blockedBy list is empty before beginning work.
151
+ - Use TaskList to see all tasks in summary form.`,
152
+ execute: async (args, context) => {
153
+ const taskManager = context.taskManager;
154
+ const taskId = args.taskId;
155
+ const task = await taskManager.getTask(taskId);
156
+ if (!task) {
157
+ return {
158
+ success: false,
159
+ content: `Task with ID ${taskId} not found.`,
160
+ };
161
+ }
162
+ return {
163
+ success: true,
164
+ content: JSON.stringify(task, null, 2),
165
+ };
166
+ },
167
+ };
168
+ export const taskUpdateTool = {
169
+ name: TASK_UPDATE_TOOL_NAME,
170
+ config: {
171
+ type: "function",
172
+ function: {
173
+ name: TASK_UPDATE_TOOL_NAME,
174
+ description: "Update a task in the task list",
175
+ parameters: {
176
+ type: "object",
177
+ properties: {
178
+ taskId: {
179
+ type: "string",
180
+ description: "The ID of the task to update",
181
+ },
182
+ subject: {
183
+ type: "string",
184
+ description: "New subject for the task",
185
+ },
186
+ description: {
187
+ type: "string",
188
+ description: "New description for the task",
189
+ },
190
+ activeForm: {
191
+ type: "string",
192
+ description: 'Present continuous form shown in spinner when in_progress (e.g., "Running tests")',
193
+ },
194
+ status: {
195
+ type: "string",
196
+ enum: ["pending", "in_progress", "completed", "deleted"],
197
+ description: "New status for the task",
198
+ },
199
+ addBlocks: {
200
+ type: "array",
201
+ items: { type: "string" },
202
+ description: "Task IDs that this task blocks",
203
+ },
204
+ addBlockedBy: {
205
+ type: "array",
206
+ items: { type: "string" },
207
+ description: "Task IDs that block this task",
208
+ },
209
+ owner: {
210
+ type: "string",
211
+ description: "New owner for the task",
212
+ },
213
+ metadata: {
214
+ type: "object",
215
+ description: "Metadata keys to merge into the task. Set a key to null to delete it.",
216
+ },
217
+ },
218
+ required: ["taskId"],
219
+ },
220
+ },
221
+ },
222
+ prompt: () => `Use this tool to update a task in the task list.
223
+
224
+ ## When to Use This Tool
225
+
226
+ **Mark tasks as resolved:**
227
+ - When you have completed the work described in a task
228
+ - When a task is no longer needed or has been superseded
229
+ - IMPORTANT: Always mark your assigned tasks as resolved when you finish them
230
+ - After resolving, call TaskList to find your next task
231
+
232
+ - ONLY mark a task as completed when you have FULLY accomplished it
233
+ - If you encounter errors, blockers, or cannot finish, keep the task as in_progress
234
+ - When blocked, create a new task describing what needs to be resolved
235
+ - Never mark a task as completed if:
236
+ - Tests are failing
237
+ - Implementation is partial
238
+ - You encountered unresolved errors
239
+ - You couldn't find necessary files or dependencies
240
+
241
+ **Delete tasks:**
242
+ - When a task is no longer relevant or was created in error
243
+ - Setting status to \`deleted\` permanently removes the task
244
+
245
+ **Update task details:**
246
+ - When requirements change or become clearer
247
+ - When establishing dependencies between tasks
248
+
249
+ ## Fields You Can Update
250
+
251
+ - **status**: The task status (see Status Workflow below)
252
+ - **subject**: Change the task title (imperative form, e.g., "Run tests")
253
+ - **description**: Change the task description
254
+ - **activeForm**: Present continuous form shown in spinner when in_progress (e.g., "Running tests")
255
+ - **owner**: Change the task owner (agent name)
256
+ - **metadata**: Merge metadata keys into the task (set a key to null to delete it)
257
+ - **addBlocks**: Mark tasks that cannot start until this one completes
258
+ - **addBlockedBy**: Mark tasks that must complete before this one can start
259
+
260
+ ## Status Workflow
261
+
262
+ Status progresses: \`pending\` → \`in_progress\` → \`completed\`
263
+
264
+ Use \`deleted\` to permanently remove a task.
265
+
266
+ ## Staleness
267
+
268
+ Make sure to read a task's latest state using \`TaskGet\` before updating it.
269
+
270
+ ## Examples
271
+
272
+ Mark task as in progress when starting work:
273
+ \`\`\`json
274
+ {"taskId": "1", "status": "in_progress"}
275
+ \`\`\`
276
+
277
+ Mark task as completed after finishing work:
278
+ \`\`\`json
279
+ {"taskId": "1", "status": "completed"}
280
+ \`\`\`
281
+
282
+ Delete a task:
283
+ \`\`\`json
284
+ {"taskId": "1", "status": "deleted"}
285
+ \`\`\`
286
+
287
+ Claim a task by setting owner:
288
+ \`\`\`json
289
+ {"taskId": "1", "owner": "my-name"}
290
+ \`\`\`
291
+
292
+ Set up task dependencies:
293
+ \`\`\`json
294
+ {"taskId": "2", "addBlockedBy": ["1"]}
295
+ \`\`\`
296
+ `,
297
+ execute: async (args, context) => {
298
+ const taskManager = context.taskManager;
299
+ const taskId = args.taskId;
300
+ const existingTask = await taskManager.getTask(taskId);
301
+ if (!existingTask) {
302
+ return {
303
+ success: false,
304
+ content: `Task with ID ${taskId} not found.`,
305
+ };
306
+ }
307
+ const updatedFields = [];
308
+ const updatedTask = {
309
+ ...existingTask,
310
+ };
311
+ if (args.subject !== undefined && args.subject !== existingTask.subject) {
312
+ updatedTask.subject = args.subject;
313
+ updatedFields.push("subject");
314
+ }
315
+ if (args.description !== undefined &&
316
+ args.description !== existingTask.description) {
317
+ updatedTask.description = args.description;
318
+ updatedFields.push("description");
319
+ }
320
+ if (args.status !== undefined && args.status !== existingTask.status) {
321
+ updatedTask.status = args.status;
322
+ updatedFields.push("status");
323
+ }
324
+ if (args.activeForm !== undefined &&
325
+ args.activeForm !== existingTask.activeForm) {
326
+ updatedTask.activeForm = args.activeForm;
327
+ updatedFields.push("activeForm");
328
+ }
329
+ if (args.owner !== undefined && args.owner !== existingTask.owner) {
330
+ updatedTask.owner = args.owner;
331
+ updatedFields.push("owner");
332
+ }
333
+ if (args.metadata !== undefined) {
334
+ const newMetadata = { ...(existingTask.metadata || {}) };
335
+ for (const [key, value] of Object.entries(args.metadata)) {
336
+ if (value === null) {
337
+ delete newMetadata[key];
338
+ }
339
+ else {
340
+ newMetadata[key] = value;
341
+ }
342
+ }
343
+ updatedTask.metadata = newMetadata;
344
+ updatedFields.push("metadata");
345
+ }
346
+ if (args.addBlocks !== undefined) {
347
+ const blocksToAdd = args.addBlocks.filter((id) => !updatedTask.blocks.includes(id));
348
+ if (blocksToAdd.length > 0) {
349
+ updatedTask.blocks = [...updatedTask.blocks, ...blocksToAdd];
350
+ updatedFields.push("blocks");
351
+ // Also update the blockedBy of the target tasks
352
+ for (const targetId of blocksToAdd) {
353
+ const targetTask = await taskManager.getTask(targetId);
354
+ if (targetTask && !targetTask.blockedBy.includes(taskId)) {
355
+ await taskManager.updateTask({
356
+ ...targetTask,
357
+ blockedBy: [...targetTask.blockedBy, taskId],
358
+ });
359
+ }
360
+ }
361
+ }
362
+ }
363
+ if (args.addBlockedBy !== undefined) {
364
+ const blockedByToAdd = args.addBlockedBy.filter((id) => !updatedTask.blockedBy.includes(id));
365
+ if (blockedByToAdd.length > 0) {
366
+ updatedTask.blockedBy = [...updatedTask.blockedBy, ...blockedByToAdd];
367
+ updatedFields.push("blockedBy");
368
+ // Also update the blocks of the target tasks
369
+ for (const targetId of blockedByToAdd) {
370
+ const targetTask = await taskManager.getTask(targetId);
371
+ if (targetTask && !targetTask.blocks.includes(taskId)) {
372
+ await taskManager.updateTask({
373
+ ...targetTask,
374
+ blocks: [...targetTask.blocks, taskId],
375
+ });
376
+ }
377
+ }
378
+ }
379
+ }
380
+ await taskManager.updateTask(updatedTask);
381
+ let content = `Updated task #${taskId} ${updatedFields.join(", ")}`;
382
+ if (updatedTask.status === "completed") {
383
+ content += `\n\nTask completed. Call TaskList now to find your next available task or see if your work unblocked others.`;
384
+ }
385
+ return {
386
+ success: true,
387
+ content,
388
+ shortResult: `Updated task ${taskId}`,
389
+ };
390
+ },
391
+ };
392
+ export const taskListTool = {
393
+ name: TASK_LIST_TOOL_NAME,
394
+ config: {
395
+ type: "function",
396
+ function: {
397
+ name: TASK_LIST_TOOL_NAME,
398
+ description: "List all tasks in the task list",
399
+ parameters: {
400
+ type: "object",
401
+ properties: {
402
+ status: {
403
+ type: "string",
404
+ enum: ["pending", "in_progress", "completed", "deleted"],
405
+ description: "Optional filter by status.",
406
+ },
407
+ },
408
+ },
409
+ },
410
+ },
411
+ prompt: () => `Use this tool to list all tasks in the task list.
412
+
413
+ ## When to Use This Tool
414
+
415
+ - To see what tasks are available to work on (status: 'pending', no owner, not blocked)
416
+ - To check overall progress on the project
417
+ - To find tasks that are blocked and need dependencies resolved
418
+ - After completing a task, to check for newly unblocked work or claim the next available task
419
+ - **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
420
+
421
+ ## Output
422
+
423
+ Returns a summary of each task:
424
+ - **id**: Task identifier (use with TaskGet, TaskUpdate)
425
+ - **subject**: Brief description of the task
426
+ - **status**: 'pending', 'in_progress', or 'completed'
427
+ - **owner**: Agent ID if assigned, empty if available
428
+ - **blockedBy**: List of open task IDs that must be resolved first (tasks with blockedBy cannot be claimed until dependencies resolve)
429
+
430
+ Use TaskGet with a specific task ID to view full details including description and comments.`,
431
+ execute: async (args, context) => {
432
+ const taskManager = context.taskManager;
433
+ let tasks = await taskManager.listTasks();
434
+ if (args.status) {
435
+ tasks = tasks.filter((t) => t.status === args.status);
436
+ }
437
+ if (tasks.length === 0) {
438
+ return {
439
+ success: true,
440
+ content: "No tasks found.",
441
+ };
442
+ }
443
+ // Sort by ID numerically
444
+ tasks.sort((a, b) => parseInt(a.id, 10) - parseInt(b.id, 10));
445
+ const content = tasks
446
+ .map((t) => `[${t.id}] ${t.subject} (${t.status})`)
447
+ .join("\n");
448
+ return {
449
+ success: true,
450
+ content,
451
+ };
452
+ },
453
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"taskOutputTool.d.ts","sourceRoot":"","sources":["../../src/tools/taskOutputTool.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,UAAU,EAAc,MAAM,YAAY,CAAC;AAKjE,eAAO,MAAM,cAAc,EAAE,UAuK5B,CAAC"}
1
+ {"version":3,"file":"taskOutputTool.d.ts","sourceRoot":"","sources":["../../src/tools/taskOutputTool.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,UAAU,EAAc,MAAM,YAAY,CAAC;AAKjE,eAAO,MAAM,cAAc,EAAE,UA6L5B,CAAC"}
@@ -7,31 +7,43 @@ export const taskOutputTool = {
7
7
  type: "function",
8
8
  function: {
9
9
  name: TASK_OUTPUT_TOOL_NAME,
10
- description: "Retrieves output from a running or completed background task",
10
+ description: "Retrieves output from a running or completed task",
11
11
  parameters: {
12
12
  type: "object",
13
13
  properties: {
14
14
  task_id: {
15
15
  type: "string",
16
- description: "The ID of the background task to retrieve output from",
17
- },
18
- filter: {
19
- type: "string",
20
- description: "Optional regular expression to filter the output lines.",
16
+ description: "The task ID to get output from",
21
17
  },
22
18
  block: {
23
19
  type: "boolean",
24
- description: "If true, wait for the task to complete before returning output. If false, return current output immediately.",
20
+ default: true,
21
+ description: "Whether to wait for completion",
22
+ },
23
+ timeout: {
24
+ type: "number",
25
+ minimum: 0,
26
+ maximum: 600000,
27
+ default: 30000,
28
+ description: "Max wait time in ms",
25
29
  },
26
30
  },
27
31
  required: ["task_id"],
28
32
  },
29
33
  },
30
34
  },
35
+ prompt: () => `- Retrieves output from a running or completed task (background shell, agent, or remote session)
36
+ - Takes a task_id parameter identifying the task
37
+ - Returns the task output along with status information
38
+ - Use block=true (default) to wait for task completion
39
+ - Use block=false for non-blocking check of current status
40
+ - Task IDs can be found using the /tasks command
41
+ - Works with all task types: background shells, async agents, and remote sessions`,
31
42
  execute: async (args, context) => {
32
43
  const taskId = args.task_id;
33
44
  const filter = args.filter;
34
- const block = args.block;
45
+ const block = args.block ?? true;
46
+ const timeout = args.timeout ?? 30000;
35
47
  if (!taskId || typeof taskId !== "string") {
36
48
  return {
37
49
  success: false,
@@ -74,6 +86,7 @@ export const taskOutputTool = {
74
86
  return new Promise((resolve) => {
75
87
  let timeoutHandle = null;
76
88
  let isAborted = false;
89
+ const startTime = Date.now();
77
90
  const cleanup = () => {
78
91
  if (timeoutHandle) {
79
92
  clearTimeout(timeoutHandle);
@@ -101,6 +114,17 @@ export const taskOutputTool = {
101
114
  const check = () => {
102
115
  if (isAborted)
103
116
  return;
117
+ if (Date.now() - startTime > timeout) {
118
+ if (context.abortSignal) {
119
+ context.abortSignal.removeEventListener("abort", onAbort);
120
+ }
121
+ resolve({
122
+ success: true,
123
+ content: "Retrieval timed out",
124
+ shortResult: `${taskId}: timeout`,
125
+ });
126
+ return;
127
+ }
104
128
  const task = backgroundTaskManager.getTask(taskId);
105
129
  if (!task) {
106
130
  if (context.abortSignal) {
@@ -1 +1 @@
1
- {"version":3,"file":"taskStopTool.d.ts","sourceRoot":"","sources":["../../src/tools/taskStopTool.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,UAAU,EAAc,MAAM,YAAY,CAAC;AAEjE,eAAO,MAAM,YAAY,EAAE,UAoE1B,CAAC"}
1
+ {"version":3,"file":"taskStopTool.d.ts","sourceRoot":"","sources":["../../src/tools/taskStopTool.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,UAAU,EAAc,MAAM,YAAY,CAAC;AAEjE,eAAO,MAAM,YAAY,EAAE,UA0E1B,CAAC"}
@@ -5,7 +5,7 @@ export const taskStopTool = {
5
5
  type: "function",
6
6
  function: {
7
7
  name: TASK_STOP_TOOL_NAME,
8
- description: "Stops a running background task",
8
+ description: "Stop a running background task by ID",
9
9
  parameters: {
10
10
  type: "object",
11
11
  properties: {
@@ -18,6 +18,12 @@ export const taskStopTool = {
18
18
  },
19
19
  },
20
20
  },
21
+ prompt: () => `
22
+ - Stops a running background task by its ID
23
+ - Takes a task_id parameter identifying the task to stop
24
+ - Returns a success or failure status
25
+ - Use this tool when you need to terminate a long-running task
26
+ `,
21
27
  execute: async (args, context) => {
22
28
  const taskId = args.task_id;
23
29
  if (!taskId || typeof taskId !== "string") {
@@ -1 +1 @@
1
- {"version":3,"file":"taskTool.d.ts","sourceRoot":"","sources":["../../src/tools/taskTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAGtE;;;GAGG;AACH,wBAAgB,cAAc,CAAC,eAAe,EAAE,eAAe,GAAG,UAAU,CA6L3E"}
1
+ {"version":3,"file":"taskTool.d.ts","sourceRoot":"","sources":["../../src/tools/taskTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAGtE;;;GAGG;AACH,wBAAgB,cAAc,CAAC,eAAe,EAAE,eAAe,GAAG,UAAU,CAmM3E"}
@@ -48,6 +48,10 @@ export function createTaskTool(subagentManager) {
48
48
  },
49
49
  };
50
50
  },
51
+ prompt: () => `
52
+ - When doing file search, prefer to use the ${TASK_TOOL_NAME} tool in order to reduce context usage.
53
+ - 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.`,
51
55
  execute: async (args, context) => {
52
56
  return new Promise((resolve) => {
53
57
  (async () => {
@@ -111,8 +115,9 @@ export function createTaskTool(subagentManager) {
111
115
  // Resolve the tool execution early so the main agent can continue
112
116
  resolve({
113
117
  success: true,
114
- content: `Task moved to background with ID: ${taskId}. Use TaskOutput to monitor progress.`,
118
+ content: `Task moved to background with ID: ${taskId}.`,
115
119
  shortResult: "Task backgrounded",
120
+ isManuallyBackgrounded: true,
116
121
  });
117
122
  },
118
123
  });
@@ -8,6 +8,10 @@ export interface ToolPlugin {
8
8
  config: ChatCompletionFunctionTool;
9
9
  execute: (args: Record<string, unknown>, context: ToolContext) => Promise<ToolResult>;
10
10
  formatCompactParams?: (params: Record<string, unknown>, context: ToolContext) => string;
11
+ /**
12
+ * Optional function to provide a prompt to be added to the system prompt
13
+ */
14
+ prompt?: (context: ToolContext) => string;
11
15
  }
12
16
  export interface ToolResult {
13
17
  success: boolean;
@@ -19,6 +23,7 @@ export interface ToolResult {
19
23
  data: string;
20
24
  mediaType?: string;
21
25
  }>;
26
+ isManuallyBackgrounded?: boolean;
22
27
  }
23
28
  export interface ToolContext {
24
29
  abortSignal?: AbortSignal;
@@ -41,5 +46,9 @@ export interface ToolContext {
41
46
  messageId?: string;
42
47
  /** Foreground task manager for backgrounding tasks */
43
48
  foregroundTaskManager?: import("../types/processes.js").IForegroundTaskManager;
49
+ /** Task manager instance for task management */
50
+ taskManager: import("../services/taskManager.js").TaskManager;
51
+ /** Current session ID */
52
+ sessionId?: string;
44
53
  }
45
54
  //# 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;CACb;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,CAAC;IAErB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,MAAM,CAAC,EAAE,KAAK,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC,CAAC;CACJ;AAED,MAAM,WAAW,WAAW;IAC1B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,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A4B,EAAE,WAAW,CAAC;IAC9D,yBAAyB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
@@ -1 +1 @@
1
- {"version":3,"file":"writeTool.d.ts","sourceRoot":"","sources":["../../src/tools/writeTool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AAGtE;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,UA0LvB,CAAC"}
1
+ {"version":3,"file":"writeTool.d.ts","sourceRoot":"","sources":["../../src/tools/writeTool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AAGtE;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,UAiMvB,CAAC"}
@@ -11,7 +11,7 @@ export const writeTool = {
11
11
  type: "function",
12
12
  function: {
13
13
  name: "Write",
14
- description: "Writes a file to the local filesystem.\n\nUsage:\n- This tool will overwrite the existing file if there is one at the provided path.\n- If this is an existing file, you MUST use the Read tool first to read the file's contents. This tool will fail if you did not read the file first.\n- ALWAYS prefer editing existing files in the codebase. NEVER write new files unless explicitly required.\n- NEVER proactively create documentation files (*.md) or README files. Only create documentation files if explicitly requested by the User.\n- Only use emojis if the user explicitly requests it. Avoid writing emojis to files unless asked.\n- IMPORTANT: Always provide file_path parameter before content parameter when calling this tool.",
14
+ description: "Writes a file to the local filesystem.",
15
15
  parameters: {
16
16
  type: "object",
17
17
  properties: {
@@ -29,6 +29,14 @@ export const writeTool = {
29
29
  },
30
30
  },
31
31
  },
32
+ prompt: () => `
33
+ Usage:
34
+ - This tool will overwrite the existing file if there is one at the provided path.
35
+ - If this is an existing file, you MUST use the Read tool first to read the file's contents. This tool will fail if you did not read the file first.
36
+ - ALWAYS prefer editing existing files in the codebase. NEVER write new files unless explicitly required.
37
+ - NEVER proactively create documentation files (*.md) or README files. Only create documentation files if explicitly requested by the User.
38
+ - Only use emojis if the user explicitly requests it. Avoid writing emojis to files unless asked.
39
+ - IMPORTANT: Always provide file_path parameter before content parameter when calling this tool.`,
32
40
  execute: async (args, context) => {
33
41
  const filePath = args.file_path;
34
42
  const content = args.content;
@@ -29,4 +29,5 @@ export * from "./plugins.js";
29
29
  export * from "./marketplace.js";
30
30
  export * from "./memoryRule.js";
31
31
  export * from "./history.js";
32
+ export * from "./tasks.js";
32
33
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,cAAc,WAAW,CAAC;AAG1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,cAAc,WAAW,CAAC;AAG1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,iBAAiB,CAAC;AAChC,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}