@lousy-agents/agent-shell 5.22.14 → 5.22.16

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 +122 -44
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { createRequire as __rspack_createRequire } from "node:module";
3
3
  const __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
4
4
  var __webpack_modules__ = ({
5
- 433(__unused_rspack_module, __unused_rspack___webpack_exports__, __webpack_require__) {
5
+ 617(__unused_rspack_module, __unused_rspack___webpack_exports__, __webpack_require__) {
6
6
 
7
7
  ;// CONCATENATED MODULE: external "node:child_process"
8
8
  const external_node_child_process_namespaceObject = __rspack_createRequire_require("node:child_process");
@@ -1587,7 +1587,11 @@ function safeRealpathSync(targetPath, cache) {
1587
1587
  return cached;
1588
1588
  }
1589
1589
  try {
1590
- const resolved = realpathSync(pathForWindowsFilesystem(targetPath));
1590
+ const ordinary = realpathSync(pathForWindowsFilesystem(targetPath));
1591
+ // Ordinary resolution keeps the caller's letter case. Its result has no symlinks or
1592
+ // dot segments left, so native resolution on POSIX only adopts the on-disk spelling
1593
+ // that root admission compares against. Windows root admission reconciles aliases.
1594
+ const resolved = process.platform === "win32" ? ordinary : realpathSync.native(ordinary);
1591
1595
  cache?.set(targetPath, resolved);
1592
1596
  cache?.set(resolved, resolved);
1593
1597
  return resolved;
@@ -3814,6 +3818,7 @@ function validateDescriptor(value, allowUnknownFlags) {
3814
3818
  typeof value.currentUserSid !== "string" || !SID_RE.test(value.currentUserSid) ||
3815
3819
  (value.currentAppContainerSid != null && (typeof value.currentAppContainerSid !== "string" || !APP_CONTAINER_SID_RE.test(value.currentAppContainerSid))) ||
3816
3820
  typeof value.daclPresent !== "boolean" || typeof value.isLocal !== "boolean" ||
3821
+ (value.isVolumeRoot !== undefined && typeof value.isVolumeRoot !== "boolean") ||
3817
3822
  typeof value.aceListComplete !== "boolean" || !Array.isArray(value.unsupportedAceTypes) ||
3818
3823
  !value.unsupportedAceTypes.every(uint32) || !Array.isArray(value.aces) ||
3819
3824
  !value.aces.every(ace => validateAce(ace, allowUnknownFlags))) {
@@ -12212,9 +12217,14 @@ const onCopySourceAdmission = Symbol("onCopySourceAdmission");
12212
12217
 
12213
12218
  ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/file-sync.js
12214
12219
 
12220
+ function syncFile(handle) {
12221
+ return typeof handle === "number"
12222
+ ? new Promise((resolve, reject) => external_node_fs_namespaceObject.fsync(handle, error => error ? reject(error) : resolve()))
12223
+ : handle.sync();
12224
+ }
12215
12225
  async function syncFileBestEffort(handle) {
12216
12226
  try {
12217
- await handle.sync();
12227
+ await syncFile(handle);
12218
12228
  }
12219
12229
  catch (error) {
12220
12230
  if (error?.code !== "EPERM")
@@ -12920,6 +12930,7 @@ class NativeStagedFile {
12920
12930
  #verifyMode;
12921
12931
  #state = { status: "open", publication: NOT_PUBLISHED };
12922
12932
  #receipt;
12933
+ #publicationFlush;
12923
12934
  #rejectFinalSymlink = false;
12924
12935
  #unsupportedNoReplace;
12925
12936
  #fallbackCleanup;
@@ -12956,8 +12967,7 @@ class NativeStagedFile {
12956
12967
  const env_1 = { stack: [], error: void 0, hasError: false };
12957
12968
  try {
12958
12969
  const exclusive = params.overwrite === false && params.input.kind === "buffer" && params.input.stageBeforePublish === false;
12959
- // This owner never escapes. Only the internal verifier borrows its fd;
12960
- // public descriptor methods remain await-free and cannot race disposal.
12970
+ // This owner never escapes; only the internal verifier borrows its fd.
12961
12971
  const staged = native_staged_file_addDisposableResource(env_1, await NativeStagedFile.create({
12962
12972
  binding, parentFd, closeParentFd, directory, mode: params.mode, sync: params.sync,
12963
12973
  // Public staging uses portable names; existing POSIX writes accept literal names.
@@ -12976,9 +12986,10 @@ class NativeStagedFile {
12976
12986
  }
12977
12987
  let published;
12978
12988
  try {
12979
- published = exclusive
12989
+ const publication = exclusive
12980
12990
  ? staged.#completePublication(params.basename, false, params.onPublished)
12981
- : await staged.publish(params.basename, { overwrite: params.overwrite !== false }, params.onPublished);
12991
+ : staged.publish(params.basename, { overwrite: params.overwrite !== false }, params.onPublished);
12992
+ published = publication instanceof Promise ? await publication : publication;
12982
12993
  }
12983
12994
  catch (error) {
12984
12995
  if (!staged.#unsupportedNoReplace || isFsSafeNativeRequired() ||
@@ -13141,29 +13152,21 @@ class NativeStagedFile {
13141
13152
  restoreCopyMetadata(fd, input.metadata);
13142
13153
  if (this.#verifyMode)
13143
13154
  this.#assertStagePermissions(fd);
13144
- if (this.#owner.sync !== false) {
13145
- if (this.#owner.strictFileSync)
13146
- external_node_fs_namespaceObject.fsyncSync(fd);
13147
- else
13148
- syncFileBestEffortSync(fd);
13149
- }
13155
+ if (this.#owner.sync !== false)
13156
+ await (this.#owner.strictFileSync ? syncFile(fd) : syncFileBestEffort(fd));
13150
13157
  const stat = external_node_fs_namespaceObject.fstatSync(fd, { bigint: true });
13151
13158
  this.#receipt = createStagedFileReceipt(this.#owner.directory, this.#owner.name, stat);
13152
13159
  this.#assertCurrent();
13153
13160
  }
13154
13161
  catch (error) {
13155
13162
  const { receipt: cleanup, error: cleanupError } = this.#finalize();
13156
- if (cleanupError) {
13157
- throw stagedFailure("file", new AggregateError([error, cleanupError], "preparation and cleanup failed"), { phase: "prepare", publication: cleanup.publication, cleanup });
13158
- }
13159
- if (cleanup.status === "preserved") {
13160
- throw stagedFailure("file", error, { phase: "prepare", publication: cleanup.publication, cleanup });
13163
+ if (cleanupError || cleanup.status === "preserved") {
13164
+ throw stagedFailure("file", cleanupError
13165
+ ? new AggregateError([error, cleanupError], "preparation and cleanup failed") : error, { phase: "prepare", publication: cleanup.publication, cleanup });
13161
13166
  }
13162
13167
  throw error;
13163
13168
  }
13164
13169
  }
13165
- // Keep public descriptor work await-free: each call completes its mutations
13166
- // before the next invocation, including closure and cached cleanup failures.
13167
13170
  async assertCurrent() {
13168
13171
  this.#assertCurrent();
13169
13172
  }
@@ -13208,7 +13211,8 @@ class NativeStagedFile {
13208
13211
  }
13209
13212
  throw error;
13210
13213
  }
13211
- return this.#completePublication(basename, overwrite, onPublished);
13214
+ const publication = this.#completePublication(basename, overwrite, onPublished);
13215
+ return publication instanceof Promise ? await publication : publication;
13212
13216
  }
13213
13217
  catch (error) {
13214
13218
  if (isMutationAuthorityError(error))
@@ -13234,17 +13238,21 @@ class NativeStagedFile {
13234
13238
  external_node_fs_namespaceObject.fchmodSync(fd, this.#owner.mode);
13235
13239
  // Content was synced during preparation. A lost chmod leaves 0600, no wider
13236
13240
  // than modes retaining owner rw; restrictive modes still need a durable correction.
13237
- if (this.#owner.sync !== false && ((this.#owner.mode & 0o600) !== 0o600 || (stagedMode & ~this.#owner.mode) !== 0)) {
13238
- if (this.#owner.strictFileSync)
13239
- external_node_fs_namespaceObject.fsyncSync(fd);
13240
- else
13241
- syncFileBestEffortSync(fd);
13242
- }
13243
- if (this.#owner.sync !== false)
13244
- syncFileBestEffortSync(this.#owner.parentFd);
13245
- this.#assertNamed(basename, this.#owner.mode);
13246
- this.#assertDirectory();
13247
- return receipt;
13241
+ const verify = () => {
13242
+ this.#assertNamed(basename, this.#owner.mode);
13243
+ this.#assertDirectory();
13244
+ return receipt;
13245
+ };
13246
+ if (this.#owner.sync === false)
13247
+ return verify();
13248
+ this.#publicationFlush = Promise.resolve().then(async () => {
13249
+ if ((this.#owner.mode & 0o600) !== 0o600 || (stagedMode & ~this.#owner.mode) !== 0) {
13250
+ await (this.#owner.strictFileSync ? syncFile(fd) : syncFileBestEffort(fd));
13251
+ }
13252
+ await syncFileBestEffort(this.#owner.parentFd);
13253
+ return verify();
13254
+ }).finally(() => { this.#publicationFlush = undefined; });
13255
+ return this.#publicationFlush;
13248
13256
  }
13249
13257
  #finalize() {
13250
13258
  if (this.#state.status === "closed") {
@@ -13299,6 +13307,9 @@ class NativeStagedFile {
13299
13307
  return this.#state;
13300
13308
  }
13301
13309
  async cleanup() {
13310
+ // Native descriptors cannot close or be recycled while libuv is synchronizing them.
13311
+ if (this.#publicationFlush)
13312
+ await this.#publicationFlush.catch(() => { });
13302
13313
  const closed = this.#finalize();
13303
13314
  if (closed.error) {
13304
13315
  throw closed.error;
@@ -15785,8 +15796,8 @@ function pinnedWriteModeAssertion(fd, mode, assertBeforeMutation, privateCreatio
15785
15796
 
15786
15797
 
15787
15798
  // Node has no portable no-replace rename. Publish the completed stage by link,
15788
- // then remove its verified temporary name without yielding.
15789
- function publishCopyStage(params) {
15799
+ // then remove its verified temporary name after any descriptor handoff.
15800
+ async function publishCopyStage(params) {
15790
15801
  const { identity, temporaryPath, targetPath } = params;
15791
15802
  const assertCurrent = () => {
15792
15803
  directory_guard_assertSyncDirectoryGuard(params.parentGuard);
@@ -15840,13 +15851,23 @@ function publishCopyStage(params) {
15840
15851
  }
15841
15852
  }
15842
15853
  else {
15843
- const parent = external_node_fs_namespaceObject.lstatSync(external_node_path_namespaceObject.dirname(temporaryPath), { bigint: true });
15844
- const current = external_node_fs_namespaceObject.lstatSync(temporaryPath, { bigint: true });
15845
- if (parent.isSymbolicLink() || !parent.isDirectory() ||
15846
- !file_identity_sameFileIdentityForCleanup(parent, params.parentGuard.stat) ||
15847
- current.isSymbolicLink() || !current.isFile() ||
15848
- !file_identity_sameFileIdentityForCleanup(current, identity)) {
15849
- throw new errors_FsSafeError("path-mismatch", "published copy temporary name changed before cleanup");
15854
+ const verifyPair = () => {
15855
+ directory_guard_assertSyncDirectoryGuard(params.parentGuard);
15856
+ const parent = external_node_fs_namespaceObject.lstatSync(external_node_path_namespaceObject.dirname(temporaryPath), { bigint: true });
15857
+ const current = external_node_fs_namespaceObject.lstatSync(temporaryPath, { bigint: true });
15858
+ const target = external_node_fs_namespaceObject.lstatSync(targetPath, { bigint: true });
15859
+ if (parent.isSymbolicLink() || !parent.isDirectory() ||
15860
+ !file_identity_sameFileIdentityForCleanup(parent, params.parentGuard.stat) ||
15861
+ current.isSymbolicLink() || !current.isFile() || current.nlink !== 2n ||
15862
+ target.isSymbolicLink() || !target.isFile() || target.nlink !== 2n ||
15863
+ !file_identity_sameFileIdentityForCleanup(current, identity) || !file_identity_sameFileIdentityForCleanup(target, identity)) {
15864
+ throw new errors_FsSafeError("path-mismatch", "published copy temporary name changed before cleanup");
15865
+ }
15866
+ };
15867
+ verifyPair();
15868
+ if (params.beforeTemporaryUnlink) {
15869
+ await params.beforeTemporaryUnlink();
15870
+ verifyPair();
15850
15871
  }
15851
15872
  // This removes the stage's name, never the published destination or source.
15852
15873
  external_node_fs_namespaceObject.unlinkSync(temporaryPath);
@@ -15919,6 +15940,40 @@ function publishThroughPlaceholder(params, assertCurrent) {
15919
15940
  }
15920
15941
  }
15921
15942
 
15943
+ ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/publication-handle.js
15944
+
15945
+
15946
+
15947
+
15948
+
15949
+
15950
+ /** Pin the published name before releasing a descriptor opened through its stage. */
15951
+ async function openPublicationHandle(targetPath, identity) {
15952
+ const flags = read_open_flags_resolveReadOpenFlags();
15953
+ const handle = await promises_namespaceObject.open(targetPath, flags).catch(async (error) => {
15954
+ // Restrictive final modes must not be widened just to inspect publication.
15955
+ if (!hasErrorCode(error, "EACCES") || (process.arch !== "x64" && process.arch !== "arm64"))
15956
+ throw error;
15957
+ const metadataFlag = process.platform === "linux" ? 0x200000 : undefined; // O_PATH
15958
+ if (metadataFlag === undefined)
15959
+ throw error;
15960
+ return promises_namespaceObject.open(targetPath, metadataFlag | external_node_fs_namespaceObject.constants.O_NOFOLLOW);
15961
+ });
15962
+ try {
15963
+ const opened = external_node_fs_namespaceObject.fstatSync(handle.fd, { bigint: true });
15964
+ const named = external_node_fs_namespaceObject.lstatSync(targetPath, { bigint: true });
15965
+ if (!opened.isFile() || !named.isFile() || named.isSymbolicLink() ||
15966
+ !file_identity_sameFileIdentityForCleanup(opened, identity) || !file_identity_sameFileIdentityForCleanup(named, identity)) {
15967
+ throw new errors_FsSafeError("path-mismatch", "publication descriptor handoff identity changed");
15968
+ }
15969
+ return handle;
15970
+ }
15971
+ catch (error) {
15972
+ await handle.close().catch(() => undefined);
15973
+ throw error;
15974
+ }
15975
+ }
15976
+
15922
15977
  ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/pinned-write-staged.js
15923
15978
 
15924
15979
 
@@ -15940,6 +15995,7 @@ function publishThroughPlaceholder(params, assertCurrent) {
15940
15995
 
15941
15996
 
15942
15997
 
15998
+
15943
15999
 
15944
16000
 
15945
16001
  async function runPinnedStagedWrite(params, parentPath, parentGuard) {
@@ -15957,6 +16013,7 @@ async function runPinnedStagedWrite(params, parentPath, parentGuard) {
15957
16013
  let handle;
15958
16014
  let tempIdentity;
15959
16015
  let readHandle;
16016
+ let handoffCloseFailure;
15960
16017
  let renamed = false;
15961
16018
  const completeCreate = params.overwrite === false && params.input.kind !== "file" && params.input.stageBeforePublish === true;
15962
16019
  let receipt;
@@ -16011,11 +16068,15 @@ async function runPinnedStagedWrite(params, parentPath, parentGuard) {
16011
16068
  }), external_node_path_namespaceObject.basename(tempPath), external_node_fs_namespaceObject.fstatSync(handle.fd, { bigint: true }));
16012
16069
  }
16013
16070
  let verifiedIdentity = expectedTempStat;
16071
+ // Keep unreadable modes supported where Node has no read-free file open.
16072
+ const canHandoff = process.platform !== "win32" &&
16073
+ ((params.mode & 0o400) !== 0 ||
16074
+ (process.platform === "linux" && (process.arch === "x64" || process.arch === "arm64")));
16014
16075
  phase = "publish";
16015
16076
  await withAsyncDirectoryGuards([parentGuard], async () => {
16016
16077
  assertFinalSymlinkRejected(targetPath, params.rejectFinalSymlink);
16017
16078
  if (params.overwrite === false) {
16018
- publishCopyStage({
16079
+ await publishCopyStage({
16019
16080
  temporaryPath: tempPath, targetPath, fd: handle.fd,
16020
16081
  identity: tempIdentity, parentGuard,
16021
16082
  assertBeforeMutation,
@@ -16029,6 +16090,18 @@ async function runPinnedStagedWrite(params, parentPath, parentGuard) {
16029
16090
  publication = Object.freeze({ status: "published", staged: receipt, basename: params.basename, overwrite: false });
16030
16091
  params.onPublished?.(identity);
16031
16092
  },
16093
+ beforeTemporaryUnlink: !canHandoff ? undefined : async () => {
16094
+ readHandle = await openPublicationHandle(targetPath, expectedTempStat);
16095
+ // Keep the destination pinned while closing the stage's NFS dentry.
16096
+ const stagedHandle = handle;
16097
+ handle = undefined;
16098
+ try {
16099
+ await stagedHandle.close();
16100
+ }
16101
+ catch (error) {
16102
+ handoffCloseFailure = { error };
16103
+ }
16104
+ },
16032
16105
  });
16033
16106
  }
16034
16107
  else {
@@ -16056,6 +16129,7 @@ async function runPinnedStagedWrite(params, parentPath, parentGuard) {
16056
16129
  throw new errors_FsSafeError("path-mismatch", "fallback target changed during write");
16057
16130
  }
16058
16131
  const expectedHash = sha256Hex(params.input.data, params.input.encoding);
16132
+ await readHandle?.close();
16059
16133
  readHandle = await promises_namespaceObject.open(targetPath, read_open_flags_resolveReadOpenFlags());
16060
16134
  const readHandleStat = external_node_fs_namespaceObject.fstatSync(readHandle.fd, { bigint: true });
16061
16135
  const actualHash = sha256Hex(await readFileHandleBounded(readHandle, Infinity));
@@ -16094,7 +16168,11 @@ async function runPinnedStagedWrite(params, parentPath, parentGuard) {
16094
16168
  pathname: tempPath, handle, identity: tempIdentity, parentGuard, throwOnCleanupError: true,
16095
16169
  }) : "not-needed";
16096
16170
  },
16097
- close: [async () => { await readHandle?.close(); }, async () => { await handle?.close(); }],
16171
+ close: [async () => { await readHandle?.close(); }, async () => {
16172
+ await handle?.close();
16173
+ if (handoffCloseFailure)
16174
+ throw handoffCloseFailure.error;
16175
+ }],
16098
16176
  });
16099
16177
  }
16100
16178
  else
@@ -34452,4 +34530,4 @@ if (installedChunkData !== 0) { // 0 means "already installed".'
34452
34530
  // module factories are used so entry inlining is disabled
34453
34531
  // startup
34454
34532
  // Load entry module and return exports
34455
- var __webpack_exports__ = __webpack_require__(433);
34533
+ var __webpack_exports__ = __webpack_require__(617);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lousy-agents/agent-shell",
3
- "version": "5.22.14",
3
+ "version": "5.22.16",
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.10",
40
+ "@openclaw/fs-safe": "0.26.13",
41
41
  "zod": "4.6.6"
42
42
  },
43
43
  "peerDependencies": {