@cortexkit/pi-openai-auth 1.0.3 → 1.0.5
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 +8 -42
- package/dist/index.d.ts +56 -743
- package/dist/index.js +28 -29
- package/package.json +8 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import "@cortexkit/private-files";
|
|
3
|
+
import { ClaustrumClient, EnrollmentPollOutcome } from "@cortexkit/claustrum-client";
|
|
2
4
|
import { Api, AssistantMessageEventStream, Context, Model, SimpleStreamOptions } from "@earendil-works/pi-ai";
|
|
3
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
5
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.17.1+0d2d5e37d881ac14/node_modules/@cortexkit/common-auth/dist/pi-slot/slot.d.ts
|
|
4
6
|
interface PiSlotInspection {
|
|
5
7
|
slot: 'original' | 'placeholder' | 'foreign' | 'empty';
|
|
6
8
|
stash: 'valid' | 'missing';
|
|
@@ -11,7 +13,7 @@ interface PiSlot {
|
|
|
11
13
|
exitVault(): Promise<'restored' | 'conflict' | 'nothing-to-do'>;
|
|
12
14
|
}
|
|
13
15
|
//#endregion
|
|
14
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
16
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.17.1+0d2d5e37d881ac14/node_modules/@cortexkit/common-auth/dist/store/schema.d.ts
|
|
15
17
|
type OAuthCredential = {
|
|
16
18
|
type: 'oauth';
|
|
17
19
|
access?: string;
|
|
@@ -40,6 +42,8 @@ type StoredCredential = (OAuthCredential & {
|
|
|
40
42
|
/** Quota codec supplied by `/quota`: the store never interprets the map itself. */
|
|
41
43
|
interface QuotaCodec {
|
|
42
44
|
validate(value: unknown): boolean;
|
|
45
|
+
/** Normalize persisted quota before validation, when the codec supports it. */
|
|
46
|
+
decode?(value: unknown): unknown;
|
|
43
47
|
merge(stored: unknown | undefined, observation: unknown): unknown;
|
|
44
48
|
}
|
|
45
49
|
/**
|
|
@@ -198,7 +202,7 @@ interface PoolRow {
|
|
|
198
202
|
unbound?: true;
|
|
199
203
|
}
|
|
200
204
|
//#endregion
|
|
201
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
205
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.17.1+0d2d5e37d881ac14/node_modules/@cortexkit/common-auth/dist/store/errors.d.ts
|
|
202
206
|
/** Every library operation that can fail, as named in the failure value. */
|
|
203
207
|
type PoolOperation = 'initialize' | 'add' | 'replace' | 'rotate' | 'disable' | 'enable' | 'remove' | 'reorder' | 'updateSettings' | 'recordIdentity' | 'updateProviderState' | 'refresh' | 'pull' | 'publishRoster';
|
|
204
208
|
/**
|
|
@@ -245,12 +249,12 @@ declare class PoolOperationError extends Error {
|
|
|
245
249
|
});
|
|
246
250
|
}
|
|
247
251
|
//#endregion
|
|
248
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
252
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.17.1+0d2d5e37d881ac14/node_modules/@cortexkit/common-auth/dist/store/hooks.d.ts
|
|
249
253
|
interface PoolLogger {
|
|
250
254
|
warn(message: string, data?: unknown): void;
|
|
251
255
|
}
|
|
252
256
|
//#endregion
|
|
253
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
257
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.17.1+0d2d5e37d881ac14/node_modules/@cortexkit/common-auth/dist/fs/refresh-file-lock.d.ts
|
|
254
258
|
interface LockLoss {
|
|
255
259
|
readonly reason: 'taken-over' | 'expired' | 'unreadable' | 'renewal-failed' | 'marker-lost';
|
|
256
260
|
readonly expectedOwnerId: string;
|
|
@@ -281,10 +285,10 @@ declare function acquireRefreshFileLock(options: {
|
|
|
281
285
|
onContended?: () => void;
|
|
282
286
|
/** Synchronous, never awaited; throws and returned promise/thenable rejections are isolated. */
|
|
283
287
|
onRenewalTimer?: (event: 'scheduled' | 'cancelled') => void;
|
|
284
|
-
onStep?: (step: 'stale-marker-stat' | 'stale-marker-claimed' | 'stale-lock-observed' | 'stale-lock-confirmed' | 'stale-lock-removed' | 'stale-lock-recreated' | 'eviction-marker-acquired' | 'renewal-owner-confirmed' | 'renewal-marker-unavailable' | 'renewal-write-fenced' | 'renewal-write-ready' | 'relinquish-read' | 'renewal-finished' | 'release-owner-confirmed') => void | Promise<void>;
|
|
288
|
+
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>;
|
|
285
289
|
}): Promise<RefreshFileLock | null>;
|
|
286
290
|
//#endregion
|
|
287
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
291
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.17.1+0d2d5e37d881ac14/node_modules/@cortexkit/common-auth/dist/store/refresh-lock.d.ts
|
|
288
292
|
type LockStep = NonNullable<Parameters<typeof acquireRefreshFileLock>[0]['onStep']> extends ((step: infer S) => unknown) ? S : never;
|
|
289
293
|
/** Tuning shared by every lock the store takes; each field is overridable. */
|
|
290
294
|
interface PoolLockOptions {
|
|
@@ -311,9 +315,13 @@ interface LockEnvironment {
|
|
|
311
315
|
name: string;
|
|
312
316
|
path: string;
|
|
313
317
|
}, step: LockStep) => void | Promise<void>;
|
|
318
|
+
onRenewalTimer?: (lock: {
|
|
319
|
+
name: string;
|
|
320
|
+
path: string;
|
|
321
|
+
}, event: 'scheduled' | 'cancelled') => void;
|
|
314
322
|
}
|
|
315
323
|
//#endregion
|
|
316
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
324
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.17.1+0d2d5e37d881ac14/node_modules/@cortexkit/common-auth/dist/store/mutate.d.ts
|
|
317
325
|
/** Named points on the write path, for crash and ownership injection. */
|
|
318
326
|
type WriteStep = 'before-config-write' | 'after-config-write' | 'before-state-write' | 'after-state-write';
|
|
319
327
|
/** Awaitable pause points on the pull and refresh paths. */
|
|
@@ -348,11 +356,11 @@ interface StoreContext {
|
|
|
348
356
|
/** What `initializePool` did. */
|
|
349
357
|
type InitializeOutcome = 'initialized' | 'already-ready';
|
|
350
358
|
//#endregion
|
|
351
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
359
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.17.1+0d2d5e37d881ac14/node_modules/@cortexkit/common-auth/dist/store/runtime.d.ts
|
|
352
360
|
/** Where a pull was fired from; `load` fires at most once per process per row. */
|
|
353
361
|
type PullReason = 'load' | 'add' | 'replace' | 'admission';
|
|
354
362
|
//#endregion
|
|
355
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
363
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.17.1+0d2d5e37d881ac14/node_modules/@cortexkit/common-auth/dist/store/attribution.d.ts
|
|
356
364
|
/**
|
|
357
365
|
* What a pull or refresh captured about its row (named by id alongside) when
|
|
358
366
|
* it was issued. A result applies only while the row with that id still has
|
|
@@ -375,7 +383,7 @@ interface Attribution {
|
|
|
375
383
|
identity?: string;
|
|
376
384
|
}
|
|
377
385
|
//#endregion
|
|
378
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
386
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.17.1+0d2d5e37d881ac14/node_modules/@cortexkit/common-auth/dist/store/rows.d.ts
|
|
379
387
|
type FailureHook = (rowId: string, error: PoolOperationError) => void | Promise<void>;
|
|
380
388
|
interface RowOperationOptions {
|
|
381
389
|
/** Called once, awaited, on every non-success path, before locks release. */
|
|
@@ -591,7 +599,7 @@ interface RowTransitionResult {
|
|
|
591
599
|
providerState?: unknown;
|
|
592
600
|
}
|
|
593
601
|
//#endregion
|
|
594
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
602
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.17.1+0d2d5e37d881ac14/node_modules/@cortexkit/common-auth/dist/store/provider-state.d.ts
|
|
595
603
|
/**
|
|
596
604
|
* Receives a private copy of the row's provider state (undefined when the row
|
|
597
605
|
* shows none) and the row as loaded under the locks, and returns the next
|
|
@@ -627,7 +635,7 @@ declare const DECLINE_TRANSITION: unique symbol;
|
|
|
627
635
|
*/
|
|
628
636
|
type RowTransitionMutator = (current: unknown | undefined, row: PoolRow) => unknown | typeof DECLINE_TRANSITION | Promise<unknown | typeof DECLINE_TRANSITION>;
|
|
629
637
|
//#endregion
|
|
630
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
638
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.17.1+0d2d5e37d881ac14/node_modules/@cortexkit/common-auth/dist/store/publication.d.ts
|
|
631
639
|
interface PublishPlan {
|
|
632
640
|
operationId: string;
|
|
633
641
|
remove: Array<{
|
|
@@ -670,7 +678,7 @@ interface PublishResult {
|
|
|
670
678
|
receipt: PublicationReceipt;
|
|
671
679
|
}
|
|
672
680
|
//#endregion
|
|
673
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
681
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.17.1+0d2d5e37d881ac14/node_modules/@cortexkit/common-auth/dist/store/pull.d.ts
|
|
674
682
|
/** What a pull is issued with: the credential and its attribution tuple. */
|
|
675
683
|
interface PullRequest {
|
|
676
684
|
id: string;
|
|
@@ -681,7 +689,7 @@ interface PullRequest {
|
|
|
681
689
|
}
|
|
682
690
|
type PullHook = (request: PullRequest) => Promise<unknown>;
|
|
683
691
|
//#endregion
|
|
684
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
692
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.17.1+0d2d5e37d881ac14/node_modules/@cortexkit/common-auth/dist/store/refresh.d.ts
|
|
685
693
|
/** What the injected provider refresh function returns. */
|
|
686
694
|
interface ProviderRefreshResult {
|
|
687
695
|
access: string;
|
|
@@ -744,7 +752,7 @@ type RefreshOutcome = {
|
|
|
744
752
|
reason: string;
|
|
745
753
|
};
|
|
746
754
|
//#endregion
|
|
747
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
755
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.17.1+0d2d5e37d881ac14/node_modules/@cortexkit/common-auth/dist/store/settings.d.ts
|
|
748
756
|
/** The plugin's settings: every top-level config key except the pool-owned ones. */
|
|
749
757
|
type PoolSettings = Record<string, unknown>;
|
|
750
758
|
type SettingsRead = {
|
|
@@ -788,7 +796,7 @@ type UpdateSettingsResult = {
|
|
|
788
796
|
outcome: 'updated' | 'unchanged';
|
|
789
797
|
};
|
|
790
798
|
//#endregion
|
|
791
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
799
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.17.1+0d2d5e37d881ac14/node_modules/@cortexkit/common-auth/dist/store/pool.d.ts
|
|
792
800
|
interface OpenPoolStoreOptions {
|
|
793
801
|
/** The provider every row of this pool belongs to; keys the provider-wide lock. */
|
|
794
802
|
provider: string;
|
|
@@ -845,6 +853,7 @@ interface OpenPoolStoreOptions {
|
|
|
845
853
|
hold?: (point: HoldPoint, rowId: string) => void | Promise<void>;
|
|
846
854
|
onLockEvent?: LockEnvironment['onLockEvent'];
|
|
847
855
|
onLockStep?: LockEnvironment['onLockStep'];
|
|
856
|
+
onRenewalTimer?: LockEnvironment['onRenewalTimer'];
|
|
848
857
|
}
|
|
849
858
|
type PoolLoad = {
|
|
850
859
|
status: 'ready';
|
|
@@ -1193,728 +1202,17 @@ interface RefreshAllQuotaResult {
|
|
|
1193
1202
|
permanent?: boolean;
|
|
1194
1203
|
}
|
|
1195
1204
|
//#endregion
|
|
1196
|
-
//#region ../../node_modules/.bun/@cortexkit+
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
port: number;
|
|
1200
|
-
}
|
|
1201
|
-
interface ConnectionInfo {
|
|
1202
|
-
schema: number;
|
|
1203
|
-
endpoints: Endpoint[];
|
|
1204
|
-
/** Transport key bytes. Serialized on disk as a JSON array of numbers. */
|
|
1205
|
-
key: Uint8Array;
|
|
1206
|
-
/** 16-byte daemon identity. Serialized on disk as a JSON array of numbers. */
|
|
1207
|
-
daemonId: Uint8Array;
|
|
1208
|
-
pid: number;
|
|
1209
|
-
daemonVer: string;
|
|
1210
|
-
}
|
|
1211
|
-
//#endregion
|
|
1212
|
-
//#region ../../node_modules/.bun/@cortexkit+subc-client@0.16.1/node_modules/@cortexkit/subc-client/dist/envelope.d.ts
|
|
1213
|
-
/** Scheduling priority carried in flags bits 1-2. */
|
|
1214
|
-
declare enum Priority {
|
|
1215
|
-
Passive = 0,
|
|
1216
|
-
Interactive = 1,
|
|
1217
|
-
Background = 2
|
|
1218
|
-
}
|
|
1219
|
-
/** Admission behavior carried in flags bits 4-5. */
|
|
1220
|
-
declare enum AdmissionClass {
|
|
1221
|
-
Normal = 0,
|
|
1222
|
-
Expedite = 1,
|
|
1223
|
-
Sheddable = 2
|
|
1224
|
-
}
|
|
1225
|
-
//#endregion
|
|
1226
|
-
//#region ../../node_modules/.bun/@cortexkit+subc-client@0.16.1/node_modules/@cortexkit/subc-client/dist/route-handle.d.ts
|
|
1227
|
-
interface ReverseRequestContext {
|
|
1228
|
-
readonly corr: bigint;
|
|
1229
|
-
readonly method: string;
|
|
1230
|
-
}
|
|
1231
|
-
type ReverseRequestHandler = (body: Uint8Array, ctx: ReverseRequestContext) => Promise<Uint8Array> | Uint8Array;
|
|
1232
|
-
/**
|
|
1233
|
-
* Mutable handler registry prepared before route.open. The client derives
|
|
1234
|
-
* consumer_capabilities from its method families and seals that set when the
|
|
1235
|
-
* route opens; handlers for declared families may still be replaced afterward.
|
|
1236
|
-
*/
|
|
1237
|
-
declare class ReverseRequestRegistry {
|
|
1238
|
-
private readonly handlers;
|
|
1239
|
-
private declaredFamilies;
|
|
1240
|
-
onRequest(methodFamily: string, handler: ReverseRequestHandler): void;
|
|
1241
|
-
/** @internal */
|
|
1242
|
-
capabilities(): string[];
|
|
1243
|
-
/** @internal */
|
|
1244
|
-
handler(methodFamily: string): ReverseRequestHandler | undefined;
|
|
1245
|
-
/** @internal */
|
|
1246
|
-
seal(): void;
|
|
1247
|
-
}
|
|
1248
|
-
/**
|
|
1249
|
-
* Immutable identity for one route binding on one live socket. Only channel and
|
|
1250
|
-
* epoch cross the wire; the connection token remains private to this SDK.
|
|
1251
|
-
*/
|
|
1252
|
-
declare class RouteHandle {
|
|
1253
|
-
readonly channel: number;
|
|
1254
|
-
readonly epoch: number;
|
|
1255
|
-
private constructor();
|
|
1256
|
-
/** Replace the handler for a capability declared when this route opened. */
|
|
1257
|
-
onRequest(methodFamily: string, handler: ReverseRequestHandler): void;
|
|
1258
|
-
private static create;
|
|
1259
|
-
}
|
|
1260
|
-
//#endregion
|
|
1261
|
-
//#region ../../node_modules/.bun/@cortexkit+subc-client@0.16.1/node_modules/@cortexkit/subc-client/dist/client.d.ts
|
|
1262
|
-
interface BindIdentity {
|
|
1263
|
-
project_root: string;
|
|
1264
|
-
harness: string;
|
|
1265
|
-
session: string;
|
|
1266
|
-
}
|
|
1267
|
-
type RouteTarget = {
|
|
1268
|
-
kind: "tool_provider";
|
|
1269
|
-
module_id: string;
|
|
1270
|
-
} | {
|
|
1271
|
-
kind: "management_surface";
|
|
1272
|
-
module_id: string;
|
|
1273
|
-
} | {
|
|
1274
|
-
kind: "internal_service";
|
|
1275
|
-
module_id: string;
|
|
1276
|
-
service_id: string;
|
|
1277
|
-
};
|
|
1278
|
-
type ManagedRouteKind = "management_surface" | "tool_provider";
|
|
1279
|
-
interface ConsumerIdentity {
|
|
1280
|
-
module_id: string;
|
|
1281
|
-
launch_nonce: string;
|
|
1282
|
-
}
|
|
1283
|
-
interface RouteOpenOptions {
|
|
1284
|
-
/** Optional override for the consumer identity; by default the SUBC_MODULE_ID and SUBC_LAUNCH_NONCE environment variables are used when both are non-empty. Set null to send route.open without consumer_identity. */
|
|
1285
|
-
consumerIdentity?: ConsumerIdentity | null;
|
|
1286
|
-
/**
|
|
1287
|
-
* Handlers prepared before route.open. The client derives consumer_capabilities
|
|
1288
|
-
* from this registry; callers cannot declare a capability without a handler.
|
|
1289
|
-
*/
|
|
1290
|
-
reverseRequests?: ReverseRequestRegistry;
|
|
1291
|
-
}
|
|
1292
|
-
interface CatalogCapabilityRequirement {
|
|
1293
|
-
capability: string;
|
|
1294
|
-
need: "required" | "optional";
|
|
1295
|
-
}
|
|
1296
|
-
interface CatalogCapabilities {
|
|
1297
|
-
provides: string[];
|
|
1298
|
-
requires: CatalogCapabilityRequirement[];
|
|
1299
|
-
must_never_reach: string[];
|
|
1300
|
-
}
|
|
1301
|
-
/** A self-signal's anchor relative to the external surface it shapes. */
|
|
1302
|
-
type CatalogSignalAnchor = "fixed_interval" | {
|
|
1303
|
-
event: {
|
|
1304
|
-
event: string;
|
|
1305
|
-
};
|
|
1306
|
-
};
|
|
1307
|
-
/** The source of a self-signal's effective cadence. */
|
|
1308
|
-
type CatalogSignalCadence = {
|
|
1309
|
-
literal: {
|
|
1310
|
-
interval_ms: number;
|
|
1311
|
-
};
|
|
1312
|
-
} | {
|
|
1313
|
-
derived: {
|
|
1314
|
-
source: string;
|
|
1315
|
-
};
|
|
1316
|
-
};
|
|
1317
|
-
/** A self-signal declaration mirrored from a registered module manifest. */
|
|
1318
|
-
interface CatalogSelfSignalDeclaration {
|
|
1319
|
-
name: string;
|
|
1320
|
-
/** Open string for forward-compatible self-signal kinds. */
|
|
1321
|
-
kind: string;
|
|
1322
|
-
effect: "observe" | "mutate";
|
|
1323
|
-
anchored_to: CatalogSignalAnchor;
|
|
1324
|
-
cadence?: CatalogSignalCadence | null;
|
|
1325
|
-
domain?: string | null;
|
|
1326
|
-
note?: string | null;
|
|
1327
|
-
}
|
|
1328
|
-
interface CatalogEntry {
|
|
1329
|
-
module_id: string;
|
|
1330
|
-
roles: unknown[];
|
|
1331
|
-
control_ops: string[];
|
|
1332
|
-
/** Static capability claims mirrored from the registered module manifest. */
|
|
1333
|
-
capabilities?: CatalogCapabilities | null;
|
|
1334
|
-
/** Self-signal declarations mirrored verbatim from the registered manifest. */
|
|
1335
|
-
self_signals?: CatalogSelfSignalDeclaration[] | null;
|
|
1336
|
-
}
|
|
1337
|
-
interface RequestOptions {
|
|
1338
|
-
priority?: Priority;
|
|
1339
|
-
admissionClass?: AdmissionClass;
|
|
1340
|
-
timeoutMs?: number;
|
|
1341
|
-
/**
|
|
1342
|
-
* Set when the request body is opaque bytes rather than JSON. This flag is the
|
|
1343
|
-
* receiver's only signal about the body representation; reply decoding follows
|
|
1344
|
-
* the response frame's flag instead of this request option.
|
|
1345
|
-
*/
|
|
1346
|
-
binary?: boolean;
|
|
1347
|
-
/** Called for each interim PUSH / StreamData frame before the terminal reply. */
|
|
1348
|
-
onProgress?: (body: Uint8Array) => void;
|
|
1349
|
-
/**
|
|
1350
|
-
* Abort the request: when this fires while the request is still in flight, the
|
|
1351
|
-
* client emits a CANCEL frame carrying that request's own corr.
|
|
1352
|
-
*
|
|
1353
|
-
* The signal exists instead of exposing corr because corr lifetime is already
|
|
1354
|
-
* tracked here to settle replies; handing it out would make every caller keep a
|
|
1355
|
-
* second map that can disagree with this one, and would let a caller cancel a
|
|
1356
|
-
* corr it does not own.
|
|
1357
|
-
*
|
|
1358
|
-
* Cancellation is best-effort by the wire's construction: the daemon forwards
|
|
1359
|
-
* the frame on a live route and silently drops it on a departed one, and no
|
|
1360
|
-
* acknowledgement exists at any layer. Only the module's own reply proves what
|
|
1361
|
-
* happened, so the promise is NOT rejected here -- it settles however the module
|
|
1362
|
-
* answers, which may be a normal completion that beat the cancel.
|
|
1363
|
-
*/
|
|
1364
|
-
signal?: AbortSignal;
|
|
1365
|
-
}
|
|
1366
|
-
interface ManagedCallOptions extends RequestOptions {
|
|
1367
|
-
/** Overrides the per-client identity used for route.open before this call. */
|
|
1368
|
-
identity?: BindIdentity;
|
|
1369
|
-
/** Defaults to management_surface, matching the store/host management APIs. */
|
|
1370
|
-
targetKind?: ManagedRouteKind;
|
|
1371
|
-
/** Optional override for the consumer identity; by default the SUBC_MODULE_ID and SUBC_LAUNCH_NONCE environment variables are used when both are non-empty. Set null to send route.open without consumer_identity. */
|
|
1372
|
-
consumerIdentity?: ConsumerIdentity | null;
|
|
1373
|
-
/** Reverse-request handlers used by the managed route and all of its reconnect reopens. */
|
|
1374
|
-
reverseRequests?: ReverseRequestRegistry;
|
|
1375
|
-
}
|
|
1376
|
-
interface SubscribeOptions {
|
|
1377
|
-
priority?: Priority;
|
|
1378
|
-
admissionClass?: AdmissionClass;
|
|
1379
|
-
}
|
|
1380
|
-
type RoutePollKind = "status" | "liveness";
|
|
1381
|
-
interface RoutePollResult {
|
|
1382
|
-
route_channel: number;
|
|
1383
|
-
route_epoch: number;
|
|
1384
|
-
status: string | null;
|
|
1385
|
-
live: boolean | null;
|
|
1386
|
-
}
|
|
1387
|
-
interface CloseRouteOptions {
|
|
1388
|
-
/**
|
|
1389
|
-
* Await in-flight UNARY requests on the route to settle before tearing it down.
|
|
1390
|
-
* Subscriptions are always aborted (a held-open stream cannot be drained).
|
|
1391
|
-
* Defaults to false: close immediately, aborting everything in flight.
|
|
1392
|
-
*/
|
|
1393
|
-
drain?: boolean;
|
|
1394
|
-
}
|
|
1395
|
-
interface ManagedCloseRouteOptions extends CloseRouteOptions {
|
|
1396
|
-
/** Consumer identity used by the cached managed route. */
|
|
1397
|
-
consumerIdentity?: ConsumerIdentity | null;
|
|
1398
|
-
/** The registry whose derived capability set identifies the cached route. */
|
|
1399
|
-
reverseRequests?: ReverseRequestRegistry;
|
|
1400
|
-
}
|
|
1401
|
-
/**
|
|
1402
|
-
* Capped exponential reconnect backoff. maxAttempts includes the first immediate
|
|
1403
|
-
* reconnect attempt; sleeps happen only between failed transient attempts.
|
|
1404
|
-
*/
|
|
1405
|
-
interface ReconnectBackoff {
|
|
1406
|
-
/** First retry delay. */
|
|
1407
|
-
baseMs: number;
|
|
1408
|
-
/** Delay ceiling (doubling is capped here). */
|
|
1409
|
-
capMs: number;
|
|
1410
|
-
/** Max attempts (including the first) before giving up. */
|
|
1411
|
-
maxAttempts: number;
|
|
1412
|
-
}
|
|
1413
|
-
/**
|
|
1414
|
-
* A live subscription to a provider's event stream, riding a single held-open
|
|
1415
|
-
* request. `onEvent` fires for each StreamData frame; `closed` resolves when the
|
|
1416
|
-
* provider ends the stream (StreamEnd) or the consumer unsubscribes, and rejects on
|
|
1417
|
-
* an Error terminal or a route GOODBYE. `unsubscribe` cancels the held-open request
|
|
1418
|
-
* so the provider unwinds.
|
|
1419
|
-
*/
|
|
1420
|
-
interface Subscription {
|
|
1421
|
-
/** Cancel the subscription: sends Cancel on the held-open request; idempotent. */
|
|
1422
|
-
unsubscribe(): void;
|
|
1423
|
-
/** Resolves on StreamEnd or local unsubscribe; rejects on an Error terminal or route close. */
|
|
1424
|
-
readonly closed: Promise<void>;
|
|
1425
|
-
}
|
|
1426
|
-
interface ConnectOptions {
|
|
1205
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.17.1+0d2d5e37d881ac14/node_modules/@cortexkit/common-auth/dist/claustrum/insula.d.ts
|
|
1206
|
+
/** Optional transport for custom scoped clients; getUsage must not retry refusals. */
|
|
1207
|
+
interface InsulaUsageTransport {
|
|
1427
1208
|
connectionFile: string;
|
|
1428
|
-
|
|
1429
|
-
/** Default route identity used by managed call(); can be overridden per call. */
|
|
1430
|
-
identity?: BindIdentity;
|
|
1431
|
-
/** Default route target kind used by managed call(); defaults to management_surface. */
|
|
1432
|
-
targetKind?: ManagedRouteKind;
|
|
1433
|
-
/** Backoff for managed reconnect after a connection drop. */
|
|
1434
|
-
reconnectBackoff?: ReconnectBackoff;
|
|
1435
|
-
/** Injectable sleep for timer-free reconnect tests. */
|
|
1436
|
-
sleep?: (ms: number) => Promise<void>;
|
|
1437
|
-
/**
|
|
1438
|
-
* How long managed calls keep retrying route.open in-place on retryable
|
|
1439
|
-
* refusals (module_reloading, module_warming, target_unavailable, …) before
|
|
1440
|
-
* settling not_sent. This deadline is the ONLY binder on those retries —
|
|
1441
|
-
* module reloads legitimately take tens of seconds (the daemon's drain alone
|
|
1442
|
-
* defaults to 30s), so the default matches the daemon's drain ceiling.
|
|
1443
|
-
*/
|
|
1444
|
-
routeOpenRetryDeadlineMs?: number;
|
|
1445
|
-
/**
|
|
1446
|
-
* Window the post-deadline liveness probe waits for ANY inbound frame after
|
|
1447
|
-
* sending its channel-0 Ping before convicting the socket as half-open.
|
|
1448
|
-
* Genuine event-loop starvation self-protects at any setting: a loop starved
|
|
1449
|
-
* enough to delay the probe's check also delays the read loop, and when it
|
|
1450
|
-
* wakes the buffered Pong dispatches first. Exposed for deterministic tests.
|
|
1451
|
-
*/
|
|
1452
|
-
livenessProbeWindowMs?: number;
|
|
1453
|
-
/**
|
|
1454
|
-
* Hard cap on the timeout-arbitration grace window (see
|
|
1455
|
-
* TIMEOUT_ARBITRATION_GRACE_MS). A reply whose bytes are actively arriving when
|
|
1456
|
-
* the request deadline fires is given up to this long to finish dispatching
|
|
1457
|
-
* before the call settles as a timeout. Bounded and never a deadline extension;
|
|
1458
|
-
* exposed mainly so tests can prove the arbitration deterministically.
|
|
1459
|
-
*/
|
|
1460
|
-
timeoutArbitrationGraceMs?: number;
|
|
1461
|
-
/**
|
|
1462
|
-
* Observer for daemon-originated channel-0 control pushes (`route.closing`,
|
|
1463
|
-
* `route.closed`, and any op added later). Purely advisory: the daemon's
|
|
1464
|
-
* load-bearing route-death signal remains the GOODBYE frame, and nothing in
|
|
1465
|
-
* the client's own route lifecycle consumes these. The contract is the wire
|
|
1466
|
-
* contract verbatim -- unrecognized ops still arrive here (callers ignore
|
|
1467
|
-
* what they don't know, per the MUST-ignore clause), a push that fails to
|
|
1468
|
-
* parse as JSON is dropped without surfacing, and an observer throw is
|
|
1469
|
-
* swallowed like every other caller callback so it cannot fail the read loop
|
|
1470
|
-
* or unrelated requests.
|
|
1471
|
-
*/
|
|
1472
|
-
onControlPush?: (push: ControlPush) => void;
|
|
1473
|
-
}
|
|
1474
|
-
/** A parsed daemon-originated channel-0 control push. */
|
|
1475
|
-
interface ControlPush {
|
|
1476
|
-
/** The push discriminator, e.g. "route.closing" | "route.closed". */
|
|
1477
|
-
op: string;
|
|
1478
|
-
/** The full parsed body, `op` included, for op-specific fields. */
|
|
1479
|
-
body: Record<string, unknown>;
|
|
1480
|
-
}
|
|
1481
|
-
declare class SubcClient {
|
|
1482
|
-
private sock;
|
|
1483
|
-
private currentConn;
|
|
1484
|
-
private readonly opts;
|
|
1485
|
-
private nextCorr;
|
|
1486
|
-
private readonly pending;
|
|
1487
|
-
private readonly lateResponses;
|
|
1488
|
-
private readonly routes;
|
|
1489
|
-
private readonly liveRoutes;
|
|
1490
|
-
private connectionToken;
|
|
1491
|
-
private ingressEpochDropCount;
|
|
1492
|
-
private closedErr;
|
|
1493
|
-
private closeStarted;
|
|
1494
|
-
private reconnecting;
|
|
1495
|
-
private generation;
|
|
1496
|
-
private readerActive;
|
|
1497
|
-
private constructor();
|
|
1498
|
-
get conn(): ConnectionInfo;
|
|
1499
|
-
/** Read the connection file, connect, authenticate, and start the read loop. */
|
|
1500
|
-
static connect(opts: ConnectOptions): Promise<SubcClient>;
|
|
1501
|
-
/** List modules subc knows about (channel-0 catalog.list). */
|
|
1502
|
-
catalogList(moduleId?: string): Promise<CatalogEntry[]>;
|
|
1503
|
-
/**
|
|
1504
|
-
* Resolve the sole catalog claimant for a capability.
|
|
1505
|
-
*
|
|
1506
|
-
* This expresses singular intent even when the fleet permits plural claims;
|
|
1507
|
-
* ambiguity is returned instead of selecting an arbitrary module.
|
|
1508
|
-
*/
|
|
1509
|
-
resolveProvider(capability: string): Promise<string>;
|
|
1510
|
-
/** Resolve every catalog claimant in deterministic module-id order. */
|
|
1511
|
-
resolveProviders(capability: string): Promise<string[]>;
|
|
1512
|
-
/** Open a route and return its connection-bound immutable handle. */
|
|
1513
|
-
routeOpen(target: RouteTarget, identity: BindIdentity, opts?: RouteOpenOptions): Promise<RouteHandle>;
|
|
1514
|
-
/** Send a data-plane request on exactly the supplied route generation. */
|
|
1515
|
-
request(handle: RouteHandle, body: unknown, opts?: RequestOptions): Promise<unknown>;
|
|
1516
|
-
/**
|
|
1517
|
-
* Managed route + request convenience. Opens and caches a route for the module,
|
|
1518
|
-
* reconnecting and re-opening cached routes after connection drops.
|
|
1519
|
-
*/
|
|
1520
|
-
call<Response = unknown>(moduleId: string, method: string, params?: unknown, opts?: ManagedCallOptions): Promise<Response>;
|
|
1521
|
-
/**
|
|
1522
|
-
* Managed route + raw opaque-body request convenience. Unlike call(), this
|
|
1523
|
-
* sends bytes without a JSON method envelope because the BINARY flag is the
|
|
1524
|
-
* receiver's only signal that the body is not JSON. A BINARY reply resolves
|
|
1525
|
-
* to Uint8Array; a non-binary reply is decoded as JSON.
|
|
1526
|
-
*/
|
|
1527
|
-
callBinary(moduleId: string, body: Uint8Array, opts?: ManagedCallOptions): Promise<Uint8Array | unknown>;
|
|
1528
|
-
private managedCall;
|
|
1529
|
-
/** Open a held request on exactly one route generation. */
|
|
1530
|
-
subscribe(handle: RouteHandle, body: unknown, onEvent: (event: Uint8Array) => void, opts?: SubscribeOptions): Subscription;
|
|
1531
|
-
/**
|
|
1532
|
-
* Emit CANCEL for one in-flight request when its caller's signal fires.
|
|
1533
|
-
*
|
|
1534
|
-
* Emits only while the request is unsettled by this client's own book, which is
|
|
1535
|
-
* a fact it owns and can check without racing. It deliberately does NOT check
|
|
1536
|
-
* whether the route still exists: that would be a guess, and a wrong guess turns
|
|
1537
|
-
* a frame the daemon would harmlessly drop into a frame never sent -- removing
|
|
1538
|
-
* the caller's only chance at the cost of saving nothing.
|
|
1539
|
-
*/
|
|
1540
|
-
private attachCancelSignal;
|
|
1541
|
-
/** Send a pure-header cancellation for an in-flight request. */
|
|
1542
|
-
cancel(handle: RouteHandle, corr: bigint, priority?: Priority): void;
|
|
1543
|
-
/** Poll status or liveness for exactly the supplied route generation. */
|
|
1544
|
-
routePoll(handle: RouteHandle, kind: RoutePollKind): Promise<RoutePollResult>;
|
|
1545
|
-
/** Tear down exactly the supplied route generation. */
|
|
1546
|
-
closeRoute(handle: RouteHandle, opts?: CloseRouteOptions): Promise<void>;
|
|
1547
|
-
/** Close a cached managed route by its route-open identity tuple. */
|
|
1548
|
-
closeManagedRoute(target: Extract<RouteTarget, {
|
|
1549
|
-
kind: ManagedRouteKind;
|
|
1550
|
-
}>, identity: BindIdentity, opts?: ManagedCloseRouteOptions): Promise<void>;
|
|
1551
|
-
/** Alias retained for callers that name the operation by protocol channel; it still requires a full handle. */
|
|
1552
|
-
closeRouteChannel(handle: RouteHandle, opts?: CloseRouteOptions): Promise<void>;
|
|
1553
|
-
close(): void;
|
|
1554
|
-
private drainUnaryOnHandle;
|
|
1555
|
-
private sendRouteGoodbye;
|
|
1556
|
-
private static openConnection;
|
|
1557
|
-
private controlRpc;
|
|
1558
|
-
private send;
|
|
1559
|
-
/**
|
|
1560
|
-
* A request-deadline timer has fired. Before settling as a timeout, arbitrate
|
|
1561
|
-
* the timer-vs-poll race: a reply may already be in the socket buffer, unread
|
|
1562
|
-
* only because the loop was starved. Yield one check phase (setImmediate) so a
|
|
1563
|
-
* fully-buffered reply dispatches and wins via settle()'s identity guard; then,
|
|
1564
|
-
* only while the reader is actively draining THIS socket (a frame mid-arrival),
|
|
1565
|
-
* grant a single hard-capped grace before finally settling. Absent replies
|
|
1566
|
-
* still settle right after the check phase. The settle carries the deadline
|
|
1567
|
-
* marker so the managed classifier reports deadline-not-drop.
|
|
1568
|
-
*/
|
|
1569
|
-
private arbitrateTimeout;
|
|
1570
|
-
private managedRequest;
|
|
1571
|
-
private sendManaged;
|
|
1572
|
-
private cachedRouteHandle;
|
|
1573
|
-
private openCachedRoute;
|
|
1574
|
-
private lastInboundAtMs;
|
|
1575
|
-
private livenessProbe;
|
|
1576
|
-
/**
|
|
1577
|
-
* Discriminate event-loop starvation from a half-open socket after a
|
|
1578
|
-
* deadline-no-drop settle. The arbitration deliberately keeps the socket on
|
|
1579
|
-
* that verdict (a late-read reply under load must not cost a healthy
|
|
1580
|
-
* connection), but a half-open socket — peer vanished with no FIN/RST, as
|
|
1581
|
-
* after host sleep/wake — yields the SAME verdict forever, so the keep
|
|
1582
|
-
* becomes a permanent pin to a dead transport. The discriminator is
|
|
1583
|
-
* socket-level liveness evidence: send a channel-0 Ping (the daemon always
|
|
1584
|
-
* answers — subc-core control.rs) and require ANY inbound frame within the
|
|
1585
|
-
* window; the Pong suffices, and a busy socket's other traffic proves the
|
|
1586
|
-
* link just as well. Silence convicts: the socket is failed with a named
|
|
1587
|
-
* cause and closed, so the ordinary drop path (pending rejection now,
|
|
1588
|
-
* reconnect on the next call) takes over.
|
|
1589
|
-
*
|
|
1590
|
-
* Starvation cannot be falsely convicted by a short window: a loop starved
|
|
1591
|
-
* enough to delay the read loop delays this probe's own timer identically,
|
|
1592
|
-
* and when both wake the buffered Pong dispatches before the check runs.
|
|
1593
|
-
*
|
|
1594
|
-
* A PENDING CHANNEL-0 REQUEST SUSPENDS THE PROBE (both at launch and at the
|
|
1595
|
-
* conviction check). The daemon's connection loop handles frames one at a
|
|
1596
|
-
* time, and some channel-0 ops legally park it for seconds — route.open
|
|
1597
|
-
* awaits the module's bind ack inline for up to route_bind_relay_timeout
|
|
1598
|
-
* (~12s in production) — during which OUR Ping sits unread in the daemon's
|
|
1599
|
-
* socket buffer. On an otherwise-quiet connection that silence is fully
|
|
1600
|
-
* explained by our own in-flight control op, and convicting on it would
|
|
1601
|
-
* tear down a healthy connection mid-bind (BROCA's Athena panel flagged
|
|
1602
|
-
* this exact premise; the FIFO fact is verified in subc-core server.rs
|
|
1603
|
-
* connection_loop + control.rs handle_route_open). The client always knows
|
|
1604
|
-
* its own channel-0 pendings, so the gate is local and exact: no probe
|
|
1605
|
-
* while one is in flight, no conviction if one appeared during the window.
|
|
1606
|
-
*
|
|
1607
|
-
* Scope: hooked from the managed-call path only. Control-plane requests
|
|
1608
|
-
* (route.open, catalog.list) are short-lived and their failures already
|
|
1609
|
-
* escalate through reconnect classification; the managed path is where a
|
|
1610
|
-
* plugin lives for hours and where the pin was observed in production.
|
|
1611
|
-
*/
|
|
1612
|
-
/** Any in-flight channel-0 request (pendings keyed without a route handle). */
|
|
1613
|
-
private hasControlPending;
|
|
1614
|
-
private probeLivenessAfterDeadline;
|
|
1615
|
-
private ensureConnectedForManaged;
|
|
1616
|
-
private scheduleReconnectAfterDrop;
|
|
1617
|
-
private reconnectAfterDrop;
|
|
1618
|
-
private reconnectWithRetry;
|
|
1619
|
-
private replaceConnection;
|
|
1620
|
-
private reopenCachedRoutes;
|
|
1621
|
-
private timeoutMessage;
|
|
1622
|
-
private routeClosedDuringOpen;
|
|
1623
|
-
private readLoop;
|
|
1624
|
-
private dispatch;
|
|
1625
|
-
/**
|
|
1626
|
-
* Settle a pending exactly once. The object-identity guard (the map still
|
|
1627
|
-
* holds THIS pending under `key`) is the single-winner primitive: whichever of
|
|
1628
|
-
* dispatch, a timeout, fail(), failChannel(), a GOODBYE, or a deferred timeout
|
|
1629
|
-
* arbitration reaches it first wins, and every later caller no-ops. This is what
|
|
1630
|
-
* makes the deferred-timeout arbitration safe — it cannot double-settle, reject
|
|
1631
|
-
* an already-resolved promise, or delete a pending re-created for a later corr.
|
|
1632
|
-
* Returns true when this call was the settler.
|
|
1633
|
-
*/
|
|
1634
|
-
private settle;
|
|
1635
|
-
private rejectPending;
|
|
1636
|
-
private dispatchReverseRequest;
|
|
1637
|
-
private sendReverseError;
|
|
1638
|
-
private sendReverseReply;
|
|
1639
|
-
private errorFromFrame;
|
|
1640
|
-
private evictRouteHandle;
|
|
1641
|
-
private failHandle;
|
|
1642
|
-
private fail;
|
|
1643
|
-
private notSentCallError;
|
|
1644
|
-
private outcomeUnknownCallError;
|
|
1645
|
-
private terminalCallError;
|
|
1646
|
-
private notSentRecoveryError;
|
|
1647
|
-
/** Number of nonzero-channel ingress frames dropped by endpoint epoch validation. */
|
|
1648
|
-
get droppedIngressFrames(): number;
|
|
1649
|
-
private installRoute;
|
|
1650
|
-
private isLiveHandle;
|
|
1651
|
-
private assertLiveConnection;
|
|
1652
|
-
private assertLiveHandle;
|
|
1653
|
-
private allocateCorr;
|
|
1654
|
-
private closeConnectionAfterCleanupFailure;
|
|
1655
|
-
private encode;
|
|
1656
|
-
/** Decode a terminal response according to the representation on the wire. */
|
|
1657
|
-
private decodeReply;
|
|
1658
|
-
private parseJson;
|
|
1209
|
+
getUsage(): Promise<unknown>;
|
|
1659
1210
|
}
|
|
1660
1211
|
//#endregion
|
|
1661
|
-
//#region ../../node_modules/.bun/@cortexkit+
|
|
1662
|
-
type
|
|
1663
|
-
|
|
1664
|
-
handshakeTimeoutMs?: number;
|
|
1665
|
-
}) => Promise<SubcClient>;
|
|
1666
|
-
type ClaustrumClientOptions = {
|
|
1667
|
-
connectionFile?: string;
|
|
1668
|
-
handshakeTimeoutMs?: number;
|
|
1669
|
-
projectRoot?: string;
|
|
1670
|
-
storagePath?: string;
|
|
1671
|
-
identity?: BindIdentity;
|
|
1672
|
-
connector?: ClaustrumConnector;
|
|
1673
|
-
logger?: (errorClass: string) => void;
|
|
1674
|
-
};
|
|
1675
|
-
/**
|
|
1676
|
-
* Credential material plus optional non-secret identity metadata. Missing wire fields remain
|
|
1677
|
-
* `undefined`; a present non-string identity value rejects the response as invalid.
|
|
1678
|
-
*
|
|
1679
|
-
* An absent identity field means the vault had nothing to assert — NOT that identity failed.
|
|
1680
|
-
* Consumers must not collapse absence into mismatch: assert on presence, refuse on a present
|
|
1681
|
-
* difference, and serve (log, if it matters) when the field is missing. Absence proves neither
|
|
1682
|
-
* the right identity nor the wrong one, so treating it as a failure converts a vault that could
|
|
1683
|
-
* not answer into a consumer that cannot serve. The vault records no per-read success (at most
|
|
1684
|
-
* the first scoped read per principal), and nothing at all when a consumer declines to serve, so
|
|
1685
|
-
* an outage caused that way is visible only to the consumer that caused it.
|
|
1686
|
-
*/
|
|
1687
|
-
type ServedCredential = {
|
|
1688
|
-
material: string;
|
|
1689
|
-
recordVersion: number;
|
|
1690
|
-
expiresAtMs: number | null;
|
|
1691
|
-
/**
|
|
1692
|
-
* Operator-chosen record label for verifying a caller-held binding. It is not a routing key:
|
|
1693
|
-
* account-scoped routing joins `accountId` with `recordVersion`.
|
|
1694
|
-
*/
|
|
1695
|
-
credentialId?: string;
|
|
1696
|
-
/** Non-secret Code Assist project identity, present only for antigravity credentials. */
|
|
1697
|
-
projectId?: string;
|
|
1698
|
-
/**
|
|
1699
|
-
* Provider account identity the served token executes under. Account-scoped routing joins this
|
|
1700
|
-
* value with `recordVersion`; it is neither the operator's credential label nor the bearer handle.
|
|
1701
|
-
*
|
|
1702
|
-
* BEST-EFFORT, NEVER GUARANTEED, including for JWT providers. The vault parses the claim live
|
|
1703
|
-
* from the served access token and falls back to stored login-time identity; both legs can be
|
|
1704
|
-
* empty, and the serve path yields nothing rather than fabricating an id. It is absent when the
|
|
1705
|
-
* provider has no known claim, the token does not carry one, or no identity was captured at
|
|
1706
|
-
* login. Do not gate serving on its presence.
|
|
1707
|
-
*/
|
|
1708
|
-
accountId?: string;
|
|
1709
|
-
/** Non-secret account display metadata captured at login. */
|
|
1710
|
-
email?: string;
|
|
1711
|
-
/** Non-secret organization or workspace display metadata captured at login. */
|
|
1712
|
-
orgName?: string;
|
|
1713
|
-
};
|
|
1714
|
-
/**
|
|
1715
|
-
* Non-secret health for one handle, read without minting anything.
|
|
1716
|
-
*
|
|
1717
|
-
* An unresolved handle (unknown or revoked) is an ordinary answer, not an error: it decodes
|
|
1718
|
-
* as `ready: false, lastErrorCode: 'not_found'` with `credentialId`, `recordVersion` and
|
|
1719
|
-
* `stalePending` all absent. The vault omits them on purpose so a probe learns nothing about
|
|
1720
|
-
* what exists and no placeholder value is asserted about a record it never saw.
|
|
1721
|
-
*/
|
|
1722
|
-
type CredentialStatus = {
|
|
1723
|
-
ready: boolean;
|
|
1724
|
-
lastErrorCode: string | null;
|
|
1725
|
-
leaseHeld: boolean;
|
|
1726
|
-
/**
|
|
1727
|
-
* Operator-chosen record label the handle resolved to, for verifying a binding the caller
|
|
1728
|
-
* already holds. Not a routing key. Absent when the handle did not resolve.
|
|
1729
|
-
*/
|
|
1730
|
-
credentialId?: string;
|
|
1731
|
-
/**
|
|
1732
|
-
* The record's change cursor, present only when the handle resolved to a record.
|
|
1733
|
-
*
|
|
1734
|
-
* Optional, and OMITTED from the object rather than defaulted, because there is no honest
|
|
1735
|
-
* default: 0 or -1 would compare as older than every real version, so a poller would read a
|
|
1736
|
-
* revoked handle as a change it had yet to see, forever. With the key absent, TypeScript
|
|
1737
|
-
* refuses arithmetic or ordering on it until the caller has handled `undefined`, and
|
|
1738
|
-
* `'recordVersion' in status` is false. Never replace absence with a number (`?? 0`).
|
|
1739
|
-
*/
|
|
1740
|
-
recordVersion?: number;
|
|
1741
|
-
stalePending?: boolean;
|
|
1742
|
-
};
|
|
1743
|
-
type ClaustrumReporterSource = 'direct' | 'relay_status_field' | 'relay_message_parse';
|
|
1744
|
-
declare class ClaustrumClient {
|
|
1745
|
-
#private;
|
|
1746
|
-
private constructor();
|
|
1747
|
-
static connect(options?: ClaustrumClientOptions): Promise<ClaustrumClient>;
|
|
1748
|
-
getCredential(handle: string, minTtlMs?: number): Promise<ServedCredential>;
|
|
1749
|
-
statusCredential(handle: string): Promise<CredentialStatus>;
|
|
1750
|
-
reportAuthFailure(input: {
|
|
1751
|
-
handle: string;
|
|
1752
|
-
providerStatus: number;
|
|
1753
|
-
recordVersion: number;
|
|
1754
|
-
reporterSource: ClaustrumReporterSource;
|
|
1755
|
-
}): Promise<void>;
|
|
1756
|
-
/**
|
|
1757
|
-
* Enumerate what this caller's grants cover.
|
|
1758
|
-
*
|
|
1759
|
-
* `params` is `{}` and must be PRESENT: the vault rejects an absent or null params
|
|
1760
|
-
* object, so a caller cannot ask a different question by omitting it.
|
|
1761
|
-
*/
|
|
1762
|
-
listScoped(enrollmentToken?: string): Promise<ScopedInventory>;
|
|
1763
|
-
/**
|
|
1764
|
-
* Fetch by credential id, authorized by a grant rather than a bearer handle.
|
|
1765
|
-
*
|
|
1766
|
-
* `minTtlMs` is a DEMAND, not a hint: if a real upstream exchange still cannot satisfy
|
|
1767
|
-
* it, the vault refuses with `ttl_unsatisfiable` (class `context_overflow`) rather than
|
|
1768
|
-
* serving a token that will die inside the caller's own margin. That class means
|
|
1769
|
-
* reduce-and-retry, never wait-and-retry.
|
|
1770
|
-
*/
|
|
1771
|
-
getScoped(input: {
|
|
1772
|
-
credentialId: string;
|
|
1773
|
-
enrollmentToken?: string;
|
|
1774
|
-
minTtlMs?: number;
|
|
1775
|
-
}): Promise<ServedCredential>;
|
|
1776
|
-
/**
|
|
1777
|
-
* Report a served credential dead, addressed by id rather than by handle.
|
|
1778
|
-
*
|
|
1779
|
-
* VERSION-FENCED: `recordVersion` must be the one this caller was SERVED. A report
|
|
1780
|
-
* against a since-refreshed version is accepted and does nothing, which is the point --
|
|
1781
|
-
* a stale report must not kill a fresh token. `accepted: true` is the receipt that the
|
|
1782
|
-
* report was taken, never evidence that it applied.
|
|
1783
|
-
*/
|
|
1784
|
-
reportAuthFailureScoped(input: {
|
|
1785
|
-
credentialId: string;
|
|
1786
|
-
enrollmentToken?: string;
|
|
1787
|
-
providerStatus: number;
|
|
1788
|
-
recordVersion: number;
|
|
1789
|
-
reporterSource: ClaustrumReporterSource;
|
|
1790
|
-
}): Promise<void>;
|
|
1791
|
-
/**
|
|
1792
|
-
* Propose an enrollment. The consumer mints `requestSecret` itself and sends only its
|
|
1793
|
-
* hash; the raw secret NEVER leaves the process, and it is what authorizes the poll.
|
|
1794
|
-
*
|
|
1795
|
-
* IDEMPOTENT ON (name, secret): re-proposing with the same secret returns the SAME
|
|
1796
|
-
* `requestId`. That exists because `requestId` is minted server-side, so a consumer
|
|
1797
|
-
* cannot persist it before proposing -- a crash in that window would otherwise leave it
|
|
1798
|
-
* holding a secret it cannot poll with and a name held until TTL. Persist the secret
|
|
1799
|
-
* BEFORE calling this, and a crash costs nothing.
|
|
1800
|
-
*
|
|
1801
|
-
* A different secret on the same name is a different caller and is refused.
|
|
1802
|
-
*/
|
|
1803
|
-
enrollPropose(input: {
|
|
1804
|
-
name: string;
|
|
1805
|
-
requestSecretHash: string;
|
|
1806
|
-
}): Promise<{
|
|
1807
|
-
requestId: string;
|
|
1808
|
-
}>;
|
|
1809
|
-
/**
|
|
1810
|
-
* Poll a proposal. Returns `pending` until an operator decides, then exactly once
|
|
1811
|
-
* returns the token.
|
|
1812
|
-
*
|
|
1813
|
-
* THE TOKEN IS RETURNED ONCE. Persist it before doing anything else with it; a lost
|
|
1814
|
-
* token needs a fresh ceremony, not a second poll.
|
|
1815
|
-
*/
|
|
1816
|
-
enrollPoll(input: {
|
|
1817
|
-
requestId: string;
|
|
1818
|
-
requestSecret: string;
|
|
1819
|
-
}): Promise<EnrollmentPollOutcome>;
|
|
1820
|
-
/**
|
|
1821
|
-
* Exchange a live token for its successor. The old token dies when the new one is issued.
|
|
1822
|
-
*
|
|
1823
|
-
* `expectedTokenGeneration` IS REQUIRED AND IS A FENCE, not bookkeeping: it must be the
|
|
1824
|
-
* generation this caller currently holds. Two rotations racing — a retry after an
|
|
1825
|
-
* uncertain reply, or two instances of the same consumer — would otherwise each mint a
|
|
1826
|
-
* successor and each invalidate the other's, leaving a consumer holding a token the
|
|
1827
|
-
* vault has already replaced. The vault refuses a rotation whose expectation does not
|
|
1828
|
-
* match, so the loser learns it lost instead of discovering it on a later spend.
|
|
1829
|
-
*/
|
|
1830
|
-
enrollRotate(input: {
|
|
1831
|
-
token: string;
|
|
1832
|
-
expectedTokenGeneration: number;
|
|
1833
|
-
}): Promise<{
|
|
1834
|
-
token: string;
|
|
1835
|
-
tokenGeneration: number;
|
|
1836
|
-
}>;
|
|
1837
|
-
close(): void;
|
|
1838
|
-
}
|
|
1839
|
-
/**
|
|
1840
|
-
* A row from the caller's own grant-covered inventory.
|
|
1841
|
-
*
|
|
1842
|
-
* Selection fields answer different questions. Pick by what you are about
|
|
1843
|
-
* to do with the token:
|
|
1844
|
-
*
|
|
1845
|
-
* - `providerIds` — operator-assigned catalog provider ids; match exactly, with no fallback.
|
|
1846
|
-
* - `authMethod` — the closed authentication method derived from the unsealed record,
|
|
1847
|
-
* not the id spelling. Absent on sign/open-only rows or when no method is defined.
|
|
1848
|
-
*
|
|
1849
|
-
* - `refreshAdapter` — whose PROTOCOL the credential speaks. Use it when the token
|
|
1850
|
-
* goes to a provider's own endpoints. Anything else is invalid there.
|
|
1851
|
-
* - `serves` — which model VENDORS are reachable through it. Use it when choosing
|
|
1852
|
-
* where a model can be served from, and the protocol is not yours to care about.
|
|
1853
|
-
*
|
|
1854
|
-
* Never infer these fields from the id spelling. A credential reaching Anthropic models
|
|
1855
|
-
* through OpenRouter still speaks OpenRouter's protocol, not Anthropic's.
|
|
1856
|
-
*/
|
|
1857
|
-
interface ScopedInventoryRow {
|
|
1858
|
-
readonly id: string;
|
|
1859
|
-
readonly categories: readonly string[];
|
|
1860
|
-
readonly credentialType: string;
|
|
1861
|
-
readonly serves: readonly string[];
|
|
1862
|
-
/**
|
|
1863
|
-
* Operator-assigned catalog ids; empty when none are set. Always present on this type.
|
|
1864
|
-
* A daemon older than the field omits it from the wire, and that decodes as empty,
|
|
1865
|
-
* which is also what an unmapped credential reports.
|
|
1866
|
-
*/
|
|
1867
|
-
readonly providerIds: readonly string[];
|
|
1868
|
-
readonly authMethod?: 'apikey' | 'chatgpt' | 'antigravity' | 'oauth';
|
|
1869
|
-
/**
|
|
1870
|
-
* Which provider protocol this credential speaks. Absent for static keys.
|
|
1871
|
-
*
|
|
1872
|
-
* SELECT ON THIS, NOT ON `serves`, WHEN THE TOKEN GOES TO A PROVIDER'S OWN ENDPOINTS.
|
|
1873
|
-
* Measured on a live vault: eight rows serve Anthropic models and only five are Claude
|
|
1874
|
-
* OAuth -- openrouter, antigravity and cursor reach Anthropic models through their own
|
|
1875
|
-
* APIs. The id spelling does not separate them either: two contain no "anthropic" at
|
|
1876
|
-
* all, and `credentialType === 'oauth'` catches antigravity and cursor too.
|
|
1877
|
-
*/
|
|
1878
|
-
readonly refreshAdapter?: string;
|
|
1879
|
-
readonly state: string;
|
|
1880
|
-
readonly recordVersion: number;
|
|
1881
|
-
readonly operations: readonly string[];
|
|
1882
|
-
/**
|
|
1883
|
-
* NOT SERVED TODAY. The field is absent from `ListScopedCredential`, so this is always
|
|
1884
|
-
* null; it is declared because a consumer's discovery high-water mark needs it and the
|
|
1885
|
-
* absence should be visible in the type rather than discovered at runtime.
|
|
1886
|
-
*/
|
|
1887
|
-
readonly createdAtMs: number | null;
|
|
1888
|
-
readonly accountId?: string;
|
|
1889
|
-
readonly email?: string;
|
|
1890
|
-
readonly orgName?: string;
|
|
1891
|
-
}
|
|
1892
|
-
/**
|
|
1893
|
-
* An inventory reply: the covered rows, plus the cursor that says whether they moved.
|
|
1894
|
-
*
|
|
1895
|
-
* `view` is a DIGEST OVER WHAT THIS CALLER CAN SEE — ids, categories, state, operations —
|
|
1896
|
-
* and deliberately NOT over `record_version`, so a routine token refresh does not move it.
|
|
1897
|
-
* Compare it against the previous call's to decide whether to reconcile at all; it is an
|
|
1898
|
-
* opaque string and nothing but equality is defined on it.
|
|
1899
|
-
*/
|
|
1900
|
-
interface ScopedInventory {
|
|
1901
|
-
readonly rows: readonly ScopedInventoryRow[];
|
|
1902
|
-
readonly view: string;
|
|
1903
|
-
}
|
|
1904
|
-
/** What a poll found. `pending` is not an error: the operator has not decided yet. */
|
|
1905
|
-
type EnrollmentPollOutcome = {
|
|
1906
|
-
readonly status: 'pending';
|
|
1907
|
-
} | {
|
|
1908
|
-
readonly status: 'approved';
|
|
1909
|
-
readonly name: string;
|
|
1910
|
-
readonly token: string;
|
|
1911
|
-
readonly tokenGeneration: number;
|
|
1912
|
-
} | {
|
|
1913
|
-
readonly status: 'denied';
|
|
1212
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.17.1+0d2d5e37d881ac14/node_modules/@cortexkit/common-auth/dist/claustrum/custody.d.ts
|
|
1213
|
+
type ClaustrumScopedClient = Pick<ClaustrumClient, 'listScoped' | 'getScoped' | 'reportAuthFailureScoped' | 'close'> & {
|
|
1214
|
+
insula?: InsulaUsageTransport;
|
|
1914
1215
|
};
|
|
1915
|
-
//#endregion
|
|
1916
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.14.2+49be191d46b46482/node_modules/@cortexkit/common-auth/dist/claustrum/custody.d.ts
|
|
1917
|
-
type ClaustrumScopedClient = Pick<ClaustrumClient, 'listScoped' | 'getScoped' | 'reportAuthFailureScoped' | 'close'>;
|
|
1918
1216
|
/** The two credential types a plugin's family can hold; routing differs by type. */
|
|
1919
1217
|
type VaultCredentialType = 'oauth' | 'api_key';
|
|
1920
1218
|
/**
|
|
@@ -1977,7 +1275,7 @@ interface ClaustrumScopedAttempt {
|
|
|
1977
1275
|
readonly expiresAtMs: number | null;
|
|
1978
1276
|
}
|
|
1979
1277
|
//#endregion
|
|
1980
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
1278
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.17.1+0d2d5e37d881ac14/node_modules/@cortexkit/common-auth/dist/quota/map.d.ts
|
|
1981
1279
|
interface QuotaReadingEntry {
|
|
1982
1280
|
scope: string;
|
|
1983
1281
|
label: string;
|
|
@@ -2020,13 +1318,19 @@ interface CreditBudgetCleared {
|
|
|
2020
1318
|
checkedAt: number;
|
|
2021
1319
|
}
|
|
2022
1320
|
type CreditBudgetEntry = CreditBudgetReading | CreditBudgetCleared;
|
|
1321
|
+
interface QuotaCounter {
|
|
1322
|
+
value: number;
|
|
1323
|
+
checkedAt: number;
|
|
1324
|
+
}
|
|
2023
1325
|
interface QuotaMap {
|
|
2024
1326
|
limits: QuotaEntry[];
|
|
2025
1327
|
/** Absent means no observation has reported on the budget yet. */
|
|
2026
1328
|
budget?: CreditBudgetEntry;
|
|
1329
|
+
/** Provider-named counts, each with its own observation time. */
|
|
1330
|
+
counters?: Record<string, QuotaCounter>;
|
|
2027
1331
|
}
|
|
2028
1332
|
//#endregion
|
|
2029
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
1333
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.17.1+0d2d5e37d881ac14/node_modules/@cortexkit/common-auth/dist/quota/merge.d.ts
|
|
2030
1334
|
interface ObservedReading {
|
|
2031
1335
|
/** Defaults to `all`. */
|
|
2032
1336
|
scope?: string;
|
|
@@ -2060,9 +1364,11 @@ interface QuotaObservation {
|
|
|
2060
1364
|
coverage?: ObservedPair[];
|
|
2061
1365
|
/** Absent means the observation says nothing about the budget. */
|
|
2062
1366
|
budget?: ObservedBudget;
|
|
1367
|
+
/** Each named count uses its own time, independently of limits and budget. */
|
|
1368
|
+
counters?: Record<string, QuotaCounter>;
|
|
2063
1369
|
}
|
|
2064
1370
|
//#endregion
|
|
2065
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
1371
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.17.1+0d2d5e37d881ac14/node_modules/@cortexkit/common-auth/dist/claustrum/interlock.d.ts
|
|
2066
1372
|
/**
|
|
2067
1373
|
* The declined-account interlock: the user's "do not use this vault account",
|
|
2068
1374
|
* kept on the consumer side because the vault has no notion of it.
|
|
@@ -2081,7 +1387,7 @@ interface DeclinedAccount {
|
|
|
2081
1387
|
readonly accountIdentity?: string;
|
|
2082
1388
|
}
|
|
2083
1389
|
//#endregion
|
|
2084
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
1390
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.17.1+0d2d5e37d881ac14/node_modules/@cortexkit/common-auth/dist/claustrum/roster.d.ts
|
|
2085
1391
|
/**
|
|
2086
1392
|
* One vault account as the pool sees it. It carries no bearer material: the
|
|
2087
1393
|
* access token is fetched from the vault for every send. Several vault
|
|
@@ -2136,7 +1442,7 @@ interface VaultRosterFile {
|
|
|
2136
1442
|
*/
|
|
2137
1443
|
type QuotaReceipt = Pick<ClaustrumScopedAttempt, 'credentialId' | 'accountIdentity' | 'accountIdentitySource' | 'expectedAccountIdentity'>;
|
|
2138
1444
|
//#endregion
|
|
2139
|
-
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.
|
|
1445
|
+
//#region ../../node_modules/.bun/@cortexkit+common-auth@0.17.1+0d2d5e37d881ac14/node_modules/@cortexkit/common-auth/dist/claustrum/enrollment.d.ts
|
|
2140
1446
|
interface ClaustrumEnrollmentClient {
|
|
2141
1447
|
enrollPropose(input: {
|
|
2142
1448
|
name: string;
|
|
@@ -2265,6 +1571,12 @@ declare class OpenAiVault {
|
|
|
2265
1571
|
* `VAULT_REQUEST_ROSTER_WAIT_MS`.
|
|
2266
1572
|
*/
|
|
2267
1573
|
firstRoster(): Promise<void>;
|
|
1574
|
+
/**
|
|
1575
|
+
* Readies a current vault roster before request routing. The startup
|
|
1576
|
+
* discovery may have settled while this host was local, so firstRoster()
|
|
1577
|
+
* alone cannot tell a vault-mode request that it has a roster to use.
|
|
1578
|
+
*/
|
|
1579
|
+
awaitRequestRoster(): Promise<void>;
|
|
2268
1580
|
/**
|
|
2269
1581
|
* Re-reads the accounts from the vault now. Never rejects. It resolves only
|
|
2270
1582
|
* after a discovery that began after this call: one already in flight (the
|
|
@@ -2330,8 +1642,8 @@ declare class OpenAiVault {
|
|
|
2330
1642
|
* the background; a failure is logged.
|
|
2331
1643
|
*/
|
|
2332
1644
|
recordSnapshot(routeId: string, snapshot: unknown, complete: boolean, receipt: QuotaReceipt): Promise<void>;
|
|
2333
|
-
/** Joins
|
|
2334
|
-
pollQuota(routeId: string): Promise<{
|
|
1645
|
+
/** Joins a quota poll; current insula quota for the same account replaces a background ChatGPT wham/usage request. */
|
|
1646
|
+
pollQuota(routeId: string, background?: boolean): Promise<{
|
|
2335
1647
|
ok: boolean;
|
|
2336
1648
|
error?: string;
|
|
2337
1649
|
}>;
|
|
@@ -2756,4 +2068,5 @@ export declare function registerPiProvider(pi: Pick<ExtensionAPI, 'registerProvi
|
|
|
2756
2068
|
*/
|
|
2757
2069
|
export declare function createPiOpenAIRuntime(): PiOpenAIRuntime;
|
|
2758
2070
|
export default function cortexKitPiOpenAIAuth(pi: ExtensionAPI): Promise<void>;
|
|
2759
|
-
//#endregion
|
|
2071
|
+
//#endregion
|
|
2072
|
+
export {};
|