@cortexkit/opencode-antigravity-auth 3.0.17 → 3.0.18

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.
@@ -2984,7 +2984,7 @@
2984
2984
  "format": "esm"
2985
2985
  },
2986
2986
  "src/process-heartbeat.ts": {
2987
- "bytes": 17835,
2987
+ "bytes": 18961,
2988
2988
  "imports": [
2989
2989
  {
2990
2990
  "path": "node:crypto",
@@ -3046,7 +3046,7 @@
3046
3046
  "format": "esm"
3047
3047
  },
3048
3048
  "src/runtime-layout.ts": {
3049
- "bytes": 83341,
3049
+ "bytes": 83839,
3050
3050
  "imports": [
3051
3051
  {
3052
3052
  "path": "node:crypto",
@@ -3153,7 +3153,7 @@
3153
3153
  "format": "esm"
3154
3154
  },
3155
3155
  "src/runtime-paths.ts": {
3156
- "bytes": 17154,
3156
+ "bytes": 17250,
3157
3157
  "imports": [
3158
3158
  {
3159
3159
  "path": "node:crypto",
@@ -4305,7 +4305,7 @@
4305
4305
  "imports": [],
4306
4306
  "exports": [],
4307
4307
  "inputs": {},
4308
- "bytes": 3143396
4308
+ "bytes": 3145986
4309
4309
  },
4310
4310
  "dist/cli.js": {
4311
4311
  "imports": [
@@ -5460,19 +5460,19 @@
5460
5460
  "bytesInOutput": 694
5461
5461
  },
5462
5462
  "src/process-heartbeat.ts": {
5463
- "bytesInOutput": 7851
5463
+ "bytesInOutput": 8699
5464
5464
  },
5465
5465
  "src/version-fence.ts": {
5466
5466
  "bytesInOutput": 6382
5467
5467
  },
5468
5468
  "src/runtime-layout.ts": {
5469
- "bytesInOutput": 45520
5469
+ "bytesInOutput": 46055
5470
5470
  },
5471
5471
  "src/plugin/storage.ts": {
5472
5472
  "bytesInOutput": 11075
5473
5473
  },
5474
5474
  "src/runtime-paths.ts": {
5475
- "bytesInOutput": 6116
5475
+ "bytesInOutput": 6278
5476
5476
  },
5477
5477
  "src/plugin/logging-utils.ts": {
5478
5478
  "bytesInOutput": 3617
@@ -5607,7 +5607,7 @@
5607
5607
  "bytesInOutput": 1955
5608
5608
  }
5609
5609
  },
5610
- "bytes": 1177544
5610
+ "bytes": 1179089
5611
5611
  }
5612
5612
  }
5613
5613
  }
package/dist/index.js CHANGED
@@ -30494,6 +30494,7 @@ __export(process_heartbeat_exports, {
30494
30494
  holdCliProcessHeartbeat: () => holdCliProcessHeartbeat,
30495
30495
  pluginPackageVersion: () => pluginPackageVersion,
30496
30496
  processConfigFolderKey: () => processConfigFolderKey,
30497
+ processHasOlderGeneration: () => processHasOlderGeneration,
30497
30498
  processHeartbeatDir: () => processHeartbeatDir,
30498
30499
  processHeartbeatPath: () => processHeartbeatPath,
30499
30500
  recordProcessAnchor: () => recordProcessAnchor,
@@ -30522,10 +30523,19 @@ function processConfigFolderKey() {
30522
30523
  return resolve12(folder);
30523
30524
  }
30524
30525
  }
30526
+ function processHasOlderGeneration() {
30527
+ return shared.olderGeneration;
30528
+ }
30525
30529
  function layoutsRecord() {
30526
30530
  return Object.fromEntries(shared.layouts);
30527
30531
  }
30528
30532
  function storesRecord() {
30533
+ if (shared.olderGeneration)
30534
+ return Object.fromEntries(
30535
+ [.../* @__PURE__ */ new Set([...shared.layouts.keys(), ...shared.stores.keys()])].map(
30536
+ (key) => [key, "config"]
30537
+ )
30538
+ );
30529
30539
  return Object.fromEntries(shared.stores);
30530
30540
  }
30531
30541
  function recordSignature() {
@@ -30538,6 +30548,7 @@ function holdsLegacyLayout() {
30538
30548
  }
30539
30549
  function holdsFixedOldPaths() {
30540
30550
  if (holdsLegacyLayout()) return true;
30551
+ if (shared.olderGeneration) return true;
30541
30552
  for (const anchor of shared.stores.values())
30542
30553
  if (anchor === "config") return true;
30543
30554
  return false;
@@ -30579,16 +30590,17 @@ function errorText2(error) {
30579
30590
  return error instanceof Error ? error.message : String(error);
30580
30591
  }
30581
30592
  async function startProcessHeartbeat(input2) {
30582
- const pid = input2.pid ?? process.pid;
30583
- const dir = input2.dir ?? processHeartbeatDir();
30584
- shared.startedAt ??= (input2.now ?? Date.now)();
30585
- shared.owners++;
30586
- for (const [key, layout] of Object.entries(input2.layouts ?? {}))
30587
- shared.layouts.set(key, layout);
30588
- for (const [key, anchor] of Object.entries(input2.stores ?? {}))
30589
- shared.stores.set(key, anchor);
30593
+ let dir;
30590
30594
  let path5;
30591
30595
  try {
30596
+ const pid = input2.pid ?? process.pid;
30597
+ dir = input2.dir ?? processHeartbeatDir();
30598
+ shared.startedAt ??= (input2.now ?? Date.now)();
30599
+ shared.owners++;
30600
+ for (const [key, layout] of Object.entries(input2.layouts ?? {}))
30601
+ shared.layouts.set(key, layout);
30602
+ for (const [key, anchor] of Object.entries(input2.stores ?? {}))
30603
+ shared.stores.set(key, shared.olderGeneration ? "config" : anchor);
30592
30604
  path5 = await writeCurrentRecords(dir, pid, input2.version);
30593
30605
  } catch (error) {
30594
30606
  input2.logger.warn("process heartbeat not written", {
@@ -30602,10 +30614,16 @@ async function startProcessHeartbeat(input2) {
30602
30614
  async release() {
30603
30615
  if (released) return;
30604
30616
  released = true;
30605
- shared.owners = Math.max(0, shared.owners - 1);
30606
- if (shared.owners > 0) return;
30607
- if (holdsFixedOldPaths()) return;
30608
- await removeHeartbeatFile(input2.logger);
30617
+ try {
30618
+ shared.owners = Math.max(0, shared.owners - 1);
30619
+ if (shared.owners > 0) return;
30620
+ if (holdsFixedOldPaths()) return;
30621
+ await removeHeartbeatFile(input2.logger);
30622
+ } catch (error) {
30623
+ input2.logger.warn("process heartbeat not released", {
30624
+ error: errorText2(error)
30625
+ });
30626
+ }
30609
30627
  }
30610
30628
  };
30611
30629
  }
@@ -30647,7 +30665,7 @@ async function recordProcessLayout(input2) {
30647
30665
  await writeRecords(markStartedAt(input2));
30648
30666
  }
30649
30667
  async function recordProcessAnchor(input2) {
30650
- shared.stores.set(input2.key, input2.anchor);
30668
+ shared.stores.set(input2.key, shared.olderGeneration ? "config" : input2.anchor);
30651
30669
  await writeRecords(markStartedAt(input2));
30652
30670
  }
30653
30671
  function markStartedAt(input2) {
@@ -30709,7 +30727,7 @@ function __resetProcessHeartbeatForTest() {
30709
30727
  shared.writtenPath = void 0;
30710
30728
  shared.writtenLayouts = void 0;
30711
30729
  }
30712
- var stateKey, globalState, shared, HeartbeatWriteFailure, packageVersion;
30730
+ var stateKey, globalState, olderGeneration, shared, HeartbeatWriteFailure, packageVersion;
30713
30731
  var init_process_heartbeat = __esm({
30714
30732
  "src/process-heartbeat.ts"() {
30715
30733
  "use strict";
@@ -30717,15 +30735,16 @@ var init_process_heartbeat = __esm({
30717
30735
  init_runtime_paths();
30718
30736
  stateKey = /* @__PURE__ */ Symbol.for("cortexkit.antigravity-auth.process-heartbeat");
30719
30737
  globalState = globalThis;
30720
- shared = globalState[stateKey] ?? {
30721
- owners: 0,
30722
- startedAt: void 0,
30723
- layouts: /* @__PURE__ */ new Map(),
30724
- stores: /* @__PURE__ */ new Map(),
30725
- writtenPath: void 0,
30726
- writtenLayouts: void 0,
30727
- exitHookInstalled: false
30728
- };
30738
+ olderGeneration = globalState[stateKey] !== void 0 && globalState[stateKey].stores == null;
30739
+ shared = globalState[stateKey] ?? {};
30740
+ shared.owners ??= 0;
30741
+ shared.startedAt ??= void 0;
30742
+ shared.layouts ??= /* @__PURE__ */ new Map();
30743
+ shared.olderGeneration ??= olderGeneration;
30744
+ shared.stores ??= /* @__PURE__ */ new Map();
30745
+ shared.writtenPath ??= void 0;
30746
+ shared.writtenLayouts ??= void 0;
30747
+ shared.exitHookInstalled ??= false;
30729
30748
  globalState[stateKey] = shared;
30730
30749
  HeartbeatWriteFailure = class extends Error {
30731
30750
  constructor(cause) {
@@ -31239,6 +31258,17 @@ async function settleAccountStore(location, options, log16) {
31239
31258
  }
31240
31259
  async function decideAccountStore(location, options, log16) {
31241
31260
  const keepConfig = () => recordAnchor(location, options, "config", log16);
31261
+ if (processHasOlderGeneration()) {
31262
+ logOnce(
31263
+ "older-generation-account-store",
31264
+ () => showLog(
31265
+ log16,
31266
+ "antigravity-auth keeps the account store in OpenCode's config folder until OpenCode restarts, because an older version of the plugin ran in this process.",
31267
+ { accountStore: "config" }
31268
+ )
31269
+ );
31270
+ return keepConfig();
31271
+ }
31242
31272
  const configAnchor = legacyAccountFile(location.configDir);
31243
31273
  const stateAnchor = stateHomeAccountFile(location);
31244
31274
  const forward = readForwardedAccountStore(configAnchor);
@@ -32183,6 +32213,9 @@ var init_runtime_layout = __esm({
32183
32213
  storeRuns: /* @__PURE__ */ new Map(),
32184
32214
  logged: /* @__PURE__ */ new Set()
32185
32215
  };
32216
+ processState.runs ??= /* @__PURE__ */ new Map();
32217
+ processState.storeRuns ??= /* @__PURE__ */ new Map();
32218
+ processState.logged ??= /* @__PURE__ */ new Set();
32186
32219
  globalState2[stateKey2] = processState;
32187
32220
  LayoutMoveError = class extends Error {
32188
32221
  constructor(code2, message) {
@@ -32716,6 +32749,9 @@ var init_runtime_paths = __esm({
32716
32749
  locations: /* @__PURE__ */ new Map(),
32717
32750
  storeAnchors: /* @__PURE__ */ new Map()
32718
32751
  };
32752
+ shared2.decisions ??= /* @__PURE__ */ new Map();
32753
+ shared2.locations ??= /* @__PURE__ */ new Map();
32754
+ shared2.storeAnchors ??= /* @__PURE__ */ new Map();
32719
32755
  decisionState[decisionsKey] = shared2;
32720
32756
  SIGNATURE_CACHE_FILE_NAME = "antigravity-signature-cache.json";
32721
32757
  }