import type { Channel } from "../../debugger/attach/channel.js"; import { type AnsweredMessage, type FinishedMessage, type Hello, type PartiesMessage, type RequestMessage, type StatusMessage } from "../../debugger/attach/protocol.js"; import type { Checkpoint } from "../../runtime/state/checkpointStore.js"; import type { DebugStopData } from "../../runtime/debugger.js"; import type { PendingPreview } from "../../debugger/edits/rows.js"; /** The stop as the run last drew it. */ export type Shown = { checkpoint: Checkpoint | undefined; stop: DebugStopData | undefined; interruptId: string | undefined; }; /** What a visit knows once it has joined. */ export type Joined = { hello: Hello; parties: PartiesMessage; /** The activity lines the run kept since the last visit. */ recent: string[]; shown: Shown | null; /** The request waiting for an answer, or null while the program runs. */ pending: RequestMessage | null; /** Set when the program had ended before this visit. */ finished: FinishedMessage | null; /** The edits queued at the stop, as the run last said; read live, so * the `where` a verb prints after queuing one shows it. */ queuedEdits: PendingPreview; }; /** What comes after a reply, or after waiting: the next request (with * the render that came before it, when one did), a refusal because * another party answered first, the program's end, the channel closing, * or the deadline. */ export type Next = { kind: "request"; request: RequestMessage; shown: Shown | null; recent: string[]; } | { kind: "answered"; answered: AnsweredMessage; } | { kind: "finished"; finished: FinishedMessage; } | { kind: "closed"; } | { kind: "timeout"; }; export type Visit = Joined & { /** Send `result` as the reply to `pending`, then wait for what comes * next, up to `timeoutMs`. */ answer(result: unknown, timeoutMs: number): Promise; /** Reply to a later request (a panel the driver asked for after a * command), then wait as `answer` does. */ reply(id: number, result: unknown, timeoutMs: number): Promise; /** Wait for the next request without answering anything: `wait` on a * running program. */ next(timeoutMs: number): Promise; /** Ask a running program to stop at its next statement. */ pause(): void; /** Release the CLI's hold on the session and close. */ detach(): void; close(): void; }; /** How long after joining to wait for a request before deciding the * program is running. The run sends the stop and the pending request * right after `parties`, so a short grace is enough; a visit on a * stopped program sees its request well inside it. */ export declare const JOIN_GRACE_MS = 300; export type VisitRefusal = { refused: string; }; /** Join the session on `channel` as a CLI visit. Resolves once the run * has said who is on it and either sent the pending request or gone * quiet for the grace period; rejects with the run's refusal. */ export declare function openVisit(channel: Channel, graceMs?: number): Promise; /** Send `client probe` on `channel` and return the run's `status`. */ export declare function probeStatus(channel: Channel, timeoutMs: number): Promise;