sidekick-shared 0.28.1 → 0.28.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +29 -13
  3. package/dist/browser.d.ts +2 -0
  4. package/dist/browser.js +10 -1
  5. package/dist/codexQuota.js +17 -4
  6. package/dist/esm/browser.js +2 -0
  7. package/dist/esm/codexQuota.js +18 -5
  8. package/dist/esm/index.js +3 -3
  9. package/dist/esm/modelContext.js +32 -0
  10. package/dist/esm/modelInfo.js +186 -0
  11. package/dist/esm/multiProviderQuotaService.js +1 -1
  12. package/dist/esm/quota.js +356 -24
  13. package/dist/esm/quotaHistory.js +33 -8
  14. package/dist/esm/quotaPoller.js +5 -2
  15. package/dist/esm/quotaResolver.js +31 -6
  16. package/dist/esm/quotaSnapshots.js +65 -10
  17. package/dist/esm/quotaThresholds.js +7 -2
  18. package/dist/esm/schemas/index.js +2 -2
  19. package/dist/esm/schemas/quota.js +30 -0
  20. package/dist/esm/schemas/quotaHistory.js +10 -2
  21. package/dist/esm/schemas/stateFile.js +9 -0
  22. package/dist/esm/stateFile.js +18 -3
  23. package/dist/esm/statusline/claudeStatuslinePayload.js +16 -4
  24. package/dist/esm/statusline/formatter.js +57 -18
  25. package/dist/esm/statusline/index.js +2 -2
  26. package/dist/esm/zaiQuotaApi.js +4 -2
  27. package/dist/index.d.ts +6 -6
  28. package/dist/index.js +18 -5
  29. package/dist/modelContext.js +32 -0
  30. package/dist/modelInfo.js +186 -0
  31. package/dist/multiProviderQuotaService.js +1 -1
  32. package/dist/quota.d.ts +131 -1
  33. package/dist/quota.js +366 -24
  34. package/dist/quotaHistory.d.ts +10 -0
  35. package/dist/quotaHistory.js +34 -8
  36. package/dist/quotaPoller.d.ts +11 -3
  37. package/dist/quotaPoller.js +5 -2
  38. package/dist/quotaResolver.js +30 -5
  39. package/dist/quotaSnapshots.js +64 -9
  40. package/dist/quotaThresholds.js +7 -2
  41. package/dist/schemas/index.d.ts +3 -3
  42. package/dist/schemas/index.js +5 -2
  43. package/dist/schemas/quota.d.ts +258 -0
  44. package/dist/schemas/quota.js +31 -1
  45. package/dist/schemas/quotaHistory.d.ts +2 -0
  46. package/dist/schemas/quotaHistory.js +10 -2
  47. package/dist/schemas/stateFile.d.ts +34 -0
  48. package/dist/schemas/stateFile.js +10 -1
  49. package/dist/stateFile.d.ts +18 -0
  50. package/dist/stateFile.js +17 -2
  51. package/dist/statusline/claudeStatuslinePayload.d.ts +4 -3
  52. package/dist/statusline/claudeStatuslinePayload.js +16 -4
  53. package/dist/statusline/formatter.d.ts +5 -0
  54. package/dist/statusline/formatter.js +56 -17
  55. package/dist/statusline/index.d.ts +4 -4
  56. package/dist/statusline/index.js +5 -1
  57. package/dist/zaiQuotaApi.js +3 -1
  58. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -10,11 +10,11 @@ exports.extractProposedPlanShared = exports.parsePlanMarkdownShared = exports.Pl
10
10
  exports.calculateCodeImpact = exports.scoreSessionQuality = exports.calculateQualityTrend = exports.PatternExtractor = exports.HeatmapTracker = exports.FrequencyTracker = exports.readErrorHistory = exports.getTopFailingTools = exports.appendErrorHistory = exports.MAX_ERROR_HISTORY_SESSIONS = exports.ERROR_HISTORY_SCHEMA_VERSION = exports.getSnapshotPath = exports.MAX_SNAPSHOT_FILES = exports.pruneSnapshots = exports.isSnapshotValid = exports.deleteSnapshot = exports.loadSnapshot = exports.saveSnapshot = exports.SessionMonitor = exports.parseTodoDependencies = exports.EventAggregator = exports.getRandomPhrase = exports.PHRASE_CATEGORIES = exports.ALL_PHRASES = exports.HIGHLIGHT_CSS = exports.clearHighlightCache = exports.highlightEvent = exports.formatSessionJson = exports.formatSessionMarkdown = exports.formatSessionText = exports.classifyNoise = exports.shouldMergeWithPrevious = exports.classifyFollowEvent = exports.classifyMessage = exports.getSoftNoiseReason = exports.isHardNoiseFollowEvent = exports.isHardNoise = exports.formatToolSummary = exports.parseLocalDateKey = exports.formatTokenCount = exports.formatLocalDateKey = exports.formatDurationMs = exports.addLocalDays = exports.DEFAULT_JSONL_TAIL_READ_BYTES = exports.DEFAULT_JSONL_TAIL_MAX_LINE_BYTES = exports.createJsonlTail = exports.toFollowEvents = exports.resolveSessionPath = exports.createWatcher = exports.parseChangelog = void 0;
11
11
  exports.removeAccount = exports.reconcileClaudeAuthState = exports.applyActiveClaudeToLiveHome = exports.resolveActiveClaudeHome = exports.cleanupAbandonedClaudeLogins = exports.syncClaudeLiveState = exports.switchToAccountAsync = exports.switchToAccount = exports.addCurrentAccount = exports.readActiveClaudeAccount = exports.writeAccountRegistry = exports.readAccountRegistry = exports.ensureDefaultAccounts = exports.codexIdentitiesMatch = exports.readCodexAccessTokenExpiry = exports.readCodexLastRefresh = exports.readCodexAuthIdentity = exports.parseCodexAuthJson = exports.CLAUDE_REFRESH_TOKEN_LIFETIME_ESTIMATE_MS = exports.CLAUDE_ACCESS_TOKEN_LIFETIME_MS = exports.mergeClaudeLoginIntoLive = exports.claudeLoginOnly = exports.claudeRefreshFingerprint = exports.resolveClaudeRefreshExpiry = exports.isNewerClaudeCredential = exports.claudeCredentialFreshness = exports.parseClaudeCredentialBlob = exports.readClaudeMaxAccessTokenSync = exports.readClaudeMaxCredentialsRaw = exports.readClaudeMaxCredentials = exports.parseKeychainDump = exports.repairClaudeCredentialStores = exports.inspectClaudeCredentialStores = exports.getClaudeCredentialLedgerPath = exports.readClaudeCredentialLedger = exports.decideLiveClaudeWrite = exports.SIDEKICK_KEYCHAIN_COMMENT_PREFIX = exports.ClaudeCredentialWriteError = exports.deleteStoredCredentials = exports.writeActiveCredentials = exports.readClaudeCredentialStore = exports.readActiveCredentials = exports.openInBrowser = exports.parseTranscriptFromEvents = exports.parseTranscript = exports.generateHtmlReport = exports.formatCompactionLedger = exports.calculateCompactionLedger = exports.describeCostProvenance = exports.classifyCostProvenance = void 0;
