/** * The operator dashboard's types (operator-console design §3). Types only: the data * the panels read, the UI state the key reducer changes, the effects it asks for, and * the screen it draws. * * @module */ import type { PausePhase } from '../../autopilot/stops.js'; import type { View, WatchItem } from '../../autopilot/watch-view.js'; import type { InstanceRow } from '../../commands/status.js'; import type { PromptResult, SelectOption } from '../../core/prompt.js'; import type { Denial, Harness } from '../harness.js'; export type { InstanceRow }; /** One panel's data, or why it could not be read (operator-console/AC-20). */ export type PanelRead = { ok: true; data: T; } | { ok: false; reason: string; }; export interface HeaderData { /** Basename of the project root, or `(no project)`. */ project: string; branch: string | null; run: { state: 'running' | 'paused' | 'not running'; started: number; limit: number | null; }; version: string; } export interface AutopilotRow extends WatchItem { worktree: string; review?: PausePhase; } export interface AutopilotData { items: AutopilotRow[]; queue: string[]; live: boolean; paused: boolean; } /** Who is building a running instance (building-panel-all-instances/AC-3). */ export type BuildingKind = 'autopilot' | 'attended'; export interface BuildingRow { kind: BuildingKind; item: WatchItem; } /** * Every instance in flight, one row each (building-panel-all-instances/AC-2): running * first — autopilot's items in its order, then attended ones by name — then the idle. */ export interface BuildingData { running: BuildingRow[]; /** Unfinished and not running, as INSTANCES listed them. */ idle: InstanceRow[]; queue: string[]; /** One line per source that could not be read; the rest still show (building-panel-all-instances/AC-18). */ problems: string[]; } export interface RoadmapEntry { /** The file name under `backlog/`, what `aidlc start --roadmap-item` takes. */ file: string; title: string; rank: number | null; } export interface RoadmapData { counts: { inbox: number; backlog: number; hold: number; done: number; }; next: RoadmapEntry | null; /** Ready after `next`, in `roadmap next` order. */ ready: RoadmapEntry[]; } export interface SpendData { todayUsd: number | null; weekUsd: number | null; /** Seven days, oldest first; null is "not measured", drawn as `–`, never `0`. */ days: (number | null)[]; } export interface OperatorData { /** False in a directory with no AIDLC project (operator-console/AC-9). */ project: boolean; header: PanelRead; /** Null outside a git repository, where autopilot cannot run. */ autopilot: PanelRead | null; building: BuildingData; roadmap: PanelRead; spend: PanelRead; } export type PanelId = 'building' | 'roadmap' | 'spend'; export declare const PANELS: readonly PanelId[]; /** One line being edited: its text and where the cursor sits in it, in code points. */ export interface LineState { text: string; cursor: number; } /** A question drawn in place over the dashboard (operator-console/AC-42). */ export type FormState = { kind: 'text'; message: string; input: LineState; error: string | null; validate?: (v: string) => string | undefined; } | { kind: 'select'; message: string; options: SelectOption[]; cursor: number; } | { kind: 'multiselect'; message: string; options: SelectOption[]; cursor: number; chosen: string[]; required: boolean; } | { kind: 'confirm'; message: string; value: boolean; }; /** * The `readline` key name (`up`, `return`, `escape`, `pageup` …), one printable * character, `space`, or `ctrl-`. */ export type KeyName = string; export type Effect = { kind: 'quit'; } /** `aidlc `; required positionals it leaves out are asked in a form and put after `--`. */ | { kind: 'command'; argv: string[]; } | { kind: 'approve' | 'forget' | 'log' | 'open'; name: string; } | { kind: 'runItems'; count: number; } | { kind: 'pauseOrResume'; } | { kind: 'stop'; } | { kind: 'startNext'; item: string; } | { kind: 'details'; panel: PanelId; name: string; } /** A drawer line, routed as the Stream routes it. */ | { kind: 'send'; line: string; } /** ⌃K's "Ask " (operator-console/AC-41). */ | { kind: 'ask'; text: string; } /** The answer to a refused tool (operator-console/AC-48). */ | { kind: 'answer'; allow: boolean; } /** Ctrl-C while the agent replies (operator-console/AC-52). */ | { kind: 'interrupt'; } | { kind: 'newSession'; } | { kind: 'switchAgent'; to?: Harness; } /** A form the app asked through `formPrompter` was answered or cancelled. */ | { kind: 'formDone'; result: PromptResult; }; export type Mode = { kind: 'panels'; } | { kind: 'help'; } | { kind: 'overlay'; title: string; lines: string[]; offset: number; } | { kind: 'confirm'; question: string; onYes: Effect; } | { kind: 'palette'; query: LineState; cursor: number; } /** `owner: 'prompt'` is a command's question; `'run-count'` is `r`'s own. */ | { kind: 'form'; form: FormState; owner: 'prompt' | 'run-count'; } | { kind: 'drawer'; }; export interface DrawerState { open: boolean; input: LineState; /** The conversation as shown, oldest first. */ lines: string[]; /** Lines scrolled back from the end; 0 is the end (operator-console/AC-51). */ offset: number; /** The agent or a drawer command is working. */ busy: boolean; /** A refused tool waiting for `y` or `n`. */ ask: Denial | null; } export interface UiState { focus: PanelId; selected: Record; mode: Mode; drawer: DrawerState; /** One line above the key bar; red when `error` (operator-console/AC-38). */ message: { text: string; error: boolean; } | null; /** A command started from a key, still running: spun on the message line. */ working: string | null; agent: Harness; sessionUsd: number; /** BUILDING's layout; `v` cycles it (building-panel-all-instances/AC-7). */ view: View; } /** What `render` returns and the terminal draws (design §3.4). */ export interface Screen { /** Exactly `rows` lines, none wider than `columns`. */ lines: string[]; /** Cells the frame clock redraws. */ spinners: { row: number; col: number; }[]; /** Shown only while an input has focus. */ cursor: { row: number; col: number; } | null; } export interface Size { columns: number; rows: number; } //# sourceMappingURL=model.d.ts.map