style: format pi embedded utils

This commit is contained in:
Peter Steinberger
2026-01-15 06:08:17 +00:00
parent 9c1122def0
commit 47634c294d

View File

@@ -64,12 +64,12 @@ function stripDowngradedToolCallText(text: string): string {
escape = false; escape = false;
} else if (ch === "\\") { } else if (ch === "\\") {
escape = true; escape = true;
} else if (ch === "\"") { } else if (ch === '"') {
inString = false; inString = false;
} }
continue; continue;
} }
if (ch === "\"") { if (ch === '"') {
inString = true; inString = true;
continue; continue;
} }
@@ -85,7 +85,7 @@ function stripDowngradedToolCallText(text: string): string {
return null; return null;
} }
if (startChar === "\"") { if (startChar === '"') {
let escape = false; let escape = false;
for (let i = index + 1; i < input.length; i += 1) { for (let i = index + 1; i < input.length; i += 1) {
const ch = input[i]; const ch = input[i];
@@ -97,7 +97,7 @@ function stripDowngradedToolCallText(text: string): string {
escape = true; escape = true;
continue; continue;
} }
if (ch === "\"") return i + 1; if (ch === '"') return i + 1;
} }
return null; return null;
} }
@@ -154,10 +154,7 @@ function stripDowngradedToolCallText(text: string): string {
let cleaned = stripToolCalls(text); let cleaned = stripToolCalls(text);
// Remove [Tool Result for ID ...] blocks and their content. // Remove [Tool Result for ID ...] blocks and their content.
cleaned = cleaned.replace( cleaned = cleaned.replace(/\[Tool Result for ID[^\]]*\]\n?[\s\S]*?(?=\n*\[Tool |\n*$)/gi, "");
/\[Tool Result for ID[^\]]*\]\n?[\s\S]*?(?=\n*\[Tool |\n*$)/gi,
"",
);
return cleaned.trim(); return cleaned.trim();
} }