@cortexkit/opencode-antigravity-auth 3.0.32 → 3.0.34

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.
@@ -58,7 +58,7 @@
58
58
  "format": "esm"
59
59
  },
60
60
  "../core/dist/account-migration.js": {
61
- "bytes": 183913,
61
+ "bytes": 185508,
62
62
  "imports": [
63
63
  {
64
64
  "path": "node:crypto",
@@ -645,7 +645,7 @@
645
645
  "format": "esm"
646
646
  },
647
647
  "../core/dist/common-auth-embedded/fs/refresh-file-lock.js": {
648
- "bytes": 42093,
648
+ "bytes": 43780,
649
649
  "imports": [
650
650
  {
651
651
  "path": "node:crypto",
@@ -3780,7 +3780,7 @@
3780
3780
  "format": "esm"
3781
3781
  },
3782
3782
  "src/common-auth-embedded/fs/refresh-file-lock.js": {
3783
- "bytes": 42093,
3783
+ "bytes": 43780,
3784
3784
  "imports": [
3785
3785
  {
3786
3786
  "path": "node:crypto",
@@ -5941,7 +5941,7 @@
5941
5941
  "format": "esm"
5942
5942
  },
5943
5943
  "src/common-auth-embedded/routing-accessor/index.js": {
5944
- "bytes": 8194,
5944
+ "bytes": 8290,
5945
5945
  "imports": [
5946
5946
  {
5947
5947
  "path": "src/common-auth-embedded/routing-accessor/handle.js",
@@ -6565,7 +6565,7 @@
6565
6565
  "imports": [],
6566
6566
  "exports": [],
6567
6567
  "inputs": {},
6568
- "bytes": 4838272
6568
+ "bytes": 4846290
6569
6569
  },
6570
6570
  "dist/index.js": {
6571
6571
  "imports": [
@@ -7772,7 +7772,7 @@
7772
7772
  "bytesInOutput": 11044
7773
7773
  },
7774
7774
  "../core/dist/account-migration.js": {
7775
- "bytesInOutput": 150336
7775
+ "bytesInOutput": 151834
7776
7776
  },
7777
7777
  "../core/dist/account-repository.js": {
7778
7778
  "bytesInOutput": 78810
@@ -7868,7 +7868,7 @@
7868
7868
  "bytesInOutput": 2776
7869
7869
  },
7870
7870
  "../core/dist/common-auth-embedded/fs/refresh-file-lock.js": {
7871
- "bytesInOutput": 25953
7871
+ "bytesInOutput": 26961
7872
7872
  },
7873
7873
  "../core/dist/common-auth-embedded/fs/with-lock.js": {
7874
7874
  "bytesInOutput": 2399
@@ -8267,7 +8267,7 @@
8267
8267
  "bytesInOutput": 275
8268
8268
  },
8269
8269
  "src/common-auth-embedded/fs/refresh-file-lock.js": {
8270
- "bytesInOutput": 25812
8270
+ "bytesInOutput": 26834
8271
8271
  },
8272
8272
  "src/common-auth-embedded/fs/with-lock.js": {
8273
8273
  "bytesInOutput": 317
@@ -8582,7 +8582,7 @@
8582
8582
  "bytesInOutput": 0
8583
8583
  }
8584
8584
  },
8585
- "bytes": 2191230
8585
+ "bytes": 2194758
8586
8586
  }
8587
8587
  }
8588
8588
  }
package/dist/server.js CHANGED
@@ -1679,7 +1679,9 @@ function jsonBytes(bytes) {
1679
1679
  throw new AccountMigrationError("malformed or non-UTF8 durable JSON");
1680
1680
  }
1681
1681
  }
1682
- async function syncFile(path5) {
1682
+ async function syncFile(path5, boundary, role = "recovery-copy") {
1683
+ if (boundary)
1684
+ await boundary(`before-file-sync:${role}`);
1683
1685
  await secureRead(path5);
1684
1686
  const access = process.platform === "win32" ? constants.O_RDWR : constants.O_RDONLY;
1685
1687
  const handle = await open(path5, access | constants.O_NOFOLLOW);
@@ -1689,6 +1691,8 @@ async function syncFile(path5) {
1689
1691
  await handle.close();
1690
1692
  }
1691
1693
  await secureRead(path5);
1694
+ if (boundary)
1695
+ await boundary(`after-file-sync:${role}`);
1692
1696
  }
1693
1697
  function accountMigrationDurability(platform = process.platform) {
1694
1698
  return platform === "win32" ? "windows-reopened-no-directory-power-loss-guarantee" : "posix-directory-synced";
@@ -1705,7 +1709,9 @@ async function syncDirectory(path5, boundary) {
1705
1709
  }
1706
1710
  await boundary?.("after-directory-sync");
1707
1711
  }
1708
- async function exclusiveBytes(path5, bytes, expectedHash, boundary, pointerStage = false) {
1712
+ async function exclusiveBytes(path5, bytes, expectedHash, boundary, pointerStage = false, role = "recovery-copy") {
1713
+ if (boundary)
1714
+ await boundary(`before-exclusive-write:${role}`);
1709
1715
  let handle;
1710
1716
  try {
1711
1717
  if (windowsPrivateFiles) {
@@ -1720,7 +1726,11 @@ async function exclusiveBytes(path5, bytes, expectedHash, boundary, pointerStage
1720
1726
  if (handle !== void 0) {
1721
1727
  try {
1722
1728
  await handle.writeFile(bytes);
1729
+ if (boundary)
1730
+ await boundary(`before-file-sync:${role}`);
1723
1731
  await handle.sync();
1732
+ if (boundary)
1733
+ await boundary(`after-file-sync:${role}`);
1724
1734
  } finally {
1725
1735
  await handle.close();
1726
1736
  }
@@ -1729,8 +1739,10 @@ async function exclusiveBytes(path5, bytes, expectedHash, boundary, pointerStage
1729
1739
  if (digest(reopened) !== expectedHash || !reopened.equals(bytes))
1730
1740
  throw new AccountMigrationError("exclusive backup or recovery copy differs");
1731
1741
  if (handle === void 0 || !pointerStage)
1732
- await syncFile(path5);
1742
+ await syncFile(path5, boundary, role);
1733
1743
  await syncDirectory(dirname2(path5), boundary);
1744
+ if (boundary)
1745
+ await boundary(`after-exclusive-write:${role}`);
1734
1746
  }
1735
1747
  async function readJournal(paths) {
1736
1748
  if (!await exists(paths.storeDir))
@@ -1747,6 +1759,8 @@ async function readJournal(paths) {
1747
1759
  return journal;
1748
1760
  }
1749
1761
  async function saveJournal(modules, paths, lease, journal, initial = false, boundary) {
1762
+ if (boundary)
1763
+ await boundary("before-journal-write");
1750
1764
  decodeAccountMigrationJournal(journalJson(journal));
1751
1765
  const stage = journal.id;
1752
1766
  const journalTemp = `${paths.migrationPath}.${stage}.tmp`;
@@ -1767,16 +1781,18 @@ async function saveJournal(modules, paths, lease, journal, initial = false, boun
1767
1781
  const owned = typeof initial === "string" ? current?.id === initial && current.status === "inactive" : initial ? current === void 0 : current?.id === journal.id;
1768
1782
  if (!owned)
1769
1783
  throw new AccountMigrationError("journal ownership changed before write");
1770
- await syncFile(`${paths.migrationPath}.${stage}.tmp`);
1784
+ await syncFile(`${paths.migrationPath}.${stage}.tmp`, boundary, "journal-stage");
1771
1785
  await lease.assertOwned();
1772
1786
  }
1773
1787
  });
1774
- await syncFile(paths.migrationPath);
1788
+ await syncFile(paths.migrationPath, boundary, "journal");
1775
1789
  await syncDirectory(paths.storeDir, boundary);
1776
1790
  const reopened = await readJournal(paths);
1777
1791
  if (!reopened || !isDeepStrictEqual(journalJson(reopened), journalJson(journal)))
1778
1792
  throw new AccountMigrationError("journal readback differs");
1779
1793
  await lease.assertOwned();
1794
+ if (boundary)
1795
+ await boundary("after-journal-write");
1780
1796
  }
1781
1797
  function openMigrationStore(modules, paths, now, onStep) {
1782
1798
  return modules.store.openPoolStore({
@@ -1941,10 +1957,10 @@ function verifyRelocationSnapshot(backup, journal) {
1941
1957
  throw new AccountMigrationError("moved source snapshot belongs to another generation");
1942
1958
  }
1943
1959
  async function synchronizedSnapshot(paths, boundary) {
1944
- await syncFile(paths.configPath);
1960
+ await syncFile(paths.configPath, boundary, "config");
1945
1961
  const statePresent = await exists(paths.statePath);
1946
1962
  if (statePresent)
1947
- await syncFile(paths.statePath);
1963
+ await syncFile(paths.statePath, boundary, "state");
1948
1964
  await syncDirectory(paths.storeDir, boundary);
1949
1965
  return {
1950
1966
  config: await secureRead(paths.configPath),
@@ -2249,7 +2265,7 @@ async function capture(modules, paths, lease, options, previous) {
2249
2265
  const manifest = parseLegacyAccountStorage(new TextDecoder("utf-8", { fatal: true }).decode(bytes), options.now());
2250
2266
  const sourceSha256 = digest(bytes);
2251
2267
  await options.onBoundary?.("capture:before-backup");
2252
- await exclusiveBytes(join2(paths.backupsDir, `${sourceSha256}.json`), bytes, sourceSha256, options.onBoundary);
2268
+ await exclusiveBytes(join2(paths.backupsDir, `${sourceSha256}.json`), bytes, sourceSha256, options.onBoundary, false, "backup");
2253
2269
  const journal = {
2254
2270
  schemaVersion: 1,
2255
2271
  id: pathGenerationId(paths),
@@ -2270,13 +2286,13 @@ async function capture(modules, paths, lease, options, previous) {
2270
2286
  const captureBytes = Buffer.from(`${JSON.stringify(captureJson(journal), null, 2)}
2271
2287
  `);
2272
2288
  journal.captureSha256 = digest(captureBytes);
2273
- await exclusiveBytes(join2(paths.transfersDir, `${journal.id}.capture.json`), captureBytes, journal.captureSha256, options.onBoundary);
2289
+ await exclusiveBytes(join2(paths.transfersDir, `${journal.id}.capture.json`), captureBytes, journal.captureSha256, options.onBoundary, false, "capture-record");
2274
2290
  await accountsLease.assertOwned();
2275
2291
  await lease.assertOwned();
2276
2292
  if (previous !== void 0) {
2277
2293
  const archived = Buffer.from(`${JSON.stringify(journalJson(previous), null, 2)}
2278
2294
  `);
2279
- await exclusiveBytes(join2(paths.transfersDir, `${previous.id}.journal.json`), archived, digest(archived), options.onBoundary);
2295
+ await exclusiveBytes(join2(paths.transfersDir, `${previous.id}.journal.json`), archived, digest(archived), options.onBoundary, false, "archived-journal");
2280
2296
  }
2281
2297
  await saveJournal(modules, paths, lease, journal, true, options.onBoundary);
2282
2298
  return journal;
@@ -2288,7 +2304,7 @@ async function build(store, modules, paths, lease, journal, options) {
2288
2304
  await assertStateOwnership(paths, journal, false);
2289
2305
  if (!journal.mapping.length && !await exists(paths.configPath)) {
2290
2306
  const bootstrap = Buffer.from('{"version":1,"accounts":[]}\n');
2291
- await exclusiveBytes(paths.configPath, bootstrap, digest(bootstrap), options.onBoundary);
2307
+ await exclusiveBytes(paths.configPath, bootstrap, digest(bootstrap), options.onBoundary, false, "config");
2292
2308
  }
2293
2309
  await store.initialize();
2294
2310
  const known = await rowsOf(store);
@@ -2496,7 +2512,7 @@ function createAccountMigrationFactory(modules) {
2496
2512
  return await withParentTopology(modules, options.legacyPath, async (parentLease) => {
2497
2513
  const prior = await readPointer(options.legacyPath);
2498
2514
  if (prior)
2499
- await finishPointerPublication(options.legacyPath, prior, parentLease);
2515
+ await finishPointerPublication(options.legacyPath, prior, parentLease, options.onBoundary);
2500
2516
  let paths = prior ? generationPaths(options.legacyPath, prior.id) : void 0;
2501
2517
  let previous;
2502
2518
  if (paths) {
@@ -2789,13 +2805,13 @@ async function replaceRelocationPointer(modules, anchor, prior, next, id, leases
2789
2805
  await assertOwned();
2790
2806
  if (!isDeepStrictEqual(await readPointerRecord(anchor), prior))
2791
2807
  throw new AccountMigrationError("source pointer changed before rename");
2792
- await syncFile(stage);
2808
+ await syncFile(stage, boundary, "pointer-stage");
2793
2809
  await boundary?.(`${prefix}:before-rename`);
2794
2810
  }
2795
2811
  });
2796
2812
  await boundary?.(`${prefix}:after-rename-before-sync`);
2797
2813
  }
2798
- await syncFile(path5);
2814
+ await syncFile(path5, boundary, "pointer");
2799
2815
  await syncDirectory(dirname2(anchor));
2800
2816
  if (!isDeepStrictEqual(await readPointerRecord(anchor), next))
2801
2817
  throw new AccountMigrationError("relocation pointer readback differs");
@@ -2817,7 +2833,7 @@ function createAccountRelocationFactory(modules) {
2817
2833
  if (!sourceRecord)
2818
2834
  throw new AccountMigrationError("relocation source pointer missing");
2819
2835
  if (sourceRecord.schemaVersion === 1)
2820
- await finishPointerPublication(options.legacyPath, sourceRecord, sourceParent);
2836
+ await finishPointerPublication(options.legacyPath, sourceRecord, sourceParent, options.onBoundary);
2821
2837
  const source = generationPaths(options.legacyPath, sourceRecord.id);
2822
2838
  if (await exists(source.legacyPath) || await exists(options.targetPath))
2823
2839
  throw new AccountMigrationError("relocation refuses a reappeared pool file");
@@ -2827,7 +2843,7 @@ function createAccountRelocationFactory(modules) {
2827
2843
  throw new AccountMigrationError("relocation source journal missing");
2828
2844
  const prior = await readPointer(options.targetPath);
2829
2845
  if (prior)
2830
- await finishPointerPublication(options.targetPath, prior, targetParent);
2846
+ await finishPointerPublication(options.targetPath, prior, targetParent, options.onBoundary);
2831
2847
  let paths = prior ? generationPaths(options.targetPath, prior.id) : void 0;
2832
2848
  let existing = paths ? await readJournal(paths) : void 0;
2833
2849
  if (prior && (existing?.sourceKind !== "generation" || relocationOf(existing).source.legacyPath !== source.legacyPath || relocationOf(existing).source.journalId !== sourceJournal.id))
@@ -3117,10 +3133,10 @@ async function reverseRelocation(modules, options, sourceParent, targetParent) {
3117
3133
  stageName: () => journal.id,
3118
3134
  beforeRename: async () => {
3119
3135
  await lease.assertOwned();
3120
- await syncFile(stage);
3136
+ await syncFile(stage, options.onBoundary, "reverse-progress-stage");
3121
3137
  }
3122
3138
  });
3123
- await syncFile(progressPath);
3139
+ await syncFile(progressPath, options.onBoundary, "reverse-progress");
3124
3140
  await syncDirectory(paths.transfersDir);
3125
3141
  if (!isDeepStrictEqual(jsonBytes(await secureRead(progressPath)), record3))
3126
3142
  throw new AccountMigrationError("reverse progress readback differs");
@@ -3159,7 +3175,7 @@ async function reverseRelocation(modules, options, sourceParent, targetParent) {
3159
3175
  await exclusiveBytes(stage, bytes, digest(bytes), options.onBoundary);
3160
3176
  await assertOwned();
3161
3177
  await rename2(stage, path5);
3162
- await syncFile(path5);
3178
+ await syncFile(path5, options.onBoundary, "restored-copy");
3163
3179
  await syncDirectory(original.storeDir);
3164
3180
  };
3165
3181
  if (snapshot2.state !== void 0)
@@ -3179,7 +3195,7 @@ async function reverseRelocation(modules, options, sourceParent, targetParent) {
3179
3195
  const originalStore = openMigrationStore(modules, original, options.now, async (step, info) => {
3180
3196
  await originalLease.assertOwned();
3181
3197
  if (step.startsWith("after-")) {
3182
- await syncFile(step.includes("config") ? original.configPath : original.statePath);
3198
+ await syncFile(step.includes("config") ? original.configPath : original.statePath, options.onBoundary, step.includes("config") ? "config" : "state");
3183
3199
  await syncDirectory(original.storeDir);
3184
3200
  }
3185
3201
  await options.onBoundary?.(`back:public:${info.operation}:${step}`);
@@ -3515,7 +3531,7 @@ async function initializeFreshAccountStore(modules, options) {
3515
3531
  await assertSourceAbsent(resolveAccountStorePaths(options.legacyPath));
3516
3532
  const pointer = await readPointer(options.legacyPath);
3517
3533
  if (pointer)
3518
- await finishPointerPublication(options.legacyPath, pointer, parentLease);
3534
+ await finishPointerPublication(options.legacyPath, pointer, parentLease, options.onBoundary);
3519
3535
  const physical = pointer ? generationPaths(options.legacyPath, pointer.id) : await allocateGeneration(options.legacyPath);
3520
3536
  return modules.fs.withLock(physical.configPath, {
3521
3537
  name: MANAGEMENT_LOCK_NAME,
@@ -3703,9 +3719,9 @@ async function initializePrivateEmptyGeneration(modules, paths, parentLease, man
3703
3719
  await exclusiveUnpublishedBytes(paths.migrationPath, Buffer.from(`${JSON.stringify(journalJson(journal), null, 2)}
3704
3720
  `));
3705
3721
  await boundary?.("empty-stage:after-journal");
3706
- await syncFile(paths.configPath);
3722
+ await syncFile(paths.configPath, boundary, "config");
3707
3723
  await boundary?.("empty-stage:after-config-sync");
3708
- await syncFile(paths.migrationPath);
3724
+ await syncFile(paths.migrationPath, boundary, "journal");
3709
3725
  await boundary?.("empty-stage:after-journal-sync");
3710
3726
  for (const [name, path6] of [
3711
3727
  ["backups", paths.backupsDir],
@@ -3741,7 +3757,11 @@ async function initializePrivateEmptyGeneration(modules, paths, parentLease, man
3741
3757
  if (stageHandle) {
3742
3758
  try {
3743
3759
  await stageHandle.writeFile(bytes);
3760
+ if (boundary)
3761
+ await boundary("before-file-sync:pointer-stage");
3744
3762
  await stageHandle.sync();
3763
+ if (boundary)
3764
+ await boundary("after-file-sync:pointer-stage");
3745
3765
  } finally {
3746
3766
  await stageHandle.close();
3747
3767
  }
@@ -3749,7 +3769,7 @@ async function initializePrivateEmptyGeneration(modules, paths, parentLease, man
3749
3769
  if (!(await secureRead(stage)).equals(bytes))
3750
3770
  throw new AccountMigrationError("exclusive pointer stage differs");
3751
3771
  if (!stageHandle)
3752
- await syncFile(stage);
3772
+ await syncFile(stage, boundary, "pointer-stage");
3753
3773
  await boundary?.("empty-stage:after-pointer-stage");
3754
3774
  await syncDirectory(dirname2(path5));
3755
3775
  await boundary?.("empty-stage:after-parent-prelink-sync");
@@ -3802,7 +3822,7 @@ async function publishGenerationPointer(modules, paths, journal, parentLease, ma
3802
3822
  if (!currentJournal || currentJournal.id !== journal.id || !isDeepStrictEqual(journalJson(currentJournal), journalJson(journal)))
3803
3823
  throw new AccountMigrationError("publication requires its complete synced canonical journal");
3804
3824
  if (journalSavedBy !== managementLease) {
3805
- await syncFile(paths.migrationPath);
3825
+ await syncFile(paths.migrationPath, boundary, "journal");
3806
3826
  await syncDirectory(paths.storeDir);
3807
3827
  }
3808
3828
  const pointer = {
@@ -3815,7 +3835,7 @@ async function publishGenerationPointer(modules, paths, journal, parentLease, ma
3815
3835
  const stage = `${path5}.${journal.id}.tmp`;
3816
3836
  const bytes = Buffer.from(`${JSON.stringify(pointer, null, 2)}
3817
3837
  `);
3818
- await exclusiveBytes(stage, bytes, digest(bytes), void 0, true);
3838
+ await exclusiveBytes(stage, bytes, digest(bytes), boundary, true, "pointer-stage");
3819
3839
  await parentLease.assertOwned();
3820
3840
  await managementLease.assertOwned();
3821
3841
  await boundary?.("pointer:before-link");
@@ -3859,10 +3879,10 @@ async function publishGenerationPointer(modules, paths, journal, parentLease, ma
3859
3879
  await managementLease.assertOwned();
3860
3880
  if (!isDeepStrictEqual(await readPointer(paths.legacyPath), prior) || (reversed ? !isDeepStrictEqual(await readJournal(oldPaths), oldJournal) : (await readJournal(oldPaths))?.status !== "inactive"))
3861
3881
  throw new AccountMigrationError("inactive pointer changed before transition");
3862
- await syncFile(`${path5}.${stageName}.tmp`);
3882
+ await syncFile(`${path5}.${stageName}.tmp`, boundary, "pointer-stage");
3863
3883
  }
3864
3884
  });
3865
- await syncFile(path5);
3885
+ await syncFile(path5, boundary, "pointer");
3866
3886
  await syncDirectory(dirname2(path5));
3867
3887
  }
3868
3888
  await parentLease.assertOwned();
@@ -3881,7 +3901,7 @@ function writeObserver(paths, lease, boundary) {
3881
3901
  await lease.assertOwned();
3882
3902
  await assertPublishedAccountStoreGeneration(paths);
3883
3903
  if (step.startsWith("after-")) {
3884
- await syncFile(step.includes("config") ? paths.configPath : paths.statePath);
3904
+ await syncFile(step.includes("config") ? paths.configPath : paths.statePath, boundary, step.includes("config") ? "config" : "state");
3885
3905
  await syncDirectory(paths.storeDir, boundary);
3886
3906
  }
3887
3907
  await boundary?.(`public:${info.operation}:${step}`);
@@ -3889,9 +3909,9 @@ function writeObserver(paths, lease, boundary) {
3889
3909
  await assertPublishedAccountStoreGeneration(paths);
3890
3910
  };
3891
3911
  }
3892
- async function finishPointerPublication(legacyPath, pointer, lease) {
3912
+ async function finishPointerPublication(legacyPath, pointer, lease, boundary) {
3893
3913
  const path5 = accountStorePointerPath(legacyPath);
3894
- await syncFile(path5);
3914
+ await syncFile(path5, boundary, "pointer");
3895
3915
  await syncDirectory(dirname2(path5));
3896
3916
  if (await cleanupPointerStage(legacyPath, pointer, lease))
3897
3917
  await syncDirectory(dirname2(path5));
@@ -12639,9 +12659,37 @@ var init_atomic_write2 = __esm({
12639
12659
 
12640
12660
  // ../core/dist/common-auth-embedded/fs/refresh-file-lock.js
12641
12661
  import { randomUUID as randomUUID9 } from "node:crypto";
12642
- import { lstat as lstat3, mkdir as mkdir7, open as open4, readFile as readFile5, rename as rename6, rm as rm4, stat as stat3 } from "node:fs/promises";
12662
+ import { link as link2, lstat as lstat3, mkdir as mkdir7, open as open4, readFile as readFile5, rename as rename6, rm as rm4, stat as stat3 } from "node:fs/promises";
12643
12663
  import { dirname as dirname7, join as join5 } from "node:path";
12644
12664
  async function createExclusiveText(path5, text2) {
12665
+ const tempPath = `${path5}.${randomUUID9()}.tmp`;
12666
+ let handle;
12667
+ try {
12668
+ handle = await open4(tempPath, "wx", 384);
12669
+ try {
12670
+ if (leaseCreationTestHooks?.beforeWrite)
12671
+ await leaseCreationTestHooks.beforeWrite(tempPath);
12672
+ await handle.writeFile(text2, "utf8");
12673
+ } finally {
12674
+ await handle.close();
12675
+ }
12676
+ try {
12677
+ if (leaseCreationTestHooks?.beforeLink)
12678
+ await leaseCreationTestHooks.beforeLink(tempPath, path5);
12679
+ await link2(tempPath, path5);
12680
+ } catch (error) {
12681
+ const code2 = error.code;
12682
+ if (code2 !== "EPERM" && code2 !== "ENOTSUP" && code2 !== "EOPNOTSUPP" && code2 !== "EXDEV")
12683
+ throw error;
12684
+ await writeExclusiveText(path5, text2);
12685
+ }
12686
+ } finally {
12687
+ if (handle)
12688
+ await rm4(tempPath, { force: true }).catch(() => {
12689
+ });
12690
+ }
12691
+ }
12692
+ async function writeExclusiveText(path5, text2) {
12645
12693
  const handle = await open4(path5, "wx", 384);
12646
12694
  let createdStat;
12647
12695
  try {
@@ -12650,6 +12698,8 @@ async function createExclusiveText(path5, text2) {
12650
12698
  createdStat = void 0;
12651
12699
  }
12652
12700
  try {
12701
+ if (leaseCreationTestHooks?.beforeWrite)
12702
+ await leaseCreationTestHooks.beforeWrite(path5);
12653
12703
  await handle.writeFile(text2, "utf8");
12654
12704
  } catch (error) {
12655
12705
  try {
@@ -13020,7 +13070,7 @@ async function acquireRefreshFileLockWithClock(options) {
13020
13070
  if (windowsPrivateFiles)
13021
13071
  await createPrivateBytes(evictOwnerPath, bytes);
13022
13072
  else
13023
- await createExclusiveText(evictOwnerPath, bytes);
13073
+ await writeExclusiveText(evictOwnerPath, bytes);
13024
13074
  } catch (error) {
13025
13075
  const stillOurs = await removeOwnMarkerAfterFailedOwnerWrite(created, deadline);
13026
13076
  if (isLostMarkerRaceError(error) && !stillOurs)
@@ -13425,7 +13475,7 @@ async function acquireRefreshFileLockWithClock(options) {
13425
13475
  }
13426
13476
  };
13427
13477
  }
13428
- var setRefreshLockRenewalTimeout, clearRefreshLockRenewalTimeout, evictionMarkerTestHooks, OWNERLESS_MARKER_GRACE_MS;
13478
+ var leaseCreationTestHooks, setRefreshLockRenewalTimeout, clearRefreshLockRenewalTimeout, evictionMarkerTestHooks, OWNERLESS_MARKER_GRACE_MS;
13429
13479
  var init_refresh_file_lock = __esm({
13430
13480
  "../core/dist/common-auth-embedded/fs/refresh-file-lock.js"() {
13431
13481
  "use strict";
@@ -53052,7 +53102,7 @@ function isGaOwnedRequest(event) {
53052
53102
  return event.request.headers.get("x-goog-api-key") === placeholderSecret("google");
53053
53103
  }
53054
53104
  var GA_RETRY_OWNERSHIP_LIMIT = 512;
53055
- var GA_UNSUPPORTED_REQUEST_MESSAGE = "This request cannot use Antigravity. Choose a supported Antigravity model.";
53105
+ var GA_NON_CONTENT_REQUEST_MESSAGE = "This Google request isn't a model reply that Antigravity can serve.";
53056
53106
  var GA_CUSTOM_GOOGLE_ORIGIN_MESSAGE = "Antigravity pool requests need the default Google base URL. Remove the custom baseURL from the Google provider settings.";
53057
53107
  var GaRequestOwnership = class {
53058
53108
  latest = /* @__PURE__ */ new Map();
@@ -53081,13 +53131,18 @@ async function rewriteGaHttpRequest(event, input2) {
53081
53131
  if (!owned) return;
53082
53132
  const original = event.request;
53083
53133
  if (!isGaGoogleContentRequest(original)) {
53084
- throw new Error(GA_UNSUPPORTED_REQUEST_MESSAGE);
53134
+ throw new Error(GA_NON_CONTENT_REQUEST_MESSAGE);
53085
53135
  }
53086
53136
  if (!isCanonicalGoogleOrigin(original.url)) {
53087
53137
  throw new Error(GA_CUSTOM_GOOGLE_ORIGIN_MESSAGE);
53088
53138
  }
53089
53139
  if (event.kind !== "title" && !input2.isRegisteredModel(event.model.id) && !isRetiredAgyModel(event.model.id)) {
53090
- throw new Error(GA_UNSUPPORTED_REQUEST_MESSAGE);
53140
+ const modelID = event.model.id;
53141
+ const antigravityModelID = modelID.startsWith("antigravity-") ? null : `antigravity-${modelID}`;
53142
+ const suggestion = antigravityModelID !== null && input2.isRegisteredModel(antigravityModelID) ? `Use google/${antigravityModelID}.` : "Choose a google/antigravity- model.";
53143
+ throw new Error(
53144
+ `This request cannot use Antigravity: google/${modelID} is not an Antigravity model. ${suggestion}`
53145
+ );
53091
53146
  }
53092
53147
  const job = {
53093
53148
  sessionID: event.sessionID,
@@ -53737,7 +53792,7 @@ init_private_files2();
53737
53792
  // src/common-auth-embedded/fs/refresh-file-lock.js
53738
53793
  init_private_files2();
53739
53794
  import { randomUUID as randomUUID18 } from "node:crypto";
53740
- import { lstat as lstat8, mkdir as mkdir14, open as open9, readFile as readFile13, rename as rename11, rm as rm6, stat as stat13 } from "node:fs/promises";
53795
+ import { link as link3, lstat as lstat8, mkdir as mkdir14, open as open9, readFile as readFile13, rename as rename11, rm as rm6, stat as stat13 } from "node:fs/promises";
53741
53796
  import { dirname as dirname21, join as join25 } from "node:path";
53742
53797
 
53743
53798
  // src/common-auth-embedded/fs/with-lock.js
@@ -53755,7 +53810,36 @@ var LockOwnershipError2 = class extends Error {
53755
53810
  };
53756
53811
 
53757
53812
  // src/common-auth-embedded/fs/refresh-file-lock.js
53813
+ var leaseCreationTestHooks2;
53758
53814
  async function createExclusiveText2(path5, text2) {
53815
+ const tempPath = `${path5}.${randomUUID18()}.tmp`;
53816
+ let handle;
53817
+ try {
53818
+ handle = await open9(tempPath, "wx", 384);
53819
+ try {
53820
+ if (leaseCreationTestHooks2?.beforeWrite)
53821
+ await leaseCreationTestHooks2.beforeWrite(tempPath);
53822
+ await handle.writeFile(text2, "utf8");
53823
+ } finally {
53824
+ await handle.close();
53825
+ }
53826
+ try {
53827
+ if (leaseCreationTestHooks2?.beforeLink)
53828
+ await leaseCreationTestHooks2.beforeLink(tempPath, path5);
53829
+ await link3(tempPath, path5);
53830
+ } catch (error) {
53831
+ const code2 = error.code;
53832
+ if (code2 !== "EPERM" && code2 !== "ENOTSUP" && code2 !== "EOPNOTSUPP" && code2 !== "EXDEV")
53833
+ throw error;
53834
+ await writeExclusiveText2(path5, text2);
53835
+ }
53836
+ } finally {
53837
+ if (handle)
53838
+ await rm6(tempPath, { force: true }).catch(() => {
53839
+ });
53840
+ }
53841
+ }
53842
+ async function writeExclusiveText2(path5, text2) {
53759
53843
  const handle = await open9(path5, "wx", 384);
53760
53844
  let createdStat;
53761
53845
  try {
@@ -53764,6 +53848,8 @@ async function createExclusiveText2(path5, text2) {
53764
53848
  createdStat = void 0;
53765
53849
  }
53766
53850
  try {
53851
+ if (leaseCreationTestHooks2?.beforeWrite)
53852
+ await leaseCreationTestHooks2.beforeWrite(path5);
53767
53853
  await handle.writeFile(text2, "utf8");
53768
53854
  } catch (error) {
53769
53855
  try {
@@ -54138,7 +54224,7 @@ async function acquireRefreshFileLockWithClock2(options) {
54138
54224
  if (windowsPrivateFiles2)
54139
54225
  await createPrivateBytes2(evictOwnerPath, bytes);
54140
54226
  else
54141
- await createExclusiveText2(evictOwnerPath, bytes);
54227
+ await writeExclusiveText2(evictOwnerPath, bytes);
54142
54228
  } catch (error) {
54143
54229
  const stillOurs = await removeOwnMarkerAfterFailedOwnerWrite(created, deadline);
54144
54230
  if (isLostMarkerRaceError2(error) && !stillOurs)