fluxflow-cli 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/fluxflow.js +64 -89
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kushal Roy Chowdhury
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/fluxflow.js
CHANGED
|
@@ -8,8 +8,6 @@ import { render } from "ink";
|
|
|
8
8
|
import React8, { useState as useState4, useEffect as useEffect3, useRef, useMemo } from "react";
|
|
9
9
|
import { Box as Box8, Text as Text8, useInput as useInput3, useStdout, Static } from "ink";
|
|
10
10
|
import fs14 from "fs-extra";
|
|
11
|
-
import path16 from "path";
|
|
12
|
-
import { fileURLToPath as fileURLToPath9 } from "url";
|
|
13
11
|
import { MultilineInput } from "ink-multiline-input";
|
|
14
12
|
import TextInput2 from "ink-text-input";
|
|
15
13
|
|
|
@@ -257,8 +255,6 @@ import gradient from "gradient-string";
|
|
|
257
255
|
|
|
258
256
|
// src/utils/secrets.js
|
|
259
257
|
import fs2 from "fs-extra";
|
|
260
|
-
import path2 from "path";
|
|
261
|
-
import { fileURLToPath } from "url";
|
|
262
258
|
|
|
263
259
|
// src/utils/crypto.js
|
|
264
260
|
import fs from "fs";
|
|
@@ -295,12 +291,21 @@ var writeEncryptedJson = (filePath, data) => {
|
|
|
295
291
|
}
|
|
296
292
|
};
|
|
297
293
|
|
|
294
|
+
// src/utils/paths.js
|
|
295
|
+
import os from "os";
|
|
296
|
+
import path2 from "path";
|
|
297
|
+
var FLUXFLOW_DIR = path2.join(os.homedir(), ".fluxflow");
|
|
298
|
+
var LOGS_DIR = path2.join(FLUXFLOW_DIR, "logs");
|
|
299
|
+
var SECRET_DIR = path2.join(FLUXFLOW_DIR, "secret");
|
|
300
|
+
var SETTINGS_FILE = path2.join(FLUXFLOW_DIR, "settings.json");
|
|
301
|
+
var HISTORY_FILE = path2.join(SECRET_DIR, "history.json");
|
|
302
|
+
var USAGE_FILE = path2.join(SECRET_DIR, "usage.json");
|
|
303
|
+
var MEMORIES_FILE = path2.join(SECRET_DIR, "memories.json");
|
|
304
|
+
var TEMP_MEM_FILE = path2.join(SECRET_DIR, "memory-temp.json");
|
|
305
|
+
|
|
298
306
|
// src/utils/secrets.js
|
|
299
|
-
|
|
300
|
-
var
|
|
301
|
-
var AGENT_ROOT = path2.join(__dirname, "../../");
|
|
302
|
-
var SECRET_DIR = path2.join(AGENT_ROOT, "secret");
|
|
303
|
-
var SECRET_FILE = path2.join(SECRET_DIR, "secrets.json");
|
|
307
|
+
import path3 from "path";
|
|
308
|
+
var SECRET_FILE = path3.join(SECRET_DIR, "secrets.json");
|
|
304
309
|
var getAPIKey = async () => {
|
|
305
310
|
try {
|
|
306
311
|
const secrets = readEncryptedJson(SECRET_FILE, {});
|
|
@@ -476,13 +481,8 @@ Current date and Time: ${(/* @__PURE__ */ new Date()).toLocaleString()}
|
|
|
476
481
|
|
|
477
482
|
// src/utils/history.js
|
|
478
483
|
import fs3 from "fs-extra";
|
|
479
|
-
import
|
|
480
|
-
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
484
|
+
import path4 from "path";
|
|
481
485
|
import { nanoid } from "nanoid";
|
|
482
|
-
var __filename2 = fileURLToPath2(import.meta.url);
|
|
483
|
-
var __dirname2 = path3.dirname(__filename2);
|
|
484
|
-
var AGENT_ROOT2 = path3.join(__dirname2, "../../");
|
|
485
|
-
var HISTORY_FILE = path3.join(AGENT_ROOT2, "secret/history.json");
|
|
486
486
|
var WRITE_LOCK = Promise.resolve();
|
|
487
487
|
var withLock = (op) => {
|
|
488
488
|
const nextLock = WRITE_LOCK.then(async () => {
|
|
@@ -517,7 +517,7 @@ var saveChat = async (id, name, messages) => {
|
|
|
517
517
|
messages,
|
|
518
518
|
updatedAt: Date.now()
|
|
519
519
|
};
|
|
520
|
-
await fs3.ensureDir(
|
|
520
|
+
await fs3.ensureDir(path4.dirname(HISTORY_FILE));
|
|
521
521
|
await fs3.writeJson(HISTORY_FILE, history, { spaces: 2 });
|
|
522
522
|
});
|
|
523
523
|
};
|
|
@@ -530,7 +530,7 @@ var saveChatTitle = async (id, title) => {
|
|
|
530
530
|
} else {
|
|
531
531
|
history[id] = { name: title, messages: [], updatedAt: Date.now() };
|
|
532
532
|
}
|
|
533
|
-
await fs3.ensureDir(
|
|
533
|
+
await fs3.ensureDir(path4.dirname(HISTORY_FILE));
|
|
534
534
|
await fs3.writeJson(HISTORY_FILE, history, { spaces: 2 });
|
|
535
535
|
});
|
|
536
536
|
};
|
|
@@ -539,13 +539,12 @@ var deleteChat = async (id) => {
|
|
|
539
539
|
const history = await loadHistory();
|
|
540
540
|
delete history[id];
|
|
541
541
|
await fs3.writeJson(HISTORY_FILE, history, { spaces: 2 });
|
|
542
|
-
|
|
543
|
-
if (await fs3.pathExists(tempFile)) {
|
|
542
|
+
if (await fs3.pathExists(TEMP_MEM_FILE)) {
|
|
544
543
|
try {
|
|
545
|
-
const temp = await fs3.readJson(
|
|
544
|
+
const temp = await fs3.readJson(TEMP_MEM_FILE);
|
|
546
545
|
if (temp[id]) {
|
|
547
546
|
delete temp[id];
|
|
548
|
-
await fs3.writeJson(
|
|
547
|
+
await fs3.writeJson(TEMP_MEM_FILE, temp, { spaces: 2 });
|
|
549
548
|
}
|
|
550
549
|
} catch (e) {
|
|
551
550
|
}
|
|
@@ -582,15 +581,12 @@ var getTruncatedHistory = (history, exchangesToRemove = 4) => {
|
|
|
582
581
|
|
|
583
582
|
// src/utils/usage.js
|
|
584
583
|
import fs4 from "fs-extra";
|
|
585
|
-
import
|
|
586
|
-
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
587
|
-
var __dirname3 = path4.dirname(fileURLToPath3(import.meta.url));
|
|
588
|
-
var USAGE_PATH = path4.join(__dirname3, "../../secret/usage.json");
|
|
584
|
+
import path5 from "path";
|
|
589
585
|
var getDailyUsage = async () => {
|
|
590
586
|
const today = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
591
587
|
try {
|
|
592
|
-
if (await fs4.exists(
|
|
593
|
-
const data = await fs4.readJson(
|
|
588
|
+
if (await fs4.exists(USAGE_FILE)) {
|
|
589
|
+
const data = await fs4.readJson(USAGE_FILE);
|
|
594
590
|
if (data.date === today) {
|
|
595
591
|
return data.stats;
|
|
596
592
|
}
|
|
@@ -599,19 +595,21 @@ var getDailyUsage = async () => {
|
|
|
599
595
|
console.error("Failed to read usage:", err);
|
|
600
596
|
}
|
|
601
597
|
const defaultStats = { agent: 0, background: 0, search: 0 };
|
|
602
|
-
await fs4.
|
|
598
|
+
await fs4.ensureDir(path5.dirname(USAGE_FILE));
|
|
599
|
+
await fs4.writeJson(USAGE_FILE, { date: today, stats: defaultStats }, { spaces: 2 });
|
|
603
600
|
return defaultStats;
|
|
604
601
|
};
|
|
605
602
|
var incrementUsage = async (key) => {
|
|
606
603
|
const today = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
607
|
-
const data = await fs4.readJson(
|
|
604
|
+
const data = await fs4.readJson(USAGE_FILE).catch(() => ({ date: today, stats: { agent: 0, background: 0, search: 0 } }));
|
|
608
605
|
if (data.date !== today) {
|
|
609
606
|
data.date = today;
|
|
610
607
|
data.stats = { agent: 0, background: 0, search: 0 };
|
|
611
608
|
}
|
|
612
609
|
if (data.stats[key] !== void 0) {
|
|
613
610
|
data.stats[key]++;
|
|
614
|
-
await fs4.
|
|
611
|
+
await fs4.ensureDir(path5.dirname(USAGE_FILE));
|
|
612
|
+
await fs4.writeJson(USAGE_FILE, data, { spaces: 2 });
|
|
615
613
|
}
|
|
616
614
|
};
|
|
617
615
|
var checkQuota = async (key, settings) => {
|
|
@@ -661,11 +659,7 @@ var parseArgs = (argsString) => {
|
|
|
661
659
|
|
|
662
660
|
// src/tools/web_search.js
|
|
663
661
|
import fs5 from "fs";
|
|
664
|
-
import
|
|
665
|
-
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
666
|
-
var __filename3 = fileURLToPath4(import.meta.url);
|
|
667
|
-
var __dirname4 = path5.dirname(__filename3);
|
|
668
|
-
var AGENT_ROOT3 = path5.join(__dirname4, "../../");
|
|
662
|
+
import path6 from "path";
|
|
669
663
|
var web_search = async (argsString) => {
|
|
670
664
|
const { query, limit = 10 } = parseArgs(argsString);
|
|
671
665
|
if (!query) return 'ERROR: Missing "query" argument for web_search.';
|
|
@@ -693,11 +687,11 @@ Source: ${url}
|
|
|
693
687
|
Snippet: ${snippet}`);
|
|
694
688
|
count++;
|
|
695
689
|
}
|
|
696
|
-
const toolLogDir =
|
|
690
|
+
const toolLogDir = path6.join(LOGS_DIR, "tools");
|
|
697
691
|
if (!fs5.existsSync(toolLogDir)) {
|
|
698
692
|
fs5.mkdirSync(toolLogDir, { recursive: true });
|
|
699
693
|
}
|
|
700
|
-
fs5.appendFileSync(
|
|
694
|
+
fs5.appendFileSync(path6.join(toolLogDir, "search-results.log"), `RESULTS ${(/* @__PURE__ */ new Date()).toISOString()} -
|
|
701
695
|
Query: [${query}]. Results Count: ${results.length}.
|
|
702
696
|
Results: ${results}
|
|
703
697
|
|
|
@@ -705,11 +699,11 @@ Results: ${results}
|
|
|
705
699
|
`);
|
|
706
700
|
if (results.length === 0) {
|
|
707
701
|
if (html.includes("anomaly")) {
|
|
708
|
-
const toolErrDir =
|
|
702
|
+
const toolErrDir = path6.join(LOGS_DIR, "tools");
|
|
709
703
|
if (!fs5.existsSync(toolErrDir)) {
|
|
710
704
|
fs5.mkdirSync(toolErrDir, { recursive: true });
|
|
711
705
|
}
|
|
712
|
-
fs5.appendFileSync(
|
|
706
|
+
fs5.appendFileSync(path6.join(toolErrDir, "error.log"), `ERROR ${(/* @__PURE__ */ new Date()).toISOString()} - DDG detected unusual activity. Cuimp impersonation might need adjustment.
|
|
713
707
|
`);
|
|
714
708
|
throw new Error("DDG detected unusual activity. Cuimp impersonation might need adjustment.");
|
|
715
709
|
}
|
|
@@ -726,12 +720,8 @@ ${finalResults}`;
|
|
|
726
720
|
|
|
727
721
|
// src/tools/web_scrape.js
|
|
728
722
|
import fs6 from "fs";
|
|
729
|
-
import
|
|
730
|
-
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
723
|
+
import path7 from "path";
|
|
731
724
|
import * as cuimp2 from "cuimp";
|
|
732
|
-
var __filename4 = fileURLToPath5(import.meta.url);
|
|
733
|
-
var __dirname5 = path6.dirname(__filename4);
|
|
734
|
-
var AGENT_ROOT4 = path6.join(__dirname5, "../../");
|
|
735
725
|
var web_scrape = async (args) => {
|
|
736
726
|
const urlMatch = args.match(/url\s*=\s*["'](.*)["']/);
|
|
737
727
|
const url = urlMatch ? urlMatch[1] : args;
|
|
@@ -752,11 +742,11 @@ var web_scrape = async (args) => {
|
|
|
752
742
|
html = html.replace(/<header\b[^<]*(?:(?!<\/header>)<[^<]*)*<\/header>/gi, "");
|
|
753
743
|
let text = html.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
|
|
754
744
|
const finalContent = text.substring(0, 2e4);
|
|
755
|
-
const toolLogDir =
|
|
745
|
+
const toolLogDir = path7.join(LOGS_DIR, "tools");
|
|
756
746
|
if (!fs6.existsSync(toolLogDir)) {
|
|
757
747
|
fs6.mkdirSync(toolLogDir, { recursive: true });
|
|
758
748
|
}
|
|
759
|
-
fs6.appendFileSync(
|
|
749
|
+
fs6.appendFileSync(path7.join(toolLogDir, "search-scraped.log"), `RESULTS ${(/* @__PURE__ */ new Date()).toISOString()} -
|
|
760
750
|
Query: [${url}].
|
|
761
751
|
Results: ${finalContent}
|
|
762
752
|
|
|
@@ -771,14 +761,6 @@ ${finalContent}${text.length > 2e4 ? "\n\n[TRUNCATED AT 20K CHARS]" : ""}`;
|
|
|
771
761
|
};
|
|
772
762
|
|
|
773
763
|
// src/tools/memory.js
|
|
774
|
-
import path7 from "path";
|
|
775
|
-
import { fileURLToPath as fileURLToPath6 } from "url";
|
|
776
|
-
var __filename5 = fileURLToPath6(import.meta.url);
|
|
777
|
-
var __dirname6 = path7.dirname(__filename5);
|
|
778
|
-
var AGENT_ROOT5 = path7.join(__dirname6, "../../");
|
|
779
|
-
var SECRET_DIR2 = path7.join(AGENT_ROOT5, "secret");
|
|
780
|
-
var MEMORIES_PATH = path7.join(SECRET_DIR2, "memories.json");
|
|
781
|
-
var TEMP_MEM_PATH = path7.join(SECRET_DIR2, "memory-temp.json");
|
|
782
764
|
var memory = async (rawArgs, context = {}) => {
|
|
783
765
|
const parseArg = (key) => {
|
|
784
766
|
const regex = new RegExp(`${key}\\s*=\\s*(["'])(.*?)\\1(?=\\s*[,)]|\\s+\\w+\\s*=|$)`, "s");
|
|
@@ -793,7 +775,7 @@ var memory = async (rawArgs, context = {}) => {
|
|
|
793
775
|
const chatId = parseArg("chat-id") || context.chatId || context.sessionId || "default-session";
|
|
794
776
|
if (action === "temp") {
|
|
795
777
|
if (!content) return "ERROR: Missing 'content' for temp memory.";
|
|
796
|
-
const tempStorage = readEncryptedJson(
|
|
778
|
+
const tempStorage = readEncryptedJson(TEMP_MEM_FILE, {});
|
|
797
779
|
if (!tempStorage[chatId]) tempStorage[chatId] = [];
|
|
798
780
|
const MAX_CHARS = 3e3 * 4;
|
|
799
781
|
let currentTotalLength = tempStorage[chatId].reduce((acc, m) => acc + m.length, 0);
|
|
@@ -802,11 +784,11 @@ var memory = async (rawArgs, context = {}) => {
|
|
|
802
784
|
currentTotalLength -= removed.length;
|
|
803
785
|
}
|
|
804
786
|
tempStorage[chatId].push(content);
|
|
805
|
-
writeEncryptedJson(
|
|
787
|
+
writeEncryptedJson(TEMP_MEM_FILE, tempStorage);
|
|
806
788
|
return `SUCCESS: Temporary context saved for session [${chatId}]. (Size: ${currentTotalLength + content.length} chars)`;
|
|
807
789
|
}
|
|
808
790
|
if (action === "user") {
|
|
809
|
-
const memories = readEncryptedJson(
|
|
791
|
+
const memories = readEncryptedJson(MEMORIES_FILE, []);
|
|
810
792
|
if (method === "add") {
|
|
811
793
|
if (!content) return "ERROR: Missing 'content' for memory addition.";
|
|
812
794
|
const MAX_CHARS = 2e3 * 4;
|
|
@@ -817,7 +799,7 @@ var memory = async (rawArgs, context = {}) => {
|
|
|
817
799
|
}
|
|
818
800
|
const newMemory = { id: `mem-${Date.now().toString(36)}`, memory: content };
|
|
819
801
|
memories.push(newMemory);
|
|
820
|
-
writeEncryptedJson(
|
|
802
|
+
writeEncryptedJson(MEMORIES_FILE, memories);
|
|
821
803
|
return `SUCCESS: Memory added with ID [${newMemory.id}]. (Vault Size: ${currentTotalLength + content.length} chars)`;
|
|
822
804
|
}
|
|
823
805
|
if (method === "update") {
|
|
@@ -827,7 +809,7 @@ var memory = async (rawArgs, context = {}) => {
|
|
|
827
809
|
const index = memories.findIndex((m) => m.id === memId);
|
|
828
810
|
if (index === -1) return `ERROR: Memory ID [${memId}] not found.`;
|
|
829
811
|
memories[index].memory = newText;
|
|
830
|
-
writeEncryptedJson(
|
|
812
|
+
writeEncryptedJson(MEMORIES_FILE, memories);
|
|
831
813
|
return `SUCCESS: Memory [${memId}] updated.`;
|
|
832
814
|
}
|
|
833
815
|
if (method === "delete") {
|
|
@@ -836,7 +818,7 @@ var memory = async (rawArgs, context = {}) => {
|
|
|
836
818
|
const initialLen = memories.length;
|
|
837
819
|
const updatedMemories = memories.filter((m) => m.id !== memId);
|
|
838
820
|
if (updatedMemories.length === initialLen) return `ERROR: Memory ID [${memId}] not found.`;
|
|
839
|
-
writeEncryptedJson(
|
|
821
|
+
writeEncryptedJson(MEMORIES_FILE, updatedMemories);
|
|
840
822
|
return `SUCCESS: Memory [${memId}] deleted.`;
|
|
841
823
|
}
|
|
842
824
|
return `ERROR: Invalid method [${method}] for user memory. Use 'add', 'update', or 'delete'.`;
|
|
@@ -1223,15 +1205,9 @@ var dispatchTool = async (toolName, args, context = {}) => {
|
|
|
1223
1205
|
};
|
|
1224
1206
|
|
|
1225
1207
|
// src/utils/ai.js
|
|
1226
|
-
import { fileURLToPath as fileURLToPath7 } from "url";
|
|
1227
1208
|
import path13 from "path";
|
|
1228
1209
|
import fs12 from "fs";
|
|
1229
|
-
var __filename6 = fileURLToPath7(import.meta.url);
|
|
1230
|
-
var __dirname7 = path13.dirname(__filename6);
|
|
1231
|
-
var AGENT_ROOT6 = path13.join(__dirname7, "../../");
|
|
1232
1210
|
var client = null;
|
|
1233
|
-
var TEMP_MEM_PATH2 = path13.join(AGENT_ROOT6, "secret", "memory-temp.json");
|
|
1234
|
-
var PERSISTENT_MEM_PATH = path13.join(AGENT_ROOT6, "secret", "memories.json");
|
|
1235
1211
|
var TERMINATION_SIGNAL = false;
|
|
1236
1212
|
var signalTermination = () => {
|
|
1237
1213
|
TERMINATION_SIGNAL = true;
|
|
@@ -1288,9 +1264,9 @@ var getAIStream = async function* (modelName, history, settings, steeringCallbac
|
|
|
1288
1264
|
if (systemSettings?.compression === 0 && (sessionStats?.tokens || 0) > 196e3) {
|
|
1289
1265
|
modifiedHistory = getTruncatedHistory(modifiedHistory, 4);
|
|
1290
1266
|
}
|
|
1291
|
-
const tempStorage = readEncryptedJson(
|
|
1267
|
+
const tempStorage = readEncryptedJson(TEMP_MEM_FILE, {});
|
|
1292
1268
|
const otherMemories = Object.entries(tempStorage).filter(([id]) => id !== chatId).flatMap(([_, mems]) => mems).map((mem) => `- ${mem}`).join("\n");
|
|
1293
|
-
const persistentStorage = readEncryptedJson(
|
|
1269
|
+
const persistentStorage = readEncryptedJson(MEMORIES_FILE, []);
|
|
1294
1270
|
const mainUserMemories = persistentStorage.map((m) => `- ${m.memory}`).join("\n");
|
|
1295
1271
|
const janitorUserMemories = persistentStorage.map((m) => `- [${m.id}]: ${m.memory}`).join("\n");
|
|
1296
1272
|
const systemInstruction = getSystemInstruction(profile, thinkingLevel, mode, systemSettings, otherMemories, mainUserMemories, isMemoryEnabled);
|
|
@@ -1344,7 +1320,7 @@ USER_PROMPT: ${agentText}`.trim();
|
|
|
1344
1320
|
} catch (err) {
|
|
1345
1321
|
const errMsg = err.message || String(err);
|
|
1346
1322
|
const date = (/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace("T", " ");
|
|
1347
|
-
const agentErrDir = path13.join(
|
|
1323
|
+
const agentErrDir = path13.join(LOGS_DIR, "agent");
|
|
1348
1324
|
if (!fs12.existsSync(agentErrDir)) {
|
|
1349
1325
|
fs12.mkdirSync(agentErrDir, { recursive: true });
|
|
1350
1326
|
}
|
|
@@ -1507,7 +1483,7 @@ ${boxBottom}
|
|
|
1507
1483
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace("T", " ");
|
|
1508
1484
|
const isErr = result.startsWith("ERROR:");
|
|
1509
1485
|
const logStatus = isErr ? result.trim() : "SUCCESS";
|
|
1510
|
-
const toolHistDir = path13.join(
|
|
1486
|
+
const toolHistDir = path13.join(LOGS_DIR, "tools");
|
|
1511
1487
|
if (!fs12.existsSync(toolHistDir)) {
|
|
1512
1488
|
fs12.mkdirSync(toolHistDir, { recursive: true });
|
|
1513
1489
|
}
|
|
@@ -1565,7 +1541,7 @@ ${boxBottom}
|
|
|
1565
1541
|
if (parts && parts[1]?.text) {
|
|
1566
1542
|
finalSynthesis = parts[1].text;
|
|
1567
1543
|
const date = (/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace("T", " ");
|
|
1568
|
-
const janitorLogDir = path13.join(
|
|
1544
|
+
const janitorLogDir = path13.join(LOGS_DIR, "janitor");
|
|
1569
1545
|
if (!fs12.existsSync(janitorLogDir)) {
|
|
1570
1546
|
fs12.mkdirSync(janitorLogDir, { recursive: true });
|
|
1571
1547
|
}
|
|
@@ -1581,7 +1557,7 @@ ${boxBottom}
|
|
|
1581
1557
|
const toolContext = { chatId, sessionId: chatId, history };
|
|
1582
1558
|
const result = await dispatchTool(janitorToolCall.toolName, janitorToolCall.args, toolContext);
|
|
1583
1559
|
const date = (/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace("T", " ");
|
|
1584
|
-
const janitorLogDir = path13.join(
|
|
1560
|
+
const janitorLogDir = path13.join(LOGS_DIR, "janitor");
|
|
1585
1561
|
fs12.appendFileSync(path13.join(janitorLogDir, "debug.log"), `DEBUG [${date}]: RESULT [${janitorToolCall.toolName}]: ${result}
|
|
1586
1562
|
`);
|
|
1587
1563
|
if (janitorToolCall.toolName === "memory" && !janitorToolCall.args.includes("action='temp'")) {
|
|
@@ -1590,7 +1566,7 @@ ${boxBottom}
|
|
|
1590
1566
|
}
|
|
1591
1567
|
} catch (janitorErr) {
|
|
1592
1568
|
const date = (/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace("T", " ");
|
|
1593
|
-
const janitorErrDir = path13.join(
|
|
1569
|
+
const janitorErrDir = path13.join(LOGS_DIR, "janitor");
|
|
1594
1570
|
if (!fs12.existsSync(janitorErrDir)) {
|
|
1595
1571
|
fs12.mkdirSync(janitorErrDir, { recursive: true });
|
|
1596
1572
|
}
|
|
@@ -1623,9 +1599,6 @@ ${timestamp}`;
|
|
|
1623
1599
|
// src/utils/settings.js
|
|
1624
1600
|
import fs13 from "fs-extra";
|
|
1625
1601
|
import path14 from "path";
|
|
1626
|
-
import { fileURLToPath as fileURLToPath8 } from "url";
|
|
1627
|
-
var __dirname8 = path14.dirname(fileURLToPath8(import.meta.url));
|
|
1628
|
-
var SETTINGS_PATH = path14.join(__dirname8, "../../settings.json");
|
|
1629
1602
|
var DEFAULT_SETTINGS = {
|
|
1630
1603
|
mode: "Flux",
|
|
1631
1604
|
thinkingLevel: "Medium",
|
|
@@ -1654,8 +1627,8 @@ var DEFAULT_SETTINGS = {
|
|
|
1654
1627
|
};
|
|
1655
1628
|
var loadSettings = async () => {
|
|
1656
1629
|
try {
|
|
1657
|
-
if (await fs13.exists(
|
|
1658
|
-
const saved = await fs13.readJson(
|
|
1630
|
+
if (await fs13.exists(SETTINGS_FILE)) {
|
|
1631
|
+
const saved = await fs13.readJson(SETTINGS_FILE);
|
|
1659
1632
|
return {
|
|
1660
1633
|
...DEFAULT_SETTINGS,
|
|
1661
1634
|
...saved,
|
|
@@ -1673,7 +1646,8 @@ var saveSettings = async (settings) => {
|
|
|
1673
1646
|
try {
|
|
1674
1647
|
const current = await loadSettings();
|
|
1675
1648
|
const updated = { ...current, ...settings };
|
|
1676
|
-
await fs13.
|
|
1649
|
+
await fs13.ensureDir(path14.dirname(SETTINGS_FILE));
|
|
1650
|
+
await fs13.writeJson(SETTINGS_FILE, updated, { spaces: 2 });
|
|
1677
1651
|
return true;
|
|
1678
1652
|
} catch (err) {
|
|
1679
1653
|
console.error("Failed to save settings:", err);
|
|
@@ -1723,12 +1697,12 @@ function ResumeModal({ onSelect, onDelete, onClose }) {
|
|
|
1723
1697
|
import React7, { useState as useState3, useEffect as useEffect2 } from "react";
|
|
1724
1698
|
import { Box as Box7, Text as Text7, useInput as useInput2 } from "ink";
|
|
1725
1699
|
import path15 from "path";
|
|
1726
|
-
var
|
|
1700
|
+
var MEMORIES_PATH = path15.join(process.cwd(), "secret", "memories.json");
|
|
1727
1701
|
function MemoryModal({ onClose }) {
|
|
1728
1702
|
const [memories, setMemories] = useState3([]);
|
|
1729
1703
|
const [selectedIndex, setSelectedIndex] = useState3(0);
|
|
1730
1704
|
const loadMemories = () => {
|
|
1731
|
-
const data = readEncryptedJson(
|
|
1705
|
+
const data = readEncryptedJson(MEMORIES_PATH, []);
|
|
1732
1706
|
setMemories(data);
|
|
1733
1707
|
};
|
|
1734
1708
|
useEffect2(() => {
|
|
@@ -1741,7 +1715,7 @@ function MemoryModal({ onClose }) {
|
|
|
1741
1715
|
if (input === "x" && memories.length > 0) {
|
|
1742
1716
|
const idToDelete = memories[selectedIndex].id;
|
|
1743
1717
|
const updated = memories.filter((m) => m.id !== idToDelete);
|
|
1744
|
-
writeEncryptedJson(
|
|
1718
|
+
writeEncryptedJson(MEMORIES_PATH, updated);
|
|
1745
1719
|
setMemories(updated);
|
|
1746
1720
|
if (selectedIndex >= updated.length && updated.length > 0) {
|
|
1747
1721
|
setSelectedIndex(updated.length - 1);
|
|
@@ -2096,18 +2070,19 @@ ${list || "No saved chats found."}` }];
|
|
|
2096
2070
|
}
|
|
2097
2071
|
case "/reset": {
|
|
2098
2072
|
const runReset = async () => {
|
|
2099
|
-
const AGENT_ROOT7 = path16.join(path16.dirname(fileURLToPath9(import.meta.url)), "../");
|
|
2100
|
-
const logsDir = path16.join(AGENT_ROOT7, "logs");
|
|
2101
|
-
const secretDir = path16.join(AGENT_ROOT7, "secret");
|
|
2102
|
-
const settingsFile = path16.join(AGENT_ROOT7, "settings.json");
|
|
2103
2073
|
try {
|
|
2104
2074
|
setMessages((prev) => {
|
|
2105
2075
|
setCompletedIndex(prev.length + 1);
|
|
2106
2076
|
return [...prev, { id: Date.now(), role: "system", text: "\u2622\uFE0F [NUCLEAR] Initiating reset..." }];
|
|
2107
2077
|
});
|
|
2108
|
-
if (fs14.existsSync(
|
|
2109
|
-
if (fs14.existsSync(
|
|
2110
|
-
if (fs14.existsSync(
|
|
2078
|
+
if (fs14.existsSync(LOGS_DIR)) fs14.removeSync(LOGS_DIR);
|
|
2079
|
+
if (fs14.existsSync(SECRET_DIR)) fs14.removeSync(SECRET_DIR);
|
|
2080
|
+
if (fs14.existsSync(SETTINGS_FILE)) fs14.removeSync(SETTINGS_FILE);
|
|
2081
|
+
try {
|
|
2082
|
+
const items = fs14.readdirSync(FLUXFLOW_DIR);
|
|
2083
|
+
if (items.length === 0) fs14.removeSync(FLUXFLOW_DIR);
|
|
2084
|
+
} catch (e) {
|
|
2085
|
+
}
|
|
2111
2086
|
setTimeout(() => {
|
|
2112
2087
|
setActiveView("exit");
|
|
2113
2088
|
setTimeout(() => process.exit(0), 500);
|