wave-agent-sdk 0.6.4 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent.d.ts +8 -0
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +49 -240
- package/dist/constants/tools.d.ts +0 -2
- package/dist/constants/tools.d.ts.map +1 -1
- package/dist/constants/tools.js +0 -2
- package/dist/core/plugin.d.ts +86 -0
- package/dist/core/plugin.d.ts.map +1 -0
- package/dist/core/plugin.js +164 -0
- package/dist/index.d.ts +1 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -5
- package/dist/managers/MemoryRuleManager.d.ts +3 -1
- package/dist/managers/MemoryRuleManager.d.ts.map +1 -1
- package/dist/managers/MemoryRuleManager.js +2 -1
- package/dist/managers/aiManager.d.ts +13 -23
- package/dist/managers/aiManager.d.ts.map +1 -1
- package/dist/managers/aiManager.js +59 -32
- package/dist/managers/backgroundTaskManager.d.ts +3 -1
- package/dist/managers/backgroundTaskManager.d.ts.map +1 -1
- package/dist/managers/backgroundTaskManager.js +2 -1
- package/dist/managers/bashManager.d.ts +4 -4
- package/dist/managers/bashManager.d.ts.map +1 -1
- package/dist/managers/bashManager.js +5 -2
- package/dist/managers/foregroundTaskManager.d.ts +3 -0
- package/dist/managers/foregroundTaskManager.d.ts.map +1 -1
- package/dist/managers/foregroundTaskManager.js +2 -1
- package/dist/managers/hookManager.d.ts +3 -3
- package/dist/managers/hookManager.d.ts.map +1 -1
- package/dist/managers/hookManager.js +20 -19
- package/dist/managers/liveConfigManager.d.ts +6 -13
- package/dist/managers/liveConfigManager.d.ts.map +1 -1
- package/dist/managers/liveConfigManager.js +50 -45
- package/dist/managers/lspManager.d.ts +4 -5
- package/dist/managers/lspManager.d.ts.map +1 -1
- package/dist/managers/lspManager.js +13 -12
- package/dist/managers/mcpManager.d.ts +3 -2
- package/dist/managers/mcpManager.d.ts.map +1 -1
- package/dist/managers/mcpManager.js +16 -15
- package/dist/managers/messageManager.d.ts +5 -7
- package/dist/managers/messageManager.d.ts.map +1 -1
- package/dist/managers/messageManager.js +12 -7
- package/dist/managers/permissionManager.d.ts +6 -4
- package/dist/managers/permissionManager.d.ts.map +1 -1
- package/dist/managers/permissionManager.js +39 -63
- package/dist/managers/planManager.d.ts +4 -6
- package/dist/managers/planManager.d.ts.map +1 -1
- package/dist/managers/planManager.js +18 -4
- package/dist/managers/pluginManager.d.ts +10 -22
- package/dist/managers/pluginManager.d.ts.map +1 -1
- package/dist/managers/pluginManager.js +27 -14
- package/dist/managers/reversionManager.d.ts +4 -3
- package/dist/managers/reversionManager.d.ts.map +1 -1
- package/dist/managers/reversionManager.js +5 -2
- package/dist/managers/skillManager.d.ts +3 -2
- package/dist/managers/skillManager.d.ts.map +1 -1
- package/dist/managers/skillManager.js +15 -14
- package/dist/managers/slashCommandManager.d.ts +9 -16
- package/dist/managers/slashCommandManager.d.ts.map +1 -1
- package/dist/managers/slashCommandManager.js +21 -10
- package/dist/managers/subagentManager.d.ts +7 -17
- package/dist/managers/subagentManager.d.ts.map +1 -1
- package/dist/managers/subagentManager.js +41 -34
- package/dist/managers/toolManager.d.ts +15 -38
- package/dist/managers/toolManager.d.ts.map +1 -1
- package/dist/managers/toolManager.js +66 -56
- package/dist/prompts/index.d.ts +6 -3
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +8 -16
- package/dist/services/MarketplaceService.d.ts.map +1 -1
- package/dist/services/MarketplaceService.js +13 -0
- package/dist/services/aiService.d.ts +4 -0
- package/dist/services/aiService.d.ts.map +1 -1
- package/dist/services/aiService.js +47 -7
- package/dist/services/configurationService.d.ts.map +1 -1
- package/dist/services/configurationService.js +30 -11
- package/dist/services/taskManager.d.ts +3 -1
- package/dist/services/taskManager.d.ts.map +1 -1
- package/dist/services/taskManager.js +2 -1
- package/dist/tools/bashTool.js +2 -2
- package/dist/tools/editTool.d.ts.map +1 -1
- package/dist/tools/editTool.js +9 -1
- package/dist/tools/readTool.d.ts.map +1 -1
- package/dist/tools/readTool.js +2 -2
- package/dist/tools/skillTool.d.ts +2 -4
- package/dist/tools/skillTool.d.ts.map +1 -1
- package/dist/tools/skillTool.js +61 -61
- package/dist/tools/taskOutputTool.js +1 -1
- package/dist/tools/taskTool.d.ts +2 -4
- package/dist/tools/taskTool.d.ts.map +1 -1
- package/dist/tools/taskTool.js +192 -187
- package/dist/tools/types.d.ts +11 -1
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/writeTool.d.ts.map +1 -1
- package/dist/tools/writeTool.js +4 -2
- package/dist/types/marketplace.d.ts +8 -0
- package/dist/types/marketplace.d.ts.map +1 -1
- package/dist/types/permissions.d.ts +1 -1
- package/dist/types/permissions.d.ts.map +1 -1
- package/dist/types/permissions.js +1 -3
- package/dist/types/skills.d.ts +0 -2
- package/dist/types/skills.d.ts.map +1 -1
- package/dist/types/tools.d.ts +0 -15
- package/dist/types/tools.d.ts.map +1 -1
- package/dist/utils/container.d.ts +31 -0
- package/dist/utils/container.d.ts.map +1 -0
- package/dist/utils/container.js +79 -0
- package/dist/utils/containerSetup.d.ts +26 -0
- package/dist/utils/containerSetup.d.ts.map +1 -0
- package/dist/utils/containerSetup.js +165 -0
- package/dist/utils/editUtils.d.ts +0 -3
- package/dist/utils/editUtils.d.ts.map +1 -1
- package/dist/utils/editUtils.js +4 -3
- package/dist/utils/hookMatcher.d.ts +1 -1
- package/dist/utils/hookMatcher.d.ts.map +1 -1
- package/dist/utils/hookMatcher.js +2 -2
- package/dist/utils/openaiClient.js +2 -2
- package/dist/utils/stringUtils.d.ts +6 -0
- package/dist/utils/stringUtils.d.ts.map +1 -1
- package/dist/utils/stringUtils.js +8 -0
- package/package.json +1 -1
- package/src/agent.ts +60 -282
- package/src/constants/tools.ts +0 -2
- package/src/core/plugin.ts +224 -0
- package/src/index.ts +1 -6
- package/src/managers/MemoryRuleManager.ts +6 -1
- package/src/managers/aiManager.ts +83 -58
- package/src/managers/backgroundTaskManager.ts +5 -1
- package/src/managers/bashManager.ts +9 -4
- package/src/managers/foregroundTaskManager.ts +3 -0
- package/src/managers/hookManager.ts +21 -23
- package/src/managers/liveConfigManager.ts +57 -53
- package/src/managers/lspManager.ts +14 -19
- package/src/managers/mcpManager.ts +20 -20
- package/src/managers/messageManager.ts +19 -12
- package/src/managers/permissionManager.ts +45 -70
- package/src/managers/planManager.ts +26 -7
- package/src/managers/pluginManager.ts +37 -33
- package/src/managers/reversionManager.ts +5 -3
- package/src/managers/skillManager.ts +19 -20
- package/src/managers/slashCommandManager.ts +30 -25
- package/src/managers/subagentManager.ts +53 -53
- package/src/managers/toolManager.ts +91 -90
- package/src/prompts/index.ts +12 -24
- package/src/services/MarketplaceService.ts +13 -0
- package/src/services/aiService.ts +61 -15
- package/src/services/configurationService.ts +34 -13
- package/src/services/taskManager.ts +5 -1
- package/src/tools/bashTool.ts +2 -2
- package/src/tools/editTool.ts +9 -1
- package/src/tools/readTool.ts +2 -2
- package/src/tools/skillTool.ts +75 -71
- package/src/tools/taskOutputTool.ts +1 -1
- package/src/tools/taskTool.ts +224 -225
- package/src/tools/types.ts +12 -1
- package/src/tools/writeTool.ts +4 -2
- package/src/types/marketplace.ts +9 -0
- package/src/types/permissions.ts +0 -4
- package/src/types/skills.ts +0 -3
- package/src/types/tools.ts +0 -17
- package/src/utils/container.ts +92 -0
- package/src/utils/containerSetup.ts +256 -0
- package/src/utils/editUtils.ts +4 -3
- package/src/utils/hookMatcher.ts +2 -2
- package/src/utils/openaiClient.ts +2 -2
- package/src/utils/stringUtils.ts +9 -0
- package/dist/tools/deleteFileTool.d.ts +0 -6
- package/dist/tools/deleteFileTool.d.ts.map +0 -1
- package/dist/tools/deleteFileTool.js +0 -100
- package/dist/tools/multiEditTool.d.ts +0 -6
- package/dist/tools/multiEditTool.d.ts.map +0 -1
- package/dist/tools/multiEditTool.js +0 -246
- package/src/tools/deleteFileTool.ts +0 -127
- package/src/tools/multiEditTool.ts +0 -306
|
@@ -10,20 +10,22 @@ import { minimatch } from "minimatch";
|
|
|
10
10
|
import { RESTRICTED_TOOLS } from "../types/permissions.js";
|
|
11
11
|
import { splitBashCommand, stripEnvVars, stripRedirections, getSmartPrefix, DANGEROUS_COMMANDS, } from "../utils/bashParser.js";
|
|
12
12
|
import { isPathInside } from "../utils/pathSafety.js";
|
|
13
|
-
import { BASH_TOOL_NAME, EDIT_TOOL_NAME,
|
|
13
|
+
import { BASH_TOOL_NAME, EDIT_TOOL_NAME, WRITE_TOOL_NAME, READ_TOOL_NAME, LS_TOOL_NAME, } from "../constants/tools.js";
|
|
14
14
|
const SAFE_COMMANDS = ["cd", "ls", "pwd", "true", "false"];
|
|
15
|
+
import { logger } from "../utils/globalLogger.js";
|
|
15
16
|
export class PermissionManager {
|
|
16
|
-
constructor(options = {}) {
|
|
17
|
+
constructor(container, options = {}) {
|
|
18
|
+
this.container = container;
|
|
17
19
|
this.allowedRules = [];
|
|
18
20
|
this.deniedRules = [];
|
|
19
21
|
this.temporaryRules = [];
|
|
20
22
|
this.additionalDirectories = [];
|
|
21
|
-
this.logger = options.logger;
|
|
22
23
|
this.configuredDefaultMode = options.configuredDefaultMode;
|
|
23
24
|
this.allowedRules = options.allowedRules || [];
|
|
24
25
|
this.deniedRules = options.deniedRules || [];
|
|
25
26
|
this.workdir = options.workdir;
|
|
26
27
|
this.planFilePath = options.planFilePath;
|
|
28
|
+
this._logger = options.logger;
|
|
27
29
|
this.updateAdditionalDirectories(options.additionalDirectories || []);
|
|
28
30
|
}
|
|
29
31
|
/**
|
|
@@ -37,7 +39,7 @@ export class PermissionManager {
|
|
|
37
39
|
*/
|
|
38
40
|
updateConfiguredDefaultMode(defaultMode) {
|
|
39
41
|
const oldEffectiveMode = this.getCurrentEffectiveMode();
|
|
40
|
-
|
|
42
|
+
logger?.debug("Updating configured default permission mode", {
|
|
41
43
|
previous: this.configuredDefaultMode,
|
|
42
44
|
new: defaultMode,
|
|
43
45
|
});
|
|
@@ -45,7 +47,7 @@ export class PermissionManager {
|
|
|
45
47
|
const newEffectiveMode = this.getCurrentEffectiveMode();
|
|
46
48
|
if (oldEffectiveMode !== newEffectiveMode &&
|
|
47
49
|
this.onConfiguredDefaultModeChange) {
|
|
48
|
-
|
|
50
|
+
logger?.debug("Effective permission mode changed due to configuration update", {
|
|
49
51
|
oldMode: oldEffectiveMode,
|
|
50
52
|
newMode: newEffectiveMode,
|
|
51
53
|
});
|
|
@@ -62,7 +64,7 @@ export class PermissionManager {
|
|
|
62
64
|
* Update the allowed rules (e.g., when configuration reloads)
|
|
63
65
|
*/
|
|
64
66
|
updateAllowedRules(rules) {
|
|
65
|
-
|
|
67
|
+
logger?.debug("Updating allowed permission rules", {
|
|
66
68
|
count: rules.length,
|
|
67
69
|
});
|
|
68
70
|
this.allowedRules = rules;
|
|
@@ -71,7 +73,7 @@ export class PermissionManager {
|
|
|
71
73
|
* Update the denied rules (e.g., when configuration reloads)
|
|
72
74
|
*/
|
|
73
75
|
updateDeniedRules(rules) {
|
|
74
|
-
|
|
76
|
+
logger?.debug("Updating denied permission rules", {
|
|
75
77
|
count: rules.length,
|
|
76
78
|
});
|
|
77
79
|
this.deniedRules = rules;
|
|
@@ -80,7 +82,7 @@ export class PermissionManager {
|
|
|
80
82
|
* Add temporary rules for the current session
|
|
81
83
|
*/
|
|
82
84
|
addTemporaryRules(rules) {
|
|
83
|
-
|
|
85
|
+
logger?.debug("Adding temporary permission rules", {
|
|
84
86
|
count: rules.length,
|
|
85
87
|
rules,
|
|
86
88
|
});
|
|
@@ -90,14 +92,14 @@ export class PermissionManager {
|
|
|
90
92
|
* Clear all temporary rules
|
|
91
93
|
*/
|
|
92
94
|
clearTemporaryRules() {
|
|
93
|
-
|
|
95
|
+
logger?.debug("Clearing temporary permission rules");
|
|
94
96
|
this.temporaryRules = [];
|
|
95
97
|
}
|
|
96
98
|
/**
|
|
97
99
|
* Update the additional directories (e.g., when configuration reloads)
|
|
98
100
|
*/
|
|
99
101
|
updateAdditionalDirectories(directories) {
|
|
100
|
-
|
|
102
|
+
logger?.debug("Updating additional directories", {
|
|
101
103
|
count: directories.length,
|
|
102
104
|
});
|
|
103
105
|
this.additionalDirectories = directories.map((dir) => {
|
|
@@ -111,7 +113,7 @@ export class PermissionManager {
|
|
|
111
113
|
* Update the working directory
|
|
112
114
|
*/
|
|
113
115
|
updateWorkdir(workdir) {
|
|
114
|
-
|
|
116
|
+
logger?.debug("Updating working directory", {
|
|
115
117
|
workdir,
|
|
116
118
|
});
|
|
117
119
|
this.workdir = workdir;
|
|
@@ -120,7 +122,7 @@ export class PermissionManager {
|
|
|
120
122
|
* Set the current plan file path
|
|
121
123
|
*/
|
|
122
124
|
setPlanFilePath(path) {
|
|
123
|
-
|
|
125
|
+
logger?.debug("Setting plan file path", { path });
|
|
124
126
|
this.planFilePath = path;
|
|
125
127
|
}
|
|
126
128
|
/**
|
|
@@ -148,7 +150,7 @@ export class PermissionManager {
|
|
|
148
150
|
return { isInside: true, resolvedPath: absolutePath };
|
|
149
151
|
}
|
|
150
152
|
}
|
|
151
|
-
|
|
153
|
+
logger?.debug("Path is outside Safe Zone", {
|
|
152
154
|
absolutePath,
|
|
153
155
|
workdir: effectiveWorkdir,
|
|
154
156
|
additionalDirectories: this.additionalDirectories,
|
|
@@ -167,7 +169,7 @@ export class PermissionManager {
|
|
|
167
169
|
resolveEffectivePermissionMode(cliPermissionMode) {
|
|
168
170
|
// CLI override takes highest precedence
|
|
169
171
|
if (cliPermissionMode !== undefined) {
|
|
170
|
-
|
|
172
|
+
logger?.debug("Using CLI permission mode override", {
|
|
171
173
|
cliMode: cliPermissionMode,
|
|
172
174
|
configuredDefault: this.configuredDefaultMode,
|
|
173
175
|
});
|
|
@@ -175,13 +177,13 @@ export class PermissionManager {
|
|
|
175
177
|
}
|
|
176
178
|
// Use configured default mode if available
|
|
177
179
|
if (this.configuredDefaultMode !== undefined) {
|
|
178
|
-
|
|
180
|
+
logger?.debug("Using configured default permission mode", {
|
|
179
181
|
configuredDefault: this.configuredDefaultMode,
|
|
180
182
|
});
|
|
181
183
|
return this.configuredDefaultMode;
|
|
182
184
|
}
|
|
183
185
|
// Fall back to system default
|
|
184
|
-
|
|
186
|
+
logger?.debug("Using system default permission mode");
|
|
185
187
|
return "default";
|
|
186
188
|
}
|
|
187
189
|
/**
|
|
@@ -189,7 +191,7 @@ export class PermissionManager {
|
|
|
189
191
|
* Called by individual tools after validation/diff, before real operation
|
|
190
192
|
*/
|
|
191
193
|
async checkPermission(context) {
|
|
192
|
-
|
|
194
|
+
logger?.debug("Checking permission for tool", {
|
|
193
195
|
toolName: context.toolName,
|
|
194
196
|
permissionMode: context.permissionMode,
|
|
195
197
|
hasCallback: !!context.canUseToolCallback,
|
|
@@ -197,7 +199,7 @@ export class PermissionManager {
|
|
|
197
199
|
// 0. Check denied rules first - Deny always takes precedence
|
|
198
200
|
for (const rule of this.deniedRules) {
|
|
199
201
|
if (this.matchesRule(context, rule)) {
|
|
200
|
-
|
|
202
|
+
logger?.warn("Permission denied by rule", {
|
|
201
203
|
toolName: context.toolName,
|
|
202
204
|
rule,
|
|
203
205
|
});
|
|
@@ -209,28 +211,22 @@ export class PermissionManager {
|
|
|
209
211
|
}
|
|
210
212
|
// 1. If bypassPermissions mode, always allow
|
|
211
213
|
if (context.permissionMode === "bypassPermissions") {
|
|
212
|
-
|
|
214
|
+
logger?.debug("Permission bypassed for tool", {
|
|
213
215
|
toolName: context.toolName,
|
|
214
216
|
});
|
|
215
217
|
return { behavior: "allow" };
|
|
216
218
|
}
|
|
217
|
-
// 1.1 If acceptEdits mode, allow Edit,
|
|
219
|
+
// 1.1 If acceptEdits mode, allow Edit, Write
|
|
218
220
|
if (context.permissionMode === "acceptEdits") {
|
|
219
|
-
const autoAcceptedTools = [
|
|
220
|
-
EDIT_TOOL_NAME,
|
|
221
|
-
MULTI_EDIT_TOOL_NAME,
|
|
222
|
-
DELETE_FILE_TOOL_NAME,
|
|
223
|
-
WRITE_TOOL_NAME,
|
|
224
|
-
];
|
|
221
|
+
const autoAcceptedTools = [EDIT_TOOL_NAME, WRITE_TOOL_NAME];
|
|
225
222
|
if (autoAcceptedTools.includes(context.toolName)) {
|
|
226
223
|
// Enforce Safe Zone for file operations
|
|
227
|
-
const targetPath =
|
|
228
|
-
context.toolInput?.target_file);
|
|
224
|
+
const targetPath = context.toolInput?.file_path;
|
|
229
225
|
const workdir = context.toolInput?.workdir;
|
|
230
226
|
if (targetPath) {
|
|
231
227
|
const { isInside, resolvedPath } = this.isInsideSafeZone(targetPath, workdir);
|
|
232
228
|
if (!isInside) {
|
|
233
|
-
|
|
229
|
+
logger?.info("File operation outside the Safe Zone in acceptEdits mode, falling back to manual confirmation", {
|
|
234
230
|
toolName: context.toolName,
|
|
235
231
|
targetPath,
|
|
236
232
|
resolvedPath,
|
|
@@ -238,7 +234,7 @@ export class PermissionManager {
|
|
|
238
234
|
// Fall through to normal permission check flow to trigger confirmation prompt
|
|
239
235
|
}
|
|
240
236
|
else {
|
|
241
|
-
|
|
237
|
+
logger?.debug("Permission automatically accepted for tool in acceptEdits mode", {
|
|
242
238
|
toolName: context.toolName,
|
|
243
239
|
});
|
|
244
240
|
return { behavior: "allow" };
|
|
@@ -248,33 +244,21 @@ export class PermissionManager {
|
|
|
248
244
|
}
|
|
249
245
|
// 1.2 Check if tool call is allowed by persistent or temporary rules
|
|
250
246
|
if (this.isAllowedByRule(context)) {
|
|
251
|
-
|
|
247
|
+
logger?.debug("Permission allowed by persistent rule", {
|
|
252
248
|
toolName: context.toolName,
|
|
253
249
|
});
|
|
254
250
|
return { behavior: "allow" };
|
|
255
251
|
}
|
|
256
252
|
// 1.3 If plan mode, allow Read-only tools and Edit/Write for plan file
|
|
257
253
|
if (context.permissionMode === "plan") {
|
|
258
|
-
const writeTools = [
|
|
259
|
-
EDIT_TOOL_NAME,
|
|
260
|
-
MULTI_EDIT_TOOL_NAME,
|
|
261
|
-
WRITE_TOOL_NAME,
|
|
262
|
-
DELETE_FILE_TOOL_NAME,
|
|
263
|
-
];
|
|
264
|
-
if (context.toolName === DELETE_FILE_TOOL_NAME) {
|
|
265
|
-
return {
|
|
266
|
-
behavior: "deny",
|
|
267
|
-
message: "Delete operations are not allowed in plan mode.",
|
|
268
|
-
};
|
|
269
|
-
}
|
|
254
|
+
const writeTools = [EDIT_TOOL_NAME, WRITE_TOOL_NAME];
|
|
270
255
|
if (writeTools.includes(context.toolName)) {
|
|
271
|
-
const targetPath =
|
|
272
|
-
context.toolInput?.target_file);
|
|
256
|
+
const targetPath = context.toolInput?.file_path;
|
|
273
257
|
if (this.planFilePath && targetPath) {
|
|
274
258
|
const absoluteTargetPath = path.resolve(targetPath);
|
|
275
259
|
const absolutePlanPath = path.resolve(this.planFilePath);
|
|
276
260
|
if (absoluteTargetPath === absolutePlanPath) {
|
|
277
|
-
|
|
261
|
+
logger?.debug("Allowing write to plan file in plan mode", {
|
|
278
262
|
toolName: context.toolName,
|
|
279
263
|
targetPath,
|
|
280
264
|
});
|
|
@@ -289,7 +273,7 @@ export class PermissionManager {
|
|
|
289
273
|
}
|
|
290
274
|
// 2. If not a restricted tool, always allow
|
|
291
275
|
if (!this.isRestrictedTool(context.toolName)) {
|
|
292
|
-
|
|
276
|
+
logger?.debug("Tool is not restricted, allowing", {
|
|
293
277
|
toolName: context.toolName,
|
|
294
278
|
});
|
|
295
279
|
return { behavior: "allow" };
|
|
@@ -297,11 +281,11 @@ export class PermissionManager {
|
|
|
297
281
|
// 3. If custom callback provided, call it and return result
|
|
298
282
|
if (context.canUseToolCallback) {
|
|
299
283
|
try {
|
|
300
|
-
|
|
284
|
+
logger?.debug("Calling custom permission callback for tool", {
|
|
301
285
|
toolName: context.toolName,
|
|
302
286
|
});
|
|
303
287
|
const decision = await context.canUseToolCallback(context);
|
|
304
|
-
|
|
288
|
+
logger?.debug("Custom callback returned decision", {
|
|
305
289
|
toolName: context.toolName,
|
|
306
290
|
decision,
|
|
307
291
|
});
|
|
@@ -309,7 +293,7 @@ export class PermissionManager {
|
|
|
309
293
|
}
|
|
310
294
|
catch (error) {
|
|
311
295
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
312
|
-
|
|
296
|
+
logger?.error("Error in permission callback", {
|
|
313
297
|
toolName: context.toolName,
|
|
314
298
|
error: errorMessage,
|
|
315
299
|
});
|
|
@@ -321,7 +305,7 @@ export class PermissionManager {
|
|
|
321
305
|
}
|
|
322
306
|
// 4. For default mode on restricted tools without callback, integrate with CLI confirmation
|
|
323
307
|
// Note: CLI confirmation integration will be implemented in Phase 2
|
|
324
|
-
|
|
308
|
+
logger?.warn("No permission callback provided for restricted tool in default mode", {
|
|
325
309
|
toolName: context.toolName,
|
|
326
310
|
});
|
|
327
311
|
return {
|
|
@@ -334,7 +318,7 @@ export class PermissionManager {
|
|
|
334
318
|
*/
|
|
335
319
|
isRestrictedTool(toolName) {
|
|
336
320
|
const isRestricted = RESTRICTED_TOOLS.includes(toolName);
|
|
337
|
-
|
|
321
|
+
logger?.debug("Checking if tool is restricted", {
|
|
338
322
|
toolName,
|
|
339
323
|
isRestricted,
|
|
340
324
|
});
|
|
@@ -362,14 +346,9 @@ export class PermissionManager {
|
|
|
362
346
|
suggestedPrefix,
|
|
363
347
|
};
|
|
364
348
|
// Set hidePersistentOption for out-of-bounds file operations
|
|
365
|
-
const fileTools = [
|
|
366
|
-
EDIT_TOOL_NAME,
|
|
367
|
-
MULTI_EDIT_TOOL_NAME,
|
|
368
|
-
DELETE_FILE_TOOL_NAME,
|
|
369
|
-
WRITE_TOOL_NAME,
|
|
370
|
-
];
|
|
349
|
+
const fileTools = [EDIT_TOOL_NAME, WRITE_TOOL_NAME];
|
|
371
350
|
if (fileTools.includes(toolName)) {
|
|
372
|
-
const targetPath =
|
|
351
|
+
const targetPath = toolInput?.file_path;
|
|
373
352
|
const workdir = toolInput?.workdir;
|
|
374
353
|
if (targetPath) {
|
|
375
354
|
const { isInside } = this.isInsideSafeZone(targetPath, workdir);
|
|
@@ -409,7 +388,7 @@ export class PermissionManager {
|
|
|
409
388
|
context.hidePersistentOption = true;
|
|
410
389
|
}
|
|
411
390
|
}
|
|
412
|
-
|
|
391
|
+
logger?.debug("Created permission context", {
|
|
413
392
|
toolName,
|
|
414
393
|
permissionMode,
|
|
415
394
|
hasCallback: !!callback,
|
|
@@ -453,13 +432,10 @@ export class PermissionManager {
|
|
|
453
432
|
READ_TOOL_NAME,
|
|
454
433
|
WRITE_TOOL_NAME,
|
|
455
434
|
EDIT_TOOL_NAME,
|
|
456
|
-
MULTI_EDIT_TOOL_NAME,
|
|
457
|
-
DELETE_FILE_TOOL_NAME,
|
|
458
435
|
LS_TOOL_NAME,
|
|
459
436
|
];
|
|
460
437
|
if (pathTools.includes(toolName)) {
|
|
461
438
|
const targetPath = (context.toolInput?.file_path ||
|
|
462
|
-
context.toolInput?.target_file ||
|
|
463
439
|
context.toolInput?.path);
|
|
464
440
|
if (targetPath) {
|
|
465
441
|
return minimatch(targetPath, pattern, { dot: true });
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
/**
|
|
3
|
-
* Manages plan files for plan mode
|
|
4
|
-
*/
|
|
1
|
+
import { Container } from "../utils/container.js";
|
|
5
2
|
export declare class PlanManager {
|
|
6
|
-
private
|
|
3
|
+
private container;
|
|
7
4
|
private planDir;
|
|
8
|
-
|
|
5
|
+
private currentPlanFilePath;
|
|
6
|
+
constructor(container: Container);
|
|
9
7
|
/**
|
|
10
8
|
* Ensures the plan directory exists and generates a new plan file path with a random name
|
|
11
9
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planManager.d.ts","sourceRoot":"","sources":["../../src/managers/planManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"planManager.d.ts","sourceRoot":"","sources":["../../src/managers/planManager.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAOlD,qBAAa,WAAW;IAIV,OAAO,CAAC,SAAS;IAH7B,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,mBAAmB,CAAuB;gBAE9B,SAAS,EAAE,SAAS;IAIxC;;OAEG;IACU,yBAAyB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;QAC7D,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IA+BF;;OAEG;IACI,UAAU,IAAI,MAAM;CAG5B"}
|
|
@@ -5,9 +5,11 @@ import { generateRandomName } from "../utils/nameGenerator.js";
|
|
|
5
5
|
/**
|
|
6
6
|
* Manages plan files for plan mode
|
|
7
7
|
*/
|
|
8
|
+
import { logger } from "../utils/globalLogger.js";
|
|
8
9
|
export class PlanManager {
|
|
9
|
-
constructor(
|
|
10
|
-
this.
|
|
10
|
+
constructor(container) {
|
|
11
|
+
this.container = container;
|
|
12
|
+
this.currentPlanFilePath = null;
|
|
11
13
|
this.planDir = path.join(os.homedir(), ".wave", "plans");
|
|
12
14
|
}
|
|
13
15
|
/**
|
|
@@ -18,12 +20,24 @@ export class PlanManager {
|
|
|
18
20
|
await fs.mkdir(this.planDir, { recursive: true });
|
|
19
21
|
}
|
|
20
22
|
catch (error) {
|
|
21
|
-
|
|
23
|
+
logger?.error(`Failed to create plan directory: ${this.planDir}`, error);
|
|
22
24
|
throw error;
|
|
23
25
|
}
|
|
24
26
|
const name = generateRandomName(seed);
|
|
25
27
|
const filePath = path.join(this.planDir, `${name}.md`);
|
|
26
|
-
this.
|
|
28
|
+
if (this.currentPlanFilePath !== filePath) {
|
|
29
|
+
try {
|
|
30
|
+
await fs.unlink(filePath);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
if (error instanceof Error &&
|
|
34
|
+
error.code !== "ENOENT") {
|
|
35
|
+
logger?.error(`Failed to remove existing plan file: ${filePath}`, error);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
this.currentPlanFilePath = filePath;
|
|
39
|
+
}
|
|
40
|
+
logger?.info(`Generated plan file path: ${filePath}`);
|
|
27
41
|
return { path: filePath, name };
|
|
28
42
|
}
|
|
29
43
|
/**
|
|
@@ -1,33 +1,21 @@
|
|
|
1
|
-
import { Plugin, PluginConfig
|
|
2
|
-
import {
|
|
3
|
-
import { HookManager } from "./hookManager.js";
|
|
4
|
-
import { LspManager } from "./lspManager.js";
|
|
5
|
-
import { McpManager } from "./mcpManager.js";
|
|
6
|
-
import { SlashCommandManager } from "./slashCommandManager.js";
|
|
7
|
-
import { ConfigurationService } from "../services/configurationService.js";
|
|
1
|
+
import { Plugin, PluginConfig } from "../types/index.js";
|
|
2
|
+
import { Container } from "../utils/container.js";
|
|
8
3
|
export interface PluginManagerOptions {
|
|
9
4
|
workdir: string;
|
|
10
|
-
logger?: Logger;
|
|
11
|
-
skillManager?: SkillManager;
|
|
12
|
-
hookManager?: HookManager;
|
|
13
|
-
lspManager?: LspManager;
|
|
14
|
-
mcpManager?: McpManager;
|
|
15
|
-
slashCommandManager?: SlashCommandManager;
|
|
16
5
|
enabledPlugins?: Record<string, boolean>;
|
|
17
|
-
configurationService?: ConfigurationService;
|
|
18
6
|
}
|
|
19
7
|
export declare class PluginManager {
|
|
8
|
+
private container;
|
|
20
9
|
private plugins;
|
|
21
10
|
private workdir;
|
|
22
|
-
private logger?;
|
|
23
|
-
private skillManager?;
|
|
24
|
-
private hookManager?;
|
|
25
|
-
private lspManager?;
|
|
26
|
-
private mcpManager?;
|
|
27
|
-
private slashCommandManager?;
|
|
28
11
|
private enabledPlugins;
|
|
29
|
-
|
|
30
|
-
|
|
12
|
+
constructor(container: Container, options: PluginManagerOptions);
|
|
13
|
+
private get skillManager();
|
|
14
|
+
private get hookManager();
|
|
15
|
+
private get lspManager();
|
|
16
|
+
private get mcpManager();
|
|
17
|
+
private get slashCommandManager();
|
|
18
|
+
private get configurationService();
|
|
31
19
|
/**
|
|
32
20
|
* Update enabled plugins configuration
|
|
33
21
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pluginManager.d.ts","sourceRoot":"","sources":["../../src/managers/pluginManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pluginManager.d.ts","sourceRoot":"","sources":["../../src/managers/pluginManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAUzD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC1C;AAED,qBAAa,aAAa;IAMtB,OAAO,CAAC,SAAS;IALnB,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,cAAc,CAA0B;gBAGtC,SAAS,EAAE,SAAS,EAC5B,OAAO,EAAE,oBAAoB;IAM/B,OAAO,KAAK,YAAY,GAEvB;IAED,OAAO,KAAK,WAAW,GAEtB;IAED,OAAO,KAAK,UAAU,GAErB;IAED,OAAO,KAAK,UAAU,GAErB;IAED,OAAO,KAAK,mBAAmB,GAE9B;IAED,OAAO,KAAK,oBAAoB,GAE/B;IAED;;OAEG;IACH,oBAAoB,CAAC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAInE;;OAEG;YACW,oBAAoB;IAyBlC;;OAEG;YACW,gBAAgB;IAyD9B;;;OAGG;IACG,WAAW,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBzD;;OAEG;IACH,UAAU,IAAI,MAAM,EAAE;IAItB;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAG5C"}
|
|
@@ -1,18 +1,31 @@
|
|
|
1
|
+
import { logger } from "../utils/globalLogger.js";
|
|
1
2
|
import { PluginLoader } from "../services/pluginLoader.js";
|
|
2
3
|
import * as path from "path";
|
|
3
4
|
import { MarketplaceService } from "../services/MarketplaceService.js";
|
|
4
5
|
export class PluginManager {
|
|
5
|
-
constructor(options) {
|
|
6
|
+
constructor(container, options) {
|
|
7
|
+
this.container = container;
|
|
6
8
|
this.plugins = new Map();
|
|
7
9
|
this.workdir = options.workdir;
|
|
8
|
-
this.logger = options.logger;
|
|
9
|
-
this.skillManager = options.skillManager;
|
|
10
|
-
this.hookManager = options.hookManager;
|
|
11
|
-
this.lspManager = options.lspManager;
|
|
12
|
-
this.mcpManager = options.mcpManager;
|
|
13
|
-
this.slashCommandManager = options.slashCommandManager;
|
|
14
10
|
this.enabledPlugins = options.enabledPlugins || {};
|
|
15
|
-
|
|
11
|
+
}
|
|
12
|
+
get skillManager() {
|
|
13
|
+
return this.container.get("SkillManager");
|
|
14
|
+
}
|
|
15
|
+
get hookManager() {
|
|
16
|
+
return this.container.get("HookManager");
|
|
17
|
+
}
|
|
18
|
+
get lspManager() {
|
|
19
|
+
return this.container.get("LspManager");
|
|
20
|
+
}
|
|
21
|
+
get mcpManager() {
|
|
22
|
+
return this.container.get("McpManager");
|
|
23
|
+
}
|
|
24
|
+
get slashCommandManager() {
|
|
25
|
+
return this.container.get("SlashCommandManager");
|
|
26
|
+
}
|
|
27
|
+
get configurationService() {
|
|
28
|
+
return this.container.get("ConfigurationService");
|
|
16
29
|
}
|
|
17
30
|
/**
|
|
18
31
|
* Update enabled plugins configuration
|
|
@@ -34,14 +47,14 @@ export class PluginManager {
|
|
|
34
47
|
for (const p of installedRegistry.plugins) {
|
|
35
48
|
const pluginId = `${p.name}@${p.marketplace}`;
|
|
36
49
|
if (this.enabledPlugins[pluginId] !== true) {
|
|
37
|
-
|
|
50
|
+
logger?.info(`Plugin ${pluginId} is not enabled via configuration`);
|
|
38
51
|
continue;
|
|
39
52
|
}
|
|
40
53
|
await this.loadSinglePlugin(p.cachePath);
|
|
41
54
|
}
|
|
42
55
|
}
|
|
43
56
|
catch (error) {
|
|
44
|
-
|
|
57
|
+
logger?.error("Failed to load installed plugins:", error);
|
|
45
58
|
}
|
|
46
59
|
}
|
|
47
60
|
/**
|
|
@@ -52,7 +65,7 @@ export class PluginManager {
|
|
|
52
65
|
const manifest = await PluginLoader.loadManifest(absolutePath);
|
|
53
66
|
if (this.plugins.has(manifest.name)) {
|
|
54
67
|
// If already loaded (e.g. via explicit config), skip
|
|
55
|
-
|
|
68
|
+
logger?.warn(`Plugin with name '${manifest.name}' is already loaded`);
|
|
56
69
|
return;
|
|
57
70
|
}
|
|
58
71
|
const plugin = {
|
|
@@ -85,10 +98,10 @@ export class PluginManager {
|
|
|
85
98
|
this.hookManager.registerPluginHooks(plugin.hooksConfig);
|
|
86
99
|
}
|
|
87
100
|
this.plugins.set(manifest.name, plugin);
|
|
88
|
-
|
|
101
|
+
logger?.info(`Loaded plugin: ${manifest.name} v${manifest.version}`);
|
|
89
102
|
}
|
|
90
103
|
catch (error) {
|
|
91
|
-
|
|
104
|
+
logger?.error(`Failed to load plugin from ${absolutePath}`, error);
|
|
92
105
|
}
|
|
93
106
|
}
|
|
94
107
|
/**
|
|
@@ -99,7 +112,7 @@ export class PluginManager {
|
|
|
99
112
|
// Load plugins from configuration (e.g. --plugin-dir) first to give them higher priority
|
|
100
113
|
for (const config of configs) {
|
|
101
114
|
if (config.type !== "local") {
|
|
102
|
-
|
|
115
|
+
logger?.warn(`Unsupported plugin type: ${config.type}`);
|
|
103
116
|
continue;
|
|
104
117
|
}
|
|
105
118
|
const absolutePath = path.isAbsolute(config.path)
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { FileSnapshot } from "../types/reversion.js";
|
|
2
|
-
import {
|
|
2
|
+
import { Container } from "../utils/container.js";
|
|
3
3
|
export declare class ReversionManager {
|
|
4
|
+
private container;
|
|
4
5
|
private buffer;
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
constructor(container: Container);
|
|
7
|
+
private get reversionService();
|
|
7
8
|
/**
|
|
8
9
|
* Records the current state of a file into a temporary buffer.
|
|
9
10
|
* Returns a snapshotId.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reversionManager.d.ts","sourceRoot":"","sources":["../../src/managers/reversionManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"reversionManager.d.ts","sourceRoot":"","sources":["../../src/managers/reversionManager.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,qBAAa,gBAAgB;IAGf,OAAO,CAAC,SAAS;IAF7B,OAAO,CAAC,MAAM,CAAwC;gBAElC,SAAS,EAAE,SAAS;IAExC,OAAO,KAAK,gBAAgB,GAE3B;IAED;;;OAGG;IACG,cAAc,CAClB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GACxC,OAAO,CAAC,MAAM,CAAC;IAuBlB;;;OAGG;IACG,oBAAoB,CACxB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GACxC,OAAO,CAAC,MAAM,CAAC;IAIlB;;;OAGG;IACG,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBvD,OAAO,CAAC,kBAAkB,CAAsB;IAEhD;;OAEG;IACH,6BAA6B,IAAI,YAAY,EAAE;IAM/C;;;OAGG;IACH,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAIzC;;;;OAIG;IACG,QAAQ,CACZ,UAAU,EAAE,MAAM,EAAE,EACpB,WAAW,EAAE,OAAO,mBAAmB,EAAE,OAAO,EAAE,GACjD,OAAO,CAAC,MAAM,CAAC;CAqEnB"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import fs from "fs/promises";
|
|
2
2
|
export class ReversionManager {
|
|
3
|
-
constructor(
|
|
3
|
+
constructor(container) {
|
|
4
|
+
this.container = container;
|
|
4
5
|
this.buffer = new Map();
|
|
5
6
|
this.committedSnapshots = [];
|
|
6
|
-
|
|
7
|
+
}
|
|
8
|
+
get reversionService() {
|
|
9
|
+
return this.container.get("ReversionService");
|
|
7
10
|
}
|
|
8
11
|
/**
|
|
9
12
|
* Records the current state of a file into a temporary buffer.
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import type { SkillManagerOptions, SkillMetadata, Skill, SkillToolArgs, SkillInvocationContext } from "../types/index.js";
|
|
2
|
+
import { Container } from "../utils/container.js";
|
|
2
3
|
/**
|
|
3
4
|
* Manages skill discovery and loading
|
|
4
5
|
*/
|
|
5
6
|
export declare class SkillManager {
|
|
7
|
+
private container;
|
|
6
8
|
private personalSkillsPath;
|
|
7
9
|
private scanTimeout;
|
|
8
|
-
private logger?;
|
|
9
10
|
private workdir;
|
|
10
11
|
private skillMetadata;
|
|
11
12
|
private skillContent;
|
|
12
13
|
private initialized;
|
|
13
|
-
constructor(options?: SkillManagerOptions);
|
|
14
|
+
constructor(container: Container, options?: SkillManagerOptions);
|
|
14
15
|
/**
|
|
15
16
|
* Initialize the skill manager by discovering available skills
|
|
16
17
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skillManager.d.ts","sourceRoot":"","sources":["../../src/managers/skillManager.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EACb,KAAK,EAGL,aAAa,EACb,sBAAsB,
|
|
1
|
+
{"version":3,"file":"skillManager.d.ts","sourceRoot":"","sources":["../../src/managers/skillManager.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,mBAAmB,EACnB,aAAa,EACb,KAAK,EAGL,aAAa,EACb,sBAAsB,EACvB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGlD;;GAEG;AACH,qBAAa,YAAY;IAUrB,OAAO,CAAC,SAAS;IATnB,OAAO,CAAC,kBAAkB,CAAS;IACnC,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,OAAO,CAAS;IAExB,OAAO,CAAC,aAAa,CAAoC;IACzD,OAAO,CAAC,YAAY,CAA4B;IAChD,OAAO,CAAC,WAAW,CAAS;gBAGlB,SAAS,EAAE,SAAS,EAC5B,OAAO,GAAE,mBAAwB;IAQnC;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAoCjC;;OAEG;IACH,aAAa,IAAI,OAAO;IAIxB;;OAEG;IACH,kBAAkB,IAAI,aAAa,EAAE;IAQrC;;;OAGG;IACG,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC;IAgBzD;;OAEG;YACW,cAAc;IAkB5B;;OAEG;YACW,uBAAuB;IAiFrC;;OAEG;YACW,oBAAoB;IAkBlC;;OAEG;IACG,YAAY,CAChB,IAAI,EAAE,aAAa,GAClB,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,sBAAsB,CAAA;KAAE,CAAC;IAqCjE;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAY1B;;OAEG;IACH,OAAO,CAAC,qBAAqB;IAc7B;;OAEG;IACH,oBAAoB,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI;CAc5C"}
|