@cortexkit/pi-openai-auth 1.2.0 → 1.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/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.19.0+eac60b769bf9196b/node_modules/@cortexkit/common-auth/dist/pi-slot/slot.d.ts
5
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.23.0+48f2e2ce69c71a39/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.19.0+eac60b769bf9196b/node_modules/@cortexkit/common-auth/dist/store/schema.d.ts
16
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.23.0+48f2e2ce69c71a39/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.19.0+eac60b769bf9196b/node_modules/@cortexkit/common-auth/dist/store/errors.d.ts
205
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.23.0+48f2e2ce69c71a39/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.19.0+eac60b769bf9196b/node_modules/@cortexkit/common-auth/dist/store/hooks.d.ts
252
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.23.0+48f2e2ce69c71a39/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.19.0+eac60b769bf9196b/node_modules/@cortexkit/common-auth/dist/fs/refresh-file-lock.d.ts
257
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.23.0+48f2e2ce69c71a39/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.19.0+eac60b769bf9196b/node_modules/@cortexkit/common-auth/dist/store/refresh-lock.d.ts
292
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.23.0+48f2e2ce69c71a39/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.19.0+eac60b769bf9196b/node_modules/@cortexkit/common-auth/dist/store/mutate.d.ts
324
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.23.0+48f2e2ce69c71a39/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.19.0+eac60b769bf9196b/node_modules/@cortexkit/common-auth/dist/store/runtime.d.ts
359
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.23.0+48f2e2ce69c71a39/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.19.0+eac60b769bf9196b/node_modules/@cortexkit/common-auth/dist/store/attribution.d.ts
363
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.23.0+48f2e2ce69c71a39/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.19.0+eac60b769bf9196b/node_modules/@cortexkit/common-auth/dist/store/rows.d.ts
386
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.23.0+48f2e2ce69c71a39/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.19.0+eac60b769bf9196b/node_modules/@cortexkit/common-auth/dist/store/provider-state.d.ts
602
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.23.0+48f2e2ce69c71a39/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.19.0+eac60b769bf9196b/node_modules/@cortexkit/common-auth/dist/store/publication.d.ts
638
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.23.0+48f2e2ce69c71a39/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.19.0+eac60b769bf9196b/node_modules/@cortexkit/common-auth/dist/store/pull.d.ts
681
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.23.0+48f2e2ce69c71a39/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.19.0+eac60b769bf9196b/node_modules/@cortexkit/common-auth/dist/store/refresh.d.ts
692
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.23.0+48f2e2ce69c71a39/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.19.0+eac60b769bf9196b/node_modules/@cortexkit/common-auth/dist/store/settings.d.ts
755
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.23.0+48f2e2ce69c71a39/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,7 +796,7 @@ type UpdateSettingsResult = {
796
796
  outcome: 'updated' | 'unchanged';
797
797
  };
798
798
  //#endregion
799
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.19.0+eac60b769bf9196b/node_modules/@cortexkit/common-auth/dist/store/pool.d.ts
799
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.23.0+48f2e2ce69c71a39/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;
@@ -1033,11 +1033,19 @@ interface OAuthSpendControlReading {
1033
1033
  source?: string;
1034
1034
  reached: boolean;
1035
1035
  }
1036
+ /**
1037
+ * Prepaid workspace credits as the Codex backend reports them, in the usage
1038
+ * poll's `credits` object or the `x-codex-credits-*` response headers. The
1039
+ * headers carry no overage verdict, so `overageLimitReached` is optional.
1040
+ * `checkedAt` is when the source was read. It is optional because accounts
1041
+ * files written by older versions hold credits without it.
1042
+ */
1036
1043
  interface OAuthCredits {
1037
1044
  hasCredits: boolean;
1038
1045
  unlimited: boolean;
1039
- overageLimitReached: boolean;
1046
+ overageLimitReached?: boolean;
1040
1047
  balance?: number;
1048
+ checkedAt?: number;
1041
1049
  }
