@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/README.md CHANGED
@@ -6,3 +6,5 @@ User-facing packages:
6
6
 
7
7
  - `@cortexkit/opencode-anthropic-auth` for OpenCode
8
8
  - `@cortexkit/pi-anthropic-auth` for Pi
9
+
10
+ Claude Haiku 5.5 (`claude-haiku-5-5`) has a 1M-token context window and 128K max output. Standard input/output rates are $0.10/$0.50 per million tokens; all rates increase fivefold above 100K total input, including cached tokens. Optional quota priming continues to send a minimal Haiku 4.5 request to start a new quota window.
@@ -1,5 +1,4 @@
1
1
  import type { ProviderAccountUuid } from './claude-code.ts';
2
- import { type CustodyHandleResolution } from './claustrum.ts';
3
2
  import { type Cache1hMode } from './constants.ts';
4
3
  import { type LogLevel } from './logger.ts';
5
4
  export type { ProviderAccountUuid } from './claude-code.ts';
@@ -22,7 +21,6 @@ export type OAuthAccount = AccountBase & {
22
21
  type: 'oauth';
23
22
  authLineageId?: string;
24
23
  anthropicAccountUuid?: ProviderAccountUuid;
25
- claustrumHandle?: string;
26
24
  /** Non-secret scoped identity; never a capability handle or bearer token. */
27
25
  claustrumScopedCredentialId?: string;
28
26
  claustrumScopedState?: string;
@@ -51,15 +49,13 @@ export type ApiKeyAccount = AccountBase & {
51
49
  authHeader?: 'authorization-bearer' | 'x-api-key';
52
50
  };
53
51
  export type FallbackAccount = OAuthAccount | ApiKeyAccount;
54
- export type ClaustrumAccountGate = {
55
- enabled?: boolean;
56
- };
57
52
  export type ClaustrumMode = 'local' | 'claustrum';
58
53
  export type ClaustrumConfig = {
59
54
  mode?: ClaustrumMode;
60
- handlesFile?: string;
61
55
  /** Set by authoritative scoped discovery, not an authentication toggle. */
62
56
  scopedRoster?: true;
57
+ /** Producer inventory cursor committed with the roster; never a bearer. */
58
+ rosterView?: string;
63
59
  /** Authoritative, non-secret primary identity from scoped discovery. */
64
60
  primaryAccount?: {
65
61
  credentialId: string;
@@ -68,7 +64,6 @@ export type ClaustrumConfig = {
68
64
  };
69
65
  /** Preserve explicit exclusions when a vaulted account disappears and returns. */
70
66
  disabledAccountIdentities?: string[];
71
- accounts?: Record<string, ClaustrumAccountGate>;
72
67
  };
73
68
  export declare function isOAuthAccount(account: FallbackAccount): account is OAuthAccount;
74
69
  export declare function isApiKeyAccount(account: FallbackAccount): account is ApiKeyAccount;
@@ -269,7 +264,7 @@ export type AccountStorage = {
269
264
  * (to display the provider's real model costs).
270
265
  */
271
266
  export declare function isCostZeroingEnabled(storage: Pick<AccountStorage, 'costZeroing'>): boolean;
272
- export type AccountRuntimeEntry = Partial<Pick<OAuthAccount, 'access' | 'authLineageId' | 'anthropicAccountUuid' | 'claustrumScopedCredentialId' | 'claustrumScopedState' | 'claustrumHandle' | 'refresh' | 'expires' | 'lastUsed' | 'lastRefreshedAt' | 'lastRefreshError' | 'lastQuotaRefreshError' | 'quota' | 'profile' | 'prime'> & Pick<ApiKeyAccount, 'apiKey' | 'lastUsed'>>;
267
+ export type AccountRuntimeEntry = Partial<Pick<OAuthAccount, 'access' | 'authLineageId' | 'anthropicAccountUuid' | 'claustrumScopedCredentialId' | 'claustrumScopedState' | 'refresh' | 'expires' | 'lastUsed' | 'lastRefreshedAt' | 'lastRefreshError' | 'lastQuotaRefreshError' | 'quota' | 'profile' | 'prime'> & Pick<ApiKeyAccount, 'apiKey' | 'lastUsed'>>;
273
268
  export type AccountRuntimeState = {
274
269
  version: 1;
275
270
  main?: {
@@ -299,7 +294,6 @@ export type AccountStateSaveScope = {
299
294
  mainRefresh?: boolean;
300
295
  mainPrime?: boolean;
301
296
  accounts?: true | string[];
302
- setClaustrumHandleAccountIds?: readonly string[];
303
297
  };
304
298
  export type AccountManagerOptions = {
305
299
  now?: () => number;
@@ -333,18 +327,12 @@ export declare function quotaSnapshotCheckedAt(quota: OAuthQuotaSnapshot | undef
333
327
  export declare function quotaFieldSource(snapshot: OAuthQuotaSnapshot | undefined, field: QuotaFieldName): QuotaFieldSource | undefined;
334
328
  export declare function mergeHeaderQuotaForPersistence(existing: OAuthQuotaSnapshot | undefined, incoming: OAuthQuotaSnapshot): OAuthQuotaSnapshot;
335
329
  export declare function getClaustrumMode(storage: AccountStorage | null): ClaustrumMode;
336
- export declare function isOAuthAccountVaultOwned(storage: AccountStorage | null, account: FallbackAccount, binding?: CustodyHandleResolution | undefined): boolean;
337
330
  export declare function setClaustrumModePersistent(mode: ClaustrumMode, path?: string): Promise<'changed' | 'unchanged'>;
338
- export declare function clearClaustrumHandlePersistent(input: {
339
- id: string;
340
- path?: string;
341
- }): Promise<'updated' | 'missing' | 'ineligible'>;
342
331
  export interface SaveAccountsOptions {
343
332
  /** Account ids intentionally removed by this mutation. */
344
333
  removedAccountIds?: readonly string[];
345
334
  /** Preserve disk order when a stale snapshot is missing newer accounts. */
346
335
  preserveExistingAccountOrder?: boolean;
347
- setClaustrumHandleAccountIds?: readonly string[];
348
336
  }
349
337
  export declare function saveAccounts(storage: AccountStorage, path?: string, options?: SaveAccountsOptions): Promise<void>;
350
338
  /** Read-modify-write account configuration under the existing config/state lock order.
@@ -367,7 +355,6 @@ export declare function saveOAuthProfileState(input: {
367
355
  profile: OAuthAccountProfile | undefined;
368
356
  accountIdentity?: string;
369
357
  }, path?: string): Promise<boolean>;
370
- export declare function clearClaustrumRefreshErrorPersistent(accountId: string, handle: string, path?: string): Promise<boolean>;
371
358
  export declare function acquireRefreshFileLock(options: {
372
359
  name: string;
373
360
  ttlMs: number;
@@ -112,6 +112,15 @@ export declare class CacheKeepManager {
112
112
  setIntervalImpl?: typeof globalThis.setInterval;
113
113
  clearIntervalImpl?: typeof globalThis.clearInterval;
114
114
  prepareHeaders?: (headers: Headers, target: CacheKeepTarget, attempt: CacheKeepPrewarmAttempt) => Promise<Headers | undefined> | Headers | undefined;
115
+ /** Optionally reauthorize a replayable prewarm after a genuine 401.
116
+ * Return headers only for a verified newer version of the same account;
117
+ * onResponse observes only the final physical attempt. */
118
+ retryOnUnauthorized?: (input: {
119
+ target: CacheKeepTarget;
120
+ headers: Headers;
121
+ bodyText: string;
122
+ attempt: CacheKeepPrewarmAttempt;
123
+ }) => Promise<Headers | undefined> | Headers | undefined;
115
124
  onTrackedSessionsChanged?: (sessions: readonly CacheKeepTrackedSession[]) => Promise<void> | void;
116
125
  prepareBody?: (bodyText: string, target: CacheKeepTarget) => string | Promise<string>;
117
126
  onResponse?: (input: {
@@ -14,6 +14,22 @@ export declare function resetClaudeCodeIdentityCachesForTest(): void;
14
14
  * additional bootstrap request carrying a previously authorized token. */
15
15
  export declare function getClaudeCodeIdentityForVerifiedAccount(accountIdentity: string, accountUuid: ProviderAccountUuid): ClaudeCodeIdentity;
16
16
  export declare function resolveClaudeCodeIdentity(accessToken: string, model: string | undefined, accountIdentity: string | undefined): Promise<ClaudeCodeIdentity>;
17
+ /**
18
+ * The access value is not a Claude OAuth access token, so Claude cannot
19
+ * identify its account. Asking again will not help; only a new sign-in
20
+ * replaces it. The message never includes the rejected value.
21
+ */
22
+ export declare class ClaudeUnsupportedAccessError extends Error {
23
+ readonly code = "unsupported-access";
24
+ constructor();
25
+ }
26
+ /**
27
+ * Account lookup for credentials that must belong to a Claude account.
28
+ * Unlike resolveClaudeCodeIdentity, which returns an identity without an
29
+ * account UUID for any other access value, this rejects such a value with
30
+ * ClaudeUnsupportedAccessError before any network request.
31
+ */
32
+ export declare function resolveClaudeCodeAccountIdentity(accessToken: string, model: string | undefined, accountIdentity: string | undefined): Promise<ClaudeCodeIdentity>;
17
33
  export declare function buildClaudeCodeMetadataUserId(identity: ClaudeCodeIdentity): string | null;
18
34
  export declare function applyClaudeCodeMetadata(body: Record<string, unknown>, identity: ClaudeCodeIdentity): boolean;
19
35
  export declare const CLAUDE_CODE_FULL_AGENT_BETAS: readonly ['oauth-2025-04-20', 'interleaved-thinking-2025-05-14', 'thinking-token-count-2026-05-13', 'context-management-2025-06-27', 'prompt-caching-scope-2026-01-05', 'claude-code-20250219', 'advisor-tool-2026-03-01', 'advanced-tool-use-2025-11-20', 'mid-conversation-system-2026-04-07', 'effort-2025-11-24', 'fallback-credit-2026-06-01', 'extended-cache-ttl-2025-04-11', 'cache-diagnosis-2026-04-07'];
@@ -48,6 +48,8 @@ export interface ClaustrumEnrollmentPaths {
48
48
  tokenPath: string;
49
49
  }
50
50
  export declare function getClaustrumEnrollmentPaths(tokenPath: string): ClaustrumEnrollmentPaths;
51
+ /** Resolve the independently enrolled host's owner-only token and state paths. */
52
+ export declare function getHostClaustrumEnrollmentPaths(host: 'opencode' | 'pi', env?: NodeJS.ProcessEnv, cwd?: string): ClaustrumEnrollmentPaths;
51
53
  export declare function readClaustrumEnrollmentStatus(paths: ClaustrumEnrollmentPaths, proposedName?: string): Promise<ClaustrumEnrollmentStatus>;
52
54
  /** Read fresh bearer material for a scoped operation; never publish this value. */
53
55
  export declare function readClaustrumEnrollmentToken(tokenPath: string): Promise<EnrollmentTokenFile>;
@@ -1,5 +1,9 @@
1
1
  import { type AccountStorage, type OAuthAccount } from './accounts.js';
2
2
  import type { ClaustrumScopedAccount, ClaustrumScopedCustody } from './claustrum-scoped.js';
3
+ export declare class ClaustrumRosterBusyError extends Error {
4
+ readonly code = "claustrum_roster_busy";
5
+ constructor();
6
+ }
3
7
  export interface ClaustrumScopedRoster {
4
8
  /** The vault's conventional default record; absent when only labeled accounts exist. */
5
9
  primary?: ClaustrumScopedAccount;
@@ -8,6 +8,9 @@ export interface ClaustrumScopedRuntimeOptions {
8
8
  storagePath: string;
9
9
  tokenPath: string;
10
10
  connect: () => Promise<ClaustrumScopedClient>;
11
+ /** Fired once per discovery change (including the initial snapshot),
12
+ * keyed by the inventory view digest. Repeat polls with an identical
13
+ * view do not notify. */
11
14
  onRoster?: (roster: ClaustrumScopedRoster) => void;
12
15
  onError?: () => void;
13
16
  setTimeoutImpl?: typeof setTimeout;
@@ -15,6 +15,20 @@ export interface ClaustrumScopedAttempt extends ClaustrumScopedIdentity {
15
15
  readonly recordVersion: number;
16
16
  readonly expiresAtMs: number;
17
17
  }
18
+ /** Only a new version of the same account may replace an in-flight 401. */
19
+ export declare function isScopedCredentialRotation(served: ClaustrumScopedAttempt, current: ClaustrumScopedAttempt | undefined): current is ClaustrumScopedAttempt;
20
+ /** Send classes that retry once after a scoped 401, for diagnostics. */
21
+ export type ScopedRetrySite = 'model' | 'model-relay' | 'cachekeep' | 'prime' | 'quota-profile' | 'pi-model' | 'pi-model-relay' | 'pi-cachekeep';
22
+ /** Why a scoped 401 did or did not retry. Never carries credential material. */
23
+ export type ScopedRetryReason = 'rotated' | 'reauthorize-failed' | 'credential-changed' | 'account-changed' | 'version-unchanged';
24
+ /**
25
+ * Decide whether a request that got a 401 should retry with the freshly
26
+ * re-authorized receipt, and record the decision. The vault can refresh a
27
+ * credential between dispatch and the 401; this line is the consumer-side
28
+ * half of that timeline, pairing with the vault's refresh commit instant when
29
+ * a stale report has to be explained. Never logs credential material.
30
+ */
31
+ export declare function decideScopedRetryAfter401(site: ScopedRetrySite, served: ClaustrumScopedAttempt, current: ClaustrumScopedAttempt | undefined): current is ClaustrumScopedAttempt;
18
32
  /**
19
33
  * Shared OpenCode/Pi scoped read plane. There is intentionally no credential cache,
20
34
  * handle fallback, or get single-flight: each outgoing attempt must be authorized
@@ -1,5 +1,3 @@
1
- import { type BindIdentity, type CatalogEntry, type CloseRouteOptions, type ManagedCallOptions, type ManagedCloseRouteOptions, type RequestOptions, type RouteHandle, type RouteOpenOptions, type RouteTarget, SubcClient, type SubscribeOptions, type Subscription } from '@cortexkit/subc-client';
2
- import type { ClaustrumConfig, OAuthAccount } from './accounts.ts';
3
1
  export type ClaustrumEndpoint = {
4
2
  host: string;
5
3
  port: number;
@@ -21,9 +19,6 @@ export declare const PRODUCTION_CLAUSTRUM_CONNECTION_FILE_NAME = "subc-connectio
21
19
  export declare function findExistingClaustrumConnectionPath(env?: NodeJS.ProcessEnv): string | undefined;
22
20
  export declare function getDefaultClaustrumConnectionPath(env?: NodeJS.ProcessEnv): string;
23
21
  export declare function resolveClaustrumConnectionPath(explicit?: string, env?: NodeJS.ProcessEnv): string;
24
- type CustodyHandlesEnvironment = Readonly<Record<string, string | undefined>>;
25
- export declare function resolveCustodyHandlesPath(config: Pick<ClaustrumConfig, 'handlesFile'> | undefined, env: CustodyHandlesEnvironment): string;
26
- export declare function getDefaultClaustrumHandlesPath(): string;
27
22
  export declare function detectClaustrumConnection(explicitPath?: string): Promise<ClaustrumDetection>;
28
23
  export declare const CUSTODY_TOMBSTONE_PREFIX = "claustrum-tombstone:v1:";
29
24
  export declare function custodyTombstoneKey(provider: string): string;
@@ -46,207 +41,3 @@ export declare class CustodyTombstoneLoginError extends Error {
46
41
  constructor(provider: string);
47
42
  }
48
43
  export declare function assertNotCustodyTombstone(refreshToken: unknown, provider: string): void;
49
- export type CustodyHandleAccount = {
50
- label: string;
51
- handle: string;
52
- credentialId: string;
53
- };
54
- export type CustodyHandleManifest = {
55
- version: 1;
56
- provider: 'anthropic';
57
- serve: 'anthropic-auth';
58
- accounts: ReadonlyArray<CustodyHandleAccount>;
59
- superseded: ReadonlySet<string>;
60
- corruptLabels?: ReadonlySet<string>;
61
- };
62
- export type CustodyHandleResolution = {
63
- status: 'resolved';
64
- source: 'manifest';
65
- handle: string;
66
- credentialId: string;
67
- } | {
68
- status: 'resolved';
69
- source: 'legacy';
70
- handle: string;
71
- } | {
72
- status: 'unresolved';
73
- reason: 'missing-label' | 'invalid-label' | 'duplicate-label' | 'missing-entry' | 'foreign-serve' | 'superseded' | 'corrupt-binding' | 'unknown-identity';
74
- };
75
- type ParsedCustodyHandleManifest = {
76
- version: 1;
77
- provider: string;
78
- serve: string;
79
- accounts: ReadonlyArray<CustodyHandleAccount>;
80
- superseded: ReadonlySet<string>;
81
- corruptLabels: ReadonlySet<string>;
82
- };
83
- export declare function isValidCustodyLabel(value: unknown): value is string;
84
- export declare function isValidCustodyHandle(value: unknown): value is string;
85
- export declare function custodyCredentialId(label: string): string;
86
- export declare function custodyCredentialIdFromResolution(resolution: CustodyHandleResolution, label: string): string;
87
- /**
88
- * | manifest state | legacy handle | result |
89
- * | --- | --- | --- |
90
- * | matching ready entry | any | manifest handle |
91
- * | absent or invalid | present | legacy handle |
92
- * | no matching ready entry | present | legacy handle |
93
- * | foreign serve | any | unresolved |
94
- * | superseded matching entry | any | unresolved |
95
- */
96
- export declare function resolveCustodyHandle(input: {
97
- account: OAuthAccount;
98
- manifest: CustodyHandleManifest | undefined;
99
- duplicateOAuthLabels?: ReadonlySet<string>;
100
- }): CustodyHandleResolution;
101
- export declare function readCustodyHandles(json: unknown, provider: string, serve: string): ParsedCustodyHandleManifest;
102
- type CustodyHandleManifestReadResult = {
103
- status: 'ready';
104
- manifest: CustodyHandleManifest;
105
- } | {
106
- status: 'absent';
107
- } | {
108
- status: 'ignored';
109
- reason: 'foreign-serve' | 'missing-provider';
110
- } | {
111
- status: 'invalid';
112
- reason: string;
113
- };
114
- export declare const CUSTODY_MANIFEST_SELECTION_ERROR_CODES: readonly ['foreign-serve', 'invalid-label', 'missing-provider'];
115
- type CustodyManifestSelectionErrorCode = (typeof CUSTODY_MANIFEST_SELECTION_ERROR_CODES)[number];
116
- export declare class CustodyManifestSelectionError extends Error {
117
- readonly code: CustodyManifestSelectionErrorCode;
118
- constructor(code: CustodyManifestSelectionErrorCode);
119
- }
120
- export declare class CustodyHandleManifestReader {
121
- #private;
122
- constructor(options: {
123
- path: string;
124
- provider: 'anthropic';
125
- serve: 'anthropic-auth';
126
- expectedUid?: number;
127
- });
128
- read(): Promise<CustodyHandleManifestReadResult>;
129
- }
130
- export type CustodyHandleManifestWriteResult = {
131
- status: 'written' | 'unchanged';
132
- } | {
133
- status: 'refused';
134
- reason: string;
135
- code?: CustodyManifestLockErrorCode;
136
- };
137
- export type CustodyHandleManifestRemovalResult = 'removed' | 'missing' | {
138
- status: 'refused';
139
- code?: CustodyManifestLockErrorCode;
140
- };
141
- export declare const CUSTODY_MANIFEST_LOCK_TTL_MS = 30000;
142
- export declare const CUSTODY_MANIFEST_LOCK_RENEW_MS = 10000;
143
- export declare const CUSTODY_MANIFEST_LOCK_RETRY_MIN_MS = 50;
144
- export declare const CUSTODY_MANIFEST_LOCK_RETRY_MAX_MS = 150;
145
- export type CustodyManifestLockTestOptions = Partial<{
146
- ttlMs: number;
147
- retryMinMs: number;
148
- retryMaxMs: number;
149
- renewalIntervalMs: number;
150
- now: () => number;
151
- setIntervalImpl: typeof globalThis.setInterval;
152
- clearIntervalImpl: typeof globalThis.clearInterval;
153
- afterStaleOwnerRead: () => void | Promise<void>;
154
- beforeRename: () => void | Promise<void>;
155
- }>;
156
- export declare function __setCustodyManifestLockTestOptions(options?: CustodyManifestLockTestOptions): void;
157
- export declare const CUSTODY_MANIFEST_LOCK_ERROR_CODES: readonly ['lock_busy', 'owner_invalid', 'renewal_failed'];
158
- export type CustodyManifestLockErrorCode = (typeof CUSTODY_MANIFEST_LOCK_ERROR_CODES)[number];
159
- export declare class CustodyManifestLockError extends Error {
160
- readonly code: CustodyManifestLockErrorCode;
161
- constructor(message: string, code: CustodyManifestLockErrorCode);
162
- }
163
- export declare class CustodyManifestLockBusyError extends CustodyManifestLockError {
164
- constructor(message: string);
165
- }
166
- export declare class CustodyManifestLockOwnerInvalidError extends CustodyManifestLockError {
167
- constructor(message: string);
168
- }
169
- export declare class CustodyManifestLockLeaseLostError extends CustodyManifestLockError {
170
- constructor(message: string);
171
- }
172
- export declare function __deriveCustodyManifestStaleLockPrefix(lockPath: string, pathBasename: (path: string) => string): string;
173
- export declare function withCustodyManifestLock<T>(path: string, fn: (assertLease: () => Promise<void>, nonce: string) => Promise<T>): Promise<T>;
174
- type CustodyHandleManifestWriteInput = {
175
- path: string;
176
- entry: CustodyHandleAccount;
177
- expectedUid?: number;
178
- };
179
- export declare function writeCustodyHandleManifestEntry(input: CustodyHandleManifestWriteInput): Promise<CustodyHandleManifestWriteResult>;
180
- export declare function removeCustodyHandleManifestEntry(input: CustodyHandleManifestWriteInput): Promise<CustodyHandleManifestRemovalResult>;
181
- export declare function writeCustodyHandleManifestEntryLocked(input: CustodyHandleManifestWriteInput, assertLease: () => Promise<void>, lockNonce: string): Promise<CustodyHandleManifestWriteResult>;
182
- export type ClaustrumClientOptions = {
183
- connectionFile?: string;
184
- handshakeTimeoutMs?: number;
185
- connector?: ClaustrumConnector;
186
- };
187
- export type ClaustrumConnector = (options: {
188
- connectionFile: string;
189
- handshakeTimeoutMs?: number;
190
- }) => Promise<SubcClient>;
191
- export declare class ClaustrumClient {
192
- #private;
193
- private constructor();
194
- static connect(options?: ClaustrumClientOptions): Promise<ClaustrumClient>;
195
- catalogList(moduleId?: string): Promise<CatalogEntry[]>;
196
- routeOpen(target: RouteTarget, identity: BindIdentity, options?: Omit<RouteOpenOptions, 'consumerIdentity'>): Promise<RouteHandle>;
197
- request(handle: RouteHandle, body: unknown, options?: RequestOptions): Promise<unknown>;
198
- call<Response = unknown>(moduleId: string, method: string, params?: unknown, options?: Omit<ManagedCallOptions, 'consumerIdentity'>): Promise<Response>;
199
- subscribe(handle: RouteHandle, body: unknown, onEvent: (event: Uint8Array) => void, options?: SubscribeOptions): Subscription;
200
- closeRoute(handle: RouteHandle, options?: CloseRouteOptions): Promise<void>;
201
- closeManagedRoute(target: Extract<RouteTarget, {
202
- kind: 'management_surface' | 'tool_provider';
203
- }>, identity: BindIdentity, options?: Omit<ManagedCloseRouteOptions, 'consumerIdentity'>): Promise<void>;
204
- close(): void;
205
- }
206
- export declare function connectClaustrumClient(options?: ClaustrumClientOptions): Promise<ClaustrumClient>;
207
- export declare const CLAUSTRUM_MODULE_ID = "claustrum";
208
- export declare const DEFAULT_CLAUSTRUM_CREDENTIAL_MIN_TTL_MS = 120000;
209
- export declare const ERROR_CLASS_WIRE_SET: readonly ['transient', 'permanent', 'auth_required', 'context_overflow'];
210
- export type ClaustrumCredentialErrorClass = (typeof ERROR_CLASS_WIRE_SET)[number];
211
- export type ClaustrumCredentialErrorAction = 'gone' | 'reauth' | 'retry' | 'reduce_and_retry';
212
- export type ClaustrumCredential = {
213
- payload: string;
214
- expiresAtMs: number | null;
215
- recordVersion: number;
216
- projectId?: string;
217
- accountId?: string;
218
- credentialId?: string;
219
- };
220
- export type ClaustrumServedCredential = Pick<ClaustrumCredential, 'recordVersion'>;
221
- export type ClaustrumReporterSource = 'direct' | 'relay_status_field' | 'relay_message_parse';
222
- export declare class ClaustrumCredentialError extends Error {
223
- readonly code: string;
224
- readonly action: ClaustrumCredentialErrorAction;
225
- readonly errorClass: ClaustrumCredentialErrorClass;
226
- constructor(message: string, code: string, errorClass: ClaustrumCredentialErrorClass, action: ClaustrumCredentialErrorAction);
227
- }
228
- export type ClaustrumCredentialCacheOptions = {
229
- identity?: BindIdentity;
230
- now?: () => number;
231
- minTtlMs?: number;
232
- };
233
- export declare class ClaustrumCredentialCache {
234
- #private;
235
- constructor(client: ClaustrumClient, options?: ClaustrumCredentialCacheOptions);
236
- get(handle: string, minTtlMs?: number, options?: {
237
- cacheIf?: () => boolean;
238
- }): Promise<ClaustrumCredential>;
239
- peek(handle: string): ClaustrumCredential | undefined;
240
- abandonPending(handle: string): void;
241
- seedForTest(handle: string, credential: ClaustrumCredential): void;
242
- reduceMinTtlMs(): number;
243
- reportAuthFailure(handle: string, providerStatus: number, servedCredential: ClaustrumServedCredential, reporterSource?: ClaustrumReporterSource): Promise<void>;
244
- reportAuthFailure(handle: string, servedCredential: ClaustrumServedCredential, providerStatus?: number, reporterSource?: ClaustrumReporterSource): Promise<void>;
245
- invalidate(handle: string, recordVersion?: number): void;
246
- close(): void;
247
- }
248
- export type ConnectClaustrumCredentialCacheOptions = ClaustrumClientOptions & ClaustrumCredentialCacheOptions & {
249
- enabled?: boolean;
250
- };
251
- export declare function connectClaustrumCredentialCache(options?: ConnectClaustrumCredentialCacheOptions): Promise<ClaustrumCredentialCache | null>;
252
- export {};
@@ -1,5 +1,5 @@
1
- import type { AccountStorage, ClaustrumMode, FallbackAccount } from '../accounts.ts';
2
- import type { ClaustrumDetection, CustodyHandleResolution } from '../claustrum.ts';
1
+ import type { AccountStorage, ClaustrumMode } from '../accounts.ts';
2
+ import type { ClaustrumDetection } from '../claustrum.ts';
3
3
  import type { ClaustrumEnrollmentStatus } from '../claustrum-enrollment.ts';
4
4
  export declare const CLAUDE_ACCOUNT_COMMAND_NAME = "claude-account";
5
5
  export type AccountCommandAction = {
@@ -82,7 +82,6 @@ export declare function executeAccountCommand(input: {
82
82
  storage: AccountStorage;
83
83
  claustrum?: ClaustrumDetection;
84
84
  statusProjection?: AccountCommandStatusProjection;
85
- resolveCustodyBinding?: (account: FallbackAccount) => CustodyHandleResolution;
86
85
  path?: string;
87
86
  transition?: ClaustrumModeTransition;
88
87
  resetEnrollment?: () => Promise<AccountCommandResult>;
package/dist/index.d.ts CHANGED
@@ -7,7 +7,6 @@ export * from './cch.ts';
7
7
  export * from './claude-code.ts';
8
8
  export * from './claustrum.ts';
9
9
  export * from './claustrum-enrollment.ts';
10
- export * from './claustrum-enrollment-registry.ts';
11
10
  export * from './claustrum-scoped.ts';
12
11
  export * from './claustrum-scoped-roster.ts';
13
12
  export * from './claustrum-scoped-runtime.ts';
@@ -23,16 +22,60 @@ export * from './logging.ts';
23
22
  export * from './mid-conversation-output-config.ts';
24
23
  export * from './model-remap.ts';
25
24
  export * from './models.ts';
25
+ export type { NativeAccountRuntime, NativeAccountRuntimeOptions, NativeAccountWriteInput, NativeApiSubject, NativeLocalAuthorizeOptions, NativeRelayUpdate, } from './native-account-runtime.ts';
26
+ export { acquireNativeAccountRuntime, createNativeAccountRuntime, nativeAccountPolicy, } from './native-account-runtime.ts';
27
+ export type { NativeAccountMetadataPatch, NativeAccountSnapshot, NativeAccountView, } from './native-account-view.ts';
28
+ export { formatNativeAccountState } from './native-account-view.ts';
29
+ export * from './native-credential-validation.ts';
30
+ export type { NativeCustody, NativeCustodyClient, NativeCustodyErrorCode, NativeCustodyIdentity, NativeCustodyInventory, NativeCustodyLogger, NativeCustodyOptions, NativeCustodyReceipt, NativeCustodyReporterSource, NativeCustodyRetry, } from './native-custody.ts';
31
+ export { createNativeCustody, NativeCustodyError } from './native-custody.ts';
32
+ export type { NativeCustodyActivationErrorCode, NativeCustodyActivationHooks, NativeCustodyActivationOptions, NativeCustodyActivationResult, } from './native-custody-activation.ts';
33
+ export { NativeCustodyActivationError, runNativeCustodyActivation, } from './native-custody-activation.ts';
34
+ export { readNativeEnrollmentMode } from './native-enrollment-authority.ts';
35
+ export { inspectNativeHostAuthEntry, NativeHostAuthError, requireNoSupervisedAuthContentSnapshot, } from './native-host-auth.ts';
36
+ export { readNativeHostAuthKind } from './native-host-auth-read.ts';
37
+ export type { NativeLocalAttributedFailure, NativeLocalCredentialService, NativeLocalCredentialServiceOptions, NativeLocalFailurePolicyInput, } from './native-local-credential-service.ts';
38
+ export { createNativeLocalCredentialService } from './native-local-credential-service.ts';
39
+ export type { NativeLocalExternalPolicy } from './native-local-runtime-readers.ts';
40
+ export type { NativeMenuActionValues, NativeMenuCapabilityOutcome, NativeMenuDispatch, NativeMenuDispatchActionId, NativeMenuDispatchOptions, NativeMenuDispatchRequest, NativeMenuDispatchValues, NativeMenuExecutionContext, NativeMenuExecutionResult, NativeMenuExecutor, NativeMenuExecutorOptions, NativeMenuExecutorRefusalCode, NativeMenuKillswitchEntry, NativeMenuNoValues, NativeMenuRequest, NativeMenuSessionActionId, } from './native-menu-executor.ts';
41
+ export { createNativeMenuExecutor } from './native-menu-executor.ts';
42
+ export type { NativeMenuAction, NativeMenuActionId, NativeMenuCacheMode, NativeMenuChoiceParameter, NativeMenuCommandId, NativeMenuCustodyMode, NativeMenuGroup, NativeMenuGroupId, NativeMenuHost, NativeMenuLogLevel, NativeMenuModel, NativeMenuParameter, NativeMenuParameterId, NativeMenuRefusalCode, NativeMenuRoutingMode, NativeMenuStatus, } from './native-menu-model.ts';
43
+ export { getNativeMenuModel } from './native-menu-model.ts';
44
+ export type { NativeMigrationCustody, NativeMigrationHooks, NativeMigrationOptions, NativeMigrationPreflight, } from './native-migration.ts';
45
+ export { NativeMigrationError, prepareNativeMigration, releaseNativeMigrationPreflight, runNativeMigration, } from './native-migration.ts';
46
+ export type { NativeCommittedMaterial, NativeIdentityBootstrap, NativeRefreshContext, NativeRefreshDispatchVersion, NativeRefreshFailure, NativeRefreshHandoff, NativeRefreshObservation, NativeRefreshRequest, NativeRefreshRestriction, NativeRefreshResult, NativeRefreshSubject, NativeServingAdmission, } from './native-refresh-coordinator.ts';
47
+ export type { NativeLocalFailureAttribution, NativeLocalFailurePolicy, NativeLocalFailureSkipReason, } from './native-runtime.ts';
48
+ export { nativeRuntimeOptionIdentity } from './native-runtime-registry.ts';
49
+ export { isNativeTransientAccountError, NativeTransientAccountError, } from './native-transient-account.ts';
50
+ export type { CommandApplyRequest, CommandApplyResult, CommandDialogPayload, CommandInvocation, CommandMenu, CommandMenuModel, KnobValue, KnobValues, MenuAction, MenuItem, MenuKnob, MenuSection, NativeUiOptions, NotifyKind, SectionSlot, } from './native-ui.ts';
51
+ export { createNativeUi, parseApplyRequest, runPiCommandMenu, } from './native-ui.ts';
52
+ export * from './native-usage-publication.ts';
53
+ export { NATIVE_VAULT_NO_ACCOUNT_MESSAGE, NativeVaultNoAccountError, readNativeAccountsForRequest, } from './native-vault-admission.ts';
54
+ export type { NativePiAuthSlot, NativePiAuthSlotErrorCode, NativePiAuthSlotInspection, NativePiAuthSlotOptions, NativeVaultDisconnectOptions, NativeVaultDisconnectResult, } from './native-vault-connection.ts';
55
+ export { disconnectNativeVaultForHost, NativePiAuthSlotError, nativePiAuthSlotPaths, openNativePiAuthSlot, } from './native-vault-connection.ts';
56
+ export type { NativeVaultRuntime, NativeVaultRuntimeOptions, NativeVaultWatch, NativeVaultWatchOptions, } from './native-vault-runtime.ts';
57
+ export { acquireNativeVaultRuntime, createNativeVaultRuntime, discoverNativeVaultInventory, publishNativeVaultRosterSeed, publishNativeVaultRuntimeSeed, } from './native-vault-runtime.ts';
26
58
  export * from './oauth-profile.ts';
27
59
  export * from './pkce.ts';
60
+ export type { NativeMigrationJournal } from './pool-authority.ts';
61
+ export { nativeMigrationAuthorityPhase, readNativeMigrationJournal, } from './pool-authority.ts';
62
+ export type { NativeLocalPoolBinding } from './pool-binding.ts';
63
+ export { captureNativeLocalPoolBinding } from './pool-binding.ts';
64
+ export * from './pool-paths.ts';
65
+ export * from './pool-store.ts';
28
66
  export * from './prime.ts';
29
67
  export * from './provider.ts';
68
+ export type { ProviderErrorRedactor, ProviderErrorResponseScope, ProviderResponseMode, ProviderResponseSettlement, } from './provider-error.ts';
69
+ export { createProviderErrorRedactor, createProviderErrorResponseScope, } from './provider-error.ts';
30
70
  export * from './quota-header-feed.ts';
31
71
  export * from './quota-headers.ts';
32
72
  export * from './quota-manager.ts';
33
73
  export * from './quotas.ts';
34
74
  export * from './relay.ts';
75
+ export * from './request-history.ts';
35
76
  export * from './routing.ts';
77
+ export type { SseEvent, SseFramer, SseFramerOptions } from './sse.ts';
78
+ export { createSseFramer, DEFAULT_SSE_MAX_FRAME_BYTES, decodeSseFrame, isSseCandidateFrame, isTerminatedSseFrame, parseSseFrame, SseFrameTooLargeError, } from './sse.ts';
36
79
  export * from './start.ts';
37
80
  export * from './sticky-routing.ts';
38
81
  export * from './thinking-binding.ts';