export declare class PromiseTracker {
    private promises;
    private isShuttingDown;
    reset(): void;
    /**
     * Register a promise to be tracked
     */
    register<T>(promise: Promise<T>): Promise<T>;
    shutdown(): Promise<void>;
    /**
     * Wait for all registered promises to settle
     */
    awaitAll(): Promise<PromiseSettledResult<unknown>[]>;
    /**
     * Get the number of currently tracked promises
     */
    get count(): number;
    /**
     * Check if there are any pending promises
     */
    get hasPending(): boolean;
    /**
     * Get a snapshot of currently tracked promises
     */
    getSnapshot(): Promise<unknown>[];
}
/**
 * Convenience function to register a promise with the context's PromiseTracker
 */
export declare function trackPromise<T>(promise: Promise<T>): Promise<T>;
/**
 * Await all tracked promises to settle
 *
 */
export declare function shutdownPromiseTracker(): Promise<void>;
/**
 * The well-known `globalThis` key under which the background-promise registrar
 * is installed. Plugins and other bot handlers that cannot import
 * `@botpress/runtime` reach the registrar through this key — see
 * {@link registerBackgroundPromise} and {@link installGlobalBackgroundRegistrar}.
 */
export declare const BACKGROUND_PROMISE_GLOBAL_KEY: "__ADK_GLOBAL_BACKGROUND";
/**
 * Signature of the globally-installed background-promise registrar.
 *
 * Hand a promise to this function to have it awaited before the lambda is torn
 * down, without blocking the current handler. Returns the same promise so it can
 * be chained. Always safe to call: if there is no active request context (e.g.
 * cold-start top-level code, scripts, workers without a context), the promise is
 * left to run detached and returned unchanged — it is never re-thrown and the
 * call never throws.
 */
export type BackgroundPromiseRegistrar = <T>(promise: Promise<T>) => Promise<T>;
/**
 * Register a promise to be awaited before the lambda is killed.
 *
 * This is the in-runtime entry point. It bridges to the *current request's*
 * {@link PromiseTracker} (resolved from the AsyncLocalStorage context), so a
 * promise handed off here is flushed by `shutdownPromiseTracker()` at the end of
 * the request — the same machinery `trackPromise` uses.
 *
 * Unlike `trackPromise`, this never throws when no context is active: it falls
 * back to letting the promise run detached. That makes it safe to expose to
 * untrusted plugin code, which may run in contexts we do not control.
 */
export declare function registerBackgroundPromise<T>(promise: Promise<T>): Promise<T>;
/**
 * Install {@link registerBackgroundPromise} onto `globalThis` under
 * {@link BACKGROUND_PROMISE_GLOBAL_KEY} so code that cannot import
 * `@botpress/runtime` (plugins, generated handlers) can hand off background
 * promises.
 *
 * Idempotent and bundle-safe: the function is stored via `getSingleton`, so
 * multiple loaded copies of the runtime share one registrar bound to the single
 * shared AsyncLocalStorage. Runs at module load (see bottom of this file) — well
 * before any request handler or plugin executes.
 */
export declare function installGlobalBackgroundRegistrar(): BackgroundPromiseRegistrar;
//# sourceMappingURL=promises.d.ts.map