/** * OpenAI Codex OAuth Provider * * Uses OAuth tokens from AuthStorage to authenticate with ChatGPT Plus/Pro subscription. * This allows access to OpenAI models through the ChatGPT OAuth flow. * * Inspired by opencode's Codex plugin implementation: * https://github.com/sst/opencode/blob/main/packages/opencode/src/plugin/codex.ts */ import type { MastraModelConfig } from '@mastra/core/llm'; import type { LanguageModelMiddleware } from 'ai'; import { AuthStorage } from '../auth/storage.js'; /** * Get or create the shared AuthStorage instance */ export declare function getAuthStorage(): AuthStorage; /** * Set a custom AuthStorage instance (useful for TUI integration) */ export declare function setAuthStorage(storage: AuthStorage | undefined): void; /** Valid thinking level values. */ export type ThinkingLevel = 'off' | 'low' | 'medium' | 'high' | 'xhigh'; export declare function getEffectiveThinkingLevel(modelId: string, level: ThinkingLevel): ThinkingLevel; export declare const THINKING_LEVEL_TO_REASONING_EFFORT: Record; /** * Create Codex middleware with the given reasoning effort level. */ export declare function createCodexMiddleware(reasoningEffort?: string): LanguageModelMiddleware; /** * Build a fetch function that handles OpenAI Codex OAuth. * Preserves non-authorization headers from init. * When rewriteUrl is true (default), rewrites /v1/responses and /chat/completions * to the Codex API endpoint. Set rewriteUrl: false for gateway usage where the * SDK already targets the correct URL. */ export declare function buildOpenAICodexOAuthFetch(opts?: { authStorage?: AuthStorage; rewriteUrl?: boolean; }): typeof fetch; /** * Creates an OpenAI model using ChatGPT OAuth authentication * Uses OAuth tokens from AuthStorage (auto-refreshes when needed) * * IMPORTANT: This uses the Codex API endpoint, not the standard OpenAI API. * URLs are rewritten from /v1/responses or /chat/completions to the Codex endpoint. */ export declare function openaiCodexProvider(modelId?: string, options?: { thinkingLevel?: ThinkingLevel; headers?: Record; }): MastraModelConfig; //# sourceMappingURL=openai-codex.d.ts.map