@cortexkit/anthropic-auth-core 2.5.7 → 2.6.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.
@@ -18,7 +18,10 @@ export interface ClaustrumConsumerOptions<Q = QuotaObservation> {
18
18
  /** This host's enrollment token, written by setup. */
19
19
  tokenPath: string;
20
20
  family: ClaustrumFamily;
21
- connect: () => Promise<ClaustrumScopedClient>;
21
+ /** Enrollment-name prefix, required by the default host connection. */
22
+ pluginId?: string;
23
+ /** Used outside host authority; hosted connections always use the relay. */
24
+ connect?: () => Promise<ClaustrumScopedClient>;
22
25
  /**
23
26
  * How long one `connect()` attempt may take before this consumer treats the
24
27
  * vault as unreachable (default 10 s). A connect that never settles would
@@ -31,6 +34,7 @@ export interface ClaustrumConsumerOptions<Q = QuotaObservation> {
31
34
  * Whether the plugin currently takes its accounts from the vault (custody
32
35
  * mode) rather than from local logins. Checked before every discovery,
33
36
  * commit and dispatch; false closes the vault connection and refuses sends.
37
+ * Host authority always selects custody and does not call this callback.
34
38
  */
35
39
  isCustodyActive?: () => boolean | Promise<boolean>;
36
40
  /** Ids of the plugin's local pool rows; no vault route id may equal one. */
@@ -249,16 +249,19 @@ export declare const SERVING_MARGIN_MS = 300000;
249
249
  export declare const KEPT_RECEIPT_MARGIN_MS = 60000;
250
250
  /**
251
251
  * Reads this consumer's vault credentials (list, fetch, 401 report), with the
252
- * enrollment token as authorization. Used by every host of a plugin. Every
253
- * physical send asks the vault first while reachable. Only an unreachable vault permits
254
- * reuse of the last validated receipt, in memory and bounded by its expiry.
255
- * The enrollment token is re-read per operation so revocation and disconnect
256
- * still take effect without a process restart.
252
+ * enrollment token or the host's grant as authorization. Used by every host of a
253
+ * plugin. Every physical send asks the vault first while reachable. Only an
254
+ * unreachable vault permits reuse of the last validated receipt, in memory and
255
+ * bounded by its expiry. Outside host authority the enrollment token is re-read
256
+ * per operation so revocation and disconnect still take effect without a restart.
257
257
  */
258
258
  export declare class ClaustrumScopedCustody {
259
259
  #private;
260
260
  constructor(options: {
261
- client: ClaustrumScopedClient;
261
+ /** While hosted, only a client returned by connectVaultHost is accepted. */
262
+ client?: ClaustrumScopedClient;
263
+ /** Enrollment-name prefix, required when using the default host client. */
264
+ pluginId?: string;
262
265
  family: ClaustrumFamilyInput;
263
266
  tokenPath?: string;
264
267
  readToken?: () => Promise<EnrollmentTokenFile>;
@@ -309,8 +312,8 @@ export declare class ClaustrumScopedCustody {
309
312
  * Report that a send this consumer actually made was rejected. Only a 401
310
313
  * is reported (the vault refuses 429, 402 and 5xx reports), addressed by
311
314
  * credential id with the exact record version that send was served, and
312
- * signed with the enrollment token that authorized it. A receipt this
313
- * custody did not issue is refused rather than reported.
315
+ * sent through the client and enrollment token that authorized it. A receipt
316
+ * this custody did not issue is refused rather than reported.
314
317
  */
315
318
  reportFailure(attempt: ClaustrumScopedAttempt, status: number, reporterSource: ClaustrumReporterSource): Promise<void>;
316
319
  /**
@@ -124,6 +124,8 @@ export declare function readClaustrumEnrollmentStatus(paths: ClaustrumEnrollment
124
124
  * owner-only, as every private-file read there does.
125
125
  */
126
126
  export declare function enrollmentAuthority(paths: ClaustrumEnrollmentPaths, proposedName: string): Promise<'vault' | 'local' | 'unreadable'>;
127
+ /** Host authority takes precedence without reading any plugin enrollment files. */
128
+ export declare function vaultAuthority(paths: ClaustrumEnrollmentPaths, proposedName: string): Promise<'host' | 'vault' | 'local' | 'unreadable'>;
127
129
  /**
128
130
  * Read fresh bearer material for one scoped operation; never publish it.
129
131
  * Re-reading per operation is what lets an operator reissue a token on disk.
@@ -0,0 +1,8 @@
1
+ import type { ClaustrumScopedClient } from './custody.js';
2
+ export declare const VAULT_HOST_STATUS = "Served by Thalamus";
3
+ export declare const VAULT_HOST_CONNECT_REFUSAL = "This host gets its vault accounts from Thalamus, so it can't connect to the vault itself.";
4
+ export declare function isVaultHostClient(client: ClaustrumScopedClient): boolean;
5
+ /** The spawn marker, not a global installed by another plugin, selects authority. */
6
+ export declare function hasVaultHost(): boolean;
7
+ /** Read at connect time so a bridge installed after the auth plugin can recover. */
8
+ export declare function connectVaultHost(pluginId?: string): ClaustrumScopedClient;
@@ -46,7 +46,10 @@ export interface ClaustrumDiscoveryHubOptions {
46
46
  * member for any row and is refused.
47
47
  */
48
48
  family: ClassifyingClaustrumFamily<string>;
49
- connect: () => Promise<ClaustrumScopedClient>;
49
+ /** Enrollment-name prefix, required by the default host connection. */
50
+ pluginId?: string;
51
+ /** Used outside host authority; hosted connections always use the relay. */
52
+ connect?: () => Promise<ClaustrumScopedClient>;
50
53
  /**
51
54
  * How long one `connect()` attempt may take before the hub treats the vault
52
55
  * as unreachable (default 10 s, as `ClaustrumConsumerOptions`). The hub's
@@ -60,6 +63,7 @@ export interface ClaustrumDiscoveryHubOptions {
60
63
  * state only, never from the vault: on every hub tick, and when a member
61
64
  * refreshes or authorizes. The first false read revokes every lease,
62
65
  * closes the connection and clears every member.
66
+ * Host authority always selects custody and does not call this callback.
63
67
  */
64
68
  isCustodyActive?: () => boolean | Promise<boolean>;
65
69
  parseIdentity?: IdentityParser;
@@ -4,8 +4,9 @@ export { ClaustrumCredentialError, type ClaustrumReporterSource, type Enrollment
4
4
  export { ClaustrumUnreachableError, classifyVaultFailure, VAULT_FAILURE_CLASSES, type VaultFailureClass, } from './availability.js';
5
5
  export { ClaustrumConsumer, type ClaustrumConsumerOptions, type ClaustrumWatchState, DEFAULT_CONNECT_TIMEOUT_MS, type SendOptions, } from './consumer.js';
6
6
  export { type AccountIdentitySource, type ClassifyingClaustrumFamily, type ClaustrumFamily, type ClaustrumFamilyInput, type ClaustrumRosterWatch, type ClaustrumRosterWatchOptions, type ClaustrumScopedAttempt, type ClaustrumScopedClient, ClaustrumScopedCustody, type ClaustrumScopedIdentity, decideScopedRetryAfter401, type IdentityParser, isScopedCredentialRotation, KEPT_RECEIPT_MARGIN_MS, type KeptReceiptState, type ScopedRetryReason, SERVING_MARGIN_MS, type SkippedVaultReason, type SkippedVaultRecord, type VaultCredential, type VaultCredentialType, type VaultGrantReach, type VaultGrantTuple, type VaultInventory, type VaultRowFacts, } from './custody.js';
7
- export { type ClaustrumEnrollmentClient, type ClaustrumEnrollmentConnection, type ClaustrumEnrollmentDisconnectResult, ClaustrumEnrollmentManager, type ClaustrumEnrollmentPaths, type ClaustrumEnrollmentResetResult, type ClaustrumEnrollmentStatus, classifyEnrollmentError, connectClaustrumEnrollmentClient, disconnectClaustrumEnrollment, type EnrollmentDisposition, enrollmentAuthority, enrollmentName, getClaustrumEnrollmentPaths, hostEnrollmentPaths, RETRYABLE_ENROLLMENT_CODES, readClaustrumEnrollmentStatus, readClaustrumEnrollmentToken, resetClaustrumEnrollmentState, TERMINAL_ENROLLMENT_CODES, } from './enrollment.js';
7
+ export { type ClaustrumEnrollmentClient, type ClaustrumEnrollmentConnection, type ClaustrumEnrollmentDisconnectResult, ClaustrumEnrollmentManager, type ClaustrumEnrollmentPaths, type ClaustrumEnrollmentResetResult, type ClaustrumEnrollmentStatus, classifyEnrollmentError, connectClaustrumEnrollmentClient, disconnectClaustrumEnrollment, type EnrollmentDisposition, enrollmentAuthority, enrollmentName, getClaustrumEnrollmentPaths, hostEnrollmentPaths, RETRYABLE_ENROLLMENT_CODES, readClaustrumEnrollmentStatus, readClaustrumEnrollmentToken, resetClaustrumEnrollmentState, TERMINAL_ENROLLMENT_CODES, vaultAuthority, } from './enrollment.js';
8
8
  export { ClaustrumConsumerError, type ClaustrumConsumerFailureKind, type ClaustrumLogger, } from './errors.js';
9
+ export { connectVaultHost, VAULT_HOST_CONNECT_REFUSAL, VAULT_HOST_STATUS, } from './host.js';
9
10
  export { assertHostSlotMatchesMode, assertNotCustodyPlaceholder, CUSTODY_PLACEHOLDER_PREFIX, classifyHostSlot, custodyPlaceholder, custodyPlaceholderKey, type HostSlotContent, isCustodyPlaceholder, isCustodyPlaceholderValue, } from './host-slot.js';
10
11
  export { ClaustrumDiscoveryHub, type ClaustrumDiscoveryHubOptions, type ClaustrumHubMemberOptions, type ClaustrumHubRefusals, type ClaustrumLeasedCustody, type CustodyLease, } from './hub.js';
11
12
  export { acquireInsulaQuotaSource, type InsulaQuotaContext, type InsulaQuotaLookup, type InsulaQuotaMiss, type InsulaQuotaOptions, type InsulaQuotaReading, type InsulaQuotaResult, type InsulaQuotaSource, type InsulaUsageEntry, type InsulaUsageTransport, type InsulaUsageWatch, type InsulaUsageWindow, type InsulaWatchOptions, } from './insula.js';
@@ -1,3 +1,4 @@
1
+ import type { NativeLocalPoolBinding } from './pool-binding.ts';
1
2
  export declare const MESSAGE_THREADS_BETA = "message-threads-2026-08-12";
2
3
  type Body = Record<string, unknown>;
3
4
  export interface MessageThreadInput {
@@ -6,10 +7,13 @@ export interface MessageThreadInput {
6
7
  account: string;
7
8
  credential: string;
8
9
  session: string;
10
+ request?: string;
9
11
  replyToolNames?: ReadonlyMap<string, string | null>;
10
12
  }
11
13
  export interface MessageThreadSnapshot {
12
14
  identity: string;
15
+ accountIdentity: string;
16
+ credentialIdentity: string;
13
17
  fingerprint: string;
14
18
  messages: string[];
15
19
  prefix: string;
@@ -26,6 +30,10 @@ export type MessageThreadDecision = {
26
30
  previousMessageId: string;
27
31
  deltaMessages: unknown[];
28
32
  };
33
+ export type MessageThreadCreateReason = 'no_anchor' | 'clock_rollback' | 'expired' | 'identity_changed' | 'too_few_messages' | 'assistant_missing' | 'extra_assistant' | 'reply_invalid' | 'reply_changed' | 'fixed_changed' | 'prefix_changed';
34
+ export type MessageThreadDisposition = 'never_seen' | 'superseded' | 'stream_cancelled' | 'stream_error' | 'signal_aborted' | 'invalid_completion' | 'invalid_reply' | 'response_refusal' | 'response_fallback' | 'response_rewritten' | 'thread_rejected' | 'account_disabled' | 'evicted' | 'session_deleted';
35
+ /** Refresh preserves the local epoch; replacing a login advances it even when the row id is reused. */
36
+ export declare function localMessageThreadCredential(binding: NativeLocalPoolBinding): string;
29
37
  type ReplyToolName = (name: unknown) => string | undefined;
30
38
  export declare function messageThreadSnapshot(input: MessageThreadInput, identity?: string, fingerprint?: string): MessageThreadSnapshot;
31
39
  /** Decide from immutable request facts; no session state or clock is read here. */
@@ -46,16 +54,19 @@ export declare class MessageThreadTracker {
46
54
  private readonly hashBudget;
47
55
  private readonly sessions;
48
56
  private messageHashes;
57
+ private readonly dispositions;
58
+ private readonly instance;
49
59
  constructor(capacity?: number, now?: () => number, hashBudget?: number);
50
- forget(session: string): void;
60
+ forget(session: string, disposition?: MessageThreadDisposition): void;
51
61
  private prune;
52
62
  private failureFor;
63
+ logCreate(session: string, reason: MessageThreadCreateReason, anchor?: MessageThreadAnchor, input?: Pick<MessageThreadInput, 'account' | 'credential' | 'request'>, now?: number): void;
53
64
  prepare(input: MessageThreadInput): {
54
65
  decision: MessageThreadDecision;
55
66
  body: Body;
56
67
  normalizeToolName: ReplyToolName;
57
68
  complete: (facts: MessageThreadCompletion) => void;
58
- fail: () => void;
69
+ fail: (disposition?: MessageThreadDisposition) => void;
59
70
  };
60
71
  }
61
72
  /** Observe without teeing or buffering the response; cancellation cannot publish an anchor. */
@@ -70,7 +81,7 @@ export declare function prepareMessageThreadRequest(tracker: MessageThreadTracke
70
81
  signal?: AbortSignal;
71
82
  }): Promise<{
72
83
  readonly bodyText: string;
73
- fail: () => void;
84
+ fail: (disposition?: MessageThreadDisposition) => void;
74
85
  observe: (response: Response) => Response;
75
86
  recover(response: Response, send: (body: string) => Promise<Response>, beforeResend?: (rejected: Response) => Promise<boolean | {
76
87
  credential: string;
@@ -110,10 +110,10 @@ export interface NativeAccountRuntime {
110
110
  */
111
111
  reorder(routeIds: readonly string[], movedRouteId?: string): Promise<void>;
112
112
  captureLocalSubject(routeId: string): Promise<NativeRefreshSubject>;
113
- publishLocal(subject: NativeKnownCredentialSubject, patch: NativeAccountMetadataPatch): Promise<boolean>;
113
+ publishLocal(subject: NativeKnownCredentialSubject, patch: NativeAccountMetadataPatch, signal?: AbortSignal): Promise<boolean>;
114
114
  publishApi(subject: NativeApiSubject, patch: {
115
115
  lastUsed: number;
116
- }): Promise<boolean>;
116
+ }, signal?: AbortSignal): Promise<boolean>;
117
117
  resetBackoff(routeId: string, fence: NativeRefreshSubject | NativeCustodyReceipt, kind?: 'refresh' | 'quota' | 'all'): Promise<boolean>;
118
118
  getOrCreateAuthLineage(routeId: string, fence: NativeKnownCredentialSubject | NativeCustodyReceipt): Promise<string | undefined>;
119
119
  incrementPrimeUsage(routeId: string, fence: NativeKnownCredentialSubject | NativeCustodyReceipt, delta?: PrimeUsageDelta): Promise<boolean>;
@@ -140,6 +140,7 @@ export interface NativeCustodyLogger {
140
140
  debug: (message: string, data?: unknown) => void;
141
141
  }
142
142
  export interface NativeCustodyOptions {
143
+ onConnectionChanged?: () => void;
143
144
  host: 'opencode' | 'pi';
144
145
  connect: () => Promise<NativeCustodyClient>;
145
146
  readToken?: () => Promise<{
@@ -217,6 +218,10 @@ export type NativeCustodyRetry = {
217
218
  code?: NativeCustodyErrorCode;
218
219
  };
219
220
  export interface NativeCustody {
221
+ /** Whether a 401 needs fresh authorization because a previous relay issued the receipt. */
222
+ isPreviousConnectionReceipt?: (receipt: NativeCustodyReceipt) => boolean;
223
+ /** Authority lifetime only; replacing a relay does not retire issued tokens. */
224
+ readonly generation?: number;
220
225
  discover: (signal?: AbortSignal) => Promise<NativeCustodyInventory>;
221
226
  authorize: (identity: NativeCustodyIdentity, signal?: AbortSignal) => Promise<NativeCustodyReceipt>;
222
227
  reportFailure: (receipt: NativeCustodyReceipt, status: number, reporterSource: NativeCustodyReporterSource) => Promise<void>;
@@ -240,5 +245,5 @@ export interface NativeCustody {
240
245
  watchRoster: (options: NativeRosterWatchOptions) => NativeRosterWatch;
241
246
  close: () => void;
242
247
  }
243
- /** Share a lazy Claustrum connection; each authorize call reads a fresh enrollment token and OAuth receipt. */
248
+ /** Share a lazy vault connection; each authorization obtains a fresh scoped OAuth receipt. */
244
249
  export declare function createNativeCustody(options: NativeCustodyOptions): NativeCustody;
@@ -1,4 +1,4 @@
1
- import { enrollmentAuthority, readClaustrumEnrollmentStatus } from "./internal-types/claustrum/index.js";
1
+ import { readClaustrumEnrollmentStatus, vaultAuthority } from "./internal-types/claustrum/index.js";
2
2
  import { NativeCustodyError } from './native-custody.ts';
3
3
  /** Test-only reset for the once-per-process enrollment mode log. */
4
4
  export declare function __resetEnrollmentModeLogForTests(): void;
@@ -20,8 +20,8 @@ export declare const PRIVATE_FILES_UNAVAILABLE_MESSAGE = "Private file support d
20
20
  export declare class NativePrivateFilesUnavailableError extends NativeCustodyError {
21
21
  constructor();
22
22
  }
23
- /** Enrollment files, not account settings, choose the host's credential source. */
23
+ /** Host authority takes precedence over enrollment files and account settings. */
24
24
  export declare function readNativeEnrollmentMode(host: 'opencode' | 'pi', env?: NodeJS.ProcessEnv, dependencies?: {
25
- enrollmentAuthority: typeof enrollmentAuthority;
25
+ enrollmentAuthority: typeof vaultAuthority;
26
26
  readClaustrumEnrollmentStatus: typeof readClaustrumEnrollmentStatus;
27
27
  }): Promise<'local' | 'claustrum'>;
@@ -3,6 +3,6 @@ import type { NativeAccountMetadataPatch } from './native-account-view.ts';
3
3
  export declare function acquireNativeLocalPublisher(key: string): {
4
4
  release(): void;
5
5
  run: <T>(write: () => Promise<T>) => Promise<T>;
6
- enqueue(key: string, patch: NativeAccountMetadataPatch, write: (patch: NativeAccountMetadataPatch) => Promise<boolean>): Promise<boolean>;
6
+ enqueue(key: string, patch: NativeAccountMetadataPatch, write: (patch: NativeAccountMetadataPatch) => Promise<boolean>, signal?: AbortSignal): Promise<boolean>;
7
7
  drain(): Promise<void>;
8
8
  };
@@ -29,7 +29,7 @@ export declare class NativeQuotaObservations extends Map<string, NativeQuotaObse
29
29
  quota: OAuthQuotaSnapshot;
30
30
  clearAt?: number;
31
31
  } | undefined;
32
- publish(accountId: string, observation: NativeQuotaObservation, write: () => Promise<boolean>): Promise<void>;
32
+ publish(accountId: string, observation: NativeQuotaObservation, write: (signal: AbortSignal) => Promise<boolean>): Promise<void>;
33
33
  /**
34
34
  * Registers a response-header reading before its detached save starts, so
35
35
  * routing in this process sees it while the save waits on file locks. A
@@ -39,5 +39,9 @@ export declare class NativeQuotaObservations extends Map<string, NativeQuotaObse
39
39
  hold(accountId: string, observation: NativeQuotaObservation): boolean;
40
40
  /** Forgets a held reading whose save was refused, unless a later reading already replaced it. */
41
41
  forget(accountId: string, observation: NativeQuotaObservation): void;
42
+ /** Preserve the writer's result while tracking its lock wait for terminal shutdown. */
43
+ trackPublication<T>(write: (signal: AbortSignal) => Promise<T>): Promise<T>;
42
44
  drain(): Promise<void>;
45
+ close(): Promise<void>;
46
+ hasPendingPublications(): boolean;
43
47
  }
@@ -235,6 +235,6 @@ export type NativeRefreshResult = {
235
235
  };
236
236
  /** Independent local machinery: construction performs no network or migration. */
237
237
  export declare function createNativeRefreshCoordinator(options: NativeRefreshCoordinatorOptions): {
238
- authorize: (request: NativeRefreshRequest) => Promise<NativeRefreshResult>;
238
+ authorize(request: NativeRefreshRequest): Promise<NativeRefreshResult>;
239
239
  };
240
240
  export {};
@@ -93,6 +93,10 @@ export declare function decodeNativeRuntime(value: unknown, storageId: string):
93
93
  /** Read snapshots are deeply frozen; writer callbacks receive a mutable clone. */
94
94
  export declare function readNativeRuntime(path: string, storageId: string, ownership?: OwnerOnlyOptions): Promise<NativeRuntimeRead>;
95
95
  export interface NativeRuntimeWriteHooks {
96
+ /** Cancels lock acquisition only, never a write that already owns the lock. */
97
+ signal?: AbortSignal;
98
+ /** Synchronous authority and ownership check at each physical rename. */
99
+ beforeCommit?: () => void;
96
100
  onLockEvent?: (event: NativeLockEvent) => void;
97
101
  publication?: PublicationOptions;
98
102
  /** Verify that the observed account still matches the current pool record or vault roster and that the caller still owns the locks protecting those records. */
@@ -122,6 +126,8 @@ export type NativeRuntimeOptionalPublication = {
122
126
  status: 'skipped';
123
127
  };
124
128
  export interface NativeRuntimeOptionalWriteHooks {
129
+ signal?: AbortSignal;
130
+ beforeCommit?: () => void;
125
131
  onLockEvent?: (event: NativeLockEvent) => void;
126
132
  publication?: PublicationOptions;
127
133
  /**
@@ -9,9 +9,14 @@ export declare function classifySafeErrorForLog(error: unknown): {
9
9
  name: string;
10
10
  code: string;
11
11
  };
12
- /** Own advisory writes for one host instance and join them before runtime close. */
12
+ /** A retiring lease may stop waiting, but cannot cancel a shared runtime's writes. */
13
+ export declare function waitForNativeUsageDrain(work: Promise<unknown>): Promise<void>;
14
+ /** Own advisory writes; only terminal close may cancel pending lock acquisition. */
13
15
  export declare function createNativeUsagePublisher(channel: string): {
16
+ signal: AbortSignal;
17
+ hasPending: () => boolean;
14
18
  observe: (write: Promise<unknown>) => Promise<void>;
15
- publish(write: () => Promise<unknown>): void;
16
- drain(): Promise<void>;
19
+ publish(write: (signal: AbortSignal) => Promise<unknown>): void;
20
+ drain: () => Promise<void>;
21
+ close(): Promise<void>;
17
22
  };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Latches the Thalamus vault-host marker for the life of the process. The read
3
+ * mirrors common-auth's `hasVaultHost()`, which the pinned common-auth doesn't
4
+ * export yet. A later change of the marker refuses every request until restart.
5
+ */
6
+ export declare function isVaultHosted(): boolean;
7
+ /** Final synchronous admission fence after awaited reads and before credential use or publication. */
8
+ export declare function assertHostAuthorityStable(): void;
9
+ /** Cancel owned relay work as soon as any operation observes an authority change. */
10
+ export declare function onHostAuthorityChanged(stop: () => void): () => void;
11
+ /** Test-only process restart seam. Production callers must restart instead. */
12
+ export declare function resetVaultHostAuthorityForTests(): void;
@@ -4,6 +4,7 @@ export declare function watchNativeVaultAuthority(holder: {
4
4
  tokenPath: string;
5
5
  retain: (roster: NativeVaultRosterDocument | undefined) => void;
6
6
  close: () => void;
7
+ isHosted?: () => boolean;
7
8
  }): () => void;
8
9
  export declare function retainNativeVaultRoster(path: string, roster: NativeVaultRosterDocument | undefined): void;
9
10
  export declare function closeNativeVaultAuthority(tokenPath: string): void;
@@ -103,7 +103,7 @@ export interface NativeVaultRuntime {
103
103
  * The caller reports only the receipt rejected by its final HTTP attempt.
104
104
  */
105
105
  prepareRetry(receipt: NativeCustodyReceipt, signal?: AbortSignal, site?: NativeScoped401Site): Promise<NativeCustodyRetry>;
106
- publish(receipt: NativeCustodyReceipt, patch: NativeAccountMetadataPatch): Promise<boolean>;
106
+ publish(receipt: NativeCustodyReceipt, patch: NativeAccountMetadataPatch, signal?: AbortSignal): Promise<boolean>;
107
107
  fetchQuota(routeId: string, fetchImpl?: typeof fetch, signal?: AbortSignal, dispatch?: QuotaRequestDispatch, purpose?: NativeVaultQuotaPurpose): Promise<OAuthQuotaSnapshot>;
108
108
  fetchProfile(routeId: string, fetchImpl?: typeof fetch, signal?: AbortSignal): Promise<OAuthAccountProfile>;
109
109
  /** Return the fetched account profile without waiting for its metadata write. NativeDisplayProfile.persisted reports whether that asynchronous write succeeded, failed or was refused. */
package/dist/prime.d.ts CHANGED
@@ -163,8 +163,8 @@ export declare function primeMarkerPath(markerDir: string, accountId: 'main' | s
163
163
  /**
164
164
  * Scheduler for `/claude-prime`. Mirrors `CacheKeepManager` lifecycle (unref'd
165
165
  * 60s interval, idempotent start/stop, swallowed tick errors) but adds the
166
- * cross-process atomic marker claim before firing — exactly one OpenCode
167
- * process fires per reset epoch even with N concurrent instances.
166
+ * cross-process atomic marker claim before firing, shared across hosts and
167
+ * account stores when the Claude account identity is verified.
168
168
  *
169
169
  * Dependencies are injected so the manager can be exercised deterministically
170
170
  * without filesystem, network, or live OAuth state.
@@ -173,6 +173,8 @@ export type PrimeManagerOptions = {
173
173
  loadStorage: () => Promise<AccountStorage | null>;
174
174
  /** Returns a non-secret digest, or undefined when identity is unavailable. */
175
175
  getAccountFingerprint: (accountId: 'main' | string) => Promise<string | undefined>;
176
+ /** Returns the verified Claude account UUID, never a local route id. */
177
+ getAccountIdentity?: (accountId: 'main' | string) => Promise<string | undefined>;
176
178
  refreshQuota: (accountId: 'main' | string) => Promise<PrimeRefreshResult>;
177
179
  sendPrime: (accountId: 'main' | string) => Promise<PrimeSendResult>;
178
180
  recordSuccess: (accountId: 'main' | string, usage: {
@@ -215,7 +217,9 @@ export declare class PrimeManager {
215
217
  isWindowActive(accountId: 'main' | string): boolean;
216
218
  private runForAccount;
217
219
  private tryClaim;
218
- private tryClaimBootstrap;
220
+ private verifiedMarkerDir;
221
+ private verifiedMarkerPath;
222
+ private readMarkerNames;
219
223
  private tryClaimPath;
220
224
  private hasAnyClaimMarker;
221
225
  private fire;
@@ -0,0 +1,6 @@
1
+ export declare const SERVER_FALLBACK_USAGE_MARKER_TEXT = "\u2060\u2060";
2
+ export declare const SERVER_FALLBACK_USAGE_SIGNATURE_PREFIX = "cortexkit-server-fallback-usage-v1:";
3
+ /** Usage-only thinking parts are local metadata, not provider conversation state. */
4
+ export declare function isServerFallbackUsageMarker(value: unknown): boolean;
5
+ /** Strip by text or signature prefix, including markers with corrupted signatures. */
6
+ export declare function stripServerFallbackUsageMarkers(body: Record<string, unknown>): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/anthropic-auth-core",
3
- "version": "2.5.7",
3
+ "version": "2.6.0",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -30,7 +30,7 @@
30
30
  "prepublishOnly": "bun run build"
31
31
  },
32
32
  "devDependencies": {
33
- "@cortexkit/common-auth": "0.39.1"
33
+ "@cortexkit/common-auth": "0.40.0"
34
34
  },
35
35
  "dependencies": {
36
36
  "@cortexkit/claustrum-client": "0.13.0",