@cortexkit/opencode-antigravity-auth 3.0.31 → 3.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +117 -36
- package/dist/cli.js.map +3 -3
- package/dist/cli.meta.json +8 -8
- package/dist/index.js +168 -58
- package/dist/index.js.map +3 -3
- package/dist/index.meta.json +10 -10
- package/dist/server.js +168 -58
- package/dist/server.js.map +3 -3
- package/dist/server.meta.json +1 -1
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.d.ts +6 -0
- package/dist/src/common-auth-embedded/fs/refresh-file-lock.js +47 -3
- package/dist/src/common-auth-embedded/routing-accessor/index.d.ts +30 -5
- package/dist/src/common-auth-embedded/routing-accessor/index.js +122 -33
- package/dist/src/common-auth-embedded/source-output.json +18 -18
- package/dist/src/plugin/__fixtures__/verified-store.js +2 -2
- package/dist/tui-build-map.json +1 -1
- package/dist/tui-ga-build-map.json +1 -1
- package/dist/types/src/common-auth-embedded/fs/refresh-file-lock.d.ts +6 -0
- package/dist/types/src/common-auth-embedded/routing-accessor/index.d.ts +30 -5
- package/package.json +2 -2
- package/src/common-auth-embedded/fs/refresh-file-lock.d.ts +6 -0
- package/src/common-auth-embedded/fs/refresh-file-lock.js +47 -3
- package/src/common-auth-embedded/routing-accessor/index.d.ts +30 -5
- package/src/common-auth-embedded/routing-accessor/index.js +122 -33
- package/src/common-auth-embedded/source-output.json +18 -18
package/dist/cli.meta.json
CHANGED
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"format": "esm"
|
|
59
59
|
},
|
|
60
60
|
"../core/dist/account-migration.js": {
|
|
61
|
-
"bytes":
|
|
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":
|
|
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":
|
|
3783
|
+
"bytes": 43780,
|
|
3784
3784
|
"imports": [
|
|
3785
3785
|
{
|
|
3786
3786
|
"path": "node:crypto",
|
|
@@ -4412,7 +4412,7 @@
|
|
|
4412
4412
|
"imports": [],
|
|
4413
4413
|
"exports": [],
|
|
4414
4414
|
"inputs": {},
|
|
4415
|
-
"bytes":
|
|
4415
|
+
"bytes": 3232655
|
|
4416
4416
|
},
|
|
4417
4417
|
"dist/cli.js": {
|
|
4418
4418
|
"imports": [
|
|
@@ -5208,7 +5208,7 @@
|
|
|
5208
5208
|
"bytesInOutput": 11044
|
|
5209
5209
|
},
|
|
5210
5210
|
"../core/dist/account-migration.js": {
|
|
5211
|
-
"bytesInOutput":
|
|
5211
|
+
"bytesInOutput": 151826
|
|
5212
5212
|
},
|
|
5213
5213
|
"../core/dist/account-repository.js": {
|
|
5214
5214
|
"bytesInOutput": 78687
|
|
@@ -5304,7 +5304,7 @@
|
|
|
5304
5304
|
"bytesInOutput": 2776
|
|
5305
5305
|
},
|
|
5306
5306
|
"../core/dist/common-auth-embedded/fs/refresh-file-lock.js": {
|
|
5307
|
-
"bytesInOutput":
|
|
5307
|
+
"bytesInOutput": 26961
|
|
5308
5308
|
},
|
|
5309
5309
|
"../core/dist/common-auth-embedded/fs/with-lock.js": {
|
|
5310
5310
|
"bytesInOutput": 2399
|
|
@@ -5697,7 +5697,7 @@
|
|
|
5697
5697
|
"bytesInOutput": 275
|
|
5698
5698
|
},
|
|
5699
5699
|
"src/common-auth-embedded/fs/refresh-file-lock.js": {
|
|
5700
|
-
"bytesInOutput":
|
|
5700
|
+
"bytesInOutput": 26834
|
|
5701
5701
|
},
|
|
5702
5702
|
"src/common-auth-embedded/fs/with-lock.js": {
|
|
5703
5703
|
"bytesInOutput": 317
|
|
@@ -5745,7 +5745,7 @@
|
|
|
5745
5745
|
"bytesInOutput": 292
|
|
5746
5746
|
}
|
|
5747
5747
|
},
|
|
5748
|
-
"bytes":
|
|
5748
|
+
"bytes": 1216024
|
|
5749
5749
|
}
|
|
5750
5750
|
}
|
|
5751
5751
|
}
|
package/dist/index.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),
|
|
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
|
|
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";
|
|
@@ -37129,7 +37179,7 @@ init_private_files2();
|
|
|
37129
37179
|
// src/common-auth-embedded/fs/refresh-file-lock.js
|
|
37130
37180
|
init_private_files2();
|
|
37131
37181
|
import { randomUUID as randomUUID16 } from "node:crypto";
|
|
37132
|
-
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";
|
|
37182
|
+
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";
|
|
37133
37183
|
import { dirname as dirname19, join as join19 } from "node:path";
|
|
37134
37184
|
|
|
37135
37185
|
// src/common-auth-embedded/fs/with-lock.js
|
|
@@ -37147,7 +37197,36 @@ var LockOwnershipError2 = class extends Error {
|
|
|
37147
37197
|
};
|
|
37148
37198
|
|
|
37149
37199
|
// src/common-auth-embedded/fs/refresh-file-lock.js
|
|
37200
|
+
var leaseCreationTestHooks2;
|
|
37150
37201
|
async function createExclusiveText2(path5, text2) {
|
|
37202
|
+
const tempPath = `${path5}.${randomUUID16()}.tmp`;
|
|
37203
|
+
let handle;
|
|
37204
|
+
try {
|
|
37205
|
+
handle = await open9(tempPath, "wx", 384);
|
|
37206
|
+
try {
|
|
37207
|
+
if (leaseCreationTestHooks2?.beforeWrite)
|
|
37208
|
+
await leaseCreationTestHooks2.beforeWrite(tempPath);
|
|
37209
|
+
await handle.writeFile(text2, "utf8");
|
|
37210
|
+
} finally {
|
|
37211
|
+
await handle.close();
|
|
37212
|
+
}
|
|
37213
|
+
try {
|
|
37214
|
+
if (leaseCreationTestHooks2?.beforeLink)
|
|
37215
|
+
await leaseCreationTestHooks2.beforeLink(tempPath, path5);
|
|
37216
|
+
await link3(tempPath, path5);
|
|
37217
|
+
} catch (error) {
|
|
37218
|
+
const code2 = error.code;
|
|
37219
|
+
if (code2 !== "EPERM" && code2 !== "ENOTSUP" && code2 !== "EOPNOTSUPP" && code2 !== "EXDEV")
|
|
37220
|
+
throw error;
|
|
37221
|
+
await writeExclusiveText2(path5, text2);
|
|
37222
|
+
}
|
|
37223
|
+
} finally {
|
|
37224
|
+
if (handle)
|
|
37225
|
+
await rm6(tempPath, { force: true }).catch(() => {
|
|
37226
|
+
});
|
|
37227
|
+
}
|
|
37228
|
+
}
|
|
37229
|
+
async function writeExclusiveText2(path5, text2) {
|
|
37151
37230
|
const handle = await open9(path5, "wx", 384);
|
|
37152
37231
|
let createdStat;
|
|
37153
37232
|
try {
|
|
@@ -37156,6 +37235,8 @@ async function createExclusiveText2(path5, text2) {
|
|
|
37156
37235
|
createdStat = void 0;
|
|
37157
37236
|
}
|
|
37158
37237
|
try {
|
|
37238
|
+
if (leaseCreationTestHooks2?.beforeWrite)
|
|
37239
|
+
await leaseCreationTestHooks2.beforeWrite(path5);
|
|
37159
37240
|
await handle.writeFile(text2, "utf8");
|
|
37160
37241
|
} catch (error) {
|
|
37161
37242
|
try {
|
|
@@ -37530,7 +37611,7 @@ async function acquireRefreshFileLockWithClock2(options) {
|
|
|
37530
37611
|
if (windowsPrivateFiles2)
|
|
37531
37612
|
await createPrivateBytes2(evictOwnerPath, bytes);
|
|
37532
37613
|
else
|
|
37533
|
-
await
|
|
37614
|
+
await writeExclusiveText2(evictOwnerPath, bytes);
|
|
37534
37615
|
} catch (error) {
|
|
37535
37616
|
const stillOurs = await removeOwnMarkerAfterFailedOwnerWrite(created, deadline);
|
|
37536
37617
|
if (isLostMarkerRaceError2(error) && !stillOurs)
|
|
@@ -54399,32 +54480,61 @@ function reportRouting(input2) {
|
|
|
54399
54480
|
const report = handle.report;
|
|
54400
54481
|
if (typeof report !== "function")
|
|
54401
54482
|
return;
|
|
54402
|
-
const identity3 = {
|
|
54403
|
-
account_id: input2.accountId,
|
|
54404
|
-
...input2.credentialId !== void 0 ? { credential_id: input2.credentialId } : {}
|
|
54405
|
-
};
|
|
54406
54483
|
let payload;
|
|
54407
|
-
|
|
54408
|
-
|
|
54409
|
-
|
|
54410
|
-
|
|
54411
|
-
|
|
54412
|
-
|
|
54413
|
-
|
|
54484
|
+
if ("kind" in input2) {
|
|
54485
|
+
switch (input2.kind) {
|
|
54486
|
+
case "turn_notes_supported": {
|
|
54487
|
+
const { model, supported } = input2;
|
|
54488
|
+
if (typeof model !== "string" || model.length === 0 || typeof supported !== "boolean")
|
|
54489
|
+
return;
|
|
54490
|
+
payload = {
|
|
54491
|
+
kind: "turn_notes_supported",
|
|
54492
|
+
model,
|
|
54493
|
+
supported
|
|
54494
|
+
};
|
|
54495
|
+
break;
|
|
54496
|
+
}
|
|
54497
|
+
case "turn_note_skipped": {
|
|
54498
|
+
const { after_tool_use_id, reason } = input2;
|
|
54499
|
+
if (typeof after_tool_use_id !== "string" || after_tool_use_id.length === 0 || reason !== "anchor_missing" && reason !== "before_user_message" && reason !== "unsupported_model" && reason !== "not_oauth")
|
|
54500
|
+
return;
|
|
54501
|
+
payload = {
|
|
54502
|
+
kind: "turn_note_skipped",
|
|
54503
|
+
after_tool_use_id,
|
|
54504
|
+
reason
|
|
54505
|
+
};
|
|
54506
|
+
break;
|
|
54507
|
+
}
|
|
54508
|
+
default:
|
|
54414
54509
|
return;
|
|
54415
|
-
|
|
54510
|
+
}
|
|
54511
|
+
} else {
|
|
54512
|
+
const identity3 = {
|
|
54513
|
+
account_id: input2.accountId,
|
|
54514
|
+
...input2.credentialId !== void 0 ? { credential_id: input2.credentialId } : {}
|
|
54515
|
+
};
|
|
54516
|
+
switch (input2.outcome) {
|
|
54517
|
+
case "served":
|
|
54518
|
+
payload = { ...identity3, outcome: "served", headers: input2.headers };
|
|
54519
|
+
break;
|
|
54520
|
+
case "exhausted": {
|
|
54521
|
+
const { window, pool } = input2;
|
|
54522
|
+
if (window !== "5h" && window !== "7d")
|
|
54523
|
+
return;
|
|
54524
|
+
if (pool !== void 0 && (typeof pool !== "string" || !/^[a-z0-9._-]{1,64}$/.test(pool)))
|
|
54525
|
+
return;
|
|
54526
|
+
payload = {
|
|
54527
|
+
...identity3,
|
|
54528
|
+
outcome: "exhausted",
|
|
54529
|
+
window,
|
|
54530
|
+
...pool ? { pool } : {},
|
|
54531
|
+
...input2.resetsAt !== void 0 ? { resets_at: input2.resetsAt } : {}
|
|
54532
|
+
};
|
|
54533
|
+
break;
|
|
54534
|
+
}
|
|
54535
|
+
default:
|
|
54416
54536
|
return;
|
|
54417
|
-
payload = {
|
|
54418
|
-
...identity3,
|
|
54419
|
-
outcome: "exhausted",
|
|
54420
|
-
window,
|
|
54421
|
-
...pool ? { pool } : {},
|
|
54422
|
-
...input2.resetsAt !== void 0 ? { resets_at: input2.resetsAt } : {}
|
|
54423
|
-
};
|
|
54424
|
-
break;
|
|
54425
54537
|
}
|
|
54426
|
-
default:
|
|
54427
|
-
return;
|
|
54428
54538
|
}
|
|
54429
54539
|
const pending = report.call(handle, payload);
|
|
54430
54540
|
if (isObject2(pending) && typeof pending.then === "function") {
|