wave-agent-sdk 0.5.0 → 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.
- package/dist/agent.d.ts +14 -11
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +64 -151
- package/dist/constants/subagents.d.ts +5 -0
- package/dist/constants/subagents.d.ts.map +1 -0
- package/dist/constants/subagents.js +4 -0
- package/dist/constants/tools.d.ts +4 -1
- package/dist/constants/tools.d.ts.map +1 -1
- package/dist/constants/tools.js +4 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/managers/aiManager.d.ts +2 -5
- package/dist/managers/aiManager.d.ts.map +1 -1
- package/dist/managers/aiManager.js +43 -48
- package/dist/managers/backgroundTaskManager.d.ts.map +1 -1
- package/dist/managers/backgroundTaskManager.js +63 -53
- package/dist/managers/foregroundTaskManager.d.ts.map +1 -1
- package/dist/managers/foregroundTaskManager.js +3 -2
- package/dist/managers/mcpManager.d.ts.map +1 -1
- package/dist/managers/messageManager.d.ts +13 -27
- package/dist/managers/messageManager.d.ts.map +1 -1
- package/dist/managers/messageManager.js +94 -89
- package/dist/managers/permissionManager.d.ts.map +1 -1
- package/dist/managers/permissionManager.js +25 -15
- package/dist/managers/planManager.d.ts +1 -1
- package/dist/managers/planManager.d.ts.map +1 -1
- package/dist/managers/planManager.js +2 -2
- package/dist/managers/reversionManager.d.ts.map +1 -1
- package/dist/managers/reversionManager.js +23 -2
- package/dist/managers/slashCommandManager.d.ts +3 -0
- package/dist/managers/slashCommandManager.d.ts.map +1 -1
- package/dist/managers/slashCommandManager.js +8 -3
- package/dist/managers/subagentManager.d.ts +8 -14
- package/dist/managers/subagentManager.d.ts.map +1 -1
- package/dist/managers/subagentManager.js +46 -112
- package/dist/managers/toolManager.d.ts +11 -0
- package/dist/managers/toolManager.d.ts.map +1 -1
- package/dist/managers/toolManager.js +20 -2
- package/dist/{constants/prompts.d.ts → prompts/index.d.ts} +17 -15
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +309 -0
- package/dist/services/aiService.d.ts +0 -1
- package/dist/services/aiService.d.ts.map +1 -1
- package/dist/services/aiService.js +4 -140
- package/dist/services/memory.d.ts +0 -3
- package/dist/services/memory.d.ts.map +1 -1
- package/dist/services/memory.js +0 -59
- package/dist/services/session.d.ts +15 -1
- package/dist/services/session.d.ts.map +1 -1
- package/dist/services/session.js +57 -1
- package/dist/services/taskManager.d.ts +25 -0
- package/dist/services/taskManager.d.ts.map +1 -0
- package/dist/services/taskManager.js +164 -0
- package/dist/tools/askUserQuestion.d.ts.map +1 -1
- package/dist/tools/askUserQuestion.js +39 -25
- package/dist/tools/bashTool.d.ts.map +1 -1
- package/dist/tools/bashTool.js +13 -11
- package/dist/tools/editTool.d.ts.map +1 -1
- package/dist/tools/editTool.js +2 -1
- package/dist/tools/exitPlanMode.d.ts.map +1 -1
- package/dist/tools/exitPlanMode.js +26 -2
- package/dist/tools/globTool.d.ts.map +1 -1
- package/dist/tools/globTool.js +8 -2
- package/dist/tools/grepTool.d.ts.map +1 -1
- package/dist/tools/grepTool.js +17 -6
- package/dist/tools/lsTool.d.ts.map +1 -1
- package/dist/tools/lsTool.js +3 -1
- package/dist/tools/readTool.d.ts.map +1 -1
- package/dist/tools/readTool.js +16 -1
- package/dist/tools/taskManagementTools.d.ts +6 -0
- package/dist/tools/taskManagementTools.d.ts.map +1 -0
- package/dist/tools/taskManagementTools.js +461 -0
- package/dist/tools/taskOutputTool.d.ts.map +1 -1
- package/dist/tools/taskOutputTool.js +32 -8
- package/dist/tools/taskStopTool.d.ts.map +1 -1
- package/dist/tools/taskStopTool.js +7 -1
- package/dist/tools/taskTool.d.ts.map +1 -1
- package/dist/tools/taskTool.js +37 -2
- package/dist/tools/types.d.ts +11 -0
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/writeTool.d.ts.map +1 -1
- package/dist/tools/writeTool.js +9 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/messaging.d.ts +2 -18
- package/dist/types/messaging.d.ts.map +1 -1
- package/dist/types/processes.d.ts +16 -6
- package/dist/types/processes.d.ts.map +1 -1
- package/dist/types/tasks.d.ts +13 -0
- package/dist/types/tasks.d.ts.map +1 -0
- package/dist/types/tasks.js +1 -0
- package/dist/types/tools.d.ts +4 -1
- package/dist/types/tools.d.ts.map +1 -1
- package/dist/utils/builtinSubagents.d.ts.map +1 -1
- package/dist/utils/builtinSubagents.js +59 -44
- package/dist/utils/cacheControlUtils.d.ts.map +1 -1
- package/dist/utils/cacheControlUtils.js +18 -12
- package/dist/utils/constants.d.ts +0 -4
- package/dist/utils/constants.d.ts.map +1 -1
- package/dist/utils/constants.js +0 -4
- package/dist/utils/convertMessagesForAPI.js +2 -2
- package/dist/utils/editUtils.d.ts.map +1 -1
- package/dist/utils/editUtils.js +2 -2
- package/dist/utils/gitUtils.d.ts +7 -0
- package/dist/utils/gitUtils.d.ts.map +1 -0
- package/dist/utils/gitUtils.js +24 -0
- package/dist/utils/messageOperations.d.ts +3 -58
- package/dist/utils/messageOperations.d.ts.map +1 -1
- package/dist/utils/messageOperations.js +4 -146
- package/dist/utils/nameGenerator.d.ts +1 -1
- package/dist/utils/nameGenerator.d.ts.map +1 -1
- package/dist/utils/nameGenerator.js +19 -3
- package/package.json +1 -1
- package/src/agent.ts +86 -183
- package/src/constants/subagents.ts +4 -0
- package/src/constants/tools.ts +4 -1
- package/src/index.ts +1 -0
- package/src/managers/aiManager.ts +63 -70
- package/src/managers/backgroundTaskManager.ts +58 -54
- package/src/managers/foregroundTaskManager.ts +3 -2
- package/src/managers/mcpManager.ts +6 -3
- package/src/managers/messageManager.ts +126 -142
- package/src/managers/permissionManager.ts +32 -21
- package/src/managers/planManager.ts +2 -2
- package/src/managers/reversionManager.ts +26 -2
- package/src/managers/slashCommandManager.ts +12 -3
- package/src/managers/subagentManager.ts +60 -144
- package/src/managers/toolManager.ts +32 -2
- package/src/prompts/index.ts +366 -0
- package/src/services/aiService.ts +3 -145
- package/src/services/memory.ts +0 -72
- package/src/services/session.ts +73 -0
- package/src/services/taskManager.ts +195 -0
- package/src/tools/askUserQuestion.ts +51 -29
- package/src/tools/bashTool.ts +15 -17
- package/src/tools/editTool.ts +3 -1
- package/src/tools/exitPlanMode.ts +27 -3
- package/src/tools/globTool.ts +10 -2
- package/src/tools/grepTool.ts +17 -6
- package/src/tools/lsTool.ts +3 -1
- package/src/tools/readTool.ts +17 -1
- package/src/tools/taskManagementTools.ts +516 -0
- package/src/tools/taskOutputTool.ts +34 -12
- package/src/tools/taskStopTool.ts +7 -1
- package/src/tools/taskTool.ts +45 -1
- package/src/tools/types.ts +12 -0
- package/src/tools/writeTool.ts +9 -2
- package/src/types/index.ts +1 -0
- package/src/types/messaging.ts +1 -21
- package/src/types/processes.ts +18 -7
- package/src/types/tasks.ts +13 -0
- package/src/types/tools.ts +4 -1
- package/src/utils/builtinSubagents.ts +81 -45
- package/src/utils/cacheControlUtils.ts +26 -18
- package/src/utils/constants.ts +0 -5
- package/src/utils/convertMessagesForAPI.ts +2 -2
- package/src/utils/editUtils.ts +2 -6
- package/src/utils/gitUtils.ts +24 -0
- package/src/utils/messageOperations.ts +6 -229
- package/src/utils/nameGenerator.ts +20 -3
- package/dist/constants/prompts.d.ts.map +0 -1
- package/dist/constants/prompts.js +0 -118
- package/dist/tools/todoWriteTool.d.ts +0 -6
- package/dist/tools/todoWriteTool.d.ts.map +0 -1
- package/dist/tools/todoWriteTool.js +0 -220
- package/src/constants/prompts.ts +0 -155
- package/src/tools/todoWriteTool.ts +0 -257
package/dist/tools/grepTool.js
CHANGED
|
@@ -12,7 +12,7 @@ export const grepTool = {
|
|
|
12
12
|
type: "function",
|
|
13
13
|
function: {
|
|
14
14
|
name: GREP_TOOL_NAME,
|
|
15
|
-
description:
|
|
15
|
+
description: "A powerful search tool built on ripgrep",
|
|
16
16
|
parameters: {
|
|
17
17
|
type: "object",
|
|
18
18
|
properties: {
|
|
@@ -47,7 +47,7 @@ export const grepTool = {
|
|
|
47
47
|
},
|
|
48
48
|
"-n": {
|
|
49
49
|
type: "boolean",
|
|
50
|
-
description: 'Show line numbers in output (rg -n). Requires output_mode: "content", ignored otherwise.',
|
|
50
|
+
description: 'Show line numbers in output (rg -n). Requires output_mode: "content", ignored otherwise. Defaults to true.',
|
|
51
51
|
},
|
|
52
52
|
"-i": {
|
|
53
53
|
type: "boolean",
|
|
@@ -59,7 +59,7 @@ export const grepTool = {
|
|
|
59
59
|
},
|
|
60
60
|
head_limit: {
|
|
61
61
|
type: "number",
|
|
62
|
-
description: 'Limit output to first N lines/entries, equivalent to "| head -N". Works across all output modes: content (limits output lines), files_with_matches (limits file paths), count (limits count entries). Defaults to
|
|
62
|
+
description: 'Limit output to first N lines/entries, equivalent to "| head -N". Works across all output modes: content (limits output lines), files_with_matches (limits file paths), count (limits count entries). Defaults to 0 (unlimited).',
|
|
63
63
|
},
|
|
64
64
|
multiline: {
|
|
65
65
|
type: "boolean",
|
|
@@ -70,6 +70,17 @@ export const grepTool = {
|
|
|
70
70
|
},
|
|
71
71
|
},
|
|
72
72
|
},
|
|
73
|
+
prompt: () => `A powerful search tool built on ripgrep
|
|
74
|
+
|
|
75
|
+
Usage:
|
|
76
|
+
- ALWAYS use ${GREP_TOOL_NAME} for search tasks. NEVER invoke \`grep\` or \`rg\` as a ${BASH_TOOL_NAME} command. The ${GREP_TOOL_NAME} tool has been optimized for correct permissions and access.
|
|
77
|
+
- Supports full regex syntax (e.g., "log.*Error", "function\\s+\\w+")
|
|
78
|
+
- Filter files with glob parameter (e.g., "*.js", "**/*.tsx") or type parameter (e.g., "js", "py", "rust")
|
|
79
|
+
- Output modes: "content" shows matching lines, "files_with_matches" shows only file paths (default), "count" shows match counts
|
|
80
|
+
- Use ${TASK_TOOL_NAME} tool for open-ended searches requiring multiple rounds
|
|
81
|
+
- Pattern syntax: Uses ripgrep (not grep) - literal braces need escaping (use \`interface\\{\\}\` to find \`interface{}\` in Go code)
|
|
82
|
+
- Multiline matching: By default patterns match within single lines only. For cross-line patterns like \`struct \\{[\\s\\S]*?field\`, use \`multiline: true\`
|
|
83
|
+
`,
|
|
73
84
|
execute: async (args, context) => {
|
|
74
85
|
const pattern = args.pattern;
|
|
75
86
|
const searchPath = args.path;
|
|
@@ -78,7 +89,7 @@ export const grepTool = {
|
|
|
78
89
|
const contextBefore = args["-B"];
|
|
79
90
|
const contextAfter = args["-A"];
|
|
80
91
|
const contextAround = args["-C"];
|
|
81
|
-
const showLineNumbers = args["-n"];
|
|
92
|
+
const showLineNumbers = args["-n"] !== false;
|
|
82
93
|
const caseInsensitive = args["-i"];
|
|
83
94
|
const fileType = args.type;
|
|
84
95
|
const headLimit = args.head_limit;
|
|
@@ -181,8 +192,8 @@ export const grepTool = {
|
|
|
181
192
|
let finalOutput = output;
|
|
182
193
|
let lines = output.split("\n");
|
|
183
194
|
// Set default head_limit if not specified to prevent excessive token usage
|
|
184
|
-
const effectiveHeadLimit = headLimit ||
|
|
185
|
-
if (lines.length > effectiveHeadLimit) {
|
|
195
|
+
const effectiveHeadLimit = headLimit || 0;
|
|
196
|
+
if (effectiveHeadLimit > 0 && lines.length > effectiveHeadLimit) {
|
|
186
197
|
lines = lines.slice(0, effectiveHeadLimit);
|
|
187
198
|
finalOutput = lines.join("\n");
|
|
188
199
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lsTool.d.ts","sourceRoot":"","sources":["../../src/tools/lsTool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AAQtE;;GAEG;AACH,eAAO,MAAM,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"lsTool.d.ts","sourceRoot":"","sources":["../../src/tools/lsTool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AAQtE;;GAEG;AACH,eAAO,MAAM,MAAM,EAAE,UAqMpB,CAAC"}
|
package/dist/tools/lsTool.js
CHANGED
|
@@ -12,7 +12,7 @@ export const lsTool = {
|
|
|
12
12
|
type: "function",
|
|
13
13
|
function: {
|
|
14
14
|
name: LS_TOOL_NAME,
|
|
15
|
-
description:
|
|
15
|
+
description: "Lists files and directories in a given path.",
|
|
16
16
|
parameters: {
|
|
17
17
|
type: "object",
|
|
18
18
|
properties: {
|
|
@@ -32,6 +32,8 @@ export const lsTool = {
|
|
|
32
32
|
},
|
|
33
33
|
},
|
|
34
34
|
},
|
|
35
|
+
prompt: () => `
|
|
36
|
+
Lists files and directories in a given path. The path parameter must be an absolute path, not a relative path. You can optionally provide an array of glob patterns to ignore with the ignore parameter. You should generally prefer the ${GLOB_TOOL_NAME} and ${GREP_TOOL_NAME} tools, if you know which directories to search.`,
|
|
35
37
|
execute: async (args, context) => {
|
|
36
38
|
const targetPath = args.path;
|
|
37
39
|
const ignorePatterns = args.ignore;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readTool.d.ts","sourceRoot":"","sources":["../../src/tools/readTool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AA6HtE;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"readTool.d.ts","sourceRoot":"","sources":["../../src/tools/readTool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AA6HtE;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,UAkOtB,CAAC"}
|
package/dist/tools/readTool.js
CHANGED
|
@@ -113,11 +113,26 @@ async function processImageFile(filePath, context) {
|
|
|
113
113
|
*/
|
|
114
114
|
export const readTool = {
|
|
115
115
|
name: READ_TOOL_NAME,
|
|
116
|
+
prompt: () => `Reads a file from the local filesystem. You can access any file directly by using this tool.
|
|
117
|
+
Assume this tool is able to read all files on the machine. If the User provides a path to a file assume that path is valid. It is okay to read a file that does not exist; an error will be returned.
|
|
118
|
+
|
|
119
|
+
Usage:
|
|
120
|
+
- The file_path parameter must be an absolute path, not a relative path
|
|
121
|
+
- By default, it reads up to 2000 lines starting from the beginning of the file
|
|
122
|
+
- You can optionally specify a line offset and limit (especially handy for long files), but it's recommended to read the whole file by not providing these parameters
|
|
123
|
+
- Any lines longer than 2000 characters will be truncated
|
|
124
|
+
- Results are returned using cat -n format, with line numbers starting at 1
|
|
125
|
+
- This tool allows Agent to read images (eg PNG, JPG, etc). When reading an image file the contents are presented visually as Agent is a multimodal LLM.
|
|
126
|
+
- This tool can read Jupyter notebooks (.ipynb files) and returns all cells with their outputs, combining code, text, and visualizations.
|
|
127
|
+
- You have the capability to call multiple tools in a single response. It is always better to speculatively read multiple files as a batch that are potentially useful.
|
|
128
|
+
- You will regularly be asked to read screenshots. If the user provides a path to a screenshot ALWAYS use this tool to view the file at the path. This tool will work with all temporary file paths like /var/folders/123/abc/T/TemporaryItems/NSIRD_screencaptureui_ZfB1tD/Screenshot.png
|
|
129
|
+
- If you read a file that exists but has empty contents you will receive a system reminder warning in place of file contents.
|
|
130
|
+
- Binary document formats (PDF, DOC, DOCX, XLS, XLSX, PPT, PPTX) are not supported and will return an error.`,
|
|
116
131
|
config: {
|
|
117
132
|
type: "function",
|
|
118
133
|
function: {
|
|
119
134
|
name: READ_TOOL_NAME,
|
|
120
|
-
description:
|
|
135
|
+
description: "Read a file from the local filesystem.",
|
|
121
136
|
parameters: {
|
|
122
137
|
type: "object",
|
|
123
138
|
properties: {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ToolPlugin } from "./types.js";
|
|
2
|
+
export declare const taskCreateTool: ToolPlugin;
|
|
3
|
+
export declare const taskGetTool: ToolPlugin;
|
|
4
|
+
export declare const taskUpdateTool: ToolPlugin;
|
|
5
|
+
export declare const taskListTool: ToolPlugin;
|
|
6
|
+
//# sourceMappingURL=taskManagementTools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taskManagementTools.d.ts","sourceRoot":"","sources":["../../src/tools/taskManagementTools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AASjE,eAAO,MAAM,cAAc,EAAE,UA0H5B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,UAyDzB,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,UA+P5B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,UAkE1B,CAAC"}
|
|
@@ -0,0 +1,461 @@
|
|
|
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
|
+
if (context.reversionManager && context.messageId) {
|
|
106
|
+
const taskPath = taskManager.getTaskPath(taskId);
|
|
107
|
+
await context.reversionManager.recordSnapshot(context.messageId, taskPath, "create");
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
success: true,
|
|
111
|
+
content: `Task created with ID: ${taskId}`,
|
|
112
|
+
shortResult: `Created task ${taskId}: ${task.subject}`,
|
|
113
|
+
};
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
export const taskGetTool = {
|
|
117
|
+
name: TASK_GET_TOOL_NAME,
|
|
118
|
+
config: {
|
|
119
|
+
type: "function",
|
|
120
|
+
function: {
|
|
121
|
+
name: TASK_GET_TOOL_NAME,
|
|
122
|
+
description: "Get a task by ID from the task list",
|
|
123
|
+
parameters: {
|
|
124
|
+
type: "object",
|
|
125
|
+
properties: {
|
|
126
|
+
taskId: {
|
|
127
|
+
type: "string",
|
|
128
|
+
description: "The ID of the task to retrieve",
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
required: ["taskId"],
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
prompt: () => `Use this tool to retrieve a task by its ID from the task list.
|
|
136
|
+
|
|
137
|
+
## When to Use This Tool
|
|
138
|
+
|
|
139
|
+
- When you need the full description and context before starting work on a task
|
|
140
|
+
- To understand task dependencies (what it blocks, what blocks it)
|
|
141
|
+
- After being assigned a task, to get complete requirements
|
|
142
|
+
|
|
143
|
+
## Output
|
|
144
|
+
|
|
145
|
+
Returns full task details:
|
|
146
|
+
- **subject**: Task title
|
|
147
|
+
- **description**: Detailed requirements and context
|
|
148
|
+
- **status**: 'pending', 'in_progress', or 'completed'
|
|
149
|
+
- **blocks**: Tasks waiting on this one to complete
|
|
150
|
+
- **blockedBy**: Tasks that must complete before this one can start
|
|
151
|
+
|
|
152
|
+
## Tips
|
|
153
|
+
|
|
154
|
+
- After fetching a task, verify its blockedBy list is empty before beginning work.
|
|
155
|
+
- Use TaskList to see all tasks in summary form.`,
|
|
156
|
+
execute: async (args, context) => {
|
|
157
|
+
const taskManager = context.taskManager;
|
|
158
|
+
const taskId = args.taskId;
|
|
159
|
+
const task = await taskManager.getTask(taskId);
|
|
160
|
+
if (!task) {
|
|
161
|
+
return {
|
|
162
|
+
success: false,
|
|
163
|
+
content: `Task with ID ${taskId} not found.`,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
success: true,
|
|
168
|
+
content: JSON.stringify(task, null, 2),
|
|
169
|
+
};
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
export const taskUpdateTool = {
|
|
173
|
+
name: TASK_UPDATE_TOOL_NAME,
|
|
174
|
+
config: {
|
|
175
|
+
type: "function",
|
|
176
|
+
function: {
|
|
177
|
+
name: TASK_UPDATE_TOOL_NAME,
|
|
178
|
+
description: "Update a task in the task list",
|
|
179
|
+
parameters: {
|
|
180
|
+
type: "object",
|
|
181
|
+
properties: {
|
|
182
|
+
taskId: {
|
|
183
|
+
type: "string",
|
|
184
|
+
description: "The ID of the task to update",
|
|
185
|
+
},
|
|
186
|
+
subject: {
|
|
187
|
+
type: "string",
|
|
188
|
+
description: "New subject for the task",
|
|
189
|
+
},
|
|
190
|
+
description: {
|
|
191
|
+
type: "string",
|
|
192
|
+
description: "New description for the task",
|
|
193
|
+
},
|
|
194
|
+
activeForm: {
|
|
195
|
+
type: "string",
|
|
196
|
+
description: 'Present continuous form shown in spinner when in_progress (e.g., "Running tests")',
|
|
197
|
+
},
|
|
198
|
+
status: {
|
|
199
|
+
type: "string",
|
|
200
|
+
enum: ["pending", "in_progress", "completed", "deleted"],
|
|
201
|
+
description: "New status for the task",
|
|
202
|
+
},
|
|
203
|
+
addBlocks: {
|
|
204
|
+
type: "array",
|
|
205
|
+
items: { type: "string" },
|
|
206
|
+
description: "Task IDs that this task blocks",
|
|
207
|
+
},
|
|
208
|
+
addBlockedBy: {
|
|
209
|
+
type: "array",
|
|
210
|
+
items: { type: "string" },
|
|
211
|
+
description: "Task IDs that block this task",
|
|
212
|
+
},
|
|
213
|
+
owner: {
|
|
214
|
+
type: "string",
|
|
215
|
+
description: "New owner for the task",
|
|
216
|
+
},
|
|
217
|
+
metadata: {
|
|
218
|
+
type: "object",
|
|
219
|
+
description: "Metadata keys to merge into the task. Set a key to null to delete it.",
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
required: ["taskId"],
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
prompt: () => `Use this tool to update a task in the task list.
|
|
227
|
+
|
|
228
|
+
## When to Use This Tool
|
|
229
|
+
|
|
230
|
+
**Mark tasks as resolved:**
|
|
231
|
+
- When you have completed the work described in a task
|
|
232
|
+
- When a task is no longer needed or has been superseded
|
|
233
|
+
- IMPORTANT: Always mark your assigned tasks as resolved when you finish them
|
|
234
|
+
- After resolving, call TaskList to find your next task
|
|
235
|
+
|
|
236
|
+
- ONLY mark a task as completed when you have FULLY accomplished it
|
|
237
|
+
- If you encounter errors, blockers, or cannot finish, keep the task as in_progress
|
|
238
|
+
- When blocked, create a new task describing what needs to be resolved
|
|
239
|
+
- Never mark a task as completed if:
|
|
240
|
+
- Tests are failing
|
|
241
|
+
- Implementation is partial
|
|
242
|
+
- You encountered unresolved errors
|
|
243
|
+
- You couldn't find necessary files or dependencies
|
|
244
|
+
|
|
245
|
+
**Delete tasks:**
|
|
246
|
+
- When a task is no longer relevant or was created in error
|
|
247
|
+
- Setting status to \`deleted\` permanently removes the task
|
|
248
|
+
|
|
249
|
+
**Update task details:**
|
|
250
|
+
- When requirements change or become clearer
|
|
251
|
+
- When establishing dependencies between tasks
|
|
252
|
+
|
|
253
|
+
## Fields You Can Update
|
|
254
|
+
|
|
255
|
+
- **status**: The task status (see Status Workflow below)
|
|
256
|
+
- **subject**: Change the task title (imperative form, e.g., "Run tests")
|
|
257
|
+
- **description**: Change the task description
|
|
258
|
+
- **activeForm**: Present continuous form shown in spinner when in_progress (e.g., "Running tests")
|
|
259
|
+
- **owner**: Change the task owner (agent name)
|
|
260
|
+
- **metadata**: Merge metadata keys into the task (set a key to null to delete it)
|
|
261
|
+
- **addBlocks**: Mark tasks that cannot start until this one completes
|
|
262
|
+
- **addBlockedBy**: Mark tasks that must complete before this one can start
|
|
263
|
+
|
|
264
|
+
## Status Workflow
|
|
265
|
+
|
|
266
|
+
Status progresses: \`pending\` → \`in_progress\` → \`completed\`
|
|
267
|
+
|
|
268
|
+
Use \`deleted\` to permanently remove a task.
|
|
269
|
+
|
|
270
|
+
## Staleness
|
|
271
|
+
|
|
272
|
+
Make sure to read a task's latest state using \`TaskGet\` before updating it.
|
|
273
|
+
|
|
274
|
+
## Examples
|
|
275
|
+
|
|
276
|
+
Mark task as in progress when starting work:
|
|
277
|
+
\`\`\`json
|
|
278
|
+
{"taskId": "1", "status": "in_progress"}
|
|
279
|
+
\`\`\`
|
|
280
|
+
|
|
281
|
+
Mark task as completed after finishing work:
|
|
282
|
+
\`\`\`json
|
|
283
|
+
{"taskId": "1", "status": "completed"}
|
|
284
|
+
\`\`\`
|
|
285
|
+
|
|
286
|
+
Delete a task:
|
|
287
|
+
\`\`\`json
|
|
288
|
+
{"taskId": "1", "status": "deleted"}
|
|
289
|
+
\`\`\`
|
|
290
|
+
|
|
291
|
+
Claim a task by setting owner:
|
|
292
|
+
\`\`\`json
|
|
293
|
+
{"taskId": "1", "owner": "my-name"}
|
|
294
|
+
\`\`\`
|
|
295
|
+
|
|
296
|
+
Set up task dependencies:
|
|
297
|
+
\`\`\`json
|
|
298
|
+
{"taskId": "2", "addBlockedBy": ["1"]}
|
|
299
|
+
\`\`\`
|
|
300
|
+
`,
|
|
301
|
+
execute: async (args, context) => {
|
|
302
|
+
const taskManager = context.taskManager;
|
|
303
|
+
const taskId = args.taskId;
|
|
304
|
+
const existingTask = await taskManager.getTask(taskId);
|
|
305
|
+
if (!existingTask) {
|
|
306
|
+
return {
|
|
307
|
+
success: false,
|
|
308
|
+
content: `Task with ID ${taskId} not found.`,
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
if (context.reversionManager && context.messageId) {
|
|
312
|
+
const taskPath = taskManager.getTaskPath(taskId);
|
|
313
|
+
await context.reversionManager.recordSnapshot(context.messageId, taskPath, "modify");
|
|
314
|
+
}
|
|
315
|
+
const updatedFields = [];
|
|
316
|
+
const updatedTask = {
|
|
317
|
+
...existingTask,
|
|
318
|
+
};
|
|
319
|
+
if (args.subject !== undefined && args.subject !== existingTask.subject) {
|
|
320
|
+
updatedTask.subject = args.subject;
|
|
321
|
+
updatedFields.push("subject");
|
|
322
|
+
}
|
|
323
|
+
if (args.description !== undefined &&
|
|
324
|
+
args.description !== existingTask.description) {
|
|
325
|
+
updatedTask.description = args.description;
|
|
326
|
+
updatedFields.push("description");
|
|
327
|
+
}
|
|
328
|
+
if (args.status !== undefined && args.status !== existingTask.status) {
|
|
329
|
+
updatedTask.status = args.status;
|
|
330
|
+
updatedFields.push("status");
|
|
331
|
+
}
|
|
332
|
+
if (args.activeForm !== undefined &&
|
|
333
|
+
args.activeForm !== existingTask.activeForm) {
|
|
334
|
+
updatedTask.activeForm = args.activeForm;
|
|
335
|
+
updatedFields.push("activeForm");
|
|
336
|
+
}
|
|
337
|
+
if (args.owner !== undefined && args.owner !== existingTask.owner) {
|
|
338
|
+
updatedTask.owner = args.owner;
|
|
339
|
+
updatedFields.push("owner");
|
|
340
|
+
}
|
|
341
|
+
if (args.metadata !== undefined) {
|
|
342
|
+
const newMetadata = { ...(existingTask.metadata || {}) };
|
|
343
|
+
for (const [key, value] of Object.entries(args.metadata)) {
|
|
344
|
+
if (value === null) {
|
|
345
|
+
delete newMetadata[key];
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
newMetadata[key] = value;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
updatedTask.metadata = newMetadata;
|
|
352
|
+
updatedFields.push("metadata");
|
|
353
|
+
}
|
|
354
|
+
if (args.addBlocks !== undefined) {
|
|
355
|
+
const blocksToAdd = args.addBlocks.filter((id) => !updatedTask.blocks.includes(id));
|
|
356
|
+
if (blocksToAdd.length > 0) {
|
|
357
|
+
updatedTask.blocks = [...updatedTask.blocks, ...blocksToAdd];
|
|
358
|
+
updatedFields.push("blocks");
|
|
359
|
+
// Also update the blockedBy of the target tasks
|
|
360
|
+
for (const targetId of blocksToAdd) {
|
|
361
|
+
const targetTask = await taskManager.getTask(targetId);
|
|
362
|
+
if (targetTask && !targetTask.blockedBy.includes(taskId)) {
|
|
363
|
+
await taskManager.updateTask({
|
|
364
|
+
...targetTask,
|
|
365
|
+
blockedBy: [...targetTask.blockedBy, taskId],
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
if (args.addBlockedBy !== undefined) {
|
|
372
|
+
const blockedByToAdd = args.addBlockedBy.filter((id) => !updatedTask.blockedBy.includes(id));
|
|
373
|
+
if (blockedByToAdd.length > 0) {
|
|
374
|
+
updatedTask.blockedBy = [...updatedTask.blockedBy, ...blockedByToAdd];
|
|
375
|
+
updatedFields.push("blockedBy");
|
|
376
|
+
// Also update the blocks of the target tasks
|
|
377
|
+
for (const targetId of blockedByToAdd) {
|
|
378
|
+
const targetTask = await taskManager.getTask(targetId);
|
|
379
|
+
if (targetTask && !targetTask.blocks.includes(taskId)) {
|
|
380
|
+
await taskManager.updateTask({
|
|
381
|
+
...targetTask,
|
|
382
|
+
blocks: [...targetTask.blocks, taskId],
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
await taskManager.updateTask(updatedTask);
|
|
389
|
+
let content = `Updated task #${taskId} ${updatedFields.join(", ")}`;
|
|
390
|
+
if (updatedTask.status === "completed") {
|
|
391
|
+
content += `\n\nTask completed. Call TaskList now to find your next available task or see if your work unblocked others.`;
|
|
392
|
+
}
|
|
393
|
+
return {
|
|
394
|
+
success: true,
|
|
395
|
+
content,
|
|
396
|
+
shortResult: `Updated task ${taskId}`,
|
|
397
|
+
};
|
|
398
|
+
},
|
|
399
|
+
};
|
|
400
|
+
export const taskListTool = {
|
|
401
|
+
name: TASK_LIST_TOOL_NAME,
|
|
402
|
+
config: {
|
|
403
|
+
type: "function",
|
|
404
|
+
function: {
|
|
405
|
+
name: TASK_LIST_TOOL_NAME,
|
|
406
|
+
description: "List all tasks in the task list",
|
|
407
|
+
parameters: {
|
|
408
|
+
type: "object",
|
|
409
|
+
properties: {
|
|
410
|
+
status: {
|
|
411
|
+
type: "string",
|
|
412
|
+
enum: ["pending", "in_progress", "completed", "deleted"],
|
|
413
|
+
description: "Optional filter by status.",
|
|
414
|
+
},
|
|
415
|
+
},
|
|
416
|
+
},
|
|
417
|
+
},
|
|
418
|
+
},
|
|
419
|
+
prompt: () => `Use this tool to list all tasks in the task list.
|
|
420
|
+
|
|
421
|
+
## When to Use This Tool
|
|
422
|
+
|
|
423
|
+
- To see what tasks are available to work on (status: 'pending', no owner, not blocked)
|
|
424
|
+
- To check overall progress on the project
|
|
425
|
+
- To find tasks that are blocked and need dependencies resolved
|
|
426
|
+
- After completing a task, to check for newly unblocked work or claim the next available task
|
|
427
|
+
- **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
|
|
428
|
+
|
|
429
|
+
## Output
|
|
430
|
+
|
|
431
|
+
Returns a summary of each task:
|
|
432
|
+
- **id**: Task identifier (use with TaskGet, TaskUpdate)
|
|
433
|
+
- **subject**: Brief description of the task
|
|
434
|
+
- **status**: 'pending', 'in_progress', or 'completed'
|
|
435
|
+
- **owner**: Agent ID if assigned, empty if available
|
|
436
|
+
- **blockedBy**: List of open task IDs that must be resolved first (tasks with blockedBy cannot be claimed until dependencies resolve)
|
|
437
|
+
|
|
438
|
+
Use TaskGet with a specific task ID to view full details including description and comments.`,
|
|
439
|
+
execute: async (args, context) => {
|
|
440
|
+
const taskManager = context.taskManager;
|
|
441
|
+
let tasks = await taskManager.listTasks();
|
|
442
|
+
if (args.status) {
|
|
443
|
+
tasks = tasks.filter((t) => t.status === args.status);
|
|
444
|
+
}
|
|
445
|
+
if (tasks.length === 0) {
|
|
446
|
+
return {
|
|
447
|
+
success: true,
|
|
448
|
+
content: "No tasks found.",
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
// Sort by ID numerically
|
|
452
|
+
tasks.sort((a, b) => parseInt(a.id, 10) - parseInt(b.id, 10));
|
|
453
|
+
const content = tasks
|
|
454
|
+
.map((t) => `[${t.id}] ${t.subject} (${t.status})`)
|
|
455
|
+
.join("\n");
|
|
456
|
+
return {
|
|
457
|
+
success: true,
|
|
458
|
+
content,
|
|
459
|
+
};
|
|
460
|
+
},
|
|
461
|
+
};
|
|
@@ -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,
|
|
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"}
|