wave-agent-sdk 0.2.1 → 0.5.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 +66 -20
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +156 -83
- package/dist/constants/prompts.d.ts +7 -2
- package/dist/constants/prompts.d.ts.map +1 -1
- package/dist/constants/prompts.js +41 -5
- package/dist/constants/tools.d.ts +2 -2
- package/dist/constants/tools.js +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/managers/MemoryRuleManager.d.ts.map +1 -1
- package/dist/managers/MemoryRuleManager.js +16 -2
- package/dist/managers/aiManager.d.ts +14 -4
- package/dist/managers/aiManager.d.ts.map +1 -1
- package/dist/managers/aiManager.js +61 -9
- 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/bashManager.d.ts.map +1 -1
- package/dist/managers/bashManager.js +0 -3
- 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/liveConfigManager.d.ts.map +1 -1
- package/dist/managers/lspManager.d.ts.map +1 -1
- package/dist/managers/lspManager.js +3 -1
- package/dist/managers/messageManager.d.ts +34 -4
- package/dist/managers/messageManager.d.ts.map +1 -1
- package/dist/managers/messageManager.js +104 -13
- package/dist/managers/permissionManager.d.ts.map +1 -1
- package/dist/managers/permissionManager.js +11 -13
- package/dist/managers/pluginManager.d.ts.map +1 -1
- package/dist/managers/pluginManager.js +3 -2
- package/dist/managers/pluginScopeManager.d.ts +13 -2
- package/dist/managers/pluginScopeManager.d.ts.map +1 -1
- package/dist/managers/pluginScopeManager.js +38 -0
- package/dist/managers/reversionManager.d.ts +39 -0
- package/dist/managers/reversionManager.d.ts.map +1 -0
- package/dist/managers/reversionManager.js +118 -0
- package/dist/managers/slashCommandManager.d.ts +4 -1
- package/dist/managers/slashCommandManager.d.ts.map +1 -1
- package/dist/managers/slashCommandManager.js +16 -6
- package/dist/managers/subagentManager.d.ts +13 -2
- package/dist/managers/subagentManager.d.ts.map +1 -1
- package/dist/managers/subagentManager.js +144 -35
- package/dist/managers/toolManager.d.ts +11 -1
- package/dist/managers/toolManager.d.ts.map +1 -1
- package/dist/managers/toolManager.js +11 -3
- package/dist/services/GitService.d.ts.map +1 -1
- package/dist/services/GitService.js +6 -2
- package/dist/services/MarketplaceService.d.ts +14 -1
- package/dist/services/MarketplaceService.d.ts.map +1 -1
- package/dist/services/MarketplaceService.js +72 -4
- 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/aiService.js +1 -1
- package/dist/services/configurationService.d.ts +18 -2
- package/dist/services/configurationService.d.ts.map +1 -1
- package/dist/services/configurationService.js +62 -0
- package/dist/services/fileWatcher.d.ts +0 -5
- package/dist/services/fileWatcher.d.ts.map +1 -1
- package/dist/services/fileWatcher.js +0 -11
- package/dist/services/memory.js +1 -1
- package/dist/services/pluginLoader.d.ts.map +1 -1
- package/dist/services/pluginLoader.js +6 -1
- package/dist/services/reversionService.d.ts +24 -0
- package/dist/services/reversionService.d.ts.map +1 -0
- package/dist/services/reversionService.js +76 -0
- package/dist/services/session.d.ts +7 -0
- package/dist/services/session.d.ts.map +1 -1
- package/dist/services/session.js +126 -3
- package/dist/tools/bashTool.d.ts +0 -8
- package/dist/tools/bashTool.d.ts.map +1 -1
- package/dist/tools/bashTool.js +52 -174
- package/dist/tools/deleteFileTool.d.ts.map +1 -1
- package/dist/tools/deleteFileTool.js +9 -0
- package/dist/tools/editTool.d.ts.map +1 -1
- package/dist/tools/editTool.js +15 -4
- package/dist/tools/multiEditTool.d.ts.map +1 -1
- package/dist/tools/multiEditTool.js +16 -5
- 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 +7 -0
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/tools/writeTool.d.ts.map +1 -1
- package/dist/tools/writeTool.js +9 -0
- package/dist/types/commands.d.ts +1 -0
- package/dist/types/commands.d.ts.map +1 -1
- package/dist/types/configuration.d.ts +3 -0
- package/dist/types/configuration.d.ts.map +1 -1
- package/dist/types/environment.d.ts +2 -1
- package/dist/types/environment.d.ts.map +1 -1
- package/dist/types/environment.js +0 -6
- package/dist/types/history.d.ts +5 -0
- package/dist/types/history.d.ts.map +1 -0
- package/dist/types/history.js +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/marketplace.d.ts +4 -0
- package/dist/types/marketplace.d.ts.map +1 -1
- package/dist/types/messaging.d.ts +7 -1
- 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/types/reversion.d.ts +29 -0
- package/dist/types/reversion.d.ts.map +1 -0
- package/dist/types/reversion.js +1 -0
- package/dist/utils/builtinSubagents.d.ts.map +1 -1
- package/dist/utils/builtinSubagents.js +16 -0
- package/dist/utils/constants.d.ts +2 -2
- package/dist/utils/constants.d.ts.map +1 -1
- package/dist/utils/constants.js +2 -2
- package/dist/utils/editUtils.d.ts +4 -9
- package/dist/utils/editUtils.d.ts.map +1 -1
- package/dist/utils/editUtils.js +54 -55
- package/dist/utils/messageOperations.d.ts +3 -1
- package/dist/utils/messageOperations.d.ts.map +1 -1
- package/dist/utils/messageOperations.js +8 -1
- package/dist/utils/openaiClient.d.ts.map +1 -1
- package/dist/utils/openaiClient.js +56 -26
- package/dist/utils/promptHistory.d.ts +20 -0
- package/dist/utils/promptHistory.d.ts.map +1 -0
- package/dist/utils/promptHistory.js +117 -0
- package/package.json +5 -3
- package/src/agent.ts +193 -109
- package/src/constants/prompts.ts +45 -5
- package/src/constants/tools.ts +2 -2
- package/src/index.ts +1 -1
- package/src/managers/MemoryRuleManager.ts +18 -2
- package/src/managers/aiManager.ts +87 -18
- package/src/managers/backgroundBashManager.ts +1 -0
- package/src/managers/backgroundTaskManager.ts +306 -0
- package/src/managers/bashManager.ts +0 -4
- package/src/managers/foregroundTaskManager.ts +26 -0
- package/src/managers/liveConfigManager.ts +2 -1
- package/src/managers/lspManager.ts +3 -1
- package/src/managers/messageManager.ts +136 -18
- package/src/managers/permissionManager.ts +11 -13
- package/src/managers/pluginManager.ts +4 -3
- package/src/managers/pluginScopeManager.ts +57 -8
- package/src/managers/reversionManager.ts +152 -0
- package/src/managers/slashCommandManager.ts +30 -7
- package/src/managers/subagentManager.ts +176 -31
- package/src/managers/toolManager.ts +23 -4
- package/src/services/GitService.ts +6 -2
- package/src/services/MarketplaceService.ts +100 -4
- package/src/services/MemoryRuleService.ts +18 -6
- package/src/services/aiService.ts +1 -1
- package/src/services/configurationService.ts +79 -1
- package/src/services/fileWatcher.ts +0 -13
- package/src/services/memory.ts +1 -1
- package/src/services/pluginLoader.ts +7 -1
- package/src/services/reversionService.ts +94 -0
- package/src/services/session.ts +161 -3
- package/src/tools/bashTool.ts +73 -200
- package/src/tools/deleteFileTool.ts +15 -0
- package/src/tools/editTool.ts +20 -10
- package/src/tools/multiEditTool.ts +21 -11
- 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 +7 -0
- package/src/tools/writeTool.ts +14 -0
- package/src/types/commands.ts +3 -0
- package/src/types/configuration.ts +4 -0
- package/src/types/environment.ts +3 -1
- package/src/types/history.ts +4 -0
- package/src/types/index.ts +1 -0
- package/src/types/marketplace.ts +5 -0
- package/src/types/messaging.ts +9 -1
- package/src/types/processes.ts +33 -4
- package/src/types/reversion.ts +29 -0
- package/src/utils/builtinSubagents.ts +18 -0
- package/src/utils/constants.ts +2 -2
- package/src/utils/editUtils.ts +66 -58
- package/src/utils/messageOperations.ts +10 -0
- package/src/utils/openaiClient.ts +69 -35
- package/src/utils/promptHistory.ts +133 -0
- package/dist/utils/bashHistory.d.ts +0 -50
- package/dist/utils/bashHistory.d.ts.map +0 -1
- package/dist/utils/bashHistory.js +0 -256
- package/src/utils/bashHistory.ts +0 -320
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { TASK_STOP_TOOL_NAME } from "../constants/tools.js";
|
|
2
|
+
import { ToolContext, ToolPlugin, ToolResult } from "./types.js";
|
|
3
|
+
|
|
4
|
+
export const taskStopTool: ToolPlugin = {
|
|
5
|
+
name: TASK_STOP_TOOL_NAME,
|
|
6
|
+
config: {
|
|
7
|
+
type: "function",
|
|
8
|
+
function: {
|
|
9
|
+
name: TASK_STOP_TOOL_NAME,
|
|
10
|
+
description: "Stops a running background task",
|
|
11
|
+
parameters: {
|
|
12
|
+
type: "object",
|
|
13
|
+
properties: {
|
|
14
|
+
task_id: {
|
|
15
|
+
type: "string",
|
|
16
|
+
description: "The ID of the background task to stop",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
required: ["task_id"],
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
execute: async (
|
|
24
|
+
args: Record<string, unknown>,
|
|
25
|
+
context: ToolContext,
|
|
26
|
+
): Promise<ToolResult> => {
|
|
27
|
+
const taskId = args.task_id as string;
|
|
28
|
+
|
|
29
|
+
if (!taskId || typeof taskId !== "string") {
|
|
30
|
+
return {
|
|
31
|
+
success: false,
|
|
32
|
+
content: "",
|
|
33
|
+
error: "task_id parameter is required and must be a string",
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const backgroundTaskManager = context?.backgroundTaskManager;
|
|
38
|
+
if (!backgroundTaskManager) {
|
|
39
|
+
return {
|
|
40
|
+
success: false,
|
|
41
|
+
content: "",
|
|
42
|
+
error: "Background task manager not available",
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const stopped = backgroundTaskManager.stopTask(taskId);
|
|
47
|
+
if (stopped) {
|
|
48
|
+
return {
|
|
49
|
+
success: true,
|
|
50
|
+
content: `Task ${taskId} has been stopped`,
|
|
51
|
+
shortResult: `Stopped ${taskId}`,
|
|
52
|
+
};
|
|
53
|
+
} else {
|
|
54
|
+
const task = backgroundTaskManager.getTask(taskId);
|
|
55
|
+
if (!task) {
|
|
56
|
+
return {
|
|
57
|
+
success: false,
|
|
58
|
+
content: "",
|
|
59
|
+
error: `Task with ID ${taskId} not found`,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
success: false,
|
|
64
|
+
content: "",
|
|
65
|
+
error: `Failed to stop task ${taskId} (status: ${task.status})`,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
formatCompactParams: (params: Record<string, unknown>) => {
|
|
70
|
+
return params.task_id as string;
|
|
71
|
+
},
|
|
72
|
+
};
|
package/src/tools/taskTool.ts
CHANGED
|
@@ -46,6 +46,11 @@ export function createTaskTool(subagentManager: SubagentManager): ToolPlugin {
|
|
|
46
46
|
type: "string",
|
|
47
47
|
description: `The type or name of subagent to use. Available options: ${availableSubagents.map((c) => c.name).join(", ") || "none"}`,
|
|
48
48
|
},
|
|
49
|
+
run_in_background: {
|
|
50
|
+
type: "boolean",
|
|
51
|
+
description:
|
|
52
|
+
"Set to true to run this command in the background. Use TaskOutput to read the output later.",
|
|
53
|
+
},
|
|
49
54
|
},
|
|
50
55
|
required: ["description", "prompt", "subagent_type"],
|
|
51
56
|
},
|
|
@@ -57,80 +62,131 @@ export function createTaskTool(subagentManager: SubagentManager): ToolPlugin {
|
|
|
57
62
|
args: Record<string, unknown>,
|
|
58
63
|
context: ToolContext,
|
|
59
64
|
): Promise<ToolResult> => {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
65
|
+
return new Promise((resolve) => {
|
|
66
|
+
(async () => {
|
|
67
|
+
// Input validation
|
|
68
|
+
const description = args.description as string;
|
|
69
|
+
const prompt = args.prompt as string;
|
|
70
|
+
const subagent_type = args.subagent_type as string;
|
|
71
|
+
const run_in_background = args.run_in_background as boolean;
|
|
72
|
+
|
|
73
|
+
if (!description || typeof description !== "string") {
|
|
74
|
+
return resolve({
|
|
75
|
+
success: false,
|
|
76
|
+
content: "",
|
|
77
|
+
error: "description parameter is required and must be a string",
|
|
78
|
+
shortResult: "Task delegation failed",
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (!prompt || typeof prompt !== "string") {
|
|
83
|
+
return resolve({
|
|
84
|
+
success: false,
|
|
85
|
+
content: "",
|
|
86
|
+
error: "prompt parameter is required and must be a string",
|
|
87
|
+
shortResult: "Task delegation failed",
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (!subagent_type || typeof subagent_type !== "string") {
|
|
92
|
+
return resolve({
|
|
93
|
+
success: false,
|
|
94
|
+
content: "",
|
|
95
|
+
error: "subagent_type parameter is required and must be a string",
|
|
96
|
+
shortResult: "Task delegation failed",
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
try {
|
|
101
|
+
// Subagent selection logic with explicit name matching only
|
|
102
|
+
const configuration =
|
|
103
|
+
await subagentManager.findSubagent(subagent_type);
|
|
104
|
+
|
|
105
|
+
if (!configuration) {
|
|
106
|
+
// Error handling for nonexistent subagents with available subagents listing
|
|
107
|
+
const allConfigs = subagentManager.getConfigurations();
|
|
108
|
+
const availableNames = allConfigs.map((c) => c.name).join(", ");
|
|
109
|
+
|
|
110
|
+
return resolve({
|
|
111
|
+
success: false,
|
|
112
|
+
content: "",
|
|
113
|
+
error: `No subagent found matching "${subagent_type}". Available subagents: ${availableNames || "none"}`,
|
|
114
|
+
shortResult: "Subagent not found",
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Create subagent instance and execute task
|
|
119
|
+
const instance = await subagentManager.createInstance(
|
|
120
|
+
configuration,
|
|
121
|
+
{
|
|
122
|
+
description,
|
|
123
|
+
prompt,
|
|
124
|
+
subagent_type,
|
|
125
|
+
},
|
|
126
|
+
run_in_background,
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
let isBackgrounded = false;
|
|
130
|
+
|
|
131
|
+
// Register for backgrounding if not already in background
|
|
132
|
+
if (!run_in_background && context.foregroundTaskManager) {
|
|
133
|
+
context.foregroundTaskManager.registerForegroundTask({
|
|
134
|
+
id: instance.subagentId,
|
|
135
|
+
backgroundHandler: async () => {
|
|
136
|
+
isBackgrounded = true;
|
|
137
|
+
const taskId = await subagentManager.backgroundInstance(
|
|
138
|
+
instance.subagentId,
|
|
139
|
+
);
|
|
140
|
+
// Resolve the tool execution early so the main agent can continue
|
|
141
|
+
resolve({
|
|
142
|
+
success: true,
|
|
143
|
+
content: `Task moved to background with ID: ${taskId}. Use TaskOutput to monitor progress.`,
|
|
144
|
+
shortResult: "Task backgrounded",
|
|
145
|
+
});
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
try {
|
|
151
|
+
const result = await subagentManager.executeTask(
|
|
152
|
+
instance,
|
|
153
|
+
prompt,
|
|
154
|
+
context.abortSignal,
|
|
155
|
+
run_in_background,
|
|
156
|
+
);
|
|
157
|
+
|
|
158
|
+
if (isBackgrounded) return;
|
|
159
|
+
|
|
160
|
+
if (run_in_background) {
|
|
161
|
+
return resolve({
|
|
162
|
+
success: true,
|
|
163
|
+
content: `Task started in background with ID: ${result}`,
|
|
164
|
+
shortResult: `Task started in background: ${result}`,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return resolve({
|
|
169
|
+
success: true,
|
|
170
|
+
content: result,
|
|
171
|
+
shortResult: `Task completed by ${configuration.name}`,
|
|
172
|
+
});
|
|
173
|
+
} finally {
|
|
174
|
+
if (!run_in_background && context.foregroundTaskManager) {
|
|
175
|
+
context.foregroundTaskManager.unregisterForegroundTask(
|
|
176
|
+
instance.subagentId,
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
} catch (error) {
|
|
181
|
+
return resolve({
|
|
182
|
+
success: false,
|
|
183
|
+
content: "",
|
|
184
|
+
error: `Task delegation failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
185
|
+
shortResult: "Delegation error",
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
})();
|
|
189
|
+
});
|
|
134
190
|
},
|
|
135
191
|
|
|
136
192
|
formatCompactParams: (params: Record<string, unknown>) => {
|
package/src/tools/types.ts
CHANGED
|
@@ -39,6 +39,7 @@ export interface ToolResult {
|
|
|
39
39
|
export interface ToolContext {
|
|
40
40
|
abortSignal?: AbortSignal;
|
|
41
41
|
backgroundBashManager?: import("../managers/backgroundBashManager.js").BackgroundBashManager;
|
|
42
|
+
backgroundTaskManager?: import("../managers/backgroundTaskManager.js").BackgroundTaskManager;
|
|
42
43
|
workdir: string;
|
|
43
44
|
/** Permission mode for this tool execution */
|
|
44
45
|
permissionMode?: PermissionMode;
|
|
@@ -50,4 +51,10 @@ export interface ToolContext {
|
|
|
50
51
|
mcpManager?: import("../managers/mcpManager.js").McpManager;
|
|
51
52
|
/** LSP manager instance for code intelligence */
|
|
52
53
|
lspManager?: import("../types/lsp.js").ILspManager;
|
|
54
|
+
/** Reversion manager instance for file snapshots */
|
|
55
|
+
reversionManager?: import("../managers/reversionManager.js").ReversionManager;
|
|
56
|
+
/** Current message ID for associating snapshots */
|
|
57
|
+
messageId?: string;
|
|
58
|
+
/** Foreground task manager for backgrounding tasks */
|
|
59
|
+
foregroundTaskManager?: import("../types/processes.js").IForegroundTaskManager;
|
|
53
60
|
}
|
package/src/tools/writeTool.ts
CHANGED
|
@@ -126,9 +126,23 @@ export const writeTool: ToolPlugin = {
|
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
+
// Record snapshot for reversion
|
|
130
|
+
let snapshotId: string | undefined;
|
|
131
|
+
if (context.reversionManager && context.messageId) {
|
|
132
|
+
snapshotId = await context.reversionManager.recordSnapshot(
|
|
133
|
+
context.messageId,
|
|
134
|
+
resolvedPath,
|
|
135
|
+
isExistingFile ? "modify" : "create",
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
129
139
|
// Write file
|
|
130
140
|
try {
|
|
131
141
|
await writeFile(resolvedPath, content, "utf-8");
|
|
142
|
+
// Commit snapshot on success
|
|
143
|
+
if (context.reversionManager && snapshotId) {
|
|
144
|
+
await context.reversionManager.commitSnapshot(snapshotId);
|
|
145
|
+
}
|
|
132
146
|
} catch (writeError) {
|
|
133
147
|
return {
|
|
134
148
|
success: false,
|
package/src/types/commands.ts
CHANGED
|
@@ -29,4 +29,7 @@ export interface CustomSlashCommand {
|
|
|
29
29
|
isNested: boolean; // Whether command is in a subdirectory
|
|
30
30
|
depth: number; // 0 = root, 1 = nested
|
|
31
31
|
segments: string[]; // Path components for ID generation (e.g., ["openspec", "apply"])
|
|
32
|
+
|
|
33
|
+
// Plugin support
|
|
34
|
+
pluginPath?: string; // Absolute path to the plugin root directory (only set for plugin commands)
|
|
32
35
|
}
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
import type { HookEvent, HookEventConfig } from "./hooks.js";
|
|
10
10
|
import type { PermissionMode } from "./permissions.js";
|
|
11
11
|
|
|
12
|
+
export type Scope = "user" | "project" | "local";
|
|
13
|
+
|
|
12
14
|
/**
|
|
13
15
|
* Root configuration structure for all Wave Agent settings including hooks and environment variables
|
|
14
16
|
*/
|
|
@@ -28,6 +30,8 @@ export interface WaveConfiguration {
|
|
|
28
30
|
};
|
|
29
31
|
/** New field for scoped plugin management */
|
|
30
32
|
enabledPlugins?: Record<string, boolean>;
|
|
33
|
+
/** Preferred language for agent communication */
|
|
34
|
+
language?: string;
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
/**
|
package/src/types/environment.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { Scope } from "./configuration.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Environment Variable System Types
|
|
3
5
|
*
|
|
@@ -100,5 +102,5 @@ export interface EnvironmentConflict {
|
|
|
100
102
|
/** Final resolved value (which source won) */
|
|
101
103
|
resolvedValue: string;
|
|
102
104
|
/** Which source provided the final value */
|
|
103
|
-
source:
|
|
105
|
+
source: Scope;
|
|
104
106
|
}
|
package/src/types/index.ts
CHANGED
package/src/types/marketplace.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Scope } from "./configuration.js";
|
|
2
|
+
|
|
1
3
|
export interface MarketplaceOwner {
|
|
2
4
|
name: string;
|
|
3
5
|
email?: string;
|
|
@@ -34,6 +36,7 @@ export type MarketplaceSource =
|
|
|
34
36
|
export interface KnownMarketplace {
|
|
35
37
|
name: string;
|
|
36
38
|
source: MarketplaceSource;
|
|
39
|
+
isBuiltin?: boolean;
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
export interface KnownMarketplacesRegistry {
|
|
@@ -45,6 +48,8 @@ export interface InstalledPlugin {
|
|
|
45
48
|
marketplace: string;
|
|
46
49
|
version: string;
|
|
47
50
|
cachePath: string;
|
|
51
|
+
scope?: Scope;
|
|
52
|
+
projectPath?: string;
|
|
48
53
|
}
|
|
49
54
|
|
|
50
55
|
export interface InstalledPluginsRegistry {
|
package/src/types/messaging.ts
CHANGED
|
@@ -12,6 +12,7 @@ export enum MessageSource {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export interface Message {
|
|
15
|
+
id?: string; // Unique identifier for the message
|
|
15
16
|
role: "user" | "assistant";
|
|
16
17
|
blocks: MessageBlock[];
|
|
17
18
|
usage?: Usage; // Usage data for this message's AI operation (assistant messages only)
|
|
@@ -27,7 +28,8 @@ export type MessageBlock =
|
|
|
27
28
|
| CompressBlock
|
|
28
29
|
| MemoryBlock
|
|
29
30
|
| SubagentBlock
|
|
30
|
-
| ReasoningBlock
|
|
31
|
+
| ReasoningBlock
|
|
32
|
+
| FileHistoryBlock;
|
|
31
33
|
|
|
32
34
|
export interface TextBlock {
|
|
33
35
|
type: "text";
|
|
@@ -101,9 +103,15 @@ export interface SubagentBlock {
|
|
|
101
103
|
status: "active" | "completed" | "error" | "aborted";
|
|
102
104
|
sessionId: string;
|
|
103
105
|
configuration: SubagentConfiguration;
|
|
106
|
+
runInBackground?: boolean;
|
|
104
107
|
}
|
|
105
108
|
|
|
106
109
|
export interface ReasoningBlock {
|
|
107
110
|
type: "reasoning";
|
|
108
111
|
content: string;
|
|
109
112
|
}
|
|
113
|
+
|
|
114
|
+
export interface FileHistoryBlock {
|
|
115
|
+
type: "file_history";
|
|
116
|
+
snapshots: import("./reversion.js").FileSnapshot[];
|
|
117
|
+
}
|
package/src/types/processes.ts
CHANGED
|
@@ -5,14 +5,43 @@
|
|
|
5
5
|
|
|
6
6
|
import type { ChildProcess } from "child_process";
|
|
7
7
|
|
|
8
|
-
export
|
|
8
|
+
export type BackgroundTaskStatus =
|
|
9
|
+
| "running"
|
|
10
|
+
| "completed"
|
|
11
|
+
| "failed"
|
|
12
|
+
| "killed";
|
|
13
|
+
export type BackgroundTaskType = "shell" | "subagent";
|
|
14
|
+
|
|
15
|
+
export interface BackgroundTask {
|
|
9
16
|
id: string;
|
|
10
|
-
|
|
11
|
-
|
|
17
|
+
type: BackgroundTaskType;
|
|
18
|
+
status: BackgroundTaskStatus;
|
|
12
19
|
startTime: number;
|
|
13
|
-
|
|
20
|
+
endTime?: number;
|
|
21
|
+
command?: string; // for shell
|
|
22
|
+
description?: string; // for subagent
|
|
14
23
|
stdout: string;
|
|
15
24
|
stderr: string;
|
|
16
25
|
exitCode?: number;
|
|
17
26
|
runtime?: number;
|
|
18
27
|
}
|
|
28
|
+
|
|
29
|
+
export interface BackgroundShell extends BackgroundTask {
|
|
30
|
+
type: "shell";
|
|
31
|
+
process: ChildProcess;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface ForegroundTask {
|
|
35
|
+
id: string;
|
|
36
|
+
backgroundHandler: () => Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface IForegroundTaskManager {
|
|
40
|
+
registerForegroundTask(task: ForegroundTask): void;
|
|
41
|
+
unregisterForegroundTask(id: string): void;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface IForegroundTaskManager {
|
|
45
|
+
registerForegroundTask(task: ForegroundTask): void;
|
|
46
|
+
unregisterForegroundTask(id: string): void;
|
|
47
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the state of a file before an agent operation.
|
|
3
|
+
*/
|
|
4
|
+
export interface FileSnapshot {
|
|
5
|
+
/** The ID of the message/turn this snapshot is associated with. */
|
|
6
|
+
messageId: string;
|
|
7
|
+
/** Absolute path to the file. */
|
|
8
|
+
filePath: string;
|
|
9
|
+
/** Path to the stored snapshot file. */
|
|
10
|
+
snapshotPath?: string;
|
|
11
|
+
/** When the snapshot was taken. */
|
|
12
|
+
timestamp: number;
|
|
13
|
+
/** The operation that triggered this snapshot. */
|
|
14
|
+
operation: "create" | "modify" | "delete";
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A point in the conversation history that can be reverted to.
|
|
19
|
+
*/
|
|
20
|
+
export interface Checkpoint {
|
|
21
|
+
/** The index of the user message in the history. */
|
|
22
|
+
index: number;
|
|
23
|
+
/** The unique ID of the user message. */
|
|
24
|
+
messageId: string;
|
|
25
|
+
/** A short snippet of the message content for the UI. */
|
|
26
|
+
preview: string;
|
|
27
|
+
/** When the message was sent. */
|
|
28
|
+
timestamp: number;
|
|
29
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { GENERAL_PURPOSE_SYSTEM_PROMPT } from "../constants/prompts.js";
|
|
1
2
|
import type { SubagentConfiguration } from "./subagentParser.js";
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -7,10 +8,27 @@ import type { SubagentConfiguration } from "./subagentParser.js";
|
|
|
7
8
|
export function getBuiltinSubagents(): SubagentConfiguration[] {
|
|
8
9
|
return [
|
|
9
10
|
createExploreSubagent(),
|
|
11
|
+
createGeneralPurposeSubagent(),
|
|
10
12
|
// Add more built-in subagents here as needed
|
|
11
13
|
];
|
|
12
14
|
}
|
|
13
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Create the General-Purpose built-in subagent configuration
|
|
18
|
+
* Specialized for multi-step research and implementation tasks
|
|
19
|
+
*/
|
|
20
|
+
function createGeneralPurposeSubagent(): SubagentConfiguration {
|
|
21
|
+
return {
|
|
22
|
+
name: "general-purpose",
|
|
23
|
+
description:
|
|
24
|
+
"General-purpose agent for researching complex questions, searching for code, and executing multi-step tasks. When you are searching for a keyword or file and are not confident that you will find the right match in the first few tries use this agent to perform the search for you.",
|
|
25
|
+
systemPrompt: GENERAL_PURPOSE_SYSTEM_PROMPT,
|
|
26
|
+
filePath: "<builtin:general-purpose>",
|
|
27
|
+
scope: "builtin",
|
|
28
|
+
priority: 3,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
14
32
|
/**
|
|
15
33
|
* Create the Explore built-in subagent configuration
|
|
16
34
|
* Specialized for codebase exploration and file search tasks
|
package/src/utils/constants.ts
CHANGED
|
@@ -12,9 +12,9 @@ import os from "os";
|
|
|
12
12
|
export const DATA_DIRECTORY = path.join(os.homedir(), ".wave");
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Prompt history file path
|
|
16
16
|
*/
|
|
17
|
-
export const
|
|
17
|
+
export const PROMPT_HISTORY_FILE = path.join(DATA_DIRECTORY, "history.jsonl");
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* Error log directory path
|