@cortexkit/pi-openai-auth 1.0.5 → 1.2.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 +60 -28
- package/dist/index.js +24 -24
- package/package.json +3 -3
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.
|
|
5
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.19.0+eac60b769bf9196b/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.
|
|
16
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.19.0+eac60b769bf9196b/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.
|
|
205
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.19.0+eac60b769bf9196b/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.
|
|
252
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.19.0+eac60b769bf9196b/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.
|
|
257
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.19.0+eac60b769bf9196b/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;
|
|
@@ -269,7 +269,7 @@ interface RefreshFileLock {
|
|
|
269
269
|
whenLost(): Promise<LockLoss>;
|
|
270
270
|
hasLost(): boolean;
|
|
271
271
|
}
|
|
272
|
-
|
|
272
|
+
type RefreshFileLockOptions = {
|
|
273
273
|
name: string;
|
|
274
274
|
ttlMs: number;
|
|
275
275
|
/**
|
|
@@ -278,7 +278,6 @@ declare function acquireRefreshFileLock(options: {
|
|
|
278
278
|
* be one host's path.
|
|
279
279
|
*/
|
|
280
280
|
path: string;
|
|
281
|
-
now?: () => number;
|
|
282
281
|
renew?: boolean;
|
|
283
282
|
renewIntervalMs?: number;
|
|
284
283
|
/** Notifies a live-owner refusal without awaiting; observer failures are ignored. */
|
|
@@ -286,9 +285,11 @@ declare function acquireRefreshFileLock(options: {
|
|
|
286
285
|
/** Synchronous, never awaited; throws and returned promise/thenable rejections are isolated. */
|
|
287
286
|
onRenewalTimer?: (event: 'scheduled' | 'cancelled') => void;
|
|
288
287
|
onStep?: (step: 'stale-marker-stat' | 'stale-marker-claimed' | 'stale-lock-observed' | 'lock-read-ready' | 'lock-missing' | 'stale-lock-confirmed' | 'stale-lock-removed' | 'stale-lock-recreated' | 'eviction-marker-acquired' | 'renewal-owner-confirmed' | 'renewal-marker-unavailable' | 'renewal-write-fenced' | 'renewal-write-ready' | 'renewal-write-finished' | 'relinquish-read' | 'renewal-finished' | 'release-owner-confirmed') => void | Promise<void>;
|
|
289
|
-
}
|
|
288
|
+
};
|
|
289
|
+
/** Filesystem leases share wall time across all callers and processes. */
|
|
290
|
+
declare function acquireRefreshFileLock(options: RefreshFileLockOptions): Promise<RefreshFileLock | null>;
|
|
290
291
|
//#endregion
|
|
291
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
292
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.19.0+eac60b769bf9196b/node_modules/@cortexkit/common-auth/dist/store/refresh-lock.d.ts
|
|
292
293
|
type LockStep = NonNullable<Parameters<typeof acquireRefreshFileLock>[0]['onStep']> extends ((step: infer S) => unknown) ? S : never;
|
|
293
294
|
/** Tuning shared by every lock the store takes; each field is overridable. */
|
|
294
295
|
interface PoolLockOptions {
|
|
@@ -309,7 +310,6 @@ type LockEvent = {
|
|
|
309
310
|
path: string;
|
|
310
311
|
};
|
|
311
312
|
interface LockEnvironment {
|
|
312
|
-
now: () => number;
|
|
313
313
|
onLockEvent?: (event: LockEvent) => void;
|
|
314
314
|
onLockStep?: (lock: {
|
|
315
315
|
name: string;
|
|
@@ -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.
|
|
324
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.19.0+eac60b769bf9196b/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.
|
|
359
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.19.0+eac60b769bf9196b/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.
|
|
363
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.19.0+eac60b769bf9196b/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.
|
|
386
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.19.0+eac60b769bf9196b/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.
|
|
602
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.19.0+eac60b769bf9196b/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.
|
|
638
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.19.0+eac60b769bf9196b/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.
|
|
681
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.19.0+eac60b769bf9196b/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.
|
|
692
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.19.0+eac60b769bf9196b/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.
|
|
755
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.19.0+eac60b769bf9196b/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.
|
|
799
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.19.0+eac60b769bf9196b/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;
|
|
@@ -829,7 +829,7 @@ interface OpenPoolStoreOptions {
|
|
|
829
829
|
requireCredentialStamps?: boolean;
|
|
830
830
|
/** Require an exact secret fingerprint for every roster-publication removal. */
|
|
831
831
|
requireRemovedFingerprint?: boolean;
|
|
832
|
-
/**
|
|
832
|
+
/** Logical clock for refresh stamps and `addedAt`; filesystem leases always use wall time. */
|
|
833
833
|
now?: () => number;
|
|
834
834
|
/**
|
|
835
835
|
* Ordered store-lock list held across every read-modify-write. Defaults to
|
|
@@ -1202,14 +1202,14 @@ interface RefreshAllQuotaResult {
|
|
|
1202
1202
|
permanent?: boolean;
|
|
1203
1203
|
}
|
|
1204
1204
|
//#endregion
|
|
1205
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
1205
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.19.0+eac60b769bf9196b/node_modules/@cortexkit/common-auth/dist/claustrum/insula.d.ts
|
|
1206
1206
|
/** Optional transport for custom scoped clients; getUsage must not retry refusals. */
|
|
1207
1207
|
interface InsulaUsageTransport {
|
|
1208
1208
|
connectionFile: string;
|
|
1209
1209
|
getUsage(): Promise<unknown>;
|
|
1210
1210
|
}
|
|
1211
1211
|
//#endregion
|
|
1212
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
1212
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.19.0+eac60b769bf9196b/node_modules/@cortexkit/common-auth/dist/claustrum/custody.d.ts
|
|
1213
1213
|
type ClaustrumScopedClient = Pick<ClaustrumClient, 'listScoped' | 'getScoped' | 'reportAuthFailureScoped' | 'close'> & {
|
|
1214
1214
|
insula?: InsulaUsageTransport;
|
|
1215
1215
|
};
|
|
@@ -1229,6 +1229,30 @@ interface SkippedVaultRecord {
|
|
|
1229
1229
|
readonly credentialId?: string;
|
|
1230
1230
|
readonly reason: SkippedVaultReason;
|
|
1231
1231
|
}
|
|
1232
|
+
/**
|
|
1233
|
+
* One grant this consumer's enrollment holds, as the vault's list reply names
|
|
1234
|
+
* it: for example `{ selectorKind: 'category', selector: 'openai-native',
|
|
1235
|
+
* operation: 'read' }`. `selectorKind` is `exact` (the selector is a credential
|
|
1236
|
+
* id) or `category` (a bare category name); both open strings.
|
|
1237
|
+
*/
|
|
1238
|
+
interface VaultGrantTuple {
|
|
1239
|
+
readonly selectorKind: string;
|
|
1240
|
+
readonly selector: string;
|
|
1241
|
+
readonly operation: string;
|
|
1242
|
+
}
|
|
1243
|
+
/**
|
|
1244
|
+
* What this consumer is granted, independent of what those grants currently
|
|
1245
|
+
* reach. It is what tells two empty listings apart: no rows with `grants === 0`
|
|
1246
|
+
* means no grant at all (the fix is `ck auth grant`), while no rows with
|
|
1247
|
+
* `grants > 0` means a grant that reaches no credential, usually logins that
|
|
1248
|
+
* lack the category (`ck auth reclassify --from-registry`); `tuples` names the
|
|
1249
|
+
* selector that matched nothing. Never written to the roster file.
|
|
1250
|
+
*/
|
|
1251
|
+
interface VaultGrantReach {
|
|
1252
|
+
/** How many grants the consumer holds, deposit grants excluded. */
|
|
1253
|
+
readonly grants: number;
|
|
1254
|
+
readonly tuples: readonly VaultGrantTuple[];
|
|
1255
|
+
}
|
|
1232
1256
|
/**
|
|
1233
1257
|
* Where a receipt's `accountIdentity` came from: the vault asserted it in the
|
|
1234
1258
|
* served reply, the plugin's `parseIdentity` read it from the served token, or
|
|
@@ -1275,7 +1299,7 @@ interface ClaustrumScopedAttempt {
|
|
|
1275
1299
|
readonly expiresAtMs: number | null;
|
|
1276
1300
|
}
|
|
1277
1301
|
//#endregion
|
|
1278
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
1302
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.19.0+eac60b769bf9196b/node_modules/@cortexkit/common-auth/dist/quota/map.d.ts
|
|
1279
1303
|
interface QuotaReadingEntry {
|
|
1280
1304
|
scope: string;
|
|
1281
1305
|
label: string;
|
|
@@ -1330,7 +1354,7 @@ interface QuotaMap {
|
|
|
1330
1354
|
counters?: Record<string, QuotaCounter>;
|
|
1331
1355
|
}
|
|
1332
1356
|
//#endregion
|
|
1333
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
1357
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.19.0+eac60b769bf9196b/node_modules/@cortexkit/common-auth/dist/quota/merge.d.ts
|
|
1334
1358
|
interface ObservedReading {
|
|
1335
1359
|
/** Defaults to `all`. */
|
|
1336
1360
|
scope?: string;
|
|
@@ -1368,7 +1392,7 @@ interface QuotaObservation {
|
|
|
1368
1392
|
counters?: Record<string, QuotaCounter>;
|
|
1369
1393
|
}
|
|
1370
1394
|
//#endregion
|
|
1371
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
1395
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.19.0+eac60b769bf9196b/node_modules/@cortexkit/common-auth/dist/claustrum/interlock.d.ts
|
|
1372
1396
|
/**
|
|
1373
1397
|
* The declined-account interlock: the user's "do not use this vault account",
|
|
1374
1398
|
* kept on the consumer side because the vault has no notion of it.
|
|
@@ -1387,7 +1411,7 @@ interface DeclinedAccount {
|
|
|
1387
1411
|
readonly accountIdentity?: string;
|
|
1388
1412
|
}
|
|
1389
1413
|
//#endregion
|
|
1390
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
1414
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.19.0+eac60b769bf9196b/node_modules/@cortexkit/common-auth/dist/claustrum/roster.d.ts
|
|
1391
1415
|
/**
|
|
1392
1416
|
* One vault account as the pool sees it. It carries no bearer material: the
|
|
1393
1417
|
* access token is fetched from the vault for every send. Several vault
|
|
@@ -1442,7 +1466,7 @@ interface VaultRosterFile {
|
|
|
1442
1466
|
*/
|
|
1443
1467
|
type QuotaReceipt = Pick<ClaustrumScopedAttempt, 'credentialId' | 'accountIdentity' | 'accountIdentitySource' | 'expectedAccountIdentity'>;
|
|
1444
1468
|
//#endregion
|
|
1445
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
1469
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.19.0+eac60b769bf9196b/node_modules/@cortexkit/common-auth/dist/claustrum/enrollment.d.ts
|
|
1446
1470
|
interface ClaustrumEnrollmentClient {
|
|
1447
1471
|
enrollPropose(input: {
|
|
1448
1472
|
name: string;
|
|
@@ -1502,6 +1526,8 @@ interface VaultPaths extends ClaustrumEnrollmentPaths {
|
|
|
1502
1526
|
/** One vault account as routing sees it. */
|
|
1503
1527
|
interface VaultRoute {
|
|
1504
1528
|
id: string;
|
|
1529
|
+
/** The vault credential name, distinct from its stable routing id. */
|
|
1530
|
+
credentialId?: string;
|
|
1505
1531
|
kind: 'oauth' | 'api-key';
|
|
1506
1532
|
/** The ChatGPT account it signs in as, when the vault knows it. */
|
|
1507
1533
|
identity?: string;
|
|
@@ -1586,6 +1612,12 @@ declare class OpenAiVault {
|
|
|
1586
1612
|
*/
|
|
1587
1613
|
refresh(): Promise<VaultRosterFile | undefined>;
|
|
1588
1614
|
snapshot(): VaultRosterFile | undefined;
|
|
1615
|
+
/**
|
|
1616
|
+
* What the vault says this host is granted, from the latest list, without
|
|
1617
|
+
* any I/O. Undefined is unknown (a vault that does not report grants, or
|
|
1618
|
+
* nothing listed yet), never zero grants.
|
|
1619
|
+
*/
|
|
1620
|
+
grantReach(): VaultGrantReach | undefined;
|
|
1589
1621
|
/** Whether the vault serves this host any account (whatever its state). */
|
|
1590
1622
|
serves(): boolean;
|
|
1591
1623
|
/**
|