import { Event } from '../../../util/vs/base/common/event'; import { IHeaders } from '../../networking/common/fetcherService'; /** * This is the quota info we get from the `copilot_internal/user` endpoint. * It is accessed via the copilot token object */ export interface CopilotUserQuotaInfo { quota_reset_date?: string; quota_snapshots?: { chat: { quota_id: string; entitlement: number; remaining: number; unlimited: boolean; overage_count: number; overage_permitted: boolean; percent_remaining: number; has_quota?: boolean; }; completions: { quota_id: string; entitlement: number; remaining: number; unlimited: boolean; overage_count: number; overage_permitted: boolean; percent_remaining: number; has_quota?: boolean; }; premium_interactions: { quota_id: string; entitlement: number; remaining: number; unlimited: boolean; overage_count: number; overage_permitted: boolean; percent_remaining: number; has_quota?: boolean; }; }; } export interface IChatQuota { quota: number; percentRemaining: number; unlimited: boolean; hasQuota: boolean; additionalUsageUsed: number; additionalUsageEnabled: boolean; resetDate: Date; } export interface QuotaSnapshot { /** String representation of the entitlement count, "-1" for unlimited. */ readonly entitlement: string; /** Percentage of quota remaining (0–100), rounded up to 1 decimal. */ readonly percent_remaining: number; /** Whether additional usage (usage beyond included credits) is permitted. */ readonly overage_permitted: boolean; /** Number of additional usage units consumed, rounded up to 1 decimal. */ readonly overage_count: number; /** Whether the user has active quota for this category. */ readonly has_quota?: boolean; /** ISO 8601 date when the quota resets, if applicable. */ readonly reset_date?: string; } export type QuotaSnapshots = Record; export interface IChatQuotaService { readonly _serviceBrand: undefined; readonly onDidChange: Event; readonly quotaInfo: IChatQuota | undefined; readonly rateLimitInfo: { readonly session: IChatQuota | undefined; readonly weekly: IChatQuota | undefined; }; quotaExhausted: boolean; additionalUsageEnabled: boolean; /** AIC credits accumulated for the given turn, from copilot_usage.total_nano_aiu. */ getCreditsForTurn(turnId: string): number | undefined; processQuotaHeaders(headers: IHeaders): void; processQuotaSnapshots(snapshots: QuotaSnapshots): void; /** Accumulate per-request cost from copilot_usage.total_nano_aiu (in nano-AIUs), scoped to a turn. */ setLastCopilotUsage(totalNanoAiu: number, turnId: string): void; /** Reset accumulated credits for the given turn. */ resetTurnCredits(turnId: string): void; clearQuota(): void; /** * Fetches up-to-date quota data from the `copilot_internal/user` endpoint. * Errors are caught and logged. */ refreshQuota(): Promise; } export declare const IChatQuotaService: import("../../../util/common/services").ServiceIdentifier; //# sourceMappingURL=chatQuotaService.d.ts.map