1042
1050
  type AccountBase = {
1043
1051
  id: string;
@@ -1202,17 +1210,92 @@ interface RefreshAllQuotaResult {
1202
1210
  permanent?: boolean;
1203
1211
  }
1204
1212
  //#endregion
1205
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.19.0+eac60b769bf9196b/node_modules/@cortexkit/common-auth/dist/claustrum/insula.d.ts
1213
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.23.0+48f2e2ce69c71a39/node_modules/@cortexkit/common-auth/dist/claustrum/watch.d.ts
1214
+ /**
1215
+ * How a host currently learns about changes, for logs and status displays.
1216
+ * `watching`: a watch was accepted and is open, so polling is reduced to a
1217
+ * slow safety read. `polling`: no watch is open yet (not started, opening, or
1218
+ * re-subscribing after a close), so the host polls at its usual interval.
1219
+ * `fallback`: the watch is unavailable (an older module or client, a refusal,
1220
+ * the watch limit, or repeated failures), so the host polls at its usual
1221
+ * interval and may try a watch again later. Never carries secrets.
1222
+ */
1223
+ type WatchMode = 'watching' | 'polling' | 'fallback';
1224
+ /**
1225
+ * The fields every change notice carries, from the vault's watchScoped and
1226
+ * insula's usage.watch alike.
1227
+ */
1228
+ interface ChangeNotice {
1229
+ readonly kind: string;
1230
+ readonly epoch: string;
1231
+ readonly seq: number;
1232
+ }
1233
+ /** A vault watch notice: `view` is the same digest `list_scoped` returns. */
1234
+ interface ScopedWatchNoticeShape extends ChangeNotice {
1235
+ readonly view: string;
1236
+ }
1237
+ /**
1238
+ * How a vault watch ended, as claustrum-client 0.12.0 reports it. `refused`
1239
+ * and `not_accepting` both mean the watch closed before its first notice; the
1240
+ * client then made one `list_scoped` read to learn why, and `refused` carries
1241
+ * that read's refusal.
1242
+ */
1243
+ type ScopedWatchEnd = {
1244
+ readonly kind: 'refused';
1245
+ readonly error: unknown;
1246
+ } | {
1247
+ readonly kind: 'transport_lost';
1248
+ readonly error: unknown;
1249
+ } | {
1250
+ readonly kind: 'ended' | 'not_accepting' | 'unsupported' | 'stopped';
1251
+ };
1252
+ interface ScopedWatchHandle {
1253
+ stop(): void;
1254
+ readonly closed: Promise<ScopedWatchEnd>;
1255
+ }
1256
+ /**
1257
+ * The part of a vault client that can watch. claustrum-client added
1258
+ * `watchScoped` in 0.12.0; the peer range still admits 0.6.2, so it is
1259
+ * optional and detected at run time.
1260
+ */
1261
+ interface ScopedWatchSource {
1262
+ watchScoped?(onNotice: (notice: ScopedWatchNoticeShape) => void, options?: {
1263
+ enrollmentToken?: string;
1264
+ }): ScopedWatchHandle;
1265
+ }
1266
+ //#endregion
1267
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.23.0+48f2e2ce69c71a39/node_modules/@cortexkit/common-auth/dist/claustrum/insula.d.ts
1268
+ /**
1269
+ * A held-open `usage.watch` stream. `closed` resolves when insula ends the
1270
+ * stream (STREAM_END at shutdown, or a reply that ends it) or after `stop()`,
1271
+ * and rejects with insula's refusal (an error with a `code`, such as
1272
+ * `unknown_method` from an insula that predates the method, or
1273
+ * `usage_watch_limit` when 64 watches are already open) or with the
1274
+ * transport failure.
1275
+ */
1276
+ interface InsulaUsageWatch {
1277
+ stop(): void;
1278
+ readonly closed: Promise<void>;
1279
+ }
1206
1280
  /** Optional transport for custom scoped clients; getUsage must not retry refusals. */
1207
1281
  interface InsulaUsageTransport {
1208
1282
  connectionFile: string;
1209
1283
  getUsage(): Promise<unknown>;
1284
+ /**
1285
+ * Open a `usage.watch` stream, passing each notice's raw JSON body to
1286
+ * `onNotice`. Optional: a transport without it is polled as before.
1287
+ */
1288
+ watchUsage?(onNotice: (body: Uint8Array) => void): InsulaUsageWatch;
1210
1289
  }
1211
1290
  //#endregion
1212
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.19.0+eac60b769bf9196b/node_modules/@cortexkit/common-auth/dist/claustrum/custody.d.ts
1291
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.23.0+48f2e2ce69c71a39/node_modules/@cortexkit/common-auth/dist/claustrum/custody.d.ts
1292
+ /**
1293
+ * `watchScoped` is present from claustrum-client 0.12.0. Hosts detect it at
1294
+ * run time and keep polling without it.
1295
+ */
1213
1296
  type ClaustrumScopedClient = Pick<ClaustrumClient, 'listScoped' | 'getScoped' | 'reportAuthFailureScoped' | 'close'> & {
1214
1297
  insula?: InsulaUsageTransport;
1215
- };
1298
+ } & ScopedWatchSource;
1216
1299
  /** The two credential types a plugin's family can hold; routing differs by type. */
