import { SpawnOptions, CliProcess, CliName } from '@0xtiby/spawner'; type StopReason = "sentinel" | "max_iterations" | "error" | "aborted"; interface IterationError { code: string; message: string; raw: string; } interface IterationResult { number: number; exitCode: number; sentinelDetected: boolean; stdout: string; startedAt: string; durationMs: number; tokensIn: number | null; tokensOut: number | null; error: IterationError | null; } interface LoopResult { iterations: IterationResult[]; stopReason: StopReason; } interface LoopOptions { cli: CliName; prompt: string; cwd: string; model?: string; maxIterations?: number; sentinel?: string; vars?: Record; sessionId?: string; signal?: AbortSignal; startIteration?: number; autoApprove?: boolean; onOutput?: (chunk: string) => void; } type Spawner = (options: SpawnOptions) => CliProcess; interface LoopDeps { spawn?: Spawner; } declare function loop(options: LoopOptions, deps?: LoopDeps): Promise; export { type IterationError, type IterationResult, type LoopDeps, type LoopOptions, type LoopResult, type Spawner, type StopReason, loop };