/** * Patches window.fetch at module-import time — before any React component * mounts and before any AI SDK can capture the fetch reference. This is the * key difference from installing the patch in a useEffect: by the time a * useEffect runs, the Vercel AI SDK (and others) may have already resolved * their fetch reference and bypass the patch entirely. * * Handles three credit-error surfaces: * 1. HTTP 402 with { code: "insufficient_credits" } — regular JSON routes. * 2. HTTP 200 streaming body containing "insufficient_credits" — SSE, ndjson, * or Vercel AI SDK data-stream (text/plain) routes. * 3. Manual call to notifyInsufficientCredits() from any error handler. */ type Listener = () => void; /** * Subscribe to insufficient-credits events detected in window.fetch. * Returns an unsubscribe function for use in useEffect cleanup. * * The fetch patch is installed at module load time regardless of whether * anyone calls this function. This exists for components that need a direct * callback rather than the global DOM event. */ export declare function subscribeFetchWatcher(listener: Listener): () => void; export {};