wave-agent-sdk 0.4.0 → 0.5.1
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 +28 -5
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +54 -37
- package/dist/constants/tools.d.ts +2 -2
- package/dist/constants/tools.js +2 -2
- package/dist/managers/MemoryRuleManager.js +1 -1
- package/dist/managers/aiManager.d.ts +3 -3
- package/dist/managers/aiManager.d.ts.map +1 -1
- package/dist/managers/aiManager.js +3 -4
- package/dist/managers/backgroundBashManager.d.ts.map +1 -1
- package/dist/managers/backgroundBashManager.js +1 -0
- package/dist/managers/backgroundTaskManager.d.ts +35 -0
- package/dist/managers/backgroundTaskManager.d.ts.map +1 -0
- package/dist/managers/backgroundTaskManager.js +249 -0
- package/dist/managers/foregroundTaskManager.d.ts +9 -0
- package/dist/managers/foregroundTaskManager.d.ts.map +1 -0
- package/dist/managers/foregroundTaskManager.js +20 -0
- package/dist/managers/liveConfigManager.d.ts +1 -1
- package/dist/managers/lspManager.d.ts.map +1 -1
- package/dist/managers/lspManager.js +3 -1
- package/dist/managers/messageManager.d.ts +12 -2
- package/dist/managers/messageManager.d.ts.map +1 -1
- package/dist/managers/messageManager.js +36 -2
- package/dist/managers/permissionManager.d.ts.map +1 -1
- package/dist/managers/permissionManager.js +1 -7
- package/dist/managers/pluginManager.d.ts.map +1 -1
- package/dist/managers/pluginManager.js +3 -2
- package/dist/managers/slashCommandManager.d.ts +3 -0
- package/dist/managers/slashCommandManager.d.ts.map +1 -1
- package/dist/managers/slashCommandManager.js +1 -0
- package/dist/managers/subagentManager.d.ts +11 -2
- package/dist/managers/subagentManager.d.ts.map +1 -1
- package/dist/managers/subagentManager.js +137 -39
- package/dist/managers/toolManager.d.ts +7 -1
- package/dist/managers/toolManager.d.ts.map +1 -1
- package/dist/managers/toolManager.js +9 -3
- package/dist/services/GitService.d.ts.map +1 -1
- package/dist/services/GitService.js +6 -2
- package/dist/services/MarketplaceService.d.ts +2 -2
- package/dist/services/MarketplaceService.d.ts.map +1 -1
- package/dist/services/MarketplaceService.js +18 -11
- package/dist/services/MemoryRuleService.d.ts +1 -1
- package/dist/services/MemoryRuleService.d.ts.map +1 -1
- package/dist/services/MemoryRuleService.js +13 -2
- package/dist/services/memory.js +1 -1
- package/dist/tools/bashTool.d.ts +0 -8
- package/dist/tools/bashTool.d.ts.map +1 -1
- package/dist/tools/bashTool.js +44 -172
- package/dist/tools/editTool.d.ts.map +1 -1
- package/dist/tools/editTool.js +6 -5
- package/dist/tools/multiEditTool.d.ts.map +1 -1
- package/dist/tools/multiEditTool.js +7 -6
- package/dist/tools/taskOutputTool.d.ts +3 -0
- package/dist/tools/taskOutputTool.d.ts.map +1 -0
- package/dist/tools/taskOutputTool.js +149 -0
- package/dist/tools/taskStopTool.d.ts +3 -0
- package/dist/tools/taskStopTool.d.ts.map +1 -0
- package/dist/tools/taskStopTool.js +65 -0
- package/dist/tools/taskTool.d.ts.map +1 -1
- package/dist/tools/taskTool.js +105 -63
- package/dist/tools/types.d.ts +3 -0
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/types/marketplace.d.ts +1 -0
- package/dist/types/marketplace.d.ts.map +1 -1
- package/dist/types/messaging.d.ts +1 -0
- package/dist/types/messaging.d.ts.map +1 -1
- package/dist/types/processes.d.ts +24 -4
- package/dist/types/processes.d.ts.map +1 -1
- package/dist/utils/editUtils.d.ts +2 -11
- package/dist/utils/editUtils.d.ts.map +1 -1
- package/dist/utils/editUtils.js +52 -79
- package/dist/utils/messageOperations.d.ts +3 -1
- package/dist/utils/messageOperations.d.ts.map +1 -1
- package/dist/utils/messageOperations.js +5 -1
- package/package.json +5 -5
- package/src/agent.ts +73 -45
- package/src/constants/tools.ts +2 -2
- package/src/managers/MemoryRuleManager.ts +1 -1
- package/src/managers/aiManager.ts +6 -9
- package/src/managers/backgroundBashManager.ts +1 -0
- package/src/managers/backgroundTaskManager.ts +306 -0
- package/src/managers/foregroundTaskManager.ts +26 -0
- package/src/managers/lspManager.ts +3 -1
- package/src/managers/messageManager.ts +48 -2
- package/src/managers/permissionManager.ts +1 -7
- package/src/managers/pluginManager.ts +4 -3
- package/src/managers/slashCommandManager.ts +4 -0
- package/src/managers/subagentManager.ts +167 -35
- package/src/managers/toolManager.ts +16 -4
- package/src/services/GitService.ts +6 -2
- package/src/services/MarketplaceService.ts +30 -12
- package/src/services/MemoryRuleService.ts +18 -6
- package/src/services/memory.ts +1 -1
- package/src/tools/bashTool.ts +59 -196
- package/src/tools/editTool.ts +6 -17
- package/src/tools/multiEditTool.ts +7 -18
- package/src/tools/taskOutputTool.ts +174 -0
- package/src/tools/taskStopTool.ts +72 -0
- package/src/tools/taskTool.ts +130 -74
- package/src/tools/types.ts +3 -0
- package/src/types/marketplace.ts +1 -0
- package/src/types/messaging.ts +1 -0
- package/src/types/processes.ts +33 -4
- package/src/utils/editUtils.ts +65 -103
- package/src/utils/messageOperations.ts +7 -0
|
@@ -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,MAAM,EACN,aAAa,EACb,WAAW,EACX,KAAK,EACN,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EACL,iBAAiB,EACjB,KAAK,0BAA0B,EAChC,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file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U,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;IACG,uBAAuB,CAC3B,gBAAgB,EAAE,KAAK,CAAC;QACtB,WAAW,EAAE,WAAW,CAAC;QACzB,UAAU,EAAE,MAAM,CAAC;QACnB,aAAa,EAAE,qBAAqB,CAAC;KACtC,CAAC,GACD,OAAO,CAAC,IAAI,CAAC;IAkFhB;;;OAGG;IACH,OAAO,CAAC,uBAAuB;CAgEhC"}
|
|
@@ -17,6 +17,8 @@ export class SubagentManager {
|
|
|
17
17
|
this.getLanguage = options.getLanguage;
|
|
18
18
|
this.hookManager = options.hookManager;
|
|
19
19
|
this.onUsageAdded = options.onUsageAdded;
|
|
20
|
+
this.backgroundTaskManager = options.backgroundTaskManager;
|
|
21
|
+
this.memoryRuleManager = options.memoryRuleManager;
|
|
20
22
|
}
|
|
21
23
|
/**
|
|
22
24
|
* Initialize the SubagentManager by loading and caching configurations
|
|
@@ -53,7 +55,7 @@ export class SubagentManager {
|
|
|
53
55
|
/**
|
|
54
56
|
* Create a new subagent instance with isolated managers
|
|
55
57
|
*/
|
|
56
|
-
async createInstance(configuration, parameters) {
|
|
58
|
+
async createInstance(configuration, parameters, runInBackground) {
|
|
57
59
|
if (!this.parentToolManager) {
|
|
58
60
|
throw new Error("SubagentManager not properly initialized - call initialize() first");
|
|
59
61
|
}
|
|
@@ -66,6 +68,7 @@ export class SubagentManager {
|
|
|
66
68
|
logger: this.logger,
|
|
67
69
|
sessionType: "subagent",
|
|
68
70
|
subagentType: parameters.subagent_type,
|
|
71
|
+
memoryRuleManager: this.memoryRuleManager,
|
|
69
72
|
});
|
|
70
73
|
// Use the parent tool manager directly - tool restrictions will be handled by allowedTools parameter
|
|
71
74
|
const toolManager = this.parentToolManager;
|
|
@@ -119,7 +122,7 @@ export class SubagentManager {
|
|
|
119
122
|
};
|
|
120
123
|
this.instances.set(subagentId, instance);
|
|
121
124
|
// Create subagent block in parent message manager
|
|
122
|
-
this.parentMessageManager.addSubagentBlock(subagentId, configuration.name, messageManager.getSessionId(), configuration, "active", parameters);
|
|
125
|
+
this.parentMessageManager.addSubagentBlock(subagentId, configuration.name, messageManager.getSessionId(), configuration, "active", parameters, runInBackground);
|
|
123
126
|
return instance;
|
|
124
127
|
}
|
|
125
128
|
/**
|
|
@@ -128,7 +131,7 @@ export class SubagentManager {
|
|
|
128
131
|
* IMPORTANT: This method automatically filters out the Task tool from allowedTools
|
|
129
132
|
* to prevent subagents from spawning other subagents (infinite recursion protection)
|
|
130
133
|
*/
|
|
131
|
-
async executeTask(instance, prompt, abortSignal) {
|
|
134
|
+
async executeTask(instance, prompt, abortSignal, runInBackground) {
|
|
132
135
|
try {
|
|
133
136
|
// Check if already aborted before starting
|
|
134
137
|
if (abortSignal?.aborted) {
|
|
@@ -139,23 +142,99 @@ export class SubagentManager {
|
|
|
139
142
|
this.parentMessageManager.updateSubagentBlock(instance.subagentId, {
|
|
140
143
|
status: "active",
|
|
141
144
|
});
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
145
|
+
if (runInBackground && this.backgroundTaskManager) {
|
|
146
|
+
const taskId = this.backgroundTaskManager.generateId();
|
|
147
|
+
const startTime = Date.now();
|
|
148
|
+
this.backgroundTaskManager.addTask({
|
|
149
|
+
id: taskId,
|
|
150
|
+
type: "subagent",
|
|
151
|
+
status: "running",
|
|
152
|
+
startTime,
|
|
153
|
+
description: instance.configuration.description,
|
|
154
|
+
stdout: "",
|
|
155
|
+
stderr: "",
|
|
156
|
+
});
|
|
157
|
+
instance.backgroundTaskId = taskId;
|
|
158
|
+
// Execute in background
|
|
159
|
+
(async () => {
|
|
160
|
+
try {
|
|
161
|
+
const result = await this.internalExecute(instance, prompt, abortSignal);
|
|
162
|
+
const task = this.backgroundTaskManager?.getTask(taskId);
|
|
163
|
+
if (task) {
|
|
164
|
+
task.status = "completed";
|
|
165
|
+
task.stdout = result;
|
|
166
|
+
task.endTime = Date.now();
|
|
167
|
+
task.runtime = task.endTime - startTime;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
const task = this.backgroundTaskManager?.getTask(taskId);
|
|
172
|
+
if (task) {
|
|
173
|
+
task.status = "failed";
|
|
174
|
+
task.stderr =
|
|
175
|
+
error instanceof Error ? error.message : String(error);
|
|
176
|
+
task.endTime = Date.now();
|
|
177
|
+
task.runtime = task.endTime - startTime;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
})();
|
|
181
|
+
return taskId;
|
|
158
182
|
}
|
|
183
|
+
return await this.internalExecute(instance, prompt, abortSignal);
|
|
184
|
+
}
|
|
185
|
+
catch (error) {
|
|
186
|
+
this.updateInstanceStatus(instance.subagentId, "error");
|
|
187
|
+
this.parentMessageManager.updateSubagentBlock(instance.subagentId, {
|
|
188
|
+
status: "error",
|
|
189
|
+
});
|
|
190
|
+
throw error;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
async backgroundInstance(subagentId) {
|
|
194
|
+
const instance = this.instances.get(subagentId);
|
|
195
|
+
if (!instance) {
|
|
196
|
+
throw new Error(`Subagent instance ${subagentId} not found`);
|
|
197
|
+
}
|
|
198
|
+
if (!this.backgroundTaskManager) {
|
|
199
|
+
throw new Error("BackgroundTaskManager not available");
|
|
200
|
+
}
|
|
201
|
+
const taskId = this.backgroundTaskManager.generateId();
|
|
202
|
+
const startTime = Date.now();
|
|
203
|
+
this.backgroundTaskManager.addTask({
|
|
204
|
+
id: taskId,
|
|
205
|
+
type: "subagent",
|
|
206
|
+
status: "running",
|
|
207
|
+
startTime,
|
|
208
|
+
description: instance.configuration.description,
|
|
209
|
+
stdout: "",
|
|
210
|
+
stderr: "",
|
|
211
|
+
});
|
|
212
|
+
instance.backgroundTaskId = taskId;
|
|
213
|
+
// Update parent message manager to reflect background status
|
|
214
|
+
this.parentMessageManager.updateSubagentBlock(subagentId, {
|
|
215
|
+
runInBackground: true,
|
|
216
|
+
});
|
|
217
|
+
return taskId;
|
|
218
|
+
}
|
|
219
|
+
async internalExecute(instance, prompt, abortSignal) {
|
|
220
|
+
// Set up consolidated abort handler to prevent listener accumulation
|
|
221
|
+
let abortCleanup;
|
|
222
|
+
if (abortSignal) {
|
|
223
|
+
abortCleanup = addConsolidatedAbortListener(abortSignal, [
|
|
224
|
+
() => {
|
|
225
|
+
// Update status to aborted
|
|
226
|
+
this.updateInstanceStatus(instance.subagentId, "aborted");
|
|
227
|
+
this.parentMessageManager.updateSubagentBlock(instance.subagentId, {
|
|
228
|
+
status: "aborted",
|
|
229
|
+
});
|
|
230
|
+
},
|
|
231
|
+
() => {
|
|
232
|
+
// Abort the AI execution
|
|
233
|
+
instance.aiManager.abortAIMessage();
|
|
234
|
+
},
|
|
235
|
+
]);
|
|
236
|
+
}
|
|
237
|
+
try {
|
|
159
238
|
// Add the user's prompt as a message
|
|
160
239
|
instance.messageManager.addUserMessage({ content: prompt });
|
|
161
240
|
// Create allowed tools list - always exclude Task tool to prevent subagent recursion
|
|
@@ -190,23 +269,15 @@ export class SubagentManager {
|
|
|
190
269
|
tools: allowedTools,
|
|
191
270
|
model: resolvedModel,
|
|
192
271
|
});
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
]);
|
|
200
|
-
}
|
|
201
|
-
else {
|
|
202
|
-
await executeAI;
|
|
203
|
-
}
|
|
272
|
+
// If we have an abort signal, race against it using utilities to prevent listener accumulation
|
|
273
|
+
if (abortSignal) {
|
|
274
|
+
await Promise.race([
|
|
275
|
+
executeAI,
|
|
276
|
+
createAbortPromise(abortSignal, "Task was aborted"),
|
|
277
|
+
]);
|
|
204
278
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
if (abortCleanup) {
|
|
208
|
-
abortCleanup();
|
|
209
|
-
}
|
|
279
|
+
else {
|
|
280
|
+
await executeAI;
|
|
210
281
|
}
|
|
211
282
|
// Get the latest messages to extract the response
|
|
212
283
|
const messages = instance.messageManager.getMessages();
|
|
@@ -224,15 +295,41 @@ export class SubagentManager {
|
|
|
224
295
|
this.parentMessageManager.updateSubagentBlock(instance.subagentId, {
|
|
225
296
|
status: "completed",
|
|
226
297
|
});
|
|
298
|
+
// If this was transitioned to background, update the background task
|
|
299
|
+
if (instance.backgroundTaskId && this.backgroundTaskManager) {
|
|
300
|
+
const task = this.backgroundTaskManager.getTask(instance.backgroundTaskId);
|
|
301
|
+
if (task) {
|
|
302
|
+
task.status = "completed";
|
|
303
|
+
task.stdout = response || "Task completed with no text response";
|
|
304
|
+
task.endTime = Date.now();
|
|
305
|
+
if (task.startTime) {
|
|
306
|
+
task.runtime = task.endTime - task.startTime;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
227
310
|
return response || "Task completed with no text response";
|
|
228
311
|
}
|
|
229
312
|
catch (error) {
|
|
230
|
-
this
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
313
|
+
// If this was transitioned to background, update the background task with error
|
|
314
|
+
if (instance.backgroundTaskId && this.backgroundTaskManager) {
|
|
315
|
+
const task = this.backgroundTaskManager.getTask(instance.backgroundTaskId);
|
|
316
|
+
if (task) {
|
|
317
|
+
task.status = "failed";
|
|
318
|
+
task.stderr = error instanceof Error ? error.message : String(error);
|
|
319
|
+
task.endTime = Date.now();
|
|
320
|
+
if (task.startTime) {
|
|
321
|
+
task.runtime = task.endTime - task.startTime;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
234
325
|
throw error;
|
|
235
326
|
}
|
|
327
|
+
finally {
|
|
328
|
+
// Clean up abort listeners to prevent memory leaks
|
|
329
|
+
if (abortCleanup) {
|
|
330
|
+
abortCleanup();
|
|
331
|
+
}
|
|
332
|
+
}
|
|
236
333
|
}
|
|
237
334
|
/**
|
|
238
335
|
* Get instance by subagent ID
|
|
@@ -299,6 +396,7 @@ export class SubagentManager {
|
|
|
299
396
|
logger: this.logger,
|
|
300
397
|
sessionType: "subagent",
|
|
301
398
|
subagentType: configuration.name, // Use configuration name for restored sessions
|
|
399
|
+
memoryRuleManager: this.memoryRuleManager,
|
|
302
400
|
});
|
|
303
401
|
// Use the parent tool manager
|
|
304
402
|
const toolManager = this.parentToolManager;
|
|
@@ -10,10 +10,14 @@ export interface ToolManagerOptions {
|
|
|
10
10
|
mcpManager: McpManager;
|
|
11
11
|
lspManager?: ILspManager;
|
|
12
12
|
logger?: Logger;
|
|
13
|
-
/**
|
|
13
|
+
/** Permission manager for handling tool permission checks */
|
|
14
14
|
permissionManager?: PermissionManager;
|
|
15
|
+
/** Foreground task manager for backgrounding tasks */
|
|
16
|
+
foregroundTaskManager?: import("../types/processes.js").IForegroundTaskManager;
|
|
15
17
|
/** Reversion manager for file snapshots */
|
|
16
18
|
reversionManager?: ReversionManager;
|
|
19
|
+
/** Background task manager for background execution */
|
|
20
|
+
backgroundTaskManager?: import("./backgroundTaskManager.js").BackgroundTaskManager;
|
|
17
21
|
/** Permission mode for tool execution (defaults to "default") */
|
|
18
22
|
permissionMode?: PermissionMode;
|
|
19
23
|
/** Custom permission callback for tool usage */
|
|
@@ -31,7 +35,9 @@ declare class ToolManager {
|
|
|
31
35
|
private lspManager?;
|
|
32
36
|
private logger?;
|
|
33
37
|
private permissionManager?;
|
|
38
|
+
private foregroundTaskManager?;
|
|
34
39
|
private reversionManager?;
|
|
40
|
+
private backgroundTaskManager?;
|
|
35
41
|
private permissionMode?;
|
|
36
42
|
private canUseToolCallback?;
|
|
37
43
|
constructor(options: ToolManagerOptions);
|
|
@@ -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;AAmB7E,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,KAAK,EACV,MAAM,EACN,cAAc,EACd,kBAAkB,EAClB,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,CAAC,EAAE,WAAW,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,sDAAsD;IACtD,qBAAqB,CAAC,EAAE,OAAO,uBAAuB,EAAE,sBAAsB,CAAC;IAC/E,2CAA2C;IAC3C,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,uDAAuD;IACvD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G7D;AAGD,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import { bashTool
|
|
1
|
+
import { bashTool } from "../tools/bashTool.js";
|
|
2
|
+
import { taskOutputTool } from "../tools/taskOutputTool.js";
|
|
3
|
+
import { taskStopTool } from "../tools/taskStopTool.js";
|
|
2
4
|
import { deleteFileTool } from "../tools/deleteFileTool.js";
|
|
3
5
|
import { editTool } from "../tools/editTool.js";
|
|
4
6
|
import { multiEditTool } from "../tools/multiEditTool.js";
|
|
@@ -27,7 +29,9 @@ class ToolManager {
|
|
|
27
29
|
this.lspManager = options.lspManager;
|
|
28
30
|
this.logger = options.logger;
|
|
29
31
|
this.permissionManager = options.permissionManager;
|
|
32
|
+
this.foregroundTaskManager = options.foregroundTaskManager;
|
|
30
33
|
this.reversionManager = options.reversionManager;
|
|
34
|
+
this.backgroundTaskManager = options.backgroundTaskManager;
|
|
31
35
|
// Store CLI permission mode, let PermissionManager resolve effective mode
|
|
32
36
|
this.permissionMode = options.permissionMode;
|
|
33
37
|
this.canUseToolCallback = options.canUseToolCallback;
|
|
@@ -64,8 +68,8 @@ class ToolManager {
|
|
|
64
68
|
initializeBuiltInTools(deps) {
|
|
65
69
|
const builtInTools = [
|
|
66
70
|
bashTool,
|
|
67
|
-
|
|
68
|
-
|
|
71
|
+
taskOutputTool,
|
|
72
|
+
taskStopTool,
|
|
69
73
|
deleteFileTool,
|
|
70
74
|
editTool,
|
|
71
75
|
multiEditTool,
|
|
@@ -117,6 +121,8 @@ class ToolManager {
|
|
|
117
121
|
canUseToolCallback: this.canUseToolCallback,
|
|
118
122
|
permissionManager: this.permissionManager,
|
|
119
123
|
reversionManager: this.reversionManager,
|
|
124
|
+
backgroundTaskManager: this.backgroundTaskManager,
|
|
125
|
+
foregroundTaskManager: this.foregroundTaskManager,
|
|
120
126
|
mcpManager: this.mcpManager,
|
|
121
127
|
lspManager: this.lspManager,
|
|
122
128
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GitService.d.ts","sourceRoot":"","sources":["../../src/services/GitService.ts"],"names":[],"mappings":"AAKA,qBAAa,UAAU;IACrB;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IASxC;;OAEG;IACG,KAAK,CACT,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"GitService.d.ts","sourceRoot":"","sources":["../../src/services/GitService.ts"],"names":[],"mappings":"AAKA,qBAAa,UAAU;IACrB;;OAEG;IACG,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC;IASxC;;OAEG;IACG,KAAK,CACT,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC;IA4BhB;;OAEG;IACG,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAe7C,OAAO,CAAC,cAAc;CA6BvB"}
|
|
@@ -31,7 +31,9 @@ export class GitService {
|
|
|
31
31
|
}
|
|
32
32
|
try {
|
|
33
33
|
const refArgs = ref ? `-b "${ref}"` : "--depth 1";
|
|
34
|
-
await execAsync(`
|
|
34
|
+
await execAsync(`git clone ${refArgs} "${url}" "${targetPath}"`, {
|
|
35
|
+
env: { ...process.env, LC_ALL: "C" },
|
|
36
|
+
});
|
|
35
37
|
}
|
|
36
38
|
catch (error) {
|
|
37
39
|
throw this.handleGitError(urlOrRepo, error);
|
|
@@ -45,7 +47,9 @@ export class GitService {
|
|
|
45
47
|
throw new Error("Git is not installed or not found in PATH. Please install Git to use Git/GitHub marketplaces.");
|
|
46
48
|
}
|
|
47
49
|
try {
|
|
48
|
-
await execAsync(`
|
|
50
|
+
await execAsync(`git -C "${targetPath}" pull`, {
|
|
51
|
+
env: { ...process.env, LC_ALL: "C" },
|
|
52
|
+
});
|
|
49
53
|
}
|
|
50
54
|
catch (error) {
|
|
51
55
|
throw this.handleGitError(targetPath, error);
|
|
@@ -62,11 +62,11 @@ export declare class MarketplaceService {
|
|
|
62
62
|
/**
|
|
63
63
|
* Installs a plugin from a marketplace
|
|
64
64
|
*/
|
|
65
|
-
installPlugin(pluginAtMarketplace: string): Promise<InstalledPlugin>;
|
|
65
|
+
installPlugin(pluginAtMarketplace: string, projectPath?: string): Promise<InstalledPlugin>;
|
|
66
66
|
/**
|
|
67
67
|
* Uninstalls a plugin
|
|
68
68
|
*/
|
|
69
|
-
uninstallPlugin(pluginAtMarketplace: string): Promise<void>;
|
|
69
|
+
uninstallPlugin(pluginAtMarketplace: string, projectPath?: string): Promise<void>;
|
|
70
70
|
/**
|
|
71
71
|
* Updates a plugin (uninstall followed by install)
|
|
72
72
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarketplaceService.d.ts","sourceRoot":"","sources":["../../src/services/MarketplaceService.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,gBAAgB,EAChB,yBAAyB,EACzB,eAAe,EACf,wBAAwB,EACxB,mBAAmB,EACpB,MAAM,yBAAyB,CAAC;AAGjC;;;;;GAKG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,qBAAqB,CAAS;IACtC,OAAO,CAAC,oBAAoB,CAAS;IACrC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAMzC;;IAoBF;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAUhC;;OAEG;IACG,oBAAoB,IAAI,OAAO,CAAC,yBAAyB,CAAC;IAoBhE;;OAEG;IACG,mBAAmB,IAAI,OAAO,CAAC,wBAAwB,CAAC;IAa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G;IACG,oBAAoB,IAAI,OAAO,CAAC,yBAAyB,CAAC;IAoBhE;;OAEG;IACG,mBAAmB,IAAI,OAAO,CAAC,wBAAwB,CAAC;IAa9D;;OAEG;IACG,qBAAqB,CACzB,QAAQ,EAAE,yBAAyB,GAClC,OAAO,CAAC,IAAI,CAAC;IAOhB;;OAEG;IACG,oBAAoB,CACxB,QAAQ,EAAE,wBAAwB,GACjC,OAAO,CAAC,IAAI,CAAC;IAOhB;;OAEG;IACG,uBAAuB,CAC3B,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,mBAAmB,CAAC;IAwB/B;;OAEG;IACI,kBAAkB,CAAC,WAAW,EAAE,gBAAgB,GAAG,MAAM;IAehE;;OAEG;IACG,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA0F9D;;OAEG;IACG,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAQrD;;OAEG;IACG,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAcpD;;OAEG;IACG,iBAAiB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA6CrD;;OAEG;IACG,aAAa,CACjB,mBAAmB,EAAE,MAAM,EAC3B,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,eAAe,CAAC;IA0H3B;;OAEG;IACG,eAAe,CACnB,mBAAmB,EAAE,MAAM,EAC3B,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC;IAqChB;;OAEG;IACG,YAAY,CAAC,mBAAmB,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;CAI1E"}
|
|
@@ -253,7 +253,7 @@ export class MarketplaceService {
|
|
|
253
253
|
/**
|
|
254
254
|
* Installs a plugin from a marketplace
|
|
255
255
|
*/
|
|
256
|
-
async installPlugin(pluginAtMarketplace) {
|
|
256
|
+
async installPlugin(pluginAtMarketplace, projectPath) {
|
|
257
257
|
const [pluginName, marketplaceName] = pluginAtMarketplace.split("@");
|
|
258
258
|
if (!pluginName || !marketplaceName) {
|
|
259
259
|
throw new Error("Invalid plugin format. Use name@marketplace");
|
|
@@ -315,12 +315,15 @@ export class MarketplaceService {
|
|
|
315
315
|
await fs.mkdir(path.dirname(cachePath), { recursive: true });
|
|
316
316
|
await fs.rename(tmpPluginDir, cachePath);
|
|
317
317
|
const installedRegistry = await this.getInstalledPlugins();
|
|
318
|
-
const existingIndex = installedRegistry.plugins.findIndex((p) => p.name === pluginName &&
|
|
318
|
+
const existingIndex = installedRegistry.plugins.findIndex((p) => p.name === pluginName &&
|
|
319
|
+
p.marketplace === marketplaceName &&
|
|
320
|
+
p.projectPath === projectPath);
|
|
319
321
|
const installedPlugin = {
|
|
320
322
|
name: pluginName,
|
|
321
323
|
marketplace: marketplaceName,
|
|
322
324
|
version,
|
|
323
325
|
cachePath,
|
|
326
|
+
projectPath,
|
|
324
327
|
};
|
|
325
328
|
if (existingIndex >= 0) {
|
|
326
329
|
installedRegistry.plugins[existingIndex] = installedPlugin;
|
|
@@ -345,24 +348,28 @@ export class MarketplaceService {
|
|
|
345
348
|
/**
|
|
346
349
|
* Uninstalls a plugin
|
|
347
350
|
*/
|
|
348
|
-
async uninstallPlugin(pluginAtMarketplace) {
|
|
351
|
+
async uninstallPlugin(pluginAtMarketplace, projectPath) {
|
|
349
352
|
const [pluginName, marketplaceName] = pluginAtMarketplace.split("@");
|
|
350
353
|
if (!pluginName || !marketplaceName) {
|
|
351
354
|
throw new Error("Invalid plugin format. Use name@marketplace");
|
|
352
355
|
}
|
|
353
356
|
const installedRegistry = await this.getInstalledPlugins();
|
|
354
|
-
const pluginIndex = installedRegistry.plugins.findIndex((p) => p.name === pluginName &&
|
|
357
|
+
const pluginIndex = installedRegistry.plugins.findIndex((p) => p.name === pluginName &&
|
|
358
|
+
p.marketplace === marketplaceName &&
|
|
359
|
+
p.projectPath === projectPath);
|
|
355
360
|
if (pluginIndex === -1) {
|
|
356
|
-
throw new Error(`Plugin ${pluginName}@${marketplaceName} is not installed`);
|
|
361
|
+
throw new Error(`Plugin ${pluginName}@${marketplaceName} is not installed${projectPath ? ` for project ${projectPath}` : ""}`);
|
|
357
362
|
}
|
|
358
|
-
const
|
|
359
|
-
// Remove
|
|
360
|
-
if (existsSync(plugin.cachePath)) {
|
|
361
|
-
await fs.rm(plugin.cachePath, { recursive: true, force: true });
|
|
362
|
-
}
|
|
363
|
-
// Remove from registry
|
|
363
|
+
const pluginToRemove = installedRegistry.plugins[pluginIndex];
|
|
364
|
+
// Remove from registry first
|
|
364
365
|
installedRegistry.plugins.splice(pluginIndex, 1);
|
|
365
366
|
await this.saveInstalledPlugins(installedRegistry);
|
|
367
|
+
// Check if any other project is still using this same cache path
|
|
368
|
+
const isStillReferenced = installedRegistry.plugins.some((p) => p.cachePath === pluginToRemove.cachePath);
|
|
369
|
+
// Only remove cached files if no other references exist
|
|
370
|
+
if (!isStillReferenced && existsSync(pluginToRemove.cachePath)) {
|
|
371
|
+
await fs.rm(pluginToRemove.cachePath, { recursive: true, force: true });
|
|
372
|
+
}
|
|
366
373
|
}
|
|
367
374
|
/**
|
|
368
375
|
* Updates a plugin (uninstall followed by install)
|
|
@@ -7,6 +7,6 @@ export declare class MemoryRuleService {
|
|
|
7
7
|
/**
|
|
8
8
|
* Determines if a rule matches any of the given file paths using minimatch.
|
|
9
9
|
*/
|
|
10
|
-
isRuleActive(rule: MemoryRule, filesInContext: string[]): boolean;
|
|
10
|
+
isRuleActive(rule: MemoryRule, filesInContext: string[], workdir?: string): boolean;
|
|
11
11
|
}
|
|
12
12
|
//# sourceMappingURL=MemoryRuleService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryRuleService.d.ts","sourceRoot":"","sources":["../../src/services/MemoryRuleService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MemoryRuleService.d.ts","sourceRoot":"","sources":["../../src/services/MemoryRuleService.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAsB,MAAM,wBAAwB,CAAC;AAE7E,qBAAa,iBAAiB;IAC5B;;OAEG;IACH,SAAS,CACP,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,SAAS,GAAG,MAAM,GACzB,UAAU;IAgCb;;OAEG;IACH,YAAY,CACV,IAAI,EAAE,UAAU,EAChB,cAAc,EAAE,MAAM,EAAE,EACxB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO;CAkBX"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { minimatch } from "minimatch";
|
|
2
|
+
import * as path from "node:path";
|
|
2
3
|
import { parseFrontmatter } from "../utils/markdownParser.js";
|
|
3
4
|
export class MemoryRuleService {
|
|
4
5
|
/**
|
|
@@ -35,10 +36,20 @@ export class MemoryRuleService {
|
|
|
35
36
|
/**
|
|
36
37
|
* Determines if a rule matches any of the given file paths using minimatch.
|
|
37
38
|
*/
|
|
38
|
-
isRuleActive(rule, filesInContext) {
|
|
39
|
+
isRuleActive(rule, filesInContext, workdir) {
|
|
39
40
|
if (!rule.metadata.paths || rule.metadata.paths.length === 0) {
|
|
40
41
|
return true;
|
|
41
42
|
}
|
|
42
|
-
return filesInContext.some((filePath) =>
|
|
43
|
+
return filesInContext.some((filePath) => {
|
|
44
|
+
// Normalize path relative to workdir if it's an absolute path
|
|
45
|
+
let normalizedPath = filePath;
|
|
46
|
+
if (workdir && path.isAbsolute(filePath)) {
|
|
47
|
+
normalizedPath = path.relative(workdir, filePath);
|
|
48
|
+
}
|
|
49
|
+
return rule.metadata.paths.some((pattern) => {
|
|
50
|
+
const isMatch = minimatch(normalizedPath, pattern, { dot: true });
|
|
51
|
+
return isMatch;
|
|
52
|
+
});
|
|
53
|
+
});
|
|
43
54
|
}
|
|
44
55
|
}
|
package/dist/services/memory.js
CHANGED
|
@@ -126,7 +126,7 @@ export const readMemoryFile = async (workdir) => {
|
|
|
126
126
|
return "";
|
|
127
127
|
}
|
|
128
128
|
logger.error("Failed to read memory file", { memoryFilePath, error });
|
|
129
|
-
|
|
129
|
+
return "";
|
|
130
130
|
}
|
|
131
131
|
};
|
|
132
132
|
// Get merged memory content (project memory + user memory)
|
package/dist/tools/bashTool.d.ts
CHANGED
|
@@ -3,12 +3,4 @@ import type { ToolPlugin } from "./types.js";
|
|
|
3
3
|
* Bash command execution tool - supports both foreground and background execution
|
|
4
4
|
*/
|
|
5
5
|
export declare const bashTool: ToolPlugin;
|
|
6
|
-
/**
|
|
7
|
-
* BashOutput tool - retrieves output from background bash shells
|
|
8
|
-
*/
|
|
9
|
-
export declare const bashOutputTool: ToolPlugin;
|
|
10
|
-
/**
|
|
11
|
-
* KillBash tool - kills a running background bash shell
|
|
12
|
-
*/
|
|
13
|
-
export declare const killBashTool: ToolPlugin;
|
|
14
6
|
//# sourceMappingURL=bashTool.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bashTool.d.ts","sourceRoot":"","sources":["../../src/tools/bashTool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"bashTool.d.ts","sourceRoot":"","sources":["../../src/tools/bashTool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AActE;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,UAyWtB,CAAC"}
|