import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle"; import { IContextKeyService } from "@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service"; import { ILogService } from "@codingame/monaco-vscode-api/vscode/vs/platform/log/common/log.service"; import { IStorageService } from "@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service"; import { ITelemetryService } from "@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service"; import { IWorkbenchContribution } from "@codingame/monaco-vscode-api/vscode/vs/workbench/common/contributions"; import { IWorkbenchAssignmentService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/assignment/common/assignmentService.service"; import { IChatEntitlementService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/chat/common/chatEntitlementService.service"; import { ILanguageModelsService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/common/languageModels.service"; import { IChatInputNotificationService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/contrib/chat/browser/widget/input/chatInputNotificationService.service"; /** * Core-side workbench contribution that shows chat input notifications for * quota exhaustion and quota-approaching thresholds. * * Listens to `IChatEntitlementService` quota change events and determines * whether a new threshold has been crossed, then shows the highest-priority * notification: * * 1. **Quota exhausted** — info, auto-dismissed on next message. * 2. **Quota approaching** — info, auto-dismissed on next message. * 3. **Rate-limit warning** — info, auto-dismissed on next message. */ export declare class ChatQuotaNotificationContribution extends Disposable implements IWorkbenchContribution { private readonly _chatEntitlementService; private readonly _chatInputNotificationService; private readonly _contextKeyService; private readonly _languageModelsService; private readonly _storageService; private readonly _assignmentService; private readonly _telemetryService; private readonly _logService; static readonly ID = "workbench.contrib.chatQuotaNotification"; /** Tracks whether the current notification is the quota-exhausted variant. */ private _showingExhausted; /** * Previous percent-used for threshold crossing detection. * `undefined` means no data has been seen yet — the first value * establishes a baseline without triggering a notification. */ private _prevQuotaPercentUsed; private _prevAdditionalUsageEnabled; private _prevSessionPercentUsed; private _prevWeeklyPercentUsed; private _trajectoryTreatment; private _trajectoryAssignmentRequested; constructor(_chatEntitlementService: IChatEntitlementService, _chatInputNotificationService: IChatInputNotificationService, _contextKeyService: IContextKeyService, _languageModelsService: ILanguageModelsService, _storageService: IStorageService, _assignmentService: IWorkbenchAssignmentService, _telemetryService: ITelemetryService, _logService: ILogService); /** * Reads the already-evaluated trajectory experiment cohort. The assignment * service resolves the cohort asynchronously, so this is requested only once * the user has met every non-experiment condition required for the nudge. * * Stores the raw treatment value. `undefined` means the user is not * assigned to the flight (or assignments are not available); only a `true` * treatment renders the nudge. We deliberately do not coerce a missing * assignment into a synthetic "control" value, since that would assume an * enrollment that may not exist. Enrollment telemetry is emitted only when * the user is actually assigned to a flight. */ private _resolveTrajectoryTreatment; private _requestTrajectoryTreatment; private _getRelevantSnapshot; private _isQuotaUsedUp; private _isUBBEligible; private _update; private _computeQuotaWarning; private _computeQuotaTrajectoryWarning; private _showQuotaTrajectoryWarning; private _handleCreditEfficiencyLearnMoreCommand; private _logQuotaTrajectoryNudgeEnrolled; /** * Returns the highest threshold that was newly crossed, or `undefined`. */ private _findCrossedThreshold; private _showExhaustedNotification; private _showOverageActivationNotification; private _showQuotaApproachingWarning; private _computeRateLimitWarning; private _checkRateLimitCrossing; private _showRateLimitWarning; /** * Returns `true` only when a Copilot model is actively selected. * Returns `false` if no model is selected yet (widget not initialized) * or if the selected model is from a non-Copilot vendor (BYOK). */ private _isCopilotModelSelected; private _isManagedPlan; private _isManagedPlanBlocked; private _showManagedPlanBlockedNotification; private _formatResetDate; private _getTrajectoryPeriodKey; private _isTrajectoryShownInCurrentPeriod; private _storeTrajectoryShown; private _setNotification; private _hideNotification; /** * Returns `true` only when there is an actual quota snapshot indicating that * credit is available (i.e. quota is not used up). Returns `false` when no * snapshot has loaded yet, so the transient "no data" state at startup/reload * is not mistaken for recovery. */ private _isQuotaKnownAvailable; private _isExhaustedDismissed; private _setExhaustedDismissed; private _clearExhaustedDismissed; }