import type { CommandExecutionOptions, CommandExecutionResult, CommandExecutor, } from "../ports/command-executor.ts"; export type PiExecOptions = { cwd?: string; timeout?: number; signal?: AbortSignal; }; export type PiExecResult = { stdout: string; stderr: string; code: number; killed: boolean; }; export type PiExecApi = { exec( command: string, args: string[], options?: PiExecOptions, ): Promise; sendUserMessage( content: string, options?: { deliverAs?: "steer" | "followUp" }, ): void; }; export class PiCommandExecutor implements CommandExecutor { constructor(private readonly pi: PiExecApi) {} async exec( command: string, args: string[], options: CommandExecutionOptions, ): Promise { return this.pi.exec(command, args, { cwd: options.cwd, timeout: options.timeoutMs, signal: options.signal, }); } }