fluxflow-cli 1.5.0 → 1.5.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.
Files changed (2) hide show
  1. package/dist/fluxflow.js +119 -85
  2. package/package.json +1 -1
package/dist/fluxflow.js CHANGED
@@ -754,28 +754,35 @@ Current date and Time is: ${dateTimeStr}
754
754
  --- END SYSTEM INSTRUCTION ---`.trim();
755
755
  };
756
756
  getJanitorInstruction = (originalText, agentRaws, userMemories = "", isMemoryEnabled = true, needTitle = false) => {
757
- return `ORIGINAL USER PROMPT: ${originalText.substring(0, 500)}
757
+ let agentRes = `${agentRaws.replace(/tool:functions\..*\n/g, "").replace(/<think>.*<\/think>/g, "").replace(/\[Prompted on:.*?\]/g, "").replace(/\[turn: continue\]/g, "").replace(/\[turn: finish\]/g, "").replace(/\[TOOL_RESULTS\]/g, "").replace(/\[tool_results\]/g, "").substring(0, 3500)}`;
758
+ if (agentRes.length > 3500) {
759
+ agentRes += "\n... (truncated) ...";
760
+ }
761
+ let originalTextProcessed = originalText.replace(/\[Prompted on:.*?\]/g, "");
762
+ return `USER PROMPT: ${originalTextProcessed.substring(0, 600)}${originalTextProcessed.length > 600 ? "\n... (truncated) ..." : ""}
758
763
  AGENT RAWS (responses from this turn):
759
- ${agentRaws.substring(0, 2e3).replace(/tool:functions\..*\n/g, "").replace(/<think>.*<\/think>/g, "").replace(/\[Prompted on:.*?\]/g, "").replace(/\[turn: continue\]/g, "").replace(/\[turn: finish\]/g, "")}${agentRaws.length > 1500 ? "\n... (truncated) ..." : ""}
764
+ ${agentRes}
765
+ ${userMemories ? `
766
+
767
+ -- CURRENT PERSISTENT USER MEMORIES --
768
+ ${userMemories}
769
+ -------------------------------------------------
770
+ ` : ""}
760
771
 
761
772
  --- START SYSTEM INSTRUCTION (STRICT HEADLESS LOGIC WORKER: ZERO USER-FACING TEXT POLICY) ---
762
- YOU ARE A SILENT BACKGROUND SYSTEM PROCESS. YOU HAVE NO MOUTH. YOUR ONLY OUTPUT MEDIUM IS VALID TOOL CALL SYNTAX.
773
+ YOU ARE A SILENT BACKGROUND SYSTEM PROCESS. YOU HAVE NO MOUTH. YOUR ONLY OUTPUT MEDIUM IS VALID TOOL CALLS.
763
774
  [CRITICAL RULES]
764
775
  1. OUTPUT ONLY 'tool:functions.xxx' CALLS.
765
- 2. DO NOT EXPLAIN. DO NOT SUMMARIZE AGENT RAWS. DO NOT TALK TO THE USER.
776
+ 2. DO NOT EXPLAIN. DO NOT TALK TO THE USER.
766
777
  3. NON-TOOL TEXT WILL BREAK THE SYSTEM.
767
- 4. DO NOT REPEAT AGENT RAWS IN YOUR RESPONSE.
768
- 5. IF YOU GET ONLY USER RESPONSE AND NO AGENT RAWS, THEN JUST USE TEMP MEMORY TO LOG THE SUMMARY OF USER QUERY.
778
+ 4. DO NOT REPEAT AGENT RAWS AND TOOL RESULTS IN YOUR RESPONSE.
779
+ 5. IF YOU GET ONLY USER QUERY AND NO AGENT RAWS, THEN JUST USE TEMP MEMORY TO LOG THE SUMMARY OF USER QUERY.
769
780
 
770
781
  YOUR JOB: Analyze the 'User prompt' and 'Agent Raws' to extract facts for long-term memory or handle system tasks.
771
782
  ${isMemoryEnabled ? `If user tell something that is important (like, hobbies, preferences, facts about user, hates, likes, etc) to know user better over time, use long term memory tools.` : ""}
772
783
 
773
784
  ${JANITOR_TOOLS_PROTOCOL(isMemoryEnabled, needTitle)}
774
785
 
775
- ${userMemories ? `-- CURRENT PERSISTENT USER MEMORIES --
776
- ${userMemories}
777
- -------------------------------------------------
778
- ` : ""}
779
786
  Current date and Time: ${(/* @__PURE__ */ new Date()).toLocaleString()}
780
787
 
781
788
  --- END SYSTEM INSTRUCTION ---`.trim();
