/** * Minimal OpenAI chat completions client. * * No SDK dependency: this project ships three runtime dependencies and none of them opens a socket. * Adding a vendor SDK for one optional command would change that materially, and the surface used * here is a single POST with a JSON schema response format. * * This is one of the two places in the codebase that send message content off the machine, the * other being `typesafe-client.ts`. Both are only reachable from `email-content annotate`, never * from `extract()` or the corpus scanner. See * docs/threat-model.md, "Configured exception: LLM annotation". */ import { ApiError, type ApiConfig, type Usage } from './http'; export type { Usage } from './http'; export type OpenAIConfig = ApiConfig; export interface CompletionRequest { system: string; user: string; schemaName: string; schema: Record; } /** * The narrow surface the annotator depends on. * * Depending on this rather than on the concrete client is what lets the annotator's validation * logic be tested without a network call, which matters because that validation is the guard * against a model returning indices that do not exist. */ export interface CompletionClient { readonly model: string; complete(request: CompletionRequest): Promise; } export declare class OpenAIError extends ApiError { constructor(message: string, status: number, retryable: boolean); } /** Load configuration from the environment, after process.loadEnvFile(). */ export declare function configFromEnv(model: string, overrides?: Partial): OpenAIConfig; export declare class OpenAIClient implements CompletionClient { private readonly config; readonly usage: Usage; constructor(config: OpenAIConfig); get model(): string; /** * Request a structured completion and return the parsed object. * * Retries on rate limits and transient server errors with exponential backoff plus jitter. A * schema violation is not retried: strict mode means the model already failed to satisfy the * contract, and a retry would usually fail the same way. */ complete(request: CompletionRequest): Promise; } //# sourceMappingURL=client.d.ts.map