import { type DbExec } from "../db/client.js"; export interface ExecutionFence { threadId: string; turnId: string; runId: string; generation: string; /** * A requested Stop expires the run's lease, and the stopped run still has * to save what it wrote. This fence holds while the lease names the run and * generation, however expired; a worker that claims the turn replaces both. */ outlivesStop?: true; } export declare class ExecutionFenceError extends Error { readonly code: string; constructor(code: string, message: string); } export declare class StaleExecutionFenceError extends ExecutionFenceError { constructor(fence: ExecutionFence); } export declare class MissingExecutionFenceError extends ExecutionFenceError { constructor(); } export declare function currentExecutionFence(): ExecutionFence | undefined; export declare function currentExecutionFenceForScope(scope: { runId?: string; threadId?: string; turnId?: string; }): ExecutionFence | undefined; export declare function withExecutionLeaseRequested(work: () => T): T; export declare function withExecutionFence(fence: ExecutionFence, work: () => T): T; export declare function runWithoutExecutionFence(work: () => T): T; export declare function lockAndAssertCurrentExecutionFences(tx: DbExec, ignoredFence?: ExecutionFence): Promise; export declare function withFencedExecutionWrite(write: (tx: DbExec) => Promise, scope?: { runId?: string; threadId?: string; turnId?: string; }): Promise;