@cortexkit/pi-anthropic-auth 2.3.0 → 2.4.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.
package/dist/native.d.ts CHANGED
@@ -28,6 +28,7 @@ export interface PiVaultPollOptions {
28
28
  }
29
29
  export declare class PiNativeRuntime {
30
30
  private readonly paths;
31
+ private readonly holderRegistration;
31
32
  private readonly initialization;
32
33
  private readonly env;
33
34
  private vaultWatch;
package/dist/native.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { resolve } from 'node:path';
2
- import { acquireNativeAccountRuntime, createNativeUsagePublisher, getAccountStatePath, getHostClaustrumEnrollmentPaths, isKillswitchEnabled, killswitchPassesPolicy, logger, nativeAccountCanServe, nativeMigrationAuthorityPhase, nativeRuntimeOptionIdentity, quotaSnapshotHasStandardWindows, quotaSnapshotPassesModelScope, quotaSnapshotPassesPolicy, readNativeAccountsForRequest, readNativeMigrationJournal, resolveClaustrumConnectionPath, resolveLocalRoutingDestination, resolveNativePoolPaths, } from '@cortexkit/anthropic-auth-core';
2
+ import { acquireNativeAccountRuntime, createNativeUsagePublisher, getAccountStatePath, getHostClaustrumEnrollmentPaths, isKillswitchEnabled, killswitchPassesPolicy, logger, nativeAccountCanServe, nativeMigrationAuthorityPhase, nativeRuntimeOptionIdentity, quotaSnapshotHasStandardWindows, quotaSnapshotPassesModelScope, quotaSnapshotPassesPolicy, readNativeAccountsForRequest, readNativeMigrationJournal, registerNativePoolHolder, resolveClaustrumConnectionPath, resolveLocalRoutingDestination, resolveNativePoolPaths, } from '@cortexkit/anthropic-auth-core';
3
3
  import { getPiAccountStoragePath, getPiClaustrumConnectionOptions, getPiConfigDir, requirePiNativeHostAuth, } from './paths.js';
4
4
  export function piAttemptAccessToken(attempt) {
5
5
  return attempt.source === 'vault'
@@ -72,6 +72,7 @@ export function isNativeMigrationRequired(error) {
72
72
  export const PI_VAULT_POLL_INTERVAL_MS = 2000;
73
73
  export class PiNativeRuntime {
74
74
  paths;
75
+ holderRegistration;
75
76
  initialization;
76
77
  env;
77
78
  vaultWatch;
@@ -94,7 +95,19 @@ export class PiNativeRuntime {
94
95
  const poll = options.vaultPoll ?? { intervalMs: PI_VAULT_POLL_INTERVAL_MS };
95
96
  const identity = getPiClaustrumConnectionOptions(storagePath).identity;
96
97
  this.paths = resolveNativePoolPaths(storagePath);
97
- this.initialization = this.paths.then((paths) => {
98
+ // Record that this process uses these files before any pool I/O, so a
99
+ // later version never moves them while it runs. A refusal (the files
100
+ // were moved, or an override points into a managed folder) fails
101
+ // initialization, which every request then reports.
102
+ this.holderRegistration = this.paths.then((paths) => registerNativePoolHolder({
103
+ paths,
104
+ role: 'pi',
105
+ kind: 'pi',
106
+ onLockEvent: options.local?.onLockEvent,
107
+ }));
108
+ void this.holderRegistration.catch(() => { });
109
+ this.initialization = this.holderRegistration.then(async () => {
110
+ const paths = await this.paths;
98
111
  const runtime = acquireNativeAccountRuntime({
99
112
  paths,
100
113
  host: 'pi',
@@ -290,6 +303,7 @@ export class PiNativeRuntime {
290
303
  close() {
291
304
  this.closed = true;
292
305
  this.vaultWatch?.close();
306
+ void this.holderRegistration.then((registration) => registration.close(), () => { });
293
307
  this.closing ??= (async () => {
294
308
  await this.usagePublications.drain();
295
309
  await this.drainRoutingPublications();
package/dist/stream.js CHANGED
@@ -114,6 +114,7 @@ async function getPiStickyRouter(storagePath) {
114
114
  path,
115
115
  vaultSeed,
116
116
  onLockEvent: runtime.onLockEvent,
117
+ relocationGuard: runtime.relocationGuard,
117
118
  });
118
119
  setBoundedService(stickyRouters, path, router);
119
120
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/pi-anthropic-auth",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -36,7 +36,7 @@
36
36
  "prepublishOnly": "bun run build"
37
37
  },
38
38
  "dependencies": {
39
- "@cortexkit/anthropic-auth-core": "2.3.0"
39
+ "@cortexkit/anthropic-auth-core": "2.4.0"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@earendil-works/pi-ai": ">=0.86.1 <2",