@cortexkit/anthropic-auth-core 1.22.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/accounts.d.ts +52 -8
- package/dist/cachekeep.d.ts +27 -1
- package/dist/cch.d.ts +11 -1
- package/dist/claude-code.d.ts +23 -1
- package/dist/claustrum-enrollment.d.ts +72 -0
- package/dist/claustrum-scoped-roster.d.ts +27 -0
- package/dist/claustrum-scoped-runtime.d.ts +31 -0
- package/dist/claustrum-scoped.d.ts +53 -0
- package/dist/claustrum.d.ts +16 -82
- package/dist/commands/account.d.ts +38 -11
- package/dist/constants.d.ts +3 -2
- package/dist/custom-headers.d.ts +3 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.js +29700 -31
- package/dist/internal-types/LICENSE +21 -0
- package/dist/internal-types/commands/builtins.d.ts +71 -0
- package/dist/internal-types/commands/index.d.ts +10 -0
- package/dist/internal-types/commands/menu.d.ts +61 -0
- package/dist/internal-types/commands/model.d.ts +238 -0
- package/dist/internal-types/commands/pi.d.ts +23 -0
- package/dist/internal-types/commands/seam.d.ts +72 -0
- package/dist/internal-types/fs/refresh-file-lock.d.ts +33 -0
- package/dist/internal-types/logger/capture-sink.d.ts +14 -0
- package/dist/internal-types/logger/engine.d.ts +100 -0
- package/dist/internal-types/logger/index.d.ts +6 -0
- package/dist/internal-types/logger/redact.d.ts +11 -0
- package/dist/internal-types/pi-slot/index.d.ts +3 -0
- package/dist/internal-types/pi-slot/slot.d.ts +49 -0
- package/dist/internal-types/quota/codec.d.ts +11 -0
- package/dist/internal-types/quota/format.d.ts +46 -0
- package/dist/internal-types/quota/index.d.ts +10 -0
- package/dist/internal-types/quota/map.d.ts +63 -0
- package/dist/internal-types/quota/merge.d.ts +48 -0
- package/dist/internal-types/quota/projection.d.ts +64 -0
- package/dist/internal-types/store/attribution.d.ts +28 -0
- package/dist/internal-types/store/errors.d.ts +55 -0
- package/dist/internal-types/store/hooks.d.ts +12 -0
- package/dist/internal-types/store/identity.d.ts +39 -0
- package/dist/internal-types/store/index.d.ts +21 -0
- package/dist/internal-types/store/mutate.d.ts +189 -0
- package/dist/internal-types/store/pool.d.ts +196 -0
- package/dist/internal-types/store/provider-state.d.ts +131 -0
- package/dist/internal-types/store/publication.d.ts +47 -0
- package/dist/internal-types/store/pull.d.ts +36 -0
- package/dist/internal-types/store/refresh-lock.d.ts +63 -0
- package/dist/internal-types/store/refresh.d.ts +72 -0
- package/dist/internal-types/store/rows.d.ts +313 -0
- package/dist/internal-types/store/runtime.d.ts +36 -0
- package/dist/internal-types/store/schema.d.ts +443 -0
- package/dist/internal-types/store/settings.d.ts +63 -0
- package/dist/internal-types/store/torn.d.ts +78 -0
- package/dist/migration-source.d.ts +33 -0
- package/dist/model-remap.d.ts +27 -0
- package/dist/models.d.ts +60 -0
- package/dist/native-account-runtime.d.ts +121 -0
- package/dist/native-account-view.d.ts +126 -0
- package/dist/native-command-effects.d.ts +59 -0
- package/dist/native-credential-validation.d.ts +42 -0
- package/dist/native-custody-activation.d.ts +45 -0
- package/dist/native-custody.d.ts +114 -0
- package/dist/native-enrollment-authority.d.ts +2 -0
- package/dist/native-host-auth-read.d.ts +3 -0
- package/dist/native-host-auth-write.d.ts +51 -0
- package/dist/native-host-auth.d.ts +12 -0
- package/dist/native-local-credential-service.d.ts +76 -0
- package/dist/native-local-runtime-readers.d.ts +22 -0
- package/dist/native-lock-observer.d.ts +12 -0
- package/dist/native-menu-executor.d.ts +243 -0
- package/dist/native-menu-model.d.ts +142 -0
- package/dist/native-migration-proof.d.ts +28 -0
- package/dist/native-migration-source.d.ts +47 -0
- package/dist/native-migration.d.ts +66 -0
- package/dist/native-quota-codec.d.ts +32 -0
- package/dist/native-refresh-coordinator.d.ts +240 -0
- package/dist/native-roster-seed.d.ts +115 -0
- package/dist/native-runtime-registry.d.ts +19 -0
- package/dist/native-runtime.d.ts +204 -0
- package/dist/native-transient-account.d.ts +38 -0
- package/dist/native-ui.d.ts +45 -0
- package/dist/native-usage-publication.d.ts +11 -0
- package/dist/native-vault-admission.d.ts +8 -0
- package/dist/native-vault-connection.d.ts +33 -0
- package/dist/native-vault-paths.d.ts +13 -0
- package/dist/native-vault-runtime.d.ts +102 -0
- package/dist/native-vault-seed.d.ts +16 -0
- package/dist/oauth-profile.d.ts +2 -1
- package/dist/pool-authority.d.ts +159 -0
- package/dist/pool-binding.d.ts +32 -0
- package/dist/pool-paths.d.ts +21 -0
- package/dist/pool-store.d.ts +32 -0
- package/dist/prime.d.ts +11 -3
- package/dist/provider-error.d.ts +139 -0
- package/dist/quota-header-feed.d.ts +13 -0
- package/dist/quota-manager.d.ts +30 -5
- package/dist/relay.d.ts +22 -1
- package/dist/request-history.d.ts +34 -0
- package/dist/sse.d.ts +81 -0
- package/dist/sticky-routing.d.ts +29 -0
- package/package.json +9 -3
- package/dist/accounts.js +0 -3330
- package/dist/auth.js +0 -182
- package/dist/cache1h.js +0 -97
- package/dist/cachekeep-registry.js +0 -124
- package/dist/cachekeep.js +0 -578
- package/dist/cch.js +0 -127
- package/dist/claude-code.js +0 -388
- package/dist/claustrum.js +0 -529
- package/dist/commands/account.js +0 -239
- package/dist/constants.js +0 -82
- package/dist/dump.js +0 -616
- package/dist/fast.js +0 -66
- package/dist/json.js +0 -10
- package/dist/killswitch.js +0 -132
- package/dist/logger.js +0 -286
- package/dist/logging.js +0 -59
- package/dist/mid-conversation-output-config.js +0 -89
- package/dist/models.js +0 -141
- package/dist/network-errors.js +0 -27
- package/dist/oauth-profile.js +0 -54
- package/dist/pkce.js +0 -17
- package/dist/prime.js +0 -823
- package/dist/provider.js +0 -0
- package/dist/quota-header-feed.js +0 -279
- package/dist/quota-headers.js +0 -121
- package/dist/quota-manager.js +0 -805
- package/dist/quotas.js +0 -141
- package/dist/relay.js +0 -1243
- package/dist/routing.js +0 -94
- package/dist/start.js +0 -29
- package/dist/sticky-routing.js +0 -523
- package/dist/thinking-binding.js +0 -54
- package/dist/token-fingerprint.js +0 -8
package/dist/models.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
export const CLAUDE_FABLE_5_MODEL_ID = 'claude-fable-5';
|
|
2
|
-
export const CLAUDE_MYTHOS_5_MODEL_ID = 'claude-mythos-5';
|
|
3
|
-
export const CLAUDE_FABLE_5_1_MODEL_ID = 'claude-fable-5-1';
|
|
4
|
-
export const CLAUDE_MYTHOS_5_1_MODEL_ID = 'claude-mythos-5-1';
|
|
5
|
-
/**
|
|
6
|
-
* Haiku 4.5 model identifier used by `/claude-prime` to start each OAuth
|
|
7
|
-
* account's five-hour quota window with a minimal request. Usage is measured
|
|
8
|
-
* from response accounting. Kept distinct from the Fable/Mythos pricing block
|
|
9
|
-
* above so per-million-token cost estimation does not conflate families.
|
|
10
|
-
*/
|
|
11
|
-
export const CLAUDE_HAIKU_4_5_MODEL_ID = 'claude-haiku-4-5';
|
|
12
|
-
/**
|
|
13
|
-
* Per-million-token USD pricing for Haiku 4.5. Used to project the cumulative
|
|
14
|
-
* cost of prime requests from persisted usage counters — never persisted on
|
|
15
|
-
* disk; derive at display time so future pricing revisions land in one place.
|
|
16
|
-
*/
|
|
17
|
-
export const CLAUDE_HAIKU_4_5_PRICING = {
|
|
18
|
-
input: 1,
|
|
19
|
-
output: 5,
|
|
20
|
-
};
|
|
21
|
-
export const CLAUDE_FABLE_MYTHOS_5_1_MODEL_IDS = [
|
|
22
|
-
CLAUDE_FABLE_5_1_MODEL_ID,
|
|
23
|
-
CLAUDE_MYTHOS_5_1_MODEL_ID,
|
|
24
|
-
];
|
|
25
|
-
export const CLAUDE_FABLE_MYTHOS_5_MODEL_IDS = [
|
|
26
|
-
CLAUDE_FABLE_5_MODEL_ID,
|
|
27
|
-
CLAUDE_MYTHOS_5_MODEL_ID,
|
|
28
|
-
...CLAUDE_FABLE_MYTHOS_5_1_MODEL_IDS,
|
|
29
|
-
];
|
|
30
|
-
export const CLAUDE_FABLE_MYTHOS_5_SUMMARIZED_THINKING = {
|
|
31
|
-
type: 'adaptive',
|
|
32
|
-
display: 'summarized',
|
|
33
|
-
};
|
|
34
|
-
export const CLAUDE_FABLE_MYTHOS_5_PRICING = {
|
|
35
|
-
input: 10,
|
|
36
|
-
output: 50,
|
|
37
|
-
cacheRead: 1,
|
|
38
|
-
cacheWrite5m: 12.5,
|
|
39
|
-
cacheWrite1h: 20,
|
|
40
|
-
};
|
|
41
|
-
export const CLAUDE_FABLE_MYTHOS_5_1_PRICING = {
|
|
42
|
-
input: 10,
|
|
43
|
-
output: 50,
|
|
44
|
-
cacheRead: 0.25,
|
|
45
|
-
cacheWrite5m: 12.5,
|
|
46
|
-
cacheWrite1h: 20,
|
|
47
|
-
};
|
|
48
|
-
export const CLAUDE_FABLE_MYTHOS_5_CONTEXT_WINDOW = 1_000_000;
|
|
49
|
-
export const CLAUDE_FABLE_MYTHOS_5_MAX_OUTPUT_TOKENS = 128_000;
|
|
50
|
-
export const CLAUDE_FABLE_MYTHOS_5_RELEASE_DATE = '2026-06-09';
|
|
51
|
-
export const CLAUDE_FABLE_MYTHOS_5_1_RELEASE_DATE = '2026-09-01';
|
|
52
|
-
export const CLAUDE_FABLE_MYTHOS_5_MODEL_SPECS = {
|
|
53
|
-
[CLAUDE_FABLE_5_MODEL_ID]: {
|
|
54
|
-
id: CLAUDE_FABLE_5_MODEL_ID,
|
|
55
|
-
name: 'Claude Fable 5',
|
|
56
|
-
},
|
|
57
|
-
[CLAUDE_MYTHOS_5_MODEL_ID]: {
|
|
58
|
-
id: CLAUDE_MYTHOS_5_MODEL_ID,
|
|
59
|
-
name: 'Claude Mythos 5',
|
|
60
|
-
limited: true,
|
|
61
|
-
},
|
|
62
|
-
[CLAUDE_FABLE_5_1_MODEL_ID]: {
|
|
63
|
-
id: CLAUDE_FABLE_5_1_MODEL_ID,
|
|
64
|
-
name: 'Claude Fable 5.1',
|
|
65
|
-
},
|
|
66
|
-
[CLAUDE_MYTHOS_5_1_MODEL_ID]: {
|
|
67
|
-
id: CLAUDE_MYTHOS_5_1_MODEL_ID,
|
|
68
|
-
name: 'Claude Mythos 5.1',
|
|
69
|
-
limited: true,
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
export const CLAUDE_FABLE_MYTHOS_5_1_MODEL_SPECS = {
|
|
73
|
-
[CLAUDE_FABLE_5_1_MODEL_ID]: CLAUDE_FABLE_MYTHOS_5_MODEL_SPECS[CLAUDE_FABLE_5_1_MODEL_ID],
|
|
74
|
-
[CLAUDE_MYTHOS_5_1_MODEL_ID]: CLAUDE_FABLE_MYTHOS_5_MODEL_SPECS[CLAUDE_MYTHOS_5_1_MODEL_ID],
|
|
75
|
-
};
|
|
76
|
-
export function isClaudeFableOrMythos5Model(model) {
|
|
77
|
-
return (typeof model === 'string' &&
|
|
78
|
-
CLAUDE_FABLE_MYTHOS_5_MODEL_IDS.some((id) => model === id || model.startsWith(`${id}-`)));
|
|
79
|
-
}
|
|
80
|
-
export function isClaudeFableOrMythos51Model(model) {
|
|
81
|
-
return (typeof model === 'string' &&
|
|
82
|
-
CLAUDE_FABLE_MYTHOS_5_1_MODEL_IDS.some((id) => model === id || model.startsWith(`${id}-`)));
|
|
83
|
-
}
|
|
84
|
-
export function isClaudeFable51Model(model) {
|
|
85
|
-
if (typeof model !== 'string')
|
|
86
|
-
return false;
|
|
87
|
-
return (model === CLAUDE_FABLE_5_1_MODEL_ID ||
|
|
88
|
-
model.startsWith(`${CLAUDE_FABLE_5_1_MODEL_ID}-`));
|
|
89
|
-
}
|
|
90
|
-
export function getClaudeFableMythos5ReleaseDate(model) {
|
|
91
|
-
return isClaudeFableOrMythos51Model(model)
|
|
92
|
-
? CLAUDE_FABLE_MYTHOS_5_1_RELEASE_DATE
|
|
93
|
-
: CLAUDE_FABLE_MYTHOS_5_RELEASE_DATE;
|
|
94
|
-
}
|
|
95
|
-
export const CLAUDE_SONNET_5_MODEL_ID = 'claude-sonnet-5';
|
|
96
|
-
/**
|
|
97
|
-
* Sonnet 5 enables adaptive thinking by default but ships `display: "omitted"`,
|
|
98
|
-
* so the `thinking` field returns empty and the user sees nothing. Injecting
|
|
99
|
-
* this makes the adaptive thinking summary visible. Reuses the Fable/Mythos
|
|
100
|
-
* shape because the API contract is identical.
|
|
101
|
-
*/
|
|
102
|
-
export const CLAUDE_SONNET_5_ADAPTIVE_THINKING = CLAUDE_FABLE_MYTHOS_5_SUMMARIZED_THINKING;
|
|
103
|
-
export function isClaudeSonnet5Model(model) {
|
|
104
|
-
return (typeof model === 'string' &&
|
|
105
|
-
(model === CLAUDE_SONNET_5_MODEL_ID ||
|
|
106
|
-
model.startsWith(`${CLAUDE_SONNET_5_MODEL_ID}-`)));
|
|
107
|
-
}
|
|
108
|
-
export const CLAUDE_OPUS_5_MODEL_ID = 'claude-opus-5';
|
|
109
|
-
/**
|
|
110
|
-
* Opus 5 has the same adaptive-thinking-by-default + `display: "omitted"`
|
|
111
|
-
* shape as Sonnet 5, so the injected thinking must also be summarized to be
|
|
112
|
-
* visible. Kept as its own constant per the PR #100 lesson — hook callers
|
|
113
|
-
* should reference the per-family name (`CLAUDE_OPUS_5_ADAPTIVE_THINKING`,
|
|
114
|
-
* not the Fable/Mythos alias) so a future divergence between the families
|
|
115
|
-
* only changes this re-export, not every call site.
|
|
116
|
-
*/
|
|
117
|
-
export const CLAUDE_OPUS_5_ADAPTIVE_THINKING = CLAUDE_FABLE_MYTHOS_5_SUMMARIZED_THINKING;
|
|
118
|
-
export function isClaudeOpus5Model(model) {
|
|
119
|
-
return (typeof model === 'string' &&
|
|
120
|
-
(model === CLAUDE_OPUS_5_MODEL_ID ||
|
|
121
|
-
model.startsWith(`${CLAUDE_OPUS_5_MODEL_ID}-`)));
|
|
122
|
-
}
|
|
123
|
-
export function isOpenAIReasoningSignature(value) {
|
|
124
|
-
if (typeof value !== 'string')
|
|
125
|
-
return false;
|
|
126
|
-
if (value.startsWith('gAAAA'))
|
|
127
|
-
return true;
|
|
128
|
-
if (!value.startsWith('{'))
|
|
129
|
-
return false;
|
|
130
|
-
try {
|
|
131
|
-
const parsed = JSON.parse(value);
|
|
132
|
-
return (parsed.type === 'reasoning' &&
|
|
133
|
-
typeof parsed.id === 'string' &&
|
|
134
|
-
parsed.id.startsWith('rs_') &&
|
|
135
|
-
typeof parsed.encrypted_content === 'string' &&
|
|
136
|
-
parsed.encrypted_content.startsWith('gAAAA'));
|
|
137
|
-
}
|
|
138
|
-
catch {
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
}
|
package/dist/network-errors.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
const TRANSIENT_NETWORK_ERROR_CODES = new Set([
|
|
2
|
-
'EAI_AGAIN',
|
|
3
|
-
'ECONNREFUSED',
|
|
4
|
-
'ECONNRESET',
|
|
5
|
-
'EHOSTUNREACH',
|
|
6
|
-
'ENETUNREACH',
|
|
7
|
-
'ENOTFOUND',
|
|
8
|
-
'ETIMEDOUT',
|
|
9
|
-
'UND_ERR_CONNECT_TIMEOUT',
|
|
10
|
-
]);
|
|
11
|
-
function errorField(error, field) {
|
|
12
|
-
if (!error || typeof error !== 'object')
|
|
13
|
-
return undefined;
|
|
14
|
-
const value = error[field];
|
|
15
|
-
return typeof value === 'string' ? value : undefined;
|
|
16
|
-
}
|
|
17
|
-
export function isTransientNetworkError(error) {
|
|
18
|
-
const code = errorField(error, 'code');
|
|
19
|
-
if (code && TRANSIENT_NETWORK_ERROR_CODES.has(code))
|
|
20
|
-
return true;
|
|
21
|
-
const message = error instanceof Error
|
|
22
|
-
? error.message
|
|
23
|
-
: (errorField(error, 'message') ?? String(error));
|
|
24
|
-
if (message.includes('fetch failed'))
|
|
25
|
-
return true;
|
|
26
|
-
return [...TRANSIENT_NETWORK_ERROR_CODES].some((candidate) => message.includes(candidate));
|
|
27
|
-
}
|
package/dist/oauth-profile.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
const PROFILE_URL = 'https://api.anthropic.com/api/oauth/profile';
|
|
2
|
-
export const PROFILE_TTL_MS = 7 * 24 * 60 * 60 * 1000;
|
|
3
|
-
export async function fetchOAuthAccountProfile(input) {
|
|
4
|
-
const response = await (input.fetchImpl ?? fetch)(PROFILE_URL, {
|
|
5
|
-
method: 'GET',
|
|
6
|
-
signal: input.signal,
|
|
7
|
-
headers: {
|
|
8
|
-
Authorization: `Bearer ${input.accessToken}`,
|
|
9
|
-
Accept: 'application/json',
|
|
10
|
-
'anthropic-beta': 'oauth-2025-04-20',
|
|
11
|
-
},
|
|
12
|
-
});
|
|
13
|
-
if (!response.ok) {
|
|
14
|
-
throw new Error(`Claude profile check failed: ${response.status}`);
|
|
15
|
-
}
|
|
16
|
-
const value = (await response.json());
|
|
17
|
-
const tier = value.organization?.rate_limit_tier;
|
|
18
|
-
const orgType = value.organization?.organization_type;
|
|
19
|
-
if (typeof tier !== 'string' ||
|
|
20
|
-
tier.trim() === '' ||
|
|
21
|
-
typeof orgType !== 'string' ||
|
|
22
|
-
orgType.trim() === '') {
|
|
23
|
-
throw new Error('Claude profile response is missing account metadata');
|
|
24
|
-
}
|
|
25
|
-
return {
|
|
26
|
-
tier,
|
|
27
|
-
orgType,
|
|
28
|
-
checkedAt: input.now?.() ?? Date.now(),
|
|
29
|
-
...(input.accountIdentity !== undefined && {
|
|
30
|
-
accountIdentity: input.accountIdentity,
|
|
31
|
-
}),
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
export function oauthProfileMatchesIdentity(profile, accountIdentity) {
|
|
35
|
-
if (!profile)
|
|
36
|
-
return false;
|
|
37
|
-
if (accountIdentity === undefined)
|
|
38
|
-
return true;
|
|
39
|
-
return (profile.accountIdentity === undefined ||
|
|
40
|
-
profile.accountIdentity === accountIdentity);
|
|
41
|
-
}
|
|
42
|
-
export function oauthProfileIsFresh(profile, now = Date.now()) {
|
|
43
|
-
return Boolean(profile &&
|
|
44
|
-
Number.isFinite(profile.checkedAt) &&
|
|
45
|
-
now >= profile.checkedAt &&
|
|
46
|
-
now - profile.checkedAt < PROFILE_TTL_MS);
|
|
47
|
-
}
|
|
48
|
-
export function formatOAuthAccountTier(profile) {
|
|
49
|
-
const match = profile?.tier.match(/^default_claude_max_(\d+)x$/);
|
|
50
|
-
if (!match)
|
|
51
|
-
return undefined;
|
|
52
|
-
const label = `Max ${match[1]}x`;
|
|
53
|
-
return profile?.orgType === 'claude_team' ? `Team · ${label}` : label;
|
|
54
|
-
}
|
package/dist/pkce.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
function base64UrlEncode(bytes) {
|
|
2
|
-
let bin = '';
|
|
3
|
-
for (const byte of bytes)
|
|
4
|
-
bin += String.fromCharCode(byte);
|
|
5
|
-
return btoa(bin).replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
|
|
6
|
-
}
|
|
7
|
-
export async function generatePKCE() {
|
|
8
|
-
const buf = new Uint8Array(64);
|
|
9
|
-
crypto.getRandomValues(buf);
|
|
10
|
-
const verifier = base64UrlEncode(buf);
|
|
11
|
-
const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(verifier));
|
|
12
|
-
return {
|
|
13
|
-
verifier,
|
|
14
|
-
challenge: base64UrlEncode(new Uint8Array(digest)),
|
|
15
|
-
method: 'S256',
|
|
16
|
-
};
|
|
17
|
-
}
|