wave-agent-sdk 1.0.6 → 1.0.8

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 (52) hide show
  1. package/builtin/skills/settings/ENV.md +1 -0
  2. package/builtin/skills/settings/MODELS.md +3 -0
  3. package/builtin/subagents/vision.md +18 -0
  4. package/dist/agent.d.ts +11 -0
  5. package/dist/agent.js +15 -0
  6. package/dist/constants/tools.d.ts +1 -0
  7. package/dist/constants/tools.js +1 -0
  8. package/dist/index.d.ts +3 -1
  9. package/dist/index.js +1 -1
  10. package/dist/managers/aiManager.js +46 -7
  11. package/dist/managers/messageManager.d.ts +1 -1
  12. package/dist/managers/messageManager.js +9 -3
  13. package/dist/managers/permissionManager.d.ts +5 -0
  14. package/dist/managers/permissionManager.js +18 -2
  15. package/dist/managers/pluginManager.d.ts +9 -0
  16. package/dist/managers/pluginManager.js +20 -0
  17. package/dist/managers/subagentManager.d.ts +12 -0
  18. package/dist/managers/subagentManager.js +32 -2
  19. package/dist/managers/toolManager.js +7 -0
  20. package/dist/services/aiService.d.ts +3 -4
  21. package/dist/services/aiService.js +7 -20
  22. package/dist/services/artifactAvailability.d.ts +7 -0
  23. package/dist/services/artifactAvailability.js +26 -0
  24. package/dist/services/artifactSession.d.ts +27 -0
  25. package/dist/services/artifactSession.js +52 -0
  26. package/dist/services/configurationService.d.ts +9 -1
  27. package/dist/services/configurationService.js +26 -1
  28. package/dist/services/initializationService.js +5 -0
  29. package/dist/tools/agentTool.js +2 -1
  30. package/dist/tools/artifactTool.d.ts +2 -0
  31. package/dist/tools/artifactTool.js +357 -0
  32. package/dist/tools/bashTool.js +11 -11
  33. package/dist/tools/types.d.ts +3 -1
  34. package/dist/tools/webFetchTool.js +141 -0
  35. package/dist/types/agent.d.ts +2 -0
  36. package/dist/types/config.d.ts +2 -0
  37. package/dist/types/configuration.d.ts +2 -0
  38. package/dist/types/core.d.ts +1 -34
  39. package/dist/types/index.d.ts +1 -0
  40. package/dist/types/messaging.d.ts +3 -1
  41. package/dist/types/permissions.d.ts +3 -1
  42. package/dist/types/permissions.js +2 -1
  43. package/dist/utils/bashParser.d.ts +14 -0
  44. package/dist/utils/bashParser.js +45 -1
  45. package/dist/utils/cacheControlUtils.d.ts +5 -27
  46. package/dist/utils/cacheControlUtils.js +12 -73
  47. package/dist/utils/convertMessagesForAPI.js +51 -4
  48. package/dist/utils/messageOperations.d.ts +4 -2
  49. package/dist/utils/messageOperations.js +23 -7
  50. package/dist/utils/subagentParser.d.ts +5 -2
  51. package/dist/utils/subagentParser.js +14 -4
  52. package/package.json +2 -1
@@ -158,7 +158,7 @@ export const addToolBlockToMessageInMessages = (messages, messageId, params) =>
158
158
  return { messages: newMessages, toolBlockId };
159
159
  };
160
160
  // Update Tool Block of the last assistant or user message
