/** * JEV HTTP client — the single transport boundary for the unified classifier. * * Two endpoints are supported: * - `typesafe`: POST https://api.typesafe.ai/v1/systemone * (Authorization: Bearer $TYPESAFE_API_KEY, model `jev-latest`) * - `openrouter`: POST https://openrouter.ai/api/alpha/decisions * (Authorization: Bearer $OPENROUTER_API_KEY, model `typesafe/jev-1.13`) * * The client validates the response shape against the requested question * types — a malformed answer fails the call so the engine can fall back. */ import type { AuthOperationOptions, ClassifierApi, ClassifierContext, ClassifierModel, ClassifierResult, ModelsClassifierOptions } from "@earendil-works/pi-ai"; import type { JevQuestions, JevRequest, JevResponse } from "./types.ts"; export type JevEndpoint = "typesafe" | "openrouter"; export declare const JEV_ENDPOINT_URLS: Record; export declare const JEV_DEFAULT_MODELS: Record; export declare const JEV_API_KEY_ENVS: Record; export declare const JEV_DEFAULT_TIMEOUT_MS = 4000; export interface JevClientOptions { endpoint: JevEndpoint; apiKey: string; model?: string; baseUrl?: string; timeoutMs?: number; fetchFn?: typeof fetch; signal?: AbortSignal; } export interface JevClient { decide(request: Omit): Promise; } interface PreparedJevDecision { identity: string; effectiveModel?: string; /** Present only after native authenticated model resolution. */ authenticatedModel?: string; decide(): Promise; } export interface ClassifierRuntimeReadiness { status: "disabled" | "unknown" | "available" | "unavailable"; available: boolean; reason?: string; model?: string; } /** @internal Authentication-only probe; never submits a model request. */ export declare function probeJevClient(client: JevClient, signal?: AbortSignal): Promise; /** @internal Resolve the effective transport/model before looking in the cache. */ export declare function prepareJevDecision(client: JevClient, request: Omit): Promise; /** Parse the top-level response; every requested question must have a valid answer. */ export declare function parseJevResponse(payload: unknown, questions: JevQuestions): JevResponse | undefined; export interface ClassifierRuntime { getAvailableOfType(type: "classifier", provider?: string, options?: AuthOperationOptions): Promise[]>; getModelOfType(type: "classifier", provider: string, id: string): ClassifierModel | undefined; classify(model: ClassifierModel, context: ClassifierContext, options?: ModelsClassifierOptions): Promise; } export interface NativeJevClientOptions { /** Absent means auto across authenticated classifier providers. */ endpoint?: JevEndpoint; model?: string; timeoutMs?: number; } export declare function createNativeJevClient(runtime: ClassifierRuntime, options?: NativeJevClientOptions): JevClient; export declare function createJevClient(options: JevClientOptions): JevClient; /** Pick an endpoint from an explicit choice, or infer from which API key env exists. */ export declare function resolveJevEndpoint(preferred: JevEndpoint | undefined, env?: Record): { endpoint: JevEndpoint; apiKey: string; } | undefined; export {};