feat(S-102): Test-drive and implement --timeout flag, config layering, and default in

This commit is contained in:
2026-05-19 19:39:46 -05:00
parent 5375c83c77
commit dc3fe8d6eb
6 changed files with 182 additions and 15 deletions
+20 -5
View File
@@ -28,12 +28,14 @@ export async function executePrompt(
stdout: "",
stderr: "",
exitCode: -1,
client,
durationMs: 0,
});
}
const spawnImpl = options.spawn ?? defaultSpawn;
const existsSyncImpl = options.existsSync ?? defaultExistsSync;
const timeoutMs = options.timeoutMs ?? 300_000;
const timeoutMs = options.timeoutMs ?? 600_000;
const command = options.clientPath ?? client;
if (options.clientPath && !existsSyncImpl(options.clientPath)) {
@@ -46,6 +48,8 @@ export async function executePrompt(
stdout: "",
stderr: "",
exitCode: -1,
client,
durationMs: 0,
});
}
const args = argBuilder(prompt);
@@ -55,6 +59,7 @@ export async function executePrompt(
let timedOut = false;
let stdout = "";
let stderr = "";
const startMs = Date.now();
const child = spawnImpl(command, args, {
shell: false,
@@ -80,8 +85,16 @@ export async function executePrompt(
if (settled) return;
settled = true;
clearTimeout(timeout);
if (err) reject(err);
else resolve(result!);
const durationMs = Date.now() - startMs;
if (err) {
if (err instanceof ExecError) {
err.result.client = client;
err.result.durationMs = durationMs;
}
reject(err);
} else {
resolve({ ...result!, client, durationMs });
}
}
child.on("error", (err: NodeJS.ErrnoException) => {
@@ -89,7 +102,7 @@ export async function executePrompt(
settle(new ClientNotFoundError(client));
} else {
settle(
new ExecError(err.message, { stdout, stderr, exitCode: -1 })
new ExecError(err.message, { stdout, stderr, exitCode: -1, client, durationMs: 0 })
);
}
});
@@ -101,10 +114,12 @@ export async function executePrompt(
stdout,
stderr,
exitCode: -1,
client,
durationMs: 0,
})
);
} else {
settle(undefined, { stdout, stderr, exitCode: code ?? -1 });
settle(undefined, { stdout, stderr, exitCode: code ?? -1, client, durationMs: 0 });
}
});
});