refactor: move shell output ANSI stripping to app layer
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import stripAnsi from "strip-ansi";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { getNowMs, isPerfLoggingEnabled, perfLog } from "./perf";
|
import { getNowMs, isPerfLoggingEnabled, perfLog } from "./perf";
|
||||||
|
|
||||||
@@ -973,7 +974,7 @@ const ShellToolCallSchema = z
|
|||||||
return {
|
return {
|
||||||
type: "shell" as const,
|
type: "shell" as const,
|
||||||
command,
|
command,
|
||||||
output: resultParsed.data.output,
|
output: stripAnsi(resultParsed.data.output),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -983,7 +984,7 @@ const ShellToolCallSchema = z
|
|||||||
return {
|
return {
|
||||||
type: "shell" as const,
|
type: "shell" as const,
|
||||||
command,
|
command,
|
||||||
output: errorParsed.data.content,
|
output: stripAnsi(errorParsed.data.content),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import stripAnsi from "strip-ansi";
|
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
// ---- Principal Parameter Extraction ----
|
// ---- 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({ 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 })),
|
z.object({ path: z.string() }).transform((d) => ({ type: "path" as const, value: d.path })),
|
||||||
// Command as string
|
// 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)
|
// 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
|
// Other text params
|
||||||
z.object({ title: z.string() }).transform((d) => ({ type: "text" as const, value: d.title })),
|
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 })),
|
z.object({ name: z.string() }).transform((d) => ({ type: "text" as const, value: d.name })),
|
||||||
|
|||||||
Reference in New Issue
Block a user