(opts: {
path: string;
abort: AbortSignal;
env: NodeJS.ProcessEnv;
sessionId?: string;
})
| 2 | import { spawnWithTerminalGuard } from '@/utils/spawnWithTerminalGuard'; |
| 3 | |
| 4 | export async function opencodeLocal(opts: { |
| 5 | path: string; |
| 6 | abort: AbortSignal; |
| 7 | env: NodeJS.ProcessEnv; |
| 8 | sessionId?: string; |
| 9 | }): Promise<void> { |
| 10 | const args: string[] = []; |
| 11 | if (opts.sessionId) { |
| 12 | if (process.platform === 'win32' && /[&|<>^()%!"\r\n]/u.test(opts.sessionId)) { |
| 13 | throw new Error('Invalid sessionId'); |
| 14 | } |
| 15 | args.push('--session', opts.sessionId); |
| 16 | } |
| 17 | |
| 18 | logger.debug(`[OpencodeLocal] Spawning opencode with args: ${JSON.stringify(args)}`); |
| 19 | |
| 20 | await spawnWithTerminalGuard({ |
| 21 | command: 'opencode', |
| 22 | args, |
| 23 | cwd: opts.path, |
| 24 | env: opts.env, |
| 25 | signal: opts.abort, |
| 26 | shell: process.platform === 'win32', |
| 27 | logLabel: 'OpencodeLocal', |
| 28 | spawnName: 'opencode', |
| 29 | installHint: 'OpenCode CLI', |
| 30 | includeCause: true, |
| 31 | logExit: true |
| 32 | }); |
| 33 | } |
no test coverage detected