snow-ai 0.6.37 → 0.6.39
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 +234 -148
- package/bundle/package.json +1 -1
- package/package.json +1 -1
package/bundle/cli.mjs
CHANGED
|
@@ -1473,7 +1473,7 @@ var require_react_development = __commonJS({
|
|
|
1473
1473
|
}
|
|
1474
1474
|
return dispatcher.useContext(Context);
|
|
1475
1475
|
}
|
|
1476
|
-
function
|
|
1476
|
+
function useState70(initialState) {
|
|
1477
1477
|
var dispatcher = resolveDispatcher();
|
|
1478
1478
|
return dispatcher.useState(initialState);
|
|
1479
1479
|
}
|
|
@@ -1485,7 +1485,7 @@ var require_react_development = __commonJS({
|
|
|
1485
1485
|
var dispatcher = resolveDispatcher();
|
|
1486
1486
|
return dispatcher.useRef(initialValue);
|
|
1487
1487
|
}
|
|
1488
|
-
function
|
|
1488
|
+
function useEffect64(create3, deps) {
|
|
1489
1489
|
var dispatcher = resolveDispatcher();
|
|
1490
1490
|
return dispatcher.useEffect(create3, deps);
|
|
1491
1491
|
}
|
|
@@ -2268,7 +2268,7 @@ var require_react_development = __commonJS({
|
|
|
2268
2268
|
exports2.useContext = useContext13;
|
|
2269
2269
|
exports2.useDebugValue = useDebugValue;
|
|
2270
2270
|
exports2.useDeferredValue = useDeferredValue;
|
|
2271
|
-
exports2.useEffect =
|
|
2271
|
+
exports2.useEffect = useEffect64;
|
|
2272
2272
|
exports2.useId = useId;
|
|
2273
2273
|
exports2.useImperativeHandle = useImperativeHandle2;
|
|
2274
2274
|
exports2.useInsertionEffect = useInsertionEffect;
|
|
@@ -2276,7 +2276,7 @@ var require_react_development = __commonJS({
|
|
|
2276
2276
|
exports2.useMemo = useMemo40;
|
|
2277
2277
|
exports2.useReducer = useReducer8;
|
|
2278
2278
|
exports2.useRef = useRef16;
|
|
2279
|
-
exports2.useState =
|
|
2279
|
+
exports2.useState = useState70;
|
|
2280
2280
|
exports2.useSyncExternalStore = useSyncExternalStore2;
|
|
2281
2281
|
exports2.useTransition = useTransition;
|
|
2282
2282
|
exports2.version = ReactVersion;
|
|
@@ -71304,7 +71304,7 @@ var init_version = __esm({
|
|
|
71304
71304
|
// dist/api/chat.js
|
|
71305
71305
|
function convertToOpenAIMessages(messages, includeBuiltinSystemPrompt = true, customSystemPromptOverride, planMode = false, vulnerabilityHuntingMode = false) {
|
|
71306
71306
|
var _a21;
|
|
71307
|
-
const
|
|
71307
|
+
const customSystemPrompts = customSystemPromptOverride;
|
|
71308
71308
|
let result2 = messages.map((msg) => {
|
|
71309
71309
|
if (msg.role === "user" && msg.images && msg.images.length > 0) {
|
|
71310
71310
|
const contentParts = [];
|
|
@@ -71383,12 +71383,15 @@ function convertToOpenAIMessages(messages, includeBuiltinSystemPrompt = true, cu
|
|
|
71383
71383
|
if (result2.length > 0 && ((_a21 = result2[0]) == null ? void 0 : _a21.role) === "system") {
|
|
71384
71384
|
return result2;
|
|
71385
71385
|
}
|
|
71386
|
-
if (
|
|
71386
|
+
if (customSystemPrompts && customSystemPrompts.length > 0) {
|
|
71387
71387
|
if (includeBuiltinSystemPrompt) {
|
|
71388
71388
|
result2 = [
|
|
71389
71389
|
{
|
|
71390
71390
|
role: "system",
|
|
71391
|
-
content:
|
|
71391
|
+
content: customSystemPrompts.map((text3) => ({
|
|
71392
|
+
type: "text",
|
|
71393
|
+
text: text3
|
|
71394
|
+
}))
|
|
71392
71395
|
},
|
|
71393
71396
|
{
|
|
71394
71397
|
role: "user",
|
|
@@ -71400,7 +71403,10 @@ function convertToOpenAIMessages(messages, includeBuiltinSystemPrompt = true, cu
|
|
|
71400
71403
|
result2 = [
|
|
71401
71404
|
{
|
|
71402
71405
|
role: "system",
|
|
71403
|
-
content:
|
|
71406
|
+
content: customSystemPrompts.map((text3) => ({
|
|
71407
|
+
type: "text",
|
|
71408
|
+
text: text3
|
|
71409
|
+
}))
|
|
71404
71410
|
},
|
|
71405
71411
|
...result2
|
|
71406
71412
|
];
|
|
@@ -71491,8 +71497,8 @@ async function* createStreamingChatCompletion(options3, abortSignal, onRetry) {
|
|
|
71491
71497
|
const { getSystemPromptConfig: getSystemPromptConfig2 } = await Promise.resolve().then(() => (init_apiConfig(), apiConfig_exports));
|
|
71492
71498
|
const systemPromptConfig = getSystemPromptConfig2();
|
|
71493
71499
|
const customPrompt = systemPromptConfig == null ? void 0 : systemPromptConfig.prompts.find((p) => p.id === options3.customSystemPromptId);
|
|
71494
|
-
if (customPrompt) {
|
|
71495
|
-
customSystemPromptContent = customPrompt.content;
|
|
71500
|
+
if (customPrompt == null ? void 0 : customPrompt.content) {
|
|
71501
|
+
customSystemPromptContent = [customPrompt.content];
|
|
71496
71502
|
}
|
|
71497
71503
|
}
|
|
71498
71504
|
customSystemPromptContent || (customSystemPromptContent = getCustomSystemPromptForConfig(config3));
|
|
@@ -71735,7 +71741,7 @@ function toResponseImageUrl(image3) {
|
|
|
71735
71741
|
return `data:${mimeType};base64,${data}`;
|
|
71736
71742
|
}
|
|
71737
71743
|
function convertToResponseInput(messages, includeBuiltinSystemPrompt = true, customSystemPromptOverride, planMode = false, vulnerabilityHuntingMode = false) {
|
|
71738
|
-
const
|
|
71744
|
+
const customSystemPrompts = customSystemPromptOverride;
|
|
71739
71745
|
const result2 = [];
|
|
71740
71746
|
for (const msg of messages) {
|
|
71741
71747
|
if (!msg)
|
|
@@ -71833,8 +71839,8 @@ function convertToResponseInput(messages, includeBuiltinSystemPrompt = true, cus
|
|
|
71833
71839
|
}
|
|
71834
71840
|
}
|
|
71835
71841
|
let systemInstructions;
|
|
71836
|
-
if (
|
|
71837
|
-
systemInstructions =
|
|
71842
|
+
if (customSystemPrompts && customSystemPrompts.length > 0) {
|
|
71843
|
+
systemInstructions = customSystemPrompts.join("\n\n");
|
|
71838
71844
|
if (includeBuiltinSystemPrompt) {
|
|
71839
71845
|
result2.unshift({
|
|
71840
71846
|
type: "message",
|
|
@@ -71927,8 +71933,8 @@ async function* createStreamingResponse(options3, abortSignal, onRetry) {
|
|
|
71927
71933
|
const { getSystemPromptConfig: getSystemPromptConfig2 } = await Promise.resolve().then(() => (init_apiConfig(), apiConfig_exports));
|
|
71928
71934
|
const systemPromptConfig = getSystemPromptConfig2();
|
|
71929
71935
|
const customPrompt = systemPromptConfig == null ? void 0 : systemPromptConfig.prompts.find((p) => p.id === options3.customSystemPromptId);
|
|
71930
|
-
if (customPrompt) {
|
|
71931
|
-
customSystemPromptContent = customPrompt.content;
|
|
71936
|
+
if (customPrompt == null ? void 0 : customPrompt.content) {
|
|
71937
|
+
customSystemPromptContent = [customPrompt.content];
|
|
71932
71938
|
}
|
|
71933
71939
|
}
|
|
71934
71940
|
customSystemPromptContent || (customSystemPromptContent = getCustomSystemPromptForConfig(config3));
|
|
@@ -72203,7 +72209,7 @@ function convertToolsToGemini(tools) {
|
|
|
72203
72209
|
}
|
|
72204
72210
|
function convertToGeminiMessages(messages, includeBuiltinSystemPrompt = true, customSystemPromptOverride, planMode = false, vulnerabilityHuntingMode = false) {
|
|
72205
72211
|
var _a21;
|
|
72206
|
-
const
|
|
72212
|
+
const customSystemPrompts = customSystemPromptOverride;
|
|
72207
72213
|
let systemInstruction;
|
|
72208
72214
|
const contents = [];
|
|
72209
72215
|
const toolCallIdToFunctionName = /* @__PURE__ */ new Map();
|
|
@@ -72212,7 +72218,7 @@ function convertToGeminiMessages(messages, includeBuiltinSystemPrompt = true, cu
|
|
|
72212
72218
|
if (!msg)
|
|
72213
72219
|
continue;
|
|
72214
72220
|
if (msg.role === "system") {
|
|
72215
|
-
systemInstruction = msg.content;
|
|
72221
|
+
systemInstruction = [msg.content];
|
|
72216
72222
|
continue;
|
|
72217
72223
|
}
|
|
72218
72224
|
if (msg.role === "assistant" && msg.tool_calls && msg.tool_calls.length > 0) {
|
|
@@ -72335,8 +72341,8 @@ function convertToGeminiMessages(messages, includeBuiltinSystemPrompt = true, cu
|
|
|
72335
72341
|
const role = msg.role === "assistant" ? "model" : "user";
|
|
72336
72342
|
contents.push({ role, parts });
|
|
72337
72343
|
}
|
|
72338
|
-
if (
|
|
72339
|
-
systemInstruction =
|
|
72344
|
+
if (customSystemPrompts && customSystemPrompts.length > 0) {
|
|
72345
|
+
systemInstruction = customSystemPrompts;
|
|
72340
72346
|
if (includeBuiltinSystemPrompt) {
|
|
72341
72347
|
contents.unshift({
|
|
72342
72348
|
role: "user",
|
|
@@ -72344,9 +72350,11 @@ function convertToGeminiMessages(messages, includeBuiltinSystemPrompt = true, cu
|
|
|
72344
72350
|
{ text: getSystemPromptForMode(planMode, vulnerabilityHuntingMode) }
|
|
72345
72351
|
]
|
|
72346
72352
|
});
|
|
72347
|
-
} else if (!systemInstruction && includeBuiltinSystemPrompt) {
|
|
72348
|
-
systemInstruction = getSystemPromptForMode(planMode, vulnerabilityHuntingMode);
|
|
72349
72353
|
}
|
|
72354
|
+
} else if (!systemInstruction && includeBuiltinSystemPrompt) {
|
|
72355
|
+
systemInstruction = [
|
|
72356
|
+
getSystemPromptForMode(planMode, vulnerabilityHuntingMode)
|
|
72357
|
+
];
|
|
72350
72358
|
}
|
|
72351
72359
|
return { systemInstruction, contents };
|
|
72352
72360
|
}
|
|
@@ -72376,8 +72384,8 @@ async function* createStreamingGeminiCompletion(options3, abortSignal, onRetry)
|
|
|
72376
72384
|
const { getSystemPromptConfig: getSystemPromptConfig2 } = await Promise.resolve().then(() => (init_apiConfig(), apiConfig_exports));
|
|
72377
72385
|
const systemPromptConfig = getSystemPromptConfig2();
|
|
72378
72386
|
const customPrompt = systemPromptConfig == null ? void 0 : systemPromptConfig.prompts.find((p) => p.id === options3.customSystemPromptId);
|
|
72379
|
-
if (customPrompt) {
|
|
72380
|
-
customSystemPromptContent = customPrompt.content;
|
|
72387
|
+
if (customPrompt == null ? void 0 : customPrompt.content) {
|
|
72388
|
+
customSystemPromptContent = [customPrompt.content];
|
|
72381
72389
|
}
|
|
72382
72390
|
}
|
|
72383
72391
|
customSystemPromptContent || (customSystemPromptContent = getCustomSystemPromptForConfig(config3));
|
|
@@ -72393,7 +72401,7 @@ async function* createStreamingGeminiCompletion(options3, abortSignal, onRetry)
|
|
|
72393
72401
|
);
|
|
72394
72402
|
const requestBody = {
|
|
72395
72403
|
contents,
|
|
72396
|
-
systemInstruction: systemInstruction ? { parts:
|
|
72404
|
+
systemInstruction: systemInstruction ? { parts: systemInstruction.map((text3) => ({ text: text3 })) } : void 0
|
|
72397
72405
|
};
|
|
72398
72406
|
if ((_a21 = config3.geminiThinking) == null ? void 0 : _a21.enabled) {
|
|
72399
72407
|
requestBody.generationConfig = {
|
|
@@ -73324,13 +73332,13 @@ Please provide your review in a clear, structured format.`;
|
|
|
73324
73332
|
if (!config3.advancedModel) {
|
|
73325
73333
|
throw new Error("Advanced model not configured");
|
|
73326
73334
|
}
|
|
73327
|
-
const
|
|
73335
|
+
const customSystemPrompts = getCustomSystemPrompt();
|
|
73328
73336
|
let processedMessages = messages;
|
|
73329
|
-
if (
|
|
73337
|
+
if (customSystemPrompts && customSystemPrompts.length > 0) {
|
|
73330
73338
|
processedMessages = [
|
|
73331
73339
|
{
|
|
73332
73340
|
role: "system",
|
|
73333
|
-
content:
|
|
73341
|
+
content: customSystemPrompts.join("\n\n")
|
|
73334
73342
|
},
|
|
73335
73343
|
...messages
|
|
73336
73344
|
];
|
|
@@ -74918,7 +74926,7 @@ function migrateSystemPromptFromTxt() {
|
|
|
74918
74926
|
return;
|
|
74919
74927
|
}
|
|
74920
74928
|
const config3 = {
|
|
74921
|
-
active: "default",
|
|
74929
|
+
active: ["default"],
|
|
74922
74930
|
prompts: [
|
|
74923
74931
|
{
|
|
74924
74932
|
id: "default",
|
|
@@ -74948,6 +74956,11 @@ function getSystemPromptConfig() {
|
|
|
74948
74956
|
return void 0;
|
|
74949
74957
|
}
|
|
74950
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
|
+
}
|
|
74951
74964
|
return config3;
|
|
74952
74965
|
} catch (error) {
|
|
74953
74966
|
console.error("Failed to read system prompt config:", error);
|
|
@@ -74976,14 +74989,21 @@ function getCustomSystemPromptForConfig(apiConfig) {
|
|
|
74976
74989
|
return void 0;
|
|
74977
74990
|
}
|
|
74978
74991
|
if (systemPromptId) {
|
|
74979
|
-
const
|
|
74980
|
-
|
|
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;
|
|
74981
74998
|
}
|
|
74982
|
-
if (!config3.active) {
|
|
74999
|
+
if (!config3.active || config3.active.length === 0) {
|
|
74983
75000
|
return void 0;
|
|
74984
75001
|
}
|
|
74985
|
-
const
|
|
74986
|
-
|
|
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;
|
|
74987
75007
|
}
|
|
74988
75008
|
function getCustomHeaders() {
|
|
74989
75009
|
return getCustomHeadersForConfig(getOpenAiConfig());
|
|
@@ -75209,12 +75229,12 @@ function convertToolsToAnthropic(tools) {
|
|
|
75209
75229
|
}
|
|
75210
75230
|
function convertToAnthropicMessages(messages, includeBuiltinSystemPrompt = true, customSystemPromptOverride, cacheTTL = "5m", disableThinking = false, planMode = false, vulnerabilityHuntingMode = false) {
|
|
75211
75231
|
var _a21;
|
|
75212
|
-
const
|
|
75213
|
-
let
|
|
75232
|
+
const customSystemPrompts = customSystemPromptOverride;
|
|
75233
|
+
let systemContents;
|
|
75214
75234
|
const anthropicMessages = [];
|
|
75215
75235
|
for (const msg of messages) {
|
|
75216
75236
|
if (msg.role === "system") {
|
|
75217
|
-
|
|
75237
|
+
systemContents = [msg.content];
|
|
75218
75238
|
continue;
|
|
75219
75239
|
}
|
|
75220
75240
|
if (msg.role === "tool" && msg.tool_call_id) {
|
|
@@ -75342,8 +75362,8 @@ function convertToAnthropicMessages(messages, includeBuiltinSystemPrompt = true,
|
|
|
75342
75362
|
}
|
|
75343
75363
|
}
|
|
75344
75364
|
}
|
|
75345
|
-
if (
|
|
75346
|
-
|
|
75365
|
+
if (customSystemPrompts && customSystemPrompts.length > 0) {
|
|
75366
|
+
systemContents = customSystemPrompts;
|
|
75347
75367
|
if (includeBuiltinSystemPrompt) {
|
|
75348
75368
|
anthropicMessages.unshift({
|
|
75349
75369
|
role: "user",
|
|
@@ -75355,14 +75375,16 @@ function convertToAnthropicMessages(messages, includeBuiltinSystemPrompt = true,
|
|
|
75355
75375
|
}
|
|
75356
75376
|
]
|
|
75357
75377
|
});
|
|
75358
|
-
} else if (!systemContent && includeBuiltinSystemPrompt) {
|
|
75359
|
-
systemContent = getSystemPromptForMode(planMode, vulnerabilityHuntingMode);
|
|
75360
75378
|
}
|
|
75379
|
+
} else if (!systemContents && includeBuiltinSystemPrompt) {
|
|
75380
|
+
systemContents = [
|
|
75381
|
+
getSystemPromptForMode(planMode, vulnerabilityHuntingMode)
|
|
75382
|
+
];
|
|
75361
75383
|
}
|
|
75362
75384
|
let lastUserMessageIndex = -1;
|
|
75363
75385
|
for (let i = anthropicMessages.length - 1; i >= 0; i--) {
|
|
75364
75386
|
if (((_a21 = anthropicMessages[i]) == null ? void 0 : _a21.role) === "user") {
|
|
75365
|
-
if (
|
|
75387
|
+
if (customSystemPrompts && customSystemPrompts.length > 0 && i === 0) {
|
|
75366
75388
|
continue;
|
|
75367
75389
|
}
|
|
75368
75390
|
lastUserMessageIndex = i;
|
|
@@ -75389,13 +75411,11 @@ function convertToAnthropicMessages(messages, includeBuiltinSystemPrompt = true,
|
|
|
75389
75411
|
}
|
|
75390
75412
|
}
|
|
75391
75413
|
}
|
|
75392
|
-
const system =
|
|
75393
|
-
|
|
75394
|
-
|
|
75395
|
-
|
|
75396
|
-
|
|
75397
|
-
}
|
|
75398
|
-
] : 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;
|
|
75399
75419
|
return { system, messages: anthropicMessages };
|
|
75400
75420
|
}
|
|
75401
75421
|
async function* parseSSEStream3(reader) {
|
|
@@ -75470,8 +75490,8 @@ async function* createStreamingAnthropicCompletion(options3, abortSignal, onRetr
|
|
|
75470
75490
|
const { getSystemPromptConfig: getSystemPromptConfig2 } = await Promise.resolve().then(() => (init_apiConfig(), apiConfig_exports));
|
|
75471
75491
|
const systemPromptConfig = getSystemPromptConfig2();
|
|
75472
75492
|
const customPrompt = systemPromptConfig == null ? void 0 : systemPromptConfig.prompts.find((p) => p.id === options3.customSystemPromptId);
|
|
75473
|
-
if (customPrompt) {
|
|
75474
|
-
customSystemPromptContent = customPrompt.content;
|
|
75493
|
+
if (customPrompt == null ? void 0 : customPrompt.content) {
|
|
75494
|
+
customSystemPromptContent = [customPrompt.content];
|
|
75475
75495
|
}
|
|
75476
75496
|
}
|
|
75477
75497
|
customSystemPromptContent || (customSystemPromptContent = getCustomSystemPromptForConfig(config3));
|
|
@@ -81079,19 +81099,19 @@ var init_en = __esm({
|
|
|
81079
81099
|
},
|
|
81080
81100
|
systemPromptConfig: {
|
|
81081
81101
|
title: "System Prompt Management",
|
|
81082
|
-
subtitle: "Manage multiple system prompts
|
|
81083
|
-
activePrompt: "Active
|
|
81102
|
+
subtitle: "Manage multiple system prompts (multi-select supported)",
|
|
81103
|
+
activePrompt: "Active Prompts:",
|
|
81084
81104
|
none: "None",
|
|
81085
81105
|
noPromptsConfigured: "No system prompts configured. Press Enter to add one.",
|
|
81086
81106
|
availablePrompts: "Available Prompts:",
|
|
81087
81107
|
actions: "Actions:",
|
|
81088
|
-
activate: "
|
|
81089
|
-
deactivate: "Deactivate",
|
|
81108
|
+
activate: "Toggle",
|
|
81109
|
+
deactivate: "Deactivate All",
|
|
81090
81110
|
edit: "Edit",
|
|
81091
81111
|
delete: "Delete",
|
|
81092
81112
|
addNew: "Add New",
|
|
81093
81113
|
escBack: "[ESC] Back",
|
|
81094
|
-
navigationHint: "
|
|
81114
|
+
navigationHint: "\u2191\u2193 Select prompt | Space Toggle | \u2190\u2192 Select action | Enter Confirm",
|
|
81095
81115
|
addNewTitle: "Add New System Prompt",
|
|
81096
81116
|
editTitle: "Edit System Prompt",
|
|
81097
81117
|
nameLabel: "Name:",
|
|
@@ -81108,7 +81128,8 @@ var init_en = __esm({
|
|
|
81108
81128
|
confirmDelete: "Confirm Delete",
|
|
81109
81129
|
deleteConfirmMessage: "Are you sure you want to delete",
|
|
81110
81130
|
confirmHint: "Press Y to confirm, N or ESC to cancel",
|
|
81111
|
-
saveError: "Failed to save"
|
|
81131
|
+
saveError: "Failed to save",
|
|
81132
|
+
activeCount: "{count} active"
|
|
81112
81133
|
},
|
|
81113
81134
|
configScreen: {
|
|
81114
81135
|
title: "API & Model Configuration",
|
|
@@ -81190,7 +81211,8 @@ var init_en = __esm({
|
|
|
81190
81211
|
followGlobal: "Follow Global: {name}",
|
|
81191
81212
|
followGlobalWithParentheses: "Follow Global ({name})",
|
|
81192
81213
|
followGlobalNoneWithParentheses: "Follow Global (None)",
|
|
81193
|
-
notUse: "Not Use"
|
|
81214
|
+
notUse: "Not Use",
|
|
81215
|
+
systemPromptMultiSelectHint: "Space: toggle | Enter: confirm | Esc: cancel"
|
|
81194
81216
|
},
|
|
81195
81217
|
customHeaders: {
|
|
81196
81218
|
title: "Custom Headers Management",
|
|
@@ -82344,19 +82366,19 @@ var init_zh = __esm({
|
|
|
82344
82366
|
},
|
|
82345
82367
|
systemPromptConfig: {
|
|
82346
82368
|
title: "\u7CFB\u7EDF\u63D0\u793A\u8BCD\u7BA1\u7406",
|
|
82347
|
-
subtitle: "\u7BA1\u7406\u591A\u4E2A\u7CFB\u7EDF\u63D0\u793A\u8BCD\
|
|
82348
|
-
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:",
|
|
82349
82371
|
none: "\u65E0",
|
|
82350
82372
|
noPromptsConfigured: "\u672A\u914D\u7F6E\u7CFB\u7EDF\u63D0\u793A\u8BCD\u3002\u6309 Enter \u6DFB\u52A0\u4E00\u4E2A\u3002",
|
|
82351
82373
|
availablePrompts: "\u53EF\u7528\u63D0\u793A\u8BCD:",
|
|
82352
82374
|
actions: "\u64CD\u4F5C:",
|
|
82353
|
-
activate: "\u6FC0\u6D3B",
|
|
82354
|
-
deactivate: "\u505C\u7528",
|
|
82375
|
+
activate: "\u5207\u6362\u6FC0\u6D3B",
|
|
82376
|
+
deactivate: "\u5168\u90E8\u505C\u7528",
|
|
82355
82377
|
edit: "\u7F16\u8F91",
|
|
82356
82378
|
delete: "\u5220\u9664",
|
|
82357
82379
|
addNew: "\u6DFB\u52A0\u65B0\u63D0\u793A\u8BCD",
|
|
82358
82380
|
escBack: "[ESC] \u8FD4\u56DE",
|
|
82359
|
-
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",
|
|
82360
82382
|
addNewTitle: "\u6DFB\u52A0\u65B0\u7CFB\u7EDF\u63D0\u793A\u8BCD",
|
|
82361
82383
|
editTitle: "\u7F16\u8F91\u7CFB\u7EDF\u63D0\u793A\u8BCD",
|
|
82362
82384
|
nameLabel: "\u540D\u79F0:",
|
|
@@ -82373,7 +82395,8 @@ var init_zh = __esm({
|
|
|
82373
82395
|
confirmDelete: "\u786E\u8BA4\u5220\u9664",
|
|
82374
82396
|
deleteConfirmMessage: "\u786E\u5B9A\u8981\u5220\u9664",
|
|
82375
82397
|
confirmHint: "\u6309 Y \u786E\u8BA4,N \u6216 ESC \u53D6\u6D88",
|
|
82376
|
-
saveError: "\u4FDD\u5B58\u5931\u8D25"
|
|
82398
|
+
saveError: "\u4FDD\u5B58\u5931\u8D25",
|
|
82399
|
+
activeCount: "\u5DF2\u6FC0\u6D3B {count} \u4E2A"
|
|
82377
82400
|
},
|
|
82378
82401
|
configScreen: {
|
|
82379
82402
|
title: "API \u548C\u6A21\u578B\u914D\u7F6E",
|
|
@@ -82455,7 +82478,8 @@ var init_zh = __esm({
|
|
|
82455
82478
|
followGlobal: "\u8DDF\u968F\u5168\u5C40\uFF1A{name}",
|
|
82456
82479
|
followGlobalWithParentheses: "\u8DDF\u968F\u5168\u5C40\uFF08{name}\uFF09",
|
|
82457
82480
|
followGlobalNoneWithParentheses: "\u8DDF\u968F\u5168\u5C40\uFF08\u65E0\uFF09",
|
|
82458
|
-
notUse: "\u4E0D\u4F7F\u7528"
|
|
82481
|
+
notUse: "\u4E0D\u4F7F\u7528",
|
|
82482
|
+
systemPromptMultiSelectHint: "\u7A7A\u683C: \u5207\u6362\u9009\u4E2D | Enter: \u786E\u8BA4 | Esc: \u53D6\u6D88"
|
|
82459
82483
|
},
|
|
82460
82484
|
customHeaders: {
|
|
82461
82485
|
title: "\u81EA\u5B9A\u4E49\u8BF7\u6C42\u5934\u7BA1\u7406",
|
|
@@ -83608,19 +83632,19 @@ var init_zh_TW = __esm({
|
|
|
83608
83632
|
},
|
|
83609
83633
|
systemPromptConfig: {
|
|
83610
83634
|
title: "\u7CFB\u7D71\u63D0\u793A\u8A5E\u7BA1\u7406",
|
|
83611
|
-
subtitle: "\u7BA1\u7406\u591A\u500B\u7CFB\u7D71\u63D0\u793A\u8A5E\
|
|
83612
|
-
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:",
|
|
83613
83637
|
none: "\u7121",
|
|
83614
83638
|
noPromptsConfigured: "\u672A\u914D\u7F6E\u7CFB\u7D71\u63D0\u793A\u8A5E\u3002\u6309 Enter \u65B0\u589E\u4E00\u500B\u3002",
|
|
83615
83639
|
availablePrompts: "\u53EF\u7528\u63D0\u793A\u8A5E:",
|
|
83616
83640
|
actions: "\u64CD\u4F5C:",
|
|
83617
|
-
activate: "\u555F\u7528",
|
|
83618
|
-
deactivate: "\u505C\u7528",
|
|
83641
|
+
activate: "\u5207\u63DB\u555F\u7528",
|
|
83642
|
+
deactivate: "\u5168\u90E8\u505C\u7528",
|
|
83619
83643
|
edit: "\u7DE8\u8F2F",
|
|
83620
83644
|
delete: "\u522A\u9664",
|
|
83621
83645
|
addNew: "\u65B0\u589E\u65B0\u63D0\u793A\u8A5E",
|
|
83622
83646
|
escBack: "[ESC] \u8FD4\u56DE",
|
|
83623
|
-
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",
|
|
83624
83648
|
addNewTitle: "\u65B0\u589E\u65B0\u7CFB\u7D71\u63D0\u793A\u8A5E",
|
|
83625
83649
|
editTitle: "\u7DE8\u8F2F\u7CFB\u7D71\u63D0\u793A\u8A5E",
|
|
83626
83650
|
nameLabel: "\u540D\u7A31:",
|
|
@@ -83637,7 +83661,8 @@ var init_zh_TW = __esm({
|
|
|
83637
83661
|
confirmDelete: "\u78BA\u8A8D\u522A\u9664",
|
|
83638
83662
|
deleteConfirmMessage: "\u78BA\u5B9A\u8981\u522A\u9664",
|
|
83639
83663
|
confirmHint: "\u6309 Y \u78BA\u8A8D,N \u6216 ESC \u53D6\u6D88",
|
|
83640
|
-
saveError: "\u5132\u5B58\u5931\u6557"
|
|
83664
|
+
saveError: "\u5132\u5B58\u5931\u6557",
|
|
83665
|
+
activeCount: "\u5DF2\u555F\u7528 {count} \u500B"
|
|
83641
83666
|
},
|
|
83642
83667
|
configScreen: {
|
|
83643
83668
|
title: "API \u548C\u6A21\u578B\u914D\u7F6E",
|
|
@@ -83719,7 +83744,8 @@ var init_zh_TW = __esm({
|
|
|
83719
83744
|
followGlobal: "\u8DDF\u96A8\u5168\u57DF\uFF1A{name}",
|
|
83720
83745
|
followGlobalWithParentheses: "\u8DDF\u96A8\u5168\u57DF\uFF08{name}\uFF09",
|
|
83721
83746
|
followGlobalNoneWithParentheses: "\u8DDF\u96A8\u5168\u57DF\uFF08\u7121\uFF09",
|
|
83722
|
-
notUse: "\u4E0D\u4F7F\u7528"
|
|
83747
|
+
notUse: "\u4E0D\u4F7F\u7528",
|
|
83748
|
+
systemPromptMultiSelectHint: "\u7A7A\u683C: \u5207\u63DB\u9078\u4E2D | Enter: \u78BA\u8A8D | Esc: \u53D6\u6D88"
|
|
83723
83749
|
},
|
|
83724
83750
|
customHeaders: {
|
|
83725
83751
|
title: "\u81EA\u8A02\u8ACB\u6C42\u982D\u7BA1\u7406",
|
|
@@ -89373,49 +89399,15 @@ var init_Menu = __esm({
|
|
|
89373
89399
|
// dist/ui/components/common/UpdateNotice.js
|
|
89374
89400
|
function UpdateNotice({ currentVersion: currentVersion2, latestVersion, terminalWidth }) {
|
|
89375
89401
|
const { t } = useI18n();
|
|
89376
|
-
const [wavePosition, setWavePosition] = (0, import_react61.useState)(0);
|
|
89377
|
-
(0, import_react61.useEffect)(() => {
|
|
89378
|
-
const interval = setInterval(() => {
|
|
89379
|
-
setWavePosition((prev) => (prev + 1) % 12);
|
|
89380
|
-
}, 100);
|
|
89381
|
-
return () => clearInterval(interval);
|
|
89382
|
-
}, []);
|
|
89383
|
-
const waveChars = ["\u2591", "\u2592", "\u2593", "\u2588", "\u2593", "\u2592", "\u2591"];
|
|
89384
|
-
const arrowHeight = 8;
|
|
89385
|
-
const arrowShapes = [
|
|
89386
|
-
" \u2588 ",
|
|
89387
|
-
" \u2588\u2588\u2588 ",
|
|
89388
|
-
" \u2588\u2588\u2588\u2588\u2588 ",
|
|
89389
|
-
" \u2588\u2588\u2588\u2588\u2588\u2588\u2588 ",
|
|
89390
|
-
" \u2588\u2588\u2588 ",
|
|
89391
|
-
" \u2588\u2588\u2588 ",
|
|
89392
|
-
" \u2588\u2588\u2588 ",
|
|
89393
|
-
" \u2588\u2588\u2588 "
|
|
89394
|
-
];
|
|
89395
|
-
const createWaveArrow = () => {
|
|
89396
|
-
const lines = [];
|
|
89397
|
-
for (let row = 0; row < arrowHeight; row++) {
|
|
89398
|
-
const shape = arrowShapes[row] || "";
|
|
89399
|
-
const waveOffset = (wavePosition + row) % 12;
|
|
89400
|
-
let waveChar = "\u2591";
|
|
89401
|
-
if (waveOffset < waveChars.length) {
|
|
89402
|
-
waveChar = waveChars[waveOffset] || "\u2591";
|
|
89403
|
-
}
|
|
89404
|
-
const line = shape.replace(/█/g, waveChar);
|
|
89405
|
-
lines.push(line);
|
|
89406
|
-
}
|
|
89407
|
-
return lines;
|
|
89408
|
-
};
|
|
89409
|
-
const arrowLines = createWaveArrow();
|
|
89410
89402
|
return import_react61.default.createElement(
|
|
89411
89403
|
Box_default,
|
|
89412
89404
|
{ paddingX: 1, marginBottom: 1 },
|
|
89413
89405
|
import_react61.default.createElement(
|
|
89414
89406
|
Box_default,
|
|
89415
|
-
{ borderStyle: "double", borderColor: "#FFD700", paddingX: 2, paddingY: 1, width: terminalWidth - 2
|
|
89407
|
+
{ borderStyle: "double", borderColor: "#FFD700", paddingX: 2, paddingY: 1, width: terminalWidth - 2 },
|
|
89416
89408
|
import_react61.default.createElement(
|
|
89417
89409
|
Box_default,
|
|
89418
|
-
{ flexDirection: "column"
|
|
89410
|
+
{ flexDirection: "column" },
|
|
89419
89411
|
import_react61.default.createElement(Text, { bold: true, color: "#FFD700" }, t.welcome.updateNoticeTitle),
|
|
89420
89412
|
import_react61.default.createElement(
|
|
89421
89413
|
Text,
|
|
@@ -89449,8 +89441,7 @@ function UpdateNotice({ currentVersion: currentVersion2, latestVersion, terminal
|
|
|
89449
89441
|
" ",
|
|
89450
89442
|
"https://github.com/MayDay-wpf/snow-cli"
|
|
89451
89443
|
)
|
|
89452
|
-
)
|
|
89453
|
-
import_react61.default.createElement(Box_default, { flexDirection: "column", marginLeft: 2, justifyContent: "center" }, arrowLines.map((line, index) => import_react61.default.createElement(Text, { key: index, color: "#FFD700" }, line)))
|
|
89444
|
+
)
|
|
89454
89445
|
)
|
|
89455
89446
|
);
|
|
89456
89447
|
}
|
|
@@ -89902,7 +89893,8 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
|
|
|
89902
89893
|
const [systemPromptId, setSystemPromptId] = (0, import_react64.useState)(void 0);
|
|
89903
89894
|
const [customHeadersSchemeId, setCustomHeadersSchemeId] = (0, import_react64.useState)(void 0);
|
|
89904
89895
|
const [systemPrompts, setSystemPrompts] = (0, import_react64.useState)([]);
|
|
89905
|
-
const [
|
|
89896
|
+
const [activeSystemPromptIds, setActiveSystemPromptIds] = (0, import_react64.useState)([]);
|
|
89897
|
+
const [pendingPromptIds, setPendingPromptIds] = (0, import_react64.useState)(/* @__PURE__ */ new Set());
|
|
89906
89898
|
const [customHeaderSchemes, setCustomHeaderSchemes] = (0, import_react64.useState)([]);
|
|
89907
89899
|
const [activeCustomHeadersSchemeId, setActiveCustomHeadersSchemeId] = (0, import_react64.useState)("");
|
|
89908
89900
|
const [anthropicBeta, setAnthropicBeta] = (0, import_react64.useState)(false);
|
|
@@ -90060,7 +90052,7 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
|
|
|
90060
90052
|
setEditSimilarityThreshold(config3.editSimilarityThreshold ?? 0.75);
|
|
90061
90053
|
const systemPromptConfig = getSystemPromptConfig();
|
|
90062
90054
|
setSystemPrompts(((systemPromptConfig == null ? void 0 : systemPromptConfig.prompts) || []).map((p) => ({ id: p.id, name: p.name })));
|
|
90063
|
-
|
|
90055
|
+
setActiveSystemPromptIds((systemPromptConfig == null ? void 0 : systemPromptConfig.active) || []);
|
|
90064
90056
|
const customHeadersConfig = getCustomHeadersConfig();
|
|
90065
90057
|
setCustomHeaderSchemes(((customHeadersConfig == null ? void 0 : customHeadersConfig.schemes) || []).map((s) => ({ id: s.id, name: s.name })));
|
|
90066
90058
|
setActiveCustomHeadersSchemeId((customHeadersConfig == null ? void 0 : customHeadersConfig.active) || "");
|
|
@@ -90165,7 +90157,8 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
|
|
|
90165
90157
|
return `${resolvedBaseUrl}/chat/completions`;
|
|
90166
90158
|
};
|
|
90167
90159
|
const getSystemPromptSelectItems = () => {
|
|
90168
|
-
const
|
|
90160
|
+
const activeNames = activeSystemPromptIds.map((id) => getSystemPromptNameById(id)).join(", ");
|
|
90161
|
+
const activeLabel = activeNames ? t.configScreen.followGlobalWithParentheses.replace("{name}", activeNames) : t.configScreen.followGlobalNoneWithParentheses;
|
|
90169
90162
|
return [
|
|
90170
90163
|
{ label: activeLabel, value: "__FOLLOW__" },
|
|
90171
90164
|
{ label: t.configScreen.notUse, value: "__DISABLED__" },
|
|
@@ -90178,6 +90171,8 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
|
|
|
90178
90171
|
const getSystemPromptSelectedValue = () => {
|
|
90179
90172
|
if (systemPromptId === "")
|
|
90180
90173
|
return "__DISABLED__";
|
|
90174
|
+
if (Array.isArray(systemPromptId))
|
|
90175
|
+
return "__FOLLOW__";
|
|
90181
90176
|
if (systemPromptId)
|
|
90182
90177
|
return systemPromptId;
|
|
90183
90178
|
return "__FOLLOW__";
|
|
@@ -90473,10 +90468,13 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
|
|
|
90473
90468
|
let display = t.configScreen.followGlobalNone;
|
|
90474
90469
|
if (systemPromptId === "") {
|
|
90475
90470
|
display = t.configScreen.notUse;
|
|
90476
|
-
} else if (systemPromptId) {
|
|
90471
|
+
} else if (Array.isArray(systemPromptId) && systemPromptId.length > 0) {
|
|
90472
|
+
display = systemPromptId.map((id) => getSystemPromptNameById(id)).join(", ");
|
|
90473
|
+
} else if (systemPromptId && typeof systemPromptId === "string") {
|
|
90477
90474
|
display = getSystemPromptNameById(systemPromptId);
|
|
90478
|
-
} else if (
|
|
90479
|
-
|
|
90475
|
+
} else if (activeSystemPromptIds.length > 0) {
|
|
90476
|
+
const activeNames = activeSystemPromptIds.map((id) => getSystemPromptNameById(id)).join(", ");
|
|
90477
|
+
display = t.configScreen.followGlobal.replace("{name}", activeNames);
|
|
90480
90478
|
}
|
|
90481
90479
|
return import_react64.default.createElement(
|
|
90482
90480
|
Box_default,
|
|
@@ -90991,6 +90989,9 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
|
|
|
90991
90989
|
if (isEditing && (currentField === "profile" || currentField === "requestMethod" || currentField === "systemPromptId" || currentField === "customHeadersSchemeId" || currentField === "anthropicCacheTTL" || currentField === "advancedModel" || currentField === "basicModel" || currentField === "responsesReasoningEffort") && key.escape) {
|
|
90992
90990
|
setIsEditing(false);
|
|
90993
90991
|
setSearchTerm("");
|
|
90992
|
+
if (currentField === "systemPromptId") {
|
|
90993
|
+
setPendingPromptIds(/* @__PURE__ */ new Set());
|
|
90994
|
+
}
|
|
90994
90995
|
forceUpdate((prev) => prev + 1);
|
|
90995
90996
|
return;
|
|
90996
90997
|
}
|
|
@@ -91130,6 +91131,15 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
|
|
|
91130
91131
|
setManualInputValue(getCurrentValue());
|
|
91131
91132
|
});
|
|
91132
91133
|
} else {
|
|
91134
|
+
if (currentField === "systemPromptId") {
|
|
91135
|
+
if (Array.isArray(systemPromptId)) {
|
|
91136
|
+
setPendingPromptIds(new Set(systemPromptId));
|
|
91137
|
+
} else if (systemPromptId && systemPromptId !== "") {
|
|
91138
|
+
setPendingPromptIds(/* @__PURE__ */ new Set([systemPromptId]));
|
|
91139
|
+
} else {
|
|
91140
|
+
setPendingPromptIds(/* @__PURE__ */ new Set());
|
|
91141
|
+
}
|
|
91142
|
+
}
|
|
91133
91143
|
setIsEditing(true);
|
|
91134
91144
|
}
|
|
91135
91145
|
}
|
|
@@ -91459,10 +91469,54 @@ function ConfigScreen({ onBack, onSave, inlineMode = false }) {
|
|
|
91459
91469
|
currentField === "systemPromptId" && (() => {
|
|
91460
91470
|
const items = getSystemPromptSelectItems();
|
|
91461
91471
|
const selected = getSystemPromptSelectedValue();
|
|
91462
|
-
return import_react64.default.createElement(
|
|
91463
|
-
|
|
91464
|
-
|
|
91465
|
-
|
|
91472
|
+
return import_react64.default.createElement(
|
|
91473
|
+
Box_default,
|
|
91474
|
+
{ flexDirection: "column" },
|
|
91475
|
+
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 }) => {
|
|
91476
|
+
const isMeta = value === "__FOLLOW__" || value === "__DISABLED__";
|
|
91477
|
+
return import_react64.default.createElement(
|
|
91478
|
+
Text,
|
|
91479
|
+
{ color: isSelected ? "cyan" : isMarked ? theme14.colors.menuInfo : "white" },
|
|
91480
|
+
isMeta ? "" : isMarked ? "[\u2713] " : "[ ] ",
|
|
91481
|
+
label
|
|
91482
|
+
);
|
|
91483
|
+
}, onToggleItem: (item) => {
|
|
91484
|
+
if (item.value === "__FOLLOW__" || item.value === "__DISABLED__") {
|
|
91485
|
+
applySystemPromptSelectValue(item.value);
|
|
91486
|
+
setPendingPromptIds(/* @__PURE__ */ new Set());
|
|
91487
|
+
setIsEditing(false);
|
|
91488
|
+
return;
|
|
91489
|
+
}
|
|
91490
|
+
setPendingPromptIds((prev) => {
|
|
91491
|
+
const next = new Set(prev);
|
|
91492
|
+
if (next.has(item.value)) {
|
|
91493
|
+
next.delete(item.value);
|
|
91494
|
+
} else {
|
|
91495
|
+
next.add(item.value);
|
|
91496
|
+
}
|
|
91497
|
+
return next;
|
|
91498
|
+
});
|
|
91499
|
+
}, onSelect: (item) => {
|
|
91500
|
+
if (item.value === "__FOLLOW__" || item.value === "__DISABLED__") {
|
|
91501
|
+
applySystemPromptSelectValue(item.value);
|
|
91502
|
+
setPendingPromptIds(/* @__PURE__ */ new Set());
|
|
91503
|
+
setIsEditing(false);
|
|
91504
|
+
return;
|
|
91505
|
+
}
|
|
91506
|
+
const finalIds = pendingPromptIds.size > 0 ? Array.from(pendingPromptIds) : [item.value];
|
|
91507
|
+
if (pendingPromptIds.size > 0 && !pendingPromptIds.has(item.value)) {
|
|
91508
|
+
finalIds.push(item.value);
|
|
91509
|
+
}
|
|
91510
|
+
setSystemPromptId(finalIds.length === 1 ? finalIds[0] : finalIds);
|
|
91511
|
+
setPendingPromptIds(/* @__PURE__ */ new Set());
|
|
91512
|
+
setIsEditing(false);
|
|
91513
|
+
} }),
|
|
91514
|
+
import_react64.default.createElement(
|
|
91515
|
+
Box_default,
|
|
91516
|
+
{ marginTop: 1 },
|
|
91517
|
+
import_react64.default.createElement(Text, { color: theme14.colors.menuSecondary, dimColor: true }, t.configScreen.systemPromptMultiSelectHint || "Space: toggle | Enter: confirm | Esc: cancel")
|
|
91518
|
+
)
|
|
91519
|
+
);
|
|
91466
91520
|
})(),
|
|
91467
91521
|
currentField === "customHeadersSchemeId" && (() => {
|
|
91468
91522
|
const items = getCustomHeadersSchemeSelectItems();
|
|
@@ -442348,20 +442402,33 @@ var init_sessionManager = __esm({
|
|
|
442348
442402
|
if (!this.currentSession || this.currentSession.messages.length < 2) {
|
|
442349
442403
|
return;
|
|
442350
442404
|
}
|
|
442405
|
+
const targetSession = this.currentSession;
|
|
442406
|
+
const targetSessionId = targetSession.id;
|
|
442351
442407
|
try {
|
|
442352
|
-
const firstUserMessage =
|
|
442353
|
-
const firstAssistantMessage =
|
|
442408
|
+
const firstUserMessage = targetSession.messages.find((m) => m.role === "user");
|
|
442409
|
+
const firstAssistantMessage = targetSession.messages.find((m) => m.role === "assistant");
|
|
442354
442410
|
if (!firstUserMessage || !firstAssistantMessage) {
|
|
442355
442411
|
logger.warn("Summary agent: Could not find first user/assistant messages");
|
|
442356
442412
|
return;
|
|
442357
442413
|
}
|
|
442358
442414
|
const result2 = await summaryAgent.generateSummary(firstUserMessage.content, firstAssistantMessage.content);
|
|
442359
442415
|
if (result2) {
|
|
442360
|
-
this.currentSession.
|
|
442361
|
-
|
|
442362
|
-
|
|
442416
|
+
if (!this.currentSession || this.currentSession.id !== targetSessionId) {
|
|
442417
|
+
targetSession.title = result2.title;
|
|
442418
|
+
targetSession.summary = result2.summary;
|
|
442419
|
+
await this.saveSession(targetSession);
|
|
442420
|
+
logger.info("Summary agent: Updated detached session summary", {
|
|
442421
|
+
sessionId: targetSessionId,
|
|
442422
|
+
title: result2.title,
|
|
442423
|
+
summary: result2.summary
|
|
442424
|
+
});
|
|
442425
|
+
return;
|
|
442426
|
+
}
|
|
442427
|
+
targetSession.title = result2.title;
|
|
442428
|
+
targetSession.summary = result2.summary;
|
|
442429
|
+
await this.saveSession(targetSession);
|
|
442363
442430
|
logger.info("Summary agent: Successfully updated session summary", {
|
|
442364
|
-
sessionId:
|
|
442431
|
+
sessionId: targetSessionId,
|
|
442365
442432
|
title: result2.title,
|
|
442366
442433
|
summary: result2.summary
|
|
442367
442434
|
});
|
|
@@ -459330,7 +459397,7 @@ function SystemPromptConfigScreen({ onBack }) {
|
|
|
459330
459397
|
const { theme: theme14 } = useTheme();
|
|
459331
459398
|
const [config3, setConfig] = (0, import_react72.useState)(() => {
|
|
459332
459399
|
return getSystemPromptConfig() || {
|
|
459333
|
-
active:
|
|
459400
|
+
active: [],
|
|
459334
459401
|
prompts: []
|
|
459335
459402
|
};
|
|
459336
459403
|
});
|
|
@@ -459343,7 +459410,7 @@ function SystemPromptConfigScreen({ onBack }) {
|
|
|
459343
459410
|
const [editingField, setEditingField] = (0, import_react72.useState)("name");
|
|
459344
459411
|
const [error, setError] = (0, import_react72.useState)("");
|
|
459345
459412
|
const [successMessage, setSuccessMessage] = (0, import_react72.useState)("");
|
|
459346
|
-
const actions = config3.prompts.length > 0 ? config3.active ? ["activate", "deactivate", "edit", "delete", "add", "back"] : ["activate", "edit", "delete", "add", "back"] : ["add", "back"];
|
|
459413
|
+
const actions = config3.prompts.length > 0 ? config3.active.length > 0 ? ["activate", "deactivate", "edit", "delete", "add", "back"] : ["activate", "edit", "delete", "add", "back"] : ["add", "back"];
|
|
459347
459414
|
(0, import_react72.useEffect)(() => {
|
|
459348
459415
|
if (!actions.includes(currentAction)) {
|
|
459349
459416
|
setCurrentAction(actions[0] || "add");
|
|
@@ -459370,9 +459437,11 @@ function SystemPromptConfigScreen({ onBack }) {
|
|
|
459370
459437
|
if (config3.prompts.length === 0 || selectedIndex >= config3.prompts.length)
|
|
459371
459438
|
return;
|
|
459372
459439
|
const prompt = config3.prompts[selectedIndex];
|
|
459440
|
+
const isAlreadyActive = config3.active.includes(prompt.id);
|
|
459441
|
+
const newActive = isAlreadyActive ? config3.active.filter((id) => id !== prompt.id) : [...config3.active, prompt.id];
|
|
459373
459442
|
const newConfig = {
|
|
459374
459443
|
...config3,
|
|
459375
|
-
active:
|
|
459444
|
+
active: newActive
|
|
459376
459445
|
};
|
|
459377
459446
|
if (saveAndRefresh(newConfig)) {
|
|
459378
459447
|
setError("");
|
|
@@ -459381,7 +459450,7 @@ function SystemPromptConfigScreen({ onBack }) {
|
|
|
459381
459450
|
const handleDeactivate = () => {
|
|
459382
459451
|
const newConfig = {
|
|
459383
459452
|
...config3,
|
|
459384
|
-
active:
|
|
459453
|
+
active: []
|
|
459385
459454
|
};
|
|
459386
459455
|
if (saveAndRefresh(newConfig)) {
|
|
459387
459456
|
setError("");
|
|
@@ -459457,7 +459526,7 @@ function SystemPromptConfigScreen({ onBack }) {
|
|
|
459457
459526
|
return;
|
|
459458
459527
|
const promptToDelete = config3.prompts[selectedIndex];
|
|
459459
459528
|
const newPrompts = config3.prompts.filter((_3, i) => i !== selectedIndex);
|
|
459460
|
-
const newActive = config3.active
|
|
459529
|
+
const newActive = config3.active.filter((id) => id !== promptToDelete.id);
|
|
459461
459530
|
const newConfig = {
|
|
459462
459531
|
active: newActive,
|
|
459463
459532
|
prompts: newPrompts
|
|
@@ -459483,7 +459552,7 @@ function SystemPromptConfigScreen({ onBack }) {
|
|
|
459483
459552
|
const newConfig = {
|
|
459484
459553
|
...config3,
|
|
459485
459554
|
prompts: [...config3.prompts, newPrompt],
|
|
459486
|
-
active: config3.prompts.length === 0 ? newPrompt.id : config3.active
|
|
459555
|
+
active: config3.prompts.length === 0 ? [newPrompt.id] : config3.active
|
|
459487
459556
|
};
|
|
459488
459557
|
if (saveAndRefresh(newConfig)) {
|
|
459489
459558
|
setView("list");
|
|
@@ -459518,6 +459587,8 @@ function SystemPromptConfigScreen({ onBack }) {
|
|
|
459518
459587
|
if (config3.prompts.length > 0) {
|
|
459519
459588
|
setSelectedIndex((prev) => prev < config3.prompts.length - 1 ? prev + 1 : 0);
|
|
459520
459589
|
}
|
|
459590
|
+
} else if (_input === " ") {
|
|
459591
|
+
handleActivate();
|
|
459521
459592
|
} else if (key.leftArrow) {
|
|
459522
459593
|
const currentIdx = actions.indexOf(currentAction);
|
|
459523
459594
|
setCurrentAction(actions[currentIdx > 0 ? currentIdx - 1 : actions.length - 1]);
|
|
@@ -459578,7 +459649,10 @@ function SystemPromptConfigScreen({ onBack }) {
|
|
|
459578
459649
|
}
|
|
459579
459650
|
}, { isActive: view === "confirmDelete" });
|
|
459580
459651
|
if (view === "list") {
|
|
459581
|
-
const
|
|
459652
|
+
const activePromptNames = config3.active.map((id) => {
|
|
459653
|
+
var _a21;
|
|
459654
|
+
return (_a21 = config3.prompts.find((p) => p.id === id)) == null ? void 0 : _a21.name;
|
|
459655
|
+
}).filter(Boolean).join(", ");
|
|
459582
459656
|
return import_react72.default.createElement(
|
|
459583
459657
|
Box_default,
|
|
459584
459658
|
{ flexDirection: "column", padding: 1 },
|
|
@@ -459595,7 +459669,15 @@ function SystemPromptConfigScreen({ onBack }) {
|
|
|
459595
459669
|
{ bold: true },
|
|
459596
459670
|
t.systemPromptConfig.activePrompt,
|
|
459597
459671
|
" ",
|
|
459598
|
-
import_react72.default.createElement(Text, { color: theme14.colors.success },
|
|
459672
|
+
import_react72.default.createElement(Text, { color: theme14.colors.success }, activePromptNames || t.systemPromptConfig.none),
|
|
459673
|
+
config3.active.length > 0 && import_react72.default.createElement(
|
|
459674
|
+
Text,
|
|
459675
|
+
{ dimColor: true },
|
|
459676
|
+
" ",
|
|
459677
|
+
"(",
|
|
459678
|
+
t.systemPromptConfig.activeCount.replace("{count}", String(config3.active.length)),
|
|
459679
|
+
")"
|
|
459680
|
+
)
|
|
459599
459681
|
)
|
|
459600
459682
|
),
|
|
459601
459683
|
config3.prompts.length === 0 ? import_react72.default.createElement(
|
|
@@ -459611,11 +459693,11 @@ function SystemPromptConfigScreen({ onBack }) {
|
|
|
459611
459693
|
{ key: prompt.id, marginLeft: 2 },
|
|
459612
459694
|
import_react72.default.createElement(
|
|
459613
459695
|
Text,
|
|
459614
|
-
{ color: index === selectedIndex ? theme14.colors.menuSelected : prompt.id
|
|
459615
|
-
index === selectedIndex ? "
|
|
459616
|
-
prompt.id
|
|
459696
|
+
{ color: index === selectedIndex ? theme14.colors.menuSelected : config3.active.includes(prompt.id) ? theme14.colors.menuInfo : theme14.colors.menuNormal },
|
|
459697
|
+
index === selectedIndex ? "> " : " ",
|
|
459698
|
+
config3.active.includes(prompt.id) ? "[\u2713] " : "[ ] ",
|
|
459617
459699
|
prompt.name,
|
|
459618
|
-
prompt.content && import_react72.default.createElement(
|
|
459700
|
+
typeof prompt.content === "string" && prompt.content.length > 0 && import_react72.default.createElement(
|
|
459619
459701
|
Text,
|
|
459620
459702
|
{ dimColor: true },
|
|
459621
459703
|
" ",
|
|
@@ -567637,10 +567719,10 @@ ${cleanThinkingContent2(msg.reasoning_content)}`);
|
|
|
567637
567719
|
}
|
|
567638
567720
|
return parts.length > 0 ? parts.join("\n") : null;
|
|
567639
567721
|
}
|
|
567640
|
-
function prepareMessagesForCompression(conversationMessages,
|
|
567722
|
+
function prepareMessagesForCompression(conversationMessages, customSystemPrompts) {
|
|
567641
567723
|
const messages = [];
|
|
567642
|
-
if (
|
|
567643
|
-
messages.push({ role: "system", content:
|
|
567724
|
+
if (customSystemPrompts && customSystemPrompts.length > 0) {
|
|
567725
|
+
messages.push({ role: "system", content: customSystemPrompts.join("\n\n") });
|
|
567644
567726
|
} else {
|
|
567645
567727
|
messages.push({
|
|
567646
567728
|
role: "system",
|
|
@@ -567670,8 +567752,8 @@ ${conversationTranscript}`
|
|
|
567670
567752
|
});
|
|
567671
567753
|
return messages;
|
|
567672
567754
|
}
|
|
567673
|
-
async function compressWithChatCompletions(modelName, conversationMessages,
|
|
567674
|
-
const messages = prepareMessagesForCompression(conversationMessages,
|
|
567755
|
+
async function compressWithChatCompletions(modelName, conversationMessages, customSystemPrompts) {
|
|
567756
|
+
const messages = prepareMessagesForCompression(conversationMessages, customSystemPrompts);
|
|
567675
567757
|
let summary = "";
|
|
567676
567758
|
let usage = {
|
|
567677
567759
|
prompt_tokens: 0,
|
|
@@ -567699,8 +567781,8 @@ async function compressWithChatCompletions(modelName, conversationMessages, cust
|
|
|
567699
567781
|
}
|
|
567700
567782
|
return { summary, usage };
|
|
567701
567783
|
}
|
|
567702
|
-
async function compressWithResponses(modelName, conversationMessages,
|
|
567703
|
-
const messages = prepareMessagesForCompression(conversationMessages,
|
|
567784
|
+
async function compressWithResponses(modelName, conversationMessages, customSystemPrompts) {
|
|
567785
|
+
const messages = prepareMessagesForCompression(conversationMessages, customSystemPrompts);
|
|
567704
567786
|
let summary = "";
|
|
567705
567787
|
let usage = {
|
|
567706
567788
|
prompt_tokens: 0,
|
|
@@ -567728,8 +567810,8 @@ async function compressWithResponses(modelName, conversationMessages, customSyst
|
|
|
567728
567810
|
}
|
|
567729
567811
|
return { summary, usage };
|
|
567730
567812
|
}
|
|
567731
|
-
async function compressWithGemini(modelName, conversationMessages,
|
|
567732
|
-
const messages = prepareMessagesForCompression(conversationMessages,
|
|
567813
|
+
async function compressWithGemini(modelName, conversationMessages, customSystemPrompts) {
|
|
567814
|
+
const messages = prepareMessagesForCompression(conversationMessages, customSystemPrompts);
|
|
567733
567815
|
let summary = "";
|
|
567734
567816
|
let usage = {
|
|
567735
567817
|
prompt_tokens: 0,
|
|
@@ -567756,8 +567838,8 @@ async function compressWithGemini(modelName, conversationMessages, customSystemP
|
|
|
567756
567838
|
}
|
|
567757
567839
|
return { summary, usage };
|
|
567758
567840
|
}
|
|
567759
|
-
async function compressWithAnthropic(modelName, conversationMessages,
|
|
567760
|
-
const messages = prepareMessagesForCompression(conversationMessages,
|
|
567841
|
+
async function compressWithAnthropic(modelName, conversationMessages, customSystemPrompts) {
|
|
567842
|
+
const messages = prepareMessagesForCompression(conversationMessages, customSystemPrompts);
|
|
567761
567843
|
let summary = "";
|
|
567762
567844
|
let usage = {
|
|
567763
567845
|
prompt_tokens: 0,
|
|
@@ -568424,6 +568506,8 @@ Output: ${combinedOutput}`;
|
|
|
568424
568506
|
} else if (result2.success && result2.action === "showProfilePanel") {
|
|
568425
568507
|
options3.onSwitchProfile();
|
|
568426
568508
|
} else if (result2.success && result2.action === "home") {
|
|
568509
|
+
sessionManager.clearCurrentSession();
|
|
568510
|
+
options3.clearSavedMessages();
|
|
568427
568511
|
resetTerminal(stdout);
|
|
568428
568512
|
navigateTo("welcome");
|
|
568429
568513
|
} else if (result2.success && result2.action === "showUsagePanel") {
|
|
@@ -568598,6 +568682,8 @@ Output: ${combinedOutput}`;
|
|
|
568598
568682
|
options3.setMessages((prev) => [...prev, errorMessage]);
|
|
568599
568683
|
}
|
|
568600
568684
|
} else if (result2.success && result2.action === "home") {
|
|
568685
|
+
sessionManager.clearCurrentSession();
|
|
568686
|
+
options3.clearSavedMessages();
|
|
568601
568687
|
resetTerminal(stdout);
|
|
568602
568688
|
navigateTo("welcome");
|
|
568603
568689
|
} else if (result2.success && result2.action === "toggleYolo") {
|
package/bundle/package.json
CHANGED