12
12
  exports.getClaudeConfigPath = exports.getClaudeProfileHome = exports.getClaudeProfilesDir = exports.onAccountsChanged = exports.getActiveAccountStatus = exports.ACCOUNT_PROVIDER_IDS = exports.removeSavedAccountProfile = exports.replaceSavedAccountProfiles = exports.setActiveSavedAccount = exports.upsertSavedAccountProfile = exports.getActiveSavedAccount = exports.listSavedAccountProfiles = exports.writeSavedAccountRegistry = exports.readSavedAccountRegistry = exports.getAccountsDir = exports.ACCOUNT_CONSUMER_REACHABILITY = exports.describeAccountConsumer = exports.detectRunningAccountConsumersSync = exports.detectRunningAccountConsumers = exports.findRunningProcessesSync = exports.findRunningProcesses = exports.keepAliveCommand = exports.refreshInactiveAccounts = exports.getAccountLaunchEnv = exports.getHealthSidecarPath = exports.readHealthSidecar = exports.listAccountsWithHealth = exports.getAccountHealth = exports.cleanupAbandonedLogins = exports.syncLiveAccountStateSync = exports.syncLiveAccountState = exports.getLastSwitchPath = exports.readLastSwitch = exports.discardAccountLogin = exports.resolveClaudeLoginCommand = exports.listAllAccounts = exports.getLastSwitch = exports.undoLastSwitch = exports.switchAccountAsync = exports.switchAccount = exports.spawnAccountLogin = exports.finalizeAccountLoginAsync = exports.finalizeAccountLogin = exports.getAccountLoginStatusAsync = exports.getAccountLoginStatus = exports.beginAccountLogin = exports.isMultiAccountEnabled = exports.resolveActiveClaudeAccount = exports.getActiveAccount = exports.listAccounts = void 0;
