snow-ai 0.6.36 → 0.6.37
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 +77 -2
- package/bundle/package.json +1 -1
- package/package.json +1 -1
package/bundle/cli.mjs
CHANGED
|
@@ -48079,7 +48079,8 @@ function getSystemPrompt() {
|
|
|
48079
48079
|
const codeSearchSection = getCodeSearchSection(hasCodebase);
|
|
48080
48080
|
const platformCommandsSection = getPlatformCommandsSection();
|
|
48081
48081
|
const timeInfo = getCurrentTimeInfo();
|
|
48082
|
-
const
|
|
48082
|
+
const cliPid = String(process.pid);
|
|
48083
|
+
const finalPrompt = basePrompt.replace("PLACEHOLDER_FOR_WORKFLOW_SECTION", workflowSection).replace("PLACEHOLDER_FOR_CODE_SEARCH_SECTION", codeSearchSection).replace("PLACEHOLDER_FOR_PLATFORM_COMMANDS_SECTION", platformCommandsSection).replace(/PLACEHOLDER_FOR_CLI_PID/g, cliPid);
|
|
48083
48084
|
return appendSystemContext(finalPrompt, systemEnv, timeInfo);
|
|
48084
48085
|
}
|
|
48085
48086
|
function getSystemPromptForMode(planMode, vulnerabilityHuntingMode) {
|
|
@@ -48215,6 +48216,17 @@ and other shell features. Your capabilities include text processing, data filter
|
|
|
48215
48216
|
manipulation, workflow automation, and complex command chaining to solve sophisticated
|
|
48216
48217
|
system administration and data processing challenges.
|
|
48217
48218
|
|
|
48219
|
+
**\u26A0 CRITICAL - SELF-PROTECTION (Node.js Process Safety):**
|
|
48220
|
+
This CLI runs as a Node.js process (PID: PLACEHOLDER_FOR_CLI_PID). You MUST NEVER execute commands that kill Node.js processes by name, as doing so will terminate the CLI itself and crash the session. Blocked patterns include:
|
|
48221
|
+
- PowerShell: \`Stop-Process -Name node*\`, \`Get-Process *node* | Stop-Process\`, or any pipeline that filters node processes then pipes to \`Stop-Process\`
|
|
48222
|
+
- CMD: \`taskkill /IM node.exe\`, \`taskkill /F /IM node.exe\`
|
|
48223
|
+
- Unix: \`killall node\`, \`pkill node\`, \`pkill -f node\`
|
|
48224
|
+
If the user needs to kill specific Node.js processes (e.g. dev servers), you MUST:
|
|
48225
|
+
1. First list processes to identify the specific PIDs: \`Get-Process node\` or \`ps aux | grep node\`
|
|
48226
|
+
2. Then kill by specific PID while excluding PID PLACEHOLDER_FOR_CLI_PID: e.g. \`Stop-Process -Id <target_pid>\` or \`kill <target_pid>\`
|
|
48227
|
+
3. Or use an exclusion filter: \`Get-Process node | Where-Object { $_.Id -ne PLACEHOLDER_FOR_CLI_PID } | Stop-Process\`
|
|
48228
|
+
Never use broad process-name-based kill commands that would match all Node.js processes.
|
|
48229
|
+
|
|
48218
48230
|
**Sub-Agent & Skills - Important Distinction:**
|
|
48219
48231
|
|
|
48220
48232
|
**CRITICAL: Sub-Agents and Skills are COMPLETELY DIFFERENT - DO NOT confuse them!**
|
|
@@ -48259,7 +48271,7 @@ PLACEHOLDER_FOR_PLATFORM_COMMANDS_SECTION
|
|
|
48259
48271
|
- This file may not exist. If you can't find it, please ignore it.
|
|
48260
48272
|
|
|
48261
48273
|
Remember: **ACTION > ANALYSIS**. Write code first, investigate only when blocked.
|
|
48262
|
-
You
|
|
48274
|
+
You are running as a Node.js process (PID: PLACEHOLDER_FOR_CLI_PID). If a user requests killing Node.js processes, you MUST warn them that this would also terminate the CLI, list processes with their PIDs first, and help them selectively kill only the intended targets while excluding PID PLACEHOLDER_FOR_CLI_PID.`;
|
|
48263
48275
|
}
|
|
48264
48276
|
});
|
|
48265
48277
|
|
|
@@ -363844,6 +363856,51 @@ ${formattedDiagnostics}`;
|
|
|
363844
363856
|
function isDangerousCommand(command) {
|
|
363845
363857
|
return DANGEROUS_PATTERNS.some((pattern) => pattern.test(command));
|
|
363846
363858
|
}
|
|
363859
|
+
function isSelfDestructiveCommand(command) {
|
|
363860
|
+
const lower = command.toLowerCase();
|
|
363861
|
+
const cliPid = process.pid;
|
|
363862
|
+
if (lower.includes("stop-process") && /\bnode\b/i.test(command)) {
|
|
363863
|
+
return {
|
|
363864
|
+
isSelfDestructive: true,
|
|
363865
|
+
reason: "Command would terminate Node.js processes, including this CLI itself",
|
|
363866
|
+
suggestion: `This CLI is running as Node.js (PID: ${cliPid}). Add a PID exclusion filter, e.g.: Where-Object { ... -and $_.Id -ne ${cliPid} }`
|
|
363867
|
+
};
|
|
363868
|
+
}
|
|
363869
|
+
if (/\btaskkill\b/i.test(command) && /\bnode(\.exe)?\b/i.test(command)) {
|
|
363870
|
+
return {
|
|
363871
|
+
isSelfDestructive: true,
|
|
363872
|
+
reason: "Command would terminate node.exe processes, including this CLI itself",
|
|
363873
|
+
suggestion: `This CLI is running as node.exe (PID: ${cliPid}). Use "taskkill /PID <target_pid>" for specific processes, excluding PID ${cliPid}.`
|
|
363874
|
+
};
|
|
363875
|
+
}
|
|
363876
|
+
if (/\bkillall\s+(-\w+\s+)*node\b/i.test(command)) {
|
|
363877
|
+
return {
|
|
363878
|
+
isSelfDestructive: true,
|
|
363879
|
+
reason: "killall node would terminate ALL Node.js processes, including this CLI",
|
|
363880
|
+
suggestion: `Use "kill <specific_pid>" to target individual processes, excluding PID ${cliPid}.`
|
|
363881
|
+
};
|
|
363882
|
+
}
|
|
363883
|
+
if (/\bpkill\s+(-\w+\s+)*node\b/i.test(command)) {
|
|
363884
|
+
return {
|
|
363885
|
+
isSelfDestructive: true,
|
|
363886
|
+
reason: "pkill node would terminate Node.js processes, including this CLI",
|
|
363887
|
+
suggestion: `Use "kill <specific_pid>" to target individual processes, excluding PID ${cliPid}.`
|
|
363888
|
+
};
|
|
363889
|
+
}
|
|
363890
|
+
const pidPatterns = [
|
|
363891
|
+
new RegExp(`\\bkill\\s+(-\\d+\\s+)*${cliPid}\\b`),
|
|
363892
|
+
new RegExp(`\\bStop-Process\\s+.*-Id\\s+${cliPid}\\b`, "i"),
|
|
363893
|
+
new RegExp(`\\btaskkill\\b.*\\/PID\\s+${cliPid}\\b`, "i")
|
|
363894
|
+
];
|
|
363895
|
+
if (pidPatterns.some((p) => p.test(command))) {
|
|
363896
|
+
return {
|
|
363897
|
+
isSelfDestructive: true,
|
|
363898
|
+
reason: `Command directly targets this CLI process (PID: ${cliPid})`,
|
|
363899
|
+
suggestion: `PID ${cliPid} is the Snow CLI process. Killing it will terminate the current session.`
|
|
363900
|
+
};
|
|
363901
|
+
}
|
|
363902
|
+
return { isSelfDestructive: false };
|
|
363903
|
+
}
|
|
363847
363904
|
function truncateOutput(output2, maxLength) {
|
|
363848
363905
|
if (!output2)
|
|
363849
363906
|
return "";
|
|
@@ -364255,6 +364312,10 @@ var init_bash = __esm({
|
|
|
364255
364312
|
if (isDangerousCommand(command)) {
|
|
364256
364313
|
throw new Error(`Dangerous command detected and blocked: ${command.slice(0, 50)}`);
|
|
364257
364314
|
}
|
|
364315
|
+
const selfDestruct = isSelfDestructiveCommand(command);
|
|
364316
|
+
if (selfDestruct.isSelfDestructive) {
|
|
364317
|
+
throw new Error(`[SELF-PROTECTION] Command blocked: ${selfDestruct.reason}. ${selfDestruct.suggestion}`);
|
|
364318
|
+
}
|
|
364258
364319
|
if (this.isSSHPath(this.workingDirectory)) {
|
|
364259
364320
|
const parsed = parseSSHUrl(this.workingDirectory);
|
|
364260
364321
|
if (!parsed) {
|
|
@@ -556532,6 +556593,19 @@ function useBashMode() {
|
|
|
556532
556593
|
return isSensitiveCommand(command);
|
|
556533
556594
|
}, []);
|
|
556534
556595
|
const executeCommand2 = (0, import_react96.useCallback)(async (command, timeout2 = 3e4) => {
|
|
556596
|
+
const selfDestruct = isSelfDestructiveCommand(command);
|
|
556597
|
+
if (selfDestruct.isSelfDestructive) {
|
|
556598
|
+
setState((prev) => ({ ...prev, isExecuting: false }));
|
|
556599
|
+
return {
|
|
556600
|
+
success: false,
|
|
556601
|
+
stdout: "",
|
|
556602
|
+
stderr: `[SELF-PROTECTION] ${selfDestruct.reason}
|
|
556603
|
+
${selfDestruct.suggestion}`,
|
|
556604
|
+
command,
|
|
556605
|
+
exitCode: 1,
|
|
556606
|
+
signal: null
|
|
556607
|
+
};
|
|
556608
|
+
}
|
|
556535
556609
|
setState((prev) => ({
|
|
556536
556610
|
...prev,
|
|
556537
556611
|
isExecuting: true,
|
|
@@ -556879,6 +556953,7 @@ var init_useBashMode = __esm({
|
|
|
556879
556953
|
"use strict";
|
|
556880
556954
|
import_react96 = __toESM(require_react(), 1);
|
|
556881
556955
|
init_sensitiveCommandManager();
|
|
556956
|
+
init_security_utils();
|
|
556882
556957
|
}
|
|
556883
556958
|
});
|
|
556884
556959
|
|
package/bundle/package.json
CHANGED