xonecas.io
64875
Mc

mini-coder / commit aabd4ea

fix: use .nullable() instead of .optional() in shell tool schema

Per AI SDK prompt engineering docs, .nullable() is more compatible
with strict schema validation (OpenAI structured outputs). The Zod
schema uses .nullable() for the LLM contract while ShellInput keeps
fields optional for internal callers.

xonecas2026-03-22 aabd4ea980d9a05d7af9b8e4f814ff261885af89 parent 3e6a85a

1 file changed

src/tools/shell.ts+11−8
@@ -10,17 +10,20 @@ const ShellSchema = z.object({
1010 .number()
1111 .int()
1212 .min(1000)
13- .optional()
13+ .nullable()
1414 .describe(
1515 "Timeout in milliseconds. If omitted, the command runs until it exits.",
1616 ),
1717 env: z
1818 .record(z.string(), z.string())
19- .optional()
19+ .nullable()
2020 .describe("Additional environment variables to set"),
2121 });
2222
23-type ShellInput = z.infer<typeof ShellSchema> & {
23+type ShellInput = {
24+ command: string;
25+ timeout?: number | null;
26+ env?: Record<string, string> | null;
2427 cwd?: string;
2528 };
2629
@@ -40,11 +43,11 @@ const MAX_OUTPUT_BYTES = 10_000; // 10KB per stream
4043
4144 export async function runShellCommand(input: ShellInput): Promise<ShellOutput> {
4245 const cwd = input.cwd ?? process.cwd();
43- const timeout = input.timeout;
46+ const timeout = input.timeout ?? undefined;
47+ const inputEnv = input.env ?? undefined;
4448 const existingGitCount =
45- Number(
46- input.env?.GIT_CONFIG_COUNT ?? process.env.GIT_CONFIG_COUNT ?? "0",
47- ) || 0;
49+ Number(inputEnv?.GIT_CONFIG_COUNT ?? process.env.GIT_CONFIG_COUNT ?? "0") ||
50+ 0;
4851 const gitIdx = String(existingGitCount);
4952 const env: Record<string, string | undefined> = Object.assign(
5053 {},
@@ -55,7 +58,7 @@ export async function runShellCommand(input: ShellInput): Promise<ShellOutput> {
5558 [`GIT_CONFIG_KEY_${gitIdx}`]: "color.ui",
5659 [`GIT_CONFIG_VALUE_${gitIdx}`]: "always",
5760 },
58- input.env ?? {},
61+ inputEnv ?? {},
5962 );
6063
6164 let timedOut = false;