wave-agent-sdk 0.14.4 → 0.15.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.
- package/builtin/skills/settings/SKILLS.md +31 -6
- package/dist/agent.d.ts +4 -5
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +10 -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/messageManager.d.ts.map +1 -1
- package/dist/managers/messageManager.js +7 -6
- 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/managers/slashCommandManager.d.ts.map +1 -1
- package/dist/managers/slashCommandManager.js +16 -4
- package/dist/managers/subagentManager.d.ts +6 -1
- package/dist/managers/subagentManager.d.ts.map +1 -1
- package/dist/managers/subagentManager.js +17 -18
- package/dist/prompts/index.d.ts +1 -3
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +3 -6
- 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/jsonlHandler.d.ts +4 -4
- package/dist/services/jsonlHandler.d.ts.map +1 -1
- package/dist/services/jsonlHandler.js +4 -13
- package/dist/services/session.d.ts.map +1 -1
- package/dist/services/session.js +7 -13
- package/dist/tools/agentTool.d.ts.map +1 -1
- package/dist/tools/agentTool.js +16 -4
- package/dist/tools/bashTool.d.ts.map +1 -1
- package/dist/tools/bashTool.js +4 -50
- package/dist/tools/editTool.js +1 -1
- package/dist/tools/skillTool.d.ts.map +1 -1
- package/dist/tools/skillTool.js +16 -4
- 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/types/messaging.d.ts +1 -0
- package/dist/types/messaging.d.ts.map +1 -1
- package/dist/types/session.d.ts +0 -4
- package/dist/types/session.d.ts.map +1 -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/messageOperations.d.ts.map +1 -1
- package/dist/utils/messageOperations.js +5 -0
- 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 +12 -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/messageManager.ts +7 -8
- package/src/managers/permissionManager.ts +6 -6
- package/src/managers/slashCommandManager.ts +24 -5
- package/src/managers/subagentManager.ts +28 -23
- package/src/prompts/index.ts +3 -8
- package/src/services/aiService.ts +10 -12
- package/src/services/hook.ts +0 -15
- package/src/services/jsonlHandler.ts +12 -24
- package/src/services/session.ts +9 -15
- package/src/tools/agentTool.ts +24 -5
- package/src/tools/bashTool.ts +4 -56
- package/src/tools/editTool.ts +1 -1
- package/src/tools/skillTool.ts +24 -4
- package/src/tools/types.ts +0 -3
- package/src/types/agent.ts +0 -1
- package/src/types/hooks.ts +1 -7
- package/src/types/messaging.ts +1 -0
- package/src/types/session.ts +0 -8
- package/src/utils/editUtils.ts +3 -73
- package/src/utils/markdownParser.ts +85 -11
- package/src/utils/messageOperations.ts +5 -0
- package/src/utils/openaiClient.ts +0 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messaging.d.ts","sourceRoot":"","sources":["../../src/types/messaging.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEvC,oBAAY,aAAa;IACvB,IAAI,SAAS;IACb,IAAI,SAAS;CACd;AAED,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;IAC3B,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC3C,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,MAAM,YAAY,GACpB,SAAS,GACT,UAAU,GACV,SAAS,GACT,UAAU,GACV,SAAS,GACT,YAAY,GACZ,cAAc,GACd,gBAAgB,GAChB,qBAAqB,CAAC;AAE1B,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,KAAK,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC;CAC7B;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,E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EAAE,cAAc,CAAC;IACrB,SAAS,EAAE,OAAO,gBAAgB,EAAE,YAAY,EAAE,CAAC;CACpD;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC;IAC5B,MAAM,EAAE,WAAW,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
|
package/dist/types/session.d.ts
CHANGED
|
@@ -4,10 +4,6 @@
|
|
|
4
4
|
*
|
|
5
5
|
* SIMPLIFIED: Removed unused interfaces to focus on core functionality
|
|
6
6
|
*/
|
|
7
|
-
import type { Message } from "./messaging.js";
|
|
8
|
-
export interface SessionMessage extends Message {
|
|
9
|
-
timestamp: string;
|
|
10
|
-
}
|
|
11
7
|
export interface SessionFilename {
|
|
12
8
|
sessionId: string;
|
|
13
9
|
sessionType: "main" | "subagent";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/types/session.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/types/session.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,GAAG,UAAU,CAAC;CAClC"}
|
|
@@ -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":"messageOperations.d.ts","sourceRoot":"","sources":["../../src/utils/messageOperations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,OA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O,EAiC/B,CAAC;AAGF,eAAO,MAAM,cAAc,GAAI,wBAG5B,aAAa,KAAG,OAAO,EAiBzB,CAAC;AAGF,eAAO,MAAM,mBAAmB,GAAI,gCAIjC,gBAAgB,KAAG,OAAO,EAmB5B,CAAC;AAGF,eAAO,MAAM,qBAAqB,GAAI,0CAKnC,kBAAkB,KAAG,OAAO,EAuB9B,CAAC;AAEF;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,MAAM,CAU3D;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAAI,UAAU,OAAO,EAAE,KAAG,OAAO,EASlE,CAAC;AAEF;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAoBtD;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GACb,MAAM,CAUR;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAkB1D;AAED,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC;IAC5B,MAAM,EAAE,WAAW,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,gCAAgC,GAAI,8DAO9C,4BAA4B,KAAG,OAAO,EAkBxC,CAAC"}
|
|
@@ -67,6 +67,7 @@ export const addUserMessageToMessages = ({ messages, content, customCommandConte
|
|
|
67
67
|
id: id || generateMessageId(),
|
|
68
68
|
role: "user",
|
|
69
69
|
blocks,
|
|
70
|
+
timestamp: new Date().toISOString(),
|
|
70
71
|
...(isMeta !== undefined && { isMeta }),
|
|
71
72
|
};
|
|
72
73
|
return [...messages, userMessage];
|
|
@@ -123,6 +124,7 @@ export const addAssistantMessageToMessages = (messages, content, toolCalls, usag
|
|
|
123
124
|
id: generateMessageId(),
|
|
124
125
|
role: "assistant",
|
|
125
126
|
blocks,
|
|
127
|
+
timestamp: new Date().toISOString(),
|
|
126
128
|
usage, // Include usage data if provided
|
|
127
129
|
...(additionalFields ? { additionalFields: { ...additionalFields } } : {}),
|
|
128
130
|
};
|
|
@@ -279,6 +281,7 @@ export const addErrorBlockToMessage = ({ messages, error, }) => {
|
|
|
279
281
|
content: error,
|
|
280
282
|
},
|
|
281
283
|
],
|
|
284
|
+
timestamp: new Date().toISOString(),
|
|
282
285
|
});
|
|
283
286
|
}
|
|
284
287
|
return newMessages;
|
|
@@ -297,6 +300,7 @@ export const addBangMessage = ({ messages, command, }) => {
|
|
|
297
300
|
exitCode: null,
|
|
298
301
|
},
|
|
299
302
|
],
|
|
303
|
+
timestamp: new Date().toISOString(),
|
|
300
304
|
};
|
|
301
305
|
return [...messages, outputMessage];
|
|
302
306
|
};
|
|
@@ -442,6 +446,7 @@ export const addNotificationMessageToMessages = ({ messages, taskId, taskType, s
|
|
|
442
446
|
id: generateMessageId(),
|
|
443
447
|
role: "user",
|
|
444
448
|
blocks: [block],
|
|
449
|
+
timestamp: new Date().toISOString(),
|
|
445
450
|
};
|
|
446
451
|
return [...messages, notificationMessage];
|
|
447
452
|
};
|
|
@@ -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,IAAI,EAAE,CAAC,CAAC;IACR,QAAQ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N;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;
|
|
@@ -911,4 +894,16 @@ export class Agent {
|
|
|
911
894
|
public get taskListId(): string {
|
|
912
895
|
return this.taskManager.getTaskListId();
|
|
913
896
|
}
|
|
897
|
+
|
|
898
|
+
/**
|
|
899
|
+
* Check if there are any running background tasks or active subagents
|
|
900
|
+
*/
|
|
901
|
+
public get hasRunningBackgroundWork(): boolean {
|
|
902
|
+
const runningTasks = this.backgroundTaskManager
|
|
903
|
+
.getAllTasks()
|
|
904
|
+
.some((t) => t.status === "running");
|
|
905
|
+
const activeSubagents =
|
|
906
|
+
this.subagentManager.getActiveInstances().length > 0;
|
|
907
|
+
return runningTasks || activeSubagents;
|
|
908
|
+
}
|
|
914
909
|
}
|
|
@@ -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
|
|
@@ -669,7 +669,6 @@ export class HookManager {
|
|
|
669
669
|
event === "Stop" ||
|
|
670
670
|
event === "SubagentStop" ||
|
|
671
671
|
event === "WorktreeCreate" ||
|
|
672
|
-
event === "CwdChanged" ||
|
|
673
672
|
event === "SessionStart" ||
|
|
674
673
|
event === "SessionEnd"
|
|
675
674
|
) {
|
|
@@ -773,7 +772,6 @@ export class HookManager {
|
|
|
773
772
|
SubagentStop: 0,
|
|
774
773
|
PermissionRequest: 0,
|
|
775
774
|
WorktreeCreate: 0,
|
|
776
|
-
CwdChanged: 0,
|
|
777
775
|
SessionStart: 0,
|
|
778
776
|
SessionEnd: 0,
|
|
779
777
|
},
|
|
@@ -788,7 +786,6 @@ export class HookManager {
|
|
|
788
786
|
SubagentStop: 0,
|
|
789
787
|
PermissionRequest: 0,
|
|
790
788
|
WorktreeCreate: 0,
|
|
791
|
-
CwdChanged: 0,
|
|
792
789
|
SessionStart: 0,
|
|
793
790
|
SessionEnd: 0,
|
|
794
791
|
};
|
|
@@ -815,35 +812,6 @@ export class HookManager {
|
|
|
815
812
|
};
|
|
816
813
|
}
|
|
817
814
|
|
|
818
|
-
/**
|
|
819
|
-
* Execute CwdChanged hooks.
|
|
820
|
-
*/
|
|
821
|
-
async executeCwdChangedHooks(
|
|
822
|
-
oldCwd: string,
|
|
823
|
-
newCwd: string,
|
|
824
|
-
sessionId: string,
|
|
825
|
-
transcriptPath: string,
|
|
826
|
-
env: Record<string, string>,
|
|
827
|
-
): Promise<HookExecutionResult[]> {
|
|
828
|
-
const context: ExtendedHookExecutionContext = {
|
|
829
|
-
event: "CwdChanged",
|
|
830
|
-
projectDir: this.workdir,
|
|
831
|
-
timestamp: new Date(),
|
|
832
|
-
sessionId,
|
|
833
|
-
transcriptPath,
|
|
834
|
-
cwd: newCwd,
|
|
835
|
-
oldCwd,
|
|
836
|
-
newCwd,
|
|
837
|
-
env,
|
|
838
|
-
};
|
|
839
|
-
const results = await this.executeHooks("CwdChanged", context);
|
|
840
|
-
if (results.length > 0) {
|
|
841
|
-
// For CwdChanged hooks, we don't block, just log errors
|
|
842
|
-
this.processHookResults("CwdChanged", results);
|
|
843
|
-
}
|
|
844
|
-
return results;
|
|
845
|
-
}
|
|
846
|
-
|
|
847
815
|
/**
|
|
848
816
|
* Register hooks provided by a plugin
|
|
849
817
|
*/
|
|
@@ -518,6 +518,7 @@ export class MessageManager {
|
|
|
518
518
|
sessionId: this.sessionId,
|
|
519
519
|
},
|
|
520
520
|
],
|
|
521
|
+
timestamp: new Date().toISOString(),
|
|
521
522
|
...(usage && { usage }),
|
|
522
523
|
};
|
|
523
524
|
|
|
@@ -959,15 +960,13 @@ export class MessageManager {
|
|
|
959
960
|
try {
|
|
960
961
|
const { writeFile } = await import("fs/promises");
|
|
961
962
|
|
|
962
|
-
const sessionMessages: import("../types/session.js").SessionMessage[] =
|
|
963
|
-
messages.map((message) => ({
|
|
964
|
-
...message,
|
|
965
|
-
timestamp: new Date().toISOString(),
|
|
966
|
-
}));
|
|
967
|
-
|
|
968
963
|
const content =
|
|
969
|
-
|
|
970
|
-
|
|
964
|
+
messages
|
|
965
|
+
.map((m) => {
|
|
966
|
+
const { timestamp, ...rest } = m;
|
|
967
|
+
return JSON.stringify({ timestamp, ...rest });
|
|
968
|
+
})
|
|
969
|
+
.join("\n") + (messages.length > 0 ? "\n" : "");
|
|
971
970
|
|
|
972
971
|
await writeFile(this.transcriptPath, content, "utf8");
|
|
973
972
|
} catch (error) {
|