/**
 * GitHub Copilot model catalog (CAPI) — dynamic prompt-token budgets.
 *
 * GitHub's Copilot API (CAPI) exposes distinct model limits via `GET {baseUrl}/models`:
 *
 *   - `capabilities.limits.max_context_window_tokens` is the model's total context capacity
 *     (prompt + completion reserve).
 *   - `capabilities.limits.max_prompt_tokens` is the maximum prompt/input budget Atomic can safely
 *     fill before the provider must reserve output tokens.
 *   - `billing.token_prices.<tier>.context_max` is a prompt-token billing/selection threshold. The
 *     `default` tier is the short prompt budget (e.g. gpt-5.5 272k, Claude 200k); a
 *     `long_context` tier adds a selectable larger prompt budget (e.g. gpt-5.5 922k, Claude 936k).
 *
 * Atomic shows the model's full context window for the selectable long tier (the
 * `max_context_window_tokens` total, e.g. 1_000_000/1_050_000), matching how the native `openai/*`
 * and `anthropic/*` providers advertise these models. Because GitHub enforces a lower server-side
 * prompt cap (`max_prompt_tokens`, e.g. 936k/922k) below that total, the prompt cap is retained as
 * an internal effective input budget (`CopilotModelContext.maxInputTokens`) that drives compaction
 * thresholds and the overflow-recovery guard, so the branded total can be displayed without
 * overrunning the server limit. The default (short) tier stays at the `default` billing tier's
 * prompt budget.
 *
 * This data is intentionally NOT baked into a static map: GitHub adds/removes models and retiers
 * windows over time (e.g. a model that disappears from the catalog), so a hardcoded snapshot goes
 * stale. Instead the catalog is fetched live (gated on the user actually having the GitHub Copilot
 * provider) and cached on disk for a short TTL, exactly like the Copilot CLI.
 */
/** Resolved input-token context window(s) for a single Copilot model. */
export interface CopilotModelContext {
    /**
     * Base/displayed context window — shown in the footer. The default tier's `context_max`, or the
     * model-level `max_prompt_tokens` fallback otherwise.
     */
    contextWindow: number;
    /**
     * Selectable windows (`[default, long]`) when the model exposes a `long_context` tier larger than
     * its default; absent for single-window models. The long entry is the model's full
     * `max_context_window_tokens` (total capacity) when advertised, matching `openai/*` and
     * `anthropic/*`.
     */
    contextWindowOptions?: readonly number[];
    /**
     * Hard prompt/input cap (`max_prompt_tokens`) when it sits below the displayed long window. Used
     * as the effective input budget for compaction thresholds and overflow recovery so the branded
     * total can be shown without overrunning GitHub's server-side prompt limit. Absent when the
     * displayed window already equals the input cap.
     */
    maxInputTokens?: number;
}
/** Map of model id → resolved input-token context window(s). */
export type CopilotModelCatalog = ReadonlyMap<string, CopilotModelContext>;
/** Safety fallback when a model reports neither `max_prompt_tokens` nor `max_context_window_tokens`. */
export declare const COPILOT_CONTEXT_WINDOW_FALLBACK = 128000;
export declare const COPILOT_CATALOG_API_VERSION = "2026-06-01";
/**
 * Headers GitHub's CAPI expects for catalog reads. Mirrors the editor headers pi-ai already sends
 * for Copilot token refresh and model-policy calls, plus the dated API version.
 */
export declare const COPILOT_CATALOG_HEADERS: Readonly<Record<string, string>>;
/** Default (non-enterprise) Copilot CAPI base URL when the token has no resolvable `proxy-ep`. */
export declare const DEFAULT_COPILOT_API_BASE_URL = "https://api.individual.githubcopilot.com";
/** Disk-cache freshness window, matching the Copilot CLI's list-models cache TTL. */
export declare const COPILOT_CATALOG_CACHE_TTL_MS: number;
/** Current on-disk cache schema version. */
export declare const COPILOT_CATALOG_CACHE_VERSION: 3;
/**
 * Resolve the Copilot CAPI base URL.
 *
 * Copilot access tokens embed a `proxy-ep=proxy.<host>` segment; the API host is the same host with
 * `proxy.` swapped for `api.`. Falls back to the enterprise host or the individual default. (pi-ai
 * exposes an equivalent helper, but its published `dist` mangles the export name, so the small,
 * stable parsing logic is reimplemented here.)
 */
