import type { DebuggerState } from "../debugger/debuggerState.js"; import type { AgencyCallbacks } from "./hooks.js"; import type { InvocationOptions } from "./invocationOptions.js"; import type { CheckpointEdit, StopAt } from "./state/checkpointPatch/index.js"; import type { RunUsage, ServedInvocationOutcome } from "./invocationUsage.js"; import { type Interrupt, type InterruptResponse } from "./interrupts.js"; import type { Checkpoint, CheckpointStore } from "./state/checkpointStore.js"; import type { RuntimeContext } from "./state/context.js"; import type { GraphState, RunNodeCoreResult } from "./types.js"; /** What the leg that stopped was started with. A resume does not remember * these (see `InvocationOptions`), so the debugger passes them back on * every resume and rewind it issues; otherwise a caller's policy, host, * budget, callbacks, and cancel signal would be gone after the first * step. */ export type LegOptions = { invocation?: InvocationOptions; callbacks?: AgencyCallbacks; abortSignal?: AbortSignal; pauseSignal?: AbortSignal; /** The run began in `runNode`, so the leg that ends it fires * `onAgentEnd` (see `agentEnd.ts`). */ agentEnd?: boolean; }; /** What the debugger's legs came to: the leg the program paused or * finished on, or the error a leg threw. `usage` is the last leg's, * which is the run's total so far, since a resume seeds its meter from * the checkpoint it restores; absent when the debugger ran no leg. */ export type AttachedRunResult = { result: RunNodeCoreResult; usage?: RunUsage; } | { threw: unknown; usage: RunUsage; }; export type AttachedDebugger = { /** Answer a batch of debug stops with the user's commands, resuming with * `leg`'s options each time, and return when the program pauses on * something else or finishes. */ run(result: RunNodeCoreResult, leg: LegOptions): Promise; /** The program finished while attached, without passing through `run`. */ finished(result: RunNodeCoreResult): Promise; /** A step in the run `runKey` was let through because another run is * being debugged (`debugRun.ts`); once per such run is enough. */ ignoring?(runKey: string): void; /** A new run took the debugger: what the driver keeps for one run, the * pending overrides, is the old run's and is dropped. */ ownerChanged?(): void; }; export { ATTACHED_RESUME, isAttachedResume } from "./debugRun.js"; export declare function attachedDebuggerOf(ctx: RuntimeContext): AttachedDebugger | undefined; /** The four functions a driver drives a program through, the shape a * compiled module exports bound to its own context (`imports.mustache`). * The debugger's `ModuleFunctions` is this type. */ export type AttachFunctions = { respondToInterrupts: (interrupts: Interrupt[], responses: InterruptResponse[], opts?: { overrides?: Record; edits?: CheckpointEdit[]; at?: StopAt; metadata?: Record; invocation?: InvocationOptions; abortSignal?: AbortSignal; pauseSignal?: AbortSignal; }) => Promise; rewindFrom: (checkpoint: Checkpoint, overrides: Record, opts?: { edits?: CheckpointEdit[]; at?: StopAt; metadata?: Record; invocation?: InvocationOptions; abortSignal?: AbortSignal; pauseSignal?: AbortSignal; }) => Promise; /** The serve-style resume, which hands back a thrown leg as an outcome * with its usage instead of throwing; the attached driver uses it when * the module has it. */ respondToInterruptsForServe?: (interrupts: Interrupt[], responses: InterruptResponse[], opts?: { overrides?: Record; edits?: CheckpointEdit[]; at?: StopAt; metadata?: Record; invocation?: InvocationOptions; abortSignal?: AbortSignal; pauseSignal?: AbortSignal; }) => Promise>; __setDebugger: (dbg: DebuggerState | null) => void; /** Absent from a module compiled before it existed. */ __getDebugger?: () => DebuggerState | null; __getCheckpoints: () => CheckpointStore; }; /** The four functions bound to `ctx`, for an attach server that runs * inside the program and has no module to ask. Bound here, in the * runtime that owns the context, and handed to `registerAttach`: the * `#platform` file can be a different copy of the runtime than the one * the program imported (a test loads the program's copy through vite and * the platform file through Node), and a copy that did not load the * program's modules cannot resume them. */ export declare function attachFunctionsFor(ctx: RuntimeContext): AttachFunctions; type Outcome = ServedInvocationOutcome>; /** The outcome of one leg, with its debug stops answered. While the leg * paused on nothing but debug stops and a debugger is attached, the stops * go to the debugger and the leg it resumes becomes the outcome, carrying * that leg's usage, which is the run's total so far; a leg that threw is * a thrown outcome, as it is with no debugger. A batch that mixes stops * with the program's own interrupts loses the stops: a resume never * reads an answer for a debug stop (the stopped branch carries on from * the flag in its frame), so the caller answers the rest and nothing is * remembered. A final value is reported to the debugger unless the * debugger ran the leg that produced it. A paused checkpoint, from the * caller's own pause signal, is a suspension and goes back as it is. A * batch of stops that reaches here after the debugger was detached, in * the moment between the stop and this settle, is let go with the leg's * own options, as the debugger's `quit` lets a stop go: the caller must * never be handed a stop. */ export declare function settleStops(ctx: RuntimeContext, outcome: Outcome, leg: LegOptions): Promise; /** `settleStops` for an exported function, whose value is the bare * `Interrupt[]` rather than a node's `{ data }` wrapper. The debugger's * resumes return the wrapper, so the value is unwrapped again after. */ export declare function settleFunctionStops(ctx: RuntimeContext, outcome: ServedInvocationOutcome, leg: LegOptions): Promise>;