@cortexkit/anthropic-auth-core 2.4.3 → 2.4.5

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.
@@ -50,6 +50,12 @@ export interface ClaustrumConsumerOptions<Q = QuotaObservation> {
50
50
  * routine token refresh, which never moves the view.
51
51
  */
52
52
  onRoster?: (roster: VaultRosterFile) => void;
53
+ /**
54
+ * Called once when a coalesced discovery starts, with its completion promise.
55
+ * Covers explicit refresh, poll, watch and send-triggered discovery, even when
56
+ * the view does not change. Observe rejection when attaching async work.
57
+ */
58
+ onDiscovery?: (promise: Promise<VaultRosterFile | undefined>) => void;
53
59
  onError?: (error: unknown) => void;
54
60
  /**
55
61
  * How often `start()` ticks. A tick lists the vault when no vault watch is
@@ -104,6 +110,8 @@ export interface HubMemberPort {
104
110
  keptReceiptState(): KeptReceiptState;
105
111
  /** Apply the union of every member's roster in memory to kept receipts. */
106
112
  retainUnion(): void;
113
+ /** Share a committed preference change with live members using this roster file. */
114
+ publishRoster(roster: VaultRosterFile): void;
107
115
  forget(credentialId: string): void;
108
116
  /** The member closed: the hub stops committing and pushing to it. */
109
117
  detach(): void;
@@ -113,6 +121,8 @@ export interface HubRefreshOutcome {
113
121
  }
114
122
  /** What the hub may do to one member's memory. Package-internal. */
115
123
  export interface HubMemberHooks {
124
+ /** Observe a hub discovery without relying on member refresh overrides. */
125
+ discovery(promise: Promise<HubRefreshOutcome | undefined>): void;
116
126
  /**
117
127
  * Set the roster in memory as a consumer's own refresh does (pending quota
118
128
  * readings included) and notify `onRoster` when its view changed.
@@ -25,7 +25,8 @@ export interface ClaustrumFamily {
25
25
  /** Non-secret classification facts, including rows decoded by older clients. */
26
26
  export interface VaultRowFacts {
27
27
  readonly credentialId: string;
28
- readonly credentialType: string;
28
+ /** Internal serving type derived from `authMethod`, not the id's type hint. */
29
+ readonly credentialType: VaultCredentialType;
29
30
  readonly authMethod?: string;
30
31
  readonly refreshAdapter?: string;
31
32
  readonly providerIds?: readonly string[];
@@ -108,7 +109,10 @@ export interface VaultInventory {
108
109
  readonly view: string;
109
110
  readonly credentials: readonly VaultCredential[];
110
111
  readonly skipped: readonly SkippedVaultRecord[];
111
- /** Classifying families only: fixed refusal codes, never classifier errors. */
112
+ /**
113
+ * Classifying families only: declared policy codes or the fixed library codes
114
+ * `unknown-auth-method`, `unmapped` and `unclassified`, never classifier errors.
115
+ */
112
116
  readonly refused?: readonly {
113
117
  credentialId?: string;
114
118
  code: string;
@@ -1,5 +1,5 @@
1
1
  import type { QuotaObservation } from '../quota/index.js';
2
- import { type ClaustrumConsumer } from './consumer.js';
2
+ import { type ClaustrumConsumer, type ClaustrumConsumerOptions } from './consumer.js';
3
3
  import { type ClassifyingClaustrumFamily, type ClaustrumScopedClient, ClaustrumScopedCustody, type IdentityParser, type KeptReceiptState, type VaultGrantReach } from './custody.js';
4
4
  import { type ClaustrumLogger } from './errors.js';
5
5
  import { type AccountMapper, type VaultRosterFile } from './roster.js';
@@ -100,6 +100,8 @@ export interface ClaustrumHubMemberOptions<_Q = QuotaObservation> {
100
100
  reservedRouteIds?: () => Iterable<string>;
101
101
  /** As `ClaustrumConsumerOptions.onRoster`: once per change of view. */
102
102
  onRoster?: (roster: VaultRosterFile) => void;
103
+ /** Observe every hub discovery's member result, including background work. */
104
+ onDiscovery?: ClaustrumConsumerOptions<_Q>['onDiscovery'];
103
105
  /** This member's own failures, such as a roster commit that failed. */
104
106
  onError?: (error: unknown) => void;
105
107
  logger?: ClaustrumLogger;
@@ -21,7 +21,8 @@ export interface LockLoss {
21
21
  export interface RefreshFileLock {
22
22
  readonly ownerId: string;
23
23
  assertOwned(): Promise<void>;
24
- release(): Promise<void>;
24
+ /** Abort stops release retries; the unrenewed lease is left to expire by TTL. */
25
+ release(signal?: AbortSignal): Promise<void>;
25
26
  /** Resolves once on detected loss; remains pending after an owner's release. */
26
27
  whenLost(): Promise<LockLoss>;
27
28
  hasLost(): boolean;
@@ -0,0 +1,11 @@
1
+ import type { NativeRefreshResult } from './native-refresh-coordinator.ts';
2
+ export type NativeAccountRefusalReason = 'account-policy' | 'account-unavailable' | 'credential-changed';
3
+ /** A closed, credential-free refusal that retrying a background send cannot fix. */
4
+ export declare class NativeAccountRefusal extends Error {
5
+ readonly reason: NativeAccountRefusalReason;
6
+ constructor(reason: NativeAccountRefusalReason);
7
+ }
8
+ /** Unknown failures and vault outages retain the caller's existing retry policy. */
9
+ export declare function nativeAccountRefusal(error: unknown): NativeAccountRefusal | undefined;
10
+ /** Refresh/validation backoff and failed I/O are not permanent account refusals. */
11
+ export declare function nativeLocalAccountRefusal(result: NativeRefreshResult): NativeAccountRefusal | undefined;
@@ -1,4 +1,6 @@
1
1
  import type { OAuthQuotaSnapshot } from './accounts.ts';
2
2
  export declare function isQuotaBearingHeaderFrame(headers: Headers): boolean;
3
+ /** Only a rejected status or raw utilization at least one confirms a 429's limit. */
4
+ export declare function quotaExhaustionFromHeaders(headers: Headers, modelId?: string, now?: number): OAuthQuotaSnapshot;
3
5
  export declare function normalizeQuotaHeaders(headers: Headers, now?: number): OAuthQuotaSnapshot;
4
6
  export declare function mergeHeaderQuotaSnapshot(existing: OAuthQuotaSnapshot | undefined, incoming: OAuthQuotaSnapshot): OAuthQuotaSnapshot;
@@ -90,9 +90,12 @@ export declare function stickyRouteCandidateWeight(input: {
90
90
  export declare function stickyRouteKnownFableExhausted(candidate: StickyRouteCandidate, storage: AccountStorage | null, now?: number): boolean;
91
91
  export declare function decideStickyQuotaFailure(input: {
92
92
  quota: OAuthQuotaSnapshot | QuotaState | undefined;
93
+ responseHeaders?: Headers;
93
94
  modelId?: string;
94
95
  now?: number;
95
96
  }): StickyQuotaFailureDecision;
97
+ /** Bound an unconfirmed 429's host retry while preserving any shorter upstream wait. */
98
+ export declare function stickyRetainRetryHeaders(upstream: Headers, now?: number): Headers;
96
99
  export declare function getStickyRoutingStatePath(accountStoragePath: string): string;
97
100
  export declare function stickyRetryAfterWithJitter(sessionId: string, retryAfterSeconds: number): number;
98
101
  export declare class StickySessionRouter {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/anthropic-auth-core",
3
- "version": "2.4.3",
3
+ "version": "2.4.5",
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.29.0"
33
+ "@cortexkit/common-auth": "0.31.0"
34
34
  },
35
35
  "dependencies": {
36
36
  "@cortexkit/claustrum-client": "0.13.0",