import { type LLMConfig } from "./llm.js"; import type { SearchAdapter, SubAdapterFailure } from "./search.js"; import { type SourceAuthorityMode } from "./source-authority.js"; import { type Plan, type Critique } from "./plan.js"; import { type BrowserOptions, type FetchedPage } from "./browser.js"; import { type SourceWithContent } from "./synthesize.js"; import { type VerificationReport } from "./verify.js"; import { type MultiModelCostEstimate } from "./pricing.js"; import { type DomainFilter } from "./domain-filter.js"; import type { PageCache } from "./cache.js"; import { type RobotsCache } from "./robots.js"; export interface BrowserLike { start(): Promise; fetch(url: string): Promise; close(): Promise; } export interface AgentConfig { llm: LLMConfig; models?: { plan?: string; synth?: string; critique?: string; }; maxCostUsd?: number; preKept?: SourceWithContent[]; search: SearchAdapter; fallbackSearch?: SearchAdapter; browser: BrowserOptions; resultsPerQuery: number; maxSources: number; maxWordsPerSource: number; deepRounds: number; concurrency: number; cache?: PageCache; browserFactory?: (opts: BrowserOptions) => BrowserLike; respectRobots?: boolean; robotsUserAgent?: string; robotsCache?: RobotsCache; verifyCitations?: boolean; citeMinRecall?: number; pdfMaxPages?: number; include?: string[]; domainFilter?: DomainFilter; env?: Record; tldr?: boolean; sinceMs?: number; dedupeNearDupes?: boolean; nearDupeThreshold?: number; sourceAuthority?: SourceAuthorityMode; onEvent?: (event: AgentEvent) => void; onSynthesizeToken?: (chunk: string, round: number) => void; } export type AgentEvent = { type: "plan.start"; question: string; } | { type: "plan.done"; plan: Plan; } | { type: "round.start"; round: number; queries: string[]; } | { type: "search.start"; query: string; } | { type: "search.done"; query: string; count: number; } | { type: "search.error"; query: string; message: string; rateLimited: boolean; } | { type: "search.fallback"; adapter: string; queries: string[]; } | { type: "search.hinted"; hosts: string[]; queries: string[]; } | { type: "search.fallback-skipped"; adapter: string; allow: string[]; } | { type: "search.degraded"; query: string; failures: SubAdapterFailure[]; } | { type: "fetch.start"; url: string; cached: boolean; } | { type: "fetch.done"; url: string; ok: boolean; status: number; words: number; cached: boolean; } | { type: "fetch.skipped"; url: string; reason: "robots" | "pdf-no-extractor" | "pdf-extract-error" | "domain-deny" | "domain-not-allowed" | "stale" | "near-duplicate"; } | { type: "include.done"; ingested: number; skipped: number; } | { type: "synthesize.start"; sourceCount: number; round: number; } | { type: "synthesize.done"; round: number; } | { type: "critique.start"; round: number; } | { type: "critique.done"; round: number; critique: Critique; } | { type: "verify.done"; report: VerificationReport; } | { type: "llm.call"; phase: "plan" | "synth" | "critique"; round: number; inputTokens: number; outputTokens: number; model: string; }; export interface RoundTrace { round: number; queries: string[]; candidatesFound: number; fetched: number; kept: number; critique?: Critique; } export interface AgentResult { question: string; plan: Plan; sources: SourceWithContent[]; answer: string; markdown: string; rounds: RoundTrace[]; verification?: VerificationReport; cost: MultiModelCostEstimate; usage: { queries: number; fetched: number; kept: number; rounds: number; cacheHits: number; citationsTotal: number; citationsSupported: number; llm: { inputTokens: number; outputTokens: number; calls: number; }; estimatedCostUsd: number; }; } export interface SearchErrorInfo { query: string; message: string; rateLimited: boolean; } export declare class NoSourcesError extends Error { readonly adapter: string; readonly queries: string[]; readonly candidatesFound: number; readonly searchErrors: SearchErrorInfo[]; readonly droppedByDomainFilter: number; readonly fallbackSkipped?: string; constructor(adapter: string, queries: string[], candidatesFound: number, searchErrors: SearchErrorInfo[], opts?: { droppedByDomainFilter?: number; fallbackSkipped?: string; }); } export declare function runAgent(question: string, config: AgentConfig, signal?: AbortSignal): Promise; //# sourceMappingURL=agent.d.ts.map