/** * Shared extraction pipeline for LLM argument/field extractors. * * Each extractor implements the same call → parse → repair → parse loop with * explicit failure propagation. The differences are the prompt, the parser, and the * optional repair prompt. This helper owns only that orchestration — callers * retain full control of their schema, validators, and prompts. */ import { type GenerateTextParams, ModelType } from "../types/model.js"; import type { IAgentRuntime } from "../types/runtime.js"; type ModelTypeValue = (typeof ModelType)[keyof typeof ModelType]; export interface ExtractorPipelineResult { /** Parsed value from the first or repaired model call, or null when both failed. */ parsed: TParsed | null; /** * Raw model output. When the repair pass ran, this is the repair output; * otherwise it is the first call's output. */ raw: string; /** True when the repair prompt was issued. */ repaired: boolean; } export interface RunExtractorPipelineArgs { runtime: IAgentRuntime; prompt: string; /** Request-bound canonical system context, when already supplied by the caller. */ system?: string; /** Opt in to a provider text response format for both first and repair calls. */ responseFormat?: GenerateTextParams["responseFormat"]; /** * Convert the raw model text into a typed value. Return `null` when the * output is unparseable or fails validation; that triggers the repair pass. */ parser: (raw: string) => TParsed | null; /** * Build the repair prompt from the raw first-pass output. Omit to skip * the repair pass entirely. */ buildRepairPrompt?: (rawFirstPass: string) => string; /** Defaults to {@link ModelType.TEXT_LARGE}. */ modelType?: ModelTypeValue; } /** * Run the canonical extractor pipeline. * * Order of operations: * 1. Call the model with `prompt`. * 2. Run `parser` on the result. If it returns non-null, return that. * 3. Otherwise, if `buildRepairPrompt` is provided, call the model again * with the repair prompt and run `parser` on that result. * 4. Model and transport failures propagate after being reported. */ export declare function runExtractorPipeline(args: RunExtractorPipelineArgs): Promise>; export {};