/**
 * `captureFetchToRawSink` — wrap a `fetch` so every request / response / error
 * against a provider is recorded into a `RawProviderSink` as the canonical
 * `RawProviderEvent` triple. The one substrate copy of the fetch-capture
 * pattern four consumers hand-roll (legal ships two copies).
 *
 * The returned value is a plain `typeof fetch` — pass it as the `fetchImpl` to
 * any OpenAI-compatible backend factory. Capture is best-effort by default: a
 * sink write that throws does NOT take down the underlying LLM call (set
 * `failClosed` to change that). Uses the existing `defaultProviderRedactor` +
 * `providerFromBaseUrl` — no new redaction policy.
 */
import { type ExtractedUsage } from './extract-usage';
import { type ProviderRedactor, type RawProviderSink } from './raw-provider-sink';
export interface CaptureFetchContext {
    /** Logical run id stamped on every captured event. Required — without it
     *  the raw events can't be paired with their parent `Run`. */
    runId: string;
    /** Optional logical span id (enables span-level sink filtering). */
    spanId?: string;
    /** Resolved base URL (normalised, no trailing slash). Used for the event's
     *  `baseUrl` and for endpoint-path extraction. */
    baseUrl: string;
    /** Model id the caller intends to invoke. Stamped on every event. */
    model: string;
    /** Provider override. When omitted, `providerFromBaseUrl(baseUrl)`. */
    provider?: string;
}
export interface CaptureFetchOptions {
    /** Override the capture-time redactor. Default `defaultProviderRedactor`. */
    redactor?: ProviderRedactor;
    /** Cap on captured response-body bytes; beyond it the body is truncated and
     *  `body_truncated` is added to `redactedFields`. Default 2 MiB. */
    responseBodyByteCap?: number;
    /** When true, a sink-write failure propagates to the caller. Default false
     *  — capture is best-effort so a sink failure never kills the LLM call. */
    failClosed?: boolean;
    /**
     * Invoked with the token usage parsed off each successful response (JSON or
     * SSE), keyed by the captured context. Lets a caller fold usage → cost without
     * re-cloning the response themselves. Not called when the response carries no
     * usage. Best-effort: a throw here is swallowed (it never kills the LLM call)
     * unless `failClosed` is set.
     */
    onUsage?: (usage: ExtractedUsage, ctx: CaptureFetchContext) => void;
}
export declare function captureFetchToRawSink(fetch: typeof globalThis.fetch, sink: RawProviderSink, ctx: CaptureFetchContext, opts?: CaptureFetchOptions): typeof globalThis.fetch;
//# sourceMappingURL=capture-fetch.d.ts.map