@cortexkit/anthropic-auth-core 2.6.0 → 2.7.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.
@@ -15,6 +15,7 @@ export declare const VAULT_FAILURE_CLASSES: Readonly<{
15
15
  unavailable: "unreachable";
16
16
  timeout: "unreachable";
17
17
  route_closed: "unreachable";
18
+ route_busy: "unreachable";
18
19
  daemon_draining: "unreachable";
19
20
  connection_closed: "unreachable";
20
21
  connection_dropped: "unreachable";
@@ -6,7 +6,7 @@ export { ClaustrumConsumer, type ClaustrumConsumerOptions, type ClaustrumWatchSt
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
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
+ export { connectVaultHost, hasVaultHost, VAULT_HOST_CONNECT_REFUSAL, VAULT_HOST_STATUS, } from './host.js';
10
10
  export { assertHostSlotMatchesMode, assertNotCustodyPlaceholder, CUSTODY_PLACEHOLDER_PREFIX, classifyHostSlot, custodyPlaceholder, custodyPlaceholderKey, type HostSlotContent, isCustodyPlaceholder, isCustodyPlaceholderValue, } from './host-slot.js';
11
11
  export { ClaustrumDiscoveryHub, type ClaustrumDiscoveryHubOptions, type ClaustrumHubMemberOptions, type ClaustrumHubRefusals, type ClaustrumLeasedCustody, type CustodyLease, } from './hub.js';
12
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';
@@ -0,0 +1,51 @@
1
+ export type SessionCacheTtl = 'none' | 'short' | 'long';
2
+ export type SessionKeepWarmMode = 'off' | 'hours' | 'always' | 'auto';
3
+ export interface SessionCacheHours {
4
+ from: string;
5
+ to: string;
6
+ tz: string;
7
+ }
8
+ export interface SessionCachePolicy {
9
+ ttl?: SessionCacheTtl;
10
+ keep_warm?: SessionKeepWarmMode;
11
+ hours?: SessionCacheHours;
12
+ }
13
+ export interface SessionToolWait {
14
+ /** Epoch milliseconds when the oldest running plan tool started. */
15
+ since: number;
16
+ }
17
+ /**
18
+ * The stop reasons the llm-runner contract defines today; any other string is
19
+ * accepted too, for reasons that contract adds later.
20
+ */
21
+ export type CacheWarmStopReason = 'cost-cap' | 'count-cap' | 'outside-hours' | 'session-ended' | 'unsupported' | (string & Record<never, never>);
22
+ export interface CacheTouchInput {
23
+ /** Integer epoch milliseconds when the provider answered. */
24
+ at: number;
25
+ ttlMs: number | 'implicit';
26
+ source: 'response' | 'warm';
27
+ }
28
+ export interface CacheWarmStoppedInput {
29
+ /** Integer epoch milliseconds. */
30
+ at: number;
31
+ reason: CacheWarmStopReason;
32
+ }
33
+ /**
34
+ * Read the session's current plan on every decision; never retain it across
35
+ * requests. Null means the plugin keeps its own settings. No I/O or exceptions.
36
+ */
37
+ export declare function sessionCachePolicy(sessionId: string): SessionCachePolicy | null;
38
+ /** Read the oldest running plan tool afresh, without I/O or exceptions. */
39
+ export declare function sessionToolWait(sessionId: string): SessionToolWait | null;
40
+ /**
41
+ * Call only after the reply has been handed to the host, never on the awaited
42
+ * request path. Synchronous fire-and-forget, with no retries; the bridge owns
43
+ * redelivery of the newest touch. Accessor and report failures are absorbed.
44
+ */
45
+ export declare function reportCacheTouch(sessionId: string, input: CacheTouchInput): void;
46
+ /**
47
+ * Call off the request path, after handing the reply to the host. Report only
48
+ * a session that actually warmed, never one that was off from the start.
49
+ * Synchronous fire-and-forget; failures are absorbed and never retried here.
50
+ */
51
+ export declare function reportCacheWarmStopped(sessionId: string, input: CacheWarmStoppedInput): void;
@@ -3,6 +3,8 @@
3
3
  * shaping. Account ids are vault account ids, not local pool rows. Nothing is
4
4
  * persisted here; plugins on routes the runner does not serve get no turn notes.
5
5
  */
6
+ export type { CacheTouchInput, CacheWarmStoppedInput, CacheWarmStopReason, SessionCacheHours, SessionCachePolicy, SessionCacheTtl, SessionKeepWarmMode, SessionToolWait, } from './cache-policy.js';
7
+ export { reportCacheTouch, reportCacheWarmStopped, sessionCachePolicy, sessionToolWait, } from './cache-policy.js';
6
8
  /** An eligible vault route, not a local pool row. */
7
9
  export interface RoutingCandidate {
8
10
  /** Vault account id, not the plugin's route id. */
@@ -94,4 +96,3 @@ export declare function askRouting<Candidate extends RoutingCandidate>(input: As
94
96
  * or redacted here.
95
97
  */
96
98
  export declare function reportRouting(input: ReportRoutingInput): void;
97
- export {};
@@ -9,7 +9,7 @@ export declare class SessionCacheActivity {
9
9
  record(sessionId: string, accountId: string, ttlMs: number | undefined, lastAcceptedAt?: number): void;
10
10
  holdUntil(sessionId: string | null | undefined, accountId: string, now?: number, maxWait?: MaxSameAccountWait): number | undefined;
11
11
  /** A late keep-warm send must not replace a newer turn on a different account. */
12
- recordPrewarm(sessionId: string, accountId: string, acceptedAt?: number): void;
12
+ recordPrewarm(sessionId: string, accountId: string, acceptedAt?: number, ttlMs?: number): void;
13
13
  forget(sessionId: string): void;
14
14
  ttlMs(sessionId: string | null | undefined): number;
15
15
  }
@@ -0,0 +1,21 @@
1
+ import { type CacheTouchInput, type CacheWarmStoppedInput, type SessionCachePolicy, type SessionCacheTtl } from "./internal-types/routing-accessor/index.js";
2
+ export type { SessionCachePolicy, SessionCacheTtl, SessionKeepWarmMode, } from "./internal-types/routing-accessor/index.js";
3
+ /** API-key requests return no session cache policy, leaving host settings unchanged. */
4
+ export declare function readSessionCachePolicy(sessionId: string | null | undefined, isOAuth: boolean): SessionCachePolicy | null;
5
+ /**
6
+ * Admitting a real response can retire an older warmed target before body
7
+ * inspection finishes. Buffer both report kinds until the outer host callback
8
+ * settles; later background callbacks still send without awaiting the bridge.
9
+ */
10
+ export declare function withSessionCacheReportHandoff<Args extends unknown[], T>(work: (...args: Args) => Promise<T>): (...args: Args) => Promise<T>;
11
+ /**
12
+ * Queue at host hand-off or after a completed background warm. Thalamus's
13
+ * routing report bridge, not auth, resends its newest failed touch.
14
+ */
15
+ export declare function reportSessionCacheTouch(sessionId: string, input: CacheTouchInput): void;
16
+ /** Stops describe actual warming, not a refusal to start warming. */
17
+ export declare function reportSessionCacheWarmStopped(sessionId: string, input: CacheWarmStoppedInput): boolean;
18
+ /** Apply only a lifetime override; the host still chooses breakpoint placement. */
19
+ export declare function applySessionCacheTtl(body: Record<string, unknown>, ttl: SessionCacheTtl | undefined): void;
20
+ /** The longest sent cache lifetime bounds when every cached prefix is gone. */
21
+ export declare function requestCacheLifetimeMs(input: Record<string, unknown> | string): number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/anthropic-auth-core",
3
- "version": "2.6.0",
3
+ "version": "2.7.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.40.0"
33
+ "@cortexkit/common-auth": "0.42.0"
34
34
  },
35
35
  "dependencies": {
36
36
  "@cortexkit/claustrum-client": "0.13.0",