13
- exports.classifyQuotaFreshness = exports.resolveQuota = exports.writeQuotaSnapshot = exports.readQuotaSnapshot = exports.QuotaPoller = exports.describeQuotaFailure = exports.withQuotaProjections = exports.projectQuotaWindow = exports.fetchQuota = exports.SEVEN_DAY_WINDOW_MS = exports.QUOTA_PROVIDER_IDS = exports.FIVE_HOUR_WINDOW_MS = exports.AutoSwitchController = exports.decideAutoSwitch = exports.DEFAULT_AUTO_SWITCH_CONFIG = exports.removeLauncher = exports.writeLauncher = exports.writeAccountLauncher = exports.CODEX_KEYRING_FIX_HINT = exports.getCodexCredentialStoreMode = exports.cleanupAbandonedCodexLogins = exports.syncCodexLiveState = exports.removeCodexAccount = exports.switchToCodexAccountAsync = exports.switchToCodexAccount = exports.finalizeCodexAccountAsync = exports.finalizeCodexAccount = exports.prepareCodexAccountAsync = exports.prepareCodexAccount = exports.getCodexExecutionEnv = exports.resolveSidekickCodexHome = exports.resolveActiveCodexAccount = exports.getActiveCodexAccount = exports.listCodexAccounts = exports.getSystemCodexHome = exports.getCodexMonitoringHomes = exports.getCodexProfileHome = exports.getCodexProfilesDir = exports.getClaudeProjectsDir = exports.isDefaultClaudeHome = exports.getDefaultClaudeHome = exports.getLiveClaudeHome = exports.readLiveClaudeIdentity = exports.readClaudeProfileIdentity = exports.isClaudeProfileAuthenticated = exports.CLAUDE_SECURESTORAGE_CONFIG_DIR_ENV = exports.buildClaudeChildEnv = exports.claudeKeychainAccountName = exports.claudeKeychainService = exports.claudeKeychainSuffix = void 0;
14
- exports.registerModelAlias = exports.importResolvedModelCatalog = exports.exportResolvedModelCatalog = exports.MODEL_PROVIDER_IDS = exports.formatCost = exports.sortModelIds = exports.compareModelIds = exports.getModelDisplayInfo = exports.shortModelName = exports.mergeCostSources = exports.calculateCostWithProvenance = exports.calculateCostWithPricing = exports.calculateCost = exports.getModelInfo = exports.resolveModelPricing = exports.getModelPricing = exports.parseModelId = exports.DEFAULT_CONTEXT_WINDOW = exports.resolveModelContextWindow = exports.getModelContextWindowSize = exports.selectStatuslineAccount = exports.formatStatusline = exports.estimateTimeToQuota = exports.BurnRateCalculator = exports.RUNTIME_QUOTA_PROVIDER_IDS = exports.MultiProviderQuotaService = exports.resolveZaiQuota = exports.readZaiCredentials = exports.quotaStateFromZaiQuotaLimitPayload = exports.fetchZaiQuotaFromApi = exports.CodexQuotaWatcher = exports.resolveCodexQuotaFromLocalSources = exports.resolveCodexQuota = exports.readLatestCodexQuotaFromRollouts = exports.quotaFromCodexRateLimits = exports.fetchCodexQuotaFromApi = exports.fetchCodexResetCreditsFromApi = exports.getWorkspaceIdFromPath = exports.pruneQuotaHistory = exports.readQuotaHistoryDailyBuckets = exports.readQuotaHistoryRange = exports.appendQuotaHistorySample = exports.quotaFromStatuslinePayload = exports.parseClaudeStatuslinePayload = exports.evaluateQuotaThresholds = exports.describeQuotaThresholdAlert = exports.DEFAULT_QUOTA_THRESHOLDS = exports.QUOTA_FRESH_MAX_AGE_MS = exports.QUOTA_AGING_MAX_AGE_MS = exports.formatQuotaAge = void 0;
15
- exports.providerFailureDiagnosisSchema = exports.providerRetryAfterSchema = exports.providerFailureEvidenceSchema = exports.providerAuthenticationEvidenceSchema = exports.quotaHistoryDailyBucketSchema = exports.quotaHistorySampleSchema = exports.quotaHistoryRuntimeProviderSchema = exports.providerQuotaMapSchema = exports.zaiProviderQuotaStateSchema = exports.codexProviderQuotaStateSchema = exports.claudeProviderQuotaStateSchema = exports.providerQuotaStateSchema = exports.runtimeQuotaProviderSchema = exports.quotaFailureDescriptorSchema = exports.peakHoursStateSchema = exports.codexResetCreditsSnapshotSchema = exports.codexResetCreditSchema = exports.quotaSourceSchema = exports.quotaProviderIdSchema = exports.quotaFailureKindSchema = exports.quotaStateSchema = exports.quotaWindowSchema = exports.extractSessionEvents = exports.permissionModeSchema = exports.sessionEventSchema = exports.sessionMessageSchema = exports.messageUsageSchema = exports.ToolCallTracker = exports.extractToolCalls = exports.extractToolCall = exports.extractErrorMessage = exports.categorizeError = exports.gatherAssetsForCwd = exports.codexSessions = exports.readCodexAssets = exports.claudeSessions = exports.readClaudeAssets = exports.extractCommands = exports.extractFilePaths = exports.extractUrls = exports.extractTokenUsage = exports.getObservedContextWindowPath = exports.recordObservedContextWindow = exports.loadObservedContextWindows = exports.LITELLM_CATALOG_URL = exports.normalizeLiteLlmContextWindows = exports.normalizeLiteLlmCatalog = exports.hydratePricingCatalog = exports.RESOLVED_MODEL_CATALOG_SCHEMA_VERSION = exports.resolveModelAlias = void 0;
16
- exports.readStoredCodexAccount = exports.repairCodexCredentialStores = exports.inspectCodexCredentialStores = exports.fetchProviderServiceStatus = exports.PROVIDER_RECOVERY_ACTIONS = exports.PROVIDER_FAILURE_EVIDENCE_SOURCES = exports.PROVIDER_FAILURE_CODES = exports.PROVIDER_CREDENTIAL_KINDS = exports.PROVIDER_AUTHENTICATION_STATES = exports.PROVIDER_AUTHENTICATION_SOURCES = exports.diagnoseProviderFailure = exports.mergeFailingToolWindows = exports.failingToolTrend = exports.FAILING_TOOL_TREND_ARROWS = exports.scopePeakHoursToSessionProvider = exports.PEAK_HOURS_DESCRIPTION = exports.PEAK_HOURS_CACHE_MS = exports.isClaudeCodeSessionProvider = exports.getScheduledPeakHoursState = exports.fetchPeakHoursStatus = exports.DEFAULT_PEAK_HOURS_TIMEOUT_MS = exports.createPeakHoursNotApplicableState = exports._resetPeakHoursCache = exports.runDoctor = exports.getSessionDiagnostics = exports.formatHealthReport = exports.toLegacyProviderStatus = exports.fetchOpenAIStatus = exports.fetchProviderStatus = exports.assistantTurnToolRefSchema = exports.assistantTurnToolGroupStepSchema = exports.assistantTurnTimelineItemSchema = exports.assistantTurnSubagentStatusSchema = exports.assistantTurnSubagentSchema = exports.assistantTurnReasoningTimelineItemSchema = exports.assistantTurnProjectionSchema = exports.assistantTurnProcessStepSchema = exports.assistantTurnProcessSchema = exports.assistantTurnNarrationStepSchema = exports.assistantTurnEventTypeSchema = exports.assistantTurnEventSchema = exports.listAllAccountsResultSchema = exports.savedAccountProfileSchema = exports.accountEntrySchema = exports.accountLoginStatusSchema = exports.beginAccountLoginResultSchema = exports.accountManagerResultSchema = exports.accountProviderIdSchema = exports.activeAccountStatusSchema = exports.activeProviderAccountStatusSchema = void 0;
17
- exports.resolveWorkspaceRoots = exports.TOOL_CATEGORIES = exports.classifyTool = exports.CODEX_ARCHIVED_SESSIONS_SUBDIR = exports.CODEX_SESSIONS_SUBDIR = exports.getCodexSessionsDirs = exports.syncCodexLiveStateAsync = void 0;
13
+ exports.quotaWindowHasData = exports.quotaWindowApplies = exports.quotaStateFromClaudeUsagePayload = exports.quotaSampleExpired = exports.projectQuotaWindow = exports.formatExtraUsage = exports.fetchQuota = exports.extraQuotaRows = exports.claudePlanLabel = exports.SEVEN_DAY_WINDOW_MS = exports.QUOTA_PROVIDER_IDS = exports.FIVE_HOUR_WINDOW_MS = exports.AutoSwitchController = exports.decideAutoSwitch = exports.DEFAULT_AUTO_SWITCH_CONFIG = exports.removeLauncher = exports.writeLauncher = exports.writeAccountLauncher = exports.CODEX_KEYRING_FIX_HINT = exports.getCodexCredentialStoreMode = exports.cleanupAbandonedCodexLogins = exports.syncCodexLiveState = exports.removeCodexAccount = exports.switchToCodexAccountAsync = exports.switchToCodexAccount = exports.finalizeCodexAccountAsync = exports.finalizeCodexAccount = exports.prepareCodexAccountAsync = exports.prepareCodexAccount = exports.getCodexExecutionEnv = exports.resolveSidekickCodexHome = exports.resolveActiveCodexAccount = exports.getActiveCodexAccount = exports.listCodexAccounts = exports.getSystemCodexHome = exports.getCodexMonitoringHomes = exports.getCodexProfileHome = exports.getCodexProfilesDir = exports.getClaudeProjectsDir = exports.isDefaultClaudeHome = exports.getDefaultClaudeHome = exports.getLiveClaudeHome = exports.readLiveClaudeIdentity = exports.readClaudeProfileIdentity = exports.isClaudeProfileAuthenticated = exports.CLAUDE_SECURESTORAGE_CONFIG_DIR_ENV = exports.buildClaudeChildEnv = exports.claudeKeychainAccountName = exports.claudeKeychainService = exports.claudeKeychainSuffix = void 0;
14
+ exports.calculateCostWithPricing = exports.calculateCost = exports.getModelInfo = exports.resolveModelPricing = exports.getModelPricing = exports.parseModelId = exports.DEFAULT_CONTEXT_WINDOW = exports.resolveModelContextWindow = exports.getModelContextWindowSize = exports.selectStatuslineAccount = exports.formatStatusline = exports.estimateTimeToQuota = exports.BurnRateCalculator = exports.RUNTIME_QUOTA_PROVIDER_IDS = exports.MultiProviderQuotaService = exports.resolveZaiQuota = exports.readZaiCredentials = exports.quotaStateFromZaiQuotaLimitPayload = exports.fetchZaiQuotaFromApi = exports.CodexQuotaWatcher = exports.resolveCodexQuotaFromLocalSources = exports.resolveCodexQuota = exports.readLatestCodexQuotaFromRollouts = exports.quotaFromCodexRateLimits = exports.fetchCodexQuotaFromApi = exports.fetchCodexResetCreditsFromApi = exports.quotaHistoryWindow = exports.getWorkspaceIdFromPath = exports.pruneQuotaHistory = exports.readQuotaHistoryDailyBuckets = exports.readQuotaHistoryRange = exports.appendQuotaHistorySample = exports.quotaFromStatuslinePayload = exports.parseClaudeStatuslinePayload = exports.evaluateQuotaThresholds = exports.describeQuotaThresholdAlert = exports.DEFAULT_QUOTA_THRESHOLDS = exports.QUOTA_FRESH_MAX_AGE_MS = exports.QUOTA_AGING_MAX_AGE_MS = exports.formatQuotaAge = exports.classifyQuotaFreshness = exports.resolveQuota = exports.writeQuotaSnapshot = exports.readQuotaSnapshot = exports.QuotaPoller = exports.describeQuotaFailure = exports.withQuotaProjections = exports.withClaudePlan = exports.quotaWindowShortLabel = exports.quotaWindowLabel = void 0;
15
+ exports.quotaFailureDescriptorSchema = exports.peakHoursStateSchema = exports.codexResetCreditsSnapshotSchema = exports.codexResetCreditSchema = exports.quotaSourceSchema = exports.quotaProviderIdSchema = exports.quotaFailureKindSchema = exports.quotaExtraUsageSchema = exports.quotaLimitRowSchema = exports.quotaStateSchema = exports.quotaWindowSchema = exports.extractSessionEvents = exports.permissionModeSchema = exports.sessionEventSchema = exports.sessionMessageSchema = exports.messageUsageSchema = exports.ToolCallTracker = exports.extractToolCalls = exports.extractToolCall = exports.extractErrorMessage = exports.categorizeError = exports.gatherAssetsForCwd = exports.codexSessions = exports.readCodexAssets = exports.claudeSessions = exports.readClaudeAssets = exports.extractCommands = exports.extractFilePaths = exports.extractUrls = exports.extractTokenUsage = exports.getObservedContextWindowPath = exports.recordObservedContextWindow = exports.loadObservedContextWindows = exports.LITELLM_CATALOG_URL = exports.normalizeLiteLlmContextWindows = exports.normalizeLiteLlmCatalog = exports.hydratePricingCatalog = exports.RESOLVED_MODEL_CATALOG_SCHEMA_VERSION = exports.resolveModelAlias = exports.registerModelAlias = exports.importResolvedModelCatalog = exports.exportResolvedModelCatalog = exports.MODEL_PROVIDER_IDS = exports.formatCost = exports.sortModelIds = exports.compareModelIds = exports.getModelDisplayInfo = exports.shortModelName = exports.mergeCostSources = exports.calculateCostWithProvenance = void 0;
16
+ exports.FAILING_TOOL_TREND_ARROWS = exports.scopePeakHoursToSessionProvider = exports.PEAK_HOURS_DESCRIPTION = exports.PEAK_HOURS_CACHE_MS = exports.isClaudeCodeSessionProvider = exports.getScheduledPeakHoursState = exports.fetchPeakHoursStatus = exports.DEFAULT_PEAK_HOURS_TIMEOUT_MS = exports.createPeakHoursNotApplicableState = exports._resetPeakHoursCache = exports.runDoctor = exports.getSessionDiagnostics = exports.formatHealthReport = exports.toLegacyProviderStatus = exports.fetchOpenAIStatus = exports.fetchProviderStatus = exports.assistantTurnToolRefSchema = exports.assistantTurnToolGroupStepSchema = exports.assistantTurnTimelineItemSchema = exports.assistantTurnSubagentStatusSchema = exports.assistantTurnSubagentSchema = exports.assistantTurnReasoningTimelineItemSchema = exports.assistantTurnProjectionSchema = exports.assistantTurnProcessStepSchema = exports.assistantTurnProcessSchema = exports.assistantTurnNarrationStepSchema = exports.assistantTurnEventTypeSchema = exports.assistantTurnEventSchema = exports.listAllAccountsResultSchema = exports.savedAccountProfileSchema = exports.accountEntrySchema = exports.accountLoginStatusSchema = exports.beginAccountLoginResultSchema = exports.accountManagerResultSchema = exports.accountProviderIdSchema = exports.activeAccountStatusSchema = exports.activeProviderAccountStatusSchema = exports.providerFailureDiagnosisSchema = exports.providerRetryAfterSchema = exports.providerFailureEvidenceSchema = exports.providerAuthenticationEvidenceSchema = exports.quotaHistoryDailyBucketSchema = exports.quotaHistorySampleSchema = exports.quotaHistoryRuntimeProviderSchema = exports.providerQuotaMapSchema = exports.zaiProviderQuotaStateSchema = exports.codexProviderQuotaStateSchema = exports.claudeProviderQuotaStateSchema = exports.providerQuotaStateSchema = exports.runtimeQuotaProviderSchema = void 0;
17
+ exports.resolveWorkspaceRoots = exports.TOOL_CATEGORIES = exports.classifyTool = exports.CODEX_ARCHIVED_SESSIONS_SUBDIR = exports.CODEX_SESSIONS_SUBDIR = exports.getCodexSessionsDirs = exports.syncCodexLiveStateAsync = exports.readStoredCodexAccount = exports.repairCodexCredentialStores = exports.inspectCodexCredentialStores = exports.fetchProviderServiceStatus = exports.PROVIDER_RECOVERY_ACTIONS = exports.PROVIDER_FAILURE_EVIDENCE_SOURCES = exports.PROVIDER_FAILURE_CODES = exports.PROVIDER_CREDENTIAL_KINDS = exports.PROVIDER_AUTHENTICATION_STATES = exports.PROVIDER_AUTHENTICATION_SOURCES = exports.diagnoseProviderFailure = exports.mergeFailingToolWindows = exports.failingToolTrend = void 0;
18
18
  var usageNormalization_1 = require("./usageNormalization");
