import type { CompletionRequest } from '../types/messages.js'; import type { NexusResponse } from '../types/response.js'; import type { ResponseFormatConfig } from '../types/config.js'; import { type RagChunk } from '../hallucination/rag.js'; /** * The one method a workflow needs from a client. A `NexusAI` client fits, and so does a test * double. */ export interface WorkflowClient { /** Runs one completion. */ complete(request: CompletionRequest): Promise; } /** One step of a workflow and the response it produced. */ export interface WorkflowStepResult { /** The step's name, such as `summarize` or `verify`. */ step: string; /** Its response. */ response: NexusResponse; } /** The outcome of a workflow. */ export interface WorkflowResult { /** The final answer's text. */ content: string; /** The final step's response. */ response: NexusResponse; /** Every step, in order, for inspecting how the answer was reached. */ steps: WorkflowStepResult[]; } /** Options for `summarizeVerifyFormat`. */ export interface SummarizeVerifyFormatOptions { /** Model used for every step. */ model: string; /** The content to summarize. */ input: string; /** Sources to check the summary against. Without them, the verify step is skipped. */ verifyContext?: string[]; /** Format of the final answer, such as a JSON schema. */ responseFormat?: ResponseFormatConfig; /** Replaces the default summarization instruction. */ summaryInstruction?: string; /** Replaces the default formatting instruction. */ finalInstruction?: string; } /** Options for `ragAnswer`. */ export interface RagAnswerOptions { /** Model that answers. */ model: string; /** The question. */ question: string; /** Retrieved passages the answer must cite. */ chunks: RagChunk[]; /** Checks the answer against the passages and repairs unsupported claims. */ verify?: boolean; } /** Options for `extractStructured`. */ export interface ExtractStructuredOptions { /** Model that extracts. */ model: string; /** The text to extract from. */ input: string; /** JSON Schema the extraction must match. */ schema: Record; /** Replaces the default extraction instruction. */ instruction?: string; } /** Options for `classifyRoute`. */ export interface ClassifyRouteOptions { /** Model that classifies. */ model: string; /** The text to classify. */ input: string; /** The labels to choose from. */ labels: string[]; /** Replaces the default classification instruction. */ instruction?: string; } /** Options for `compareAndDecide`. */ export interface CompareOptions { /** Model that decides. */ model: string; /** What the decision is about. */ input: string; /** The options to choose between. */ options: string[]; /** What the choice should weigh. */ criteria?: string[]; } /** * Summarizes content, verifies the summary against sources when given, then formats it: two * completions, or three to four with verification, each step returned. */ export declare function summarizeVerifyFormat(client: WorkflowClient, options: SummarizeVerifyFormatOptions): Promise; /** * Answers a question from retrieved passages with citations, optionally verifying and repairing the * answer against them. */ export declare function ragAnswer(client: WorkflowClient, options: RagAnswerOptions): Promise; /** Extracts structured data matching a JSON schema. */ export declare function extractStructured(client: WorkflowClient, options: ExtractStructuredOptions): Promise; /** * Picks exactly one label for the input, at temperature 0, returning `{ label, confidence }` as * JSON. */ export declare function classifyRoute(client: WorkflowClient, options: ClassifyRouteOptions): Promise; /** Compares options against criteria and chooses one, reasoning privately before answering. */ export declare function compareAndDecide(client: WorkflowClient, options: CompareOptions): Promise;