fluxflow-cli 1.19.2 → 1.19.4
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/dist/fluxflow.js +202 -51
- package/package.json +1 -1
package/dist/fluxflow.js
CHANGED
|
@@ -1204,7 +1204,7 @@ ${mode === "Flux" ? `- PROJECT TOOLS (path = relative to CWD) -
|
|
|
1204
1204
|
- File structure: Real newlines for code formatting`.trim() : `
|
|
1205
1205
|
- FILE TOOLS ARE NOT AVAILABLE IN FLOW (Tell user,\` /mode flux\` if needed)`.trim()}
|
|
1206
1206
|
|
|
1207
|
-
- Results: Passed as [TOOL RESULT]
|
|
1207
|
+
- Results: Passed as [TOOL RESULT]
|
|
1208
1208
|
- MAX Tool call stack: STRICTLY 3 per turn`.trim();
|
|
1209
1209
|
}
|
|
1210
1210
|
});
|
|
@@ -2396,12 +2396,13 @@ var init_thinking_prompts = __esm({
|
|
|
2396
2396
|
|
|
2397
2397
|
// src/utils/prompts.js
|
|
2398
2398
|
import fs4 from "fs";
|
|
2399
|
-
var getMemoryPrompt, getSystemInstruction, getJanitorInstruction;
|
|
2399
|
+
var cachedProjectContextBlock, getMemoryPrompt, getSystemInstruction, getJanitorInstruction;
|
|
2400
2400
|
var init_prompts = __esm({
|
|
2401
2401
|
async "src/utils/prompts.js"() {
|
|
2402
2402
|
await init_main_tools();
|
|
2403
2403
|
init_janitor_tools();
|
|
2404
2404
|
init_thinking_prompts();
|
|
2405
|
+
cachedProjectContextBlock = null;
|
|
2405
2406
|
getMemoryPrompt = (tempMemories = "", userMemories = "", isMemoryEnabled = true, isContext32k = false) => {
|
|
2406
2407
|
if (!isMemoryEnabled) return "";
|
|
2407
2408
|
const tempMemoriesStr = tempMemories?.length > 0 && !isContext32k ? `-- RECENT CONTEXT FROM OTHER CHATS (PRIORITY: DYNAMIC-LOW, FOCUS: Chat Context > Recent) --
|
|
@@ -2413,7 +2414,7 @@ ${userMemories}` : "";
|
|
|
2413
2414
|
${parts.join("\n\n")}
|
|
2414
2415
|
` : "";
|
|
2415
2416
|
};
|
|
2416
|
-
getSystemInstruction = (profile, thinkingLevel, mode, systemSettings, isMemoryEnabled = true) => {
|
|
2417
|
+
getSystemInstruction = (profile, thinkingLevel, mode, systemSettings, isMemoryEnabled = true, isFirstPrompt = false) => {
|
|
2417
2418
|
let thinkingConfig = "";
|
|
2418
2419
|
if (thinkingLevel !== "GEM") {
|
|
2419
2420
|
let levelKey = thinkingLevel;
|
|
@@ -2451,24 +2452,27 @@ ${nicknameStr.length || userInstrStr.length ? "" : "\n"}` : "";
|
|
|
2451
2452
|
{ name: "design.md", desc: "UI/UX" },
|
|
2452
2453
|
{ name: "architecture.md", desc: "System Structure" }
|
|
2453
2454
|
];
|
|
2454
|
-
|
|
2455
|
-
|
|
2455
|
+
if (isFirstPrompt || cachedProjectContextBlock === null) {
|
|
2456
|
+
const foundFiles = projectContextFiles.filter((f) => fs4.existsSync(f.name));
|
|
2457
|
+
cachedProjectContextBlock = mode === "Flux" && foundFiles.length > 0 ? `
|
|
2456
2458
|
-- PROJECT CONTEXT (Source of Truth) --
|
|
2457
2459
|
${foundFiles.map((f) => `- ${f.name}: ${f.desc}`).join("\n")}
|
|
2458
2460
|
Check these first; These Files > Training Data. Safety rules apply
|
|
2459
2461
|
` : "";
|
|
2462
|
+
}
|
|
2463
|
+
const projectContextBlock = cachedProjectContextBlock;
|
|
2460
2464
|
return `${nameStr}${nicknameStr}${userInstrStr}[SYSTEM]
|
|
2461
2465
|
Identity: Flux Flow (by Kushal Roy Chowdhury). Conversational, Sassy${mode === "Flux" ? ", Respectful" : ", Friendly, Humorous, Sarcastic"}, CLI Agent
|
|
2462
2466
|
Mode: ${mode}${thinkingLevel !== "Fast" ? " (Thinking Mode)" : ""}. ${mode === "Flux" ? "Logical, Highly Detailed, Task-Driven. Prioritizes scalable file/folder structures, modular architecture, clean code abstractions, step-by-step execution. Industry standard latest coding practices/libraries, clean code, Double Check Imports, Client-Server Sync" : "Concise"}
|
|
2463
2467
|
|
|
2464
2468
|
-- AGENT LOOP RULES (PRIORITY: HIGH) --
|
|
2465
|
-
- **MUST END WITH [turn: continue] to CONTINUE loop OR [turn: finish] to END loop**
|
|
2466
|
-
- Tool Called? No post tool
|
|
2469
|
+
- **MANDATORY: MUST END WITH [turn: continue] to CONTINUE loop OR [turn: finish] to END loop**
|
|
2470
|
+
- Tool Called? No post tool chat until [turn: continue]
|
|
2467
2471
|
- NEVER USE [turn: continue] [turn:finish] together
|
|
2468
2472
|
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2473
|
+
-- MARKERS --
|
|
2474
|
+
- TOOL SYSTEM: [TOOL RESULT] (system priority)
|
|
2475
|
+
- SYSTEM NOTIFICATION: [SYSTEM], [METADATA] in user turn
|
|
2472
2476
|
${thinkingLevel !== "GEM" ? `
|
|
2473
2477
|
-- THINKING RULES --
|
|
2474
2478
|
${thinkingConfig}
|
|
@@ -2488,7 +2492,6 @@ ${projectContextBlock}
|
|
|
2488
2492
|
|
|
2489
2493
|
-- FORMATTING --
|
|
2490
2494
|
- GFM Supported
|
|
2491
|
-
- Tables: Max 4 cols
|
|
2492
2495
|
- NO LaTeX${mode === "Flux" ? "" : ". Kaomojis"}
|
|
2493
2496
|
[/SYSTEM]`.trim();
|
|
2494
2497
|
};
|
|
@@ -2932,6 +2935,7 @@ var init_usage = __esm({
|
|
|
2932
2935
|
duration: 0,
|
|
2933
2936
|
tokens: 0,
|
|
2934
2937
|
cachedTokens: 0,
|
|
2938
|
+
candidateTokens: 0,
|
|
2935
2939
|
linesAdded: 0,
|
|
2936
2940
|
linesRemoved: 0,
|
|
2937
2941
|
imageCalls: []
|
|
@@ -5476,7 +5480,116 @@ ${newMemoryListStr}
|
|
|
5476
5480
|
await RevertManager.startTransaction(chatId, agentText);
|
|
5477
5481
|
try {
|
|
5478
5482
|
let modifiedHistory = [...history.slice(0, -1)];
|
|
5483
|
+
const summariesFile = path16.join(SECRET_DIR, "chat-summaries.json");
|
|
5484
|
+
let summaries = readEncryptedJson(summariesFile, {});
|
|
5485
|
+
let chatDataObj = summaries[chatId] || { summary: "", historyLength: 0 };
|
|
5486
|
+
if (typeof chatDataObj === "string") {
|
|
5487
|
+
chatDataObj = { summary: chatDataObj, historyLength: 0 };
|
|
5488
|
+
}
|
|
5489
|
+
const incomingCleanLength = history.filter((m) => (m.role === "user" || m.role === "agent" || m.role === "system") && !String(m.id).startsWith("welcome") && !m.isMeta).length;
|
|
5490
|
+
if (incomingCleanLength < chatDataObj.historyLength) {
|
|
5491
|
+
delete summaries[chatId];
|
|
5492
|
+
writeEncryptedJson(summariesFile, summaries);
|
|
5493
|
+
chatDataObj = { summary: "", historyLength: 0 };
|
|
5494
|
+
}
|
|
5479
5495
|
if (systemSettings?.compression === 0 && (sessionStats?.tokens || 0) > 254e3) {
|
|
5496
|
+
yield { type: "status", content: "Condensing session context..." };
|
|
5497
|
+
const flattenContext = (hist) => {
|
|
5498
|
+
return hist.filter((m) => (m.role === "user" || m.role === "agent" || m.role === "system") && !String(m.id).startsWith("welcome") && !m.isMeta).map((m) => {
|
|
5499
|
+
const role = m.text?.startsWith("[TOOL RESULT]") ? "TOOL" : m.role === "agent" ? "AGENT" : "USER";
|
|
5500
|
+
return `[${role}]: ${m.text}`;
|
|
5501
|
+
}).join("\n\n");
|
|
5502
|
+
};
|
|
5503
|
+
const runCondenser = async (flattenedText2, oldSummary2) => {
|
|
5504
|
+
const systemInstruction = `You are an expert context condenser. Summarize the provided chat history (which may include previous summaries, user instructions, agent outputs, and tool results) into a detailed, coherent, and highly technical summary of 1000 to 1500 words. Focus on preserving the architectural decisions made, current system state, task progress, and critical code details. Under no circumstances exceed MAX 2000 words.`;
|
|
5505
|
+
const prompt = oldSummary2 ? `Here is the previous summary:
|
|
5506
|
+
${oldSummary2}
|
|
5507
|
+
|
|
5508
|
+
Here is the new conversation history:
|
|
5509
|
+
${flattenedText2}
|
|
5510
|
+
|
|
5511
|
+
Provide a new consolidated summary of the entire session.` : `Here is the conversation history:
|
|
5512
|
+
${flattenedText2}
|
|
5513
|
+
|
|
5514
|
+
Provide a consolidated summary of the entire session.`;
|
|
5515
|
+
try {
|
|
5516
|
+
const response = await client.models.generateContent({
|
|
5517
|
+
model: "gemini-3.1-flash-lite",
|
|
5518
|
+
contents: prompt,
|
|
5519
|
+
config: {
|
|
5520
|
+
systemInstruction,
|
|
5521
|
+
maxOutputTokens: 2048,
|
|
5522
|
+
temperature: 0.3,
|
|
5523
|
+
safetySettings: [
|
|
5524
|
+
{ category: HarmCategory.HARM_CATEGORY_HARASSMENT, threshold: HarmBlockThreshold.BLOCK_NONE },
|
|
5525
|
+
{ category: HarmCategory.HARM_CATEGORY_HATE_SPEECH, threshold: HarmBlockThreshold.BLOCK_NONE },
|
|
5526
|
+
{ category: HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT, threshold: HarmBlockThreshold.BLOCK_NONE },
|
|
5527
|
+
{ category: HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT, threshold: HarmBlockThreshold.BLOCK_NONE }
|
|
5528
|
+
],
|
|
5529
|
+
thinkingConfig: { includeThoughts: false, thinkingLevel: ThinkingLevel.MEDIUM }
|
|
5530
|
+
}
|
|
5531
|
+
});
|
|
5532
|
+
return response.text || "";
|
|
5533
|
+
} catch (err) {
|
|
5534
|
+
try {
|
|
5535
|
+
const response = await client.models.generateContent({
|
|
5536
|
+
model: "gemini-2.5-flash",
|
|
5537
|
+
contents: prompt,
|
|
5538
|
+
config: {
|
|
5539
|
+
systemInstruction,
|
|
5540
|
+
maxOutputTokens: 2048,
|
|
5541
|
+
temperature: 0.3,
|
|
5542
|
+
safetySettings: [
|
|
5543
|
+
{ category: HarmCategory.HARM_CATEGORY_HARASSMENT, threshold: HarmBlockThreshold.BLOCK_NONE },
|
|
5544
|
+
{ category: HarmCategory.HARM_CATEGORY_HATE_SPEECH, threshold: HarmBlockThreshold.BLOCK_NONE },
|
|
5545
|
+
{ category: HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT, threshold: HarmBlockThreshold.BLOCK_NONE },
|
|
5546
|
+
{ category: HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT, threshold: HarmBlockThreshold.BLOCK_NONE }
|
|
5547
|
+
],
|
|
5548
|
+
thinkingConfig: { includeThoughts: false, thinkingBudget: 8192 }
|
|
5549
|
+
}
|
|
5550
|
+
});
|
|
5551
|
+
return response.text || "";
|
|
5552
|
+
} catch (e) {
|
|
5553
|
+
try {
|
|
5554
|
+
const response = await client.models.generateContent({
|
|
5555
|
+
model: "gemini-2.5-flash-lite",
|
|
5556
|
+
contents: prompt,
|
|
5557
|
+
config: {
|
|
5558
|
+
systemInstruction,
|
|
5559
|
+
maxOutputTokens: 2048,
|
|
5560
|
+
temperature: 0.3,
|
|
5561
|
+
safetySettings: [
|
|
5562
|
+
{ category: HarmCategory.HARM_CATEGORY_HARASSMENT, threshold: HarmBlockThreshold.BLOCK_NONE },
|
|
5563
|
+
{ category: HarmCategory.HARM_CATEGORY_HATE_SPEECH, threshold: HarmBlockThreshold.BLOCK_NONE },
|
|
5564
|
+
{ category: HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT, threshold: HarmBlockThreshold.BLOCK_NONE },
|
|
5565
|
+
{ category: HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT, threshold: HarmBlockThreshold.BLOCK_NONE }
|
|
5566
|
+
],
|
|
5567
|
+
thinkingConfig: { includeThoughts: false, thinkingBudget: 8192 }
|
|
5568
|
+
}
|
|
5569
|
+
});
|
|
5570
|
+
return response.text || "";
|
|
5571
|
+
} catch (e2) {
|
|
5572
|
+
return "";
|
|
5573
|
+
}
|
|
5574
|
+
}
|
|
5575
|
+
}
|
|
5576
|
+
};
|
|
5577
|
+
const flattenedText = flattenContext(modifiedHistory);
|
|
5578
|
+
summaries = readEncryptedJson(summariesFile, {});
|
|
5579
|
+
let chatData = summaries[chatId] || { summary: "", historyLength: 0 };
|
|
5580
|
+
if (typeof chatData === "string") {
|
|
5581
|
+
chatData = { summary: chatData, historyLength: 0 };
|
|
5582
|
+
}
|
|
5583
|
+
const oldSummary = chatData.summary || "";
|
|
5584
|
+
const newSummary = await runCondenser(flattenedText, oldSummary);
|
|
5585
|
+
if (newSummary) {
|
|
5586
|
+
chatData.summary = newSummary;
|
|
5587
|
+
summaries[chatId] = chatData;
|
|
5588
|
+
writeEncryptedJson(summariesFile, summaries);
|
|
5589
|
+
modifiedHistory = [];
|
|
5590
|
+
}
|
|
5591
|
+
}
|
|
5592
|
+
if (systemSettings?.compression === 0 && (sessionStats?.tokens || 0) > 255e3) {
|
|
5480
5593
|
modifiedHistory = getTruncatedHistory(modifiedHistory, 6);
|
|
5481
5594
|
}
|
|
5482
5595
|
if (isFirstPrompt && isMemoryEnabled) {
|
|
@@ -5736,13 +5849,26 @@ ${newMemoryListStr}
|
|
|
5736
5849
|
const cwdMismatch = lastCwd ? lastCwd !== process.cwd() : false;
|
|
5737
5850
|
chatPaths[chatId] = process.cwd();
|
|
5738
5851
|
writeEncryptedJson(PATHS_FILE, chatPaths);
|
|
5852
|
+
summaries = readEncryptedJson(summariesFile, {});
|
|
5853
|
+
chatDataObj = summaries[chatId] || { summary: "", historyLength: 0 };
|
|
5854
|
+
if (typeof chatDataObj === "string") {
|
|
5855
|
+
chatDataObj = { summary: chatDataObj, historyLength: 0 };
|
|
5856
|
+
}
|
|
5857
|
+
const currentSummary = typeof chatDataObj === "object" ? chatDataObj.summary || "" : chatDataObj || "";
|
|
5858
|
+
const summaryBlock = currentSummary ? `
|
|
5859
|
+
|
|
5860
|
+
--- CONTEXT SUMMARY OF PREVIOUS TURNS (PRIORITY: HIGH) ---
|
|
5861
|
+
${currentSummary}
|
|
5862
|
+
|
|
5863
|
+
` : "";
|
|
5739
5864
|
let dirStructure = process.cwd() + "\n" + getDirTree(process.cwd(), dynamicMaxDepth);
|
|
5740
|
-
const firstUserMsg = `[SYSTEM METADATA (PRIORITY: DYNAMIC)] Time: ${dateTimeStr} | v${versionFluxflow2}
|
|
5865
|
+
const firstUserMsg = `[SYSTEM METADATA (PRIORITY: DYNAMIC), Chat Context >> Metadata] Time: ${dateTimeStr} | v${versionFluxflow2}
|
|
5741
5866
|
CWD: ${process.cwd()}${cwdMismatch ? ` (CWD Mismatch! Previous Path: ${lastCwd})` : ""}
|
|
5742
5867
|
**DIRECTORY STRUCTURE**
|
|
5743
5868
|
${dirStructure}
|
|
5869
|
+
${summaryBlock}
|
|
5744
5870
|
${memoryPrompt}
|
|
5745
|
-
${thinkingLevel != "Fast" ? `${modelName.toLowerCase().startsWith("gemma") ? "[SYSTEM] **STRICTLY FOLLOW THINKING POLICY AS CRITICAL PRIORITY. DO NOT START A RESPONSE WITHOUT <think> ... </think
|
|
5871
|
+
${thinkingLevel != "Fast" ? `${modelName.toLowerCase().startsWith("gemma") ? "[SYSTEM] **STRICTLY FOLLOW THINKING POLICY AS CRITICAL PRIORITY. DO NOT START A RESPONSE WITHOUT <think> ... </think>**\n" : ""}` : ""}[USER] ${agentText.replace(/\s*\[Prompted on:.*?\]/g, "").trim()}`.trim();
|
|
5746
5872
|
modifiedHistory.push({ role: "user", text: firstUserMsg });
|
|
5747
5873
|
let lastUsage = null;
|
|
5748
5874
|
const MAX_LOOPS = mode === "Flux" ? 70 : 7;
|
|
@@ -5773,7 +5899,7 @@ ${thinkingLevel != "Fast" ? `${modelName.toLowerCase().startsWith("gemma") ? "[S
|
|
|
5773
5899
|
|
|
5774
5900
|
[STEERING HINT]: ${hint}`;
|
|
5775
5901
|
} else {
|
|
5776
|
-
modifiedHistory.push({ role: "user", text: `${thinkingLevel != "Fast" ? `${modelName.toLowerCase().startsWith("gemma") ? "[SYSTEM] **STRICTLY FOLLOW THINKING POLICY AS CRITICAL PRIORITY. DO NOT START A RESPONSE WITHOUT <think> ... </think
|
|
5902
|
+
modifiedHistory.push({ role: "user", text: `${thinkingLevel != "Fast" ? `${modelName.toLowerCase().startsWith("gemma") ? "[SYSTEM] **STRICTLY FOLLOW THINKING POLICY AS CRITICAL PRIORITY. DO NOT START A RESPONSE WITHOUT <think> ... </think>**\n" : ""}` : ""}[STEERING HINT]: ${hint}` });
|
|
5777
5903
|
}
|
|
5778
5904
|
yield { type: "status", content: "Steering Hint Injected." };
|
|
5779
5905
|
}
|
|
@@ -5818,7 +5944,7 @@ ${thinkingLevel != "Fast" ? `${modelName.toLowerCase().startsWith("gemma") ? "[S
|
|
|
5818
5944
|
const parts = [{ text: msg.text }];
|
|
5819
5945
|
if (msg.binaryPart) {
|
|
5820
5946
|
const physicalUserTurnsAfter = arr.slice(idx + 1).filter((m) => m.role === "user" && !m.text?.startsWith("[TOOL RESULT]")).length;
|
|
5821
|
-
if (physicalUserTurnsAfter <=
|
|
5947
|
+
if (physicalUserTurnsAfter <= 2) {
|
|
5822
5948
|
parts.push(msg.binaryPart);
|
|
5823
5949
|
}
|
|
5824
5950
|
}
|
|
@@ -5843,7 +5969,7 @@ ${thinkingLevel != "Fast" ? `${modelName.toLowerCase().startsWith("gemma") ? "[S
|
|
|
5843
5969
|
} else if (retryCount > 0) {
|
|
5844
5970
|
yield { type: "model_update", content: null };
|
|
5845
5971
|
}
|
|
5846
|
-
currentSystemInstruction = getSystemInstruction(profile, !(targetModel || "gemma").toLowerCase().startsWith("gemma") ? "GEM" : thinkingLevel, mode, systemSettings, isMemoryEnabled,
|
|
5972
|
+
currentSystemInstruction = getSystemInstruction(profile, !(targetModel || "gemma").toLowerCase().startsWith("gemma") ? "GEM" : thinkingLevel, mode, systemSettings, isMemoryEnabled, isFirstPrompt);
|
|
5847
5973
|
const isGemma = modelName && modelName.toLowerCase().startsWith("gemma");
|
|
5848
5974
|
const lastUserMsg = contents[contents.length - 1];
|
|
5849
5975
|
if (isGemma) {
|
|
@@ -5862,13 +5988,6 @@ ${thinkingLevel != "Fast" ? `${modelName.toLowerCase().startsWith("gemma") ? "[S
|
|
|
5862
5988
|
}
|
|
5863
5989
|
}
|
|
5864
5990
|
let activeContents = contents;
|
|
5865
|
-
let cachedContentName = null;
|
|
5866
|
-
if (settings.apiTier !== "Free" && (sessionStats?.tokens || 0) > 16384) {
|
|
5867
|
-
if (lastUsage?.cachedContentTokenCount > 0) {
|
|
5868
|
-
fs17.appendFileSync("status_check.txt", `[${(/* @__PURE__ */ new Date()).toLocaleString()}] IMPLICIT CACHE HIT: ${lastUsage.cachedContentTokenCount} tokens
|
|
5869
|
-
`);
|
|
5870
|
-
}
|
|
5871
|
-
}
|
|
5872
5991
|
stream = await client.models.generateContentStream({
|
|
5873
5992
|
model: targetModel || "gemma-4-31b-it",
|
|
5874
5993
|
contents: activeContents,
|
|
@@ -5876,7 +5995,7 @@ ${thinkingLevel != "Fast" ? `${modelName.toLowerCase().startsWith("gemma") ? "[S
|
|
|
5876
5995
|
systemInstruction: currentSystemInstruction,
|
|
5877
5996
|
temperature: mode === "Flux" ? 1 : 1.4,
|
|
5878
5997
|
maxOutputTokens: 32768,
|
|
5879
|
-
mediaResolution: "
|
|
5998
|
+
mediaResolution: "MEDIA_RESOLUTION_MEDIUM",
|
|
5880
5999
|
safetySettings: [
|
|
5881
6000
|
{ category: HarmCategory.HARM_CATEGORY_HARASSMENT, threshold: HarmBlockThreshold.BLOCK_NONE },
|
|
5882
6001
|
{ category: HarmCategory.HARM_CATEGORY_HATE_SPEECH, threshold: HarmBlockThreshold.BLOCK_NONE },
|
|
@@ -6510,11 +6629,11 @@ ${boxBottom}` };
|
|
|
6510
6629
|
if (TERMINATION_SIGNAL) break;
|
|
6511
6630
|
const signalSafeText2 = (turnText || "").trim();
|
|
6512
6631
|
const hasFinish2 = /\[\s*(turn\s*:)?\s*finish\s*\]/i.test(signalSafeText2.toLowerCase());
|
|
6513
|
-
const
|
|
6632
|
+
const hasContinue2 = /\[\s*(turn\s*:)?\s*continue\s*\]/i.test(signalSafeText2.toLowerCase());
|
|
6514
6633
|
const didCallTool = toolResults.length > 0 || lastToolSniffed !== null;
|
|
6515
6634
|
const pureOutputText = signalSafeText2.replace(/(?:<think>|\[think\])[\s\S]*?(?:<\/think>|\[\/think\])/gi, "").trim();
|
|
6516
6635
|
const endsNormally = /[.!?}"'`’“”]$|```$/s.test(pureOutputText);
|
|
6517
|
-
if (!hasFinish2 && !
|
|
6636
|
+
if (!hasFinish2 && !hasContinue2 && !didCallTool && signalSafeText2.length > 0 && !endsNormally && !isThinkingLoop && !isStutteringLoop && !isGeneralLoop) {
|
|
6518
6637
|
throw new Error("Silent stream cutoff (500): Model stream closed cleanly but cut off mid-sentence without signals.");
|
|
6519
6638
|
}
|
|
6520
6639
|
success = true;
|
|
@@ -6636,10 +6755,14 @@ Error Log can be found in ${path16.join(LOGS_DIR, "agent", "error.log")}`);
|
|
|
6636
6755
|
if (lastUsage) {
|
|
6637
6756
|
const total = lastUsage.totalTokenCount || 0;
|
|
6638
6757
|
const cached = lastUsage.cachedContentTokenCount || 0;
|
|
6758
|
+
const candidates = (lastUsage.candidatesTokenCount || 0) + (lastUsage.thoughtsTokenCount || 0);
|
|
6639
6759
|
await addToUsage("tokens", total);
|
|
6640
6760
|
if (cached > 0) {
|
|
6641
6761
|
await addToUsage("cachedTokens", cached);
|
|
6642
6762
|
}
|
|
6763
|
+
if (candidates > 0) {
|
|
6764
|
+
await addToUsage("candidateTokens", candidates);
|
|
6765
|
+
}
|
|
6643
6766
|
yield { type: "usage", content: lastUsage };
|
|
6644
6767
|
}
|
|
6645
6768
|
fullAgentResponseChunks.push(turnText);
|
|
@@ -6650,10 +6773,11 @@ Error Log can be found in ${path16.join(LOGS_DIR, "agent", "error.log")}`);
|
|
|
6650
6773
|
}
|
|
6651
6774
|
const signalSafeText = getSanitizedText(turnText);
|
|
6652
6775
|
const hasFinish = /\[\s*(turn\s*:)?\s*finish\s*\]/i.test(signalSafeText.toLowerCase());
|
|
6776
|
+
const hasContinue = /\[\s*(turn\s*:)?\s*continue\s*\]/i.test(signalSafeText.toLowerCase());
|
|
6653
6777
|
const shouldContinue = toolCallPointer > 0;
|
|
6654
6778
|
yield { type: "status", content: "Working..." };
|
|
6655
6779
|
const cleanedTurnText = contextSafeReplace(turnText, /\[\s*(turn\s*:)?\s*(continue|finish)\s*\]/gi, "").trim();
|
|
6656
|
-
let isActuallyFinished = hasFinish && !shouldContinue;
|
|
6780
|
+
let isActuallyFinished = hasFinish && !shouldContinue || !shouldContinue && !hasContinue;
|
|
6657
6781
|
if (isActuallyFinished) {
|
|
6658
6782
|
const fullAgentTextRaw = fullAgentResponseChunks.join("\n");
|
|
6659
6783
|
const cleanedFullResponse = fullAgentTextRaw.replace(/(?:<think>|\[think\])[\s\S]*?(?:<\/think>|\[\/think\])/g, "").trim();
|
|
@@ -6666,24 +6790,37 @@ Error Log can be found in ${path16.join(LOGS_DIR, "agent", "error.log")}`);
|
|
|
6666
6790
|
needTitle
|
|
6667
6791
|
}
|
|
6668
6792
|
};
|
|
6669
|
-
const timestamp = `Responded on ${(/* @__PURE__ */ new Date()).toLocaleString()}`;
|
|
6670
|
-
const finalWithTime = `${cleanedFullResponse}
|
|
6671
|
-
|
|
6672
|
-
${timestamp}`;
|
|
6673
6793
|
if (modifiedHistory.length > 0 && modifiedHistory[modifiedHistory.length - 1].role === "agent") {
|
|
6674
|
-
modifiedHistory[modifiedHistory.length - 1].text =
|
|
6794
|
+
modifiedHistory[modifiedHistory.length - 1].text = cleanedFullResponse;
|
|
6675
6795
|
} else {
|
|
6676
|
-
modifiedHistory.push({ role: "agent", text:
|
|
6796
|
+
modifiedHistory.push({ role: "agent", text: cleanedFullResponse });
|
|
6797
|
+
}
|
|
6798
|
+
try {
|
|
6799
|
+
const summariesFile2 = path16.join(SECRET_DIR, "chat-summaries.json");
|
|
6800
|
+
const summaries2 = readEncryptedJson(summariesFile2, {});
|
|
6801
|
+
let existing = summaries2[chatId] || { summary: "", historyLength: 0 };
|
|
6802
|
+
if (typeof existing === "string") {
|
|
6803
|
+
existing = { summary: existing, historyLength: 0 };
|
|
6804
|
+
}
|
|
6805
|
+
const cleanLen = modifiedHistory.filter((m) => (m.role === "user" || m.role === "agent" || m.role === "system") && !String(m.id).startsWith("welcome") && !m.isMeta).length;
|
|
6806
|
+
existing.historyLength = cleanLen;
|
|
6807
|
+
summaries2[chatId] = existing;
|
|
6808
|
+
writeEncryptedJson(summariesFile2, summaries2);
|
|
6809
|
+
} catch (e) {
|
|
6677
6810
|
}
|
|
6678
6811
|
}
|
|
6679
6812
|
if (isActuallyFinished) break;
|
|
6680
6813
|
const nextAgentMsg = cleanedTurnText.trim() || "*Working...*";
|
|
6681
6814
|
modifiedHistory.push({ role: "agent", text: nextAgentMsg });
|
|
6682
6815
|
if (toolResults.length > 0 || anyToolExecutedInThisTurn) {
|
|
6683
|
-
toolResults.
|
|
6816
|
+
if (toolResults.length > 0) {
|
|
6817
|
+
const combinedText = toolResults.map((tr) => tr.text).join("\n\n");
|
|
6818
|
+
const binaryPart = toolResults.find((tr) => tr.binaryPart)?.binaryPart || null;
|
|
6819
|
+
modifiedHistory.push({ role: "user", text: combinedText, binaryPart });
|
|
6820
|
+
}
|
|
6684
6821
|
} else {
|
|
6685
6822
|
if (wasToolCalledInLastLoop) {
|
|
6686
|
-
modifiedHistory.push({ role: "user", text: `[SYSTEM] System
|
|
6823
|
+
modifiedHistory.push({ role: "user", text: `[SYSTEM] System failed to verify tool execution, Verify tool syntax, proper escaping and try again if failed` });
|
|
6687
6824
|
} else {
|
|
6688
6825
|
modifiedHistory.push({ role: "user", text: `[SYSTEM] ${isStutteringLoop && !isThinkingLoop ? `STUTTERING DETECTED by Internal System. Re-calibrate your response & proceed.` : `${isThinkingLoop ? " OVER-THINKING" : " LOOP"} DETECTED by Internal System${isThinkingLoop ? " for current EFFORT_LEVEL" : ""}. ${isThinkingLoop ? "If you have planned the task, prioritize the execution/output. " : "If you have finished your task use [turn: finish] else continue."}`}` });
|
|
6689
6826
|
}
|
|
@@ -7335,6 +7472,7 @@ function App({ args = [] }) {
|
|
|
7335
7472
|
const [sessionBackgroundCalls, setSessionBackgroundCalls] = useState10(0);
|
|
7336
7473
|
const [sessionTotalTokens, setSessionTotalTokens] = useState10(0);
|
|
7337
7474
|
const [sessionTotalCachedTokens, setSessionTotalCachedTokens] = useState10(0);
|
|
7475
|
+
const [sessionTotalCandidateTokens, setSessionTotalCandidateTokens] = useState10(0);
|
|
7338
7476
|
const [sessionToolSuccess, setSessionToolSuccess] = useState10(0);
|
|
7339
7477
|
const [sessionToolFailure, setSessionToolFailure] = useState10(0);
|
|
7340
7478
|
const [sessionToolDenied, setSessionToolDenied] = useState10(0);
|
|
@@ -8528,12 +8666,30 @@ ${timestamp}` };
|
|
|
8528
8666
|
let apiStart = Date.now();
|
|
8529
8667
|
let isFirstPacket = true;
|
|
8530
8668
|
try {
|
|
8531
|
-
const
|
|
8669
|
+
const rawHistory = [...messages, userMessage].filter(
|
|
8532
8670
|
(m) => m.role !== "think" && !m.isVisualFeedback && !String(m.id).startsWith("welcome")
|
|
8533
|
-
)
|
|
8534
|
-
|
|
8535
|
-
|
|
8536
|
-
|
|
8671
|
+
);
|
|
8672
|
+
const cleanHistoryForAI = [];
|
|
8673
|
+
rawHistory.forEach((m, idx) => {
|
|
8674
|
+
let text = m.fullText || m.text;
|
|
8675
|
+
if (m.role === "user" && idx < rawHistory.length - 1) {
|
|
8676
|
+
const userIndex = text.lastIndexOf("[USER]");
|
|
8677
|
+
if (userIndex !== -1) {
|
|
8678
|
+
text = text.substring(userIndex + 6).trim();
|
|
8679
|
+
}
|
|
8680
|
+
}
|
|
8681
|
+
if (m.role === "system" && text?.startsWith("[TOOL RESULT]")) {
|
|
8682
|
+
const prev = cleanHistoryForAI[cleanHistoryForAI.length - 1];
|
|
8683
|
+
if (prev && prev.role === "system" && prev.text?.startsWith("[TOOL RESULT]")) {
|
|
8684
|
+
prev.text += "\n\n" + text;
|
|
8685
|
+
return;
|
|
8686
|
+
}
|
|
8687
|
+
}
|
|
8688
|
+
cleanHistoryForAI.push({
|
|
8689
|
+
...m,
|
|
8690
|
+
text
|
|
8691
|
+
});
|
|
8692
|
+
});
|
|
8537
8693
|
const stream = getAIStream(
|
|
8538
8694
|
activeModel,
|
|
8539
8695
|
cleanHistoryForAI,
|
|
@@ -8713,15 +8869,6 @@ Selection: ${val}`,
|
|
|
8713
8869
|
if (packet.type === "interactive_turn_finished") {
|
|
8714
8870
|
setIsProcessing(false);
|
|
8715
8871
|
hasFiredJanitor = true;
|
|
8716
|
-
setMessages((prev) => {
|
|
8717
|
-
const aiHistory = packet.data.history;
|
|
8718
|
-
return prev.map((msg, idx) => {
|
|
8719
|
-
if (aiHistory[idx]) {
|
|
8720
|
-
return { ...msg, fullText: aiHistory[idx].text };
|
|
8721
|
-
}
|
|
8722
|
-
return msg;
|
|
8723
|
-
});
|
|
8724
|
-
});
|
|
8725
8872
|
runJanitorTask(
|
|
8726
8873
|
{ profile: profileData, thinkingLevel, mode, janitorModel, chatId, systemSettings, sessionStats },
|
|
8727
8874
|
packet.data.agentText,
|
|
@@ -8757,11 +8904,15 @@ Selection: ${val}`,
|
|
|
8757
8904
|
if (packet.type === "usage") {
|
|
8758
8905
|
const total = packet.content.totalTokenCount || 0;
|
|
8759
8906
|
const cached = packet.content.cachedContentTokenCount || 0;
|
|
8907
|
+
const candidates = packet.content.candidatesTokenCount || 0;
|
|
8760
8908
|
setSessionStats({ tokens: total });
|
|
8761
8909
|
setSessionTotalTokens((prev) => prev + total);
|
|
8762
8910
|
if (cached > 0) {
|
|
8763
8911
|
setSessionTotalCachedTokens((prev) => prev + cached);
|
|
8764
8912
|
}
|
|
8913
|
+
if (candidates > 0) {
|
|
8914
|
+
setSessionTotalCandidateTokens((prev) => prev + candidates);
|
|
8915
|
+
}
|
|
8765
8916
|
setSessionAgentCalls((prev) => prev + 1);
|
|
8766
8917
|
continue;
|
|
8767
8918
|
}
|
|
@@ -9137,7 +9288,7 @@ Selection: ${val}`,
|
|
|
9137
9288
|
}
|
|
9138
9289
|
)), /* @__PURE__ */ React13.createElement(Box13, { paddingX: 1, marginTop: 1 }, /* @__PURE__ */ React13.createElement(Text13, { color: "gray", dimColor: true, italic: true }, "(Press Enter to confirm selection)")));
|
|
9139
9290
|
case "stats":
|
|
9140
|
-
return /* @__PURE__ */ React13.createElement(Box13, { flexDirection: "column", borderStyle: "round", paddingX: 3, paddingY: 1, width: Math.min(100, (stdout?.columns || 100) - 2) }, /* @__PURE__ */ React13.createElement(Box13, { marginBottom: 1 }, /* @__PURE__ */ React13.createElement(Text13, { color: "white", bold: true, underline: true }, "SESSION TELEMETRY")), /* @__PURE__ */ React13.createElement(Box13, { flexDirection: "column" }, /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Session Duration:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, formatMsDuration(Date.now() - SESSION_START_TIME))), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Agent Interactions:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, sessionAgentCalls)), /* @__PURE__ */ React13.createElement(Box13, { marginLeft: 2 }, /* @__PURE__ */ React13.createElement(Box13, { width: 23 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue", dimColor: true }, "\xBB API Time:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, formatMsDuration(sessionApiTime))), /* @__PURE__ */ React13.createElement(Box13, { marginLeft: 2 }, /* @__PURE__ */ React13.createElement(Box13, { width: 23 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue", dimColor: true }, "\xBB Tool Time:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, formatMsDuration(sessionToolTime))), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Background Tasks:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, sessionBackgroundCalls)), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Tokens Consumed:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, formatTokens(sessionTotalTokens))), sessionTotalCachedTokens > 0 && /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Cached Tokens:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, formatTokens(sessionTotalCachedTokens))), sessionImageCount > 0 && /* @__PURE__ */ React13.createElement(React13.Fragment, null, /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Images Made:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, sessionImageCount)), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Image Credits:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, Number(((sessionImageCredits || 0) * 1e3).toFixed(0)), " credits"))), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Code Changes (Sess):")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, /* @__PURE__ */ React13.createElement(Text13, { color: "green" }, "+", linesAdded), " ", /* @__PURE__ */ React13.createElement(Text13, { color: "red" }, "-", linesRemoved))), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Tool Calls (Sess):")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, sessionToolSuccess + sessionToolFailure + sessionToolDenied, " ( "), /* @__PURE__ */ React13.createElement(Text13, { color: "green" }, "\u2713 ", sessionToolSuccess), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, " "), /* @__PURE__ */ React13.createElement(Text13, { color: "yellow" }, "\u2298 ", sessionToolDenied), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, " "), /* @__PURE__ */ React13.createElement(Text13, { color: "red" }, "\u2715 ", sessionToolFailure), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, " )"))), /* @__PURE__ */ React13.createElement(Box13, { flexDirection: "column", marginTop: 1 }, /* @__PURE__ */ React13.createElement(Text13, { color: "white", bold: true, underline: true }, "DAILY USAGE TRACKER"), /* @__PURE__ */ React13.createElement(Box13, { marginTop: 1 }, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Wall Time Today:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, formatDuration(dailyUsage?.duration || 0))), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Agent Interactions:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, dailyUsage?.agent || 0)), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Background Tasks:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, dailyUsage?.background || 0)), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Tokens Used Today:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, formatTokens(dailyUsage?.tokens || 0))), (dailyUsage?.cachedTokens || 0) > 0 && /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Served from Cache:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, formatTokens(dailyUsage.cachedTokens))), (dailyUsage?.imageCalls?.length || 0) > 0 && /* @__PURE__ */ React13.createElement(React13.Fragment, null, /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Images Made Today:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, dailyUsage.imageCalls.length)), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Image Credits Today:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, Number(((dailyUsage.imageCalls.reduce((sum, c) => sum + c.cost, 0) || 0) * 1e3).toFixed(0)), " credits"))), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Code Changes Today:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, /* @__PURE__ */ React13.createElement(Text13, { color: "green" }, "+", dailyUsage?.linesAdded || 0), " ", /* @__PURE__ */ React13.createElement(Text13, { color: "red" }, "-", dailyUsage?.linesRemoved || 0))), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Tool Calls Today:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, (dailyUsage?.toolSuccess || 0) + (dailyUsage?.toolFailure || 0) + (dailyUsage?.toolDenied || 0), " ( "), /* @__PURE__ */ React13.createElement(Text13, { color: "green" }, "\u2713 ", dailyUsage?.toolSuccess || 0), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, " "), /* @__PURE__ */ React13.createElement(Text13, { color: "yellow" }, "\u2298 ", dailyUsage?.toolDenied || 0), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, " "), /* @__PURE__ */ React13.createElement(Text13, { color: "red" }, "\u2715 ", dailyUsage?.toolFailure || 0), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, " )"))), /* @__PURE__ */ React13.createElement(Text13, { dimColor: true, marginTop: 1, italic: true }, "(Press ESC to return to chat)"));
|
|
9291
|
+
return /* @__PURE__ */ React13.createElement(Box13, { flexDirection: "column", borderStyle: "round", paddingX: 3, paddingY: 1, width: Math.min(100, (stdout?.columns || 100) - 2) }, /* @__PURE__ */ React13.createElement(Box13, { marginBottom: 1 }, /* @__PURE__ */ React13.createElement(Text13, { color: "white", bold: true, underline: true }, "SESSION TELEMETRY")), /* @__PURE__ */ React13.createElement(Box13, { flexDirection: "column" }, /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Session Duration:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, formatMsDuration(Date.now() - SESSION_START_TIME))), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Agent Interactions:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, sessionAgentCalls)), /* @__PURE__ */ React13.createElement(Box13, { marginLeft: 2 }, /* @__PURE__ */ React13.createElement(Box13, { width: 23 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue", dimColor: true }, "\xBB API Time:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, formatMsDuration(sessionApiTime))), /* @__PURE__ */ React13.createElement(Box13, { marginLeft: 2 }, /* @__PURE__ */ React13.createElement(Box13, { width: 23 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue", dimColor: true }, "\xBB Tool Time:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, formatMsDuration(sessionToolTime))), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Background Tasks:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, sessionBackgroundCalls)), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Tokens Consumed:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, formatTokens(sessionTotalTokens))), sessionTotalTokens > 0 && /* @__PURE__ */ React13.createElement(React13.Fragment, null, /* @__PURE__ */ React13.createElement(Box13, { marginLeft: 2 }, /* @__PURE__ */ React13.createElement(Box13, { width: 23 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue", dimColor: true }, "\xBB Input Tokens:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, formatTokens(sessionTotalTokens - sessionTotalCandidateTokens))), sessionTotalCachedTokens > 0 && /* @__PURE__ */ React13.createElement(Box13, { marginLeft: 4 }, /* @__PURE__ */ React13.createElement(Box13, { width: 21 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue", dimColor: true }, "\xBB Cached:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, formatTokens(sessionTotalCachedTokens))), sessionTotalCandidateTokens > 0 && /* @__PURE__ */ React13.createElement(Box13, { marginLeft: 2 }, /* @__PURE__ */ React13.createElement(Box13, { width: 23 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue", dimColor: true }, "\xBB Output Tokens:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, formatTokens(sessionTotalCandidateTokens)))), sessionImageCount > 0 && /* @__PURE__ */ React13.createElement(React13.Fragment, null, /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Images Made:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, sessionImageCount)), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Image Credits:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, Number(((sessionImageCredits || 0) * 1e3).toFixed(0)), " credits"))), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Code Changes (Sess):")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, /* @__PURE__ */ React13.createElement(Text13, { color: "green" }, "+", linesAdded), " ", /* @__PURE__ */ React13.createElement(Text13, { color: "red" }, "-", linesRemoved))), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Tool Calls (Sess):")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, sessionToolSuccess + sessionToolFailure + sessionToolDenied, " ( "), /* @__PURE__ */ React13.createElement(Text13, { color: "green" }, "\u2713 ", sessionToolSuccess), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, " "), /* @__PURE__ */ React13.createElement(Text13, { color: "yellow" }, "\u2298 ", sessionToolDenied), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, " "), /* @__PURE__ */ React13.createElement(Text13, { color: "red" }, "\u2715 ", sessionToolFailure), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, " )"))), /* @__PURE__ */ React13.createElement(Box13, { flexDirection: "column", marginTop: 1 }, /* @__PURE__ */ React13.createElement(Text13, { color: "white", bold: true, underline: true }, "DAILY USAGE TRACKER"), /* @__PURE__ */ React13.createElement(Box13, { marginTop: 1 }, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Wall Time Today:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, formatDuration(dailyUsage?.duration || 0))), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Agent Interactions:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, dailyUsage?.agent || 0)), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Background Tasks:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, dailyUsage?.background || 0)), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Tokens Used Today:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, formatTokens(dailyUsage?.tokens || 0))), (dailyUsage?.tokens || 0) > 0 && /* @__PURE__ */ React13.createElement(React13.Fragment, null, /* @__PURE__ */ React13.createElement(Box13, { marginLeft: 2 }, /* @__PURE__ */ React13.createElement(Box13, { width: 23 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue", dimColor: true }, "\xBB Input Tokens:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, formatTokens((dailyUsage?.tokens || 0) - (dailyUsage?.candidateTokens || 0)))), (dailyUsage?.cachedTokens || 0) > 0 && /* @__PURE__ */ React13.createElement(Box13, { marginLeft: 4 }, /* @__PURE__ */ React13.createElement(Box13, { width: 21 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue", dimColor: true }, "\xBB Cached:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, formatTokens(dailyUsage.cachedTokens))), (dailyUsage?.candidateTokens || 0) > 0 && /* @__PURE__ */ React13.createElement(Box13, { marginLeft: 2 }, /* @__PURE__ */ React13.createElement(Box13, { width: 23 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue", dimColor: true }, "\xBB Output Tokens:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, formatTokens(dailyUsage.candidateTokens)))), (dailyUsage?.imageCalls?.length || 0) > 0 && /* @__PURE__ */ React13.createElement(React13.Fragment, null, /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Images Made Today:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, dailyUsage.imageCalls.length)), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Image Credits Today:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, Number(((dailyUsage.imageCalls.reduce((sum, c) => sum + c.cost, 0) || 0) * 1e3).toFixed(0)), " credits"))), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Code Changes Today:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, /* @__PURE__ */ React13.createElement(Text13, { color: "green" }, "+", dailyUsage?.linesAdded || 0), " ", /* @__PURE__ */ React13.createElement(Text13, { color: "red" }, "-", dailyUsage?.linesRemoved || 0))), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 25 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Tool Calls Today:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, (dailyUsage?.toolSuccess || 0) + (dailyUsage?.toolFailure || 0) + (dailyUsage?.toolDenied || 0), " ( "), /* @__PURE__ */ React13.createElement(Text13, { color: "green" }, "\u2713 ", dailyUsage?.toolSuccess || 0), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, " "), /* @__PURE__ */ React13.createElement(Text13, { color: "yellow" }, "\u2298 ", dailyUsage?.toolDenied || 0), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, " "), /* @__PURE__ */ React13.createElement(Text13, { color: "red" }, "\u2715 ", dailyUsage?.toolFailure || 0), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, " )"))), /* @__PURE__ */ React13.createElement(Text13, { dimColor: true, marginTop: 1, italic: true }, "(Press ESC to return to chat)"));
|
|
9141
9292
|
case "autoExecDanger":
|
|
9142
9293
|
return /* @__PURE__ */ React13.createElement(Box13, { flexDirection: "column", borderStyle: "round", borderColor: "yellow", paddingX: 2, paddingY: 1, width: "100%" }, /* @__PURE__ */ React13.createElement(Text13, { color: "yellow", bold: true, underline: true }, "\u26A0\uFE0F SECURITY WARNING: AUTO EXECUTE MODE"), /* @__PURE__ */ React13.createElement(Text13, { marginTop: 1 }, "Turning this ON allows the agent to execute terminal commands automatically without requiring your approval for each step."), /* @__PURE__ */ React13.createElement(Text13, { marginTop: 1, color: "yellow" }, "RISKS INVOLVED:"), /* @__PURE__ */ React13.createElement(Text13, null, "\u2022 The agent may execute destructive commands (rm -rf, etc.) by mistake."), /* @__PURE__ */ React13.createElement(Text13, null, "\u2022 Unintended system changes if the agent hallucinates a path or command."), /* @__PURE__ */ React13.createElement(Text13, null, "\u2022 Reduced control over the agent's step-by-step decision making."), /* @__PURE__ */ React13.createElement(Box13, { marginTop: 1 }, /* @__PURE__ */ React13.createElement(
|
|
9143
9294
|
CommandMenu,
|
|
@@ -9545,7 +9696,7 @@ Selection: ${val}`,
|
|
|
9545
9696
|
const agentActiveMs = sessionApiTime + sessionToolTime;
|
|
9546
9697
|
const apiPercent = agentActiveMs > 0 ? (sessionApiTime / agentActiveMs * 100).toFixed(1) : "0.0";
|
|
9547
9698
|
const toolPercent = agentActiveMs > 0 ? (sessionToolTime / agentActiveMs * 100).toFixed(1) : "0.0";
|
|
9548
|
-
return /* @__PURE__ */ React13.createElement(Box13, { flexDirection: "column", borderStyle: "round", paddingX: 3, paddingY: 1, borderColor: "red", width: Math.min(100, (stdout?.columns || 100) - 2), marginTop: 0, marginBottom: 1 }, /* @__PURE__ */ React13.createElement(Box13, { marginBottom: 1 }, /* @__PURE__ */ React13.createElement(Text13, { color: "cyan", bold: true }, "Agent powering down. ", /* @__PURE__ */ React13.createElement(Text13, { color: "magenta" }, "Goodbye!"))), /* @__PURE__ */ React13.createElement(Box13, { flexDirection: "column" }, /* @__PURE__ */ React13.createElement(Text13, { color: "white", bold: true, underline: true }, "Interaction Summary"), /* @__PURE__ */ React13.createElement(Box13, { marginTop: 1 }, /* @__PURE__ */ React13.createElement(Box13, { width: 20 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Session ID:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, chatId)), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 20 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Tool Calls:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, sessionToolSuccess + sessionToolFailure + sessionToolDenied, " ( ", /* @__PURE__ */ React13.createElement(Text13, { color: "green" }, "\u2713 ", sessionToolSuccess), " ", /* @__PURE__ */ React13.createElement(Text13, { color: "yellow" }, "\u2298 ", sessionToolDenied), " ", /* @__PURE__ */ React13.createElement(Text13, { color: "red" }, "\u2715 ", sessionToolFailure), " )")), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 20 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Success Rate:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, successRate, "%")), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 20 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Code Changes:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, /* @__PURE__ */ React13.createElement(Text13, { color: "green" }, "+", linesAdded), " ", /* @__PURE__ */ React13.createElement(Text13, { color: "red" }, "-", linesRemoved))), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 20 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Tokens Consumed:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, formatTokens(sessionTotalTokens))), sessionTotalCachedTokens > 0 && /* @__PURE__ */ React13.createElement(Box13,
|
|
9699
|
+
return /* @__PURE__ */ React13.createElement(Box13, { flexDirection: "column", borderStyle: "round", paddingX: 3, paddingY: 1, borderColor: "red", width: Math.min(100, (stdout?.columns || 100) - 2), marginTop: 0, marginBottom: 1 }, /* @__PURE__ */ React13.createElement(Box13, { marginBottom: 1 }, /* @__PURE__ */ React13.createElement(Text13, { color: "cyan", bold: true }, "Agent powering down. ", /* @__PURE__ */ React13.createElement(Text13, { color: "magenta" }, "Goodbye!"))), /* @__PURE__ */ React13.createElement(Box13, { flexDirection: "column" }, /* @__PURE__ */ React13.createElement(Text13, { color: "white", bold: true, underline: true }, "Interaction Summary"), /* @__PURE__ */ React13.createElement(Box13, { marginTop: 1 }, /* @__PURE__ */ React13.createElement(Box13, { width: 20 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Session ID:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, chatId)), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 20 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Tool Calls:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, sessionToolSuccess + sessionToolFailure + sessionToolDenied, " ( ", /* @__PURE__ */ React13.createElement(Text13, { color: "green" }, "\u2713 ", sessionToolSuccess), " ", /* @__PURE__ */ React13.createElement(Text13, { color: "yellow" }, "\u2298 ", sessionToolDenied), " ", /* @__PURE__ */ React13.createElement(Text13, { color: "red" }, "\u2715 ", sessionToolFailure), " )")), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 20 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Success Rate:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, successRate, "%")), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 20 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Code Changes:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, /* @__PURE__ */ React13.createElement(Text13, { color: "green" }, "+", linesAdded), " ", /* @__PURE__ */ React13.createElement(Text13, { color: "red" }, "-", linesRemoved))), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 20 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Tokens Consumed:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, formatTokens(sessionTotalTokens))), sessionTotalTokens > 0 && /* @__PURE__ */ React13.createElement(React13.Fragment, null, /* @__PURE__ */ React13.createElement(Box13, { marginLeft: 2 }, /* @__PURE__ */ React13.createElement(Box13, { width: 18 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue", dimColor: true }, "\xBB Input Tokens:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, formatTokens(sessionTotalTokens - sessionTotalCandidateTokens))), sessionTotalCachedTokens > 0 && /* @__PURE__ */ React13.createElement(Box13, { marginLeft: 4 }, /* @__PURE__ */ React13.createElement(Box13, { width: 16 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue", dimColor: true }, "\xBB Cached:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, formatTokens(sessionTotalCachedTokens))), sessionTotalCandidateTokens > 0 && /* @__PURE__ */ React13.createElement(Box13, { marginLeft: 2 }, /* @__PURE__ */ React13.createElement(Box13, { width: 18 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue", dimColor: true }, "\xBB Output Tokens:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, formatTokens(sessionTotalCandidateTokens)))), sessionImageCount > 0 && /* @__PURE__ */ React13.createElement(React13.Fragment, null, /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 20 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Images Made:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, sessionImageCount)), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 20 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Image Credits:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, Number(((sessionImageCredits || 0) * 1e3).toFixed(0)), " credits")))), /* @__PURE__ */ React13.createElement(Box13, { flexDirection: "column", marginTop: 1 }, /* @__PURE__ */ React13.createElement(Text13, { color: "white", bold: true, underline: true }, "Performance"), /* @__PURE__ */ React13.createElement(Box13, { marginTop: 1 }, /* @__PURE__ */ React13.createElement(Box13, { width: 20 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Wall Time:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, formatMsDuration(wallTimeMs))), /* @__PURE__ */ React13.createElement(Box13, null, /* @__PURE__ */ React13.createElement(Box13, { width: 20 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue" }, "Agent Active:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, formatMsDuration(agentActiveMs))), /* @__PURE__ */ React13.createElement(Box13, { marginLeft: 2 }, /* @__PURE__ */ React13.createElement(Box13, { width: 18 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue", dimColor: true }, "\xBB API Time:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, formatMsDuration(sessionApiTime), " (", apiPercent, "%)")), /* @__PURE__ */ React13.createElement(Box13, { marginLeft: 2 }, /* @__PURE__ */ React13.createElement(Box13, { width: 18 }, /* @__PURE__ */ React13.createElement(Text13, { color: "blue", dimColor: true }, "\xBB Tool Time:")), /* @__PURE__ */ React13.createElement(Text13, { color: "white" }, formatMsDuration(sessionToolTime), " (", toolPercent, "%)"))));
|
|
9549
9700
|
})(), suggestions.length > 0 && (() => {
|
|
9550
9701
|
const windowSize = 5;
|
|
9551
9702
|
const startIdx = Math.max(0, Math.min(selectedIndex - 2, suggestions.length - windowSize));
|