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:
@@ -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`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user