import type { Provider, ProviderMessage } from "../providers/ProviderTypes.js"; import { type AgentTierResolution, type CodaliGatewayAgentAssignment } from "./AgentTierResolver.js"; import type { CodaliContextPack, CodaliGatewayClassifierOutput, CodaliGatewayPlannerOutput, CodaliGatewayRequest, CodaliGatewayResult } from "./CodaliGatewayTypes.js"; import { type GatewayPolicyCompilation } from "./GatewayPolicyCompiler.js"; import { CodaliGatewayPlanner, type CodaliGatewayPlanningResult, type CodaliGatewayPlannerOptions, type CodaliGatewayPlannerToolDescriptor } from "./GatewayPlanner.js"; import { type CodaliGatewayRunTrace, type CodaliGatewayStore } from "./CodaliGatewayStore.js"; import { type CodaliGatewayReplayFixture, type CodaliGatewayReplayFixtureOptions, type CodaliGatewayTraceReadResult } from "./GatewayTraceReplay.js"; import { CodaliGatewayStateMachine, type CodaliGatewayStateMachineOptions, type CodaliGatewayWorkerExecutionResult, type CodaliGatewayWorkerTaskRunner } from "./GatewayStateMachine.js"; import { type CodaliGroundingMode } from "./GroundingMode.js"; import { buildTemporalContext } from "./TemporalContext.js"; import { type GatewayDatasetGatewayCollectionOptions, type GatewayDatasetStore } from "../storage/GatewayDatasetStore.js"; export interface CodaliGatewayFinalSynthesizerOptions { maxTokens?: number; temperature?: number; retryAttempts?: number; } export interface CodaliGatewayOptions { /** Used for final synthesis, and for planning when `plannerProvider` is unset. */ provider: Provider; /** * Model for the classifier and planner stages. * * These run on every question and only emit JSON, so they want a fast model. * Final synthesis wants a strong one. Sharing a single provider forced both * onto the same model: binding a small orchestrator changed only the worker, * and planning still went to the large synthesizer — which on a slow local * node meant every run paid the big model's latency twice before any tool * was called. */ plannerProvider?: Provider; store?: CodaliGatewayStore; planner?: CodaliGatewayPlanner; plannerOptions?: CodaliGatewayPlannerOptions; stateMachine?: CodaliGatewayStateMachine; taskRunner?: CodaliGatewayWorkerTaskRunner; workerOptions?: Omit; agentInventory?: unknown[]; agentResolution?: AgentTierResolution; /** * The agent actually serving final synthesis. * * Without it the gateway re-resolves `final_synthesizer` from the raw * inventory and reports whatever that picks — which is not necessarily the * model the caller bound and passed as `provider`. Traces then name a model * that was never called. */ finalAgent?: CodaliGatewayAgentAssignment; /** * Model-facing tool descriptors, keyed by tool name. Derived from the * caller's ToolRegistry rather than stored here, so the planner can never see * a schema the executor would not honour. Without these the planner only * sees bare tool names and cannot choose competently. */ toolDescriptors?: Record; finalSynthesizerOptions?: CodaliGatewayFinalSynthesizerOptions; datasetStore?: GatewayDatasetStore; datasetCollection?: GatewayDatasetGatewayCollectionOptions; } export interface CodaliGatewayPlanResult { runId: string; /** Absolute time range this run resolved from the query, if any. */ temporal?: ReturnType; policyCompilation: GatewayPolicyCompilation; classifier: CodaliGatewayClassifierOutput; planner: CodaliGatewayPlannerOutput; planning: CodaliGatewayPlanningResult; trace?: CodaliGatewayRunTrace; } export interface CodaliGatewayWorkerRunResult { runId: string; planning: CodaliGatewayPlanResult; workers: CodaliGatewayWorkerExecutionResult; trace?: CodaliGatewayRunTrace; } export interface CodaliGatewayFinalSynthesisInput { runId: string; request: CodaliGatewayRequest; planning?: CodaliGatewayPlanResult; workers?: CodaliGatewayWorkerExecutionResult; contextPack?: CodaliContextPack; agentResolution?: AgentTierResolution; } export declare const buildCodaliGatewayFinalSynthesizerMessages: (request: CodaliGatewayRequest, contextPack: CodaliContextPack, grounding?: CodaliGroundingMode) => ProviderMessage[]; export declare class CodaliGateway { private readonly options; readonly store: CodaliGatewayStore; private readonly planner; constructor(options: CodaliGatewayOptions); readTrace(runId: string): Promise; exportReplayFixture(runId: string, options?: CodaliGatewayReplayFixtureOptions): Promise; plan(request: CodaliGatewayRequest): Promise; executeWorkerTasks(request: CodaliGatewayRequest): Promise; run(request: CodaliGatewayRequest): Promise; synthesizeFinalAnswer(input: CodaliGatewayFinalSynthesisInput): Promise; /** * Executes an already-computed plan. Public so a caller can interleave its * own tracing between planning and execution without re-planning. */ executePlannedWorkerTasks(request: CodaliGatewayRequest, planning: CodaliGatewayPlanResult): Promise; private collectDatasetResult; private resolveFinalAgent; private validateRequiredFinalLargeModel; private buildFinalPolicyBlockedResult; /** * Builds a result that came out of the finalizer without a synthesizer * failure — the deterministic and artifact modes, and the schema-unsatisfied * partial. Kept in one place so every finished result carries the same * fields regardless of which mode produced it. */ /** * Returns the clarifying question instead of an answer. Carries the same * result contract as any other outcome so a caller needs no special case * beyond checking `status`. */ buildClarificationResult(request: CodaliGatewayRequest, planning: CodaliGatewayPlanResult, question: string): Promise; private buildFinalizedResult; private buildDegradedFinalResult; private buildFailedFinalResult; private updateRunPreservingMetadata; private resolveStateMachine; } export declare const createCodaliGateway: (options: CodaliGatewayOptions) => CodaliGateway; export declare const runCodaliGatewayPlanning: (request: CodaliGatewayRequest, options: CodaliGatewayOptions) => Promise; export declare const runCodaliGatewayWorkerTasks: (request: CodaliGatewayRequest, options: CodaliGatewayOptions) => Promise; export declare const runCodaliGateway: (request: CodaliGatewayRequest, options: CodaliGatewayOptions) => Promise; //# sourceMappingURL=CodaliGateway.d.ts.map