/** * Undici-backed driver — gives Node callers full control over the * connection pool, keep-alive, pipelining, and HTTP/2 negotiation that * the runtime's built-in fetch hides behind a default `Agent`. * * Peer dependency: `undici`. The package is **not** bundled — the * driver dynamically imports `undici` the first time `request()` is * called, so misina's other entry points stay zero-dep. Make sure * `undici` is in your project's `dependencies` (any 6.x or newer). * * @example * ```ts * import { Agent } from "undici" * import { undiciDriver } from "misina/driver/undici" * * const api = createMisina({ * driver: undiciDriver({ * dispatcher: new Agent({ * connections: 100, * keepAliveTimeout: 30_000, * pipelining: 1, * allowH2: true, // HTTP/2 multiplexing * }), * }), * baseURL: "https://inference.example.com", * }) * ``` */ import type { MisinaDriverFactory } from "../types.mjs"; /** * Opaque handle for `undici.Dispatcher` (Agent / Pool / Client). We * intentionally don't import the type from `undici` so the package is * not a hard dependency at the type level. Pass the value you got * from `new Agent(...)` / `new Pool(...)` directly; we forward it as- * is to undici's `fetch`. */ export type UndiciDispatcher = any; export interface UndiciDriverOptions { /** * Pre-built undici `Agent` / `Pool` / `Client` to route every * request through. Created once in your app, reused across calls. * Required — without a dispatcher this driver collapses to a * dynamic-import wrapper around `globalThis.fetch`, defeating the * point of installing it. */ dispatcher: UndiciDispatcher; /** * Override the undici `fetch` import. Mostly for tests; otherwise * the driver lazy-imports `undici` on first call. */ fetch?: (input: Request, init?: { dispatcher?: UndiciDispatcher; }) => Promise; } declare const undiciDriver: MisinaDriverFactory; export { undiciDriver }; export default undiciDriver;