wave-agent-sdk 0.6.5 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (190) hide show
  1. package/dist/agent.d.ts +8 -0
  2. package/dist/agent.d.ts.map +1 -1
  3. package/dist/agent.js +49 -240
  4. package/dist/constants/tools.d.ts +0 -2
  5. package/dist/constants/tools.d.ts.map +1 -1
  6. package/dist/constants/tools.js +0 -2
  7. package/dist/core/plugin.d.ts +86 -0
  8. package/dist/core/plugin.d.ts.map +1 -0
  9. package/dist/core/plugin.js +164 -0
  10. package/dist/core/session.d.ts +3 -0
  11. package/dist/core/session.d.ts.map +1 -0
  12. package/dist/core/session.js +1 -0
  13. package/dist/index.d.ts +2 -9
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +2 -10
  16. package/dist/managers/MemoryRuleManager.d.ts +3 -1
  17. package/dist/managers/MemoryRuleManager.d.ts.map +1 -1
  18. package/dist/managers/MemoryRuleManager.js +2 -1
  19. package/dist/managers/aiManager.d.ts +13 -23
  20. package/dist/managers/aiManager.d.ts.map +1 -1
  21. package/dist/managers/aiManager.js +60 -32
  22. package/dist/managers/backgroundTaskManager.d.ts +3 -1
  23. package/dist/managers/backgroundTaskManager.d.ts.map +1 -1
  24. package/dist/managers/backgroundTaskManager.js +2 -1
  25. package/dist/managers/bashManager.d.ts +4 -4
  26. package/dist/managers/bashManager.d.ts.map +1 -1
  27. package/dist/managers/bashManager.js +5 -2
  28. package/dist/managers/foregroundTaskManager.d.ts +3 -0
  29. package/dist/managers/foregroundTaskManager.d.ts.map +1 -1
  30. package/dist/managers/foregroundTaskManager.js +2 -1
  31. package/dist/managers/hookManager.d.ts +3 -3
  32. package/dist/managers/hookManager.d.ts.map +1 -1
  33. package/dist/managers/hookManager.js +20 -19
  34. package/dist/managers/liveConfigManager.d.ts +6 -13
  35. package/dist/managers/liveConfigManager.d.ts.map +1 -1
  36. package/dist/managers/liveConfigManager.js +50 -45
  37. package/dist/managers/lspManager.d.ts +4 -5
  38. package/dist/managers/lspManager.d.ts.map +1 -1
  39. package/dist/managers/lspManager.js +13 -12
  40. package/dist/managers/mcpManager.d.ts +3 -2
  41. package/dist/managers/mcpManager.d.ts.map +1 -1
  42. package/dist/managers/mcpManager.js +16 -15
  43. package/dist/managers/messageManager.d.ts +5 -7
  44. package/dist/managers/messageManager.d.ts.map +1 -1
  45. package/dist/managers/messageManager.js +12 -7
  46. package/dist/managers/permissionManager.d.ts +6 -4
  47. package/dist/managers/permissionManager.d.ts.map +1 -1
  48. package/dist/managers/permissionManager.js +39 -63
  49. package/dist/managers/planManager.d.ts +4 -6
  50. package/dist/managers/planManager.d.ts.map +1 -1
  51. package/dist/managers/planManager.js +18 -4
  52. package/dist/managers/pluginManager.d.ts +10 -22
  53. package/dist/managers/pluginManager.d.ts.map +1 -1
  54. package/dist/managers/pluginManager.js +27 -14
  55. package/dist/managers/reversionManager.d.ts +4 -3
  56. package/dist/managers/reversionManager.d.ts.map +1 -1
  57. package/dist/managers/reversionManager.js +5 -2
  58. package/dist/managers/skillManager.d.ts +3 -2
  59. package/dist/managers/skillManager.d.ts.map +1 -1
  60. package/dist/managers/skillManager.js +15 -14
  61. package/dist/managers/slashCommandManager.d.ts +9 -16
  62. package/dist/managers/slashCommandManager.d.ts.map +1 -1
  63. package/dist/managers/slashCommandManager.js +21 -10
  64. package/dist/managers/subagentManager.d.ts +7 -17
  65. package/dist/managers/subagentManager.d.ts.map +1 -1
  66. package/dist/managers/subagentManager.js +41 -34
  67. package/dist/managers/toolManager.d.ts +15 -38
  68. package/dist/managers/toolManager.d.ts.map +1 -1
  69. package/dist/managers/toolManager.js +67 -56
  70. package/dist/prompts/index.d.ts +6 -2
  71. package/dist/prompts/index.d.ts.map +1 -1
  72. package/dist/prompts/index.js +8 -4
  73. package/dist/services/MarketplaceService.d.ts.map +1 -1
  74. package/dist/services/MarketplaceService.js +13 -0
  75. package/dist/services/aiService.d.ts +4 -0
  76. package/dist/services/aiService.d.ts.map +1 -1
  77. package/dist/services/aiService.js +47 -7
  78. package/dist/services/configurationService.d.ts.map +1 -1
  79. package/dist/services/configurationService.js +30 -11
  80. package/dist/services/taskManager.d.ts +3 -1
  81. package/dist/services/taskManager.d.ts.map +1 -1
  82. package/dist/services/taskManager.js +3 -2
  83. package/dist/tools/bashTool.d.ts.map +1 -1
  84. package/dist/tools/bashTool.js +19 -4
  85. package/dist/tools/editTool.d.ts.map +1 -1
  86. package/dist/tools/editTool.js +16 -4
  87. package/dist/tools/readTool.d.ts.map +1 -1
  88. package/dist/tools/readTool.js +2 -2
  89. package/dist/tools/skillTool.d.ts +2 -4
  90. package/dist/tools/skillTool.d.ts.map +1 -1
  91. package/dist/tools/skillTool.js +61 -61
  92. package/dist/tools/taskOutputTool.d.ts.map +1 -1
  93. package/dist/tools/taskOutputTool.js +3 -2
  94. package/dist/tools/taskTool.d.ts +2 -4
  95. package/dist/tools/taskTool.d.ts.map +1 -1
  96. package/dist/tools/taskTool.js +192 -187
  97. package/dist/tools/types.d.ts +12 -1
  98. package/dist/tools/types.d.ts.map +1 -1
  99. package/dist/tools/writeTool.d.ts.map +1 -1
  100. package/dist/tools/writeTool.js +5 -2
  101. package/dist/types/core.d.ts +2 -0
  102. package/dist/types/core.d.ts.map +1 -1
  103. package/dist/types/marketplace.d.ts +8 -0
  104. package/dist/types/marketplace.d.ts.map +1 -1
  105. package/dist/types/messaging.d.ts +1 -0
  106. package/dist/types/messaging.d.ts.map +1 -1
  107. package/dist/types/permissions.d.ts +3 -1
  108. package/dist/types/permissions.d.ts.map +1 -1
  109. package/dist/types/permissions.js +1 -3
  110. package/dist/types/skills.d.ts +0 -2
  111. package/dist/types/skills.d.ts.map +1 -1
  112. package/dist/types/tools.d.ts +0 -15
  113. package/dist/types/tools.d.ts.map +1 -1
  114. package/dist/utils/container.d.ts +31 -0
  115. package/dist/utils/container.d.ts.map +1 -0
  116. package/dist/utils/container.js +79 -0
  117. package/dist/utils/containerSetup.d.ts +26 -0
  118. package/dist/utils/containerSetup.d.ts.map +1 -0
  119. package/dist/utils/containerSetup.js +187 -0
  120. package/dist/utils/editUtils.d.ts +0 -3
  121. package/dist/utils/editUtils.d.ts.map +1 -1
  122. package/dist/utils/editUtils.js +4 -3
  123. package/dist/utils/hookMatcher.d.ts +1 -1
  124. package/dist/utils/hookMatcher.d.ts.map +1 -1
  125. package/dist/utils/hookMatcher.js +2 -2
  126. package/dist/utils/messageOperations.d.ts +2 -1
  127. package/dist/utils/messageOperations.d.ts.map +1 -1
  128. package/dist/utils/messageOperations.js +4 -1
  129. package/dist/utils/openaiClient.js +2 -2
  130. package/dist/utils/stringUtils.d.ts +6 -0
  131. package/dist/utils/stringUtils.d.ts.map +1 -1
  132. package/dist/utils/stringUtils.js +8 -0
  133. package/package.json +1 -1
  134. package/src/agent.ts +60 -282
  135. package/src/constants/tools.ts +0 -2
  136. package/src/core/plugin.ts +224 -0
  137. package/src/core/session.ts +6 -0
  138. package/src/index.ts +2 -11
  139. package/src/managers/MemoryRuleManager.ts +6 -1
  140. package/src/managers/aiManager.ts +84 -58
  141. package/src/managers/backgroundTaskManager.ts +5 -1
  142. package/src/managers/bashManager.ts +9 -4
  143. package/src/managers/foregroundTaskManager.ts +3 -0
  144. package/src/managers/hookManager.ts +21 -23
  145. package/src/managers/liveConfigManager.ts +57 -53
  146. package/src/managers/lspManager.ts +14 -19
  147. package/src/managers/mcpManager.ts +20 -20
  148. package/src/managers/messageManager.ts +19 -12
  149. package/src/managers/permissionManager.ts +45 -70
  150. package/src/managers/planManager.ts +26 -7
  151. package/src/managers/pluginManager.ts +37 -33
  152. package/src/managers/reversionManager.ts +5 -3
  153. package/src/managers/skillManager.ts +19 -20
  154. package/src/managers/slashCommandManager.ts +30 -25
  155. package/src/managers/subagentManager.ts +53 -53
  156. package/src/managers/toolManager.ts +93 -90
  157. package/src/prompts/index.ts +13 -5
  158. package/src/services/MarketplaceService.ts +13 -0
  159. package/src/services/aiService.ts +61 -15
  160. package/src/services/configurationService.ts +34 -13
  161. package/src/services/taskManager.ts +6 -2
  162. package/src/tools/bashTool.ts +19 -4
  163. package/src/tools/editTool.ts +17 -4
  164. package/src/tools/readTool.ts +2 -2
  165. package/src/tools/skillTool.ts +75 -71
  166. package/src/tools/taskOutputTool.ts +3 -2
  167. package/src/tools/taskTool.ts +224 -225
  168. package/src/tools/types.ts +14 -1
  169. package/src/tools/writeTool.ts +5 -2
  170. package/src/types/core.ts +2 -0
  171. package/src/types/marketplace.ts +9 -0
  172. package/src/types/messaging.ts +1 -0
  173. package/src/types/permissions.ts +2 -4
  174. package/src/types/skills.ts +0 -3
  175. package/src/types/tools.ts +0 -17
  176. package/src/utils/container.ts +92 -0
  177. package/src/utils/containerSetup.ts +279 -0
  178. package/src/utils/editUtils.ts +4 -3
  179. package/src/utils/hookMatcher.ts +2 -2
  180. package/src/utils/messageOperations.ts +5 -0
  181. package/src/utils/openaiClient.ts +2 -2
  182. package/src/utils/stringUtils.ts +9 -0
  183. package/dist/tools/deleteFileTool.d.ts +0 -6
  184. package/dist/tools/deleteFileTool.d.ts.map +0 -1
  185. package/dist/tools/deleteFileTool.js +0 -100
  186. package/dist/tools/multiEditTool.d.ts +0 -6
  187. package/dist/tools/multiEditTool.d.ts.map +0 -1
  188. package/dist/tools/multiEditTool.js +0 -246
  189. package/src/tools/deleteFileTool.ts +0 -127
  190. 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 { createTaskTool } from "../tools/taskTool.js";
