fluxflow-cli 3.18.1 → 3.18.2
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 +107 -72
- package/package.json +2 -2
package/dist/fluxflow.js
CHANGED
|
@@ -3134,7 +3134,7 @@ var init_text = __esm({
|
|
|
3134
3134
|
if (!msg.isStreaming && blocksCache.has(cacheKey)) {
|
|
3135
3135
|
return blocksCache.get(cacheKey);
|
|
3136
3136
|
}
|
|
3137
|
-
const text = flattenString(cleanSignals(msg.text || ""));
|
|
3137
|
+
const text = flattenString(cleanSignals(msg.text || "", msg.role === "think"));
|
|
3138
3138
|
const streamCacheKey = `${msg.id}-${columns}`;
|
|
3139
3139
|
let cachedBlocks = /* @__PURE__ */ new Map();
|
|
3140
3140
|
if (msg.isStreaming) {
|
|
@@ -3437,13 +3437,29 @@ var init_text = __esm({
|
|
|
3437
3437
|
}
|
|
3438
3438
|
return inCode;
|
|
3439
3439
|
};
|
|
3440
|
-
REGEX_CLEAN_SIGNALS = /\[SYSTEM\][\s\S]*?\[\/SYSTEM\]|<(think|thought)>[\s\S]
|
|
3440
|
+
REGEX_CLEAN_SIGNALS = /\[SYSTEM\][\s\S]*?\[\/SYSTEM\]|<(think|thought)>[\s\S]*?<\/(think|thought)>|\[ANSWER\][\s\S]*?(?:\[\/ANSWER\]|$)|\[TOOL RESULT\]:?\s*|^\s*(SUCCESS|ERROR):.*(\r?\n)?|\[\s*turn\s*:\s*(continue|finish)\s*\]|\[\[END\]\]|\[\s*turn\s*:?.*?$|\n\s*turn\s*:?.*?$|\[\s*(?:turn|ANSWER|TOOL).*?$|\n\nResponded on .*|\n\n\[Prompted on: .*\]|@\[TerminalName:.*?, ProcessId:.*?\]/gmi;
|
|
3441
3441
|
REGEX_ARROWS_ALL = /(\$?\\?\/?\\rightarrow\$?|\$\\rightarrow\$)|(\$?\\?\/?\\leftarrow\$?|\$\\leftarrow\$)|(\$?\\?\/?\\uparrow\$?|\$\\uparrow\$)|(\$?\\?\/?\\downarrow\$?|\$\\downarrow\$)|(\$?\\?\/?\\leftrightarrow\$?|\$\\leftrightarrow\$)/gi;
|
|
3442
3442
|
REGEX_TOOLS = /\b(write_file|update_file|read_folder|view_file|exec_command|web_search|web_scrape|search_keyword|write_pdf|write_docx|generate_image)\b/gi;
|
|
3443
|
-
bypassBacktick =
|
|
3444
|
-
cleanSignals = (text) => {
|
|
3443
|
+
bypassBacktick = true;
|
|
3444
|
+
cleanSignals = (text, isThinkRole = false) => {
|
|
3445
3445
|
if (!text) return text;
|
|
3446
|
+
if (isThinkRole) {
|
|
3447
|
+
return text.replace(/^<(think|thought)>/gi, "").replace(/<\/(think|thought)>$/gi, "");
|
|
3448
|
+
}
|
|
3446
3449
|
let result = text.replace(REGEX_INITIAL_THINK, "</think>").replace(REGEX_INITIAL_TOOL, (match, _nl, offset, str) => !bypassBacktick && isInsideBacktick(str, offset) ? match : "");
|
|
3450
|
+
if (result && result.includes("[tool:")) {
|
|
3451
|
+
result = result.replace(/<(\w+)(?:[^>]*)>\s*([\s\S]*?\[tool:[^\]]*\][\s\S]*?)\s*<\/\1>/gi, (match, tagName, innerContent) => {
|
|
3452
|
+
if (innerContent && innerContent.includes("[tool:")) return innerContent.trim();
|
|
3453
|
+
return match;
|
|
3454
|
+
});
|
|
3455
|
+
if (bypassBacktick) {
|
|
3456
|
+
result = result.replace(/```(?:tool|yaml|function|json)?\s*\n?([\s\S]*?)\n?\```/gi, (match, inner) => {
|
|
3457
|
+
if (inner.includes("[tool:")) return inner.trim();
|
|
3458
|
+
return match;
|
|
3459
|
+
});
|
|
3460
|
+
}
|
|
3461
|
+
result = result.replace(/<(\w+)(?:[^>]*)>\r?\n?/gi, "").replace(/\r?\n?<\/\w+(?:[^>]*)>/gi, "");
|
|
3462
|
+
}
|
|
3447
3463
|
const trigger = "tool:functions.";
|
|
3448
3464
|
const subagentTrigger = "agent:generalist.";
|
|
3449
3465
|
if (result.toLowerCase().includes(trigger) || result.toLowerCase().includes(subagentTrigger)) {
|
|
@@ -5561,7 +5577,7 @@ var init_ChatLayout = __esm({
|
|
|
5561
5577
|
return /* @__PURE__ */ React4.createElement(MarkdownText, { key: i, text: cleanPart, color: "gray", columns: availableWidth, italic: true });
|
|
5562
5578
|
}));
|
|
5563
5579
|
};
|
|
5564
|
-
REGEX_MD_TOKENS = /(```[\s\S]*?```|`[
|
|
5580
|
+
REGEX_MD_TOKENS = /(```[\s\S]*?```|`[^`\r\n]+`|@\[.*?\]|\*\*.*?\*\*|\*.*?\*|\\\(.*?\\\)|\\\[.*?\\\]|\$.*?\$|\[.*?\]\s*\(.*?\)|\[.*?\]\s*\[.*?\]|https?:\/\/[^\s]+)/g;
|
|
5565
5581
|
REGEX_LATEX_FRAC = /\\frac\s*\{([^{}]*)\}\s*\{([^{}]*)\}/g;
|
|
5566
5582
|
REGEX_LATEX_STYLE = /(\\(?:mathbf|textbf|textit|underline|texttt)\{[^{}]*\})/g;
|
|
5567
5583
|
REGEX_MATH_MULT = /\\multiply|\\mul|\\times/g;
|
|
@@ -5708,13 +5724,17 @@ var init_ChatLayout = __esm({
|
|
|
5708
5724
|
if (part.startsWith("*") && part.endsWith("*")) {
|
|
5709
5725
|
return /* @__PURE__ */ React4.createElement(Text4, { key: j, italic: true, color: textColor }, /* @__PURE__ */ React4.createElement(InlineMarkdown, { text: part.slice(1, -1), color: textColor, italic, theme }));
|
|
5710
5726
|
}
|
|
5711
|
-
if (part.startsWith("`")
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
|
|
5717
|
-
|
|
5727
|
+
if (part.startsWith("`")) {
|
|
5728
|
+
if (part.endsWith("`") && part.length > 1) {
|
|
5729
|
+
const content = part.slice(1, -1);
|
|
5730
|
+
const formatted = content.replace(REGEX_AT_REF, (match, p1) => {
|
|
5731
|
+
return p1.split("/").pop().split("\\").pop().replace(REGEX_COLON_L, "#L");
|
|
5732
|
+
});
|
|
5733
|
+
const hasFileRef = content.includes("@[");
|
|
5734
|
+
return /* @__PURE__ */ React4.createElement(Text4, { key: j, color: highlightColor, bold: hasFileRef }, formatted);
|
|
5735
|
+
} else {
|
|
5736
|
+
return /* @__PURE__ */ React4.createElement(Text4, { key: j, color: highlightColor }, part.slice(1));
|
|
5737
|
+
}
|
|
5718
5738
|
}
|
|
5719
5739
|
if (part.startsWith("@[") && part.endsWith("]")) {
|
|
5720
5740
|
const filePath = part.slice(2, -1);
|
|
@@ -6087,9 +6107,12 @@ var init_ChatLayout = __esm({
|
|
|
6087
6107
|
if (part.startsWith("```")) {
|
|
6088
6108
|
const match = part.match(/```(\w*)\n?([\s\S]*?)(?:```|$)/);
|
|
6089
6109
|
const lang = match ? match[1] : "code";
|
|
6090
|
-
const
|
|
6110
|
+
const raw = match ? match[2] : part.replace(/^```\w*\n?/, "").replace(/```$/, "");
|
|
6111
|
+
const rawLines = raw.trimEnd().split("\n");
|
|
6112
|
+
const gutterWidth = String(rawLines.length).length;
|
|
6113
|
+
const codeWidth = columns - 7 - gutterWidth;
|
|
6114
|
+
const code = codeWidth > 5 ? wrapText(raw, codeWidth) : raw;
|
|
6091
6115
|
const codeLines = code.trimEnd().split("\n");
|
|
6092
|
-
const gutterWidth = String(codeLines.length).length;
|
|
6093
6116
|
return /* @__PURE__ */ React4.createElement(
|
|
6094
6117
|
Box3,
|
|
6095
6118
|
{
|
|
@@ -6275,7 +6298,7 @@ var init_ChatLayout = __esm({
|
|
|
6275
6298
|
return /* @__PURE__ */ React4.createElement(Box3, { marginBottom: 0, paddingX: 1, width: "100%" }, /* @__PURE__ */ React4.createElement(TerminalBox, { command: cmd, output: outputList, completed: true, columns, isPty, theme }));
|
|
6276
6299
|
}
|
|
6277
6300
|
const [animationDone, setAnimationDone] = React4.useState(!msg.isStreaming);
|
|
6278
|
-
const content = React4.useMemo(() => cleanSignals(msg.text), [msg.text]);
|
|
6301
|
+
const content = React4.useMemo(() => cleanSignals(msg.text, msg.role === "think"), [msg.text, msg.role]);
|
|
6279
6302
|
React4.useEffect(() => {
|
|
6280
6303
|
if (msg.isStreaming) setAnimationDone(false);
|
|
6281
6304
|
}, [msg.id]);
|
|
@@ -6301,7 +6324,7 @@ var init_ChatLayout = __esm({
|
|
|
6301
6324
|
finalContent.replace(/\r\n/g, "\n").replace(/\r/g, "\n").replace(/\\\n/g, "\n").replace(/\\$/, ""),
|
|
6302
6325
|
columns - 7
|
|
6303
6326
|
).split("\n").map((line, lineIdx) => /* @__PURE__ */ React4.createElement(Box3, { key: lineIdx, flexDirection: "row", width: "100%" }, /* @__PURE__ */ React4.createElement(Box3, { flexShrink: 0, width: 2 }, /* @__PURE__ */ React4.createElement(Text4, { bold: true, color: colors.userMsgText }, lineIdx === 0 ? ">" : " ")), /* @__PURE__ */ React4.createElement(Box3, { flexGrow: 1, marginLeft: 1 }, /* @__PURE__ */ React4.createElement(InlineMarkdown, { text: line, color: msg.color || colors.userMsgText, theme }))))
|
|
6304
|
-
), /* @__PURE__ */ React4.createElement(Box3, { width: columns - 1, height: 1, overflow: "hidden" }, /* @__PURE__ */ React4.createElement(Text4, { color: colors.userMsgBorder }, "\u2580".repeat(Math.max(1, columns - 1))))) : msg.role === "think" ? /* @__PURE__ */ React4.createElement(Box3, { flexDirection: "column", marginTop: 0, marginBottom: 0, paddingX:
|
|
6327
|
+
), /* @__PURE__ */ React4.createElement(Box3, { width: columns - 1, height: 1, overflow: "hidden" }, /* @__PURE__ */ React4.createElement(Text4, { color: colors.userMsgBorder }, "\u2580".repeat(Math.max(1, columns - 1))))) : msg.role === "think" ? /* @__PURE__ */ React4.createElement(Box3, { flexDirection: "column", marginTop: 0, marginBottom: 0, paddingX: 0, width: "100%" }, msg.isStreaming && !msg.duration ? /* @__PURE__ */ React4.createElement(Text4, { bold: true, color: colors.text }, "\u2727 Thinking...") : /* @__PURE__ */ React4.createElement(Text4, { bold: true, color: colors.text }, "\u2726 Thought", msg.duration ? /* @__PURE__ */ React4.createElement(Text4, { color: colors.textMuted }, " for ", /* @__PURE__ */ React4.createElement(Text4, { bold: true, color: colors.text }, formatThinkingDuration(msg.duration))) : "s..."), /* @__PURE__ */ React4.createElement(Box3, { borderStyle: "single", borderLeft: true, borderRight: false, borderTop: false, borderBottom: false, borderColor: colors.borderMuted, paddingLeft: 2, paddingTop: 0, paddingBottom: 0, flexDirection: "column", width: "100%" }, formatThinkText(finalContent, columns))) : /* @__PURE__ */ React4.createElement(Box3, { flexDirection: "column", paddingX: 1, marginTop: 0, width: "100%" }, /* @__PURE__ */ React4.createElement(CodeRenderer, { text: finalContent.replace(/ \|\n\n/g, " |\n"), columns, theme }), msg.memoryUpdated && /* @__PURE__ */ React4.createElement(Box3, { marginTop: 1, width: "100%" }, /* @__PURE__ */ React4.createElement(Text4, { color: colors.text, italic: true }, "[Memory Updated]")), msg.role === "agent" && msg.workedDuration ? /* @__PURE__ */ React4.createElement(Box3, { marginTop: 1, marginBottom: 2, width: "100%" }, /* @__PURE__ */ React4.createElement(Text4, { color: colors.textMuted }, "["), /* @__PURE__ */ React4.createElement(Text4, { color: colors.textMuted }, "Worked for ", /* @__PURE__ */ React4.createElement(Text4, { bold: true, color: colors.text }, formatThinkingDuration(msg.workedDuration))), /* @__PURE__ */ React4.createElement(Text4, { color: colors.textMuted }, "]")) : null));
|
|
6305
6328
|
});
|
|
6306
6329
|
BlockItem = React4.memo(({ block, columns = 80, showFullThinking, aiProvider, version, theme = "Dark" }) => {
|
|
6307
6330
|
const colors = getThemeColors(theme);
|
|
@@ -6334,7 +6357,7 @@ var init_ChatLayout = __esm({
|
|
|
6334
6357
|
);
|
|
6335
6358
|
}
|
|
6336
6359
|
if (type === "think-header") {
|
|
6337
|
-
return /* @__PURE__ */ React4.createElement(Box3, { flexDirection: "column", paddingX: 1, width: "100%", marginTop: 0, marginBottom: 0 }, isStreamingMsg ? /* @__PURE__ */ React4.createElement(Text4, { bold: true, color: colors.text }, "\u2727 Thinking...") : /* @__PURE__ */ React4.createElement(Text4, { bold: true, color: colors.text }, "\u2726
|
|
6360
|
+
return /* @__PURE__ */ React4.createElement(Box3, { flexDirection: "column", paddingX: 1, width: "100%", marginTop: 0, marginBottom: 0 }, isStreamingMsg ? /* @__PURE__ */ React4.createElement(Text4, { bold: true, color: colors.text }, "\u2727 Thinking...") : /* @__PURE__ */ React4.createElement(Text4, { bold: true, color: colors.text }, "\u2726 Thoughts..."), showFullThinking && /* @__PURE__ */ React4.createElement(Box3, { flexDirection: "row", width: "100%" }, /* @__PURE__ */ React4.createElement(Text4, { color: colors.textMuted }, "\u2502 ")));
|
|
6338
6361
|
}
|
|
6339
6362
|
if (type === "think-line") {
|
|
6340
6363
|
if (!showFullThinking) return null;
|
|
@@ -6677,7 +6700,7 @@ var init_StatusBar = __esm({
|
|
|
6677
6700
|
updateMemory();
|
|
6678
6701
|
const interval = setInterval(() => {
|
|
6679
6702
|
updateMemory();
|
|
6680
|
-
},
|
|
6703
|
+
}, 6e4);
|
|
6681
6704
|
return () => {
|
|
6682
6705
|
clearInterval(interval);
|
|
6683
6706
|
if (activeGetMemoryInfo === updateMemory) {
|
|
@@ -6704,7 +6727,7 @@ var init_StatusBar = __esm({
|
|
|
6704
6727
|
const pct = tokens / maxLimit * 100;
|
|
6705
6728
|
const color = pct < 60 ? colors.text : pct < 80 ? colors.warning : colors.danger;
|
|
6706
6729
|
return /* @__PURE__ */ React5.createElement(Text5, { color, dimColor: true }, pct.toFixed(0), "%");
|
|
6707
|
-
})())), /* @__PURE__ */ React5.createElement(Text5, { color: colors.textMuted, dimColor: true }, "\u2503"), /* @__PURE__ */ React5.createElement(Box4, { marginLeft: 1 }, /* @__PURE__ */ React5.createElement(Text5, { color: colors.textMuted, bold: true }, memoryUsage, "
|
|
6730
|
+
})())), /* @__PURE__ */ React5.createElement(Text5, { color: colors.textMuted, dimColor: true }, "\u2503"), /* @__PURE__ */ React5.createElement(Box4, { marginLeft: 1 }, /* @__PURE__ */ React5.createElement(Text5, { color: colors.textMuted, bold: true }, memoryUsage, " ", memoryUnit), (apiTier === "Custom" || apiTier === "Paid") && /* @__PURE__ */ React5.createElement(Box4, null, /* @__PURE__ */ React5.createElement(Text5, { color: colors.textMuted, dimColor: true }, " \u2503 "), /* @__PURE__ */ React5.createElement(Text5, { color: colors.textMuted, bold: true }, "PAID"))))
|
|
6708
6731
|
);
|
|
6709
6732
|
});
|
|
6710
6733
|
StatusBar_default = StatusBar;
|
|
@@ -6930,11 +6953,9 @@ var init_main_tools = __esm({
|
|
|
6930
6953
|
}
|
|
6931
6954
|
return `
|
|
6932
6955
|
-- TOOL DEFINITIONS --
|
|
6933
|
-
|
|
6934
|
-
|
|
6935
|
-
|
|
6936
|
-
**TOOL CALLS POLICY:**
|
|
6937
|
-
- MAX 4 TOOL CALLS/TURN${mode === "Flux" ? " (Todo: 4+, Run: max 1 or 2 consecutive)" : ""}
|
|
6956
|
+
FOR TOOL CALLING ONLY USE '[tool:functions.ToolName(arg1="value1")]' SYNTAX IN NEW LINE **NO OTHER SYNTAX ALLOWED** \u2190 MANDATORY
|
|
6957
|
+
TOOL RULES:
|
|
6958
|
+
- MAX 3 TOOL CALLS/TURN${mode === "Flux" ? " (Todo: 3+, Run: max 1 or 2 consecutive)" : ""}
|
|
6938
6959
|
${mode === "Flux" ? `- JSON ESCAPE ALL LITERAL ESCAPE SEQUENCES IN TOOL ARGUMENTS
|
|
6939
6960
|
- SAME file, MULTIPLE edits? ONE PatchFile (\u226415 blocks) \u2190 PRIORITY
|
|
6940
6961
|
- Tool denied? Ask for guidance \u2190 MANDATORY
|
|
@@ -8687,11 +8708,12 @@ ${mode === "Flux" ? "Logical, task-driven. Prioritize scalable, modular architec
|
|
|
8687
8708
|
|
|
8688
8709
|
- USE DIRECTORY STRUCTURE FOR FILE AVAILABILITY AND PATH RESOLUTION
|
|
8689
8710
|
- USE RELATIVE TIME REFERENCE eg. few mins ago
|
|
8711
|
+
- NO HALLUCINATIONS
|
|
8690
8712
|
|
|
8691
8713
|
-- THINKING GUIDANCE --
|
|
8692
8714
|
${aiProvider === "Mistral" || aiProvider === "Google" && !isGemini ? `${thinkingConfig}
|
|
8693
8715
|
${forcedReasoning || thinkingLevel !== "Fast" && (aiProvider === "Mistral" || thinkingLevel !== "xHigh" && !isGemini) ? `CRITICAL THINKING POLICY
|
|
8694
|
-
- Use <think
|
|
8716
|
+
- Use <think>...</think> for reasoning before responding any queries
|
|
8695
8717
|
` : ""}` : `${thinkingConfig}
|
|
8696
8718
|
`}
|
|
8697
8719
|
${TOOL_PROTOCOL(mode, osDetected, aiProvider.toLowerCase() === "deepseek" ? false : isMultiModal, aiProvider, systemSettings?.advanceRollback, systemSettings?.subAgents !== false)}
|
|
@@ -8703,9 +8725,8 @@ ${projectContextBlock}${isMemoryEnabled ? `
|
|
|
8703
8725
|
- Sensitive files? Ask before Read${isSystemDir ? "\n- PROTECTED DIRECTORY" : ""}
|
|
8704
8726
|
|
|
8705
8727
|
-- CHAT FORMATTING --
|
|
8706
|
-
- GFM Markdown
|
|
8707
|
-
-
|
|
8708
|
-
- Finish all chatting before tool calls${mode === "Flux" ? "" : "\n- Use Kaomojis HEAVILY"}
|
|
8728
|
+
- GFM Markdown
|
|
8729
|
+
- NEVER MIX CHAT & TOOLS IN SAME RESPONSE${mode === "Flux" ? "" : "\n- Use Kaomojis HEAVILY"}
|
|
8709
8730
|
=== END SYSTEM PROMPT ===
|
|
8710
8731
|
|
|
8711
8732
|
${nameStr}${nicknameStr}${userInstrStr}${userMemoriesStr}`.trim();
|
|
@@ -13899,7 +13920,7 @@ var init_ai = __esm({
|
|
|
13899
13920
|
RE_KIMI_JSON_PAIR = /"([^"]+)"\s*:\s*(?:"([^"]*)"|(\d+)|true|false|null)/g;
|
|
13900
13921
|
RE_KIMI_SECTION_BEGIN = /<\|\s*tool_calls_section_begin\s*\|>/gi;
|
|
13901
13922
|
RE_KIMI_SECTION_END = /<\|\s*tool_calls_section_end\s*\|>/gi;
|
|
13902
|
-
bypassBacktick2 =
|
|
13923
|
+
bypassBacktick2 = true;
|
|
13903
13924
|
client = null;
|
|
13904
13925
|
globalSettings = {};
|
|
13905
13926
|
systemInstructionCache = { key: null, value: null };
|
|
@@ -16131,8 +16152,8 @@ ${currentSummary}
|
|
|
16131
16152
|
const ideCtx = await getIDEContext();
|
|
16132
16153
|
let ideBlock = "";
|
|
16133
16154
|
if (isBridgeConnected()) {
|
|
16134
|
-
ideBlock = "\n[ADDITIONAL IDE CONTEXT]\n";
|
|
16135
16155
|
if (ideCtx.file_focused !== "none") {
|
|
16156
|
+
ideBlock = "\n[ADDITIONAL IDE CONTEXT]\n";
|
|
16136
16157
|
const relFocused = path26.relative(process.cwd(), ideCtx.file_focused);
|
|
16137
16158
|
const relOpened = (ideCtx.opened_editors || []).map((p) => {
|
|
16138
16159
|
const rel = path26.relative(process.cwd(), p);
|
|
@@ -16270,7 +16291,6 @@ ${ideCtx.warnings}
|
|
|
16270
16291
|
`;
|
|
16271
16292
|
}
|
|
16272
16293
|
} else {
|
|
16273
|
-
ideBlock += `No file currently focused.`;
|
|
16274
16294
|
}
|
|
16275
16295
|
}
|
|
16276
16296
|
const cleanAgentText = agentText.replace(/\s*\[Prompted on:.*?\]/g, "").trim();
|
|
@@ -16410,10 +16430,8 @@ OS: ${osDetected}${systemSettings?.dynamicDirAwareness ? dirStructure : ""}${cwd
|
|
|
16410
16430
|
WARNING: CWD Changed from previous: "${lastCwd}" to current: "${process.cwd()}", write change in chat to avoid future path mismatches
|
|
16411
16431
|
` : ""}${memoryPrompt}${ideBlock}
|
|
16412
16432
|
[/METADATA]
|
|
16413
|
-
${activeSummaryBlock}${thinkingLevel !== "Fast" && (aiProvider === "Mistral" || thinkingLevel !== "xHigh" && aiProvider === "Google") ? `${aiProvider === "Mistral" || modelName.toLowerCase().startsWith("gemma") ? "[SYSTEM] **STRICTLY FOLLOW THINKING POLICY AS HIGH PRIORITY. DO NOT START A RESPONSE WITHOUT <think
|
|
16414
|
-
${taggedContextStr}[USER PROMPT]
|
|
16415
|
-
${cleanPromptForModel.trim()}
|
|
16416
|
-
[/USER PROMPT]`.trim();
|
|
16433
|
+
${activeSummaryBlock}${thinkingLevel !== "Fast" && (aiProvider === "Mistral" || thinkingLevel !== "xHigh" && aiProvider === "Google") ? `${aiProvider === "Mistral" || modelName.toLowerCase().startsWith("gemma") ? "[SYSTEM] **STRICTLY FOLLOW THINKING POLICY AS HIGH PRIORITY. DO NOT START A RESPONSE WITHOUT <think>...</think>** [/SYSTEM]\n" : ""}` : ""}[SYSTEM] ONLY VALID TOOL SCHEMA REMINDER: '[tool:functions.ToolName(arg1="value1")]' NEW LINE [/SYSTEM]
|
|
16434
|
+
${taggedContextStr}[USER PROMPT] ${cleanPromptForModel.trim()} [/USER PROMPT]`.trim();
|
|
16417
16435
|
const userMsgObj = { role: "user", text: firstUserMsg };
|
|
16418
16436
|
if (attachedBinaryPart) {
|
|
16419
16437
|
userMsgObj.binaryPart = attachedBinaryPart;
|
|
@@ -16534,7 +16552,7 @@ ${combinedNudge}`;
|
|
|
16534
16552
|
}
|
|
16535
16553
|
const stripToolCallWrappers = (text) => {
|
|
16536
16554
|
if (!text || !text.includes("[tool:")) return text;
|
|
16537
|
-
text = text.replace(/<(\w+)(?:[^>]*)>\s*(\[tool:[^\]]*\]
|
|
16555
|
+
text = text.replace(/<(\w+)(?:[^>]*)>\s*([\s\S]*?\[tool:[^\]]*\][\s\S]*?)\s*<\/\1>/gi, (match2, tagName, innerContent) => {
|
|
16538
16556
|
if (innerContent && innerContent.includes("[tool:")) return innerContent.trim();
|
|
16539
16557
|
return match2;
|
|
16540
16558
|
});
|
|
@@ -16542,6 +16560,7 @@ ${combinedNudge}`;
|
|
|
16542
16560
|
if (inner.includes("[tool:")) return inner.trim();
|
|
16543
16561
|
return match2;
|
|
16544
16562
|
});
|
|
16563
|
+
text = text.replace(/<(\w+)(?:[^>]*)>\r?\n?/gi, "").replace(/\r?\n?<\/\w+(?:[^>]*)>/gi, "");
|
|
16545
16564
|
return text;
|
|
16546
16565
|
};
|
|
16547
16566
|
const contents = modifiedHistory.filter((msg) => (msg.role === "user" || msg.role === "agent" || msg.role === "system") && !String(msg.id).startsWith("welcome") && !msg.isMeta && !msg.isTerminalRecord && !(msg.text && msg.text.startsWith("[TERMINAL_RECORD]"))).map((msg, idx, arr) => {
|
|
@@ -18646,10 +18665,8 @@ Error Log can be found in ${path26.join(LOGS_DIR, "agent", "error.log")}`);
|
|
|
18646
18665
|
const targetModel = model || subAgentCustomModel || settings?.modelName || settings?.activeModel || savedSettings.activeModel;
|
|
18647
18666
|
const osDetected = process.platform === "win32" ? "Windows" : process.platform === "darwin" ? "macOS" : "Linux";
|
|
18648
18667
|
const providedToolsSection = `-- TOOL DEFINITIONS (path = relative to CWD, path separator: '/') --
|
|
18649
|
-
|
|
18650
|
-
|
|
18651
|
-
|
|
18652
|
-
TOOL POLICY:
|
|
18668
|
+
FOR TOOL CALLING ONLY USE '[tool:functions.ToolName(arg1="value1")]' SYNTAX IN NEW LINE **NO OTHER SYNTAX ALLOWED** \u2190 MANDATORY
|
|
18669
|
+
TOOL RULES:
|
|
18653
18670
|
- JSON ESCAPE ALL LITERAL ESCAPE SEQUENCES IN TOOL ARGUMENTS
|
|
18654
18671
|
- SAME file, MULTIPLE edits? ONE PatchFile (\u226415 blocks) \u2190 PRIORITY
|
|
18655
18672
|
- Need text or huge files? SearchKeyword > Full Read
|
|
@@ -18681,7 +18698,7 @@ ${providedToolsSection.trimEnd()}
|
|
|
18681
18698
|
-- THINKING GUIDANCE --
|
|
18682
18699
|
NO EXPLICIT THINKING REQUIRED. FOCUS ON TASK COMPLETION
|
|
18683
18700
|
Keep main focus on tools and task, not chatting
|
|
18684
|
-
On task completion, provide a detailed structured summary preferebly in Tables/Bullet Points with file modified info, if any task failed report back in detail,
|
|
18701
|
+
On task completion, provide a detailed structured summary preferebly in Tables/Bullet Points with file modified info, if any task failed report back in detail, NO HALLUCINATIONS
|
|
18685
18702
|
|
|
18686
18703
|
CWD: ${process.cwd()}
|
|
18687
18704
|
Current Time: ${time}
|
|
@@ -19954,7 +19971,17 @@ function App({ args = [] }) {
|
|
|
19954
19971
|
const forceRender = () => setRenderTick((t) => t + 1);
|
|
19955
19972
|
const typewriterQueueRef = useRef4([]);
|
|
19956
19973
|
const typewriterTickRef = useRef4(null);
|
|
19974
|
+
const flushTypewriterNow = () => {
|
|
19975
|
+
const queue = typewriterQueueRef.current;
|
|
19976
|
+
if (queue.length > 0 && activeStreamingMsgRef.current) {
|
|
19977
|
+
const remaining = queue.join("");
|
|
19978
|
+
queue.length = 0;
|
|
19979
|
+
activeStreamingMsgRef.current.text = flattenString(activeStreamingMsgRef.current.text + remaining);
|
|
19980
|
+
forceRender();
|
|
19981
|
+
}
|
|
19982
|
+
};
|
|
19957
19983
|
const commitActiveStreamingMessage = () => {
|
|
19984
|
+
flushTypewriterNow();
|
|
19958
19985
|
if (activeStreamingMsgRef.current) {
|
|
19959
19986
|
const msg = {
|
|
19960
19987
|
...activeStreamingMsgRef.current,
|
|
@@ -19977,24 +20004,27 @@ function App({ args = [] }) {
|
|
|
19977
20004
|
}
|
|
19978
20005
|
typewriterQueueRef.current = [];
|
|
19979
20006
|
typewriterTickRef.current = setInterval(() => {
|
|
19980
|
-
|
|
19981
|
-
|
|
19982
|
-
|
|
19983
|
-
|
|
19984
|
-
|
|
19985
|
-
|
|
19986
|
-
|
|
19987
|
-
|
|
19988
|
-
|
|
19989
|
-
|
|
19990
|
-
|
|
19991
|
-
|
|
19992
|
-
|
|
19993
|
-
|
|
19994
|
-
|
|
19995
|
-
|
|
19996
|
-
|
|
19997
|
-
|
|
20007
|
+
try {
|
|
20008
|
+
const queue = typewriterQueueRef.current;
|
|
20009
|
+
if (queue.length > 0 && activeStreamingMsgRef.current) {
|
|
20010
|
+
let batchSize = 1;
|
|
20011
|
+
if (queue.length > 85) batchSize = 30;
|
|
20012
|
+
else if (queue.length > 80) batchSize = 25;
|
|
20013
|
+
else if (queue.length > 75) batchSize = 20;
|
|
20014
|
+
else if (queue.length > 65) batchSize = 16;
|
|
20015
|
+
else if (queue.length > 50) batchSize = 12;
|
|
20016
|
+
else if (queue.length > 35) batchSize = 8;
|
|
20017
|
+
else if (queue.length > 15) batchSize = 6;
|
|
20018
|
+
else if (queue.length > 5) batchSize = 4;
|
|
20019
|
+
else if (queue.length > 3) batchSize = 2;
|
|
20020
|
+
let batchedText = "";
|
|
20021
|
+
for (let i = 0; i < batchSize && queue.length > 0; i++) {
|
|
20022
|
+
batchedText += queue.shift();
|
|
20023
|
+
}
|
|
20024
|
+
activeStreamingMsgRef.current.text = flattenString(activeStreamingMsgRef.current.text + batchedText);
|
|
20025
|
+
forceRender();
|
|
20026
|
+
}
|
|
20027
|
+
} catch (e) {
|
|
19998
20028
|
}
|
|
19999
20029
|
}, 80);
|
|
20000
20030
|
};
|
|
@@ -20003,15 +20033,6 @@ function App({ args = [] }) {
|
|
|
20003
20033
|
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
20004
20034
|
}
|
|
20005
20035
|
};
|
|
20006
|
-
const flushTypewriterNow = () => {
|
|
20007
|
-
const queue = typewriterQueueRef.current;
|
|
20008
|
-
if (queue.length > 0 && activeStreamingMsgRef.current) {
|
|
20009
|
-
const remaining = queue.join("");
|
|
20010
|
-
queue.length = 0;
|
|
20011
|
-
activeStreamingMsgRef.current.text = flattenString(activeStreamingMsgRef.current.text + remaining);
|
|
20012
|
-
forceRender();
|
|
20013
|
-
}
|
|
20014
|
-
};
|
|
20015
20036
|
const appendStreamText = (chunkText) => {
|
|
20016
20037
|
if (systemSettings.progressiveRendering && typewriterTickRef.current) {
|
|
20017
20038
|
const tokens = chunkText.split(/(\s+)/).filter(Boolean);
|
|
@@ -21620,6 +21641,7 @@ ${cleanText}`, color: "magenta" }];
|
|
|
21620
21641
|
return;
|
|
21621
21642
|
}
|
|
21622
21643
|
if (absoluteClean.startsWith("/")) {
|
|
21644
|
+
setInput("");
|
|
21623
21645
|
const parts = absoluteClean.split(" ");
|
|
21624
21646
|
const cmd = parts[0]?.toLowerCase();
|
|
21625
21647
|
switch (cmd) {
|
|
@@ -23068,10 +23090,10 @@ Selection: ${val}`,
|
|
|
23068
23090
|
if (inThinkMode && activeStreamingMsgRef.current?.role === "think") {
|
|
23069
23091
|
flushTypewriterNow();
|
|
23070
23092
|
const newText = activeStreamingMsgRef.current.text + chunkText;
|
|
23071
|
-
if (
|
|
23072
|
-
const parts = newText.split(/<\/think>/gi);
|
|
23093
|
+
if (/<\/(think|thought)>/i.test(newText)) {
|
|
23094
|
+
const parts = newText.split(/<\/(think|thought)>/gi);
|
|
23073
23095
|
const thinkPart = parts[0] || "";
|
|
23074
|
-
const agentPart = parts.slice(
|
|
23096
|
+
const agentPart = parts.slice(2).join("").replace(/<\/?(think|thought)>/gi, "");
|
|
23075
23097
|
activeStreamingMsgRef.current.text = flattenString(thinkPart);
|
|
23076
23098
|
const startTime = activeStreamingMsgRef.current.startTime || Date.now();
|
|
23077
23099
|
activeStreamingMsgRef.current.duration = Date.now() - startTime;
|
|
@@ -23079,7 +23101,7 @@ Selection: ${val}`,
|
|
|
23079
23101
|
inThinkMode = false;
|
|
23080
23102
|
currentAgentId = "agent-" + Date.now();
|
|
23081
23103
|
activeStreamingMsgRef.current = { id: currentAgentId, role: "agent", text: "", isStreaming: true };
|
|
23082
|
-
appendStreamText(agentPart
|
|
23104
|
+
appendStreamText(agentPart);
|
|
23083
23105
|
} else {
|
|
23084
23106
|
appendStreamText(chunkText);
|
|
23085
23107
|
}
|
|
@@ -23172,6 +23194,19 @@ Selection: ${val}`,
|
|
|
23172
23194
|
}
|
|
23173
23195
|
return updated;
|
|
23174
23196
|
}).reverse();
|
|
23197
|
+
const hasAgentMsg = newMsgs.some((m) => m.role === "agent" && m.text?.trim().length > 0);
|
|
23198
|
+
if (!hasAgentMsg) {
|
|
23199
|
+
const lastThinkMsg = [...newMsgs].reverse().find((m) => m.role === "think" && m.text?.trim().length > 0);
|
|
23200
|
+
if (lastThinkMsg) {
|
|
23201
|
+
newMsgs.push({
|
|
23202
|
+
id: "agent-fallback-" + Date.now(),
|
|
23203
|
+
role: "agent",
|
|
23204
|
+
text: lastThinkMsg.text,
|
|
23205
|
+
isStreaming: false,
|
|
23206
|
+
workedDuration: totalDuration2
|
|
23207
|
+
});
|
|
23208
|
+
}
|
|
23209
|
+
}
|
|
23175
23210
|
const historyToSave = newMsgs.filter((m) => !String(m.id).startsWith("welcome") && (!m.isMeta || m.text && m.text.includes("Request Cancelled")));
|
|
23176
23211
|
saveChat(chatId, null, historyToSave);
|
|
23177
23212
|
setCompletedIndex(newMsgs.length);
|