import { Config } from '@opencode-ai/sdk'; import { ToolDefinition } from '@opencode-ai/plugin'; /** * Result returned to the caller after constructing an OAuth authorization URL. */ interface GeminiAuthorization { url: string; verifier: string; state: string; } interface GeminiTokenExchangeSuccess { type: "success"; refresh: string; access: string; expires: number; email?: string; } interface GeminiTokenExchangeFailure { type: "failed"; error: string; } type GeminiTokenExchangeResult = GeminiTokenExchangeSuccess | GeminiTokenExchangeFailure; /** * Build the Gemini OAuth authorization URL including PKCE. */ declare function authorizeGemini(): Promise; /** * Exchange an authorization code using a known PKCE verifier. */ declare function exchangeGeminiWithVerifier(code: string, verifier: string): Promise; interface OAuthAuthDetails { type: "oauth"; refresh: string; access?: string; expires?: number; } interface NonOAuthAuthDetails { type: string; [key: string]: unknown; } type AuthDetails = OAuthAuthDetails | NonOAuthAuthDetails; type GetAuth = () => Promise; interface ProviderModel { cost?: { input: number; output: number; cache?: { read: number; write: number; }; }; [key: string]: unknown; } interface Provider { models?: Record; options?: Record; } interface LoaderResult { apiKey: string; fetch(input: RequestInfo, init?: RequestInit): Promise; } interface AuthMethod { provider?: string; label: string; type: "oauth" | "api"; authorize?: () => Promise<{ url: string; instructions: string; method: string; callback: (() => Promise) | ((callbackUrl: string) => Promise); }>; } interface PluginClient { auth: { set(input: { path: { id: string; }; body: OAuthAuthDetails; }): Promise; }; config?: { get(options?: unknown): Promise<{ data?: Config; } | undefined>; }; tui?: { showToast(input: { body: { title?: string; message: string; variant: "info" | "success" | "warning" | "error"; duration?: number; }; }): Promise; }; } interface PluginContext { client: PluginClient; } interface PluginResult { config?: (config: Config) => Promise; tool?: Record; auth: { provider: string; loader: (getAuth: GetAuth, provider: Provider) => Promise; methods: AuthMethod[]; }; } /** * Registers the Gemini OAuth provider for Opencode, handling auth, request rewriting, * debug logging, and response normalization for Gemini Code Assist endpoints. */ declare const GeminiCLIOAuthPlugin: ({ client }: PluginContext) => Promise; declare const GoogleOAuthPlugin: ({ client }: PluginContext) => Promise; export { type GeminiAuthorization, GeminiCLIOAuthPlugin, type GeminiTokenExchangeResult, GoogleOAuthPlugin, authorizeGemini, exchangeGeminiWithVerifier };