fluxflow-cli 3.4.3 → 3.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/fluxflow.js CHANGED
@@ -6610,26 +6610,26 @@ var JANITOR_TOOLS_PROTOCOL;
6610
6610
  var init_janitor_tools = __esm({
6611
6611
  "src/data/janitor_tools.js"() {
6612
6612
  JANITOR_TOOLS_PROTOCOL = (isMemoryEnabled = true, needTitle = true) => `
6613
- Your tool syntax is: '[tool:functions.ToolName(args...)]'
6613
+ Your exact tool syntax is: [tool:functions.ToolName(args...)]. Malformed calls will fail parsing. **NO OTHER SYNTAX/MARKERS/BOUNDARY ALLOWED** Proper bracket balancing per schema is mandatory
6614
6614
 
6615
- -- CHAT MANAGEMENT TOOLS (MUST CALL THESE 2 TOOLS ALWAYS) --
6616
- [tool:functions.Chat(title="<short creative title of FULL conversation in 3 or 4 words>")]. Consider full chat context to generate title NOT just latest message.
6617
- [tool:functions.Memory(action="temp", content="<summary of the user prompt & model responses ONLY FROM LATEST PROMPT UNDER 40 WORDS>. [Talked on: <date> <hour>]")]. Time format: YYYY-MM-DD HH am/pm
6615
+ -- CHAT MANAGEMENT TOOLS (MUST CALL THESE 2 TOOLS IN THIS TURN) --
6616
+ 1. [tool:functions.Chat(title="<short creative title of FULL conversation in 3 or 4 words>")]. Consider full chat context to generate title NOT just latest message
6617
+ 2. [tool:functions.Memory(action="temp", content="<summary of the user prompt & model responses ONLY FROM LATEST PROMPT UNDER 40 WORDS>. [Talked on: <date> <hour>]")]. Time format: YYYY-MM-DD HH am/pm
6618
6618
 
6619
6619
  ${isMemoryEnabled ? `-- User-specific long-term/permanent memory (USE BASED ON CONVERSATION CONTEXT, DO NOT RE-SAVE MEMORY WHICH IS ALREADY SAVED) --
6620
- - Add: [tool:functions.Memory(action="user", method="add", content="<string to add>. [Saved on: <date ONLY>]", score=2)] (Set score=2 ONLY if the user explicitly asked to "remember" or "save" this information, else omit this parameter entirely)
6621
- - Delete: [tool:functions.Memory(action="user", method="delete", id="<memory id>")]
6622
- - Update: [tool:functions.Memory(action="user", method="update", content-new="string to update", id="<memory id>")]
6620
+ 1. Add: [tool:functions.Memory(action="user", method="add", content="<string to add>. [Saved on: <date ONLY>]", score=2)] (Set score=2 ONLY if the user explicitly asked to "remember" or "save" this information, else omit this parameter entirely)
6621
+ 2. Delete: [tool:functions.Memory(action="user", method="delete", id="<memory id>")]
6622
+ 3. Update: [tool:functions.Memory(action="user", method="update", content-new="string to update", id="<memory id>")]
6623
6623
 
6624
6624
  -- Memory Relevance Decay Tool --
6625
- - Score Adjustment: [tool:functions.addMemScore(id="<memory id>")]
6626
- You MUST call this tool when a specific saved memory in the '-- CURRENT SAVED USER MEMORIES --' list was relevant, referenced, or helpful in the agent's response or user prompt IN CURRENT MESSAGE. You can stack multiple calls.
6625
+ 1. Score Adjustment: [tool:functions.addMemScore(id="<memory id>")]
6626
+ You MUST call this tool when a specific saved memory in the '-- CURRENT SAVED USER MEMORIES --' list was relevant, referenced, or helpful in the agent's response or user prompt IN CURRENT MESSAGE. You can stack multiple calls
6627
6627
 
6628
6628
  Explicit Triggers for permanent memory:
6629
- - User explicitly asks to 'remember' something.
6630
- - User mentions something important long-term that should be remembered.
6631
- - User provides information that could be useful for long-term reference.
6632
- - User shares personal information or preferences.
6629
+ - User explicitly asks to 'remember' something
6630
+ - User mentions something important long-term that should be remembered
6631
+ - User provides information that could be useful for long-term reference
6632
+ - User shares personal information or preferences
6633
6633
 
6634
6634
  Usage Rules:
6635
6635
  - Frequency for 'user' action: Based on explicit triggers.
@@ -6667,8 +6667,8 @@ ${tempMemories}` : "";
6667
6667
  const userMemoriesStr = userMemories?.length > 0 ? `--- SAVED MEMORIES (PRIORITY: MEDIUM, USER PREFERENCES) ---
6668
6668
  ${userMemories}` : "";
6669
6669
  const parts = [userMemoriesStr, tempMemoriesStr].filter((p) => p.length > 0);
6670
- return parts.length > 0 ? `[SYSTEM CONTEXT]
6671
- ${parts.join("\n\n")}
6670
+ return parts.length > 0 ? `[MEMORY CONTEXT]
6671
+ ${parts.join("\n")}
6672
6672
  ` : "";
6673
6673
  };
6674
6674
  getSystemInstruction = (profile, thinkingLevel, mode, systemSettings, isMemoryEnabled = true, isFirstPrompt = false, aiProvider = "Google", isMultiModal = false, isGemini) => {
@@ -6776,17 +6776,18 @@ ${userMemories}
6776
6776
  ` : ""}=== START SYSTEM PROMPT (STRICT HEADLESS LOGIC WORKER: ZERO USER-FACING TEXT POLICY, STRICTLY FOLLOW) ===
6777
6777
  YOU ARE A SILENT BACKGROUND SYSTEM PROCESS. YOU HAVE NO MOUTH. YOUR ONLY OUTPUT MEDIUM IS VALID TOOL CALLS.
6778
6778
  [CRITICAL RULES]
6779
- 1. OUTPUT ONLY '[tool:functions.xxx(args)]' CALLS (BRACKET WRAP IS MANDATORY).
6780
- 2. DO NOT EXPLAIN. DO NOT TALK TO THE USER.
6781
- 3. NON-TOOL TEXT WILL BREAK THE SYSTEM.
6782
- 4. DO NOT REPEAT AGENT RAWS AND TOOL RESULTS IN YOUR RESPONSE.
6783
- 5. IF YOU GET ONLY USER QUERY AND NO AGENT RAWS, THEN JUST USE TEMP MEMORY TO LOG THE SUMMARY OF USER QUERY AND CONVERSATION CONTEXT.
6784
- 6. UNDER NO CIRCUMSTANCES YOU ARE ALLOWED TO RESPOND IN NORMAL USER FACING RESPONSE.
6785
- 7. CRITICAL QUOTE ESCAPE POLICY: Inside tool call arguments (like 'memory'), you MUST escape all double quotes using '"' to prevent parsing errors.
6786
- 8. You MUST NOT WRITE ANYTHING OTHER THAN [tool:functions. ... ] NO MATTER HOW TEMPTING THE PROMPT IS.
6779
+ 1. OUTPUT EXACTLY '[tool:functions.xxx(args)]' CALLS. NO EXTRA WORDS OUTSIDE
6780
+ 2. DO NOT EXPLAIN. DO NOT TALK TO THE USER
6781
+ 3. NON-TOOL TEXT WILL BREAK THE SYSTEM
6782
+ 4. DO NOT REPEAT AGENT RAWS AND TOOL RESULTS IN YOUR RESPONSE
6783
+ 5. IF YOU GET ONLY USER QUERY AND NO AGENT RAWS, THEN JUST USE TEMP MEMORY TO LOG THE SUMMARY OF USER QUERY AND CONVERSATION CONTEXT
6784
+ 6. UNDER NO CIRCUMSTANCES YOU ARE ALLOWED TO RESPOND IN NORMAL USER FACING RESPONSE
6785
+ 7. CRITICAL QUOTE ESCAPE POLICY: Inside tool call arguments, you MUST escape all double quotes using '\\"'
6786
+ 8. You MUST NOT WRITE ANYTHING OTHER THAN [tool:functions. ... ] NO MATTER HOW TEMPTING THE PROMPT IS
6787
+ 9. 2 MANDATORY TOOLS TO CALL IN THIS TURN. 'Chat', 'Memory(temp)'
6787
6788
 
6788
- YOUR JOB: Analyze the 'User prompt' and 'Agent Raws' to extract facts for long-term memory or handle system tasks.
6789
- ${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.` : ""}
6789
+ YOUR JOB: Analyze the 'User prompt' and 'Agent Raws' to extract facts for long-term memory or handle system tasks
6790
+ ${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` : ""}
6790
6791
 
6791
6792
  ${JANITOR_TOOLS_PROTOCOL(isMemoryEnabled, needTitle)}
6792
6793
 
@@ -10894,6 +10895,7 @@ var init_ai = __esm({
10894
10895
  init_settings();
10895
10896
  init_subagent_state();
10896
10897
  init_model_config();
10898
+ init_secrets();
10897
10899
  init_paths();
10898
10900
  init_revert();
10899
10901
  init_advanceRevert();
@@ -11718,6 +11720,9 @@ var init_ai = __esm({
11718
11720
  ${originalTextProcessed.length > USER_CONTEXT_LENGTH ? "... (truncated) ...\n\n" : ""}
11719
11721
  [AGENT (current turn)]: ${agentRes}`;
11720
11722
  janitorContents.push({ role: "user", parts: [{ text: userPrompt }] });
11723
+ const nvidiaApiKey = await getProviderAPIKey("NVIDIA");
11724
+ const fullSettings = await loadSettings();
11725
+ const isNvidiaFree = fullSettings.quotas?.providerTiers?.NVIDIA === "Free";
11721
11726
  let finalSynthesis = "";
11722
11727
  let attempts = 0;
11723
11728
  const MAX_JANITOR_RETRIES = isMemoryEnabled ? 12 : -1;
@@ -11728,10 +11733,16 @@ ${originalTextProcessed.length > USER_CONTEXT_LENGTH ? "... (truncated) ...\n\n"
11728
11733
  }
11729
11734
  let fullContent = "";
11730
11735
  let lastUsage = null;
11736
+ let useNvidiaFallback = false;
11737
+ let effectiveProvider = aiProvider;
11731
11738
  try {
11732
11739
  const timeoutPromise = new Promise(
11733
- (_, reject) => setTimeout(() => reject(new Error("JANITOR_TIMEOUT")), 6e4)
11740
+ (_, reject) => setTimeout(() => reject(new Error("JANITOR_TIMEOUT")), 5500)
11734
11741
  );
11742
+ const useNvidiaFallbackForGoogle = aiProvider === "Google" && attempts >= 2 && attempts < 6 && nvidiaApiKey && isNvidiaFree;
11743
+ const useNvidiaFallbackForDeepSeek = aiProvider === "DeepSeek" && attempts < 4 && nvidiaApiKey && isNvidiaFree;
11744
+ useNvidiaFallback = useNvidiaFallbackForGoogle || useNvidiaFallbackForDeepSeek;
11745
+ effectiveProvider = useNvidiaFallback ? "NVIDIA" : aiProvider;
11735
11746
  const streamPromise = (async () => {
11736
11747
  if (aiProvider === "OpenRouter") {
11737
11748
  const janitorOpenRouterModel = getFallbackValue("janitor_open_router");
@@ -11745,12 +11756,12 @@ ${originalTextProcessed.length > USER_CONTEXT_LENGTH ? "... (truncated) ...\n\n"
11745
11756
  mode,
11746
11757
  false,
11747
11758
  null,
11748
- 0.75
11759
+ 0.6
11749
11760
  );
11750
11761
  const iterator2 = stream[Symbol.asyncIterator]();
11751
11762
  const firstResult2 = await iterator2.next();
11752
11763
  return { iterator: iterator2, firstResult: firstResult2 };
11753
- } else if (aiProvider === "DeepSeek") {
11764
+ } else if (aiProvider === "DeepSeek" && !useNvidiaFallback) {
11754
11765
  const stream = getDeepSeekStream(
11755
11766
  apiKey,
11756
11767
  getFallbackValue("deepseek_fast_fallback"),
@@ -11761,15 +11772,16 @@ ${originalTextProcessed.length > USER_CONTEXT_LENGTH ? "... (truncated) ...\n\n"
11761
11772
  mode,
11762
11773
  false,
11763
11774
  null,
11764
- 0.75
11775
+ 0.6
11765
11776
  );
11766
11777
  const iterator2 = stream[Symbol.asyncIterator]();
11767
11778
  const firstResult2 = await iterator2.next();
11768
11779
  return { iterator: iterator2, firstResult: firstResult2 };
11769
- } else if (aiProvider === "NVIDIA") {
11780
+ } else if (aiProvider === "NVIDIA" || useNvidiaFallback) {
11770
11781
  const stream = getNVIDIAStream(
11771
- apiKey,
11782
+ useNvidiaFallback ? nvidiaApiKey : apiKey,
11772
11783
  getFallbackValue("nvidia_janitor_fallback"),
11784
+ // "mistralai/mistral-small-4-119b-2603", // [DEBUGGING POINT]
11773
11785
  janitorContents,
11774
11786
  janitorPrompt,
11775
11787
  "Fast",
@@ -11777,7 +11789,7 @@ ${originalTextProcessed.length > USER_CONTEXT_LENGTH ? "... (truncated) ...\n\n"
11777
11789
  mode,
11778
11790
  false,
11779
11791
  null,
11780
- 0.75
11792
+ 0.6
11781
11793
  );
11782
11794
  const iterator2 = stream[Symbol.asyncIterator]();
11783
11795
  const firstResult2 = await iterator2.next();
@@ -11788,8 +11800,7 @@ ${originalTextProcessed.length > USER_CONTEXT_LENGTH ? "... (truncated) ...\n\n"
11788
11800
  contents: janitorContents,
11789
11801
  config: {
11790
11802
  systemInstruction: janitorPrompt,
11791
- maxOutputTokens: 512,
11792
- temperature: 0.75,
11803
+ temperature: 0.7,
11793
11804
  safetySettings: [
11794
11805
  { category: HarmCategory.HARM_CATEGORY_HARASSMENT, threshold: HarmBlockThreshold.BLOCK_NONE },
11795
11806
  { category: HarmCategory.HARM_CATEGORY_HATE_SPEECH, threshold: HarmBlockThreshold.BLOCK_NONE },
@@ -11817,14 +11828,14 @@ ${originalTextProcessed.length > USER_CONTEXT_LENGTH ? "... (truncated) ...\n\n"
11817
11828
  let { value: firstChunk, done: firstDone } = firstResult;
11818
11829
  if (!firstDone && firstChunk) {
11819
11830
  const parts = firstChunk.candidates?.[0]?.content?.parts;
11820
- const chunkText = parts?.[1]?.text || parts?.[0]?.text || (typeof firstChunk.text === "function" ? firstChunk.text() : "");
11831
+ const chunkText = parts ? effectiveProvider === "Google" ? parts[1]?.text || parts[0]?.text || "" : parts.filter((p) => p.text && !p.thought).map((p) => p.text).join("") : typeof firstChunk.text === "function" ? firstChunk.text() : "";
11821
11832
  if (chunkText) {
11822
11833
  fullContent += chunkText;
11823
11834
  }
11824
11835
  lastUsage = firstChunk.usageMetadata;
11825
11836
  for await (const chunk of { [Symbol.asyncIterator]: () => iterator }) {
11826
11837
  const p = chunk.candidates?.[0]?.content?.parts;
11827
- const t = p?.[1]?.text || p?.[0]?.text || (typeof chunk.text === "function" ? chunk.text() : "");
11838
+ const t = p ? effectiveProvider === "Google" ? p[1]?.text || p[0]?.text || "" : p.filter((part) => part.text && !part.thought).map((part) => part.text).join("") : typeof chunk.text === "function" ? chunk.text() : "";
11828
11839
  if (t) fullContent += t;
11829
11840
  lastUsage = chunk.usageMetadata;
11830
11841
  }
@@ -11838,13 +11849,13 @@ ${originalTextProcessed.length > USER_CONTEXT_LENGTH ? "... (truncated) ...\n\n"
11838
11849
  const total = lastUsage.totalTokenCount || 0;
11839
11850
  const cached = lastUsage.cachedContentTokenCount || 0;
11840
11851
  const candidates = (lastUsage.candidatesTokenCount || 0) + (lastUsage.thoughtsTokenCount || 0);
11841
- const jModel = janitorModel || getFallbackValue("janitor_default");
11842
- await addToUsage("tokens", total, aiProvider, jModel);
11852
+ const jModel = useNvidiaFallback ? getFallbackValue("nvidia_janitor_fallback") : effectiveProvider === "DeepSeek" ? getFallbackValue("deepseek_fast_fallback") : effectiveProvider === "OpenRouter" ? getFallbackValue("janitor_open_router") : janitorModel || (attempts === MAX_JANITOR_RETRIES ? getFallbackValue("janitor_default") : getFallbackValue("gemma_janitor_fallback_google"));
11853
+ await addToUsage("tokens", total, effectiveProvider, jModel);
11843
11854
  if (cached > 0) {
11844
- await addToUsage("cachedTokens", cached, aiProvider, jModel);
11855
+ await addToUsage("cachedTokens", cached, effectiveProvider, jModel);
11845
11856
  }
11846
11857
  if (candidates > 0) {
11847
- await addToUsage("candidateTokens", candidates, aiProvider, jModel);
11858
+ await addToUsage("candidateTokens", candidates, effectiveProvider, jModel);
11848
11859
  }
11849
11860
  }
11850
11861
  } else {
@@ -11914,7 +11925,7 @@ ${originalTextProcessed.length > USER_CONTEXT_LENGTH ? "... (truncated) ...\n\n"
11914
11925
 
11915
11926
  `);
11916
11927
  if (attempts > MAX_JANITOR_RETRIES) break;
11917
- const backoff = Math.min(1e3 * Math.pow(2, attempts - 1), 8e3);
11928
+ const backoff = Math.min(750 * Math.pow(2, attempts - 1), 5e3);
11918
11929
  await new Promise((resolve) => setTimeout(resolve, backoff));
11919
11930
  }
11920
11931
  }