fluxflow-cli 3.3.5 → 3.4.1

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 CHANGED
@@ -189,6 +189,139 @@ var init_crypto = __esm({
189
189
  }
190
190
  });
191
191
 
192
+ // src/data/model_config.js
193
+ import fs3 from "fs";
194
+ import path3 from "path";
195
+ import { fileURLToPath } from "url";
196
+ var __filename, __dirname, packageConfigPath, pathsToCheck, userConfigPath, activeConfig, multimodalModelsSet, rebuildMultimodalSet, loadRemoteModelConfig, isModelMultimodal, getModels, getDefaultModel, getFallbackValue;
197
+ var init_model_config = __esm({
198
+ "src/data/model_config.js"() {
199
+ init_paths();
200
+ __filename = fileURLToPath(import.meta.url);
201
+ __dirname = path3.dirname(__filename);
202
+ packageConfigPath = "";
203
+ pathsToCheck = [
204
+ path3.join(__dirname, "../../model_config.json"),
205
+ // Dev: src/data/model_config.js -> root
206
+ path3.join(__dirname, "../model_config.json")
207
+ // Prod: dist/fluxflow.js -> root
208
+ ];
209
+ for (const p of pathsToCheck) {
210
+ try {
211
+ if (fs3.existsSync(p)) {
212
+ packageConfigPath = p;
213
+ break;
214
+ }
215
+ } catch (e) {
216
+ }
217
+ }
218
+ userConfigPath = path3.join(FLUXFLOW_DIR, "model_config.json");
219
+ activeConfig = null;
220
+ if (fs3.existsSync(userConfigPath)) {
221
+ try {
222
+ const fileContent = fs3.readFileSync(userConfigPath, "utf-8");
223
+ const parsed = JSON.parse(fileContent);
224
+ if (parsed && parsed.providers && parsed.fallbacks && parsed.release) {
225
+ activeConfig = parsed;
226
+ }
227
+ } catch (e) {
228
+ }
229
+ }
230
+ if (!activeConfig && packageConfigPath) {
231
+ try {
232
+ const fileContent = fs3.readFileSync(packageConfigPath, "utf-8");
233
+ const parsed = JSON.parse(fileContent);
234
+ if (parsed && parsed.providers && parsed.fallbacks && parsed.release) {
235
+ activeConfig = parsed;
236
+ }
237
+ } catch (e) {
238
+ }
239
+ }
240
+ if (!activeConfig) {
241
+ console.error("\n[Error] Unable to load model configuration. Please re-install the package from your package manager.\n");
242
+ process.exit(1);
243
+ }
244
+ multimodalModelsSet = /* @__PURE__ */ new Set();
245
+ rebuildMultimodalSet = () => {
246
+ const nextSet = /* @__PURE__ */ new Set();
247
+ if (activeConfig.providers) {
248
+ for (const providerKey of Object.keys(activeConfig.providers)) {
249
+ const provider = activeConfig.providers[providerKey];
250
+ if (provider && provider.models) {
251
+ const tiers = ["Free", "Paid"];
252
+ for (const tier of tiers) {
253
+ const list = provider.models[tier];
254
+ if (Array.isArray(list)) {
255
+ for (const m of list) {
256
+ if (m && m.cmd && m.multimodal === true) {
257
+ nextSet.add(m.cmd.trim().toLowerCase());
258
+ }
259
+ }
260
+ }
261
+ }
262
+ }
263
+ }
264
+ }
265
+ if (Array.isArray(activeConfig.multimodal_models)) {
266
+ for (const m of activeConfig.multimodal_models) {
267
+ if (m && typeof m === "string") {
268
+ nextSet.add(m.trim().toLowerCase());
269
+ }
270
+ }
271
+ }
272
+ multimodalModelsSet = nextSet;
273
+ };
274
+ rebuildMultimodalSet();
275
+ loadRemoteModelConfig = async () => {
276
+ try {
277
+ const url = "https://raw.githubusercontent.com/KushalRoyChowdhury/fluxflow-cli/main/src/data/model_config.json";
278
+ const res = await fetch(url, { signal: AbortSignal.timeout(3e3) });
279
+ if (res.ok) {
280
+ const data = await res.json();
281
+ if (data && data.providers && data.fallbacks && data.release) {
282
+ const isNewerVersion = typeof data.version === "number" && data.version > activeConfig.version;
283
+ const isNewerRelease = typeof data.release === "number" && data.release > activeConfig.release;
284
+ if (isNewerVersion || isNewerRelease) {
285
+ activeConfig = data;
286
+ rebuildMultimodalSet();
287
+ try {
288
+ if (!fs3.existsSync(FLUXFLOW_DIR)) {
289
+ fs3.mkdirSync(FLUXFLOW_DIR, { recursive: true });
290
+ }
291
+ fs3.writeFileSync(userConfigPath, JSON.stringify(data, null, 2), "utf-8");
292
+ } catch (writeErr) {
293
+ }
294
+ return true;
295
+ }
296
+ }
297
+ }
298
+ } catch (e) {
299
+ }
300
+ return false;
301
+ };
302
+ isModelMultimodal = (model) => {
303
+ if (!model) return false;
304
+ const lower = model.trim().toLowerCase();
305
+ if (multimodalModelsSet.has(lower)) return true;
306
+ if (lower.startsWith("gemini-") || lower.startsWith("gemma-")) return true;
307
+ return false;
308
+ };
309
+ getModels = (provider, apiTier) => {
310
+ const p = activeConfig.providers[provider];
311
+ if (!p) return [];
312
+ return p.models[apiTier === "Free" ? "Free" : "Paid"] || [];
313
+ };
314
+ getDefaultModel = (provider, apiTier) => {
315
+ const p = activeConfig.providers[provider];
316
+ if (!p) return "";
317
+ return apiTier === "Free" ? p.default_free : p.default_paid;
318
+ };
319
+ getFallbackValue = (key) => {
320
+ return activeConfig.fallbacks[key];
321
+ };
322
+ }
323
+ });
324
+
192
325
  // src/utils/secrets.js
193
326
  var secrets_exports = {};
