/** * HTTP client for the allaigate / cortiq-router. * * Calls `POST /v1/route` with the prompt text, returns the router's decision: * `task_label`, `complexity.{score, tier}`, `confidence`, plus metadata. * * The contract matches the allaigate classifier (https://router.allaigate.com). * See also cortiq-gateway/src/router_client.rs for the reference Rust client. */ export interface ComplexityOut { score: number; tier: string; factors?: { base: number; difficulty?: number | null; ambiguity: number; novelty: number; margin: number; length: number; }; } export interface DecisionOut { task_id: number; task_label: string; taxonomy_id: string; confidence: number; confident: boolean; raw_confidence: number; margin: number; is_novel: boolean; novelty_score: number; complexity: ComplexityOut; source: string; flags: string[]; } export interface ScoreOut { task_id: number; task_label: string; probability: number; score: number; reconstruction_error: number; } export interface RouteResponse { schema_version: string; request_id: string; client_request_id?: string | null; decision: DecisionOut; scores: ScoreOut[]; routing?: { target: string; reason: string; } | null; oracle?: { consulted: boolean; model?: string | null; agreement_with_router?: boolean | null; latency_ms?: number | null; } | null; explanation?: { top1_vs_top2: string; decision_path: string; } | null; usage: { billable_decisions: number; oracle_calls: number; }; meta: { model_version: string; taxonomy_version: string; latency_ms: number; embedding_latency_ms: number; served_by: string; }; } /** The subset of RouteResponse that matters for model routing. */ export interface RouteDecision { taskLabel: string; complexityScore: number; complexityTier: string; confidence: number; requestId: string; isNovel: boolean; source: string; } export declare enum RouterErrorKind { Network = "network", Timeout = "timeout", Auth = "auth", Payment = "payment", Quota = "quota", Server = "server", InvalidRequest = "invalid_request" } export declare class RouterError extends Error { kind: RouterErrorKind; httpStatus?: number | undefined; constructor(kind: RouterErrorKind, message: string, httpStatus?: number | undefined); } export interface RouterClientOptions { /** Classifier base URL, e.g. "https://router.allaigate.com" or your own deployment. */ url: string; /** API key (cortiq_...) */ apiKey: string; /** Whether to skip TLS verification (needed for the IP-bound hosted router) */ verifyTls?: boolean; /** Request timeout in ms (the hosted router escalates hard prompts to oracle ~10s) */ timeoutMs?: number; /** Taxonomy id, e.g. "data-assistant" */ taxonomyId?: string; } export declare class RouterApiClient { private baseUrl; private apiKey; private taxonomyId?; private timeoutMs; /** Controllers for the calls currently in flight, so `abort()` reaches all of them. */ private inFlight; constructor(opts: RouterClientOptions); /** Abort every in-flight request (for cleanup). */ abort(): void; /** * Classify text → route decision. * Returns null on network/timeout error (graceful degradation). * Throws RouterError on auth/payment/quota issues. * @param text - the prompt text to classify. * @param profile - policy profile for this call. * @param signal - the caller's cancellation, honored alongside the timeout. */ route(text: string, profile?: string, signal?: AbortSignal): Promise; /** * Fetch available taxonomies (model labels) from the router. * Useful to discover what task labels the account has. */ fetchTaxonomies(): Promise<{ labels: string[]; } | null>; }