wave-agent-sdk 0.14.4 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/builtin/skills/settings/SKILLS.md +31 -6
- package/dist/agent.d.ts +0 -5
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +0 -15
- package/dist/constants/toolLimits.d.ts +10 -0
- package/dist/constants/toolLimits.d.ts.map +1 -0
- package/dist/constants/toolLimits.js +9 -0
- package/dist/managers/aiManager.d.ts +0 -5
- package/dist/managers/aiManager.d.ts.map +1 -1
- package/dist/managers/aiManager.js +0 -22
- package/dist/managers/hookManager.d.ts +0 -4
- package/dist/managers/hookManager.d.ts.map +1 -1
- package/dist/managers/hookManager.js +0 -25
- package/dist/managers/permissionManager.d.ts +1 -1
- package/dist/managers/permissionManager.d.ts.map +1 -1
- package/dist/managers/permissionManager.js +5 -5
- package/dist/prompts/index.d.ts +0 -1
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +3 -4
- package/dist/services/aiService.d.ts.map +1 -1
- package/dist/services/aiService.js +10 -8
- package/dist/services/hook.d.ts +0 -4
- package/dist/services/hook.d.ts.map +1 -1
- package/dist/services/hook.js +0 -10
- package/dist/services/session.d.ts.map +1 -1
- package/dist/services/session.js +4 -1
- package/dist/tools/bashTool.d.ts.map +1 -1
- package/dist/tools/bashTool.js +2 -45
- package/dist/tools/editTool.js +1 -1
- package/dist/tools/types.d.ts +0 -3
- package/dist/tools/types.d.ts.map +1 -1
- package/dist/types/agent.d.ts +0 -1
- package/dist/types/agent.d.ts.map +1 -1
- package/dist/types/hooks.d.ts +1 -5
- package/dist/types/hooks.d.ts.map +1 -1
- package/dist/types/hooks.js +0 -1
- package/dist/utils/editUtils.d.ts +5 -2
- package/dist/utils/editUtils.d.ts.map +1 -1
- package/dist/utils/editUtils.js +3 -57
- package/dist/utils/markdownParser.d.ts +8 -1
- package/dist/utils/markdownParser.d.ts.map +1 -1
- package/dist/utils/markdownParser.js +64 -11
- package/dist/utils/openaiClient.d.ts.map +1 -1
- package/dist/utils/openaiClient.js +0 -11
- package/package.json +1 -1
- package/src/agent.ts +0 -17
- package/src/constants/toolLimits.ts +12 -0
- package/src/managers/aiManager.ts +0 -38
- package/src/managers/hookManager.ts +0 -32
- package/src/managers/permissionManager.ts +6 -6
- package/src/prompts/index.ts +3 -5
- package/src/services/aiService.ts +10 -12
- package/src/services/hook.ts +0 -15
- package/src/services/session.ts +6 -1
- package/src/tools/bashTool.ts +2 -51
- package/src/tools/editTool.ts +1 -1
- package/src/tools/types.ts +0 -3
- package/src/types/agent.ts +0 -1
- package/src/types/hooks.ts +1 -7
- package/src/utils/editUtils.ts +3 -73
- package/src/utils/markdownParser.ts +85 -11
- package/src/utils/openaiClient.ts +0 -11
package/dist/tools/bashTool.js
CHANGED
|
@@ -204,10 +204,7 @@ Try to maintain your current working directory throughout the session by using a
|
|
|
204
204
|
}
|
|
205
205
|
// Foreground execution (original behavior)
|
|
206
206
|
return new Promise((resolve) => {
|
|
207
|
-
|
|
208
|
-
const tempCwdFile = path.join(os.tmpdir(), `wave_cwd_${Date.now()}_${Math.random().toString(36).substring(2, 11)}.tmp`);
|
|
209
|
-
const wrappedCommand = `${command} && pwd -P >| ${tempCwdFile}`;
|
|
210
|
-
const child = spawn(wrappedCommand, {
|
|
207
|
+
const child = spawn(command, {
|
|
211
208
|
shell: true,
|
|
212
209
|
stdio: "pipe",
|
|
213
210
|
cwd: context.workdir,
|
|
@@ -362,50 +359,10 @@ Try to maintain your current working directory throughout the session by using a
|
|
|
362
359
|
if (timeoutHandle) {
|
|
363
360
|
clearTimeout(timeoutHandle);
|
|
364
361
|
}
|
|
365
|
-
// Read the new CWD from the temporary file
|
|
366
|
-
let newCwd;
|
|
367
|
-
try {
|
|
368
|
-
if (fs.existsSync(tempCwdFile)) {
|
|
369
|
-
newCwd = fs.readFileSync(tempCwdFile, "utf8").trim();
|
|
370
|
-
// Validate the path exists before calling the callback
|
|
371
|
-
fs.accessSync(newCwd, fs.constants.F_OK);
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
catch (fileError) {
|
|
375
|
-
logger.warn(`Could not read or validate new CWD from temp file ${tempCwdFile}:`, fileError);
|
|
376
|
-
newCwd = undefined;
|
|
377
|
-
}
|
|
378
|
-
finally {
|
|
379
|
-
// Ensure temp file is cleaned up even if reading fails
|
|
380
|
-
try {
|
|
381
|
-
if (fs.existsSync(tempCwdFile)) {
|
|
382
|
-
fs.unlinkSync(tempCwdFile);
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
catch (fileError) {
|
|
386
|
-
logger.error("Failed to clean up temp CWD file:", fileError);
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
// If CWD changed, call the onCwdChange callback and add notification
|
|
390
|
-
let cwdChangedNotification = "";
|
|
391
|
-
if (newCwd && newCwd !== context.workdir && context.onCwdChange) {
|
|
392
|
-
const isInSafeZone = context.permissionManager?.isPathInSafeZone?.(newCwd) ?? true;
|
|
393
|
-
if (isInSafeZone) {
|
|
394
|
-
context.onCwdChange(newCwd);
|
|
395
|
-
}
|
|
396
|
-
else if (context.originalWorkdir) {
|
|
397
|
-
context.onCwdChange(context.originalWorkdir);
|
|
398
|
-
cwdChangedNotification = `Shell cwd was reset to ${context.originalWorkdir}\n`;
|
|
399
|
-
}
|
|
400
|
-
else {
|
|
401
|
-
context.onCwdChange(newCwd);
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
362
|
const exitCode = code ?? 0;
|
|
405
363
|
const combinedOutput = outputBuffer + (errorBuffer ? "\n" + errorBuffer : "");
|
|
406
364
|
// Handle large output by truncation and persistence if needed
|
|
407
|
-
const finalOutput =
|
|
408
|
-
(combinedOutput || `Command executed with exit code: ${exitCode}`);
|
|
365
|
+
const finalOutput = combinedOutput || `Command executed with exit code: ${exitCode}`;
|
|
409
366
|
const content = processOutput(finalOutput);
|
|
410
367
|
const lines = combinedOutput.trim().split("\n");
|
|
411
368
|
const shortResult = lines.length <= 3
|
package/dist/tools/editTool.js
CHANGED
package/dist/tools/types.d.ts
CHANGED
|
@@ -38,7 +38,6 @@ export interface ToolContext {
|
|
|
38
38
|
abortSignal?: AbortSignal;
|
|
39
39
|
backgroundTaskManager?: import("../managers/backgroundTaskManager.js").BackgroundTaskManager;
|
|
40
40
|
workdir: string;
|
|
41
|
-
originalWorkdir?: string;
|
|
42
41
|
/** Permission mode for this tool execution */
|
|
43
42
|
permissionMode?: PermissionMode;
|
|
44
43
|
/** Custom permission callback */
|
|
@@ -87,7 +86,5 @@ export interface ToolContext {
|
|
|
87
86
|
mtime: number;
|
|
88
87
|
hash: string;
|
|
89
88
|
}>;
|
|
90
|
-
/** Callback to notify when the current working directory changes */
|
|
91
|
-
onCwdChange?: (newCwd: string) => void;
|
|
92
89
|
}
|
|
93
90
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EACnB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,0BAA0B,CAAC;IACnC,OAAO,EAAE,CACP,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,EAAE,WAAW,KACjB,OAAO,CAAC,UAAU,CAAC,CAAC;IACzB,mBAAmB,CAAC,EAAE,CACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,OAAO,EAAE,WAAW,KACjB,MAAM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AAC;IAC1C,yCAAyC;IACzC,iBAAiB,CAAC,EAAE;QAClB,YAAY,EAAE,MAAM,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,mEAAmE;IACnE,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC9D"}
|
package/dist/types/agent.d.ts
CHANGED
|
@@ -78,7 +78,6 @@ export interface AgentCallbacks extends MessageManagerCallbacks, BackgroundTaskM
|
|
|
78
78
|
onConfiguredModelsChange?: (models: string[]) => void;
|
|
79
79
|
onLoadingChange?: (loading: boolean) => void;
|
|
80
80
|
onCommandRunningChange?: (running: boolean) => void;
|
|
81
|
-
onWorkdirChange?: (newCwd: string) => void;
|
|
82
81
|
onQueuedMessagesChange?: (messages: QueuedMessage[]) => void;
|
|
83
82
|
}
|
|
84
83
|
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/types/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,KAAK,EACV,OAAO,EACP,MAAM,EACN,cAAc,EACd,kBAAkB,EAClB,WAAW,EACX,YAAY,EACZ,cAAc,EACf,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AAC3F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAE/E;;;;;GAKG;AACH,MAAM,WAAW,YAAY;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AAI,CAAC;CAC9D"}
|
package/dist/types/hooks.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* enabling automated actions at specific workflow points.
|
|
6
6
|
*/
|
|
7
7
|
export type { WaveConfiguration, HookConfiguration, PartialHookConfiguration, HookConfigurationRecord, } from "./configuration.js";
|
|
8
|
-
export type HookEvent = "PreToolUse" | "PostToolUse" | "UserPromptSubmit" | "Stop" | "SubagentStop" | "PermissionRequest" | "WorktreeCreate" | "
|
|
8
|
+
export type HookEvent = "PreToolUse" | "PostToolUse" | "UserPromptSubmit" | "Stop" | "SubagentStop" | "PermissionRequest" | "WorktreeCreate" | "SessionStart" | "SessionEnd";
|
|
9
9
|
export interface HookCommand {
|
|
10
10
|
type: "command";
|
|
11
11
|
command: string;
|
|
@@ -67,8 +67,6 @@ export interface HookJsonInput {
|
|
|
67
67
|
user_prompt?: string;
|
|
68
68
|
subagent_type?: string;
|
|
69
69
|
name?: string;
|
|
70
|
-
old_cwd?: string;
|
|
71
|
-
new_cwd?: string;
|
|
72
70
|
source?: SessionStartSource;
|
|
73
71
|
agent_type?: string;
|
|
74
72
|
end_source?: SessionEndSource;
|
|
@@ -83,8 +81,6 @@ export interface ExtendedHookExecutionContext extends HookExecutionContext {
|
|
|
83
81
|
userPrompt?: string;
|
|
84
82
|
subagentType?: string;
|
|
85
83
|
worktreeName?: string;
|
|
86
|
-
oldCwd?: string;
|
|
87
|
-
newCwd?: string;
|
|
88
84
|
source?: SessionStartSource;
|
|
89
85
|
agentType?: string;
|
|
90
86
|
endSource?: SessionEndSource;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/types/hooks.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,YAAY,EACV,iBAAiB,EACjB,iBAAiB,EACjB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAG5B,MAAM,MAAM,SAAS,GACjB,YAAY,GACZ,a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AkB,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B;AAGD,MAAM,WAAW,4BAA6B,SAAQ,oBAAoB;IACxE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,gBAAgB,CAAC;CAC9B;AAGD,MAAM,WAAW,eAAe;IAC9B,gBAAgB,EAAE,MAAM,CAAC;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB"}
|
package/dist/types/hooks.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility functions for file editing tools
|
|
3
|
+
*/
|
|
1
4
|
/**
|
|
2
5
|
* Escape regular expression special characters
|
|
3
6
|
*/
|
|
4
7
|
export declare function escapeRegExp(string: string): string;
|
|
5
8
|
/**
|
|
6
|
-
*
|
|
9
|
+
* Returns a generic error message when old_string is not found.
|
|
7
10
|
*/
|
|
8
|
-
export declare function analyzeEditMismatch(
|
|
11
|
+
export declare function analyzeEditMismatch(): string;
|
|
9
12
|
//# sourceMappingURL=editUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editUtils.d.ts","sourceRoot":"","sources":["../../src/utils/editUtils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"editUtils.d.ts","sourceRoot":"","sources":["../../src/utils/editUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,MAAM,CAE5C"}
|
package/dist/utils/editUtils.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Utility functions for file editing tools
|
|
3
3
|
*/
|
|
4
|
-
import { formatLineNumberPrefix } from "./stringUtils.js";
|
|
5
4
|
/**
|
|
6
5
|
* Escape regular expression special characters
|
|
7
6
|
*/
|
|
@@ -9,61 +8,8 @@ export function escapeRegExp(string) {
|
|
|
9
8
|
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
10
9
|
}
|
|
11
10
|
/**
|
|
12
|
-
*
|
|
11
|
+
* Returns a generic error message when old_string is not found.
|
|
13
12
|
*/
|
|
14
|
-
export function analyzeEditMismatch(
|
|
15
|
-
|
|
16
|
-
const searchLines = searchString.split("\n");
|
|
17
|
-
if (searchLines.length === 0 || contentLines.length === 0) {
|
|
18
|
-
return "old_string not found in file (empty search or content)";
|
|
19
|
-
}
|
|
20
|
-
let bestMatchIndex = -1;
|
|
21
|
-
let bestMatchScore = -1;
|
|
22
|
-
// Sliding window to find the best partial match
|
|
23
|
-
for (let i = 0; i <= contentLines.length - searchLines.length; i++) {
|
|
24
|
-
let currentScore = 0;
|
|
25
|
-
for (let j = 0; j < searchLines.length; j++) {
|
|
26
|
-
if (contentLines[i + j] === searchLines[j]) {
|
|
27
|
-
currentScore++;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
// Heuristic: prioritize matches where first or last lines match
|
|
31
|
-
if (contentLines[i] === searchLines[0])
|
|
32
|
-
currentScore += 0.5;
|
|
33
|
-
if (contentLines[i + searchLines.length - 1] ===
|
|
34
|
-
searchLines[searchLines.length - 1])
|
|
35
|
-
currentScore += 0.5;
|
|
36
|
-
// Also consider trimmed matches to catch indentation issues
|
|
37
|
-
for (let j = 0; j < searchLines.length; j++) {
|
|
38
|
-
if (contentLines[i + j].trim() === searchLines[j].trim() &&
|
|
39
|
-
contentLines[i + j] !== searchLines[j]) {
|
|
40
|
-
currentScore += 0.1;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
if (currentScore > bestMatchScore) {
|
|
44
|
-
bestMatchScore = currentScore;
|
|
45
|
-
bestMatchIndex = i;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
// If no decent match found (score <= 0), return generic message
|
|
49
|
-
if (bestMatchScore <= 0) {
|
|
50
|
-
return "old_string not found in file (no similar block found)";
|
|
51
|
-
}
|
|
52
|
-
// Generate detailed report
|
|
53
|
-
const reportLines = [
|
|
54
|
-
`old_string not found in file. Best partial match found at line ${bestMatchIndex + 1}:`,
|
|
55
|
-
];
|
|
56
|
-
for (let j = 0; j < searchLines.length; j++) {
|
|
57
|
-
const lineNum = bestMatchIndex + j + 1;
|
|
58
|
-
const actualLine = contentLines[bestMatchIndex + j];
|
|
59
|
-
const expectedLine = searchLines[j];
|
|
60
|
-
if (actualLine === expectedLine) {
|
|
61
|
-
reportLines.push(`${formatLineNumberPrefix(lineNum)}${actualLine}`);
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
reportLines.push(`${formatLineNumberPrefix(lineNum)}- ${expectedLine}`);
|
|
65
|
-
reportLines.push(`${formatLineNumberPrefix(lineNum)}+ ${actualLine}`);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return reportLines.join("\n");
|
|
13
|
+
export function analyzeEditMismatch() {
|
|
14
|
+
return "old_string not found in file";
|
|
69
15
|
}
|
|
@@ -27,7 +27,14 @@ export declare function parseBashCommands(content: string): {
|
|
|
27
27
|
processedContent: string;
|
|
28
28
|
};
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* Truncate output if it exceeds the size limit.
|
|
31
|
+
* Writes to a temp file and returns a preview + file path if truncated.
|
|
32
|
+
*/
|
|
33
|
+
export declare function truncateOutput(output: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* Replace bash command placeholders with their outputs.
|
|
36
|
+
* Uses function replacer to avoid $$, $&, $' corruption in shell output.
|
|
37
|
+
* Handles both inline (!`cmd`) and block (```! cmd ```) syntax.
|
|
31
38
|
*/
|
|
32
39
|
export declare function replaceBashCommandsWithOutput(content: string, results: BashCommandResult[]): string;
|
|
33
40
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdownParser.d.ts","sourceRoot":"","sources":["../../src/utils/markdownParser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"markdownParser.d.ts","sourceRoot":"","sources":["../../src/utils/markdownParser.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAQlE,UAAU,kBAAkB;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,wBAAwB,CAAC;CACnC;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG;IACjD,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB,CA8DA;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,kBAAkB,CA4CtE;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB;AAYD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG;IAClD,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAyCA;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAgBrD;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,iBAAiB,EAAE,GAC3B,MAAM,CAuBR;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,MAAM,EAAE,EAClB,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,MAAc,GACtB,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAkC9B"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { readFileSync } from "fs";
|
|
1
|
+
import { readFileSync, writeFileSync, mkdirSync } from "fs";
|
|
2
2
|
import { exec } from "child_process";
|
|
3
3
|
import { promisify } from "util";
|
|
4
|
+
import { join } from "path";
|
|
5
|
+
import { tmpdir } from "os";
|
|
6
|
+
import { SKILL_BASH_MAX_OUTPUT_CHARS, PREVIEW_SIZE_BYTES, } from "../constants/toolLimits.js";
|
|
4
7
|
const execAsync = promisify(exec);
|
|
5
8
|
/**
|
|
6
9
|
* Parse YAML frontmatter from markdown content
|
|
@@ -97,13 +100,38 @@ export function parseMarkdownFile(filePath) {
|
|
|
97
100
|
throw new Error(`Failed to parse markdown file ${filePath}: ${error instanceof Error ? error.message : String(error)}`);
|
|
98
101
|
}
|
|
99
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Block syntax pattern: ```! command ```
|
|
105
|
+
*/
|
|
106
|
+
const BLOCK_BASH_REGEX = /```!\s*\n?([\s\S]*?)\n?```/g;
|
|
107
|
+
/**
|
|
108
|
+
* Inline syntax pattern: !`command`
|
|
109
|
+
*/
|
|
110
|
+
const INLINE_BASH_REGEX = /!`([^`]+)`/g;
|
|
100
111
|
export function parseBashCommands(content) {
|
|
101
|
-
|
|
112
|
+
// Performance gate: skip expensive regex if no bash pattern exists
|
|
113
|
+
// Covers the common case where 93% of skills have no bash substitution
|
|
114
|
+
if (!content.includes("!`") && !content.includes("```!")) {
|
|
115
|
+
return { commands: [], processedContent: content };
|
|
116
|
+
}
|
|
102
117
|
const commands = [];
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
118
|
+
// Extract block commands
|
|
119
|
+
let blockMatch;
|
|
120
|
+
const blockRegex = new RegExp(BLOCK_BASH_REGEX.source, BLOCK_BASH_REGEX.flags);
|
|
121
|
+
while ((blockMatch = blockRegex.exec(content)) !== null) {
|
|
122
|
+
const cmd = blockMatch[1].trim();
|
|
123
|
+
if (cmd) {
|
|
124
|
+
commands.push(cmd);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
// Extract inline commands
|
|
128
|
+
let inlineMatch;
|
|
129
|
+
const inlineRegex = new RegExp(INLINE_BASH_REGEX.source, INLINE_BASH_REGEX.flags);
|
|
130
|
+
while ((inlineMatch = inlineRegex.exec(content)) !== null) {
|
|
131
|
+
const cmd = inlineMatch[1].trim();
|
|
132
|
+
if (cmd) {
|
|
133
|
+
commands.push(cmd);
|
|
134
|
+
}
|
|
107
135
|
}
|
|
108
136
|
// For now, return the content as-is. The actual command execution
|
|
109
137
|
// will be handled by the slash command manager
|
|
@@ -113,18 +141,43 @@ export function parseBashCommands(content) {
|
|
|
113
141
|
};
|
|
114
142
|
}
|
|
115
143
|
/**
|
|
116
|
-
*
|
|
144
|
+
* Truncate output if it exceeds the size limit.
|
|
145
|
+
* Writes to a temp file and returns a preview + file path if truncated.
|
|
146
|
+
*/
|
|
147
|
+
export function truncateOutput(output) {
|
|
148
|
+
if (output.length <= SKILL_BASH_MAX_OUTPUT_CHARS) {
|
|
149
|
+
return output;
|
|
150
|
+
}
|
|
151
|
+
const preview = output.slice(0, PREVIEW_SIZE_BYTES);
|
|
152
|
+
const tempDir = join(tmpdir(), "wave-skill-bash");
|
|
153
|
+
mkdirSync(tempDir, { recursive: true });
|
|
154
|
+
const tempFile = join(tempDir, `output-${Date.now()}-${Math.random().toString(36).slice(2, 8)}.txt`);
|
|
155
|
+
writeFileSync(tempFile, output, "utf-8");
|
|
156
|
+
return `${preview}\n\n[Output truncated (${output.length} chars). Full output saved to: ${tempFile}]`;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Replace bash command placeholders with their outputs.
|
|
160
|
+
* Uses function replacer to avoid $$, $&, $' corruption in shell output.
|
|
161
|
+
* Handles both inline (!`cmd`) and block (```! cmd ```) syntax.
|
|
117
162
|
*/
|
|
118
163
|
export function replaceBashCommandsWithOutput(content, results) {
|
|
119
|
-
const bashCommandRegex = /!`([^`]+)`/g;
|
|
120
164
|
let processedContent = content;
|
|
121
165
|
let commandIndex = 0;
|
|
122
|
-
|
|
166
|
+
// Replace block syntax first: ```! command ```
|
|
167
|
+
processedContent = processedContent.replace(BLOCK_BASH_REGEX, () => {
|
|
168
|
+
if (commandIndex < results.length) {
|
|
169
|
+
const result = results[commandIndex++];
|
|
170
|
+
return truncateOutput(result.output);
|
|
171
|
+
}
|
|
172
|
+
return "";
|
|
173
|
+
});
|
|
174
|
+
// Replace inline syntax: !`command`
|
|
175
|
+
processedContent = processedContent.replace(INLINE_BASH_REGEX, () => {
|
|
123
176
|
if (commandIndex < results.length) {
|
|
124
177
|
const result = results[commandIndex++];
|
|
125
|
-
return result.output;
|
|
178
|
+
return truncateOutput(result.output);
|
|
126
179
|
}
|
|
127
|
-
return
|
|
180
|
+
return "";
|
|
128
181
|
});
|
|
129
182
|
return processedContent;
|
|
130
183
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openaiClient.d.ts","sourceRoot":"","sources":["../../src/utils/openaiClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sCAAsC,EACtC,mCAAmC,EACnC,mBAAmB,EACnB,cAAc,EACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,KAAK,YAAY,GACb,sCAAsC,GACtC,mCAAmC,CAAC;AAExC,UAAU,WAAW,CAAC,CAAC;IACrB,IAA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CAAC,GAClC,cAAc,CACnB;;MA2BN;YAEa,OAAO;YAqIN,oBAAoB;CAqCpC"}
|
|
@@ -108,27 +108,16 @@ export class OpenAIClient {
|
|
|
108
108
|
error.status = response.status;
|
|
109
109
|
error.body = errorBody;
|
|
110
110
|
if (response.status === 429 && attempt < maxRetries) {
|
|
111
|
-
const responseHeaders = {};
|
|
112
|
-
response.headers.forEach((value, key) => {
|
|
113
|
-
responseHeaders[key] = value;
|
|
114
|
-
});
|
|
115
111
|
logger.warn("OpenAI API 429 Too Many Requests, retrying...", {
|
|
116
112
|
attempt: attempt + 1,
|
|
117
113
|
status: response.status,
|
|
118
|
-
responseHeaders,
|
|
119
114
|
});
|
|
120
115
|
lastError = error;
|
|
121
116
|
continue;
|
|
122
117
|
}
|
|
123
|
-
const responseHeaders = {};
|
|
124
|
-
response.headers.forEach((value, key) => {
|
|
125
|
-
responseHeaders[key] = value;
|
|
126
|
-
});
|
|
127
118
|
logger.error("OpenAI API Error:", {
|
|
128
119
|
status: response.status,
|
|
129
120
|
statusText: response.statusText,
|
|
130
|
-
requestHeaders: headers,
|
|
131
|
-
responseHeaders,
|
|
132
121
|
errorBody,
|
|
133
122
|
});
|
|
134
123
|
throw error;
|
package/package.json
CHANGED
package/src/agent.ts
CHANGED
|
@@ -218,13 +218,6 @@ export class Agent {
|
|
|
218
218
|
}
|
|
219
219
|
};
|
|
220
220
|
|
|
221
|
-
// Wire up CWD change callback from AIManager to sync Agent's workdir
|
|
222
|
-
this.aiManager.setOnCwdChange((newCwd) => {
|
|
223
|
-
this.workdir = newCwd;
|
|
224
|
-
this.container.register("Workdir", newCwd);
|
|
225
|
-
this.options.callbacks?.onWorkdirChange?.(newCwd);
|
|
226
|
-
});
|
|
227
|
-
|
|
228
221
|
// Wire up message queue to process when agent becomes idle
|
|
229
222
|
this.messageQueue.onMessageEnqueued = () => {
|
|
230
223
|
// If the AI is NOT loading and command is not running, trigger dequeue
|
|
@@ -287,16 +280,6 @@ export class Agent {
|
|
|
287
280
|
return this.workdir;
|
|
288
281
|
}
|
|
289
282
|
|
|
290
|
-
/**
|
|
291
|
-
* Set the working directory
|
|
292
|
-
* @param newCwd - The new working directory
|
|
293
|
-
*/
|
|
294
|
-
public setWorkdir(newCwd: string): void {
|
|
295
|
-
this.workdir = newCwd;
|
|
296
|
-
this.container.register("Workdir", newCwd);
|
|
297
|
-
this.options.callbacks?.onWorkdirChange?.(newCwd);
|
|
298
|
-
}
|
|
299
|
-
|
|
300
283
|
/** Get project memory content */
|
|
301
284
|
public get projectMemory(): string {
|
|
302
285
|
return this._projectMemoryContent;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool output size limits matching Claude Code patterns.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/** System-wide default max result size in characters. */
|
|
6
|
+
export const DEFAULT_MAX_RESULT_SIZE_CHARS = 50_000;
|
|
7
|
+
|
|
8
|
+
/** Per-command cap for skill bash substitution (inline/block). */
|
|
9
|
+
export const SKILL_BASH_MAX_OUTPUT_CHARS = 30_000;
|
|
10
|
+
|
|
11
|
+
/** Preview size in characters when output is persisted to disk. */
|
|
12
|
+
export const PREVIEW_SIZE_BYTES = 2_048;
|
|
@@ -33,7 +33,6 @@ import { logger } from "../utils/globalLogger.js";
|
|
|
33
33
|
export interface AIManagerCallbacks {
|
|
34
34
|
onCompactionStateChange?: (isCompacting: boolean) => void;
|
|
35
35
|
onUsageAdded?: (usage: Usage) => void;
|
|
36
|
-
onCwdChange?: (newCwd: string) => void;
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
export interface AIManagerOptions {
|
|
@@ -55,12 +54,10 @@ export class AIManager {
|
|
|
55
54
|
onLoadingChange?: (loading: boolean) => void;
|
|
56
55
|
private toolAbortController: AbortController | null = null;
|
|
57
56
|
private workdir: string;
|
|
58
|
-
private originalWorkdir: string;
|
|
59
57
|
private systemPrompt?: string;
|
|
60
58
|
private subagentType?: string; // Store subagent type for hook context
|
|
61
59
|
private stream: boolean; // Streaming mode flag
|
|
62
60
|
private modelOverride?: string;
|
|
63
|
-
private _onCwdChange?: (newCwd: string) => void; // Store callback for CWD changes
|
|
64
61
|
private consecutiveCompactionFailures: number = 0;
|
|
65
62
|
private readonly maxTurns?: number;
|
|
66
63
|
|
|
@@ -70,13 +67,11 @@ export class AIManager {
|
|
|
70
67
|
options: AIManagerOptions,
|
|
71
68
|
) {
|
|
72
69
|
this.workdir = options.workdir;
|
|
73
|
-
this.originalWorkdir = options.workdir;
|
|
74
70
|
this.systemPrompt = options.systemPrompt;
|
|
75
71
|
this.subagentType = options.subagentType; // Store subagent type
|
|
76
72
|
this.stream = options.stream ?? true; // Default to true if not specified
|
|
77
73
|
this.callbacks = options.callbacks ?? {};
|
|
78
74
|
this.modelOverride = options.modelOverride;
|
|
79
|
-
this._onCwdChange = options.callbacks?.onCwdChange; // Initialize onCwdChange
|
|
80
75
|
this.maxTurns = options.maxTurns;
|
|
81
76
|
}
|
|
82
77
|
|
|
@@ -174,14 +169,6 @@ export class AIManager {
|
|
|
174
169
|
return this.workdir;
|
|
175
170
|
}
|
|
176
171
|
|
|
177
|
-
public getOriginalWorkdir(): string {
|
|
178
|
-
return this.originalWorkdir;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
public setOnCwdChange(callback: (newCwd: string) => void): void {
|
|
182
|
-
this._onCwdChange = callback;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
172
|
private isCompacting: boolean = false;
|
|
186
173
|
private callbacks: AIManagerCallbacks;
|
|
187
174
|
|
|
@@ -247,7 +234,6 @@ export class AIManager {
|
|
|
247
234
|
if (toolPlugin?.formatCompactParams) {
|
|
248
235
|
const context: ToolContext = {
|
|
249
236
|
workdir: this.workdir,
|
|
250
|
-
originalWorkdir: this.originalWorkdir,
|
|
251
237
|
taskManager: this.taskManager,
|
|
252
238
|
};
|
|
253
239
|
return toolPlugin.formatCompactParams(toolArgs, context);
|
|
@@ -657,7 +643,6 @@ export class AIManager {
|
|
|
657
643
|
filteredToolPlugins,
|
|
658
644
|
{
|
|
659
645
|
workdir: this.workdir,
|
|
660
|
-
originalWorkdir: this.originalWorkdir,
|
|
661
646
|
memory: combinedMemory,
|
|
662
647
|
language: this.getLanguage(),
|
|
663
648
|
isSubagent: !!this.subagentType,
|
|
@@ -908,7 +893,6 @@ export class AIManager {
|
|
|
908
893
|
abortSignal: toolAbortController.signal,
|
|
909
894
|
backgroundTaskManager: this.backgroundTaskManager,
|
|
910
895
|
workdir: this.workdir,
|
|
911
|
-
originalWorkdir: this.originalWorkdir,
|
|
912
896
|
messageId: this.messageManager.getMessages().slice(-1)[0]?.id,
|
|
913
897
|
sessionId: this.messageManager.getSessionId(),
|
|
914
898
|
toolCallId: toolId,
|
|
@@ -927,28 +911,6 @@ export class AIManager {
|
|
|
927
911
|
stage: "running", // Keep it in running stage while updating result
|
|
928
912
|
});
|
|
929
913
|
},
|
|
930
|
-
onCwdChange: async (newCwd: string) => {
|
|
931
|
-
const oldCwd = this.workdir;
|
|
932
|
-
this.workdir = newCwd;
|
|
933
|
-
this._onCwdChange?.(newCwd);
|
|
934
|
-
if (this.hookManager) {
|
|
935
|
-
const sessionId = this.messageManager.getSessionId();
|
|
936
|
-
const transcriptPath =
|
|
937
|
-
this.messageManager.getTranscriptPath();
|
|
938
|
-
const env = Object.fromEntries(
|
|
939
|
-
Object.entries(process.env).filter(
|
|
940
|
-
(e) => e[1] !== undefined,
|
|
941
|
-
),
|
|
942
|
-
) as Record<string, string>;
|
|
943
|
-
await this.hookManager.executeCwdChangedHooks(
|
|
944
|
-
oldCwd,
|
|
945
|
-
newCwd,
|
|
946
|
-
sessionId,
|
|
947
|
-
transcriptPath,
|
|
948
|
-
env,
|
|
949
|
-
);
|
|
950
|
-
}
|
|
951
|
-
},
|
|
952
914
|
};
|
|
953
915
|
|
|
954
916
|
// Execute tool
|