export type ResumableScopeOpts = { /** Shown in traces, checkpoint locations. Required. */ name: string; /** Default: "". Label used only for grouping this scope's * steps in trace files and debugger UI — execution is unaffected * by collisions. If two TS files use the same `moduleId` + * `name`, their scopes will appear under the same group in those * UIs, but each scope still gets its own isolated frame on the * stack at runtime. Override when you want a TS helper to appear * under a distinct module label in the debugger. */ moduleId?: string; /** Default: false. When true, pins a `result-entry` checkpoint at * scope entry so the calling Agency function's `result.retry()` * rewinds to this scope's start, exactly as it would for a * generated function body. Disabled by default because pinned * checkpoints accumulate without bound (evictIfNeeded only evicts * unpinned) and the per-entry JSON deep-clone of stateStack + * globals is a real per-keystroke cost. Pair this with the * resultCheckpointSetup template which has the same behavior for * compiled Agency function bodies. Not related to the debugger — * for that, see `agency.callsite()` and the per-step ALS frame. */ pinResultCheckpoint?: boolean; }; export type ResumableScope = { /** Resumable step. Each call gets an auto-incrementing id (0, 1, * 2, ...) tied to the order `s.step(...)` is invoked. On resume, * the body re-runs only if not already completed; once complete, * the cached return value is returned without re-executing. * * Step calls MUST be issued in a stable order across runs — see * the determinism contract on `withResumableScope`. */ step(fn: () => T | Promise): Promise; /** Get a frame-local value persisted across resume. Returns * `undefined` for unset keys. */ getLocal(key: string): T | undefined; /** Set a frame-local value. The value is serialized into the * scope's frame and survives resume. */ setLocal(key: string, value: T): void; /** Halt the scope; `withResumableScope` resolves with `result`. * Use this to bubble a final value (e.g. an interrupt-response * outcome the step body has already handled) out of the scope * without executing the remaining steps. Sets the underlying * Runner's `halted` flag, so every subsequent `s.step(...)` * short-circuits without invoking its callback. Does NOT throw, * and does NOT raise an interrupt to the caller — for the * latter, see the planned `agency.interrupt()` helper. */ halt(result: unknown): void; }; export declare function withResumableScope(opts: ResumableScopeOpts, body: (s: ResumableScope) => Promise): Promise;