import { Checkpoint, type SourceLocationOpts, type ThreadMessages, type BranchSummary, type GuardSummary, type LoopState, type ThreadSummary } from "../runtime/state/checkpointStore.js"; import type { BusyEntry, DebugStopData, StopLocation } from "../runtime/debugger.js"; import { type BusyShown } from "./busy.js"; import type { PendingPreview, StopView } from "./edits/rows.js"; export type ValWithOverride = { key: string; value: unknown; override?: unknown; }; export declare class UIState { private activityLog; private pending; private mode; /** The stop's checkpoint as the driver sent it. */ private base?; /** What the panes draw: the base with the pending edits applied, or * the base when there are none or the preview is refused. */ private checkpoint?; /** Where the program is stopped: the stop's location when the driver * gave one, else the checkpoint's own. Names the frame whose locals * are shown and the source line that is highlighted. */ private location?; /** The stop's own location, kept while a branch is being viewed. */ private stopLocation?; /** The stop record the driver passed, when the stop is a debug stop. */ private stop?; /** The module whose globals the globals pane shows: the viewed * frame's. The source pane shows `location.moduleId`, the stop's. */ private globalsModuleId?; private sourceMap?; private currentLine?; private args; private locals; private globals; private stdoutContent; private sourceMapCache; /** What the program is waiting on, as the run last reported it, each * with the time this UI first saw it. */ private busy; constructor(); static fromCheckpoint(checkpoint: Checkpoint | undefined): UIState; /** * Resolve a moduleId (e.g., "stdlib/index.agency") to an actual file path, * trying the given extensions. Handles stdlib modules that live inside * node_modules/agency-lang/stdlib/ when running from an external project. */ resolveModulePath(moduleId: string, extensions: string[]): string | null; private agencyToJsFile; /** Show `checkpoint`, at `stop` when the driver has a stop record, else * at the checkpoint's own location. `interruptId` is the user interrupt * the checkpoint was taken for, when there is one: an interrupt raised * inside a tool, a fork, or a parallel arm is stamped on the shared * checkpoint at the join, whose location has no branch path, so the * branch is found by the interrupt's id. */ setCheckpoint(checkpoint: Checkpoint | undefined, stop?: DebugStopData, interruptId?: string): Promise; /** Fill the args and locals panes from the frame at `location`, and * the globals pane from `moduleId`'s globals as that frame's stack * sees them. False when the checkpoint has no such frame. The * checkpoint is the preview; a value the pending edits changed is * marked by comparing it with the same place in the stop's own * checkpoint, so only the frame an edit named shows it, whatever * the edit called the frame. */ private showFrame; /** Look at a branch's stack: the locals and globals panes show its * last frame, and the source pane keeps the stop's line and module. * An empty path returns to the stop. */ viewBranch(path: string[]): void; /** The value of a variable as the panes show it: an argument or a * local of the viewed frame, else a global of the viewed module. */ lookupVariable(name: string): unknown; /** Every branch in the checkpoint; see `Checkpoint.listBranches`. */ listBranches(): BranchSummary[]; /** The guards the stopped code runs under, outermost first. */ listGuards(): GuardSummary[]; /** The tool loop the stopped code is in, or null. The loop counts a * round when its request returns, so at the loop's own stop before a * request the stop's label, `round N`, is the round the person sees. */ loopState(): LoopState | null; /** One entry per variable of `obj`, the preview's values. With * `before`, the same place in the stop's own checkpoint, an entry * whose value differs carries the preview's as its override and the * stop's as its value, so the pane highlights it; one that is the * same shows the stop's own value. The two are compared as the wire * writes them: the preview holds a Date as a tagged object, the * stop's checkpoint in this process may hold the Date itself. */ setWithOverrides(obj: Record, array: ValWithOverride[], before?: Record): void; log(message: string): void; setSourceMap(): Promise; setMode(mode: "stepping" | "running"): void; /** Replace the queued edits with the driver's copy, and redraw the * panes from the checkpoint as it will be once they apply. */ setPending(preview: PendingPreview): void; /** `base` with the pending edits applied; `base` itself when none are * pending or the patch is refused (the driver has already said why). */ private previewed; /** What the panes draw from, for the edit tables: the stop's * checkpoint, where the stop is, where the person is looking, and * the pending edits. Null before a stop. */ getStopView(): StopView | null; getPending(): PendingPreview; /** Replace the list of open waits with the run's latest, keeping the * time each one was first seen (`withSince`). */ setBusy(entries: BusyEntry[], now?: number): void; /** The open waits, the one that began last at the end. */ getBusy(): BusyShown[]; /** The source line of a stop's or a wait's location, from the source * map of its module when that map has been loaded (`loadSourceMap`); * undefined when it has not, or has no entry for the step. */ lineFor(location: StopLocation): number | undefined; /** Whether the module's source map is loaded. */ hasSourceMap(moduleId: string): boolean; /** Load `moduleId`'s source map into the cache from its compiled * module; false, with a line in the log, when it cannot be. */ loadSourceMap(moduleId: string): Promise; /** The threads the stopped code sees, the active one marked. */ listThreads(): ThreadSummary[]; /** The messages of `threadId`, or of the active thread when none is * named. */ /** The thread's messages as the panes show them, with the ones a * pending edit added marked: those past the end of the stop's own * list, and the queued ones past the end of its queue. */ getThreadMessages(threadId?: string): ThreadMessages | null; private threadMessagesOf; /** The module the source pane shows: the stop's, or, before any stop * while the program runs, the one it is waiting in. */ getModuleId(): string; /** The module the globals pane shows: the viewed frame's, which after * `b` can differ from the source pane's. */ getGlobalsModuleId(): string; /** Where the program is stopped, as the panes show it. */ getLocation(): SourceLocationOpts | undefined; /** The stop's line, or -1 before a stop or when the map has no entry * for it; `setSourceMap` logs the reason once, so a redraw does not. */ getCurrentLine(): number; getArgs(): ValWithOverride[]; getLocals(): ValWithOverride[]; getGlobals(): ValWithOverride[]; /** The call stack, read from the checkpoint's frames: one entry per * frame from the root stack down to the stack the program is stopped * on, the stopped frame last. The tool loop's own frame is shown as * `llm()`, and the compiler-named frame of a fork or parallel arm or * a block argument as `block`. Only Agency code and the TypeScript * that claims a resumable scope have frames; other TypeScript * functions do not appear. */ getCallStack(): { functionName: string; moduleId: string; }[]; getActivityLog(): string[]; stepping(): void; addToStdout(text: string): void; getStdout(): string[]; getTokenStats(): { totalTokens: number; totalCost: number; }; toJSON(): { activityLog: string[]; pending: PendingPreview; mode: "running" | "stepping"; checkpoint: import("../runtime/state/checkpointStore.js").CheckpointJSON | undefined; args: ValWithOverride[]; locals: ValWithOverride[]; globals: ValWithOverride[]; stdoutContent: string[]; }; static fromJSON(json: any): UIState; clone(): UIState; private isInternalVar; private filterDupeVals; }