Files
orcs-code/src/utils/model/check1mAccess.ts
did:key:z6MkqDnb7Siv3Cwj7pGJq4T5EsUisECqR8KpnDLwcaZq5TPr d2542c9a62 asdf
Squash the current repository state back into one baseline commit while
preserving the README reframing and repository contents.

Constraint: User explicitly requested a single squashed commit with subject "asdf"
Confidence: high
Scope-risk: broad
Reversibility: clean
Directive: This commit intentionally rewrites published history; coordinate before future force-pushes
Tested: git status clean; local history rewritten to one commit; force-pushed main to origin and instructkr
Not-tested: Fresh clone verification after push
2026-03-31 03:34:03 -07:00

73 lines
2.2 KiB
TypeScript

import type { OverageDisabledReason } from 'src/services/claudeAiLimits.js'
import { isClaudeAISubscriber } from '../auth.js'
import { getGlobalConfig } from '../config.js'
import { is1mContextDisabled } from '../context.js'
/**
* Check if extra usage is enabled based on the cached disabled reason.
* Extra usage is considered enabled if there's no disabled reason,
* or if the disabled reason indicates it's provisioned but temporarily unavailable.
*/
function isExtraUsageEnabled(): boolean {
const reason = getGlobalConfig().cachedExtraUsageDisabledReason
// undefined = no cache yet, treat as not enabled (conservative)
if (reason === undefined) {
return false
}
// null = no disabled reason from API, extra usage is enabled
if (reason === null) {
return true
}
// Check which disabled reasons still mean "provisioned"
switch (reason as OverageDisabledReason) {
// Provisioned but credits depleted — still counts as enabled
case 'out_of_credits':
return true
// Not provisioned or actively disabled
case 'overage_not_provisioned':
case 'org_level_disabled':
case 'org_level_disabled_until':
case 'seat_tier_level_disabled':
case 'member_level_disabled':
case 'seat_tier_zero_credit_limit':
case 'group_zero_credit_limit':
case 'member_zero_credit_limit':
case 'org_service_level_disabled':
case 'org_service_zero_credit_limit':
case 'no_limits_configured':
case 'unknown':
return false
default:
return false
}
}
// @[MODEL LAUNCH]: Add check if the new model supports 1M context
export function checkOpus1mAccess(): boolean {
if (is1mContextDisabled()) {
return false
}
if (isClaudeAISubscriber()) {
// Subscribers have access if extra usage is enabled for their account
return isExtraUsageEnabled()
}
// Non-subscribers (API/PAYG) have access
return true
}
export function checkSonnet1mAccess(): boolean {
if (is1mContextDisabled()) {
return false
}
if (isClaudeAISubscriber()) {
// Subscribers have access if extra usage is enabled for their account
return isExtraUsageEnabled()
}
// Non-subscribers (API/PAYG) have access
return true
}