MCPcopy Create free account
hub / github.com/codeaashu/claude-code / getMockStatus

Function getMockStatus

src/services/mockRateLimits.ts:627–676  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

625}
626
627export function getMockStatus(): string {
628 if (
629 !mockEnabled ||
630 (Object.keys(mockHeaders).length === 0 && !mockSubscriptionType)
631 ) {
632 return 'No mock headers active (using real limits)'
633 }
634
635 const lines: string[] = []
636 lines.push('Active mock headers:')
637
638 // Show subscription type - either explicitly set or default
639 const effectiveSubscription =
640 mockSubscriptionType || DEFAULT_MOCK_SUBSCRIPTION
641 if (mockSubscriptionType) {
642 lines.push(` Subscription Type: ${mockSubscriptionType} (explicitly set)`)
643 } else {
644 lines.push(` Subscription Type: ${effectiveSubscription} (default)`)
645 }
646
647 Object.entries(mockHeaders).forEach(([key, value]) => {
648 if (value !== undefined) {
649 // Format the header name nicely
650 const formattedKey = key
651 .replace('anthropic-ratelimit-unified-', '')
652 .replace(/-/g, ' ')
653 .replace(/\b\w/g, c => c.toUpperCase())
654
655 // Format timestamps as human-readable
656 if (key.includes('reset') && value) {
657 const timestamp = Number(value)
658 const date = new Date(timestamp * 1000)
659 lines.push(` ${formattedKey}: ${value} (${date.toLocaleString()})`)
660 } else {
661 lines.push(` ${formattedKey}: ${value}`)
662 }
663 }
664 })
665
666 // Show exceeded limits if any
667 if (exceededLimits.length > 0) {
668 lines.push('\nExceeded limits (contributing to representative claim):')
669 exceededLimits.forEach(limit => {
670 const date = new Date(limit.resetsAt * 1000)
671 lines.push(` ${limit.type}: resets at ${date.toLocaleString()}`)
672 })
673 }
674
675 return lines.join('\n')
676}
677
678export function clearMockHeaders(): void {
679 mockHeaders = {}

Callers

nothing calls this directly

Calls 4

keysMethod · 0.80
forEachMethod · 0.80
entriesMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected