/** * Jev-compatible typed judgment HTTP adapter (SP-305, #184). * * Implements the domain `TypedJudgmentPort` over Node's global `fetch` * (Node ≥ 22.19; no new npm dependencies) against `POST /v1/systemone`. * Local OpenJev is the default endpoint; hosted Jev (TypeSafe / Codiv) is * opt-in via `allow_remote` (enforced by the config schema) plus a key from * the env var named by `api_key_env` (enforced by the factory — fail closed). * * Wire notes (OpenJev README + `openjev/api.py`, `openjev/engine.py`): * - Request: `{model, state, questions: {id: {type, instructions, criteria}}}` * plus the OpenJev-only `samples` extension, sent for loopback endpoints * only (hosted Jev rejects unknown fields). * - Success: `{model, answers: {id: {type, …}}, usage}`. `noul` answers carry * P(yes) ∈ [0,1]; `score` answers are 0-indexed expected levels — this * adapter lifts them onto the question's anchor scores. * - Errors: 400 (`detail` string or `{error_type, message}`), 422 (FastAPI * validation list), 401/403 (`{detail: {error_type, message}}`), 429, 529. * Only 429/529 are retried (max 2, linear backoff, inside `timeout_ms`). * * Privacy: thrown errors and logs never include state or question prompt * text; every constructed message passes through `redactPromptFromError`. * The API key is read from the environment at construction, never from * config files, and is never logged. */ import { type TypedJudgmentAnswers, type TypedJudgmentPort, type TypedJudgmentQuestion } from '../../domain/ports/typed-judgment-port.js'; import type { TypedJudgmentConfig } from '../../domain/types/index.js'; type FetchLike = (url: string, init: RequestInit) => Promise; /** True when the endpoint is loopback (local OpenJev). */ export declare function isLoopbackEndpoint(endpoint: string): boolean; /** * `TypedJudgmentPort` over global fetch against a Jev-compatible endpoint. * * Construction is cheap and side-effect free apart from reading no env — * the API key (remote endpoints only) is handed in by * {@link createTypedJudgmentPort}, which is the fail-closed composition path. * Direct construction is intended for tests; the factory enforces remote-key * gating. */ export declare class JevTypedJudgmentAdapter implements TypedJudgmentPort { #private; constructor(config: TypedJudgmentConfig, apiKey?: string, fetchImpl?: FetchLike); judge(state: string, questions: readonly TypedJudgmentQuestion[], options: { signal: AbortSignal; }): Promise; } /** Why no typed judgment port was created. */ export type TypedJudgmentUnavailableReason = 'typed_judgment_disabled' | 'typed_judgment_remote_key_missing'; export type CreateTypedJudgmentPortResult = { port: TypedJudgmentPort; } | { port: null; reason: TypedJudgmentUnavailableReason; }; /** * Composition-root factory (SP-305, #184). Fails closed: * - `enabled: false` → `{ port: null, reason: 'typed_judgment_disabled' }` * - remote endpoint with an empty/missing `api_key_env` value → * `{ port: null, reason: 'typed_judgment_remote_key_missing' }` * * The key is read from `env[config.api_key_env]` here (at construction) and * only ever lives inside the adapter; it is never read from config files * and never logged. */ export declare function createTypedJudgmentPort(config: TypedJudgmentConfig, env?: Readonly>): CreateTypedJudgmentPortResult; export {}; //# sourceMappingURL=jev-typed-judgment-adapter.d.ts.map