MCPcopy
hub / github.com/codeaashu/claude-code / extractQuotaStatusFromHeaders

Function extractQuotaStatusFromHeaders

src/services/claudeAiLimits.ts:454–485  ·  view source on GitHub ↗
(
  headers: globalThis.Headers,
)

Source from the content-addressed store, hash-verified

452}
453
454export function extractQuotaStatusFromHeaders(
455 headers: globalThis.Headers,
456): void {
457 // Check if we need to process rate limits
458 const isSubscriber = isClaudeAISubscriber()
459
460 if (!shouldProcessRateLimits(isSubscriber)) {
461 // If we have any rate limit state, clear it
462 rawUtilization = {}
463 if (currentLimits.status !== 'allowed' || currentLimits.resetsAt) {
464 const defaultLimits: ClaudeAILimits = {
465 status: 'allowed',
466 unifiedRateLimitFallbackAvailable: false,
467 isUsingOverage: false,
468 }
469 emitStatusChange(defaultLimits)
470 }
471 return
472 }
473
474 // Process headers (applies mocks from /mock-limits command if active)
475 const headersToUse = processRateLimitHeaders(headers)
476 rawUtilization = extractRawUtilization(headersToUse)
477 const newLimits = computeNewLimitsFromHeaders(headersToUse)
478
479 // Cache extra usage status (persists across sessions)
480 cacheExtraUsageDisabledReason(headersToUse)
481
482 if (!isEqual(currentLimits, newLimits)) {
483 emitStatusChange(newLimits)
484 }
485}
486
487export function extractQuotaStatusFromError(error: APIError): void {
488 if (

Callers 2

checkQuotaStatusFunction · 0.85
queryModelFunction · 0.85

Calls 7

shouldProcessRateLimitsFunction · 0.85
emitStatusChangeFunction · 0.85
processRateLimitHeadersFunction · 0.85
extractRawUtilizationFunction · 0.85
isClaudeAISubscriberFunction · 0.50

Tested by

no test coverage detected