export declare function copilotApiBaseUrlFromToken(token: string | undefined, enterpriseDomain?: string): string;
/** Raw token limits parsed from a CAPI model entry. */
export interface CopilotModelLimits {
    /** `capabilities.limits.max_prompt_tokens` — maximum prompt/input budget (the hard input cap). */
    maxPromptTokens?: number;
    /** `capabilities.limits.max_context_window_tokens` — total context capacity (the displayed long tier). */
    maxContextWindowTokens?: number;
    /** `capabilities.limits.max_output_tokens` — output reserve; derives the input cap when `max_prompt_tokens` is absent. */
    maxOutputTokens?: number;
    /** `billing.token_prices.default.context_max` — default-tier prompt threshold. */
    defaultContextMax?: number;
    /** `billing.token_prices.long_context.context_max` — long-context prompt threshold. */
    longContextMax?: number;
}
/**
 * Resolve a model's input-token context window(s) from its CAPI limits.
 *
 * `contextWindow` is the model's base input budget — the default tier's `context_max` when tiered,
 * otherwise `max_prompt_tokens ?? max_context_window_tokens ?? 128_000`. A `long_context` tier that
 * is larger than the base adds a second selectable window. Returns `undefined` when the entry
 * carries no usable limit signal at all.
 */
export declare function resolveCopilotModelContext(limits: CopilotModelLimits): CopilotModelContext | undefined;
/**
 * Parse a raw CAPI `/models` response body into an input-token context-window catalog.
 */
export declare function parseCopilotModelCatalog(body: unknown): CopilotModelCatalog;
export interface FetchCopilotModelCatalogOptions {
    /** Valid Copilot CAPI bearer token (e.g. from `modelRegistry.getApiKeyForProvider`). */
    token: string;
    /** Override the resolved base URL; defaults to one derived from the token. */
    baseUrl?: string;
    /** Enterprise domain, used for base-URL resolution when the token lacks a `proxy-ep`. */
    enterpriseDomain?: string;
    /** Extra/override request headers. */
    headers?: Record<string, string>;
    /** Injectable `fetch` for testing. */
    fetchImpl?: typeof fetch;
    /** Abort signal. */
    signal?: AbortSignal;
}
/** Fetch and parse the live Copilot model catalog from CAPI `GET {baseUrl}/models`. */
export declare function fetchCopilotModelCatalog(options: FetchCopilotModelCatalogOptions): Promise<CopilotModelCatalog>;
/** Replace the active catalog the registry derives context windows from. */
export declare function setActiveCopilotModelCatalog(catalog: CopilotModelCatalog): void;
/** The active catalog (empty until a successful auth-gated fetch/cache load). */
export declare function getActiveCopilotModelCatalog(): CopilotModelCatalog;
/** Reset the active catalog (primarily for tests). */
export declare function clearActiveCopilotModelCatalog(): void;
export interface ReadCopilotCatalogCacheOptions {
    /** Expected CAPI host; a cached file from a different host is ignored. */
    host: string;
    /** Current epoch ms (injectable for tests). */
    now?: number;
    /** Freshness window; defaults to {@link COPILOT_CATALOG_CACHE_TTL_MS}. */
    ttlMs?: number;
}
/** Read a fresh, host-matching catalog from the cache file, or `undefined` if missing/stale/invalid. */
export declare function readCopilotCatalogCache(path: string, options: ReadCopilotCatalogCacheOptions): CopilotModelCatalog | undefined;
/** Write the catalog to the cache file (creating parent dirs). Best-effort; never throws. */
export declare function writeCopilotCatalogCache(path: string, baseUrl: string, catalog: CopilotModelCatalog, now?: number): void;
/** Host component of a base URL, for matching {@link readCopilotCatalogCache} `host`. */
export declare function copilotCatalogCacheHost(baseUrl: string): string;
/** Standard on-disk cache path for the Copilot model catalog under an agent directory. */
export declare function copilotCatalogCachePath(agentDir: string): string;
/**
 * Seed the active catalog synchronously from the on-disk cache, gated on a Copilot access token.
 *
 * Called at model-registry construction so a returning user's previously selected long-context
 * window is recognized before startup validation runs — otherwise the persisted choice would warn
 * ("context window 936k is not supported…") and reset until the async refresh completes. The cache
 * TTL is intentionally ignored here: stale-but-present windows are still valid for selection, and
 * the async loader independently refetches on its own freshness window. Returns true when a catalog
 * was applied. No-op (returns false) without a token or a host-matching cached catalog.
 */
export declare function seedActiveCopilotModelCatalogFromCache(accessToken: string | undefined, cachePath: string, now?: number): boolean;
//# sourceMappingURL=copilot-model-catalog.d.ts.map