/** * WebController — orchestration for `fetch_and_index`. * * Owns a single set of injected index deps (vector store + keyword search) and * drives the parallel-fetch / serial-index pipeline: * * 1. Build a `PoolJob` per request URL. * 2. runPool fetches them in parallel (concurrency from the caller, cpu-capped * for batch). Each job runs fetchAndConvertOne, whose internal index drain * is already SERIAL — so even when N fetches race, the per-URL indexing * never overlaps with itself. Cross-URL overlap is acceptable for * pgvector (row locks) but would contend on PostgreSQL WAL; the per-URL * serial drain keeps the worst case to N concurrent single-writers, which * PostgreSQL tolerates and pgvector handles trivially. * 3. Drain the allSettled-shaped results in input order and return per-URL * status + chunk counts. * * The controller is the composition root that wires the real vector/keyword * stores into the fetcher's `WebIndexDeps`. Tests construct it with a captured * in-memory deps map instead. */ import type { IVectorStore, IKeywordSearch } from "@massa-th0th/shared"; import { type FetchOneResult } from "./fetcher.js"; export interface FetchRequest { url: string; source?: string; } export interface FetchAndIndexParams { /** Single URL (legacy single shape). */ url?: string; /** Label for the single-`url` case. */ source?: string; /** Batch shape. Wins over `url` when both are provided. */ requests?: FetchRequest[]; /** Max URLs fetched in parallel (1-8, default 1). */ concurrency?: number; /** Bypass the TTL cache. */ force?: boolean; /** Per-call cache window override (ms). `0` bypasses like force. */ ttl?: number; /** projectId scoping the indexed chunks. Defaults to "web". */ projectId?: string; } export interface WebControllerDeps { vectorStore: IVectorStore; keywordSearch: IKeywordSearch; } export declare class WebController { private static instance; private readonly deps; private readonly cache; constructor(deps: WebControllerDeps); static getInstance(): WebController; /** * Boot the singleton with real store deps. The Tools API route calls this lazily * on first request (after resolving the async vector store). Idempotent. */ static instantiate(deps: WebControllerDeps): WebController; /** For tests: reset the singleton + clear the cache. */ static resetInstance(): void; /** Build the WebIndexDeps seam from the real stores + the in-memory cache. */ private indexDeps; fetchAndIndex(params: FetchAndIndexParams): Promise<{ success: boolean; results: FetchOneResult[]; concurrency: number; capped: boolean; }>; } //# sourceMappingURL=web-controller.d.ts.map