/** * The console loop (aidlc-console/AC-1, aidlc-console/AC-8, aidlc-console/AC-9, * aidlc-console/AC-11, aidlc-console/AC-14, aidlc-console/AC-15, * aidlc-console/AC-16, aidlc-console/AC-19, aidlc-console/AC-25, * aidlc-console/AC-27, aidlc-console/AC-28, aidlc-console/AC-29, * aidlc-console/AC-31, aidlc-console/AC-33, aidlc-console/AC-34). * * Every effect goes through `ConsoleDeps`, so tests drive the loop with scripted * input and read back what it wrote. The loop itself writes no file: commands the * user runs do (aidlc-console/AC-5). * * @module */ import type { PausePhase } from '../autopilot/stops.js'; import type { Prompter } from '../core/prompt.js'; import { type ItemView } from './autopilot-view.js'; import { type TurnProcess } from './conversation.js'; import { type Harness } from './harness.js'; import { type View } from '../autopilot/watch-view.js'; export type Input = { kind: 'line'; text: string; } | { kind: 'toggle'; } | { kind: 'focus'; } | { kind: 'eof'; }; export interface ConsoleIO { /** * Wait for one input. While waiting, `tick` runs every 2 s and the lines it * returns are printed above the prompt, keeping what the user has typed. */ read(prompt: string, tick: () => string[], complete: (line: string) => [string[], string]): Promise; write(text: string): void; /** Replace the last frame drawn with `lines`; `write` ends a frame. */ frame(lines: string[]): void; /** One key, for the focused autopilot section. */ key(): Promise; columns(): number | undefined; /** Run `run` with stdout and stderr shown and also collected. */ capture(run: () => Promise): Promise<{ value: T; output: string; }>; } export type { TurnProcess }; export interface AutopilotAccess { items(): { view: ItemView; worktree: string; review?: PausePhase; }[]; running(): boolean; read(path: string): string | null; logs: string; approve(name: string): void; forget(name: string): void; /** The full-screen watch view, until `q`, Esc or Ctrl-C (colorful-autopilot-watch/AC-17). */ watch(view: View): Promise; } export interface ConsoleDeps { io: ConsoleIO; prompter: Prompter; version: string; harness: Harness; standing(agent: string): string[]; latestVersion(): Promise; /** Top-level command names, for completion. */ commandNames(): string[]; /** Required positionals `argv` leaves out, by name; null when its first word is not a command. */ missingArgs(argv: string[]): string[] | null; /** Run `aidlc ` in-process; false when it failed. */ runCommand(argv: string[]): Promise; /** Start one agent turn with `stdin` as its message; `onLine` gets each stdout line. */ spawnTurn(argv: string[], stdin: string, onLine: (line: string) => void, onErr?: (line: string) => void): TurnProcess; /** Run a shell line with its output shown; resolves with what it printed. */ runShell(cmd: string): Promise<{ code: number | null; output: string; }>; openShell(cwd: string): Promise; /** Null outside a git repository. */ autopilot: AutopilotAccess | null; } export declare const PROMPT = "\u203A "; export declare function runSession(deps: ConsoleDeps): Promise; //# sourceMappingURL=session.d.ts.map