import type { AnyModel, Api, ApiKeyAuth, AssistantMessageEventStream, ClassifierApi, ClassifierModel, ImageApi, Model, OAuthAuth, OAuthCredentials, OAuthLoginCallbacks, Provider, ProviderClassifier, ProviderImages, RefreshModelsContext, SimpleStreamOptions, TranscriptContext } from "@bastani/pi-ai"; import type { ModelsJsonModelOverride, ModelsJsonProvider } from "./model-config.ts"; import { clearConfigValueCache } from "./resolve-config-value.ts"; export interface ExtensionOAuthConfig { name: string; loginLabel?: string; usesCallbackServer?: boolean; login(callbacks: OAuthLoginCallbacks, signal: AbortSignal): Promise; /** * Refresh expired credentials. Pass `signal` to the network call, but add no timeout or abort of your own: Atomic * never aborts it on a timeout, because once the request is sent the provider may already have rotated the * refresh token. The caller stops waiting after 60 seconds; a later result is still saved, and a graceful exit * waits briefly for it. It is a required parameter so the contract is stated in the type. * Throw `OAuthRefreshRejectedError` when the provider rejected the stored login; common error shapes are mapped * onto it (see `extensionRefreshRejection`). */ refreshToken(credentials: OAuthCredentials, signal: AbortSignal): Promise; getApiKey(credentials: OAuthCredentials): string; modifyModels?(models: Model[], credentials: OAuthCredentials): Model[]; } interface ProviderModelConfigBase { id: string; name: string; api?: string; baseUrl?: string; input: AnyModel["input"]; inputLimits?: AnyModel["inputLimits"]; cost: AnyModel["cost"]; headers?: Record; } export interface ProviderChatModelConfig extends ProviderModelConfigBase { type?: "chat"; api?: Api; reasoning: boolean; thinkingLevelMap?: Model["thinkingLevelMap"]; promptCache?: Model["promptCache"]; contextWindow: number; maxTokens: number; samplingParams?: Model["samplingParams"]; samplingParamsByThinkingLevel?: Model["samplingParamsByThinkingLevel"]; compat?: Model["compat"]; } export interface ProviderImageModelConfig extends ProviderModelConfigBase { type: "image"; api?: ImageApi; output: ("text" | "image")[]; } export interface ProviderClassifierModelConfig extends ProviderModelConfigBase { type: "classifier"; api?: ClassifierApi; contextWindow: number; compat?: ClassifierModel["compat"]; } export type ProviderModelConfig = ProviderChatModelConfig | ProviderImageModelConfig | ProviderClassifierModelConfig; /** Input type for the extension registerProvider API. */ export interface ProviderConfigInput { name?: string; aliasOf?: string; baseUrl?: string; apiKey?: string; api?: Api; streamSimple?: (model: Model, context: TranscriptContext, options?: SimpleStreamOptions) => AssistantMessageEventStream; images?: Partial>; classifiers?: Partial>; headers?: Record; authHeader?: boolean; oauth?: ExtensionOAuthConfig; models?: ProviderModelConfig[]; refreshModels?(context: RefreshModelsContext): Promise>; } export type AuthStatus = { configured: boolean; source?: "stored" | "runtime" | "environment" | "fallback" | "models_json_key" | "models_json_command"; label?: string; }; export declare const clearApiKeyCache: typeof clearConfigValueCache; export declare function applyModelOverride(model: Model, override: ModelsJsonModelOverride): Model; export declare function applyModelsJson(providerId: string, baseModels: readonly AnyModel[], config: ModelsJsonProvider | undefined): AnyModel[]; export declare function applyExtension(providerId: string, models: readonly AnyModel[], config: ProviderConfigInput | undefined): AnyModel[]; export declare function configuredApiKey(config: ModelsJsonProvider | undefined, extension: ProviderConfigInput | undefined): string | undefined; export declare function configuredHeaders(config: ModelsJsonProvider | undefined, extension: ProviderConfigInput | undefined): Record | undefined; export declare function composeApiKeyAuth(providerId: string, base: Provider | undefined, config: ModelsJsonProvider | undefined, extension: ProviderConfigInput | undefined): ApiKeyAuth | undefined; export declare function composeOAuthAuth(providerId: string, base: Provider | undefined, config: ModelsJsonProvider | undefined, extension: ProviderConfigInput | undefined): OAuthAuth | undefined; export declare function rawModelHeaders(model: AnyModel, config: ModelsJsonProvider | undefined, extension: ProviderConfigInput | undefined): Record | undefined; export {}; //# sourceMappingURL=provider-composer-internal.d.ts.map