snow-ai 0.5.13 → 0.5.14
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/bundle/cli.mjs +57 -2
- package/bundle/package.json +1 -1
- package/package.json +1 -1
package/bundle/cli.mjs
CHANGED
|
@@ -353011,10 +353011,11 @@ var init_bash = __esm({
|
|
|
353011
353011
|
* Execute a terminal command in the working directory
|
|
353012
353012
|
* @param command - The command to execute (e.g., "npm -v", "git status")
|
|
353013
353013
|
* @param timeout - Timeout in milliseconds (default: 30000ms = 30s)
|
|
353014
|
+
* @param abortSignal - Optional AbortSignal to cancel command execution (e.g., ESC key)
|
|
353014
353015
|
* @returns Execution result including stdout, stderr, and exit code
|
|
353015
353016
|
* @throws Error if command execution fails critically
|
|
353016
353017
|
*/
|
|
353017
|
-
async executeCommand(command, timeout2 = 3e4) {
|
|
353018
|
+
async executeCommand(command, timeout2 = 3e4, abortSignal) {
|
|
353018
353019
|
const executedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
353019
353020
|
try {
|
|
353020
353021
|
if (isDangerousCommand(command)) {
|
|
@@ -353033,6 +353034,24 @@ var init_bash = __esm({
|
|
|
353033
353034
|
}
|
|
353034
353035
|
});
|
|
353035
353036
|
processManager.register(childProcess2);
|
|
353037
|
+
let abortHandler;
|
|
353038
|
+
if (abortSignal) {
|
|
353039
|
+
abortHandler = () => {
|
|
353040
|
+
if (childProcess2.pid && !childProcess2.killed) {
|
|
353041
|
+
try {
|
|
353042
|
+
if (process.platform === "win32") {
|
|
353043
|
+
exec4(`taskkill /PID ${childProcess2.pid} /T /F 2>NUL`, {
|
|
353044
|
+
windowsHide: true
|
|
353045
|
+
});
|
|
353046
|
+
} else {
|
|
353047
|
+
childProcess2.kill("SIGTERM");
|
|
353048
|
+
}
|
|
353049
|
+
} catch {
|
|
353050
|
+
}
|
|
353051
|
+
}
|
|
353052
|
+
};
|
|
353053
|
+
abortSignal.addEventListener("abort", abortHandler);
|
|
353054
|
+
}
|
|
353036
353055
|
const { stdout, stderr } = await new Promise((resolve10, reject2) => {
|
|
353037
353056
|
var _a21, _b14;
|
|
353038
353057
|
let stdoutData = "";
|
|
@@ -353045,6 +353064,9 @@ var init_bash = __esm({
|
|
|
353045
353064
|
});
|
|
353046
353065
|
childProcess2.on("error", reject2);
|
|
353047
353066
|
childProcess2.on("close", (code2, signal) => {
|
|
353067
|
+
if (abortHandler && abortSignal) {
|
|
353068
|
+
abortSignal.removeEventListener("abort", abortHandler);
|
|
353069
|
+
}
|
|
353048
353070
|
if (signal) {
|
|
353049
353071
|
const error = new Error(`Process killed by signal ${signal}`);
|
|
353050
353072
|
error.code = code2 || 1;
|
|
@@ -353074,6 +353096,16 @@ var init_bash = __esm({
|
|
|
353074
353096
|
if (error.code === "ETIMEDOUT") {
|
|
353075
353097
|
throw new Error(`Command timed out after ${timeout2}ms: ${command}`);
|
|
353076
353098
|
}
|
|
353099
|
+
if (abortSignal == null ? void 0 : abortSignal.aborted) {
|
|
353100
|
+
return {
|
|
353101
|
+
stdout: truncateOutput(error.stdout || "", this.maxOutputLength),
|
|
353102
|
+
stderr: truncateOutput(error.stderr || "Command execution interrupted by user (ESC key pressed)", this.maxOutputLength),
|
|
353103
|
+
exitCode: 130,
|
|
353104
|
+
// Standard exit code for SIGINT/user interrupt
|
|
353105
|
+
command,
|
|
353106
|
+
executedAt
|
|
353107
|
+
};
|
|
353108
|
+
}
|
|
353077
353109
|
return {
|
|
353078
353110
|
stdout: truncateOutput(error.stdout || "", this.maxOutputLength),
|
|
353079
353111
|
stderr: truncateOutput(error.stderr || error.message || "", this.maxOutputLength),
|
|
@@ -439049,7 +439081,7 @@ AI Tip: Provide searchContent (string) and replaceContent (string).`);
|
|
|
439049
439081
|
timeout: args2.timeout || 3e4
|
|
439050
439082
|
});
|
|
439051
439083
|
try {
|
|
439052
|
-
result2 = await terminalService2.executeCommand(args2.command, args2.timeout);
|
|
439084
|
+
result2 = await terminalService2.executeCommand(args2.command, args2.timeout, abortSignal);
|
|
439053
439085
|
} finally {
|
|
439054
439086
|
setTerminalExecutionState2({
|
|
439055
439087
|
isExecuting: false,
|
|
@@ -527772,6 +527804,23 @@ function extractMultimodalContent(result2) {
|
|
|
527772
527804
|
async function executeToolCall(toolCall, abortSignal, onTokenUpdate, onSubAgentMessage, requestToolConfirmation, isToolAutoApproved, yoloMode, addToAlwaysApproved, onUserInteractionNeeded) {
|
|
527773
527805
|
let result2;
|
|
527774
527806
|
let executionError = null;
|
|
527807
|
+
let escKeyListener;
|
|
527808
|
+
let abortController;
|
|
527809
|
+
if (toolCall.function.name === "terminal-execute" && !abortSignal) {
|
|
527810
|
+
abortController = new AbortController();
|
|
527811
|
+
abortSignal = abortController.signal;
|
|
527812
|
+
escKeyListener = (data) => {
|
|
527813
|
+
const str2 = data.toString();
|
|
527814
|
+
if (str2 === "\x1B" && abortController && !(abortSignal == null ? void 0 : abortSignal.aborted)) {
|
|
527815
|
+
console.log("\n[ESC] Interrupting command execution...");
|
|
527816
|
+
abortController.abort();
|
|
527817
|
+
}
|
|
527818
|
+
};
|
|
527819
|
+
if (process.stdin.isTTY && process.stdin.setRawMode) {
|
|
527820
|
+
process.stdin.setRawMode(true);
|
|
527821
|
+
process.stdin.on("data", escKeyListener);
|
|
527822
|
+
}
|
|
527823
|
+
}
|
|
527775
527824
|
try {
|
|
527776
527825
|
const args2 = JSON.parse(toolCall.function.arguments);
|
|
527777
527826
|
try {
|
|
@@ -527919,6 +527968,12 @@ ${combinedOutput}`;
|
|
|
527919
527968
|
console.warn("Failed to execute afterToolCall hook:", error);
|
|
527920
527969
|
}
|
|
527921
527970
|
}
|
|
527971
|
+
if (escKeyListener) {
|
|
527972
|
+
if (process.stdin.isTTY && process.stdin.setRawMode) {
|
|
527973
|
+
process.stdin.setRawMode(false);
|
|
527974
|
+
process.stdin.off("data", escKeyListener);
|
|
527975
|
+
}
|
|
527976
|
+
}
|
|
527922
527977
|
return result2;
|
|
527923
527978
|
}
|
|
527924
527979
|
function getToolResourceType(toolName) {
|
package/bundle/package.json
CHANGED