forked from sanbuphy/learn-coding-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck1mAccess.ts
More file actions
72 lines (65 loc) · 2.16 KB
/
check1mAccess.ts
File metadata and controls
72 lines (65 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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
}