import type { JobStateName, JobStatus, WaitingFor } from "./protocol.js"; import { type ProfileTerm } from "./profiles.js"; export interface TermSignals { /** OSC 0 / OSC 2: the window title the agent set. */ title?: string; /** OSC 9 or OSC 777 notify: the last notification and when it came. */ notify?: { text: string; at: number; }; /** The last BEL. */ bellAt?: number; /** OSC 133: A/B (a prompt is shown) idle, C (a command runs) busy, D done → idle. */ prompt?: "idle" | "busy"; promptAt?: number; /** On the alternate screen (a full-screen TUI): its last line is not a result. */ alt: boolean; /** The screen's text last changed then. */ changedAt: number; at: number; } /** The part of xterm's Terminal the collector uses (headless or a fake in tests). */ export interface TermLike { parser: { registerOscHandler(ident: number, cb: (data: string) => boolean): unknown; }; onBell(cb: () => void): unknown; buffer: { active: { type: string; }; }; } /** * Collects the signals. `changed` is called when something a reader cares about moved; * the host then writes the file (screen changes come in through `screen`). */ export declare class TermSignalCollector { private s; private hash; private readonly term; private readonly changed; constructor(term: TermLike, changed: () => void, now?: number); private note; /** The screen's text now: a change moves changedAt. True when it changed. */ screen(text: string, now?: number): boolean; signals(now?: number): TermSignals; } export declare function readTermSignals(file: string): TermSignals | undefined; export interface TermVerdict { state: Extract; status: JobStatus; waitingFor: WaitingFor; summary: string | null; question: string | null; /** Quiet enough for typing a task in. */ quiet: boolean; } /** The last non-empty line of a screen. */ export declare function lastLine(screen: string): string | undefined; /** * The row of a level 0 agent, from the strongest signal down (the process's exit is the * daemon's, before this): the profile's regexes, OSC 133 marks, a notification or bell * since the last input, then the screen settling. `inputAt` is when roost last typed into * it (a reply or the task); `typed` whether anything was ever given to it. */ export declare function inferTermState(sig: TermSignals | undefined, screen: string, term: ProfileTerm, o: { now: number; inputAt: number; typed: boolean; }): TermVerdict;