161
- export const updateToolBlockInMessage = ({ messages, id, messageId, parameters, result, success, error, stage, name, shortResult, startLineNumber, images, compactParams, parametersChunk, isManuallyBackgrounded, }) => {
161
+ export const updateToolBlockInMessage = ({ messages, id, messageId, parameters, result, success, error, stage, name, shortResult, startLineNumber, images, compactParams, parametersChunk, backgroundTaskId, backgroundedByUser, assistantAutoBackgrounded, }) => {
162
162
  const newMessages = [...messages];
163
163
  // If messageId is provided, target that specific message
164
164
  if (messageId) {
@@ -170,6 +170,9 @@ export const updateToolBlockInMessage = ({ messages, id, messageId, parameters,
170
170
  if (toolBlock.type === "tool") {
171
171
  if (parameters !== undefined)
172
172
  toolBlock.parameters = parameters;
173
+ else if (parametersChunk !== undefined)
174
+ toolBlock.parameters =
175
+ (toolBlock.parameters || "") + parametersChunk;
173
176
  if (result !== undefined)
174
177
  toolBlock.result = result;
175
178
  if (shortResult !== undefined)
@@ -188,8 +191,12 @@ export const updateToolBlockInMessage = ({ messages, id, messageId, parameters,
188
191
  toolBlock.compactParams = compactParams;
189
192
  if (parametersChunk !== undefined)
190
193
  toolBlock.parametersChunk = parametersChunk;
191
- if (isManuallyBackgrounded !== undefined)
192
- toolBlock.isManuallyBackgrounded = isManuallyBackgrounded;
194
+ if (backgroundTaskId !== undefined)
195
+ toolBlock.backgroundTaskId = backgroundTaskId;
196
+ if (backgroundedByUser !== undefined)
197
+ toolBlock.backgroundedByUser = backgroundedByUser;
198
+ if (assistantAutoBackgrounded !== undefined)
199
+ toolBlock.assistantAutoBackgrounded = assistantAutoBackgrounded;
193
200
  }
194
201
  }
195
202
  }
@@ -204,6 +211,9 @@ export const updateToolBlockInMessage = ({ messages, id, messageId, parameters,
204
211
  if (toolBlock.type === "tool") {
205
212
  if (parameters !== undefined)
206
213
  toolBlock.parameters = parameters;
214
+ else if (parametersChunk !== undefined)
215
+ toolBlock.parameters =
216
+ (toolBlock.parameters || "") + parametersChunk;
207
217
  if (result !== undefined)
208
218
  toolBlock.result = result;
209
219
  if (shortResult !== undefined)
@@ -222,8 +232,12 @@ export const updateToolBlockInMessage = ({ messages, id, messageId, parameters,
222
232
  toolBlock.compactParams = compactParams;
223
233
  if (parametersChunk !== undefined)
224
234
  toolBlock.parametersChunk = parametersChunk;
225
- if (isManuallyBackgrounded !== undefined)
226
- toolBlock.isManuallyBackgrounded = isManuallyBackgrounded;
235
+ if (backgroundTaskId !== undefined)
236
+ toolBlock.backgroundTaskId = backgroundTaskId;
237
+ if (backgroundedByUser !== undefined)
238
+ toolBlock.backgroundedByUser = backgroundedByUser;
239
+ if (assistantAutoBackgrounded !== undefined)
240
+ toolBlock.assistantAutoBackgrounded = assistantAutoBackgrounded;
227
241
  }
228
242
  const foundMessageId = newMessages[i].id;
229
243
  return { messages: newMessages, messageId: foundMessageId };
@@ -233,7 +247,7 @@ export const updateToolBlockInMessage = ({ messages, id, messageId, parameters,
233
247
  // This handles cases where we're streaming tool parameters before execution
234
248
  newMessages[i].blocks.push({
235
249
  type: "tool",
236
- parameters: parameters,
250
+ parameters: parameters !== undefined ? parameters : (parametersChunk ?? ""),
237
251
  result: result || "",
238
252
  shortResult: shortResult,
239
253
  startLineNumber: startLineNumber,
@@ -245,7 +259,9 @@ export const updateToolBlockInMessage = ({ messages, id, messageId, parameters,
245
259
  stage: stage ?? "start",
246
260
  compactParams: compactParams,
247
261
  parametersChunk: parametersChunk,
248
- isManuallyBackgrounded: isManuallyBackgrounded,
262
+ backgroundTaskId: backgroundTaskId,
263
+ backgroundedByUser: backgroundedByUser,
264
+ assistantAutoBackgrounded: assistantAutoBackgrounded,
249
265
  });
250
266
  const foundMessageId = newMessages[i].id;
251
267
  return { messages: newMessages, messageId: foundMessageId };
@@ -17,9 +17,12 @@ export interface SubagentConfiguration {
17
17
  export declare function parseAgentFile(filePath: string, scope: "plugin", pluginRoot: string): SubagentConfiguration;
18
18
  /**
19
19
  * Load all subagent configurations from project and user directories, plus built-in subagents
20
+ * @param workdir - Working directory to scan for project-level subagents
21
+ * @param env - Merged environment (settings.json env over OS env). Defaults to process.env.
22
+ * Used for conditional registration of builtin subagents (e.g. WAVE_VISION_MODEL).
20
23
  */
21
- export declare function loadSubagentConfigurations(workdir: string): Promise<SubagentConfiguration[]>;
24
+ export declare function loadSubagentConfigurations(workdir: string, env?: Record<string, string>): Promise<SubagentConfiguration[]>;
22
25
  /**
23
26
  * Find subagent by exact name match
24
27
  */
25
- export declare function findSubagentByName(name: string, workdir: string): Promise<SubagentConfiguration | null>;
28
+ export declare function findSubagentByName(name: string, workdir: string, env?: Record<string, string>): Promise<SubagentConfiguration | null>;
@@ -158,15 +158,25 @@ function scanSubagentDirectory(dirPath, scope) {
158
158
  }
159
159
  /**
160
160
  * Load all subagent configurations from project and user directories, plus built-in subagents
161
+ * @param workdir - Working directory to scan for project-level subagents
162
+ * @param env - Merged environment (settings.json env over OS env). Defaults to process.env.
163
+ * Used for conditional registration of builtin subagents (e.g. WAVE_VISION_MODEL).
161
164
  */
162
- export async function loadSubagentConfigurations(workdir) {
165
+ export async function loadSubagentConfigurations(workdir, env = process.env) {
163
166
  const projectWaveDir = join(workdir, ".wave", "agents");
164
167
  const projectClaudeDir = join(workdir, ".claude", "agents");
165
168
  const userWaveDir = join(process.env.HOME || "~", ".wave", "agents");
166
169
  const userClaudeDir = join(process.env.HOME || "~", ".claude", "agents");
167
170
  const builtinDir = getBuiltinSubagentsDir();
168
171
  // Load configurations from all sources
169
- const builtinConfigs = scanSubagentDirectory(builtinDir, "builtin");
172
+ let builtinConfigs = scanSubagentDirectory(builtinDir, "builtin");
173
+ // Conditional registration: builtin subagents whose frontmatter requires the
174
+ // WAVE_VISION_MODEL env var (`model: visionModel`) are only loaded when it is
175
+ // set — otherwise the main model would delegate image recognition to a
176
+ // subagent that resolves to a non-vision model.
177
+ if (!env.WAVE_VISION_MODEL) {
178
+ builtinConfigs = builtinConfigs.filter((config) => config.model !== "visionModel");
179
+ }
170
180
  const userClaudeConfigs = scanSubagentDirectory(userClaudeDir, "user");
171
181
  const userWaveConfigs = scanSubagentDirectory(userWaveDir, "user");
172
182
  const projectClaudeConfigs = scanSubagentDirectory(projectClaudeDir, "project");
@@ -193,7 +203,7 @@ export async function loadSubagentConfigurations(workdir) {
193
203
  /**
194
204
  * Find subagent by exact name match
195
205
  */
196
- export async function findSubagentByName(name, workdir) {
197
- const configurations = await loadSubagentConfigurations(workdir);
206
+ export async function findSubagentByName(name, workdir, env) {
207
+ const configurations = await loadSubagentConfigurations(workdir, env);
198
208
  return configurations.find((config) => config.name === name) || null;
199
209
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wave-agent-sdk",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "SDK for building AI-powered development tools and agents",
5
5
  "keywords": [
6
6
  "ai",
@@ -55,6 +55,7 @@
55
55
  "fuzzysort": "^3.1.0",
56
56
  "glob": "^13.0.0",
57
57
  "lru-cache": "^11.3.5",
58
+ "marked": "^17.0.2",
58
59
  "minimatch": "^10.0.3",
59
60
  "openai": "^5.12.2",
60
61
  "turndown": "^7.2.2"