export type ResponderKind = "actor" | "llm" | "pattern" | "system" | "any"; export type MatchLevel = "L0" | "L1" | "L2" | "L3"; export interface ResponderPredicate { kind: ResponderKind; did?: string; model?: string; capability?: string; domain?: string; trust_gte?: number; trust_lt?: number; budget_usd?: number; latency_secs?: number; match_level_gte?: MatchLevel; age_days_lt?: number; available?: boolean; expression?: string; } export type InferInput = { inline: unknown; inline_kind?: string; } | { record_id: string; } | { ref: { kind: string; id: string; }; }; export interface AnswerShape { kind: string; required_fields?: string[]; schema_ref?: string; } export interface AdaptiveDial { replay_if?: string; create_if?: string; else: number; } export type Dial = number | AdaptiveDial; export type OrchestrationPatternName = "single_shot" | "verify" | "waterfall" | "retry_on_low_confidence" | "escalate" | "ensemble_with_audit"; export interface Orchestration { pattern: OrchestrationPatternName; primary?: ResponderPredicate[]; verifier?: ResponderPredicate; tiebreaker?: ResponderPredicate; agreement_threshold?: number; retry_max?: number; retry_threshold?: number; stages?: ResponderPredicate[]; audit?: ResponderPredicate; } export type FoldFunctionName = "consensus" | "best_of" | "waterfall_first" | "ensemble_weighted" | "expression"; export type FoldTieBreak = "highest_trust" | "highest_confidence" | "most_recent" | "lexicographic"; export interface Fold { function: FoldFunctionName; weight_expression?: string; tie_break?: FoldTieBreak; min_quorum?: number; expression?: string; } export type ObligationStrategy = "last_writer_wins" | "fulfills_wins" | "validation_error"; export interface SideEffects { reversible?: boolean; idempotent?: boolean; max_cost_usd?: number; max_latency_secs?: number; obligation_resolution?: ObligationStrategy; } export interface Relevance { model?: string; threshold?: number; top_k?: number; } export interface InferRequest { input: { goal: string; context?: Record; } | InferInput; answer_shape?: AnswerShape; responders: ResponderPredicate[]; fold: Fold; orchestration?: Orchestration; dial?: Dial; relevance?: Relevance; side_effects?: SideEffects; metadata?: Record; } export interface ProvenanceEntry { responder_did: string; response_record_id: string; weight: number; match_level: string; trust_at_dispatch: number; } export interface TrustSummary { mean: number; min: number; max: number; n_contributors: number; } export interface InferResult { answer: unknown; provenance: ProvenanceEntry[]; trust_summary: TrustSummary; cost_actual_usd: number; cost_charged_but_failed_usd?: number; fold_function: string; chosen_response_id?: string; know_record_id: string; thread_id: string; latency_ms?: number; } export interface InferOptions { wait?: boolean; poll_interval_ms?: number; poll_timeout_ms?: number; thread?: string; } export interface InferPending { pending: true; correlation_id: string; thread_id: string; } export declare function buildInferInput(input: InferRequest["input"]): InferInput; export declare function buildInferQueryBody(req: InferRequest): Record; export declare function findInferResult(records: Array>, correlationId: string): InferResult | undefined; export declare function randomThreadId(): string;