wave-agent-sdk 0.11.1 → 0.11.3
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/dist/managers/aiManager.d.ts.map +1 -1
- package/dist/managers/aiManager.js +7 -0
- package/dist/prompts/index.d.ts +2 -1
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +2 -0
- package/dist/tools/bashTool.d.ts.map +1 -1
- package/dist/tools/bashTool.js +41 -2
- package/dist/tools/types.d.ts +2 -0
- package/dist/tools/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/managers/aiManager.ts +7 -0
- package/src/prompts/index.ts +3 -0
- package/src/tools/bashTool.ts +48 -2
- package/src/tools/types.ts +2 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aiManager.d.ts","sourceRoot":"","sources":["../../src/managers/aiManager.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,KAAK,EAGN,MAAM,mBAAmB,CAAC;AAY3B,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAKlD,MAAM,WAAW,kBAAkB;IACjC,wBAAwB,CAAC,EAAE,CAAC,aAAa,EAAE,OAAO,KAAK,IAAI,CAAC;IAC5D,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACvC;AAED,MAAM,WAAW,gBAAgB;IAC/B,SAAS,CAAC,EAAE,kBAAkB,CAAC;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uEAAuE;IACvE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,kDAAkD;IAClD,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,qBAAa,SAAS;IAYlB,OAAO,CAAC,SAAS;IAXZ,SAAS,EAAE,OAAO,CAAS;IAClC,OAAO,CA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,GAEhC;IAED,OAAO,KAAK,WAAW,GAEtB;IAED,OAAO,KAAK,gBAAgB,GAM3B;IAED,OAAO,KAAK,iBAAiB,GAE5B;IAED,OAAO,KAAK,oBAAoB,GAE/B;IAGM,gBAAgB,IAAI,aAAa;IAIjC,cAAc,IAAI,WAAW;IA6B7B,iBAAiB,IAAI,MAAM;IAI3B,WAAW,IAAI,MAAM,GAAG,SAAS;IAIjC,oBAAoB,IAAI,OAAO;IAItC,OAAO,CAAC,aAAa,CAAkB;IACvC,OAAO,CAAC,SAAS,CAAqB;IAEtC;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAcvB,YAAY,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI;IAItC,cAAc,IAAI,IAAI;IAuB7B,OAAO,CAAC,qBAAqB;YAsBf,8BAA8B;IAgFrC,gBAAgB,IAAI,OAAO;IAI3B,gBAAgB,CAAC,aAAa,EAAE,OAAO,GAAG,IAAI;IAOrD,OAAO,KAAK,eAAe,GAE1B;IAED,OAAO,KAAK,YAAY,GAEvB;IAEY,aAAa,CACxB,OAAO,GAAE;QACP,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,oEAAoE;QACpE,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;QACxB,SAAS,CAAC,EAAE,MAAM,CAAC;KACf,GACL,OAAO,CAAC,IAAI,CAAC;IAklBhB;;;;OAIG;YACW,gBAAgB;IAiE9B;;;OAGG;YACW,sBAAsB;IA6DpC;;OAEG;YACW,uBAAuB;CAwDtC"}
|
|
@@ -492,6 +492,13 @@ export class AIManager {
|
|
|
492
492
|
stage: "running", // Keep it in running stage while updating shortResult
|
|
493
493
|
});
|
|
494
494
|
},
|
|
495
|
+
onResultUpdate: (result) => {
|
|
496
|
+
this.messageManager.updateToolBlock({
|
|
497
|
+
id: toolId,
|
|
498
|
+
result,
|
|
499
|
+
stage: "running", // Keep it in running stage while updating result
|
|
500
|
+
});
|
|
501
|
+
},
|
|
495
502
|
};
|
|
496
503
|
// Execute tool
|
|
497
504
|
const toolResult = await this.toolManager.execute(functionToolCall.function?.name || "", toolArgs, context);
|
package/dist/prompts/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ToolPlugin } from "../tools/types.js";
|
|
2
2
|
import { PermissionMode } from "../types/permissions.js";
|
|
3
|
+
export declare const MAX_PARALLEL_TOOL_CALLS = 3;
|
|
3
4
|
export declare const BASE_SYSTEM_PROMPT = "You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.\n\n# Doing tasks\nThe user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:\n- NEVER propose changes to code you haven't read. If a user asks about or wants you to modify a file, read it first. Understand existing code before suggesting modifications.\n- Be careful not to introduce security vulnerabilities such as command injection, XSS, SQL injection, and other OWASP top 10 vulnerabilities. If you notice that you wrote insecure code, immediately fix it.\n- Avoid over-engineering. Only make changes that are directly requested or clearly necessary. Keep solutions simple and focused.\n - Don't add features, refactor code, or make \"improvements\" beyond what was asked. A bug fix doesn't need surrounding code cleaned up. A simple feature doesn't need extra configurability. Don't add docstrings, comments, or type annotations to code you didn't change. Only add comments where the logic isn't self-evident.\n - Don't add error handling, fallbacks, or validation for scenarios that can't happen. Trust internal code and framework guarantees. Only validate at system boundaries (user input, external APIs). Don't use feature flags or backwards-compatibility shims when you can just change the code.\n - Don't create helpers, utilities, or abstractions for one-time operations. Don't design for hypothetical future requirements. The right amount of complexity is the minimum needed for the current task\u2014three similar lines of code is better than a premature abstraction.\n- Avoid backwards-compatibility hacks like renaming unused `_vars`, re-exporting types, adding `// removed` comments for removed code, etc. If something is unused, delete it completely.";
|
|
4
|
-
export declare const TOOL_POLICY = "\n# Tool usage policy\n- You can call multiple tools in a single response. If you intend to call multiple tools and there are no dependencies between them, make all independent tool calls in parallel. Maximize use of parallel tool calls where possible to increase efficiency.\n- However, if some tool calls depend on previous calls to inform dependent values, do NOT call these tools in parallel and instead call them sequentially. For instance, if one operation must complete before another starts, run these operations sequentially instead. Never use placeholders or guess missing parameters in tool calls.\n- If the user specifies that they want you to run tools \"in parallel\", you MUST send a single message with multiple tool use content blocks.";
|
|
5
|
+
export declare const TOOL_POLICY = "\n# Tool usage policy\n- You can call multiple tools in a single response. If you intend to call multiple tools and there are no dependencies between them, make all independent tool calls in parallel. Maximize use of parallel tool calls where possible to increase efficiency.\n- **Limit**: You MUST NOT call more than 3 tools in parallel in a single response.\n- However, if some tool calls depend on previous calls to inform dependent values, do NOT call these tools in parallel and instead call them sequentially. For instance, if one operation must complete before another starts, run these operations sequentially instead. Never use placeholders or guess missing parameters in tool calls.\n- If the user specifies that they want you to run tools \"in parallel\", you MUST send a single message with multiple tool use content blocks.";
|
|
5
6
|
export declare function buildPlanModePrompt(planFilePath: string, planExists: boolean, isSubagent?: boolean): string;
|
|
6
7
|
export declare const DEFAULT_SYSTEM_PROMPT = "You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.\n\n# Doing tasks\nThe user will primarily request you perform software engineering tasks. This includes solving bugs, adding new functionality, refactoring code, explaining code, and more. For these tasks the following steps are recommended:\n- NEVER propose changes to code you haven't read. If a user asks about or wants you to modify a file, read it first. Understand existing code before suggesting modifications.\n- Be careful not to introduce security vulnerabilities such as command injection, XSS, SQL injection, and other OWASP top 10 vulnerabilities. If you notice that you wrote insecure code, immediately fix it.\n- Avoid over-engineering. Only make changes that are directly requested or clearly necessary. Keep solutions simple and focused.\n - Don't add features, refactor code, or make \"improvements\" beyond what was asked. A bug fix doesn't need surrounding code cleaned up. A simple feature doesn't need extra configurability. Don't add docstrings, comments, or type annotations to code you didn't change. Only add comments where the logic isn't self-evident.\n - Don't add error handling, fallbacks, or validation for scenarios that can't happen. Trust internal code and framework guarantees. Only validate at system boundaries (user input, external APIs). Don't use feature flags or backwards-compatibility shims when you can just change the code.\n - Don't create helpers, utilities, or abstractions for one-time operations. Don't design for hypothetical future requirements. The right amount of complexity is the minimum needed for the current task\u2014three similar lines of code is better than a premature abstraction.\n- Avoid backwards-compatibility hacks like renaming unused `_vars`, re-exporting types, adding `// removed` comments for removed code, etc. If something is unused, delete it completely.";
|
|
7
8
|
export declare const COMPRESS_MESSAGES_SYSTEM_PROMPT = "You have been working on the task described above but have not yet completed it. Write a continuation summary that will allow you (or another instance of yourself) to resume work efficiently in a future context window where the conversation history will be replaced with this summary. Your summary should be structured, concise, and actionable. Include:\n1. Task Overview\nThe user's core request and success criteria\nAny clarifications or constraints they specified\n2. Current State\nWhat has been completed so far\nFiles created, modified, or analyzed (with paths if relevant)\nKey outputs or artifacts produced\n3. Important Discoveries\nTechnical constraints or requirements uncovered\nDecisions made and their rationale\nErrors encountered and how they were resolved\nWhat approaches were tried that didn't work (and why)\n4. Next Steps\nSpecific actions needed to complete the task\nAny blockers or open questions to resolve\nPriority order if multiple steps remain\n5. Context to Preserve\nUser preferences or style requirements\nDomain-specific details that aren't obvious\nAny promises made to the user\nBe concise but complete\u2014err on the side of including information that would prevent duplicate work or repeated mistakes. Write in a way that enables immediate resumption of the task.\nWrap your summary in <summary></summary> tags.";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAazD,eAAO,MAAM,kBAAkB,g9DAU+J,CAAC;AAE/L,eAAO,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAazD,eAAO,MAAM,uBAAuB,IAAI,CAAC;AAEzC,eAAO,MAAM,kBAAkB,g9DAU+J,CAAC;AAE/L,eAAO,MAAM,WAAW,y0BAKqH,CAAC;AAE9I,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,OAAO,EACnB,UAAU,GAAE,OAAe,GAC1B,MAAM,CAmFR;AAED,eAAO,MAAM,qBAAqB,g9DAAqB,CAAC;AAExD,eAAO,MAAM,+BAA+B,20CAsBG,CAAC;AAEhD,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,KAAK,EAAE,UAAU,EAAE,EACnB,OAAO,GAAE;IACP,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE;QACT,YAAY,EAAE,MAAM,CAAC;QACrB,UAAU,EAAE,OAAO,CAAC;KACrB,CAAC;IACF,UAAU,CAAC,EAAE;QACX,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,cAAc,CAAC,EAAE,cAAc,CAAC;CAC5B,GACL,MAAM,CAiDR"}
|
package/dist/prompts/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { isGitRepository } from "../utils/gitUtils.js";
|
|
|
3
3
|
import { buildAutoMemoryPrompt } from "./autoMemory.js";
|
|
4
4
|
import { EXPLORE_SUBAGENT_TYPE, PLAN_SUBAGENT_TYPE, } from "../constants/subagents.js";
|
|
5
5
|
import { ASK_USER_QUESTION_TOOL_NAME, EDIT_TOOL_NAME, WRITE_TOOL_NAME, EXIT_PLAN_MODE_TOOL_NAME, AGENT_TOOL_NAME, } from "../constants/tools.js";
|
|
6
|
+
export const MAX_PARALLEL_TOOL_CALLS = 3;
|
|
6
7
|
export const BASE_SYSTEM_PROMPT = `You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.
|
|
7
8
|
|
|
8
9
|
# Doing tasks
|
|
@@ -17,6 +18,7 @@ The user will primarily request you perform software engineering tasks. This inc
|
|
|
17
18
|
export const TOOL_POLICY = `
|
|
18
19
|
# Tool usage policy
|
|
19
20
|
- You can call multiple tools in a single response. If you intend to call multiple tools and there are no dependencies between them, make all independent tool calls in parallel. Maximize use of parallel tool calls where possible to increase efficiency.
|
|
21
|
+
- **Limit**: You MUST NOT call more than ${MAX_PARALLEL_TOOL_CALLS} tools in parallel in a single response.
|
|
20
22
|
- However, if some tool calls depend on previous calls to inform dependent values, do NOT call these tools in parallel and instead call them sequentially. For instance, if one operation must complete before another starts, run these operations sequentially instead. Never use placeholders or guess missing parameters in tool calls.
|
|
21
23
|
- If the user specifies that they want you to run tools "in parallel", you MUST send a single message with multiple tool use content blocks.`;
|
|
22
24
|
export function buildPlanModePrompt(planFilePath, planExists, isSubagent = false) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bashTool.d.ts","sourceRoot":"","sources":["../../src/tools/bashTool.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"bashTool.d.ts","sourceRoot":"","sources":["../../src/tools/bashTool.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AAuDtE;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,UA2ZtB,CAAC"}
|
package/dist/tools/bashTool.js
CHANGED
|
@@ -28,6 +28,19 @@ function processOutput(output) {
|
|
|
28
28
|
"\n\n... (output truncated, failed to persist full output)");
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Simple throttle function to limit the frequency of updates.
|
|
33
|
+
*/
|
|
34
|
+
function throttle(func, limit) {
|
|
35
|
+
let inThrottle;
|
|
36
|
+
return function () {
|
|
37
|
+
if (!inThrottle) {
|
|
38
|
+
func();
|
|
39
|
+
inThrottle = true;
|
|
40
|
+
setTimeout(() => (inThrottle = false), limit);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
31
44
|
/**
|
|
32
45
|
* Bash command execution tool - supports both foreground and background execution
|
|
33
46
|
*/
|
|
@@ -194,6 +207,29 @@ Usage notes:
|
|
|
194
207
|
let errorBuffer = "";
|
|
195
208
|
let isAborted = false;
|
|
196
209
|
let isBackgrounded = false;
|
|
210
|
+
let isFinished = false;
|
|
211
|
+
const updateRealtimeResults = throttle(() => {
|
|
212
|
+
if (isAborted || isBackgrounded || isFinished)
|
|
213
|
+
return;
|
|
214
|
+
const combinedOutput = outputBuffer + (errorBuffer ? "\n" + errorBuffer : "");
|
|
215
|
+
// Update shortResult: last 3 lines
|
|
216
|
+
if (context.onShortResultUpdate) {
|
|
217
|
+
const tail = combinedOutput.slice(-5000);
|
|
218
|
+
const lines = tail.trim().split("\n");
|
|
219
|
+
const shortResult = lines.length <= 3
|
|
220
|
+
? lines.join("\n")
|
|
221
|
+
: `... +${lines.length - 3} lines\n` + lines.slice(-3).join("\n");
|
|
222
|
+
context.onShortResultUpdate(shortResult);
|
|
223
|
+
}
|
|
224
|
+
// Update full result
|
|
225
|
+
if (context.onResultUpdate) {
|
|
226
|
+
const content = combinedOutput.length <= MAX_OUTPUT_LENGTH
|
|
227
|
+
? combinedOutput
|
|
228
|
+
: combinedOutput.substring(0, MAX_OUTPUT_LENGTH) +
|
|
229
|
+
"\n\n... (output truncated)";
|
|
230
|
+
context.onResultUpdate(content);
|
|
231
|
+
}
|
|
232
|
+
}, 1000);
|
|
197
233
|
const foregroundTaskId = `bash_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
198
234
|
// Register as foreground task
|
|
199
235
|
if (context.foregroundTaskManager && command) {
|
|
@@ -292,15 +328,18 @@ Usage notes:
|
|
|
292
328
|
if (!isAborted && !isBackgrounded && !runInBackground) {
|
|
293
329
|
const chunk = stripAnsiColors(data.toString());
|
|
294
330
|
outputBuffer += chunk;
|
|
331
|
+
updateRealtimeResults();
|
|
295
332
|
}
|
|
296
333
|
});
|
|
297
334
|
child.stderr?.on("data", (data) => {
|
|
298
335
|
if (!isAborted && !isBackgrounded && !runInBackground) {
|
|
299
336
|
const chunk = stripAnsiColors(data.toString());
|
|
300
337
|
errorBuffer += chunk;
|
|
338
|
+
updateRealtimeResults();
|
|
301
339
|
}
|
|
302
340
|
});
|
|
303
341
|
child.on("exit", (code) => {
|
|
342
|
+
isFinished = true;
|
|
304
343
|
if (context.foregroundTaskManager) {
|
|
305
344
|
context.foregroundTaskManager.unregisterForegroundTask(foregroundTaskId);
|
|
306
345
|
}
|
|
@@ -316,8 +355,7 @@ Usage notes:
|
|
|
316
355
|
const lines = combinedOutput.trim().split("\n");
|
|
317
356
|
const shortResult = lines.length <= 3
|
|
318
357
|
? lines.join("\n")
|
|
319
|
-
: lines.slice(
|
|
320
|
-
`\n... +${lines.length - 3} lines`;
|
|
358
|
+
: `... +${lines.length - 3} lines\n` + lines.slice(-3).join("\n");
|
|
321
359
|
resolve({
|
|
322
360
|
success: exitCode === 0,
|
|
323
361
|
content,
|
|
@@ -329,6 +367,7 @@ Usage notes:
|
|
|
329
367
|
}
|
|
330
368
|
});
|
|
331
369
|
child.on("error", (error) => {
|
|
370
|
+
isFinished = true;
|
|
332
371
|
if (context.foregroundTaskManager) {
|
|
333
372
|
context.foregroundTaskManager.unregisterForegroundTask(foregroundTaskId);
|
|
334
373
|
}
|
package/dist/tools/types.d.ts
CHANGED
|
@@ -67,5 +67,7 @@ export interface ToolContext {
|
|
|
67
67
|
toolCallId?: string;
|
|
68
68
|
/** Callback to update the short result of the current tool block */
|
|
69
69
|
onShortResultUpdate?: (shortResult: string) => void;
|
|
70
|
+
/** Callback to update the full result of the current tool block */
|
|
71
|
+
onResultUpdate?: (result: string) => void;
|
|
70
72
|
}
|
|
71
73
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1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E;IACpE,mBAAmB,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IACpD,mEAAmE;IACnE,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3C"}
|
package/package.json
CHANGED
|
@@ -692,6 +692,13 @@ export class AIManager {
|
|
|
692
692
|
stage: "running", // Keep it in running stage while updating shortResult
|
|
693
693
|
});
|
|
694
694
|
},
|
|
695
|
+
onResultUpdate: (result: string) => {
|
|
696
|
+
this.messageManager.updateToolBlock({
|
|
697
|
+
id: toolId,
|
|
698
|
+
result,
|
|
699
|
+
stage: "running", // Keep it in running stage while updating result
|
|
700
|
+
});
|
|
701
|
+
},
|
|
695
702
|
};
|
|
696
703
|
|
|
697
704
|
// Execute tool
|
package/src/prompts/index.ts
CHANGED
|
@@ -15,6 +15,8 @@ import {
|
|
|
15
15
|
AGENT_TOOL_NAME,
|
|
16
16
|
} from "../constants/tools.js";
|
|
17
17
|
|
|
18
|
+
export const MAX_PARALLEL_TOOL_CALLS = 3;
|
|
19
|
+
|
|
18
20
|
export const BASE_SYSTEM_PROMPT = `You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.
|
|
19
21
|
|
|
20
22
|
# Doing tasks
|
|
@@ -30,6 +32,7 @@ The user will primarily request you perform software engineering tasks. This inc
|
|
|
30
32
|
export const TOOL_POLICY = `
|
|
31
33
|
# Tool usage policy
|
|
32
34
|
- You can call multiple tools in a single response. If you intend to call multiple tools and there are no dependencies between them, make all independent tool calls in parallel. Maximize use of parallel tool calls where possible to increase efficiency.
|
|
35
|
+
- **Limit**: You MUST NOT call more than ${MAX_PARALLEL_TOOL_CALLS} tools in parallel in a single response.
|
|
33
36
|
- However, if some tool calls depend on previous calls to inform dependent values, do NOT call these tools in parallel and instead call them sequentially. For instance, if one operation must complete before another starts, run these operations sequentially instead. Never use placeholders or guess missing parameters in tool calls.
|
|
34
37
|
- If the user specifies that they want you to run tools "in parallel", you MUST send a single message with multiple tool use content blocks.`;
|
|
35
38
|
|
package/src/tools/bashTool.ts
CHANGED
|
@@ -45,6 +45,20 @@ function processOutput(output: string): string {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Simple throttle function to limit the frequency of updates.
|
|
50
|
+
*/
|
|
51
|
+
function throttle(func: () => void, limit: number) {
|
|
52
|
+
let inThrottle: boolean;
|
|
53
|
+
return function () {
|
|
54
|
+
if (!inThrottle) {
|
|
55
|
+
func();
|
|
56
|
+
inThrottle = true;
|
|
57
|
+
setTimeout(() => (inThrottle = false), limit);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
48
62
|
/**
|
|
49
63
|
* Bash command execution tool - supports both foreground and background execution
|
|
50
64
|
*/
|
|
@@ -232,6 +246,35 @@ Usage notes:
|
|
|
232
246
|
let errorBuffer = "";
|
|
233
247
|
let isAborted = false;
|
|
234
248
|
let isBackgrounded = false;
|
|
249
|
+
let isFinished = false;
|
|
250
|
+
|
|
251
|
+
const updateRealtimeResults = throttle(() => {
|
|
252
|
+
if (isAborted || isBackgrounded || isFinished) return;
|
|
253
|
+
|
|
254
|
+
const combinedOutput =
|
|
255
|
+
outputBuffer + (errorBuffer ? "\n" + errorBuffer : "");
|
|
256
|
+
|
|
257
|
+
// Update shortResult: last 3 lines
|
|
258
|
+
if (context.onShortResultUpdate) {
|
|
259
|
+
const tail = combinedOutput.slice(-5000);
|
|
260
|
+
const lines = tail.trim().split("\n");
|
|
261
|
+
const shortResult =
|
|
262
|
+
lines.length <= 3
|
|
263
|
+
? lines.join("\n")
|
|
264
|
+
: `... +${lines.length - 3} lines\n` + lines.slice(-3).join("\n");
|
|
265
|
+
context.onShortResultUpdate(shortResult);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Update full result
|
|
269
|
+
if (context.onResultUpdate) {
|
|
270
|
+
const content =
|
|
271
|
+
combinedOutput.length <= MAX_OUTPUT_LENGTH
|
|
272
|
+
? combinedOutput
|
|
273
|
+
: combinedOutput.substring(0, MAX_OUTPUT_LENGTH) +
|
|
274
|
+
"\n\n... (output truncated)";
|
|
275
|
+
context.onResultUpdate(content);
|
|
276
|
+
}
|
|
277
|
+
}, 1000);
|
|
235
278
|
|
|
236
279
|
const foregroundTaskId = `bash_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
237
280
|
|
|
@@ -346,6 +389,7 @@ Usage notes:
|
|
|
346
389
|
if (!isAborted && !isBackgrounded && !runInBackground) {
|
|
347
390
|
const chunk = stripAnsiColors(data.toString());
|
|
348
391
|
outputBuffer += chunk;
|
|
392
|
+
updateRealtimeResults();
|
|
349
393
|
}
|
|
350
394
|
});
|
|
351
395
|
|
|
@@ -353,10 +397,12 @@ Usage notes:
|
|
|
353
397
|
if (!isAborted && !isBackgrounded && !runInBackground) {
|
|
354
398
|
const chunk = stripAnsiColors(data.toString());
|
|
355
399
|
errorBuffer += chunk;
|
|
400
|
+
updateRealtimeResults();
|
|
356
401
|
}
|
|
357
402
|
});
|
|
358
403
|
|
|
359
404
|
child.on("exit", (code) => {
|
|
405
|
+
isFinished = true;
|
|
360
406
|
if (context.foregroundTaskManager) {
|
|
361
407
|
context.foregroundTaskManager.unregisterForegroundTask(
|
|
362
408
|
foregroundTaskId,
|
|
@@ -381,8 +427,7 @@ Usage notes:
|
|
|
381
427
|
const shortResult =
|
|
382
428
|
lines.length <= 3
|
|
383
429
|
? lines.join("\n")
|
|
384
|
-
: lines.slice(
|
|
385
|
-
`\n... +${lines.length - 3} lines`;
|
|
430
|
+
: `... +${lines.length - 3} lines\n` + lines.slice(-3).join("\n");
|
|
386
431
|
|
|
387
432
|
resolve({
|
|
388
433
|
success: exitCode === 0,
|
|
@@ -397,6 +442,7 @@ Usage notes:
|
|
|
397
442
|
});
|
|
398
443
|
|
|
399
444
|
child.on("error", (error) => {
|
|
445
|
+
isFinished = true;
|
|
400
446
|
if (context.foregroundTaskManager) {
|
|
401
447
|
context.foregroundTaskManager.unregisterForegroundTask(
|
|
402
448
|
foregroundTaskId,
|
package/src/tools/types.ts
CHANGED
|
@@ -87,4 +87,6 @@ export interface ToolContext {
|
|
|
87
87
|
toolCallId?: string;
|
|
88
88
|
/** Callback to update the short result of the current tool block */
|
|
89
89
|
onShortResultUpdate?: (shortResult: string) => void;
|
|
90
|
+
/** Callback to update the full result of the current tool block */
|
|
91
|
+
onResultUpdate?: (result: string) => void;
|
|
90
92
|
}
|