import type { ChatCompletionMessageParam } from "openai/resources/chat/completions"; import { type AssistantMessage, type Context, type Model, type ServiceTier, type StreamFunction, type StreamOptions, type ToolChoice } from "../types"; import { type ResolvedOpenAICompat } from "./openai-completions-compat"; /** Test seam: the provider base URL as resolved from trusted env. */ export declare function resolveOpenAICompletionsBaseUrlForTest(baseUrl: string | undefined, authCredentialType: "api_key" | "oauth" | undefined): string; /** * Identify "real progress" stream chunks vs. keepalives, role-only preambles, * and empty `{choices:[]}` no-ops emitted by some OpenAI-compatible endpoints. * Without this filter, every keepalive resets `iterateWithIdleTimeout`'s * deadline, so a provider that streams nothing but pings keeps the watchdog * asleep indefinitely — observed against z.ai/GLM via OpenRouter where a * subagent stalled for hours with no error surfaced. * * A chunk counts as progress when it carries terminal usage, a finish reason, * or any model-produced delta (content / tool calls / reasoning / refusal). * Role-only `delta: { role: "assistant" }` preambles do NOT count; we want the * (longer) first-event timeout to keep governing until real output appears. */ export declare function isOpenAICompletionsProgressChunk(chunk: unknown): boolean; export interface OpenAICompletionsOptions extends StreamOptions { toolChoice?: ToolChoice; reasoning?: "minimal" | "low" | "medium" | "high" | "xhigh" | "max"; /** Force-disable reasoning where supported, or request the lowest effort on generic effort endpoints. */ disableReasoning?: boolean; serviceTier?: ServiceTier; } export declare const streamOpenAICompletions: StreamFunction<"openai-completions">; export declare function parseChunkUsage(rawUsage: object, model: Model<"openai-completions">, premiumRequests: number | undefined): AssistantMessage["usage"]; export declare function convertMessages(model: Model<"openai-completions">, context: Context, compat: ResolvedOpenAICompat): ChatCompletionMessageParam[]; /** * Detect compatibility settings from provider and baseUrl for known providers. * Provider takes precedence over URL-based detection since it's explicitly configured. * Returns a fully resolved OpenAICompat object with all fields set. */ export declare function detectCompat(model: Model<"openai-completions">): ResolvedOpenAICompat;