refactor: move shell output ANSI stripping to app layer

This commit is contained in:
Mohamed Boudra
2026-01-30 14:57:35 +07:00
parent 25c7d5afa9
commit 025a68c3a4
2 changed files with 5 additions and 5 deletions
+3 -2
View File
@@ -1,3 +1,4 @@
import stripAnsi from "strip-ansi";
import { z } from "zod";
import { getNowMs, isPerfLoggingEnabled, perfLog } from "./perf";
@@ -973,7 +974,7 @@ const ShellToolCallSchema = z
return {
type: "shell" as const,
command,
output: resultParsed.data.output,
output: stripAnsi(resultParsed.data.output),
};
}
@@ -983,7 +984,7 @@ const ShellToolCallSchema = z
return {
type: "shell" as const,
command,
output: errorParsed.data.content,
output: stripAnsi(errorParsed.data.content),
};
}
@@ -1,4 +1,3 @@
import stripAnsi from "strip-ansi";
import { z } from "zod";
// ---- Principal Parameter Extraction ----
@@ -19,9 +18,9 @@ const PrincipalParamSchema = z.union([
z.object({ filePath: z.string() }).transform((d) => ({ type: "path" as const, value: d.filePath })),
z.object({ path: z.string() }).transform((d) => ({ type: "path" as const, value: d.path })),
// Command as string
z.object({ command: z.string() }).transform((d) => ({ type: "command" as const, value: stripAnsi(d.command) })),
z.object({ command: z.string() }).transform((d) => ({ type: "command" as const, value: d.command })),
// Command as array (Codex sends this)
z.object({ command: z.array(z.string()).nonempty() }).transform((d) => ({ type: "command" as const, value: stripAnsi(d.command.join(" ")) })),
z.object({ command: z.array(z.string()).nonempty() }).transform((d) => ({ type: "command" as const, value: d.command.join(" ") })),
// Other text params
z.object({ title: z.string() }).transform((d) => ({ type: "text" as const, value: d.title })),
z.object({ name: z.string() }).transform((d) => ({ type: "text" as const, value: d.name })),