1217
1300
  type VaultCredentialType = 'oauth' | 'api_key';
1218
1301
  /**
@@ -1297,9 +1380,20 @@ interface ClaustrumScopedAttempt {
1297
1380
  readonly accessToken: string;
1298
1381
  readonly recordVersion: number;
1299
1382
  readonly expiresAtMs: number | null;
1383
+ /**
1384
+ * True when this receipt was not freshly served but is the last token kept
1385
+ * from an earlier read, used because the vault could not be reached. A 401
1386
+ * with such a receipt must not be retried and is not reported to the vault,
1387
+ * which is unreachable.
1388
+ */
1389
+ readonly fromKeptReceipt?: true;
1390
+ }
1391
+ interface KeptReceiptState {
1392
+ readonly active: boolean;
1393
+ readonly since: number | null;
1300
1394
  }
1301
1395
  //#endregion
1302
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.19.0+eac60b769bf9196b/node_modules/@cortexkit/common-auth/dist/quota/map.d.ts
1396
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.23.0+48f2e2ce69c71a39/node_modules/@cortexkit/common-auth/dist/quota/map.d.ts
1303
1397
  interface QuotaReadingEntry {
1304
1398
  scope: string;
1305
1399
  label: string;
@@ -1346,15 +1440,33 @@ interface QuotaCounter {
1346
1440
  value: number;
1347
1441
  checkedAt: number;
1348
1442
  }
1443
+ /**
1444
+ * Prepaid credits a provider account holds beside its rate-limit windows (for
1445
+ * example a ChatGPT workspace's credits, which keep requests working after a
1446
+ * window is used up). This is a state, not a count or the spend budget: the
1447
+ * account has credits or not, they may be unlimited, and the provider may
1448
+ * report a balance. It carries its own observation time.
1449
+ */
1450
+ interface QuotaCredits {
1451
+ hasCredits: boolean;
1452
+ unlimited: boolean;
1453
+ /** The balance the provider reported, when it reported one. */
1454
+ balance?: number;
1455
+ /** The provider's verdict that the overage allowance is used up. */
1456
+ overageLimitReached?: boolean;
1457
+ checkedAt: number;
1458
+ }
1349
1459
  interface QuotaMap {
1350
1460
  limits: QuotaEntry[];
1351
1461
  /** Absent means no observation has reported on the budget yet. */
1352
1462
  budget?: CreditBudgetEntry;
1353
1463
  /** Provider-named counts, each with its own observation time. */
1354
1464
  counters?: Record<string, QuotaCounter>;
1465
+ /** Absent means no observation has reported on prepaid credits yet. */
1466
+ credits?: QuotaCredits;
1355
1467
  }
1356
1468
  //#endregion
1357
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.19.0+eac60b769bf9196b/node_modules/@cortexkit/common-auth/dist/quota/merge.d.ts
1469
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.23.0+48f2e2ce69c71a39/node_modules/@cortexkit/common-auth/dist/quota/merge.d.ts
1358
1470
  interface ObservedReading {
1359
1471
  /** Defaults to `all`. */
1360
1472
  scope?: string;
@@ -1390,9 +1502,14 @@ interface QuotaObservation {
1390
1502
  budget?: ObservedBudget;
1391
1503
  /** Each named count uses its own time, independently of limits and budget. */
1392
1504
  counters?: Record<string, QuotaCounter>;
1505
+ /**
1506
+ * Prepaid credits, judged by their own time independently of limits, budget
1507
+ * and counters. Absent means the observation says nothing about credits.
1508
+ */
1509
+ credits?: QuotaCredits;
1393
1510
  }
1394
1511
  //#endregion
1395
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.19.0+eac60b769bf9196b/node_modules/@cortexkit/common-auth/dist/claustrum/interlock.d.ts
1512
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.23.0+48f2e2ce69c71a39/node_modules/@cortexkit/common-auth/dist/claustrum/interlock.d.ts
1396
1513
  /**
1397
1514
  * The declined-account interlock: the user's "do not use this vault account",
1398
1515
  * kept on the consumer side because the vault has no notion of it.
@@ -1411,7 +1528,7 @@ interface DeclinedAccount {
1411
1528
  readonly accountIdentity?: string;
1412
1529
  }
1413
1530
  //#endregion
1414
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.19.0+eac60b769bf9196b/node_modules/@cortexkit/common-auth/dist/claustrum/roster.d.ts
1531
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.23.0+48f2e2ce69c71a39/node_modules/@cortexkit/common-auth/dist/claustrum/roster.d.ts
1415
1532
  /**
1416
1533
  * One vault account as the pool sees it. It carries no bearer material: the
1417
1534
  * access token is fetched from the vault for every send. Several vault
@@ -1466,7 +1583,18 @@ interface VaultRosterFile {
1466
1583
  */
1467
1584
  type QuotaReceipt = Pick<ClaustrumScopedAttempt, 'credentialId' | 'accountIdentity' | 'accountIdentitySource' | 'expectedAccountIdentity'>;
1468
1585
  //#endregion
1469
- //#region ../../node_modules/.bun/@cortexkit+common-auth@0.19.0+eac60b769bf9196b/node_modules/@cortexkit/common-auth/dist/claustrum/enrollment.d.ts
1586
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.23.0+48f2e2ce69c71a39/node_modules/@cortexkit/common-auth/dist/claustrum/consumer.d.ts
1587
+ /**
1588
+ * How a started consumer learns about changes, for logs and status displays.
1589
+ * `insula` is present when the consumer was given an insula source. Never
1590
+ * carries secrets.
1591
+ */
1592
+ interface ClaustrumWatchState {
1593
+ readonly vault: WatchMode;
1594
+ readonly insula?: WatchMode;
1595
+ }
1596
+ //#endregion
1597
+ //#region ../../node_modules/.bun/@cortexkit+common-auth@0.23.0+48f2e2ce69c71a39/node_modules/@cortexkit/common-auth/dist/claustrum/enrollment.d.ts
1470
1598
  interface ClaustrumEnrollmentClient {
1471
1599
  enrollPropose(input: {
1472
1600
  name: string;
@@ -1567,6 +1695,12 @@ interface OpenAiVaultOptions {
1567
1695
  pollIntervalMs?: number;
1568
1696
  fetchImpl?: () => typeof fetch;
1569
1697
  now?: () => number;
1698
+ /**
1699
+ * Replace the timers behind the background poll, the vault and insula
1700
+ * watches' retries and the outage probe (tests).
1701
+ */
1702
+ setTimeoutImpl?: typeof setTimeout;
1703
+ clearTimeoutImpl?: typeof clearTimeout;
1570
1704
  }
1571
1705
  /** One host's view of its OpenAI accounts in the vault. */
1572
1706
  declare class OpenAiVault {
@@ -1585,9 +1719,13 @@ declare class OpenAiVault {
1585
1719
  */
1586
1720
  enrolled(): boolean;
1587
1721
  /**
1588
- * Polls enrollment files and the vault's accounts. With local authority the
1589
- * consumer sends no vault request. A new enrollment completed by another
1590
- * process is detected on the next poll.
1722
+ * Starts the consumer's background poll and its vault and insula watches.
1723
+ * With local authority the consumer sends no vault request. A new
1724
+ * enrollment completed by another process is detected on the next poll.
1725
+ * While the vault watch is open the poll lists the vault only every five
1726
+ * minutes, and a notice that the visible accounts changed starts a
1727
+ * discovery at once; without a watch (an older vault or client, or a
1728
+ * refusal) every poll lists the vault as before.
1591
1729
  */
1592
1730
  start(): void;
1593
1731
  /**
@@ -1612,6 +1750,16 @@ declare class OpenAiVault {
1612
1750
  */
1613
1751
  refresh(): Promise<VaultRosterFile | undefined>;
1614
1752
  snapshot(): VaultRosterFile | undefined;
1753
+ /**
1754
+ * Whether the consumer learns about vault and insula changes from a watch
1755
+ * or by polling, without any I/O.
1756
+ */
1757
+ watchState(): ClaustrumWatchState;
1758
+ /**
1759
+ * Whether any account is being served the last token the vault gave it
1760
+ * because the vault cannot be reached, without any I/O.
1761
+ */
1762
+ keptReceiptState(): KeptReceiptState;
1615
1763
  /**
1616
1764
  * What the vault says this host is granted, from the latest list, without
1617
1765
  * any I/O. Undefined is unknown (a vault that does not report grants, or
@@ -1674,7 +1822,7 @@ declare class OpenAiVault {
1674
1822
  * the background; a failure is logged.
1675
1823
  */
1676
1824
  recordSnapshot(routeId: string, snapshot: unknown, complete: boolean, receipt: QuotaReceipt): Promise<void>;
1677
- /** Joins a quota poll; current insula quota for the same account replaces a background ChatGPT wham/usage request. */
1825
+ /** Joins a quota poll; insula decides whether a background provider read is needed. */
1678
1826
  pollQuota(routeId: string, background?: boolean): Promise<{
1679
1827
  ok: boolean;
1680
1828
  error?: string;
@@ -1767,7 +1915,10 @@ declare class PiMainAccount {
1767
1915
  currentIdentity(): string | undefined;
1768
1916
  /** The quota map routing reads: undefined until a reading arrives. */
1769
1917
  quotaMap(): QuotaMap | undefined;
1770
- /** The fixed windows of the quota map, plus the last poll's budget and reset credits. */
1918
+ /**
1919
+ * The fixed windows of the quota map and its prepaid credits, plus the last
1920
+ * poll's budget and reset credits.
1921
+ */
1771
1922
  quotaSnapshot(): OAuthQuotaSnapshot | undefined;
1772
1923
  /**
1773
1924
  * Asks for a quota poll, at most once per `MAIN_PULL_RETRY_MS` unless
@@ -1972,6 +2123,11 @@ declare class PiOpenAIRuntime {
1972
2123
  readonly pool: PiPoolSource;
1973
2124
  readonly vault: OpenAiVault;
1974
2125
  private readonly deps;
2126
+ /**
2127
+ * Which accounts this runtime serves on prepaid credits, so the info line
2128
+ * is written once when an account starts serving on them.
2129
+ */
2130
+ private readonly creditsServing;
1975
2131
  /**
1976
2132
  * The vault account behind each recent vault token, with the receipt the
1977
2133
  * vault served the token under, newest last, so a rate-limit frame