@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/quotas.js
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { isOAuthAccount } from './accounts.js';
|
|
2
|
-
import { formatOAuthAccountTier } from './oauth-profile.js';
|
|
3
|
-
export const CLAUDE_QUOTAS_COMMAND_NAME = 'claude-quota';
|
|
4
|
-
const WINDOW_LABELS = {
|
|
5
|
-
five_hour: '5h',
|
|
6
|
-
seven_day: '1w',
|
|
7
|
-
};
|
|
8
|
-
function formatPercent(value) {
|
|
9
|
-
return `${Math.round(value * 10) / 10}%`;
|
|
10
|
-
}
|
|
11
|
-
function formatAge(checkedAt, now) {
|
|
12
|
-
const elapsedMs = Math.max(0, now - checkedAt);
|
|
13
|
-
const minutes = Math.floor(elapsedMs / 60_000);
|
|
14
|
-
if (minutes < 1)
|
|
15
|
-
return 'just now';
|
|
16
|
-
if (minutes === 1)
|
|
17
|
-
return '1m ago';
|
|
18
|
-
if (minutes < 60)
|
|
19
|
-
return `${minutes}m ago`;
|
|
20
|
-
const hours = Math.floor(minutes / 60);
|
|
21
|
-
const remainder = minutes % 60;
|
|
22
|
-
if (remainder === 0)
|
|
23
|
-
return `${hours}h ago`;
|
|
24
|
-
return `${hours}h ${remainder}m ago`;
|
|
25
|
-
}
|
|
26
|
-
function formatResetDuration(resetsAt, now) {
|
|
27
|
-
const resetTime = Date.parse(resetsAt);
|
|
28
|
-
if (!Number.isFinite(resetTime))
|
|
29
|
-
return resetsAt;
|
|
30
|
-
const remainingMs = resetTime - now;
|
|
31
|
-
if (remainingMs <= 0)
|
|
32
|
-
return 'now';
|
|
33
|
-
const totalMinutes = Math.max(1, Math.ceil(remainingMs / 60_000));
|
|
34
|
-
if (totalMinutes < 60)
|
|
35
|
-
return `in ${totalMinutes}m`;
|
|
36
|
-
const hours = Math.floor(totalMinutes / 60);
|
|
37
|
-
const minutes = totalMinutes % 60;
|
|
38
|
-
if (minutes === 0)
|
|
39
|
-
return `in ${hours}h`;
|
|
40
|
-
return `in ${hours}h ${minutes}m`;
|
|
41
|
-
}
|
|
42
|
-
function formatReset(resetsAt, now) {
|
|
43
|
-
if (!resetsAt)
|
|
44
|
-
return '';
|
|
45
|
-
return `, resets ${formatResetDuration(resetsAt, now)}`;
|
|
46
|
-
}
|
|
47
|
-
function formatWindow(key, window, now, bindingWindow) {
|
|
48
|
-
if (!window)
|
|
49
|
-
return ` - ${WINDOW_LABELS[key]}: unknown`;
|
|
50
|
-
const line = [
|
|
51
|
-
` - ${WINDOW_LABELS[key]}: ${formatPercent(window.remainingPercent)} remaining`,
|
|
52
|
-
` (${formatPercent(window.usedPercent)} used`,
|
|
53
|
-
`${formatReset(window.resetsAt, now)}, checked ${formatAge(window.checkedAt, now)})`,
|
|
54
|
-
].join('');
|
|
55
|
-
return bindingWindow === key ? `${line} •` : line;
|
|
56
|
-
}
|
|
57
|
-
export function formatQuotaMoney(money) {
|
|
58
|
-
try {
|
|
59
|
-
return new Intl.NumberFormat('en-US', {
|
|
60
|
-
style: 'currency',
|
|
61
|
-
currency: money.currency,
|
|
62
|
-
minimumFractionDigits: money.exponent,
|
|
63
|
-
maximumFractionDigits: money.exponent,
|
|
64
|
-
}).format(money.amountMinor / 10 ** money.exponent);
|
|
65
|
-
}
|
|
66
|
-
catch {
|
|
67
|
-
return `${money.amountMinor} ${money.currency}`;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
function formatScopedWindow(window, now) {
|
|
71
|
-
return [
|
|
72
|
-
` - ${window.title}: ${formatPercent(window.remainingPercent)} remaining`,
|
|
73
|
-
` (${formatPercent(window.usedPercent)} used`,
|
|
74
|
-
`${formatReset(window.resetsAt, now)}, checked ${formatAge(window.checkedAt, now)})`,
|
|
75
|
-
].join('');
|
|
76
|
-
}
|
|
77
|
-
function accountName(account) {
|
|
78
|
-
return account.label?.trim() || account.id;
|
|
79
|
-
}
|
|
80
|
-
function accountStoredError(account) {
|
|
81
|
-
return (account.lastQuotaRefreshError?.message ?? account.lastRefreshError?.message);
|
|
82
|
-
}
|
|
83
|
-
export function buildFallbackQuotaSummaries(storage, errors = new Map()) {
|
|
84
|
-
if (!storage?.accounts.length)
|
|
85
|
-
return [];
|
|
86
|
-
return storage.accounts.filter(isOAuthAccount).map((account) => {
|
|
87
|
-
const error = errors.get(account.id) ?? accountStoredError(account);
|
|
88
|
-
return {
|
|
89
|
-
name: accountName(account),
|
|
90
|
-
role: 'fallback',
|
|
91
|
-
enabled: account.enabled !== false,
|
|
92
|
-
quota: account.quota,
|
|
93
|
-
...(formatOAuthAccountTier(account.profile) && {
|
|
94
|
-
tierLabel: formatOAuthAccountTier(account.profile),
|
|
95
|
-
}),
|
|
96
|
-
lastRefreshedAt: account.lastRefreshedAt,
|
|
97
|
-
...(error && { error }),
|
|
98
|
-
};
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
export function buildClaudeQuotaSummary(input) {
|
|
102
|
-
const now = input.now ?? Date.now();
|
|
103
|
-
const lines = ['## Claude Quotas', ''];
|
|
104
|
-
if (input.refreshedAt) {
|
|
105
|
-
lines.push(`Refreshed: ${formatAge(input.refreshedAt, now)}`, '');
|
|
106
|
-
}
|
|
107
|
-
if (!input.accounts.length) {
|
|
108
|
-
lines.push('No Claude OAuth accounts found yet.');
|
|
109
|
-
return lines.join('\n');
|
|
110
|
-
}
|
|
111
|
-
for (const account of input.accounts) {
|
|
112
|
-
const role = account.role === 'main' ? 'main' : 'fallback';
|
|
113
|
-
const disabled = account.enabled === false ? ' disabled' : '';
|
|
114
|
-
lines.push(`### ${account.name} (${role}${disabled})`);
|
|
115
|
-
if (account.tierLabel)
|
|
116
|
-
lines.push(` - Tier: ${account.tierLabel}`);
|
|
117
|
-
if (account.lastRefreshedAt) {
|
|
118
|
-
lines.push(` - Last token refresh: ${formatAge(account.lastRefreshedAt, now)}`);
|
|
119
|
-
}
|
|
120
|
-
if (account.error) {
|
|
121
|
-
lines.push(` - Error: ${account.error}`);
|
|
122
|
-
}
|
|
123
|
-
lines.push(formatWindow('five_hour', account.quota?.five_hour, now, account.quota?.bindingWindow));
|
|
124
|
-
lines.push(formatWindow('seven_day', account.quota?.seven_day, now, account.quota?.bindingWindow));
|
|
125
|
-
for (const window of account.quota?.scoped ?? []) {
|
|
126
|
-
const line = formatScopedWindow(window, now);
|
|
127
|
-
lines.push(account.quota?.bindingWindow === window.id ? `${line} •` : line);
|
|
128
|
-
}
|
|
129
|
-
const extraUsage = account.quota?.extraUsage;
|
|
130
|
-
if (extraUsage) {
|
|
131
|
-
const used = formatQuotaMoney(extraUsage.used);
|
|
132
|
-
const limit = formatQuotaMoney(extraUsage.limit);
|
|
133
|
-
lines.push(` - credits ${used}/${limit}${extraUsage.exhausted ? ' · exhausted' : ''}`);
|
|
134
|
-
}
|
|
135
|
-
if (account.quota?.fallbackAdvised === true) {
|
|
136
|
-
lines.push(' - → fallback advised');
|
|
137
|
-
}
|
|
138
|
-
lines.push('');
|
|
139
|
-
}
|
|
140
|
-
return lines.join('\n').trimEnd();
|
|
141
|
-
}
|