@cortexkit/opencode-antigravity-auth 3.0.34 → 3.0.35

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 (101) hide show
  1. package/dist/cli.js +413 -182
  2. package/dist/cli.js.map +4 -4
  3. package/dist/cli.meta.json +196 -69
  4. package/dist/index.js +506 -245
  5. package/dist/index.js.map +4 -4
  6. package/dist/index.meta.json +217 -90
  7. package/dist/server.js +578 -291
  8. package/dist/server.js.map +4 -4
  9. package/dist/server.meta.json +1 -1
  10. package/dist/src/common-auth-embedded/auth-menu/accounts.js +9 -3
  11. package/dist/src/common-auth-embedded/claustrum/consumer.d.ts +5 -1
  12. package/dist/src/common-auth-embedded/claustrum/consumer.js +14 -5
  13. package/dist/src/common-auth-embedded/claustrum/custody.d.ts +11 -8
  14. package/dist/src/common-auth-embedded/claustrum/custody.js +26 -15
  15. package/dist/src/common-auth-embedded/claustrum/enrollment.d.ts +2 -0
  16. package/dist/src/common-auth-embedded/claustrum/enrollment.js +7 -0
  17. package/dist/src/common-auth-embedded/claustrum/host.d.ts +8 -0
  18. package/dist/src/common-auth-embedded/claustrum/host.js +113 -0
  19. package/dist/src/common-auth-embedded/claustrum/hub.d.ts +5 -1
  20. package/dist/src/common-auth-embedded/claustrum/hub.js +5 -2
  21. package/dist/src/common-auth-embedded/claustrum/index.d.ts +2 -1
  22. package/dist/src/common-auth-embedded/claustrum/index.js +2 -1
  23. package/dist/src/common-auth-embedded/opencode2/install.js +42 -9
  24. package/dist/src/common-auth-embedded/opencode2/types.d.ts +3 -1
  25. package/dist/src/common-auth-embedded/setup/command.js +8 -4
  26. package/dist/src/common-auth-embedded/setup/enroll.js +3 -0
  27. package/dist/src/common-auth-embedded/source-output.json +68 -52
  28. package/dist/src/ga/rpc/protocol.d.ts +1 -0
  29. package/dist/src/ga/rpc/protocol.d.ts.map +1 -1
  30. package/dist/src/ga/rpc/protocol.js +4 -1
  31. package/dist/src/ga/rpc/protocol.js.map +1 -1
  32. package/dist/src/ga/server/auth.d.ts.map +1 -1
  33. package/dist/src/ga/server/auth.js +27 -4
  34. package/dist/src/ga/server/auth.js.map +1 -1
  35. package/dist/src/ga/server/index.d.ts.map +1 -1
  36. package/dist/src/ga/server/index.js +5 -1
  37. package/dist/src/ga/server/index.js.map +1 -1
  38. package/dist/src/ga/tui/host-ga.d.ts +1 -0
  39. package/dist/src/ga/tui/host-ga.d.ts.map +1 -1
  40. package/dist/src/ga/tui/host-ga.js +41 -20
  41. package/dist/src/ga/tui/host-ga.js.map +1 -1
  42. package/dist/src/plugin/__fixtures__/verified-store.d.ts +1 -1
  43. package/dist/src/plugin/__fixtures__/verified-store.js +4 -4
  44. package/dist/src/plugin/auth-loader.js +1 -1
  45. package/dist/src/plugin/auth-loader.js.map +1 -1
  46. package/dist/src/plugin/background-vault-quota-refresh.js +1 -1
  47. package/dist/src/plugin/background-vault-quota-refresh.js.map +1 -1
  48. package/dist/src/plugin/index.d.ts.map +1 -1
  49. package/dist/src/plugin/index.js +2 -2
  50. package/dist/src/plugin/index.js.map +1 -1
  51. package/dist/src/plugin/shared/source-sidebar.js +1 -1
  52. package/dist/src/plugin/shared/source-sidebar.js.map +1 -1
  53. package/dist/src/plugin/vault-activation.d.ts.map +1 -1
  54. package/dist/src/plugin/vault-activation.js +10 -2
  55. package/dist/src/plugin/vault-activation.js.map +1 -1
  56. package/dist/src/plugin/vault-custody.d.ts.map +1 -1
  57. package/dist/src/plugin/vault-custody.js +25 -3
  58. package/dist/src/plugin/vault-custody.js.map +1 -1
  59. package/dist/src/runtime-layout.js +3 -3
  60. package/dist/src/runtime-layout.js.map +1 -1
  61. package/dist/src/setup.d.ts.map +1 -1
  62. package/dist/src/setup.js +8 -5
  63. package/dist/src/setup.js.map +1 -1
  64. package/dist/tui-build-map.json +1 -1
  65. package/dist/tui-ga-build-map.json +5 -5
  66. package/dist/types/src/common-auth-embedded/claustrum/consumer.d.ts +5 -1
  67. package/dist/types/src/common-auth-embedded/claustrum/custody.d.ts +11 -8
  68. package/dist/types/src/common-auth-embedded/claustrum/enrollment.d.ts +2 -0
  69. package/dist/types/src/common-auth-embedded/claustrum/host.d.ts +8 -0
  70. package/dist/types/src/common-auth-embedded/claustrum/hub.d.ts +5 -1
  71. package/dist/types/src/common-auth-embedded/claustrum/index.d.ts +2 -1
  72. package/dist/types/src/common-auth-embedded/opencode2/types.d.ts +3 -1
  73. package/dist/types/src/ga/rpc/protocol.d.ts +1 -0
  74. package/dist/types/src/ga/rpc/protocol.d.ts.map +1 -1
  75. package/dist/types/src/ga/server/auth.d.ts.map +1 -1
  76. package/dist/types/src/ga/server/index.d.ts.map +1 -1
  77. package/dist/types/src/plugin/index.d.ts.map +1 -1
  78. package/dist/types/src/plugin/vault-activation.d.ts.map +1 -1
  79. package/dist/types/src/plugin/vault-custody.d.ts.map +1 -1
  80. package/dist/types/src/setup.d.ts.map +1 -1
  81. package/package.json +2 -2
  82. package/src/common-auth-embedded/auth-menu/accounts.js +9 -3
  83. package/src/common-auth-embedded/claustrum/consumer.d.ts +5 -1
  84. package/src/common-auth-embedded/claustrum/consumer.js +14 -5
  85. package/src/common-auth-embedded/claustrum/custody.d.ts +11 -8
  86. package/src/common-auth-embedded/claustrum/custody.js +26 -15
  87. package/src/common-auth-embedded/claustrum/enrollment.d.ts +2 -0
  88. package/src/common-auth-embedded/claustrum/enrollment.js +7 -0
  89. package/src/common-auth-embedded/claustrum/host.d.ts +8 -0
  90. package/src/common-auth-embedded/claustrum/host.js +113 -0
  91. package/src/common-auth-embedded/claustrum/hub.d.ts +5 -1
  92. package/src/common-auth-embedded/claustrum/hub.js +5 -2
  93. package/src/common-auth-embedded/claustrum/index.d.ts +2 -1
  94. package/src/common-auth-embedded/claustrum/index.js +2 -1
  95. package/src/common-auth-embedded/opencode2/install.js +42 -9
  96. package/src/common-auth-embedded/opencode2/types.d.ts +3 -1
  97. package/src/common-auth-embedded/setup/command.js +8 -4
  98. package/src/common-auth-embedded/setup/enroll.js +3 -0
  99. package/src/common-auth-embedded/source-output.json +68 -52
  100. package/src/tui-ga-compiled/host-ga.js +13 -5
  101. package/src/tui-ga-raw/host-ga.tsx +43 -19
