wave-agent-sdk 1.0.7 → 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.
- package/builtin/skills/settings/ENV.md +1 -0
- package/builtin/skills/settings/MODELS.md +3 -0
- package/builtin/subagents/vision.md +18 -0
- package/dist/constants/tools.d.ts +1 -0
- package/dist/constants/tools.js +1 -0
- package/dist/managers/aiManager.js +46 -4
- package/dist/managers/messageManager.js +8 -2
- package/dist/managers/permissionManager.d.ts +5 -0
- package/dist/managers/permissionManager.js +18 -2
- package/dist/managers/pluginManager.d.ts +9 -0
- package/dist/managers/pluginManager.js +20 -0
- package/dist/managers/subagentManager.d.ts +12 -0
- package/dist/managers/subagentManager.js +32 -2
- package/dist/managers/toolManager.js +7 -0
- package/dist/services/aiService.d.ts +1 -1
- package/dist/services/aiService.js +3 -2
- package/dist/services/artifactAvailability.d.ts +7 -0
- package/dist/services/artifactAvailability.js +26 -0
- package/dist/services/artifactSession.d.ts +27 -0
- package/dist/services/artifactSession.js +52 -0
- package/dist/services/configurationService.d.ts +2 -1
- package/dist/services/configurationService.js +16 -1
- package/dist/services/initializationService.js +5 -0
- package/dist/tools/agentTool.js +2 -1
- package/dist/tools/artifactTool.d.ts +2 -0
- package/dist/tools/artifactTool.js +357 -0
- package/dist/tools/bashTool.js +11 -11
- package/dist/tools/types.d.ts +3 -1
- package/dist/tools/webFetchTool.js +141 -0
- package/dist/types/agent.d.ts +2 -0
- package/dist/types/config.d.ts +2 -0
- package/dist/types/configuration.d.ts +2 -0
- package/dist/types/messaging.d.ts +3 -1
- package/dist/types/permissions.d.ts +3 -1
- package/dist/types/permissions.js +2 -1
- package/dist/utils/bashParser.d.ts +14 -0
- package/dist/utils/bashParser.js +45 -1
- package/dist/utils/convertMessagesForAPI.js +51 -4
- package/dist/utils/messageOperations.d.ts +4 -2
- package/dist/utils/messageOperations.js +23 -7
- package/dist/utils/subagentParser.d.ts +5 -2
- package/dist/utils/subagentParser.js +14 -4
- package/package.json +2 -1
|
@@ -27,6 +27,7 @@ Wave uses several environment variables to control its core functionality. Varia
|
|
|
27
27
|
| `WAVE_CUSTOM_HEADERS` | Custom HTTP headers for the AI gateway. Newline-separated `Key: Value` pairs (e.g., `"X-Foo: bar\nAuthorization: Bearer xxx"`). | - |
|
|
28
28
|
| `WAVE_MODEL` | The primary AI model to use for the agent. | `gemini-3-flash` |
|
|
29
29
|
| `WAVE_FAST_MODEL` | The fast AI model to use for quick tasks. | `gemini-2.5-flash` |
|
|
30
|
+
| `WAVE_VISION_MODEL` | Vision-capable model used by the built-in `vision` subagent for image recognition. When set, the built-in `vision` subagent is registered (its frontmatter `model: visionModel` resolves to this value); when unset, the subagent is not loaded. Useful when the main model is fast but non-vision (e.g. DeepSeek). | - (not registered) |
|
|
30
31
|
| `WAVE_MAX_INPUT_TOKENS` | Maximum number of input tokens allowed. | `200000` |
|
|
31
32
|
| `WAVE_MAX_OUTPUT_TOKENS` | Maximum number of output tokens allowed. | `32000` |
|
|
32
33
|
| `WAVE_DISABLE_AUTO_MEMORY` | Set to `1` or `true` to disable the auto-memory feature. | `false` |
|
|
@@ -105,12 +105,15 @@ You can also set the default models Wave uses via environment variables in `sett
|
|
|
105
105
|
"env": {
|
|
106
106
|
"WAVE_MODEL": "gemini-3-flash",
|
|
107
107
|
"WAVE_FAST_MODEL": "gemini-2.5-flash",
|
|
108
|
+
"WAVE_VISION_MODEL": "qwen-vl-max",
|
|
108
109
|
"WAVE_MAX_INPUT_TOKENS": "100000",
|
|
109
110
|
"WAVE_MAX_OUTPUT_TOKENS": "4096"
|
|
110
111
|
}
|
|
111
112
|
}
|
|
112
113
|
```
|
|
113
114
|
|
|
115
|
+
`WAVE_VISION_MODEL` names a vision-capable model for the built-in `vision` subagent. Setting it registers the subagent, whose frontmatter `model: visionModel` resolves to this value — so a fast non-vision main model can delegate image recognition. Leave it unset to disable the built-in `vision` subagent.
|
|
116
|
+
|
|
114
117
|
## Live Reload
|
|
115
118
|
|
|
116
119
|
Model configurations support **live reload**. When you modify the `models` field or model-related environment variables in `settings.json`, the changes take effect immediately without restarting Wave.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: vision
|
|
3
|
+
description: 'Image recognition specialist that runs on the model specified by the WAVE_VISION_MODEL environment variable. Use this when the current model does not support image recognition but the user has shared an image (identify the image by its "[Image source: <path>]" metadata). Pass the image file path(s) in the prompt; this agent reads the image with the Read tool and returns a detailed text description of its contents.'
|
|
4
|
+
tools: [Read]
|
|
5
|
+
model: visionModel
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
You are an image recognition specialist. You run on a vision-capable model and your job is to look at image files and return detailed text descriptions of their contents.
|
|
9
|
+
|
|
10
|
+
When given image file path(s):
|
|
11
|
+
- Use the Read tool on each image path to load it. The Read tool returns the image as base64 image data that you can see directly.
|
|
12
|
+
- Describe the image contents in detail: what is shown, any visible text (transcribe verbatim where relevant), layout, colors, objects, and anything else the caller asked about.
|
|
13
|
+
- If an image cannot be read (file missing, not an image, or too large), report the error clearly and state which path failed.
|
|
14
|
+
- Do not invent or guess content you cannot see — only describe what the image actually shows.
|
|
15
|
+
- Return your description directly as a text message. Do NOT create files.
|
|
16
|
+
- Avoid using emojis in your response.
|
|
17
|
+
|
|
18
|
+
Complete the image recognition task and report your findings clearly.
|
|
@@ -22,3 +22,4 @@ export declare const WEB_FETCH_TOOL_NAME = "WebFetch";
|
|
|
22
22
|
export declare const ENTER_WORKTREE_TOOL_NAME = "EnterWorktree";
|
|
23
23
|
export declare const EXIT_WORKTREE_TOOL_NAME = "ExitWorktree";
|
|
24
24
|
export declare const WORKFLOW_TOOL_NAME = "Workflow";
|
|
25
|
+
export declare const ARTIFACT_TOOL_NAME = "Artifact";
|
package/dist/constants/tools.js
CHANGED
|
@@ -20,6 +20,14 @@ import { logOTelEvent } from "../telemetry/events.js";
|
|
|
20
20
|
const MAX_FORK_TURNS = 3;
|
|
21
21
|
/** Max turns for the auto-memory extraction fork. */
|
|
22
22
|
const MAX_AUTO_MEMORY_FORK_TURNS = 5;
|
|
23
|
+
/**
|
|
24
|
+
* Max consecutive auto-resumes after `finish_reason === "length"` when the
|
|
25
|
+
* truncated turn produced NO tool calls (aligned with Claude Code's
|
|
26
|
+
* MAX_OUTPUT_TOKENS_RECOVERY_LIMIT). A tool call resets the counter — it is
|
|
27
|
+
* real progress. Exhausting the limit terminates the turn with an error
|
|
28
|
+
* instead of re-planning forever.
|
|
29
|
+
*/
|
|
30
|
+
const MAX_OUTPUT_TOKENS_RECOVERY_LIMIT = 3;
|
|
23
31
|
// Truncate text to `max` chars and append a "… [+N chars]" marker when exceeded.
|
|
24
32
|
// Used for background_tasks description/command fields (≤1000 chars per spec FR-063).
|
|
25
33
|
function truncateWithMarker(text, max) {
|
|
@@ -138,6 +146,9 @@ export class AIManager {
|
|
|
138
146
|
if (this.modelOverride === "fastModel") {
|
|
139
147
|
modelToUse = parentModelConfig.fastModel;
|
|
140
148
|
}
|
|
149
|
+
else if (this.modelOverride === "visionModel") {
|
|
150
|
+
modelToUse = parentModelConfig.visionModel;
|
|
151
|
+
}
|
|
141
152
|
else if (this.modelOverride !== "inherit") {
|
|
142
153
|
modelToUse = this.modelOverride;
|
|
143
154
|
}
|
|
@@ -1217,6 +1228,10 @@ ${question}`;
|
|
|
1217
1228
|
toolAbortController = this.toolAbortController;
|
|
1218
1229
|
}
|
|
1219
1230
|
let turnDepth = turnOffset;
|
|
1231
|
+
// Consecutive truncation recoveries within this turn (no tool calls
|
|
1232
|
+
// in between). Reset to 0 on tool calls / at each sendAIMessage entry,
|
|
1233
|
+
// matching Claude Code's maxOutputTokensRecoveryCount semantics.
|
|
1234
|
+
let maxOutputTokensRecoveryCount = 0;
|
|
1220
1235
|
inner: while (true) {
|
|
1221
1236
|
let llmSpan;
|
|
1222
1237
|
try {
|
|
@@ -1300,10 +1315,15 @@ ${question}`;
|
|
|
1300
1315
|
// Use parametersChunk as compact param for better performance
|
|
1301
1316
|
// No need to extract params or generate compact params during streaming
|
|
1302
1317
|
// Update tool block with streaming parameters using parametersChunk as compact param
|
|
1318
|
+
// `parameters` is only present on start/running/end (authoritative); streaming
|
|
1319
|
+
// carries only `parametersChunk`, so don't forward `parameters: undefined`
|
|
1320
|
+
// (it would overwrite the accumulated block params in consumers)
|
|
1303
1321
|
this.messageManager.updateToolBlock({
|
|
1304
1322
|
id: toolCall.id,
|
|
1305
1323
|
name: toolCall.name,
|
|
1306
|
-
|
|
1324
|
+
...(toolCall.parameters !== undefined
|
|
1325
|
+
? { parameters: toolCall.parameters }
|
|
1326
|
+
: {}),
|
|
1307
1327
|
parametersChunk: toolCall.parametersChunk,
|
|
1308
1328
|
stage: toolCall.stage || "streaming", // Default to streaming if stage not provided
|
|
1309
1329
|
});
|
|
@@ -1462,13 +1482,34 @@ ${question}`;
|
|
|
1462
1482
|
const lastMessage = this.messageManager.getMessages()[this.messageManager.getMessages().length - 1];
|
|
1463
1483
|
const toolBlocks = lastMessage?.blocks.filter((block) => block.type === "tool") || [];
|
|
1464
1484
|
const hasBackgrounded = toolBlocks.length > 0 &&
|
|
1465
|
-
toolBlocks.some((block) => block.
|
|
1485
|
+
toolBlocks.some((block) => block.backgroundedByUser);
|
|
1466
1486
|
if (hasBackgrounded) {
|
|
1467
1487
|
logger?.info("Some tools were manually backgrounded, stopping.");
|
|
1468
1488
|
}
|
|
1469
1489
|
else if (!isCurrentlyAborted) {
|
|
1490
|
+
// If the response was truncated WITHOUT any tool calls,
|
|
1491
|
+
// enforce the consecutive recovery limit (aligned with Claude
|
|
1492
|
+
// Code's MAX_OUTPUT_TOKENS_RECOVERY_LIMIT = 3). Re-planning
|
|
1493
|
+
// loops that never produce output would otherwise continue
|
|
1494
|
+
// until the platform kills the task.
|
|
1495
|
+
if (result.finish_reason === "length" &&
|
|
1496
|
+
toolCalls.length === 0 &&
|
|
1497
|
+
maxOutputTokensRecoveryCount >=
|
|
1498
|
+
MAX_OUTPUT_TOKENS_RECOVERY_LIMIT) {
|
|
1499
|
+
this.messageManager.addErrorBlock(`Response exceeded the output token limit ${MAX_OUTPUT_TOKENS_RECOVERY_LIMIT + 1} consecutive times without producing output or tool calls. Stopped to avoid an infinite loop. Break the remaining work into smaller pieces and try again.`);
|
|
1500
|
+
break inner;
|
|
1501
|
+
}
|
|
1470
1502
|
// If response was truncated, add a hidden continuation message
|
|
1471
1503
|
if (result.finish_reason === "length") {
|
|
1504
|
+
if (toolCalls.length === 0) {
|
|
1505
|
+
// Pure truncation — count toward the recovery limit.
|
|
1506
|
+
maxOutputTokensRecoveryCount++;
|
|
1507
|
+
}
|
|
1508
|
+
else {
|
|
1509
|
+
// Truncated with tool calls — real progress, reset the
|
|
1510
|
+
// consecutive counter.
|
|
1511
|
+
maxOutputTokensRecoveryCount = 0;
|
|
1512
|
+
}
|
|
1472
1513
|
this.messageManager.addUserMessage({
|
|
1473
1514
|
content: "Output token limit hit. Resume directly — no apology, no recap of what you were doing. Pick up mid-thought if that is where the cut happened. Break remaining work into smaller pieces.",
|
|
1474
1515
|
isMeta: true,
|
|
@@ -1881,7 +1922,9 @@ ${question}`;
|
|
|
1881
1922
|
name: toolName,
|
|
1882
1923
|
compactParams,
|
|
1883
1924
|
shortResult: toolResult.shortResult,
|
|
1884
|
-
|
|
1925
|
+
backgroundTaskId: toolResult.backgroundTaskId,
|
|
1926
|
+
backgroundedByUser: toolResult.backgroundedByUser,
|
|
1927
|
+
assistantAutoBackgrounded: toolResult.assistantAutoBackgrounded,
|
|
1885
1928
|
startLineNumber: toolResult.startLineNumber,
|
|
1886
1929
|
images: toolResult.images,
|
|
1887
1930
|
timestamp: Date.now(),
|
|
@@ -1900,7 +1943,6 @@ ${question}`;
|
|
|
1900
1943
|
stage: "end",
|
|
1901
1944
|
name: toolName,
|
|
1902
1945
|
compactParams,
|
|
1903
|
-
isManuallyBackgrounded: false,
|
|
1904
1946
|
timestamp: Date.now(),
|
|
1905
1947
|
});
|
|
1906
1948
|
}
|
|
@@ -686,7 +686,9 @@ export class MessageManager {
|
|
|
686
686
|
stage: "end",
|
|
687
687
|
success: false,
|
|
688
688
|
error: errorMessage,
|
|
689
|
-
|
|
689
|
+
backgroundTaskId: block.backgroundTaskId,
|
|
690
|
+
backgroundedByUser: block.backgroundedByUser,
|
|
691
|
+
assistantAutoBackgrounded: block.assistantAutoBackgrounded,
|
|
690
692
|
timestamp,
|
|
691
693
|
});
|
|
692
694
|
}
|
|
@@ -730,7 +732,11 @@ export class MessageManager {
|
|
|
730
732
|
// only sees messages from the latest compact summary forward — matching
|
|
731
733
|
// the compact and resume behaviors (which also fold memory).
|
|
732
734
|
this.setMessages(sliceFromLastCompact(newMessages));
|
|
733
|
-
|
|
735
|
+
// savedMessageCount tracks in-memory progress, so it must be the folded
|
|
736
|
+
// length. Using the full disk count here would make saveSession's
|
|
737
|
+
// slice(savedMessageCount) empty after a rewind past a compact boundary
|
|
738
|
+
// and silently drop every subsequent message from the session file.
|
|
739
|
+
this.savedMessageCount = this.messages.length;
|
|
734
740
|
}
|
|
735
741
|
/**
|
|
736
742
|
* Rewrite the session file with the current messages.
|
|
@@ -82,6 +82,11 @@ export declare class PermissionManager {
|
|
|
82
82
|
* Get all instance-specific denied rules
|
|
83
83
|
*/
|
|
84
84
|
getInstanceDeniedRules(): string[];
|
|
85
|
+
/**
|
|
86
|
+
* Add an instance-level allowed rule (session-level, in-memory only).
|
|
87
|
+
* Unlike addPermissionRule, this does NOT persist to settings.local.json.
|
|
88
|
+
*/
|
|
89
|
+
addInstanceAllowedRule(rule: string): void;
|
|
85
90
|
/**
|
|
86
91
|
* Get all additional directories
|
|
87
92
|
*/
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import path from "node:path";
|
|
9
9
|
import { minimatch } from "minimatch";
|
|
10
10
|
import { RESTRICTED_TOOLS } from "../types/permissions.js";
|
|
11
|
-
import { splitBashCommand, stripEnvVars, stripRedirections, hasWriteRedirections, getSmartPrefix, isDangerousFind, hasCommandSubstitution, hasProcessSubstitution, hasSedInPlace, DANGEROUS_COMMANDS, READ_ONLY_COMMANDS, } from "../utils/bashParser.js";
|
|
11
|
+
import { splitBashCommand, stripEnvVars, stripRedirections, hasWriteRedirections, getSmartPrefix, isDangerousFind, hasCommandSubstitution, hasProcessSubstitution, hasSedInPlace, stripGitScopePrefix, DANGEROUS_COMMANDS, READ_ONLY_COMMANDS, } from "../utils/bashParser.js";
|
|
12
12
|
import { isPathInside } from "../utils/pathSafety.js";
|
|
13
13
|
import { BASH_TOOL_NAME, EDIT_TOOL_NAME, WRITE_TOOL_NAME, READ_TOOL_NAME, ASK_USER_QUESTION_TOOL_NAME, } from "../constants/tools.js";
|
|
14
14
|
const DEFAULT_ALLOWED_RULES = [
|
|
@@ -140,6 +140,15 @@ export class PermissionManager {
|
|
|
140
140
|
getInstanceDeniedRules() {
|
|
141
141
|
return [...this.instanceDeniedRules];
|
|
142
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Add an instance-level allowed rule (session-level, in-memory only).
|
|
145
|
+
* Unlike addPermissionRule, this does NOT persist to settings.local.json.
|
|
146
|
+
*/
|
|
147
|
+
addInstanceAllowedRule(rule) {
|
|
148
|
+
if (!this.instanceAllowedRules.includes(rule)) {
|
|
149
|
+
this.instanceAllowedRules.push(rule);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
143
152
|
/**
|
|
144
153
|
* Get all additional directories
|
|
145
154
|
*/
|
|
@@ -676,7 +685,14 @@ export class PermissionManager {
|
|
|
676
685
|
.replace(/\*/g, ".*"); // Replace * with .*
|
|
677
686
|
const regex = new RegExp(`^${regexPattern}$`, "s");
|
|
678
687
|
const matched = regex.test(processedPart);
|
|
679
|
-
|
|
688
|
+
if (matched)
|
|
689
|
+
return true;
|
|
690
|
+
// Leading git global scope flags (e.g. `git -C <path>`) only change the
|
|
691
|
+
// target repository, not the subcommand being run, so rules like
|
|
692
|
+
// Bash(git status*) also cover `git -C <path> status`. The raw command
|
|
693
|
+
// is checked first so path-specific rules (e.g. deny rules on
|
|
694
|
+
// `git -C /secret status`) still match.
|
|
695
|
+
return regex.test(stripGitScopePrefix(processedPart));
|
|
680
696
|
}
|
|
681
697
|
// Handle path-based rules (e.g., "Read(**/*.env)")
|
|
682
698
|
const pathTools = [READ_TOOL_NAME, WRITE_TOOL_NAME, EDIT_TOOL_NAME];
|
|
@@ -6,10 +6,19 @@ export interface PluginManagerOptions {
|
|
|
6
6
|
}
|
|
7
7
|
export declare class PluginManager {
|
|
8
8
|
private container;
|
|
9
|
+
/**
|
|
10
|
+
* Read-only helper scripts shipped by builtin plugins that the agent runs via
|
|
11
|
+
* Bash. When such a plugin is enabled, its rules are registered as instance
|
|
12
|
+
* level allow rules (in-memory only, never persisted) so the scripts run
|
|
13
|
+
* without a permission prompt. Wildcards keep the rules valid across install
|
|
14
|
+
* locations; each rule anchors on the script filename.
|
|
15
|
+
*/
|
|
16
|
+
private static readonly BUILTIN_PLUGIN_ALLOW_RULES;
|
|
9
17
|
private plugins;
|
|
10
18
|
private workdir;
|
|
11
19
|
private enabledPlugins;
|
|
12
20
|
constructor(container: Container, options: PluginManagerOptions);
|
|
21
|
+
private get permissionManager();
|
|
13
22
|
private get skillManager();
|
|
14
23
|
private get hookManager();
|
|
15
24
|
private get lspManager();
|
|
@@ -11,6 +11,9 @@ export class PluginManager {
|
|
|
11
11
|
this.workdir = options.workdir;
|
|
12
12
|
this.enabledPlugins = options.enabledPlugins || {};
|
|
13
13
|
}
|
|
14
|
+
get permissionManager() {
|
|
15
|
+
return this.container.get("PermissionManager");
|
|
16
|
+
}
|
|
14
17
|
get skillManager() {
|
|
15
18
|
return this.container.get("SkillManager");
|
|
16
19
|
}
|
|
@@ -221,6 +224,13 @@ export class PluginManager {
|
|
|
221
224
|
if (this.enabledPlugins[`${entry.name}@builtin`] !== true)
|
|
222
225
|
continue;
|
|
223
226
|
await this.loadSinglePlugin(path.join(builtinDir, entry.name));
|
|
227
|
+
// Register allow rules only after the plugin actually loaded, so a
|
|
228
|
+
// failed load never leaves permission grants behind.
|
|
229
|
+
if (this.plugins.has(entry.name)) {
|
|
230
|
+
for (const rule of PluginManager.BUILTIN_PLUGIN_ALLOW_RULES[entry.name] || []) {
|
|
231
|
+
this.permissionManager?.addInstanceAllowedRule(rule);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
224
234
|
}
|
|
225
235
|
}
|
|
226
236
|
catch (error) {
|
|
@@ -240,3 +250,13 @@ export class PluginManager {
|
|
|
240
250
|
return this.plugins.get(name);
|
|
241
251
|
}
|
|
242
252
|
}
|
|
253
|
+
/**
|
|
254
|
+
* Read-only helper scripts shipped by builtin plugins that the agent runs via
|
|
255
|
+
* Bash. When such a plugin is enabled, its rules are registered as instance
|
|
256
|
+
* level allow rules (in-memory only, never persisted) so the scripts run
|
|
257
|
+
* without a permission prompt. Wildcards keep the rules valid across install
|
|
258
|
+
* locations; each rule anchors on the script filename.
|
|
259
|
+
*/
|
|
260
|
+
PluginManager.BUILTIN_PLUGIN_ALLOW_RULES = {
|
|
261
|
+
sdd: ["Bash(node *spec-count.js*)"],
|
|
262
|
+
};
|
|
@@ -87,6 +87,18 @@ export declare class SubagentManager {
|
|
|
87
87
|
* Load all available subagent configurations and cache them
|
|
88
88
|
*/
|
|
89
89
|
loadConfigurations(): Promise<SubagentConfiguration[]>;
|
|
90
|
+
/**
|
|
91
|
+
* Rebuild the cached subagent configurations. Called after settings.json
|
|
92
|
+
* env becomes available (post loadMergedConfiguration) so conditional
|
|
93
|
+
* builtin subagents (e.g. `model: visionModel` requiring WAVE_VISION_MODEL)
|
|
94
|
+
* register correctly. Plugin agents are preserved across the rebuild.
|
|
95
|
+
*/
|
|
96
|
+
refreshConfigurations(): Promise<SubagentConfiguration[]>;
|
|
97
|
+
/**
|
|
98
|
+
* Get the merged environment (OS env overlaid with settings.json env) used
|
|
99
|
+
* for conditional subagent registration (e.g. WAVE_VISION_MODEL).
|
|
100
|
+
*/
|
|
101
|
+
private getMergedEnv;
|
|
90
102
|
/**
|
|
91
103
|
* Get cached configurations synchronously (must call loadConfigurations first)
|
|
92
104
|
*/
|
|
@@ -70,10 +70,40 @@ export class SubagentManager {
|
|
|
70
70
|
async loadConfigurations() {
|
|
71
71
|
if (this.cachedConfigurations === null) {
|
|
72
72
|
const { loadSubagentConfigurations } = await import("../utils/subagentParser.js");
|
|
73
|
-
this.cachedConfigurations = await loadSubagentConfigurations(this.workdir);
|
|
73
|
+
this.cachedConfigurations = await loadSubagentConfigurations(this.workdir, this.getMergedEnv());
|
|
74
74
|
}
|
|
75
75
|
return this.cachedConfigurations;
|
|
76
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Rebuild the cached subagent configurations. Called after settings.json
|
|
79
|
+
* env becomes available (post loadMergedConfiguration) so conditional
|
|
80
|
+
* builtin subagents (e.g. `model: visionModel` requiring WAVE_VISION_MODEL)
|
|
81
|
+
* register correctly. Plugin agents are preserved across the rebuild.
|
|
82
|
+
*/
|
|
83
|
+
async refreshConfigurations() {
|
|
84
|
+
// Preserve plugin agents (namespaced `pluginName:agentName`) across the rebuild
|
|
85
|
+
const pluginAgents = (this.cachedConfigurations ?? []).filter((config) => config.name.includes(":"));
|
|
86
|
+
this.cachedConfigurations = null;
|
|
87
|
+
await this.loadConfigurations();
|
|
88
|
+
for (const agent of pluginAgents) {
|
|
89
|
+
this.cachedConfigurations.push(agent);
|
|
90
|
+
}
|
|
91
|
+
// Re-sort by priority then name (matches registerPluginAgents)
|
|
92
|
+
this.cachedConfigurations.sort((a, b) => {
|
|
93
|
+
if (a.priority !== b.priority)
|
|
94
|
+
return a.priority - b.priority;
|
|
95
|
+
return a.name.localeCompare(b.name);
|
|
96
|
+
});
|
|
97
|
+
return this.cachedConfigurations;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Get the merged environment (OS env overlaid with settings.json env) used
|
|
101
|
+
* for conditional subagent registration (e.g. WAVE_VISION_MODEL).
|
|
102
|
+
*/
|
|
103
|
+
getMergedEnv() {
|
|
104
|
+
return (this.configurationService?.getMergedEnv?.() ??
|
|
105
|
+
process.env);
|
|
106
|
+
}
|
|
77
107
|
/**
|
|
78
108
|
* Get cached configurations synchronously (must call loadConfigurations first)
|
|
79
109
|
*/
|
|
@@ -95,7 +125,7 @@ export class SubagentManager {
|
|
|
95
125
|
}
|
|
96
126
|
// Fall back to filesystem scan for non-plugin agents
|
|
97
127
|
const { findSubagentByName } = await import("../utils/subagentParser.js");
|
|
98
|
-
return findSubagentByName(name, this.workdir);
|
|
128
|
+
return findSubagentByName(name, this.workdir, this.getMergedEnv());
|
|
99
129
|
}
|
|
100
130
|
/**
|
|
101
131
|
* Register plugin agents into the cached configurations.
|
|
@@ -9,6 +9,8 @@ import { cronCreateTool } from "../tools/cronCreateTool.js";
|
|
|
9
9
|
import { cronDeleteTool } from "../tools/cronDeleteTool.js";
|
|
10
10
|
import { cronListTool } from "../tools/cronListTool.js";
|
|
11
11
|
import { webFetchTool } from "../tools/webFetchTool.js";
|
|
12
|
+
import { artifactTool } from "../tools/artifactTool.js";
|
|
13
|
+
import { isArtifactEnabled } from "../services/artifactAvailability.js";
|
|
12
14
|
// New tools
|
|
13
15
|
import { globTool } from "../tools/globTool.js";
|
|
14
16
|
import { grepTool } from "../tools/grepTool.js";
|
|
@@ -95,6 +97,11 @@ class ToolManager {
|
|
|
95
97
|
exitWorktreeTool,
|
|
96
98
|
workflowTool,
|
|
97
99
|
];
|
|
100
|
+
// Artifact is a feature-gated tool: not registered at all while the frame
|
|
101
|
+
// backend is not live, unless settings.json opts in via enableArtifact: true.
|
|
102
|
+
if (isArtifactEnabled(this.container.get("Workdir"))) {
|
|
103
|
+
builtInTools.push(artifactTool);
|
|
104
|
+
}
|
|
98
105
|
for (const tool of builtInTools) {
|
|
99
106
|
if (this.shouldEnableTool(tool.name)) {
|
|
100
107
|
this.toolsRegistry.set(tool.name, tool);
|
|
@@ -425,7 +425,9 @@ async function processStreamingResponse(stream, onContentUpdate, onToolUpdate, o
|
|
|
425
425
|
if (functionDelta.arguments) {
|
|
426
426
|
existingCall.function.arguments += functionDelta.arguments;
|
|
427
427
|
}
|
|
428
|
-
// Emit streaming updates for all chunks with actual content (including first chunk)
|
|
428
|
+
// Emit streaming updates for all chunks with actual content (including first chunk).
|
|
429
|
+
// Streaming carries only the delta `parametersChunk` — consumers accumulate it;
|
|
430
|
+
// authoritative `parameters` arrives at `start` (empty) / `running` / `end`.
|
|
429
431
|
if (onToolUpdate &&
|
|
430
432
|
existingCall.function.name &&
|
|
431
433
|
functionDelta.arguments &&
|
|
@@ -434,7 +436,6 @@ async function processStreamingResponse(stream, onContentUpdate, onToolUpdate, o
|
|
|
434
436
|
onToolUpdate({
|
|
435
437
|
id: existingCall.id,
|
|
436
438
|
name: existingCall.function.name,
|
|
437
|
-
parameters: existingCall.function.arguments,
|
|
438
439
|
parametersChunk: functionDelta.arguments,
|
|
439
440
|
stage: "streaming",
|
|
440
441
|
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Code default for Artifact availability. Flip to true after the frame backend goes live. */
|
|
2
|
+
export declare const ARTIFACT_DEFAULT_ENABLED = false;
|
|
3
|
+
/**
|
|
4
|
+
* Whether the Artifact tool should be registered / usable for the given workdir.
|
|
5
|
+
* Explicit `enableArtifact` in merged settings wins over the code default.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isArtifactEnabled(workdir?: string): boolean;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Artifact feature availability.
|
|
3
|
+
*
|
|
4
|
+
* The frame backend (`POST /api/frame/deploy/direct`) is not live yet, so the
|
|
5
|
+
* code default is DISABLED. Internal beta / gradual rollout enables the feature
|
|
6
|
+
* via settings.json `enableArtifact: true` without code changes. Once the
|
|
7
|
+
* backend goes live, flip `ARTIFACT_DEFAULT_ENABLED` to `true` so an unset
|
|
8
|
+
* `enableArtifact` defaults to enabled (matching Claude Code's `enableArtifact`
|
|
9
|
+
* "unset follows feature availability" semantics).
|
|
10
|
+
*/
|
|
11
|
+
import { loadMergedWaveConfig } from "./configurationService.js";
|
|
12
|
+
/** Code default for Artifact availability. Flip to true after the frame backend goes live. */
|
|
13
|
+
export const ARTIFACT_DEFAULT_ENABLED = false;
|
|
14
|
+
/**
|
|
15
|
+
* Whether the Artifact tool should be registered / usable for the given workdir.
|
|
16
|
+
* Explicit `enableArtifact` in merged settings wins over the code default.
|
|
17
|
+
*/
|
|
18
|
+
export function isArtifactEnabled(workdir) {
|
|
19
|
+
if (workdir) {
|
|
20
|
+
const config = loadMergedWaveConfig(workdir);
|
|
21
|
+
if (config?.enableArtifact !== undefined) {
|
|
22
|
+
return config.enableArtifact;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return ARTIFACT_DEFAULT_ENABLED;
|
|
26
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session-scoped state shared between the Artifact tool and the WebFetch tool.
|
|
3
|
+
*
|
|
4
|
+
* - file_path → artifact record: lets a model republish a file it already
|
|
5
|
+
* published this session without passing `url` again, and enables the
|
|
6
|
+
* same-session auto-allow (the publish was already confirmed once).
|
|
7
|
+
* - slug → latest known version: powers the stale-version guard
|
|
8
|
+
* (local knowledge older than the live version blocks a redeploy
|
|
9
|
+
* unless `force` is set) and lets WebFetch record versions it observed.
|
|
10
|
+
*
|
|
11
|
+
* State is keyed by sessionId so parallel sessions never observe each other.
|
|
12
|
+
*/
|
|
13
|
+
export interface ArtifactRecord {
|
|
14
|
+
url: string;
|
|
15
|
+
slug: string;
|
|
16
|
+
version: string;
|
|
17
|
+
}
|
|
18
|
+
/** Record a successful publish so same-session republishes auto-allow. */
|
|
19
|
+
export declare function recordArtifact(sessionId: string, filePath: string, record: ArtifactRecord): void;
|
|
20
|
+
/** Look up an artifact previously published in this session by file path. */
|
|
21
|
+
export declare function getArtifactByFilePath(sessionId: string, filePath: string): ArtifactRecord | undefined;
|
|
22
|
+
/** Latest version of a slug this session has observed (publish, conflict, or read). */
|
|
23
|
+
export declare function getRecordedVersion(sessionId: string, slug: string): string | undefined;
|
|
24
|
+
/** Record an observed version (from a publish, a 409 conflict, or a WebFetch read). */
|
|
25
|
+
export declare function recordVersion(sessionId: string, slug: string, version: string): void;
|
|
26
|
+
/** Clear all session-scoped artifact state (used when a session ends). */
|
|
27
|
+
export declare function clearArtifactSession(sessionId: string): void;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session-scoped state shared between the Artifact tool and the WebFetch tool.
|
|
3
|
+
*
|
|
4
|
+
* - file_path → artifact record: lets a model republish a file it already
|
|
5
|
+
* published this session without passing `url` again, and enables the
|
|
6
|
+
* same-session auto-allow (the publish was already confirmed once).
|
|
7
|
+
* - slug → latest known version: powers the stale-version guard
|
|
8
|
+
* (local knowledge older than the live version blocks a redeploy
|
|
9
|
+
* unless `force` is set) and lets WebFetch record versions it observed.
|
|
10
|
+
*
|
|
11
|
+
* State is keyed by sessionId so parallel sessions never observe each other.
|
|
12
|
+
*/
|
|
13
|
+
const sessionArtifacts = new Map();
|
|
14
|
+
const sessionSlugVersions = new Map();
|
|
15
|
+
function fileMapFor(sessionId) {
|
|
16
|
+
let map = sessionArtifacts.get(sessionId);
|
|
17
|
+
if (!map) {
|
|
18
|
+
map = new Map();
|
|
19
|
+
sessionArtifacts.set(sessionId, map);
|
|
20
|
+
}
|
|
21
|
+
return map;
|
|
22
|
+
}
|
|
23
|
+
function slugMapFor(sessionId) {
|
|
24
|
+
let map = sessionSlugVersions.get(sessionId);
|
|
25
|
+
if (!map) {
|
|
26
|
+
map = new Map();
|
|
27
|
+
sessionSlugVersions.set(sessionId, map);
|
|
28
|
+
}
|
|
29
|
+
return map;
|
|
30
|
+
}
|
|
31
|
+
/** Record a successful publish so same-session republishes auto-allow. */
|
|
32
|
+
export function recordArtifact(sessionId, filePath, record) {
|
|
33
|
+
fileMapFor(sessionId).set(filePath, record);
|
|
34
|
+
slugMapFor(sessionId).set(record.slug, record.version);
|
|
35
|
+
}
|
|
36
|
+
/** Look up an artifact previously published in this session by file path. */
|
|
37
|
+
export function getArtifactByFilePath(sessionId, filePath) {
|
|
38
|
+
return sessionArtifacts.get(sessionId)?.get(filePath);
|
|
39
|
+
}
|
|
40
|
+
/** Latest version of a slug this session has observed (publish, conflict, or read). */
|
|
41
|
+
export function getRecordedVersion(sessionId, slug) {
|
|
42
|
+
return sessionSlugVersions.get(sessionId)?.get(slug);
|
|
43
|
+
}
|
|
44
|
+
/** Record an observed version (from a publish, a 409 conflict, or a WebFetch read). */
|
|
45
|
+
export function recordVersion(sessionId, slug, version) {
|
|
46
|
+
slugMapFor(sessionId).set(slug, version);
|
|
47
|
+
}
|
|
48
|
+
/** Clear all session-scoped artifact state (used when a session ends). */
|
|
49
|
+
export function clearArtifactSession(sessionId) {
|
|
50
|
+
sessionArtifacts.delete(sessionId);
|
|
51
|
+
sessionSlugVersions.delete(sessionId);
|
|
52
|
+
}
|
|
@@ -81,9 +81,10 @@ export declare class ConfigurationService {
|
|
|
81
81
|
* @param fastModel - Fast model override (optional)
|
|
82
82
|
* @param maxTokens - Max output tokens override (optional)
|
|
83
83
|
* @param permissionMode - Permission mode override (optional)
|
|
84
|
+
* @param visionModel - Vision model override (optional)
|
|
84
85
|
* @returns Resolved model configuration with defaults
|
|
85
86
|
*/
|
|
86
|
-
resolveModelConfig(model?: string, fastModel?: string, maxTokens?: number, permissionMode?: PermissionMode): ModelConfig;
|
|
87
|
+
resolveModelConfig(model?: string, fastModel?: string, maxTokens?: number, permissionMode?: PermissionMode, visionModel?: string): ModelConfig;
|
|
87
88
|
/**
|
|
88
89
|
* Resolves token limit with fallbacks
|
|
89
90
|
* Resolution priority: override > options > env (from settings.json) > process.env > default
|
|
@@ -459,9 +459,10 @@ export class ConfigurationService {
|
|
|
459
459
|
* @param fastModel - Fast model override (optional)
|
|
460
460
|
* @param maxTokens - Max output tokens override (optional)
|
|
461
461
|
* @param permissionMode - Permission mode override (optional)
|
|
462
|
+
* @param visionModel - Vision model override (optional)
|
|
462
463
|
* @returns Resolved model configuration with defaults
|
|
463
464
|
*/
|
|
464
|
-
resolveModelConfig(model, fastModel, maxTokens, permissionMode) {
|
|
465
|
+
resolveModelConfig(model, fastModel, maxTokens, permissionMode, visionModel) {
|
|
465
466
|
// Resolve agent model: override > options > currentConfiguration (settings.json model, possibly remote-merged) > process.env
|
|
466
467
|
// Priority: user's explicit model field > admin's env.WAVE_MODEL default.
|
|
467
468
|
// If admin wants hard enforcement, they set the `model` scalar field (overwrites local in mergeRemoteSettings).
|
|
@@ -473,11 +474,16 @@ export class ConfigurationService {
|
|
|
473
474
|
const resolvedFastModel = fastModel ||
|
|
474
475
|
this.options.fastModel ||
|
|
475
476
|
(this.envSnapshot.WAVE_FAST_MODEL ?? process.env.WAVE_FAST_MODEL);
|
|
477
|
+
// Resolve vision model: override > options > process.env (includes settings.json env)
|
|
478
|
+
const resolvedVisionModel = visionModel ||
|
|
479
|
+
this.options.visionModel ||
|
|
480
|
+
(this.envSnapshot.WAVE_VISION_MODEL ?? process.env.WAVE_VISION_MODEL);
|
|
476
481
|
// Resolve max output tokens
|
|
477
482
|
const resolvedMaxTokens = this.resolveMaxOutputTokens(maxTokens);
|
|
478
483
|
const baseConfig = {
|
|
479
484
|
model: resolvedAgentModel,
|
|
480
485
|
fastModel: resolvedFastModel,
|
|
486
|
+
visionModel: resolvedVisionModel,
|
|
481
487
|
maxTokens: resolvedMaxTokens,
|
|
482
488
|
permissionMode: permissionMode ?? this.options.permissionMode,
|
|
483
489
|
};
|
|
@@ -1062,9 +1068,13 @@ export function loadWaveConfigFromFile(filePath) {
|
|
|
1062
1068
|
autoMemoryEnabled: config.autoMemoryEnabled !== undefined
|
|
1063
1069
|
? config.autoMemoryEnabled
|
|
1064
1070
|
: undefined,
|
|
1071
|
+
autoMemoryFrequency: config.autoMemoryFrequency !== undefined
|
|
1072
|
+
? config.autoMemoryFrequency
|
|
1073
|
+
: undefined,
|
|
1065
1074
|
models: config.models || undefined,
|
|
1066
1075
|
marketplaces: config.marketplaces || undefined,
|
|
1067
1076
|
worktree: config.worktree || undefined,
|
|
1077
|
+
enableArtifact: config.enableArtifact !== undefined ? config.enableArtifact : undefined,
|
|
1068
1078
|
};
|
|
1069
1079
|
}
|
|
1070
1080
|
catch (error) {
|
|
@@ -1209,6 +1219,10 @@ export function loadMergedWaveConfig(workdir) {
|
|
|
1209
1219
|
if (config.worktree !== undefined) {
|
|
1210
1220
|
mergedConfig.worktree = config.worktree;
|
|
1211
1221
|
}
|
|
1222
|
+
// Merge enableArtifact (last one wins)
|
|
1223
|
+
if (config.enableArtifact !== undefined) {
|
|
1224
|
+
mergedConfig.enableArtifact = config.enableArtifact;
|
|
1225
|
+
}
|
|
1212
1226
|
// Merge models
|
|
1213
1227
|
if (config.models) {
|
|
1214
1228
|
if (!mergedConfig.models)
|
|
@@ -1247,5 +1261,6 @@ export function loadMergedWaveConfig(workdir) {
|
|
|
1247
1261
|
? mergedConfig.models
|
|
1248
1262
|
: undefined,
|
|
1249
1263
|
worktree: mergedConfig.worktree,
|
|
1264
|
+
enableArtifact: mergedConfig.enableArtifact,
|
|
1250
1265
|
};
|
|
1251
1266
|
}
|
|
@@ -64,6 +64,11 @@ export class InitializationService {
|
|
|
64
64
|
const phaseStart = performance.now();
|
|
65
65
|
// Load hooks configuration using ConfigurationService
|
|
66
66
|
const configResult = await configurationService.loadMergedConfiguration(workdir);
|
|
67
|
+
// Rebuild subagent configurations now that settings.json env is loaded
|
|
68
|
+
// into the snapshot: conditional builtin subagents (model: visionModel
|
|
69
|
+
// → WAVE_VISION_MODEL) can only register once the env is available.
|
|
70
|
+
// Plugin agents are preserved by refreshConfigurations.
|
|
71
|
+
await subagentManager.refreshConfigurations();
|
|
67
72
|
hookManager.loadConfigurationFromWaveConfig(configResult.configuration);
|
|
68
73
|
// Update plugin manager with enabled plugins configuration
|
|
69
74
|
if (configResult.configuration?.enabledPlugins) {
|
package/dist/tools/agentTool.js
CHANGED
|
@@ -172,7 +172,8 @@ When using the Agent tool, you must specify a subagent_type parameter to select
|
|
|
172
172
|
success: true,
|
|
173
173
|
content: `Agent backgrounded with ID: ${taskId}.${outputPath ? ` Real-time output: ${outputPath}` : ""}`,
|
|
174
174
|
shortResult: "Agent backgrounded",
|
|
175
|
-
|
|
175
|
+
backgroundedByUser: true,
|
|
176
|
+
backgroundTaskId: taskId,
|
|
176
177
|
});
|
|
177
178
|
},
|
|
178
179
|
});
|