/** * GitHub Copilot OAuth Provider * * Uses OAuth tokens from AuthStorage to authenticate with GitHub Copilot's chat API. * The Copilot API speaks an OpenAI-compatible chat format, so we plug * `@ai-sdk/openai-compatible` into Copilot's API URL and use a custom fetch to inject * the bearer token and Copilot-specific headers. * * Inspired by: * - opencode: https://github.com/anomalyco/opencode/blob/dev/packages/opencode/src/plugin/github-copilot/copilot.ts * - pi-mono: https://github.com/badlogic/pi-mono/blob/main/packages/ai/src/utils/oauth/github-copilot.ts */ import type { MastraModelConfig } from '@mastra/core/llm'; import type { CopilotModelEntry } from '../auth/providers/github-copilot.js'; 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 tests / TUI integration). */ export declare function setAuthStorage(storage: AuthStorage | undefined): void; /** * Build a fetch wrapper that authenticates with GitHub Copilot OAuth. * * - Injects the short-lived Copilot bearer token (auto-refreshed by AuthStorage). * - Adds the VS Code-like Copilot headers required by the API. * - Rewrites the request URL onto the per-token API base when `rewriteUrl` is true. */ export declare function buildGitHubCopilotOAuthFetch(opts?: { authStorage?: AuthStorage; rewriteUrl?: boolean; }): typeof fetch; /** * Creates a model that talks to GitHub Copilot using OAuth credentials. * * Copilot's `/chat/completions` endpoint is OpenAI-compatible, but GitHub Copilot * is not OpenAI. Use the generic OpenAI-compatible adapter with Copilot's base URL * instead of the OpenAI provider plus URL rewriting. */ export declare function githubCopilotProvider(modelId?: string, options?: { headers?: Record; }): MastraModelConfig; /** Reset the in-process Copilot catalog cache (test seam, also useful after logout). */ export declare function clearCopilotCatalogCache(): void; /** * Return the user's currently-available Copilot models. * * - Returns `[]` when the user is not logged in to GitHub Copilot. * - Returns the cached list when a recent fetch succeeded. * - On the cache-miss / expired path, fetches `/models` with a 5s timeout, filters * to picker-enabled and non-policy-disabled models, then caches for 10 minutes. * - On fetch failure, returns a small hard-coded fallback (so packs still work * offline) and caches that for 1 minute to avoid hammering the API. * * Concurrent calls during a fetch share the inflight promise. */ export declare function getCopilotModelCatalog(opts?: { authStorage?: AuthStorage; }): Promise; //# sourceMappingURL=github-copilot.d.ts.map