@@ -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;