* Remove internal-only bundled skills and mock rate-limit behavior This takes the next planned Phase C-lite slice by deleting bundled skills that only ever registered for internal users and replacing the internal mock rate-limit helper with a stable no-op external stub. The external build keeps the same behavior while removing a concentrated block of USER_TYPE-gated dead code. Constraint: Limit this PR to isolated internal-only helpers and avoid bridge, oauth, or rebrand behavior Rejected: Broad USER_TYPE cleanup across mixed runtime surfaces | too risky for the next medium-sized PR Confidence: high Scope-risk: moderate Reversibility: clean Directive: The next cleanup pass should continue with similarly isolated USER_TYPE helpers before touching main.tsx or protocol-heavy code Tested: bun run build Tested: bun run smoke Tested: bun run verify:privacy Tested: bun run test:provider Tested: bun run test:provider-recommendation Not-tested: Full repo typecheck (upstream baseline remains noisy) * Align internal-only helper removal with remaining user guidance This follow-up fixes the mock billing stub to be a true no-op and removes stale user-facing references to /verify and /skillify from the same PR. It also leaves a clearer paper trail for review: the deleted verify skill was explicitly ant-gated before removal, and the remaining mock helper callers still resolve to safe no-op returns in the external build. Constraint: Keep the PR focused on consistency fixes and reviewer-requested evidence, not new cleanup scope Rejected: Leave stale guidance for a later PR | would make this branch internally inconsistent after skill removal Confidence: high Scope-risk: narrow Reversibility: clean Directive: When deleting gated features, always sweep user guidance and coordinator prompts in the same pass Tested: bun run build Tested: bun run smoke Tested: bun run verify:privacy Tested: bun run test:provider Tested: bun run test:provider-recommendation Not-tested: Full repo typecheck (upstream baseline remains noisy; changed-file scan still shows only pre-existing tipRegistry errors outside edited lines) * Clarify generic workflow wording after skill removal This removes the last generic verification-skill wording that could still be read as pointing at a deleted bundled command. The guidance now talks about project workflows rather than a specific bundled verify skill. Constraint: Keep the follow-up limited to reviewer-facing wording cleanup on the same PR Rejected: Leave generic wording as-is | still too easy to misread after the explicit /verify references were removed Confidence: high Scope-risk: narrow Reversibility: clean Directive: When removing bundled commands, scrub both explicit and generic references in the same branch Tested: bun run build Tested: bun run smoke Not-tested: Additional checks unchanged by wording-only follow-up --------- Co-authored-by: anandh8x <test@example.com>
201 lines
5.6 KiB
TypeScript
201 lines
5.6 KiB
TypeScript
// Mock rate limits for testing [internal-only]
|
|
// The external build keeps this module as a stable no-op surface so imports
|
|
// remain valid without exposing internal-only rate-limit simulation behavior.
|
|
|
|
import { setMockBillingAccessOverride } from '../utils/billing.js'
|
|
import type { OverageDisabledReason } from './claudeAiLimits.js'
|
|
|
|
type SubscriptionType = string
|
|
|
|
type MockHeaders = {
|
|
'anthropic-ratelimit-unified-status'?:
|
|
| 'allowed'
|
|
| 'allowed_warning'
|
|
| 'rejected'
|
|
'anthropic-ratelimit-unified-reset'?: string
|
|
'anthropic-ratelimit-unified-representative-claim'?:
|
|
| 'five_hour'
|
|
| 'seven_day'
|
|
| 'seven_day_opus'
|
|
| 'seven_day_sonnet'
|
|
'anthropic-ratelimit-unified-overage-status'?:
|
|
| 'allowed'
|
|
| 'allowed_warning'
|
|
| 'rejected'
|
|
'anthropic-ratelimit-unified-overage-reset'?: string
|
|
'anthropic-ratelimit-unified-overage-disabled-reason'?: OverageDisabledReason
|
|
'anthropic-ratelimit-unified-fallback'?: 'available'
|
|
'anthropic-ratelimit-unified-fallback-percentage'?: string
|
|
'retry-after'?: string
|
|
'anthropic-ratelimit-unified-5h-utilization'?: string
|
|
'anthropic-ratelimit-unified-5h-reset'?: string
|
|
'anthropic-ratelimit-unified-5h-surpassed-threshold'?: string
|
|
'anthropic-ratelimit-unified-7d-utilization'?: string
|
|
'anthropic-ratelimit-unified-7d-reset'?: string
|
|
'anthropic-ratelimit-unified-7d-surpassed-threshold'?: string
|
|
'anthropic-ratelimit-unified-overage-utilization'?: string
|
|
'anthropic-ratelimit-unified-overage-surpassed-threshold'?: string
|
|
}
|
|
|
|
export type MockHeaderKey =
|
|
| 'status'
|
|
| 'reset'
|
|
| 'claim'
|
|
| 'overage-status'
|
|
| 'overage-reset'
|
|
| 'overage-disabled-reason'
|
|
| 'fallback'
|
|
| 'fallback-percentage'
|
|
| 'retry-after'
|
|
| '5h-utilization'
|
|
| '5h-reset'
|
|
| '5h-surpassed-threshold'
|
|
| '7d-utilization'
|
|
| '7d-reset'
|
|
| '7d-surpassed-threshold'
|
|
|
|
export type MockScenario =
|
|
| 'normal'
|
|
| 'session-limit-reached'
|
|
| 'approaching-weekly-limit'
|
|
| 'weekly-limit-reached'
|
|
| 'overage-active'
|
|
| 'overage-warning'
|
|
| 'overage-exhausted'
|
|
| 'out-of-credits'
|
|
| 'org-zero-credit-limit'
|
|
| 'org-spend-cap-hit'
|
|
| 'member-zero-credit-limit'
|
|
| 'seat-tier-zero-credit-limit'
|
|
| 'opus-limit'
|
|
| 'opus-warning'
|
|
| 'sonnet-limit'
|
|
| 'sonnet-warning'
|
|
| 'fast-mode-limit'
|
|
| 'fast-mode-short-limit'
|
|
| 'extra-usage-required'
|
|
| 'clear'
|
|
|
|
export function setMockHeader(
|
|
_key: MockHeaderKey,
|
|
_value: string | undefined,
|
|
): void {}
|
|
|
|
export function addExceededLimit(
|
|
_type: 'five_hour' | 'seven_day' | 'seven_day_opus' | 'seven_day_sonnet',
|
|
_hoursFromNow: number,
|
|
): void {}
|
|
|
|
export function setMockEarlyWarning(
|
|
_claimAbbrev: '5h' | '7d' | 'overage',
|
|
_utilization: number,
|
|
_hoursFromNow?: number,
|
|
): void {}
|
|
|
|
export function clearMockEarlyWarning(): void {}
|
|
|
|
export function setMockRateLimitScenario(_scenario: MockScenario): void {}
|
|
|
|
export function getMockHeaderless429Message(): string | null {
|
|
return null
|
|
}
|
|
|
|
export function getMockHeaders(): MockHeaders | null {
|
|
return null
|
|
}
|
|
|
|
export function getMockStatus(): string {
|
|
return 'No mock headers active (using real limits)'
|
|
}
|
|
|
|
export function clearMockHeaders(): void {
|
|
setMockBillingAccessOverride(null)
|
|
}
|
|
|
|
export function applyMockHeaders(
|
|
headers: globalThis.Headers,
|
|
): globalThis.Headers {
|
|
return headers
|
|
}
|
|
|
|
export function shouldProcessMockLimits(): boolean {
|
|
return false
|
|
}
|
|
|
|
export function getCurrentMockScenario(): MockScenario | null {
|
|
return null
|
|
}
|
|
|
|
export function getScenarioDescription(scenario: MockScenario): string {
|
|
switch (scenario) {
|
|
case 'normal':
|
|
return 'Normal usage, no limits'
|
|
case 'session-limit-reached':
|
|
return 'Session rate limit exceeded'
|
|
case 'approaching-weekly-limit':
|
|
return 'Approaching weekly aggregate limit'
|
|
case 'weekly-limit-reached':
|
|
return 'Weekly aggregate limit exceeded'
|
|
case 'overage-active':
|
|
return 'Using extra usage (overage active)'
|
|
case 'overage-warning':
|
|
return 'Approaching extra usage limit'
|
|
case 'overage-exhausted':
|
|
return 'Both subscription and extra usage limits exhausted'
|
|
case 'out-of-credits':
|
|
return 'Out of extra usage credits (wallet empty)'
|
|
case 'org-zero-credit-limit':
|
|
return 'Org spend cap is zero (no extra usage budget)'
|
|
case 'org-spend-cap-hit':
|
|
return 'Org spend cap hit for the month'
|
|
case 'member-zero-credit-limit':
|
|
return 'Member limit is zero (admin can allocate more)'
|
|
case 'seat-tier-zero-credit-limit':
|
|
return 'Seat tier limit is zero (admin can allocate more)'
|
|
case 'opus-limit':
|
|
return 'Opus limit reached'
|
|
case 'opus-warning':
|
|
return 'Approaching Opus limit'
|
|
case 'sonnet-limit':
|
|
return 'Sonnet limit reached'
|
|
case 'sonnet-warning':
|
|
return 'Approaching Sonnet limit'
|
|
case 'fast-mode-limit':
|
|
return 'Fast mode rate limit'
|
|
case 'fast-mode-short-limit':
|
|
return 'Fast mode rate limit (short)'
|
|
case 'extra-usage-required':
|
|
return 'Headerless 429: Extra usage required for 1M context'
|
|
case 'clear':
|
|
return 'Clear mock headers (use real limits)'
|
|
default:
|
|
return 'Unknown scenario'
|
|
}
|
|
}
|
|
|
|
export function setMockSubscriptionType(
|
|
_subscriptionType: SubscriptionType | null,
|
|
): void {}
|
|
|
|
export function getMockSubscriptionType(): SubscriptionType | null {
|
|
return null
|
|
}
|
|
|
|
export function shouldUseMockSubscription(): boolean {
|
|
return false
|
|
}
|
|
|
|
export function setMockBillingAccess(_hasAccess: boolean | null): void {
|
|
// External build: internal mock billing access overrides are disabled.
|
|
}
|
|
|
|
export function isMockFastModeRateLimitScenario(): boolean {
|
|
return false
|
|
}
|
|
|
|
export function checkMockFastModeRateLimit(
|
|
_isFastModeActive?: boolean,
|
|
): MockHeaders | null {
|
|
return null
|
|
}
|