@cortexkit/pi-openai-auth 1.0.2 → 1.0.3

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/README.md CHANGED
@@ -13,7 +13,7 @@ Requires Pi 1.0.1 or newer.
13
13
  Install with Pi's package manager:
14
14
 
15
15
  ```bash
16
- pi install npm:@cortexkit/pi-openai-auth@1.0.2
16
+ pi install npm:@cortexkit/pi-openai-auth@1.0.3
17
17
  ```
18
18
 
19
19
  For an unpinned install:
package/dist/index.d.ts CHANGED
@@ -2183,6 +2183,10 @@ interface ClaustrumEnrollmentPaths {
2183
2183
  tokenPath: string;
2184
2184
  }
2185
2185
  //#endregion
2186
+ //#region ../core/dist/pool-routing.d.ts
2187
+ /** Existing callbacks may return a promise for an in-progress quota poll. */
2188
+ type QuotaReadingRequest = ((id: string) => void) | ((id: string) => Promise<unknown> | undefined);
2189
+ //#endregion
2186
2190
  //#region ../core/dist/vault.d.ts
2187
2191
  type VaultHost = 'opencode' | 'pi';
2188
2192
  interface VaultPaths extends ClaustrumEnrollmentPaths {
@@ -2326,7 +2330,7 @@ declare class OpenAiVault {
2326
2330
  * the background; a failure is logged.
2327
2331
  */
2328
2332
  recordSnapshot(routeId: string, snapshot: unknown, complete: boolean, receipt: QuotaReceipt): Promise<void>;
2329
- /** Takes one quota reading for a vault account through the usage endpoint. */
2333
+ /** Joins an existing quota poll, or starts one through the usage endpoint. */
2330
2334
  pollQuota(routeId: string): Promise<{
2331
2335
  ok: boolean;
2332
2336
  error?: string;
@@ -2336,7 +2340,7 @@ declare class OpenAiVault {
2336
2340
  * because it has no reading yet. At most one reading per account is in
2337
2341
  * flight.
2338
2342
  */
2339
- requestReading(routeId: string): void;
2343
+ requestReading(routeId: string): ReturnType<QuotaReadingRequest>;
2340
2344
  /** Readings for the routable vault accounts whose last one is older than `maxAgeMs`. */
2341
2345
  pollStale(maxAgeMs: number): Promise<Array<{
2342
2346
  id: string;
@@ -2424,9 +2428,9 @@ declare class PiMainAccount {
2424
2428
  /**
2425
2429
  * Asks for a quota poll, at most once per `MAIN_PULL_RETRY_MS` unless
2426
2430
  * `force`. Admission calls this for every refusal for want of a reading, so
2427
- * it never waits.
2431
+ * callers may join the returned poll for their first reading.
2428
2432
  */
2429
- requestReading(force?: boolean): void;
2433
+ requestReading(force?: boolean): Promise<MainPollResult> | undefined;
2430
2434
  /** The poll under way, if any, so a caller may wait a bounded time for it. */
2431
2435
  pending(): Promise<MainPollResult> | undefined;
2432
2436
  /** Polls now (joining a poll already under way) and reports how it ended. */
@@ -2500,6 +2504,7 @@ declare class PiPoolSource {
2500
2504
  private readonly pending;
2501
2505
  private readonly writes;
2502
2506
  private readonly lastPull;
2507
+ private readonly quotaPulls;
2503
2508
  private readonly polled;
2504
2509
  /** The latest full poll snapshot per row id, for the `/openai` quota check. */
2505
2510
  private readonly polledSnapshots;
@@ -2537,7 +2542,6 @@ declare class PiPoolSource {
2537
2542
  * observed whose store write has not landed.
2538
2543
  */
2539
2544
  private withLocalState;
2540
- private merged;
2541
2545
  private replaceRow;
2542
2546
  /**
2543
2547
  * Polls every row this process has not polled for its current credential:
@@ -2548,9 +2552,11 @@ declare class PiPoolSource {
2548
2552
  /**
2549
2553
  * Asks the store for a quota poll of one row, at most once per
2550
2554
  * `POOL_PULL_RETRY_MS` unless `force`. Admission calls this for every row
2551
- * it refuses for want of a reading, so it never waits.
2555
+ * it refuses for want of a reading. First-reading admission may join the
2556
+ * returned promise; callers with an existing reading remain nonblocking.
2552
2557
  */
2553
- requestReading(id: string, force?: boolean): void;
2558
+ requestReading(id: string, force?: boolean): Promise<void> | undefined;
2559
+ private coalescedPull;
2554
2560
  private pull;
2555
2561
  private applyObservation;
2556
2562
  /**