19
19
  Object.defineProperty(exports, "normalizeProviderUsage", { enumerable: true, get: function () { return usageNormalization_1.normalizeProviderUsage; } });
20
20
  Object.defineProperty(exports, "extractNormalizedUsage", { enumerable: true, get: function () { return usageNormalization_1.extractNormalizedUsage; } });
@@ -552,8 +552,18 @@ var quota_1 = require("./quota");
552
552
  Object.defineProperty(exports, "FIVE_HOUR_WINDOW_MS", { enumerable: true, get: function () { return quota_1.FIVE_HOUR_WINDOW_MS; } });
553
553
  Object.defineProperty(exports, "QUOTA_PROVIDER_IDS", { enumerable: true, get: function () { return quota_1.QUOTA_PROVIDER_IDS; } });
554
554
  Object.defineProperty(exports, "SEVEN_DAY_WINDOW_MS", { enumerable: true, get: function () { return quota_1.SEVEN_DAY_WINDOW_MS; } });
555
+ Object.defineProperty(exports, "claudePlanLabel", { enumerable: true, get: function () { return quota_1.claudePlanLabel; } });
556
+ Object.defineProperty(exports, "extraQuotaRows", { enumerable: true, get: function () { return quota_1.extraQuotaRows; } });
555
557
  Object.defineProperty(exports, "fetchQuota", { enumerable: true, get: function () { return quota_1.fetchQuota; } });
