@cortexkit/opencode-openai-auth 1.8.4 → 1.8.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.
Files changed (47) hide show
  1. package/dist/bin.js +2 -2
  2. package/dist/{codex-request-C78nXs79.d.ts → codex-request-By530v1D.d.ts} +2 -1
  3. package/dist/{index-hvmj07f7.js → index-8x42xzxb.js} +20 -20
  4. package/dist/{index-t8248wa4.js → index-a7xv52hy.js} +1 -1
  5. package/dist/{index-k7zb6wa7.js → index-g5hv0tda.js} +1 -1
  6. package/dist/{index-pg5c6by3.js → index-jh90fx7y.js} +1 -1
  7. package/dist/index-n12zjwh9.js +8 -0
  8. package/dist/{index-e7gekawr.js → index-rmc6hwg6.js} +1 -1
  9. package/dist/{index-nsdjapq1.js → index-zah8t2d2.js} +1 -1
  10. package/dist/{index-1htk005d.js → index-zf649dj2.js} +1 -1
  11. package/dist/index-zne9tzy9.js +91 -0
  12. package/dist/index.d.ts +1 -1
  13. package/dist/index.js +1 -1
  14. package/dist/rpc/port-file.js +1 -1
  15. package/dist/rpc/protocol.js +1 -1
  16. package/dist/rpc/rpc-client.js +1 -1
  17. package/dist/sidebar-state.js +1 -1
  18. package/dist/tui-preferences.js +1 -1
  19. package/dist/tui.d.ts +1 -20
  20. package/dist/v2/server.d.ts +1 -1
  21. package/dist/v2/server.js +2 -2
  22. package/package.json +2 -2
  23. package/src/tui-compiled/raw/shared/0f77ebc3c914c9c6-custody.js +20 -6
  24. package/src/tui-compiled/raw/shared/169b2b4bf30909bc-consumer.js +25 -0
  25. package/src/tui-compiled/raw/shared/30f5bc480f31f51c-roster.js +1 -1
  26. package/src/tui-compiled/raw/shared/352d228be2832bd4-hub.js +55 -5
  27. package/src/tui-compiled/raw/shared/4825e03209d6ae3e-with-lock.js +1 -1
  28. package/src/tui-compiled/raw/shared/549daf371622c304-index.tsx +497 -0
  29. package/src/tui-compiled/raw/shared/7c97ac0cec074ae7-format.js +208 -0
  30. package/src/tui-compiled/raw/shared/b4ad0d49429f0096-map.js +98 -0
  31. package/src/tui-compiled/raw/shared/b717cdcce3966455-projection.js +90 -0
  32. package/src/tui-compiled/raw/shared/e8cd4929507508d8-refresh-file-lock.js +3 -1
  33. package/src/tui-compiled/raw/tui.tsx +233 -634
  34. package/src/tui-compiled/runtime/shared/0f77ebc3c914c9c6-custody.js +20 -6
  35. package/src/tui-compiled/runtime/shared/169b2b4bf30909bc-consumer.js +25 -0
  36. package/src/tui-compiled/runtime/shared/30f5bc480f31f51c-roster.js +1 -1
  37. package/src/tui-compiled/runtime/shared/352d228be2832bd4-hub.js +55 -5
  38. package/src/tui-compiled/runtime/shared/4825e03209d6ae3e-with-lock.js +1 -1
  39. package/src/tui-compiled/runtime/shared/549daf371622c304-index.js +550 -0
  40. package/src/tui-compiled/runtime/shared/7c97ac0cec074ae7-format.js +208 -0
  41. package/src/tui-compiled/runtime/shared/b4ad0d49429f0096-map.js +98 -0
  42. package/src/tui-compiled/runtime/shared/b717cdcce3966455-projection.js +90 -0
  43. package/src/tui-compiled/runtime/shared/e8cd4929507508d8-refresh-file-lock.js +3 -1
  44. package/src/tui-compiled/runtime/tui.js +258 -879
  45. package/dist/index-a5h82jha.js +0 -8
  46. package/dist/index-kemp2vh4.js +0 -91
  47. /package/dist/{index-hnmbhgk4.js → index-95s2mw9w.js} +0 -0