194
327
  __export(secrets_exports, {
@@ -204,14 +337,14 @@ __export(secrets_exports, {
204
337
  saveSearchKey: () => saveSearchKey,
205
338
  saveSecret: () => saveSecret
206
339
  });
207
- import fs3 from "fs-extra";
208
- import path3 from "path";
340
+ import fs4 from "fs-extra";
341
+ import path4 from "path";
209
342
  var SECRET_FILE, getAPIKey, getProviderAPIKey, saveProviderAPIKey, getSecret, saveSecret, getSearchSecrets, saveAPIKey, saveSearchKey, saveSearchId, removeSecret, removeAPIKey;
210
343
  var init_secrets = __esm({
211
344
  "src/utils/secrets.js"() {
212
345
  init_crypto();
213
346
  init_paths();
214
- SECRET_FILE = path3.join(SECRET_DIR, "secrets.json");
347
+ SECRET_FILE = path4.join(SECRET_DIR, "secrets.json");
215
348
  getAPIKey = async () => {
216
349
  try {
217
350
  const secrets = readEncryptedJson(SECRET_FILE, {});
@@ -252,7 +385,7 @@ var init_secrets = __esm({
252
385
  }
253
386
  };
254
387
  saveSecret = async (key, value) => {
255
- await fs3.ensureDir(SECRET_DIR);
388
+ await fs4.ensureDir(SECRET_DIR);
256
389
  let current = readEncryptedJson(SECRET_FILE, {});
257
390
  current[key] = value;
258
391
  writeEncryptedJson(SECRET_FILE, current);
@@ -289,18 +422,19 @@ __export(settings_exports, {
289
422
  loadSettings: () => loadSettings,
290
423
  saveSettings: () => saveSettings
291
424
  });
292
- import fs4 from "fs-extra";
293
- import path4 from "path";
425
+ import fs5 from "fs-extra";
426
+ import path5 from "path";
294
427
  var DEFAULT_SETTINGS, loadSettings, migrateToExternal, saveSettings;
295
428
  var init_settings = __esm({
296
429
  "src/utils/settings.js"() {
297
430
  init_paths();
298
431
  init_crypto();
432
+ init_model_config();
299
433
  DEFAULT_SETTINGS = {
300
434
  mode: "Flux",
301
435
  thinkingLevel: "Medium",
302
436
  aiProvider: "Google",
303
- activeModel: "gemma-4-31b-it",
437
+ activeModel: getDefaultModel("Google", "Free") || "gemma-4-31b-it",
304
438
  showFullThinking: true,
305
439
  apiTier: "Free",
306
440
  quotas: {
@@ -343,7 +477,7 @@ var init_settings = __esm({
343
477
  loadSettings = async () => {
344
478
  let settingsObj = { ...DEFAULT_SETTINGS };
345
479
  try {
346
- if (await fs4.exists(SETTINGS_FILE)) {
480
+ if (await fs5.exists(SETTINGS_FILE)) {
347
481
  const saved = readAesEncryptedJson(SETTINGS_FILE);
348
482
  if (saved.imageSettings && saved.imageSettings.apiKey) {
349
483
  try {
@@ -395,12 +529,12 @@ var init_settings = __esm({
395
529
  const { FLUXFLOW_DIR: FLUXFLOW_DIR2 } = await Promise.resolve().then(() => (init_paths(), paths_exports));
396
530
  const folders = ["logs", "secret"];
397
531
  for (const folder of folders) {
398
- const src = path4.join(FLUXFLOW_DIR2, folder);
399
- const dest = path4.join(newPath, folder);
532
+ const src = path5.join(FLUXFLOW_DIR2, folder);
533
+ const dest = path5.join(newPath, folder);
400
534
  try {
401
- if (await fs4.exists(src)) {
402
- await fs4.ensureDir(dest);
403
- await fs4.copy(src, dest, { overwrite: true });
535
+ if (await fs5.exists(src)) {
536
+ await fs5.ensureDir(dest);
537
+ await fs5.copy(src, dest, { overwrite: true });
404
538
  }
405
539
  } catch (err) {
406
540
  console.error(`Migration failed for ${folder}:`, err);
@@ -426,7 +560,7 @@ var init_settings = __esm({
426
560
  if (updated.imageSettings) {
427
561
  updated.imageSettings = { ...updated.imageSettings, apiKey: "" };
428
562
  }
429
- await fs4.ensureDir(path4.dirname(SETTINGS_FILE));
563
+ await fs5.ensureDir(path5.dirname(SETTINGS_FILE));
430
564
  writeAesEncryptedJson(SETTINGS_FILE, updated);
431
565
  return true;
432
566
  } catch (err) {
@@ -4696,7 +4830,7 @@ var init_ChatLayout = __esm({
4696
4830
  }
4697
4831
  if (type === "agent-line") {
4698
4832
  if (!text || text.trim() === "") {
4699
- return null;
4833
+ return /* @__PURE__ */ React4.createElement(Box3, { height: 1 });
4700
4834
  }
4701
4835
  const animatedText = useStreamingText(text, isStreamingMsg, block.isActiveBlock);
4702
4836
  return /* @__PURE__ */ React4.createElement(Box3, { flexDirection: "column", paddingX: 1, width: "100%" }, /* @__PURE__ */ React4.createElement(CodeRenderer, { text: animatedText, columns }));
@@ -5197,7 +5331,7 @@ var init_main_tools = __esm({
5197
5331
  };
5198
5332
  TOOL_PROTOCOL = (mode, osDetected, isMultiModal, aiProvider, advanceRollback = false) => `
5199
5333
  -- TOOL DEFINITIONS --
5200
- Internal tools. **MUST use the EXACT syntax** [tool:functions.ToolName(args)]. **NO OTHER SYNTAX/MARKERS/BOUNDARY ALLOWED**
5334
+ Internal tools. **MUST use the EXACT syntax** [tool:functions.ToolName(args)]. **NO OTHER SYNTAX/MARKERS/BOUNDARY ALLOWED** Proper bracket balancing per schema is mandatory
5201
5335
 
5202
5336
  **TOOL USAGE POLICY:**
5203
5337
  - **MAX 3 TOOL CALLS PER TURN${mode === "Flux" ? " (EXCEPTION FOR Todo TOOL: 3+ CALLS ALLOWED, Run TOOL: Limit 1, OR 2 CONSECUTIVE Run TOOL)" : ""}. Next Turn, verify tool results, plan next**
@@ -6518,7 +6652,7 @@ var init_thinking_prompts = __esm({
6518
6652
  });
6519
6653
 
6520
6654
  // src/utils/prompts.js
6521
- import fs5 from "fs";
6655
+ import fs6 from "fs";
6522
6656
  var cachedProjectContextBlock, getMemoryPrompt, getSystemInstruction, getJanitorInstruction;
6523
6657
  var init_prompts = __esm({
6524
6658
  async "src/utils/prompts.js"() {
@@ -6594,7 +6728,7 @@ ${nicknameStr.length || userInstrStr.length ? "" : "\n"}` : "";
6594
6728
  { name: "architecture.md", desc: "System Structure" }
6595
6729
  ];
6596
6730
  if (isFirstPrompt || cachedProjectContextBlock === null) {
6597
- const foundFiles = projectContextFiles.filter((f) => fs5.existsSync(f.name));
6731
+ const foundFiles = projectContextFiles.filter((f) => fs6.existsSync(f.name));
6598
6732
  cachedProjectContextBlock = mode === "Flux" && foundFiles.length > 0 ? `
6599
6733
  -- PROJECT CONTEXT --
6600
6734
  ${foundFiles.map((f) => `- ${f.name}: ${f.desc}`).join("\n")}
@@ -6663,35 +6797,35 @@ Current date and Time: ${(/* @__PURE__ */ new Date()).toLocaleString([], { year:
6663
6797
  });
6664
6798
 
6665
6799
  // src/utils/revert.js
6666
- import fs6 from "fs-extra";
6667
- import path5 from "path";
6800
+ import fs7 from "fs-extra";
6801
+ import path6 from "path";
6668
6802
  async function performRestoration(change, tx) {
6669
6803
  try {
6670
6804
  if (change.type === "create") {
6671
- if (await fs6.pathExists(change.filePath)) {
6672
- await fs6.chmod(change.filePath, 438).catch(() => {
6805
+ if (await fs7.pathExists(change.filePath)) {
6806
+ await fs7.chmod(change.filePath, 438).catch(() => {
6673
6807
  });
6674
- await fs6.remove(change.filePath);
6808
+ await fs7.remove(change.filePath);
6675
6809
  }
6676
6810
  } else if (change.type === "update") {
6677
6811
  if (!change.backupFile) return;
6678
- const backupPath = path5.join(BACKUPS_DIR, tx.chatId, change.backupFile);
6679
- if (await fs6.pathExists(backupPath)) {
6812
+ const backupPath = path6.join(BACKUPS_DIR, tx.chatId, change.backupFile);
6813
+ if (await fs7.pathExists(backupPath)) {
6680
6814
  const backupContainer = readEncryptedJson(backupPath, null);
6681
6815
  if (!backupContainer || !backupContainer.data) {
6682
- throw new Error(`Backup container corrupt or empty for ${path5.basename(change.filePath)}`);
6816
+ throw new Error(`Backup container corrupt or empty for ${path6.basename(change.filePath)}`);
6683
6817
  }
6684
6818
  const decrypted = decryptAes(backupContainer.data);
6685
- if (await fs6.pathExists(change.filePath)) {
6686
- await fs6.chmod(change.filePath, 438).catch(() => {
6819
+ if (await fs7.pathExists(change.filePath)) {
6820
+ await fs7.chmod(change.filePath, 438).catch(() => {
6687
6821
  });
6688
6822
  }
6689
- await fs6.writeFile(change.filePath, decrypted, "utf8");
6823
+ await fs7.writeFile(change.filePath, decrypted, "utf8");
6690
6824
  } else {
6691
6825
  }
6692
6826
  }
6693
6827
  } catch (err) {
6694
- throw new Error(`Restoration failed for ${path5.basename(change.filePath)}: ${err.message}`);
6828
+ throw new Error(`Restoration failed for ${path6.basename(change.filePath)}: ${err.message}`);
6695
6829
  }
6696
6830
  }
6697
6831
  async function restoreWithRetry(change, tx, maxAttempts = 7) {
@@ -6716,7 +6850,7 @@ var init_revert = __esm({
6716
6850
  "src/utils/revert.js"() {
6717
6851
  init_paths();
6718
6852
  init_crypto();
6719
- fs6.ensureDirSync(BACKUPS_DIR);
6853
+ fs7.ensureDirSync(BACKUPS_DIR);
6720
6854
  currentTransaction = null;
6721
6855
  lastChatId = null;
6722
6856
  RevertManager = {
@@ -6741,16 +6875,16 @@ var init_revert = __esm({
6741
6875
  if (lastTx) {
6742
6876
  const alreadyBackedUp2 = lastTx.changes.some((c) => c.filePath === absolutePath);
6743
6877
  if (alreadyBackedUp2) return;
6744
- const fileExists2 = await fs6.pathExists(absolutePath);
6878
+ const fileExists2 = await fs7.pathExists(absolutePath);
6745
6879
  let type2 = fileExists2 || forcedContent ? "update" : "create";
6746
6880
  let backupFile2 = null;
6747
6881
  if (type2 === "update") {
6748
- const fileName = path5.basename(absolutePath);
6882
+ const fileName = path6.basename(absolutePath);
6749
6883
  backupFile2 = `${lastTx.id}_${fileName}.bak`;
6750
- const chatBackupDir = path5.join(BACKUPS_DIR, lastTx.chatId);
6751
- await fs6.ensureDir(chatBackupDir);
6752
- const backupPath = path5.join(chatBackupDir, backupFile2);
6753
- let content = forcedContent !== null ? forcedContent : await fs6.readFile(absolutePath, "utf8").catch(() => null);
6884
+ const chatBackupDir = path6.join(BACKUPS_DIR, lastTx.chatId);
6885
+ await fs7.ensureDir(chatBackupDir);
6886
+ const backupPath = path6.join(chatBackupDir, backupFile2);
6887
+ let content = forcedContent !== null ? forcedContent : await fs7.readFile(absolutePath, "utf8").catch(() => null);
6754
6888
  if (content !== null) {
6755
6889
  writeEncryptedJson(backupPath, { data: encryptAes(content) });
6756
6890
  } else {
@@ -6766,16 +6900,16 @@ var init_revert = __esm({
6766
6900
  }
6767
6901
  const alreadyBackedUp = currentTransaction.changes.some((c) => c.filePath === absolutePath);
6768
6902
  if (alreadyBackedUp) return;
6769
- const fileExists = await fs6.pathExists(absolutePath);
6903
+ const fileExists = await fs7.pathExists(absolutePath);
6770
6904
  let type = fileExists || forcedContent ? "update" : "create";
6771
6905
  let backupFile = null;
6772
6906
  if (type === "update") {
6773
- const fileName = path5.basename(absolutePath);
6907
+ const fileName = path6.basename(absolutePath);
6774
6908
  backupFile = `${currentTransaction.id}_${fileName}.bak`;
6775
- const chatBackupDir = path5.join(BACKUPS_DIR, currentTransaction.chatId);
6776
- await fs6.ensureDir(chatBackupDir);
6777
- const backupPath = path5.join(chatBackupDir, backupFile);
6778
- let content = forcedContent !== null ? forcedContent : await fs6.readFile(absolutePath, "utf8").catch(() => null);
6909
+ const chatBackupDir = path6.join(BACKUPS_DIR, currentTransaction.chatId);
6910
+ await fs7.ensureDir(chatBackupDir);
6911
+ const backupPath = path6.join(chatBackupDir, backupFile);
6912
+ let content = forcedContent !== null ? forcedContent : await fs7.readFile(absolutePath, "utf8").catch(() => null);
6779
6913
  if (content !== null) {
6780
6914
  writeEncryptedJson(backupPath, { data: encryptAes(content) });
6781
6915
  } else {
@@ -6798,14 +6932,14 @@ var init_revert = __esm({
6798
6932
  if (removed.changes) {
6799
6933
  for (const change of removed.changes) {
6800
6934
  if (change.backupFile) {
6801
- await fs6.remove(path5.join(BACKUPS_DIR, removed.chatId, change.backupFile)).catch(() => {
6935
+ await fs7.remove(path6.join(BACKUPS_DIR, removed.chatId, change.backupFile)).catch(() => {
6802
6936
  });
6803
6937
  }
6804
6938
  }
6805
6939
  }
6806
6940
  }
6807
6941
  writeEncryptedJson(LEDGER_FILE, ledger);
6808
- await fs6.remove(ACTIVE_TX_FILE).catch(() => {
6942
+ await fs7.remove(ACTIVE_TX_FILE).catch(() => {
6809
6943
  });
6810
6944
  } catch (err) {
6811
6945
  } finally {
@@ -6814,7 +6948,7 @@ var init_revert = __esm({
6814
6948
  },
6815
6949
  async recoverCrashedTransaction() {
6816
6950
  try {
6817
- if (await fs6.pathExists(ACTIVE_TX_FILE)) {
6951
+ if (await fs7.pathExists(ACTIVE_TX_FILE)) {
6818
6952
  const orphanedTx = readEncryptedJson(ACTIVE_TX_FILE, null);
6819
6953
  if (orphanedTx?.changes?.length > 0) {
6820
6954
  const ledger = readEncryptedJson(LEDGER_FILE, []);
@@ -6823,7 +6957,7 @@ var init_revert = __esm({
6823
6957
  writeEncryptedJson(LEDGER_FILE, ledger);
6824
6958
  }
6825
6959
  }
6826
- await fs6.remove(ACTIVE_TX_FILE).catch(() => {
6960
+ await fs7.remove(ACTIVE_TX_FILE).catch(() => {
6827
6961
  });
6828
6962
  }
6829
6963
  } catch (e) {
@@ -6843,8 +6977,8 @@ var init_revert = __esm({
6843
6977
  }
6844
6978
  for (const change of tx.changes) {
6845
6979
  if (change.backupFile) {
6846
- const backupPath = path5.join(BACKUPS_DIR, tx.chatId, change.backupFile);
6847
- await fs6.remove(backupPath).catch(() => {
6980
+ const backupPath = path6.join(BACKUPS_DIR, tx.chatId, change.backupFile);
6981
+ await fs7.remove(backupPath).catch(() => {
6848
6982
  });
6849
6983
  }
6850
6984
  }
@@ -6863,7 +6997,7 @@ var init_revert = __esm({
6863
6997
  },
6864
6998
  async deleteChatBackups(chatId) {
6865
6999
  try {
6866
- await fs6.remove(path5.join(BACKUPS_DIR, chatId));
7000
+ await fs7.remove(path6.join(BACKUPS_DIR, chatId));
6867
7001
  let ledger = readEncryptedJson(LEDGER_FILE, []);
6868
7002
  const clean = ledger.filter((t) => t.chatId !== chatId);
6869
7003
  if (ledger.length !== clean.length) writeEncryptedJson(LEDGER_FILE, clean);
@@ -6875,8 +7009,8 @@ var init_revert = __esm({
6875
7009
  });
6876
7010
 
6877
7011
  // src/utils/history.js
6878
- import fs7 from "fs-extra";
6879
- import path6 from "path";
7012
+ import fs8 from "fs-extra";
7013
+ import path7 from "path";
6880
7014
  import { nanoid } from "nanoid";
6881
7015
  var WRITE_LOCK, withLock, loadHistory, saveChat, saveChatTitle, deleteChat, generateChatId, cleanupOldHistory, parseCustomDate, cleanupLogFile, cleanupOldLogs, getTruncatedHistory, saveChatContext, loadChatContext;
6882
7016
  var init_history = __esm({
@@ -6900,9 +7034,9 @@ var init_history = __esm({
6900
7034
  return nextLock;
6901
7035
  };
6902
7036
  loadHistory = async () => {
6903
- await fs7.ensureDir(HISTORY_DIR);
7037
+ await fs8.ensureDir(HISTORY_DIR);
6904
7038
  let history = {};
6905
- if (await fs7.pathExists(HISTORY_FILE)) {
7039
+ if (await fs8.pathExists(HISTORY_FILE)) {
6906
7040
  try {
6907
7041
  history = readEncryptedJson(HISTORY_FILE, {});
6908
7042
  } catch (e) {
@@ -6910,10 +7044,10 @@ var init_history = __esm({
6910
7044
  }
6911
7045
  }
6912
7046
  for (const id in history) {
6913
- const chatFile = path6.join(HISTORY_DIR, `${id}.json`);
7047
+ const chatFile = path7.join(HISTORY_DIR, `${id}.json`);
6914
7048
  Object.defineProperty(history[id], "messages", {
6915
7049
  get: () => {
6916
- if (fs7.existsSync(chatFile)) {
7050
+ if (fs8.existsSync(chatFile)) {
6917
7051
  try {
6918
7052
  return readEncryptedJson(chatFile, []);
6919
7053
  } catch (e) {
@@ -6936,7 +7070,7 @@ var init_history = __esm({
6936
7070
  };
6937
7071
  saveChat = async (id, name, messages) => {
6938
7072
  return withLock(async () => {
6939
- await fs7.ensureDir(HISTORY_DIR);
7073
+ await fs8.ensureDir(HISTORY_DIR);
6940
7074
  const history = await loadHistory();
6941
7075
  const existingChat = history[id];
6942
7076
  let persistentMessages = (messages || []).filter(
@@ -6950,7 +7084,7 @@ var init_history = __esm({
6950
7084
  } catch (e) {
6951
7085
  }
6952
7086
  const finalName = name || (existingChat ? existingChat.name : `Session ${id.slice(-6)}`);
6953
- const chatFile = path6.join(HISTORY_DIR, `${id}.json`);
7087
+ const chatFile = path7.join(HISTORY_DIR, `${id}.json`);
6954
7088
  writeEncryptedJson(chatFile, persistentMessages);
6955
7089
  history[id] = {
6956
7090
  name: finalName,
@@ -6997,7 +7131,7 @@ var init_history = __esm({
6997
7131
  };
6998
7132
  }
6999
7133
  writeEncryptedJson(HISTORY_FILE, indexHistory);
7000
- if (await fs7.pathExists(CONTEXT_FILE)) {
7134
+ if (await fs8.pathExists(CONTEXT_FILE)) {
7001
7135
  try {
7002
7136
  const contextData = readEncryptedJson(CONTEXT_FILE, []);
7003
7137
  if (Array.isArray(contextData)) {
@@ -7018,10 +7152,10 @@ var init_history = __esm({
7018
7152
  writeEncryptedJson(TEMP_MEM_CHAT_FILE, cache);
7019
7153
  }
7020
7154
  await RevertManager.deleteChatBackups(id);
7021
- const chatFile = path6.join(HISTORY_DIR, `${id}.json`);
7022
- if (await fs7.pathExists(chatFile)) {
7155
+ const chatFile = path7.join(HISTORY_DIR, `${id}.json`);
7156
+ if (await fs8.pathExists(chatFile)) {
7023
7157
  try {
7024
- await fs7.remove(chatFile);
7158
+ await fs8.remove(chatFile);
7025
7159
  } catch (e) {
7026
7160
  }
7027
7161
  }
@@ -7094,8 +7228,8 @@ var init_history = __esm({
7094
7228
  };
7095
7229
  cleanupLogFile = async (filePath) => {
7096
7230
  try {
7097
- if (!await fs7.pathExists(filePath)) return;
7098
- const content = await fs7.readFile(filePath, "utf8");
7231
+ if (!await fs8.pathExists(filePath)) return;
7232
+ const content = await fs8.readFile(filePath, "utf8");
7099
7233
  if (!content.trim()) return;
7100
7234
  const lines = content.split("\n");
7101
7235
  const entries = [];
@@ -7135,26 +7269,26 @@ var init_history = __esm({
7135
7269
  }
7136
7270
  const finalContent = keptEntries.join("\n").trim();
7137
7271
  if (finalContent) {
7138
- await fs7.writeFile(filePath, finalContent + "\n", "utf8");
7272
+ await fs8.writeFile(filePath, finalContent + "\n", "utf8");
7139
7273
  } else {
7140
- await fs7.writeFile(filePath, "", "utf8");
7274
+ await fs8.writeFile(filePath, "", "utf8");
7141
7275
  }
7142
7276
  } catch (e) {
7143
7277
  }
7144
7278
  };
7145
7279
  cleanupOldLogs = async (logsDir) => {
7146
7280
  try {
7147
- if (!await fs7.pathExists(logsDir)) return;
7281
+ if (!await fs8.pathExists(logsDir)) return;
7148
7282
  const cleanRecursive = async (dir) => {
7149
- const files = await fs7.readdir(dir);
7283
+ const files = await fs8.readdir(dir);
7150
7284
  for (const file of files) {
7151
- const fullPath = path6.join(dir, file);
7152
- const stat = await fs7.stat(fullPath);
7285
+ const fullPath = path7.join(dir, file);
7286
+ const stat = await fs8.stat(fullPath);
7153
7287
  if (stat.isDirectory()) {
7154
7288
  await cleanRecursive(fullPath);
7155
- const subFiles = await fs7.readdir(fullPath);
7289
+ const subFiles = await fs8.readdir(fullPath);
7156
7290
  if (subFiles.length === 0) {
7157
- await fs7.remove(fullPath);
7291
+ await fs8.remove(fullPath);
7158
7292
  }
7159
7293
  } else if (file.endsWith(".log")) {
7160
7294
  await cleanupLogFile(fullPath);
@@ -7189,7 +7323,7 @@ var init_history = __esm({
7189
7323
  };
7190
7324
  loadChatContext = async (chatId) => {
7191
7325
  try {
7192
- if (!await fs7.pathExists(CONTEXT_FILE)) return { total: 0, context: 0 };
7326
+ if (!await fs8.pathExists(CONTEXT_FILE)) return { total: 0, context: 0 };
7193
7327
  const contextData = readEncryptedJson(CONTEXT_FILE, []);
7194
7328
  if (!Array.isArray(contextData)) return { total: 0, context: 0 };
7195
7329
  const entry = contextData.find((item) => Object.keys(item)[0] === String(chatId));
@@ -7202,8 +7336,8 @@ var init_history = __esm({
7202
7336
  });
7203
7337
 
7204
7338
  // src/utils/usage.js
7205
- import fs8 from "fs-extra";
7206
- import path7 from "path";
7339
+ import fs9 from "fs-extra";
7340
+ import path8 from "path";
7207
7341
  import os3 from "os";
7208
7342
  var getLocalBackupPath, BACKUP_FILE, generateSaveId, cachedUsage, writeTimeout, lastWriteTime, isDirty, defaultStats, purgeOldHistory, loadUsageFromFile, flushUsage, queueFlush, initUsage, forceFlushUsage, getDailyUsage, getMonthlyUsage, incrementUsage, runtimeSession, addToUsage, getCustomPeriodUsage, checkQuota, getImageQuotaBuckets, getImageQuotaLimit, checkImageQuota, getImageQuotaStats, recordImageGeneration;
7209
7343
  var init_usage = __esm({
@@ -7212,14 +7346,14 @@ var init_usage = __esm({
7212
7346
  init_crypto();
7213
7347
  getLocalBackupPath = () => {
7214
7348
  if (process.platform === "win32") {
7215
- const localAppData = process.env.LOCALAPPDATA || path7.join(os3.homedir(), "AppData", "Local");
7216
- return path7.join(localAppData, "FxFl", "backups", "backup.json");
7349
+ const localAppData = process.env.LOCALAPPDATA || path8.join(os3.homedir(), "AppData", "Local");
7350
+ return path8.join(localAppData, "FxFl", "backups", "backup.json");
7217
7351
  }
7218
7352
  if (process.platform === "darwin") {
7219
- return path7.join(os3.homedir(), "Library", "Application Support", "FxFl", "backups", "backup.json");
7353
+ return path8.join(os3.homedir(), "Library", "Application Support", "FxFl", "backups", "backup.json");
7220
7354
  }
7221
- const xdgDataHome = process.env.XDG_DATA_HOME || path7.join(os3.homedir(), ".local", "share");
7222
- return path7.join(xdgDataHome, "fxfl", "backups", "backup.json");
7355
+ const xdgDataHome = process.env.XDG_DATA_HOME || path8.join(os3.homedir(), ".local", "share");
7356
+ return path8.join(xdgDataHome, "fxfl", "backups", "backup.json");
7223
7357
  };
7224
7358
  BACKUP_FILE = getLocalBackupPath();
7225
7359
  generateSaveId = () => Math.random().toString(36).substring(2) + Date.now().toString(36);
@@ -7261,8 +7395,8 @@ var init_usage = __esm({
7261
7395
  let primaryData = null;
7262
7396
  let backupData = null;
7263
7397
  try {
7264
- if (await fs8.exists(tempFile)) {
7265
- const rawContent = (await fs8.readFile(tempFile, "utf8")).trim();
7398
+ if (await fs9.exists(tempFile)) {
7399
+ const rawContent = (await fs9.readFile(tempFile, "utf8")).trim();
7266
7400
  let parsed = null;
7267
7401
  if (rawContent.startsWith("{") || rawContent.startsWith("[")) {
7268
7402
  parsed = JSON.parse(rawContent);
@@ -7272,26 +7406,26 @@ var init_usage = __esm({
7272
7406
  if (parsed && parsed.date && parsed.stats) {
7273
7407
  primaryData = parsed;
7274
7408
  try {
7275
- await fs8.rename(tempFile, USAGE_FILE);
7409
+ await fs9.rename(tempFile, USAGE_FILE);
7276
7410
  } catch (e) {
7277
7411
  }
7278
7412
  } else {
7279
7413
  try {
7280
- await fs8.remove(tempFile);
7414
+ await fs9.remove(tempFile);
7281
7415
  } catch (e) {
7282
7416
  }
7283
7417
  }
7284
7418
  }
7285
7419
  } catch (err) {
7286
7420
  try {
7287
- await fs8.remove(tempFile);
7421
+ await fs9.remove(tempFile);
7288
7422
  } catch (e) {
7289
7423
  }
7290
7424
  }
7291
7425
  if (!primaryData) {
7292
7426
  try {
7293
- if (await fs8.exists(USAGE_FILE)) {
7294
- const rawContent = (await fs8.readFile(USAGE_FILE, "utf8")).trim();
7427
+ if (await fs9.exists(USAGE_FILE)) {
7428
+ const rawContent = (await fs9.readFile(USAGE_FILE, "utf8")).trim();
7295
7429
  if (rawContent.startsWith("{") || rawContent.startsWith("[")) {
7296
7430
  primaryData = JSON.parse(rawContent);
7297
7431
  } else {
@@ -7302,8 +7436,8 @@ var init_usage = __esm({
7302
7436
  }
7303
7437
  }
7304
7438
  try {
7305
- if (await fs8.exists(BACKUP_FILE)) {
7306
- const rawContent = (await fs8.readFile(BACKUP_FILE, "utf8")).trim();
7439
+ if (await fs9.exists(BACKUP_FILE)) {
7440
+ const rawContent = (await fs9.readFile(BACKUP_FILE, "utf8")).trim();
7307
7441
  if (rawContent.startsWith("{") || rawContent.startsWith("[")) {
7308
7442
  backupData = JSON.parse(rawContent);
7309
7443
  } else {
@@ -7317,8 +7451,8 @@ var init_usage = __esm({
7317
7451
  if (primaryData.saveId !== backupData.saveId) {
7318
7452
  resolvedData = primaryData;
7319
7453
  try {
7320
- await fs8.ensureDir(path7.dirname(BACKUP_FILE));
7321
- await fs8.copy(USAGE_FILE, BACKUP_FILE);
7454
+ await fs9.ensureDir(path8.dirname(BACKUP_FILE));
7455
+ await fs9.copy(USAGE_FILE, BACKUP_FILE);
7322
7456
  } catch (e) {
7323
7457
  }
7324
7458
  } else {
@@ -7327,15 +7461,15 @@ var init_usage = __esm({
7327
7461
  } else if (primaryData && !backupData) {
7328
7462
  resolvedData = primaryData;
7329
7463
  try {
7330
- await fs8.ensureDir(path7.dirname(BACKUP_FILE));
7331
- await fs8.copy(USAGE_FILE, BACKUP_FILE);
7464
+ await fs9.ensureDir(path8.dirname(BACKUP_FILE));
7465
+ await fs9.copy(USAGE_FILE, BACKUP_FILE);
7332
7466
  } catch (e) {
7333
7467
  }
7334
7468
  } else if (!primaryData && backupData) {
7335
7469
  resolvedData = backupData;
7336
7470
  try {
7337
- await fs8.ensureDir(path7.dirname(USAGE_FILE));
7338
- await fs8.copy(BACKUP_FILE, USAGE_FILE);
7471
+ await fs9.ensureDir(path8.dirname(USAGE_FILE));
7472
+ await fs9.copy(BACKUP_FILE, USAGE_FILE);
7339
7473
  } catch (e) {
7340
7474
  }
7341
7475
  }
@@ -7375,11 +7509,11 @@ var init_usage = __esm({
7375
7509
  flushUsage = async () => {
7376
7510
  if (!isDirty || !cachedUsage) return;
7377
7511
  try {
7378
- await fs8.ensureDir(path7.dirname(USAGE_FILE));
7512
+ await fs9.ensureDir(path8.dirname(USAGE_FILE));
7379
7513
  let diskData = null;
7380
7514
  try {
7381
- if (await fs8.exists(USAGE_FILE)) {
7382
- const rawContent = (await fs8.readFile(USAGE_FILE, "utf8")).trim();
7515
+ if (await fs9.exists(USAGE_FILE)) {
7516
+ const rawContent = (await fs9.readFile(USAGE_FILE, "utf8")).trim();
7383
7517
  if (rawContent.startsWith("{") || rawContent.startsWith("[")) {
7384
7518
  diskData = JSON.parse(rawContent);
7385
7519
  } else {
@@ -7455,14 +7589,14 @@ var init_usage = __esm({
7455
7589
  cachedUsage.saveId = generateSaveId();
7456
7590
  const tempFile = USAGE_FILE + ".tmp";
7457
7591
  const encryptedStr = encryptAes(JSON.stringify(cachedUsage, null, 2));
7458
- await fs8.writeFile(tempFile, encryptedStr, "utf8");
7459
- const fd = await fs8.open(tempFile, "r+");
7460
- await fs8.fsync(fd);
7461
- await fs8.close(fd);
7462
- await fs8.rename(tempFile, USAGE_FILE);
7592
+ await fs9.writeFile(tempFile, encryptedStr, "utf8");
7593
+ const fd = await fs9.open(tempFile, "r+");
7594
+ await fs9.fsync(fd);
7595
+ await fs9.close(fd);
7596
+ await fs9.rename(tempFile, USAGE_FILE);
7463
7597
  try {
7464
- await fs8.ensureDir(path7.dirname(BACKUP_FILE));
7465
- await fs8.copy(USAGE_FILE, BACKUP_FILE);
7598
+ await fs9.ensureDir(path8.dirname(BACKUP_FILE));
7599
+ await fs9.copy(USAGE_FILE, BACKUP_FILE);
7466
7600
  } catch (backupErr) {
7467
7601
  }
7468
7602
  isDirty = false;
@@ -7946,10 +8080,10 @@ var init_usage = __esm({
7946
8080
 
7947
8081
  // src/utils/puppeteer_helper.js
7948
8082
  import os4 from "os";
7949
- import path8 from "path";
7950
- import fs9 from "fs";
8083
+ import path9 from "path";
8084
+ import fs10 from "fs";
7951
8085
  import { createRequire } from "module";
7952
- import { fileURLToPath } from "url";
8086
+ import { fileURLToPath as fileURLToPath2 } from "url";
7953
8087
  function getPuppeteerConfig() {
7954
8088
  const platform = os4.platform();
7955
8089
  const arch = os4.arch();
@@ -7972,11 +8106,11 @@ function getPuppeteerConfig() {
7972
8106
  } else {
7973
8107
  return {};
7974
8108
  }
7975
- let configPath = path8.resolve(__dirname, "..", "..", ".puppeteerrc.cjs");
7976
- if (!fs9.existsSync(configPath)) {
7977
- configPath = path8.resolve(__dirname, "..", ".puppeteerrc.cjs");
8109
+ let configPath = path9.resolve(__dirname2, "..", "..", ".puppeteerrc.cjs");
8110
+ if (!fs10.existsSync(configPath)) {
8111
+ configPath = path9.resolve(__dirname2, "..", ".puppeteerrc.cjs");
7978
8112
  }
7979
- if (!fs9.existsSync(configPath)) {
8113
+ if (!fs10.existsSync(configPath)) {
7980
8114
  return {};
7981
8115
  }
7982
8116
  try {
@@ -7986,14 +8120,14 @@ function getPuppeteerConfig() {
7986
8120
  if (cacheDir) {
7987
8121
  process.env.PUPPETEER_CACHE_DIR = cacheDir;
7988
8122
  if (version) {
7989
- const expectedPath = path8.join(
8123
+ const expectedPath = path9.join(
7990
8124
  cacheDir,
7991
8125
  "chrome",
7992
8126
  `${pptrPlatform}-${version}`,
7993
8127
  subDir,
7994
8128
  execName
7995
8129
  );
7996
- if (fs9.existsSync(expectedPath)) {
8130
+ if (fs10.existsSync(expectedPath)) {
7997
8131
  return {
7998
8132
  executablePath: expectedPath,
7999
8133
  cacheDirectory: cacheDir
@@ -8001,15 +8135,15 @@ function getPuppeteerConfig() {
8001
8135
  }
8002
8136
  }
8003
8137
  const findExecutable = (dir) => {
8004
- if (!fs9.existsSync(dir)) return null;
8138
+ if (!fs10.existsSync(dir)) return null;
8005
8139
  try {
8006
- const files = fs9.readdirSync(dir);
8140
+ const files = fs10.readdirSync(dir);
8007
8141
  const dirsToSearch = [];
8008
8142
  for (const file of files) {
8009
- const fullPath = path8.join(dir, file);
8143
+ const fullPath = path9.join(dir, file);
8010
8144
  let stat;
8011
8145
  try {
8012
- stat = fs9.statSync(fullPath);
8146
+ stat = fs10.statSync(fullPath);
8013
8147
  } catch (e) {
8014
8148
  continue;
8015
8149
  }
@@ -8051,11 +8185,11 @@ function getPuppeteerConfig() {
8051
8185
  }
8052
8186
  return {};
8053
8187
  }
8054
- var require2, __dirname;
8188
+ var require2, __dirname2;
8055
8189
  var init_puppeteer_helper = __esm({
8056
8190
  "src/utils/puppeteer_helper.js"() {
8057
8191
  require2 = createRequire(import.meta.url);
8058
- __dirname = path8.dirname(fileURLToPath(import.meta.url));
8192
+ __dirname2 = path9.dirname(fileURLToPath2(import.meta.url));
8059
8193
  }
8060
8194
  });
8061
8195
 
@@ -8336,8 +8470,8 @@ var init_chat = __esm({
8336
8470
  });
8337
8471
 
8338
8472
  // src/tools/view_file.js
8339
- import fs10 from "fs";
8340
- import path9 from "path";
8473
+ import fs11 from "fs";
8474
+ import path10 from "path";
8341
8475
  var view_file;
8342
8476
  var init_view_file = __esm({
8343
8477
  "src/tools/view_file.js"() {
@@ -8349,16 +8483,16 @@ var init_view_file = __esm({
8349
8483
  const finalStart = sLine || 1;
8350
8484
  const finalEnd = eLine || (sLine ? sLine + 800 : 800);
8351
8485
  if (!targetPath) return 'ERROR: Missing "path" argument for view_file.';
8352
- const absolutePath = path9.resolve(process.cwd(), targetPath);
8486
+ const absolutePath = path10.resolve(process.cwd(), targetPath);
8353
8487
  try {
8354
- if (!fs10.existsSync(absolutePath)) {
8488
+ if (!fs11.existsSync(absolutePath)) {
8355
8489
  return `ERROR: File [${targetPath}] does not exist.`;
8356
8490
  }
8357
- const stats = fs10.statSync(absolutePath);
8491
+ const stats = fs11.statSync(absolutePath);
8358
8492
  if (stats.isDirectory()) {
8359
8493
  return `ERROR: Path [${targetPath}] is a directory. Use list_files instead.`;
8360
8494
  }
8361
- const ext = path9.extname(targetPath).toLowerCase();
8495
+ const ext = path10.extname(targetPath).toLowerCase();
8362
8496
  const videoExtensions = [".mp4", ".mkv", ".avi", ".mov", ".webm", ".flv", ".wmv", ".mpeg", ".mpg"];
8363
8497
  if (videoExtensions.includes(ext)) {
8364
8498
  const format = ext.slice(1).toUpperCase();
@@ -8378,7 +8512,7 @@ var init_view_file = __esm({
8378
8512
  if (!isMultiModal) {
8379
8513
  return `ERROR: Multimodality is not supported for the current model. Unable to load [${targetPath}].`;
8380
8514
  }
8381
- const buffer = fs10.readFileSync(absolutePath);
8515
+ const buffer = fs11.readFileSync(absolutePath);
8382
8516
  const base64 = buffer.toString("base64");
8383
8517
  const mimeType = mimeMap[ext];
8384
8518
  return {
@@ -8391,7 +8525,7 @@ var init_view_file = __esm({
8391
8525
  }
8392
8526
  };
8393
8527
  }
8394
- let content = fs10.readFileSync(absolutePath, "utf8");
8528
+ let content = fs11.readFileSync(absolutePath, "utf8");
8395
8529
  if (content.startsWith("\uFEFF")) {
8396
8530
  content = content.slice(1);
8397
8531
  }
@@ -8415,8 +8549,8 @@ ${code}`;
8415
8549
  });
8416
8550
 
8417
8551
  // src/tools/write_file.js
8418
- import fs11 from "fs";
8419
- import path10 from "path";
8552
+ import fs12 from "fs";
8553
+ import path11 from "path";
8420
8554
  var write_file;
8421
8555
  var init_write_file = __esm({
8422
8556
  "src/tools/write_file.js"() {
@@ -8427,14 +8561,14 @@ var init_write_file = __esm({
8427
8561
  if (!targetPath) return 'ERROR: Missing "path" argument for write_file.';
8428
8562
  if (content === void 0) return 'ERROR: Missing "content" argument for write_file.';
8429
8563
  content = content.replace(/^```[\w]*\n?/, "").replace(/```\s*$/, "").replace(/\r\n/g, "\n").replace(/\r/g, "\n");
8430
- const absolutePath = path10.resolve(process.cwd(), targetPath);
8431
- const parentDir = path10.dirname(absolutePath);
8564
+ const absolutePath = path11.resolve(process.cwd(), targetPath);
8565
+ const parentDir = path11.dirname(absolutePath);
8432
8566
  try {
8433
8567
  await RevertManager.recordFileChange(absolutePath);
8434
8568
  let ancestry = "";
8435
- if (fs11.existsSync(absolutePath)) {
8569
+ if (fs12.existsSync(absolutePath)) {
8436
8570
  try {
8437
- const oldData = fs11.readFileSync(absolutePath, "utf8");
8571
+ const oldData = fs12.readFileSync(absolutePath, "utf8");
8438
8572
  const lines = oldData.split(/\r?\n/);
8439
8573
  ancestry = `Old File contents:
8440
8574
  ${lines.map((l, i) => `${i + 1} | ${l}`).join("\n")}
@@ -8446,16 +8580,16 @@ ${lines.map((l, i) => `${i + 1} | ${l}`).join("\n")}
8446
8580
  `;
8447
8581
  }
8448
8582
  }
8449
- if (!fs11.existsSync(parentDir)) {
8450
- fs11.mkdirSync(parentDir, { recursive: true });
8583
+ if (!fs12.existsSync(parentDir)) {
8584
+ fs12.mkdirSync(parentDir, { recursive: true });
8451
8585
  }
8452
8586
  const strip = (t) => t.replace(/^```[\w]*\n?/, "").replace(/```\s*$/, "").replace(/\r\n/g, "\n").replace(/\r/g, "\n");
8453
8587
  const processedContent = strip(content);
8454
8588
  const finalContent = processedContent.endsWith("\n") ? processedContent : processedContent + "\n";
8455
8589
  const lineCount = finalContent.split(/\r?\n/).length;
8456
8590
  const originalSize = Buffer.byteLength(finalContent, "utf8");
8457
- fs11.writeFileSync(absolutePath, finalContent, "utf8");
8458
- let verifiedContent = fs11.readFileSync(absolutePath, "utf8");
8591
+ fs12.writeFileSync(absolutePath, finalContent, "utf8");
8592
+ let verifiedContent = fs12.readFileSync(absolutePath, "utf8");
8459
8593
  const verifiedSize = Buffer.byteLength(verifiedContent, "utf8");
8460
8594
  const verifiedLines = verifiedContent.split(/\r?\n/);
8461
8595
  const verifiedLineCount = verifiedLines.length;
@@ -8490,8 +8624,8 @@ ${snippet}`;
8490
8624
  });
8491
8625
 
8492
8626
  // src/tools/update_file.js
8493
- import fs12 from "fs";
8494
- import path11 from "path";
8627
+ import fs13 from "fs";
8628
+ import path12 from "path";
8495
8629
  var update_file;
8496
8630
  var init_update_file = __esm({
8497
8631
  "src/tools/update_file.js"() {
@@ -8507,12 +8641,12 @@ var init_update_file = __esm({
8507
8641
  if (patchPairs.length === 0) {
8508
8642
  return "ERROR: No valid replacement pairs found. Use replaceContent1, newContent1, etc.";
8509
8643
  }
8510
- const absolutePath = path11.resolve(process.cwd(), targetPath);
8644
+ const absolutePath = path12.resolve(process.cwd(), targetPath);
8511
8645
  try {
8512
- if (!fs12.existsSync(absolutePath)) {
8646
+ if (!fs13.existsSync(absolutePath)) {
8513
8647
  return `ERROR: File [${targetPath}] does not exist. Use write_file instead.`;
8514
8648
  }
8515
- let diskContent = context.forcedContent || fs12.readFileSync(absolutePath, "utf8");
8649
+ let diskContent = context.forcedContent || fs13.readFileSync(absolutePath, "utf8");
8516
8650
  if (diskContent.startsWith("\uFEFF")) diskContent = diskContent.slice(1);
8517
8651
  const originalContent = diskContent.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
8518
8652
  const { content: finalContent, results } = applyPatches(originalContent, patchPairs);
@@ -8523,7 +8657,7 @@ var init_update_file = __esm({
8523
8657
  ${failures.map((f) => ` \u2022 ${f.error}`).join("\n")}`;
8524
8658
  }
8525
8659
  await RevertManager.recordFileChange(absolutePath, originalContent);
8526
- fs12.writeFileSync(absolutePath, finalContent, "utf8");
8660
+ fs13.writeFileSync(absolutePath, finalContent, "utf8");
8527
8661
  const diffText = generateHighFidelityDiff(originalContent, finalContent, results, 12);
8528
8662
  if (failures.length > 0) {
8529
8663
  return `SUCCESS: File [${targetPath}] updated with some blocks failed. [${successes.length}/${patchPairs.length}] blocks applied.
@@ -8545,34 +8679,34 @@ ${diffText}`;
8545
8679
  });
8546
8680
 
8547
8681
  // src/tools/read_folder.js
8548
- import fs13 from "fs";
8549
- import path12 from "path";
8682
+ import fs14 from "fs";
8683
+ import path13 from "path";
8550
8684
  var read_folder;
8551
8685
  var init_read_folder = __esm({
8552
8686
  "src/tools/read_folder.js"() {
8553
8687
  init_arg_parser();
8554
8688
  read_folder = async (args) => {
8555
8689
  const { path: targetPath = "." } = parseArgs(args);
8556
- const absolutePath = path12.resolve(process.cwd(), targetPath);
8690
+ const absolutePath = path13.resolve(process.cwd(), targetPath);
8557
8691
  try {
8558
- if (!fs13.existsSync(absolutePath)) {
8692
+ if (!fs14.existsSync(absolutePath)) {
8559
8693
  return `ERROR: Path [${targetPath}] does not exist.`;
8560
8694
  }
8561
- const stats = fs13.statSync(absolutePath);
8695
+ const stats = fs14.statSync(absolutePath);
8562
8696
  if (!stats.isDirectory()) {
8563
8697
  return `ERROR: Path [${targetPath}] is a file, not a directory. Use view_file instead.`;
8564
8698
  }
8565
- const files = fs13.readdirSync(absolutePath);
8699
+ const files = fs14.readdirSync(absolutePath);
8566
8700
  const totalItems = files.length;
8567
8701
  const maxDisplay = 100;
8568
8702
  const displayItems = files.slice(0, maxDisplay);
8569
8703
  const folderData = [];
8570
8704
  for (const file of displayItems) {
8571
- const fPath = path12.join(absolutePath, file);
8705
+ const fPath = path13.join(absolutePath, file);
8572
8706
  let indicator = "\u{1F4C4}";
8573
8707
  let info = { name: file, type: "unknown", size: "N/A", mtime: "N/A" };
8574
8708
  try {
8575
- const fStats = fs13.statSync(fPath);
8709
+ const fStats = fs14.statSync(fPath);
8576
8710
  info = {
8577
8711
  name: file,
8578
8712
  type: fStats.isDirectory() ? "directory" : "file",
@@ -8657,8 +8791,8 @@ var init_ask_user = __esm({
8657
8791
 
8658
8792
  // src/tools/write_pdf.js
8659
8793
  import puppeteer3 from "puppeteer";
8660
- import path13 from "path";
8661
- import fs14 from "fs-extra";
8794
+ import path14 from "path";
8795
+ import fs15 from "fs-extra";
8662
8796
  import { PDFDocument } from "pdf-lib";
8663
8797
  var write_pdf;
8664
8798
  var init_write_pdf = __esm({
@@ -8675,10 +8809,10 @@ var init_write_pdf = __esm({
8675
8809
  } = parseArgs(args);
8676
8810
  if (!targetPath) return 'ERROR: Missing "path" argument for write_pdf.';
8677
8811
  if (!content) return 'ERROR: Missing "content" (HTML/CSS) for write_pdf.';
8678
- const absolutePath = path13.resolve(process.cwd(), targetPath);
8812
+ const absolutePath = path14.resolve(process.cwd(), targetPath);
8679
8813
  let browser = null;
8680
8814
  try {
8681
- await fs14.ensureDir(path13.dirname(absolutePath));
8815
+ await fs15.ensureDir(path14.dirname(absolutePath));
8682
8816
  await RevertManager.recordFileChange(absolutePath);
8683
8817
  const pptrConfig = getPuppeteerConfig();
8684
8818
  browser = await puppeteer3.launch({
@@ -8699,11 +8833,11 @@ var init_write_pdf = __esm({
8699
8833
  return null;
8700
8834
  }
8701
8835
  try {
8702
- const imgPath = path13.resolve(process.cwd(), originalSrc);
8703
- if (await fs14.pathExists(imgPath)) {
8704
- const ext = path13.extname(imgPath).toLowerCase().replace(".", "") || "png";
8836
+ const imgPath = path14.resolve(process.cwd(), originalSrc);
8837
+ if (await fs15.pathExists(imgPath)) {
8838
+ const ext = path14.extname(imgPath).toLowerCase().replace(".", "") || "png";
8705
8839
  const mime = ext === "jpg" ? "jpeg" : ext === "svg" ? "svg+xml" : ext;
8706
- const base64 = await fs14.readFile(imgPath, "base64");
8840
+ const base64 = await fs15.readFile(imgPath, "base64");
8707
8841
  return `data:image/${mime};base64,${base64}`;
8708
8842
  }
8709
8843
  } catch (e) {
@@ -8718,9 +8852,9 @@ var init_write_pdf = __esm({
8718
8852
  const fullTag = match[0];
8719
8853
  if (originalHref && fullTag.toLowerCase().includes("stylesheet") && !originalHref.startsWith("http://") && !originalHref.startsWith("https://") && !originalHref.startsWith("data:")) {
8720
8854
  try {
8721
- const cssPath = path13.resolve(process.cwd(), originalHref);
8722
- if (await fs14.pathExists(cssPath)) {
8723
- const cssContent = await fs14.readFile(cssPath, "utf-8");
8855
+ const cssPath = path14.resolve(process.cwd(), originalHref);
8856
+ if (await fs15.pathExists(cssPath)) {
8857
+ const cssContent = await fs15.readFile(cssPath, "utf-8");
8724
8858
  cssCache[fullTag] = `<style>${cssContent}</style>`;
8725
8859
  }
8726
8860
  } catch (e) {
@@ -8801,7 +8935,7 @@ var init_write_pdf = __esm({
8801
8935
  printBackground: true
8802
8936
  });
8803
8937
  const pdfDoc = await PDFDocument.load(pdfBytes);
8804
- const fileName = path13.basename(targetPath);
8938
+ const fileName = path14.basename(targetPath);
8805
8939
  pdfDoc.setTitle(`FluxFlow_${fileName}`);
8806
8940
  pdfDoc.setAuthor("FluxFlow CLI");
8807
8941
  pdfDoc.setSubject("Generated with Agentic AI System");
@@ -8809,8 +8943,8 @@ var init_write_pdf = __esm({
8809
8943
  pdfDoc.setCreator("FluxFlow PDF Engine");
8810
8944
  pdfDoc.setProducer("FluxFlow (Generative AI)");
8811
8945
  const finalPdfBytes = await pdfDoc.save();
8812
- await fs14.writeFile(absolutePath, finalPdfBytes);
8813
- const stats = await fs14.stat(absolutePath);
8946
+ await fs15.writeFile(absolutePath, finalPdfBytes);
8947
+ const stats = await fs15.stat(absolutePath);
8814
8948
  return `SUCCESS: PDF generated successfully at [${targetPath}] (${(stats.size / 1024).toFixed(2)} KB).`;
8815
8949
  } catch (err) {
8816
8950
  const errorMsg = err instanceof Error ? err.message : String(err);
@@ -8823,8 +8957,8 @@ var init_write_pdf = __esm({
8823
8957
  });
8824
8958
 
8825
8959
  // src/tools/write_docx.js
8826
- import fs15 from "fs-extra";
8827
- import path14 from "path";
8960
+ import fs16 from "fs-extra";
8961
+ import path15 from "path";
8828
8962
  import HTMLtoDOCX from "html-to-docx";
8829
8963
  var write_docx;
8830
8964
  var init_write_docx = __esm({
@@ -8838,11 +8972,11 @@ var init_write_docx = __esm({
8838
8972
  } = parseArgs(args);
8839
8973
  if (!targetPath) return 'ERROR: Missing "path" argument for write_docx.';
8840
8974
  if (!content) return 'ERROR: Missing "content" (HTML) for write_docx.';
8841
- const absolutePath = path14.resolve(process.cwd(), targetPath);
8975
+ const absolutePath = path15.resolve(process.cwd(), targetPath);
8842
8976
  try {
8843
- await fs15.ensureDir(path14.dirname(absolutePath));
8977
+ await fs16.ensureDir(path15.dirname(absolutePath));
8844
8978
  await RevertManager.recordFileChange(absolutePath);
8845
- const fileName = path14.basename(targetPath);
8979
+ const fileName = path15.basename(targetPath);
8846
8980
  const fullHtml = content.includes("<html") ? content : `
8847
8981
  <!DOCTYPE html>
8848
8982
  <html lang="en">
@@ -8863,7 +8997,7 @@ var init_write_docx = __esm({
8863
8997
  footer: true,
8864
8998
  pageNumber: true
8865
8999
  });
8866
- await fs15.writeFile(absolutePath, docxBuffer);
9000
+ await fs16.writeFile(absolutePath, docxBuffer);
8867
9001
  return `SUCCESS: Word document [${targetPath}] generated successfully.
8868
9002
  - Size: ${(docxBuffer.length / 1024).toFixed(1)} KB`;
8869
9003
  } catch (err) {
@@ -8875,21 +9009,21 @@ var init_write_docx = __esm({
8875
9009
  });
8876
9010
 
8877
9011
  // src/tools/search_keyword.js
8878
- import fs16 from "fs/promises";
8879
- import path15 from "path";
9012
+ import fs17 from "fs/promises";
9013
+ import path16 from "path";
8880
9014
  async function getFilesRecursively(dir, excludes, baseDir = dir, depth = 1) {
8881
9015
  if (depth > 12) return [];
8882
9016
  let results = [];
8883
9017
  let list;
8884
9018
  try {
8885
- list = await fs16.readdir(dir, { withFileTypes: true });
9019
+ list = await fs17.readdir(dir, { withFileTypes: true });
8886
9020
  } catch {
8887
9021
  return [];
8888
9022
  }
8889
9023
  for (const file of list) {
8890
- const fullPath = path15.join(dir, file.name);
8891
- const relativePath = path15.relative(baseDir, fullPath);
8892
- const pathSegments = relativePath.split(path15.sep).map((s) => s.toLowerCase());
9024
+ const fullPath = path16.join(dir, file.name);
9025
+ const relativePath = path16.relative(baseDir, fullPath);
9026
+ const pathSegments = relativePath.split(path16.sep).map((s) => s.toLowerCase());
8893
9027
  const isExcluded = excludes.some((ex) => pathSegments.includes(ex.toLowerCase()));
8894
9028
  if (isExcluded) continue;
8895
9029
  if (file.isDirectory()) {
@@ -8980,11 +9114,11 @@ var init_search_keyword = __esm({
8980
9114
  let filesToSearch = [];
8981
9115
  const rootDir = process.cwd();
8982
9116
  if (file) {
8983
- const fullPath = path15.resolve(rootDir, file);
9117
+ const fullPath = path16.resolve(rootDir, file);
8984
9118
  try {
8985
- const stat = await fs16.stat(fullPath);
9119
+ const stat = await fs17.stat(fullPath);
8986
9120
  if (stat.isFile()) {
8987
- filesToSearch.push({ fullPath, relativePath: path15.relative(rootDir, fullPath) });
9121
+ filesToSearch.push({ fullPath, relativePath: path16.relative(rootDir, fullPath) });
8988
9122
  }
8989
9123
  } catch {
8990
9124
  return `ERROR: File not found: ${file}`;
@@ -8994,7 +9128,7 @@ var init_search_keyword = __esm({
8994
9128
  }
8995
9129
  const searchPromises = filesToSearch.map(async (fileObj) => {
8996
9130
  try {
8997
- const content = await fs16.readFile(fileObj.fullPath, "utf-8");
9131
+ const content = await fs17.readFile(fileObj.fullPath, "utf-8");
8998
9132
  if (content.includes("\0")) return [];
8999
9133
  const lines = content.split(/\r?\n/);
9000
9134
  const fileMatches = [];
@@ -9052,8 +9186,8 @@ var init_search_keyword = __esm({
9052
9186
  });
9053
9187
 
9054
9188
  // src/tools/generate_image.js
9055
- import fs17 from "fs-extra";
9056
- import path16 from "path";
9189
+ import fs18 from "fs-extra";
9190
+ import path17 from "path";
9057
9191
  var injectPngMetadata, generate_image;
9058
9192
  var init_generate_image = __esm({
9059
9193
  "src/tools/generate_image.js"() {
@@ -9232,12 +9366,12 @@ var init_generate_image = __esm({
9232
9366
  "Seed": String(seed)
9233
9367
  };
9234
9368
  finalBuffer = injectPngMetadata(finalBuffer, metadata);
9235
- const absolutePath = path16.resolve(process.cwd(), outputPath);
9236
- await fs17.ensureDir(path16.dirname(absolutePath));
9369
+ const absolutePath = path17.resolve(process.cwd(), outputPath);
9370
+ await fs18.ensureDir(path17.dirname(absolutePath));
9237
9371
  await RevertManager.recordFileChange(absolutePath);
9238
- await fs17.writeFile(absolutePath, finalBuffer);
9372
+ await fs18.writeFile(absolutePath, finalBuffer);
9239
9373
  await recordImageGeneration(settings);
9240
- const ext = path16.extname(outputPath).toLowerCase();
9374
+ const ext = path17.extname(outputPath).toLowerCase();
9241
9375
  const mimeMap = {
9242
9376
  ".jpg": "image/jpeg",
9243
9377
  ".jpeg": "image/jpeg",
@@ -9352,13 +9486,13 @@ var init_addMemScore = __esm({
9352
9486
  });
9353
9487
 
9354
9488
  // src/utils/parsers.js
9355
- import fs18 from "fs-extra";
9356
- import path17 from "path";
9489
+ import fs19 from "fs-extra";
9490
+ import path18 from "path";
9357
9491
  import https from "https";
9358
9492
  async function downloadWasm(wasmFile, targetUrl = null) {
9359
9493
  const url = targetUrl || `https://unpkg.com/tree-sitter-wasms@0.1.13/out/${wasmFile}`;
9360
- const localPath = path17.join(PARSER_DIR, wasmFile);
9361
- await fs18.ensureDir(PARSER_DIR);
9494
+ const localPath = path18.join(PARSER_DIR, wasmFile);
9495
+ await fs19.ensureDir(PARSER_DIR);
9362
9496
  return new Promise((resolve, reject) => {
9363
9497
  const options = {
9364
9498
  headers: {
@@ -9379,27 +9513,27 @@ async function downloadWasm(wasmFile, targetUrl = null) {
9379
9513
  reject(new Error(`Failed to download ${wasmFile}: HTTP ${response.statusCode}`));
9380
9514
  return;
9381
9515
  }
9382
- const file = fs18.createWriteStream(localPath);
9516
+ const file = fs19.createWriteStream(localPath);
9383
9517
  response.pipe(file);
9384
9518
  file.on("finish", () => {
9385
9519
  file.close();
9386
9520
  resolve();
9387
9521
  });
9388
9522
  }).on("error", (err) => {
9389
- if (fs18.existsSync(localPath)) fs18.unlink(localPath, () => {
9523
+ if (fs19.existsSync(localPath)) fs19.unlink(localPath, () => {
9390
9524
  });
9391
9525
  reject(err);
9392
9526
  });
9393
9527
  });
9394
9528
  }
9395
9529
  function isParserInstalled(wasmFile) {
9396
- const localPath = path17.join(PARSER_DIR, wasmFile);
9397
- return fs18.existsSync(localPath);
9530
+ const localPath = path18.join(PARSER_DIR, wasmFile);
9531
+ return fs19.existsSync(localPath);
9398
9532
  }
9399
9533
  async function deleteParser(wasmFile) {
9400
- const localPath = path17.join(PARSER_DIR, wasmFile);
9401
- if (fs18.existsSync(localPath)) {
9402
- await fs18.unlink(localPath);
9534
+ const localPath = path18.join(PARSER_DIR, wasmFile);
9535
+ if (fs19.existsSync(localPath)) {
9536
+ await fs19.unlink(localPath);
9403
9537
  }
9404
9538
  }
9405
9539
  var EXTENSION_TO_WASM;
@@ -9421,8 +9555,8 @@ var init_parsers = __esm({
9421
9555
  });
9422
9556
 
9423
9557
  // src/tools/file_map.js
9424
- import fs19 from "fs-extra";
9425
- import path18 from "path";
9558
+ import fs20 from "fs-extra";
9559
+ import path19 from "path";
9426
9560
  import { createRequire as createRequire2 } from "module";
9427
9561
  function sanitize(text, limit = 50) {
9428
9562
  if (!text) return "";
@@ -9614,17 +9748,17 @@ var init_file_map = __esm({
9614
9748
  if (!filePath) {
9615
9749
  return 'ERROR: No file path provided. Use [tool:functions.FileMap(path="...")]';
9616
9750
  }
9617
- const absolutePath = path18.isAbsolute(filePath) ? filePath : path18.resolve(process.cwd(), filePath);
9618
- if (!fs19.existsSync(absolutePath)) {
9751
+ const absolutePath = path19.isAbsolute(filePath) ? filePath : path19.resolve(process.cwd(), filePath);
9752
+ if (!fs20.existsSync(absolutePath)) {
9619
9753
  return `ERROR: File not found: ${filePath}`;
9620
9754
  }
9621
- const ext = path18.extname(absolutePath).slice(1).toLowerCase();
9755
+ const ext = path19.extname(absolutePath).slice(1).toLowerCase();
9622
9756
  const wasmFile = EXTENSION_TO_WASM[ext];
9623
9757
  if (!wasmFile) {
9624
9758
  return `ERROR: Unsupported file extension: .${ext}`;
9625
9759
  }
9626
- const wasmPath = path18.resolve(PARSER_DIR, wasmFile);
9627
- if (!fs19.existsSync(wasmPath)) {
9760
+ const wasmPath = path19.resolve(PARSER_DIR, wasmFile);
9761
+ if (!fs20.existsSync(wasmPath)) {
9628
9762
  return `ERROR: Parser for .${ext} not found. Please download it in Settings > Other.`;
9629
9763
  }
9630
9764
  try {
@@ -9632,9 +9766,9 @@ var init_file_map = __esm({
9632
9766
  if (!isParserInitialized) {
9633
9767
  let tsWasmPath;
9634
9768
  try {
9635
- tsWasmPath = path18.join(path18.dirname(require3.resolve("web-tree-sitter")), "tree-sitter.wasm");
9769
+ tsWasmPath = path19.join(path19.dirname(require3.resolve("web-tree-sitter")), "tree-sitter.wasm");
9636
9770
  } catch (e) {
9637
- tsWasmPath = path18.join(process.cwd(), "node_modules", "web-tree-sitter", "tree-sitter.wasm");
9771
+ tsWasmPath = path19.join(process.cwd(), "node_modules", "web-tree-sitter", "tree-sitter.wasm");
9638
9772
  }
9639
9773
  await Parser.init({
9640
9774
  locateFile: (p) => {
@@ -9649,7 +9783,7 @@ var init_file_map = __esm({
9649
9783
  const parser = new Parser();
9650
9784
  const Lang = await TreeSitter.Language.load(wasmPath);
9651
9785
  parser.setLanguage(Lang);
9652
- const sourceCode = await fs19.readFile(absolutePath, "utf8");
9786
+ const sourceCode = await fs20.readFile(absolutePath, "utf8");
9653
9787
  const lines = sourceCode.split("\n").length;
9654
9788
  let maxDepth = 12;
9655
9789
  if (lines > 1e4) maxDepth = 2;
@@ -9672,8 +9806,8 @@ Stack: ${err.stack}` : "";
9672
9806
  });
9673
9807
 
9674
9808
  // src/tools/todo.js
9675
- import fs20 from "fs";
9676
- import path19 from "path";
9809
+ import fs21 from "fs";
9810
+ import path20 from "path";
9677
9811
  var todo;
9678
9812
  var init_todo = __esm({
9679
9813
  "src/tools/todo.js"() {
@@ -9684,8 +9818,8 @@ var init_todo = __esm({
9684
9818
  const { method, tasks, markDone } = parseArgs(args);
9685
9819
  const chatId = context.chatId || "default";
9686
9820
  if (!method) return 'ERROR: Missing "method" argument for todo tool (create/append/get).';
9687
- const todoDir = path19.join(DATA_DIR, "plan", chatId);
9688
- const todoFile = path19.join(todoDir, "todo.md");
9821
+ const todoDir = path20.join(DATA_DIR, "plan", chatId);
9822
+ const todoFile = path20.join(todoDir, "todo.md");
9689
9823
  const parseMessyArray = (input) => {
9690
9824
  if (!input || Array.isArray(input)) return input;
9691
9825
  const trimmed = String(input).trim();
@@ -9745,8 +9879,8 @@ var init_todo = __esm({
9745
9879
  };
9746
9880
  };
9747
9881
  try {
9748
- if (!fs20.existsSync(todoDir)) {
9749
- fs20.mkdirSync(todoDir, { recursive: true });
9882
+ if (!fs21.existsSync(todoDir)) {
9883
+ fs21.mkdirSync(todoDir, { recursive: true });
9750
9884
  }
9751
9885
  if (method === "create") {
9752
9886
  if (!tasks) return 'ERROR: Missing "tasks" for create method.';
@@ -9758,7 +9892,7 @@ var init_todo = __esm({
9758
9892
  markedCount = result.markedCount;
9759
9893
  }
9760
9894
  await RevertManager.recordFileChange(todoFile);
9761
- fs20.writeFileSync(todoFile, content, "utf8");
9895
+ fs21.writeFileSync(todoFile, content, "utf8");
9762
9896
  const total = content.split(/\r?\n/).map((l) => l.trim()).filter((l) => l.startsWith("- [ ]") || l.startsWith("- [x]") || l.startsWith("- [X]")).length;
9763
9897
  if (markedCount > 0) {
9764
9898
  const completed = content.split(/\r?\n/).map((l) => l.trim()).filter((l) => l.startsWith("- [x]") || l.startsWith("- [X]")).length;
@@ -9772,8 +9906,8 @@ ${content}`;
9772
9906
  if (!tasks) return 'ERROR: Missing "tasks" for append method.';
9773
9907
  const appendContent = getTasksString(tasks);
9774
9908
  await RevertManager.recordFileChange(todoFile);
9775
- fs20.appendFileSync(todoFile, appendContent, "utf8");
9776
- const fullContent = fs20.readFileSync(todoFile, "utf8");
9909
+ fs21.appendFileSync(todoFile, appendContent, "utf8");
9910
+ const fullContent = fs21.readFileSync(todoFile, "utf8");
9777
9911
  const lines = fullContent.split(/\r?\n/).map((l) => l.trim());
9778
9912
  const total = lines.filter((l) => l.startsWith("- [ ]") || l.startsWith("- [x]") || l.startsWith("- [X]")).length;
9779
9913
  const completed = lines.filter((l) => l.startsWith("- [x]") || l.startsWith("- [X]")).length;
@@ -9782,10 +9916,10 @@ ${content}`;
9782
9916
  ${fullContent}`;
9783
9917
  }
9784
9918
  if (method === "get") {
9785
- if (!fs20.existsSync(todoFile)) {
9919
+ if (!fs21.existsSync(todoFile)) {
9786
9920
  return "TODO GET: No task list found for this session.";
9787
9921
  }
9788
- let content = fs20.readFileSync(todoFile, "utf8");
9922
+ let content = fs21.readFileSync(todoFile, "utf8");
9789
9923
  let markedCount = 0;
9790
9924
  if (markDone) {
9791
9925
  const result = applyMarkDone(content, markDone);
@@ -9793,7 +9927,7 @@ ${fullContent}`;
9793
9927
  content = result.content;
9794
9928
  markedCount = result.markedCount;
9795
9929
  await RevertManager.recordFileChange(todoFile);
9796
- fs20.writeFileSync(todoFile, content, "utf8");
9930
+ fs21.writeFileSync(todoFile, content, "utf8");
9797
9931
  }
9798
9932
  }
9799
9933
  const totalLines = content.split(/\r?\n/).map((l) => l.trim());
@@ -10174,20 +10308,20 @@ var init_await = __esm({
10174
10308
  });
10175
10309
 
10176
10310
  // src/utils/advanceRevert.js
10177
- import fs21 from "fs-extra";
10178
- import path20 from "path";
10311
+ import fs22 from "fs-extra";
10312
+ import path21 from "path";
10179
10313
  async function scanWorkspace(dir, baseDir = dir) {
10180
10314
  const manifest = {};
10181
- const entries = await fs21.readdir(dir, { withFileTypes: true }).catch(() => []);
10315
+ const entries = await fs22.readdir(dir, { withFileTypes: true }).catch(() => []);
10182
10316
  for (const entry of entries) {
10183
10317
  if (JUNK_DIRECTORIES.includes(entry.name)) continue;
10184
- const fullPath = path20.join(dir, entry.name);
10185
- const relPath = path20.relative(baseDir, fullPath).replace(/\\/g, "/");
10318
+ const fullPath = path21.join(dir, entry.name);
10319
+ const relPath = path21.relative(baseDir, fullPath).replace(/\\/g, "/");
10186
10320
  if (entry.isDirectory()) {
10187
10321
  const sub = await scanWorkspace(fullPath, baseDir);
10188
10322
  Object.assign(manifest, sub);
10189
10323
  } else {
10190
- const stats = await fs21.stat(fullPath).catch(() => null);
10324
+ const stats = await fs22.stat(fullPath).catch(() => null);
10191
10325
  if (stats) {
10192
10326
  manifest[relPath] = {
10193
10327
  size: stats.size,
@@ -10199,34 +10333,34 @@ async function scanWorkspace(dir, baseDir = dir) {
10199
10333
  return manifest;
10200
10334
  }
10201
10335
  async function copyWorkspaceFiles(destDir, manifest) {
10202
- await fs21.ensureDir(destDir);
10336
+ await fs22.ensureDir(destDir);
10203
10337
  for (const relPath of Object.keys(manifest)) {
10204
- const srcPath = path20.join(process.cwd(), relPath);
10205
- const destPath = path20.join(destDir, relPath);
10206
- await fs21.ensureDir(path20.dirname(destPath));
10207
- await fs21.copyFile(srcPath, destPath).catch(() => {
10338
+ const srcPath = path21.join(process.cwd(), relPath);
10339
+ const destPath = path21.join(destDir, relPath);
10340
+ await fs22.ensureDir(path21.dirname(destPath));
10341
+ await fs22.copyFile(srcPath, destPath).catch(() => {
10208
10342
  });
10209
10343
  }
10210
10344
  }
10211
10345
  async function restoreSnapshotDir(srcDir, destDir, stats = null, baseDir = null) {
10212
- if (!await fs21.pathExists(srcDir)) return;
10346
+ if (!await fs22.pathExists(srcDir)) return;
10213
10347
  if (!baseDir) baseDir = srcDir;
10214
- const entries = await fs21.readdir(srcDir, { withFileTypes: true }).catch(() => []);
10348
+ const entries = await fs22.readdir(srcDir, { withFileTypes: true }).catch(() => []);
10215
10349
  for (const entry of entries) {
10216
- const srcPath = path20.join(srcDir, entry.name);
10217
- const destPath = path20.join(destDir, entry.name);
10350
+ const srcPath = path21.join(srcDir, entry.name);
10351
+ const destPath = path21.join(destDir, entry.name);
10218
10352
  if (entry.isDirectory()) {
10219
10353
  await restoreSnapshotDir(srcPath, destPath, stats, baseDir);
10220
10354
  } else {
10221
- const relPath = path20.relative(baseDir, srcPath).replace(/\\/g, "/");
10222
- const existed = await fs21.pathExists(destPath);
10355
+ const relPath = path21.relative(baseDir, srcPath).replace(/\\/g, "/");
10356
+ const existed = await fs22.pathExists(destPath);
10223
10357
  if (existed) {
10224
- await fs21.chmod(destPath, 438).catch(() => {
10358
+ await fs22.chmod(destPath, 438).catch(() => {
10225
10359
  });
10226
10360
  }
10227
- await fs21.ensureDir(path20.dirname(destPath));
10228
- const ok = await fs21.copyFile(srcPath, destPath).then(() => true).catch(() => false);
10229
- await fs21.chmod(destPath, 438).catch(() => {
10361
+ await fs22.ensureDir(path21.dirname(destPath));
10362
+ const ok = await fs22.copyFile(srcPath, destPath).then(() => true).catch(() => false);
10363
+ await fs22.chmod(destPath, 438).catch(() => {
10230
10364
  });
10231
10365
  if (stats) {
10232
10366
  if (!ok) {
@@ -10264,12 +10398,12 @@ var init_advanceRevert = __esm({
10264
10398
  AdvanceRevertManager = {
10265
10399
  async takeInitialSnapshot(chatId) {
10266
10400
  try {
10267
- const snapshotsDir = path20.join(DATA_DIR, "snapshots", chatId);
10268
- await fs21.remove(snapshotsDir).catch(() => {
10401
+ const snapshotsDir = path21.join(DATA_DIR, "snapshots", chatId);
10402
+ await fs22.remove(snapshotsDir).catch(() => {
10269
10403
  });
10270
- await fs21.ensureDir(snapshotsDir);
10404
+ await fs22.ensureDir(snapshotsDir);
10271
10405
  const manifest = await scanWorkspace(process.cwd());
10272
- await copyWorkspaceFiles(path20.join(snapshotsDir, "initial"), manifest);
10406
+ await copyWorkspaceFiles(path21.join(snapshotsDir, "initial"), manifest);
10273
10407
  const ledger = readEncryptedJson(LEDGER_ADVANCE_FILE, {});
10274
10408
  ledger[chatId] = {
10275
10409
  initialManifest: manifest,
@@ -10318,7 +10452,7 @@ var init_advanceRevert = __esm({
10318
10452
  for (const file of changedFiles) {
10319
10453
  deltaManifest[file] = currentManifest[file];
10320
10454
  }
10321
- const turnDir = path20.join(DATA_DIR, "snapshots", chatId, `turn_${turnNumber}`);
10455
+ const turnDir = path21.join(DATA_DIR, "snapshots", chatId, `turn_${turnNumber}`);
10322
10456
  await copyWorkspaceFiles(turnDir, deltaManifest);
10323
10457
  }
10324
10458
  session.checkpoints.push({
@@ -10352,28 +10486,28 @@ var init_advanceRevert = __esm({
10352
10486
  const checkpoints = session.checkpoints || [];
10353
10487
  const targetIdx = checkpoints.findIndex((c) => c.id === checkpointId);
10354
10488
  if (targetIdx === -1) throw new Error(`Checkpoint [${checkpointId}] not found.`);
10355
- const snapshotsDir = path20.join(DATA_DIR, "snapshots", chatId);
10489
+ const snapshotsDir = path21.join(DATA_DIR, "snapshots", chatId);
10356
10490
  const stats = { restored: 0, replaced: 0, failed: [] };
10357
10491
  const currentFiles = await scanWorkspace(process.cwd());
10358
10492
  for (const relPath of Object.keys(currentFiles)) {
10359
- const fullPath = path20.join(process.cwd(), relPath);
10360
- await fs21.chmod(fullPath, 438).catch(() => {
10493
+ const fullPath = path21.join(process.cwd(), relPath);
10494
+ await fs22.chmod(fullPath, 438).catch(() => {
10361
10495
  });
10362
- await fs21.remove(fullPath).catch(() => {
10496
+ await fs22.remove(fullPath).catch(() => {
10363
10497
  });
10364
10498
  }
10365
- const initialDir = path20.join(snapshotsDir, "initial");
10499
+ const initialDir = path21.join(snapshotsDir, "initial");
10366
10500
  await restoreSnapshotDir(initialDir, process.cwd(), stats, initialDir);
10367
10501
  for (let i = 1; i <= targetIdx; i++) {
10368
10502
  const cp = checkpoints[i];
10369
- const turnDir = path20.join(snapshotsDir, cp.id);
10503
+ const turnDir = path21.join(snapshotsDir, cp.id);
10370
10504
  await restoreSnapshotDir(turnDir, process.cwd(), stats, turnDir);
10371
10505
  if (cp.deletedFiles && cp.deletedFiles.length > 0) {
10372
10506
  for (const delFile of cp.deletedFiles) {
10373
- const fullPath = path20.join(process.cwd(), delFile);
10374
- await fs21.chmod(fullPath, 438).catch(() => {
10507
+ const fullPath = path21.join(process.cwd(), delFile);
10508
+ await fs22.chmod(fullPath, 438).catch(() => {
10375
10509
  });
10376
- await fs21.remove(fullPath).catch(() => {
10510
+ await fs22.remove(fullPath).catch(() => {
10377
10511
  });
10378
10512
  }
10379
10513
  }
@@ -10388,8 +10522,8 @@ var init_advanceRevert = __esm({
10388
10522
  },
10389
10523
  async cleanup(chatId) {
10390
10524
  try {
10391
- const snapshotsDir = path20.join(DATA_DIR, "snapshots", chatId);
10392
- await fs21.remove(snapshotsDir).catch(() => {
10525
+ const snapshotsDir = path21.join(DATA_DIR, "snapshots", chatId);
10526
+ await fs22.remove(snapshotsDir).catch(() => {
10393
10527
  });
10394
10528
  const ledger = readEncryptedJson(LEDGER_ADVANCE_FILE, {});
10395
10529
  if (ledger[chatId]) {
@@ -10743,9 +10877,9 @@ __export(ai_exports, {
10743
10877
  signalTermination: () => signalTermination
10744
10878
  });
10745
10879
  import { GoogleGenAI, ThinkingLevel, HarmBlockThreshold, HarmCategory } from "@google/genai";
10746
- import path21, { normalize } from "path";
10747
- import fs22 from "fs";
10748
- var client, globalSettings, colorMainWords, withRetry, TERMINATION_SIGNAL, MULTIMODAL_MODELS, isModelMultimodal, getCleanGroupedLength, stripAnsi2, fetchWithBackoff, getDeepSeekStream, getNVIDIAStream, wrapNvidiaStreamWithQueueDepth, getOpenRouterStream, signalTermination, isTerminationSignaled, TOOL_LABELS2, getToolDetail, runJanitorTask, getActiveToolContext, getContextSafeText, contextSafeReplace, getSanitizedText, translateKimiToolCalls, detectToolCalls, initAI, generateSimpleContent, consolidatePastMemories, compressHistory, deleteChatSummary, getAIStream, runSubagent;
10880
+ import path22, { normalize } from "path";
10881
+ import fs23 from "fs";
10882
+ var client, globalSettings, colorMainWords, withRetry, TERMINATION_SIGNAL, getCleanGroupedLength, stripAnsi2, fetchWithBackoff, getDeepSeekStream, getNVIDIAStream, wrapNvidiaStreamWithQueueDepth, getOpenRouterStream, signalTermination, isTerminationSignaled, TOOL_LABELS2, getToolDetail, runJanitorTask, getActiveToolContext, getContextSafeText, contextSafeReplace, getSanitizedText, translateKimiToolCalls, detectToolCalls, initAI, generateSimpleContent, consolidatePastMemories, compressHistory, deleteChatSummary, getAIStream, runSubagent;
10749
10883
  var init_ai = __esm({
10750
10884
  async "src/utils/ai.js"() {
10751
10885
  await init_prompts();
@@ -10759,6 +10893,7 @@ var init_ai = __esm({
10759
10893
  init_text();
10760
10894
  init_settings();
10761
10895
  init_subagent_state();
10896
+ init_model_config();
10762
10897
  init_paths();
10763
10898
  init_revert();
10764
10899
  init_advanceRevert();
@@ -10801,35 +10936,6 @@ var init_ai = __esm({
10801
10936
  }
10802
10937
  };
10803
10938
  TERMINATION_SIGNAL = false;
10804
- MULTIMODAL_MODELS = [
10805
- // OpenRouter models
10806
- "google/gemma-4-31b-it:free",
10807
- "moonshotai/kimi-k2.6:free",
10808
- "google/gemini-3.5-flash",
10809
- "qwen/qwen3.7-plus",
10810
- "minimax/minimax-m3",
10811
- "anthropic/claude-sonnet-4.5",
10812
- "anthropic/claude-opus-4.6",
10813
- "anthropic/claude-opus-4.8",
10814
- "openai/gpt-5.2-codex",
10815
- "openai/gpt-5.2-pro",
10816
- "openai/gpt-5.5-pro",
10817
- "moonshotai/kimi-k2.6",
10818
- // NVIDIA vision models
10819
- "moonshotai/kimi-k2.7",
10820
- "stepfun-ai/step-3.7-flash",
10821
- "google/gemma-4-31b-it",
10822
- "mistralai/mistral-medium-3.5-128b",
10823
- "qwen/qwen3.5-397b-a17b"
10824
- // Google models
10825
- // No need. All models on Gemini API is Multimodal
10826
- ];
10827
- isModelMultimodal = (model) => {
10828
- if (!model) return false;
10829
- const lower = model.toLowerCase();
10830
- if (lower.startsWith("gemini-") || lower.startsWith("gemma-")) return true;
10831
- return MULTIMODAL_MODELS.some((m) => m.toLowerCase() === lower);
10832
- };
10833
10939
  getCleanGroupedLength = (rawHistory) => {
10834
10940
  const preprocessed = rawHistory.filter(
10835
10941
  (m) => (m.role === "user" || m.role === "agent" || m.role === "system") && m.role !== "think" && !m.isVisualFeedback && !m.isMeta && !String(m.id).startsWith("welcome")
@@ -11139,6 +11245,7 @@ var init_ai = __esm({
11139
11245
  const isGPT = model.includes("gpt");
11140
11246
  const isQwen = model.includes("qwen");
11141
11247
  const isNemotron = model.includes("nemotron");
11248
+ const isLlama3 = model.includes("llama-3");
11142
11249
  const GPT_THINKING_LEVELS = {
11143
11250
  "Fast": "low",
11144
11251
  "Low": "low",
@@ -11157,7 +11264,8 @@ var init_ai = __esm({
11157
11264
  temperature,
11158
11265
  ...isGPT && { thinking: GPT_THINKING_LEVELS[thinkingLevel] || "high" }
11159
11266
  };
11160
- if (isKimi) {
11267
+ if (isLlama3) {
11268
+ } else if (isKimi) {
11161
11269
  body.chat_template_kwargs = { thinking: isThinking };
11162
11270
  } else if (isGemma) {
11163
11271
  body.chat_template_kwargs = { enable_thinking: isThinking };
@@ -11301,7 +11409,8 @@ var init_ai = __esm({
11301
11409
  resolve();
11302
11410
  }
11303
11411
  };
11304
- const cleanModelId = modelName.split("/").pop();
11412
+ let cleanModelId = modelName.split("/").pop();
11413
+ cleanModelId = cleanModelId.replace("llama-3.3", "llama-3_3");
11305
11414
  const pollUrl = `https://api.ngc.nvidia.com/v2/predict/queues/models/qc69jvmznzxy/${cleanModelId}`;
11306
11415
  let isStreamingStarted = false;
11307
11416
  let pollInterval = null;
@@ -11561,15 +11670,15 @@ var init_ai = __esm({
11561
11670
  return pArgs.id || pArgs.taskId;
11562
11671
  }
11563
11672
  const filePath = pArgs.path || pArgs.targetFile || pArgs.TargetFile || pArgs.directory;
11564
- return filePath ? path21.basename(filePath.replace(/["']/g, "").replace(/\\/g, "/")) : null;
11673
+ return filePath ? path22.basename(filePath.replace(/["']/g, "").replace(/\\/g, "/")) : null;
11565
11674
  } catch (e) {
11566
11675
  return null;
11567
11676
  }
11568
11677
  };
11569
11678
  runJanitorTask = async (settings, agentText, fullAgentTextRaw, history, callbacks = {}) => {
11570
11679
  if (process.stdout.isTTY) {
11571
- process.stdout.write(`\x1B]0;Finalizing...\x07`);
11572
- process.stdout.write(`\x1B]633;P;TerminalTitle=Finalizing...\x07`);
11680
+ process.stdout.write("\x1B]0;FluxFlow | Idle\x07");
11681
+ process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow | Idle\x07");
11573
11682
  }
11574
11683
  const USER_CONTEXT_LENGTH = 4 * (1024 * 2);
11575
11684
  const AGENT_CONTEXT_LENGTH = 4 * (1024 * 8);
@@ -11617,10 +11726,6 @@ ${originalTextProcessed.length > USER_CONTEXT_LENGTH ? "... (truncated) ...\n\n"
11617
11726
  let attempts = 0;
11618
11727
  const MAX_JANITOR_RETRIES = isMemoryEnabled ? 12 : -1;
11619
11728
  while (attempts <= MAX_JANITOR_RETRIES) {
11620
- if (process.stdout.isTTY) {
11621
- process.stdout.write(`\x1B]0;Retrying Finalizing... (${attempts + 1})...\x07`);
11622
- process.stdout.write(`\x1B]633;P;TerminalTitle=Retrying Finalizing... (${attempts + 1})...\x07`);
11623
- }
11624
11729
  try {
11625
11730
  if (!await checkQuota("background", settings)) {
11626
11731
  return;
@@ -11633,7 +11738,7 @@ ${originalTextProcessed.length > USER_CONTEXT_LENGTH ? "... (truncated) ...\n\n"
11633
11738
  );
11634
11739
  const streamPromise = (async () => {
11635
11740
  if (aiProvider === "OpenRouter") {
11636
- const janitorOpenRouterModel = "google/gemma-4-26b-a4b-it:free";
11741
+ const janitorOpenRouterModel = getFallbackValue("janitor_open_router");
11637
11742
  const stream = getOpenRouterStream(
11638
11743
  apiKey,
11639
11744
  janitorOpenRouterModel,
@@ -11652,7 +11757,7 @@ ${originalTextProcessed.length > USER_CONTEXT_LENGTH ? "... (truncated) ...\n\n"
11652
11757
  } else if (aiProvider === "DeepSeek") {
11653
11758
  const stream = getDeepSeekStream(
11654
11759
  apiKey,
11655
- "deepseek-chat",
11760
+ getFallbackValue("deepseek_fast_fallback"),
11656
11761
  janitorContents,
11657
11762
  janitorPrompt,
11658
11763
  "Fast",
@@ -11668,7 +11773,7 @@ ${originalTextProcessed.length > USER_CONTEXT_LENGTH ? "... (truncated) ...\n\n"
11668
11773
  } else if (aiProvider === "NVIDIA") {
11669
11774
  const stream = getNVIDIAStream(
11670
11775
  apiKey,
11671
- "deepseek-ai/deepseek-v4-flash",
11776
+ getFallbackValue("nvidia_janitor_fallback"),
11672
11777
  janitorContents,
11673
11778
  janitorPrompt,
11674
11779
  "Fast",
@@ -11683,7 +11788,7 @@ ${originalTextProcessed.length > USER_CONTEXT_LENGTH ? "... (truncated) ...\n\n"
11683
11788
  return { iterator: iterator2, firstResult: firstResult2 };
11684
11789
  } else {
11685
11790
  const stream = await client.models.generateContentStream({
11686
- model: janitorModel || (attempts === MAX_JANITOR_RETRIES ? "gemini-3.1-flash-lite" : "gemma-4-26b-a4b-it"),
11791
+ model: janitorModel || (attempts === MAX_JANITOR_RETRIES ? getFallbackValue("janitor_default") : getFallbackValue("gemma_janitor_fallback_google")),
11687
11792
  contents: janitorContents,
11688
11793
  config: {
11689
11794
  systemInstruction: janitorPrompt,
@@ -11729,7 +11834,7 @@ ${originalTextProcessed.length > USER_CONTEXT_LENGTH ? "... (truncated) ...\n\n"
11729
11834
  const total = lastUsage.totalTokenCount || 0;
11730
11835
  const cached = lastUsage.cachedContentTokenCount || 0;
11731
11836
  const candidates = (lastUsage.candidatesTokenCount || 0) + (lastUsage.thoughtsTokenCount || 0);
11732
- const jModel = janitorModel || "gemini-3.1-flash-lite";
11837
+ const jModel = janitorModel || getFallbackValue("janitor_default");
11733
11838
  await addToUsage("tokens", total, aiProvider, jModel);
11734
11839
  if (cached > 0) {
11735
11840
  await addToUsage("cachedTokens", cached, aiProvider, jModel);
@@ -11791,9 +11896,6 @@ ${originalTextProcessed.length > USER_CONTEXT_LENGTH ? "... (truncated) ...\n\n"
11791
11896
  } catch (err) {
11792
11897
  attempts++;
11793
11898
  const date = (/* @__PURE__ */ new Date()).toLocaleString();
11794
- if (process.stdout.isTTY) {
11795
- process.stdout.write(`\x1B]0;Finalizing Error\x07`);
11796
- }
11797
11899
  const errLog = err instanceof Error ? (() => {
11798
11900
  try {
11799
11901
  return JSON.parse(JSON.parse(err.message).error.message).error.message;
@@ -11802,9 +11904,9 @@ ${originalTextProcessed.length > USER_CONTEXT_LENGTH ? "... (truncated) ...\n\n"
11802
11904
  }
11803
11905
  })() : String(err);
11804
11906
  await new Promise((resolve) => setTimeout(resolve, 1e3));
11805
- const janitorErrDir = path21.join(LOGS_DIR, "janitor");
11806
- if (!fs22.existsSync(janitorErrDir)) fs22.mkdirSync(janitorErrDir, { recursive: true });
11807
- fs22.appendFileSync(path21.join(janitorErrDir, "error.log"), `ERROR [Attempt ${attempts}/${MAX_JANITOR_RETRIES + 1}] [${date}]: ${errLog}
11907
+ const janitorErrDir = path22.join(LOGS_DIR, "janitor");
11908
+ if (!fs23.existsSync(janitorErrDir)) fs23.mkdirSync(janitorErrDir, { recursive: true });
11909
+ fs23.appendFileSync(path22.join(janitorErrDir, "error.log"), `ERROR [Attempt ${attempts}/${MAX_JANITOR_RETRIES + 1}] [${date}]: ${errLog}
11808
11910
 
11809
11911
  `);
11810
11912
  if (attempts > MAX_JANITOR_RETRIES) break;
@@ -11813,16 +11915,10 @@ ${originalTextProcessed.length > USER_CONTEXT_LENGTH ? "... (truncated) ...\n\n"
11813
11915
  }
11814
11916
  }
11815
11917
  if (attempts) {
11816
- const janitorErrDir = path21.join(LOGS_DIR, "janitor");
11817
- fs22.appendFileSync(path21.join(janitorErrDir, "error.log"), `-----------------------------------------------------------------------------
11918
+ const janitorErrDir = path22.join(LOGS_DIR, "janitor");
11919
+ fs23.appendFileSync(path22.join(janitorErrDir, "error.log"), `-----------------------------------------------------------------------------
11818
11920
 
11819
11921
  `);
11820
- if (attempts >= MAX_JANITOR_RETRIES) {
11821
- if (process.stdout.isTTY) {
11822
- process.stdout.write(`\x1B]0;${isMemoryEnabled ? "Finalizing Error" : "Finalizing Skipped"}\x07`);
11823
- }
11824
- await new Promise((resolve) => setTimeout(resolve, 3e3));
11825
- }
11826
11922
  }
11827
11923
  if (process.stdout.isTTY) {
11828
11924
  try {
@@ -12310,10 +12406,10 @@ ${newMemoryListStr}
12310
12406
  let attempts = 0;
12311
12407
  const maxAttempts = 5;
12312
12408
  let success = false;
12313
- let targetModel = "gemma-4-26b-a4b-it";
12314
- if (aiProvider === "OpenRouter") targetModel = "google/gemma-4-26b-a4b-it:free";
12315
- if (aiProvider === "DeepSeek") targetModel = "deepseek-v4-flash";
12316
- if (aiProvider === "NVIDIA") targetModel = "deepseek-ai/deepseek-v4-flash";
12409
+ let targetModel = getFallbackValue("gemma_janitor_fallback_google");
12410
+ if (aiProvider === "OpenRouter") targetModel = getFallbackValue("janitor_open_router");
12411
+ if (aiProvider === "DeepSeek") targetModel = getFallbackValue("deepseek_level_1");
12412
+ if (aiProvider === "NVIDIA") targetModel = getFallbackValue("nvidia_janitor_fallback");
12317
12413
  while (attempts <= maxAttempts && !success) {
12318
12414
  attempts++;
12319
12415
  try {
@@ -12345,10 +12441,10 @@ ${newMemoryListStr}
12345
12441
  }
12346
12442
  })() : String(err);
12347
12443
  ;
12348
- const janitorLogDir = path21.join(LOGS_DIR, "janitor");
12349
- if (!fs22.existsSync(janitorLogDir)) fs22.mkdirSync(janitorLogDir, { recursive: true });
12350
- fs22.appendFileSync(
12351
- path21.join(janitorLogDir, "error.log"),
12444
+ const janitorLogDir = path22.join(LOGS_DIR, "janitor");
12445
+ if (!fs23.existsSync(janitorLogDir)) fs23.mkdirSync(janitorLogDir, { recursive: true });
12446
+ fs23.appendFileSync(
12447
+ path22.join(janitorLogDir, "error.log"),
12352
12448
  `[${(/* @__PURE__ */ new Date()).toLocaleString()}] Past memory batch consolidation error: ${errLog}
12353
12449
  `
12354
12450
  );
@@ -12356,7 +12452,7 @@ ${newMemoryListStr}
12356
12452
  };
12357
12453
  compressHistory = async (settings, history, isAuto = false) => {
12358
12454
  const { chatId, aiProvider = "Google" } = settings;
12359
- const summariesFile = path21.join(SECRET_DIR, "chat-summaries.json");
12455
+ const summariesFile = path22.join(SECRET_DIR, "chat-summaries.json");
12360
12456
  const flattenContext = (hist) => {
12361
12457
  return hist.filter(
12362
12458
  (m) => (m.role === "user" || m.role === "agent" || m.role === "system") && m.role !== "think" && !m.isVisualFeedback && !m.isMeta && !String(m.id).startsWith("welcome")
@@ -12377,10 +12473,10 @@ Provide a new consolidated summary of the entire session.` : `Here is the conver
12377
12473
  ${flattenedText2}
12378
12474
 
12379
12475
  Provide a consolidated summary of the entire session.`;
12380
- let targetModel = "gemma-4-26b-a4b-it";
12381
- if (aiProvider === "OpenRouter") targetModel = "google/gemma-4-26b-a4b-it:free";
12382
- if (aiProvider === "DeepSeek") targetModel = "deepseek-v4-flash";
12383
- if (aiProvider === "NVIDIA") targetModel = "deepseek-ai/deepseek-v4-flash";
12476
+ let targetModel = getFallbackValue("gemma_janitor_fallback_google");
12477
+ if (aiProvider === "OpenRouter") targetModel = getFallbackValue("janitor_open_router");
12478
+ if (aiProvider === "DeepSeek") targetModel = getFallbackValue("deepseek_level_1");
12479
+ if (aiProvider === "NVIDIA") targetModel = getFallbackValue("nvidia_janitor_fallback");
12384
12480
  let attempts = 0;
12385
12481
  let success = false;
12386
12482
  let response = null;
@@ -12393,7 +12489,7 @@ Provide a consolidated summary of the entire session.`;
12393
12489
  if (attempts > 3) {
12394
12490
  if (aiProvider === "Google") {
12395
12491
  try {
12396
- const fallbackModel = "gemini-3.1-flash-lite";
12492
+ const fallbackModel = getFallbackValue("general_fallback");
12397
12493
  const fallback = await generateSimpleContent(settings, fallbackModel, prompt, systemInstruction, "Fast");
12398
12494
  return fallback.text || "";
12399
12495
  } catch (e) {
@@ -12430,8 +12526,8 @@ Provide a consolidated summary of the entire session.`;
12430
12526
  };
12431
12527
  deleteChatSummary = (chatId) => {
12432
12528
  try {
12433
- const summariesFile = path21.join(SECRET_DIR, "chat-summaries.json");
12434
- if (fs22.existsSync(summariesFile)) {
12529
+ const summariesFile = path22.join(SECRET_DIR, "chat-summaries.json");
12530
+ if (fs23.existsSync(summariesFile)) {
12435
12531
  const summaries = readEncryptedJson(summariesFile, {});
12436
12532
  if (summaries[chatId]) {
12437
12533
  delete summaries[chatId];
@@ -12447,7 +12543,7 @@ Provide a consolidated summary of the entire session.`;
12447
12543
  if (!client && aiProvider === "Google") throw new Error("AI not initialized");
12448
12544
  const isMemoryEnabled = systemSettings?.memory !== false;
12449
12545
  const originalText = history[history.length - 1].text;
12450
- const summariesFile = path21.join(SECRET_DIR, "chat-summaries.json");
12546
+ const summariesFile = path22.join(SECRET_DIR, "chat-summaries.json");
12451
12547
  let wasCompressedInStream = false;
12452
12548
  const isFirstPrompt = history.filter((m) => m.role === "user").length === 1;
12453
12549
  const hasTitleSignal = originalText.includes("[TITLE-UPDATE]");
@@ -12691,7 +12787,7 @@ Provide a consolidated summary of the entire session.`;
12691
12787
  ];
12692
12788
  const safeReaddirWithTypes = (dir) => {
12693
12789
  try {
12694
- return fs22.readdirSync(dir, { withFileTypes: true });
12790
+ return fs23.readdirSync(dir, { withFileTypes: true });
12695
12791
  } catch (e) {
12696
12792
  return [];
12697
12793
  }
@@ -12704,16 +12800,16 @@ Provide a consolidated summary of the entire session.`;
12704
12800
  if (COLLAPSED_DIRS_GLOBAL.includes(entry.name)) continue;
12705
12801
  if (entry.isDirectory()) {
12706
12802
  currentCount.value++;
12707
- countFolders(path21.join(dir, entry.name), currentCount, depth + 1);
12803
+ countFolders(path22.join(dir, entry.name), currentCount, depth + 1);
12708
12804
  }
12709
12805
  }
12710
12806
  return currentCount.value;
12711
12807
  };
12712
12808
  const getDirTree = (dir, maxDepth, prefix = "", depth = 1) => {
12713
12809
  const entries = safeReaddirWithTypes(dir);
12714
- const sep = path21.sep;
12810
+ const sep = path22.sep;
12715
12811
  if (entries.length > 100) {
12716
- return `${prefix}\u2514\u2500\u2500 ${path21.basename(dir)}${sep} ...100+ files...
12812
+ return `${prefix}\u2514\u2500\u2500 ${path22.basename(dir)}${sep} ...100+ files...
12717
12813
  `;
12718
12814
  }
12719
12815
  let result = "";
@@ -12731,7 +12827,7 @@ Provide a consolidated summary of the entire session.`;
12731
12827
  ];
12732
12828
  finalItems.forEach((item, index) => {
12733
12829
  const isLast = index === finalItems.length - 1;
12734
- const filePath = path21.join(dir, item.name);
12830
+ const filePath = path22.join(dir, item.name);
12735
12831
  const connector = isLast ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ";
12736
12832
  const childPrefix = prefix + (isLast ? " " : "\u2502 ");
12737
12833
  if (item.isCollapsed) {
@@ -12816,10 +12912,10 @@ ${currentSummary}
12816
12912
  if (isBridgeConnected()) {
12817
12913
  ideBlock = "[IDE CONTEXT]\n";
12818
12914
  if (ideCtx.file_focused !== "none") {
12819
- const relFocused = path21.relative(process.cwd(), ideCtx.file_focused);
12915
+ const relFocused = path22.relative(process.cwd(), ideCtx.file_focused);
12820
12916
  const relOpened = (ideCtx.opened_editors || []).map((p) => {
12821
- const rel = path21.relative(process.cwd(), p);
12822
- return rel.startsWith("..") ? `[External] ${path21.basename(p)}` : rel;
12917
+ const rel = path22.relative(process.cwd(), p);
12918
+ return rel.startsWith("..") ? `[External] ${path22.basename(p)}` : rel;
12823
12919
  });
12824
12920
  ideBlock += `Focused File: ${relFocused}
12825
12921
  Cursor Line: ${ideCtx.cursor_line}
@@ -12861,7 +12957,7 @@ Cursor Line: ${ideCtx.cursor_line}
12861
12957
  }
12862
12958
  const getSumForLimit = (limit, activeFiles2) => {
12863
12959
  return activeFiles2.reduce((sum, f) => {
12864
- const isFocused = ideCtx.file_focused && (f.path === ideCtx.file_focused || path21.resolve(process.cwd(), f.path) === path21.resolve(ideCtx.file_focused));
12960
+ const isFocused = ideCtx.file_focused && (f.path === ideCtx.file_focused || path22.resolve(process.cwd(), f.path) === path22.resolve(ideCtx.file_focused));
12865
12961
  const fileLimit = isFocused ? Math.ceil(limit * 1.2) : limit;
12866
12962
  return sum + Math.min(f.edits.length, fileLimit);
12867
12963
  }, 0);
@@ -12895,7 +12991,7 @@ Cursor Line: ${ideCtx.cursor_line}
12895
12991
  }
12896
12992
  }
12897
12993
  for (const file of activeFiles) {
12898
- const isFocused = ideCtx.file_focused && (file.path === ideCtx.file_focused || path21.resolve(process.cwd(), file.path) === path21.resolve(ideCtx.file_focused));
12994
+ const isFocused = ideCtx.file_focused && (file.path === ideCtx.file_focused || path22.resolve(process.cwd(), file.path) === path22.resolve(ideCtx.file_focused));
12899
12995
  const fileLimit = isFocused ? Math.ceil(chosenLimit * 1.2) : chosenLimit;
12900
12996
  if (file.edits.length > fileLimit) {
12901
12997
  file.edits = file.edits.slice(-fileLimit);
@@ -12980,9 +13076,9 @@ ${ideCtx.warnings}
12980
13076
  endLine = matchRange[2] ? parseInt(matchRange[2], 10) : startLine;
12981
13077
  filePath = tagClean.slice(0, matchRange.index);
12982
13078
  }
12983
- const absPath = path21.resolve(process.cwd(), filePath);
12984
- if (fs22.existsSync(absPath)) {
12985
- const stats = fs22.statSync(absPath);
13079
+ const absPath = path22.resolve(process.cwd(), filePath);
13080
+ if (fs23.existsSync(absPath)) {
13081
+ const stats = fs23.statSync(absPath);
12986
13082
  if (stats.isFile()) {
12987
13083
  const pathLower = filePath.toLowerCase();
12988
13084
  const isPdf = pathLower.endsWith(".pdf");
@@ -12991,7 +13087,7 @@ ${ideCtx.warnings}
12991
13087
  const isMultimodalFile = isImage || isPdf || isOfficeFile;
12992
13088
  const isSupported = aiProvider === "Google" || MULTIMODAL_MODELS.includes(modelName);
12993
13089
  if (isMultimodalFile && !isSupported) {
12994
- const label = `\u2718 Unsupported Modality: ${path21.basename(filePath)}`;
13090
+ const label = `\u2718 Unsupported Modality: ${path22.basename(filePath)}`;
12995
13091
  let terminalWidth = 115;
12996
13092
  if (process.stdout.isTTY) {
12997
13093
  terminalWidth = process.stdout.columns - 5 || 120;
@@ -13042,7 +13138,7 @@ ${ideCtx.warnings}
13042
13138
  } else {
13043
13139
  let totalLines = "...";
13044
13140
  try {
13045
- const content = fs22.readFileSync(absPath, "utf8");
13141
+ const content = fs23.readFileSync(absPath, "utf8");
13046
13142
  totalLines = content.split("\n").length;
13047
13143
  } catch (e) {
13048
13144
  }
@@ -13158,6 +13254,7 @@ ${activeSummaryBlock}${thinkingLevel !== "Fast" && thinkingLevel !== "xHigh" &&
13158
13254
  let accumulatedContext = "";
13159
13255
  let dedupeBuffer = "";
13160
13256
  let isDedupeActive = false;
13257
+ let detectedAnyToolCalls = false;
13161
13258
  let targetModel = modelName;
13162
13259
  let currentSystemInstruction = "";
13163
13260
  while (retryCount <= MAX_RETRIES && inStreamRetryCount <= MAX_RETRIES && !success && !TERMINATION_SIGNAL) {
@@ -13245,21 +13342,6 @@ ${activeSummaryBlock}${thinkingLevel !== "Fast" && thinkingLevel !== "xHigh" &&
13245
13342
  throw new Error("Error: Quota Exausted for Agent");
13246
13343
  }
13247
13344
  targetModel = modelName;
13248
- if (aiProvider === "DeepSeek" && thinkingLevel === "Fast" && targetModel.includes("flash")) {
13249
- targetModel = "deepseek-chat";
13250
- }
13251
- if (retryCount === MAX_RETRIES - 1) {
13252
- targetModel = aiProvider === "DeepSeek" ? "deepseek-v4-flash" : "gemini-3-flash-preview";
13253
- yield { type: "model_update", content: "Trying with fallback model" };
13254
- } else if (retryCount === MAX_RETRIES) {
13255
- targetModel = aiProvider === "DeepSeek" ? "deepseek-v4-pro" : "gemini-3.5-flash";
13256
- yield { type: "model_update", content: "Trying with fallback model" };
13257
- } else if (retryCount > 12 && retryCount < MAX_RETRIES - 2 && settings.apiKey !== "custom") {
13258
- targetModel = "gemma-4-31b-it";
13259
- yield { type: "model_update", content: "Trying with fallback Gemma Model" };
13260
- } else if (retryCount > 0) {
13261
- yield { type: "model_update", content: null };
13262
- }
13263
13345
  currentSystemInstruction = getSystemInstruction(profile, !(targetModel || "gemma").toLowerCase().startsWith("gemma") ? thinkingLevel : thinkingLevel, mode, systemSettings, isMemoryEnabled, isFirstPrompt, aiProvider, aiProvider === "Google" ? true : isMultiModal, !(targetModel || "gemma").toLowerCase().startsWith("gemma") ? true : false);
13264
13346
  const lastUserMsg = contents[contents.length - 1];
13265
13347
  if (isBridgeConnected() & loop > 0) {
@@ -13649,6 +13731,7 @@ ${ideErr} [/ERROR]`;
13649
13731
  }
13650
13732
  const toolContext = getActiveToolContext(turnText);
13651
13733
  if (toolContext.inside) {
13734
+ detectedAnyToolCalls = true;
13652
13735
  if (!lastToolEventTime) lastToolEventTime = Date.now();
13653
13736
  const NORMALIZE_MAP = {
13654
13737
  "Ask": "ask",
@@ -13692,7 +13775,7 @@ ${ideErr} [/ERROR]`;
13692
13775
  if (keyword) {
13693
13776
  detail = keyword.replace(/["']/g, "");
13694
13777
  } else if (filePath) {
13695
- detail = path21.basename(filePath.replace(/["']/g, "").replace(/\\/g, "/"));
13778
+ detail = path22.basename(filePath.replace(/["']/g, "").replace(/\\/g, "/"));
13696
13779
  } else if (title && (potentialTool === "invoke" || potentialTool === "invoke_sync")) {
13697
13780
  detail = title.replace(/["']/g, "").substring(0, 30);
13698
13781
  } else if (id && potentialTool === "get_progress") {
@@ -13721,7 +13804,7 @@ ${ideErr} [/ERROR]`;
13721
13804
  if (potentialTool === "invoke" || potentialTool === "invoke_sync" || potentialTool === "get_progress") {
13722
13805
  detail = val.substring(0, 30);
13723
13806
  } else {
13724
- detail = potentialTool === "search_keyword" || potentialTool === "file_map" ? val : path21.basename(val.replace(/\\/g, "/"));
13807
+ detail = potentialTool === "search_keyword" || potentialTool === "file_map" ? val : path22.basename(val.replace(/\\/g, "/"));
13725
13808
  }
13726
13809
  }
13727
13810
  }
@@ -13923,9 +14006,9 @@ ${ideErr} [/ERROR]`;
13923
14006
  let totalLines = "...";
13924
14007
  let actualEndLine = eLine;
13925
14008
  try {
13926
- const absPath = path21.resolve(process.cwd(), targetPath2);
13927
- if (fs22.existsSync(absPath)) {
13928
- const content = fs22.readFileSync(absPath, "utf8");
14009
+ const absPath = path22.resolve(process.cwd(), targetPath2);
14010
+ if (fs23.existsSync(absPath)) {
14011
+ const content = fs23.readFileSync(absPath, "utf8");
13929
14012
  const lines = content.split("\n").length;
13930
14013
  totalLines = lines;
13931
14014
  actualEndLine = Math.min(eLine, lines);
@@ -13945,8 +14028,8 @@ ${ideErr} [/ERROR]`;
13945
14028
  }
13946
14029
  } else if (normToolName === "list_files" || normToolName === "read_folder") {
13947
14030
  const action = normToolName === "list_files" ? "List" : "Browsed";
13948
- const path23 = parseArgs(toolCall.args).path;
13949
- label = `\u2714 ${action}: ${path23 === "." ? "./" : path23}`;
14031
+ const path24 = parseArgs(toolCall.args).path;
14032
+ label = `\u2714 ${action}: ${path24 === "." ? "./" : path24}`;
13950
14033
  } else if (normToolName === "write_file" || normToolName === "update_file") {
13951
14034
  const action = normToolName === "write_file" ? "Created" : "Edited";
13952
14035
  label = `\u2714 ${action}: ${parseArgs(toolCall.args).path || "..."}`;
@@ -14032,7 +14115,7 @@ ${ideErr} [/ERROR]`;
14032
14115
  const { command } = parseArgs(toolCall.args);
14033
14116
  if (command && settings.systemSettings && settings.systemSettings.allowExternalAccess === false) {
14034
14117
  const riskyPatterns = [/[a-zA-Z]:[\\\/]/i, /^\//, /\.\.[\\\/]/, /\/etc\//, /\/var\//, /\/root\//, /\/bin\//, /\/usr\//];
14035
- const currentDrive = path21.resolve(process.cwd()).substring(0, 3).toLowerCase();
14118
+ const currentDrive = path22.resolve(process.cwd()).substring(0, 3).toLowerCase();
14036
14119
  const splitCommands = (cmdString) => {
14037
14120
  const commands = [];
14038
14121
  let current = "";
@@ -14161,8 +14244,8 @@ ${ideErr} [/ERROR]`;
14161
14244
  const targetPath = parsedArgs.path || parsedArgs.targetPath || null;
14162
14245
  if (targetPath) {
14163
14246
  const isExternalOff = settings.systemSettings && settings.systemSettings.allowExternalAccess === false;
14164
- const absoluteTarget = path21.resolve(targetPath);
14165
- const absoluteCwd = path21.resolve(process.cwd());
14247
+ const absoluteTarget = path22.resolve(targetPath);
14248
+ const absoluteCwd = path22.resolve(process.cwd());
14166
14249
  if (isExternalOff && !absoluteTarget.startsWith(absoluteCwd)) {
14167
14250
  const denyMsg = `Access Denied. You are not allowed to access files outside the current workspace.`;
14168
14251
  if (normToolName === "write_file" || normToolName === "update_file") {
@@ -14351,7 +14434,7 @@ ${boxMid}`) };
14351
14434
  const toolArgs = parseArgs(toolCall.args);
14352
14435
  const { path: filePath } = toolArgs;
14353
14436
  if (filePath) {
14354
- const absPath = path21.resolve(process.cwd(), filePath);
14437
+ const absPath = path22.resolve(process.cwd(), filePath);
14355
14438
  const normalize2 = (p) => p ? p.toLowerCase().replace(/\\/g, "/").replace(/^[a-z]:/, (m) => m.toUpperCase()) : "";
14356
14439
  const normAbsPath = normalize2(absPath);
14357
14440
  let originalContent = "";
@@ -14361,8 +14444,8 @@ ${boxMid}`) };
14361
14444
  if (currentIDE && normFocused === normAbsPath && currentIDE.full_content) {
14362
14445
  originalContent = currentIDE.full_content;
14363
14446
  hasOriginal = true;
14364
- } else if (fs22.existsSync(absPath)) {
14365
- originalContent = fs22.readFileSync(absPath, "utf8");
14447
+ } else if (fs23.existsSync(absPath)) {
14448
+ originalContent = fs23.readFileSync(absPath, "utf8");
14366
14449
  hasOriginal = true;
14367
14450
  }
14368
14451
  originalContentForReporting = originalContent;
@@ -14389,9 +14472,9 @@ ${boxMid}`) };
14389
14472
  const successes = patchResults.filter((r) => r.success);
14390
14473
  const failures = patchResults.filter((r) => !r.success);
14391
14474
  if (successes.length === 0) {
14392
- const errorMsg = `[TOOL RESULT]: ERROR: Failed to apply patches to [${path21.basename(absPath)}].
14475
+ const errorMsg = `[TOOL RESULT]: ERROR: Failed to apply patches to [${path22.basename(absPath)}].
14393
14476
  ${failures.map((f) => ` \u2022 ${f.error}`).join("\n")}`;
14394
- const errorLabel = `\u2714 Edited: ${path21.basename(absPath)}`.toUpperCase();
14477
+ const errorLabel = `\u2714 Edited: ${path22.basename(absPath)}`.toUpperCase();
14395
14478
  let terminalWidth = 115;
14396
14479
  if (process.stdout.isTTY) {
14397
14480
  terminalWidth = process.stdout.columns - 5 || 120;
@@ -14409,19 +14492,19 @@ ${boxMid}}`) };
14409
14492
  continue;
14410
14493
  }
14411
14494
  }
14412
- yield { type: "status", content: `Opening Diff in IDE: ${path21.basename(absPath)}` };
14495
+ yield { type: "status", content: `Opening Diff in IDE: ${path22.basename(absPath)}` };
14413
14496
  showDiffInIDE(absPath, originalContent, modifiedContent);
14414
14497
  diffOpened = true;
14415
14498
  await new Promise((r) => setTimeout(r, 50));
14416
14499
  } else if (normToolName === "write_file") {
14417
14500
  const rawContent = toolArgs.content || toolArgs.newContent || "";
14418
14501
  const modifiedContent = rawContent.endsWith("\n") ? rawContent : rawContent + "\n";
14419
- if (!fs22.existsSync(absPath)) {
14502
+ if (!fs23.existsSync(absPath)) {
14420
14503
  isNewFileCreated = true;
14421
- fs22.mkdirSync(path21.dirname(absPath), { recursive: true });
14422
- fs22.writeFileSync(absPath, "", "utf8");
14504
+ fs23.mkdirSync(path22.dirname(absPath), { recursive: true });
14505
+ fs23.writeFileSync(absPath, "", "utf8");
14423
14506
  }
14424
- yield { type: "status", content: `Opening New File Diff in IDE: ${path21.basename(absPath)}` };
14507
+ yield { type: "status", content: `Opening New File Diff in IDE: ${path22.basename(absPath)}` };
14425
14508
  showDiffInIDE(absPath, "", modifiedContent);
14426
14509
  diffOpened = true;
14427
14510
  await new Promise((r) => setTimeout(r, 50));
@@ -14457,11 +14540,11 @@ ${boxMid}}`) };
14457
14540
  if (normToolName === "write_file" || normToolName === "update_file") {
14458
14541
  const { path: filePath } = parseArgs(toolCall.args);
14459
14542
  if (filePath) {
14460
- const absPath = path21.resolve(process.cwd(), filePath);
14543
+ const absPath = path22.resolve(process.cwd(), filePath);
14461
14544
  closeDiffInIDE(absPath, approval);
14462
- if (approval === "deny" && isNewFileCreated && fs22.existsSync(absPath)) {
14545
+ if (approval === "deny" && isNewFileCreated && fs23.existsSync(absPath)) {
14463
14546
  try {
14464
- fs22.unlinkSync(absPath);
14547
+ fs23.unlinkSync(absPath);
14465
14548
  } catch (e) {
14466
14549
  }
14467
14550
  }
@@ -14473,13 +14556,13 @@ ${boxMid}}`) };
14473
14556
  }
14474
14557
  if (approval === "allow" && diffOpened && isBridgeConnected()) {
14475
14558
  const { path: filePath } = parseArgs(toolCall.args);
14476
- const absPath = path21.resolve(process.cwd(), filePath);
14559
+ const absPath = path22.resolve(process.cwd(), filePath);
14477
14560
  const finalIDE = await getIDEContext();
14478
14561
  let finalContent = "";
14479
14562
  if (finalIDE && finalIDE.file_focused === absPath && finalIDE.full_content) {
14480
14563
  finalContent = finalIDE.full_content;
14481
- } else if (fs22.existsSync(absPath)) {
14482
- finalContent = fs22.readFileSync(absPath, "utf8");
14564
+ } else if (fs23.existsSync(absPath)) {
14565
+ finalContent = fs23.readFileSync(absPath, "utf8");
14483
14566
  }
14484
14567
  const verifiedLines = finalContent.split(/\r?\n/);
14485
14568
  const verifiedLineCount = verifiedLines.length;
@@ -14647,7 +14730,7 @@ ${boxMid}`) };
14647
14730
  try {
14648
14731
  const { path: filePath } = parseArgs(toolCall.args);
14649
14732
  if (filePath) {
14650
- const absPath = path21.resolve(process.cwd(), filePath);
14733
+ const absPath = path22.resolve(process.cwd(), filePath);
14651
14734
  const currentIDE = await getIDEContext();
14652
14735
  if (currentIDE && currentIDE.file_focused === absPath && currentIDE.full_content) {
14653
14736
  execToolContext.forcedContent = currentIDE.full_content;
@@ -14662,7 +14745,7 @@ ${boxMid}`) };
14662
14745
  if ((normToolName === "write_file" || normToolName === "update_file") && result.startsWith("SUCCESS")) {
14663
14746
  const { path: filePath } = parseArgs(toolCall.args);
14664
14747
  if (filePath) {
14665
- const absPath = path21.resolve(process.cwd(), filePath);
14748
+ const absPath = path22.resolve(process.cwd(), filePath);
14666
14749
  openFileInEditor(absPath);
14667
14750
  }
14668
14751
  }
@@ -14925,9 +15008,9 @@ ${boxMid}`) };
14925
15008
  })() : String(err);
14926
15009
  ;
14927
15010
  const date = (/* @__PURE__ */ new Date()).toLocaleString();
14928
- const agentErrDir = path21.join(LOGS_DIR, "agent");
14929
- if (!fs22.existsSync(agentErrDir)) fs22.mkdirSync(agentErrDir, { recursive: true });
14930
- fs22.appendFileSync(path21.join(agentErrDir, "error.log"), `ERROR [${date}]: ${errLog}
15011
+ const agentErrDir = path22.join(LOGS_DIR, "agent");
15012
+ if (!fs23.existsSync(agentErrDir)) fs23.mkdirSync(agentErrDir, { recursive: true });
15013
+ fs23.appendFileSync(path22.join(agentErrDir, "error.log"), `ERROR [${date}]: ${errLog}
14931
15014
 
14932
15015
  ----------------------------------------------------------------------
14933
15016
 
@@ -14974,7 +15057,7 @@ ${recoveryText}`
14974
15057
  yield { type: "status", content: `Error Occured. Recovering Stream...` };
14975
15058
  } else {
14976
15059
  throw new Error(`Stream collapsed too many times. (Failed to resolve ${MAX_RETRIES} times)
14977
- Error Log can be found in ${path21.join(LOGS_DIR, "agent", "error.log")}`);
15060
+ Error Log can be found in ${path22.join(LOGS_DIR, "agent", "error.log")}`);
14978
15061
  }
14979
15062
  } else {
14980
15063
  if (retryCount <= MAX_RETRIES) {
@@ -14992,7 +15075,7 @@ Error Log can be found in ${path21.join(LOGS_DIR, "agent", "error.log")}`);
14992
15075
  yield { type: "status", content: `Trying to reach ${modelName}` };
14993
15076
  } else {
14994
15077
  throw new Error(`Model ${modelName} cannot be reached. (Failed ${MAX_RETRIES} times)
14995
- Error Log can be found in ${path21.join(LOGS_DIR, "agent", "error.log")}`);
15078
+ Error Log can be found in ${path22.join(LOGS_DIR, "agent", "error.log")}`);
14996
15079
  }
14997
15080
  }
14998
15081
  }
@@ -15024,6 +15107,7 @@ Error Log can be found in ${path21.join(LOGS_DIR, "agent", "error.log")}`);
15024
15107
  const cleanedTurnText = contextSafeReplace(turnText, /(\[\s*(turn\s*:)?\s*(continue|finish)\s*\]|\[\[END\]\])/gi, "").trim();
15025
15108
  let isActuallyFinished = (hasFinish || toolResults.length === 0) && !isThinkingLoop && !isStutteringLoop && !isGeneralLoop;
15026
15109
  isActuallyFinished = toolResults.length === 0 ? isActuallyFinished : false;
15110
+ isActuallyFinished = detectedAnyToolCalls || wasToolCalledInLastLoop ? false : isActuallyFinished;
15027
15111
  if (turnText && turnText.trim().endsWith('")]') && toolResults.length === 0) {
15028
15112
  isActuallyFinished = false;
15029
15113
  }
@@ -15051,13 +15135,20 @@ Error Log can be found in ${path21.join(LOGS_DIR, "agent", "error.log")}`);
15051
15135
  modifiedHistory.push({ role: "agent", text: nextAgentMsg });
15052
15136
  if (toolResults.length > 0 || anyToolExecutedInThisTurn) {
15053
15137
  if (toolResults.length > 0) {
15054
- const combinedText = toolResults.map((tr) => tr.text).join("\n\n");
15138
+ let combinedText = toolResults.map((tr) => tr.text).join("\n\n");
15139
+ const toolActionableText = turnText.replace(/(?:<(think|thought|thoughts)>|\[(think|thought|thoughts)\])[\s\S]*?(?:<\/(think|thought|thoughts)>|\[\/(think|thought|thoughts)\]|$)/gi, "");
15140
+ const attemptedToolsCount = (toolActionableText.match(/\[tool:functions/g) || []).length;
15141
+ if (toolResults.length < attemptedToolsCount) {
15142
+ combinedText += `
15143
+
15144
+ [SYSTEM] Only ${toolResults.length} out of ${attemptedToolsCount} attempted tool calls were executed. Verify proper syntax compliance & try failed calls again [/SYSTEM]`;
15145
+ }
15055
15146
  const binaryPart = toolResults.find((tr) => tr.binaryPart)?.binaryPart || null;
15056
15147
  modifiedHistory.push({ role: "user", text: combinedText, binaryPart });
15057
15148
  }
15058
15149
  } else {
15059
- if (wasToolCalledInLastLoop) {
15060
- modifiedHistory.push({ role: "user", text: `[SYSTEM] Failed to verify tool execution, MUST check if executed or failed. On failure try again [/SYSTEM]` });
15150
+ if (wasToolCalledInLastLoop || detectedAnyToolCalls) {
15151
+ modifiedHistory.push({ role: "user", text: `[SYSTEM] Failed to execute some tools. Verify proper syntax compliance & try again [/SYSTEM]` });
15061
15152
  } else {
15062
15153
  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 execution/output" : "If you have finished your task use [[END]]"}`} [/SYSTEM]` });
15063
15154
  }
@@ -15098,10 +15189,10 @@ Error Log can be found in ${path21.join(LOGS_DIR, "agent", "error.log")}`);
15098
15189
  }
15099
15190
  })() : String(err);
15100
15191
  const date = (/* @__PURE__ */ new Date()).toLocaleString();
15101
- const agentErrDir = path21.join(LOGS_DIR, "agent");
15192
+ const agentErrDir = path22.join(LOGS_DIR, "agent");
15102
15193
  yield { type: "text", content: `\u274C CRITICAL ERROR: ${errLog}` };
15103
- if (!fs22.existsSync(agentErrDir)) fs22.mkdirSync(agentErrDir, { recursive: true });
15104
- fs22.appendFileSync(path21.join(agentErrDir, "error.log"), `CRITICAL ERROR [${date}]: ${err}
15194
+ if (!fs23.existsSync(agentErrDir)) fs23.mkdirSync(agentErrDir, { recursive: true });
15195
+ fs23.appendFileSync(path22.join(agentErrDir, "error.log"), `CRITICAL ERROR [${date}]: ${err}
15105
15196
 
15106
15197
  ----------------------------------------------------------------------
15107
15198
 
@@ -15243,20 +15334,20 @@ ${cleanResponse}
15243
15334
  } else if (normalizedToolName === "web_scrape" || normalizedToolName === "webscrape") {
15244
15335
  label = `\u2714 \x1B[95mScraped\x1B[0m`;
15245
15336
  } else if (normalizedToolName === "view_file" || normalizedToolName === "viewfile" || normalizedToolName === "readfile") {
15246
- const path23 = parseArgs(toolCall.args).path || "";
15247
- label = `\u2714 \x1B[95mRead File\x1B[0m: ${path23}`;
15337
+ const path24 = parseArgs(toolCall.args).path || "";
15338
+ label = `\u2714 \x1B[95mRead File\x1B[0m: ${path24}`;
15248
15339
  } else if (normalizedToolName === "list_files" || normalizedToolName === "read_folder" || normalizedToolName === "readfolder") {
15249
- const path23 = parseArgs(toolCall.args).path || "";
15250
- label = `\u2714 \x1B[95mBrowsed Folder\x1B[0m: ${path23}`;
15340
+ const path24 = parseArgs(toolCall.args).path || "";
15341
+ label = `\u2714 \x1B[95mBrowsed Folder\x1B[0m: ${path24}`;
15251
15342
  } else if (normalizedToolName === "write_file" || normalizedToolName === "writefile") {
15252
- const path23 = parseArgs(toolCall.args).path || "";
15253
- label = `\u2714 \x1B[95mFile Created\x1B[0m: ${path23}`;
15343
+ const path24 = parseArgs(toolCall.args).path || "";
15344
+ label = `\u2714 \x1B[95mFile Created\x1B[0m: ${path24}`;
15254
15345
  } else if (normalizedToolName === "update_file" || normalizedToolName === "updatefile" || normalizedToolName === "patchfile" || normalizedToolName === "patch_file" || normalizedToolName === "patchfile" || normalizedToolName === "updatefile") {
15255
- const path23 = parseArgs(toolCall.args).path || "";
15256
- label = `\u2714 \x1B[95mFile Edited\x1B[0m: ${path23}`;
15346
+ const path24 = parseArgs(toolCall.args).path || "";
15347
+ label = `\u2714 \x1B[95mFile Edited\x1B[0m: ${path24}`;
15257
15348
  } else if (normalizedToolName === "file_map" || normalizedToolName === "filemap") {
15258
- const path23 = parseArgs(toolCall.args).path || "";
15259
- label = `\u2714 \x1B[95mIndexed\x1B[0m: ${path23}`;
15349
+ const path24 = parseArgs(toolCall.args).path || "";
15350
+ label = `\u2714 \x1B[95mIndexed\x1B[0m: ${path24}`;
15260
15351
  } else if (normalizedToolName === "await") {
15261
15352
  const { time } = parseArgs(toolCall.args);
15262
15353
  let sec = parseFloat(time) || 0;
@@ -16171,7 +16262,7 @@ var init_RevertModal = __esm({
16171
16262
  import puppeteer4 from "puppeteer";
16172
16263
  import { exec } from "child_process";
16173
16264
  import { promisify } from "util";
16174
- import fs23 from "fs";
16265
+ import fs24 from "fs";
16175
16266
  var execAsync, checkPuppeteerReady, installPuppeteerBrowser;
16176
16267
  var init_setup = __esm({
16177
16268
  "src/utils/setup.js"() {
@@ -16180,11 +16271,11 @@ var init_setup = __esm({
16180
16271
  checkPuppeteerReady = () => {
16181
16272
  try {
16182
16273
  const pptrConfig = getPuppeteerConfig();
16183
- if (pptrConfig.executablePath && fs23.existsSync(pptrConfig.executablePath)) {
16274
+ if (pptrConfig.executablePath && fs24.existsSync(pptrConfig.executablePath)) {
16184
16275
  return true;
16185
16276
  }
16186
16277
  const exePath = puppeteer4.executablePath();
16187
- const exists = exePath && fs23.existsSync(exePath);
16278
+ const exists = exePath && fs24.existsSync(exePath);
16188
16279
  if (exists) return true;
16189
16280
  } catch (e) {
16190
16281
  return false;
@@ -16271,10 +16362,10 @@ __export(app_exports, {
16271
16362
  import os5 from "os";
16272
16363
  import React16, { useState as useState15, useEffect as useEffect12, useRef as useRef4, useMemo as useMemo2 } from "react";
16273
16364
  import { Box as Box14, Text as Text16, useInput as useInput9, useStdout as useStdout2, Static } from "ink";
16274
- import fs24 from "fs-extra";
16275
- import path22 from "path";
16365
+ import fs25 from "fs-extra";
16366
+ import path23 from "path";
16276
16367
  import { exec as exec2 } from "child_process";
16277
- import { fileURLToPath as fileURLToPath2 } from "url";
16368
+ import { fileURLToPath as fileURLToPath3 } from "url";
16278
16369
  import TextInput4 from "ink-text-input";
16279
16370
  import SelectInput2 from "ink-select-input";
16280
16371
  import gradient2 from "gradient-string";
@@ -16581,8 +16672,8 @@ function App({ args = [] }) {
16581
16672
  const [setupStep, setSetupStep] = useState15(0);
16582
16673
  const [latestVer, setLatestVer] = useState15(null);
16583
16674
  const [showFullThinking, setShowFullThinking] = useState15(false);
16584
- const [activeModel, setActiveModel] = useState15("gemma-4-31b-it");
16585
- const [janitorModel, setJanitorModel] = useState15("gemma-4-26b-a4b-it");
16675
+ const [activeModel, setActiveModel] = useState15(getDefaultModel("Google", "Free") || "gemma-4-31b-it");
16676
+ const [janitorModel, setJanitorModel] = useState15(getFallbackValue("gemma_janitor_fallback_google") || "gemma-4-26b-a4b-it");
16586
16677
  const [isInitializing, setIsInitializing] = useState15(true);
16587
16678
  const [isAppFocused, setIsAppFocused] = useState15(true);
16588
16679
  const lastFocusEventTime = useRef4(0);
@@ -16592,10 +16683,10 @@ function App({ args = [] }) {
16592
16683
  const kbPath = getKeybindingsPath(ideName);
16593
16684
  if (!kbPath) return;
16594
16685
  try {
16595
- await fs24.ensureDir(path22.dirname(kbPath));
16686
+ await fs25.ensureDir(path23.dirname(kbPath));
16596
16687
  let bindings = [];
16597
- if (fs24.existsSync(kbPath)) {
16598
- const content = fs24.readFileSync(kbPath, "utf8").trim();
16688
+ if (fs25.existsSync(kbPath)) {
16689
+ const content = fs25.readFileSync(kbPath, "utf8").trim();
16599
16690
  if (content) {
16600
16691
  try {
16601
16692
  bindings = parseJsonc(content);
@@ -16615,7 +16706,7 @@ function App({ args = [] }) {
16615
16706
  },
16616
16707
  "when": "terminalFocus"
16617
16708
  });
16618
- fs24.writeFileSync(kbPath, JSON.stringify(bindings, null, 4), "utf8");
16709
+ fs25.writeFileSync(kbPath, JSON.stringify(bindings, null, 4), "utf8");
16619
16710
  cachedShortcut = "Shift + Enter";
16620
16711
  setMessages((prev) => {
16621
16712
  setCompletedIndex(prev.length + 1);
@@ -16736,37 +16827,14 @@ function App({ args = [] }) {
16736
16827
  if (isThirdRender.current) {
16737
16828
  return;
16738
16829
  }
16739
- const s = emojiSpace(2);
16740
- let defaultModel = "";
16741
- let modelDisplayName = "";
16742
- if (apiTier === "Free") {
16743
- if (aiProvider === "Google") {
16744
- defaultModel = "gemma-4-31b-it";
16745
- modelDisplayName = "Gemma 4 (Free default)";
16746
- } else if (aiProvider === "DeepSeek") {
16747
- defaultModel = "deepseek-v4-flash";
16748
- modelDisplayName = "DeepSeek Flash (Free default)";
16749
- } else if (aiProvider === "NVIDIA") {
16750
- defaultModel = "deepseek-ai/deepseek-v4-flash";
16751
- modelDisplayName = "DeepSeek V4 Flash (NVIDIA)";
16752
- } else {
16753
- defaultModel = "google/gemma-4-31b-it:free";
16754
- modelDisplayName = "Gemma 4 (Free default)";
16755
- }
16756
- } else {
16757
- if (aiProvider === "Google") {
16758
- defaultModel = "gemini-3-flash-preview";
16759
- modelDisplayName = "Gemini 3 Flash";
16760
- } else if (aiProvider === "DeepSeek") {
16761
- defaultModel = "deepseek-v4-flash";
16762
- modelDisplayName = "DeepSeek Flash";
16763
- } else if (aiProvider === "NVIDIA") {
16764
- defaultModel = "deepseek-ai/deepseek-v4-flash";
16765
- modelDisplayName = "DeepSeek V4 Flash (NVIDIA)";
16766
- } else {
16767
- defaultModel = "deepseek/deepseek-v4-flash";
16768
- modelDisplayName = "DeepSeek Flash";
16769
- }
16830
+ const defaultModel = getDefaultModel(aiProvider, apiTier);
16831
+ let modelDisplayName = defaultModel;
16832
+ if (defaultModel.includes("gemma")) {
16833
+ modelDisplayName = "Gemma";
16834
+ } else if (defaultModel.includes("deepseek")) {
16835
+ modelDisplayName = "DeepSeek Flash";
16836
+ } else if (defaultModel.includes("gemini")) {
16837
+ modelDisplayName = "Gemini Flash";
16770
16838
  }
16771
16839
  setActiveModel(defaultModel);
16772
16840
  saveSettings({ apiTier, activeModel: defaultModel });
@@ -17239,11 +17307,39 @@ function App({ args = [] }) {
17239
17307
  }
17240
17308
  if (suggestions.length > 0 && activeView === "chat") {
17241
17309
  if (key.upArrow) {
17242
- setSelectedIndex((prev) => prev > 0 ? prev - 1 : suggestions.length - 1);
17310
+ setSelectedIndex((prev) => {
17311
+ let nextIdx = prev > 0 ? prev - 1 : suggestions.length - 1;
17312
+ let loops = 0;
17313
+ while (nextIdx !== prev && loops < suggestions.length) {
17314
+ const sug = suggestions[nextIdx];
17315
+ const cmdName = sug?.cmd || sug || "";
17316
+ if (typeof cmdName === "string" && cmdName.trimStart().startsWith("---")) {
17317
+ nextIdx = nextIdx > 0 ? nextIdx - 1 : suggestions.length - 1;
17318
+ loops++;
17319
+ } else {
17320
+ break;
17321
+ }
17322
+ }
17323
+ return nextIdx;
17324
+ });
17243
17325
  return;
17244
17326
  }
17245
17327
  if (key.downArrow) {
17246
- setSelectedIndex((prev) => prev < suggestions.length - 1 ? prev + 1 : 0);
17328
+ setSelectedIndex((prev) => {
17329
+ let nextIdx = prev < suggestions.length - 1 ? prev + 1 : 0;
17330
+ let loops = 0;
17331
+ while (nextIdx !== prev && loops < suggestions.length) {
17332
+ const sug = suggestions[nextIdx];
17333
+ const cmdName = sug?.cmd || sug || "";
17334
+ if (typeof cmdName === "string" && cmdName.trimStart().startsWith("---")) {
17335
+ nextIdx = nextIdx < suggestions.length - 1 ? nextIdx + 1 : 0;
17336
+ loops++;
17337
+ } else {
17338
+ break;
17339
+ }
17340
+ }
17341
+ return nextIdx;
17342
+ });
17247
17343
  return;
17248
17344
  }
17249
17345
  if (key.return) {
@@ -17294,7 +17390,7 @@ function App({ args = [] }) {
17294
17390
  useEffect12(() => {
17295
17391
  async function init() {
17296
17392
  try {
17297
- const pkg = JSON.parse(fs24.readFileSync(path22.join(process.cwd(), "package.json"), "utf8"));
17393
+ const pkg = JSON.parse(fs25.readFileSync(path23.join(process.cwd(), "package.json"), "utf8"));
17298
17394
  initBridge(versionFluxflow || pkg.version || "2.0.0");
17299
17395
  } catch (e) {
17300
17396
  initBridge("2.0.0");
@@ -17314,6 +17410,7 @@ function App({ args = [] }) {
17314
17410
  return [...prev, { id: "setup-done-" + Date.now(), role: "system", text: "[SYSTEM] All dependencies installed successfully.", isMeta: true }];
17315
17411
  });
17316
17412
  }
17413
+ await loadRemoteModelConfig();
17317
17414
  const saved = await loadSettings();
17318
17415
  originalAllowExternalAccessRef.current = saved.systemSettings?.allowExternalAccess ?? false;
17319
17416
  originalMemoryRef.current = saved.systemSettings?.memory ?? true;
@@ -17335,28 +17432,7 @@ function App({ args = [] }) {
17335
17432
  if (parsedArgs.model) {
17336
17433
  setActiveModel(parsedArgs.model);
17337
17434
  } else if (parsedArgs.provider) {
17338
- let defaultModel = "";
17339
- if (currentTier === "Free") {
17340
- if (startupProvider === "Google") {
17341
- defaultModel = "gemma-4-31b-it";
17342
- } else if (startupProvider === "DeepSeek") {
17343
- defaultModel = "deepseek-v4-flash";
17344
- } else if (startupProvider === "OpenRouter") {
17345
- defaultModel = "google/gemma-4-31b-it:free";
17346
- } else if (startupProvider === "NVIDIA") {
17347
- defaultModel = "deepseek-ai/deepseek-v4-flash";
17348
- }
17349
- } else {
17350
- if (startupProvider === "Google") {
17351
- defaultModel = "gemini-3-flash-preview";
17352
- } else if (startupProvider === "DeepSeek") {
17353
- defaultModel = "deepseek-v4-flash";
17354
- } else if (startupProvider === "OpenRouter") {
17355
- defaultModel = "deepseek/deepseek-v4-flash";
17356
- } else if (startupProvider === "NVIDIA") {
17357
- defaultModel = "deepseek-ai/deepseek-v4-flash";
17358
- }
17359
- }
17435
+ const defaultModel = getDefaultModel(startupProvider, currentTier);
17360
17436
  setActiveModel(defaultModel);
17361
17437
  } else {
17362
17438
  setActiveModel(saved.activeModel);
@@ -17417,7 +17493,7 @@ function App({ args = [] }) {
17417
17493
  if (!parsedArgs.playground) {
17418
17494
  deleteChat(PLAYGROUND_CHAT_ID).catch(() => {
17419
17495
  });
17420
- fs24.remove(path22.join(DATA_DIR, "playground")).catch(() => {
17496
+ fs25.remove(path23.join(DATA_DIR, "playground")).catch(() => {
17421
17497
  });
17422
17498
  }
17423
17499
  performVersionCheck(false, freshSettings);
@@ -17451,9 +17527,9 @@ function App({ args = [] }) {
17451
17527
  }
17452
17528
  }
17453
17529
  if (parsedArgs.playground) {
17454
- const playgroundDir = path22.join(DATA_DIR, "playground");
17530
+ const playgroundDir = path23.join(DATA_DIR, "playground");
17455
17531
  try {
17456
- fs24.ensureDirSync(playgroundDir);
17532
+ fs25.ensureDirSync(playgroundDir);
17457
17533
  process.chdir(playgroundDir);
17458
17534
  } catch (e) {
17459
17535
  }
@@ -17494,8 +17570,8 @@ function App({ args = [] }) {
17494
17570
  if (kbPath) {
17495
17571
  try {
17496
17572
  let bindings = [];
17497
- if (fs24.existsSync(kbPath)) {
17498
- const content = fs24.readFileSync(kbPath, "utf8").trim();
17573
+ if (fs25.existsSync(kbPath)) {
17574
+ const content = fs25.readFileSync(kbPath, "utf8").trim();
17499
17575
  if (content) {
17500
17576
  bindings = parseJsonc(content);
17501
17577
  }
@@ -17659,211 +17735,7 @@ function App({ args = [] }) {
17659
17735
  {
17660
17736
  cmd: "/model",
17661
17737
  desc: "Select Agent Model",
17662
- subs: aiProvider === "OpenRouter" ? apiTier === "Free" ? [
17663
- {
17664
- cmd: "google/gemma-4-31b-it:free",
17665
- desc: "Multimodal"
17666
- },
17667
- {
17668
- cmd: "moonshotai/kimi-k2.6:free",
17669
- desc: "Multimodal"
17670
- },
17671
- {
17672
- cmd: "qwen/qwen3-coder:free",
17673
- desc: "Text Only"
17674
- },
17675
- {
17676
- cmd: "z-ai/glm-4.5-air:free",
17677
- desc: "Text Only"
17678
- }
17679
- ] : [
17680
- {
17681
- cmd: "google/gemini-3.5-flash",
17682
- desc: "Multimodal"
17683
- },
17684
- {
17685
- cmd: "qwen/qwen3.7-plus",
17686
- desc: "Multimodal"
17687
- },
17688
- {
17689
- cmd: "minimax/minimax-m3",
17690
- desc: "Multimodal"
17691
- },
17692
- {
17693
- cmd: "anthropic/claude-sonnet-4.5",
17694
- desc: "Multimodal"
17695
- },
17696
- {
17697
- cmd: "anthropic/claude-opus-4.6",
17698
- desc: "Multimodal"
17699
- },
17700
- {
17701
- cmd: "anthropic/claude-opus-4.8",
17702
- desc: "Multimodal"
17703
- },
17704
- {
17705
- cmd: "deepseek/deepseek-v4-pro",
17706
- desc: "Text Only"
17707
- },
17708
- {
17709
- cmd: "deepseek/deepseek-v4-flash",
17710
- desc: "Text Only"
17711
- },
17712
- {
17713
- cmd: "xiaomi/mimo-v2.5-pro",
17714
- desc: "Text Only"
17715
- },
17716
- {
17717
- cmd: "z-ai/glm-5",
17718
- desc: "Text Only"
17719
- },
17720
- {
17721
- cmd: "openai/gpt-5.2-codex",
17722
- desc: "Multimodal"
17723
- },
17724
- {
17725
- cmd: "openai/gpt-5.2-pro",
17726
- desc: "Multimodal"
17727
- },
17728
- {
17729
- cmd: "openai/gpt-5.5-pro",
17730
- desc: "Multimodal"
17731
- },
17732
- {
17733
- cmd: "moonshotai/kimi-k2.6",
17734
- desc: "Multimodal"
17735
- }
17736
- ] : aiProvider === "DeepSeek" ? [
17737
- {
17738
- cmd: "deepseek-v4-flash",
17739
- desc: "Fast & Efficient (Text Only)"
17740
- },
17741
- {
17742
- cmd: "deepseek-v4-pro",
17743
- desc: "High-Intelligence Reasoning (Text Only)"
17744
- }
17745
- ] : aiProvider === "NVIDIA" ? [
17746
- // --- Kimi (Moonshot AI) ---
17747
- {
17748
- cmd: "moonshotai/kimi-k2.7",
17749
- desc: "Multimodal"
17750
- },
17751
- // --- DeepSeek Family ---
17752
- {
17753
- cmd: "deepseek-ai/deepseek-v4-flash",
17754
- desc: "Text Only"
17755
- },
17756
- {
17757
- cmd: "deepseek-ai/deepseek-v4-pro",
17758
- desc: "Text Only"
17759
- },
17760
- // --- StepFun ---
17761
- {
17762
- cmd: "stepfun-ai/step-3.7-flash",
17763
- desc: "Multimodal"
17764
- },
17765
- // --- Gemma Family (Google) ---
17766
- {
17767
- cmd: "google/gemma-4-31b-it",
17768
- desc: "Multimodal"
17769
- },
17770
- {
17771
- cmd: "google/diffusiongemma-26b-a4b-it",
17772
- desc: "Mega Fast [Experimental]"
17773
- },
17774
- // --- Mistral ---
17775
- {
17776
- cmd: "mistralai/mistral-medium-3.5-128b",
17777
- desc: "Multimodal"
17778
- },
17779
- // --- GPT Open Source Series (OpenAI) ---
17780
- {
17781
- cmd: "openai/gpt-oss-20b",
17782
- desc: "Text Only"
17783
- },
17784
- {
17785
- cmd: "openai/gpt-oss-120b",
17786
- desc: "Text Only"
17787
- },
17788
- // --- GLM (Zhipu AI) ---
17789
- {
17790
- cmd: "z-ai/glm-5.2",
17791
- desc: "Text Only"
17792
- },
17793
- // --- MiniMax Family ---
17794
- {
17795
- cmd: "minimaxai/minimax-m2.7",
17796
- desc: "Text Only"
17797
- },
17798
- {
17799
- cmd: "minimaxai/minimax-m3",
17800
- desc: "Text Only"
17801
- },
17802
- // QWEN
17803
- {
17804
- cmd: "qwen/qwen3.5-397b-a17b",
17805
- desc: "Multimodal"
17806
- },
17807
- // NVIDIA NEMOTRON
17808
- {
17809
- cmd: "nvidia/nemotron-3-ultra-550b-a55b",
17810
- desc: "Text Only [EXPERIMENTAL]"
17811
- }
17812
- ] : apiTier === "Free" ? [
17813
- {
17814
- cmd: "gemma-4-26b-a4b-it",
17815
- desc: "Standard & Faster (Multimodal)"
17816
- },
17817
- {
17818
- cmd: "gemma-4-31b-it",
17819
- desc: "Standard Default (Multimodal)"
17820
- },
17821
- {
17822
- cmd: "gemini-2.5-flash-lite",
17823
- desc: "Fast & Cheap (Multimodal) [Limited Free Quota]"
17824
- },
17825
- {
17826
- cmd: "gemini-2.5-flash",
17827
- desc: "Fast & Reliable (Multimodal) [Limited Free Quota]"
17828
- },
17829
- {
17830
- cmd: "gemini-3-flash-preview",
17831
- desc: "Fast & Lightweight (Multimodal) [Limited Free Quota]"
17832
- },
17833
- {
17834
- cmd: "gemini-3.5-flash",
17835
- desc: "Flash Latest (Multimodal) [Limited Free Quota] Instability Issues"
17836
- }
17837
- ] : [
17838
- {
17839
- cmd: "gemini-2.5-flash-lite",
17840
- desc: "Fast & Cheap (Multimodal)"
17841
- },
17842
- {
17843
- cmd: "gemini-2.5-flash",
17844
- desc: "Fast & Reliable (Multimodal)"
17845
- },
17846
- {
17847
- cmd: "gemini-2.5-pro",
17848
- desc: "Last gen Pro reasoning (Multimodal)"
17849
- },
17850
- {
17851
- cmd: "gemini-3.1-flash-lite",
17852
- desc: "Ultra-Fast & Lite (Multimodal)"
17853
- },
17854
- {
17855
- cmd: "gemini-3-flash-preview",
17856
- desc: "Default, Fast & Lightweight (Multimodal)"
17857
- },
17858
- {
17859
- cmd: "gemini-3.5-flash",
17860
- desc: "Flash Latest (Multimodal) [Instability Issues]"
17861
- },
17862
- {
17863
- cmd: "gemini-3.1-pro-preview",
17864
- desc: "Pro Reasoning (Multimodal)"
17865
- }
17866
- ]
17738
+ subs: getModels(aiProvider, apiTier)
17867
17739
  },
17868
17740
  {
17869
17741
  cmd: "/mode",
@@ -18024,22 +17896,22 @@ ${cleanText}`, color: "magenta" }];
18024
17896
  });
18025
17897
  break;
18026
17898
  }
18027
- const src = path22.join(DATA_DIR, "playground");
18028
- const dest = path22.join(parsedArgs.originalCwd, "playground-export");
17899
+ const src = path23.join(DATA_DIR, "playground");
17900
+ const dest = path23.join(parsedArgs.originalCwd, "playground-export");
18029
17901
  const moveFiles = async () => {
18030
17902
  try {
18031
17903
  setMessages((prev) => {
18032
17904
  setCompletedIndex(prev.length + 1);
18033
17905
  return [...prev, { id: Date.now(), role: "system", text: `[PLAYGROUND] Exporting playground content to ${dest}`, isMeta: true }];
18034
17906
  });
18035
- await fs24.ensureDir(dest);
17907
+ await fs25.ensureDir(dest);
18036
17908
  const excludeDirs = ["node_modules", ".git", ".venv", "venv", "env", ".next", "dist", "build", ".cache"];
18037
- await fs24.copy(src, dest, {
17909
+ await fs25.copy(src, dest, {
18038
17910
  overwrite: true,
18039
17911
  filter: (srcPath) => {
18040
- const relative = path22.relative(src, srcPath);
17912
+ const relative = path23.relative(src, srcPath);
18041
17913
  if (!relative) return true;
18042
- const parts2 = relative.split(path22.sep);
17914
+ const parts2 = relative.split(path23.sep);
18043
17915
  return !parts2.some((part) => excludeDirs.includes(part));
18044
17916
  }
18045
17917
  });
@@ -18099,7 +17971,7 @@ ${cleanText}`, color: "magenta" }];
18099
17971
  }
18100
17972
  }
18101
17973
  setTimeout(() => {
18102
- fs24.emptyDir(path22.join(DATA_DIR, "playground")).catch((err) => {
17974
+ fs25.emptyDir(path23.join(DATA_DIR, "playground")).catch((err) => {
18103
17975
  setMessages((prev) => {
18104
17976
  const newMsgs = [...prev, {
18105
17977
  id: "playground-" + Date.now(),
@@ -18343,17 +18215,19 @@ ${cleanText}`, color: "magenta" }];
18343
18215
  case "/model": {
18344
18216
  if (parts[1]) {
18345
18217
  const mod = parts.slice(1).join(" ");
18346
- if (mod === "gemma-4-31b-it" && apiTier !== "Free" && aiProvider === "Google") {
18218
+ const freeDefault = getDefaultModel("Google", "Free");
18219
+ const paidDefault = getDefaultModel("Google", "Paid");
18220
+ if (mod === freeDefault && apiTier !== "Free" && aiProvider === "Google") {
18347
18221
  setMessages((prev) => {
18348
18222
  setCompletedIndex(prev.length + 1);
18349
18223
  return [...prev, {
18350
18224
  id: Date.now(),
18351
18225
  role: "system",
18352
- text: `**[ACCESS DENIED]** Gemma is restricted to the Free API tier. Automatically switching you to **Gemini 3 Flash Preview** for optimal performance.`,
18226
+ text: `**[ACCESS DENIED]** ${freeDefault} is restricted to the Free API tier. Automatically switching you to **${paidDefault}** for optimal performance.`,
18353
18227
  isMeta: true
18354
18228
  }];
18355
18229
  });
18356
- setActiveModel("gemini-3-flash-preview");
18230
+ setActiveModel(paidDefault);
18357
18231
  } else {
18358
18232
  setActiveModel(mod);
18359
18233
  const s2 = emojiSpace(2);
@@ -18402,7 +18276,7 @@ ${cleanText}`, color: "magenta" }];
18402
18276
  }
18403
18277
  case "/export": {
18404
18278
  const exportFile = `export-fluxflow-${chatId}.txt`;
18405
- const exportPath = path22.join(process.cwd(), exportFile);
18279
+ const exportPath = path23.join(process.cwd(), exportFile);
18406
18280
  const exportLines = [];
18407
18281
  let insideAgentBlock = false;
18408
18282
  for (let i = 0; i < messages.length; i++) {
@@ -18454,7 +18328,7 @@ ${cleanText}`, color: "magenta" }];
18454
18328
  }
18455
18329
  const fileContent = exportLines.join("\n");
18456
18330
  try {
18457
- fs24.writeFileSync(exportPath, fileContent, "utf8");
18331
+ fs25.writeFileSync(exportPath, fileContent, "utf8");
18458
18332
  setMessages((prev) => {
18459
18333
  setCompletedIndex(prev.length + 1);
18460
18334
  return [...prev, {
@@ -18501,12 +18375,12 @@ ${list || "No saved chats found."}`, isMeta: true }];
18501
18375
  setCompletedIndex(prev.length + 1);
18502
18376
  return [...prev, { id: Date.now(), role: "system", text: "[NUCLEAR] Initiating reset...", isMeta: true }];
18503
18377
  });
18504
- if (fs24.existsSync(LOGS_DIR)) fs24.removeSync(LOGS_DIR);
18505
- if (fs24.existsSync(SECRET_DIR)) fs24.removeSync(SECRET_DIR);
18506
- if (fs24.existsSync(SETTINGS_FILE)) fs24.removeSync(SETTINGS_FILE);
18378
+ if (fs25.existsSync(LOGS_DIR)) fs25.removeSync(LOGS_DIR);
18379
+ if (fs25.existsSync(SECRET_DIR)) fs25.removeSync(SECRET_DIR);
18380
+ if (fs25.existsSync(SETTINGS_FILE)) fs25.removeSync(SETTINGS_FILE);
18507
18381
  try {
18508
- const items = fs24.readdirSync(FLUXFLOW_DIR);
18509
- if (items.length === 0) fs24.removeSync(FLUXFLOW_DIR);
18382
+ const items = fs25.readdirSync(FLUXFLOW_DIR);
18383
+ if (items.length === 0) fs25.removeSync(FLUXFLOW_DIR);
18510
18384
  } catch (e) {
18511
18385
  }
18512
18386
  setTimeout(() => {
@@ -18628,15 +18502,15 @@ ${list || "No saved chats found."}`, isMeta: true }];
18628
18502
  # SKILLS & WORKFLOWS
18629
18503
  - [Define custom step-by-step recipes for this project here]
18630
18504
  `;
18631
- const filePath = path22.join(process.cwd(), "FluxFlow.md");
18632
- if (fs24.pathExistsSync(filePath)) {
18505
+ const filePath = path23.join(process.cwd(), "FluxFlow.md");
18506
+ if (fs25.pathExistsSync(filePath)) {
18633
18507
  setMessages((prev) => {
18634
18508
  setCompletedIndex(prev.length + 1);
18635
18509
  return [...prev, { id: "init-err-" + Date.now(), role: "system", text: "ERROR: FluxFlow.md already exists in this directory.", isMeta: true }];
18636
18510
  });
18637
18511
  } else {
18638
18512
  try {
18639
- fs24.writeFileSync(filePath, template);
18513
+ fs25.writeFileSync(filePath, template);
18640
18514
  setMessages((prev) => {
18641
18515
  setCompletedIndex(prev.length + 1);
18642
18516
  return [...prev, { id: "init-ok-" + Date.now(), role: "system", text: "[SUCCESS] FluxFlow.md has been initialized. You can now customize it for this project.", isMeta: true }];
@@ -19532,7 +19406,17 @@ Selection: ${val}`,
19532
19406
  return [];
19533
19407
  }, [input, isFilePickerDismissed]);
19534
19408
  useEffect12(() => {
19535
- setSelectedIndex(0);
19409
+ let startIdx = 0;
19410
+ while (startIdx < suggestions.length) {
19411
+ const sug = suggestions[startIdx];
19412
+ const cmdName = sug?.cmd || sug || "";
19413
+ if (typeof cmdName === "string" && cmdName.trimStart().startsWith("---")) {
19414
+ startIdx++;
19415
+ } else {
19416
+ break;
19417
+ }
19418
+ }
19419
+ setSelectedIndex(startIdx < suggestions.length ? startIdx : 0);
19536
19420
  }, [suggestions]);
19537
19421
  const [suggestionVisibleCount, setSuggestionVisibleCount] = useState15(0);
19538
19422
  const prevSuggestionsLenRef = useRef4(0);
@@ -19708,16 +19592,9 @@ Selection: ${val}`,
19708
19592
  setAiProvider(selectedProvider);
19709
19593
  setApiKey(key);
19710
19594
  initAI(key, { aiProvider: selectedProvider, onIDEApproval: resetPendingApproval });
19711
- let defaultModel = "gemma-4-31b-it";
19712
- if (selectedProvider === "OpenRouter") {
19713
- defaultModel = "google/gemma-4-31b-it:free";
19714
- } else if (selectedProvider === "DeepSeek") {
19715
- defaultModel = "deepseek-v4-flash";
19716
- } else if (selectedProvider === "NVIDIA") {
19717
- defaultModel = "deepseek-ai/deepseek-v4-flash";
19718
- }
19719
- setActiveModel(defaultModel);
19720
19595
  const targetTier = (quotas.providerTiers || {})[selectedProvider] || "Free";
19596
+ const defaultModel = getDefaultModel(selectedProvider, targetTier);
19597
+ setActiveModel(defaultModel);
19721
19598
  setApiTier(targetTier);
19722
19599
  saveSettings({ aiProvider: selectedProvider, activeModel: defaultModel, apiTier: targetTier, quotas });
19723
19600
  setMessages((prev) => [
@@ -20036,16 +19913,9 @@ Selection: ${val}`,
20036
19913
  setAiProvider(prov);
20037
19914
  setApiKey(keyInput);
20038
19915
  initAI(keyInput, { aiProvider: prov, onIDEApproval: resetPendingApproval });
20039
- let defaultModel = "gemma-4-31b-it";
20040
- if (prov === "OpenRouter") {
20041
- defaultModel = "google/gemma-4-31b-it:free";
20042
- } else if (prov === "DeepSeek") {
20043
- defaultModel = "deepseek-v4-flash";
20044
- } else if (prov === "NVIDIA") {
20045
- defaultModel = "moonshotai/kimi-k2.6";
20046
- }
20047
- setActiveModel(defaultModel);
20048
19916
  const targetTier = (quotas.providerTiers || {})[prov] || "Free";
19917
+ const defaultModel = getDefaultModel(prov, targetTier);
19918
+ setActiveModel(defaultModel);
20049
19919
  setApiTier(targetTier);
20050
19920
  newSettings.aiProvider = prov;
20051
19921
  newSettings.activeModel = defaultModel;
@@ -20607,7 +20477,19 @@ Selection: ${val}`,
20607
20477
  )), /* @__PURE__ */ React16.createElement(Box14, { marginTop: 1 }, /* @__PURE__ */ React16.createElement(Text16, { color: "gray", italic: true }, "(Press ESC to go back to provider selection)")))), /* @__PURE__ */ React16.createElement(Box14, { paddingX: 1, marginTop: 1 }, /* @__PURE__ */ React16.createElement(Text16, { color: "gray", italic: true }, setupStep === 0 ? "(Use arrows to select and Enter to confirm)" : "(Press Enter to confirm and initialize)"))) : renderActiveView(), confirmExit && /* @__PURE__ */ React16.createElement(Box14, { borderStyle: "round", borderColor: "white", paddingX: 2, marginY: 0, width: "100%" }, /* @__PURE__ */ React16.createElement(Text16, { color: "white", bold: true }, "\u{1F534} EXIT CONFIRMATION: "), /* @__PURE__ */ React16.createElement(Text16, { color: "white" }, "Press "), /* @__PURE__ */ React16.createElement(Text16, { color: "white", bold: true }, "CTRL + C"), /* @__PURE__ */ React16.createElement(Text16, { color: "white" }, " again to exit (", exitCountdown, "s). Press "), /* @__PURE__ */ React16.createElement(Text16, { color: "gray", bold: true }, "ESC"), /* @__PURE__ */ React16.createElement(Text16, { color: "white" }, " to cancel.")), suggestions.length > 0 && (() => {
20608
20478
  const windowSize = 5;
20609
20479
  let startIdx = suggestionOffsetRef.current;
20610
- if (selectedIndex < startIdx) {
20480
+ let firstSelectableIndex = 0;
20481
+ while (firstSelectableIndex < suggestions.length) {
20482
+ const sug = suggestions[firstSelectableIndex];
20483
+ const cmdName = sug?.cmd || sug || "";
20484
+ if (typeof cmdName === "string" && cmdName.trimStart().startsWith("---")) {
20485
+ firstSelectableIndex++;
20486
+ } else {
20487
+ break;
20488
+ }
20489
+ }
20490
+ if (selectedIndex <= firstSelectableIndex) {
20491
+ startIdx = 0;
20492
+ } else if (selectedIndex < startIdx) {
20611
20493
  startIdx = selectedIndex;
20612
20494
  } else if (selectedIndex >= startIdx + windowSize) {
20613
20495
  startIdx = selectedIndex - windowSize + 1;
@@ -20623,7 +20505,7 @@ Selection: ${val}`,
20623
20505
  width: "100%",
20624
20506
  marginBottom: 1
20625
20507
  },
20626
- /* @__PURE__ */ React16.createElement(Box14, { paddingX: 1, marginBottom: 0, justifyContent: "space-between", width: "100%" }, /* @__PURE__ */ React16.createElement(Text16, { color: "white", bold: true }, suggestions[0]?.cmd?.startsWith("@") ? "FILE SUGGESTIONS" : "COMMAND SUGGESTIONS"), suggestions[0]?.cmd?.startsWith("@") ? /* @__PURE__ */ React16.createElement(Text16, { color: "gray", italic: true }, "(Use '#Lstart-Lend' to specify line numbers)") : input.startsWith("/model") && apiTier === "Free" ? (() => {
20508
+ /* @__PURE__ */ React16.createElement(Box14, { paddingX: 1, marginBottom: 0, justifyContent: "space-between", width: "100%" }, /* @__PURE__ */ React16.createElement(Text16, { color: "white", bold: true }, suggestions[0]?.cmd?.startsWith("@") ? "FILE SUGGESTIONS" : "COMMAND SUGGESTIONS"), suggestions[0]?.cmd?.startsWith("@") ? /* @__PURE__ */ React16.createElement(Text16, { color: "gray", italic: true }, "(Use \\'#Lstart-Lend\\' to specify line numbers)") : input.startsWith("/model") && apiTier === "Free" ? (() => {
20627
20509
  let url = "https://aistudio.google.com/billing";
20628
20510
  let label = "billing";
20629
20511
  if (aiProvider === "DeepSeek") {
@@ -20641,7 +20523,8 @@ Selection: ${val}`,
20641
20523
  visible.slice(0, suggestionVisibleCount).map((s, i) => {
20642
20524
  const actualIdx = startIdx + i;
20643
20525
  const isActive = actualIdx === selectedIndex;
20644
- const isGemmaDisabled = s.cmd === "gemma-4-31b-it" && apiTier !== "Free";
20526
+ const isDivider = typeof s.cmd === "string" && s.cmd.trimStart().startsWith("---");
20527
+ const isGemmaDisabled = s.cmd === getDefaultModel("Google", "Free") && apiTier !== "Free";
20645
20528
  return /* @__PURE__ */ React16.createElement(
20646
20529
  Box14,
20647
20530
  {
@@ -20650,18 +20533,18 @@ Selection: ${val}`,
20650
20533
  backgroundColor: isActive ? "#2a2a2a" : void 0,
20651
20534
  paddingX: 1
20652
20535
  },
20653
- /* @__PURE__ */ React16.createElement(Box14, { width: 3 }, /* @__PURE__ */ React16.createElement(Text16, { color: isActive ? "white" : "gray", bold: isActive }, isActive ? " \u276F" : " ")),
20536
+ /* @__PURE__ */ React16.createElement(Box14, { width: 3 }, /* @__PURE__ */ React16.createElement(Text16, { color: isActive ? "#B8BDC9" : "gray", bold: isActive }, isActive ? " \u276F" : " ")),
20654
20537
  /* @__PURE__ */ React16.createElement(Box14, { width: 55 }, /* @__PURE__ */ React16.createElement(
20655
20538
  Text16,
20656
20539
  {
20657
- color: isGemmaDisabled ? "gray" : isActive ? "white" : "grey",
20658
- bold: isActive
20540
+ color: isDivider ? "#D0CCD8" : isGemmaDisabled ? "gray" : isActive ? "white" : "grey",
20541
+ bold: false
20659
20542
  },
20660
20543
  s.cmd?.startsWith("@[") && s.cmd?.endsWith("]") ? (() => {
20661
20544
  const pathPart = s.cmd.slice(2, -1);
20662
20545
  const parts = pathPart.split(/[/\\]/);
20663
20546
  return parts[parts.length - 1];
20664
- })() : s.cmd
20547
+ })() : s.cmd && s.cmd.includes("/") ? s.cmd.split("/").pop() : s.cmd
20665
20548
  )),
20666
20549
  /* @__PURE__ */ React16.createElement(Box14, { flexGrow: 1 }, /* @__PURE__ */ React16.createElement(Text16, { color: `${!isActive ? "gray" : "white"}`, italic: true }, s.desc))
20667
20550
  );
@@ -20718,6 +20601,7 @@ var init_app = __esm({
20718
20601
  init_witty_phrases();
20719
20602
  init_RevertModal();
20720
20603
  init_usage();
20604
+ init_model_config();
20721
20605
  init_TerminalBox();
20722
20606
  init_arg_parser();
20723
20607
  init_paths();
@@ -20777,11 +20661,11 @@ var init_app = __esm({
20777
20661
  if (process.platform === "win32") {
20778
20662
  const appData = process.env.APPDATA;
20779
20663
  if (!appData) return null;
20780
- return path22.join(appData, dirName, "User", "keybindings.json");
20664
+ return path23.join(appData, dirName, "User", "keybindings.json");
20781
20665
  } else if (process.platform === "darwin") {
20782
- return path22.join(home, "Library", "Application Support", dirName, "User", "keybindings.json");
20666
+ return path23.join(home, "Library", "Application Support", dirName, "User", "keybindings.json");
20783
20667
  } else {
20784
- return path22.join(home, ".config", dirName, "User", "keybindings.json");
20668
+ return path23.join(home, ".config", dirName, "User", "keybindings.json");
20785
20669
  }
20786
20670
  };
20787
20671
  parseJsonc = (content) => {
@@ -20825,8 +20709,8 @@ var init_app = __esm({
20825
20709
  SESSION_START_TIME = Date.now();
20826
20710
  CHANGELOG_URL = "https://fluxflow-cli.onrender.com/changelog";
20827
20711
  DOCS_URL = "https://fluxflow-cli.onrender.com/";
20828
- packageJsonPath = path22.join(path22.dirname(fileURLToPath2(import.meta.url)), "../package.json");
20829
- packageJson = JSON.parse(fs24.readFileSync(packageJsonPath, "utf8"));
20712
+ packageJsonPath = path23.join(path23.dirname(fileURLToPath3(import.meta.url)), "../package.json");
20713
+ packageJson = JSON.parse(fs25.readFileSync(packageJsonPath, "utf8"));
20830
20714
  versionFluxflow = packageJson.version;
20831
20715
  updatedOn = packageJson.date || "2026-05-20";
20832
20716
  ResolutionModal = ({ data, onResolve, onEdit }) => /* @__PURE__ */ React16.createElement(Box14, { flexDirection: "column", borderStyle: "round", borderColor: "grey", padding: 0, width: "100%" }, /* @__PURE__ */ React16.createElement(Box14, { paddingX: 1 }, /* @__PURE__ */ React16.createElement(Text16, { color: "white", bold: true, underline: true }, data.startsWith("/btw") ? "QUESTION" : "STEERING HINT", " RESOLUTION")), /* @__PURE__ */ React16.createElement(Box14, { paddingX: 1, marginTop: 1 }, /* @__PURE__ */ React16.createElement(Text16, null, "The agent already finished the task before your ", data.startsWith("/btw") ? "question" : "hint", " was consumed.")), /* @__PURE__ */ React16.createElement(Box14, { marginTop: 1, backgroundColor: "#222", paddingX: 2, width: "100%" }, /* @__PURE__ */ React16.createElement(Text16, { italic: true, color: "gray" }, '"', data.replace("/btw", "").trim(), '"')), /* @__PURE__ */ React16.createElement(Box14, { paddingX: 1, marginTop: 1 }, /* @__PURE__ */ React16.createElement(Text16, { color: "grey" }, "How would you like to proceed?")), /* @__PURE__ */ React16.createElement(Box14, { marginTop: 0 }, /* @__PURE__ */ React16.createElement(
@@ -20923,20 +20807,20 @@ var init_app = __esm({
20923
20807
  const scan = (currentDir) => {
20924
20808
  if (fileList.length >= 2e3) return;
20925
20809
  try {
20926
- const files = fs24.readdirSync(currentDir);
20810
+ const files = fs25.readdirSync(currentDir);
20927
20811
  for (const file of files) {
20928
20812
  if (fileList.length >= 2e3) return;
20929
20813
  if (["node_modules", ".git", ".gemini", "dist", "build", ".next", ".cache", "out"].includes(file)) {
20930
20814
  continue;
20931
20815
  }
20932
- const filePath = path22.join(currentDir, file);
20933
- const stat = fs24.statSync(filePath);
20816
+ const filePath = path23.join(currentDir, file);
20817
+ const stat = fs25.statSync(filePath);
20934
20818
  if (stat.isDirectory()) {
20935
20819
  scan(filePath);
20936
20820
  } else {
20937
20821
  fileList.push({
20938
20822
  name: flattenString(file),
20939
- relativePath: flattenString(path22.relative(process.cwd(), filePath))
20823
+ relativePath: flattenString(path23.relative(process.cwd(), filePath))
20940
20824
  });
20941
20825
  }
20942
20826
  }
@@ -21040,7 +20924,7 @@ var init_app = __esm({
21040
20924
 
21041
20925
  // src/cli.jsx
21042
20926
  import { spawn as spawn3 } from "child_process";
21043
- import { fileURLToPath as fileURLToPath3 } from "url";
20927
+ import { fileURLToPath as fileURLToPath4 } from "url";
21044
20928
  import os6 from "os";
21045
20929
  var totalSystemRamBytes = os6.totalmem();
21046
20930
  var totalSystemRamMB = totalSystemRamBytes / (1024 * 1024);
@@ -21057,7 +20941,7 @@ if (!isNaN(_allocValue) && _allocValue < 64) {
21057
20941
  }
21058
20942
  var _maxAllowed = Math.floor(totalSystemRamMB * 0.75);
21059
20943
  var HEAP_LIMIT = !isNaN(_allocValue) && _allocValue > 0 ? Math.min(_allocValue, _maxAllowed) : Math.max(1536, Math.min(32768, calculatedLimit));
21060
- var isBundled = fileURLToPath3(import.meta.url).endsWith(".js");
20944
+ var isBundled = fileURLToPath4(import.meta.url).endsWith(".js");
21061
20945
  if (isBundled && !process.execArgv.some((arg) => arg.includes("max-old-space-size"))) {
21062
20946
  if (!Number.isNaN(_allocValue)) {
21063
20947
  console.log(`
@@ -21068,7 +20952,7 @@ if (isBundled && !process.execArgv.some((arg) => arg.includes("max-old-space-siz
21068
20952
  `--max-old-space-size=${HEAP_LIMIT}`,
21069
20953
  `--expose-gc`,
21070
20954
  `--max-semi-space-size=1`,
21071
- fileURLToPath3(import.meta.url),
20955
+ fileURLToPath4(import.meta.url),
21072
20956
  ...process.argv.slice(2)
21073
20957
  ], { stdio: "inherit" });
21074
20958
  cp.on("exit", (code) => process.exit(code || 0));
@@ -21079,11 +20963,11 @@ if (isBundled && !process.execArgv.some((arg) => arg.includes("max-old-space-siz
21079
20963
  const isVersion = args.includes("--version") || args.includes("-v");
21080
20964
  const isUpdate = args[0] === "--update";
21081
20965
  if (isVersion || isHelp || isHelpCommands || isUpdate) {
21082
- const fs25 = await import("fs");
21083
- const path23 = await import("path");
21084
- const { fileURLToPath: fileURLToPath4 } = await import("url");
21085
- const packageJsonPath2 = path23.join(path23.dirname(fileURLToPath4(import.meta.url)), "../package.json");
21086
- const packageJson2 = JSON.parse(fs25.readFileSync(packageJsonPath2, "utf8"));
20966
+ const fs26 = await import("fs");
20967
+ const path24 = await import("path");
20968
+ const { fileURLToPath: fileURLToPath5 } = await import("url");
20969
+ const packageJsonPath2 = path24.join(path24.dirname(fileURLToPath5(import.meta.url)), "../package.json");
20970
+ const packageJson2 = JSON.parse(fs26.readFileSync(packageJsonPath2, "utf8"));
21087
20971
  const versionFluxflow2 = packageJson2.version;
21088
20972
  if (isVersion) {
21089
20973
  console.log(`v${versionFluxflow2}`);