UNPKG

@struktoai/mirage-core

Version:

A Unified Virtual Filesystem For AI Agents

48 lines • 2.75 kB
/** * The one error an aborted invocation rejects with. A signal's own reason * rides along as `cause` (a caller's `abort(x)`, a timeout's TimeoutError) * so every gate keys on one name and the caller still sees why. */ export declare function makeAbortError(signal?: AbortSignal): DOMException; /** * Whether the signal has fired. A call rather than a property read, so a * check that comes after an earlier one is not narrowed away as stale. */ export declare function hasAborted(signal?: AbortSignal): boolean; /** Fold two optional abort signals into one; either aborting aborts. */ export declare function mergeSignals(a: AbortSignal | null | undefined, b: AbortSignal | null | undefined): AbortSignal | undefined; export declare function sleep(ms: number, signal?: AbortSignal): Promise<void>; /** * Call `fire` once `seconds` have passed, and return what cancels it. A * delay past what one timer takes is waited out in turns. */ export declare function atDeadline(seconds: number, fire: () => void): () => void; /** * What a stop that names a signal aborts with (`timeout`'s TERM): what the * stopped run started gets a stop's grace to finish, a guest landing the * file it left open, as one a `kill` stops does through its process's * signal. Python cancels the run and joins it whole, so it needs none. * It is an AbortError, as a plain `abort()` is, since `throwIfAborted` * throws the reason itself and every check keys on that name. */ export declare class SignalStop extends DOMException { readonly signal: number; constructor(signal: number); } /** The signal a stop named, through any signal merged over it; null for a plain abort. */ export declare function stopSignal(signal: AbortSignal | null | undefined): number | null; /** Settle with `promise`, or reject as an abort as soon as `signal` fires. */ export declare function abortable<T>(promise: Promise<T>, signal?: AbortSignal): Promise<T>; /** How long a cancelled tree gets to unwind before the caller is released anyway. */ export declare const ABORT_JOIN_MS = 250; /** * The twin of Python's `run_cancellable`: cancel, then join. A cancelled * asyncio task unwinds at its next await, so Python joins it fully. A JS * promise cannot be cancelled, so once `signal` fires the tree is given * `graceMs` to reach a checkpoint, close its producers and settle with * its own error (which keeps the caller's abort reason); a leaf that is * blocked past that is left running and the caller is released. A * function is asked for the grace when the signal fires. */ export declare function runCancellable<T>(promise: Promise<T>, signal: AbortSignal | undefined, graceMs?: number | (() => number)): Promise<T>; //# sourceMappingURL=abort.d.ts.map