@cortexkit/anthropic-auth-core 2.5.2 → 2.5.4

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.
@@ -1,17 +1,38 @@
1
+ import * as nodePath from 'node:path';
2
+ import { type HolderLiveness } from './holder-registry.ts';
3
+ import { type OwnerOnlyOptions } from './owner-only.ts';
1
4
  export declare const CACHE_KEEP_REGISTRY_LEASE_MS: number;
5
+ export declare const CACHE_KEEP_STOP_REASONS: readonly ['cost-cap', 'schedule', 'evicted', 'policy-refused', 'retries-exhausted', 'session-forgotten', 'disabled'];
6
+ export type CacheKeepStopReason = (typeof CACHE_KEEP_STOP_REASONS)[number];
2
7
  export type CacheKeepTrackedSession = {
3
8
  id: string;
4
9
  cacheExpiresAt: number;
5
10
  nextPrewarmAt: number;
11
+ ttlMs?: number;
12
+ lastTouchAt?: number;
13
+ lastTouchKind?: 'response' | 'warm';
14
+ warmStopped?: {
15
+ at: number;
16
+ reason: CacheKeepStopReason;
17
+ };
18
+ };
19
+ export declare function getLegacyCacheKeepRegistryDirectory(scope: 'opencode' | 'pi'): string;
20
+ export declare function getDefaultCacheKeepRegistryDirectory(scope: 'opencode' | 'pi', env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform, pathApi?: Pick<typeof nodePath, 'join' | 'resolve'>): string;
21
+ export declare function getCacheKeepRegistryDirectories(scope: 'opencode' | 'pi', override?: string, env?: NodeJS.ProcessEnv): {
22
+ directory: string;
23
+ legacyDirectory: string | undefined;
6
24
  };
7
- export declare function getDefaultCacheKeepRegistryDirectory(scope: 'opencode' | 'pi'): string;
8
25
  export declare class CacheKeepSessionRegistry {
9
26
  private readonly options;
10
- private readonly filePath;
27
+ private readonly directories;
28
+ private readonly filePaths;
11
29
  private writeChain;
12
30
  private lastSweepAt?;
13
31
  constructor(options: {
14
32
  directory: string;
33
+ legacyDirectory?: string;
34
+ ownerOnly?: OwnerOnlyOptions;
35
+ liveness?: HolderLiveness;
15
36
  now?: () => number;
16
37
  leaseMs?: number;
17
38
  instanceId?: string;
@@ -19,6 +40,8 @@ export declare class CacheKeepSessionRegistry {
19
40
  publish(sessions: readonly CacheKeepTrackedSession[]): Promise<void>;
20
41
  list(localSessions?: readonly CacheKeepTrackedSession[]): Promise<CacheKeepTrackedSession[]>;
21
42
  dispose(): Promise<void>;
43
+ private recordPaths;
44
+ private mayRemove;
22
45
  private sweepExpiredRecords;
23
46
  private restoreSweptRecord;
24
47
  }
@@ -1,6 +1,6 @@
1
1
  import type { AccountStorage } from './accounts.ts';
2
2
  import { type CacheKeepFailure } from './cachekeep-failure.ts';
3
- import type { CacheKeepTrackedSession } from './cachekeep-registry.ts';
3
+ import type { CacheKeepStopReason, CacheKeepTrackedSession } from './cachekeep-registry.ts';
4
4
  import { type NativeAccountRefusalReason } from './native-account-refusal.ts';
5
5
  import { type ProviderErrorSummary } from './provider-error.ts';
6
6
  export declare const CLAUDE_CACHE_KEEP_COMMAND_NAME = "claude-cachekeep";
@@ -95,7 +95,7 @@ export type CacheKeepTarget = {
95
95
  * untrack() when the round ends or its prefix becomes unusable.
96
96
  */
97
97
  sourceWarm?: boolean;
98
- };
98
+ } & Pick<CacheKeepTrackedSession, 'ttlMs' | 'lastTouchAt' | 'lastTouchKind'>;
99
99
  /**
100
100
  * Fingerprint of the cacheable prefix of a request body: tools, system
101
101
  * blocks, and messages up to the last cache breakpoint. The billing header
@@ -156,6 +156,7 @@ export type CacheKeepPrewarmValidation = {
156
156
  export declare class CacheKeepManager {
157
157
  private readonly options;
158
158
  private readonly targets;
159
+ private readonly stoppedSessions;
159
160
  private timer;
160
161
  private tickPromise;
161
162
  private nextPrewarmAttemptId;
@@ -210,6 +211,7 @@ export declare class CacheKeepManager {
210
211
  nextPrewarmAt: number | undefined;
211
212
  };
212
213
  trackedSessions(): CacheKeepTrackedSession[];
214
+ registrySessions(): CacheKeepTrackedSession[];
213
215
  trackedOAuthRoute(sessionId: string): {
214
216
  oauthAccountId?: string;
215
217
  } | undefined;
@@ -232,7 +234,7 @@ export declare class CacheKeepManager {
232
234
  * (a finished recovery round, a model change, a cleared session) and
233
235
  * logs it where the decision is made. Returns whether a target existed.
234
236
  */
235
- untrack(id: string): boolean;
237
+ untrack(id: string, reason?: CacheKeepStopReason): boolean;
236
238
  trackedCount(): number;
237
239
  /**
238
240
  * Drop targets whose cache has already expired, without sending or
@@ -243,6 +245,7 @@ export declare class CacheKeepManager {
243
245
  private publishTrackedSessions;
244
246
  private totalBodyBytes;
245
247
  private removeTarget;
248
+ private retainStopped;
246
249
  private evictOldestTarget;
247
250
  private pruneTargets;
248
251
  track(input: {
@@ -257,8 +260,9 @@ export declare class CacheKeepManager {
257
260
  accountStoragePath?: string;
258
261
  isSubagent?: boolean;
259
262
  sourceWarm?: boolean;
263
+ ttlMs?: number;
260
264
  /** Restore only the remaining lifetime, never grant a restarted cache a new hour. */
261
- retained?: Pick<CacheKeepTarget, 'cacheExpiresAt' | 'nextPrewarmAt'>;
265
+ retained?: Pick<CacheKeepTarget, 'cacheExpiresAt' | 'nextPrewarmAt' | 'ttlMs' | 'lastTouchAt' | 'lastTouchKind'>;
262
266
  }): {
263
267
  tracked: true;
264
268
  } | {
@@ -0,0 +1,3 @@
1
+ import * as nodePath from 'node:path';
2
+ export declare function getHostHome(env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): string;
3
+ export declare function getHostDataHome(env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform, pathApi?: Pick<typeof nodePath, 'join' | 'resolve'>): string;
package/dist/index.d.ts CHANGED
@@ -17,6 +17,7 @@ export * from './custom-headers.ts';
17
17
  export * from './dump.ts';
18
18
  export * from './fast.ts';
19
19
  export * from './holder-registry.ts';
20
+ export * from './host-paths.ts';
20
21
  export * from './json.ts';
21
22
  export * from './killswitch.ts';
22
23
  export * from './logger.ts';