wave-agent-sdk 0.12.0 → 0.12.2
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/README.md +0 -13
- package/builtin/skills/settings/ENV.md +4 -0
- package/builtin/skills/settings/HOOKS.md +4 -0
- package/builtin/skills/settings/MODELS.md +4 -0
- package/builtin/skills/settings/SKILL.md +5 -1
- package/builtin/skills/settings/SKILLS.md +13 -0
- package/dist/agent.d.ts +2 -2
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +3 -2
- package/dist/managers/aiManager.d.ts.map +1 -1
- package/dist/managers/aiManager.js +0 -4
- package/dist/managers/backgroundTaskManager.d.ts.map +1 -1
- package/dist/managers/backgroundTaskManager.js +9 -2
- package/dist/managers/cronManager.d.ts.map +1 -1
- package/dist/managers/cronManager.js +1 -0
- package/dist/managers/permissionManager.d.ts.map +1 -1
- package/dist/managers/permissionManager.js +9 -5
- package/dist/managers/slashCommandManager.d.ts.map +1 -1
- package/dist/managers/slashCommandManager.js +2 -0
- package/dist/prompts/index.d.ts +11 -3
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +97 -11
- package/dist/services/configurationService.d.ts +1 -1
- package/dist/services/configurationService.d.ts.map +1 -1
- package/dist/services/configurationService.js +26 -15
- package/dist/services/fileWatcher.d.ts.map +1 -1
- package/dist/services/fileWatcher.js +12 -2
- package/dist/services/hook.d.ts.map +1 -1
- package/dist/services/hook.js +6 -1
- package/dist/services/session.d.ts.map +1 -1
- package/dist/services/session.js +2 -14
- package/dist/tools/bashTool.d.ts.map +1 -1
- package/dist/tools/bashTool.js +30 -19
- package/dist/tools/webFetchTool.d.ts.map +1 -1
- package/dist/tools/webFetchTool.js +1 -1
- package/dist/tools/writeTool.d.ts.map +1 -1
- package/dist/tools/writeTool.js +6 -0
- package/dist/types/core.d.ts +2 -0
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/core.js +2 -0
- package/dist/utils/bashParser.d.ts +4 -0
- package/dist/utils/bashParser.d.ts.map +1 -1
- package/dist/utils/bashParser.js +23 -0
- package/dist/utils/messageOperations.d.ts +10 -0
- package/dist/utils/messageOperations.d.ts.map +1 -1
- package/dist/utils/messageOperations.js +51 -0
- package/dist/utils/stringUtils.d.ts +4 -0
- package/dist/utils/stringUtils.d.ts.map +1 -1
- package/dist/utils/stringUtils.js +21 -0
- package/package.json +1 -1
- package/src/agent.ts +3 -2
- package/src/managers/aiManager.ts +0 -6
- package/src/managers/backgroundTaskManager.ts +9 -2
- package/src/managers/cronManager.ts +1 -0
- package/src/managers/permissionManager.ts +9 -4
- package/src/managers/slashCommandManager.ts +2 -0
- package/src/prompts/index.ts +111 -9
- package/src/services/configurationService.ts +34 -20
- package/src/services/fileWatcher.ts +13 -2
- package/src/services/hook.ts +4 -1
- package/src/services/session.ts +2 -21
- package/src/tools/bashTool.ts +32 -22
- package/src/tools/webFetchTool.ts +3 -2
- package/src/tools/writeTool.ts +10 -0
- package/src/types/core.ts +4 -0
- package/src/utils/bashParser.ts +24 -0
- package/src/utils/messageOperations.ts +57 -0
- package/src/utils/stringUtils.ts +20 -0
|
@@ -356,17 +356,31 @@ export class ConfigurationService {
|
|
|
356
356
|
* @returns Resolved model configuration with defaults
|
|
357
357
|
*/
|
|
358
358
|
resolveModelConfig(model, fastModel, maxTokens, permissionMode) {
|
|
359
|
-
//
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
359
|
+
// Resolve agent model: override > options > env (settings.json) > process.env
|
|
360
|
+
const resolvedAgentModel = model ||
|
|
361
|
+
this.options.model ||
|
|
362
|
+
this.env.WAVE_MODEL ||
|
|
363
|
+
process.env.WAVE_MODEL;
|
|
364
|
+
// Resolve fast model: override > options > env (settings.json) > process.env
|
|
365
|
+
const resolvedFastModel = fastModel ||
|
|
366
|
+
this.options.fastModel ||
|
|
367
|
+
this.env.WAVE_FAST_MODEL ||
|
|
368
|
+
process.env.WAVE_FAST_MODEL;
|
|
369
|
+
// Validate required fields
|
|
370
|
+
if (!resolvedAgentModel) {
|
|
371
|
+
throw new ConfigurationError(CONFIG_ERRORS.MISSING_MODEL, "model", {
|
|
372
|
+
constructor: model,
|
|
373
|
+
environment: process.env.WAVE_MODEL,
|
|
374
|
+
settings: this.env.WAVE_MODEL,
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
if (!resolvedFastModel) {
|
|
378
|
+
throw new ConfigurationError(CONFIG_ERRORS.MISSING_FAST_MODEL, "fastModel", {
|
|
379
|
+
constructor: fastModel,
|
|
380
|
+
environment: process.env.WAVE_FAST_MODEL,
|
|
381
|
+
settings: this.env.WAVE_FAST_MODEL,
|
|
382
|
+
});
|
|
383
|
+
}
|
|
370
384
|
// Resolve max output tokens
|
|
371
385
|
const resolvedMaxTokens = this.resolveMaxOutputTokens(maxTokens);
|
|
372
386
|
const baseConfig = {
|
|
@@ -483,13 +497,10 @@ export class ConfigurationService {
|
|
|
483
497
|
this.options.model = model;
|
|
484
498
|
}
|
|
485
499
|
/**
|
|
486
|
-
* Get all configured models from settings.json and
|
|
500
|
+
* Get all configured models from settings.json and environment
|
|
487
501
|
*/
|
|
488
502
|
getConfiguredModels() {
|
|
489
|
-
const DEFAULT_AGENT_MODEL = "gemini-3-flash";
|
|
490
503
|
const models = new Set();
|
|
491
|
-
// Add default model
|
|
492
|
-
models.add(DEFAULT_AGENT_MODEL);
|
|
493
504
|
// Add current model from options or environment
|
|
494
505
|
const currentModel = this.options.model || this.env.WAVE_MODEL || process.env.WAVE_MODEL;
|
|
495
506
|
if (currentModel) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileWatcher.d.ts","sourceRoot":"","sources":["../../src/services/fileWatcher.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC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b,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,GACxC,OAAO,CAAC,IAAI,CAAC;IA+BhB;;;OAGG;IACG,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB9C;;;OAGG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI;IA0BxD;;;OAGG;IACH,qBAAqB,IAAI,iBAAiB,EAAE;IAM5C;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;YAahB,iBAAiB;IAqD/B,OAAO,CAAC,wBAAwB;IAoChC,OAAO,CAAC,eAAe;CAoCxB"}
|
|
@@ -111,10 +111,13 @@ export class FileWatcherService extends EventEmitter {
|
|
|
111
111
|
*/
|
|
112
112
|
async cleanup() {
|
|
113
113
|
const paths = Array.from(this.watchers.keys());
|
|
114
|
-
|
|
114
|
+
for (const path of paths) {
|
|
115
|
+
await this.unwatchFile(path);
|
|
116
|
+
}
|
|
115
117
|
if (this.globalWatcher) {
|
|
116
|
-
|
|
118
|
+
const watcher = this.globalWatcher;
|
|
117
119
|
this.globalWatcher = null;
|
|
120
|
+
await watcher.close();
|
|
118
121
|
}
|
|
119
122
|
}
|
|
120
123
|
async initializeWatcher(entry) {
|
|
@@ -131,6 +134,13 @@ export class FileWatcherService extends EventEmitter {
|
|
|
131
134
|
usePolling: entry.config.fallbackPolling,
|
|
132
135
|
interval: entry.config.pollInterval,
|
|
133
136
|
});
|
|
137
|
+
// Unref the global watcher to allow natural exit if it's the only thing left
|
|
138
|
+
// (chokidar watchers keep the process alive by default)
|
|
139
|
+
// Note: some platforms might need additional handling
|
|
140
|
+
const watcher = this.globalWatcher;
|
|
141
|
+
if (watcher.unref) {
|
|
142
|
+
watcher.unref();
|
|
143
|
+
}
|
|
134
144
|
this.setupGlobalWatcherEvents();
|
|
135
145
|
}
|
|
136
146
|
// Add path to global watcher
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../../src/services/hook.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,4BAA4B,EAElC,MAAM,mBAAmB,CAAC;AA0E3B;;GAEG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,oBAAoB,GAAG,4BAA4B,EAC5D,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,mBAAmB,CAAC,
|
|
1
|
+
{"version":3,"file":"hook.d.ts","sourceRoot":"","sources":["../../src/services/hook.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,KAAK,4BAA4B,EAElC,MAAM,mBAAmB,CAAC;AA0E3B;;GAEG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,oBAAoB,GAAG,4BAA4B,EAC5D,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,mBAAmB,CAAC,CA6I9B;AAED;;GAEG;AACH,wBAAsB,eAAe,CACnC,QAAQ,EAAE,MAAM,EAAE,EAClB,OAAO,EAAE,oBAAoB,GAAG,4BAA4B,EAC5D,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAchC;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAsBtD"}
|
package/dist/services/hook.js
CHANGED
|
@@ -119,11 +119,12 @@ export async function executeCommand(command, context, options) {
|
|
|
119
119
|
});
|
|
120
120
|
}
|
|
121
121
|
// Set up timeout
|
|
122
|
+
let forceKillTimeoutHandle;
|
|
122
123
|
const timeoutHandle = setTimeout(() => {
|
|
123
124
|
timedOut = true;
|
|
124
125
|
childProcess.kill("SIGTERM");
|
|
125
126
|
// Force kill after additional delay
|
|
126
|
-
setTimeout(() => {
|
|
127
|
+
forceKillTimeoutHandle = setTimeout(() => {
|
|
127
128
|
if (!childProcess.killed) {
|
|
128
129
|
childProcess.kill("SIGKILL");
|
|
129
130
|
}
|
|
@@ -163,6 +164,8 @@ export async function executeCommand(command, context, options) {
|
|
|
163
164
|
// Handle process completion
|
|
164
165
|
childProcess.on("close", (code) => {
|
|
165
166
|
clearTimeout(timeoutHandle);
|
|
167
|
+
if (forceKillTimeoutHandle)
|
|
168
|
+
clearTimeout(forceKillTimeoutHandle);
|
|
166
169
|
const duration = Date.now() - startTime;
|
|
167
170
|
resolve({
|
|
168
171
|
success: !timedOut && (code === 0 || code === null),
|
|
@@ -176,6 +179,8 @@ export async function executeCommand(command, context, options) {
|
|
|
176
179
|
// Handle process errors
|
|
177
180
|
childProcess.on("error", (error) => {
|
|
178
181
|
clearTimeout(timeoutHandle);
|
|
182
|
+
if (forceKillTimeoutHandle)
|
|
183
|
+
clearTimeout(forceKillTimeoutHandle);
|
|
179
184
|
const duration = Date.now() - startTime;
|
|
180
185
|
resolve({
|
|
181
186
|
success: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/services/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAMH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/services/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAMH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAQjD,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,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oBAAoB,CACxC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,WAAW,CAAC,EAAE,MAAM,GAAG,UAAU,GAChC,OAAO,CAAC,OAAO,CAAC,CAsClB;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC1C,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAkCxB;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,CACjC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,WAAW,GAAE,MAAM,GAAG,UAAmB,GACxC,OAAO,CAAC,IAAI,CAAC,CA6Bf;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EACf,SAAS,GAAE,MAAY,GACtB,MAAM,CAQR;AAED;;;;;;GAMG;AACH,wBAAsB,wBAAwB,CAC5C,gBAAgB,CAAC,EAAE,MAAM,EACzB,mBAAmB,CAAC,EAAE,OAAO,EAC7B,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC,CA0ClC;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,gBAAgB,EAAE,MAAM,EACxB,OAAO,EAAE,MAAM,GACd,OAAO,CAAC;IAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;IAAC,UAAU,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAiCxD"}
|
package/dist/services/session.js
CHANGED
|
@@ -22,6 +22,7 @@ import { PathEncoder } from "../utils/pathEncoder.js";
|
|
|
22
22
|
import { JsonlHandler } from "../services/jsonlHandler.js";
|
|
23
23
|
import { extractLatestTotalTokens } from "../utils/tokenCalculation.js";
|
|
24
24
|
import { logger } from "../utils/globalLogger.js";
|
|
25
|
+
import { getMessageContent } from "../utils/messageOperations.js";
|
|
25
26
|
/**
|
|
26
27
|
* Generate a new session ID using Node.js native crypto.randomUUID()
|
|
27
28
|
* @returns UUID string for session identification
|
|
@@ -655,20 +656,7 @@ export async function getFirstMessageContent(sessionId, workdir) {
|
|
|
655
656
|
}
|
|
656
657
|
try {
|
|
657
658
|
const message = JSON.parse(firstLine);
|
|
658
|
-
|
|
659
|
-
const textBlock = message.blocks.find((block) => block.type === "text");
|
|
660
|
-
if (textBlock && "content" in textBlock) {
|
|
661
|
-
return textBlock.content;
|
|
662
|
-
}
|
|
663
|
-
const commandBlock = message.blocks.find((block) => block.type === "bang");
|
|
664
|
-
if (commandBlock && "command" in commandBlock) {
|
|
665
|
-
return commandBlock.command;
|
|
666
|
-
}
|
|
667
|
-
const compressBlock = message.blocks.find((block) => block.type === "compress");
|
|
668
|
-
if (compressBlock && "content" in compressBlock) {
|
|
669
|
-
return compressBlock.content;
|
|
670
|
-
}
|
|
671
|
-
return null;
|
|
659
|
+
return getMessageContent(message) || null;
|
|
672
660
|
}
|
|
673
661
|
catch (error) {
|
|
674
662
|
logger.warn(`Failed to parse first message in session ${sessionId}:`, error);
|
|
@@ -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;AAwCtE;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,UAmbtB,CAAC"}
|
package/dist/tools/bashTool.js
CHANGED
|
@@ -28,19 +28,6 @@ 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
|
-
}
|
|
44
31
|
/**
|
|
45
32
|
* Bash command execution tool - supports both foreground and background execution
|
|
46
33
|
*/
|
|
@@ -104,8 +91,8 @@ Usage notes:
|
|
|
104
91
|
- You can use the \`run_in_background\` parameter to run the command in the background, which allows you to continue working while the command runs. You can monitor the output using the ${READ_TOOL_NAME} tool as it becomes available. You do not need to use '&' at the end of the command when using this parameter.
|
|
105
92
|
- Avoid using ${BASH_TOOL_NAME} with the \`find\`, \`sed\`, \`awk\`, or \`echo\` commands, unless explicitly instructed or when these commands are truly necessary for the task. Instead, always prefer using the dedicated tools for these commands:
|
|
106
93
|
- File search: Use ${GLOB_TOOL_NAME} (NOT find or ls)
|
|
107
|
-
- Content search: Use ${GREP_TOOL_NAME}
|
|
108
|
-
- Read files: Use ${READ_TOOL_NAME}
|
|
94
|
+
- Content search: Use ${GREP_TOOL_NAME} (NOT grep or rg)
|
|
95
|
+
- Read files: Use ${READ_TOOL_NAME} (NOT cat/head/tail)
|
|
109
96
|
- Edit files: Use ${EDIT_TOOL_NAME} (NOT sed/awk)
|
|
110
97
|
- Write files: Use ${WRITE_TOOL_NAME} (NOT echo >/cat <<EOF)
|
|
111
98
|
- Communication: Output text directly (NOT echo/printf)
|
|
@@ -123,7 +110,28 @@ Usage notes:
|
|
|
123
110
|
</bad-example>
|
|
124
111
|
|
|
125
112
|
- Reserve bash tools exclusively for actual system commands and terminal operations that require shell execution. NEVER use bash echo or other command-line tools to communicate thoughts, explanations, or instructions to the user. Output all communication directly in your response text instead.
|
|
126
|
-
- When making multiple bash tool calls, you MUST send a single message with multiple tools calls to run the calls in parallel. For example, if you need to run "git status" and "git diff", send a single message with two tool calls in parallel
|
|
113
|
+
- When making multiple bash tool calls, you MUST send a single message with multiple tools calls to run the calls in parallel. For example, if you need to run "git status" and "git diff", send a single message with two tool calls in parallel.
|
|
114
|
+
|
|
115
|
+
# Git operations
|
|
116
|
+
Git Safety Protocol:
|
|
117
|
+
- NEVER update the git config
|
|
118
|
+
- NEVER run destructive git commands (push --force, reset --hard, checkout ., restore ., clean -f, branch -D) unless the user explicitly requests these actions. Taking unauthorized destructive actions is unhelpful and can result in lost work, so it's best to ONLY run these commands when given direct instructions
|
|
119
|
+
- NEVER skip hooks (--no-verify, --no-gpg-sign, etc) unless the user explicitly requests it
|
|
120
|
+
- NEVER run force push to main/master, warn the user if they request it
|
|
121
|
+
- CRITICAL: Always create NEW commits rather than amending, unless the user explicitly requests a git amend. When a pre-commit hook fails, the commit did NOT happen — so --amend would modify the PREVIOUS commit, which may result in destroying work or losing previous changes. Instead, after hook failure, fix the issue, re-stage, and create a NEW commit
|
|
122
|
+
- When staging files, prefer adding specific files by name rather than using "git add -A" or "git add .", which can accidentally include sensitive files (.env, credentials) or large binaries
|
|
123
|
+
- NEVER commit changes unless the user explicitly asks you to. It is VERY IMPORTANT to only commit when explicitly asked, otherwise the user will feel that you are being too proactive
|
|
124
|
+
- IMPORTANT: Never use git commands with the -i flag (like git rebase -i or git add -i) since they require interactive input which is not supported.
|
|
125
|
+
|
|
126
|
+
Use the gh command via the Bash tool for GitHub-related tasks including working with issues, pull requests, checks, and releases. If given a Github URL use the gh command to get the information needed.
|
|
127
|
+
|
|
128
|
+
# Avoid unnecessary sleep commands
|
|
129
|
+
- Do not sleep between commands that can run immediately — just run them.
|
|
130
|
+
- If your command is long running and you would like to be notified when it finishes — use \`run_in_background\`. No sleep needed.
|
|
131
|
+
- Do not retry failing commands in a sleep loop — diagnose the root cause.
|
|
132
|
+
- If waiting for a background task you started with \`run_in_background\`, you will be notified when it completes — do not poll.
|
|
133
|
+
- If you must poll an external process, use a check command (e.g. \`gh run view\`) rather than sleeping first.
|
|
134
|
+
- If you must sleep, keep the duration short (1-5 seconds) to avoid blocking the user.`,
|
|
127
135
|
execute: async (args, context) => {
|
|
128
136
|
const command = args.command;
|
|
129
137
|
const runInBackground = args.run_in_background;
|
|
@@ -208,7 +216,7 @@ Usage notes:
|
|
|
208
216
|
let isAborted = false;
|
|
209
217
|
let isBackgrounded = false;
|
|
210
218
|
let isFinished = false;
|
|
211
|
-
const updateRealtimeResults =
|
|
219
|
+
const updateRealtimeResults = () => {
|
|
212
220
|
if (isAborted || isBackgrounded || isFinished)
|
|
213
221
|
return;
|
|
214
222
|
const combinedOutput = outputBuffer + (errorBuffer ? "\n" + errorBuffer : "");
|
|
@@ -229,7 +237,7 @@ Usage notes:
|
|
|
229
237
|
"\n\n... (output truncated)";
|
|
230
238
|
context.onResultUpdate(content);
|
|
231
239
|
}
|
|
232
|
-
}
|
|
240
|
+
};
|
|
233
241
|
const foregroundTaskId = `bash_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
234
242
|
// Register as foreground task
|
|
235
243
|
if (context.foregroundTaskManager && command) {
|
|
@@ -306,9 +314,12 @@ Usage notes:
|
|
|
306
314
|
}
|
|
307
315
|
}
|
|
308
316
|
}
|
|
317
|
+
const processedOutput = processOutput(outputBuffer + (errorBuffer ? "\n" + errorBuffer : ""));
|
|
309
318
|
resolve({
|
|
310
319
|
success: false,
|
|
311
|
-
content:
|
|
320
|
+
content: processedOutput
|
|
321
|
+
? `${processedOutput}\n\n${reason}`
|
|
322
|
+
: reason,
|
|
312
323
|
error: reason,
|
|
313
324
|
});
|
|
314
325
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webFetchTool.d.ts","sourceRoot":"","sources":["../../src/tools/webFetchTool.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AA+BtE,eAAO,MAAM,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"webFetchTool.d.ts","sourceRoot":"","sources":["../../src/tools/webFetchTool.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AA+BtE,eAAO,MAAM,YAAY,EAAE,UAiK1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeTool.d.ts","sourceRoot":"","sources":["../../src/tools/writeTool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AAItE;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"writeTool.d.ts","sourceRoot":"","sources":["../../src/tools/writeTool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AAItE;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,UAiNvB,CAAC"}
|
package/dist/tools/writeTool.js
CHANGED
|
@@ -117,6 +117,12 @@ Usage:
|
|
|
117
117
|
// Record snapshot for reversion
|
|
118
118
|
let snapshotId;
|
|
119
119
|
if (context.reversionManager && context.messageId) {
|
|
120
|
+
// Log memory usage before large operations if in debug mode
|
|
121
|
+
if (process.env.LOG_LEVEL === "DEBUG") {
|
|
122
|
+
const usage = process.memoryUsage();
|
|
123
|
+
logger.debug(`[Memory Before Write] RSS: ${Math.round(usage.rss / 1024 / 1024)}MB, ` +
|
|
124
|
+
`Heap: ${Math.round(usage.heapUsed / 1024 / 1024)}/${Math.round(usage.heapTotal / 1024 / 1024)}MB`, { filePath, contentLength: content.length });
|
|
125
|
+
}
|
|
120
126
|
snapshotId = await context.reversionManager.recordSnapshot(context.messageId, resolvedPath, isExistingFile ? "modify" : "create");
|
|
121
127
|
}
|
|
122
128
|
// Write file
|
package/dist/types/core.d.ts
CHANGED
|
@@ -77,6 +77,8 @@ export declare class ConfigurationError extends Error {
|
|
|
77
77
|
}
|
|
78
78
|
export declare const CONFIG_ERRORS: {
|
|
79
79
|
readonly MISSING_BASE_URL: "Gateway configuration requires baseURL. Provide via constructor or WAVE_BASE_URL environment variable.";
|
|
80
|
+
readonly MISSING_MODEL: "Agent configuration requires model. Provide via constructor or WAVE_MODEL environment variable.";
|
|
81
|
+
readonly MISSING_FAST_MODEL: "Agent configuration requires fastModel. Provide via constructor or WAVE_FAST_MODEL environment variable.";
|
|
80
82
|
readonly INVALID_WAVE_MAX_INPUT_TOKENS: "Token limit must be a positive integer.";
|
|
81
83
|
readonly EMPTY_BASE_URL: "Base URL cannot be empty string.";
|
|
82
84
|
};
|
package/dist/types/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/types/core.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACpC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACnC,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACnC,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;CACrC;AAED;;;GAGG;AACH,MAAM,WAAW,KAAK;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IAGtC,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,cAAc,CAAC,EAAE;QACf,yBAAyB,EAAE,MAAM,CAAC;QAClC,yBAAyB,EAAE,MAAM,CAAC;KACnC,CAAC;CACH;AAED;;;GAGG;AACH,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ANGED
|
@@ -13,6 +13,8 @@ export class ConfigurationError extends Error {
|
|
|
13
13
|
// Standard error messages
|
|
14
14
|
export const CONFIG_ERRORS = {
|
|
15
15
|
MISSING_BASE_URL: "Gateway configuration requires baseURL. Provide via constructor or WAVE_BASE_URL environment variable.",
|
|
16
|
+
MISSING_MODEL: "Agent configuration requires model. Provide via constructor or WAVE_MODEL environment variable.",
|
|
17
|
+
MISSING_FAST_MODEL: "Agent configuration requires fastModel. Provide via constructor or WAVE_FAST_MODEL environment variable.",
|
|
16
18
|
INVALID_WAVE_MAX_INPUT_TOKENS: "Token limit must be a positive integer.",
|
|
17
19
|
EMPTY_BASE_URL: "Base URL cannot be empty string.",
|
|
18
20
|
};
|
|
@@ -42,6 +42,10 @@ export declare const TOOL_RULES: Record<string, ToolRule>;
|
|
|
42
42
|
* Registry of dangerous subcommands for specific tools.
|
|
43
43
|
*/
|
|
44
44
|
export declare const DANGEROUS_SUBCOMMANDS: Record<string, string[]>;
|
|
45
|
+
/**
|
|
46
|
+
* Checks if a find command is dangerous (e.g., contains -exec, -delete, etc.).
|
|
47
|
+
*/
|
|
48
|
+
export declare function isDangerousFind(command: string): boolean;
|
|
45
49
|
/**
|
|
46
50
|
* Extracts a "smart prefix" from a bash command based on common developer tools.
|
|
47
51
|
* Returns null if the command is blacklisted or cannot be safely prefix-matched.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bashParser.d.ts","sourceRoot":"","sources":["../../src/utils/bashParser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAoH1D;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CA2CpD;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAuHzD;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MA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G;AACH,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAoD/C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAQ1D,CAAC;AA2DF;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAmBxD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA2J7D"}
|
package/dist/utils/bashParser.js
CHANGED
|
@@ -544,6 +544,29 @@ function shouldStopAtArg(arg) {
|
|
|
544
544
|
return true;
|
|
545
545
|
return false;
|
|
546
546
|
}
|
|
547
|
+
/**
|
|
548
|
+
* Checks if a find command is dangerous (e.g., contains -exec, -delete, etc.).
|
|
549
|
+
*/
|
|
550
|
+
export function isDangerousFind(command) {
|
|
551
|
+
const stripped = stripRedirections(stripEnvVars(command));
|
|
552
|
+
const tokens = stripped.match(/(?:[^\s"']+|"[^"]*"|'[^']*')+/g) || [];
|
|
553
|
+
if (tokens.length === 0 || tokens[0] !== "find")
|
|
554
|
+
return false;
|
|
555
|
+
const dangerousFlags = [
|
|
556
|
+
"-exec",
|
|
557
|
+
"-execdir",
|
|
558
|
+
"-ok",
|
|
559
|
+
"-okdir",
|
|
560
|
+
"-delete",
|
|
561
|
+
"-fprint",
|
|
562
|
+
"-fprint0",
|
|
563
|
+
"-fprintf",
|
|
564
|
+
];
|
|
565
|
+
return tokens.some((token) => {
|
|
566
|
+
const unquoted = token.replace(/^(['"])(.*)\1$/, "$2");
|
|
567
|
+
return dangerousFlags.includes(unquoted);
|
|
568
|
+
});
|
|
569
|
+
}
|
|
547
570
|
/**
|
|
548
571
|
* Extracts a "smart prefix" from a bash command based on common developer tools.
|
|
549
572
|
* Returns null if the command is blacklisted or cannot be safely prefix-matched.
|
|
@@ -121,8 +121,18 @@ export declare function countToolBlocks(messages: Message[]): number;
|
|
|
121
121
|
* Used for hook error handling when the user prompt needs to be erased
|
|
122
122
|
*/
|
|
123
123
|
export declare const removeLastUserMessage: (messages: Message[]) => Message[];
|
|
124
|
+
/**
|
|
125
|
+
* Efficiently clone a message for UI freezing.
|
|
126
|
+
* Clones the message object and its blocks array, but reuses string references.
|
|
127
|
+
*/
|
|
128
|
+
export declare function cloneMessage(message: Message): Message;
|
|
124
129
|
/**
|
|
125
130
|
* Helper to format tool and token summary
|
|
126
131
|
*/
|
|
127
132
|
export declare function formatToolTokenSummary(toolCount: number, tokens: number): string;
|
|
133
|
+
/**
|
|
134
|
+
* Extracts displayable text from a Message object, handling various block types.
|
|
135
|
+
* Returns the first available content block.
|
|
136
|
+
*/
|
|
137
|
+
export declare function getMessageContent(message: Message): string;
|
|
128
138
|
//# sourceMappingURL=messageOperations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageOperations.d.ts","sourceRoot":"","sources":["../../src/utils/messageOperations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAa,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD,OAAO,EAAE,qCAAqC,EAAE,MAAM,qBAAqB,CAAC;AAI5E,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnD,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAGD,MAAM,WAAW,oBAAqB,SAAQ,iBAAiB;IAC7D,QAAQ,EAAE,OAAO,EAAE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AM,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,CAyB1D"}
|
|
@@ -435,6 +435,33 @@ export const removeLastUserMessage = (messages) => {
|
|
|
435
435
|
}
|
|
436
436
|
return newMessages;
|
|
437
437
|
};
|
|
438
|
+
/**
|
|
439
|
+
* Efficiently clone a message for UI freezing.
|
|
440
|
+
* Clones the message object and its blocks array, but reuses string references.
|
|
441
|
+
*/
|
|
442
|
+
export function cloneMessage(message) {
|
|
443
|
+
return {
|
|
444
|
+
...message,
|
|
445
|
+
blocks: message.blocks.map((block) => {
|
|
446
|
+
const clonedBlock = { ...block };
|
|
447
|
+
// Deep clone arrays/objects within blocks if they exist
|
|
448
|
+
if (clonedBlock.type === "tool" && clonedBlock.images) {
|
|
449
|
+
clonedBlock.images = clonedBlock.images.map((img) => ({ ...img }));
|
|
450
|
+
}
|
|
451
|
+
else if (clonedBlock.type === "image" && clonedBlock.imageUrls) {
|
|
452
|
+
clonedBlock.imageUrls = [...clonedBlock.imageUrls];
|
|
453
|
+
}
|
|
454
|
+
else if (clonedBlock.type === "file_history" && clonedBlock.snapshots) {
|
|
455
|
+
clonedBlock.snapshots = clonedBlock.snapshots.map((s) => ({ ...s }));
|
|
456
|
+
}
|
|
457
|
+
return clonedBlock;
|
|
458
|
+
}),
|
|
459
|
+
// Clone additionalFields if it exists
|
|
460
|
+
...(message.additionalFields
|
|
461
|
+
? { additionalFields: { ...message.additionalFields } }
|
|
462
|
+
: {}),
|
|
463
|
+
};
|
|
464
|
+
}
|
|
438
465
|
/**
|
|
439
466
|
* Helper to format tool and token summary
|
|
440
467
|
*/
|
|
@@ -449,3 +476,27 @@ export function formatToolTokenSummary(toolCount, tokens) {
|
|
|
449
476
|
summary += ")";
|
|
450
477
|
return summary;
|
|
451
478
|
}
|
|
479
|
+
/**
|
|
480
|
+
* Extracts displayable text from a Message object, handling various block types.
|
|
481
|
+
* Returns the first available content block.
|
|
482
|
+
*/
|
|
483
|
+
export function getMessageContent(message) {
|
|
484
|
+
// Find first available content block
|
|
485
|
+
const textBlock = message.blocks.find((block) => block.type === "text");
|
|
486
|
+
if (textBlock && "content" in textBlock) {
|
|
487
|
+
return textBlock.content;
|
|
488
|
+
}
|
|
489
|
+
const slashBlock = message.blocks.find((block) => block.type === "slash");
|
|
490
|
+
if (slashBlock && "command" in slashBlock) {
|
|
491
|
+
return `/${slashBlock.command}${slashBlock.args ? ` ${slashBlock.args}` : ""}`;
|
|
492
|
+
}
|
|
493
|
+
const bangBlock = message.blocks.find((block) => block.type === "bang");
|
|
494
|
+
if (bangBlock && "command" in bangBlock) {
|
|
495
|
+
return `!${bangBlock.command}`;
|
|
496
|
+
}
|
|
497
|
+
const compressBlock = message.blocks.find((block) => block.type === "compress");
|
|
498
|
+
if (compressBlock && "content" in compressBlock) {
|
|
499
|
+
return compressBlock.content;
|
|
500
|
+
}
|
|
501
|
+
return "";
|
|
502
|
+
}
|
|
@@ -23,4 +23,8 @@ export declare const stripAnsiColors: (text: string) => string;
|
|
|
23
23
|
* @returns Formatted line number prefix
|
|
24
24
|
*/
|
|
25
25
|
export declare function formatLineNumberPrefix(lineNumber: number): string;
|
|
26
|
+
/**
|
|
27
|
+
* Efficiently get the last N lines of a string without splitting the whole string.
|
|
28
|
+
*/
|
|
29
|
+
export declare function getLastLines(text: string, count: number): string;
|
|
26
30
|
//# sourceMappingURL=stringUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stringUtils.d.ts","sourceRoot":"","sources":["../../src/utils/stringUtils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAgC/D;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,aAAa,EAAE,MAAM,GACpB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAwBxB;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,KAAG,MAK9C,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEjE"}
|
|
1
|
+
{"version":3,"file":"stringUtils.d.ts","sourceRoot":"","sources":["../../src/utils/stringUtils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAgC/D;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,aAAa,EAAE,MAAM,GACpB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAwBxB;AAED;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,MAAM,MAAM,KAAG,MAK9C,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEjE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAehE"}
|
|
@@ -77,3 +77,24 @@ export const stripAnsiColors = (text) => {
|
|
|
77
77
|
export function formatLineNumberPrefix(lineNumber) {
|
|
78
78
|
return `${lineNumber.toString().padStart(6)}\t`;
|
|
79
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Efficiently get the last N lines of a string without splitting the whole string.
|
|
82
|
+
*/
|
|
83
|
+
export function getLastLines(text, count) {
|
|
84
|
+
if (!text || count <= 0)
|
|
85
|
+
return "";
|
|
86
|
+
let pos = text.length;
|
|
87
|
+
let found = 0;
|
|
88
|
+
while (pos > 0 && found < count) {
|
|
89
|
+
const nextNewline = text.lastIndexOf("\n", pos - 1);
|
|
90
|
+
if (nextNewline === -1) {
|
|
91
|
+
pos = 0;
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
pos = nextNewline;
|
|
96
|
+
found++;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return text.substring(pos === 0 && found < count ? 0 : pos + 1);
|
|
100
|
+
}
|
package/package.json
CHANGED
package/src/agent.ts
CHANGED
|
@@ -425,9 +425,10 @@ export class Agent {
|
|
|
425
425
|
this.aiManager.abortAIMessage();
|
|
426
426
|
}
|
|
427
427
|
|
|
428
|
-
/** Execute bash command */
|
|
429
|
-
public async
|
|
428
|
+
/** Execute bash command (bang command) */
|
|
429
|
+
public async bang(command: string): Promise<void> {
|
|
430
430
|
await this.bangManager?.executeCommand(command);
|
|
431
|
+
await this.messageManager.saveSession();
|
|
431
432
|
}
|
|
432
433
|
|
|
433
434
|
public async clearMessages(): Promise<void> {
|
|
@@ -531,12 +531,6 @@ export class AIManager {
|
|
|
531
531
|
);
|
|
532
532
|
}
|
|
533
533
|
}
|
|
534
|
-
if (
|
|
535
|
-
result.response_headers &&
|
|
536
|
-
Object.keys(result.response_headers).length > 0
|
|
537
|
-
) {
|
|
538
|
-
logger?.debug("AI response headers:", result.response_headers);
|
|
539
|
-
}
|
|
540
534
|
|
|
541
535
|
if (
|
|
542
536
|
result.additionalFields &&
|
|
@@ -86,7 +86,7 @@ export class BackgroundTaskManager {
|
|
|
86
86
|
logStream.end();
|
|
87
87
|
if (child.pid) {
|
|
88
88
|
process.kill(-child.pid, "SIGTERM");
|
|
89
|
-
setTimeout(() => {
|
|
89
|
+
const forceKillTimer = setTimeout(() => {
|
|
90
90
|
if (child.pid && !child.killed) {
|
|
91
91
|
try {
|
|
92
92
|
process.kill(-child.pid, "SIGKILL");
|
|
@@ -95,6 +95,7 @@ export class BackgroundTaskManager {
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
}, 1000);
|
|
98
|
+
forceKillTimer.unref();
|
|
98
99
|
} else {
|
|
99
100
|
child.kill("SIGTERM");
|
|
100
101
|
}
|
|
@@ -112,6 +113,11 @@ export class BackgroundTaskManager {
|
|
|
112
113
|
if (timeout && timeout > 0) {
|
|
113
114
|
timeoutHandle = setTimeout(() => {
|
|
114
115
|
if (shell.status === "running") {
|
|
116
|
+
const timeoutMsg = "\n\nCommand timed out";
|
|
117
|
+
shell.stderr += timeoutMsg;
|
|
118
|
+
if (logStream.writable) {
|
|
119
|
+
logStream.write(timeoutMsg);
|
|
120
|
+
}
|
|
115
121
|
this.stopTask(id);
|
|
116
122
|
}
|
|
117
123
|
}, timeout);
|
|
@@ -223,7 +229,7 @@ export class BackgroundTaskManager {
|
|
|
223
229
|
logStream.end();
|
|
224
230
|
if (child.pid) {
|
|
225
231
|
process.kill(-child.pid, "SIGTERM");
|
|
226
|
-
setTimeout(() => {
|
|
232
|
+
const forceKillTimer = setTimeout(() => {
|
|
227
233
|
if (child.pid && !child.killed) {
|
|
228
234
|
try {
|
|
229
235
|
process.kill(-child.pid, "SIGKILL");
|
|
@@ -232,6 +238,7 @@ export class BackgroundTaskManager {
|
|
|
232
238
|
}
|
|
233
239
|
}
|
|
234
240
|
}, 1000);
|
|
241
|
+
forceKillTimer.unref();
|
|
235
242
|
} else {
|
|
236
243
|
child.kill("SIGTERM");
|
|
237
244
|
}
|