snow-ai 0.6.36 → 0.6.38
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 +304 -108
- 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
|
|
|
@@ -71292,7 +71304,7 @@ var init_version = __esm({
|
|
|
71292
71304
|
// dist/api/chat.js
|
|
71293
71305
|
function convertToOpenAIMessages(messages, includeBuiltinSystemPrompt = true, customSystemPromptOverride, planMode = false, vulnerabilityHuntingMode = false) {
|
|
71294
71306
|
var _a21;
|
|
71295
|
-
const
|
|
71307
|
+
const customSystemPrompts = customSystemPromptOverride;
|
|
71296
71308
|
let result2 = messages.map((msg) => {
|
|
71297
71309
|
if (msg.role === "user" && msg.images && msg.images.length > 0) {
|
|
71298
71310
|
const contentParts = [];
|
|
@@ -71371,12 +71383,15 @@ function convertToOpenAIMessages(messages, includeBuiltinSystemPrompt = true, cu
|
|
|
71371
71383
|
if (result2.length > 0 && ((_a21 = result2[0]) == null ? void 0 : _a21.role) === "system") {
|
|
71372
71384
|
return result2;
|
|
71373
71385
|
}
|
|
71374
|
-
if (
|
|
71386
|
+
if (customSystemPrompts && customSystemPrompts.length > 0) {
|
|
71375
71387
|
if (includeBuiltinSystemPrompt) {
|
|
71376
71388
|
result2 = [
|
|
71377
71389
|
{
|
|
71378
71390
|
role: "system",
|
|
71379
|
-
content:
|
|
71391
|
+
content: customSystemPrompts.map((text3) => ({
|
|
71392
|
+
type: "text",
|
|
71393
|
+
text: text3
|
|
71394
|
+
}))
|
|
71380
71395
|
},
|
|
71381
71396
|
{
|
|
71382
71397
|
role: "user",
|
|
@@ -71388,7 +71403,10 @@ function convertToOpenAIMessages(messages, includeBuiltinSystemPrompt = true, cu
|
|
|
71388
71403
|
result2 = [
|
|
71389
71404
|
{
|
|
71390
71405
|
role: "system",
|
|
71391
|
-
content:
|
|
71406
|
+
content: customSystemPrompts.map((text3) => ({
|
|
71407
|
+
type: "text",
|
|
71408
|
+
text: text3
|
|
71409
|
+
}))
|
|
71392
71410
|
},
|
|
71393
71411
|
...result2
|
|
71394
71412
|
];
|
|
@@ -71479,8 +71497,8 @@ async function* createStreamingChatCompletion(options3, abortSignal, onRetry) {
|
|
|
71479
71497
|
const { getSystemPromptConfig: getSystemPromptConfig2 } = await Promise.resolve().then(() => (init_apiConfig(), apiConfig_exports));
|
|
71480
71498
|
const systemPromptConfig = getSystemPromptConfig2();
|
|
71481
71499
|
const customPrompt = systemPromptConfig == null ? void 0 : systemPromptConfig.prompts.find((p) => p.id === options3.customSystemPromptId);
|
|
71482
|
-
if (customPrompt) {
|
|
71483
|
-
customSystemPromptContent = customPrompt.content;
|
|
71500
|
+
if (customPrompt == null ? void 0 : customPrompt.content) {
|
|
71501
|
+
customSystemPromptContent = [customPrompt.content];
|
|
71484
71502
|
}
|
|
71485
71503
|
}
|
|
71486
71504
|
customSystemPromptContent || (customSystemPromptContent = getCustomSystemPromptForConfig(config3));
|
|
@@ -71723,7 +71741,7 @@ function toResponseImageUrl(image3) {
|
|
|
71723
71741
|
return `data:${mimeType};base64,${data}`;
|
|
71724
71742
|
}
|
|
71725
71743
|
function convertToResponseInput(messages, includeBuiltinSystemPrompt = true, customSystemPromptOverride, planMode = false, vulnerabilityHuntingMode = false) {
|
|
71726
|
-
const
|
|
71744
|
+
const customSystemPrompts = customSystemPromptOverride;
|
|
71727
71745
|
const result2 = [];
|
|
71728
71746
|
for (const msg of messages) {
|
|
71729
71747
|
if (!msg)
|
|
@@ -71821,8 +71839,8 @@ function convertToResponseInput(messages, includeBuiltinSystemPrompt = true, cus
|
|
|
71821
71839
|
}
|
|
71822
71840
|
}
|
|
71823
71841
|
let systemInstructions;
|
|
71824
|
-
if (
|
|
71825
|
-
systemInstructions =
|
|
71842
|
+
if (customSystemPrompts && customSystemPrompts.length > 0) {
|
|
71843
|
+
systemInstructions = customSystemPrompts.join("\n\n");
|
|
71826
71844
|
if (includeBuiltinSystemPrompt) {
|
|
71827
71845
|
result2.unshift({
|
|
71828
71846
|
type: "message",
|
|
@@ -71915,8 +71933,8 @@ async function* createStreamingResponse(options3, abortSignal, onRetry) {
|
|
|
71915
71933
|
const { getSystemPromptConfig: getSystemPromptConfig2 } = await Promise.resolve().then(() => (init_apiConfig(), apiConfig_exports));
|
|
71916
71934
|
const systemPromptConfig = getSystemPromptConfig2();
|
|
71917
71935
|
const customPrompt = systemPromptConfig == null ? void 0 : systemPromptConfig.prompts.find((p) => p.id === options3.customSystemPromptId);
|
|
71918
|
-
if (customPrompt) {
|
|
71919
|
-
customSystemPromptContent = customPrompt.content;
|
|
71936
|
+
if (customPrompt == null ? void 0 : customPrompt.content) {
|
|
71937
|
+
customSystemPromptContent = [customPrompt.content];
|
|
71920
71938
|
}
|
|
71921
71939
|
}
|
|
71922
71940
|
customSystemPromptContent || (customSystemPromptContent = getCustomSystemPromptForConfig(config3));
|
|
@@ -72191,7 +72209,7 @@ function convertToolsToGemini(tools) {
|
|
|
72191
72209
|
}
|
|
72192
72210
|
function convertToGeminiMessages(messages, includeBuiltinSystemPrompt = true, customSystemPromptOverride, planMode = false, vulnerabilityHuntingMode = false) {
|
|
72193
72211
|
var _a21;
|
|
72194
|
-
const
|
|
72212
|
+
const customSystemPrompts = customSystemPromptOverride;
|
|
72195
72213
|
let systemInstruction;
|
|
72196
72214
|
const contents = [];
|
|
72197
72215
|
const toolCallIdToFunctionName = /* @__PURE__ */ new Map();
|
|
@@ -72200,7 +72218,7 @@ function convertToGeminiMessages(messages, includeBuiltinSystemPrompt = true, cu
|
|
|
72200
72218
|
if (!msg)
|
|
72201
72219
|
continue;
|
|
72202
72220
|
if (msg.role === "system") {
|
|
72203
|
-
systemInstruction = msg.content;
|
|
72221
|
+
systemInstruction = [msg.content];
|
|
72204
72222
|
continue;
|
|
72205
72223
|
}
|
|
72206
72224
|
if (msg.role === "assistant" && msg.tool_calls && msg.tool_calls.length > 0) {
|
|
@@ -72323,8 +72341,8 @@ function convertToGeminiMessages(messages, includeBuiltinSystemPrompt = true, cu
|
|
|
72323
72341
|
const role = msg.role === "assistant" ? "model" : "user";
|
|
72324
72342
|
contents.push({ role, parts });
|
|
72325
72343
|
}
|
|
72326
|
-
if (
|
|
72327
|
-
systemInstruction =
|
|
72344
|
+
if (customSystemPrompts && customSystemPrompts.length > 0) {
|
|
72345
|
+
systemInstruction = customSystemPrompts;
|
|
72328
72346
|
if (includeBuiltinSystemPrompt) {
|
|
72329
72347
|
contents.unshift({
|
|
72330
72348
|
role: "user",
|
|
@@ -72332,9 +72350,11 @@ function convertToGeminiMessages(messages, includeBuiltinSystemPrompt = true, cu
|
|
|
72332
72350
|
{ text: getSystemPromptForMode(planMode, vulnerabilityHuntingMode) }
|
|
72333
72351
|
]
|
|
72334
72352
|
});
|
|
72335
|
-
} else if (!systemInstruction && includeBuiltinSystemPrompt) {
|
|
72336
|
-
systemInstruction = getSystemPromptForMode(planMode, vulnerabilityHuntingMode);
|
|
72337
72353
|
}
|
|
72354
|
+
} else if (!systemInstruction && includeBuiltinSystemPrompt) {
|
|
72355
|
+
systemInstruction = [
|
|
72356
|
+
getSystemPromptForMode(planMode, vulnerabilityHuntingMode)
|
|
72357
|
+
];
|
|
72338
72358
|
}
|
|
72339
72359
|
return { systemInstruction, contents };
|
|
72340
72360
|
}
|
|
@@ -72364,8 +72384,8 @@ async function* createStreamingGeminiCompletion(options3, abortSignal, onRetry)
|
|
|
72364
72384
|
const { getSystemPromptConfig: getSystemPromptConfig2 } = await Promise.resolve().then(() => (init_apiConfig(), apiConfig_exports));
|
|
72365
72385
|
const systemPromptConfig = getSystemPromptConfig2();
|
|
72366
72386
|
const customPrompt = systemPromptConfig == null ? void 0 : systemPromptConfig.prompts.find((p) => p.id === options3.customSystemPromptId);
|
|
72367
|
-
if (customPrompt) {
|
|
72368
|
-
customSystemPromptContent = customPrompt.content;
|
|
72387
|
+
if (customPrompt == null ? void 0 : customPrompt.content) {
|
|
72388
|
+
customSystemPromptContent = [customPrompt.content];
|
|
72369
72389
|
}
|
|
72370
72390
|
}
|
|
72371
72391
|
customSystemPromptContent || (customSystemPromptContent = getCustomSystemPromptForConfig(config3));
|
|
@@ -72381,7 +72401,7 @@ async function* createStreamingGeminiCompletion(options3, abortSignal, onRetry)
|
|
|
72381
72401
|
);
|
|
72382
72402
|
const requestBody = {
|
|
72383
72403
|
contents,
|
|
72384
|
-
systemInstruction: systemInstruction ? { parts:
|
|
72404
|
+
systemInstruction: systemInstruction ? { parts: systemInstruction.map((text3) => ({ text: text3 })) } : void 0
|
|
72385
72405
|
};
|
|
72386
72406
|
if ((_a21 = config3.geminiThinking) == null ? void 0 : _a21.enabled) {
|
|
72387
72407
|
requestBody.generationConfig = {
|
|
@@ -73312,13 +73332,13 @@ Please provide your review in a clear, structured format.`;
|
|
|
73312
73332
|
if (!config3.advancedModel) {
|
|
73313
73333
|
throw new Error("Advanced model not configured");
|
|
73314
73334
|
}
|
|
73315
|
-
const
|
|
73335
|
+
const customSystemPrompts = getCustomSystemPrompt();
|
|
73316
73336
|
let processedMessages = messages;
|
|
73317
|
-
if (
|
|
73337
|
+
if (customSystemPrompts && customSystemPrompts.length > 0) {
|
|
73318
73338
|
processedMessages = [
|
|
73319
73339
|
{
|
|
73320
73340
|
role: "system",
|
|
73321
|
-
content:
|
|
73341
|
+
content: customSystemPrompts.join("\n\n")
|
|
73322
73342
|
},
|
|
73323
73343
|
...messages
|
|
73324
73344
|
];
|
|
@@ -74906,7 +74926,7 @@ function migrateSystemPromptFromTxt() {
|
|
|
74906
74926
|
return;
|
|
74907
74927
|
}
|
|
74908
74928
|
const config3 = {
|
|
74909
|
-
active: "default",
|
|
74929
|
+
active: ["default"],
|
|
74910
74930
|
prompts: [
|
|
74911
74931
|
{
|
|
74912
74932
|
id: "default",
|
|
@@ -74936,6 +74956,11 @@ function getSystemPromptConfig() {
|
|
|
74936
74956
|
return void 0;
|
|
74937
74957
|
}
|
|
74938
74958
|
const config3 = JSON.parse(content);
|
|
74959
|
+
if (typeof config3.active === "string") {
|
|
74960
|
+
config3.active = config3.active ? [config3.active] : [];
|
|
74961
|
+
} else if (!Array.isArray(config3.active)) {
|
|
74962
|
+
config3.active = [];
|
|
74963
|
+
}
|
|
74939
74964
|
return config3;
|
|
74940
74965
|
} catch (error) {
|
|
74941
74966
|
console.error("Failed to read system prompt config:", error);
|
|
@@ -74964,14 +74989,21 @@ function getCustomSystemPromptForConfig(apiConfig) {
|
|
|
74964
74989
|
return void 0;
|
|
74965
74990
|
}
|
|
74966
74991
|
if (systemPromptId) {
|
|
74967
|
-
const
|
|
74968
|
-
|
|
74992
|
+
const ids = Array.isArray(systemPromptId) ? systemPromptId : [systemPromptId];
|
|
74993
|
+
const contents2 = ids.map((id) => {
|
|
74994
|
+
var _a21;
|
|
74995
|
+
return (_a21 = config3.prompts.find((p) => p.id === id)) == null ? void 0 : _a21.content;
|
|
74996
|
+
}).filter((c) => typeof c === "string" && c.length > 0);
|
|
74997
|
+
return contents2.length > 0 ? contents2 : void 0;
|
|
74969
74998
|
}
|
|
74970
|
-
if (!config3.active) {
|
|
74999
|
+
if (!config3.active || config3.active.length === 0) {
|
|
74971
75000
|
return void 0;
|
|
74972
75001
|
}
|
|
74973
|
-
const
|
|
74974
|
-
|
|
75002
|
+
const contents = config3.active.map((id) => {
|
|
75003
|
+
var _a21;
|
|
75004
|
+
return (_a21 = config3.prompts.find((p) => p.id === id)) == null ? void 0 : _a21.content;
|
|
75005
|
+
}).filter((c) => typeof c === "string" && c.length > 0);
|
|
75006
|
+
return contents.length > 0 ? contents : void 0;
|
|
74975
75007
|
}
|
|
74976
75008
|
function getCustomHeaders() {
|
|
74977
75009
|
return getCustomHeadersForConfig(getOpenAiConfig());
|
|
@@ -75197,12 +75229,12 @@ function convertToolsToAnthropic(tools) {
|
|
|
75197
75229
|
}
|
|
75198
75230
|
function convertToAnthropicMessages(messages, includeBuiltinSystemPrompt = true, customSystemPromptOverride, cacheTTL = "5m", disableThinking = false, planMode = false, vulnerabilityHuntingMode = false) {
|
|
75199
75231
|
var _a21;
|
|
75200
|
-
const
|
|
75201
|
-
let
|
|
75232
|
+
const customSystemPrompts = customSystemPromptOverride;
|
|
75233
|
+
let systemContents;
|
|
75202
75234
|
const anthropicMessages = [];
|
|
75203
75235
|
for (const msg of messages) {
|
|
75204
75236
|
if (msg.role === "system") {
|
|
75205
|
-
|
|
75237
|
+
systemContents = [msg.content];
|
|
75206
75238
|
continue;
|
|
75207
75239
|
}
|
|
75208
75240
|
if (msg.role === "tool" && msg.tool_call_id) {
|
|
@@ -75330,8 +75362,8 @@ function convertToAnthropicMessages(messages, includeBuiltinSystemPrompt = true,
|
|
|
75330
75362
|
}
|
|
75331
75363
|
}
|
|
75332
75364
|
}
|
|
75333
|
-
if (
|
|
75334
|
-
|
|
75365
|
+
if (customSystemPrompts && customSystemPrompts.length > 0) {
|
|
75366
|
+
systemContents = customSystemPrompts;
|
|
75335
75367
|
if (includeBuiltinSystemPrompt) {
|
|
75336
75368
|
anthropicMessages.unshift({
|
|
75337
75369
|
role: "user",
|
|
@@ -75343,14 +75375,16 @@ function convertToAnthropicMessages(messages, includeBuiltinSystemPrompt = true,
|
|
|
75343
75375
|
}
|
|
75344
75376
|
]
|
|
75345
75377
|
});
|
|
75346
|
-
} else if (!systemContent && includeBuiltinSystemPrompt) {
|
|
75347
|
-
systemContent = getSystemPromptForMode(planMode, vulnerabilityHuntingMode);
|
|
75348
75378
|
}
|
|
75379
|
+
} else if (!systemContents && includeBuiltinSystemPrompt) {
|
|
75380
|
+
systemContents = [
|
|
75381
|
+
getSystemPromptForMode(planMode, vulnerabilityHuntingMode)
|
|
75382
|
+
];
|
|
75349
75383
|
}
|
|
75350
75384
|
let lastUserMessageIndex = -1;
|
|
75351
75385
|
for (let i = anthropicMessages.length - 1; i >= 0; i--) {
|
|
75352
75386
|
if (((_a21 = anthropicMessages[i]) == null ? void 0 : _a21.role) === "user") {
|
|
75353
|
-
if (
|
|
75387
|
+
if (customSystemPrompts && customSystemPrompts.length > 0 && i === 0) {
|
|
75354
75388
|
continue;
|
|
75355
75389
|
}
|
|
75356
75390
|
lastUserMessageIndex = i;
|
|
@@ -75377,13 +75411,11 @@ function convertToAnthropicMessages(messages, includeBuiltinSystemPrompt = true,
|
|
|
75377
75411
|
}
|
|
75378
75412
|
}
|
|
75379
75413
|
}
|
|
75380
|
-
const system =
|
|
75381
|
-
|
|
75382
|
-
|
|
75383
|
-
|
|
75384
|
-
|
|
75385
|
-
}
|
|
75386
|
-
] : void 0;
|
|
75414
|
+
const system = systemContents && systemContents.length > 0 ? systemContents.map((text3, index) => ({
|
|
75415
|
+
type: "text",
|
|
75416
|
+
text: text3,
|
|
75417
|
+
...index === systemContents.length - 1 ? { cache_control: { type: "ephemeral", ttl: cacheTTL } } : {}
|
|
75418
|
+
})) : void 0;
|
|
75387
75419
|
return { system, messages: anthropicMessages };
|
|
75388
75420
|
}
|
|
75389
75421
|
async function* parseSSEStream3(reader) {
|
|
@@ -75458,8 +75490,8 @@ async function* createStreamingAnthropicCompletion(options3, abortSignal, onRetr
|
|
|
75458
75490
|
const { getSystemPromptConfig: getSystemPromptConfig2 } = await Promise.resolve().then(() => (init_apiConfig(), apiConfig_exports));
|
|
75459
75491
|
const systemPromptConfig = getSystemPromptConfig2();
|
|
75460
75492
|
const customPrompt = systemPromptConfig == null ? void 0 : systemPromptConfig.prompts.find((p) => p.id === options3.customSystemPromptId);
|
|
75461
|
-
if (customPrompt) {
|
|
75462
|
-
customSystemPromptContent = customPrompt.content;
|
|
75493
|
+
if (customPrompt == null ? void 0 : customPrompt.content) {
|
|
75494
|
+
customSystemPromptContent = [customPrompt.content];
|
|
75463
75495
|
}
|
|
75464
75496
|
}
|
|
75465
75497
|
customSystemPromptContent || (customSystemPromptContent = getCustomSystemPromptForConfig(config3));
|
|
@@ -81067,19 +81099,19 @@ var init_en = __esm({
|
|
|
81067
81099
|
},
|
|
81068
81100
|
systemPromptConfig: {
|
|
81069
81101
|
title: "System Prompt Management",
|
|
81070
|
-
subtitle: "Manage multiple system prompts
|
|
81071
|
-
activePrompt: "Active
|
|
81102
|
+
subtitle: "Manage multiple system prompts (multi-select supported)",
|
|
81103
|
+
activePrompt: "Active Prompts:",
|
|
81072
81104
|
none: "None",
|
|
81073
81105
|
noPromptsConfigured: "No system prompts configured. Press Enter to add one.",
|
|
81074
81106
|
availablePrompts: "Available Prompts:",
|
|
81075
81107
|
actions: "Actions:",
|
|
81076
|
-
activate: "
|
|
81077
|
-
deactivate: "Deactivate",
|
|
81108
|
+
activate: "Toggle",
|
|
81109
|
+
deactivate: "Deactivate All",
|
|
81078
81110
|
edit: "Edit",
|
|
81079
81111
|
delete: "Delete",
|
|
81080
81112
|
addNew: "Add New",
|
|
81081
81113
|
escBack: "[ESC] Back",
|
|
81082
|
-
navigationHint: "
|
|
81114
|
+
navigationHint: "\u2191\u2193 Select prompt | Space Toggle | \u2190\u2192 Select action | Enter Confirm",
|
|
81083
81115
|
addNewTitle: "Add New System Prompt",
|
|
81084
81116
|
editTitle: "Edit System Prompt",
|
|
81085
81117
|
nameLabel: "Name:",
|
|
@@ -81096,7 +81128,8 @@ var init_en = __esm({
|
|
|
81096
81128
|
confirmDelete: "Confirm Delete",
|
|
81097
81129
|
deleteConfirmMessage: "Are you sure you want to delete",
|
|
81098
81130
|
confirmHint: "Press Y to confirm, N or ESC to cancel",
|
|
81099
|
-
saveError: "Failed to save"
|
|
81131
|
+
saveError: "Failed to save",
|
|
81132
|
+
activeCount: "{count} active"
|
|
81100
81133
|
},
|
|
81101
81134
|
configScreen: {
|
|
81102
81135
|
title: "API & Model Configuration",
|
|
@@ -81178,7 +81211,8 @@ var init_en = __esm({
|
|
|
81178
81211
|
followGlobal: "Follow Global: {name}",
|
|
81179
81212
|
followGlobalWithParentheses: "Follow Global ({name})",
|
|
81180
81213
|
followGlobalNoneWithParentheses: "Follow Global (None)",
|
|
81181
|
-
notUse: "Not Use"
|
|
81214
|
+
notUse: "Not Use",
|
|
81215
|
+
systemPromptMultiSelectHint: "Space: toggle | Enter: confirm | Esc: cancel"
|
|
81182
81216
|
},
|
|
81183
81217
|
customHeaders: {
|
|
81184
81218
|
title: "Custom Headers Management",
|
|
@@ -82332,19 +82366,19 @@ var init_zh = __esm({
|
|
|
82332
82366
|
},
|
|
82333
82367
|
systemPromptConfig: {
|
|
82334
82368
|
title: "\u7CFB\u7EDF\u63D0\u793A\u8BCD\u7BA1\u7406",
|
|
82335
|
-
subtitle: "\u7BA1\u7406\u591A\u4E2A\u7CFB\u7EDF\u63D0\u793A\u8BCD\
|
|
82336
|
-
activePrompt: "\u6D3B\
|
|
82369
|
+
subtitle: "\u7BA1\u7406\u591A\u4E2A\u7CFB\u7EDF\u63D0\u793A\u8BCD\uFF08\u652F\u6301\u591A\u9009\u6FC0\u6D3B\uFF09",
|
|
82370
|
+
activePrompt: "\u5DF2\u6FC0\u6D3B\u63D0\u793A\u8BCD:",
|
|
82337
82371
|
none: "\u65E0",
|
|
82338
82372
|
noPromptsConfigured: "\u672A\u914D\u7F6E\u7CFB\u7EDF\u63D0\u793A\u8BCD\u3002\u6309 Enter \u6DFB\u52A0\u4E00\u4E2A\u3002",
|
|
82339
82373
|
availablePrompts: "\u53EF\u7528\u63D0\u793A\u8BCD:",
|
|
82340
82374
|
actions: "\u64CD\u4F5C:",
|
|
82341
|
-
activate: "\u6FC0\u6D3B",
|
|
82342
|
-
deactivate: "\u505C\u7528",
|
|
82375
|
+
activate: "\u5207\u6362\u6FC0\u6D3B",
|
|
82376
|
+
deactivate: "\u5168\u90E8\u505C\u7528",
|
|
82343
82377
|
edit: "\u7F16\u8F91",
|
|
82344
82378
|
delete: "\u5220\u9664",
|
|
82345
82379
|
addNew: "\u6DFB\u52A0\u65B0\u63D0\u793A\u8BCD",
|
|
82346
82380
|
escBack: "[ESC] \u8FD4\u56DE",
|
|
82347
|
-
navigationHint: "\
|
|
82381
|
+
navigationHint: "\u2191\u2193 \u9009\u62E9\u63D0\u793A\u8BCD | \u7A7A\u683C \u5207\u6362\u6FC0\u6D3B | \u2190\u2192 \u9009\u62E9\u64CD\u4F5C | Enter \u786E\u8BA4",
|
|
82348
82382
|
addNewTitle: "\u6DFB\u52A0\u65B0\u7CFB\u7EDF\u63D0\u793A\u8BCD",
|
|
82349
82383
|
editTitle: "\u7F16\u8F91\u7CFB\u7EDF\u63D0\u793A\u8BCD",
|
|
82350
82384
|
nameLabel: "\u540D\u79F0:",
|
|
@@ -82361,7 +82395,8 @@ var init_zh = __esm({
|
|
|
82361
82395
|
confirmDelete: "\u786E\u8BA4\u5220\u9664",
|
|
82362
82396
|
deleteConfirmMessage: "\u786E\u5B9A\u8981\u5220\u9664",
|
|
82363
82397
|
confirmHint: "\u6309 Y \u786E\u8BA4,N \u6216 ESC \u53D6\u6D88",
|
|
82364
|
-
saveError: "\u4FDD\u5B58\u5931\u8D25"
|
|
82398
|
+
saveError: "\u4FDD\u5B58\u5931\u8D25",
|
|
82399
|
+
activeCount: "\u5DF2\u6FC0\u6D3B {count} \u4E2A"
|
|
82365
82400
|
},
|
|
82366
82401
|
configScreen: {
|
|
82367
82402
|
title: "API \u548C\u6A21\u578B\u914D\u7F6E",
|
|
@@ -82443,7 +82478,8 @@ var init_zh = __esm({
|
|
|
82443
82478
|
followGlobal: "\u8DDF\u968F\u5168\u5C40\uFF1A{name}",
|
|
82444
82479
|
followGlobalWithParentheses: "\u8DDF\u968F\u5168\u5C40\uFF08{name}\uFF09",
|
|
82445
82480
|
followGlobalNoneWithParentheses: "\u8DDF\u968F\u5168\u5C40\uFF08\u65E0\uFF09",
|
|
82446
|
-
notUse: "\u4E0D\u4F7F\u7528"
|
|
82481
|
+
notUse: "\u4E0D\u4F7F\u7528",
|
|
82482
|
+
systemPromptMultiSelectHint: "\u7A7A\u683C: \u5207\u6362\u9009\u4E2D | Enter: \u786E\u8BA4 | Esc: \u53D6\u6D88"
|
|
82447
82483
|
},
|
|
82448
82484
|
customHeaders: {
|
|
82449
82485
|
title: "\u81EA\u5B9A\u4E49\u8BF7\u6C42\u5934\u7BA1\u7406",
|
|
@@ -83596,19 +83632,19 @@ var init_zh_TW = __esm({
|
|
|
83596
83632
|
},
|
|
83597
83633
|
systemPromptConfig: {
|
|
83598
83634
|
title: "\u7CFB\u7D71\u63D0\u793A\u8A5E\u7BA1\u7406",
|
|
83599
|
-
subtitle: "\u7BA1\u7406\u591A\u500B\u7CFB\u7D71\u63D0\u793A\u8A5E\
|
|
83600
|
-
activePrompt: "\
|
|
83635
|
+
subtitle: "\u7BA1\u7406\u591A\u500B\u7CFB\u7D71\u63D0\u793A\u8A5E\uFF08\u652F\u63F4\u591A\u9078\u555F\u7528\uFF09",
|
|
83636
|
+
activePrompt: "\u5DF2\u555F\u7528\u63D0\u793A\u8A5E:",
|
|
83601
83637
|
none: "\u7121",
|
|
83602
83638
|
noPromptsConfigured: "\u672A\u914D\u7F6E\u7CFB\u7D71\u63D0\u793A\u8A5E\u3002\u6309 Enter \u65B0\u589E\u4E00\u500B\u3002",
|
|
83603
83639
|
availablePrompts: "\u53EF\u7528\u63D0\u793A\u8A5E:",
|
|
83604
83640
|
actions: "\u64CD\u4F5C:",
|
|
83605
|
-
activate: "\u555F\u7528",
|
|
83606
|
-
deactivate: "\u505C\u7528",
|
|
83641
|
+
activate: "\u5207\u63DB\u555F\u7528",
|
|
83642
|
+
deactivate: "\u5168\u90E8\u505C\u7528",
|
|
83607
83643
|
edit: "\u7DE8\u8F2F",
|
|
83608
83644
|
delete: "\u522A\u9664",
|
|
83609
83645
|
addNew: "\u65B0\u589E\u65B0\u63D0\u793A\u8A5E",
|
|
83610
83646
|
escBack: "[ESC] \u8FD4\u56DE",
|
|
83611
|
-
navigationHint: "\
|
|
83647
|
+
navigationHint: "\u2191\u2193 \u9078\u64C7\u63D0\u793A\u8A5E | \u7A7A\u683C \u5207\u63DB\u555F\u7528 | \u2190\u2192 \u9078\u64C7\u64CD\u4F5C | Enter \u78BA\u8A8D",
|
|
83612
83648
|
addNewTitle: "\u65B0\u589E\u65B0\u7CFB\u7D71\u63D0\u793A\u8A5E",
|
|
83613
83649
|
editTitle: "\u7DE8\u8F2F\u7CFB\u7D71\u63D0\u793A\u8A5E",
|
|
83614
83650
|
nameLabel: "\u540D\u7A31:",
|
|
@@ -83625,7 +83661,8 @@ var init_zh_TW = __esm({
|
|
|
83625
83661
|
confirmDelete: "\u78BA\u8A8D\u522A\u9664",
|
|
83626
83662
|
deleteConfirmMessage: "\u78BA\u5B9A\u8981\u522A\u9664",
|
|
83627
83663
|
confirmHint: "\u6309 Y \u78BA\u8A8D,N \u6216 ESC \u53D6\u6D88",
|
|
83628
|
-
saveError: "\u5132\u5B58\u5931\u6557"
|
|
83664
|
+
saveError: "\u5132\u5B58\u5931\u6557",
|
|
83665
|
+
activeCount: "\u5DF2\u555F\u7528 {count} \u500B"
|
|
83629
83666
|
},
|
|
83630
83667
|
configScreen: {
|
|
83631
83668
|
title: "API \u548C\u6A21\u578B\u914D\u7F6E",
|
|
@@ -83707,7 +83744,8 @@ var init_zh_TW = __esm({
|
|
|
83707
83744
|
followGlobal: "\u8DDF\u96A8\u5168\u57DF\uFF1A{name}",
|
|
83708
83745
|
followGlobalWithParentheses: "\u8DDF\u96A8\u5168\u57DF\uFF08{name}\uFF09",
|
|
83709
83746
|
followGlobalNoneWithParentheses: "\u8DDF\u96A8\u5168\u57DF\uFF08\u7121\uFF09",
|
|
83710
|
-
notUse: "\u4E0D\u4F7F\u7528"
|
|
83747
|
+
notUse: "\u4E0D\u4F7F\u7528",
|
|
83748
|
+
systemPromptMultiSelectHint: "\u7A7A\u683C: \u5207\u63DB\u9078\u4E2D | Enter: \u78BA\u8A8D | Esc: \u53D6\u6D88"
|
|
83711
83749
|
},
|
|
83712
83750
|
customHeaders: {
|
|
83713
83751
|
title: "\u81EA\u8A02\u8ACB\u6C42\u982D\u7BA1\u7406",
|
|
@@ -89890,7 +89928,8 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
|
|
|
89890
89928
|
const [systemPromptId, setSystemPromptId] = (0, import_react64.useState)(void 0);
|
|
89891
89929
|
const [customHeadersSchemeId, setCustomHeadersSchemeId] = (0, import_react64.useState)(void 0);
|
|
89892
89930
|
const [systemPrompts, setSystemPrompts] = (0, import_react64.useState)([]);
|
|
89893
|
-
const [
|
|
89931
|
+
const [activeSystemPromptIds, setActiveSystemPromptIds] = (0, import_react64.useState)([]);
|
|
89932
|
+
const [pendingPromptIds, setPendingPromptIds] = (0, import_react64.useState)(/* @__PURE__ */ new Set());
|
|
89894
89933
|
const [customHeaderSchemes, setCustomHeaderSchemes] = (0, import_react64.useState)([]);
|
|
89895
89934
|
const [activeCustomHeadersSchemeId, setActiveCustomHeadersSchemeId] = (0, import_react64.useState)("");
|
|
89896
89935
|
const [anthropicBeta, setAnthropicBeta] = (0, import_react64.useState)(false);
|
|
@@ -90048,7 +90087,7 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
|
|
|
90048
90087
|
setEditSimilarityThreshold(config3.editSimilarityThreshold ?? 0.75);
|
|
90049
90088
|
const systemPromptConfig = getSystemPromptConfig();
|
|
90050
90089
|
setSystemPrompts(((systemPromptConfig == null ? void 0 : systemPromptConfig.prompts) || []).map((p) => ({ id: p.id, name: p.name })));
|
|
90051
|
-
|
|
90090
|
+
setActiveSystemPromptIds((systemPromptConfig == null ? void 0 : systemPromptConfig.active) || []);
|
|
90052
90091
|
const customHeadersConfig = getCustomHeadersConfig();
|
|
90053
90092
|
setCustomHeaderSchemes(((customHeadersConfig == null ? void 0 : customHeadersConfig.schemes) || []).map((s) => ({ id: s.id, name: s.name })));
|
|
90054
90093
|
setActiveCustomHeadersSchemeId((customHeadersConfig == null ? void 0 : customHeadersConfig.active) || "");
|
|
@@ -90153,7 +90192,8 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
|
|
|
90153
90192
|
return `${resolvedBaseUrl}/chat/completions`;
|
|
90154
90193
|
};
|
|
90155
90194
|
const getSystemPromptSelectItems = () => {
|
|
90156
|
-
const
|
|
90195
|
+
const activeNames = activeSystemPromptIds.map((id) => getSystemPromptNameById(id)).join(", ");
|
|
90196
|
+
const activeLabel = activeNames ? t.configScreen.followGlobalWithParentheses.replace("{name}", activeNames) : t.configScreen.followGlobalNoneWithParentheses;
|
|
90157
90197
|
return [
|
|
90158
90198
|
{ label: activeLabel, value: "__FOLLOW__" },
|
|
90159
90199
|
{ label: t.configScreen.notUse, value: "__DISABLED__" },
|
|
@@ -90166,6 +90206,8 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
|
|
|
90166
90206
|
const getSystemPromptSelectedValue = () => {
|
|
90167
90207
|
if (systemPromptId === "")
|
|
90168
90208
|
return "__DISABLED__";
|
|
90209
|
+
if (Array.isArray(systemPromptId))
|
|
90210
|
+
return "__FOLLOW__";
|
|
90169
90211
|
if (systemPromptId)
|
|
90170
90212
|
return systemPromptId;
|
|
90171
90213
|
return "__FOLLOW__";
|
|
@@ -90461,10 +90503,13 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
|
|
|
90461
90503
|
let display = t.configScreen.followGlobalNone;
|
|
90462
90504
|
if (systemPromptId === "") {
|
|
90463
90505
|
display = t.configScreen.notUse;
|
|
90464
|
-
} else if (systemPromptId) {
|
|
90506
|
+
} else if (Array.isArray(systemPromptId) && systemPromptId.length > 0) {
|
|
90507
|
+
display = systemPromptId.map((id) => getSystemPromptNameById(id)).join(", ");
|
|
90508
|
+
} else if (systemPromptId && typeof systemPromptId === "string") {
|
|
90465
90509
|
display = getSystemPromptNameById(systemPromptId);
|
|
90466
|
-
} else if (
|
|
90467
|
-
|
|
90510
|
+
} else if (activeSystemPromptIds.length > 0) {
|
|
90511
|
+
const activeNames = activeSystemPromptIds.map((id) => getSystemPromptNameById(id)).join(", ");
|
|
90512
|
+
display = t.configScreen.followGlobal.replace("{name}", activeNames);
|
|
90468
90513
|
}
|
|
90469
90514
|
return import_react64.default.createElement(
|
|
90470
90515
|
Box_default,
|
|
@@ -90979,6 +91024,9 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
|
|
|
90979
91024
|
if (isEditing && (currentField === "profile" || currentField === "requestMethod" || currentField === "systemPromptId" || currentField === "customHeadersSchemeId" || currentField === "anthropicCacheTTL" || currentField === "advancedModel" || currentField === "basicModel" || currentField === "responsesReasoningEffort") && key.escape) {
|
|
90980
91025
|
setIsEditing(false);
|
|
90981
91026
|
setSearchTerm("");
|
|
91027
|
+
if (currentField === "systemPromptId") {
|
|
91028
|
+
setPendingPromptIds(/* @__PURE__ */ new Set());
|
|
91029
|
+
}
|
|
90982
91030
|
forceUpdate((prev) => prev + 1);
|
|
90983
91031
|
return;
|
|
90984
91032
|
}
|
|
@@ -91118,6 +91166,15 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
|
|
|
91118
91166
|
setManualInputValue(getCurrentValue());
|
|
91119
91167
|
});
|
|
91120
91168
|
} else {
|
|
91169
|
+
if (currentField === "systemPromptId") {
|
|
91170
|
+
if (Array.isArray(systemPromptId)) {
|
|
91171
|
+
setPendingPromptIds(new Set(systemPromptId));
|
|
91172
|
+
} else if (systemPromptId && systemPromptId !== "") {
|
|
91173
|
+
setPendingPromptIds(/* @__PURE__ */ new Set([systemPromptId]));
|
|
91174
|
+
} else {
|
|
91175
|
+
setPendingPromptIds(/* @__PURE__ */ new Set());
|
|
91176
|
+
}
|
|
91177
|
+
}
|
|
91121
91178
|
setIsEditing(true);
|
|
91122
91179
|
}
|
|
91123
91180
|
}
|
|
@@ -91447,10 +91504,54 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
|
|
|
91447
91504
|
currentField === "systemPromptId" && (() => {
|
|
91448
91505
|
const items = getSystemPromptSelectItems();
|
|
91449
91506
|
const selected = getSystemPromptSelectedValue();
|
|
91450
|
-
return import_react64.default.createElement(
|
|
91451
|
-
|
|
91452
|
-
|
|
91453
|
-
|
|
91507
|
+
return import_react64.default.createElement(
|
|
91508
|
+
Box_default,
|
|
91509
|
+
{ flexDirection: "column" },
|
|
91510
|
+
import_react64.default.createElement(ScrollableSelectInput, { items, limit: 10, initialIndex: Math.max(0, items.findIndex((opt) => opt.value === selected)), isFocused: true, selectedValues: pendingPromptIds, renderItem: ({ label, value, isSelected, isMarked }) => {
|
|
91511
|
+
const isMeta = value === "__FOLLOW__" || value === "__DISABLED__";
|
|
91512
|
+
return import_react64.default.createElement(
|
|
91513
|
+
Text,
|
|
91514
|
+
{ color: isSelected ? "cyan" : isMarked ? theme14.colors.menuInfo : "white" },
|
|
91515
|
+
isMeta ? "" : isMarked ? "[x] " : "[ ] ",
|
|
91516
|
+
label
|
|
91517
|
+
);
|
|
91518
|
+
}, onToggleItem: (item) => {
|
|
91519
|
+
if (item.value === "__FOLLOW__" || item.value === "__DISABLED__") {
|
|
91520
|
+
applySystemPromptSelectValue(item.value);
|
|
91521
|
+
setPendingPromptIds(/* @__PURE__ */ new Set());
|
|
91522
|
+
setIsEditing(false);
|
|
91523
|
+
return;
|
|
91524
|
+
}
|
|
91525
|
+
setPendingPromptIds((prev) => {
|
|
91526
|
+
const next = new Set(prev);
|
|
91527
|
+
if (next.has(item.value)) {
|
|
91528
|
+
next.delete(item.value);
|
|
91529
|
+
} else {
|
|
91530
|
+
next.add(item.value);
|
|
91531
|
+
}
|
|
91532
|
+
return next;
|
|
91533
|
+
});
|
|
91534
|
+
}, onSelect: (item) => {
|
|
91535
|
+
if (item.value === "__FOLLOW__" || item.value === "__DISABLED__") {
|
|
91536
|
+
applySystemPromptSelectValue(item.value);
|
|
91537
|
+
setPendingPromptIds(/* @__PURE__ */ new Set());
|
|
91538
|
+
setIsEditing(false);
|
|
91539
|
+
return;
|
|
91540
|
+
}
|
|
91541
|
+
const finalIds = pendingPromptIds.size > 0 ? Array.from(pendingPromptIds) : [item.value];
|
|
91542
|
+
if (pendingPromptIds.size > 0 && !pendingPromptIds.has(item.value)) {
|
|
91543
|
+
finalIds.push(item.value);
|
|
91544
|
+
}
|
|
91545
|
+
setSystemPromptId(finalIds.length === 1 ? finalIds[0] : finalIds);
|
|
91546
|
+
setPendingPromptIds(/* @__PURE__ */ new Set());
|
|
91547
|
+
setIsEditing(false);
|
|
91548
|
+
} }),
|
|
91549
|
+
import_react64.default.createElement(
|
|
91550
|
+
Box_default,
|
|
91551
|
+
{ marginTop: 1 },
|
|
91552
|
+
import_react64.default.createElement(Text, { color: theme14.colors.menuSecondary, dimColor: true }, t.configScreen.systemPromptMultiSelectHint || "Space: toggle | Enter: confirm | Esc: cancel")
|
|
91553
|
+
)
|
|
91554
|
+
);
|
|
91454
91555
|
})(),
|
|
91455
91556
|
currentField === "customHeadersSchemeId" && (() => {
|
|
91456
91557
|
const items = getCustomHeadersSchemeSelectItems();
|
|
@@ -363844,6 +363945,51 @@ ${formattedDiagnostics}`;
|
|
|
363844
363945
|
function isDangerousCommand(command) {
|
|
363845
363946
|
return DANGEROUS_PATTERNS.some((pattern) => pattern.test(command));
|
|
363846
363947
|
}
|
|
363948
|
+
function isSelfDestructiveCommand(command) {
|
|
363949
|
+
const lower = command.toLowerCase();
|
|
363950
|
+
const cliPid = process.pid;
|
|
363951
|
+
if (lower.includes("stop-process") && /\bnode\b/i.test(command)) {
|
|
363952
|
+
return {
|
|
363953
|
+
isSelfDestructive: true,
|
|
363954
|
+
reason: "Command would terminate Node.js processes, including this CLI itself",
|
|
363955
|
+
suggestion: `This CLI is running as Node.js (PID: ${cliPid}). Add a PID exclusion filter, e.g.: Where-Object { ... -and $_.Id -ne ${cliPid} }`
|
|
363956
|
+
};
|
|
363957
|
+
}
|
|
363958
|
+
if (/\btaskkill\b/i.test(command) && /\bnode(\.exe)?\b/i.test(command)) {
|
|
363959
|
+
return {
|
|
363960
|
+
isSelfDestructive: true,
|
|
363961
|
+
reason: "Command would terminate node.exe processes, including this CLI itself",
|
|
363962
|
+
suggestion: `This CLI is running as node.exe (PID: ${cliPid}). Use "taskkill /PID <target_pid>" for specific processes, excluding PID ${cliPid}.`
|
|
363963
|
+
};
|
|
363964
|
+
}
|
|
363965
|
+
if (/\bkillall\s+(-\w+\s+)*node\b/i.test(command)) {
|
|
363966
|
+
return {
|
|
363967
|
+
isSelfDestructive: true,
|
|
363968
|
+
reason: "killall node would terminate ALL Node.js processes, including this CLI",
|
|
363969
|
+
suggestion: `Use "kill <specific_pid>" to target individual processes, excluding PID ${cliPid}.`
|
|
363970
|
+
};
|
|
363971
|
+
}
|
|
363972
|
+
if (/\bpkill\s+(-\w+\s+)*node\b/i.test(command)) {
|
|
363973
|
+
return {
|
|
363974
|
+
isSelfDestructive: true,
|
|
363975
|
+
reason: "pkill node would terminate Node.js processes, including this CLI",
|
|
363976
|
+
suggestion: `Use "kill <specific_pid>" to target individual processes, excluding PID ${cliPid}.`
|
|
363977
|
+
};
|
|
363978
|
+
}
|
|
363979
|
+
const pidPatterns = [
|
|
363980
|
+
new RegExp(`\\bkill\\s+(-\\d+\\s+)*${cliPid}\\b`),
|
|
363981
|
+
new RegExp(`\\bStop-Process\\s+.*-Id\\s+${cliPid}\\b`, "i"),
|
|
363982
|
+
new RegExp(`\\btaskkill\\b.*\\/PID\\s+${cliPid}\\b`, "i")
|
|
363983
|
+
];
|
|
363984
|
+
if (pidPatterns.some((p) => p.test(command))) {
|
|
363985
|
+
return {
|
|
363986
|
+
isSelfDestructive: true,
|
|
363987
|
+
reason: `Command directly targets this CLI process (PID: ${cliPid})`,
|
|
363988
|
+
suggestion: `PID ${cliPid} is the Snow CLI process. Killing it will terminate the current session.`
|
|
363989
|
+
};
|
|
363990
|
+
}
|
|
363991
|
+
return { isSelfDestructive: false };
|
|
363992
|
+
}
|
|
363847
363993
|
function truncateOutput(output2, maxLength) {
|
|
363848
363994
|
if (!output2)
|
|
363849
363995
|
return "";
|
|
@@ -364255,6 +364401,10 @@ var init_bash = __esm({
|
|
|
364255
364401
|
if (isDangerousCommand(command)) {
|
|
364256
364402
|
throw new Error(`Dangerous command detected and blocked: ${command.slice(0, 50)}`);
|
|
364257
364403
|
}
|
|
364404
|
+
const selfDestruct = isSelfDestructiveCommand(command);
|
|
364405
|
+
if (selfDestruct.isSelfDestructive) {
|
|
364406
|
+
throw new Error(`[SELF-PROTECTION] Command blocked: ${selfDestruct.reason}. ${selfDestruct.suggestion}`);
|
|
364407
|
+
}
|
|
364258
364408
|
if (this.isSSHPath(this.workingDirectory)) {
|
|
364259
364409
|
const parsed = parseSSHUrl(this.workingDirectory);
|
|
364260
364410
|
if (!parsed) {
|
|
@@ -442287,20 +442437,33 @@ var init_sessionManager = __esm({
|
|
|
442287
442437
|
if (!this.currentSession || this.currentSession.messages.length < 2) {
|
|
442288
442438
|
return;
|
|
442289
442439
|
}
|
|
442440
|
+
const targetSession = this.currentSession;
|
|
442441
|
+
const targetSessionId = targetSession.id;
|
|
442290
442442
|
try {
|
|
442291
|
-
const firstUserMessage =
|
|
442292
|
-
const firstAssistantMessage =
|
|
442443
|
+
const firstUserMessage = targetSession.messages.find((m) => m.role === "user");
|
|
442444
|
+
const firstAssistantMessage = targetSession.messages.find((m) => m.role === "assistant");
|
|
442293
442445
|
if (!firstUserMessage || !firstAssistantMessage) {
|
|
442294
442446
|
logger.warn("Summary agent: Could not find first user/assistant messages");
|
|
442295
442447
|
return;
|
|
442296
442448
|
}
|
|
442297
442449
|
const result2 = await summaryAgent.generateSummary(firstUserMessage.content, firstAssistantMessage.content);
|
|
442298
442450
|
if (result2) {
|
|
442299
|
-
this.currentSession.
|
|
442300
|
-
|
|
442301
|
-
|
|
442451
|
+
if (!this.currentSession || this.currentSession.id !== targetSessionId) {
|
|
442452
|
+
targetSession.title = result2.title;
|
|
442453
|
+
targetSession.summary = result2.summary;
|
|
442454
|
+
await this.saveSession(targetSession);
|
|
442455
|
+
logger.info("Summary agent: Updated detached session summary", {
|
|
442456
|
+
sessionId: targetSessionId,
|
|
442457
|
+
title: result2.title,
|
|
442458
|
+
summary: result2.summary
|
|
442459
|
+
});
|
|
442460
|
+
return;
|
|
442461
|
+
}
|
|
442462
|
+
targetSession.title = result2.title;
|
|
442463
|
+
targetSession.summary = result2.summary;
|
|
442464
|
+
await this.saveSession(targetSession);
|
|
442302
442465
|
logger.info("Summary agent: Successfully updated session summary", {
|
|
442303
|
-
sessionId:
|
|
442466
|
+
sessionId: targetSessionId,
|
|
442304
442467
|
title: result2.title,
|
|
442305
442468
|
summary: result2.summary
|
|
442306
442469
|
});
|
|
@@ -459269,7 +459432,7 @@ function SystemPromptConfigScreen({ onBack }) {
|
|
|
459269
459432
|
const { theme: theme14 } = useTheme();
|
|
459270
459433
|
const [config3, setConfig] = (0, import_react72.useState)(() => {
|
|
459271
459434
|
return getSystemPromptConfig() || {
|
|
459272
|
-
active:
|
|
459435
|
+
active: [],
|
|
459273
459436
|
prompts: []
|
|
459274
459437
|
};
|
|
459275
459438
|
});
|
|
@@ -459282,7 +459445,7 @@ function SystemPromptConfigScreen({ onBack }) {
|
|
|
459282
459445
|
const [editingField, setEditingField] = (0, import_react72.useState)("name");
|
|
459283
459446
|
const [error, setError] = (0, import_react72.useState)("");
|
|
459284
459447
|
const [successMessage, setSuccessMessage] = (0, import_react72.useState)("");
|
|
459285
|
-
const actions = config3.prompts.length > 0 ? config3.active ? ["activate", "deactivate", "edit", "delete", "add", "back"] : ["activate", "edit", "delete", "add", "back"] : ["add", "back"];
|
|
459448
|
+
const actions = config3.prompts.length > 0 ? config3.active.length > 0 ? ["activate", "deactivate", "edit", "delete", "add", "back"] : ["activate", "edit", "delete", "add", "back"] : ["add", "back"];
|
|
459286
459449
|
(0, import_react72.useEffect)(() => {
|
|
459287
459450
|
if (!actions.includes(currentAction)) {
|
|
459288
459451
|
setCurrentAction(actions[0] || "add");
|
|
@@ -459309,9 +459472,11 @@ function SystemPromptConfigScreen({ onBack }) {
|
|
|
459309
459472
|
if (config3.prompts.length === 0 || selectedIndex >= config3.prompts.length)
|
|
459310
459473
|
return;
|
|
459311
459474
|
const prompt = config3.prompts[selectedIndex];
|
|
459475
|
+
const isAlreadyActive = config3.active.includes(prompt.id);
|
|
459476
|
+
const newActive = isAlreadyActive ? config3.active.filter((id) => id !== prompt.id) : [...config3.active, prompt.id];
|
|
459312
459477
|
const newConfig = {
|
|
459313
459478
|
...config3,
|
|
459314
|
-
active:
|
|
459479
|
+
active: newActive
|
|
459315
459480
|
};
|
|
459316
459481
|
if (saveAndRefresh(newConfig)) {
|
|
459317
459482
|
setError("");
|
|
@@ -459320,7 +459485,7 @@ function SystemPromptConfigScreen({ onBack }) {
|
|
|
459320
459485
|
const handleDeactivate = () => {
|
|
459321
459486
|
const newConfig = {
|
|
459322
459487
|
...config3,
|
|
459323
|
-
active:
|
|
459488
|
+
active: []
|
|
459324
459489
|
};
|
|
459325
459490
|
if (saveAndRefresh(newConfig)) {
|
|
459326
459491
|
setError("");
|
|
@@ -459396,7 +459561,7 @@ function SystemPromptConfigScreen({ onBack }) {
|
|
|
459396
459561
|
return;
|
|
459397
459562
|
const promptToDelete = config3.prompts[selectedIndex];
|
|
459398
459563
|
const newPrompts = config3.prompts.filter((_3, i) => i !== selectedIndex);
|
|
459399
|
-
const newActive = config3.active
|
|
459564
|
+
const newActive = config3.active.filter((id) => id !== promptToDelete.id);
|
|
459400
459565
|
const newConfig = {
|
|
459401
459566
|
active: newActive,
|
|
459402
459567
|
prompts: newPrompts
|
|
@@ -459422,7 +459587,7 @@ function SystemPromptConfigScreen({ onBack }) {
|
|
|
459422
459587
|
const newConfig = {
|
|
459423
459588
|
...config3,
|
|
459424
459589
|
prompts: [...config3.prompts, newPrompt],
|
|
459425
|
-
active: config3.prompts.length === 0 ? newPrompt.id : config3.active
|
|
459590
|
+
active: config3.prompts.length === 0 ? [newPrompt.id] : config3.active
|
|
459426
459591
|
};
|
|
459427
459592
|
if (saveAndRefresh(newConfig)) {
|
|
459428
459593
|
setView("list");
|
|
@@ -459457,6 +459622,8 @@ function SystemPromptConfigScreen({ onBack }) {
|
|
|
459457
459622
|
if (config3.prompts.length > 0) {
|
|
459458
459623
|
setSelectedIndex((prev) => prev < config3.prompts.length - 1 ? prev + 1 : 0);
|
|
459459
459624
|
}
|
|
459625
|
+
} else if (_input === " ") {
|
|
459626
|
+
handleActivate();
|
|
459460
459627
|
} else if (key.leftArrow) {
|
|
459461
459628
|
const currentIdx = actions.indexOf(currentAction);
|
|
459462
459629
|
setCurrentAction(actions[currentIdx > 0 ? currentIdx - 1 : actions.length - 1]);
|
|
@@ -459517,7 +459684,10 @@ function SystemPromptConfigScreen({ onBack }) {
|
|
|
459517
459684
|
}
|
|
459518
459685
|
}, { isActive: view === "confirmDelete" });
|
|
459519
459686
|
if (view === "list") {
|
|
459520
|
-
const
|
|
459687
|
+
const activePromptNames = config3.active.map((id) => {
|
|
459688
|
+
var _a21;
|
|
459689
|
+
return (_a21 = config3.prompts.find((p) => p.id === id)) == null ? void 0 : _a21.name;
|
|
459690
|
+
}).filter(Boolean).join(", ");
|
|
459521
459691
|
return import_react72.default.createElement(
|
|
459522
459692
|
Box_default,
|
|
459523
459693
|
{ flexDirection: "column", padding: 1 },
|
|
@@ -459534,7 +459704,15 @@ function SystemPromptConfigScreen({ onBack }) {
|
|
|
459534
459704
|
{ bold: true },
|
|
459535
459705
|
t.systemPromptConfig.activePrompt,
|
|
459536
459706
|
" ",
|
|
459537
|
-
import_react72.default.createElement(Text, { color: theme14.colors.success },
|
|
459707
|
+
import_react72.default.createElement(Text, { color: theme14.colors.success }, activePromptNames || t.systemPromptConfig.none),
|
|
459708
|
+
config3.active.length > 0 && import_react72.default.createElement(
|
|
459709
|
+
Text,
|
|
459710
|
+
{ dimColor: true },
|
|
459711
|
+
" ",
|
|
459712
|
+
"(",
|
|
459713
|
+
t.systemPromptConfig.activeCount.replace("{count}", String(config3.active.length)),
|
|
459714
|
+
")"
|
|
459715
|
+
)
|
|
459538
459716
|
)
|
|
459539
459717
|
),
|
|
459540
459718
|
config3.prompts.length === 0 ? import_react72.default.createElement(
|
|
@@ -459550,11 +459728,11 @@ function SystemPromptConfigScreen({ onBack }) {
|
|
|
459550
459728
|
{ key: prompt.id, marginLeft: 2 },
|
|
459551
459729
|
import_react72.default.createElement(
|
|
459552
459730
|
Text,
|
|
459553
|
-
{ color: index === selectedIndex ? theme14.colors.menuSelected : prompt.id
|
|
459554
|
-
index === selectedIndex ? "
|
|
459555
|
-
prompt.id
|
|
459731
|
+
{ color: index === selectedIndex ? theme14.colors.menuSelected : config3.active.includes(prompt.id) ? theme14.colors.menuInfo : theme14.colors.menuNormal },
|
|
459732
|
+
index === selectedIndex ? "> " : " ",
|
|
459733
|
+
config3.active.includes(prompt.id) ? "[x] " : "[ ] ",
|
|
459556
459734
|
prompt.name,
|
|
459557
|
-
prompt.content && import_react72.default.createElement(
|
|
459735
|
+
typeof prompt.content === "string" && prompt.content.length > 0 && import_react72.default.createElement(
|
|
459558
459736
|
Text,
|
|
459559
459737
|
{ dimColor: true },
|
|
459560
459738
|
" ",
|
|
@@ -556532,6 +556710,19 @@ function useBashMode() {
|
|
|
556532
556710
|
return isSensitiveCommand(command);
|
|
556533
556711
|
}, []);
|
|
556534
556712
|
const executeCommand2 = (0, import_react96.useCallback)(async (command, timeout2 = 3e4) => {
|
|
556713
|
+
const selfDestruct = isSelfDestructiveCommand(command);
|
|
556714
|
+
if (selfDestruct.isSelfDestructive) {
|
|
556715
|
+
setState((prev) => ({ ...prev, isExecuting: false }));
|
|
556716
|
+
return {
|
|
556717
|
+
success: false,
|
|
556718
|
+
stdout: "",
|
|
556719
|
+
stderr: `[SELF-PROTECTION] ${selfDestruct.reason}
|
|
556720
|
+
${selfDestruct.suggestion}`,
|
|
556721
|
+
command,
|
|
556722
|
+
exitCode: 1,
|
|
556723
|
+
signal: null
|
|
556724
|
+
};
|
|
556725
|
+
}
|
|
556535
556726
|
setState((prev) => ({
|
|
556536
556727
|
...prev,
|
|
556537
556728
|
isExecuting: true,
|
|
@@ -556879,6 +557070,7 @@ var init_useBashMode = __esm({
|
|
|
556879
557070
|
"use strict";
|
|
556880
557071
|
import_react96 = __toESM(require_react(), 1);
|
|
556881
557072
|
init_sensitiveCommandManager();
|
|
557073
|
+
init_security_utils();
|
|
556882
557074
|
}
|
|
556883
557075
|
});
|
|
556884
557076
|
|
|
@@ -567562,10 +567754,10 @@ ${cleanThinkingContent2(msg.reasoning_content)}`);
|
|
|
567562
567754
|
}
|
|
567563
567755
|
return parts.length > 0 ? parts.join("\n") : null;
|
|
567564
567756
|
}
|
|
567565
|
-
function prepareMessagesForCompression(conversationMessages,
|
|
567757
|
+
function prepareMessagesForCompression(conversationMessages, customSystemPrompts) {
|
|
567566
567758
|
const messages = [];
|
|
567567
|
-
if (
|
|
567568
|
-
messages.push({ role: "system", content:
|
|
567759
|
+
if (customSystemPrompts && customSystemPrompts.length > 0) {
|
|
567760
|
+
messages.push({ role: "system", content: customSystemPrompts.join("\n\n") });
|
|
567569
567761
|
} else {
|
|
567570
567762
|
messages.push({
|
|
567571
567763
|
role: "system",
|
|
@@ -567595,8 +567787,8 @@ ${conversationTranscript}`
|
|
|
567595
567787
|
});
|
|
567596
567788
|
return messages;
|
|
567597
567789
|
}
|
|
567598
|
-
async function compressWithChatCompletions(modelName, conversationMessages,
|
|
567599
|
-
const messages = prepareMessagesForCompression(conversationMessages,
|
|
567790
|
+
async function compressWithChatCompletions(modelName, conversationMessages, customSystemPrompts) {
|
|
567791
|
+
const messages = prepareMessagesForCompression(conversationMessages, customSystemPrompts);
|
|
567600
567792
|
let summary = "";
|
|
567601
567793
|
let usage = {
|
|
567602
567794
|
prompt_tokens: 0,
|
|
@@ -567624,8 +567816,8 @@ async function compressWithChatCompletions(modelName, conversationMessages, cust
|
|
|
567624
567816
|
}
|
|
567625
567817
|
return { summary, usage };
|
|
567626
567818
|
}
|
|
567627
|
-
async function compressWithResponses(modelName, conversationMessages,
|
|
567628
|
-
const messages = prepareMessagesForCompression(conversationMessages,
|
|
567819
|
+
async function compressWithResponses(modelName, conversationMessages, customSystemPrompts) {
|
|
567820
|
+
const messages = prepareMessagesForCompression(conversationMessages, customSystemPrompts);
|
|
567629
567821
|
let summary = "";
|
|
567630
567822
|
let usage = {
|
|
567631
567823
|
prompt_tokens: 0,
|
|
@@ -567653,8 +567845,8 @@ async function compressWithResponses(modelName, conversationMessages, customSyst
|
|
|
567653
567845
|
}
|
|
567654
567846
|
return { summary, usage };
|
|
567655
567847
|
}
|
|
567656
|
-
async function compressWithGemini(modelName, conversationMessages,
|
|
567657
|
-
const messages = prepareMessagesForCompression(conversationMessages,
|
|
567848
|
+
async function compressWithGemini(modelName, conversationMessages, customSystemPrompts) {
|
|
567849
|
+
const messages = prepareMessagesForCompression(conversationMessages, customSystemPrompts);
|
|
567658
567850
|
let summary = "";
|
|
567659
567851
|
let usage = {
|
|
567660
567852
|
prompt_tokens: 0,
|
|
@@ -567681,8 +567873,8 @@ async function compressWithGemini(modelName, conversationMessages, customSystemP
|
|
|
567681
567873
|
}
|
|
567682
567874
|
return { summary, usage };
|
|
567683
567875
|
}
|
|
567684
|
-
async function compressWithAnthropic(modelName, conversationMessages,
|
|
567685
|
-
const messages = prepareMessagesForCompression(conversationMessages,
|
|
567876
|
+
async function compressWithAnthropic(modelName, conversationMessages, customSystemPrompts) {
|
|
567877
|
+
const messages = prepareMessagesForCompression(conversationMessages, customSystemPrompts);
|
|
567686
567878
|
let summary = "";
|
|
567687
567879
|
let usage = {
|
|
567688
567880
|
prompt_tokens: 0,
|
|
@@ -568349,6 +568541,8 @@ Output: ${combinedOutput}`;
|
|
|
568349
568541
|
} else if (result2.success && result2.action === "showProfilePanel") {
|
|
568350
568542
|
options3.onSwitchProfile();
|
|
568351
568543
|
} else if (result2.success && result2.action === "home") {
|
|
568544
|
+
sessionManager.clearCurrentSession();
|
|
568545
|
+
options3.clearSavedMessages();
|
|
568352
568546
|
resetTerminal(stdout);
|
|
568353
568547
|
navigateTo("welcome");
|
|
568354
568548
|
} else if (result2.success && result2.action === "showUsagePanel") {
|
|
@@ -568523,6 +568717,8 @@ Output: ${combinedOutput}`;
|
|
|
568523
568717
|
options3.setMessages((prev) => [...prev, errorMessage]);
|
|
568524
568718
|
}
|
|
568525
568719
|
} else if (result2.success && result2.action === "home") {
|
|
568720
|
+
sessionManager.clearCurrentSession();
|
|
568721
|
+
options3.clearSavedMessages();
|
|
568526
568722
|
resetTerminal(stdout);
|
|
568527
568723
|
navigateTo("welcome");
|
|
568528
568724
|
} else if (result2.success && result2.action === "toggleYolo") {
|
package/bundle/package.json
CHANGED