@@ -984,59 +991,69 @@ var init_web_search = __esm({
984
991
  web_search = async (argsString) => {
985
992
  const { query, limit = 10 } = parseArgs(argsString);
986
993
  if (!query) return 'ERROR: Missing "query" argument for web_search.';
987
- try {
988
- await new Promise((r) => setTimeout(r, Math.random() * 1e3 + 500));
989
- const response = await cuimp.get(`https://html.duckduckgo.com/html/?q=${encodeURIComponent(query)}`, {
990
- headers: {
991
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36"
992
- }
993
- });
994
- const html = response.data;
995
- const results = [];
996
- const resultRegex = /<a[^>]*class="result__a"[^>]*href="([^"]+)"[^>]*>([\s\S]*?)<\/a>[\s\S]*?<a[^>]*class="result__snippet"[^>]*>([\s\S]*?)<\/a>/g;
997
- let match;
998
- let count = 0;
999
- while ((match = resultRegex.exec(html)) !== null && count < limit) {
1000
- let url = match[1];
1001
- if (url.includes("uddg=")) {
1002
- url = decodeURIComponent(url.split("uddg=")[1].split("&")[0]);
1003
- }
1004
- const title = match[2].replace(/<[^>]*>/g, "").trim();
1005
- const snippet = match[3].replace(/<[^>]*>/g, "").trim();
1006
- results.push(`${count + 1}. ${title}
994
+ const maxRetries = 3;
995
+ let lastError = null;
996
+ for (let attempt = 1; attempt <= maxRetries; attempt++) {
997
+ try {
998
+ const userAgents = [
999
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36",
1000
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36",
1001
+ "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36",
1002
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0"
1003
+ ];
1004
+ const randomUA = userAgents[Math.floor(Math.random() * userAgents.length)];
1005
+ const jitter = attempt === 1 ? Math.random() * 1e3 + 500 : Math.random() * 2e3 + 1e3;
1006
+ await new Promise((r) => setTimeout(r, jitter));
1007
+ const response = await cuimp.get(`https://html.duckduckgo.com/html/?q=${encodeURIComponent(query)}`, {
1008
+ headers: {
1009
+ "User-Agent": randomUA,
1010
+ "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8",
1011
+ "Accept-Language": "en-US,en;q=0.9",
1012
+ "Referer": "https://duckduckgo.com/",
1013
+ "Upgrade-Insecure-Requests": "1",
1014
+ "Cache-Control": "max-age=0"
1015
+ }
1016
+ });
1017
+ const html = response.data;
1018
+ const results = [];
1019
+ const resultRegex = /<a[^>]*class="result__a"[^>]*href="([^"]+)"[^>]*>([\s\S]*?)<\/a>[\s\S]*?<a[^>]*class="result__snippet"[^>]*>([\s\S]*?)<\/a>/g;
1020
+ let match;
1021
+ let count = 0;
1022
+ while ((match = resultRegex.exec(html)) !== null && count < limit) {
1023
+ let url = match[1];
1024
+ if (url.includes("uddg=")) {
1025
+ url = decodeURIComponent(url.split("uddg=")[1].split("&")[0]);
1026
+ }
1027
+ const title = match[2].replace(/<[^>]*>/g, "").trim();
1028
+ const snippet = match[3].replace(/<[^>]*>/g, "").trim();
1029
+ results.push(`${count + 1}. ${title}
1007
1030
  Source: ${url}
1008
1031
  Snippet: ${snippet}`);
1009
- count++;
1010
- }
1011
- const toolLogDir = path6.join(LOGS_DIR, "tools");
1012
- if (!fs6.existsSync(toolLogDir)) {
1013
- fs6.mkdirSync(toolLogDir, { recursive: true });
1014
- }
1015
- fs6.appendFileSync(path6.join(toolLogDir, "search-results.log"), `RESULTS ${(/* @__PURE__ */ new Date()).toISOString()} -
1016
- Query: [${query}]. Results Count: ${results.length}.
1017
- Results: ${results}
1018
-
1019
-
1020
- `);
1021
- if (results.length === 0) {
1022
- if (html.includes("anomaly")) {
1023
- const toolErrDir = path6.join(LOGS_DIR, "tools");
1024
- if (!fs6.existsSync(toolErrDir)) {
1025
- fs6.mkdirSync(toolErrDir, { recursive: true });
1032
+ count++;
1033
+ }
1034
+ if (results.length === 0) {
1035
+ if (html.includes("anomaly")) {
1036
+ throw new Error("DDG_ANOMALY_DETECTED");
1026
1037
  }
1027
- fs6.appendFileSync(path6.join(toolErrDir, "error.log"), `ERROR ${(/* @__PURE__ */ new Date()).toISOString()} - DDG detected unusual activity. Cuimp impersonation might need adjustment.
1028
- `);
1029
- throw new Error("DDG detected unusual activity. Cuimp impersonation might need adjustment.");
1038
+ return `No results found for query: [${query}].`;
1030
1039
  }
1031
- return `No results found for query: [${query}].`;
1032
- }
1033
- const finalResults = results.join("\n\n");
1034
- return `Search results for [${query}]:
1040
+ const finalResults = results.join("\n\n");
1041
+ return `Search results for [${query}]:
1035
1042
 
1036
1043
  ${finalResults}`;
1037
- } catch (err) {
1038
- return `ERROR: Search failed. Unable to read.`;
1044
+ } catch (err) {
1045
+ lastError = err;
1046
+ const toolErrDir = path6.join(LOGS_DIR, "tools");
1047
+ if (!fs6.existsSync(toolErrDir)) fs6.mkdirSync(toolErrDir, { recursive: true });
1048
+ fs6.appendFileSync(path6.join(toolErrDir, "error.log"), `ERROR ${(/* @__PURE__ */ new Date()).toISOString()} - Attempt ${attempt}/${maxRetries} failed: ${err.message}
1049
+ `);
1050
+ if (attempt < maxRetries) {
1051
+ const backoff = Math.pow(2, attempt) * 1e3;
1052
+ await new Promise((r) => setTimeout(r, backoff));
1053
+ }
1054
+ }
1039
1055
  }
1056
+ return `ERROR: Search failed after ${maxRetries} attempts. Last error: ${lastError.message}`;
1040
1057
  };
1041
1058
  }
1042
1059
  });
@@ -1052,39 +1069,56 @@ var init_web_scrape = __esm({
1052
1069
  web_scrape = async (args) => {
1053
1070
  const urlMatch = args.match(/url\s*=\s*["'](.*)["']/);
1054
1071
  const url = urlMatch ? urlMatch[1] : args;
1055
- try {
1056
- const response = await cuimp2.get(url, {
1057
- headers: {
1058
- "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36",
1059
- "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
1060
- "Accept-Language": "en-US,en;q=0.5"
1061
- }
1062
- });
1063
- let html = response.data;
1064
- if (!html) throw new Error("No content received from URL.");
1065
- html = html.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "");
1066
- html = html.replace(/<style\b[^<]*(?:(?!<\/style>)<[^<]*)*<\/style>/gi, "");
1067
- html = html.replace(/<nav\b[^<]*(?:(?!<\/nav>)<[^<]*)*<\/nav>/gi, "");
1068
- html = html.replace(/<footer\b[^<]*(?:(?!<\/footer>)<[^<]*)*<\/footer>/gi, "");
1069
- html = html.replace(/<header\b[^<]*(?:(?!<\/header>)<[^<]*)*<\/header>/gi, "");
1070
- let text = html.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
1071
- const finalContent = text.substring(0, 2e4);
1072
- const toolLogDir = path7.join(LOGS_DIR, "tools");
1073
- if (!fs7.existsSync(toolLogDir)) {
1074
- fs7.mkdirSync(toolLogDir, { recursive: true });
1075
- }
1076
- fs7.appendFileSync(path7.join(toolLogDir, "search-scraped.log"), `RESULTS ${(/* @__PURE__ */ new Date()).toISOString()} -
1077
- Query: [${url}].
1078
- Results: ${finalContent}
1079
-
1072
+ const maxRetries = 3;
1073
+ let lastError = null;
1074
+ for (let attempt = 1; attempt <= maxRetries; attempt++) {
1075
+ try {
1076
+ const userAgents = [
1077
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36",
1078
+ "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36",
1079
+ "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36",
1080
+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:126.0) Gecko/20100101 Firefox/126.0"
1081
+ ];
1082
+ const randomUA = userAgents[Math.floor(Math.random() * userAgents.length)];
1083
+ const jitter = attempt === 1 ? Math.random() * 1e3 + 500 : Math.random() * 2e3 + 1e3;
1084
+ await new Promise((r) => setTimeout(r, jitter));
1085
+ const response = await cuimp2.get(url, {
1086
+ headers: {
1087
+ "User-Agent": randomUA,
1088
+ "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8",
1089
+ "Accept-Language": "en-US,en;q=0.9",
1090
+ "Referer": "https://www.google.com/",
1091
+ "Upgrade-Insecure-Requests": "1",
1092
+ "Cache-Control": "max-age=0"
1093
+ }
1094
+ });
1095
+ let html = response.data;
1096
+ if (!html) throw new Error("EMPTY_RESPONSE");
1097
+ html = html.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "");
1098
+ html = html.replace(/<style\b[^<]*(?:(?!<\/style>)<[^<]*)*<\/style>/gi, "");
1099
+ html = html.replace(/<nav\b[^<]*(?:(?!<\/nav>)<[^<]*)*<\/nav>/gi, "");
1100
+ html = html.replace(/<footer\b[^<]*(?:(?!<\/footer>)<[^<]*)*<\/footer>/gi, "");
1101
+ html = html.replace(/<header\b[^<]*(?:(?!<\/header>)<[^<]*)*<\/header>/gi, "");
1102
+ let text = html.replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
1103
+ const finalContent = text.substring(0, 2e4);
1104
+ const toolLogDir = path7.join(LOGS_DIR, "tools");
1105
+ if (!fs7.existsSync(toolLogDir)) fs7.mkdirSync(toolLogDir, { recursive: true });
1106
+ fs7.appendFileSync(path7.join(toolLogDir, "search-scraped.log"), `RESULTS ${(/* @__PURE__ */ new Date()).toISOString()} -
1107
+ URL: [${url}]. Content Length: ${finalContent.length}
1080
1108
 
1081
1109
  `);
1082
- return `CONTENT FROM [${url}]:
1110
+ return `CONTENT FROM [${url}]:
1083
1111
 
1084
1112
  ${finalContent}${text.length > 2e4 ? "\n\n[TRUNCATED AT 20K CHARS]" : ""}`;
1085
- } catch (err) {
1086
- return `ERROR: Failed to read page at ${url}. Unable to read.`;
1113
+ } catch (err) {
1114
+ lastError = err;
1115
+ if (attempt < maxRetries) {
1116
+ const backoff = Math.pow(2, attempt) * 1e3;
1117
+ await new Promise((r) => setTimeout(r, backoff));
1118
+ }
1119
+ }
1087
1120
  }
1121
+ return `ERROR: Scrape failed after ${maxRetries} attempts. Last error: ${lastError.message}`;
1088
1122
  };
1089
1123
  }
1090
1124
  });
@@ -4039,7 +4073,7 @@ var init_app = __esm({
4039
4073
  init_setup();
4040
4074
  SESSION_START_TIME = Date.now();
4041
4075
  CHANGELOG_URL = "https://fluxflow-cli.onrender.com/changelog.html";
4042
- versionFluxflow = "1.5.0";
4076
+ versionFluxflow = "1.5.1";
4043
4077
  updatedOn = "2026-05-01";
4044
4078
  ResolutionModal = ({ data, onResolve, onEdit }) => /* @__PURE__ */ React10.createElement(Box10, { flexDirection: "column", borderStyle: "round", borderColor: "magenta", paddingX: 2, paddingY: 1, width: "100%" }, /* @__PURE__ */ React10.createElement(Text10, { color: "magenta", bold: true, underline: true }, "\u{1F7E3} STEERING HINT RESOLUTION"), /* @__PURE__ */ React10.createElement(Text10, { marginTop: 1 }, "The agent already finished the task (turn: finish) before your hint was consumed."), /* @__PURE__ */ React10.createElement(Box10, { marginTop: 1, backgroundColor: "#222", paddingX: 1, width: "100%" }, /* @__PURE__ */ React10.createElement(Text10, { italic: true, color: "gray" }, '"', data, '"')), /* @__PURE__ */ React10.createElement(Box10, { marginTop: 1 }, /* @__PURE__ */ React10.createElement(Text10, { color: "cyan" }, "How would you like to proceed?")), /* @__PURE__ */ React10.createElement(Box10, { marginTop: 1 }, /* @__PURE__ */ React10.createElement(
4045
4079
  CommandMenu,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fluxflow-cli",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "A high-fidelity agentic terminal assistant for the Flux Era.",
5
5
  "keywords": [
6
6
  "ai",