Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(mcp-host): remove escapes such as ESC ( B from generator text whole
marcoteb8e32c7f219d2
diff --git a/mcp-host/src/workflow/__tests__/toolText.test.ts b/mcp-host/src/workflow/__tests__/toolText.test.tsindex 2ef856da8..839717dab 100644--- a/mcp-host/src/workflow/__tests__/toolText.test.ts+++ b/mcp-host/src/workflow/__tests__/toolText.test.ts@@ -10,6 +10,8 @@ describe('cleanText', () => {it('drops ANSI escapes copied from a terminal', () => {expect(cleanText('\u001b[31mERROR\u001b[0m done')).toBe('ERROR done')expect(cleanText('\u001b]0;title\u0007after')).toBe('after')+ expect(cleanText('\u001b(Bplain\u001b[0m')).toBe('plain')+ expect(cleanText('\u001b7saved\u001b8 \u001bcreset')).toBe('saved reset')})it('keeps the text after an unterminated escape', () => {diff --git a/mcp-host/src/workflow/toolText.ts b/mcp-host/src/workflow/toolText.tsindex b1e243e21..0e39dca65 100644--- a/mcp-host/src/workflow/toolText.ts+++ b/mcp-host/src/workflow/toolText.ts@@ -7,9 +7,12 @@* once, before a generator reads them, covers every string that can reach a file.*/-/** CSI and terminated OSC sequences, then any other escape and its next byte. */+/**+ * CSI and terminated OSC sequences, then any other escape with its+ * intermediate bytes and final byte, as in ESC ( B, ESC 7 and ESC c.+ */const ANSI_ESCAPE =- /\u001b\[[0-?]*[ -/]*[@-~]|\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)|\u001b[@-_]?/g+ /\u001b\[[0-?]*[ -/]*[@-~]|\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)|\u001b[ -/]*[0-~]?/g/** Characters XML 1.0 cannot carry, plus DEL. Tab and newline are kept. */const UNREPRESENTABLE = /[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F\uFFFE\uFFFF]/g