@lousy-agents/agent-shell 5.22.21 → 5.22.23

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 (2) hide show
  1. package/dist/index.js +153 -95
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1232,7 +1232,7 @@ function sameCleanupStatValue(left, right) {
1232
1232
  return false;
1233
1233
  return sameStatValue(left, right);
1234
1234
  }
1235
- function file_identity_sameFileIdentityForCleanup(left, right, platform = process.platform) {
1235
+ function sameFileIdentityForCleanup(left, right, platform = process.platform) {
1236
1236
  if (platform !== "win32") {
1237
1237
  return sameCleanupStatValue(left.dev, right.dev) && sameCleanupStatValue(left.ino, right.ino);
1238
1238
  }
@@ -3220,19 +3220,32 @@ async function serializePathWrite(key, run) {
3220
3220
 
3221
3221
  function assertOwnedDirectory(expected, actual) {
3222
3222
  if (actual.isSymbolicLink() || !actual.isDirectory()) {
3223
- throw new FsSafeError("not-file", "directory mode target must be a real directory");
3223
+ throw new errors_FsSafeError("not-file", "directory mode target must be a real directory");
3224
3224
  }
3225
3225
  if (!sameFileIdentityForCleanup(expected, actual)) {
3226
- throw new FsSafeError("path-mismatch", "directory changed before its mode could be applied");
3226
+ throw new errors_FsSafeError("path-mismatch", "directory changed before its mode could be applied");
3227
+ }
3228
+ }
3229
+ /** The caller retains a verified native mkdir receipt and owns the descriptor lifetime. */
3230
+ function finalizeCreatedDirectoryModeSync(child, mode) {
3231
+ if (mode === undefined || !child.created || process.platform === "win32")
3232
+ return;
3233
+ const expected = strict_file_identity_inspectFileIdentitySync(() => external_node_fs_namespaceObject.fstatSync(child.fd, { bigint: true }));
3234
+ assertOwnedDirectory(expected, expected);
3235
+ external_node_fs_namespaceObject.fchmodSync(child.fd, mode & 0o7777);
3236
+ const finalized = strict_file_identity_inspectFileIdentitySync(() => external_node_fs_namespaceObject.fstatSync(child.fd, { bigint: true }), expected);
3237
+ assertOwnedDirectory(expected, finalized);
3238
+ if ((finalized.mode & 4095n) !== BigInt(mode & 0o7777)) {
3239
+ throw new errors_FsSafeError("path-mismatch", "created directory mode could not be finalized");
3227
3240
  }
3228
3241
  }
3229
3242
  /** Serializes use and close: even a queued path-based fd operation retains its descriptor. */
3230
- function directory_mode_node_ownDirectoryMode(params) {
3243
+ function ownDirectoryMode(params) {
3231
3244
  let pending = Promise.resolve();
3232
3245
  let closing;
3233
3246
  const enqueue = (run) => {
3234
3247
  if (closing)
3235
- return Promise.reject(new FsSafeError("path-mismatch", "directory mode owner is closed"));
3248
+ return Promise.reject(new errors_FsSafeError("path-mismatch", "directory mode owner is closed"));
3236
3249
  const operation = pending.then(run);
3237
3250
  pending = operation.catch(() => undefined);
3238
3251
  return operation;
@@ -3285,7 +3298,7 @@ function directory_mode_node_ownDirectoryMode(params) {
3285
3298
  throw dispatchDeadlineFailure.error;
3286
3299
  checks.check?.();
3287
3300
  if (!params.ignoreChmodError && finalMode !== mode) {
3288
- throw new FsSafeError("path-mismatch", "directory final mode could not be verified");
3301
+ throw new errors_FsSafeError("path-mismatch", "directory final mode could not be verified");
3289
3302
  }
3290
3303
  }),
3291
3304
  close() {
@@ -3333,7 +3346,7 @@ async function pinNodeDirectoryForMode(dirPath, options = {}) {
3333
3346
  assertOwner(expected);
3334
3347
  if (process.platform === "win32") {
3335
3348
  // POSIX mode enforcement is unsupported; retain strict path identity checks.
3336
- return directory_mode_node_ownDirectoryMode({
3349
+ return ownDirectoryMode({
3337
3350
  inspect: async () => { assertOwner(await inspectDirectoryIdentity(dirPath, expected)); return 0; },
3338
3351
  chmod: async () => undefined, close: async () => undefined, ignoreChmodError: true,
3339
3352
  });
@@ -3380,7 +3393,7 @@ async function pinNodeDirectoryForMode(dirPath, options = {}) {
3380
3393
  assertOwner(followed);
3381
3394
  };
3382
3395
  const observeCanonical = observer;
3383
- const owner = directory_mode_node_ownDirectoryMode({
3396
+ const owner = ownDirectoryMode({
3384
3397
  inspect,
3385
3398
  inspectCanonical: observeCanonical ? () => {
3386
3399
  const observed = observeCanonical();
@@ -4559,7 +4572,7 @@ function creation_boundary_assertPrivateCreationFile(stat, fd) {
4559
4572
  assertDarwinCreationAcl(fd);
4560
4573
  }
4561
4574
  function assertRecordedFile(current, identity) {
4562
- if (!current.isFile() || current.isSymbolicLink() || !file_identity_sameFileIdentityForCleanup(current, identity)) {
4575
+ if (!current.isFile() || current.isSymbolicLink() || !sameFileIdentityForCleanup(current, identity)) {
4563
4576
  throw new errors_FsSafeError("path-mismatch", "created file cleanup preserved a replacement");
4564
4577
  }
4565
4578
  }
@@ -5339,7 +5352,7 @@ function exclusive_create_assertExclusiveCreateLeaf(pathname) {
5339
5352
 
5340
5353
 
5341
5354
 
5342
- function* atomic_io_wait(value) {
5355
+ function* wait(value) {
5343
5356
  return (yield value);
5344
5357
  }
5345
5358
  async function runAsync(procedure) {
@@ -5364,7 +5377,7 @@ function runSync(procedure) {
5364
5377
  step = procedure.next(step.value);
5365
5378
  return step.value;
5366
5379
  }
5367
- function atomic_io_inspectAtomicIdentity(io, read, expected, synchronous = false, admit) {
5380
+ function inspectAtomicIdentity(io, read, expected, synchronous = false, admit) {
5368
5381
  if (io.asynchronous && !synchronous) {
5369
5382
  const inspect = admit ? async () => {
5370
5383
  const stat = await read();
@@ -5416,7 +5429,7 @@ class AtomicIo {
5416
5429
  }
5417
5430
  }
5418
5431
  const resource = this.asyncFs
5419
- ? yield* atomic_io_wait(withMode
5432
+ ? yield* wait(withMode
5420
5433
  ? this.asyncFs.open(pathname, flags, mode)
5421
5434
  : this.asyncFs.open(pathname, flags))
5422
5435
  : withMode
@@ -5429,7 +5442,7 @@ class AtomicIo {
5429
5442
  return this.syncFs.lstatSync(pathname);
5430
5443
  if (this.asyncFs === promises_namespaceObject)
5431
5444
  return external_node_fs_namespaceObject.lstatSync(pathname);
5432
- return yield* atomic_io_wait(this.asyncFs.lstat(pathname));
5445
+ return yield* wait(this.asyncFs.lstat(pathname));
5433
5446
  }
5434
5447
  lstatExact(pathname, synchronousBuiltin = true) {
5435
5448
  if (!this.asyncFs)
@@ -5441,34 +5454,40 @@ class AtomicIo {
5441
5454
  *mkdir(directory, mode) {
5442
5455
  if (this.asyncFs) {
5443
5456
  const pathname = this.asyncFs === promises_namespaceObject ? recursiveMkdirPath(directory) : directory;
5444
- yield* atomic_io_wait(this.asyncFs.mkdir(pathname, { recursive: true, mode }));
5457
+ yield* wait(this.asyncFs.mkdir(pathname, { recursive: true, mode }));
5445
5458
  }
5446
5459
  else {
5447
5460
  const pathname = this.syncFs === external_node_fs_namespaceObject ? recursiveMkdirPath(directory) : directory;
5448
5461
  this.syncFs.mkdirSync(pathname, { recursive: true, mode });
5449
5462
  }
5450
5463
  }
5464
+ *mkdirExclusive(directory, mode) {
5465
+ if (this.asyncFs)
5466
+ yield* wait(this.asyncFs.mkdir(directory, { recursive: false, mode }));
5467
+ else
5468
+ this.syncFs.mkdirSync(directory, { recursive: false, mode });
5469
+ }
5451
5470
  *rename(source, destination) {
5452
5471
  if (this.asyncFs)
5453
- yield* atomic_io_wait(this.asyncFs.rename(source, destination));
5472
+ yield* wait(this.asyncFs.rename(source, destination));
5454
5473
  else
5455
5474
  this.syncFs.renameSync(source, destination);
5456
5475
  }
5457
5476
  *remove(pathname) {
5458
5477
  if (this.asyncFs)
5459
- yield* atomic_io_wait(this.asyncFs.rm(pathname, { force: true }));
5478
+ yield* wait(this.asyncFs.rm(pathname, { force: true }));
5460
5479
  else
5461
5480
  this.syncFs.rmSync(pathname, { force: true });
5462
5481
  }
5463
5482
  *unlink(pathname) {
5464
5483
  if (this.asyncFs)
5465
- yield* atomic_io_wait(this.asyncFs.unlink(pathname));
5484
+ yield* wait(this.asyncFs.unlink(pathname));
5466
5485
  else
5467
5486
  this.syncFs.unlinkSync(pathname);
5468
5487
  }
5469
5488
  *delay(milliseconds) {
5470
5489
  if (this.asynchronous)
5471
- yield* atomic_io_wait(sleep(milliseconds));
5490
+ yield* wait(sleep(milliseconds));
5472
5491
  else
5473
5492
  sleepSync(milliseconds);
5474
5493
  }
@@ -5488,7 +5507,7 @@ class AtomicFile {
5488
5507
  return this.io.syncFs.fstatSync(this.resource);
5489
5508
  if (this.io.asyncFs === promises_namespaceObject)
5490
5509
  return external_node_fs_namespaceObject.fstatSync(this.resource.fd);
5491
- return yield* atomic_io_wait(this.resource.stat());
5510
+ return yield* wait(this.resource.stat());
5492
5511
  }
5493
5512
  statExact() {
5494
5513
  if (typeof this.resource === "number")
@@ -5507,7 +5526,7 @@ class AtomicFile {
5507
5526
  if (typeof this.resource === "number")
5508
5527
  this.io.syncFs.fsyncSync(this.resource);
5509
5528
  else
5510
- yield* atomic_io_wait(this.resource.sync());
5529
+ yield* wait(this.resource.sync());
5511
5530
  }
5512
5531
  *syncBestEffort() {
5513
5532
  try {
@@ -5540,7 +5559,7 @@ class AtomicFile {
5540
5559
  }
5541
5560
  *readFile(sizeHint) {
5542
5561
  if (typeof this.resource !== "number")
5543
- return yield* atomic_io_wait(readFileHandleBounded(this.resource, Infinity));
5562
+ return yield* wait(readFileHandleBounded(this.resource, Infinity));
5544
5563
  if (sizeHint === undefined)
5545
5564
  return this.io.syncFs.readFileSync(this.resource);
5546
5565
  const fd = this.resource;
@@ -5570,7 +5589,7 @@ class AtomicFile {
5570
5589
  if (typeof this.resource === "number")
5571
5590
  this.io.syncFs.ftruncateSync(this.resource, length);
5572
5591
  else
5573
- yield* atomic_io_wait(this.resource.truncate(length));
5592
+ yield* wait(this.resource.truncate(length));
5574
5593
  }
5575
5594
  }
5576
5595
 
@@ -5605,14 +5624,14 @@ function* replace_file_descriptor_syncDirectoryBestEffort(io, dirPath) {
5605
5624
  }
5606
5625
  }
5607
5626
  function replace_file_descriptor_directoryOpenFlags() {
5608
- return (syncFs.constants.O_RDONLY |
5609
- syncFs.constants.O_DIRECTORY |
5610
- syncFs.constants.O_NOFOLLOW |
5611
- syncFs.constants.O_NONBLOCK);
5627
+ return (external_node_fs_namespaceObject.constants.O_RDONLY |
5628
+ external_node_fs_namespaceObject.constants.O_DIRECTORY |
5629
+ external_node_fs_namespaceObject.constants.O_NOFOLLOW |
5630
+ external_node_fs_namespaceObject.constants.O_NONBLOCK);
5612
5631
  }
5613
5632
  function assertDirectory(identity, dirPath) {
5614
5633
  if (identity.isSymbolicLink() || !identity.isDirectory()) {
5615
- throw new FsSafeError("not-file", `Atomic replace parent must be a real directory: ${dirPath}`);
5634
+ throw new errors_FsSafeError("not-file", `Atomic replace parent must be a real directory: ${dirPath}`);
5616
5635
  }
5617
5636
  return identity;
5618
5637
  }
@@ -5623,16 +5642,16 @@ async function pinDirectoryForMode(params) {
5623
5642
  if (process.platform === "win32") {
5624
5643
  return;
5625
5644
  }
5626
- const expected = params.fsModule === fs
5627
- ? inspectFileIdentitySync(() => assertDirectory(syncFs.lstatSync(params.dirPath, { bigint: true }), params.dirPath))
5628
- : await inspectFileIdentity(async () => assertDirectory(await params.fsModule.lstat(params.dirPath, { bigint: true }), params.dirPath));
5645
+ const expected = params.expectedIdentity ?? (params.fsModule === promises_namespaceObject
5646
+ ? strict_file_identity_inspectFileIdentitySync(() => assertDirectory(external_node_fs_namespaceObject.lstatSync(params.dirPath, { bigint: true }), params.dirPath))
5647
+ : await strict_file_identity_inspectFileIdentity(async () => assertDirectory(await params.fsModule.lstat(params.dirPath, { bigint: true }), params.dirPath)));
5629
5648
  const handle = await params.fsModule.open(params.dirPath, replace_file_descriptor_directoryOpenFlags());
5630
5649
  try {
5631
5650
  const owner = ownDirectoryMode({
5632
5651
  async inspect() {
5633
- const opened = params.fsModule === fs
5634
- ? inspectFileIdentitySync(() => assertDirectory(syncFs.fstatSync(handle.fd, { bigint: true }), params.dirPath), expected)
5635
- : await inspectFileIdentity(async () => assertDirectory(await handle.stat({ bigint: true }), params.dirPath), expected);
5652
+ const opened = params.fsModule === promises_namespaceObject
5653
+ ? strict_file_identity_inspectFileIdentitySync(() => assertDirectory(external_node_fs_namespaceObject.fstatSync(handle.fd, { bigint: true }), params.dirPath), expected)
5654
+ : await strict_file_identity_inspectFileIdentity(async () => assertDirectory(await handle.stat({ bigint: true }), params.dirPath), expected);
5636
5655
  return Number(opened.mode & 4095n);
5637
5656
  },
5638
5657
  chmod: (mode) => {
@@ -5663,7 +5682,7 @@ function* applyDirectoryMode(io, params) {
5663
5682
  }));
5664
5683
  let primary;
5665
5684
  try {
5666
- if (owner)
5685
+ if (owner && params.mode !== "preserve")
5667
5686
  yield* wait(owner.apply(params.mode));
5668
5687
  }
5669
5688
  catch (error) {
@@ -5684,13 +5703,15 @@ function* applyDirectoryMode(io, params) {
5684
5703
  if (process.platform === "win32")
5685
5704
  return;
5686
5705
  const admit = (stat) => assertDirectory(stat, params.dirPath);
5687
- const expected = inspectAtomicIdentity(io, () => io.lstatExact(params.dirPath), undefined, false, admit);
5706
+ const expected = params.expectedIdentity ?? inspectAtomicIdentity(io, () => io.lstatExact(params.dirPath), undefined, false, admit);
5688
5707
  const file = yield* io.open(params.dirPath, replace_file_descriptor_directoryOpenFlags());
5689
5708
  let primary;
5690
5709
  try {
5691
5710
  inspectAtomicIdentity(io, () => file.statExact(), expected, false, admit);
5692
- params.mutation?.assert();
5693
- file.chmod(params.mode & 0o7777);
5711
+ if (params.mode !== "preserve") {
5712
+ params.mutation?.assert();
5713
+ file.chmod(params.mode & 0o7777);
5714
+ }
5694
5715
  }
5695
5716
  catch (error) {
5696
5717
  primary = { error };
@@ -5709,7 +5730,7 @@ function* writeTempFile(io, params) {
5709
5730
  params.mutation?.assert();
5710
5731
  const file = yield* io.open(params.tempPath, "wx", params.mode);
5711
5732
  try {
5712
- const openedInspection = atomic_io_inspectAtomicIdentity(io, () => file.statExact());
5733
+ const openedInspection = inspectAtomicIdentity(io, () => file.statExact());
5713
5734
  const identity = (io.asynchronous ? (yield openedInspection) : openedInspection);
5714
5735
  params.onIdentity?.(identity);
5715
5736
  params.mutation?.assert();
@@ -5718,7 +5739,7 @@ function* writeTempFile(io, params) {
5718
5739
  yield writing;
5719
5740
  if ((io.asyncFs === promises_namespaceObject || (process.platform === "win32" && io.syncFs === external_node_fs_namespaceObject)) && !params.sync) {
5720
5741
  // Matching non-durable writes have no I/O left after this identity fence.
5721
- const current = atomic_io_inspectAtomicIdentity(io, () => file.statExact(), identity, true);
5742
+ const current = inspectAtomicIdentity(io, () => file.statExact(), identity, true);
5722
5743
  const modeMask = process.platform === "win32" ? 0o200 : 0o7777;
5723
5744
  if (Number(current.mode & BigInt(modeMask)) === (params.mode & modeMask))
5724
5745
  return { file, identity };
@@ -5728,7 +5749,7 @@ function* writeTempFile(io, params) {
5728
5749
  yield chmod;
5729
5750
  if (params.sync)
5730
5751
  yield* file.syncBestEffort();
5731
- const currentInspection = atomic_io_inspectAtomicIdentity(io, () => file.statExact(), identity);
5752
+ const currentInspection = inspectAtomicIdentity(io, () => file.statExact(), identity);
5732
5753
  if (io.asynchronous)
5733
5754
  yield currentInspection;
5734
5755
  return { file, identity };
@@ -5774,7 +5795,7 @@ async function removeOwnedPath(params) {
5774
5795
  if (current.isSymbolicLink() ||
5775
5796
  !current.isFile() ||
5776
5797
  current.nlink !== 1n ||
5777
- !file_identity_sameFileIdentityForCleanup(current, params.identity)) {
5798
+ !sameFileIdentityForCleanup(current, params.identity)) {
5778
5799
  return "preserved";
5779
5800
  }
5780
5801
  await promises_namespaceObject.unlink(params.pathname);
@@ -5797,11 +5818,11 @@ async function cleanupPinnedFilePath(params) {
5797
5818
  await assertAsyncDirectoryGuard(guard);
5798
5819
  const parent = external_node_fs_namespaceObject.lstatSync(guard.dir, { bigint: true });
5799
5820
  if (parent.isSymbolicLink() || !parent.isDirectory() ||
5800
- !file_identity_sameFileIdentityForCleanup(parent, guard.stat))
5821
+ !sameFileIdentityForCleanup(parent, guard.stat))
5801
5822
  return "preserved";
5802
5823
  const opened = external_node_fs_namespaceObject.fstatSync(params.handle.fd, { bigint: true });
5803
5824
  if (!opened.isFile() || opened.nlink !== 1n ||
5804
- !file_identity_sameFileIdentityForCleanup(opened, params.identity))
5825
+ !sameFileIdentityForCleanup(opened, params.identity))
5805
5826
  return "preserved";
5806
5827
  }
5807
5828
  catch (error) {
@@ -5936,7 +5957,7 @@ function pathStillMatchesReceipt(entry) {
5936
5957
  try {
5937
5958
  const current = external_node_fs_namespaceObject.lstatSync(entry.path, { bigint: true });
5938
5959
  return (!entry.singleLinkFile || (current.isFile() && current.nlink === 1n)) &&
5939
- file_identity_sameFileIdentityForCleanup(current, entry.identity);
5960
+ sameFileIdentityForCleanup(current, entry.identity);
5940
5961
  }
5941
5962
  catch {
5942
5963
  // A missing pathname grants no authority over an entry created after this lookup.
@@ -6040,7 +6061,7 @@ async function removePathIfIdentityUnchanged(targetPath, identity) {
6040
6061
  const parentGuard = await directory_guard_createAsyncDirectoryGuard(external_node_path_namespaceObject.dirname(targetPath), { bigint: true });
6041
6062
  await withAsyncDirectoryGuards([parentGuard], async () => {
6042
6063
  const current = external_node_fs_namespaceObject.lstatSync(targetPath, { bigint: true });
6043
- if (current.isSymbolicLink() || !current.isFile() || !file_identity_sameFileIdentityForCleanup(current, identity))
6064
+ if (current.isSymbolicLink() || !current.isFile() || !sameFileIdentityForCleanup(current, identity))
6044
6065
  return;
6045
6066
  await promises_namespaceObject.unlink(targetPath);
6046
6067
  });
@@ -6115,7 +6136,7 @@ class AtomicTempOwner {
6115
6136
  this.onIdentity(temp.identity);
6116
6137
  }
6117
6138
  inspectOwned(read, pathname, pathnameEntry, expected) {
6118
- return atomic_io_inspectAtomicIdentity(this.io, read, expected, false, stat => assertOwnedFile(stat, pathname, pathnameEntry));
6139
+ return inspectAtomicIdentity(this.io, read, expected, false, stat => assertOwnedFile(stat, pathname, pathnameEntry));
6119
6140
  }
6120
6141
  *assertCurrent(pathname = this.pathname) {
6121
6142
  const openedInspection = this.inspectOwned(() => this.resource.statExact(), pathname, false, this.identity);
@@ -6195,9 +6216,9 @@ class AtomicTempOwner {
6195
6216
  try {
6196
6217
  const observation = this.io.lstatExact(this.pathname);
6197
6218
  const current = this.io.asyncFs && this.io.asyncFs !== promises_namespaceObject
6198
- ? yield* atomic_io_wait(observation) : observation;
6219
+ ? yield* wait(observation) : observation;
6199
6220
  if (!current.isSymbolicLink() && current.isFile() && current.nlink === 1n &&
6200
- file_identity_sameFileIdentityForCleanup(current, identity)) {
6221
+ sameFileIdentityForCleanup(current, identity)) {
6201
6222
  yield* this.io.unlink(this.pathname);
6202
6223
  }
6203
6224
  return true;
@@ -6268,7 +6289,7 @@ function probeEntry(directory, name, names) {
6268
6289
  original = strict_file_identity_inspectFileIdentitySync(() => external_node_fs_namespaceObject.lstatSync(originalPath, { bigint: true }));
6269
6290
  try {
6270
6291
  const other = strict_file_identity_inspectFileIdentitySync(() => external_node_fs_namespaceObject.lstatSync(external_node_path_namespaceObject.join(directory, alternate), { bigint: true }));
6271
- const sameIdentity = file_identity_sameFileIdentityForCleanup(original, other);
6292
+ const sameIdentity = sameFileIdentityForCleanup(original, other);
6272
6293
  if (sameIdentity || bothListed) {
6273
6294
  // Matching inodes can belong to newly linked case-distinct names.
6274
6295
  const currentNames = new Set(external_node_fs_namespaceObject.readdirSync(directory));
@@ -10002,7 +10023,7 @@ async function withNativeDirectory(params, operation, discard) {
10002
10023
  }
10003
10024
  }
10004
10025
  /** Admit only an ordinary direct child; aliases keep the full resolver. */
10005
- function tryMkdirNativeDirectChild(root, relativePath) {
10026
+ function tryMkdirNativeDirectChild(root, relativePath, mode) {
10006
10027
  if (!isSafePathSegment(relativePath, { allowDotPrefix: true }) || relativePath.endsWith(".") ||
10007
10028
  getFsSafeTestHooks()?.beforeRootFallbackMutation)
10008
10029
  return false;
@@ -10018,7 +10039,7 @@ function tryMkdirNativeDirectChild(root, relativePath) {
10018
10039
  return false;
10019
10040
  }
10020
10041
  try {
10021
- mkdirNativeRootChild({ root, target });
10042
+ mkdirNativeRootChild({ root, target }, mode);
10022
10043
  return true;
10023
10044
  }
10024
10045
  catch (error) {
@@ -10127,7 +10148,7 @@ function ensureNativeRootCurrentLegacy(root, binding) {
10127
10148
  root_create_native_disposeResources(env_4);
10128
10149
  }
10129
10150
  }
10130
- function mkdirNativeRootChild(params) {
10151
+ function mkdirNativeRootChild(params, mode) {
10131
10152
  const env_5 = { stack: [], error: void 0, hasError: false };
10132
10153
  try {
10133
10154
  const binding = native_getNativeBinding("openBeneath", "mkdirChildBeneath");
@@ -10137,19 +10158,28 @@ function mkdirNativeRootChild(params) {
10137
10158
  rootPath: params.root.rootReal, rootIdentity: params.root.rootIdentity,
10138
10159
  }), false);
10139
10160
  verifyMkdirDirectory(binding, rootOwner.fd, params.root.rootReal);
10140
- const flags = (nodeDirectorySearchOnlyFlags()?.flags ?? external_node_fs_namespaceObject.constants.O_RDONLY) |
10161
+ const flags = (mode === undefined ? nodeDirectorySearchOnlyFlags()?.flags ?? external_node_fs_namespaceObject.constants.O_RDONLY : external_node_fs_namespaceObject.constants.O_RDONLY) |
10141
10162
  (external_node_fs_namespaceObject.constants.O_DIRECTORY ?? 0) | (external_node_fs_namespaceObject.constants.O_NOFOLLOW ?? 0);
10142
10163
  const name = external_node_path_namespaceObject.basename(params.target);
10143
10164
  // The admitted Root is already this operation's immediate parent. Retain
10144
10165
  // both handles through the same fresh pathname and canonical identity fences.
10145
10166
  const child = binding.mkdirOpenChildBeneath
10146
- ? binding.mkdirOpenChildBeneath(rootOwner.fd, name, 0o777, flags).fd
10147
- : (binding.mkdirChildBeneath(rootOwner.fd, name, 0o777), binding.openBeneath(rootOwner.fd, name, flags).fd);
10167
+ ? binding.mkdirOpenChildBeneath(rootOwner.fd, name, mode ?? 0o777, flags)
10168
+ : {
10169
+ created: binding.mkdirChildBeneath(rootOwner.fd, name, mode ?? 0o777),
10170
+ fd: binding.openBeneath(rootOwner.fd, name, flags).fd,
10171
+ };
10148
10172
  const close = captureNativeFdClose(binding);
10149
- const childOwner = root_create_native_addDisposableResource(env_5, { [Symbol.dispose]() { close(child); } }, false);
10173
+ const childOwner = root_create_native_addDisposableResource(env_5, { [Symbol.dispose]() { close(child.fd); } }, false);
10150
10174
  root_context_assertRootIdentityCurrentSync(params.root);
10151
- verifyMkdirDirectory(binding, child, params.target);
10175
+ verifyMkdirDirectory(binding, child.fd, params.target);
10152
10176
  verifyMkdirDirectory(binding, rootOwner.fd, params.root.rootReal);
10177
+ if (mode !== undefined && child.created) {
10178
+ finalizeCreatedDirectoryModeSync(child, mode);
10179
+ verifyMkdirDirectory(binding, child.fd, params.target);
10180
+ verifyMkdirDirectory(binding, rootOwner.fd, params.root.rootReal);
10181
+ root_context_assertRootIdentityCurrentSync(params.root);
10182
+ }
10153
10183
  }
10154
10184
  catch (e_5) {
10155
10185
  env_5.error = e_5;
@@ -10517,7 +10547,7 @@ function removeSiblingIfOwned(params) {
10517
10547
  if (current.isSymbolicLink() ||
10518
10548
  !current.isFile() ||
10519
10549
  (current.nlink !== 1n && current.nlink !== 2n) ||
10520
- !file_identity_sameFileIdentityForCleanup(current, params.identity)) {
10550
+ !sameFileIdentityForCleanup(current, params.identity)) {
10521
10551
  throw pathMismatch("isolated producer sibling changed before cleanup");
10522
10552
  }
10523
10553
  external_node_fs_namespaceObject.unlinkSync(params.targetPath);
@@ -11219,6 +11249,8 @@ async function createPrivateWindowsFileHandle(selected, options) {
11219
11249
 
11220
11250
 
11221
11251
 
11252
+
11253
+
11222
11254
  function sameDirectoryFacts(left, right) {
11223
11255
  return left.dev === right.dev && left.ino === right.ino && left.mode === right.mode &&
11224
11256
  left.nlink === right.nlink;
@@ -11478,6 +11510,13 @@ async function mkdirPathComponentsWithGuards(params) {
11478
11510
  if (!createdAuthorization || !createdEvidence) {
11479
11511
  directory_guard_assertDirectoryGuard(parentGuard, "native");
11480
11512
  }
11513
+ if (created && params.finalizeCreatedMode && params.mode !== undefined) {
11514
+ await runAsync(applyDirectoryMode(AtomicIo.async(promises_namespaceObject), {
11515
+ dirPath: currentGuard.dir, mode: params.mode, expectedIdentity: currentGuard.stat,
11516
+ }));
11517
+ directory_guard_assertDirectoryGuard(parentGuard, "native");
11518
+ directory_guard_assertDirectoryGuard(currentGuard, "native");
11519
+ }
11481
11520
  current = admittedNextPath;
11482
11521
  }
11483
11522
  return current;
@@ -12280,9 +12319,9 @@ function removeNativeCreatedFileIfStillPinned(params) {
12280
12319
  const targetPath = external_node_path_namespaceObject.join(params.parentPath, params.basename);
12281
12320
  const target = external_node_fs_namespaceObject.lstatSync(targetPath, { bigint: true });
12282
12321
  if (!parentPathStat.isSymbolicLink() && parentPathStat.isDirectory() &&
12283
- file_identity_sameFileIdentityForCleanup(parentPathStat, parentFdStat) &&
12322
+ sameFileIdentityForCleanup(parentPathStat, parentFdStat) &&
12284
12323
  !target.isSymbolicLink() && target.isFile() &&
12285
- file_identity_sameFileIdentityForCleanup(target, params.created)) {
12324
+ sameFileIdentityForCleanup(target, params.created)) {
12286
12325
  external_node_fs_namespaceObject.rmSync(targetPath);
12287
12326
  }
12288
12327
  }
@@ -13980,7 +14019,7 @@ function sidecarLockSnapshotMatches(current, observed) {
13980
14019
  }
13981
14020
  if (observed.stat &&
13982
14021
  current.stat &&
13983
- !file_identity_sameFileIdentityForCleanup(observed.stat, current.stat)) {
14022
+ !sameFileIdentityForCleanup(observed.stat, current.stat)) {
13984
14023
  return false;
13985
14024
  }
13986
14025
  if (observed.raw !== undefined) {
@@ -14746,7 +14785,7 @@ function cleanupCreatedSidecar(lockPath, raw, fd, parent, identity) {
14746
14785
  throw new errors_FsSafeError("helper-unavailable", "creator cleanup is unavailable");
14747
14786
  }
14748
14787
  const entry = parent.binding.rootRemovalStat(parent.fd, name);
14749
- if (entry.directory || entry.symlink || !file_identity_sameFileIdentityForCleanup(identity, entry))
14788
+ if (entry.directory || entry.symlink || !sameFileIdentityForCleanup(identity, entry))
14750
14789
  throw sidecar_lock_retained_mismatch("identity");
14751
14790
  }
14752
14791
  else if (!parent.binding.stagedFileMatches || !parent.binding.removeStagedFile) {
@@ -14762,7 +14801,7 @@ function cleanupCreatedSidecar(lockPath, raw, fd, parent, identity) {
14762
14801
  throw error;
14763
14802
  }
14764
14803
  const stat = external_node_fs_namespaceObject.fstatSync(fd, { bigint: true });
14765
- if (!stat.isFile() || stat.nlink !== 1n || !file_identity_sameFileIdentityForCleanup(identity, stat))
14804
+ if (!stat.isFile() || stat.nlink !== 1n || !sameFileIdentityForCleanup(identity, stat))
14766
14805
  throw sidecar_lock_retained_mismatch("identity");
14767
14806
  assertOwnerRecord(fd, Buffer.from(raw));
14768
14807
  if (windows) {
@@ -14820,7 +14859,7 @@ function retainCreatedSidecar(lockPath, raw, createdFd, guard, nativeParent) {
14820
14859
  let fd;
14821
14860
  try {
14822
14861
  const parentStat = external_node_fs_namespaceObject.fstatSync(parentFd, { bigint: true });
14823
- if (!parentStat.isDirectory() || !file_identity_sameFileIdentityForCleanup(guard.stat, parentStat))
14862
+ if (!parentStat.isDirectory() || !sameFileIdentityForCleanup(guard.stat, parentStat))
14824
14863
  throw sidecar_lock_retained_mismatch("identity");
14825
14864
  fd = binding.openBeneath(parentFd, name, nativeOpenFlags(external_node_fs_namespaceObject.constants.O_RDONLY | external_node_fs_namespaceObject.constants.O_NONBLOCK)).fd;
14826
14865
  const ownedFd = fd;
@@ -14835,7 +14874,7 @@ function retainCreatedSidecar(lockPath, raw, createdFd, guard, nativeParent) {
14835
14874
  throw error;
14836
14875
  }
14837
14876
  const current = external_node_fs_namespaceObject.fstatSync(ownedFd, { bigint: true });
14838
- if (!current.isFile() || current.nlink !== 1n || !file_identity_sameFileIdentityForCleanup(created, current))
14877
+ if (!current.isFile() || current.nlink !== 1n || !sameFileIdentityForCleanup(created, current))
14839
14878
  throw sidecar_lock_retained_mismatch("identity");
14840
14879
  return true;
14841
14880
  };
@@ -15262,7 +15301,7 @@ async function acquireSidecarLock(options, context) {
15262
15301
  }
15263
15302
  const snapshot = { raw, payload, stat: external_node_fs_namespaceObject.fstatSync(handle.fd, { bigint: true }), ownershipToken };
15264
15303
  createdSnapshot = snapshot;
15265
- if (retainedSidecar && !file_identity_sameFileIdentityForCleanup(retainedSidecar.identity, snapshot.stat)) {
15304
+ if (retainedSidecar && !sameFileIdentityForCleanup(retainedSidecar.identity, snapshot.stat)) {
15266
15305
  throw new errors_FsSafeError("path-mismatch", "created sidecar lock identity changed before admission");
15267
15306
  }
15268
15307
  if (snapshot.stat.nlink === 0n) {
@@ -15538,7 +15577,7 @@ function snapshotMatchesSync(lockPath, observed) {
15538
15577
  const openedStat = external_node_fs_namespaceObject.fstatSync(fd, { bigint: true });
15539
15578
  // Token-owned files can have different descriptor/path identities on VirtioFS.
15540
15579
  // Require a known descriptor identity without rejecting that supported drift.
15541
- if (!openedStat.isFile() || !file_identity_sameFileIdentityForCleanup(openedStat, openedStat)) {
15580
+ if (!openedStat.isFile() || !sameFileIdentityForCleanup(openedStat, openedStat)) {
15542
15581
  return false;
15543
15582
  }
15544
15583
  if (observed.raw !== undefined && openedStat.size !== BigInt(Buffer.byteLength(observed.raw))) {
@@ -15546,7 +15585,7 @@ function snapshotMatchesSync(lockPath, observed) {
15546
15585
  }
15547
15586
  const raw = external_node_fs_namespaceObject.readFileSync(fd, "utf8");
15548
15587
  const afterStat = external_node_fs_namespaceObject.lstatSync(lockPath, { bigint: true });
15549
- if (!afterStat.isFile() || !file_identity_sameFileIdentityForCleanup(beforeStat, afterStat)) {
15588
+ if (!afterStat.isFile() || !sameFileIdentityForCleanup(beforeStat, afterStat)) {
15550
15589
  return false;
15551
15590
  }
15552
15591
  return sidecarLockSnapshotMatches({ raw, payload: null, stat: afterStat }, observed);
@@ -15821,8 +15860,8 @@ async function publishCopyStage(params) {
15821
15860
  const staged = external_node_fs_namespaceObject.lstatSync(temporaryPath, { bigint: true });
15822
15861
  const opened = external_node_fs_namespaceObject.fstatSync(params.fd, { bigint: true });
15823
15862
  if (!staged.isFile() || staged.isSymbolicLink() || staged.nlink !== 1n ||
15824
- !file_identity_sameFileIdentityForCleanup(staged, identity) ||
15825
- !file_identity_sameFileIdentityForCleanup(opened, identity)) {
15863
+ !sameFileIdentityForCleanup(staged, identity) ||
15864
+ !sameFileIdentityForCleanup(opened, identity)) {
15826
15865
  throw new errors_FsSafeError("path-mismatch", "exclusive copy stage changed before publication");
15827
15866
  }
15828
15867
  };
@@ -15863,7 +15902,7 @@ async function publishCopyStage(params) {
15863
15902
  }
15864
15903
  const target = external_node_fs_namespaceObject.lstatSync(targetPath, { bigint: true });
15865
15904
  if (!target.isFile() || target.isSymbolicLink() || target.nlink !== 1n ||
15866
- !file_identity_sameFileIdentityForCleanup(target, identity)) {
15905
+ !sameFileIdentityForCleanup(target, identity)) {
15867
15906
  throw new errors_FsSafeError("path-mismatch", "renamed copy target changed after publication");
15868
15907
  }
15869
15908
  }
@@ -15874,10 +15913,10 @@ async function publishCopyStage(params) {
15874
15913
  const current = external_node_fs_namespaceObject.lstatSync(temporaryPath, { bigint: true });
15875
15914
  const target = external_node_fs_namespaceObject.lstatSync(targetPath, { bigint: true });
15876
15915
  if (parent.isSymbolicLink() || !parent.isDirectory() ||
15877
- !file_identity_sameFileIdentityForCleanup(parent, params.parentGuard.stat) ||
15916
+ !sameFileIdentityForCleanup(parent, params.parentGuard.stat) ||
15878
15917
  current.isSymbolicLink() || !current.isFile() || current.nlink !== 2n ||
15879
15918
  target.isSymbolicLink() || !target.isFile() || target.nlink !== 2n ||
15880
- !file_identity_sameFileIdentityForCleanup(current, identity) || !file_identity_sameFileIdentityForCleanup(target, identity)) {
15919
+ !sameFileIdentityForCleanup(current, identity) || !sameFileIdentityForCleanup(target, identity)) {
15881
15920
  throw new errors_FsSafeError("path-mismatch", "published copy temporary name changed before cleanup");
15882
15921
  }
15883
15922
  };
@@ -15901,7 +15940,7 @@ async function publishCopyStage(params) {
15901
15940
  }
15902
15941
  function isEmptyPlaceholder(current, identity) {
15903
15942
  return current.isFile() && !current.isSymbolicLink() && current.nlink === 1n &&
15904
- current.size === 0n && file_identity_sameFileIdentityForCleanup(current, identity);
15943
+ current.size === 0n && sameFileIdentityForCleanup(current, identity);
15905
15944
  }
15906
15945
  function publishThroughPlaceholder(params, assertCurrent) {
15907
15946
  const { targetPath, temporaryPath } = params;
@@ -15980,7 +16019,7 @@ async function openPublicationHandle(targetPath, identity) {
15980
16019
  const opened = external_node_fs_namespaceObject.fstatSync(handle.fd, { bigint: true });
15981
16020
  const named = external_node_fs_namespaceObject.lstatSync(targetPath, { bigint: true });
15982
16021
  if (!opened.isFile() || !named.isFile() || named.isSymbolicLink() ||
15983
- !file_identity_sameFileIdentityForCleanup(opened, identity) || !file_identity_sameFileIdentityForCleanup(named, identity)) {
16022
+ !sameFileIdentityForCleanup(opened, identity) || !sameFileIdentityForCleanup(named, identity)) {
15984
16023
  throw new errors_FsSafeError("path-mismatch", "publication descriptor handoff identity changed");
15985
16024
  }
15986
16025
  return handle;
@@ -16984,9 +17023,9 @@ var root_mkdir_native_disposeResources = (undefined && undefined.__disposeResour
16984
17023
 
16985
17024
 
16986
17025
 
16987
- function tryMkdirNativeParents(root, relativePath) {
17026
+ function tryMkdirNativeParents(root, relativePath, mode) {
16988
17027
  try {
16989
- return mkdirOrdinaryNativeParents(root, relativePath);
17028
+ return mkdirOrdinaryNativeParents(root, relativePath, mode);
16990
17029
  }
16991
17030
  catch (error) {
16992
17031
  if (hasNodeErrorCode(error, "ENOTDIR"))
@@ -16994,7 +17033,7 @@ function tryMkdirNativeParents(root, relativePath) {
16994
17033
  throw error;
16995
17034
  }
16996
17035
  }
16997
- function mkdirOrdinaryNativeParents(root, relativePath) {
17036
+ function mkdirOrdinaryNativeParents(root, relativePath, mode) {
16998
17037
  if (getFsSafeTestHooks()?.beforeRootFallbackMutation)
16999
17038
  return false;
17000
17039
  const segments = relativePath.split(external_node_path_namespaceObject.sep === "\\" ? /[\\/]/ : "/");
@@ -17019,7 +17058,7 @@ function mkdirOrdinaryNativeParents(root, relativePath) {
17019
17058
  catch (error) {
17020
17059
  // Reuse this exact Root snapshot and failed parent observation without an
17021
17060
  // intervening await. All opened ancestors still receive fresh native fences.
17022
- return hasNodeErrorCode(error, "ENOENT") ? mkdirMissingParents(root, segments, rootStat) : false;
17061
+ return hasNodeErrorCode(error, "ENOENT") ? mkdirMissingParents(root, segments, rootStat, mode) : false;
17023
17062
  }
17024
17063
  try {
17025
17064
  if (realpath_realpathSync.native(windows_path_alias_pathForWindowsFilesystem(parentPath)) !== parentPath)
@@ -17028,12 +17067,12 @@ function mkdirOrdinaryNativeParents(root, relativePath) {
17028
17067
  catch {
17029
17068
  return false;
17030
17069
  }
17031
- return mkdirExistingParent(root, segments, parentIdentity);
17070
+ return mkdirExistingParent(root, segments, parentIdentity, mode);
17032
17071
  }
17033
17072
  /** Ordinary missing suffixes need no policy callbacks or repeated path resolution. */
17034
- function mkdirMissingParents(root, segments, rootStat) {
17073
+ function mkdirMissingParents(root, segments, rootStat, mode) {
17035
17074
  const binding = native_getNativeBinding("openBeneath", "mkdirChildBeneath");
17036
- if (!binding?.openBeneath || !binding.mkdirOpenChildBeneath)
17075
+ if (!binding?.openBeneath || !binding.mkdirChildBeneath || (!binding.mkdirOpenChildBeneath && mode === undefined))
17037
17076
  return false;
17038
17077
  let parentDepth = segments.length - 2;
17039
17078
  let parentPath;
@@ -17073,7 +17112,7 @@ function mkdirMissingParents(root, segments, rootStat) {
17073
17112
  if (errors.length)
17074
17113
  throw new AggregateError(errors, "mkdir directory close failed");
17075
17114
  } }, false);
17076
- const flags = (nodeDirectorySearchOnlyFlags()?.flags ?? external_node_fs_namespaceObject.constants.O_RDONLY) |
17115
+ const flags = (mode === undefined ? nodeDirectorySearchOnlyFlags()?.flags ?? external_node_fs_namespaceObject.constants.O_RDONLY : external_node_fs_namespaceObject.constants.O_RDONLY) |
17077
17116
  (external_node_fs_namespaceObject.constants.O_DIRECTORY ?? 0) | (external_node_fs_namespaceObject.constants.O_NOFOLLOW ?? 0);
17078
17117
  let current = rootOwner.fd;
17079
17118
  if (parentDepth > 0) {
@@ -17089,12 +17128,21 @@ function mkdirMissingParents(root, segments, rootStat) {
17089
17128
  };
17090
17129
  assertCurrent();
17091
17130
  for (const segment of segments.slice(parentDepth)) {
17092
- const child = binding.mkdirOpenChildBeneath(current, segment, 0o777, flags);
17131
+ const child = binding.mkdirOpenChildBeneath
17132
+ ? binding.mkdirOpenChildBeneath(current, segment, mode ?? 0o777, flags)
17133
+ : {
17134
+ created: binding.mkdirChildBeneath(current, segment, mode ?? 0o777),
17135
+ fd: binding.openBeneath(current, segment, flags).fd,
17136
+ };
17093
17137
  parentPath = external_node_path_namespaceObject.join(parentPath, segment);
17094
17138
  directories.push({ fd: child.fd, pathname: parentPath });
17095
17139
  // Retain every ancestor until the complete suffix is admitted. The
17096
17140
  // post-create fence also precedes the next synchronous child mutation.
17097
17141
  assertCurrent();
17142
+ if (mode !== undefined && child.created) {
17143
+ finalizeCreatedDirectoryModeSync(child, mode);
17144
+ assertCurrent();
17145
+ }
17098
17146
  current = child.fd;
17099
17147
  }
17100
17148
  return true;
@@ -17113,7 +17161,7 @@ function mkdirMissingParents(root, segments, rootStat) {
17113
17161
  throw error;
17114
17162
  }
17115
17163
  }
17116
- function mkdirExistingParent(root, segments, parentIdentity) {
17164
+ function mkdirExistingParent(root, segments, parentIdentity, mode) {
17117
17165
  const env_2 = { stack: [], error: void 0, hasError: false };
17118
17166
  try {
17119
17167
  const target = external_node_path_namespaceObject.join(root.rootReal, ...segments);
@@ -17126,7 +17174,7 @@ function mkdirExistingParent(root, segments, parentIdentity) {
17126
17174
  rootPath: root.rootReal, rootIdentity: root.rootIdentity,
17127
17175
  }), false);
17128
17176
  verifyMkdirDirectory(binding, rootOwner.fd, root.rootReal);
17129
- const flags = (nodeDirectorySearchOnlyFlags()?.flags ?? external_node_fs_namespaceObject.constants.O_RDONLY) |
17177
+ const flags = (mode === undefined ? nodeDirectorySearchOnlyFlags()?.flags ?? external_node_fs_namespaceObject.constants.O_RDONLY : external_node_fs_namespaceObject.constants.O_RDONLY) |
17130
17178
  (external_node_fs_namespaceObject.constants.O_DIRECTORY ?? 0) | (external_node_fs_namespaceObject.constants.O_NOFOLLOW ?? 0);
17131
17179
  const close = captureNativeFdClose(binding);
17132
17180
  const parent = binding.openBeneath(rootOwner.fd, segments.slice(0, -1).join("/"), flags).fd;
@@ -17136,14 +17184,24 @@ function mkdirExistingParent(root, segments, parentIdentity) {
17136
17184
  root_context_assertRootIdentityCurrentSync(root);
17137
17185
  const name = segments.at(-1);
17138
17186
  const child = binding.mkdirOpenChildBeneath
17139
- ? binding.mkdirOpenChildBeneath(parent, name, 0o777, flags).fd
17140
- : (binding.mkdirChildBeneath(parent, name, 0o777), binding.openBeneath(parent, name, flags).fd);
17141
- const childOwner = root_mkdir_native_addDisposableResource(env_2, { [Symbol.dispose]() { close(child); } }, false);
17187
+ ? binding.mkdirOpenChildBeneath(parent, name, mode ?? 0o777, flags)
17188
+ : {
17189
+ created: binding.mkdirChildBeneath(parent, name, mode ?? 0o777),
17190
+ fd: binding.openBeneath(parent, name, flags).fd,
17191
+ };
17192
+ const childOwner = root_mkdir_native_addDisposableResource(env_2, { [Symbol.dispose]() { close(child.fd); } }, false);
17142
17193
  root_context_assertRootIdentityCurrentSync(root);
17143
- verifyMkdirDirectory(binding, child, target);
17194
+ verifyMkdirDirectory(binding, child.fd, target);
17144
17195
  directory_guard_inspectDirectoryIdentitySync(parentPath, parentIdentity);
17145
17196
  verifyMkdirDirectory(binding, parent, parentPath);
17146
17197
  verifyMkdirDirectory(binding, rootOwner.fd, root.rootReal);
17198
+ if (mode !== undefined && child.created) {
17199
+ finalizeCreatedDirectoryModeSync(child, mode);
17200
+ verifyMkdirDirectory(binding, child.fd, target);
17201
+ verifyMkdirDirectory(binding, parent, parentPath);
17202
+ verifyMkdirDirectory(binding, rootOwner.fd, root.rootReal);
17203
+ root_context_assertRootIdentityCurrentSync(root);
17204
+ }
17147
17205
  return true;
17148
17206
  }
17149
17207
  catch (e_2) {
@@ -18303,7 +18361,7 @@ async function assertMissingRemovalPrefixCurrent(rootGuard, intermediates) {
18303
18361
  catch (error) {
18304
18362
  throw removalAncestorChanged(error);
18305
18363
  }
18306
- if (!file_identity_sameFileIdentityForCleanup(deepestGuard.stat, deepest) ||
18364
+ if (!sameFileIdentityForCleanup(deepestGuard.stat, deepest) ||
18307
18365
  !sameCanonicalDirectory(deepestGuard.realPath, deepest.path)) {
18308
18366
  throw removalAncestorChanged();
18309
18367
  }
@@ -18328,7 +18386,7 @@ async function captureNonrecursiveRemovalAdmission(root, targetPath, options, re
18328
18386
  await assertRootIdentityCurrent(root);
18329
18387
  throw normalizeRemoveGuardError(error);
18330
18388
  }
18331
- if (!file_identity_sameFileIdentityForCleanup(rootGuard.stat, root.rootIdentity))
18389
+ if (!sameFileIdentityForCleanup(rootGuard.stat, root.rootIdentity))
18332
18390
  throw rootPathChangedError();
18333
18391
  if (parentPath === root.rootReal) {
18334
18392
  const rootAssertion = createRemovalDirectoryAssertion(rootGuard.dir, rootGuard.stat, rootGuard.realPath);
@@ -18492,7 +18550,7 @@ async function removePathInRootFallback(root, targetPath, options, receipts) {
18492
18550
  });
18493
18551
  let examined = 0;
18494
18552
  const rootGuard = await directory_guard_createAsyncDirectoryGuard(root.rootReal, { bigint: true });
18495
- if (!file_identity_sameFileIdentityForCleanup(rootGuard.stat, root.rootIdentity))
18553
+ if (!sameFileIdentityForCleanup(rootGuard.stat, root.rootIdentity))
18496
18554
  throw rootPathChangedError();
18497
18555
  const guards = [
18498
18556
  createRemovalDirectoryAssertion(rootGuard.dir, rootGuard.stat, rootGuard.realPath),
@@ -18569,7 +18627,7 @@ async function removePathInRootFallback(root, targetPath, options, receipts) {
18569
18627
  throw normalizeRemovePathError(error, details(target, "inspect"));
18570
18628
  }
18571
18629
  if (!isPathInside(directoryGuard.realPath, target) || !isPathInside(target, directoryGuard.realPath) ||
18572
- !file_identity_sameFileIdentityForCleanup(directoryGuard.stat, initial)) {
18630
+ !sameFileIdentityForCleanup(directoryGuard.stat, initial)) {
18573
18631
  throw new errors_FsSafeError("path-mismatch", "removal directory changed during operation");
18574
18632
  }
18575
18633
  guards.push(createRemovalDirectoryAssertion(directoryGuard.dir, directoryGuard.stat, directoryGuard.realPath));
@@ -19244,7 +19302,7 @@ async function finishRootFallbackWrite(params) {
19244
19302
  // identity without reading bytes; a different object must still fail.
19245
19303
  await verify();
19246
19304
  }
19247
- else if (!file_identity_sameFileIdentityForCleanup(current, identity)) {
19305
+ else if (!sameFileIdentityForCleanup(current, identity)) {
19248
19306
  const opened = await params.openForCompatibility();
19249
19307
  accepted = handle = opened.opened.handle;
19250
19308
  identity = opened.identity;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lousy-agents/agent-shell",
3
- "version": "5.22.21",
3
+ "version": "5.22.23",
4
4
  "description": "A flight recorder for npm script execution",
5
5
  "type": "module",
6
6
  "repository": {
@@ -37,7 +37,7 @@
37
37
  "typecheck": "tsc --noEmit"
38
38
  },
39
39
  "dependencies": {
40
- "@openclaw/fs-safe": "0.26.15",
40
+ "@openclaw/fs-safe": "0.27.0",
41
41
  "zod": "4.6.6"
42
42
  },
43
43
  "peerDependencies": {