558
+ Object.defineProperty(exports, "formatExtraUsage", { enumerable: true, get: function () { return quota_1.formatExtraUsage; } });
556
559
  Object.defineProperty(exports, "projectQuotaWindow", { enumerable: true, get: function () { return quota_1.projectQuotaWindow; } });
560
+ Object.defineProperty(exports, "quotaSampleExpired", { enumerable: true, get: function () { return quota_1.quotaSampleExpired; } });
561
+ Object.defineProperty(exports, "quotaStateFromClaudeUsagePayload", { enumerable: true, get: function () { return quota_1.quotaStateFromClaudeUsagePayload; } });
562
+ Object.defineProperty(exports, "quotaWindowApplies", { enumerable: true, get: function () { return quota_1.quotaWindowApplies; } });
563
+ Object.defineProperty(exports, "quotaWindowHasData", { enumerable: true, get: function () { return quota_1.quotaWindowHasData; } });
564
+ Object.defineProperty(exports, "quotaWindowLabel", { enumerable: true, get: function () { return quota_1.quotaWindowLabel; } });
565
+ Object.defineProperty(exports, "quotaWindowShortLabel", { enumerable: true, get: function () { return quota_1.quotaWindowShortLabel; } });
566
+ Object.defineProperty(exports, "withClaudePlan", { enumerable: true, get: function () { return quota_1.withClaudePlan; } });
557
567
  Object.defineProperty(exports, "withQuotaProjections", { enumerable: true, get: function () { return quota_1.withQuotaProjections; } });
558
568
  var quotaPresentation_1 = require("./quotaPresentation");
559
569
  Object.defineProperty(exports, "describeQuotaFailure", { enumerable: true, get: function () { return quotaPresentation_1.describeQuotaFailure; } });
