fix: unblock claude-cli live runs

This commit is contained in:
Peter Steinberger
2026-01-11 00:22:48 +00:00
parent d8f1124d59
commit 24c3ab6fe0
5 changed files with 51 additions and 13 deletions

View File

@@ -59,13 +59,14 @@ export async function runCommandWithTimeout(
? { timeoutMs: optionsOrTimeout }
: optionsOrTimeout;
const { timeoutMs, cwd, input, env } = options;
const hasInput = input !== undefined;
// Spawn with inherited stdin (TTY) so tools like `pi` stay interactive when needed.
return await new Promise((resolve, reject) => {
const child = spawn(argv[0], argv.slice(1), {
stdio: [input ? "pipe" : "inherit", "pipe", "pipe"],
stdio: [hasInput ? "pipe" : "inherit", "pipe", "pipe"],
cwd,
env: env ? { ...process.env, ...env } : process.env,
env: env ?? process.env,
});
let stdout = "";
let stderr = "";
@@ -74,8 +75,8 @@ export async function runCommandWithTimeout(
child.kill("SIGKILL");
}, timeoutMs);
if (input && child.stdin) {
child.stdin.write(input);
if (hasInput && child.stdin) {
child.stdin.write(input ?? "");
child.stdin.end();
}