17
- import { createSkillTool } from "../tools/skillTool.js";
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.tools = new Map();
28
- this.mcpManager = options.mcpManager;
29
- this.lspManager = options.lspManager;
30
- this.logger = options.logger;
31
- this.permissionManager = options.permissionManager;
32
- this.taskManager = options.taskManager;
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.tools.set(tool.name, tool);
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, TodoWrite, etc.). When called with
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(deps) {
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.tools.set(tool.name, tool);
92
- }
93
- // Register tools that require dependencies
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
- if (deps?.skillManager) {
99
- const skillTool = createSkillTool(deps.skillManager);
100
- this.tools.set(skillTool.name, skillTool);
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,55 @@ 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 = this.permissionManager
119
- ? this.permissionManager.getCurrentEffectiveMode(this.permissionMode)
120
- : this.permissionMode || "default";
117
+ const effectivePermissionMode = permissionManager
118
+ ? permissionManager.getCurrentEffectiveMode(permissionMode)
119
+ : permissionMode || "default";
121
120
  // Enhance context with permission-related fields
121
+ const canUseToolCallback = this.container.has("CanUseToolCallback")
122
+ ? this.container.get("CanUseToolCallback")
123
+ : undefined;
122
124
  const enhancedContext = {
123
125
  ...context,
124
126
  permissionMode: effectivePermissionMode,
125
- canUseToolCallback: this.canUseToolCallback,
126
- permissionManager: this.permissionManager,
127
- taskManager: this.taskManager,
128
- reversionManager: this.reversionManager,
129
- backgroundTaskManager: this.backgroundTaskManager,
130
- foregroundTaskManager: this.foregroundTaskManager,
127
+ canUseToolCallback,
128
+ permissionManager,
129
+ taskManager: this.container.get("TaskManager"),
130
+ reversionManager: this.container.get("ReversionManager"),
131
+ backgroundTaskManager: this.container.get("BackgroundTaskManager"),
132
+ foregroundTaskManager: this.container.get("ForegroundTaskManager"),
131
133
  mcpManager: this.mcpManager,
132
- lspManager: this.lspManager,
134
+ lspManager: this.container.get("LspManager"),
135
+ subagentManager: this.container.has("SubagentManager")
136
+ ? this.container.get("SubagentManager")
137
+ : undefined,
138
+ skillManager: this.container.has("SkillManager")
139
+ ? this.container.get("SkillManager")
140
+ : undefined,
133
141
  sessionId: context.sessionId,
134
142
  };
135
- this.logger?.debug("Executing tool with enhanced context", {
143
+ logger?.debug("Executing tool with enhanced context", {
136
144
  toolName: name,
137
- cliPermissionMode: this.permissionMode,
145
+ permissionMode,
138
146
  effectivePermissionMode,
139
- hasPermissionManager: !!this.permissionManager,
140
- hasPermissionCallback: !!this.canUseToolCallback,
147
+ hasPermissionManager: !!permissionManager,
141
148
  });
142
149
  // Check if it's an MCP tool first
143
150
  if (this.mcpManager.isMcpTool(name)) {
144
151
  return this.mcpManager.executeMcpToolByRegistry(name, args, enhancedContext);
145
152
  }
146
153
  // Check built-in tools
147
- const plugin = this.tools.get(name);
154
+ const plugin = this.toolsRegistry.get(name);
148
155
  if (plugin) {
149
156
  try {
150
157
  return await plugin.execute(args, enhancedContext);
151
158
  }
152
159
  catch (error) {
153
- this.logger?.error("Tool execution failed", {
160
+ logger?.error("Tool execution failed", {
154
161
  toolName: name,
155
162
  error: error instanceof Error ? error.message : String(error),
156
163
  });
@@ -161,7 +168,7 @@ class ToolManager {
161
168
  };
162
169
  }
163
170
  }
164
- this.logger?.warn("Tool not found", { toolName: name });
171
+ logger?.warn("Tool not found", { toolName: name });
165
172
  return {
166
173
  success: false,
167
174
  content: "",
@@ -169,13 +176,13 @@ class ToolManager {
169
176
  };
170
177
  }
171
178
  list() {
172
- const builtInTools = Array.from(this.tools.values());
179
+ const builtInTools = Array.from(this.toolsRegistry.values());
173
180
  const mcpTools = this.mcpManager.getMcpToolPlugins();
174
181
  return [...builtInTools, ...mcpTools];
175
182
  }
176
183
  getToolsConfig() {
177
184
  const effectivePermissionMode = this.getPermissionMode();
178
- const builtInToolsConfig = Array.from(this.tools.values())
185
+ const builtInToolsConfig = Array.from(this.toolsRegistry.values())
179
186
  .filter((tool) => {
180
187
  if (effectivePermissionMode === "bypassPermissions") {
181
188
  if (tool.name === "ExitPlanMode" || tool.name === "AskUserQuestion") {
@@ -195,35 +202,39 @@ class ToolManager {
195
202
  * Get the list of registered tool plugins
196
203
  */
197
204
  getTools() {
198
- return Array.from(this.tools.values());
205
+ return Array.from(this.toolsRegistry.values());
199
206
  }
200
207
  /**
201
208
  * Get the current permission mode
202
209
  */
203
210
  getPermissionMode() {
204
- if (this.permissionManager) {
205
- return this.permissionManager.getCurrentEffectiveMode(this.permissionMode);
211
+ const permissionManager = this.container.get("PermissionManager");
212
+ const permissionMode = this.container.has("PermissionMode")
213
+ ? this.container.get("PermissionMode")
214
+ : undefined;
215
+ if (permissionManager) {
216
+ return permissionManager.getCurrentEffectiveMode(permissionMode);
206
217
  }
207
- return this.permissionMode || "default";
218
+ return permissionMode || "default";
208
219
  }
209
220
  /**
210
221
  * Set the permission mode
211
222
  * @param mode - The new permission mode
212
223
  */
213
224
  setPermissionMode(mode) {
214
- this.permissionMode = mode;
225
+ this.container.register("PermissionMode", mode);
215
226
  }
216
227
  /**
217
228
  * Get the permission manager
218
229
  */
219
230
  getPermissionManager() {
220
- return this.permissionManager;
231
+ return this.container.get("PermissionManager");
221
232
  }
222
233
  /**
223
234
  * Get the task manager
224
235
  */
225
236
  getTaskManager() {
226
- return this.taskManager;
237
+ return this.container.get("TaskManager");
227
238
  }
228
239
  }
229
240
  // Export tool registry class and types
@@ -5,10 +5,12 @@ export declare function buildPlanModePrompt(planFilePath: string, planExists: bo
5
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.";
6
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.";
7
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.";
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- Deleting files (no rm or deletion)\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- Deleting files (no rm or deletion)\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.";
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.";
10
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```";
11
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";
12
14
  export declare function buildSystemPrompt(basePrompt: string | undefined, tools: ToolPlugin[], options?: {
13
15
  workdir?: string;
14
16
  memory?: string;
@@ -18,5 +20,7 @@ export declare function buildSystemPrompt(basePrompt: string | undefined, tools:
18
20
  planFilePath: string;
19
21
  planExists: boolean;
20
22
  };
23
+ availableSubagents?: SubagentConfiguration[];
24
+ availableSkills?: SkillMetadata[];
21
25
  }): string;
22
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;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,21EAoCuC,CAAC;AAEnF,eAAO,MAAM,2BAA2B,25EAiD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AU,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"}
@@ -135,7 +135,6 @@ export const EXPLORE_SUBAGENT_SYSTEM_PROMPT = `You are a file search specialist.
135
135
  This is a READ-ONLY exploration task. You are STRICTLY PROHIBITED from:
136
136
  - Creating new files (no Write, touch, or file creation of any kind)
137
137
  - Modifying existing files (no Edit operations)
138
- - Deleting files (no rm or deletion)
139
138
  - Moving or copying files (no mv or cp)
140
139
  - Creating temporary files anywhere, including /tmp
141
140
  - Using redirect operators (>, >>, |) or heredocs to write to files
@@ -172,7 +171,6 @@ export const PLAN_SUBAGENT_SYSTEM_PROMPT = `You are a software architect and pla
172
171
  This is a READ-ONLY planning task. You are STRICTLY PROHIBITED from:
173
172
  - Creating new files (no Write, touch, or file creation of any kind)
174
173
  - Modifying existing files (no Edit operations)
175
- - Deleting files (no rm or deletion)
176
174
  - Moving or copying files (no mv or cp)
177
175
  - Creating temporary files anywhere, including /tmp
178
176
  - Using redirect operators (>, >>, |) or heredocs to write to files
@@ -262,10 +260,16 @@ Be concise but complete—err on the side of including information that would pr
262
260
  Wrap your summary in <summary></summary> tags.`;
263
261
  export function buildSystemPrompt(basePrompt, tools, options = {}) {
264
262
  let prompt = basePrompt || DEFAULT_SYSTEM_PROMPT;
265
- prompt += `\n\n${TOOL_POLICY}`;
263
+ if (tools.length > 0) {
264
+ prompt += `\n\n${TOOL_POLICY}`;
265
+ }
266
266
  for (const tool of tools) {
267
267
  if (tool.prompt) {
268
- prompt += tool.prompt();
268
+ prompt += tool.prompt({
269
+ availableSubagents: options.availableSubagents,
270
+ availableSkills: options.availableSkills,
271
+ workdir: options.workdir,
272
+ });
269
273
  }
270
274
  }
271
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;IAoBhE;;OAEG;IACG,mBAAmB,IAAI,OAAO,CAAC,wBAAwB,CAAC;IAa9D;;OAEG;IACG,qBAAqB,CACzB,QAAQ,EAAE,yBAAyB,GAClC,OAAO,CAAC,IAAI,CAAC;IAOhB;;OAEG;IACG,oBAAoB,CACxB,QAAQ,EAAE,wBAAwB,GACjC,OAAO,CAAC,IAAI,CAAC;IAOhB;;OAEG;IACG,uBAAuB,CAC3B,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,mBAAmB,CAAC;IAwB/B;;OAEG;IACI,kBAAkB,CAAC,WAAW,EAAE,gBAAgB,GAAG,MAAM;IAehE;;OAEG;I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A8BhE;;OAEG;IACG,mBAAmB,IAAI,OAAO,CAAC,wBAAwB,CAAC;IAgB9D;;OAEG;IACG,qBAAqB,CACzB,QAAQ,EAAE,yBAAyB,GAClC,OAAO,CAAC,IAAI,CAAC;IAOhB;;OAEG;IACG,oBAAoB,CACxB,QAAQ,EAAE,wBAAwB,GACjC,OAAO,CAAC,IAAI,CAAC;IAOhB;;OAEG;IACG,uBAAuB,CAC3B,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,mBAAmB,CAAC;IAwB/B;;OAEG;IACI,kBAAkB,CAAC,WAAW,EAAE,gBAAgB,GAAG,MAAM;IAehE;;OAEG;IACG,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA0F9D;;OAEG;IACG,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAQrD;;OAEG;IACG,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAcpD;;OAEG;IACG,iBAAiB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA6CrD;;OAEG;IACG,aAAa,CACjB,mBAAmB,EAAE,MAAM,EAC3B,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,eAAe,CAAC;IA0H3B;;OAEG;IACG,eAAe,CACnB,mBAAmB,EAAE,MAAM,EAC3B,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,IAAI,CAAC;IAqChB;;OAEG;IACG,YAAY,CAAC,mBAAmB,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;CAI1E"}
@@ -46,6 +46,16 @@ export class MarketplaceService {
46
46
  }
47
47
  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;AAG7B,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAKL,KAAK,WAAW,EACjB,MAAM,+BAA+B,CAAC;AA+FvC,MAAM,WAAW,gBAAgB;IAE/B,aAAa,EAAE,aAAa,CAAC;IAC7B,WAAW,EAAE,WAAW,CAAC;IAGzB,QAAQ,EAAE,0BAA0B,EAAE,CAAC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,0BAA0B,EAAE,CAAC;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC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ger } 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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
+ {"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,GA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,EAAE,MAAM,CAAC,GAAG,SAAS,EAC3C,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EAC9C,OAAO,GAAE,uBAA4B,GACpC,wBAAwB,CAoC1B;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,GACf,iBAAiB,GAAG,IAAI,CA+C1B;AAED;;;GAGG;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 || process.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
- this.env.WAVE_BASE_URL || process.env.WAVE_BASE_URL || "";
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
- const resolvedAgentModel = agentModel ||
343
- this.env.WAVE_MODEL ||
344
- process.env.WAVE_MODEL ||
345
- DEFAULT_AGENT_MODEL;
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
- const resolvedFastModel = fastModel ||
348
- this.env.WAVE_FAST_MODEL ||
349
- process.env.WAVE_FAST_MODEL ||
350
- DEFAULT_FAST_MODEL;
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;AAGzC,qBAAa,WAAY,SAAQ,YAAY;IAC3C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,UAAU,CAAS;gBAEf,UAAU,EAAE,MAAM;IAMvB,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"}
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"}
@@ -4,8 +4,9 @@ import { homedir } from "os";
4
4
  import { EventEmitter } from "events";
5
5
  import { logger } from "../utils/globalLogger.js";
6
6
  export class TaskManager extends EventEmitter {
7
- constructor(taskListId) {
7
+ constructor(container, taskListId) {
8
8
  super();
9
+ this.container = container;
9
10
  this.taskListId = taskListId;
10
11
  this.baseDir = join(homedir(), ".wave", "tasks");
11
12
  }
@@ -31,7 +32,7 @@ export class TaskManager extends EventEmitter {
31
32
  const lockPath = this.getLockPath();
32
33
  let lockHandle;
33
34
  const maxRetries = 100;
34
- const retryDelay = process.env.NODE_ENV === "test" ? 10 : 100;
35
+ const retryDelay = process.env.NODE_ENV === "test" ? 1 : 100;
35
36
  await this.ensureSessionDir();
36
37
  for (let i = 0; i < maxRetries; i++) {
37
38
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"bashTool.d.ts","sourceRoot":"","sources":["../../src/tools/bashTool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AActE;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,UAkXtB,CAAC"}
1
+ {"version":3,"file":"bashTool.d.ts","sourceRoot":"","sources":["../../src/tools/bashTool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AActE;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,UAiYtB,CAAC"}