import type { Profile } from "../agent/profile.ts"; import type { Turn } from "../agent/turn.ts"; import type { RuleStore } from "../corpus/store.ts"; import type { Answer, AskContext, Cache, Stage } from "./types.ts"; export type PipelineOptions = { store: RuleStore; profile: Profile; stages: Stage[]; cache?: Cache; /** * Scopes every cache key. Bump it when the corpus changes, and every stale * answer becomes unreachable at once with no keys to enumerate and delete. * * It is set HERE and nowhere else, because a reader and a writer that * disagree about the version never share an entry again. */ cacheVersion?: string; }; export type RunInput = { question: string; history?: Turn[]; caller?: AskContext["caller"]; signal?: AbortSignal; }; /** What a whole run produced, including the stages that failed on the way. */ export type RunResult = { answer: Answer | null; degraded: string[]; /** Every stage that ran, in order, and what it did. For a status page. */ trace: { stage: string; outcome: "answered" | "passed" | "skipped" | "failed"; ms: number; }[]; }; /** * The answer pipeline. * * Stages run in order and the first one that can answer wins. Every stage before * the last is an optimisation, so a stage that fails must degrade to a miss and * let the run continue. It must never take the answer down with it. * * A failure is REPORTED, not swallowed. A stage that quietly returns null when * it is actually broken looks exactly like a stage that had nothing to say, and * the difference is the whole diagnosis: one is healthy, and the other has been * sending every question to the most expensive layer for weeks. */ export declare function createPipeline(options: PipelineOptions): { run: (input: RunInput) => Promise; contextFor: (input: RunInput) => AskContext; cache: Cache; stages: Stage[]; store: RuleStore; profile: { game: { name: string; slug: string; description: string; }; identity?: string | undefined; vocabulary: { use: string; insteadOf: string[]; means: string; }[]; cards: { enabled: boolean; linkScheme: string; noun: string; nounPlural: string; maxInlineImages: number; textFields: { field: string; describes: string; }[]; statFields: { field: string; describes: string; }[]; }; tokens?: { syntax: string; groups: { label: string; examples: string[]; }[]; } | undefined; scope: { answer: string[]; refuse: string[]; }; attribution?: { text: string; url: string; official: boolean; } | undefined; extraGuidance: string[]; }; }; export type Pipeline = ReturnType; //# sourceMappingURL=pipeline.d.ts.map