fix: sanitize output in print-mode to prevent terminal escape sequences

- Add sanitizeText import to print-mode.ts

- Sanitize content.text before writing to stdout

- Prevents terminal control sequences from affecting user terminal
This commit is contained in:
djdembeck
2026-04-10 13:54:03 -05:00
parent 9ed5a70d08
commit 1dfd174667
@@ -6,6 +6,7 @@
* - `omp --mode json "prompt"` - JSON event stream
*/
import type { AssistantMessage, ImageContent } from "@oh-my-pi/pi-ai";
import { sanitizeText } from "@oh-my-pi/pi-natives";
import type { AgentSession } from "../session/agent-session";
/**
@@ -173,7 +174,7 @@ export async function runPrintMode(session: AgentSession, options: PrintModeOpti
// Output text content
for (const content of assistantMsg.content) {
if (content.type === "text") {
process.stdout.write(`${content.text}\n`);
process.stdout.write(`${sanitizeText(content.text)}\n`);
}
}
}