export interface RuntimeSpawnOpts { workdir: string; prompt: string; model?: string; resumeSessionId?: string; env: Record; } export interface RuntimeSpawnCallbacks { onOutput: () => void; onSessionId: (id: string) => Promise | void; } export interface LastModelResult { model: string; } export interface RuntimeHandle { pid: number; exited: Promise; stderrText: Promise; /** Best-effort stderr captured so far (tail-capped); safe to call anytime. */ stderrPartial(): string; /** Release the stderr stream when EOF will never arrive (orphaned descendants). */ stderrCancel(): void; } export interface SessionOutputResult { hasOutput: boolean; tokenCount: number; } export interface RuntimeBackend { readonly name: string; spawn(opts: RuntimeSpawnOpts, callbacks: RuntimeSpawnCallbacks): Promise; lastSessionModel(sessionId: string | undefined): Promise; sessionExists(sessionId: string): Promise; getSessionOutputTokens(sessionId: string | undefined): Promise; }