@cortexkit/anthropic-auth-core 1.23.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.
Files changed (134) hide show
  1. package/README.md +2 -0
  2. package/dist/accounts.d.ts +3 -16
  3. package/dist/cachekeep.d.ts +9 -0
  4. package/dist/claude-code.d.ts +16 -0
  5. package/dist/claustrum-enrollment.d.ts +2 -0
  6. package/dist/claustrum-scoped-roster.d.ts +4 -0
  7. package/dist/claustrum-scoped-runtime.d.ts +3 -0
  8. package/dist/claustrum-scoped.d.ts +14 -0
  9. package/dist/claustrum.d.ts +0 -209
  10. package/dist/commands/account.d.ts +2 -3
  11. package/dist/index.d.ts +44 -1
  12. package/dist/index.js +29700 -38
  13. package/dist/internal-types/LICENSE +21 -0
  14. package/dist/internal-types/commands/builtins.d.ts +71 -0
  15. package/dist/internal-types/commands/index.d.ts +10 -0
  16. package/dist/internal-types/commands/menu.d.ts +61 -0
  17. package/dist/internal-types/commands/model.d.ts +238 -0
  18. package/dist/internal-types/commands/pi.d.ts +23 -0
  19. package/dist/internal-types/commands/seam.d.ts +72 -0
  20. package/dist/internal-types/fs/refresh-file-lock.d.ts +33 -0
  21. package/dist/internal-types/logger/capture-sink.d.ts +14 -0
  22. package/dist/internal-types/logger/engine.d.ts +100 -0
  23. package/dist/internal-types/logger/index.d.ts +6 -0
  24. package/dist/internal-types/logger/redact.d.ts +11 -0
  25. package/dist/internal-types/pi-slot/index.d.ts +3 -0
  26. package/dist/internal-types/pi-slot/slot.d.ts +49 -0
  27. package/dist/internal-types/quota/codec.d.ts +11 -0
  28. package/dist/internal-types/quota/format.d.ts +46 -0
  29. package/dist/internal-types/quota/index.d.ts +10 -0
  30. package/dist/internal-types/quota/map.d.ts +63 -0
  31. package/dist/internal-types/quota/merge.d.ts +48 -0
  32. package/dist/internal-types/quota/projection.d.ts +64 -0
  33. package/dist/internal-types/store/attribution.d.ts +28 -0
  34. package/dist/internal-types/store/errors.d.ts +55 -0
  35. package/dist/internal-types/store/hooks.d.ts +12 -0
  36. package/dist/internal-types/store/identity.d.ts +39 -0
  37. package/dist/internal-types/store/index.d.ts +21 -0
  38. package/dist/internal-types/store/mutate.d.ts +189 -0
  39. package/dist/internal-types/store/pool.d.ts +196 -0
  40. package/dist/internal-types/store/provider-state.d.ts +131 -0
  41. package/dist/internal-types/store/publication.d.ts +47 -0
  42. package/dist/internal-types/store/pull.d.ts +36 -0
  43. package/dist/internal-types/store/refresh-lock.d.ts +63 -0
  44. package/dist/internal-types/store/refresh.d.ts +72 -0
  45. package/dist/internal-types/store/rows.d.ts +313 -0
  46. package/dist/internal-types/store/runtime.d.ts +36 -0
  47. package/dist/internal-types/store/schema.d.ts +443 -0
  48. package/dist/internal-types/store/settings.d.ts +63 -0
  49. package/dist/internal-types/store/torn.d.ts +78 -0
  50. package/dist/migration-source.d.ts +33 -0
  51. package/dist/models.d.ts +41 -0
  52. package/dist/native-account-runtime.d.ts +121 -0
  53. package/dist/native-account-view.d.ts +126 -0
  54. package/dist/native-command-effects.d.ts +59 -0
  55. package/dist/native-credential-validation.d.ts +42 -0
  56. package/dist/native-custody-activation.d.ts +45 -0
  57. package/dist/native-custody.d.ts +114 -0
  58. package/dist/native-enrollment-authority.d.ts +2 -0
  59. package/dist/native-host-auth-read.d.ts +3 -0
  60. package/dist/native-host-auth-write.d.ts +51 -0
  61. package/dist/native-host-auth.d.ts +12 -0
  62. package/dist/native-local-credential-service.d.ts +76 -0
  63. package/dist/native-local-runtime-readers.d.ts +22 -0
  64. package/dist/native-lock-observer.d.ts +12 -0
  65. package/dist/native-menu-executor.d.ts +243 -0
  66. package/dist/native-menu-model.d.ts +142 -0
  67. package/dist/native-migration-proof.d.ts +28 -0
  68. package/dist/native-migration-source.d.ts +47 -0
  69. package/dist/native-migration.d.ts +66 -0
  70. package/dist/native-quota-codec.d.ts +32 -0
  71. package/dist/native-refresh-coordinator.d.ts +240 -0
  72. package/dist/native-roster-seed.d.ts +115 -0
  73. package/dist/native-runtime-registry.d.ts +19 -0
  74. package/dist/native-runtime.d.ts +204 -0
  75. package/dist/native-transient-account.d.ts +38 -0
  76. package/dist/native-ui.d.ts +45 -0
  77. package/dist/native-usage-publication.d.ts +11 -0
  78. package/dist/native-vault-admission.d.ts +8 -0
  79. package/dist/native-vault-connection.d.ts +33 -0
  80. package/dist/native-vault-paths.d.ts +13 -0
  81. package/dist/native-vault-runtime.d.ts +102 -0
  82. package/dist/native-vault-seed.d.ts +16 -0
  83. package/dist/pool-authority.d.ts +159 -0
  84. package/dist/pool-binding.d.ts +32 -0
  85. package/dist/pool-paths.d.ts +21 -0
  86. package/dist/pool-store.d.ts +32 -0
  87. package/dist/provider-error.d.ts +139 -0
  88. package/dist/quota-manager.d.ts +18 -7
  89. package/dist/relay.d.ts +14 -1
  90. package/dist/request-history.d.ts +34 -0
  91. package/dist/sse.d.ts +81 -0
  92. package/dist/sticky-routing.d.ts +27 -0
  93. package/package.json +9 -4
  94. package/dist/accounts.js +0 -3881
  95. package/dist/auth.js +0 -185
  96. package/dist/cache1h.js +0 -97
  97. package/dist/cachekeep-registry.js +0 -124
  98. package/dist/cachekeep.js +0 -604
  99. package/dist/cch.js +0 -172
  100. package/dist/claude-code.js +0 -403
  101. package/dist/claustrum-enrollment-registry.d.ts +0 -17
  102. package/dist/claustrum-enrollment-registry.js +0 -194
  103. package/dist/claustrum-enrollment.js +0 -485
  104. package/dist/claustrum-scoped-roster.js +0 -194
  105. package/dist/claustrum-scoped-runtime.js +0 -230
  106. package/dist/claustrum-scoped.js +0 -193
  107. package/dist/claustrum.js +0 -1471
  108. package/dist/commands/account.js +0 -368
  109. package/dist/constants.js +0 -83
  110. package/dist/custom-headers.js +0 -102
  111. package/dist/dump.js +0 -616
  112. package/dist/fast.js +0 -66
  113. package/dist/json.js +0 -10
  114. package/dist/killswitch.js +0 -132
  115. package/dist/logger.js +0 -288
  116. package/dist/logging.js +0 -59
  117. package/dist/mid-conversation-output-config.js +0 -89
  118. package/dist/model-remap.js +0 -72
  119. package/dist/models.js +0 -177
  120. package/dist/network-errors.js +0 -27
  121. package/dist/oauth-profile.js +0 -60
  122. package/dist/pkce.js +0 -17
  123. package/dist/prime.js +0 -841
  124. package/dist/provider.js +0 -0
  125. package/dist/quota-header-feed.js +0 -331
  126. package/dist/quota-headers.js +0 -121
  127. package/dist/quota-manager.js +0 -856
  128. package/dist/quotas.js +0 -141
  129. package/dist/relay.js +0 -1303
  130. package/dist/routing.js +0 -94
  131. package/dist/start.js +0 -29
  132. package/dist/sticky-routing.js +0 -541
  133. package/dist/thinking-binding.js +0 -54
  134. 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
- }