MCPcopy Create free account
hub / github.com/Noumena-Network/code / getMockStatus

Function getMockStatus

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

Source from the content-addressed store, hash-verified

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

Callers 3

callFunction · 0.85
callFunction · 0.85

Calls 2

keysMethod · 0.80
entriesMethod · 0.80

Tested by

no test coverage detected