@cortexkit/pi-openai-auth 1.5.0 → 1.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.
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
2
  import "@cortexkit/private-files";
3
3
  import { ClaustrumClient, EnrollmentPollOutcome } from "@cortexkit/claustrum-client";
4
4
  import { Api, AssistantMessageEventStream, Context, Model, SimpleStreamOptions } from "@earendil-works/pi-ai";
5
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.25.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/pi-slot/slot.d.ts
5
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.26.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/pi-slot/slot.d.ts
6
6
  interface PiSlotInspection {
7
7
  slot: 'original' | 'placeholder' | 'foreign' | 'empty';
8
8
  stash: 'valid' | 'missing';
@@ -13,7 +13,7 @@ interface PiSlot {
13
13
  exitVault(): Promise<'restored' | 'conflict' | 'nothing-to-do'>;
14
14
  }
15
15
  //#endregion
16
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.25.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/store/schema.d.ts
16
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.26.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/store/schema.d.ts
17
17
  type OAuthCredential = {
18
18
  type: 'oauth';
19
19
  access?: string;
@@ -202,7 +202,7 @@ interface PoolRow {
202
202
  unbound?: true;
203
203
  }
204
204
  //#endregion
205
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.25.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/store/errors.d.ts
205
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.26.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/store/errors.d.ts
206
206
  /** Every library operation that can fail, as named in the failure value. */
207
207
  type PoolOperation = 'initialize' | 'add' | 'replace' | 'rotate' | 'disable' | 'enable' | 'remove' | 'reorder' | 'updateSettings' | 'recordIdentity' | 'updateProviderState' | 'refresh' | 'pull' | 'publishRoster';
208
208
  /**
@@ -249,12 +249,12 @@ declare class PoolOperationError extends Error {
249
249
  });
250
250
  }
251
251
  //#endregion
252
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.25.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/store/hooks.d.ts
252
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.26.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/store/hooks.d.ts
253
253
  interface PoolLogger {
254
254
  warn(message: string, data?: unknown): void;
255
255
  }
256
256
  //#endregion
257
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.25.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/fs/refresh-file-lock.d.ts
257
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.26.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/fs/refresh-file-lock.d.ts
258
258
  interface LockLoss {
259
259
  readonly reason: 'taken-over' | 'expired' | 'unreadable' | 'renewal-failed' | 'marker-lost';
260
260
  readonly expectedOwnerId: string;
@@ -289,7 +289,7 @@ type RefreshFileLockOptions = {
289
289
  /** Filesystem leases share wall time across all callers and processes. */
290
290
  declare function acquireRefreshFileLock(options: RefreshFileLockOptions): Promise<RefreshFileLock | null>;
291
291
  //#endregion
292
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.25.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/store/refresh-lock.d.ts
292
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.26.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/store/refresh-lock.d.ts
293
293
  type LockStep = NonNullable<Parameters<typeof acquireRefreshFileLock>[0]['onStep']> extends ((step: infer S) => unknown) ? S : never;
294
294
  /** Tuning shared by every lock the store takes; each field is overridable. */
295
295
  interface PoolLockOptions {
@@ -321,7 +321,7 @@ interface LockEnvironment {
321
321
  }, event: 'scheduled' | 'cancelled') => void;
322
322
  }
323
323
  //#endregion
324
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.25.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/store/mutate.d.ts
324
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.26.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/store/mutate.d.ts
325
325
  /** Named points on the write path, for crash and ownership injection. */
326
326
  type WriteStep = 'before-config-write' | 'after-config-write' | 'before-state-write' | 'after-state-write';
327
327
  /** Awaitable pause points on the pull and refresh paths. */
@@ -356,11 +356,11 @@ interface StoreContext {
356
356
  /** What `initializePool` did. */
357
357
  type InitializeOutcome = 'initialized' | 'already-ready';
358
358
  //#endregion
359
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.25.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/store/runtime.d.ts
359
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.26.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/store/runtime.d.ts
360
360
  /** Where a pull was fired from; `load` fires at most once per process per row. */
361
361
  type PullReason = 'load' | 'add' | 'replace' | 'admission';
362
362
  //#endregion
363
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.25.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/store/attribution.d.ts
363
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.26.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/store/attribution.d.ts
364
364
  /**
365
365
  * What a pull or refresh captured about its row (named by id alongside) when
366
366
  * it was issued. A result applies only while the row with that id still has
@@ -383,7 +383,7 @@ interface Attribution {
383
383
  identity?: string;
384
384
  }
385
385
  //#endregion
386
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.25.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/store/rows.d.ts
386
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.26.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/store/rows.d.ts
387
387
  type FailureHook = (rowId: string, error: PoolOperationError) => void | Promise<void>;
388
388
  interface RowOperationOptions {
389
389
  /** Called once, awaited, on every non-success path, before locks release. */
@@ -599,7 +599,7 @@ interface RowTransitionResult {
599
599
  providerState?: unknown;
600
600
  }
601
601
  //#endregion
602
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.25.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/store/provider-state.d.ts
602
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.26.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/store/provider-state.d.ts
603
603
  /**
604
604
  * Receives a private copy of the row's provider state (undefined when the row
605
605
  * shows none) and the row as loaded under the locks, and returns the next
@@ -635,7 +635,7 @@ declare const DECLINE_TRANSITION: unique symbol;
635
635
  */
636
636
  type RowTransitionMutator = (current: unknown | undefined, row: PoolRow) => unknown | typeof DECLINE_TRANSITION | Promise<unknown | typeof DECLINE_TRANSITION>;
637
637
  //#endregion
638
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.25.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/store/publication.d.ts
638
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.26.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/store/publication.d.ts
639
639
  interface PublishPlan {
640
640
  operationId: string;
641
641
  remove: Array<{
@@ -678,7 +678,7 @@ interface PublishResult {
678
678
  receipt: PublicationReceipt;
679
679
  }
680
680
  //#endregion
681
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.25.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/store/pull.d.ts
681
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.26.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/store/pull.d.ts
682
682
  /** What a pull is issued with: the credential and its attribution tuple. */
683
683
  interface PullRequest {
684
684
  id: string;
@@ -689,7 +689,7 @@ interface PullRequest {
689
689
  }
690
690
  type PullHook = (request: PullRequest) => Promise<unknown>;
691
691
  //#endregion
692
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.25.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/store/refresh.d.ts
692
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.26.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/store/refresh.d.ts
693
693
  /** What the injected provider refresh function returns. */
694
694
  interface ProviderRefreshResult {
695
695
  access: string;
@@ -752,7 +752,7 @@ type RefreshOutcome = {
752
752
  reason: string;
753
753
  };
754
754
  //#endregion
755
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.25.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/store/settings.d.ts
755
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.26.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/store/settings.d.ts
756
756
  /** The plugin's settings: every top-level config key except the pool-owned ones. */
757
757
  type PoolSettings = Record<string, unknown>;
758
758
  type SettingsRead = {
@@ -796,13 +796,26 @@ type UpdateSettingsResult = {
796
796
  outcome: 'updated' | 'unchanged';
797
797
  };
798
798
  //#endregion
799
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.25.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/store/pool.d.ts
799
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.26.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/store/pool.d.ts
800
800
  interface OpenPoolStoreOptions {
801
801
  /** The provider every row of this pool belongs to; keys the provider-wide lock. */
802
802
  provider: string;
803
803
  configPath: string;
804
804
  statePath: string;
805
805
  quota: QuotaCodec;
806
+ /**
807
+ * Opt in to detached, coalesced quota publication, with any `quota` codec.
808
+ * Each accepted observation is queued whole for its row and binding, and
809
+ * the queue is applied in arrival order through `quota.merge` under the
810
+ * store locks, so the codec's own merge decides which fields a newer or
811
+ * older reading replaces. Accepted readings appear in read/load
812
+ * immediately, merged the same way; the returned promise still rejects
813
+ * current-row refusals before queueing. Await dispose or close at shutdown
814
+ * to drain.
815
+ */
816
+ coalesceQuota?: boolean;
817
+ /** Bounded quota drain on close/dispose, in milliseconds; defaults to 1,000. */
818
+ quotaDrainTimeoutMs?: number;
806
819
  /**
807
820
  * The codec of the provider state kept beside each row's credential (see
808
821
  * `ProviderStateCodec`). Without it no row shows a provider state, and
@@ -976,6 +989,10 @@ interface PoolStore {
976
989
  }>;
977
990
  refresh(id: string, provider: ProviderRefresh, options?: RefreshOptions): Promise<RefreshOutcome>;
978
991
  recordQuota(id: string, attribution: Attribution, observation: unknown): Promise<void>;
992
+ /** Drain opted-in quota publication; subsequent coalesced readings refuse. Idempotent. */
993
+ close(): Promise<void>;
994
+ /** Same bounded quota drain as close(). Does not wait for provider pull hooks. */
995
+ dispose(): Promise<void>;
979
996
  /** Fires a pull for a row admission refused for want of a reading. */
980
997
  requestReading(id: string): void;
981
998
  /** Resolves once every pull fired so far has settled. */
@@ -1210,7 +1227,7 @@ interface RefreshAllQuotaResult {
1210
1227
  permanent?: boolean;
1211
1228
  }
1212
1229
  //#endregion
1213
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.25.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/claustrum/watch.d.ts
1230
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.26.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/claustrum/watch.d.ts
1214
1231
  /**
1215
1232
  * How a host currently learns about changes, for logs and status displays.
1216
1233
  * `watching`: a watch was accepted and is open, so polling is reduced to a
@@ -1264,7 +1281,7 @@ interface ScopedWatchSource {
1264
1281
  }): ScopedWatchHandle;
1265
1282
  }
1266
1283
  //#endregion
1267
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.25.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/claustrum/insula.d.ts
1284
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.26.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/claustrum/insula.d.ts
1268
1285
  /**
1269
1286
  * A held-open `usage.watch` stream. `closed` resolves when insula ends the
1270
1287
  * stream (STREAM_END at shutdown, or a reply that ends it) or after `stop()`,
@@ -1288,7 +1305,7 @@ interface InsulaUsageTransport {
1288
1305
  watchUsage?(onNotice: (body: Uint8Array) => void): InsulaUsageWatch;
1289
1306
  }
1290
1307
  //#endregion
1291
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.25.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/claustrum/custody.d.ts
1308
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.26.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/claustrum/custody.d.ts
1292
1309
  /**
1293
1310
  * `watchScoped` is present from claustrum-client 0.12.0. Hosts detect it at
1294
1311
  * run time and keep polling without it.
@@ -1393,7 +1410,7 @@ interface KeptReceiptState {
1393
1410
  readonly since: number | null;
1394
1411
  }
1395
1412
  //#endregion
1396
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.25.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/quota/map.d.ts
1413
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.26.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/quota/map.d.ts
1397
1414
  interface QuotaReadingEntry {
1398
1415
  scope: string;
1399
1416
  label: string;
@@ -1466,7 +1483,7 @@ interface QuotaMap {
1466
1483
  credits?: QuotaCredits;
1467
1484
  }
1468
1485
  //#endregion
1469
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.25.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/quota/merge.d.ts
1486
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.26.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/quota/merge.d.ts
1470
1487
  interface ObservedReading {
1471
1488
  /** Defaults to `all`. */
1472
1489
  scope?: string;
@@ -1509,7 +1526,7 @@ interface QuotaObservation {
1509
1526
  credits?: QuotaCredits;
1510
1527
  }
1511
1528
  //#endregion
1512
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.25.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/claustrum/interlock.d.ts
1529
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.26.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/claustrum/interlock.d.ts
1513
1530
  /**
1514
1531
  * The declined-account interlock: the user's "do not use this vault account",
1515
1532
  * kept on the consumer side because the vault has no notion of it.
@@ -1528,7 +1545,7 @@ interface DeclinedAccount {
1528
1545
  readonly accountIdentity?: string;
1529
1546
  }
1530
1547
  //#endregion
1531
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.25.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/claustrum/roster.d.ts
1548
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.26.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/claustrum/roster.d.ts
1532
1549
  /**
1533
1550
  * One vault account as the pool sees it. It carries no bearer material: the
1534
1551
  * access token is fetched from the vault for every send. Several vault
@@ -1589,7 +1606,7 @@ interface ReorderVaultRosterResult {
1589
1606
  */
1590
1607
  type QuotaReceipt = Pick<ClaustrumScopedAttempt, 'credentialId' | 'accountIdentity' | 'accountIdentitySource' | 'expectedAccountIdentity'>;
1591
1608
  //#endregion
1592
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.25.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/claustrum/consumer.d.ts
1609
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.26.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/claustrum/consumer.d.ts
1593
1610
  /**
1594
1611
  * How a started consumer learns about changes, for logs and status displays.
1595
1612
  * `insula` is present when the consumer was given an insula source. Never
@@ -1600,7 +1617,7 @@ interface ClaustrumWatchState {
1600
1617
  readonly insula?: WatchMode;
1601
1618
  }
1602
1619
  //#endregion
1603
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.25.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/claustrum/enrollment.d.ts
1620
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.26.0+edd79cef82a5b402/node_modules/@cortexkit/common-auth/dist/claustrum/enrollment.d.ts
1604
1621
  interface ClaustrumEnrollmentClient {
1605
1622
  enrollPropose(input: {
1606
1623
  name: string;
@@ -2000,6 +2017,8 @@ declare class PiPoolSource {
2000
2017
  private snapshot;
2001
2018
  private inflightRead;
2002
2019
  private store;
2020
+ private readonly stores;
2021
+ private disposal;
2003
2022
  private initializing;
2004
2023
  private readonly refreshing;
2005
2024
  private readonly backoff;
@@ -2099,8 +2118,8 @@ declare class PiPoolSource {
2099
2118
  pollRows(storage: AccountStorage | null): Promise<PoolPollResult[]>;
2100
2119
  /** Whether Pi is in vault mode, which sets the whole pool aside. */
2101
2120
  private setAside;
2102
- /** Stops new polls and writes; ones already started finish on their own. */
2103
- dispose(): void;
2121
+ /** Stop admission, submit accepted snapshots, then drain each serving store. */
2122
+ dispose(): Promise<void>;
2104
2123
  /** Resolves once every queued quota write, poll, refresh and initialization has settled (tests). */
2105
2124
  settled(): Promise<void>;
2106
2125
  }