wave-agent-sdk 0.8.3 → 0.8.4
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.js +2 -2
- package/dist/constants/tools.d.ts +1 -2
- package/dist/constants/tools.d.ts.map +1 -1
- package/dist/constants/tools.js +1 -2
- package/dist/managers/permissionManager.d.ts.map +1 -1
- package/dist/managers/permissionManager.js +2 -7
- package/dist/managers/subagentManager.d.ts +3 -3
- package/dist/managers/subagentManager.d.ts.map +1 -1
- package/dist/managers/subagentManager.js +13 -12
- package/dist/managers/toolManager.d.ts +2 -2
- package/dist/managers/toolManager.d.ts.map +1 -1
- package/dist/managers/toolManager.js +4 -6
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +3 -3
- package/dist/tools/agentTool.d.ts +6 -0
- package/dist/tools/agentTool.d.ts.map +1 -0
- package/dist/tools/{taskTool.js → agentTool.js} +42 -30
- package/dist/tools/grepTool.js +2 -2
- package/dist/tools/skillTool.js +2 -2
- package/dist/tools/types.d.ts +1 -1
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/utils/builtinSubagents.d.ts.map +1 -1
- package/dist/utils/builtinSubagents.js +1 -3
- package/dist/utils/gitUtils.d.ts.map +1 -1
- package/dist/utils/gitUtils.js +47 -1
- package/dist/utils/path.d.ts +0 -10
- package/dist/utils/path.d.ts.map +1 -1
- package/dist/utils/path.js +0 -61
- package/package.json +1 -1
- package/src/agent.ts +2 -2
- package/src/constants/tools.ts +1 -2
- package/src/managers/permissionManager.ts +1 -7
- package/src/managers/subagentManager.ts +13 -12
- package/src/managers/toolManager.ts +4 -6
- package/src/prompts/index.ts +3 -2
- package/src/tools/{taskTool.ts → agentTool.ts} +42 -30
- package/src/tools/grepTool.ts +2 -2
- package/src/tools/skillTool.ts +2 -2
- package/src/tools/types.ts +1 -1
- package/src/utils/builtinSubagents.ts +0 -3
- package/src/utils/gitUtils.ts +48 -1
- package/src/utils/path.ts +0 -62
- package/dist/tools/lsTool.d.ts +0 -6
- package/dist/tools/lsTool.d.ts.map +0 -1
- package/dist/tools/lsTool.js +0 -175
- package/dist/tools/taskTool.d.ts +0 -6
- package/dist/tools/taskTool.d.ts.map +0 -1
- package/src/tools/lsTool.ts +0 -212
package/dist/agent.js
CHANGED
|
@@ -280,7 +280,7 @@ export class Agent {
|
|
|
280
280
|
}
|
|
281
281
|
/** Unified interrupt method, interrupts both AI messages and command execution */
|
|
282
282
|
abortMessage() {
|
|
283
|
-
this.abortAIMessage(); // This will abort tools including
|
|
283
|
+
this.abortAIMessage(); // This will abort tools including Agent tool (subagents)
|
|
284
284
|
this.abortBashCommand();
|
|
285
285
|
this.abortSlashCommand();
|
|
286
286
|
}
|
|
@@ -314,7 +314,7 @@ export class Agent {
|
|
|
314
314
|
/** Destroy managers, clean up resources */
|
|
315
315
|
async destroy() {
|
|
316
316
|
await this.messageManager.saveSession();
|
|
317
|
-
this.abortAIMessage(); // This will abort tools including
|
|
317
|
+
this.abortAIMessage(); // This will abort tools including Agent tool (subagents)
|
|
318
318
|
this.abortBashCommand();
|
|
319
319
|
this.abortSlashCommand();
|
|
320
320
|
// Cleanup background task manager
|
|
@@ -7,10 +7,9 @@ export declare const EXIT_PLAN_MODE_TOOL_NAME = "ExitPlanMode";
|
|
|
7
7
|
export declare const GLOB_TOOL_NAME = "Glob";
|
|
8
8
|
export declare const GREP_TOOL_NAME = "Grep";
|
|
9
9
|
export declare const LSP_TOOL_NAME = "LSP";
|
|
10
|
-
export declare const LS_TOOL_NAME = "LS";
|
|
11
10
|
export declare const READ_TOOL_NAME = "Read";
|
|
12
11
|
export declare const SKILL_TOOL_NAME = "Skill";
|
|
13
|
-
export declare const
|
|
12
|
+
export declare const AGENT_TOOL_NAME = "Agent";
|
|
14
13
|
export declare const TASK_CREATE_TOOL_NAME = "TaskCreate";
|
|
15
14
|
export declare const TASK_GET_TOOL_NAME = "TaskGet";
|
|
16
15
|
export declare const TASK_UPDATE_TOOL_NAME = "TaskUpdate";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/constants/tools.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,2BAA2B,oBAAoB,CAAC;AAC7D,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,qBAAqB,eAAe,CAAC;AAClD,eAAO,MAAM,mBAAmB,aAAa,CAAC;AAC9C,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,wBAAwB,iBAAiB,CAAC;AACvD,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,aAAa,QAAQ,CAAC;AACnC,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/constants/tools.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,2BAA2B,oBAAoB,CAAC;AAC7D,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,qBAAqB,eAAe,CAAC;AAClD,eAAO,MAAM,mBAAmB,aAAa,CAAC;AAC9C,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,wBAAwB,iBAAiB,CAAC;AACvD,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,aAAa,QAAQ,CAAC;AACnC,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,eAAe,UAAU,CAAC;AACvC,eAAO,MAAM,eAAe,UAAU,CAAC;AACvC,eAAO,MAAM,qBAAqB,eAAe,CAAC;AAClD,eAAO,MAAM,kBAAkB,YAAY,CAAC;AAC5C,eAAO,MAAM,qBAAqB,eAAe,CAAC;AAClD,eAAO,MAAM,mBAAmB,aAAa,CAAC;AAC9C,eAAO,MAAM,eAAe,UAAU,CAAC"}
|
package/dist/constants/tools.js
CHANGED
|
@@ -7,10 +7,9 @@ export const EXIT_PLAN_MODE_TOOL_NAME = "ExitPlanMode";
|
|
|
7
7
|
export const GLOB_TOOL_NAME = "Glob";
|
|
8
8
|
export const GREP_TOOL_NAME = "Grep";
|
|
9
9
|
export const LSP_TOOL_NAME = "LSP";
|
|
10
|
-
export const LS_TOOL_NAME = "LS";
|
|
11
10
|
export const READ_TOOL_NAME = "Read";
|
|
12
11
|
export const SKILL_TOOL_NAME = "Skill";
|
|
13
|
-
export const
|
|
12
|
+
export const AGENT_TOOL_NAME = "Agent";
|
|
14
13
|
export const TASK_CREATE_TOOL_NAME = "TaskCreate";
|
|
15
14
|
export const TASK_GET_TOOL_NAME = "TaskGet";
|
|
16
15
|
export const TASK_UPDATE_TOOL_NAME = "TaskUpdate";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissionManager.d.ts","sourceRoot":"","sources":["../../src/managers/permissionManager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"permissionManager.d.ts","sourceRoot":"","sources":["../../src/managers/permissionManager.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EAClB,cAAc,EACf,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAgBhD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AA8BlD,MAAM,WAAW,wBAAwB;IACvC,uDAAuD;IACvD,qBAAqB,CAAC,EAAE,cAAc,CAAC;IACvC,kCAAkC;IAClC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,iCAAiC;IACjC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{ splitBashCommand, stripEnvVars, stripRedirections, hasWriteRedirections, getSmartPrefix, DANGEROUS_COMMANDS, } from "../utils/bashParser.js";
|
|
12
12
|
import { isPathInside } from "../utils/pathSafety.js";
|
|
13
|
-
import { BASH_TOOL_NAME, EDIT_TOOL_NAME, WRITE_TOOL_NAME, READ_TOOL_NAME,
|
|
13
|
+
import { BASH_TOOL_NAME, EDIT_TOOL_NAME, WRITE_TOOL_NAME, READ_TOOL_NAME, } from "../constants/tools.js";
|
|
14
14
|
const SAFE_COMMANDS = ["cd", "ls", "pwd", "true", "false"];
|
|
15
15
|
const DEFAULT_ALLOWED_RULES = [
|
|
16
16
|
"Bash(git status*)",
|
|
@@ -413,12 +413,7 @@ export class PermissionManager {
|
|
|
413
413
|
return matched;
|
|
414
414
|
}
|
|
415
415
|
// Handle path-based rules (e.g., "Read(**/*.env)")
|
|
416
|
-
const pathTools = [
|
|
417
|
-
READ_TOOL_NAME,
|
|
418
|
-
WRITE_TOOL_NAME,
|
|
419
|
-
EDIT_TOOL_NAME,
|
|
420
|
-
LS_TOOL_NAME,
|
|
421
|
-
];
|
|
416
|
+
const pathTools = [READ_TOOL_NAME, WRITE_TOOL_NAME, EDIT_TOOL_NAME];
|
|
422
417
|
if (pathTools.includes(toolName)) {
|
|
423
418
|
const targetPath = (context.toolInput?.file_path ||
|
|
424
419
|
context.toolInput?.path);
|
|
@@ -87,12 +87,12 @@ export declare class SubagentManager {
|
|
|
87
87
|
model?: string;
|
|
88
88
|
}, runInBackground?: boolean, onUpdate?: () => void): Promise<SubagentInstance>;
|
|
89
89
|
/**
|
|
90
|
-
* Execute
|
|
90
|
+
* Execute agent using subagent instance
|
|
91
91
|
*
|
|
92
|
-
* IMPORTANT: This method automatically filters out the
|
|
92
|
+
* IMPORTANT: This method automatically filters out the Agent tool from allowedTools
|
|
93
93
|
* to prevent subagents from spawning other subagents (infinite recursion protection)
|
|
94
94
|
*/
|
|
95
|
-
|
|
95
|
+
executeAgent(instance: SubagentInstance, prompt: string, abortSignal?: AbortSignal, runInBackground?: boolean): Promise<string>;
|
|
96
96
|
backgroundInstance(subagentId: string): Promise<string>;
|
|
97
97
|
private internalExecute;
|
|
98
98
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subagentManager.d.ts","sourceRoot":"","sources":["../../src/managers/subagentManager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,KAAK,EACV,OAAO,EACP,aAAa,EACb,WAAW,EACX,KAAK,EACN,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"subagentManager.d.ts","sourceRoot":"","sources":["../../src/managers/subagentManager.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,KAAK,EACV,OAAO,EACP,aAAa,EACb,WAAW,EACX,KAAK,EACN,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAQ/C,OAAO,EACL,iBAAiB,EACjB,KAAK,0BAA0B,EAChC,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGlD,MAAM,WAAW,wBAAwB;IAEvC,gDAAgD;IAChD,0BAA0B,CAAC,EAAE,CAC3B,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,iBAAiB,KACtB,IAAI,CAAC;IACV,wDAAwD;IACxD,+BAA+B,CAAC,EAAE,CAAC,UAAU,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,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,EACD,eAAe,CAAC,EAAE,OAAO,EACzB,QAAQ,CAAC,EAAE,MAAM,IAAI,GACpB,OAAO,CAAC,gBAAgB,CAAC;IAsH5B;;;;;OAKG;IACG,YAAY,CAChB,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,EAAE,MAAM,EACd,WAAW,CAAC,EAAE,WAAW,EACzB,eAAe,CAAC,EAAE,OAAO,GACxB,OAAO,CAAC,MAAM,CAAC;IAwEZ,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;YAqC/C,eAAe;IA2I7B;;OAEG;IACH,WAAW,CAAC,UAAU,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI;IAIxD;;OAEG;IACH,oBAAoB,CAClB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,gBAAgB,CAAC,QAAQ,CAAC,GACjC,IAAI;IAOP;;OAEG;IACH,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;IAOhE;;OAEG;IACH,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAYzC;;OAEG;IACH,kBAAkB,IAAI,gBAAgB,EAAE;IAOxC;;OAEG;IACH,OAAO,IAAI,IAAI;IAIf;;;OAGG;IACH,OAAO,CAAC,uBAAuB;CAqFhC"}
|
|
@@ -2,6 +2,7 @@ import { randomUUID } from "crypto";
|
|
|
2
2
|
import { AIManager } from "./aiManager.js";
|
|
3
3
|
import { MessageManager } from "./messageManager.js";
|
|
4
4
|
import { ToolManager } from "./toolManager.js";
|
|
5
|
+
import { AGENT_TOOL_NAME } from "../constants/tools.js";
|
|
5
6
|
import { addConsolidatedAbortListener, createAbortPromise, } from "../utils/abortUtils.js";
|
|
6
7
|
import { logger } from "../utils/globalLogger.js";
|
|
7
8
|
export class SubagentManager {
|
|
@@ -152,16 +153,16 @@ export class SubagentManager {
|
|
|
152
153
|
return instance;
|
|
153
154
|
}
|
|
154
155
|
/**
|
|
155
|
-
* Execute
|
|
156
|
+
* Execute agent using subagent instance
|
|
156
157
|
*
|
|
157
|
-
* IMPORTANT: This method automatically filters out the
|
|
158
|
+
* IMPORTANT: This method automatically filters out the Agent tool from allowedTools
|
|
158
159
|
* to prevent subagents from spawning other subagents (infinite recursion protection)
|
|
159
160
|
*/
|
|
160
|
-
async
|
|
161
|
+
async executeAgent(instance, prompt, abortSignal, runInBackground) {
|
|
161
162
|
try {
|
|
162
163
|
// Check if already aborted before starting
|
|
163
164
|
if (abortSignal?.aborted) {
|
|
164
|
-
throw new Error("
|
|
165
|
+
throw new Error("Agent was aborted before execution started");
|
|
165
166
|
}
|
|
166
167
|
// Set status to active and update parent
|
|
167
168
|
this.updateInstanceStatus(instance.subagentId, "active");
|
|
@@ -269,17 +270,17 @@ export class SubagentManager {
|
|
|
269
270
|
try {
|
|
270
271
|
// Add the user's prompt as a message
|
|
271
272
|
instance.messageManager.addUserMessage({ content: prompt });
|
|
272
|
-
// Create enabled tools list - always exclude
|
|
273
|
+
// Create enabled tools list - always exclude Agent tool to prevent subagent recursion
|
|
273
274
|
// Use instance.configuration.tools if provided, otherwise fallback to all tools
|
|
274
275
|
let enabledTools = instance.configuration.tools;
|
|
275
|
-
// Always filter out the
|
|
276
|
+
// Always filter out the Agent tool to prevent subagents from creating sub-subagents
|
|
276
277
|
if (enabledTools) {
|
|
277
|
-
enabledTools = enabledTools.filter((tool) => tool !==
|
|
278
|
+
enabledTools = enabledTools.filter((tool) => tool !== AGENT_TOOL_NAME);
|
|
278
279
|
}
|
|
279
280
|
else {
|
|
280
|
-
// If no tools specified, get all tools except
|
|
281
|
+
// If no tools specified, get all tools except Agent
|
|
281
282
|
const allTools = instance.toolManager.list().map((tool) => tool.name);
|
|
282
|
-
enabledTools = allTools.filter((tool) => tool !==
|
|
283
|
+
enabledTools = allTools.filter((tool) => tool !== AGENT_TOOL_NAME);
|
|
283
284
|
}
|
|
284
285
|
// Execute the AI request with tool restrictions
|
|
285
286
|
// The AIManager will handle abort signals through its own abort controllers
|
|
@@ -309,7 +310,7 @@ export class SubagentManager {
|
|
|
309
310
|
if (abortSignal && !instance.backgroundTaskId) {
|
|
310
311
|
await Promise.race([
|
|
311
312
|
executeAI,
|
|
312
|
-
createAbortPromise(abortSignal, "
|
|
313
|
+
createAbortPromise(abortSignal, "Agent was aborted"),
|
|
313
314
|
]);
|
|
314
315
|
}
|
|
315
316
|
else {
|
|
@@ -336,14 +337,14 @@ export class SubagentManager {
|
|
|
336
337
|
const task = backgroundTaskManager.getTask(instance.backgroundTaskId);
|
|
337
338
|
if (task) {
|
|
338
339
|
task.status = "completed";
|
|
339
|
-
task.stdout = response || "
|
|
340
|
+
task.stdout = response || "Agent completed with no text response";
|
|
340
341
|
task.endTime = Date.now();
|
|
341
342
|
if (task.startTime) {
|
|
342
343
|
task.runtime = task.endTime - task.startTime;
|
|
343
344
|
}
|
|
344
345
|
}
|
|
345
346
|
}
|
|
346
|
-
return response || "
|
|
347
|
+
return response || "Agent completed with no text response";
|
|
347
348
|
}
|
|
348
349
|
catch (error) {
|
|
349
350
|
const backgroundTaskManager = this.container.has("BackgroundTaskManager")
|
|
@@ -31,10 +31,10 @@ declare class ToolManager {
|
|
|
31
31
|
*
|
|
32
32
|
* This method can be called multiple times safely. When called without dependencies,
|
|
33
33
|
* it registers basic tools (Bash, Read, Write, TaskCreate, etc.). When called with
|
|
34
|
-
* dependencies, it also registers tools that require managers (
|
|
34
|
+
* dependencies, it also registers tools that require managers (Agent, Skill).
|
|
35
35
|
*
|
|
36
36
|
* @param deps Optional dependencies for advanced tools
|
|
37
|
-
* @param deps.subagentManager SubagentManager instance for
|
|
37
|
+
* @param deps.subagentManager SubagentManager instance for Agent tool
|
|
38
38
|
* @param deps.skillManager SkillManager instance for Skill tool
|
|
39
39
|
*
|
|
40
40
|
* @example
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolManager.d.ts","sourceRoot":"","sources":["../../src/managers/toolManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"toolManager.d.ts","sourceRoot":"","sources":["../../src/managers/toolManager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAsB7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,KAAK,EACV,cAAc,EAGf,MAAM,mBAAmB,CAAC;AAM3B,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAIlD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,SAAS,CAAC;IACrB,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;;;;GAKG;AACH,cAAM,WAAW;IACf,OAAO,CAAC,aAAa,CAAiC;IACtD,OAAO,CAAC,KAAK,CAAC,CAAW;IACzB,OAAO,CAAC,SAAS,CAAY;gBAEjB,OAAO,EAAE,kBAAkB;IAKvC,OAAO,KAAK,UAAU,GAErB;IAED;;OAEG;IACI,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI;IAIvC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACI,sBAAsB,IAAI,IAAI;IA4BrC;;OAEG;IACH,OAAO,CAAC,gBAAgB;IASxB;;;;;;;;;;;;OAYG;IACG,OAAO,CACX,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,UAAU,CAAC;IAuFtB,IAAI,IAAI,UAAU,EAAE;IAMpB,cAAc,CAAC,OAAO,CAAC,EAAE;QACvB,kBAAkB,CAAC,EAAE,qBAAqB,EAAE,CAAC;QAC7C,eAAe,CAAC,EAAE,aAAa,EAAE,CAAC;QAClC,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,0BAA0B,EAAE;IAgChC;;OAEG;IACI,QAAQ,IAAI,UAAU,EAAE;IAI/B;;OAEG;IACI,iBAAiB,IAAI,cAAc;IAa1C;;;OAGG;IACI,iBAAiB,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI;IAIpD;;OAEG;IACI,oBAAoB,IAAI,iBAAiB,GAAG,SAAS;IAI5D;;OAEG;IACI,cAAc,IACjB,OAAO,4BAA4B,EAAE,WAAW,GAChD,SAAS;CAKd;AAGD,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -8,10 +8,9 @@ import { askUserQuestionTool } from "../tools/askUserQuestion.js";
|
|
|
8
8
|
// New tools
|
|
9
9
|
import { globTool } from "../tools/globTool.js";
|
|
10
10
|
import { grepTool } from "../tools/grepTool.js";
|
|
11
|
-
import { lsTool } from "../tools/lsTool.js";
|
|
12
11
|
import { readTool } from "../tools/readTool.js";
|
|
13
12
|
import { lspTool } from "../tools/lspTool.js";
|
|
14
|
-
import {
|
|
13
|
+
import { agentTool } from "../tools/agentTool.js";
|
|
15
14
|
import { skillTool } from "../tools/skillTool.js";
|
|
16
15
|
import { taskCreateTool, taskGetTool, taskUpdateTool, taskListTool, } from "../tools/taskManagementTools.js";
|
|
17
16
|
import { logger } from "../utils/globalLogger.js";
|
|
@@ -41,10 +40,10 @@ class ToolManager {
|
|
|
41
40
|
*
|
|
42
41
|
* This method can be called multiple times safely. When called without dependencies,
|
|
43
42
|
* it registers basic tools (Bash, Read, Write, TaskCreate, etc.). When called with
|
|
44
|
-
* dependencies, it also registers tools that require managers (
|
|
43
|
+
* dependencies, it also registers tools that require managers (Agent, Skill).
|
|
45
44
|
*
|
|
46
45
|
* @param deps Optional dependencies for advanced tools
|
|
47
|
-
* @param deps.subagentManager SubagentManager instance for
|
|
46
|
+
* @param deps.subagentManager SubagentManager instance for Agent tool
|
|
48
47
|
* @param deps.skillManager SkillManager instance for Skill tool
|
|
49
48
|
*
|
|
50
49
|
* @example
|
|
@@ -70,10 +69,9 @@ class ToolManager {
|
|
|
70
69
|
askUserQuestionTool,
|
|
71
70
|
globTool,
|
|
72
71
|
grepTool,
|
|
73
|
-
lsTool,
|
|
74
72
|
readTool,
|
|
75
73
|
lspTool,
|
|
76
|
-
|
|
74
|
+
agentTool,
|
|
77
75
|
skillTool,
|
|
78
76
|
taskCreateTool,
|
|
79
77
|
taskGetTool,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAkB/C,eAAO,MAAM,kBAAkB,g9DAU+J,CAAC;AAE/L,eAAO,MAAM,WAAW,qvBAIqH,CAAC;AAE9I,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,OAAO,EACnB,UAAU,GAAE,OAAe,GAC1B,MAAM,CAmFR;AAED,eAAO,MAAM,qBAAqB,g9DAAqB,CAAC;AAExD,eAAO,MAAM,2BAA2B,igBAWO,CAAC;AAEhD,eAAO,MAAM,6BAA6B,izCAeK,CAAC;AAEhD,eAAO,MAAM,8BAA8B,mzEAmCuC,CAAC;AAEnF,eAAO,MAAM,2BAA2B,q3EAgDyG,CAAC;AAElJ,eAAO,MAAM,WAAW,kkDAoBjB,CAAC;AAER,eAAO,MAAM,+BAA+B,20CAsBG,CAAC;AAEhD,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,KAAK,EAAE,UAAU,EAAE,EACnB,OAAO,GAAE;IACP,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE;QACT,YAAY,EAAE,MAAM,CAAC;QACrB,UAAU,EAAE,OAAO,CAAC;KACrB,CAAC;CACE,GACL,MAAM,CAsCR"}
|
package/dist/prompts/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as os from "node:os";
|
|
2
2
|
import { isGitRepository } from "../utils/gitUtils.js";
|
|
3
3
|
import { EXPLORE_SUBAGENT_TYPE, PLAN_SUBAGENT_TYPE, } from "../constants/subagents.js";
|
|
4
|
-
import { ASK_USER_QUESTION_TOOL_NAME, BASH_TOOL_NAME, EDIT_TOOL_NAME, GLOB_TOOL_NAME, GREP_TOOL_NAME, READ_TOOL_NAME, WRITE_TOOL_NAME, EXIT_PLAN_MODE_TOOL_NAME, } from "../constants/tools.js";
|
|
4
|
+
import { ASK_USER_QUESTION_TOOL_NAME, BASH_TOOL_NAME, EDIT_TOOL_NAME, GLOB_TOOL_NAME, GREP_TOOL_NAME, READ_TOOL_NAME, WRITE_TOOL_NAME, EXIT_PLAN_MODE_TOOL_NAME, AGENT_TOOL_NAME, } from "../constants/tools.js";
|
|
5
5
|
export const BASE_SYSTEM_PROMPT = `You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.
|
|
6
6
|
|
|
7
7
|
# Doing tasks
|
|
@@ -39,7 +39,7 @@ You should build your plan incrementally by writing to or editing this file. NOT
|
|
|
39
39
|
## Plan Workflow
|
|
40
40
|
|
|
41
41
|
### Phase 1: Initial Understanding
|
|
42
|
-
Goal: Gain a comprehensive understanding of the user's request by reading through code and asking them questions. Critical: In this phase you should only use the
|
|
42
|
+
Goal: Gain a comprehensive understanding of the user's request by reading through code and asking them questions. Critical: In this phase you should only use the ${AGENT_TOOL_NAME} tool with subagent_type=${EXPLORE_SUBAGENT_TYPE}.
|
|
43
43
|
|
|
44
44
|
1. Focus on understanding the user's request and the code associated with their request. Actively search for existing functions, utilities, and patterns that can be reused — avoid proposing new code when suitable implementations already exist.
|
|
45
45
|
|
|
@@ -52,7 +52,7 @@ Goal: Gain a comprehensive understanding of the user's request by reading throug
|
|
|
52
52
|
### Phase 2: Design
|
|
53
53
|
Goal: Design an implementation approach.
|
|
54
54
|
|
|
55
|
-
Launch
|
|
55
|
+
Launch agent(s) with subagent_type=${PLAN_SUBAGENT_TYPE} to design the implementation based on the user's intent and your exploration results from Phase 1.
|
|
56
56
|
|
|
57
57
|
You can launch up to 3 agent(s) in parallel.
|
|
58
58
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agentTool.d.ts","sourceRoot":"","sources":["../../src/tools/agentTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AAStE;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,UA0PvB,CAAC"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { EXPLORE_SUBAGENT_TYPE } from "../constants/subagents.js";
|
|
2
|
-
import {
|
|
2
|
+
import { AGENT_TOOL_NAME } from "../constants/tools.js";
|
|
3
3
|
import { countToolBlocks, formatToolTokenSummary, } from "../utils/messageOperations.js";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Agent tool plugin for launching specialized agents to handle complex tasks
|
|
6
6
|
*/
|
|
7
|
-
export const
|
|
8
|
-
name:
|
|
7
|
+
export const agentTool = {
|
|
8
|
+
name: AGENT_TOOL_NAME,
|
|
9
9
|
config: {
|
|
10
10
|
type: "function",
|
|
11
11
|
function: {
|
|
12
|
-
name:
|
|
13
|
-
description: "
|
|
12
|
+
name: AGENT_TOOL_NAME,
|
|
13
|
+
description: "Launch a new agent to handle complex, multi-step tasks autonomously.",
|
|
14
14
|
parameters: {
|
|
15
15
|
type: "object",
|
|
16
16
|
properties: {
|
|
@@ -38,18 +38,30 @@ export const taskTool = {
|
|
|
38
38
|
prompt: (args) => {
|
|
39
39
|
const subagentList = args?.availableSubagents
|
|
40
40
|
? args.availableSubagents
|
|
41
|
-
.map((config) =>
|
|
41
|
+
.map((config) => {
|
|
42
|
+
let toolsStr = "";
|
|
43
|
+
if (config.tools && config.tools.length > 0) {
|
|
44
|
+
toolsStr = ` (Tools: ${config.tools.join(", ")})`;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
toolsStr = " (Tools: *)";
|
|
48
|
+
}
|
|
49
|
+
return `- ${config.name}: ${config.description}${toolsStr}`;
|
|
50
|
+
})
|
|
42
51
|
.join("\n")
|
|
43
52
|
: "";
|
|
44
|
-
return `
|
|
45
|
-
|
|
53
|
+
return `Launch a new agent to handle complex, multi-step tasks autonomously.
|
|
54
|
+
|
|
55
|
+
The Agent tool launches specialized agents (subprocesses) that autonomously handle complex tasks. Each agent type has specific capabilities and tools available to it.
|
|
56
|
+
|
|
57
|
+
Available agent types and the tools they have access to:
|
|
58
|
+
${subagentList || "No agents configured"}
|
|
46
59
|
|
|
47
|
-
|
|
48
|
-
${subagentList || "No subagents configured"}
|
|
60
|
+
When using the Agent tool, you must specify a subagent_type parameter to select which agent type to use.
|
|
49
61
|
|
|
50
|
-
- When doing file search, prefer to use the ${
|
|
51
|
-
- You should proactively use the ${
|
|
52
|
-
- 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 ${
|
|
62
|
+
- When doing file search, prefer to use the ${AGENT_TOOL_NAME} tool in order to reduce context usage.
|
|
63
|
+
- You should proactively use the ${AGENT_TOOL_NAME} tool with specialized agents when the task at hand matches the agent's description.
|
|
64
|
+
- 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 ${AGENT_TOOL_NAME} tool with subagent_type=${EXPLORE_SUBAGENT_TYPE} instead of running search commands directly.`;
|
|
53
65
|
},
|
|
54
66
|
execute: async (args, context) => {
|
|
55
67
|
const subagentManager = context.subagentManager;
|
|
@@ -58,7 +70,7 @@ ${subagentList || "No subagents configured"}
|
|
|
58
70
|
success: false,
|
|
59
71
|
content: "",
|
|
60
72
|
error: "Subagent manager not available in tool context",
|
|
61
|
-
shortResult: "
|
|
73
|
+
shortResult: "Agent delegation failed",
|
|
62
74
|
};
|
|
63
75
|
}
|
|
64
76
|
// Input validation
|
|
@@ -71,7 +83,7 @@ ${subagentList || "No subagents configured"}
|
|
|
71
83
|
success: false,
|
|
72
84
|
content: "",
|
|
73
85
|
error: "description parameter is required and must be a string",
|
|
74
|
-
shortResult: "
|
|
86
|
+
shortResult: "Agent delegation failed",
|
|
75
87
|
};
|
|
76
88
|
}
|
|
77
89
|
if (!prompt || typeof prompt !== "string") {
|
|
@@ -79,7 +91,7 @@ ${subagentList || "No subagents configured"}
|
|
|
79
91
|
success: false,
|
|
80
92
|
content: "",
|
|
81
93
|
error: "prompt parameter is required and must be a string",
|
|
82
|
-
shortResult: "
|
|
94
|
+
shortResult: "Agent delegation failed",
|
|
83
95
|
};
|
|
84
96
|
}
|
|
85
97
|
if (!subagent_type || typeof subagent_type !== "string") {
|
|
@@ -87,7 +99,7 @@ ${subagentList || "No subagents configured"}
|
|
|
87
99
|
success: false,
|
|
88
100
|
content: "",
|
|
89
101
|
error: "subagent_type parameter is required and must be a string",
|
|
90
|
-
shortResult: "
|
|
102
|
+
shortResult: "Agent delegation failed",
|
|
91
103
|
};
|
|
92
104
|
}
|
|
93
105
|
try {
|
|
@@ -100,12 +112,12 @@ ${subagentList || "No subagents configured"}
|
|
|
100
112
|
return {
|
|
101
113
|
success: false,
|
|
102
114
|
content: "",
|
|
103
|
-
error: `No
|
|
104
|
-
shortResult: "
|
|
115
|
+
error: `No agent found matching "${subagent_type}". Available agents: ${availableNames || "none"}`,
|
|
116
|
+
shortResult: "Agent not found",
|
|
105
117
|
};
|
|
106
118
|
}
|
|
107
119
|
let isBackgrounded = false;
|
|
108
|
-
// Create subagent instance and execute
|
|
120
|
+
// Create subagent instance and execute agent
|
|
109
121
|
const instance = await subagentManager.createInstance(configuration, {
|
|
110
122
|
description,
|
|
111
123
|
prompt,
|
|
@@ -140,27 +152,27 @@ ${subagentList || "No subagents configured"}
|
|
|
140
152
|
await subagentManager.backgroundInstance(instance.subagentId);
|
|
141
153
|
resolve({
|
|
142
154
|
success: true,
|
|
143
|
-
content: "
|
|
144
|
-
shortResult: "
|
|
155
|
+
content: "Agent backgrounded",
|
|
156
|
+
shortResult: "Agent backgrounded",
|
|
145
157
|
isManuallyBackgrounded: true,
|
|
146
158
|
});
|
|
147
159
|
},
|
|
148
160
|
});
|
|
149
161
|
}
|
|
150
162
|
try {
|
|
151
|
-
const result = await subagentManager.
|
|
163
|
+
const result = await subagentManager.executeAgent(instance, prompt, context.abortSignal, run_in_background);
|
|
152
164
|
if (isBackgrounded) {
|
|
153
165
|
return;
|
|
154
166
|
}
|
|
155
167
|
if (run_in_background) {
|
|
156
168
|
resolve({
|
|
157
169
|
success: true,
|
|
158
|
-
content: `
|
|
159
|
-
shortResult: `
|
|
170
|
+
content: `Agent started in background with ID: ${result}`,
|
|
171
|
+
shortResult: `Agent started in background: ${result}`,
|
|
160
172
|
});
|
|
161
173
|
return;
|
|
162
174
|
}
|
|
163
|
-
// Cleanup subagent instance after
|
|
175
|
+
// Cleanup subagent instance after agent completion
|
|
164
176
|
subagentManager.cleanupInstance(instance.subagentId);
|
|
165
177
|
const messages = instance.messageManager.getMessages();
|
|
166
178
|
const tokens = instance.messageManager.getlatestTotalTokens();
|
|
@@ -169,7 +181,7 @@ ${subagentList || "No subagents configured"}
|
|
|
169
181
|
resolve({
|
|
170
182
|
success: true,
|
|
171
183
|
content: result,
|
|
172
|
-
shortResult: `
|
|
184
|
+
shortResult: `Agent completed${summary ? ` ${summary}` : ""}`,
|
|
173
185
|
});
|
|
174
186
|
}
|
|
175
187
|
catch (error) {
|
|
@@ -177,7 +189,7 @@ ${subagentList || "No subagents configured"}
|
|
|
177
189
|
resolve({
|
|
178
190
|
success: false,
|
|
179
191
|
content: "",
|
|
180
|
-
error: `
|
|
192
|
+
error: `Agent delegation failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
181
193
|
shortResult: "Delegation error",
|
|
182
194
|
});
|
|
183
195
|
}
|
|
@@ -194,7 +206,7 @@ ${subagentList || "No subagents configured"}
|
|
|
194
206
|
return {
|
|
195
207
|
success: false,
|
|
196
208
|
content: "",
|
|
197
|
-
error: `
|
|
209
|
+
error: `Agent delegation failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
198
210
|
shortResult: "Delegation error",
|
|
199
211
|
};
|
|
200
212
|
}
|
package/dist/tools/grepTool.js
CHANGED
|
@@ -2,7 +2,7 @@ import { spawn } from "child_process";
|
|
|
2
2
|
import { getGlobIgnorePatterns } from "../utils/fileFilter.js";
|
|
3
3
|
import { rgPath } from "@vscode/ripgrep";
|
|
4
4
|
import { getDisplayPath } from "../utils/path.js";
|
|
5
|
-
import { GREP_TOOL_NAME, BASH_TOOL_NAME,
|
|
5
|
+
import { GREP_TOOL_NAME, BASH_TOOL_NAME, AGENT_TOOL_NAME, } from "../constants/tools.js";
|
|
6
6
|
/**
|
|
7
7
|
* Grep tool plugin - powerful search tool based on ripgrep
|
|
8
8
|
*/
|
|
@@ -77,7 +77,7 @@ export const grepTool = {
|
|
|
77
77
|
- Supports full regex syntax (e.g., "log.*Error", "function\\s+\\w+")
|
|
78
78
|
- Filter files with glob parameter (e.g., "*.js", "**/*.tsx") or type parameter (e.g., "js", "py", "rust")
|
|
79
79
|
- Output modes: "content" shows matching lines, "files_with_matches" shows only file paths (default), "count" shows match counts
|
|
80
|
-
- Use ${
|
|
80
|
+
- Use ${AGENT_TOOL_NAME} tool for open-ended searches requiring multiple rounds
|
|
81
81
|
- Pattern syntax: Uses ripgrep (not grep) - literal braces need escaping (use \`interface\\{\\}\` to find \`interface{}\` in Go code)
|
|
82
82
|
- Multiline matching: By default patterns match within single lines only. For cross-line patterns like \`struct \\{[\\s\\S]*?field\`, use \`multiline: true\`
|
|
83
83
|
`,
|
package/dist/tools/skillTool.js
CHANGED
|
@@ -119,8 +119,8 @@ export const skillTool = {
|
|
|
119
119
|
context.onShortResultUpdate?.(shortResult);
|
|
120
120
|
});
|
|
121
121
|
try {
|
|
122
|
-
const result = await subagentManager.
|
|
123
|
-
// Cleanup subagent instance after
|
|
122
|
+
const result = await subagentManager.executeAgent(instance, skillResult.content, context.abortSignal, false);
|
|
123
|
+
// Cleanup subagent instance after agent completion
|
|
124
124
|
subagentManager.cleanupInstance(instance.subagentId);
|
|
125
125
|
const messages = instance.messageManager.getMessages();
|
|
126
126
|
const tokens = instance.messageManager.getlatestTotalTokens();
|
package/dist/tools/types.d.ts
CHANGED
|
@@ -54,7 +54,7 @@ export interface ToolContext {
|
|
|
54
54
|
foregroundTaskManager?: import("../types/processes.js").IForegroundTaskManager;
|
|
55
55
|
/** Task manager instance for task management */
|
|
56
56
|
taskManager: import("../services/taskManager.js").TaskManager;
|
|
57
|
-
/** Subagent manager instance for
|
|
57
|
+
/** Subagent manager instance for agent delegation */
|
|
58
58
|
subagentManager?: import("../managers/subagentManager.js").SubagentManager;
|
|
59
59
|
/** Skill manager instance for skill invocation */
|
|
60
60
|
skillManager?: import("../managers/skillManager.js").SkillManager;
|
|
@@ -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,OAAO,KAAK,EAAE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;IACtD,qBAAqB,CAAC,EAAE,OAAO,uBAAuB,EAAE,sBAAsB,CAAC;IAC/E,gDAAgD;IAChD,WAAW,EAAE,OAAO,4BAA4B,EAAE,WAAW,CAAC;IAC9D,qDAAqD;IACrD,eAAe,CAAC,EAAE,OAAO,gCAAgC,EAAE,eAAe,CAAC;IAC3E,kDAAkD;IAClD,YAAY,CAAC,EAAE,OAAO,6BAA6B,EAAE,YAAY,CAAC;IAClE,yBAAyB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oEAAoE;IACpE,mBAAmB,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;CACrD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builtinSubagents.d.ts","sourceRoot":"","sources":["../../src/utils/builtinSubagents.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"builtinSubagents.d.ts","sourceRoot":"","sources":["../../src/utils/builtinSubagents.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAEjE;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,qBAAqB,EAAE,CAQ7D"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BASH_SUBAGENT_TYPE, EXPLORE_SUBAGENT_TYPE, PLAN_SUBAGENT_TYPE, GENERAL_PURPOSE_SUBAGENT_TYPE, } from "../constants/subagents.js";
|
|
2
2
|
import { BASH_SUBAGENT_SYSTEM_PROMPT, GENERAL_PURPOSE_SYSTEM_PROMPT, PLAN_SUBAGENT_SYSTEM_PROMPT, EXPLORE_SUBAGENT_SYSTEM_PROMPT, } from "../prompts/index.js";
|
|
3
|
-
import { BASH_TOOL_NAME, GLOB_TOOL_NAME, GREP_TOOL_NAME, READ_TOOL_NAME,
|
|
3
|
+
import { BASH_TOOL_NAME, GLOB_TOOL_NAME, GREP_TOOL_NAME, READ_TOOL_NAME, LSP_TOOL_NAME, } from "../constants/tools.js";
|
|
4
4
|
/**
|
|
5
5
|
* Get all built-in subagent configurations
|
|
6
6
|
* Built-in subagents have priority 3 (lowest) and can be overridden by user/project configs
|
|
@@ -55,7 +55,6 @@ function createExploreSubagent() {
|
|
|
55
55
|
GREP_TOOL_NAME,
|
|
56
56
|
READ_TOOL_NAME,
|
|
57
57
|
BASH_TOOL_NAME,
|
|
58
|
-
LS_TOOL_NAME,
|
|
59
58
|
LSP_TOOL_NAME,
|
|
60
59
|
];
|
|
61
60
|
return {
|
|
@@ -80,7 +79,6 @@ function createPlanSubagent() {
|
|
|
80
79
|
GREP_TOOL_NAME,
|
|
81
80
|
READ_TOOL_NAME,
|
|
82
81
|
BASH_TOOL_NAME,
|
|
83
|
-
LS_TOOL_NAME,
|
|
84
82
|
LSP_TOOL_NAME,
|
|
85
83
|
];
|
|
86
84
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gitUtils.d.ts","sourceRoot":"","sources":["../../src/utils/gitUtils.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAevD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAUlD;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"gitUtils.d.ts","sourceRoot":"","sources":["../../src/utils/gitUtils.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAevD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAUlD;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CA2D1D;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAW1D;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAYvE"}
|