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
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { bashTool } from "../tools/bashTool.js";
|
|
2
2
|
import { taskOutputTool } from "../tools/taskOutputTool.js";
|
|
3
3
|
import { taskStopTool } from "../tools/taskStopTool.js";
|
|
4
|
-
import { deleteFileTool } from "../tools/deleteFileTool.js";
|
|
5
4
|
import { editTool } from "../tools/editTool.js";
|
|
6
|
-
import { multiEditTool } from "../tools/multiEditTool.js";
|
|
7
5
|
import { writeTool } from "../tools/writeTool.js";
|
|
8
6
|
import { exitPlanModeTool } from "../tools/exitPlanMode.js";
|
|
9
7
|
import { askUserQuestionTool } from "../tools/askUserQuestion.js";
|
|
@@ -13,9 +11,10 @@ import { grepTool } from "../tools/grepTool.js";
|
|
|
13
11
|
import { lsTool } from "../tools/lsTool.js";
|
|
14
12
|
import { readTool } from "../tools/readTool.js";
|
|
15
13
|
import { lspTool } from "../tools/lspTool.js";
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
14
|
+
import { taskTool } from "../tools/taskTool.js";
|
|
15
|
+
import { skillTool } from "../tools/skillTool.js";
|
|
18
16
|
import { taskCreateTool, taskGetTool, taskUpdateTool, taskListTool, } from "../tools/taskManagementTools.js";
|
|
17
|
+
import { logger } from "../utils/globalLogger.js";
|
|
19
18
|
/**
|
|
20
19
|
* Tool Manager
|
|
21
20
|
*
|
|
@@ -24,30 +23,24 @@ import { taskCreateTool, taskGetTool, taskUpdateTool, taskListTool, } from "../t
|
|
|
24
23
|
*/
|
|
25
24
|
class ToolManager {
|
|
26
25
|
constructor(options) {
|
|
27
|
-
this.
|
|
28
|
-
this.
|
|
29
|
-
this.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
this.
|
|
33
|
-
this.foregroundTaskManager = options.foregroundTaskManager;
|
|
34
|
-
this.reversionManager = options.reversionManager;
|
|
35
|
-
this.backgroundTaskManager = options.backgroundTaskManager;
|
|
36
|
-
// Store CLI permission mode, let PermissionManager resolve effective mode
|
|
37
|
-
this.permissionMode = options.permissionMode;
|
|
38
|
-
this.canUseToolCallback = options.canUseToolCallback;
|
|
26
|
+
this.toolsRegistry = new Map();
|
|
27
|
+
this.container = options.container;
|
|
28
|
+
this.tools = options.tools;
|
|
29
|
+
}
|
|
30
|
+
get mcpManager() {
|
|
31
|
+
return this.container.get("McpManager");
|
|
39
32
|
}
|
|
40
33
|
/**
|
|
41
34
|
* Register a new tool
|
|
42
35
|
*/
|
|
43
36
|
register(tool) {
|
|
44
|
-
this.
|
|
37
|
+
this.toolsRegistry.set(tool.name, tool);
|
|
45
38
|
}
|
|
46
39
|
/**
|
|
47
40
|
* Initialize built-in tools. Can be called with dependencies for tools that require them.
|
|
48
41
|
*
|
|
49
42
|
* This method can be called multiple times safely. When called without dependencies,
|
|
50
|
-
* it registers basic tools (Bash, Read, Write,
|
|
43
|
+
* it registers basic tools (Bash, Read, Write, TaskCreate, etc.). When called with
|
|
51
44
|
* dependencies, it also registers tools that require managers (Task, Skill).
|
|
52
45
|
*
|
|
53
46
|
* @param deps Optional dependencies for advanced tools
|
|
@@ -66,14 +59,12 @@ class ToolManager {
|
|
|
66
59
|
* });
|
|
67
60
|
* ```
|
|
68
61
|
*/
|
|
69
|
-
initializeBuiltInTools(
|
|
62
|
+
initializeBuiltInTools() {
|
|
70
63
|
const builtInTools = [
|
|
71
64
|
bashTool,
|
|
72
65
|
taskOutputTool,
|
|
73
66
|
taskStopTool,
|
|
74
|
-
deleteFileTool,
|
|
75
67
|
editTool,
|
|
76
|
-
multiEditTool,
|
|
77
68
|
writeTool,
|
|
78
69
|
exitPlanModeTool,
|
|
79
70
|
askUserQuestionTool,
|
|
@@ -82,23 +73,27 @@ class ToolManager {
|
|
|
82
73
|
lsTool,
|
|
83
74
|
readTool,
|
|
84
75
|
lspTool,
|
|
76
|
+
taskTool,
|
|
77
|
+
skillTool,
|
|
85
78
|
taskCreateTool,
|
|
86
79
|
taskGetTool,
|
|
87
80
|
taskUpdateTool,
|
|
88
81
|
taskListTool,
|
|
89
82
|
];
|
|
90
83
|
for (const tool of builtInTools) {
|
|
91
|
-
this.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (deps?.subagentManager) {
|
|
95
|
-
const taskTool = createTaskTool(deps.subagentManager);
|
|
96
|
-
this.tools.set(taskTool.name, taskTool);
|
|
84
|
+
if (this.shouldEnableTool(tool.name)) {
|
|
85
|
+
this.toolsRegistry.set(tool.name, tool);
|
|
86
|
+
}
|
|
97
87
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Check if a tool should be enabled based on tools configuration
|
|
91
|
+
*/
|
|
92
|
+
shouldEnableTool(name) {
|
|
93
|
+
if (!this.tools) {
|
|
94
|
+
return true;
|
|
101
95
|
}
|
|
96
|
+
return this.tools.some((toolName) => toolName.toLowerCase() === name.toLowerCase());
|
|
102
97
|
}
|
|
103
98
|
/**
|
|
104
99
|
* Execute a tool by name with the provided arguments and context
|
|
@@ -114,43 +109,54 @@ class ToolManager {
|
|
|
114
109
|
* @returns Promise resolving to the tool execution result
|
|
115
110
|
*/
|
|
116
111
|
async execute(name, args, context) {
|
|
112
|
+
const permissionManager = this.container.get("PermissionManager");
|
|
113
|
+
const permissionMode = this.container.has("PermissionMode")
|
|
114
|
+
? this.container.get("PermissionMode")
|
|
115
|
+
: undefined;
|
|
117
116
|
// Resolve effective permission mode (CLI override > configuration > default)
|
|
118
|
-
const effectivePermissionMode =
|
|
119
|
-
?
|
|
120
|
-
:
|
|
117
|
+
const effectivePermissionMode = permissionManager
|
|
118
|
+
? permissionManager.getCurrentEffectiveMode(permissionMode)
|
|
119
|
+
: permissionMode || "default";
|
|
121
120
|
// Enhance context with permission-related fields
|
|
122
121
|
const enhancedContext = {
|
|
123
122
|
...context,
|
|
124
123
|
permissionMode: effectivePermissionMode,
|
|
125
|
-
canUseToolCallback: this.
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
124
|
+
canUseToolCallback: this.container.has("CanUseToolCallback")
|
|
125
|
+
? this.container.get("CanUseToolCallback")
|
|
126
|
+
: undefined,
|
|
127
|
+
permissionManager,
|
|
128
|
+
taskManager: this.container.get("TaskManager"),
|
|
129
|
+
reversionManager: this.container.get("ReversionManager"),
|
|
130
|
+
backgroundTaskManager: this.container.get("BackgroundTaskManager"),
|
|
131
|
+
foregroundTaskManager: this.container.get("ForegroundTaskManager"),
|
|
131
132
|
mcpManager: this.mcpManager,
|
|
132
|
-
lspManager: this.
|
|
133
|
+
lspManager: this.container.get("LspManager"),
|
|
134
|
+
subagentManager: this.container.has("SubagentManager")
|
|
135
|
+
? this.container.get("SubagentManager")
|
|
136
|
+
: undefined,
|
|
137
|
+
skillManager: this.container.has("SkillManager")
|
|
138
|
+
? this.container.get("SkillManager")
|
|
139
|
+
: undefined,
|
|
133
140
|
sessionId: context.sessionId,
|
|
134
141
|
};
|
|
135
|
-
|
|
142
|
+
logger?.debug("Executing tool with enhanced context", {
|
|
136
143
|
toolName: name,
|
|
137
|
-
|
|
144
|
+
permissionMode,
|
|
138
145
|
effectivePermissionMode,
|
|
139
|
-
hasPermissionManager: !!
|
|
140
|
-
hasPermissionCallback: !!this.canUseToolCallback,
|
|
146
|
+
hasPermissionManager: !!permissionManager,
|
|
141
147
|
});
|
|
142
148
|
// Check if it's an MCP tool first
|
|
143
149
|
if (this.mcpManager.isMcpTool(name)) {
|
|
144
150
|
return this.mcpManager.executeMcpToolByRegistry(name, args, enhancedContext);
|
|
145
151
|
}
|
|
146
152
|
// Check built-in tools
|
|
147
|
-
const plugin = this.
|
|
153
|
+
const plugin = this.toolsRegistry.get(name);
|
|
148
154
|
if (plugin) {
|
|
149
155
|
try {
|
|
150
156
|
return await plugin.execute(args, enhancedContext);
|
|
151
157
|
}
|
|
152
158
|
catch (error) {
|
|
153
|
-
|
|
159
|
+
logger?.error("Tool execution failed", {
|
|
154
160
|
toolName: name,
|
|
155
161
|
error: error instanceof Error ? error.message : String(error),
|
|
156
162
|
});
|
|
@@ -161,7 +167,7 @@ class ToolManager {
|
|
|
161
167
|
};
|
|
162
168
|
}
|
|
163
169
|
}
|
|
164
|
-
|
|
170
|
+
logger?.warn("Tool not found", { toolName: name });
|
|
165
171
|
return {
|
|
166
172
|
success: false,
|
|
167
173
|
content: "",
|
|
@@ -169,13 +175,13 @@ class ToolManager {
|
|
|
169
175
|
};
|
|
170
176
|
}
|
|
171
177
|
list() {
|
|
172
|
-
const builtInTools = Array.from(this.
|
|
178
|
+
const builtInTools = Array.from(this.toolsRegistry.values());
|
|
173
179
|
const mcpTools = this.mcpManager.getMcpToolPlugins();
|
|
174
180
|
return [...builtInTools, ...mcpTools];
|
|
175
181
|
}
|
|
176
182
|
getToolsConfig() {
|
|
177
183
|
const effectivePermissionMode = this.getPermissionMode();
|
|
178
|
-
const builtInToolsConfig = Array.from(this.
|
|
184
|
+
const builtInToolsConfig = Array.from(this.toolsRegistry.values())
|
|
179
185
|
.filter((tool) => {
|
|
180
186
|
if (effectivePermissionMode === "bypassPermissions") {
|
|
181
187
|
if (tool.name === "ExitPlanMode" || tool.name === "AskUserQuestion") {
|
|
@@ -195,35 +201,39 @@ class ToolManager {
|
|
|
195
201
|
* Get the list of registered tool plugins
|
|
196
202
|
*/
|
|
197
203
|
getTools() {
|
|
198
|
-
return Array.from(this.
|
|
204
|
+
return Array.from(this.toolsRegistry.values());
|
|
199
205
|
}
|
|
200
206
|
/**
|
|
201
207
|
* Get the current permission mode
|
|
202
208
|
*/
|
|
203
209
|
getPermissionMode() {
|
|
204
|
-
|
|
205
|
-
|
|
210
|
+
const permissionManager = this.container.get("PermissionManager");
|
|
211
|
+
const permissionMode = this.container.has("PermissionMode")
|
|
212
|
+
? this.container.get("PermissionMode")
|
|
213
|
+
: undefined;
|
|
214
|
+
if (permissionManager) {
|
|
215
|
+
return permissionManager.getCurrentEffectiveMode(permissionMode);
|
|
206
216
|
}
|
|
207
|
-
return
|
|
217
|
+
return permissionMode || "default";
|
|
208
218
|
}
|
|
209
219
|
/**
|
|
210
220
|
* Set the permission mode
|
|
211
221
|
* @param mode - The new permission mode
|
|
212
222
|
*/
|
|
213
223
|
setPermissionMode(mode) {
|
|
214
|
-
this.
|
|
224
|
+
this.container.register("PermissionMode", mode);
|
|
215
225
|
}
|
|
216
226
|
/**
|
|
217
227
|
* Get the permission manager
|
|
218
228
|
*/
|
|
219
229
|
getPermissionManager() {
|
|
220
|
-
return this.
|
|
230
|
+
return this.container.get("PermissionManager");
|
|
221
231
|
}
|
|
222
232
|
/**
|
|
223
233
|
* Get the task manager
|
|
224
234
|
*/
|
|
225
235
|
getTaskManager() {
|
|
226
|
-
return this.
|
|
236
|
+
return this.container.get("TaskManager");
|
|
227
237
|
}
|
|
228
238
|
}
|
|
229
239
|
// Export tool registry class and types
|
package/dist/prompts/index.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { ToolPlugin } from "../tools/types.js";
|
|
2
2
|
export declare const BASE_SYSTEM_PROMPT = "You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.\n\n# Doing tasks\nThe user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:\n- NEVER propose changes to code you haven't read. If a user asks about or wants you to modify a file, read it first. Understand existing code before suggesting modifications.\n- Be careful not to introduce security vulnerabilities such as command injection, XSS, SQL injection, and other OWASP top 10 vulnerabilities. If you notice that you wrote insecure code, immediately fix it.\n- Avoid over-engineering. Only make changes that are directly requested or clearly necessary. Keep solutions simple and focused.\n - Don't add features, refactor code, or make \"improvements\" beyond what was asked. A bug fix doesn't need surrounding code cleaned up. A simple feature doesn't need extra configurability. Don't add docstrings, comments, or type annotations to code you didn't change. Only add comments where the logic isn't self-evident.\n - Don't add error handling, fallbacks, or validation for scenarios that can't happen. Trust internal code and framework guarantees. Only validate at system boundaries (user input, external APIs). Don't use feature flags or backwards-compatibility shims when you can just change the code.\n - Don't create helpers, utilities, or abstractions for one-time operations. Don't design for hypothetical future requirements. The right amount of complexity is the minimum needed for the current task\u2014three similar lines of code is better than a premature abstraction.\n- Avoid backwards-compatibility hacks like renaming unused `_vars`, re-exporting types, adding `// removed` comments for removed code, etc. If something is unused, delete it completely.";
|
|
3
3
|
export declare const TOOL_POLICY = "\n# Tool usage policy\n- You can call multiple tools in a single response. If you intend to call multiple tools and there are no dependencies between them, make all independent tool calls in parallel. Maximize use of parallel tool calls where possible to increase efficiency.\n- However, if some tool calls depend on previous calls to inform dependent values, do NOT call these tools in parallel and instead call them sequentially. For instance, if one operation must complete before another starts, run these operations sequentially instead. Never use placeholders or guess missing parameters in tool calls.\n- If the user specifies that they want you to run tools \"in parallel\", you MUST send a single message with multiple tool use content blocks.";
|
|
4
|
-
export declare const TASK_MANAGEMENT_POLICY = "\n# Task Management\nYou have access to the TaskCreate, TaskGet, TaskUpdate, and TaskList tools to help you manage and plan tasks. Use these tools VERY frequently to ensure that you are tracking your tasks and giving the user visibility into your progress.\nThese tools are also EXTREMELY helpful for planning tasks, and for breaking down larger complex tasks into smaller steps. If you do not use this tool when planning, you may forget to do important tasks - and that is unacceptable.\nIt is critical that you mark tasks as completed as soon as you are done with a task. Do not batch up multiple tasks before marking them as completed.";
|
|
5
4
|
export declare function buildPlanModePrompt(planFilePath: string, planExists: boolean, isSubagent?: boolean): string;
|
|
6
5
|
export declare const DEFAULT_SYSTEM_PROMPT = "You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.\n\n# Doing tasks\nThe user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:\n- NEVER propose changes to code you haven't read. If a user asks about or wants you to modify a file, read it first. Understand existing code before suggesting modifications.\n- Be careful not to introduce security vulnerabilities such as command injection, XSS, SQL injection, and other OWASP top 10 vulnerabilities. If you notice that you wrote insecure code, immediately fix it.\n- Avoid over-engineering. Only make changes that are directly requested or clearly necessary. Keep solutions simple and focused.\n - Don't add features, refactor code, or make \"improvements\" beyond what was asked. A bug fix doesn't need surrounding code cleaned up. A simple feature doesn't need extra configurability. Don't add docstrings, comments, or type annotations to code you didn't change. Only add comments where the logic isn't self-evident.\n - Don't add error handling, fallbacks, or validation for scenarios that can't happen. Trust internal code and framework guarantees. Only validate at system boundaries (user input, external APIs). Don't use feature flags or backwards-compatibility shims when you can just change the code.\n - Don't create helpers, utilities, or abstractions for one-time operations. Don't design for hypothetical future requirements. The right amount of complexity is the minimum needed for the current task\u2014three similar lines of code is better than a premature abstraction.\n- Avoid backwards-compatibility hacks like renaming unused `_vars`, re-exporting types, adding `// removed` comments for removed code, etc. If something is unused, delete it completely.";
|
|
7
6
|
export declare const BASH_SUBAGENT_SYSTEM_PROMPT = "You are a command execution specialist. Your role is to execute bash commands efficiently and safely.\n\nGuidelines:\n- Execute commands precisely as instructed\n- For git operations, follow git safety protocols\n- Report command output clearly and concisely\n- If a command fails, explain the error and suggest solutions\n- Use command chaining (&&) for dependent operations\n- Quote paths with spaces properly\n- For clear communication, avoid using emojis\n\nComplete the requested operations efficiently.";
|
|
8
7
|
export declare const GENERAL_PURPOSE_SYSTEM_PROMPT = "You are an agent. Given the user's message, you should use the tools available to complete the task. Do what has been asked; nothing more, nothing less. When you complete the task simply respond with a detailed writeup.\n\nYour strengths:\n- Searching for code, configurations, and patterns across large codebases\n- Analyzing multiple files to understand system architecture\n- Investigating complex questions that require exploring many files\n- Performing multi-step research tasks\n\nGuidelines:\n- For file searches: Use Grep or Glob when you need to search broadly. Use Read when you know the specific file path.\n- For analysis: Start broad and narrow down. Use multiple search strategies if the first doesn't yield results.\n- Be thorough: Check multiple locations, consider different naming conventions, look for related files.\n- NEVER create files unless they're absolutely necessary for achieving your goal. ALWAYS prefer editing an existing file to creating a new one.\n- NEVER proactively create documentation files (*.md) or README files. Only create documentation files if explicitly requested.\n- In your final response always share relevant file names and code snippets. Any file paths you return in your response MUST be absolute. Do NOT use relative paths.\n- For clear communication, avoid using emojis.";
|
|
9
|
-
export declare const EXPLORE_SUBAGENT_SYSTEM_PROMPT = "You are a file search specialist. You excel at thoroughly navigating and exploring codebases.\n\t\n\t=== CRITICAL: READ-ONLY MODE - NO FILE MODIFICATIONS ===\n\tThis is a READ-ONLY exploration task. You are STRICTLY PROHIBITED from:\n\t- Creating new files (no Write, touch, or file creation of any kind)\n\t- Modifying existing files (no Edit operations)\n\t-
|
|
10
|
-
export declare const PLAN_SUBAGENT_SYSTEM_PROMPT = "You are a software architect and planning specialist. Your role is to explore the codebase and design implementation plans.\n\n=== CRITICAL: READ-ONLY MODE - NO FILE MODIFICATIONS ===\nThis is a READ-ONLY planning task. You are STRICTLY PROHIBITED from:\n- Creating new files (no Write, touch, or file creation of any kind)\n- Modifying existing files (no Edit operations)\n-
|
|
8
|
+
export declare const EXPLORE_SUBAGENT_SYSTEM_PROMPT = "You are a file search specialist. You excel at thoroughly navigating and exploring codebases.\n\t\n\t=== CRITICAL: READ-ONLY MODE - NO FILE MODIFICATIONS ===\n\tThis is a READ-ONLY exploration task. You are STRICTLY PROHIBITED from:\n\t- Creating new files (no Write, touch, or file creation of any kind)\n\t- Modifying existing files (no Edit operations)\n\t- Moving or copying files (no mv or cp)\n\t- Creating temporary files anywhere, including /tmp\n\t- Using redirect operators (>, >>, |) or heredocs to write to files\n\t- Running ANY commands that change system state\n\t\n\tYour role is EXCLUSIVELY to search and analyze existing code. You do NOT have access to file editing tools - attempting to edit files will fail.\n\t\n\tYour strengths:\n\t- Rapidly finding files using glob patterns\n\t- Searching code and text with powerful regex patterns\n\t- Reading and analyzing file contents\n\t- Using Language Server Protocol (LSP) for deep code intelligence (definitions, references, etc.)\n\t\n\tGuidelines:\n\t- Use Glob for broad file pattern matching\n\t- Use Grep for searching file contents with regex\n\t- Use Read when you know the specific file path you need to read\n\t- Use LSP for code intelligence features like finding definitions, references, implementations, and symbols. This is especially useful for understanding complex code relationships.\n\t- Use Bash ONLY for read-only operations (ls, git status, git log, git diff, find, cat, head, tail)\n\t- NEVER use Bash for: mkdir, touch, rm, cp, mv, git add, git commit, npm install, pip install, or any file creation/modification\n\t- Adapt your search approach based on the thoroughness level specified by the caller\n\t- Return file paths as absolute paths in your final response\n\t- For clear communication, avoid using emojis\n\t- Communicate your final report directly as a regular message - do NOT attempt to create files\n\t\n\tNOTE: You are meant to be a fast agent that returns output as quickly as possible. In order to achieve this you must:\n\t- Make efficient use of the tools that you have at your disposal: be smart about how you search for files and implementations\n\t- Wherever possible you should try to spawn multiple parallel tool calls for grepping and reading files\n\t\n\tComplete the user's search request efficiently and report your findings clearly.";
|
|
9
|
+
export declare const PLAN_SUBAGENT_SYSTEM_PROMPT = "You are a software architect and planning specialist. Your role is to explore the codebase and design implementation plans.\n\n=== CRITICAL: READ-ONLY MODE - NO FILE MODIFICATIONS ===\nThis is a READ-ONLY planning task. You are STRICTLY PROHIBITED from:\n- Creating new files (no Write, touch, or file creation of any kind)\n- Modifying existing files (no Edit operations)\n- Moving or copying files (no mv or cp)\n- Creating temporary files anywhere, including /tmp\n- Using redirect operators (>, >>, |) or heredocs to write to files\n- Running ANY commands that change system state\n\nYour role is EXCLUSIVELY to explore the codebase and design implementation plans. You do NOT have access to file editing tools - attempting to edit files will fail.\n\nYou will be provided with a set of requirements and optionally a perspective on how to approach the design process.\n\n## Your Process\n\n1. **Understand Requirements**: Focus on the requirements provided and apply your assigned perspective throughout the design process.\n\n2. **Explore Thoroughly**:\n - Read any files provided to you in the initial prompt\n - Find existing patterns and conventions using Glob, Grep, and Read\n - Understand the current architecture\n - Identify similar features as reference\n - Trace through relevant code paths\n - Use Bash ONLY for read-only operations (ls, git status, git log, git diff, find, cat, head, tail)\n - NEVER use Bash for: mkdir, touch, rm, cp, mv, git add, git commit, npm install, pip install, or any file creation/modification\n\n3. **Design Solution**:\n - Create implementation approach based on your assigned perspective\n - Consider trade-offs and architectural decisions\n - Follow existing patterns where appropriate\n\n4. **Detail the Plan**:\n - Provide step-by-step implementation strategy\n - Identify dependencies and sequencing\n - Anticipate potential challenges\n\n## Required Output\n\nEnd your response with:\n\n### Critical Files for Implementation\nList 3-5 files most critical for implementing this plan:\n- path/to/file1.ts - [Brief reason: e.g., \"Core logic to modify\"]\n- path/to/file2.ts - [Brief reason: e.g., \"Interfaces to implement\"]\n- path/to/file3.ts - [Brief reason: e.g., \"Pattern to follow\"]\n\nREMEMBER: You can ONLY explore and plan. You CANNOT and MUST NOT write, edit, or modify any files. You do NOT have access to file editing tools.";
|
|
11
10
|
export declare const INIT_PROMPT = "Please analyze this codebase and create a AGENTS.md file, which will be given to future instances of Agent to operate in this repository.\n\nWhat to add:\n1. Commands that will be commonly used, such as how to build, lint, and run tests. Include the necessary commands to develop in this codebase, such as how to run a single test.\n2. High-level code architecture and structure so that future instances can be productive more quickly. Focus on the \"big picture\" architecture that requires reading multiple files to understand.\n\nUsage notes:\n- If there's already a AGENTS.md, suggest improvements to it.\n- When you make the initial AGENTS.md, do not repeat yourself and do not include obvious instructions like \"Provide helpful error messages to users\", \"Write unit tests for all new utilities\", \"Never include sensitive information (API keys, tokens) in code or commits\".\n- Avoid listing every component or file structure that can be easily discovered.\n- Don't include generic development practices.\n- If there are Cursor rules (in .cursor/rules/ or .cursorrules) or Copilot rules (in .github/copilot-instructions.md), make sure to include the important parts.\n- If there is a README.md, make sure to include the important parts.\n- Do not make up information such as \"Common Development Tasks\", \"Tips for Development\", \"Support and Documentation\" unless this is expressly included in other files that you read.\n- Be sure to prefix the file with the following text:\n\n```\n# AGENTS.md\n\nThis file provides guidance to Agent when working with code in this repository.\n```";
|
|
12
11
|
export declare const COMPRESS_MESSAGES_SYSTEM_PROMPT = "You have been working on the task described above but have not yet completed it. Write a continuation summary that will allow you (or another instance of yourself) to resume work efficiently in a future context window where the conversation history will be replaced with this summary. Your summary should be structured, concise, and actionable. Include:\n1. Task Overview\nThe user's core request and success criteria\nAny clarifications or constraints they specified\n2. Current State\nWhat has been completed so far\nFiles created, modified, or analyzed (with paths if relevant)\nKey outputs or artifacts produced\n3. Important Discoveries\nTechnical constraints or requirements uncovered\nDecisions made and their rationale\nErrors encountered and how they were resolved\nWhat approaches were tried that didn't work (and why)\n4. Next Steps\nSpecific actions needed to complete the task\nAny blockers or open questions to resolve\nPriority order if multiple steps remain\n5. Context to Preserve\nUser preferences or style requirements\nDomain-specific details that aren't obvious\nAny promises made to the user\nBe concise but complete\u2014err on the side of including information that would prevent duplicate work or repeated mistakes. Write in a way that enables immediate resumption of the task.\nWrap your summary in <summary></summary> tags.";
|
|
12
|
+
import type { SubagentConfiguration } from "../utils/subagentParser.js";
|
|
13
|
+
import type { SkillMetadata } from "../types/skills.js";
|
|
13
14
|
export declare function buildSystemPrompt(basePrompt: string | undefined, tools: ToolPlugin[], options?: {
|
|
14
15
|
workdir?: string;
|
|
15
16
|
memory?: string;
|
|
@@ -19,5 +20,7 @@ export declare function buildSystemPrompt(basePrompt: string | undefined, tools:
|
|
|
19
20
|
planFilePath: string;
|
|
20
21
|
planExists: boolean;
|
|
21
22
|
};
|
|
23
|
+
availableSubagents?: SubagentConfiguration[];
|
|
24
|
+
availableSkills?: SkillMetadata[];
|
|
22
25
|
}): string;
|
|
23
26
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAiB/C,eAAO,MAAM,kBAAkB,g9DAU+J,CAAC;AAE/L,eAAO,MAAM,WAAW,qvBAIqH,CAAC;AAE9I,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,OAAO,EACnB,UAAU,GAAE,OAAe,GAC1B,MAAM,CAmFR;AAED,eAAO,MAAM,qBAAqB,g9DAAqB,CAAC;AAExD,eAAO,MAAM,2BAA2B,igBAWO,CAAC;AAEhD,eAAO,MAAM,6BAA6B,izCAeK,CAAC;AAEhD,eAAO,MAAM,8BAA8B,mzEAmCuC,CAAC;AAEnF,eAAO,MAAM,2BAA2B,q3EAgDyG,CAAC;AAElJ,eAAO,MAAM,WAAW,kkDAoBjB,CAAC;AAER,eAAO,MAAM,+BAA+B,20CAsBG,CAAC;AAEhD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,KAAK,EAAE,UAAU,EAAE,EACnB,OAAO,GAAE;IACP,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE;QACT,YAAY,EAAE,MAAM,CAAC;QACrB,UAAU,EAAE,OAAO,CAAC;KACrB,CAAC;IACF,kBAAkB,CAAC,EAAE,qBAAqB,EAAE,CAAC;IAC7C,eAAe,CAAC,EAAE,aAAa,EAAE,CAAC;CAC9B,GACL,MAAM,CAgDR"}
|
package/dist/prompts/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as os from "node:os";
|
|
2
2
|
import { isGitRepository } from "../utils/gitUtils.js";
|
|
3
3
|
import { EXPLORE_SUBAGENT_TYPE, PLAN_SUBAGENT_TYPE, } from "../constants/subagents.js";
|
|
4
|
-
import { ASK_USER_QUESTION_TOOL_NAME, BASH_TOOL_NAME, EDIT_TOOL_NAME, GLOB_TOOL_NAME, GREP_TOOL_NAME, READ_TOOL_NAME,
|
|
4
|
+
import { ASK_USER_QUESTION_TOOL_NAME, BASH_TOOL_NAME, EDIT_TOOL_NAME, GLOB_TOOL_NAME, GREP_TOOL_NAME, READ_TOOL_NAME, WRITE_TOOL_NAME, EXIT_PLAN_MODE_TOOL_NAME, } from "../constants/tools.js";
|
|
5
5
|
export const BASE_SYSTEM_PROMPT = `You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.
|
|
6
6
|
|
|
7
7
|
# Doing tasks
|
|
@@ -18,11 +18,6 @@ export const TOOL_POLICY = `
|
|
|
18
18
|
- You can call multiple tools in a single response. If you intend to call multiple tools and there are no dependencies between them, make all independent tool calls in parallel. Maximize use of parallel tool calls where possible to increase efficiency.
|
|
19
19
|
- However, if some tool calls depend on previous calls to inform dependent values, do NOT call these tools in parallel and instead call them sequentially. For instance, if one operation must complete before another starts, run these operations sequentially instead. Never use placeholders or guess missing parameters in tool calls.
|
|
20
20
|
- If the user specifies that they want you to run tools "in parallel", you MUST send a single message with multiple tool use content blocks.`;
|
|
21
|
-
export const TASK_MANAGEMENT_POLICY = `
|
|
22
|
-
# Task Management
|
|
23
|
-
You have access to the ${TASK_CREATE_TOOL_NAME}, ${TASK_GET_TOOL_NAME}, ${TASK_UPDATE_TOOL_NAME}, and ${TASK_LIST_TOOL_NAME} tools to help you manage and plan tasks. Use these tools VERY frequently to ensure that you are tracking your tasks and giving the user visibility into your progress.
|
|
24
|
-
These tools are also EXTREMELY helpful for planning tasks, and for breaking down larger complex tasks into smaller steps. If you do not use this tool when planning, you may forget to do important tasks - and that is unacceptable.
|
|
25
|
-
It is critical that you mark tasks as completed as soon as you are done with a task. Do not batch up multiple tasks before marking them as completed.`;
|
|
26
21
|
export function buildPlanModePrompt(planFilePath, planExists, isSubagent = false) {
|
|
27
22
|
const planFileInfo = planExists
|
|
28
23
|
? `A plan file already exists at ${planFilePath}. You can read it and make incremental edits using the ${EDIT_TOOL_NAME} tool if you need to.`
|
|
@@ -140,7 +135,6 @@ export const EXPLORE_SUBAGENT_SYSTEM_PROMPT = `You are a file search specialist.
|
|
|
140
135
|
This is a READ-ONLY exploration task. You are STRICTLY PROHIBITED from:
|
|
141
136
|
- Creating new files (no Write, touch, or file creation of any kind)
|
|
142
137
|
- Modifying existing files (no Edit operations)
|
|
143
|
-
- Deleting files (no rm or deletion)
|
|
144
138
|
- Moving or copying files (no mv or cp)
|
|
145
139
|
- Creating temporary files anywhere, including /tmp
|
|
146
140
|
- Using redirect operators (>, >>, |) or heredocs to write to files
|
|
@@ -177,7 +171,6 @@ export const PLAN_SUBAGENT_SYSTEM_PROMPT = `You are a software architect and pla
|
|
|
177
171
|
This is a READ-ONLY planning task. You are STRICTLY PROHIBITED from:
|
|
178
172
|
- Creating new files (no Write, touch, or file creation of any kind)
|
|
179
173
|
- Modifying existing files (no Edit operations)
|
|
180
|
-
- Deleting files (no rm or deletion)
|
|
181
174
|
- Moving or copying files (no mv or cp)
|
|
182
175
|
- Creating temporary files anywhere, including /tmp
|
|
183
176
|
- Using redirect operators (>, >>, |) or heredocs to write to files
|
|
@@ -267,17 +260,16 @@ Be concise but complete—err on the side of including information that would pr
|
|
|
267
260
|
Wrap your summary in <summary></summary> tags.`;
|
|
268
261
|
export function buildSystemPrompt(basePrompt, tools, options = {}) {
|
|
269
262
|
let prompt = basePrompt || DEFAULT_SYSTEM_PROMPT;
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
toolNames.has(TASK_GET_TOOL_NAME) ||
|
|
273
|
-
toolNames.has(TASK_UPDATE_TOOL_NAME) ||
|
|
274
|
-
toolNames.has(TASK_LIST_TOOL_NAME)) {
|
|
275
|
-
prompt += TASK_MANAGEMENT_POLICY;
|
|
263
|
+
if (tools.length > 0) {
|
|
264
|
+
prompt += `\n\n${TOOL_POLICY}`;
|
|
276
265
|
}
|
|
277
|
-
prompt += `\n\n${TOOL_POLICY}`;
|
|
278
266
|
for (const tool of tools) {
|
|
279
267
|
if (tool.prompt) {
|
|
280
|
-
prompt += tool.prompt(
|
|
268
|
+
prompt += tool.prompt({
|
|
269
|
+
availableSubagents: options.availableSubagents,
|
|
270
|
+
availableSkills: options.availableSkills,
|
|
271
|
+
workdir: options.workdir,
|
|
272
|
+
});
|
|
281
273
|
}
|
|
282
274
|
}
|
|
283
275
|
if (options.language) {
|
|
@@ -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;
|
|
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,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try {
|
|
48
48
|
const content = await fs.readFile(this.knownMarketplacesPath, "utf-8");
|
|
49
|
+
if (!content.trim()) {
|
|
50
|
+
return {
|
|
51
|
+
marketplaces: [
|
|
52
|
+
{
|
|
53
|
+
...MarketplaceService.BUILTIN_MARKETPLACE,
|
|
54
|
+
isBuiltin: true,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
};
|
|
58
|
+
}
|
|
49
59
|
return JSON.parse(content);
|
|
50
60
|
}
|
|
51
61
|
catch (error) {
|
|
@@ -62,6 +72,9 @@ export class MarketplaceService {
|
|
|
62
72
|
}
|
|
63
73
|
try {
|
|
64
74
|
const content = await fs.readFile(this.installedPluginsPath, "utf-8");
|
|
75
|
+
if (!content.trim()) {
|
|
76
|
+
return { plugins: [] };
|
|
77
|
+
}
|
|
65
78
|
return JSON.parse(content);
|
|
66
79
|
}
|
|
67
80
|
catch (error) {
|
|
@@ -2,6 +2,10 @@ import { ChatCompletionMessageToolCall } from "openai/resources";
|
|
|
2
2
|
import { ChatCompletionMessageParam, ChatCompletionFunctionTool } from "openai/resources.js";
|
|
3
3
|
import type { GatewayConfig, ModelConfig } from "../types/index.js";
|
|
4
4
|
import { type ClaudeUsage } from "../utils/cacheControlUtils.js";
|
|
5
|
+
/**
|
|
6
|
+
* Resets the rate limiter state. Primarily used for testing.
|
|
7
|
+
*/
|
|
8
|
+
export declare function resetRateLimiter(): void;
|
|
5
9
|
export interface CallAgentOptions {
|
|
6
10
|
gatewayConfig: GatewayConfig;
|
|
7
11
|
modelConfig: ModelConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aiService.d.ts","sourceRoot":"","sources":["../../src/services/aiService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAGL,0BAA0B,EAC1B,0BAA0B,EAE3B,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"aiService.d.ts","sourceRoot":"","s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AAC;IAC7C,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,aAAa,CAAC,EACV,MAAM,GACN,QAAQ,GACR,YAAY,GACZ,gBAAgB,GAChB,eAAe,GACf,IAAI,CAAC;IACT,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC5C;AAED,wBAAsB,SAAS,CAC7B,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,CAuT1B;AA4OD,MAAM,WAAW,uBAAuB;IAEtC,aAAa,EAAE,aAAa,CAAC;IAC7B,WAAW,EAAE,WAAW,CAAC;IAGzB,QAAQ,EAAE,0BAA0B,EAAE,CAAC;IACvC,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE;QACN,aAAa,EAAE,MAAM,CAAC;QACtB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;CACH;AAED,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,sBAAsB,CAAC,CA2EjC"}
|
|
@@ -1,10 +1,47 @@
|
|
|
1
1
|
import { OpenAIClient } from "../utils/openaiClient.js";
|
|
2
2
|
import { logger } from "../utils/globalLogger.js";
|
|
3
|
+
import { addOnceAbortListener } from "../utils/abortUtils.js";
|
|
3
4
|
import { transformMessagesForClaudeCache, addCacheControlToLastTool, isClaudeModel, extendUsageWithCacheMetrics, } from "../utils/cacheControlUtils.js";
|
|
4
5
|
import * as os from "os";
|
|
5
6
|
import * as fs from "fs";
|
|
6
7
|
import * as path from "path";
|
|
7
8
|
import { COMPRESS_MESSAGES_SYSTEM_PROMPT } from "../prompts/index.js";
|
|
9
|
+
// Global rate limiter state for 1 QPS
|
|
10
|
+
let nextAllowedTime = 0;
|
|
11
|
+
const MIN_INTERVAL = 1000; // 1 second for 1 QPS
|
|
12
|
+
/**
|
|
13
|
+
* Resets the rate limiter state. Primarily used for testing.
|
|
14
|
+
*/
|
|
15
|
+
export function resetRateLimiter() {
|
|
16
|
+
nextAllowedTime = 0;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Acquires a slot for an AI request, ensuring 1 QPS limit.
|
|
20
|
+
* @param abortSignal Optional abort signal to cancel waiting
|
|
21
|
+
*/
|
|
22
|
+
async function acquireSlot(abortSignal) {
|
|
23
|
+
if (abortSignal?.aborted) {
|
|
24
|
+
throw new Error("Request was aborted");
|
|
25
|
+
}
|
|
26
|
+
const now = Date.now();
|
|
27
|
+
const waitTime = Math.max(0, nextAllowedTime - now);
|
|
28
|
+
// Reserve the slot synchronously to ensure global ordering
|
|
29
|
+
nextAllowedTime = Math.max(now, nextAllowedTime) + MIN_INTERVAL;
|
|
30
|
+
if (waitTime > 0) {
|
|
31
|
+
await new Promise((resolve, reject) => {
|
|
32
|
+
const timeout = setTimeout(() => {
|
|
33
|
+
cleanup();
|
|
34
|
+
resolve();
|
|
35
|
+
}, waitTime);
|
|
36
|
+
const cleanup = abortSignal
|
|
37
|
+
? addOnceAbortListener(abortSignal, () => {
|
|
38
|
+
clearTimeout(timeout);
|
|
39
|
+
reject(new Error("Request was aborted"));
|
|
40
|
+
})
|
|
41
|
+
: () => { };
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
8
45
|
/**
|
|
9
46
|
* Get specific configuration parameters based on model name
|
|
10
47
|
* @param modelName Model name
|
|
@@ -22,17 +59,15 @@ function getModelConfig(modelName, baseConfig = {}) {
|
|
|
22
59
|
// gpt-5-codex model sets temperature to undefined
|
|
23
60
|
config.temperature = undefined;
|
|
24
61
|
}
|
|
25
|
-
if (modelName.startsWith("gemini-3-flash")) {
|
|
26
|
-
config.vertexai = {
|
|
27
|
-
thinking_config: {
|
|
28
|
-
thinking_level: "minimal",
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
62
|
return config;
|
|
33
63
|
}
|
|
34
64
|
export async function callAgent(options) {
|
|
35
65
|
const { gatewayConfig, modelConfig, messages, abortSignal, workdir, tools, model, systemPrompt, onContentUpdate, onToolUpdate, onReasoningUpdate, } = options;
|
|
66
|
+
// Apply global 1 QPS rate limit
|
|
67
|
+
if (process.env.NODE_ENV !== "test" ||
|
|
68
|
+
modelConfig.agentModel === "rate-limit-test") {
|
|
69
|
+
await acquireSlot(abortSignal);
|
|
70
|
+
}
|
|
36
71
|
// Declare variables outside try block for error handling access
|
|
37
72
|
let openaiMessages;
|
|
38
73
|
let createParams;
|
|
@@ -409,6 +444,11 @@ async function processStreamingResponse(stream, onContentUpdate, onToolUpdate, o
|
|
|
409
444
|
}
|
|
410
445
|
export async function compressMessages(options) {
|
|
411
446
|
const { gatewayConfig, modelConfig, messages, abortSignal } = options;
|
|
447
|
+
// Apply global 1 QPS rate limit
|
|
448
|
+
if (process.env.NODE_ENV !== "test" ||
|
|
449
|
+
modelConfig.agentModel === "rate-limit-test") {
|
|
450
|
+
await acquireSlot(abortSignal);
|
|
451
|
+
}
|
|
412
452
|
// Create OpenAI client with injected configuration
|
|
413
453
|
const openai = new OpenAIClient({
|
|
414
454
|
apiKey: gatewayConfig.apiKey,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configurationService.d.ts","sourceRoot":"","sources":["../../src/services/configurationService.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EACV,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,KAAK,EACN,MAAM,2BAA2B,CAAC;AAOnC,OAAO,EACL,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAE7B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,aAAa,EACb,WAAW,EAGX,cAAc,EACf,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAGvC;;;;;GAKG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,oBAAoB,CAAkC;IAC9D,OAAO,CAAC,GAAG,CAA8B;IAIzC;;OAEG;IACG,uBAAuB,CAC3B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,uBAAuB,CAAC;IAiFnC;;OAEG;IACH,qBAAqB,CAAC,MAAM,EAAE,iBAAiB,GAAG,gBAAgB;IA2IlE;;OAEG;IACH,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,gBAAgB;IAwC7D;;OAEG;IACH,uBAAuB,IAAI,iBAAiB,GAAG,IAAI;IAInD;;;OAGG;IACH,kBAAkB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAIrD;;OAEG;IACH,kBAAkB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAQ5C;;;;;;;;;;OAUG;IACH,oBAAoB,CAClB,MAAM,CAAC,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,EAChB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACvC,YAAY,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC,EAC5C,KAAK,CAAC,EAAE,aAAa,CAAC,OAAO,CAAC,GAC7B,aAAa;
|
|
1
|
+
{"version":3,"file":"configurationService.d.ts","sourceRoot":"","sources":["../../src/services/configurationService.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EACV,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,KAAK,EACN,MAAM,2BAA2B,CAAC;AAOnC,OAAO,EACL,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,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AACH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,MAAM,EAAE,GAClB,iBAAiB,GAAG,IAAI,CAQ1B;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,iBAAiB,GAAG,IAAI,CAE7D;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,GACd,iBAAiB,GAAG,IAAI,CAE1B;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,GACd,iBAAiB,GAAG,IAAI,CA+H1B"}
|
|
@@ -288,7 +288,7 @@ export class ConfigurationService {
|
|
|
288
288
|
resolvedApiKey = apiKey;
|
|
289
289
|
}
|
|
290
290
|
else {
|
|
291
|
-
resolvedApiKey = this.env.WAVE_API_KEY
|
|
291
|
+
resolvedApiKey = this.env.WAVE_API_KEY;
|
|
292
292
|
}
|
|
293
293
|
// Resolve base URL: constructor > env (settings.json) > process.env
|
|
294
294
|
// Note: Explicitly provided empty strings should be treated as invalid, not fall back to env
|
|
@@ -297,8 +297,23 @@ export class ConfigurationService {
|
|
|
297
297
|
resolvedBaseURL = baseURL;
|
|
298
298
|
}
|
|
299
299
|
else {
|
|
300
|
-
resolvedBaseURL =
|
|
301
|
-
|
|
300
|
+
resolvedBaseURL = this.env.WAVE_BASE_URL || "";
|
|
301
|
+
}
|
|
302
|
+
// If we have a parent configuration, use it as a fallback for API key and base URL
|
|
303
|
+
if (this.currentConfiguration?.env) {
|
|
304
|
+
if (resolvedApiKey === undefined) {
|
|
305
|
+
resolvedApiKey = this.currentConfiguration.env.WAVE_API_KEY;
|
|
306
|
+
}
|
|
307
|
+
if (!resolvedBaseURL) {
|
|
308
|
+
resolvedBaseURL = this.currentConfiguration.env.WAVE_BASE_URL || "";
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
// Fallback to process.env if still not resolved (for dynamic updates in tests)
|
|
312
|
+
if (resolvedApiKey === undefined) {
|
|
313
|
+
resolvedApiKey = process.env.WAVE_API_KEY;
|
|
314
|
+
}
|
|
315
|
+
if (!resolvedBaseURL) {
|
|
316
|
+
resolvedBaseURL = process.env.WAVE_BASE_URL || "";
|
|
302
317
|
}
|
|
303
318
|
if (!resolvedBaseURL && baseURL === undefined) {
|
|
304
319
|
throw new ConfigurationError(CONFIG_ERRORS.MISSING_BASE_URL, "baseURL", {
|
|
@@ -339,15 +354,19 @@ export class ConfigurationService {
|
|
|
339
354
|
const DEFAULT_AGENT_MODEL = "gemini-3-flash";
|
|
340
355
|
const DEFAULT_FAST_MODEL = "gemini-2.5-flash";
|
|
341
356
|
// Resolve agent model: constructor > env (settings.json) > process.env > default
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
357
|
+
let resolvedAgentModel = agentModel || this.env.WAVE_MODEL;
|
|
358
|
+
if (!resolvedAgentModel && this.currentConfiguration?.env?.WAVE_MODEL) {
|
|
359
|
+
resolvedAgentModel = this.currentConfiguration.env.WAVE_MODEL;
|
|
360
|
+
}
|
|
361
|
+
resolvedAgentModel =
|
|
362
|
+
resolvedAgentModel || process.env.WAVE_MODEL || DEFAULT_AGENT_MODEL;
|
|
346
363
|
// Resolve fast model: constructor > env (settings.json) > process.env > default
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
364
|
+
let resolvedFastModel = fastModel || this.env.WAVE_FAST_MODEL;
|
|
365
|
+
if (!resolvedFastModel && this.currentConfiguration?.env?.WAVE_FAST_MODEL) {
|
|
366
|
+
resolvedFastModel = this.currentConfiguration.env.WAVE_FAST_MODEL;
|
|
367
|
+
}
|
|
368
|
+
resolvedFastModel =
|
|
369
|
+
resolvedFastModel || process.env.WAVE_FAST_MODEL || DEFAULT_FAST_MODEL;
|
|
351
370
|
// Resolve max output tokens
|
|
352
371
|
const resolvedMaxTokens = this.resolveMaxOutputTokens(maxTokens);
|
|
353
372
|
return {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { EventEmitter } from "events";
|
|
2
2
|
import { Task } from "../types/tasks.js";
|
|
3
|
+
import { Container } from "../utils/container.js";
|
|
3
4
|
export declare class TaskManager extends EventEmitter {
|
|
5
|
+
private container;
|
|
4
6
|
private readonly baseDir;
|
|
5
7
|
private taskListId;
|
|
6
|
-
constructor(taskListId: string);
|
|
8
|
+
constructor(container: Container, taskListId: string);
|
|
7
9
|
getTaskListId(): string;
|
|
8
10
|
setTaskListId(taskListId: string): void;
|
|
9
11
|
private getSessionDir;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taskManager.d.ts","sourceRoot":"","sources":["../../src/services/taskManager.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"taskManager.d.ts","sourceRoot":"","sources":["../../src/services/taskManager.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,qBAAa,WAAY,SAAQ,YAAY;IAKzC,OAAO,CAAC,SAAS;IAJnB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,UAAU,CAAS;gBAGjB,SAAS,EAAE,SAAS,EAC5B,UAAU,EAAE,MAAM;IAOb,aAAa,IAAI,MAAM;IAIvB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAI9C,OAAO,CAAC,aAAa;IAId,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAI1C,OAAO,CAAC,WAAW;IAIb,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;YAIzB,QAAQ;IA2CtB,OAAO,CAAC,YAAY;IAed,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAcnD,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAmB7C,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAWrC,SAAS,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IA+B5B,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC;IActC;;OAEG;IACU,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;CAG3C"}
|