/** * Linkup Provider Adapter. * * Implements the Linkup Provider Descriptor with the Search capability * on top of the direct-HTTP transport (`./client.ts`). The Adapter owns * credentials, transport lifecycle, Provider field mapping, and failure * normalization; shared execution owns cache and retry policy. * * Structurally cloned from `providers/tavily/adapter.ts` (Tavily/Parallel * research-poll analog, IMPLEMENTATION-CONTRACT analog-adapter table). * * Boundary rules (ARCHITECTURE.md §2): * - May import capability types, normalized errors, Provider identity * types, and the Adapter-local credential and transport Modules. * - Must NOT import command presentation, output mode, or another * Provider's Adapter. * * Field mapping (Linkup wire → normalized): * Search results[].name -> title * Search results[].url -> url * Search results[].content -> summary (falls back to snippet) * Search results[].favicon -> (dropped) * Search results[].type -> (dropped) * * Control mapping (SearchControls → Linkup-native API params): * domain -> includeDomains: [domain] * recency -> fromDate/toDate ISO date window (oneDay/oneWeek/ * oneMonth/oneYear; noLimit omits dates) * contentSize -> depth (high→"deep", medium/absent→"standard") * topic -> keyword appended to q * location -> locale keyword appended to q * type -> REJECTED (UnsupportedOptionError) * * Field mapping (Linkup wire → normalized, reader /fetch): * url -> finalUrl (falls back to the requested url) * markdown -> content (empty → ApiError; never cache an empty fetch) * rawHtml / images -> (dropped) * renderJs -> renderJs wire field (control honored; defaults true * when absent for SPA compatibility) * * Research lifecycle (mirrors createExaDescriptor, Linkup SPEC §Research): * POST /research — submit task once (no retry, double-charge * prevention on a usage-based endpoint) * GET /research/:id — poll every LINKUP_RESEARCH_POLL_INTERVAL_MS * (default 5000) until completed/failed/not_found * updatedAt / output.answer -> report (canonical object output) * output (string) -> report (flat output fallback) * markdown -> report (flat markdown fallback) * output.sources[].name -> sources[].title (fallback url) * output.sources[].url -> sources[].url * `model` mapping: mini→"S", auto→"L", pro→"XL" (reasoningDepth) * transient poll errors (429/5xx/network/timeout) are retried up to * MAX_POLL_RETRIES=3 before propagating; failed poll -> ApiError 500 * with no raw body in the message. * `not_found` triggers at most ONE recreation (Tavily/Parallel guard). * State-file persistence via createAsyncJobStateFile + computeAsyncJobStateHash * double-charge prevention; resume on Ctrl-C / crash. */ import type { ProviderDescriptor } from "../types.js"; import type { AsyncJobStateFile } from "../../lib/async-job-state.js"; import { type LinkupTransportDeps } from "./client.js"; /** * Dependencies the Linkup Adapter accepts. The unified `transport` * seam carries `fetch` and timer injection; `now` makes the * recency→date window deterministic in tests. */ export interface LinkupAdapterDependencies { /** Optional transport injection (fetch, timers, env). */ readonly transport?: LinkupTransportDeps; /** * Injectable clock for the recency→fromDate window. Defaults to * `Date.now`; tests pass a fixed epoch. */ readonly now?: () => number; /** Optional Research state-file port (double-charge prevention). */ readonly researchStateFile?: AsyncJobStateFile; /** Optional directory containing research state files (for locking). */ readonly researchStateDir?: string; } /** * Build the Linkup Provider Descriptor. The descriptor advertises the * capabilities the constructed Adapter supplies and constructs an * Adapter whose Search, Reader, Research, Quota, and Diagnostics * Capabilities own credentials, transport, * Provider field mapping, and failure normalization. Construction is * side-effect-free; the transport is invoked per Capability call. * Tests pass `transport` (typically a fake-fetch wrapper); production * uses the no-argument factory which resolves to the global `fetch` * and timers inside the transport Module. */ export declare function createLinkupDescriptor(dependencies?: LinkupAdapterDependencies): ProviderDescriptor; //# sourceMappingURL=adapter.d.ts.map