/** * providers/openai-compat-diagnostics.ts * * The diagnostic surface of the generic OpenAI-compatible provider: what a * chat request LOOKED like, and what a failed one actually SAID. * * Split out of openai-compat.ts, which had grown past the 800-line cap. These * helpers are pure and provider-agnostic, they read a request or an error and * return a description, so they carry no client, no retry state and no * streaming state, and the provider file is left holding only the client * lifecycle and the chat/stream loop. * * Two jobs live here: * * - `buildChatRequestFingerprint` summarizes a request by SHAPE (message and * token counts, image parts, tool count, reasoning settings) and never by * content, so a turn can be logged without putting the conversation in the * log. * - `extractOpenAICompatErrorDiagnostic` / `buildOpenAICompatErrorMessage` * turn a vendor error into one honest line. OpenAI-compatible backends * disagree about where the reason lives, a top-level `code`/`type`, a * nested `error` object, a bare string body, a request id on a header under * either spelling, so the reason is pulled from wherever that backend put * it rather than reported as a bare status code. */ import type { ChatRequest } from './interface.js'; export interface ChatRequestFingerprint { readonly model: string; readonly messageCount: number; readonly userMessages: number; readonly assistantMessages: number; readonly toolMessages: number; readonly contentChars: number; readonly imageParts: number; readonly toolCount: number; readonly systemPromptChars: number; readonly reasoningEffort: ChatRequest['reasoningEffort'] | null; readonly reasoningSummary: boolean; readonly maxTokens: number | null; } export interface OpenAICompatErrorDiagnostic { readonly status?: number | undefined; readonly code?: string | undefined; readonly type?: string | undefined; readonly requestId?: string | undefined; readonly detail?: string | undefined; readonly rawMessage: string; } export declare function buildChatRequestFingerprint(request: ChatRequest, model: string): ChatRequestFingerprint; export declare function extractOpenAICompatErrorDiagnostic(err: unknown): OpenAICompatErrorDiagnostic; export declare function buildOpenAICompatErrorMessage(providerName: string, phase: 'request' | 'stream', diagnostic: OpenAICompatErrorDiagnostic): string; //# sourceMappingURL=openai-compat-diagnostics.d.ts.map