@@ -85,16 +85,28 @@ function credentialTypeOf(row, family) {
85
85
  return notMine;
86
86
  if (!row.categories.includes(family.category))
87
87
  return notMine;
88
- if (row.credentialType !== 'oauth' && row.credentialType !== 'api_key')
89
- return notMine;
90
88
  if ('classify' in family) {
91
- // Older clients omit these facts entirely; do not call a policy that needs them.
89
+ const metadata = rowFactsOf(row);
90
+ let type;
91
+ // The id's type is only a hint; the vault's auth method determines serving.
92
+ switch (metadata.authMethod) {
93
+ case 'apikey':
94
+ type = 'api_key';
95
+ break;
96
+ case 'chatgpt':
97
+ case 'antigravity':
98
+ case 'oauth':
99
+ type = 'oauth';
100
+ break;
101
+ default:
102
+ return { kind: 'refused', code: 'unknown-auth-method' };
103
+ }
92
104
  const facts = {
93
105
  credentialId: row.id,
94
- credentialType: row.credentialType,
106
+ credentialType: type,
95
107
  categories: row.categories,
96
108
  refreshAdapter: row.refreshAdapter,
97
- ...rowFactsOf(row),
109
+ ...metadata,
98
110
  };
99
111
  if (facts.providerIds === undefined)
100
112
  return { kind: 'refused', code: 'unmapped' };
@@ -103,7 +115,7 @@ function credentialTypeOf(row, family) {
103
115
  if (result.kind === 'not-mine')
104
116
  return notMine;
105
117
  if (result.kind === 'mine' && typeof result.member === 'string')
106
- return { kind: 'mine', type: row.credentialType, member: result.member };
118
+ return { kind: 'mine', type, member: result.member };
107
119
  if (result.kind === 'refused' &&
108
120
  typeof result.code === 'string' &&
109
121
  /^[a-z][a-z0-9-]{0,31}$/.test(result.code) &&
@@ -116,6 +128,8 @@ function credentialTypeOf(row, family) {
116
128
  }
117
129
  return { kind: 'refused', code: 'unclassified' };
118
130
  }
131
+ if (row.credentialType !== 'oauth' && row.credentialType !== 'api_key')
132
+ return notMine;
119
133
  if (row.credentialType === 'oauth')
120
134
  return row.refreshAdapter === family.refreshAdapter
121
135
  ? { kind: 'mine', type: 'oauth' }
@@ -314,8 +314,17 @@ export class ClaustrumConsumer {
314
314
  this.#refreshing = undefined;
315
315
  });
316
316
  this.#track(this.#refreshing);
317
+ this.#notifyDiscovery(this.#refreshing);
317
318
  return this.#refreshing;
318
319
  }
320
+ #notifyDiscovery(promise) {
321
+ try {
322
+ this.#options.onDiscovery?.(promise);
323
+ }
324
+ catch (error) {
325
+ this.#options.onError?.(error);
326
+ }
327
+ }
319
328
  /**
320
329
  * Poll in the background and open the vault and insula watches. Until the
321
330
  * vault watch is accepted, and whenever it is unavailable, every tick lists
@@ -571,6 +580,13 @@ export class ClaustrumConsumer {
571
580
  /** The hub's handle on this member's memory. */
572
581
  #hubHooks() {
