/** * Deferred promise utility — maps Python's asyncio.Future for the RELAY client. * * Uses a manual promise constructor for Node 18+ compatibility. */ /** * A promise with externalised `resolve`/`reject` and a `settled` flag, * used by the RELAY client to bridge server-push events back to in-flight * JSON-RPC request callers. */ export interface Deferred { /** The wrapped promise. */ promise: Promise; /** Resolve the promise idempotently (later calls are ignored). */ resolve: (value: T | PromiseLike) => void; /** Reject the promise idempotently (later calls are ignored). */ reject: (reason?: unknown) => void; /** True once either `resolve` or `reject` has been called. */ readonly settled: boolean; } /** * Create a {@link Deferred} with externalised `resolve` / `reject` and a * `settled` flag. * * The returned object exposes the promise plus its resolve and reject * functions so callers outside the executor can settle it. Later calls to * `resolve` or `reject` are idempotent. * * @typeParam T - Resolution value type of the wrapped promise. * @returns A fresh `Deferred` in pending state. */ export declare function createDeferred(): Deferred; /** * Race a promise against a timeout. * * @typeParam T - Resolution value type of the input promise. * @param promise - Promise to race against the timeout. * @param ms - Timeout in milliseconds. * @param label - Label used in the timeout error message. Defaults to * `"Operation"`. * @returns A new promise that resolves with `promise`'s value if it settles * before the timeout, and rejects with a timeout `Error` otherwise. */ export declare function withTimeout(promise: Promise, ms: number, label?: string): Promise;