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
+11 -4
View File
@@ -21,7 +21,7 @@ export interface CliDeps {
prompt: string,
config?: { client?: ClientName; defaultClient?: ClientName }
) => ClientName | null;
resolveConfig?: () => { paths: Partial<Record<ClientName, string>>; defaultClient?: ClientName };
resolveConfig?: () => { paths: Partial<Record<ClientName, string>>; defaultClient?: ClientName; timeout?: number };
stdoutWrite?: (chunk: string) => void;
stderrWrite?: (chunk: string) => void;
}
@@ -54,7 +54,7 @@ export async function main(
rawArgs[0]?.includes("cli.ts") ? rawArgs.slice(1) : rawArgs;
const args = minimist(parseArgs, {
string: ["client", "prompt"],
string: ["client", "prompt", "timeout"],
boolean: ["json", "text", "help", "debug"],
alias: { h: "help" },
});
@@ -114,8 +114,12 @@ export async function main(
return 1;
}
const config = resolveConfig();
const timeoutMs =
typeof args.timeout === "string" ? Number(args.timeout) : config.timeout;
try {
const result = await executePrompt(client, prompt);
const result = await executePrompt(client, prompt, { timeoutMs });
if (jsonMode) {
console.log(JSON.stringify(result, null, 2));
} else {
@@ -167,8 +171,11 @@ export async function main(
return 1;
}
const timeoutMs =
typeof args.timeout === "string" ? Number(args.timeout) : config.timeout;
try {
const result = await executePrompt(client, prompt);
const result = await executePrompt(client, prompt, { timeoutMs });
if (jsonMode) {
console.log(JSON.stringify(result, null, 2));
} else {