diff --git a/cli.ts b/cli.ts index 6c51268..d682376 100644 --- a/cli.ts +++ b/cli.ts @@ -923,7 +923,7 @@ export async function dispatch(args: string[]): Promise { } } - const stream = config.agent.stream; + const stream = args.includes('--id') ? config.agent.stream : false; const agent = getAgentCommand({ agentName, stream }); const cmd = new Deno.Command(agent.cmd, { @@ -990,9 +990,9 @@ export async function dispatch(args: string[]): Promise { Deno.exit(status.code); } } else { - const result = await child.output(); - if (!result.success) { - Deno.exit(result.code); + const status = await child.status; + if (!status.success) { + Deno.exit(status.code); } } } diff --git a/cli_test.ts b/cli_test.ts index 1492693..e139916 100644 --- a/cli_test.ts +++ b/cli_test.ts @@ -356,6 +356,41 @@ describe('dispatch', () => { assertSpyCalls(exitStub, 0); }); + it('uses inherited stdout when dispatching without --id', async () => { + using _ = stubFiles({ + 'config.json': { + channels: { telegram: { token: 'mock-token' } }, + allowedUsers: [], + agent: { name: 'claude', stream: true }, + }, + }); + + using cmdStub = stub( + Deno, + 'Command', + () => fakeCommand(), + ); + using exitStub = stubDenoExit(); + + await dispatch(['whats', 'up']); + + assertSpyCall(cmdStub, 0, { + args: ['claude', { + args: [ + '--add-dir', + DATA_DIR, + '-p', + ], + cwd: Deno.cwd(), + stdin: 'piped', + stdout: 'inherit', + stderr: 'inherit', + }], + }); + + assertSpyCalls(exitStub, 0); + }); + it('reads prompt from file with --id', async () => { using _ = stubFiles({ 'config.json': {