fluxflow-cli 3.3.3 → 3.3.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 +177 -64
- package/package.json +2 -2
package/dist/fluxflow.js
CHANGED
|
@@ -4410,7 +4410,7 @@ var init_ChatLayout = __esm({
|
|
|
4410
4410
|
{
|
|
4411
4411
|
flexDirection: "column",
|
|
4412
4412
|
borderStyle: "single",
|
|
4413
|
-
borderLeft:
|
|
4413
|
+
borderLeft: false,
|
|
4414
4414
|
borderRight: false,
|
|
4415
4415
|
borderTop: false,
|
|
4416
4416
|
borderBottom: false,
|
|
@@ -4449,7 +4449,7 @@ var init_ChatLayout = __esm({
|
|
|
4449
4449
|
paddingRight: 0,
|
|
4450
4450
|
width: "100%"
|
|
4451
4451
|
},
|
|
4452
|
-
/* @__PURE__ */ React4.createElement(Box3,
|
|
4452
|
+
/* @__PURE__ */ React4.createElement(Box3, null, /* @__PURE__ */ React4.createElement(Text4, { color: "gray", bold: true }, "\u25B6_ ", lang.toUpperCase() || "CODE")),
|
|
4453
4453
|
/* @__PURE__ */ React4.createElement(Box3, { flexDirection: "column", width: "100%" }, codeLines.map((line, idx) => /* @__PURE__ */ React4.createElement(Box3, { key: idx, width: "100%" }, /* @__PURE__ */ React4.createElement(Box3, { width: gutterWidth + 2, flexShrink: 0 }, /* @__PURE__ */ React4.createElement(Text4, { color: "gray" }, String(idx + 1).padStart(gutterWidth, " "), " ")), /* @__PURE__ */ React4.createElement(Box3, { flexGrow: 1 }, renderHighlightedLine(line, lang, "#e1e4e8")))))
|
|
4454
4454
|
);
|
|
4455
4455
|
}
|
|
@@ -4618,6 +4618,9 @@ var init_ChatLayout = __esm({
|
|
|
4618
4618
|
}
|
|
4619
4619
|
return msg.isStreaming ? content : content.trimEnd();
|
|
4620
4620
|
}, [content, msg.role, showFullThinking, msg.isStreaming]);
|
|
4621
|
+
if (msg.role === "agent" && finalContent.trim() === "") {
|
|
4622
|
+
return null;
|
|
4623
|
+
}
|
|
4621
4624
|
return (
|
|
4622
4625
|
// [SPACE POINT]
|
|
4623
4626
|
/* @__PURE__ */ React4.createElement(Box3, { marginBottom: msg.role === "think" ? 0 : msg.role === "user" ? 0 : msg.role === "agent" ? 0 : 0, marginTop: msg.role === "think" ? 0 : msg.role === "user" ? 0 : msg.role === "agent" ? 0 : 0, flexDirection: "column", flexShrink: 0, width: "100%", flexGrow: 1 }, msg.role === "user" ? /* @__PURE__ */ React4.createElement(Box3, { flexDirection: "column", width: columns - 1 }, /* @__PURE__ */ React4.createElement(Box3, { width: columns - 1, height: 1, overflow: "hidden" }, /* @__PURE__ */ React4.createElement(Text4, { color: "#444444" }, "\u2584".repeat(Math.max(1, columns - 1)))), /* @__PURE__ */ React4.createElement(
|
|
@@ -4693,7 +4696,7 @@ var init_ChatLayout = __esm({
|
|
|
4693
4696
|
}
|
|
4694
4697
|
if (type === "agent-line") {
|
|
4695
4698
|
if (!text || text.trim() === "") {
|
|
4696
|
-
return
|
|
4699
|
+
return null;
|
|
4697
4700
|
}
|
|
4698
4701
|
const animatedText = useStreamingText(text, isStreamingMsg, block.isActiveBlock);
|
|
4699
4702
|
return /* @__PURE__ */ React4.createElement(Box3, { flexDirection: "column", paddingX: 1, width: "100%" }, /* @__PURE__ */ React4.createElement(CodeRenderer, { text: animatedText, columns }));
|
|
@@ -4775,7 +4778,7 @@ var init_ChatLayout = __esm({
|
|
|
4775
4778
|
flexDirection: "row",
|
|
4776
4779
|
width: columns,
|
|
4777
4780
|
borderStyle: "single",
|
|
4778
|
-
borderLeft:
|
|
4781
|
+
borderLeft: false,
|
|
4779
4782
|
borderRight: false,
|
|
4780
4783
|
borderTop: false,
|
|
4781
4784
|
borderBottom: false,
|
|
@@ -4794,7 +4797,7 @@ var init_ChatLayout = __esm({
|
|
|
4794
4797
|
flexDirection: "row",
|
|
4795
4798
|
width: columns,
|
|
4796
4799
|
borderStyle: "single",
|
|
4797
|
-
borderLeft:
|
|
4800
|
+
borderLeft: false,
|
|
4798
4801
|
borderRight: false,
|
|
4799
4802
|
borderTop: false,
|
|
4800
4803
|
borderBottom: false,
|
|
@@ -10828,21 +10831,78 @@ var init_ai = __esm({
|
|
|
10828
10831
|
return MULTIMODAL_MODELS.some((m) => m.toLowerCase() === lower);
|
|
10829
10832
|
};
|
|
10830
10833
|
getCleanGroupedLength = (rawHistory) => {
|
|
10831
|
-
const
|
|
10832
|
-
|
|
10833
|
-
|
|
10834
|
-
if (!isCleanMsg) return;
|
|
10834
|
+
const preprocessed = rawHistory.filter(
|
|
10835
|
+
(m) => (m.role === "user" || m.role === "agent" || m.role === "system") && m.role !== "think" && !m.isVisualFeedback && !m.isMeta && !String(m.id).startsWith("welcome")
|
|
10836
|
+
).map((m, idx, arr) => {
|
|
10835
10837
|
let text = m.fullText || m.text || "";
|
|
10836
|
-
if (m.role === "
|
|
10837
|
-
|
|
10838
|
-
|
|
10839
|
-
|
|
10840
|
-
|
|
10838
|
+
if (m.role === "user" && idx < arr.length - 1) {
|
|
10839
|
+
if (text.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")) {
|
|
10840
|
+
const summaryIndex = text.indexOf("**CONTEXT SUMMARY OF PREVIOUS TURNS");
|
|
10841
|
+
if (summaryIndex !== -1) {
|
|
10842
|
+
const prefix = text.substring(0, summaryIndex);
|
|
10843
|
+
const metadataIndex = prefix.lastIndexOf("[SYSTEM METADATA]");
|
|
10844
|
+
if (metadataIndex !== -1) {
|
|
10845
|
+
text = text.substring(metadataIndex).trim();
|
|
10846
|
+
} else {
|
|
10847
|
+
text = text.substring(summaryIndex).trim();
|
|
10848
|
+
}
|
|
10849
|
+
}
|
|
10850
|
+
} else {
|
|
10851
|
+
const userIndex = text.lastIndexOf("[USER]");
|
|
10852
|
+
const userPromptIndex = text.lastIndexOf("[USER PROMPT]");
|
|
10853
|
+
if (userIndex !== -1) {
|
|
10854
|
+
text = text.substring(userIndex + 6).trim();
|
|
10855
|
+
} else if (userPromptIndex !== -1) {
|
|
10856
|
+
text = text.substring(userPromptIndex).trim();
|
|
10857
|
+
}
|
|
10841
10858
|
}
|
|
10842
10859
|
}
|
|
10843
|
-
|
|
10860
|
+
return { ...m, text };
|
|
10844
10861
|
});
|
|
10845
|
-
|
|
10862
|
+
const cleanHistoryForAI = [];
|
|
10863
|
+
let i = 0;
|
|
10864
|
+
while (i < preprocessed.length) {
|
|
10865
|
+
const msg = preprocessed[i];
|
|
10866
|
+
if (msg.role === "user") {
|
|
10867
|
+
cleanHistoryForAI.push(msg);
|
|
10868
|
+
i++;
|
|
10869
|
+
} else {
|
|
10870
|
+
const turnMessages = [];
|
|
10871
|
+
while (i < preprocessed.length && preprocessed[i].role !== "user") {
|
|
10872
|
+
turnMessages.push(preprocessed[i]);
|
|
10873
|
+
i++;
|
|
10874
|
+
}
|
|
10875
|
+
const toolCalls = [];
|
|
10876
|
+
const toolResults = [];
|
|
10877
|
+
const finalResponses = [];
|
|
10878
|
+
turnMessages.forEach((tm) => {
|
|
10879
|
+
const textLower = (tm.text || "").toLowerCase();
|
|
10880
|
+
const hasTool = textLower.includes("tool:functions.") || textLower.includes("agent:generalist.");
|
|
10881
|
+
const isResult = tm.role === "system" && (tm.text?.startsWith("[TOOL RESULT]") || tm.text?.startsWith("SUCCESS:") || tm.text?.startsWith("ERROR:") || tm.text?.startsWith("[TERMINAL_RECORD]") || tm.isTerminalRecord);
|
|
10882
|
+
if (tm.role === "agent") {
|
|
10883
|
+
if (hasTool) {
|
|
10884
|
+
toolCalls.push(tm.text);
|
|
10885
|
+
} else {
|
|
10886
|
+
finalResponses.push(tm.text);
|
|
10887
|
+
}
|
|
10888
|
+
} else if (isResult) {
|
|
10889
|
+
toolResults.push(tm.text);
|
|
10890
|
+
} else {
|
|
10891
|
+
finalResponses.push(tm.text);
|
|
10892
|
+
}
|
|
10893
|
+
});
|
|
10894
|
+
if (toolCalls.length > 0) {
|
|
10895
|
+
cleanHistoryForAI.push({ role: "agent", text: "combined" });
|
|
10896
|
+
}
|
|
10897
|
+
if (toolResults.length > 0) {
|
|
10898
|
+
cleanHistoryForAI.push({ role: "system", text: "combined" });
|
|
10899
|
+
}
|
|
10900
|
+
if (finalResponses.length > 0) {
|
|
10901
|
+
cleanHistoryForAI.push({ role: "agent", text: "combined" });
|
|
10902
|
+
}
|
|
10903
|
+
}
|
|
10904
|
+
}
|
|
10905
|
+
return cleanHistoryForAI.length;
|
|
10846
10906
|
};
|
|
10847
10907
|
stripAnsi2 = (str) => {
|
|
10848
10908
|
if (typeof str !== "string") return str;
|
|
@@ -12897,7 +12957,8 @@ ${ideCtx.warnings}
|
|
|
12897
12957
|
}
|
|
12898
12958
|
let taggedContextBlocks = [];
|
|
12899
12959
|
let attachedBinaryPart = null;
|
|
12900
|
-
for (
|
|
12960
|
+
for (let tIdx = 0; tIdx < tagsFound.length; tIdx++) {
|
|
12961
|
+
const tag = tagsFound[tIdx];
|
|
12901
12962
|
try {
|
|
12902
12963
|
let tagClean = tag.trim().replace(/^["']|["']$/g, "");
|
|
12903
12964
|
const lineRangeRegex = /[:#]L?(\d+)(?:-L?(\d+))?$/i;
|
|
@@ -12929,12 +12990,10 @@ ${ideCtx.warnings}
|
|
|
12929
12990
|
const boxLines = [label];
|
|
12930
12991
|
const maxLen = Math.max(...boxLines.map((l) => l.length));
|
|
12931
12992
|
const boxWidth = Math.min(maxLen + 4, terminalWidth);
|
|
12932
|
-
const boxTop = `${" ".repeat(boxWidth)}`;
|
|
12933
12993
|
const boxMid = boxLines.map((line) => `${line.padEnd(boxWidth - 2).substring(0, boxWidth - 2)}`).join("\n");
|
|
12934
|
-
const
|
|
12935
|
-
|
|
12936
|
-
|
|
12937
|
-
`) };
|
|
12994
|
+
const isFirst = tIdx === 0;
|
|
12995
|
+
const isLast = tIdx === tagsFound.length - 1;
|
|
12996
|
+
yield { type: "visual_feedback", content: colorMainWords((isFirst ? "\n" : "") + boxMid + (isLast ? "\n" : "")) };
|
|
12938
12997
|
continue;
|
|
12939
12998
|
}
|
|
12940
12999
|
const finalStart = startLine !== null ? startLine : 1;
|
|
@@ -12990,10 +13049,9 @@ ${boxMid}
|
|
|
12990
13049
|
const maxLen = Math.max(...boxLines.map((l) => l.length));
|
|
12991
13050
|
const boxWidth = Math.min(maxLen + 4, terminalWidth);
|
|
12992
13051
|
const boxMid = boxLines.map((line) => `${line.padEnd(boxWidth - 2).substring(0, boxWidth - 2)}`).join("\n");
|
|
12993
|
-
const
|
|
12994
|
-
|
|
12995
|
-
|
|
12996
|
-
`) };
|
|
13052
|
+
const isFirst = tIdx === 0;
|
|
13053
|
+
const isLast = tIdx === tagsFound.length - 1;
|
|
13054
|
+
yield { type: "visual_feedback", content: colorMainWords((isFirst ? "\n" : "") + boxMid + (isLast ? "\n" : "")) };
|
|
12997
13055
|
}
|
|
12998
13056
|
}
|
|
12999
13057
|
}
|
|
@@ -13884,10 +13942,10 @@ ${ideErr} [/ERROR]`;
|
|
|
13884
13942
|
const action = normToolName === "write_file" ? "Created" : "Edited";
|
|
13885
13943
|
label = `\u2714 ${action}: ${parseArgs(toolCall.args).path || "..."}`;
|
|
13886
13944
|
} else if (normToolName === "write_pdf") {
|
|
13887
|
-
label = `\u2714
|
|
13945
|
+
label = `\u2714 Generated: ${parseArgs(toolCall.args).path || "..."}
|
|
13888
13946
|
`;
|
|
13889
13947
|
} else if (normToolName === "write_docx") {
|
|
13890
|
-
label = `\u2714
|
|
13948
|
+
label = `\u2714 Generated: ${parseArgs(toolCall.args).path || "..."}
|
|
13891
13949
|
`;
|
|
13892
13950
|
} else if (normToolName === "file_map") {
|
|
13893
13951
|
label = `\u2714 Indexed: ${parseArgs(toolCall.args).path || "..."}`;
|
|
@@ -14483,8 +14541,9 @@ ${snippet2}
|
|
|
14483
14541
|
}
|
|
14484
14542
|
const boxWidth = Math.min(feedbackLabel.length + 4, terminalWidth);
|
|
14485
14543
|
const boxMid = `${feedbackLabel.padEnd(boxWidth - 2).substring(0, boxWidth - 2)}`;
|
|
14486
|
-
|
|
14487
|
-
|
|
14544
|
+
const isFirst = toolCallPointer === 0;
|
|
14545
|
+
const isLast = toolCallPointer === allToolsFound.length - 1;
|
|
14546
|
+
yield { type: "visual_feedback", content: colorMainWords((isFirst ? "\n" : "") + boxMid + (isLast ? "\n" : "")) };
|
|
14488
14547
|
const toolEnd2 = Date.now();
|
|
14489
14548
|
lastToolFinishedAt = toolEnd2;
|
|
14490
14549
|
yield { type: "tool_time", content: toolEnd2 - executionStart };
|
|
@@ -14543,10 +14602,14 @@ ${boxMid}`) };
|
|
|
14543
14602
|
}
|
|
14544
14603
|
const boxWidth = Math.min(label.length + 4, terminalWidth);
|
|
14545
14604
|
const boxMid = `${label.padEnd(boxWidth - 2).substring(0, boxWidth - 2)}`;
|
|
14546
|
-
const
|
|
14547
|
-
|
|
14548
|
-
|
|
14549
|
-
|
|
14605
|
+
const isFirst = toolCallPointer === 0;
|
|
14606
|
+
const isLast = toolCallPointer === allToolsFound.length - 1;
|
|
14607
|
+
yield {
|
|
14608
|
+
type: "visual_feedback",
|
|
14609
|
+
content: colorMainWords(
|
|
14610
|
+
(isFirst ? "\n" : "") + boxMid + (isLast && !/(Created|Edited)/.test(boxMid) ? "\n" : "")
|
|
14611
|
+
)
|
|
14612
|
+
};
|
|
14550
14613
|
}
|
|
14551
14614
|
if (lastToolFinishedAt > 0) {
|
|
14552
14615
|
const timeSinceLastTool = Date.now() - lastToolFinishedAt;
|
|
@@ -14622,10 +14685,9 @@ ${boxBottom}`}`) };
|
|
|
14622
14685
|
}
|
|
14623
14686
|
const boxWidth = Math.min(postLabel.length + 4, terminalWidth);
|
|
14624
14687
|
const boxMid = `${postLabel.padEnd(boxWidth - 2).substring(0, boxWidth - 2)}`;
|
|
14625
|
-
const
|
|
14626
|
-
|
|
14627
|
-
|
|
14628
|
-
`) };
|
|
14688
|
+
const isFirst = toolCallPointer === 0;
|
|
14689
|
+
const isLast = toolCallPointer === allToolsFound.length - 1;
|
|
14690
|
+
yield { type: "visual_feedback", content: colorMainWords((isFirst ? "\n" : "") + boxMid + (isLast ? "\n" : "")) };
|
|
14629
14691
|
}
|
|
14630
14692
|
if (normToolName === "EmergencyRollback") {
|
|
14631
14693
|
const { method } = parseArgs(toolCall.args);
|
|
@@ -14643,10 +14705,9 @@ ${boxMid}
|
|
|
14643
14705
|
}
|
|
14644
14706
|
const boxWidth = Math.min(postLabel.length + 4, terminalWidth);
|
|
14645
14707
|
const boxMid = `${postLabel.padEnd(boxWidth - 2).substring(0, boxWidth - 2)}`;
|
|
14646
|
-
const
|
|
14647
|
-
|
|
14648
|
-
|
|
14649
|
-
`) };
|
|
14708
|
+
const isFirst = toolCallPointer === 0;
|
|
14709
|
+
const isLast = toolCallPointer === allToolsFound.length - 1;
|
|
14710
|
+
yield { type: "visual_feedback", content: colorMainWords((isFirst ? "\n" : "") + boxMid + (isLast ? "\n" : "")) };
|
|
14650
14711
|
}
|
|
14651
14712
|
}
|
|
14652
14713
|
if (normToolName === "todo") {
|
|
@@ -14695,13 +14756,12 @@ ${boxMid}
|
|
|
14695
14756
|
const output = [
|
|
14696
14757
|
`${uiTitle}`,
|
|
14697
14758
|
// Clean title with a slight indent aligned with other feedbacks
|
|
14698
|
-
...listItems.map((item) => ` ${item}`)
|
|
14759
|
+
...listItems.map((item) => ` ${item}`)
|
|
14699
14760
|
// Sub-indented items for that premium look
|
|
14700
|
-
""
|
|
14701
|
-
// Bottom padding spacing
|
|
14702
14761
|
].join("\n");
|
|
14703
|
-
|
|
14704
|
-
|
|
14762
|
+
const isFirst = toolCallPointer === 0;
|
|
14763
|
+
const isLast = toolCallPointer === allToolsFound.length - 1;
|
|
14764
|
+
yield { type: "visual_feedback", content: colorMainWords((isFirst ? "\n" : "") + output + (isLast ? "\n" : "")) };
|
|
14705
14765
|
}
|
|
14706
14766
|
}
|
|
14707
14767
|
if (normToolName === "exec_command" && settings.onExecEnd) {
|
|
@@ -15032,7 +15092,7 @@ Error Log can be found in ${path21.join(LOGS_DIR, "agent", "error.log")}`);
|
|
|
15032
15092
|
const agentErrDir = path21.join(LOGS_DIR, "agent");
|
|
15033
15093
|
yield { type: "text", content: `\u274C CRITICAL ERROR: ${errLog}` };
|
|
15034
15094
|
if (!fs22.existsSync(agentErrDir)) fs22.mkdirSync(agentErrDir, { recursive: true });
|
|
15035
|
-
fs22.appendFileSync(path21.join(agentErrDir, "error.log"), `CRITICAL ERROR [${date}]: ${
|
|
15095
|
+
fs22.appendFileSync(path21.join(agentErrDir, "error.log"), `CRITICAL ERROR [${date}]: ${err}
|
|
15036
15096
|
|
|
15037
15097
|
----------------------------------------------------------------------
|
|
15038
15098
|
|
|
@@ -18734,33 +18794,86 @@ ${timestamp}` };
|
|
|
18734
18794
|
(m) => m.role !== "think" && !m.isVisualFeedback && !m.isMeta && !String(m.id).startsWith("welcome")
|
|
18735
18795
|
);
|
|
18736
18796
|
const cleanHistoryForAI = [];
|
|
18737
|
-
rawHistory.
|
|
18738
|
-
let text = m.fullText || m.text;
|
|
18797
|
+
const preprocessed = rawHistory.map((m, idx) => {
|
|
18798
|
+
let text = m.fullText || m.text || "";
|
|
18739
18799
|
if (m.role === "user" && idx < rawHistory.length - 1) {
|
|
18740
18800
|
if (text.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")) {
|
|
18741
|
-
const summaryIndex = text.indexOf("
|
|
18801
|
+
const summaryIndex = text.indexOf("**CONTEXT SUMMARY OF PREVIOUS TURNS");
|
|
18742
18802
|
if (summaryIndex !== -1) {
|
|
18743
|
-
|
|
18803
|
+
const prefix = text.substring(0, summaryIndex);
|
|
18804
|
+
const metadataIndex = prefix.lastIndexOf("[SYSTEM METADATA]");
|
|
18805
|
+
if (metadataIndex !== -1) {
|
|
18806
|
+
text = text.substring(metadataIndex).trim();
|
|
18807
|
+
} else {
|
|
18808
|
+
text = text.substring(summaryIndex).trim();
|
|
18809
|
+
}
|
|
18744
18810
|
}
|
|
18745
18811
|
} else {
|
|
18746
18812
|
const userIndex = text.lastIndexOf("[USER]");
|
|
18813
|
+
const userPromptIndex = text.lastIndexOf("[USER PROMPT]");
|
|
18747
18814
|
if (userIndex !== -1) {
|
|
18748
18815
|
text = text.substring(userIndex + 6).trim();
|
|
18816
|
+
} else if (userPromptIndex !== -1) {
|
|
18817
|
+
text = text.substring(userPromptIndex).trim();
|
|
18749
18818
|
}
|
|
18750
18819
|
}
|
|
18751
18820
|
}
|
|
18752
|
-
|
|
18753
|
-
|
|
18754
|
-
|
|
18755
|
-
|
|
18756
|
-
|
|
18821
|
+
return { ...m, text };
|
|
18822
|
+
});
|
|
18823
|
+
let i = 0;
|
|
18824
|
+
while (i < preprocessed.length) {
|
|
18825
|
+
const msg = preprocessed[i];
|
|
18826
|
+
if (msg.role === "user") {
|
|
18827
|
+
cleanHistoryForAI.push(msg);
|
|
18828
|
+
i++;
|
|
18829
|
+
} else {
|
|
18830
|
+
const turnMessages = [];
|
|
18831
|
+
while (i < preprocessed.length && preprocessed[i].role !== "user") {
|
|
18832
|
+
turnMessages.push(preprocessed[i]);
|
|
18833
|
+
i++;
|
|
18834
|
+
}
|
|
18835
|
+
const toolCalls = [];
|
|
18836
|
+
const toolResults = [];
|
|
18837
|
+
const finalResponses = [];
|
|
18838
|
+
turnMessages.forEach((tm) => {
|
|
18839
|
+
const textLower = (tm.text || "").toLowerCase();
|
|
18840
|
+
const hasTool = textLower.includes("tool:functions.") || textLower.includes("agent:generalist.");
|
|
18841
|
+
const isResult = tm.role === "system" && (tm.text?.startsWith("[TOOL RESULT]") || tm.text?.startsWith("SUCCESS:") || tm.text?.startsWith("ERROR:") || tm.text?.startsWith("[TERMINAL_RECORD]") || tm.isTerminalRecord);
|
|
18842
|
+
if (tm.role === "agent") {
|
|
18843
|
+
if (hasTool) {
|
|
18844
|
+
toolCalls.push(tm.text);
|
|
18845
|
+
} else {
|
|
18846
|
+
finalResponses.push(tm.text);
|
|
18847
|
+
}
|
|
18848
|
+
} else if (isResult) {
|
|
18849
|
+
toolResults.push(tm.text);
|
|
18850
|
+
} else {
|
|
18851
|
+
finalResponses.push(tm.text);
|
|
18852
|
+
}
|
|
18853
|
+
});
|
|
18854
|
+
if (toolCalls.length > 0) {
|
|
18855
|
+
cleanHistoryForAI.push({
|
|
18856
|
+
role: "agent",
|
|
18857
|
+
text: toolCalls.map((tc) => tc.trim()).filter(Boolean).join("\n")
|
|
18858
|
+
});
|
|
18859
|
+
}
|
|
18860
|
+
if (toolResults.length > 0) {
|
|
18861
|
+
cleanHistoryForAI.push({
|
|
18862
|
+
role: "system",
|
|
18863
|
+
text: toolResults.map((tr) => {
|
|
18864
|
+
const trimmed = tr.trim();
|
|
18865
|
+
return trimmed.startsWith("[TOOL RESULT]") ? trimmed : `[TOOL RESULT]: ${trimmed}`;
|
|
18866
|
+
}).filter(Boolean).join("\n\n")
|
|
18867
|
+
});
|
|
18868
|
+
}
|
|
18869
|
+
if (finalResponses.length > 0) {
|
|
18870
|
+
cleanHistoryForAI.push({
|
|
18871
|
+
role: "agent",
|
|
18872
|
+
text: finalResponses.map((fr) => fr.trim()).filter(Boolean).join("\n\n")
|
|
18873
|
+
});
|
|
18757
18874
|
}
|
|
18758
18875
|
}
|
|
18759
|
-
|
|
18760
|
-
...m,
|
|
18761
|
-
text
|
|
18762
|
-
});
|
|
18763
|
-
});
|
|
18876
|
+
}
|
|
18764
18877
|
const stream = getAIStream(
|
|
18765
18878
|
activeModel,
|
|
18766
18879
|
cleanHistoryForAI,
|
|
@@ -19030,7 +19143,7 @@ Selection: ${val}`,
|
|
|
19030
19143
|
});
|
|
19031
19144
|
clearBlocksCache();
|
|
19032
19145
|
if (global.gc) {
|
|
19033
|
-
for (let
|
|
19146
|
+
for (let i2 = 0; i2 < 2; i2++) {
|
|
19034
19147
|
global.gc();
|
|
19035
19148
|
await new Promise((resolve) => setImmediate(resolve));
|
|
19036
19149
|
}
|
|
@@ -19175,7 +19288,7 @@ Selection: ${val}`,
|
|
|
19175
19288
|
let chunkText = packet.content;
|
|
19176
19289
|
if (packet.type === "text" && chunkText.includes("Request Cancelled")) {
|
|
19177
19290
|
if (global.gc) {
|
|
19178
|
-
for (let
|
|
19291
|
+
for (let i2 = 0; i2 < 3; i2++) {
|
|
19179
19292
|
global.gc();
|
|
19180
19293
|
await new Promise((resolve) => setImmediate(resolve));
|
|
19181
19294
|
}
|