package/dist/server.js CHANGED
@@ -16352,7 +16352,7 @@ var init_pull = __esm({
16352
16352
  const locks = new LockStack(ctx.lockDefaults, ctx.lockEnv);
16353
16353
  const progress = { writes: 0 };
16354
16354
  try {
16355
- const request = await withTransaction(ctx, locks, progress, { operation: "pull", rowId: id }, async (tx) => {
16355
+ const request2 = await withTransaction(ctx, locks, progress, { operation: "pull", rowId: id }, async (tx) => {
16356
16356
  if (tx.reservation(id) !== void 0)
16357
16357
  return void 0;
16358
16358
  await tx.completeTorn();
@@ -16377,14 +16377,14 @@ var init_pull = __esm({
16377
16377
  };
16378
16378
  }, { completeTorn: false });
16379
16379
  await locks.releaseAll();
16380
- if (!request) {
16380
+ if (!request2) {
16381
16381
  this.firedAtLoad.delete(id);
16382
16382
  return;
16383
16383
  }
16384
16384
  await ctx.hold?.("pull-before-request", id);
16385
16385
  let observation;
16386
16386
  try {
16387
- observation = await this.hook?.(request);
16387
+ observation = await this.hook?.(request2);
16388
16388
  } catch (cause) {
16389
16389
  throw new PoolOperationError({
16390
16390
  operation: "pull",
@@ -16398,8 +16398,8 @@ var init_pull = __esm({
16398
16398
  }
16399
16399
  const publish = rt.publishQuota ?? ((rowId2, attribution, value) => recordQuota(rt, rowId2, attribution, value));
16400
16400
  await publish(id, {
16401
- credentialEpoch: request.credentialEpoch,
16402
- ...request.identity !== void 0 ? { identity: request.identity } : {}
16401
+ credentialEpoch: request2.credentialEpoch,
16402
+ ...request2.identity !== void 0 ? { identity: request2.identity } : {}
16403
16403
  }, observation);
16404
16404
  } catch (error) {
16405
16405
  this.firedAtLoad.delete(id);
@@ -19039,12 +19039,12 @@ function coerceValues(knobs, raw) {
19039
19039
  }
19040
19040
  return { values };
19041
19041
  }
19042
- function findAction(sections, request) {
19043
- const section = sections.find((entry) => entry.id === request.sectionId);
19042
+ function findAction(sections, request2) {
19043
+ const section = sections.find((entry) => entry.id === request2.sectionId);
19044
19044
  if (!section)
19045
19045
  return void 0;
19046
- const actions = request.itemId === void 0 ? section.content.actions : section.content.items?.find((item) => item.id === request.itemId)?.actions;
19047
- return actions?.find((action) => action.id === request.actionId);
19046
+ const actions = request2.itemId === void 0 ? section.content.actions : section.content.items?.find((item) => item.id === request2.itemId)?.actions;
19047
+ return actions?.find((action) => action.id === request2.actionId);
19048
19048
  }
19049
19049
  function createCommandMenu(options) {
19050
19050
  const logger3 = options.logger ?? createLogger2("commands");
@@ -19124,10 +19124,10 @@ function createCommandMenu(options) {
19124
19124
  const own = ownInvocation(invocation, redact3);
19125
19125
  return dialogPayload(options.command, options.title, await sections(own), seam);
19126
19126
  },
19127
- async apply(request, invocation) {
19127
+ async apply(request2, invocation) {
19128
19128
  const own = ownInvocation(invocation, redact3);
19129
19129
  const finish = async (outcome2) => applyResult(options.command, options.title, await sections(own), outcome2, seam);
19130
- const action = request.command === options.command ? findAction(await sections(own), request) : void 0;
19130
+ const action = request2.command === options.command ? findAction(await sections(own), request2) : void 0;
19131
19131
  if (!action)
19132
19132
  return finish({
19133
19133
  ok: false,
@@ -19135,14 +19135,14 @@ function createCommandMenu(options) {
19135
19135
  text: "That action is no longer available."
19136
19136
  });
19137
19137
  const confirmation = confirmationOf(action);
19138
- if (confirmation && request.confirmed !== true)
19138
+ if (confirmation && request2.confirmed !== true)
19139
19139
  return finish({
19140
19140
  ok: false,
19141
19141
  code: "needs-confirmation",
19142
19142
  text: confirmation.message,
19143
19143
  needsConfirmation: true
19144
19144
  });
19145
- const coerced = coerceValues(action.knobs ?? [], request.values);
19145
+ const coerced = coerceValues(action.knobs ?? [], request2.values);
19146
19146
  if ("problem" in coerced)
19147
19147
  return finish({
19148
19148
  ok: false,
@@ -19153,7 +19153,7 @@ function createCommandMenu(options) {
19153
19153
  try {
19154
19154
  const result = await action.run({
19155
19155
  values: coerced.values,
19156
- ...request.itemId !== void 0 ? { itemId: request.itemId } : {},
19156
+ ...request2.itemId !== void 0 ? { itemId: request2.itemId } : {},
19157
19157
  invocation: own
19158
19158
  });
19159
19159
  outcome = typeof result === "string" ? { ok: true, text: result } : {
@@ -19165,8 +19165,8 @@ function createCommandMenu(options) {
19165
19165
  const failure2 = projectFailure(error);
19166
19166
  logger3.warn("command menu action failed", {
19167
19167
  command: options.command,
19168
- section: request.sectionId,
19169
- action: request.actionId,
19168
+ section: request2.sectionId,
19169
+ action: request2.actionId,
19170
19170
  code: failure2.code,
19171
19171
  error: redact3(error instanceof Error ? error.message : String(error))
19172
19172
  });
@@ -19452,6 +19452,219 @@ var init_commands = __esm({
19452
19452
  }
19453
19453
  });
19454
19454
 
19455
+ // ../core/dist/common-auth-embedded/claustrum/errors.js
19456
+ var ClaustrumConsumerError;
19457
+ var init_errors2 = __esm({
19458
+ "../core/dist/common-auth-embedded/claustrum/errors.js"() {
19459
+ "use strict";
19460
+ ClaustrumConsumerError = class extends Error {
19461
+ kind;
19462
+ constructor(kind, message) {
19463
+ super(message);
19464
+ this.name = "ClaustrumConsumerError";
19465
+ this.kind = kind;
19466
+ }
19467
+ };
19468
+ }
19469
+ });
19470
+
19471
+ // ../core/dist/common-auth-embedded/claustrum/availability.js
19472
+ import { ClaustrumCredentialError } from "@cortexkit/claustrum-client";
19473
+ import { SocketClosedError, SocketTimeoutError, SubcCallError } from "@cortexkit/subc-client";
19474
+ function classifyVaultFailure(error) {
19475
+ if (error instanceof ClaustrumUnreachableError || error instanceof SocketClosedError || error instanceof SocketTimeoutError)
19476
+ return "unreachable";
19477
+ const code2 = error instanceof ClaustrumCredentialError || error instanceof SubcCallError ? error.code : error instanceof Error && "code" in error ? error.code : void 0;
19478
+ if (typeof code2 !== "string" || !Object.hasOwn(VAULT_FAILURE_CLASSES, code2))
19479
+ return "answered";
19480
+ return VAULT_FAILURE_CLASSES[code2];
19481
+ }
19482
+ var VAULT_FAILURE_CLASSES, ClaustrumUnreachableError;
19483
+ var init_availability = __esm({
19484
+ "../core/dist/common-auth-embedded/claustrum/availability.js"() {
19485
+ "use strict";
19486
+ init_errors2();
19487
+ VAULT_FAILURE_CLASSES = Object.freeze({
19488
+ ECONNREFUSED: "unreachable",
19489
+ ENOENT: "unreachable",
19490
+ ECONNRESET: "unreachable",
19491
+ EPIPE: "unreachable",
19492
+ ETIMEDOUT: "unreachable",
19493
+ transport_error: "unreachable",
19494
+ unavailable: "unreachable",
19495
+ timeout: "unreachable",
19496
+ route_closed: "unreachable",
19497
+ daemon_draining: "unreachable",
19498
+ connection_closed: "unreachable",
19499
+ connection_dropped: "unreachable",
19500
+ request_deadline: "unreachable",
19501
+ deadline_exceeded_no_drop_observed: "unreachable",
19502
+ module_reloading: "unreachable",
19503
+ module_warming: "unreachable",
19504
+ target_unavailable: "unreachable",
19505
+ module_timeout: "unreachable",
19506
+ invalid_response: "answered",
19507
+ invalid_record_version: "answered",
19508
+ invalid_expiry: "answered",
19509
+ invalid_status: "answered",
19510
+ invalid_params: "answered",
19511
+ ttl_unsatisfiable: "answered",
19512
+ not_found: "answered",
19513
+ enrollment_revoked: "answered",
19514
+ enrollment_invalid: "answered",
19515
+ grant_denied: "answered",
19516
+ credential_unavailable: "answered",
19517
+ needs_reauth: "answered",
19518
+ declined: "answered",
19519
+ disabled: "answered",
19520
+ identity_changed: "answered",
19521
+ closed: "answered",
19522
+ client_closed: "answered",
19523
+ pending_exists: "answered",
19524
+ pending_queue_full: "answered",
19525
+ already_consumed: "answered",
19526
+ superseded: "answered",
19527
+ stale_generation: "answered",
19528
+ missing_identity: "answered",
19529
+ invalid_control_body: "answered",
19530
+ unknown_module: "answered",
19531
+ module_removed: "answered",
19532
+ capability_denied: "answered",
19533
+ unknown_channel: "unreachable",
19534
+ stale_route_epoch: "unreachable",
19535
+ capability_forbidden: "answered",
19536
+ capability_unprovided: "answered",
19537
+ capability_ambiguous: "answered",
19538
+ invalid_capability_identifier: "answered",
19539
+ binary_body_required: "answered",
19540
+ binary_call_requires_call_binary: "answered",
19541
+ corr_exhausted: "answered",
19542
+ late_route_cleanup_failed: "answered",
19543
+ reverse_request_capability_not_declared: "answered",
19544
+ stale_route_handle: "answered",
19545
+ reverse_request_unhandled: "answered",
19546
+ handler_error: "answered",
19547
+ health_error: "answered",
19548
+ duplicate_module_id: "answered",
19549
+ route_rejected: "answered",
19550
+ lock_busy: "answered",
19551
+ owner_invalid: "answered",
19552
+ renewal_failed: "answered",
19553
+ unsupported_platform: "answered",
19554
+ EACCES: "answered",
19555
+ EPERM: "answered",
19556
+ ERR_PRIVATE_FILES_SECURITY: "answered"
19557
+ });
19558
+ ClaustrumUnreachableError = class extends ClaustrumConsumerError {
19559
+ constructor() {
19560
+ super("unavailable", "Claustrum scoped operation unavailable");
19561
+ this.name = "ClaustrumUnreachableError";
19562
+ }
19563
+ };
19564
+ }
19565
+ });
19566
+
19567
+ // ../core/dist/common-auth-embedded/claustrum/host.js
19568
+ import { ClaustrumCredentialError as ClaustrumCredentialError2 } from "@cortexkit/claustrum-client";
19569
+ function isVaultHostClient(client) {
19570
+ return hostClients.has(client);
19571
+ }
19572
+ function hasVaultHost() {
19573
+ return process.env.CORTEXKIT_VAULT_HOST === "thalamus";
19574
+ }
19575
+ function hostError(error) {
19576
+ if (typeof error !== "object" || error === null)
19577
+ return error;
19578
+ const value = error;
19579
+ if (typeof value.code === "string" && (value.class === "transient" || value.class === "permanent" || value.class === "auth_required" || value.class === "context_overflow") && (value.action === "gone" || value.action === "reauth" || value.action === "retry" || value.action === "reduce_and_retry"))
19580
+ return new ClaustrumCredentialError2(value.code, value.class, value.action);
19581
+ if (value.name === "ClaustrumUnreachableError" || typeof value.code === "string" && classifyVaultFailure(Object.assign(new Error(), { code: value.code })) === "unreachable")
19582
+ return new ClaustrumUnreachableError();
19583
+ return error;
19584
+ }
19585
+ function call(operation) {
19586
+ try {
19587
+ return operation();
19588
+ } catch (error) {
19589
+ throw hostError(error);
19590
+ }
19591
+ }
19592
+ async function request(operation) {
19593
+ try {
19594
+ return await operation();
19595
+ } catch (error) {
19596
+ throw hostError(error);
19597
+ }
19598
+ }
19599
+ function wrapHostClient(client) {
19600
+ const watchScoped = client.watchScoped?.bind(client);
19601
+ const reportUsageScoped = client.reportUsageScoped?.bind(client);
19602
+ return {
19603
+ listScoped: (...args) => request(() => client.listScoped(...args)),
19604
+ getScoped: (...args) => request(() => client.getScoped(...args)),
19605
+ reportAuthFailureScoped: (...args) => request(() => client.reportAuthFailureScoped(...args)),
19606
+ close: () => call(() => client.close()),
19607
+ ...watchScoped && {
19608
+ watchScoped: (...args) => {
19609
+ const watch = call(() => watchScoped(...args));
19610
+ return {
19611
+ stop: () => call(() => watch.stop()),
19612
+ closed: request(async () => {
19613
+ const end = await watch.closed;
19614
+ return end.kind === "refused" || end.kind === "transport_lost" ? { ...end, error: hostError(end.error) } : end;
19615
+ })
19616
+ };
19617
+ }
19618
+ },
19619
+ ...reportUsageScoped && {
19620
+ reportUsageScoped: (...args) => request(() => reportUsageScoped(...args))
19621
+ },
19622
+ ...client.insula && {
19623
+ insula: wrapInsula(client.insula)
19624
+ }
19625
+ };
19626
+ }
19627
+ function wrapInsula(transport) {
19628
+ const watchUsage = transport.watchUsage?.bind(transport);
19629
+ return {
19630
+ connectionFile: transport.connectionFile,
19631
+ getUsage: () => request(() => transport.getUsage()),
19632
+ ...watchUsage && {
19633
+ watchUsage: (...args) => {
19634
+ const watch = call(() => watchUsage(...args));
19635
+ return {
19636
+ stop: () => call(() => watch.stop()),
19637
+ closed: request(() => watch.closed)
19638
+ };
19639
+ }
19640
+ }
19641
+ };
19642
+ }
19643
+ function connectVaultHost(pluginId) {
19644
+ if (!hasVaultHost() || !pluginId)
19645
+ throw new ClaustrumUnreachableError();
19646
+ try {
19647
+ const accessor = globalThis[/* @__PURE__ */ Symbol.for("cortexkit.vault")];
19648
+ if (typeof accessor !== "function")
19649
+ throw new ClaustrumUnreachableError();
19650
+ const client = wrapHostClient(accessor(pluginId));
19651
+ hostClients.add(client);
19652
+ return client;
19653
+ } catch {
19654
+ throw new ClaustrumUnreachableError();
19655
+ }
19656
+ }
19657
+ var VAULT_HOST_STATUS, VAULT_HOST_CONNECT_REFUSAL, hostClients;
19658
+ var init_host = __esm({
19659
+ "../core/dist/common-auth-embedded/claustrum/host.js"() {
19660
+ "use strict";
19661
+ init_availability();
19662
+ VAULT_HOST_STATUS = "Served by Thalamus";
19663
+ VAULT_HOST_CONNECT_REFUSAL = "This host gets its vault accounts from Thalamus, so it can't connect to the vault itself.";
19664
+ hostClients = /* @__PURE__ */ new WeakSet();
19665
+ }
19666
+ });
19667
+
19455
19668
  // ../core/dist/common-auth-embedded/auth-menu/doctor.js
19456
19669
  async function runDoctorChecks(checks) {
19457
19670
  const findings = [];
@@ -20222,7 +20435,7 @@ function deleteAllAction(options) {
20222
20435
  };
20223
20436
  }
20224
20437
  async function accountMenuActions(options) {
20225
- return actionsFor(options, await options.custody?.() === true);
20438
+ return actionsFor(options, hasVaultHost() || await options.custody?.() === true);
20226
20439
  }
20227
20440
  function actionsFor(options, custody) {
20228
20441
  const doctor = options.doctor?.length ? [doctorAction({ checks: options.doctor })] : [];
@@ -20247,7 +20460,8 @@ function actionsFor(options, custody) {
20247
20460
  ];
20248
20461
  }
20249
20462
  async function runAccountMenu(options) {
20250
- const custody = await options.custody?.() === true;
20463
+ const hosted = hasVaultHost();
20464
+ const custody = hosted || await options.custody?.() === true;
20251
20465
  const actions = actionsFor(options, custody);
20252
20466
  const [read, status] = await Promise.all([
20253
20467
  readRows(options.store),
@@ -20256,7 +20470,11 @@ async function runAccountMenu(options) {
20256
20470
  return runMenu({
20257
20471
  title: options.title,
20258
20472
  subtitle: custody ? "Accounts come from the vault; select an action" : "Select an account action",
20259
- status: [...status, ...accountLines(read)],
20473
+ status: [
20474
+ ...status,
20475
+ ...hosted ? [VAULT_HOST_STATUS] : [],
20476
+ ...accountLines(read)
20477
+ ],
20260
20478
  actions,
20261
20479
  ...options.terminal ? { terminal: options.terminal } : {}
20262
20480
  });
@@ -20265,6 +20483,7 @@ var MENU_DISABLE_REASON, STATUS_ACCOUNT_LINES;
20265
20483
  var init_accounts = __esm({
20266
20484
  "../core/dist/common-auth-embedded/auth-menu/accounts.js"() {
20267
20485
  "use strict";
20486
+ init_host();
20268
20487
  init_quota();
20269
20488
  init_store();
20270
20489
  init_doctor();
@@ -20356,118 +20575,6 @@ var init_auth_menu = __esm({
20356
20575
  }
20357
20576
  });
20358
20577
 
20359
- // ../core/dist/common-auth-embedded/claustrum/errors.js
20360
- var ClaustrumConsumerError;
20361
- var init_errors2 = __esm({
20362
- "../core/dist/common-auth-embedded/claustrum/errors.js"() {
20363
- "use strict";
20364
- ClaustrumConsumerError = class extends Error {
20365
- kind;
20366
- constructor(kind, message) {
20367
- super(message);
20368
- this.name = "ClaustrumConsumerError";
20369
- this.kind = kind;
20370
- }
20371
- };
20372
- }
20373
- });
20374
-
20375
- // ../core/dist/common-auth-embedded/claustrum/availability.js
20376
- import { ClaustrumCredentialError } from "@cortexkit/claustrum-client";
20377
- import { SocketClosedError, SocketTimeoutError, SubcCallError } from "@cortexkit/subc-client";
20378
- function classifyVaultFailure(error) {
20379
- if (error instanceof ClaustrumUnreachableError || error instanceof SocketClosedError || error instanceof SocketTimeoutError)
20380
- return "unreachable";
20381
- const code2 = error instanceof ClaustrumCredentialError || error instanceof SubcCallError ? error.code : error instanceof Error && "code" in error ? error.code : void 0;
20382
- if (typeof code2 !== "string" || !Object.hasOwn(VAULT_FAILURE_CLASSES, code2))
20383
- return "answered";
20384
- return VAULT_FAILURE_CLASSES[code2];
20385
- }
20386
- var VAULT_FAILURE_CLASSES, ClaustrumUnreachableError;
20387
- var init_availability = __esm({
20388
- "../core/dist/common-auth-embedded/claustrum/availability.js"() {
20389
- "use strict";
20390
- init_errors2();
20391
- VAULT_FAILURE_CLASSES = Object.freeze({
20392
- ECONNREFUSED: "unreachable",
20393
- ENOENT: "unreachable",
20394
- ECONNRESET: "unreachable",
20395
- EPIPE: "unreachable",
20396
- ETIMEDOUT: "unreachable",
20397
- transport_error: "unreachable",
20398
- unavailable: "unreachable",
20399
- timeout: "unreachable",
20400
- route_closed: "unreachable",
20401
- daemon_draining: "unreachable",
20402
- connection_closed: "unreachable",
20403
- connection_dropped: "unreachable",
20404
- request_deadline: "unreachable",
20405
- deadline_exceeded_no_drop_observed: "unreachable",
20406
- module_reloading: "unreachable",
20407
- module_warming: "unreachable",
20408
- target_unavailable: "unreachable",
20409
- module_timeout: "unreachable",
20410
- invalid_response: "answered",
20411
- invalid_record_version: "answered",
20412
- invalid_expiry: "answered",
20413
- invalid_status: "answered",
20414
- invalid_params: "answered",
20415
- ttl_unsatisfiable: "answered",
20416
- not_found: "answered",
20417
- enrollment_revoked: "answered",
20418
- enrollment_invalid: "answered",
20419
- grant_denied: "answered",
20420
- credential_unavailable: "answered",
20421
- needs_reauth: "answered",
20422
- declined: "answered",
20423
- disabled: "answered",
20424
- identity_changed: "answered",
20425
- closed: "answered",
20426
- client_closed: "answered",
20427
- pending_exists: "answered",
20428
- pending_queue_full: "answered",
20429
- already_consumed: "answered",
20430
- superseded: "answered",
20431
- stale_generation: "answered",
20432
- missing_identity: "answered",
20433
- invalid_control_body: "answered",
20434
- unknown_module: "answered",
20435
- module_removed: "answered",
20436
- capability_denied: "answered",
20437
- unknown_channel: "unreachable",
20438
- stale_route_epoch: "unreachable",
20439
- capability_forbidden: "answered",
20440
- capability_unprovided: "answered",
20441
- capability_ambiguous: "answered",
20442
- invalid_capability_identifier: "answered",
20443
- binary_body_required: "answered",
20444
- binary_call_requires_call_binary: "answered",
20445
- corr_exhausted: "answered",
20446
- late_route_cleanup_failed: "answered",
20447
- reverse_request_capability_not_declared: "answered",
20448
- stale_route_handle: "answered",
20449
- reverse_request_unhandled: "answered",
20450
- handler_error: "answered",
20451
- health_error: "answered",
20452
- duplicate_module_id: "answered",
20453
- route_rejected: "answered",
20454
- lock_busy: "answered",
20455
- owner_invalid: "answered",
20456
- renewal_failed: "answered",
20457
- unsupported_platform: "answered",
20458
- EACCES: "answered",
20459
- EPERM: "answered",
20460
- ERR_PRIVATE_FILES_SECURITY: "answered"
20461
- });
20462
- ClaustrumUnreachableError = class extends ClaustrumConsumerError {
20463
- constructor() {
20464
- super("unavailable", "Claustrum scoped operation unavailable");
20465
- this.name = "ClaustrumUnreachableError";
20466
- }
20467
- };
20468
- }
20469
- });
20470
-
20471
20578
  // ../core/dist/common-auth-embedded/claustrum/watch.js
20472
20579
  var SAFETY_POLL_MS, WATCH_RETRY_MS, RESUBSCRIBE_BACKOFF_MS, ChangeNoticeReader, CoalescedRead, ScopedRosterWatch;
20473
20580
  var init_watch = __esm({
@@ -20692,7 +20799,7 @@ function insulaUsageTransport(options) {
20692
20799
  timer = setTimeout(() => reject(new Error("insula usage timeout")), 3e3);
20693
20800
  timer.unref?.();
20694
20801
  });
20695
- const request = (async () => {
20802
+ const request2 = (async () => {
20696
20803
  client = options.connector ? await options.connector({
20697
20804
  connectionFile: options.connectionFile,
20698
20805
  handshakeTimeoutMs: Math.min(options.handshakeTimeoutMs ?? 3e3, 3e3)
@@ -20708,7 +20815,7 @@ function insulaUsageTransport(options) {
20708
20815
  return await client.request(route, { method: "usage.get", params: {} });
20709
20816
  })();
20710
20817
  try {
20711
- return await Promise.race([request, timeout]);
20818
+ return await Promise.race([request2, timeout]);
20712
20819
  } finally {
20713
20820
  expired = true;
20714
20821
  clearTimeout(timer);
@@ -21121,9 +21228,9 @@ import { createHash as createHash6, randomBytes as randomBytes4, randomUUID as r
21121
21228
  import { constants as fsConstants } from "node:fs";
21122
21229
  import { chmod as chmod2, mkdir as mkdir8, open as open6, readFile as readFile6, realpath as realpath3, rename as rename7, stat as stat5, unlink as unlink6 } from "node:fs/promises";
21123
21230
  import { basename as basename3, dirname as dirname9, extname, isAbsolute as isAbsolute2, join as join7, resolve as resolve7 } from "node:path";
21124
- import { ClaustrumCredentialError as ClaustrumCredentialError2, ClaustrumClient as ClaustrumWireClient, writeEnrollmentTokenFile } from "@cortexkit/claustrum-client";
21231
+ import { ClaustrumCredentialError as ClaustrumCredentialError3, ClaustrumClient as ClaustrumWireClient, writeEnrollmentTokenFile } from "@cortexkit/claustrum-client";
21125
21232
  function classifyEnrollmentError(error) {
21126
- if (!(error instanceof ClaustrumCredentialError2))
21233
+ if (!(error instanceof ClaustrumCredentialError3))
21127
21234
  return void 0;
21128
21235
  if (TERMINAL_ENROLLMENT_CODES.has(error.code))
21129
21236
  return { code: error.code, disposition: "terminal" };
@@ -21476,6 +21583,11 @@ async function enrollmentAuthority(paths, proposedName) {
21476
21583
  }
21477
21584
  return "local";
21478
21585
  }
21586
+ async function vaultAuthority(paths, proposedName) {
21587
+ if (hasVaultHost())
21588
+ return "host";
21589
+ return enrollmentAuthority(paths, proposedName);
21590
+ }
21479
21591
  async function readClaustrumEnrollmentToken(tokenPath) {
21480
21592
  const value = await readBoundedJson(tokenPath);
21481
21593
  if (value === void 0)
@@ -21589,6 +21701,7 @@ var init_enrollment = __esm({
21589
21701
  init_fs();
21590
21702
  init_private_files();
21591
21703
  init_errors2();
21704
+ init_host();
21592
21705
  ENROLLMENT_SCHEMA = 1;
21593
21706
  ENROLLMENT_FILE_MAX_BYTES = 16 * 1024;
21594
21707
  ENROLLMENT_LOCK_TTL_MS = 3e4;
@@ -21904,7 +22017,7 @@ var init_shutdown = __esm({
21904
22017
  });
21905
22018
 
21906
22019
  // ../core/dist/common-auth-embedded/claustrum/usage.js
21907
- import { ClaustrumCredentialError as ClaustrumCredentialError3 } from "@cortexkit/claustrum-client";
22020
+ import { ClaustrumCredentialError as ClaustrumCredentialError4 } from "@cortexkit/claustrum-client";
21908
22021
  function plain(value) {
21909
22022
  return value !== null && typeof value === "object" && (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
21910
22023
  }
@@ -22010,7 +22123,7 @@ var init_usage = __esm({
22010
22123
  #log(error) {
22011
22124
  let code2 = "transport_error";
22012
22125
  try {
22013
- if (error instanceof ClaustrumCredentialError3)
22126
+ if (error instanceof ClaustrumCredentialError4)
22014
22127
  code2 = /^[a-z][a-z0-9_]{0,63}$/.test(error.code) ? error.code : code2;
22015
22128
  if (this.#errors.has(code2))
22016
22129
  return;
@@ -22040,7 +22153,7 @@ var init_usage = __esm({
22040
22153
 
22041
22154
  // ../core/dist/common-auth-embedded/claustrum/custody.js
22042
22155
  import { channel } from "node:diagnostics_channel";
22043
- import { ClaustrumCredentialError as ClaustrumCredentialError4 } from "@cortexkit/claustrum-client";
22156
+ import { ClaustrumCredentialError as ClaustrumCredentialError5 } from "@cortexkit/claustrum-client";
22044
22157
  function isScopedCredentialRotation(served, current) {
22045
22158
  return current !== void 0 && !current.fromKeptReceipt && !served.fromKeptReceipt && current.credentialId === served.credentialId && current.accountIdentity === served.accountIdentity && current.recordVersion !== served.recordVersion;
22046
22159
  }
@@ -22167,6 +22280,7 @@ var init_custody = __esm({
22167
22280
  init_availability();
22168
22281
  init_enrollment();
22169
22282
  init_errors2();
22283
+ init_host();
22170
22284
  init_host_slot();
22171
22285
  init_shutdown();
22172
22286
  init_usage();
@@ -22206,15 +22320,21 @@ var init_custody = __esm({
22206
22320
  #onDrainTimeout;
22207
22321
  #disposing;
22208
22322
  constructor(options) {
22323
+ if (hasVaultHost() && options.client && !isVaultHostClient(options.client))
22324
+ throw new ClaustrumUnreachableError();
22209
22325
  const tokenPath = options.tokenPath;
22210
22326
  if (options.readToken) {
22211
22327
  this.#readToken = options.readToken;
22212
22328
  } else if (tokenPath) {
22213
22329
  this.#readToken = () => readClaustrumEnrollmentToken(tokenPath);
22330
+ } else if (hasVaultHost()) {
22331
+ this.#readToken = async () => {
22332
+ throw new ClaustrumConsumerError("not-enrolled", "Claustrum enrollment token path is required");
22333
+ };
22214
22334
  } else {
22215
22335
  throw new ClaustrumConsumerError("not-enrolled", "Claustrum enrollment token path is required");
22216
22336
  }
22217
- this.#client = options.client;
22337
+ this.#client = options.client ?? connectVaultHost(options.pluginId);
22218
22338
  this.#family = options.family;
22219
22339
  this.#parseIdentity = options.parseIdentity;
22220
22340
  this.#requireAssertion = options.requireAssertion ?? false;
@@ -22226,7 +22346,7 @@ var init_custody = __esm({
22226
22346
  this.#usage = new ScopedUsageReporter({
22227
22347
  client: this.#client,
22228
22348
  owns: (id) => this.#usageServed.has(id),
22229
- token: async () => checkedEnrollmentToken(await this.#readToken()),
22349
+ token: async () => hasVaultHost() ? "" : checkedEnrollmentToken(await this.#readToken()),
22230
22350
  logger: this.#logger,
22231
22351
  setTimeout: this.#setTimeout,
22232
22352
  clearTimeout: this.#clearTimeout
@@ -22237,7 +22357,7 @@ var init_custody = __esm({
22237
22357
  if (this.#closed || this.#outage)
22238
22358
  return;
22239
22359
  this.#outage = true;
22240
- this.#outageError = error instanceof ClaustrumCredentialError4 ? error : new ClaustrumUnreachableError();
22360
+ this.#outageError = error instanceof ClaustrumCredentialError5 ? error : new ClaustrumUnreachableError();
22241
22361
  this.#logger.warn("serving kept vault receipt", { reason: "unreachable" });
22242
22362
  this.#scheduleProbe();
22243
22363
  }
@@ -22287,6 +22407,8 @@ var init_custody = __esm({
22287
22407
  }
22288
22408
  async #token(signal) {
22289
22409
  this.#check(signal);
22410
+ if (hasVaultHost())
22411
+ return "";
22290
22412
  if (phaseDiagnostics.hasSubscribers)
22291
22413
  phaseDiagnostics.publish({
22292
22414
  logger: this.#logger,
@@ -22330,7 +22452,7 @@ var init_custody = __esm({
22330
22452
  this.transportLost(error);
22331
22453
  else
22332
22454
  this.reachable();
22333
- if (error instanceof ClaustrumCredentialError4)
22455
+ if (error instanceof ClaustrumCredentialError5)
22334
22456
  throw error;
22335
22457
  if (classifyVaultFailure(error) === "unreachable")
22336
22458
  throw new ClaustrumUnreachableError();
@@ -22549,7 +22671,7 @@ var init_custody = __esm({
22549
22671
  if (kept.since === null)
22550
22672
  kept.since = this.#now();
22551
22673
  const attempt = Object.freeze(Object.defineProperty({ ...kept.attempt, fromKeptReceipt: true }, "accessToken", { value: kept.attempt.accessToken, enumerable: false }));
22552
- this.#provenance.set(attempt, token);
22674
+ this.#provenance.set(attempt, this.#provenance.get(kept.attempt) ?? { token, client: this.#client });
22553
22675
  this.#keptAttempts.set(attempt, routeId);
22554
22676
  return attempt;
22555
22677
  }
@@ -22610,22 +22732,22 @@ var init_custody = __esm({
22610
22732
  recordVersion: served.recordVersion,
22611
22733
  expiresAtMs
22612
22734
  }, "accessToken", { value: accessToken, enumerable: false }));
22613
- this.#provenance.set(attempt, token);
22735
+ this.#provenance.set(attempt, { token, client: this.#client });
22614
22736
  return attempt;
22615
22737
  }
22616
22738
  /**
22617
22739
  * Report that a send this consumer actually made was rejected. Only a 401
22618
22740
  * is reported (the vault refuses 429, 402 and 5xx reports), addressed by
22619
22741
  * credential id with the exact record version that send was served, and
22620
- * signed with the enrollment token that authorized it. A receipt this
22621
- * custody did not issue is refused rather than reported.
22742
+ * sent through the client and enrollment token that authorized it. A receipt
22743
+ * this custody did not issue is refused rather than reported.
22622
22744
  */
22623
22745
  async reportFailure(attempt, status, reporterSource) {
22624
22746
  if (status !== 401)
22625
22747
  return;
22626
22748
  this.#check();
22627
- const token = this.#provenance.get(attempt);
22628
- if (!token)
22749
+ const provenance = this.#provenance.get(attempt);
22750
+ if (!provenance)
22629
22751
  throw new ClaustrumConsumerError("no-receipt", "Claustrum failure report requires an original dispatch receipt");
22630
22752
  const keptRoute = this.#keptAttempts.get(attempt);
22631
22753
  if (keptRoute !== void 0) {
@@ -22642,9 +22764,9 @@ var init_custody = __esm({
22642
22764
  const pending = this.#reports.get(attempt);
22643
22765
  if (pending)
22644
22766
  return pending;
22645
- const report = this.#call(() => this.#client.reportAuthFailureScoped({
22767
+ const report = this.#call(() => provenance.client.reportAuthFailureScoped({
22646
22768
  credentialId: attempt.credentialId,
22647
- enrollmentToken: token,
22769
+ enrollmentToken: provenance.token,
22648
22770
  providerStatus: 401,
22649
22771
  recordVersion: attempt.recordVersion,
22650
22772
  reporterSource
@@ -23664,6 +23786,7 @@ var init_consumer = __esm({
23664
23786
  init_custody();
23665
23787
  init_enrollment();
23666
23788
  init_errors2();
23789
+ init_host();
23667
23790
  init_insula();
23668
23791
  init_quota_writer2();
23669
23792
  init_roster();
@@ -23726,6 +23849,8 @@ var init_consumer = __esm({
23726
23849
  return pending;
23727
23850
  }
23728
23851
  async #active() {
23852
+ if (hasVaultHost())
23853
+ return true;
23729
23854
  return await this.#options.isCustodyActive?.() ?? true;
23730
23855
  }
23731
23856
  #wait(pending, signal) {
@@ -23776,7 +23901,7 @@ var init_consumer = __esm({
23776
23901
  #boundedConnect(attempt) {
23777
23902
  const setTimer = this.#options.setTimeoutImpl ?? setTimeout;
23778
23903
  const clearTimer = this.#options.clearTimeoutImpl ?? clearTimeout;
23779
- const pending = this.#options.connect().then((client) => {
23904
+ const pending = (!hasVaultHost() && this.#options.connect ? this.#options.connect() : Promise.resolve().then(() => connectVaultHost(this.#options.pluginId))).then((client) => {
23780
23905
  if (this.#shutdown.signal.aborted || attempt.timedOut) {
23781
23906
  client.close();
23782
23907
  if (!attempt.timedOut)
@@ -24029,7 +24154,8 @@ var init_consumer = __esm({
24029
24154
  if (!this.#options.insula || this.#shutdown.signal.aborted || !await this.#active())
24030
24155
  return;
24031
24156
  try {
24032
- await readClaustrumEnrollmentToken(this.#options.tokenPath);
24157
+ if (!hasVaultHost())
24158
+ await readClaustrumEnrollmentToken(this.#options.tokenPath);
24033
24159
  await this.#getCustody();
24034
24160
  await this.#insula?.source.refresh((this.#options.now ?? Date.now)());
24035
24161
  } catch {
@@ -24045,7 +24171,8 @@ var init_consumer = __esm({
24045
24171
  if (!this.#options.insula || this.#shutdown.signal.aborted || !await this.#active())
24046
24172
  return void 0;
24047
24173
  try {
24048
- await readClaustrumEnrollmentToken(this.#options.tokenPath);
24174
+ if (!hasVaultHost())
24175
+ await readClaustrumEnrollmentToken(this.#options.tokenPath);
24049
24176
  return this.#normalizeInsulaQuota(receipt2.assertedAccountIdentity);
24050
24177
  } catch {
24051
24178
  return void 0;
@@ -24060,7 +24187,8 @@ var init_consumer = __esm({
24060
24187
  if (!this.#options.insula || this.#shutdown.signal.aborted || !await this.#active())
24061
24188
  return void 0;
24062
24189
  try {
24063
- await readClaustrumEnrollmentToken(this.#options.tokenPath);
24190
+ if (!hasVaultHost())
24191
+ await readClaustrumEnrollmentToken(this.#options.tokenPath);
24064
24192
  const roster = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
24065
24193
  const row = roster?.rows.find((entry) => entry.routeId === routeId);
24066
24194
  return this.#normalizeInsulaQuota(row?.accountIdentity);
@@ -24074,7 +24202,8 @@ var init_consumer = __esm({
24074
24202
  if (!options || this.#shutdown.signal.aborted || !await this.#active())
24075
24203
  return { miss: "unreachable" };
24076
24204
  try {
24077
- await readClaustrumEnrollmentToken(this.#options.tokenPath);
24205
+ if (!hasVaultHost())
24206
+ await readClaustrumEnrollmentToken(this.#options.tokenPath);
24078
24207
  const roster = pendingVaultQuota(this.#options.rosterPath, await readVaultRoster(this.#options.rosterPath));
24079
24208
  const account = roster?.rows.find((row) => row.routeId === routeId)?.accountIdentity;
24080
24209
  if (!account || !this.#insula)
@@ -24578,6 +24707,7 @@ var init_hub = __esm({
24578
24707
  init_custody();
24579
24708
  init_enrollment();
24580
24709
  init_errors2();
24710
+ init_host();
24581
24711
  init_roster();
24582
24712
  init_shutdown();
24583
24713
  init_watch();
@@ -24807,7 +24937,7 @@ var init_hub = __esm({
24807
24937
  const entry = { generation, timedOut: false };
24808
24938
  const connectTimeoutMs = this.#options.connectTimeoutMs ?? DEFAULT_CONNECT_TIMEOUT_MS;
24809
24939
  let timer;
24810
- const connect3 = this.#options.connect().then((client) => {
24940
+ const connect3 = (!hasVaultHost() && this.#options.connect ? this.#options.connect() : Promise.resolve().then(() => connectVaultHost(this.#options.pluginId))).then((client) => {
24811
24941
  if (entry.timedOut) {
24812
24942
  client.close();
24813
24943
  throw unreachableConnect2();
@@ -24982,7 +25112,7 @@ var init_hub = __esm({
24982
25112
  * runs the inactive transition; nothing else does.
24983
25113
  */
24984
25114
  async #readAuthority() {
24985
- const active2 = await this.#options.isCustodyActive?.() ?? true;
25115
+ const active2 = hasVaultHost() || (await this.#options.isCustodyActive?.() ?? true);
24986
25116
  if (this.#shutdown.signal.aborted)
24987
25117
  return false;
24988
25118
  const was = this.#active;
@@ -25489,7 +25619,7 @@ __export(claustrum_exports, {
25489
25619
  ChangeNoticeReader: () => ChangeNoticeReader,
25490
25620
  ClaustrumConsumer: () => ClaustrumConsumer,
25491
25621
  ClaustrumConsumerError: () => ClaustrumConsumerError,
25492
- ClaustrumCredentialError: () => ClaustrumCredentialError5,
25622
+ ClaustrumCredentialError: () => ClaustrumCredentialError6,
25493
25623
  ClaustrumDiscoveryHub: () => ClaustrumDiscoveryHub,
25494
25624
  ClaustrumEnrollmentManager: () => ClaustrumEnrollmentManager,
25495
25625
  ClaustrumScopedCustody: () => ClaustrumScopedCustody,
@@ -25505,6 +25635,8 @@ __export(claustrum_exports, {
25505
25635
  ScopedRosterWatch: () => ScopedRosterWatch,
25506
25636
  TERMINAL_ENROLLMENT_CODES: () => TERMINAL_ENROLLMENT_CODES,
25507
25637
  VAULT_FAILURE_CLASSES: () => VAULT_FAILURE_CLASSES,
25638
+ VAULT_HOST_CONNECT_REFUSAL: () => VAULT_HOST_CONNECT_REFUSAL,
25639
+ VAULT_HOST_STATUS: () => VAULT_HOST_STATUS,
25508
25640
  WATCH_RETRY_MS: () => WATCH_RETRY_MS,
25509
25641
  acceptAccount: () => acceptAccount,
25510
25642
  acceptVaultRoute: () => acceptVaultRoute,
@@ -25516,6 +25648,7 @@ __export(claustrum_exports, {
25516
25648
  classifyVaultFailure: () => classifyVaultFailure,
25517
25649
  connectClaustrumEnrollmentClient: () => connectClaustrumEnrollmentClient,
25518
25650
  connectClaustrumScopedClient: () => connectClaustrumScopedClient,
25651
+ connectVaultHost: () => connectVaultHost,
25519
25652
  custodyPlaceholder: () => custodyPlaceholder,
25520
25653
  custodyPlaceholderKey: () => custodyPlaceholderKey,
25521
25654
  decideScopedRetryAfter401: () => decideScopedRetryAfter401,
@@ -25542,11 +25675,12 @@ __export(claustrum_exports, {
25542
25675
  reorderVaultRoster: () => reorderVaultRoster,
25543
25676
  resetClaustrumEnrollmentState: () => resetClaustrumEnrollmentState,
25544
25677
  resolveVaultPrimary: () => resolveVaultPrimary,
25678
+ vaultAuthority: () => vaultAuthority,
25545
25679
  vaultRosterSeed: () => vaultRosterSeed,
25546
25680
  vaultRoutingRows: () => vaultRoutingRows
25547
25681
  });
25548
25682
  import { ClaustrumClient } from "@cortexkit/claustrum-client";
25549
- import { ClaustrumCredentialError as ClaustrumCredentialError5 } from "@cortexkit/claustrum-client";
25683
+ import { ClaustrumCredentialError as ClaustrumCredentialError6 } from "@cortexkit/claustrum-client";
25550
25684
  async function connectClaustrumScopedClient(options) {
25551
25685
  const { connectTimeoutMs, ...client } = options;
25552
25686
  const limit = connectTimeoutMs ?? SCOPED_CONNECT_TIMEOUT_MS;
@@ -25583,6 +25717,7 @@ var init_claustrum = __esm({
25583
25717
  init_custody();
25584
25718
  init_enrollment();
25585
25719
  init_errors2();
25720
+ init_host();
25586
25721
  init_host_slot();
25587
25722
  init_hub();
25588
25723
  init_insula();
@@ -29008,6 +29143,7 @@ function admissionFromReceipt(ref, receipt2) {
29008
29143
  function createAntigravityVaultAccountSource(options) {
29009
29144
  const { claustrum } = options;
29010
29145
  const consumer = new claustrum.ClaustrumConsumer({
29146
+ pluginId: "antigravity-auth",
29011
29147
  rosterPath: options.rosterPath,
29012
29148
  tokenPath: options.tokenPath,
29013
29149
  family: { ...ANTIGRAVITY_VAULT_FAMILY },
@@ -29245,9 +29381,9 @@ var init_vault_account_source = __esm({
29245
29381
  });
29246
29382
 
29247
29383
  // ../core/dist/vault-enrollment-authority.js
29248
- async function enrollmentAuthority2(paths, proposedName, reader) {
29384
+ async function vaultAuthority2(paths, proposedName, reader) {
29249
29385
  try {
29250
- return await (reader ?? await loadCommonAuthClaustrum()).enrollmentAuthority(paths, proposedName);
29386
+ return await (reader ?? await loadCommonAuthClaustrum()).vaultAuthority(paths, proposedName);
29251
29387
  } catch {
29252
29388
  return "unreadable";
29253
29389
  }
@@ -30737,6 +30873,12 @@ function createOpenCodeVaultCustody(options) {
30737
30873
  const readEnrollment = async () => {
30738
30874
  if (layoutRefusal !== void 0) return unsettled;
30739
30875
  const claustrum = await loadClaustrum();
30876
+ if (process.env.CORTEXKIT_VAULT_HOST === "thalamus")
30877
+ return {
30878
+ state: "unavailable",
30879
+ code: "host",
30880
+ proposedName: OPENCODE_VAULT_ENROLLMENT_NAME
30881
+ };
30740
30882
  const status = await claustrum.readClaustrumEnrollmentStatus(
30741
30883
  await enrollmentPaths(),
30742
30884
  OPENCODE_VAULT_ENROLLMENT_NAME
@@ -30759,6 +30901,8 @@ function createOpenCodeVaultCustody(options) {
30759
30901
  const readEnrollmentSnapshot = async () => {
30760
30902
  if (layoutRefusal !== void 0)
30761
30903
  return { authority: "unreadable", status: unsettled };
30904
+ if (process.env.CORTEXKIT_VAULT_HOST === "thalamus")
30905
+ return { authority: "host", status: await readEnrollment() };
30762
30906
  const enrollment = await enrollmentPaths();
30763
30907
  const identity3 = await enrollmentFilesIdentity(enrollment);
30764
30908
  if (identity3) {
@@ -30769,7 +30913,7 @@ function createOpenCodeVaultCustody(options) {
30769
30913
  return enrollmentReading.promise;
30770
30914
  }
30771
30915
  const promise = (async () => {
30772
- const authority = await enrollmentAuthority2(
30916
+ const authority = await vaultAuthority2(
30773
30917
  enrollment,
30774
30918
  OPENCODE_VAULT_ENROLLMENT_NAME,
30775
30919
  await loadClaustrum()
@@ -30841,6 +30985,7 @@ function createOpenCodeVaultCustody(options) {
30841
30985
  observedAuthority = authority;
30842
30986
  options.onAuthorityChanged?.(authority);
30843
30987
  }
30988
+ if (authority === "host") return true;
30844
30989
  if (authority !== "vault") return false;
30845
30990
  return status.state === "approved";
30846
30991
  },
@@ -30976,7 +31121,7 @@ function createOpenCodeVaultCustody(options) {
30976
31121
  return { ok: false, reason: VAULT_ACCOUNT_REMEDY };
30977
31122
  return {
30978
31123
  ok: true,
30979
- record: authority === "vault" ? CUSTODY_MODE : LOCAL_MODE
31124
+ record: authority === "vault" || authority === "host" ? CUSTODY_MODE : LOCAL_MODE
30980
31125
  };
30981
31126
  },
30982
31127
  async custodySource() {
@@ -31002,10 +31147,16 @@ function createOpenCodeVaultCustody(options) {
31002
31147
  };
31003
31148
  },
31004
31149
  async requestAccess() {
31150
+ const claustrum = await loadClaustrum();
31151
+ if (process.env.CORTEXKIT_VAULT_HOST === "thalamus")
31152
+ throw new OpenCodeVaultCustodyError(
31153
+ claustrum.VAULT_HOST_CONNECT_REFUSAL
31154
+ );
31005
31155
  return connectStep(true);
31006
31156
  },
31007
31157
  async useVault() {
31008
31158
  refuseUnsettled();
31159
+ if (process.env.CORTEXKIT_VAULT_HOST === "thalamus") return;
31009
31160
  const enrollment = await readEnrollment();
31010
31161
  if (enrollment.state !== "approved")
31011
31162
  throw new OpenCodeVaultCustodyError(
@@ -31017,6 +31168,10 @@ function createOpenCodeVaultCustody(options) {
31017
31168
  async useLocal() {
31018
31169
  refuseUnsettled();
31019
31170
  const claustrum = await loadClaustrum();
31171
+ if (process.env.CORTEXKIT_VAULT_HOST === "thalamus")
31172
+ throw new OpenCodeVaultCustodyError(
31173
+ claustrum.VAULT_HOST_CONNECT_REFUSAL
31174
+ );
31020
31175
  const disconnected = await claustrum.disconnectClaustrumEnrollment(
31021
31176
  await enrollmentPaths(),
31022
31177
  OPENCODE_VAULT_ENROLLMENT_NAME
@@ -31047,6 +31202,9 @@ function createOpenCodeVaultCustody(options) {
31047
31202
  build: async () => {
31048
31203
  if (layoutRefusal !== void 0)
31049
31204
  return { lines: [`Vault: ${layoutRefusal}`], actions: [] };
31205
+ const claustrum = await loadClaustrum();
31206
+ if (process.env.CORTEXKIT_VAULT_HOST === "thalamus")
31207
+ return { lines: [claustrum.VAULT_HOST_STATUS], actions: [] };
31050
31208
  const status = await custody.status();
31051
31209
  const lines = statusLines(status);
31052
31210
  if (status.enrollment.state === "approved")
@@ -32079,7 +32237,7 @@ async function localAccountStoreAuthorized() {
32079
32237
  if (folder?.refusal) return false;
32080
32238
  const claustrum = await loadCommonAuthClaustrum();
32081
32239
  const vaultDir = folder ? folder.vaultDir : decidedRuntimeLayout(location) === "state-home" ? stateHomeVaultDir(location) : legacyVaultDir(accountFileForVault(location.configDir));
32082
- return await enrollmentAuthority2(
32240
+ return await vaultAuthority2(
32083
32241
  claustrum.hostEnrollmentPaths({
32084
32242
  stateDir: vaultDir,
32085
32243
  host: OPENCODE_VAULT_HOST
@@ -35060,22 +35218,22 @@ function extractAccountAccessErrorDetails(bodyText) {
35060
35218
  }
35061
35219
  function buildAccountAccessProbeRequest(projectId) {
35062
35220
  const wireModel = "gemini-3.8-flash-low";
35063
- const request = {
35221
+ const request2 = {
35064
35222
  contents: [{ role: "user", parts: [{ text: "ping" }] }],
35065
35223
  generationConfig: { maxOutputTokens: 1, temperature: 0 }
35066
35224
  };
35067
35225
  const requestMetadata = buildAgyAgentRequestMetadata(
35068
35226
  createAgyRequestSessionContext(""),
35069
- request,
35227
+ request2,
35070
35228
  wireModel
35071
35229
  );
35072
- request.labels = requestMetadata.labels;
35073
- request.sessionId = requestMetadata.sessionId;
35074
- orderAgyRequestPayloadInPlace(request);
35230
+ request2.labels = requestMetadata.labels;
35231
+ request2.sessionId = requestMetadata.sessionId;
35232
+ orderAgyRequestPayloadInPlace(request2);
35075
35233
  return {
35076
35234
  project: projectId,
35077
35235
  requestId: requestMetadata.requestId,
35078
- request,
35236
+ request: request2,
35079
35237
  model: wireModel,
35080
35238
  userAgent: "antigravity",
35081
35239
  requestType: "agent"
@@ -37208,7 +37366,7 @@ function createOpenCodeQuotaManager(client, providerId = ANTIGRAVITY_PROVIDER_ID
37208
37366
  providerId,
37209
37367
  options.fetchVia
37210
37368
  );
37211
- const fetchAccountQuota = async (account, request, purpose = "required") => {
37369
+ const fetchAccountQuota = async (account, request2, purpose = "required") => {
37212
37370
  const target = account;
37213
37371
  const ref = target.rowRef;
37214
37372
  if (options.mayRun && !await options.mayRun())
@@ -37217,9 +37375,9 @@ function createOpenCodeQuotaManager(client, providerId = ANTIGRAVITY_PROVIDER_ID
37217
37375
  if (!options.fetchStoreAccountQuota)
37218
37376
  throw new Error("Store quota authorization is unavailable");
37219
37377
  const captured = { ...target, rowRef: ref };
37220
- return purpose === "advisory" ? options.fetchStoreAccountQuota(captured, request, purpose) : options.fetchStoreAccountQuota(captured, request);
37378
+ return purpose === "advisory" ? options.fetchStoreAccountQuota(captured, request2, purpose) : options.fetchStoreAccountQuota(captured, request2);
37221
37379
  }
37222
- return purpose === "advisory" ? fetchPoolFileQuota(account, request, purpose) : fetchPoolFileQuota(account, request);
37380
+ return purpose === "advisory" ? fetchPoolFileQuota(account, request2, purpose) : fetchPoolFileQuota(account, request2);
37223
37381
  };
37224
37382
  const manager = createQuotaManager({
37225
37383
  fetchAccountQuota,
@@ -38371,7 +38529,7 @@ var BackgroundVaultQuotaRefresh = class {
38371
38529
  async assertActive(controller) {
38372
38530
  controller.signal.throwIfAborted();
38373
38531
  if (this.disposed) controller.abort();
38374
- else if (await this.options.readAuthority() !== "vault")
38532
+ else if (!["host", "vault"].includes(await this.options.readAuthority()))
38375
38533
  controller.abort({ kind: "not-active" });
38376
38534
  controller.signal.throwIfAborted();
38377
38535
  }
@@ -40080,9 +40238,9 @@ function collectToolNames(value) {
40080
40238
  function bodyStructureSummary(bodyText) {
40081
40239
  const parsed = parseBody(bodyText);
40082
40240
  if (!parsed) return { parseable: false };
40083
- const request = parsed.request && typeof parsed.request === "object" ? parsed.request : void 0;
40084
- const contents = Array.isArray(request?.contents) ? request.contents : [];
40085
- const toolNames = collectToolNames(request ?? parsed);
40241
+ const request2 = parsed.request && typeof parsed.request === "object" ? parsed.request : void 0;
40242
+ const contents = Array.isArray(request2?.contents) ? request2.contents : [];
40243
+ const toolNames = collectToolNames(request2 ?? parsed);
40086
40244
  return {
40087
40245
  parseable: true,
40088
40246
  model: typeof parsed.model === "string" ? parsed.model : void 0,
@@ -42016,15 +42174,15 @@ function assignToolIdsToContents(contents) {
42016
42174
  }
42017
42175
  const newParts = content.parts.map((part) => {
42018
42176
  if (part && typeof part === "object" && part.functionCall) {
42019
- const call = { ...part.functionCall };
42020
- if (!call.id) {
42021
- call.id = `tool-call-${++toolCallCounter}`;
42177
+ const call2 = { ...part.functionCall };
42178
+ if (!call2.id) {
42179
+ call2.id = `tool-call-${++toolCallCounter}`;
42022
42180
  }
42023
- const nameKey = typeof call.name === "string" ? call.name : `tool-${toolCallCounter}`;
42181
+ const nameKey = typeof call2.name === "string" ? call2.name : `tool-${toolCallCounter}`;
42024
42182
  const queue2 = pendingCallIdsByName.get(nameKey) || [];
42025
- queue2.push(call.id);
42183
+ queue2.push(call2.id);
42026
42184
  pendingCallIdsByName.set(nameKey, queue2);
42027
- return { ...part, functionCall: call };
42185
+ return { ...part, functionCall: call2 };
42028
42186
  }
42029
42187
  return part;
42030
42188
  });
@@ -43090,14 +43248,14 @@ function normalizeNativeFunctionResponseRoles(payload) {
43090
43248
  if (!Array.isArray(parts)) continue;
43091
43249
  let signedTurn = false;
43092
43250
  for (const part of parts) {
43093
- const call = part?.functionCall;
43094
- if (!call) continue;
43251
+ const call2 = part?.functionCall;
43252
+ if (!call2) continue;
43095
43253
  const signature = part.thoughtSignature;
43096
43254
  if (typeof signature === "string") {
43097
43255
  signedTurn = signature.length >= MIN_SIGNATURE_LENGTH && signature !== SKIP_THOUGHT_SIGNATURE;
43098
43256
  }
43099
43257
  if (signedTurn) {
43100
- signedCalls.add(String(call.id ?? call.name));
43258
+ signedCalls.add(String(call2.id ?? call2.name));
43101
43259
  }
43102
43260
  }
43103
43261
  }
@@ -43994,15 +44152,15 @@ function prepareAntigravityRequestIn(wire, input2, init, accessToken, projectId,
43994
44152
  }
43995
44153
  const newParts = content.parts.map((part) => {
43996
44154
  if (part && typeof part === "object" && part.functionCall) {
43997
- const call = { ...part.functionCall };
43998
- if (!call.id) {
43999
- call.id = `tool-call-${++toolCallCounter}`;
44155
+ const call2 = { ...part.functionCall };
44156
+ if (!call2.id) {
44157
+ call2.id = `tool-call-${++toolCallCounter}`;
44000
44158
  }
44001
- const nameKey = typeof call.name === "string" ? call.name : `tool-${toolCallCounter}`;
44159
+ const nameKey = typeof call2.name === "string" ? call2.name : `tool-${toolCallCounter}`;
44002
44160
  const queue2 = pendingCallIdsByName.get(nameKey) || [];
44003
- queue2.push(call.id);
44161
+ queue2.push(call2.id);
44004
44162
  pendingCallIdsByName.set(nameKey, queue2);
44005
- return { ...part, functionCall: call };
44163
+ return { ...part, functionCall: call2 };
44006
44164
  }
44007
44165
  return part;
44008
44166
  });
@@ -44821,13 +44979,13 @@ async function startOAuthListener({
44821
44979
  rejectCallback(new Error("Timed out waiting for OAuth callback"));
44822
44980
  }, timeoutMs);
44823
44981
  timeoutHandle.unref?.();
44824
- const server = createServer((request, response) => {
44825
- if (!request.url) {
44982
+ const server = createServer((request2, response) => {
44983
+ if (!request2.url) {
44826
44984
  response.writeHead(400, { "Content-Type": "text/plain" });
44827
44985
  response.end("Invalid request");
44828
44986
  return;
44829
44987
  }
44830
- const url = new URL(request.url, origin);
44988
+ const url = new URL(request2.url, origin);
44831
44989
  if (url.pathname !== callbackPath) {
44832
44990
  response.writeHead(404, { "Content-Type": "text/plain" });
44833
44991
  response.end("Not found");
@@ -44904,10 +45062,10 @@ var AgySessionRegistry = class {
44904
45062
  }
44905
45063
  getOrCreate(identity3) {
44906
45064
  const key = identity3.sessionId ?? FALLBACK_SESSION_KEY;
44907
- const request = this.requestSessions.getOrCreate(key);
45065
+ const request2 = this.requestSessions.getOrCreate(key);
44908
45066
  this.recordParent(key, identity3.parentSessionId);
44909
45067
  this.pruneParentRelationships();
44910
- return request;
45068
+ return request2;
44911
45069
  }
44912
45070
  beginRequest(identity3) {
44913
45071
  const key = identity3.sessionId ?? FALLBACK_SESSION_KEY;
@@ -45182,15 +45340,15 @@ async function askRouting(input2) {
45182
45340
  timer = setTimeout(() => resolve28(void 0), deadlineMs);
45183
45341
  timer.unref();
45184
45342
  });
45185
- const request = {
45343
+ const request2 = {
45186
45344
  provider: input2.provider,
45187
45345
  modelId: input2.modelId
45188
45346
  };
45189
45347
  const cap = input2.holdWaitMaxS;
45190
45348
  if (typeof cap === "number" && Number.isFinite(cap)) {
45191
- request.hold_wait_max_s = Math.max(0, Math.floor(cap));
45349
+ request2.hold_wait_max_s = Math.max(0, Math.floor(cap));
45192
45350
  }
45193
- const pending = accountFor.call(handle, request, { deadlineMs });
45351
+ const pending = accountFor.call(handle, request2, { deadlineMs });
45194
45352
  if (!isObject2(pending) || typeof pending.then !== "function")
45195
45353
  return void 0;
45196
45354
  const answer = await Promise.race([pending, expired]);
@@ -45999,15 +46157,15 @@ function isPrimaryVaultRequest(kind, headers) {
45999
46157
  // src/plugin/shared/request-services.ts
46000
46158
  var FIRST_RETRY_DELAY_MS = 1e3;
46001
46159
  var MODEL_UNAVAILABLE_TTL_MS = 60 * 60 * 1e3;
46002
- function prepareAgyWireRequest(wire, request) {
46160
+ function prepareAgyWireRequest(wire, request2) {
46003
46161
  return wire.prepare(
46004
- request.input,
46005
- request.init,
46006
- request.accessToken,
46007
- request.projectId,
46008
- request.endpoint,
46009
- request.forceThinkingRecovery ?? false,
46010
- request.options
46162
+ request2.input,
46163
+ request2.init,
46164
+ request2.accessToken,
46165
+ request2.projectId,
46166
+ request2.endpoint,
46167
+ request2.forceThinkingRecovery ?? false,
46168
+ request2.options
46011
46169
  );
46012
46170
  }
46013
46171
  var TITLE_FALLBACK_MODEL = "gemini-3.8-flash-low";
@@ -49262,10 +49420,10 @@ function scopeInvocation(scope, notify) {
49262
49420
  }
49263
49421
  function createGaMenuCommandService(input2) {
49264
49422
  return {
49265
- async apply({ request, scope, signal }) {
49423
+ async apply({ request: request2, scope, signal }) {
49266
49424
  if (signal.aborted) throw abortError(signal);
49267
49425
  const result = await input2.menu.apply(
49268
- request,
49426
+ request2,
49269
49427
  scopeInvocation(scope, input2.notify)
49270
49428
  );
49271
49429
  if (input2.afterApply) {
@@ -50497,25 +50655,25 @@ function createGaLocationServicesFactory(bindings) {
50497
50655
  return (await choose("execute")).execute(job, context);
50498
50656
  }),
50499
50657
  commands: {
50500
- apply: (request) => run(async () => {
50501
- if (request.signal.aborted) throw request.signal.reason;
50502
- return (await choose("view")).commands.apply(request);
50658
+ apply: (request2) => run(async () => {
50659
+ if (request2.signal.aborted) throw request2.signal.reason;
50660
+ return (await choose("view")).commands.apply(request2);
50503
50661
  }),
50504
- open: (request) => run(async () => {
50505
- if (request.signal.aborted) throw request.signal.reason;
50506
- return (await choose("view")).commands.open(request);
50662
+ open: (request2) => run(async () => {
50663
+ if (request2.signal.aborted) throw request2.signal.reason;
50664
+ return (await choose("view")).commands.open(request2);
50507
50665
  })
50508
50666
  },
50509
50667
  state: {
50510
- read(request) {
50668
+ read(request2) {
50511
50669
  return run(() => {
50512
50670
  const pending = reads.then(async () => {
50513
50671
  if (closing)
50514
50672
  throw new Error("The location services are disposed");
50515
- if (request.signal.aborted) throw request.signal.reason;
50673
+ if (request2.signal.aborted) throw request2.signal.reason;
50516
50674
  for (let attempt = 0; attempt < 2; attempt++) {
50517
50675
  const before = await authority();
50518
- const answer = await (await choose("view", before)).state.read(request);
50676
+ const answer = await (await choose("view", before)).state.read(request2);
50519
50677
  if (before === await authority()) return answer;
50520
50678
  }
50521
50679
  throw new Error(
@@ -51776,11 +51934,13 @@ function validateStateOutput(value, issues) {
51776
51934
  "status",
51777
51935
  "settings"
51778
51936
  ],
51779
- ["reset", "route"]
51937
+ ["reset", "route", "vaultHostStatus"]
51780
51938
  )) {
51781
51939
  return;
51782
51940
  }
51783
51941
  checkNullableKeysPresent(value, ["reset", "route"], path5, issues);
51942
+ if (present4(value, "vaultHostStatus") && value.vaultHostStatus !== "Served by Thalamus")
51943
+ issues.add(["vaultHostStatus"], "expected the hosted vault status");
51784
51944
  checkVersion(value, path5, issues);
51785
51945
  if (present4(value, "generation")) {
51786
51946
  checkGeneration(value.generation, ["generation"], issues);
@@ -52214,10 +52374,23 @@ async function readAuthority() {
52214
52374
  stateDir: folder.vaultDir,
52215
52375
  host: OPENCODE_VAULT_HOST
52216
52376
  });
52217
- return enrollmentAuthority2(paths, OPENCODE_VAULT_ENROLLMENT_NAME, claustrum);
52377
+ return vaultAuthority2(paths, OPENCODE_VAULT_ENROLLMENT_NAME, claustrum);
52218
52378
  }
52219
52379
  async function registerGaAuthMethods(context, authority = readAuthority, input2 = {}) {
52220
- const pool = createGaPoolLogin(input2);
52380
+ const local = input2.local;
52381
+ const pool = createGaPoolLogin({
52382
+ ...input2,
52383
+ ...local ? {
52384
+ local: {
52385
+ ...local,
52386
+ assertAdmission: async () => {
52387
+ if (process.env.CORTEXKIT_VAULT_HOST === "thalamus")
52388
+ throw new Error("Vault authority excludes local sign-in.");
52389
+ await local.assertAdmission();
52390
+ }
52391
+ }
52392
+ } : {}
52393
+ });
52221
52394
  const registrations = [];
52222
52395
  try {
52223
52396
  registrations.push(
@@ -52232,11 +52405,20 @@ async function registerGaAuthMethods(context, authority = readAuthority, input2
52232
52405
  label: OPENCODE2_VAULT_AUTH_LABEL
52233
52406
  },
52234
52407
  async activate() {
52235
- if (await authority() !== "vault") {
52408
+ const current = await authority();
52409
+ if (!["host", "vault"].includes(current)) {
52236
52410
  throw new Error(
52237
52411
  "Approve Antigravity vault access before activating this connection"
52238
52412
  );
52239
52413
  }
52414
+ if (current === "host") {
52415
+ const client = (await loadCommonAuthClaustrum()).connectVaultHost(
52416
+ "antigravity-auth"
52417
+ );
52418
+ await Promise.resolve(client.close()).catch(() => void 0);
52419
+ if (await authority() !== "host")
52420
+ throw new Error("Vault authority changed during activation.");
52421
+ }
52240
52422
  }
52241
52423
  },
52242
52424
  label: "Antigravity"
@@ -52344,10 +52526,10 @@ var BRIDGE_HOST = "127.0.0.1";
52344
52526
  var JOB_ID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
52345
52527
  var JOB_PATH_PATTERN = /^\/agy\/([^/]+)$/;
52346
52528
  var GA_UNCLAIMED_JOB_TTL_MS = 6e4;
52347
- function isGaGoogleContentRequest(request) {
52348
- if (request.method !== "POST") return false;
52529
+ function isGaGoogleContentRequest(request2) {
52530
+ if (request2.method !== "POST") return false;
52349
52531
  try {
52350
- return GA_GOOGLE_CONTENT_PATH.test(new URL(request.url).pathname);
52532
+ return GA_GOOGLE_CONTENT_PATH.test(new URL(request2.url).pathname);
52351
52533
  } catch {
52352
52534
  return false;
52353
52535
  }
@@ -52463,8 +52645,8 @@ async function startGaLoopbackBridge(options) {
52463
52645
  } catch {
52464
52646
  }
52465
52647
  };
52466
- const server = createServer2((request, response) => {
52467
- const pending = handle(request, response).catch((error) => {
52648
+ const server = createServer2((request2, response) => {
52649
+ const pending = handle(request2, response).catch((error) => {
52468
52650
  report(`bridge request failed: ${errorMessage(error)}`);
52469
52651
  if (!response.headersSent) {
52470
52652
  writeResponseHead(response, 500, "application/json");
@@ -52480,15 +52662,15 @@ async function startGaLoopbackBridge(options) {
52480
52662
  sockets.add(socket);
52481
52663
  socket.once("close", () => sockets.delete(socket));
52482
52664
  });
52483
- const handle = async (request, response) => {
52665
+ const handle = async (request2, response) => {
52484
52666
  const match = JOB_PATH_PATTERN.exec(
52485
- new URL(request.url ?? "/", "http://bridge").pathname
52667
+ new URL(request2.url ?? "/", "http://bridge").pathname
52486
52668
  );
52487
52669
  const candidate = match?.[1];
52488
52670
  const id = candidate !== void 0 && isGaJobId(candidate) ? candidate : null;
52489
52671
  const entry = id ? queued.get(id) : void 0;
52490
- request.resume();
52491
- if (request.method !== "POST" || !id || !entry || closing) {
52672
+ request2.resume();
52673
+ if (request2.method !== "POST" || !id || !entry || closing) {
52492
52674
  writeResponseHead(response, 404, "application/json");
52493
52675
  response.end(JSON.stringify({ error: { message: "unknown job" } }));
52494
52676
  return;
@@ -52587,10 +52769,10 @@ async function startGaLoopbackBridge(options) {
52587
52769
  signal: original.signal
52588
52770
  });
52589
52771
  },
52590
- adaptResponse(request, response) {
52772
+ adaptResponse(request2, response) {
52591
52773
  let url;
52592
52774
  try {
52593
- url = new URL(request.url);
52775
+ url = new URL(request2.url);
52594
52776
  } catch {
52595
52777
  return null;
52596
52778
  }
@@ -52947,23 +53129,23 @@ function createGaRpcActivation(options) {
52947
53129
  const parsed = AntigravityStateInputSchema.parse(input2);
52948
53130
  if (!parsed.ok) throw new GaRpcInputError(parsed.issues);
52949
53131
  if (disposed) return disposedOutput();
52950
- const request = parsed.value;
53132
+ const request2 = parsed.value;
52951
53133
  const read = await track(
52952
53134
  signal,
52953
- (readSignal) => options.state.read({ scope: request.scope, signal: readSignal })
53135
+ (readSignal) => options.state.read({ scope: request2.scope, signal: readSignal })
52954
53136
  );
52955
53137
  if (disposed) return disposedOutput();
52956
53138
  if (!Number.isSafeInteger(read.readSeq) || read.readSeq <= lastReadSeq) {
52957
53139
  throw new GaRpcContractError("State source returned a stale readSeq");
52958
53140
  }
52959
53141
  lastReadSeq = read.readSeq;
52960
- const queue2 = queueFor(request.scope);
53142
+ const queue2 = queueFor(request2.scope);
52961
53143
  queue2.lastPullAt = now();
52962
53144
  let reset = null;
52963
- if (request.generation === null) reset = "initial";
52964
- else if (request.generation !== generation) reset = "generation-changed";
52965
- else if (request.cursor > queue2.lastIssued) reset = "cursor-ahead";
52966
- const acknowledged = reset === null ? request.cursor : 0;
53145
+ if (request2.generation === null) reset = "initial";
53146
+ else if (request2.generation !== generation) reset = "generation-changed";
53147
+ else if (request2.cursor > queue2.lastIssued) reset = "cursor-ahead";
53148
+ const acknowledged = reset === null ? request2.cursor : 0;
52967
53149
  queue2.notifications = queue2.notifications.filter(
52968
53150
  (notification) => notification.cursor > acknowledged
52969
53151
  );
@@ -52973,11 +53155,13 @@ function createGaRpcActivation(options) {
52973
53155
  );
52974
53156
  const last = delivered.at(-1);
52975
53157
  const cursor = last ? last.cursor : Math.max(acknowledged, queue2.evictedThrough);
53158
+ const claustrum = await loadCommonAuthClaustrum();
52976
53159
  const output2 = {
53160
+ ...process.env.CORTEXKIT_VAULT_HOST === "thalamus" ? { vaultHostStatus: claustrum.VAULT_HOST_STATUS } : {},
52977
53161
  version: ANTIGRAVITY_RPC_VERSION,
52978
53162
  kind: "snapshot",
52979
53163
  generation,
52980
- scope: request.scope,
53164
+ scope: request2.scope,
52981
53165
  reset,
52982
53166
  cursor,
52983
53167
  dropped: Math.max(0, queue2.evictedThrough - acknowledged),
@@ -52985,7 +53169,7 @@ function createGaRpcActivation(options) {
52985
53169
  notifications: delivered,
52986
53170
  readSeq: read.readSeq,
52987
53171
  ...accountsDto(read.accounts),
52988
- route: request.scope.kind === "session" ? routeDto(read.route) : null,
53172
+ route: request2.scope.kind === "session" ? routeDto(read.route) : null,
52989
53173
  status: read.status,
52990
53174
  settings: read.settings
52991
53175
  };
@@ -52999,8 +53183,8 @@ function createGaRpcActivation(options) {
52999
53183
  const parsed = AntigravityApplyInputSchema.parse(input2);
53000
53184
  if (!parsed.ok) throw new GaRpcInputError(parsed.issues);
53001
53185
  if (disposed) return disposedOutput();
53002
- const request = parsed.value;
53003
- if (request.generation !== generation) {
53186
+ const request2 = parsed.value;
53187
+ if (request2.generation !== generation) {
53004
53188
  return {
53005
53189
  version: ANTIGRAVITY_RPC_VERSION,
53006
53190
  kind: "stale-generation",
@@ -53008,8 +53192,8 @@ function createGaRpcActivation(options) {
53008
53192
  };
53009
53193
  }
53010
53194
  const menuRequest = options.parseApplyRequest({
53011
- ...request.request,
53012
- ...request.scope.kind === "session" ? { sessionId: request.scope.sessionID } : {}
53195
+ ...request2.request,
53196
+ ...request2.scope.kind === "session" ? { sessionId: request2.scope.sessionID } : {}
53013
53197
  });
53014
53198
  if (!menuRequest) {
53015
53199
  throw new GaRpcInputError([
@@ -53020,7 +53204,7 @@ function createGaRpcActivation(options) {
53020
53204
  signal,
53021
53205
  (applySignal) => options.commands.apply({
53022
53206
  request: menuRequest,
53023
- scope: request.scope,
53207
+ scope: request2.scope,
53024
53208
  signal: applySignal
53025
53209
  })
53026
53210
  );
@@ -53035,7 +53219,7 @@ function createGaRpcActivation(options) {
53035
53219
  version: ANTIGRAVITY_RPC_VERSION,
53036
53220
  kind: "applied",
53037
53221
  generation,
53038
- scope: request.scope,
53222
+ scope: request2.scope,
53039
53223
  result
53040
53224
  };
53041
53225
  if (!AntigravityApplyOutputSchema.parse(output2).ok) {
@@ -53213,9 +53397,9 @@ function stderrLogSink(record3) {
53213
53397
  } catch {
53214
53398
  }
53215
53399
  }
53216
- function headerValue(request, names) {
53400
+ function headerValue(request2, names) {
53217
53401
  for (const name of names) {
53218
- const value = request.headers.get(name);
53402
+ const value = request2.headers.get(name);
53219
53403
  if (value) return value;
53220
53404
  }
53221
53405
  return null;
@@ -53273,7 +53457,7 @@ async function setupGaActivation(context, factory, overrides = {}) {
53273
53457
  read: (input2) => requireServing().state.read(input2)
53274
53458
  },
53275
53459
  commands: {
53276
- apply: (request) => requireServing().commands.apply(request)
53460
+ apply: (request2) => requireServing().commands.apply(request2)
53277
53461
  },
53278
53462
  parseApplyRequest: commandsModule.parseApplyRequest,
53279
53463
  onChanged: (event) => {
@@ -53327,8 +53511,8 @@ async function setupGaActivation(context, factory, overrides = {}) {
53327
53511
  "producer"
53328
53512
  );
53329
53513
  const handlers = {
53330
- state: (input2, call) => activation.handlers.state(input2, call.signal),
53331
- apply: (input2, call) => activation.handlers.apply(input2, call.signal)
53514
+ state: (input2, call2) => activation.handlers.state(input2, call2.signal),
53515
+ apply: (input2, call2) => activation.handlers.apply(input2, call2.signal)
53332
53516
  };
53333
53517
  rpcRegistration = await context.rpc.register(
53334
53518
  ANTIGRAVITY_RPC_DEFINITION,
@@ -53442,11 +53626,11 @@ function callbackParams(callbackUrl, expected) {
53442
53626
  if (expected && state !== expected) throw new Error("OAuth state mismatch");
53443
53627
  return { code: code2, state };
53444
53628
  }
53445
- async function performOAuthLogin(request, deps) {
53629
+ async function performOAuthLogin(request2, deps) {
53446
53630
  const listener = await deps.startListener();
53447
53631
  try {
53448
- const authorization = await deps.authorize(request.projectId ?? "");
53449
- if (!request.noBrowser && !request.isHeadless) {
53632
+ const authorization = await deps.authorize(request2.projectId ?? "");
53633
+ if (!request2.noBrowser && !request2.isHeadless) {
53450
53634
  await deps.openBrowser(authorization.url);
53451
53635
  }
53452
53636
  const params = callbackParams(
@@ -53456,7 +53640,7 @@ async function performOAuthLogin(request, deps) {
53456
53640
  const result = await deps.exchange(params.code, params.state);
53457
53641
  if (result.type === "failed") throw new Error(result.error);
53458
53642
  await deps.upsert(result);
53459
- request.accounts.push(result);
53643
+ request2.accounts.push(result);
53460
53644
  return result;
53461
53645
  } finally {
53462
53646
  await listener.close().catch(() => {
@@ -53716,7 +53900,7 @@ import { createHash as createHash19, randomBytes as randomBytes6, randomUUID as
53716
53900
  import { constants as fsConstants2 } from "node:fs";
53717
53901
  import { chmod as chmod6, mkdir as mkdir15, open as open10, readFile as readFile14, realpath as realpath4, rename as rename12, stat as stat14, unlink as unlink11 } from "node:fs/promises";
53718
53902
  import { basename as basename6, dirname as dirname22, extname as extname2, isAbsolute as isAbsolute4, join as join26, resolve as resolve22 } from "node:path";
53719
- import { ClaustrumCredentialError as ClaustrumCredentialError6, ClaustrumClient as ClaustrumWireClient2, writeEnrollmentTokenFile as writeEnrollmentTokenFile2 } from "@cortexkit/claustrum-client";
53903
+ import { ClaustrumCredentialError as ClaustrumCredentialError9, ClaustrumClient as ClaustrumWireClient2, writeEnrollmentTokenFile as writeEnrollmentTokenFile2 } from "@cortexkit/claustrum-client";
53720
53904
 
53721
53905
  // src/common-auth-embedded/fs/file-read-cache.js
53722
53906
  import { lstat as lstat7, stat as stat12 } from "node:fs/promises";
@@ -54643,6 +54827,90 @@ var ClaustrumConsumerError2 = class extends Error {
54643
54827
  }
54644
54828
  };
54645
54829
 
54830
+ // src/common-auth-embedded/claustrum/host.js
54831
+ import { ClaustrumCredentialError as ClaustrumCredentialError8 } from "@cortexkit/claustrum-client";
54832
+
54833
+ // src/common-auth-embedded/claustrum/availability.js
54834
+ import { ClaustrumCredentialError as ClaustrumCredentialError7 } from "@cortexkit/claustrum-client";
54835
+ import { SocketClosedError as SocketClosedError2, SocketTimeoutError as SocketTimeoutError2, SubcCallError as SubcCallError2 } from "@cortexkit/subc-client";
54836
+ var VAULT_FAILURE_CLASSES2 = Object.freeze({
54837
+ ECONNREFUSED: "unreachable",
54838
+ ENOENT: "unreachable",
54839
+ ECONNRESET: "unreachable",
54840
+ EPIPE: "unreachable",
54841
+ ETIMEDOUT: "unreachable",
54842
+ transport_error: "unreachable",
54843
+ unavailable: "unreachable",
54844
+ timeout: "unreachable",
54845
+ route_closed: "unreachable",
54846
+ daemon_draining: "unreachable",
54847
+ connection_closed: "unreachable",
54848
+ connection_dropped: "unreachable",
54849
+ request_deadline: "unreachable",
54850
+ deadline_exceeded_no_drop_observed: "unreachable",
54851
+ module_reloading: "unreachable",
54852
+ module_warming: "unreachable",
54853
+ target_unavailable: "unreachable",
54854
+ module_timeout: "unreachable",
54855
+ invalid_response: "answered",
54856
+ invalid_record_version: "answered",
54857
+ invalid_expiry: "answered",
54858
+ invalid_status: "answered",
54859
+ invalid_params: "answered",
54860
+ ttl_unsatisfiable: "answered",
54861
+ not_found: "answered",
54862
+ enrollment_revoked: "answered",
54863
+ enrollment_invalid: "answered",
54864
+ grant_denied: "answered",
54865
+ credential_unavailable: "answered",
54866
+ needs_reauth: "answered",
54867
+ declined: "answered",
54868
+ disabled: "answered",
54869
+ identity_changed: "answered",
54870
+ closed: "answered",
54871
+ client_closed: "answered",
54872
+ pending_exists: "answered",
54873
+ pending_queue_full: "answered",
54874
+ already_consumed: "answered",
54875
+ superseded: "answered",
54876
+ stale_generation: "answered",
54877
+ missing_identity: "answered",
54878
+ invalid_control_body: "answered",
54879
+ unknown_module: "answered",
54880
+ module_removed: "answered",
54881
+ capability_denied: "answered",
54882
+ unknown_channel: "unreachable",
54883
+ stale_route_epoch: "unreachable",
54884
+ capability_forbidden: "answered",
54885
+ capability_unprovided: "answered",
54886
+ capability_ambiguous: "answered",
54887
+ invalid_capability_identifier: "answered",
54888
+ binary_body_required: "answered",
54889
+ binary_call_requires_call_binary: "answered",
54890
+ corr_exhausted: "answered",
54891
+ late_route_cleanup_failed: "answered",
54892
+ reverse_request_capability_not_declared: "answered",
54893
+ stale_route_handle: "answered",
54894
+ reverse_request_unhandled: "answered",
54895
+ handler_error: "answered",
54896
+ health_error: "answered",
54897
+ duplicate_module_id: "answered",
54898
+ route_rejected: "answered",
54899
+ lock_busy: "answered",
54900
+ owner_invalid: "answered",
54901
+ renewal_failed: "answered",
54902
+ unsupported_platform: "answered",
54903
+ EACCES: "answered",
54904
+ EPERM: "answered",
54905
+ ERR_PRIVATE_FILES_SECURITY: "answered"
54906
+ });
54907
+
54908
+ // src/common-auth-embedded/claustrum/host.js
54909
+ var VAULT_HOST_CONNECT_REFUSAL2 = "This host gets its vault accounts from Thalamus, so it can't connect to the vault itself.";
54910
+ function hasVaultHost2() {
54911
+ return process.env.CORTEXKIT_VAULT_HOST === "thalamus";
54912
+ }
54913
+
54646
54914
  // src/common-auth-embedded/claustrum/enrollment.js
54647
54915
  var ENROLLMENT_SCHEMA2 = 1;
54648
54916
  var ENROLLMENT_FILE_MAX_BYTES2 = 16 * 1024;
@@ -54666,7 +54934,7 @@ var RETRYABLE_ENROLLMENT_CODES2 = /* @__PURE__ */ new Set([
54666
54934
  "pending_queue_full"
54667
54935
  ]);
54668
54936
  function classifyEnrollmentError2(error) {
54669
- if (!(error instanceof ClaustrumCredentialError6))
54937
+ if (!(error instanceof ClaustrumCredentialError9))
54670
54938
  return void 0;
54671
54939
  if (TERMINAL_ENROLLMENT_CODES2.has(error.code))
54672
54940
  return { code: error.code, disposition: "terminal" };
@@ -54990,7 +55258,7 @@ async function readEnrollmentStatus2(paths, proposedName) {
54990
55258
  }
54991
55259
  return { status: statusFromState2(state), usesProposedName: false };
54992
55260
  }
54993
- async function enrollmentAuthority3(paths, proposedName) {
55261
+ async function enrollmentAuthority2(paths, proposedName) {
54994
55262
  let status;
54995
55263
  try {
54996
55264
  status = await readClaustrumEnrollmentStatus2(paths, proposedName);
@@ -55015,6 +55283,11 @@ async function enrollmentAuthority3(paths, proposedName) {
55015
55283
  }
55016
55284
  return "local";
55017
55285
  }
55286
+ async function vaultAuthority3(paths, proposedName) {
55287
+ if (hasVaultHost2())
55288
+ return "host";
55289
+ return enrollmentAuthority2(paths, proposedName);
55290
+ }
55018
55291
  function statusFromState2(state) {
55019
55292
  if (state.phase === "pending") {
55020
55293
  return {
@@ -55983,6 +56256,8 @@ function approveCommand(requestId, name) {
55983
56256
  return `ck auth enroll approve --request-id ${requestId} --name ${name}`;
55984
56257
  }
55985
56258
  async function connectSetupHost(plugin2, host, io, terminal, fence) {
56259
+ if (hasVaultHost2())
56260
+ throw new Error(VAULT_HOST_CONNECT_REFUSAL2);
55986
56261
  const { name, paths: input2 } = plugin2.vault.hosts[host];
55987
56262
  const paths = hostEnrollmentPaths2(input2);
55988
56263
  await fence();
@@ -56466,8 +56741,8 @@ async function enrollmentReport(plugin2, hosts, recorded) {
56466
56741
  let outcome = recorded.get(host) ?? "not-enrolled";
56467
56742
  if (outcome === "unknown") {
56468
56743
  const { name, paths } = plugin2.vault.hosts[host];
56469
- const authority = await enrollmentAuthority3(hostEnrollmentPaths2(paths), name).catch(() => "unreadable");
56470
- if (authority === "vault")
56744
+ const authority = await vaultAuthority3(hostEnrollmentPaths2(paths), name).catch(() => "unreadable");
56745
+ if (authority === "vault" || authority === "host")
56471
56746
  outcome = "enrolled";
56472
56747
  else if (authority === "local")
56473
56748
  outcome = "not-enrolled";
@@ -56478,6 +56753,8 @@ async function enrollmentReport(plugin2, hosts, recorded) {
56478
56753
  }
56479
56754
  async function runSetup(plugin2, argv = [], io = {}) {
56480
56755
  const options = parseSetupFlags(argv);
56756
+ if (hasVaultHost2())
56757
+ throw new Error(VAULT_HOST_CONNECT_REFUSAL2);
56481
56758
  validatePlugin(plugin2);
56482
56759
  const terminal = io.terminal ?? processTerminal2();
56483
56760
  const detection = await detectHosts(plugin2, io);
@@ -56676,7 +56953,7 @@ function createV1VaultActivationMethod(input2) {
56676
56953
  instructions: "Vault access is approved. Activate it without signing in to Google.",
56677
56954
  callback: async () => {
56678
56955
  try {
56679
- if (await input2.readAuthority() !== "vault")
56956
+ if (!["host", "vault"].includes(await input2.readAuthority()))
56680
56957
  return { type: "failed" };
56681
56958
  try {
56682
56959
  const value = JSON.parse(
@@ -56692,8 +56969,14 @@ function createV1VaultActivationMethod(input2) {
56692
56969
  return { type: "failed" };
56693
56970
  }
56694
56971
  const claustrum = await loadCommonAuthClaustrum();
56695
- if (await input2.readAuthority() !== "vault")
56696
- return { type: "failed" };
56972
+ const current = await input2.readAuthority();
56973
+ if (!["host", "vault"].includes(current)) return { type: "failed" };
56974
+ if (current === "host") {
56975
+ const client = claustrum.connectVaultHost("antigravity-auth");
56976
+ await Promise.resolve(client.close()).catch(() => void 0);
56977
+ if (await input2.readAuthority() !== "host")
56978
+ return { type: "failed" };
56979
+ }
56697
56980
  return {
56698
56981
  ...claustrum.custodyPlaceholder(input2.providerId),
56699
56982
  type: "success"
@@ -56750,7 +57033,7 @@ async function readNativeAuth(path5) {
56750
57033
  }
56751
57034
  async function assertLocalOpenCodeLogin(legacyPath, generation) {
56752
57035
  const claustrum = await loadCommonAuthClaustrum();
56753
- if (await claustrum.enrollmentAuthority(
57036
+ if (await claustrum.vaultAuthority(
56754
57037
  claustrum.hostEnrollmentPaths({
56755
57038
  stateDir: openCodeVaultDir(legacyPath),
56756
57039
  host: "opencode"
@@ -56783,7 +57066,7 @@ async function writeNativeSlot(host, slot, context, expectedAuthority = "local")
56783
57066
  await assertSetupHostsStopped();
56784
57067
  const claustrum = await loadCommonAuthClaustrum();
56785
57068
  const stateDir = host === "opencode" ? openCodeVaultDir(resolve23(accountFileForVault())) : getPiAntigravityVaultDir();
56786
- if (await claustrum.enrollmentAuthority(
57069
+ if (await claustrum.vaultAuthority(
56787
57070
  claustrum.hostEnrollmentPaths({ stateDir, host }),
56788
57071
  `antigravity-auth-${host}`
56789
57072
  ) !== expectedAuthority)
@@ -56830,7 +57113,7 @@ async function createSetupPlugin(deps, migrateOpenCode, forceLogin = false) {
56830
57113
  paths: { stateDir: piDir, host: "pi" }
56831
57114
  }
56832
57115
  };
56833
- const authority = (host) => claustrum.enrollmentAuthority(
57116
+ const authority = (host) => claustrum.vaultAuthority(
56834
57117
  claustrum.hostEnrollmentPaths(hosts[host].paths),
56835
57118
  hosts[host].name
56836
57119
  );
@@ -56996,7 +57279,7 @@ Setup has not completed the OpenCode 2 native Google connection.
56996
57279
  );
56997
57280
  return;
56998
57281
  }
56999
- if (await authority(host) !== "vault")
57282
+ if (!["host", "vault"].includes(await authority(host)))
57000
57283
  throw new Error("Vault access must be approved before activation.");
57001
57284
  if (host === "opencode") {
57002
57285
  if (context.opencodeGeneration === "2") {
@@ -57029,7 +57312,7 @@ Setup has not completed the OpenCode 2 native Google connection.
57029
57312
  },
57030
57313
  migrate: async (host, context) => {
57031
57314
  if (context.mode === "local") await assertLocal(host, context);
57032
- else if (await authority(host) !== "vault")
57315
+ else if (!["host", "vault"].includes(await authority(host)))
57033
57316
  throw new Error("Vault access must remain approved during setup.");
57034
57317
  if (host === "opencode") {
57035
57318
  const current = await authority(host);
@@ -57095,6 +57378,9 @@ Setup has not completed the OpenCode 2 native Google connection.
57095
57378
  };
57096
57379
  }
57097
57380
  async function runPluginSetup(argv, deps, migrateOpenCode, io = {}) {
57381
+ const claustrum = await loadCommonAuthClaustrum();
57382
+ if (process.env.CORTEXKIT_VAULT_HOST === "thalamus")
57383
+ throw new Error(claustrum.VAULT_HOST_CONNECT_REFUSAL);
57098
57384
  const plugin2 = await createSetupPlugin(
57099
57385
  deps,
57100
57386
  migrateOpenCode,
@@ -57533,7 +57819,7 @@ function createDefaultCliDependencies() {
57533
57819
  isHeadless: () => Boolean(
57534
57820
  process.env.SSH_CONNECTION || process.env.SSH_CLIENT || process.env.SSH_TTY || process.env.OPENCODE_HEADLESS
57535
57821
  ),
57536
- performLogin: async (request, openBrowser, host, context) => {
57822
+ performLogin: async (request2, openBrowser, host, context) => {
57537
57823
  if (host === "pi" && !context)
57538
57824
  throw new Error(
57539
57825
  "Pi setup requires its detected native agent directory."
@@ -57548,7 +57834,7 @@ function createDefaultCliDependencies() {
57548
57834
  context?.opencodeGeneration
57549
57835
  );
57550
57836
  try {
57551
- return await performOAuthLogin(request, {
57837
+ return await performOAuthLogin(request2, {
57552
57838
  authorize: authorizeAntigravity,
57553
57839
  exchange: exchangeAntigravity,
57554
57840
  startListener: startOAuthListener,
@@ -57566,7 +57852,7 @@ function createDefaultCliDependencies() {
57566
57852
  await persistCliStoreLogin(
57567
57853
  repository,
57568
57854
  result,
57569
- request.startFresh && request.accounts.length === 0
57855
+ request2.startFresh && request2.accounts.length === 0
57570
57856
  );
57571
57857
  }
57572
57858
  });
@@ -58726,11 +59012,11 @@ async function startRpcServer2(options) {
58726
59012
  throw new TypeError("startRpcServer needs this plugin's package version");
58727
59013
  }
58728
59014
  const parseApply = (value) => {
58729
- const request = options.parseApplyRequest(value);
58730
- if (request === void 0) {
59015
+ const request2 = options.parseApplyRequest(value);
59016
+ if (request2 === void 0) {
58731
59017
  throw new RpcRequestError(400, "Invalid apply request");
58732
59018
  }
58733
- return request;
59019
+ return request2;
58734
59020
  };
58735
59021
  const server = await startRpcServer({
58736
59022
  dir: options.dir,
@@ -58742,7 +59028,7 @@ async function startRpcServer2(options) {
58742
59028
  applyDeadlineMs: 12e4,
58743
59029
  timeoutMs: 0,
58744
59030
  parsePending,
58745
- apply: (async (request) => options.apply(parseApply(request))),
59031
+ apply: (async (request2) => options.apply(parseApply(request2))),
58746
59032
  // Use only the asynchronous overload, including for synchronous producers.
58747
59033
  drainAsync: (async (cursor, session) => Promise.resolve(
58748
59034
  options.drain(cursor, session)
@@ -61892,7 +62178,7 @@ function createAuthLoader({
61892
62178
  const authority = await readAuthority2?.() ?? "local";
61893
62179
  assertOpen();
61894
62180
  if (authority === "unreadable") throw new Error(unavailableMessage);
61895
- if (authority === "vault") {
62181
+ if (authority === "vault" || authority === "host") {
61896
62182
  currentRequestSource = "vault";
61897
62183
  if (!createVaultFetch) throw new Error(unavailableMessage);
61898
62184
  vaultFetchRuntime ??= createVaultFetch().catch((error) => {
@@ -62057,7 +62343,7 @@ var HANDLED_COMMAND_SENTINEL = "ANTIGRAVITY_COMMAND_HANDLED";
62057
62343
  async function sendIgnoredMessage(client, sessionID, text2) {
62058
62344
  const session = client.session;
62059
62345
  const promptContext = await resolvePromptContext(client, sessionID);
62060
- const request = {
62346
+ const request2 = {
62061
62347
  path: { id: sessionID },
62062
62348
  body: {
62063
62349
  noReply: true,
@@ -62068,11 +62354,11 @@ async function sendIgnoredMessage(client, sessionID, text2) {
62068
62354
  }
62069
62355
  };
62070
62356
  if (typeof session?.promptAsync === "function") {
62071
- await session.promptAsync(request);
62357
+ await session.promptAsync(request2);
62072
62358
  return;
62073
62359
  }
62074
62360
  if (typeof session?.prompt === "function") {
62075
- await Promise.resolve(session.prompt(request));
62361
+ await Promise.resolve(session.prompt(request2));
62076
62362
  return;
62077
62363
  }
62078
62364
  throw new Error(
@@ -63163,7 +63449,7 @@ function createSourceSidebarPublisher(options) {
63163
63449
  const authority = await options.readAuthority();
63164
63450
  let projection;
63165
63451
  if (authority === "local") projection = await options.local();
63166
- else if (authority === "vault") {
63452
+ else if (authority === "vault" || authority === "host") {
63167
63453
  try {
63168
63454
  projection = await options.vault();
63169
63455
  } catch {
@@ -63275,7 +63561,8 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
63275
63561
  // which decides whether its served credential needs replacement.
63276
63562
  reporterSource: "direct",
63277
63563
  onAuthorityChanged: (authority) => {
63278
- if (authority !== "vault") vaultQuotaPoller?.abortTick();
63564
+ if (authority !== "vault" && authority !== "host")
63565
+ vaultQuotaPoller?.abortTick();
63279
63566
  scheduleSidebarPublication();
63280
63567
  },
63281
63568
  onRosterChanged: () => scheduleSidebarPublication()
@@ -63308,11 +63595,11 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
63308
63595
  // the caller injected a mock transport.
63309
63596
  fetchVia: dependencies.agyTransport,
63310
63597
  mayRun: mayRunLocalAccounts,
63311
- fetchStoreAccountQuota: async (account, request) => {
63598
+ fetchStoreAccountQuota: async (account, request2) => {
63312
63599
  const service = await currentStoreQuota();
63313
63600
  if (!service)
63314
63601
  throw new Error("The current store quota service is unavailable");
63315
- return service.fetchAccountQuota(account, request);
63602
+ return service.fetchAccountQuota(account, request2);
63316
63603
  },
63317
63604
  // Bind to the live AccountManager so every refresh (manual or
63318
63605
  // background) pushes the freshly-updated quota percentages into the
@@ -63749,7 +64036,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
63749
64036
  const { source, pool } = await currentVaultPool();
63750
64037
  return createVaultFetchInterceptor({
63751
64038
  assertAdmission: async () => {
63752
- if (await readAuthority2() !== "vault")
64039
+ if (!["host", "vault"].includes(await readAuthority2()))
63753
64040
  throw new Error(unavailableMessage);
63754
64041
  },
63755
64042
  client,
@@ -63863,11 +64150,11 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
63863
64150
  dir: getRpcDir(directory),
63864
64151
  parseApplyRequest: commandsModule.parseApplyRequest,
63865
64152
  version: await pluginPackageVersion(),
63866
- apply: async (request) => {
64153
+ apply: async (request2) => {
63867
64154
  const current = await currentMenu();
63868
64155
  if (current.kind === "unavailable") throw new Error(current.message);
63869
- const invocation = menuInvocation(pushNotification, request.sessionId);
63870
- const result = await current.menu.apply(request, invocation);
64156
+ const invocation = menuInvocation(pushNotification, request2.sessionId);
64157
+ const result = await current.menu.apply(request2, invocation);
63871
64158
  try {
63872
64159
  if (await readAuthority2() === "local")
63873
64160
  await lifecycle.getAccountManager()?.refreshFromRepository();
@@ -63881,7 +64168,7 @@ var createAntigravityPlugin = (providerId, options = {}) => async (input2) => {
63881
64168
  kind: "warning"
63882
64169
  }
63883
64170
  },
63884
- request.sessionId
64171
+ request2.sessionId
63885
64172
  );
63886
64173
  }
63887
64174
  const refreshed = await currentMenu();