573
582
  return {
583
+ discovery: (promise) => {
584
+ const hub = this.#hub;
585
+ if (!hub || !this.#options.onDiscovery || this.#shutdown.signal.aborted)
586
+ return;
587
+ const discovery = this.#track(promise.then((outcome) => this.#hubOutcome(hub, outcome)));
588
+ this.#notifyDiscovery(discovery);
589
+ },
574
590
  install: (roster) => {
575
591
  if (this.#shutdown.signal.aborted)
576
592
  return;
@@ -607,6 +623,9 @@ export class ClaustrumConsumer {
607
623
  */
608
624
  async #hubRefresh(hub) {
609
625
  const outcome = await hub.refresh();
626
+ return this.#hubOutcome(hub, outcome);
627
+ }
628
+ #hubOutcome(hub, outcome) {
610
629
  this.#assertOpen();
611
630
  if (!outcome)
612
631
  return undefined;
@@ -788,6 +807,8 @@ export class ClaustrumConsumer {
788
807
  this.#assertOpen();
789
808
  await declineVaultRoute(this.#options.rosterPath, routeId);
790
809
  this.#roster = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
810
+ if (this.#roster)
811
+ this.#hub?.publishRoster(this.#roster);
791
812
  // A hub member shares kept receipts with every other member, so they are
792
813
  // retained against all members' rosters, never against this one alone.
793
814
  if (this.#hub)
@@ -799,6 +820,8 @@ export class ClaustrumConsumer {
799
820
  this.#assertOpen();
800
821
  await acceptVaultRoute(this.#options.rosterPath, routeId);
801
822
  this.#roster = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
823
+ if (this.#roster)
824
+ this.#hub?.publishRoster(this.#roster);
802
825
  }
803
826
  /**
804
827
  * Set the order vault accounts are tried in (`reorderVaultRoster`), then
@@ -809,6 +832,8 @@ export class ClaustrumConsumer {
809
832
  this.#assertOpen();
810
833
  const result = await reorderVaultRoster(this.#options.rosterPath, routeIds);
811
834
  this.#roster = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
835
+ if (this.#roster)
836
+ this.#hub?.publishRoster(this.#roster);
812
837
  return result;
813
838
  }
814
839
  /**
@@ -810,7 +810,7 @@ export async function refreshVaultRoster(options) {
810
810
  throw error;
811
811
  }
812
812
  finally {
813
- await lease.release();
813
+ await lease.release(options.signal);
814
814
  }
815
815
  }
816
816
  /**
@@ -12,7 +12,7 @@
12
12
  // never replaces a view another process committed after this hub listed.
13
13
  import { createHash } from "node:crypto";
14
14
  import { readdir, stat } from "node:fs/promises";
15
- import { dirname, join } from "node:path";
15
+ import { dirname, join, resolve } from "node:path";
16
16
  import { createLogger } from "./cc9e0702a752cea7-index.js";
17
17
  import { combineAbortSignals } from "./6371b24a0573d79e-any-signal.js";
18
18
  import { ClaustrumUnreachableError } from "./94f53cfd572ba4bb-availability.js";
@@ -23,6 +23,8 @@ import { ClaustrumConsumerError } from "./ca0fccaba1d87af4-errors.js";
23
23
  import { DEFAULT_ROUTE_PREFIX, decodedVaultRoster, forgetPendingVaultDiscovery, isVaultRosterLockRefusal, readVaultRoster, refreshVaultRoster, vaultRosterSeed, } from "./30f5bc480f31f51c-roster.js";
24
24
  import { drainShutdown, shutdownWarning } from "./a670cb7f5987bc1b-shutdown.js";
25
25
  import { SAFETY_POLL_MS } from "./dc9290c2a7552ba6-watch.js";
26
+ /** Published rosters are shared only in memory; file locks still order commits. */
27
+ const sharedRosters = new Map();
26
28
  /** Lowercase ASCII, safe as a file name on every OS. */
27
29
  const FILE_ID = /^[a-z0-9][a-z0-9._-]{0,63}$/;
28
30
  /** Device names Windows reserves in every directory, with any extension. */
@@ -250,9 +252,11 @@ export class ClaustrumDiscoveryHub {
250
252
  watchMode: () => this.watchState(),
251
253
  keptReceiptState: () => this.keptReceiptState(),
252
254
  retainUnion: () => this.#retainUnion(),
255
+ publishRoster: (roster) => this.#publishRoster(entry, roster),
253
256
  forget: (credentialId) => this.#current?.custody?.forget(credentialId),
254
257
  detach: () => {
255
258
  entry.closed = true;
259
+ entry.releaseRoster?.();
256
260
  },
257
261
  };
258
262
  const consumerOptions = {
@@ -265,14 +269,58 @@ export class ClaustrumDiscoveryHub {
265
269
  }),
266
270
  ...(this.#options.mapAccount && { mapAccount: this.#options.mapAccount }),
267
271
  ...(options.onRoster && { onRoster: options.onRoster }),
272
+ ...(options.onDiscovery && { onDiscovery: options.onDiscovery }),
268
273
  ...(options.onError && { onError: options.onError }),
269
274
  logger: options.logger ?? this.#logger,
270
275
  ...(this.#options.now && { now: this.#options.now }),
271
276
  };
272
277
  const { consumer, hooks } = createHubMember(port, consumerOptions);
273
278
  entry.hooks = hooks;
279
+ const path = resolve(entry.path);
280
+ const subscribers = sharedRosters.get(path) ?? new Set();
281
+ const install = (roster) => {
282
+ // A peer cannot reactivate an off or closed member, or install routes
283
+ // that collide with this plugin instance's local pool.
284
+ if (entry.closed ||
285
+ this.#active !== true ||
286
+ !this.#current ||
287
+ !this.#live(this.#current) ||
288
+ !hooks.roster() ||
289
+ this.#collides(hooks, roster))
290
+ return;
291
+ entry.seen = JSON.stringify(decodedVaultRoster(roster));
292
+ hooks.install(roster);
293
+ if (roster.view !== this.#committed?.view)
294
+ entry.pending ??= { failures: 0, wait: 0 };
295
+ this.#retainUnion();
296
+ };
297
+ subscribers.add(install);
298
+ entry.receiveRoster = install;
299
+ sharedRosters.set(path, subscribers);
300
+ let subscribed = true;
301
+ entry.releaseRoster = () => {
302
+ if (!subscribed)
303
+ return;
304
+ subscribed = false;
305
+ subscribers.delete(install);
306
+ if (!subscribers.size)
307
+ sharedRosters.delete(path);
308
+ };
274
309
  return consumer;
275
310
  }
311
+ #publishRoster(entry, roster) {
312
+ const generation = this.#current;
313
+ if (entry.closed || !generation || !this.#live(generation))
314
+ return;
315
+ entry.seen = JSON.stringify(decodedVaultRoster(roster));
316
+ entry.hooks?.install(roster);
317
+ for (const install of sharedRosters.get(resolve(entry.path)) ?? []) {
318
+ if (!this.#live(generation))
319
+ return;
320
+ if (install !== entry.receiveRoster)
321
+ install(roster);
322
+ }
323
+ }
276
324
  // --- leases ---
277
325
  #startGeneration() {
278
326
  const generation = {
@@ -582,6 +630,8 @@ export class ClaustrumDiscoveryHub {
582
630
  }));
583
631
  run.promise = promise;
584
632
  this.#run = run;
633
+ for (const entry of this.#open())
634
+ entry.hooks?.discovery(promise);
585
635
  return promise;
586
636
  }
587
637
  /**
@@ -681,9 +731,7 @@ export class ClaustrumDiscoveryHub {
681
731
  continue;
682
732
  }
683
733
  // The push: memory holds the committed roster before refresh resolves.
684
- entry.seen = JSON.stringify(decodedVaultRoster(roster));
685
- if (!entry.closed)
686
- hooks.install(roster);
734
+ this.#publishRoster(entry, roster);
687
735
  }
688
736
  if (!this.#live(generation))
689
737
  return undefined;
@@ -850,7 +898,7 @@ export class ClaustrumDiscoveryHub {
850
898
  }
851
899
  const before = enabledRows(memory);
852
900
  entry.seen = content;
853
- hooks.install(file);
901
+ this.#publishRoster(entry, file);
854
902
  if (enabledRows(hooks.roster()) !== before)
855
903
  this.#retainUnion();
856
904
  }
@@ -1013,6 +1061,8 @@ export class ClaustrumDiscoveryHub {
1013
1061
  if (this.#shutdown.signal.aborted)
1014
1062
  return;
1015
1063
  this.#shutdown.abort(closed('Claustrum discovery hub is closed'));
1064
+ for (const entry of this.#members.values())
1065
+ entry.releaseRoster?.();
1016
1066
  if (this.#timer)
1017
1067
  (this.#options.clearTimeoutImpl ?? clearTimeout)(this.#timer);
1018
1068
  this.#timer = undefined;
@@ -38,7 +38,7 @@ export async function withLock(target, options, fn) {
38
38
  return await fn(lock);
39
39
  }
40
40
  finally {
41
- await lock.release();
41
+ await lock.release(options.signal);
42
42
  }
43
43
  }
44
44
  const remaining = options.timeoutMs - (performance.now() - started);