/**
 * Tags every Capgo API call made inside `fn` with `source`. The result is wrapped
 * in `Promise.resolve()` inside `run()` so lazy thenables still start their fetch
 * inside the async context.
 */
export declare function withApiCallSource<T>(source: string, fn: () => T): Promise<Awaited<T>>;
export declare function getApiCallSource(): string | undefined;
export declare function enableApiInstrumentation(): void;
export declare function isApiInstrumentationEnabled(): boolean;
export interface ApiCallInfo {
    url: string;
    /** Capgo API route relative to the API host, e.g. `private/cli/preflight`. */
    route?: string;
    method: string;
    status: number;
    ok: boolean;
    durationMs: number;
    source?: string;
    apikey?: string;
    error?: unknown;
}
export type ApiCallRecorder = (info: ApiCallInfo) => void;
export declare function setApiCallRecorder(fn: ApiCallRecorder): void;
/** An API call slower than this is flagged `slow` regardless of status. */
export declare const SLOW_THRESHOLD_MS = 5000;
/**
 * Turns a Capgo API route into a low-cardinality operation label. Query strings
 * are discarded and only leading static segments are kept, so ids (app ids, etc.)
 * never become labels: `private/cli/preflight` => `POST private/cli/preflight`.
 */
export declare function deriveApiOperation(route: string, method: string): string;
/**
 * A `fetch` wrapper for Capgo API calls. Times the real request (which runs
 * regardless), captures the active source label, and hands the result to the
 * injected recorder. Returns the real Response / rethrows the real error so the
 * caller's behavior is never altered. Calls `globalThis.fetch` dynamically (not
 * a captured ref) so it is testable and never self-recurses.
 */
export declare function createTimedFetch(route?: string): typeof fetch;