@@ -582,6 +592,7 @@ Object.defineProperty(exports, "readQuotaHistoryRange", { enumerable: true, get:
582
592
  Object.defineProperty(exports, "readQuotaHistoryDailyBuckets", { enumerable: true, get: function () { return quotaHistory_1.readQuotaHistoryDailyBuckets; } });
583
593
  Object.defineProperty(exports, "pruneQuotaHistory", { enumerable: true, get: function () { return quotaHistory_1.pruneQuotaHistory; } });
584
594
  Object.defineProperty(exports, "getWorkspaceIdFromPath", { enumerable: true, get: function () { return quotaHistory_1.getWorkspaceIdFromPath; } });
595
+ Object.defineProperty(exports, "quotaHistoryWindow", { enumerable: true, get: function () { return quotaHistory_1.quotaHistoryWindow; } });
585
596
  var codexQuota_1 = require("./codexQuota");
586
597
  Object.defineProperty(exports, "fetchCodexResetCreditsFromApi", { enumerable: true, get: function () { return codexQuota_1.fetchCodexResetCreditsFromApi; } });
587
598
  Object.defineProperty(exports, "fetchCodexQuotaFromApi", { enumerable: true, get: function () { return codexQuota_1.fetchCodexQuotaFromApi; } });
@@ -680,6 +691,8 @@ Object.defineProperty(exports, "extractSessionEvents", { enumerable: true, get:
680
691
  var quota_3 = require("./schemas/quota");
681
692
  Object.defineProperty(exports, "quotaWindowSchema", { enumerable: true, get: function () { return quota_3.quotaWindowSchema; } });
682
693
  Object.defineProperty(exports, "quotaStateSchema", { enumerable: true, get: function () { return quota_3.quotaStateSchema; } });
694
+ Object.defineProperty(exports, "quotaLimitRowSchema", { enumerable: true, get: function () { return quota_3.quotaLimitRowSchema; } });
695
+ Object.defineProperty(exports, "quotaExtraUsageSchema", { enumerable: true, get: function () { return quota_3.quotaExtraUsageSchema; } });
683
696
  Object.defineProperty(exports, "quotaFailureKindSchema", { enumerable: true, get: function () { return quota_3.quotaFailureKindSchema; } });
684
697
  Object.defineProperty(exports, "quotaProviderIdSchema", { enumerable: true, get: function () { return quota_3.quotaProviderIdSchema; } });
685
698
  Object.defineProperty(exports, "quotaSourceSchema", { enumerable: true, get: function () { return quota_3.quotaSourceSchema; } });
@@ -44,6 +44,38 @@ exports.getModelContextWindowSize = getModelContextWindowSize;
44
44
  const modelAliases_1 = require("./modelAliases");
45
45
  /** Known model context window sizes (in tokens); current models verified 2026-09-05. */
46
46
  const MODEL_CONTEXT_SIZES = {
47
+ // Published API limits verified 2026-10-30; GLM's API documents 1M even
48
+ // though local weights may support more. Catalog/observed overrides win.
49
+ 'gpt-6.1-sol': 1_050_000,
50
+ 'openai/gpt-6.1-sol': 1_050_000,
51
+ 'gpt-6.1-terra': 1_050_000,
52
+ 'openai/gpt-6.1-terra': 1_050_000,
53
+ 'claude-sonnet-5-5': 1_000_000,
54
+ 'anthropic/claude-sonnet-5-5': 1_000_000,
55
+ 'claude-sonnet-5.5': 1_000_000,
56
+ 'anthropic/claude-sonnet-5.5': 1_000_000,
57
+ 'claude-haiku-5-5': 1_000_000,
58
+ 'anthropic/claude-haiku-5-5': 1_000_000,
59
+ 'claude-haiku-5.5': 1_000_000,
60
+ 'anthropic/claude-haiku-5.5': 1_000_000,
61
+ 'gemini-4-argon': 1_048_576,
62
+ 'gemini/gemini-4-argon': 1_048_576,
63
+ 'gemini-3.8-flash': 1_048_576,
64
+ 'gemini/gemini-3.8-flash': 1_048_576,
65
+ 'deepseek-flash': 1_000_000,
66
+ 'deepseek/deepseek-flash': 1_000_000,
67
+ 'deepseek-v4-flash': 1_000_000,
68
+ 'deepseek/deepseek-v4-flash': 1_000_000,
69
+ 'deepseek-v4-flash-vision-exp': 1_000_000,
70
+ 'deepseek/deepseek-v4-flash-vision-exp': 1_000_000,
71
+ 'deepseek-v4-pro': 1_000_000,
72
+ 'deepseek/deepseek-v4-pro': 1_000_000,
73
+ 'glm-5.3': 1_000_000,
74
+ 'zai/glm-5.3': 1_000_000,
75
+ 'glm-5.3-flash': 1_000_000,
76
+ 'zai/glm-5.3-flash': 1_000_000,
77
+ 'glm-5.3-flashx': 1_000_000,
78
+ 'zai/glm-5.3-flashx': 1_000_000,
47
79
  // Claude — native 1M context (Fable 5+, Opus 4.6+, Sonnet 4.6+)
48
80
  'claude-fable-5-1': 1_000_000,
49
81
  'claude-fable-5.1': 1_000_000,
package/dist/modelInfo.js CHANGED
@@ -60,6 +60,192 @@ Object.defineProperty(exports, "MODEL_PROVIDER_IDS", { enumerable: true, get: fu
60
60
  * prefix matching cannot bridge the two, so both are needed.
61
61
  */
62
62
  const PRICING_TABLE = {
63
+ // Current coding models verified 2026-10-30. Standard short-context rates;
64
+ // DeepSeek uses peak rates. Gemini promotions end 2026-11-30 (Argon) and
65
+ // 2026-12-31 (Flash). Haiku 5.5 costs more above 100K prompt tokens.
66
+ // Sources and estimation limits: docs/configuration/model-resolution.md.
67
+ // Explicit direct-provider keys support offline OpenCode model IDs without
68
+ // stripping arbitrary deployment prefixes or changing alias resolution.
69
+ 'gpt-6.1-sol': {
70
+ inputCostPerMillion: 2,
71
+ outputCostPerMillion: 10,
72
+ cacheWriteCostPerMillion: 2.5,
73
+ cacheReadCostPerMillion: 0.1,
74
+ },
75
+ 'openai/gpt-6.1-sol': {
76
+ inputCostPerMillion: 2,
77
+ outputCostPerMillion: 10,
78
+ cacheWriteCostPerMillion: 2.5,
79
+ cacheReadCostPerMillion: 0.1,
80
+ },
81
+ 'gpt-6.1-terra': {
82
+ inputCostPerMillion: 1,
83
+ outputCostPerMillion: 5,
84
+ cacheWriteCostPerMillion: 1.25,
85
+ cacheReadCostPerMillion: 0.05,
86
+ },
87
+ 'openai/gpt-6.1-terra': {
88
+ inputCostPerMillion: 1,
89
+ outputCostPerMillion: 5,
90
+ cacheWriteCostPerMillion: 1.25,
91
+ cacheReadCostPerMillion: 0.05,
92
+ },
93
+ 'claude-sonnet-5-5': {
94
+ inputCostPerMillion: 2,
95
+ outputCostPerMillion: 10,
96
+ cacheWriteCostPerMillion: 2.5,
97
+ cacheReadCostPerMillion: 0.1,
98
+ },
99
+ 'anthropic/claude-sonnet-5-5': {
100
+ inputCostPerMillion: 2,
101
+ outputCostPerMillion: 10,
102
+ cacheWriteCostPerMillion: 2.5,
103
+ cacheReadCostPerMillion: 0.1,
104
+ },
105
+ 'claude-sonnet-5.5': {
106
+ inputCostPerMillion: 2,
107
+ outputCostPerMillion: 10,
108
+ cacheWriteCostPerMillion: 2.5,
109
+ cacheReadCostPerMillion: 0.1,
110
+ },
111
+ 'anthropic/claude-sonnet-5.5': {
112
+ inputCostPerMillion: 2,
113
+ outputCostPerMillion: 10,
114
+ cacheWriteCostPerMillion: 2.5,
115
+ cacheReadCostPerMillion: 0.1,
116
+ },
117
+ 'claude-haiku-5-5': {
118
+ inputCostPerMillion: 0.1,
119
+ outputCostPerMillion: 0.5,
120
+ cacheWriteCostPerMillion: 0.125,
121
+ cacheReadCostPerMillion: 0.01,
122
+ },
123
+ 'anthropic/claude-haiku-5-5': {
124
+ inputCostPerMillion: 0.1,
125
+ outputCostPerMillion: 0.5,
126
+ cacheWriteCostPerMillion: 0.125,
127
+ cacheReadCostPerMillion: 0.01,
128
+ },
129
+ 'claude-haiku-5.5': {
130
+ inputCostPerMillion: 0.1,
131
+ outputCostPerMillion: 0.5,
132
+ cacheWriteCostPerMillion: 0.125,
133
+ cacheReadCostPerMillion: 0.01,
134
+ },
135
+ 'anthropic/claude-haiku-5.5': {
136
+ inputCostPerMillion: 0.1,
137
+ outputCostPerMillion: 0.5,
138
+ cacheWriteCostPerMillion: 0.125,
139
+ cacheReadCostPerMillion: 0.01,
140
+ },
141
+ 'gemini-4-argon': {
142
+ inputCostPerMillion: 2,
143
+ outputCostPerMillion: 10,
144
+ cacheWriteCostPerMillion: 0,
145
+ cacheReadCostPerMillion: 0.1,
146
+ },
147
+ 'gemini/gemini-4-argon': {
148
+ inputCostPerMillion: 2,
149
+ outputCostPerMillion: 10,
150
+ cacheWriteCostPerMillion: 0,
151
+ cacheReadCostPerMillion: 0.1,
152
+ },
153
+ 'gemini-3.8-flash': {
154
+ inputCostPerMillion: 0.75,
155
+ outputCostPerMillion: 3.75,
156
+ cacheWriteCostPerMillion: 0,
157
+ cacheReadCostPerMillion: 0.075,
158
+ },
159
+ 'gemini/gemini-3.8-flash': {
160
+ inputCostPerMillion: 0.75,
161
+ outputCostPerMillion: 3.75,
162
+ cacheWriteCostPerMillion: 0,
163
+ cacheReadCostPerMillion: 0.075,
164
+ },
165
+ 'deepseek-flash': {
166
+ inputCostPerMillion: 0.3,
167
+ outputCostPerMillion: 1.2,
168
+ cacheWriteCostPerMillion: 0,
169
+ cacheReadCostPerMillion: 0.006,
170
+ },
171
+ 'deepseek/deepseek-flash': {
172
+ inputCostPerMillion: 0.3,
173
+ outputCostPerMillion: 1.2,
174
+ cacheWriteCostPerMillion: 0,
175
+ cacheReadCostPerMillion: 0.006,
176
+ },
177
+ 'deepseek-v4-flash': {
178
+ inputCostPerMillion: 0.3,
179
+ outputCostPerMillion: 1.2,
180
+ cacheWriteCostPerMillion: 0,
181
+ cacheReadCostPerMillion: 0.006,
182
+ },
183
+ 'deepseek/deepseek-v4-flash': {
184
+ inputCostPerMillion: 0.3,
185
+ outputCostPerMillion: 1.2,
186
+ cacheWriteCostPerMillion: 0,
187
+ cacheReadCostPerMillion: 0.006,
188
+ },
189
+ 'deepseek-v4-flash-vision-exp': {
190
+ inputCostPerMillion: 0.3,
191
+ outputCostPerMillion: 1.2,
192
+ cacheWriteCostPerMillion: 0,
193
+ cacheReadCostPerMillion: 0.006,
194
+ },
195
+ 'deepseek/deepseek-v4-flash-vision-exp': {
196
+ inputCostPerMillion: 0.3,
197
+ outputCostPerMillion: 1.2,
198
+ cacheWriteCostPerMillion: 0,
199
+ cacheReadCostPerMillion: 0.006,
200
+ },
201
+ 'deepseek-v4-pro': {
202
+ inputCostPerMillion: 1.32,
203
+ outputCostPerMillion: 3.96,
204
+ cacheWriteCostPerMillion: 0,
205
+ cacheReadCostPerMillion: 0.044,
206
+ },
207
+ 'deepseek/deepseek-v4-pro': {
208
+ inputCostPerMillion: 1.32,
209
+ outputCostPerMillion: 3.96,
210
+ cacheWriteCostPerMillion: 0,
211
+ cacheReadCostPerMillion: 0.044,
212
+ },
213
+ 'glm-5.3': {
214
+ inputCostPerMillion: 1.4,
215
+ outputCostPerMillion: 4.4,
216
+ cacheWriteCostPerMillion: 0,
217
+ cacheReadCostPerMillion: 0.26,
218
+ },
219
+ 'zai/glm-5.3': {
220
+ inputCostPerMillion: 1.4,
221
+ outputCostPerMillion: 4.4,
222
+ cacheWriteCostPerMillion: 0,
223
+ cacheReadCostPerMillion: 0.26,
224
+ },
225
+ 'glm-5.3-flash': {
226
+ inputCostPerMillion: 0.15,
227
+ outputCostPerMillion: 0.5,
228
+ cacheWriteCostPerMillion: 0,
229
+ cacheReadCostPerMillion: 0.03,
230
+ },
231
+ 'zai/glm-5.3-flash': {
232
+ inputCostPerMillion: 0.15,
233
+ outputCostPerMillion: 0.5,
234
+ cacheWriteCostPerMillion: 0,
235
+ cacheReadCostPerMillion: 0.03,
236
+ },
237
+ 'glm-5.3-flashx': {
238
+ inputCostPerMillion: 0.37,
239
+ outputCostPerMillion: 1.25,
240
+ cacheWriteCostPerMillion: 0,
241
+ cacheReadCostPerMillion: 0.075,
242
+ },
243
+ 'zai/glm-5.3-flashx': {
244
+ inputCostPerMillion: 0.37,
245
+ outputCostPerMillion: 1.25,
246
+ cacheWriteCostPerMillion: 0,
247
+ cacheReadCostPerMillion: 0.075,
248
+ },
63
249
  // ── Anthropic: Claude ──
64
250
  // Fable 5.1 cache reads cost 0.025x input; Fable 5 retains its 0.1x rate.
65
251
  'claude-fable-5-1': {
@@ -293,7 +293,7 @@ class MultiProviderQuotaService {
293
293
  await this.refreshPeakHours();
294
294
  const creds = await this.readClaudeCredentials();
295
295
  if (!creds) {
296
- this.handleUnavailableState(makeUnavailableClaudeState('Renew your Claude Max OAuth to view quota', 'auth'));
296
+ this.handleUnavailableState(makeUnavailableClaudeState('Renew your Claude login to view quota', 'auth'));
297
297
  return;
298
298
  }
299
299
  const state = await this.fetchClaudeQuota(creds.accessToken);
package/dist/quota.d.ts CHANGED
@@ -2,7 +2,7 @@ import type { QuotaProviderId } from './providerIds';
2
2
  export { QUOTA_PROVIDER_IDS } from './providerIds';
3
3
  export type { QuotaProviderId } from './providerIds';
4
4
  /**
5
- * Stateless quota fetcher for Claude Max subscription usage.
5
+ * Stateless quota fetcher for Claude subscription usage (Pro, Max, Ultra).
6
6
  *
7
7
  * Calls the Anthropic OAuth usage endpoint and returns utilization data.
8
8
  * Polling / eventing is the caller's responsibility.
@@ -12,6 +12,67 @@ export interface QuotaWindow {
12
12
  utilization: number;
13
13
  /** ISO timestamp when the window resets */
14
14
  resetsAt: string;
15
+ /**
16
+ * True when the provider reported that this window does not exist for the
17
+ * account — Claude Ultra has no five-hour session limit (`five_hour: null`),
18
+ * and a Codex plan can report a primary window without a secondary one.
19
+ * `utilization`/`resetsAt` are then `0`/`''` placeholders, so readers that
20
+ * predate the flag keep their old behaviour. Absent or false: the window
21
+ * applies (it may still be idle, with no reset time yet).
22
+ */
23
+ absent?: boolean;
24
+ /** Window length in milliseconds when the provider reports it (e.g. Codex `window_minutes`). */
25
+ windowMs?: number;
26
+ }
27
+ /**
28
+ * One usage meter as reported by the Claude usage endpoint's `limits[]` array.
29
+ * The server decides which meters exist and in what order; classify on
30
+ * `kind`, never on `label`.
31
+ */
32
+ export interface QuotaLimitRow {
33
+ /** Server meter kind, e.g. `session`, `weekly_all`, `weekly_scoped`. */
34
+ kind: string;
35
+ /** Server row group, e.g. `session` or `weekly`. */
36
+ group: string;
37
+ /** Display label derived from kind, group, and scope, e.g. `7-Day (Fable)`. */
38
+ label: string;
39
+ /** Share of the window used, 0–100. */
40
+ utilization: number;
41
+ /** ISO timestamp when the window resets; empty when unknown. */
42
+ resetsAt: string;
43
+ /** Window length in milliseconds, derived from the group when known. */
44
+ windowMs?: number;
45
+ /** Projected utilization at reset (percentage, capped at 200). */
46
+ projected?: number;
47
+ /** Model the meter is scoped to (server display name), e.g. `Fable`. */
48
+ scopeModel?: string;
49
+ /** Surface the meter is scoped to (server display name). */
50
+ scopeSurface?: string;
51
+ /** Server severity for colouring: `normal`, `warning`, `critical`. */
52
+ severity?: string;
53
+ /** The server's headline pick — the row a single-value indicator shows. */
54
+ isActive?: boolean;
55
+ /** For scoped weekly meters: how much of the all-models weekly limit this meter may use. */
56
+ allowancePercentOfWeekly?: number;
57
+ /** For scoped weekly meters: how much of the all-models weekly limit it has used. */
58
+ usedPercentOfWeekly?: number;
59
+ }
60
+ /** Claude extra-usage (usage credits) spend for the billing period. */
61
+ export interface QuotaExtraUsage {
62
+ /** Whether extra usage can currently cover requests. */
63
+ enabled: boolean;
64
+ /** Monthly cap in minor units of `currency` (cents for USD); null when uncapped. */
65
+ monthlyLimit: number | null;
66
+ /** Spend so far this period, in minor units of `currency`. */
67
+ usedCredits: number | null;
68
+ /** Share of the monthly cap used, 0–100. */
69
+ utilization: number | null;
70
+ /** ISO 4217 currency code, e.g. `USD`. */
71
+ currency?: string;
72
+ /** Number of minor-unit decimals (2 for USD). */
73
+ decimalPlaces?: number;
74
+ /** Server reason extra usage is off, e.g. `out_of_credits`. */
75
+ disabledReason?: string;
15
76
  }
16
77
  export interface CodexResetCredit {
17
78
  title?: string;
@@ -80,8 +141,23 @@ export interface QuotaState {
80
141
  resetCredits?: CodexResetCreditsSnapshot;
81
142
  /** Provider-specific plan type */
82
143
  planType?: string;
144
+ /** Display name of the subscription plan, e.g. `Pro`, `Max`, `Ultra`. */
145
+ planLabel?: string;
83
146
  /** Provider-specific rate-limit reached reason */
84
147
  rateLimitReachedType?: string;
148
+ /**
149
+ * Every usage meter the provider reported, in server order (Claude's
150
+ * `limits[]`). The `session` and `weekly_all` rows duplicate `fiveHour` and
151
+ * `sevenDay`; use `extraQuotaRows()` for the rest (e.g. a Fable weekly cap).
152
+ */
153
+ limits?: QuotaLimitRow[];
154
+ /** Claude extra-usage (usage credits) spend, when the plan reports it. */
155
+ extraUsage?: QuotaExtraUsage;
156
+ }
157
+ /** Plan facts read from the Claude OAuth credentials. */
158
+ export interface ClaudePlanInfo {
159
+ subscriptionType?: string | null;
160
+ rateLimitTier?: string | null;
85
161
  }
86
162
  export declare const FIVE_HOUR_WINDOW_MS: number;
87
163
  export declare const SEVEN_DAY_WINDOW_MS: number;
@@ -93,6 +169,39 @@ export declare const QUOTA_FRESH_MAX_AGE_MS: number;
93
169
  export declare const QUOTA_AGING_MAX_AGE_MS: number;
94
170
  /** Classify a cached sample's age. Non-finite or negative ages count as stale. */
95
171
  export declare function classifyQuotaFreshness(ageMs: number | undefined): QuotaFreshness;
172
+ /** Whether the provider reports this window for the account at all. */
173
+ export declare function quotaWindowApplies(window: QuotaWindow | null | undefined): boolean;
174
+ /** Whether the window applies and carries a reading worth showing (a reset time or any usage). */
175
+ export declare function quotaWindowHasData(window: QuotaWindow | null | undefined): boolean;
176
+ /**
177
+ * True when every window of a sample that has a known reset time has already
178
+ * reset by `nowMs`. Such a sample says nothing about current usage — showing
179
+ * it as live would print old percentages with "resets now". Samples without
180
+ * any reset time are never considered expired.
181
+ */
182
+ export declare function quotaSampleExpired(quota: QuotaState, nowMs?: number): boolean;
183
+ /**
184
+ * Human label for a window length: `5-Hour`, `Daily`, `Weekly`, `30-Day`, …
185
+ * Returns `fallback` when the length is unknown or not a whole number of hours.
186
+ */
187
+ export declare function quotaWindowLabel(windowMs: number | undefined, fallback: string): string;
188
+ /** Compact label for a window length: `5h`, `1d`, `7d`. Returns `fallback` when unknown. */
189
+ export declare function quotaWindowShortLabel(windowMs: number | undefined, fallback: string): string;
190
+ /**
191
+ * The reported meters that `fiveHour` and `sevenDay` do not already show —
192
+ * per-model or per-surface weekly caps and any future meter kind.
193
+ */
194
+ export declare function extraQuotaRows(quota: Pick<QuotaState, 'limits'>): QuotaLimitRow[];
195
+ /**
196
+ * Display name for a Claude subscription. The 20× tier was renamed Ultra and
197
+ * the 5× tier Max on 2026-10-30; credentials keep the old tier ids.
198
+ */
199
+ export declare function claudePlanLabel(plan: ClaudePlanInfo | null | undefined): string | undefined;
200
+ /**
201
+ * One-line extra-usage summary, e.g. `$12.40 of $200.00 used` or
202
+ * `$0.00 of $200.00 used · off (out of credits)`.
203
+ */
204
+ export declare function formatExtraUsage(extra: QuotaExtraUsage): string;
96
205
  /** Compact age label for status lines and table footers: `just now`, `3m ago`, `2h ago`, `3d ago`. */
97
206
  export declare function formatQuotaAge(ageMs: number | undefined): string;
98
207
  export interface QuotaProjectionInput {
@@ -112,6 +221,25 @@ export declare function withQuotaProjections<T extends QuotaState>(state: T, opt
112
221
  sevenDayWindowMs?: number;
113
222
  capturedAt?: string;
114
223
  }): T;
224
+ /**
225
+ * Normalize a Claude OAuth usage-endpoint body into a `QuotaState`.
226
+ *
227
+ * - `five_hour`/`seven_day` that are null or missing become `absent` windows
228
+ * (Ultra plans have no five-hour session limit), unless `limits[]` carries
229
+ * the matching `session`/`weekly_all` meter.
230
+ * - `limits[]` is kept verbatim as `limits` (with derived labels, window
231
+ * lengths, and projections); older servers' `seven_day_opus` /
232
+ * `seven_day_sonnet` / `seven_day_overage_included` fill it instead.
233
+ * - `extra_usage` becomes `extraUsage`.
234
+ *
235
+ * Bodies in the original two-window shape produce exactly the state they did
236
+ * before these fields existed.
237
+ */
238
+ export declare function quotaStateFromClaudeUsagePayload(payload: unknown, options?: {
239
+ capturedAt?: string;
240
+ }): QuotaState;
241
+ /** Stamp `planType` / `planLabel` from Claude credential plan facts (no-op without them). */
242
+ export declare function withClaudePlan<T extends QuotaState>(state: T, plan: ClaudePlanInfo | null | undefined): T;
115
243
  /**
116
244
  * Fetch current quota utilization from the Anthropic OAuth usage API.
117
245
  *
@@ -120,8 +248,10 @@ export declare function withQuotaProjections<T extends QuotaState>(state: T, opt
120
248
  *
121
249
  * @param accessToken - OAuth access token from `readClaudeMaxCredentials()`
122
250
  * @param options.fetchImpl - Fetch implementation (defaults to the global `fetch`; tests inject a stub)
251
+ * @param options.plan - Plan facts from the same credentials; stamps `planType` and `planLabel`
123
252
  * @returns QuotaState with utilization data and elapsed-time projections
124
253
  */
125
254
  export declare function fetchQuota(accessToken: string, options?: {
126
255
  fetchImpl?: typeof fetch;
256
+ plan?: ClaudePlanInfo | null;
127
257
  }): Promise<QuotaState>;