fluxflow-cli 1.18.24 → 1.19.0

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.
Files changed (3) hide show
  1. package/README.md +1 -1
  2. package/dist/fluxflow.js +285 -103
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  ![Flux Flow Logo](https://github.com/KushalRoyChowdhury/fluxflow-cli/blob/main/fluxflow.png)
3
3
 
4
4
  <p align="left">
5
- <a href="https://github.com/KushalRoyChowdhury/fluxflow-cli"><img src="https://img.shields.io/badge/FluxFlow-v1.10.0-blue?style=plastic" alt="FluxFlow Version"></a>
5
+ <a href="https://github.com/KushalRoyChowdhury/fluxflow-cli"><img src="https://img.shields.io/badge/FluxFlow-v1.19.0-blue?style=plastic" alt="FluxFlow Version"></a>
6
6
  <a href="https://deepmind.google"><img src="https://img.shields.io/badge/Engine-Gemma%204-red?style=plastic" alt="Engine Gemma 4"></a>
7
7
  <a href="https://pollinations.ai"><img src="https://img.shields.io/badge/Built%20With-pollinations.ai-cyan?style=plastic" alt="Built With pollinations.ai"></a>
8
8
  <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg?style=plastic" alt="License MIT"></a>
package/dist/fluxflow.js CHANGED
@@ -487,7 +487,7 @@ var init_terminal = __esm({
487
487
  // src/components/ChatLayout.jsx
488
488
  import React3, { useState as useState2, useEffect as useEffect2, useRef as useRef2 } from "react";
489
489
  import { Box as Box3, Text as Text3 } from "ink";
490
- var TOOL_LABELS, cleanSignals, formatThinkText, parseMathSymbols, InlineMarkdown, TableRenderer, MarkdownText, DiffLine, DiffBlock, CodeRenderer, formatThinkingDuration, MessageItem, ChatLayout, ChatLayout_default;
490
+ var TOOL_LABELS, cleanSignals, formatThinkText, parseMathSymbols, renderLatexText, InlineMarkdown, TableRenderer, MarkdownText, DiffLine, DiffBlock, CodeRenderer, formatThinkingDuration, MessageItem, ChatLayout, ChatLayout_default;
491
491
  var init_ChatLayout = __esm({
492
492
  "src/components/ChatLayout.jsx"() {
493
493
  init_TerminalBox();
@@ -580,10 +580,31 @@ var init_ChatLayout = __esm({
580
580
  if (!cleaned) return null;
581
581
  const availableWidth = columns - 10;
582
582
  const wrapped = wrapText(cleaned.trim(), availableWidth);
583
- return /* @__PURE__ */ React3.createElement(Box3, { width: "100%" }, /* @__PURE__ */ React3.createElement(Text3, { italic: true, color: "gray" }, wrapped));
583
+ return /* @__PURE__ */ React3.createElement(Box3, { width: "100%" }, /* @__PURE__ */ React3.createElement(Text3, { italic: true }, /* @__PURE__ */ React3.createElement(InlineMarkdown, { text: wrapped, color: "gray" })));
584
584
  };
585
585
  parseMathSymbols = (content) => {
586
- return content.replace(/\\multiply|\\mul|\\times/g, "\xD7").replace(/\\div/g, "\xF7").replace(/\\cdot/g, "\u22C5").replace(/\\infty/g, "\u221E").replace(/\\pm/g, "\xB1").replace(/\\leq/g, "\u2264").replace(/\\geq/g, "\u2265").replace(/\\neq/g, "\u2260").replace(/\\sqrt\{?(.*?)\}?/g, (_, p1) => `\u221A(${p1})`).replace(/\\alpha/g, "\u03B1").replace(/\\beta/g, "\u03B2").replace(/\\theta/g, "\u03B8").replace(/\\pi/g, "\u03C0").replace(/\\approx/g, "\u2248").replace(/\\Delta/g, "\u0394").replace(/\\sigma/g, "\u03C3").replace(/\\sum/g, "\u03A3").replace(/\\prod/g, "\u03A0").replace(/\\rightarrow|\\to/g, "\u2192").replace(/\\leftarrow/g, "\u2190").replace(/\\leftrightarrow/g, "\u2194").replace(/\\left\(|\\right\)/g, (match) => match.includes("left") ? "(" : ")").replace(/\\left\[|\\right\]/g, (match) => match.includes("left") ? "[" : "]").replace(/\\\{|\\\}/g, (match) => match.includes("{") ? "{" : "}").replace(/\\text\{?(.*?)\}?/g, "$1");
586
+ return content.replace(/\\multiply|\\mul|\\times/g, "\xD7").replace(/\\div/g, "\xF7").replace(/\\cdot/g, "\u22C5").replace(/\\infty/g, "\u221E").replace(/\\pm/g, "\xB1").replace(/\\leq/g, "\u2264").replace(/\\geq/g, "\u2265").replace(/\\neq/g, "\u2260").replace(/\\sqrt\s*\{([^}]+)\}/g, "\u221A($1)").replace(/\\sqrt\s*(\w+|\d+)/g, "\u221A($1)").replace(/\\alpha/g, "\u03B1").replace(/\\beta/g, "\u03B2").replace(/\\theta/g, "\u03B8").replace(/\\pi/g, "\u03C0").replace(/\\approx/g, "\u2248").replace(/\\Delta/g, "\u0394").replace(/\\sigma/g, "\u03C3").replace(/\\sum/g, "\u03A3").replace(/\\prod/g, "\u03A0").replace(/\\rightarrow|\\to/g, "\u2192").replace(/\\left\b|\\right\b/g, "").replace(/\\left\(|\\right\)/g, (match) => match.includes("left") ? "(" : ")").replace(/\\left\[|\\right\]/g, (match) => match.includes("left") ? "[" : "]").replace(/\\\{|\\\}/g, (match) => match.includes("{") ? "{" : "}").replace(/\\text\s*\{([^}]+)\}/g, "$1").replace(/\\text\s+(\w+)/g, "$1").replace(/\\%/g, "%");
587
+ };
588
+ renderLatexText = (content, key) => {
589
+ if (!content) return null;
590
+ let formatted = content.replace(/\\frac\s*\{([^{}]*)\}\s*\{([^{}]*)\}/g, "($1/$2)");
591
+ formatted = parseMathSymbols(formatted);
592
+ const parts = formatted.split(/(\\(?:mathbf|textbf|textit|underline|texttt)\{[^{}]*\})/g);
593
+ return /* @__PURE__ */ React3.createElement(React3.Fragment, { key }, parts.map((p, idx) => {
594
+ if (p.startsWith("\\")) {
595
+ const match = p.match(/\\(\w+)\{([^{}]*)\}/);
596
+ if (match) {
597
+ const cmd = match[1];
598
+ const inner = match[2];
599
+ const isBold = cmd === "mathbf" || cmd === "textbf";
600
+ const isItalic = cmd === "textit";
601
+ const isUnderline = cmd === "underline";
602
+ const isMono = cmd === "texttt";
603
+ return /* @__PURE__ */ React3.createElement(Text3, { key: idx, bold: isBold, italic: isItalic, underline: isUnderline, color: isMono ? "cyan" : void 0 }, inner);
604
+ }
605
+ }
606
+ return p;
607
+ }));
587
608
  };
588
609
  InlineMarkdown = React3.memo(({ text, color }) => {
589
610
  if (!text) return null;
@@ -615,22 +636,7 @@ var init_ChatLayout = __esm({
615
636
  }
616
637
  if (part.startsWith("$") && part.endsWith("$")) {
617
638
  const content = part.slice(1, -1);
618
- const latexParts = content.split(/(\\(?:mathbf|textbf|textit|underline|text|mathrm|textsf|texttt)\{.*?\})/g);
619
- return /* @__PURE__ */ React3.createElement(Text3, { key: j, color: "yellow" }, latexParts.map((lp, lpi) => {
620
- if (lp.startsWith("\\")) {
621
- const match = lp.match(/\\(\w+)\{(.*?)\}/);
622
- if (match) {
623
- const cmd = match[1];
624
- const inner = match[2];
625
- const isBold = cmd === "mathbf" || cmd === "textbf";
626
- const isItalic = cmd === "textit";
627
- const isUnderline = cmd === "underline";
628
- const isMono = cmd === "texttt";
629
- return /* @__PURE__ */ React3.createElement(Text3, { key: lpi, bold: isBold, italic: isItalic, underline: isUnderline, color: isMono ? "cyan" : void 0 }, parseMathSymbols(inner));
630
- }
631
- }
632
- return /* @__PURE__ */ React3.createElement(Text3, { key: lpi }, parseMathSymbols(lp));
633
- }));
639
+ return /* @__PURE__ */ React3.createElement(Text3, { key: j, color: "yellow" }, renderLatexText(content, j));
634
640
  }
635
641
  if (part.startsWith("[") && (part.includes("](") || part.includes("] ("))) {
636
642
  const match = part.match(/\[(.*?)\]\s*\((.*?)\)/);
@@ -643,7 +649,7 @@ var init_ChatLayout = __esm({
643
649
  if (part.startsWith("http")) {
644
650
  return /* @__PURE__ */ React3.createElement(Text3, { key: j, color: "cyan", underline: true, italic: true }, part);
645
651
  }
646
- return part;
652
+ return renderLatexText(part, j);
647
653
  }));
648
654
  });
649
655
  TableRenderer = React3.memo(({ buffer, terminalWidth = 80 }) => {
@@ -934,7 +940,7 @@ var StatusBar, StatusBar_default;
934
940
  var init_StatusBar = __esm({
935
941
  "src/components/StatusBar.jsx"() {
936
942
  init_text();
937
- StatusBar = React4.memo(({ mode, thinkingLevel, tokens = "0.0k", tokensTotal = "0.0k", chatId = "NEW-SESSION", isMemoryEnabled = true }) => {
943
+ StatusBar = React4.memo(({ mode, thinkingLevel, tokens = "0.0k", tokensTotal = "0.0k", chatId = "NEW-SESSION", isMemoryEnabled = true, apiTier = "Free" }) => {
938
944
  const modeColor = mode === "Flux" ? "yellow" : "cyan";
939
945
  const modeIcon = mode === "Flux" ? "\u26A1" : "\u{1F30A}";
940
946
  return /* @__PURE__ */ React4.createElement(
@@ -949,7 +955,7 @@ var init_StatusBar = __esm({
949
955
  },
950
956
  /* @__PURE__ */ React4.createElement(Box4, null, /* @__PURE__ */ React4.createElement(Box4, { marginRight: 1 }, /* @__PURE__ */ React4.createElement(Text4, { color: modeColor, bold: true }, modeIcon, " ", mode.toUpperCase())), /* @__PURE__ */ React4.createElement(Text4, { color: "gray", dimColor: true }, "\u2503 "), /* @__PURE__ */ React4.createElement(Box4, { marginX: 1 }, /* @__PURE__ */ React4.createElement(Text4, { color: "magenta" }, "\u{1F9E0} ", thinkingLevel)), /* @__PURE__ */ React4.createElement(Text4, { color: "gray", dimColor: true }, "\u2503 "), /* @__PURE__ */ React4.createElement(Box4, { marginX: 1 }, /* @__PURE__ */ React4.createElement(Text4, { color: "gray" }, "MEM: "), /* @__PURE__ */ React4.createElement(Text4, { color: isMemoryEnabled ? "green" : "red", bold: true }, isMemoryEnabled ? "ON" : "OFF"))),
951
957
  /* @__PURE__ */ React4.createElement(Box4, { flexGrow: 1, justifyContent: "center", paddingX: 2 }, /* @__PURE__ */ React4.createElement(Text4, null, "\u{1F4C1}"), /* @__PURE__ */ React4.createElement(Text4, { color: "gray", italic: true }, " ", truncatePath(process.cwd(), 35))),
952
- /* @__PURE__ */ React4.createElement(Box4, null, /* @__PURE__ */ React4.createElement(Text4, { color: "gray", dimColor: true }, "\u2503 "), /* @__PURE__ */ React4.createElement(Box4, { marginX: 1 }, /* @__PURE__ */ React4.createElement(Text4, null, "\u2728"), /* @__PURE__ */ React4.createElement(Text4, { color: "blue" }, " ", formatTokens(tokensTotal), " ", /* @__PURE__ */ React4.createElement(Text4, { dimColor: true }, "(", (tokens / 254e3 * 100).toFixed(0), "%)"))), /* @__PURE__ */ React4.createElement(Text4, { color: "gray", dimColor: true }, "\u2503 "), /* @__PURE__ */ React4.createElement(Box4, { marginLeft: 1 }, /* @__PURE__ */ React4.createElement(Text4, null, "\u{1F194}"), /* @__PURE__ */ React4.createElement(Text4, { color: "gray", dimColor: true, italic: true }, " ", chatId)))
958
+ /* @__PURE__ */ React4.createElement(Box4, null, /* @__PURE__ */ React4.createElement(Text4, { color: "gray", dimColor: true }, "\u2503 "), /* @__PURE__ */ React4.createElement(Box4, { marginX: 1 }, /* @__PURE__ */ React4.createElement(Text4, null, "\u2728"), /* @__PURE__ */ React4.createElement(Text4, { color: "blue" }, " ", formatTokens(tokensTotal), " ", /* @__PURE__ */ React4.createElement(Text4, { dimColor: true }, "(", (tokens / 254e3 * 100).toFixed(0), "%)"))), /* @__PURE__ */ React4.createElement(Text4, { color: "gray", dimColor: true }, "\u2503 "), /* @__PURE__ */ React4.createElement(Box4, { marginLeft: 1 }, /* @__PURE__ */ React4.createElement(Text4, null, "\u{1F194}"), /* @__PURE__ */ React4.createElement(Text4, { color: "gray", dimColor: true, italic: true }, " ", chatId), (apiTier === "Custom" || apiTier === "Paid") && /* @__PURE__ */ React4.createElement(Text4, { color: "gray", dimColor: true }, " | ", /* @__PURE__ */ React4.createElement(Text4, { color: "green", bold: true }, "PAID"))))
953
959
  );
954
960
  });
955
961
  StatusBar_default = StatusBar;
@@ -972,7 +978,7 @@ function CommandMenu({ title, subtitle, items, onSelect }) {
972
978
  flexShrink: 0,
973
979
  width: "100%"
974
980
  },
975
- /* @__PURE__ */ React5.createElement(Box5, { paddingX: 1, paddingY: 0, marginBottom: subtitle ? 0 : 1 }, /* @__PURE__ */ React5.createElement(Text5, { color: "magenta", bold: true }, "\u{1F527} ", title.toUpperCase())),
981
+ /* @__PURE__ */ React5.createElement(Box5, { paddingX: 1, paddingY: 0, marginBottom: subtitle ? 0 : 1 }, /* @__PURE__ */ React5.createElement(Text5, { color: "magenta", bold: true }, "\u{1F527} ", typeof title === "string" ? title.toUpperCase() : title)),
976
982
  subtitle && /* @__PURE__ */ React5.createElement(Box5, { paddingX: 1, marginBottom: 1 }, /* @__PURE__ */ React5.createElement(Text5, { color: "yellow", dimColor: true, italic: true }, " ", subtitle)),
977
983
  /* @__PURE__ */ React5.createElement(Box5, { flexDirection: "column", width: "100%" }, /* @__PURE__ */ React5.createElement(
978
984
  SelectInput,
@@ -2408,11 +2414,14 @@ ${parts.join("\n\n")}
2408
2414
  ` : "";
2409
2415
  };
2410
2416
  getSystemInstruction = (profile, thinkingLevel, mode, systemSettings, isMemoryEnabled = true) => {
2411
- let levelKey = thinkingLevel;
2412
- if (thinkingLevel === "Fast") levelKey = "Off";
2413
- if (thinkingLevel === "Low") levelKey = "Minimal";
2414
- if (thinkingLevel === "xHigh" || thinkingLevel === "Max") levelKey = "xHigh";
2415
- const thinkingConfig = thinking_prompts_default[levelKey] || thinking_prompts_default["Medium"];
2417
+ let thinkingConfig = "";
2418
+ if (thinkingLevel !== "GEM") {
2419
+ let levelKey = thinkingLevel;
2420
+ if (thinkingLevel === "Fast") levelKey = "Off";
2421
+ if (thinkingLevel === "Low") levelKey = "Minimal";
2422
+ if (thinkingLevel === "xHigh" || thinkingLevel === "Max") levelKey = "xHigh";
2423
+ thinkingConfig = thinking_prompts_default[levelKey] || thinking_prompts_default["Medium"];
2424
+ }
2416
2425
  const osDetected = process.platform === "win32" ? "Windows" : process.platform === "darwin" ? "macOS" : "Linux";
2417
2426
  const userInstrStr = profile.instructions && profile.instructions?.length > 0 ? `User Instructions: ${profile.instructions}
2418
2427
 
@@ -2460,14 +2469,14 @@ Mode: ${mode}${thinkingLevel !== "Fast" ? " (Thinking Mode)" : ""}. ${mode === "
2460
2469
  SYSTEM PRIORITY: [SYSTEM], [TOOL RESULT]
2461
2470
  HIGH PRIORITY: [STEERING HINT]
2462
2471
  USER PRIORITY: [USER]
2463
-
2472
+ ${thinkingLevel !== "GEM" ? `
2464
2473
  -- THINKING RULES --
2465
2474
  ${thinkingConfig}
2466
2475
  ${thinkingLevel !== "Fast" ? `
2467
2476
  CRITICAL THINKING POLICY
2468
2477
  - ALWAYS use <think> ... </think> before responding, even with simple queries/greetings
2469
2478
  - ${thinkingLevel === "Low" || thinkingLevel === "Medium" || thinkingLevel === "Fast" ? "C" : "Interrogate approaches adversarially, but c"}ommit once best solution is determined through analysis. Avoid spiraling after reaching decision point
2470
- ` : ""}
2479
+ ` : ""}` : ""}
2471
2480
  ${TOOL_PROTOCOL(mode, osDetected)}
2472
2481
  ${projectContextBlock}
2473
2482
  -- MEMORY RULES --
@@ -2922,6 +2931,7 @@ var init_usage = __esm({
2922
2931
  toolDenied: 0,
2923
2932
  duration: 0,
2924
2933
  tokens: 0,
2934
+ cachedTokens: 0,
2925
2935
  linesAdded: 0,
2926
2936
  linesRemoved: 0,
2927
2937
  imageCalls: []
@@ -3133,13 +3143,13 @@ var init_usage = __esm({
3133
3143
  const quotas = settings.quotas || {};
3134
3144
  if (tier === "Free") {
3135
3145
  if (key === "agent" || key === "background") {
3136
- return usage.agent + usage.background < 1500;
3146
+ return usage.agent + usage.background < 999999;
3137
3147
  }
3138
3148
  if (key === "search") return true;
3139
3149
  }
3140
3150
  if (tier === "Paid" || tier === "Custom") {
3141
- if (key === "agent") return usage.agent < (quotas.agentLimit || 1500);
3142
- if (key === "background") return usage.background < (quotas.backgroundLimit || 1500);
3151
+ if (key === "agent") return usage.agent < (quotas.agentLimit || 999999);
3152
+ if (key === "background") return usage.background < (quotas.backgroundLimit || 999999);
3143
3153
  if (key === "search") return usage.search < (quotas.searchLimit || 100);
3144
3154
  }
3145
3155
  return true;
@@ -4294,7 +4304,12 @@ import path13 from "path";
4294
4304
  async function getFilesRecursively(dir, excludes, baseDir = dir, depth = 1) {
4295
4305
  if (depth > 12) return [];
4296
4306
  let results = [];
4297
- const list = await fs14.readdir(dir, { withFileTypes: true });
4307
+ let list;
4308
+ try {
4309
+ list = await fs14.readdir(dir, { withFileTypes: true });
4310
+ } catch {
4311
+ return [];
4312
+ }
4298
4313
  for (const file of list) {
4299
4314
  const fullPath = path13.join(dir, file.name);
4300
4315
  const relativePath = path13.relative(baseDir, fullPath);
@@ -4317,9 +4332,22 @@ var init_search_keyword = __esm({
4317
4332
  search_keyword = async (args) => {
4318
4333
  const { keyword, file } = parseArgs(args);
4319
4334
  if (!keyword) return 'ERROR: Missing "keyword" argument.';
4320
- const excludes = ["node_modules", ".git", "dist", ".next", ".gemini"];
4335
+ const excludes = [
4336
+ "node_modules",
4337
+ ".git",
4338
+ "dist",
4339
+ ".next",
4340
+ ".gemini",
4341
+ ".exe",
4342
+ ".dll",
4343
+ ".png",
4344
+ ".jpg",
4345
+ ".jpeg",
4346
+ ".gif",
4347
+ ".zip",
4348
+ ".tgz"
4349
+ ];
4321
4350
  const maxMatches = 150;
4322
- let matches = [];
4323
4351
  try {
4324
4352
  let filesToSearch = [];
4325
4353
  const rootDir = process.cwd();
@@ -4336,30 +4364,30 @@ var init_search_keyword = __esm({
4336
4364
  } else {
4337
4365
  filesToSearch = await getFilesRecursively(rootDir, excludes);
4338
4366
  }
4339
- for (const fileObj of filesToSearch) {
4340
- if (matches.length >= maxMatches) break;
4341
- let content = await fs14.readFile(fileObj.fullPath, "utf-8");
4342
- if (content.includes("\0")) {
4343
- content = null;
4344
- continue;
4345
- }
4346
- const lines = content.split(/\r?\n/);
4347
- content = null;
4348
- for (let i = 0; i < lines.length; i++) {
4349
- if (lines[i].includes(keyword)) {
4350
- const displayPath = fileObj.relativePath.replace(/\\/g, "/");
4351
- matches.push(`${displayPath} \u2192 ${i + 1}`);
4352
- if (matches.length >= maxMatches) break;
4367
+ const searchPromises = filesToSearch.map(async (fileObj) => {
4368
+ try {
4369
+ const content = await fs14.readFile(fileObj.fullPath, "utf-8");
4370
+ if (content.includes("\0")) return [];
4371
+ const lines = content.split(/\r?\n/);
4372
+ const fileMatches = [];
4373
+ for (let i = 0; i < lines.length; i++) {
4374
+ if (lines[i].includes(keyword)) {
4375
+ const displayPath = fileObj.relativePath.replace(/\\/g, "/");
4376
+ fileMatches.push(`${displayPath} \u2192 ${i + 1}`);
4377
+ }
4353
4378
  }
4379
+ return fileMatches;
4380
+ } catch {
4381
+ return [];
4354
4382
  }
4355
- lines.length = 0;
4356
- }
4357
- filesToSearch = null;
4383
+ });
4384
+ const settledResults = await Promise.all(searchPromises);
4385
+ const matches = settledResults.flat().slice(0, maxMatches);
4358
4386
  if (typeof global.gc === "function") {
4359
4387
  global.gc();
4360
4388
  }
4361
4389
  if (matches.length === 0) {
4362
- return `Found 0 matches for keyword: "${keyword}"${file ? ` in file: ${file}` : ""}`;
4390
+ return `Found 0 matches for keyword: "${keyword}"${file ? ` in file: ${file}` : ". Try to specify files"}`;
4363
4391
  }
4364
4392
  let output = `Found ${matches.length} matches:
4365
4393
 
@@ -4388,8 +4416,8 @@ var init_settings = __esm({
4388
4416
  showFullThinking: true,
4389
4417
  apiTier: "Free",
4390
4418
  quotas: {
4391
- agentLimit: 1500,
4392
- backgroundLimit: 1500,
4419
+ agentLimit: 999999,
4420
+ backgroundLimit: 999999,
4393
4421
  searchLimit: 100,
4394
4422
  customModelId: "",
4395
4423
  customLimit: 0
@@ -4984,7 +5012,7 @@ ${originalTextProcessed.length > USER_CONTEXT_LENGTH ? "... (truncated) ...\n\n"
4984
5012
  janitorContents.push({ role: "user", parts: [{ text: userPrompt }] });
4985
5013
  let finalSynthesis = "";
4986
5014
  let attempts = 0;
4987
- const MAX_JANITOR_RETRIES = 12;
5015
+ const MAX_JANITOR_RETRIES = isMemoryEnabled ? 12 : -1;
4988
5016
  while (attempts <= MAX_JANITOR_RETRIES) {
4989
5017
  if (process.stdout.isTTY) {
4990
5018
  process.stdout.write(`\x1B]0;Retrying Finalizing... (${attempts + 1})...\x07`);
@@ -5116,7 +5144,7 @@ ${originalTextProcessed.length > USER_CONTEXT_LENGTH ? "... (truncated) ...\n\n"
5116
5144
  `);
5117
5145
  if (attempts >= MAX_JANITOR_RETRIES) {
5118
5146
  if (process.stdout.isTTY) {
5119
- process.stdout.write(`\x1B]0;Finalizing Error\x07`);
5147
+ process.stdout.write(`\x1B]0;${isMemoryEnabled ? "Finalizing Error" : "Finalizing Skipped"}\x07`);
5120
5148
  }
5121
5149
  await new Promise((resolve) => setTimeout(resolve, 3e3));
5122
5150
  }
@@ -5462,7 +5490,7 @@ ${newMemoryListStr}
5462
5490
  const otherMemories = [...cachedSummaries, ...otherRawMemories].map((mem) => `- ${mem}`).join("\n");
5463
5491
  const persistentStorage = readEncryptedJson(MEMORIES_FILE, []);
5464
5492
  const mainUserMemories = persistentStorage.map((m) => `- ${m.memory}`).join("\n");
5465
- const isContext32k = (sessionStats?.tokens || 0) >= 32e3;
5493
+ const isContext32k = (sessionStats?.tokens || 0) >= 24e3;
5466
5494
  const memoryPrompt = getMemoryPrompt(otherMemories, mainUserMemories, isMemoryEnabled, isContext32k);
5467
5495
  const dateTimeStr = (/* @__PURE__ */ new Date()).toLocaleString([], { year: "numeric", month: "numeric", day: "numeric", hour: "2-digit", minute: "2-digit", hour12: true });
5468
5496
  const COLLAPSED_DIRS_GLOBAL = [
@@ -5714,7 +5742,8 @@ CWD: ${process.cwd()}${cwdMismatch ? ` (CWD Mismatch! Previous Path: ${lastCwd})
5714
5742
  **DIRECTORY STRUCTURE**
5715
5743
  ${dirStructure}
5716
5744
  ${memoryPrompt}
5717
- ${thinkingLevel != "Fast" ? "[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();
5745
+ ${thinkingLevel != "Fast" ? `[SYSTEM] **STRICTLY FOLLOW THINKING POLICY AS CRITICAL PRIORITY. DO NOT START A RESPONSE WITHOUT ${(modelName || "gemma").toLowerCase().startsWith("gemma") ? "<think> ... </think>" : "THINKING"}**
5746
+ ` : ""}[USER] ${agentText.replace(/\s*\[Prompted on:.*?\]/g, "").trim()}`.trim();
5718
5747
  modifiedHistory.push({ role: "user", text: firstUserMsg });
5719
5748
  let lastUsage = null;
5720
5749
  const MAX_LOOPS = mode === "Flux" ? 70 : 7;
@@ -5745,7 +5774,8 @@ ${thinkingLevel != "Fast" ? "[SYSTEM] **STRICTLY FOLLOW THINKING POLICY AS CRITI
5745
5774
 
5746
5775
  [STEERING HINT]: ${hint}`;
5747
5776
  } else {
5748
- modifiedHistory.push({ role: "user", text: `${thinkingLevel != "Fast" ? "[SYSTEM] **STRICTLY FOLLOW THINKING POLICY AS CRITICAL PRIORITY. DO NOT START A RESPONSE WITHOUT <think> ... </think>**\n" : ""}[STEERING HINT]: ${hint}` });
5777
+ modifiedHistory.push({ role: "user", text: `${thinkingLevel != "Fast" ? `[SYSTEM] **STRICTLY FOLLOW THINKING POLICY AS CRITICAL PRIORITY. DO NOT START A RESPONSE WITHOUT ${(modelName || "gemma").toLowerCase().startsWith("gemma") ? "<think> ... </think>" : "THINKING"}**
5778
+ ` : ""}[STEERING HINT]: ${hint}` });
5749
5779
  }
5750
5780
  yield { type: "status", content: "Steering Hint Injected." };
5751
5781
  }
@@ -5769,7 +5799,10 @@ ${thinkingLevel != "Fast" ? "[SYSTEM] **STRICTLY FOLLOW THINKING POLICY AS CRITI
5769
5799
  let accumulatedContext = "";
5770
5800
  let dedupeBuffer = "";
5771
5801
  let isDedupeActive = false;
5802
+ let targetModel = modelName;
5803
+ let currentSystemInstruction = "";
5772
5804
  while (retryCount <= MAX_RETRIES && inStreamRetryCount <= MAX_RETRIES && !success && !TERMINATION_SIGNAL) {
5805
+ let inThinkingState = false;
5773
5806
  try {
5774
5807
  turnText = "";
5775
5808
  if (isInitialAttempt) {
@@ -5799,7 +5832,7 @@ ${thinkingLevel != "Fast" ? "[SYSTEM] **STRICTLY FOLLOW THINKING POLICY AS CRITI
5799
5832
  if (!await checkQuota("agent", settings)) {
5800
5833
  throw new Error("Error: Quota Exausted for Agent");
5801
5834
  }
5802
- let targetModel = modelName;
5835
+ targetModel = modelName;
5803
5836
  if (retryCount === MAX_RETRIES - 1) {
5804
5837
  targetModel = "gemini-3-flash-preview";
5805
5838
  yield { type: "model_update", content: "Trying with fallback model" };
@@ -5812,9 +5845,9 @@ ${thinkingLevel != "Fast" ? "[SYSTEM] **STRICTLY FOLLOW THINKING POLICY AS CRITI
5812
5845
  } else if (retryCount > 0) {
5813
5846
  yield { type: "model_update", content: null };
5814
5847
  }
5815
- const currentSystemInstruction = getSystemInstruction(profile, thinkingLevel, mode, systemSettings, isMemoryEnabled, MAX_LOOPS, loop + 1);
5848
+ currentSystemInstruction = getSystemInstruction(profile, !(targetModel || "gemma").toLowerCase().startsWith("gemma") ? "GEM" : thinkingLevel, mode, systemSettings, isMemoryEnabled, MAX_LOOPS, loop + 1);
5816
5849
  const jitInstruction = `
5817
- [SYSTEM] Tool result received. Analyze output and proceed with your turn${thinkingLevel != "Fast" ? ". **STRICTLY MAINTAIN THINKING POLICY. DO NOT START A RESPONSE WITHOUT <think> ... </think>**" : ""}`;
5850
+ [SYSTEM] Tool result received. Analyze output and proceed with your turn${thinkingLevel != "Fast" ? `. **STRICTLY MAINTAIN THINKING POLICY. DO NOT START A RESPONSE WITHOUT ${(targetModel || "gemma").toLowerCase().startsWith("gemma") ? "<think> ... </think>" : "THINKING"}**` : ""}`;
5818
5851
  const lastUserMsg = contents[contents.length - 1];
5819
5852
  let addedMarker = false;
5820
5853
  if (lastUserMsg && lastUserMsg.role === "user" && lastUserMsg.parts?.[0]?.text?.startsWith("[TOOL RESULT]")) {
@@ -5827,9 +5860,17 @@ ${thinkingLevel != "Fast" ? "[SYSTEM] **STRICTLY FOLLOW THINKING POLICY AS CRITI
5827
5860
  lastUserMsg.parts[0].text += `
5828
5861
  [SYSTEM] WARNING, Turn Limit Impending: Step ${currentStep}/${MAX_LOOPS}. Wrap up quickly/prompt user to continue & use [turn:finish] quickly.`;
5829
5862
  }
5863
+ let activeContents = contents;
5864
+ let cachedContentName = null;
5865
+ if (settings.apiTier !== "Free" && (sessionStats?.tokens || 0) > 16384) {
5866
+ if (lastUsage?.cachedContentTokenCount > 0) {
5867
+ fs17.appendFileSync("status_check.txt", `[${(/* @__PURE__ */ new Date()).toLocaleString()}] IMPLICIT CACHE HIT: ${lastUsage.cachedContentTokenCount} tokens
5868
+ `);
5869
+ }
5870
+ }
5830
5871
  stream = await client.models.generateContentStream({
5831
5872
  model: targetModel || "gemma-4-31b-it",
5832
- contents,
5873
+ contents: activeContents,
5833
5874
  config: {
5834
5875
  systemInstruction: currentSystemInstruction,
5835
5876
  temperature: mode === "Flux" ? 1 : 1.4,
@@ -5841,8 +5882,41 @@ ${thinkingLevel != "Fast" ? "[SYSTEM] **STRICTLY FOLLOW THINKING POLICY AS CRITI
5841
5882
  { category: HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT, threshold: HarmBlockThreshold.BLOCK_NONE },
5842
5883
  { category: HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT, threshold: HarmBlockThreshold.BLOCK_NONE }
5843
5884
  ],
5844
- thinkingConfig: { includeThoughts: false, thinkingLevel: ThinkingLevel.MINIMAL }
5845
- // Optimized for Gemma 4.
5885
+ thinkingConfig: (() => {
5886
+ const modelLower = (targetModel || "").toLowerCase();
5887
+ const isGemma4 = modelLower.includes("gemma-4") || modelLower.startsWith("gemma");
5888
+ const isGemini3 = modelLower.includes("gemini-3");
5889
+ if (isGemma4 || isGemini3) {
5890
+ if (isGemma4) {
5891
+ return { includeThoughts: false, thinkingLevel: ThinkingLevel.MINIMAL };
5892
+ }
5893
+ return {
5894
+ includeThoughts: true,
5895
+ thinkingLevel: {
5896
+ "Fast": modelLower.includes("pro") ? ThinkingLevel.LOW : ThinkingLevel.MINIMAL,
5897
+ "Low": ThinkingLevel.LOW,
5898
+ "Medium": ThinkingLevel.MEDIUM,
5899
+ "High": ThinkingLevel.HIGH,
5900
+ "xHigh": ThinkingLevel.HIGH
5901
+ }[thinkingLevel] || ThinkingLevel.MEDIUM
5902
+ };
5903
+ } else {
5904
+ const budget = {
5905
+ "Fast": -1,
5906
+ "Low": 512,
5907
+ "Medium": 2048,
5908
+ "High": 16384,
5909
+ "xHigh": 24576
5910
+ }[thinkingLevel] || 2048;
5911
+ if (budget === -1) {
5912
+ return { includeThoughts: false };
5913
+ }
5914
+ return {
5915
+ includeThoughts: true,
5916
+ thinkingBudget: budget
5917
+ };
5918
+ }
5919
+ })()
5846
5920
  }
5847
5921
  });
5848
5922
  if (addedMarker && contents[contents.length - 1]?.parts?.[0]) {
@@ -5860,12 +5934,40 @@ ${thinkingLevel != "Fast" ? "[SYSTEM] **STRICTLY FOLLOW THINKING POLICY AS CRITI
5860
5934
  for await (const chunk of stream) {
5861
5935
  if (TERMINATION_SIGNAL) {
5862
5936
  yield { type: "status", content: "Termination Signal Received." };
5863
- await new Promise((resolve) => setTimeout(resolve, 3e3));
5937
+ await new Promise((resolve) => setTimeout(resolve, 1500));
5864
5938
  break;
5865
5939
  }
5866
- if (chunk.text) {
5940
+ let chunkText = "";
5941
+ const parts = chunk.candidates?.[0]?.content?.parts;
5942
+ if (parts && parts.length > 0) {
5943
+ for (const part of parts) {
5944
+ if (part.thought) {
5945
+ if (part.text) {
5946
+ if (!inThinkingState) {
5947
+ chunkText += "<think>";
5948
+ inThinkingState = true;
5949
+ }
5950
+ chunkText += part.text;
5951
+ }
5952
+ } else if (part.text) {
5953
+ if (inThinkingState) {
5954
+ chunkText += "</think>";
5955
+ inThinkingState = false;
5956
+ }
5957
+ chunkText += part.text;
5958
+ }
5959
+ }
5960
+ } else {
5961
+ const t = chunk.text || "";
5962
+ if (t && inThinkingState) {
5963
+ chunkText += "</think>";
5964
+ inThinkingState = false;
5965
+ }
5966
+ chunkText += t;
5967
+ }
5968
+ if (chunkText) {
5867
5969
  if (isDedupeActive) {
5868
- dedupeBuffer += chunk.text;
5970
+ dedupeBuffer += chunkText;
5869
5971
  if (dedupeBuffer.length >= 30) {
5870
5972
  let overlapLen = 0;
5871
5973
  const maxPossibleOverlap = Math.min(accumulatedContext.length, dedupeBuffer.length);
@@ -5889,8 +5991,8 @@ ${thinkingLevel != "Fast" ? "[SYSTEM] **STRICTLY FOLLOW THINKING POLICY AS CRITI
5889
5991
  }
5890
5992
  continue;
5891
5993
  } else {
5892
- turnText += chunk.text;
5893
- yield { type: "text", content: chunk.text };
5994
+ turnText += chunkText;
5995
+ yield { type: "text", content: chunkText };
5894
5996
  }
5895
5997
  const signalSafeText3 = getSanitizedText(turnText);
5896
5998
  const toolContext = getActiveToolContext(turnText);
@@ -5970,17 +6072,20 @@ ${thinkingLevel != "Fast" ? "[SYSTEM] **STRICTLY FOLLOW THINKING POLICY AS CRITI
5970
6072
  const wordCount = thinkContent.split(/\s+/).filter((w) => w.length > 0).length;
5971
6073
  let repetitionThresholdThinking = 0.4;
5972
6074
  let repetitionThresholdResponse = 0.6;
5973
- const thinkingCaps = {
5974
- "low": 256,
5975
- "medium": 768,
5976
- "high": 2048,
5977
- "max": 4096,
5978
- "xhigh": 4096
5979
- };
5980
- const cap = thinkingCaps[thinkingLevel?.toLowerCase()] || 2500;
5981
- let isOverVerboseThinking = wordCount > cap;
6075
+ let isOverVerboseThinking = false;
6076
+ if ((targetModel || "").toLowerCase().startsWith("gemma")) {
6077
+ const thinkingCaps = {
6078
+ "low": 256,
6079
+ "medium": 768,
6080
+ "high": 2048,
6081
+ "max": 4096,
6082
+ "xhigh": 4096
6083
+ };
6084
+ const cap = thinkingCaps[thinkingLevel?.toLowerCase()] || 2500;
6085
+ isOverVerboseThinking = wordCount > cap;
6086
+ }
5982
6087
  if (repetitionRatio > repetitionThresholdThinking || isOverVerboseThinking) {
5983
- const reason = repetitionRatio > repetitionThresholdThinking ? "Thinking Loop Detected" : "Thinking Budget Exceeded";
6088
+ const reason = repetitionRatio > repetitionThresholdThinking ? "Reasoning Loop Detected" : "Thinking Budget Exceeded";
5984
6089
  yield { type: "status", content: `${reason}. Re-centering...` };
5985
6090
  isThinkingLoop = true;
5986
6091
  await new Promise((resolve) => setTimeout(resolve, 3e3));
@@ -6374,6 +6479,15 @@ ${boxBottom}` };
6374
6479
  yield { type: "liveTokens", content: lastUsage.totalTokenCount };
6375
6480
  }
6376
6481
  }
6482
+ if (inThinkingState) {
6483
+ inThinkingState = false;
6484
+ if (isDedupeActive) {
6485
+ dedupeBuffer += "</think>";
6486
+ } else {
6487
+ turnText += "</think>";
6488
+ yield { type: "text", content: "</think>" };
6489
+ }
6490
+ }
6377
6491
  if (isDedupeActive && dedupeBuffer.length > 0) {
6378
6492
  let overlapLen = 0;
6379
6493
  const maxPossibleOverlap = Math.min(accumulatedContext.length, dedupeBuffer.length);
@@ -6409,10 +6523,27 @@ ${boxBottom}` };
6409
6523
  await incrementUsage("agent");
6410
6524
  } catch (err) {
6411
6525
  if (String(err).includes("Incomplete JSON segment at the end")) {
6526
+ if (inThinkingState) {
6527
+ inThinkingState = false;
6528
+ if (isDedupeActive) {
6529
+ dedupeBuffer += "</think>";
6530
+ } else {
6531
+ turnText += "</think>";
6532
+ yield { type: "text", content: "</think>" };
6533
+ }
6534
+ }
6412
6535
  success = true;
6413
6536
  await incrementUsage("agent");
6414
6537
  break;
6415
6538
  }
6539
+ if (inThinkingState) {
6540
+ inThinkingState = false;
6541
+ if (isDedupeActive) {
6542
+ dedupeBuffer += "</think>";
6543
+ } else {
6544
+ turnText += "</think>";
6545
+ }
6546
+ }
6416
6547
  if (isDedupeActive && dedupeBuffer.length > 0) {
6417
6548
  let overlapLen = 0;
6418
6549
  const maxPossibleOverlap = Math.min(accumulatedContext.length, dedupeBuffer.length);
@@ -6505,7 +6636,12 @@ Error Log can be found in ${path16.join(LOGS_DIR, "agent", "error.log")}`);
6505
6636
  }
6506
6637
  }
6507
6638
  if (lastUsage) {
6508
- await addToUsage("tokens", lastUsage.totalTokenCount || 0);
6639
+ const total = lastUsage.totalTokenCount || 0;
6640
+ const cached = lastUsage.cachedContentTokenCount || 0;
6641
+ await addToUsage("tokens", total);
6642
+ if (cached > 0) {
6643
+ await addToUsage("cachedTokens", cached);
6644
+ }
6509
6645
  yield { type: "usage", content: lastUsage };
6510
6646
  }
6511
6647
  fullAgentResponseChunks.push(turnText);
@@ -7180,7 +7316,7 @@ function App({ args = [] }) {
7180
7316
  const [tempKey, setTempKey] = useState10("");
7181
7317
  const [activeView, setActiveView] = useState10("chat");
7182
7318
  const [apiTier, setApiTier] = useState10("Free");
7183
- const [quotas, setQuotas] = useState10({ agentLimit: 1500, backgroundLimit: 1500, searchLimit: 100, customModelId: "", customLimit: 0 });
7319
+ const [quotas, setQuotas] = useState10({ agentLimit: 999999, backgroundLimit: 999999, searchLimit: 100, customModelId: "", customLimit: 0 });
7184
7320
  const [inputConfig, setInputConfig] = useState10(null);
7185
7321
  const [systemSettings, setSystemSettings] = useState10({ memory: true, compression: 0, autoExec: false, autoDeleteHistory: "7d", autoUpdate: false, updateManager: "npm", customUpdateCommand: "" });
7186
7322
  const [profileData, setProfileData] = useState10({ name: null, nickname: null, instructions: null });
@@ -7189,6 +7325,7 @@ function App({ args = [] }) {
7189
7325
  const [sessionAgentCalls, setSessionAgentCalls] = useState10(0);
7190
7326
  const [sessionBackgroundCalls, setSessionBackgroundCalls] = useState10(0);
7191
7327
  const [sessionTotalTokens, setSessionTotalTokens] = useState10(0);
7328
+ const [sessionTotalCachedTokens, setSessionTotalCachedTokens] = useState10(0);
7192
7329
  const [sessionToolSuccess, setSessionToolSuccess] = useState10(0);
7193
7330
  const [sessionToolFailure, setSessionToolFailure] = useState10(0);
7194
7331
  const [sessionToolDenied, setSessionToolDenied] = useState10(0);
@@ -7202,10 +7339,23 @@ function App({ args = [] }) {
7202
7339
  const [execOutput, setExecOutput] = useState10("");
7203
7340
  const [isTerminalFocused, setIsTerminalFocused] = useState10(false);
7204
7341
  const [tick, setTick] = useState10(0);
7342
+ const isFirstRender = useRef3(true);
7343
+ const isSecondRender = useRef3(true);
7205
7344
  useEffect7(() => {
7345
+ if (isFirstRender.current) {
7346
+ isFirstRender.current = false;
7347
+ setTimeout(() => {
7348
+ isSecondRender.current = false;
7349
+ }, 2e3);
7350
+ return;
7351
+ }
7352
+ if (isSecondRender.current) {
7353
+ return;
7354
+ }
7206
7355
  const s = emojiSpace(2);
7207
7356
  if (apiTier === "Free") {
7208
7357
  setActiveModel("gemma-4-31b-it");
7358
+ saveSettings({ apiTier: "Free", activeModel: "gemma-4-31b-it" });
7209
7359
  setMessages((prev) => {
7210
7360
  setCompletedIndex(prev.length + 1);
7211
7361
  return [...prev, {
@@ -7217,12 +7367,13 @@ function App({ args = [] }) {
7217
7367
  });
7218
7368
  } else {
7219
7369
  setActiveModel("gemini-3-flash-preview");
7370
+ saveSettings({ apiTier: "Paid", activeModel: "gemini-3-flash-preview" });
7220
7371
  setMessages((prev) => {
7221
7372
  setCompletedIndex(prev.length + 1);
7222
7373
  return [...prev, {
7223
7374
  id: "tier-switch-" + Date.now(),
7224
7375
  role: "system",
7225
- text: `\u26A0\uFE0F${s}**[TIER LIMIT]** Auto-switched to Gemini 3 Flash Preview.`,
7376
+ text: `\u26A0\uFE0F${s}**[TIER LIMIT]** Auto-switched to Gemini 3 Flash.`,
7226
7377
  isMeta: true
7227
7378
  }];
7228
7379
  });
@@ -7512,7 +7663,7 @@ function App({ args = [] }) {
7512
7663
  }
7513
7664
  setShowFullThinking(saved.showFullThinking);
7514
7665
  setApiTier(saved.apiTier || "Free");
7515
- setQuotas(saved.quotas || { agentLimit: 1500, searchLimit: 100, customModelId: "", customLimit: 0 });
7666
+ setQuotas(saved.quotas || { agentLimit: 999999, backgroundLimit: 999999, searchLimit: 100, customModelId: "", customLimit: 0 });
7516
7667
  const freshSettings = {
7517
7668
  memory: true,
7518
7669
  compression: 0,
@@ -7618,10 +7769,11 @@ function App({ args = [] }) {
7618
7769
  showFullThinking,
7619
7770
  systemSettings,
7620
7771
  profileData,
7621
- imageSettings
7772
+ imageSettings,
7773
+ apiTier
7622
7774
  });
7623
7775
  }
7624
- }, [mode, thinkingLevel, activeModel, showFullThinking, systemSettings, profileData, imageSettings, isInitializing, parsedArgs]);
7776
+ }, [mode, thinkingLevel, activeModel, showFullThinking, systemSettings, profileData, imageSettings, isInitializing, parsedArgs, apiTier]);
7625
7777
  const handleSetup = async (val) => {
7626
7778
  const key = val.trim();
7627
7779
  if (key.length >= 30) {
@@ -7730,20 +7882,36 @@ function App({ args = [] }) {
7730
7882
  },
7731
7883
  {
7732
7884
  cmd: "/model",
7733
- desc: "Switch AI model",
7885
+ desc: "Switch Model for Agent",
7734
7886
  subs: apiTier === "Free" ? [
7735
7887
  {
7736
7888
  cmd: "gemma-4-31b-it",
7737
7889
  desc: "Standard Default"
7890
+ },
7891
+ {
7892
+ cmd: "gemini-3-flash-preview",
7893
+ desc: "Fast & Lightweight (Limited Free Quota)"
7894
+ },
7895
+ {
7896
+ cmd: "gemini-3.5-flash",
7897
+ desc: "Flash Latest (Limited Free Quota) [Instability Issues]"
7738
7898
  }
7739
7899
  ] : [
7900
+ {
7901
+ cmd: "gemini-3.1-flash-lite",
7902
+ desc: "Ultra-Fast & Lite"
7903
+ },
7740
7904
  {
7741
7905
  cmd: "gemini-3-flash-preview",
7742
- desc: "Fast & Lightweight"
7906
+ desc: "Default, Fast & Lightweight"
7743
7907
  },
7744
7908
  {
7745
7909
  cmd: "gemini-3.5-flash",
7746
- desc: "Latest"
7910
+ desc: "Flash Latest [Instability Issues]"
7911
+ },
7912
+ {
7913
+ cmd: "gemini-3.1-pro-preview",
7914
+ desc: "Pro Reasoning"
7747
7915
  }
7748
7916
  ]
7749
7917
  },
@@ -8528,6 +8696,15 @@ Selection: ${val}`,
8528
8696
  if (packet.type === "interactive_turn_finished") {
8529
8697
  setIsProcessing(false);
8530
8698
  hasFiredJanitor = true;
8699
+ setMessages((prev) => {
8700
+ const aiHistory = packet.data.history;
8701
+ return prev.map((msg, idx) => {
8702
+ if (aiHistory[idx]) {
8703
+ return { ...msg, fullText: aiHistory[idx].text };
8704
+ }
8705
+ return msg;
8706
+ });
8707
+ });
8531
8708
  runJanitorTask(
8532
8709
  { profile: profileData, thinkingLevel, mode, janitorModel, chatId, systemSettings, sessionStats },
8533
8710
  packet.data.agentText,
@@ -8562,8 +8739,12 @@ Selection: ${val}`,
8562
8739
  }
8563
8740
  if (packet.type === "usage") {
8564
8741
  const total = packet.content.totalTokenCount || 0;
8742
+ const cached = packet.content.cachedContentTokenCount || 0;
8565
8743
  setSessionStats({ tokens: total });
8566
8744
  setSessionTotalTokens((prev) => prev + total);
8745
+ if (cached > 0) {
8746
+ setSessionTotalCachedTokens((prev) => prev + cached);
8747
+ }
8567
8748
  setSessionAgentCalls((prev) => prev + 1);
8568
8749
  continue;
8569
8750
  }
@@ -8671,13 +8852,13 @@ Selection: ${val}`,
8671
8852
  currentThinkId = "think-" + Date.now();
8672
8853
  setMessages((prev) => [...prev, { id: currentThinkId, role: "think", text: "", isStreaming: true, startTime: Date.now() }]);
8673
8854
  }
8674
- if (chunkLower.includes("</think>") || chunkLower.includes("</thought>")) {
8855
+ if ((chunkLower.includes("</think>") || chunkLower.includes("</thought>")) && currentThinkId) {
8675
8856
  const parts = chunkText.split(/<\/(think|thought)>/gi);
8676
8857
  const thinkPart = parts[0] || "";
8677
8858
  const agentPart = parts.slice(2).join("").replace(/<\/?(think|thought)>/gi, "");
8678
8859
  setMessages((prev) => {
8679
8860
  const newMsgs = prev.map((m) => {
8680
- if (m.id === currentThinkId) {
8861
+ if (m.id === currentThinkId && typeof m.id === "string") {
8681
8862
  const startTime = m.startTime || parseInt(m.id.split("-")[1]) || Date.now();
8682
8863
  const duration = Date.now() - startTime;
8683
8864
  return { ...m, text: m.text + thinkPart, isStreaming: false, duration };
@@ -8850,10 +9031,10 @@ Selection: ${val}`,
8850
9031
  return /* @__PURE__ */ React13.createElement(
8851
9032
  CommandMenu,
8852
9033
  {
8853
- title: `API Tier: ${apiTier}`,
9034
+ title: /* @__PURE__ */ React13.createElement(Text13, null, "SELECT YOUR CURRENT API TIER BASED ON ", /* @__PURE__ */ React13.createElement(Text13, { color: "cyan", underline: true, bold: true }, "\x1B]8;;https://aistudio.google.com/projects\x07AI STUDIO\x1B]8;;\x07"), ". (CURRENT: ", apiTier.toUpperCase(), ")"),
8854
9035
  items: [
8855
- { label: "Free Tier (Gemini API Free Tier - Optimized for Gemma 4 Model)", value: "Free" },
8856
- { label: `Custom (for using Paid API)`, value: "Custom" },
9036
+ { label: "Free Tier (Gemini API Free Tier)", value: "Free" },
9037
+ { label: `Paid Tier (API with Billing Account)`, value: "Paid" },
8857
9038
  { label: "Back", value: "settings" }
8858
9039
  ],
8859
9040
  onSelect: (item) => {
@@ -8863,9 +9044,9 @@ Selection: ${val}`,
8863
9044
  }
8864
9045
  const newTier = item.value;
8865
9046
  setApiTier(newTier);
8866
- if (newTier === "Custom") {
9047
+ if (newTier === "Paid") {
8867
9048
  setInputConfig({
8868
- label: "Enter Agent daily limit (requests made):",
9049
+ label: "Enter Agent daily budget (requests made):",
8869
9050
  key: "quotas",
8870
9051
  subKey: "agentLimit",
8871
9052
  value: String(quotas.agentLimit)
@@ -8939,7 +9120,7 @@ Selection: ${val}`,
8939
9120
  }
8940
9121
  )), /* @__PURE__ */ React13.createElement(Box13, { paddingX: 1, marginTop: 1 }, /* @__PURE__ */ React13.createElement(Text13, { color: "gray", dimColor: true, italic: true }, "(Press Enter to confirm selection)")));
8941
9122
  case "stats":
8942
- 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))), /* @__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 || 0)), /* @__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))), /* @__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 || 0)), /* @__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)"));
9123
+ 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)"));
8943
9124
  case "autoExecDanger":
8944
9125
  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(
8945
9126
  CommandMenu,
@@ -9321,7 +9502,7 @@ Selection: ${val}`,
9321
9502
  showFullThinking,
9322
9503
  columns: Math.max(20, (stdout?.columns || 80) - 1)
9323
9504
  }
9324
- ), activeCommand && /* @__PURE__ */ React13.createElement(Box13, { marginTop: 1 }, /* @__PURE__ */ React13.createElement(TerminalBox, { command: activeCommand, output: execOutput, isFocused: isTerminalFocused, isPty: isActiveCommandPty }))), isInitializing ? /* @__PURE__ */ React13.createElement(Box13, { borderStyle: "double", borderColor: "magenta", padding: 1, flexShrink: 0 }, /* @__PURE__ */ React13.createElement(Text13, { color: "magenta" }, "\u{1F30A} Starting Flux Flow...")) : !apiKey ? /* @__PURE__ */ React13.createElement(Box13, { borderStyle: "round", borderColor: "gray", padding: 0, flexDirection: "column", flexShrink: 0, width: "100%" }, /* @__PURE__ */ React13.createElement(Box13, { paddingX: 1, marginBottom: 1 }, /* @__PURE__ */ React13.createElement(Text13, { color: "yellow", bold: true }, "\u{1F511}", emojiSpace(2), "API KEY REQUIRED")), /* @__PURE__ */ React13.createElement(Box13, { paddingX: 1, flexDirection: "column" }, /* @__PURE__ */ React13.createElement(Text13, null, "Please enter your Gemini API Key to initialize the agent."), /* @__PURE__ */ React13.createElement(Box13, { marginTop: 1 }, /* @__PURE__ */ React13.createElement(Text13, { color: "cyan", bold: true }, "\u{1F4A0} "), /* @__PURE__ */ React13.createElement(
9505
+ ), activeCommand && /* @__PURE__ */ React13.createElement(Box13, { marginTop: 1 }, /* @__PURE__ */ React13.createElement(TerminalBox, { command: activeCommand, output: execOutput, isFocused: isTerminalFocused, isPty: isActiveCommandPty }))), isInitializing ? /* @__PURE__ */ React13.createElement(Box13, { borderStyle: "double", borderColor: "magenta", padding: 1, flexShrink: 0 }, /* @__PURE__ */ React13.createElement(Text13, { color: "magenta" }, "\u{1F30A} Starting Flux Flow...")) : !apiKey ? /* @__PURE__ */ React13.createElement(Box13, { borderStyle: "round", borderColor: "gray", padding: 0, flexDirection: "column", flexShrink: 0, width: "100%" }, /* @__PURE__ */ React13.createElement(Box13, { paddingX: 1, marginBottom: 1 }, /* @__PURE__ */ React13.createElement(Text13, { color: "yellow", bold: true }, "\u{1F511}", emojiSpace(2), "API KEY REQUIRED")), /* @__PURE__ */ React13.createElement(Box13, { paddingX: 1, flexDirection: "column" }, /* @__PURE__ */ React13.createElement(Text13, null, "Please enter your Gemini API Key to initialize the agent (If billing is enabled set Tier to paid in /settings \u2192 other \u2192 API Tier)."), /* @__PURE__ */ React13.createElement(Box13, { marginTop: 1 }, /* @__PURE__ */ React13.createElement(Text13, { color: "cyan", bold: true }, "\u{1F4A0} "), /* @__PURE__ */ React13.createElement(
9325
9506
  TextInput4,
9326
9507
  {
9327
9508
  value: tempKey,
@@ -9337,7 +9518,8 @@ Selection: ${val}`,
9337
9518
  tokens: sessionStats.tokens,
9338
9519
  tokensTotal: sessionStats.tokens,
9339
9520
  chatId,
9340
- isMemoryEnabled: systemSettings.memory
9521
+ isMemoryEnabled: systemSettings.memory,
9522
+ apiTier
9341
9523
  }
9342
9524
  )), activeView === "exit" && (() => {
9343
9525
  const wallTimeMs = Date.now() - SESSION_START_TIME;
@@ -9346,7 +9528,7 @@ Selection: ${val}`,
9346
9528
  const agentActiveMs = sessionApiTime + sessionToolTime;
9347
9529
  const apiPercent = agentActiveMs > 0 ? (sessionApiTime / agentActiveMs * 100).toFixed(1) : "0.0";
9348
9530
  const toolPercent = agentActiveMs > 0 ? (sessionToolTime / agentActiveMs * 100).toFixed(1) : "0.0";
9349
- 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))), /* @__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 || 0)), /* @__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, "%)"))));
9531
+ 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, null, /* @__PURE__ */ React13.createElement(Box13, { width: 20 }, /* @__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: 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, "%)"))));
9350
9532
  })(), suggestions.length > 0 && (() => {
9351
9533
  const windowSize = 5;
9352
9534
  const startIdx = Math.max(0, Math.min(selectedIndex - 2, suggestions.length - windowSize));
@@ -9362,7 +9544,7 @@ Selection: ${val}`,
9362
9544
  paddingY: 0,
9363
9545
  width: "100%"
9364
9546
  },
9365
- /* @__PURE__ */ React13.createElement(Box13, { paddingX: 1, marginBottom: 0, justifyContent: "space-between", width: "100%" }, /* @__PURE__ */ React13.createElement(Text13, { color: "gray", bold: true, dimColor: true }, suggestions[0]?.cmd?.startsWith("@") ? "\u{1F4C1} FILE SUGGESTIONS" : "\u{1F50D} COMMAND SUGGESTIONS"), suggestions[0]?.cmd?.startsWith("@") && /* @__PURE__ */ React13.createElement(Text13, { color: "gray", dimColor: true, italic: true }, "(Use '#Lstart-Lend' to specify line numbers)")),
9547
+ /* @__PURE__ */ React13.createElement(Box13, { paddingX: 1, marginBottom: 0, justifyContent: "space-between", width: "100%" }, /* @__PURE__ */ React13.createElement(Text13, { color: "gray", bold: true, dimColor: true }, suggestions[0]?.cmd?.startsWith("@") ? "\u{1F4C1} FILE SUGGESTIONS" : "\u{1F50D} COMMAND SUGGESTIONS"), suggestions[0]?.cmd?.startsWith("@") ? /* @__PURE__ */ React13.createElement(Text13, { color: "gray", dimColor: true, italic: true }, "(Use '#Lstart-Lend' to specify line numbers)") : input.startsWith("/model") && apiTier === "Free" ? /* @__PURE__ */ React13.createElement(Text13, { color: "gray", dimColor: true, italic: true }, "Paid API has more models. Configure ", /* @__PURE__ */ React13.createElement(Text13, { color: "cyan", underline: true }, "\x1B]8;;https://aistudio.google.com/billing\x07billing\x1B]8;;\x07"), " & /settings") : null),
9366
9548
  visible.map((s, i) => {
9367
9549
  const actualIdx = startIdx + i;
9368
9550
  const isActive = actualIdx === selectedIndex;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "fluxflow-cli",
3
- "version": "1.18.24",
4
- "date": "2026-06-02",
3
+ "version": "1.19.0",
4
+ "date": "2026-06-03",
5
5
  "description": "A high-fidelity agentic terminal assistant for the Flux Era.",
6
6
  "keywords": [
7
7
  "ai",