@lousy-agents/mcp 5.23.8 → 5.23.10

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/mcp-server.js +310 -232
  2. package/package.json +1 -1
@@ -28656,7 +28656,7 @@ const external_node_async_hooks_namespaceObject = __rspack_createRequire_require
28656
28656
 
28657
28657
  const file_observation_active = new external_node_async_hooks_namespaceObject.AsyncLocalStorage();
28658
28658
  function recordFileObservationFailure(error, kind) {
28659
- const failures = file_observation_active.getStore();
28659
+ const failures = file_observation_active.getStore()?.failures;
28660
28660
  if (!failures)
28661
28661
  return;
28662
28662
  let kinds = failures.get(error);
@@ -28665,13 +28665,17 @@ function recordFileObservationFailure(error, kind) {
28665
28665
  kinds.add(kind);
28666
28666
  }
28667
28667
  function isFileObservationFailure(error, kind) {
28668
- return file_observation_active.getStore()?.get(error)?.has(kind) === true;
28668
+ return file_observation_active.getStore()?.failures.get(error)?.has(kind) === true;
28669
+ }
28670
+ async function observedFilePublicationPending(filePath, identity) {
28671
+ return await file_observation_active.getStore()?.publicationPending?.(filePath, identity) ?? false;
28669
28672
  }
28670
28673
  // Each Root observation owns its receipts, including nested and concurrent reads.
28671
- function fileObservation() {
28674
+ function fileObservation(options = {}) {
28672
28675
  const failures = new Map();
28676
+ const context = { failures, ...options };
28673
28677
  return {
28674
- run(operation) { return file_observation_active.run(failures, operation); },
28678
+ run(operation) { return file_observation_active.run(context, operation); },
28675
28679
  has(error, kind) { return failures.get(error)?.has(kind) === true; },
28676
28680
  };
28677
28681
  }
@@ -30950,17 +30954,19 @@ function cleanupSidecarStages(target, assertCurrent, native, onlyStage) {
30950
30954
  }
30951
30955
  // Readers reject the linked record and retry. Authorized cleanup may handle
30952
30956
  // the one matching stage; recognition streams past the opportunistic budget.
30953
- function sidecar_lock_staging_sidecarPublicationPending(target, onStage) {
30957
+ function sidecar_lock_staging_sidecarPublicationPending(target, onStage, options = {}) {
30954
30958
  let entries;
30955
30959
  let callbackFailure;
30956
30960
  try {
30957
30961
  const current = external_node_fs_.lstatSync(target, { bigint: true, throwIfNoEntry: false });
30958
30962
  if (!current)
30959
- return true;
30963
+ return !options.requireStage;
30964
+ if (options.identity && !sameFileIdentityForCleanup(current, options.identity))
30965
+ return false;
30960
30966
  if (!current.isFile() || current.isSymbolicLink())
30961
30967
  return false;
30962
30968
  if (current.nlink === 1n)
30963
- return true;
30969
+ return !options.requireStage;
30964
30970
  if (current.nlink !== 2n)
30965
30971
  return false;
30966
30972
  const prefix = stagingPrefix(target);
@@ -30984,7 +30990,7 @@ function sidecar_lock_staging_sidecarPublicationPending(target, onStage) {
30984
30990
  }
30985
30991
  }
30986
30992
  const after = external_node_fs_.lstatSync(target, { bigint: true, throwIfNoEntry: false });
30987
- return !after || !sameFileIdentityForCleanup(after, current) || after.nlink === 1n;
30993
+ return !options.requireStage && (!after || !sameFileIdentityForCleanup(after, current) || after.nlink === 1n);
30988
30994
  }
30989
30995
  catch {
30990
30996
  if (callbackFailure)
@@ -31513,6 +31519,236 @@ function pinNodeDirectoryForModeSync(dirPath, options = {}) {
31513
31519
  }
31514
31520
  }
31515
31521
 
31522
+ ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/test-hooks.js
31523
+
31524
+ let test_hooks_fsSafeTestHooks;
31525
+ function allowFsSafeTestHooks() {
31526
+ return false || process.env.VITEST === "true";
31527
+ }
31528
+ function getFsSafeTestHooks() {
31529
+ return test_hooks_fsSafeTestHooks;
31530
+ }
31531
+ function __setFsSafeTestHooksForTest(hooks) {
31532
+ if (hooks && !allowFsSafeTestHooks()) {
31533
+ throw new Error("__setFsSafeTestHooksForTest is only available in tests");
31534
+ }
31535
+ test_hooks_fsSafeTestHooks = hooks;
31536
+ }
31537
+
31538
+ ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/timing.js
31539
+ const MAX_TIMER_DELAY_MS = 2 ** 31 - 1;
31540
+ function scheduleTimeout(callback, ms) {
31541
+ let timer;
31542
+ if (Number.isFinite(ms) && ms > MAX_TIMER_DELAY_MS) {
31543
+ const startedAt = performance.now();
31544
+ const tick = () => {
31545
+ const remaining = ms - (performance.now() - startedAt);
31546
+ if (remaining <= 0)
31547
+ callback();
31548
+ else
31549
+ timer = setTimeout(tick, Math.min(remaining, MAX_TIMER_DELAY_MS));
31550
+ };
31551
+ // Node clamps overflowing delays to 1 ms. Rearm bounded timers against a
31552
+ // monotonic clock so clock changes and event-loop stalls cannot shorten them.
31553
+ timer = setTimeout(tick, MAX_TIMER_DELAY_MS);
31554
+ }
31555
+ else {
31556
+ timer = setTimeout(callback, ms);
31557
+ }
31558
+ return () => clearTimeout(timer);
31559
+ }
31560
+ function sleep(ms) {
31561
+ return new Promise((resolve) => { scheduleTimeout(resolve, ms); });
31562
+ }
31563
+ function sleepSync(ms) {
31564
+ if (ms <= 0) {
31565
+ return;
31566
+ }
31567
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
31568
+ }
31569
+ async function withTimeout(promise, timeoutMs, labelOrOptions = {
31570
+ message: "timeout",
31571
+ }) {
31572
+ if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
31573
+ return await promise;
31574
+ }
31575
+ const options = typeof labelOrOptions === "string" ? { label: labelOrOptions } : labelOrOptions;
31576
+ const createError = options.createError ??
31577
+ (() => new Error(options.message ?? `${options.label ?? "operation"} timed out after ${timeoutMs}ms`));
31578
+ let cancelTimeout;
31579
+ try {
31580
+ return await Promise.race([
31581
+ promise,
31582
+ new Promise((_, reject) => {
31583
+ cancelTimeout = scheduleTimeout(() => {
31584
+ try {
31585
+ reject(createError());
31586
+ }
31587
+ catch (error) {
31588
+ reject(error);
31589
+ }
31590
+ }, timeoutMs);
31591
+ }),
31592
+ ]);
31593
+ }
31594
+ finally {
31595
+ cancelTimeout?.();
31596
+ }
31597
+ }
31598
+
31599
+ ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/publication-recovery.js
31600
+
31601
+
31602
+
31603
+
31604
+
31605
+
31606
+
31607
+
31608
+ const non9pDevices = new Set();
31609
+ /** Other platforms keep their existing path even when the option is enabled. */
31610
+ function shouldPrepareDrvfsRecovery(enabled, dev) {
31611
+ if (enabled !== true)
31612
+ return false;
31613
+ // Synthetic mount evidence must not inherit observations from the real host.
31614
+ if (getFsSafeTestHooks()?.drvfsMountObservation)
31615
+ return true;
31616
+ if (process.platform !== "linux")
31617
+ return false;
31618
+ if (dev === undefined)
31619
+ return true;
31620
+ // Linux 9p allocates anonymous devices (major zero), never block devices.
31621
+ if (((dev >> 8n) & 0xfffn) !== 0n || ((dev >> 32n) & 0xfffff000n) !== 0n)
31622
+ return false;
31623
+ return !non9pDevices.has(dev);
31624
+ }
31625
+ /** Negative evidence only: a stale/reused device number can only disable recovery. */
31626
+ function mayPrepareDrvfsRecoveryAtFd(parentFd, dev) {
31627
+ if (!shouldPrepareDrvfsRecovery(true, dev))
31628
+ return false;
31629
+ if (getFsSafeTestHooks()?.drvfsMountObservation)
31630
+ return true;
31631
+ try {
31632
+ if (native_getNativeBinding()?.is9pFilesystem?.(parentFd) === false) {
31633
+ non9pDevices.add(dev);
31634
+ return false;
31635
+ }
31636
+ }
31637
+ catch { /* Unavailable evidence preserves full recovery-time verification. */ }
31638
+ return true;
31639
+ }
31640
+ /** No sampling or positive cache: the retained directory's exact mount owns admission. */
31641
+ function admitsDrvfsRenameRecoveryAtFd(parentFd) {
31642
+ try {
31643
+ const hook = getFsSafeTestHooks()?.drvfsMountObservation;
31644
+ if (!hook && process.platform !== "linux")
31645
+ return false;
31646
+ if (!Number.isInteger(parentFd) || parentFd < 0)
31647
+ return false;
31648
+ const observation = hook ? hook(parentFd) : (() => {
31649
+ if (external_node_fs_.statfsSync("/proc/self/fd", { bigint: true }).type !== 0x9fa0n)
31650
+ return undefined;
31651
+ // statfs follows this kernel-owned descriptor alias to the retained parent.
31652
+ return {
31653
+ magic: external_node_fs_.statfsSync(`/proc/self/fd/${parentFd}`, { bigint: true }).type,
31654
+ fdinfo: external_node_fs_.readFileSync(`/proc/self/fdinfo/${parentFd}`, "utf8"),
31655
+ mountinfo: external_node_fs_.readFileSync("/proc/self/mountinfo", "utf8"),
31656
+ };
31657
+ })();
31658
+ if (!observation || observation.magic !== 0x01021997n)
31659
+ return false;
31660
+ const ids = [...observation.fdinfo.matchAll(/^mnt_id:\s*(\d+)\s*$/gm)];
31661
+ if (ids.length !== 1)
31662
+ return false;
31663
+ const entries = observation.mountinfo.split("\n").filter(line => line.split(" ")[0] === ids[0][1]);
31664
+ if (entries.length !== 1)
31665
+ return false;
31666
+ const [before, after, extra] = entries[0].split(" - ");
31667
+ if (!before || !after || extra !== undefined || before.split(" ").length < 6)
31668
+ return false;
31669
+ const fields = after.split(" ");
31670
+ return fields.length === 3 && fields[0] === "9p" &&
31671
+ fields[2].split(",").some(option => option === "aname=drvfs" || option.startsWith("aname=drvfs;"));
31672
+ }
31673
+ catch {
31674
+ return false;
31675
+ }
31676
+ }
31677
+ /** Exact metadata is necessary but cannot exclude inode reuse after the final close. */
31678
+ function assertRecoveredPublication(actual, expected) {
31679
+ if (!actual.isFile() || actual.isSymbolicLink() || actual.nlink !== 1n ||
31680
+ actual.dev !== expected.dev || actual.ino !== expected.ino || actual.size !== expected.size ||
31681
+ actual.mode !== expected.mode || actual.uid !== expected.uid || actual.gid !== expected.gid) {
31682
+ throw new errors_FsSafeError("path-mismatch", "published file changed during DrvFS recovery");
31683
+ }
31684
+ }
31685
+ async function recoverAfterHiddenRename(params) {
31686
+ if (!admitsDrvfsRenameRecoveryAtFd(params.parentFd)) {
31687
+ throw new errors_FsSafeError("path-mismatch", "hidden rename recovery requires a verified DrvFS mount");
31688
+ }
31689
+ await params.closeWriter();
31690
+ for (let attempt = 0;; attempt++) {
31691
+ let recovered;
31692
+ try {
31693
+ recovered = await params.reopen();
31694
+ }
31695
+ catch (error) {
31696
+ if (!hasErrorCode(error, "ENOENT") || attempt === 4)
31697
+ throw error;
31698
+ await sleep(20);
31699
+ continue;
31700
+ }
31701
+ try {
31702
+ await params.retain?.(recovered);
31703
+ }
31704
+ catch (error) {
31705
+ await params.dispose?.(recovered).catch(() => undefined);
31706
+ throw error;
31707
+ }
31708
+ return recovered;
31709
+ }
31710
+ }
31711
+ function recoverAfterHiddenRenameSync(params) {
31712
+ if (!admitsDrvfsRenameRecoveryAtFd(params.parentFd)) {
31713
+ throw new errors_FsSafeError("path-mismatch", "hidden rename recovery requires a verified DrvFS mount");
31714
+ }
31715
+ params.closeWriter();
31716
+ for (let attempt = 0;; attempt++) {
31717
+ try {
31718
+ return params.reopen();
31719
+ }
31720
+ catch (error) {
31721
+ if (!hasErrorCode(error, "ENOENT") || attempt === 4)
31722
+ throw error;
31723
+ sleepSync(20);
31724
+ }
31725
+ }
31726
+ }
31727
+ function assertRecoveredFile(fd, expected, content) {
31728
+ assertRecoveredPublication(external_node_fs_.fstatSync(fd, { bigint: true }), expected);
31729
+ if (content && !bounded_read_readFileDescriptorBoundedSync(fd, content.byteLength).equals(content)) {
31730
+ throw new errors_FsSafeError("path-mismatch", "published content changed during DrvFS recovery");
31731
+ }
31732
+ assertRecoveredPublication(external_node_fs_.fstatSync(fd, { bigint: true }), expected);
31733
+ }
31734
+ function reopenRecoveredNativeFile(binding, parentFd, basename, expected, content) {
31735
+ if (!binding.openBeneath || !binding.closeOwnedFd || !binding.stagedFileMatches) {
31736
+ throw new errors_FsSafeError("helper-unavailable", "native DrvFS recovery requires descriptor-relative verification");
31737
+ }
31738
+ const fd = binding.openBeneath(parentFd, basename, nativeOpenFlags(external_node_fs_.constants.O_RDONLY | external_node_fs_.constants.O_NONBLOCK)).fd;
31739
+ try {
31740
+ assertRecoveredFile(fd, expected, content);
31741
+ if (!binding.stagedFileMatches(parentFd, basename, fd)) {
31742
+ throw new errors_FsSafeError("path-mismatch", "published name changed during DrvFS recovery");
31743
+ }
31744
+ return fd;
31745
+ }
31746
+ catch (error) {
31747
+ binding.closeOwnedFd(fd);
31748
+ throw error;
31749
+ }
31750
+ }
31751
+
31516
31752
  ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/root-boundary.js
31517
31753
 
31518
31754
 
@@ -31891,67 +32127,6 @@ function recursiveMkdirPath(directory) {
31891
32127
  return needsAbsolutePath ? absolutePathWithRawSegments(directory) : directory;
31892
32128
  }
31893
32129
 
31894
- ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/timing.js
31895
- const MAX_TIMER_DELAY_MS = 2 ** 31 - 1;
31896
- function scheduleTimeout(callback, ms) {
31897
- let timer;
31898
- if (Number.isFinite(ms) && ms > MAX_TIMER_DELAY_MS) {
31899
- const startedAt = performance.now();
31900
- const tick = () => {
31901
- const remaining = ms - (performance.now() - startedAt);
31902
- if (remaining <= 0)
31903
- callback();
31904
- else
31905
- timer = setTimeout(tick, Math.min(remaining, MAX_TIMER_DELAY_MS));
31906
- };
31907
- // Node clamps overflowing delays to 1 ms. Rearm bounded timers against a
31908
- // monotonic clock so clock changes and event-loop stalls cannot shorten them.
31909
- timer = setTimeout(tick, MAX_TIMER_DELAY_MS);
31910
- }
31911
- else {
31912
- timer = setTimeout(callback, ms);
31913
- }
31914
- return () => clearTimeout(timer);
31915
- }
31916
- function sleep(ms) {
31917
- return new Promise((resolve) => { scheduleTimeout(resolve, ms); });
31918
- }
31919
- function sleepSync(ms) {
31920
- if (ms <= 0) {
31921
- return;
31922
- }
31923
- Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
31924
- }
31925
- async function withTimeout(promise, timeoutMs, labelOrOptions = {
31926
- message: "timeout",
31927
- }) {
31928
- if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
31929
- return await promise;
31930
- }
31931
- const options = typeof labelOrOptions === "string" ? { label: labelOrOptions } : labelOrOptions;
31932
- const createError = options.createError ??
31933
- (() => new Error(options.message ?? `${options.label ?? "operation"} timed out after ${timeoutMs}ms`));
31934
- let cancelTimeout;
31935
- try {
31936
- return await Promise.race([
31937
- promise,
31938
- new Promise((_, reject) => {
31939
- cancelTimeout = scheduleTimeout(() => {
31940
- try {
31941
- reject(createError());
31942
- }
31943
- catch (error) {
31944
- reject(error);
31945
- }
31946
- }, timeoutMs);
31947
- }),
31948
- ]);
31949
- }
31950
- finally {
31951
- cancelTimeout?.();
31952
- }
31953
- }
31954
-
31955
32130
  ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/exclusive-create.js
31956
32131
 
31957
32132
 
@@ -32243,6 +32418,7 @@ class AtomicFile {
32243
32418
 
32244
32419
 
32245
32420
 
32421
+
32246
32422
  function replace_file_descriptor_parentCloseFailure(primary, closeError) {
32247
32423
  return primary ? new AggregateError([primary.error, closeError], "Atomic parent preparation and close failed") : closeError;
32248
32424
  }
@@ -32305,6 +32481,8 @@ async function pinDirectoryForMode(params) {
32305
32481
  ignoreChmodError: params.ignoreChmodError,
32306
32482
  });
32307
32483
  await owner.verify();
32484
+ if (params.allowDrvfsRenameRecovery)
32485
+ mayPrepareDrvfsRecoveryAtFd(handle.fd, expected.dev);
32308
32486
  return owner;
32309
32487
  }
32310
32488
  catch (error) {
@@ -32351,6 +32529,8 @@ function* applyDirectoryMode(io, params) {
32351
32529
  let primary;
32352
32530
  try {
32353
32531
  inspectAtomicIdentity(io, () => file.statExact(), expected, false, admit);
32532
+ if (params.allowDrvfsRenameRecovery)
32533
+ mayPrepareDrvfsRecoveryAtFd(file.fd, expected.dev);
32354
32534
  if (params.mode !== "preserve") {
32355
32535
  params.mutation?.assert();
32356
32536
  file.chmod(params.mode & 0o7777);
@@ -32576,146 +32756,6 @@ function __cleanupRegisteredTempPathForTest(tempPath) {
32576
32756
  }
32577
32757
  }
32578
32758
 
32579
- ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/test-hooks.js
32580
-
32581
- let test_hooks_fsSafeTestHooks;
32582
- function allowFsSafeTestHooks() {
32583
- return false || process.env.VITEST === "true";
32584
- }
32585
- function getFsSafeTestHooks() {
32586
- return test_hooks_fsSafeTestHooks;
32587
- }
32588
- function __setFsSafeTestHooksForTest(hooks) {
32589
- if (hooks && !allowFsSafeTestHooks()) {
32590
- throw new Error("__setFsSafeTestHooksForTest is only available in tests");
32591
- }
32592
- test_hooks_fsSafeTestHooks = hooks;
32593
- }
32594
-
32595
- ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/publication-recovery.js
32596
-
32597
-
32598
-
32599
-
32600
-
32601
-
32602
-
32603
- /** Other platforms keep their existing path even when the option is enabled. */
32604
- function shouldPrepareDrvfsRecovery(enabled) {
32605
- return enabled === true && (process.platform === "linux" || getFsSafeTestHooks()?.drvfsMountObservation !== undefined);
32606
- }
32607
- /** No sampling or positive cache: the retained directory's exact mount owns admission. */
32608
- function admitsDrvfsRenameRecoveryAtFd(parentFd) {
32609
- try {
32610
- const hook = getFsSafeTestHooks()?.drvfsMountObservation;
32611
- if (!hook && process.platform !== "linux")
32612
- return false;
32613
- if (!Number.isInteger(parentFd) || parentFd < 0)
32614
- return false;
32615
- const observation = hook ? hook(parentFd) : (() => {
32616
- if (external_node_fs_.statfsSync("/proc/self/fd", { bigint: true }).type !== 0x9fa0n)
32617
- return undefined;
32618
- // statfs follows this kernel-owned descriptor alias to the retained parent.
32619
- return {
32620
- magic: external_node_fs_.statfsSync(`/proc/self/fd/${parentFd}`, { bigint: true }).type,
32621
- fdinfo: external_node_fs_.readFileSync(`/proc/self/fdinfo/${parentFd}`, "utf8"),
32622
- mountinfo: external_node_fs_.readFileSync("/proc/self/mountinfo", "utf8"),
32623
- };
32624
- })();
32625
- if (!observation || observation.magic !== 0x01021997n)
32626
- return false;
32627
- const ids = [...observation.fdinfo.matchAll(/^mnt_id:\s*(\d+)\s*$/gm)];
32628
- if (ids.length !== 1)
32629
- return false;
32630
- const entries = observation.mountinfo.split("\n").filter(line => line.split(" ")[0] === ids[0][1]);
32631
- if (entries.length !== 1)
32632
- return false;
32633
- const [before, after, extra] = entries[0].split(" - ");
32634
- if (!before || !after || extra !== undefined || before.split(" ").length < 6)
32635
- return false;
32636
- const fields = after.split(" ");
32637
- return fields.length === 3 && fields[0] === "9p" &&
32638
- fields[2].split(",").some(option => option === "aname=drvfs" || option.startsWith("aname=drvfs;"));
32639
- }
32640
- catch {
32641
- return false;
32642
- }
32643
- }
32644
- /** Exact metadata is necessary but cannot exclude inode reuse after the final close. */
32645
- function assertRecoveredPublication(actual, expected) {
32646
- if (!actual.isFile() || actual.isSymbolicLink() || actual.nlink !== 1n ||
32647
- actual.dev !== expected.dev || actual.ino !== expected.ino || actual.size !== expected.size ||
32648
- actual.mode !== expected.mode || actual.uid !== expected.uid || actual.gid !== expected.gid) {
32649
- throw new errors_FsSafeError("path-mismatch", "published file changed during DrvFS recovery");
32650
- }
32651
- }
32652
- async function recoverAfterHiddenRename(params) {
32653
- if (!admitsDrvfsRenameRecoveryAtFd(params.parentFd)) {
32654
- throw new errors_FsSafeError("path-mismatch", "hidden rename recovery requires a verified DrvFS mount");
32655
- }
32656
- await params.closeWriter();
32657
- for (let attempt = 0;; attempt++) {
32658
- let recovered;
32659
- try {
32660
- recovered = await params.reopen();
32661
- }
32662
- catch (error) {
32663
- if (!hasErrorCode(error, "ENOENT") || attempt === 4)
32664
- throw error;
32665
- await sleep(20);
32666
- continue;
32667
- }
32668
- try {
32669
- await params.retain?.(recovered);
32670
- }
32671
- catch (error) {
32672
- await params.dispose?.(recovered).catch(() => undefined);
32673
- throw error;
32674
- }
32675
- return recovered;
32676
- }
32677
- }
32678
- function recoverAfterHiddenRenameSync(params) {
32679
- if (!admitsDrvfsRenameRecoveryAtFd(params.parentFd)) {
32680
- throw new errors_FsSafeError("path-mismatch", "hidden rename recovery requires a verified DrvFS mount");
32681
- }
32682
- params.closeWriter();
32683
- for (let attempt = 0;; attempt++) {
32684
- try {
32685
- return params.reopen();
32686
- }
32687
- catch (error) {
32688
- if (!hasErrorCode(error, "ENOENT") || attempt === 4)
32689
- throw error;
32690
- sleepSync(20);
32691
- }
32692
- }
32693
- }
32694
- function assertRecoveredFile(fd, expected, content) {
32695
- assertRecoveredPublication(external_node_fs_.fstatSync(fd, { bigint: true }), expected);
32696
- if (content && !bounded_read_readFileDescriptorBoundedSync(fd, content.byteLength).equals(content)) {
32697
- throw new errors_FsSafeError("path-mismatch", "published content changed during DrvFS recovery");
32698
- }
32699
- assertRecoveredPublication(external_node_fs_.fstatSync(fd, { bigint: true }), expected);
32700
- }
32701
- function reopenRecoveredNativeFile(binding, parentFd, basename, expected, content) {
32702
- if (!binding.openBeneath || !binding.closeOwnedFd || !binding.stagedFileMatches) {
32703
- throw new errors_FsSafeError("helper-unavailable", "native DrvFS recovery requires descriptor-relative verification");
32704
- }
32705
- const fd = binding.openBeneath(parentFd, basename, nativeOpenFlags(external_node_fs_.constants.O_RDONLY | external_node_fs_.constants.O_NONBLOCK)).fd;
32706
- try {
32707
- assertRecoveredFile(fd, expected, content);
32708
- if (!binding.stagedFileMatches(parentFd, basename, fd)) {
32709
- throw new errors_FsSafeError("path-mismatch", "published name changed during DrvFS recovery");
32710
- }
32711
- return fd;
32712
- }
32713
- catch (error) {
32714
- binding.closeOwnedFd(fd);
32715
- throw error;
32716
- }
32717
- }
32718
-
32719
32759
  ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/directory-receipt.js
32720
32760
 
32721
32761
 
@@ -33308,8 +33348,11 @@ function staged_directory_openStagedDirectory(directory) {
33308
33348
 
33309
33349
 
33310
33350
 
33351
+
33311
33352
  /** Retained only for an explicitly enabled operation; no new default-path I/O. */
33312
- function retainDrvfsParent(directory) {
33353
+ function retainDrvfsParent(directory, dev, filesystemChecked = false) {
33354
+ if (!shouldPrepareDrvfsRecovery(true, dev))
33355
+ return undefined;
33313
33356
  let parent;
33314
33357
  try {
33315
33358
  // Resolve through the filesystem first: lexical normalization of link/..
@@ -33323,6 +33366,11 @@ function retainDrvfsParent(directory) {
33323
33366
  assertStagedDirectoryCurrent(retained.receipt);
33324
33367
  };
33325
33368
  assertCurrent();
33369
+ if (!filesystemChecked && !mayPrepareDrvfsRecoveryAtFd(retained.fd, retained.receipt.identity.dev)) {
33370
+ parent = undefined;
33371
+ external_node_fs_.closeSync(retained.fd);
33372
+ return undefined;
33373
+ }
33326
33374
  return { fd: retained.fd, assertCurrent, close() { external_node_fs_.closeSync(retained.fd); } };
33327
33375
  }
33328
33376
  catch {
@@ -33442,10 +33490,10 @@ class AtomicTempOwner {
33442
33490
  throw new Error("Atomic temp owner has no descriptor");
33443
33491
  return this.resource.fd;
33444
33492
  }
33445
- *prepareRecovery(content, directory = external_node_path_.dirname(this.pathname)) {
33493
+ *prepareRecovery(content, directory = external_node_path_.dirname(this.pathname), filesystemChecked = false) {
33446
33494
  if (!shouldPrepareDrvfsRecovery(true))
33447
33495
  return;
33448
- this.recoveryParent = retainDrvfsParent(directory);
33496
+ this.recoveryParent = retainDrvfsParent(directory, this.identity.dev, filesystemChecked);
33449
33497
  if (!this.recoveryParent)
33450
33498
  return;
33451
33499
  const observed = this.resource.statExact();
@@ -35798,11 +35846,11 @@ function fileLockSyncRootReceiptStillCurrent(pathAuthority, receipt) {
35798
35846
 
35799
35847
 
35800
35848
 
35801
- async function rootSidecarPublicationPending(lockRoot, relative, cleanAbandoned = false) {
35849
+ async function rootSidecarPublicationPending(lockRoot, relative, options = {}) {
35802
35850
  const resolved = await lockRoot.resolve(relative);
35803
35851
  const parent = external_node_path_.dirname(resolved);
35804
35852
  const identity = await directory_guard_inspectDirectoryIdentity(parent);
35805
- if (cleanAbandoned) {
35853
+ if (options.cleanAbandoned) {
35806
35854
  const admitted = admitFileLockSyncRootPath(captureFileLockSyncRootAuthority(lockRoot), resolved);
35807
35855
  const receipt = observeDirectory(external_node_path_.dirname(admitted.path));
35808
35856
  cleanupSidecarStages(admitted.path, candidate => {
@@ -35813,7 +35861,7 @@ async function rootSidecarPublicationPending(lockRoot, relative, cleanAbandoned
35813
35861
  assertFileLockSyncRootMutationAllowed(candidate, admitted.authority.denyMutations);
35814
35862
  });
35815
35863
  }
35816
- const pending = sidecar_lock_staging_sidecarPublicationPending(resolved);
35864
+ const pending = sidecar_lock_staging_sidecarPublicationPending(resolved, undefined, options);
35817
35865
  await directory_guard_inspectDirectoryIdentity(parent, identity);
35818
35866
  return pending && await lockRoot.resolve(relative) === resolved;
35819
35867
  }
@@ -35845,7 +35893,10 @@ async function openSidecarRoot(lockRoot, relative, discardObservation, onOpenFai
35845
35893
  break;
35846
35894
  }
35847
35895
  }
35848
- const observation = fileObservation();
35896
+ const observation = fileObservation({
35897
+ publicationPending: async (candidate, identity) => discardObservation === "changed" && candidate === resolved &&
35898
+ await rootSidecarPublicationPending(lockRoot, relative, { requireStage: true, identity }),
35899
+ });
35849
35900
  try {
35850
35901
  const opened = await observation.run(() => lockRoot.open(relative));
35851
35902
  if (opened.realPath !== expectedRealPath) {
@@ -35866,13 +35917,19 @@ async function openSidecarRoot(lockRoot, relative, discardObservation, onOpenFai
35866
35917
  return null;
35867
35918
  const discardable = observation.has(error, `unlinked:${resolved}`) ||
35868
35919
  (discardObservation === "changed" && observation.has(error, `changed:${resolved}`));
35869
- if (!discardObservation || (!missing && (!completeParents || !discardable)))
35920
+ const linkedChange = discardObservation === "changed" && observation.has(error, `linked-change:${resolved}`);
35921
+ if (!discardObservation || (!missing && (!completeParents || (!discardable && !linkedChange))))
35870
35922
  throw error;
35871
35923
  try {
35924
+ // Linked-change receipts already proved a matching stage while the exact
35925
+ // descriptor was open; retained ancestry and the current path still fence it.
35872
35926
  const probe = fileObservation();
35873
35927
  try {
35874
35928
  const current = await probe.run(() => lockRoot.stat(relative));
35875
- if (!current.isFile || current.isSymbolicLink || current.nlink !== 1)
35929
+ // A successor can still hold its matching publication-stage link.
35930
+ // Discard only the old read; retained ancestry is revalidated below.
35931
+ if (!current.isFile || current.isSymbolicLink || (current.nlink !== 1 &&
35932
+ !(current.nlink === 2 && await rootSidecarPublicationPending(lockRoot, relative))))
35876
35933
  throw error;
35877
35934
  }
35878
35935
  catch (probeError) {
@@ -43524,6 +43581,7 @@ class NativeStagedFile {
43524
43581
  #recoveryIdentity;
43525
43582
  #recoveryContent;
43526
43583
  #recovered = false;
43584
+ #prepareRecovery;
43527
43585
  #publicationTask;
43528
43586
  #rejectFinalSymlink = false;
43529
43587
  #unsupportedNoReplace;
@@ -43537,6 +43595,8 @@ class NativeStagedFile {
43537
43595
  this.#assertBeforeMutation = owner.assertBeforeMutation;
43538
43596
  this.#private = owner.permissionPolicy === "private-creation";
43539
43597
  this.#verifyMode = owner.permissionPolicy !== undefined;
43598
+ this.#prepareRecovery = shouldPrepareDrvfsRecovery(owner.allowDrvfsRenameRecovery, owner.directory.identity.dev) &&
43599
+ mayPrepareDrvfsRecoveryAtFd(owner.parentFd, owner.directory.identity.dev);
43540
43600
  }
43541
43601
  // The supplied closer owns parentFd even on construction or preparation failure.
43542
43602
  static async create(owner, input, maxBytes) {
@@ -43553,7 +43613,7 @@ class NativeStagedFile {
43553
43613
  }
43554
43614
  throw error;
43555
43615
  }
43556
- if (shouldPrepareDrvfsRecovery(owner.allowDrvfsRenameRecovery) && input.kind === "buffer") {
43616
+ if (staged.#prepareRecovery && input.kind === "buffer") {
43557
43617
  staged.#recoveryContent = typeof input.data === "string" ? Buffer.from(input.data, input.encoding) : Buffer.from(input.data);
43558
43618
  }
43559
43619
  await staged.#prepare(input, maxBytes);
@@ -43791,7 +43851,7 @@ class NativeStagedFile {
43791
43851
  this.#assertCurrent();
43792
43852
  assertFinalSymlinkRejected(external_node_path_.join(this.#owner.directory.realPath, basename), this.#rejectFinalSymlink);
43793
43853
  }
43794
- if (shouldPrepareDrvfsRecovery(this.#owner.allowDrvfsRenameRecovery)) {
43854
+ if (this.#prepareRecovery) {
43795
43855
  // Apply restrictive modes before exposing the name or releasing its last fd.
43796
43856
  if ((this.#owner.mode & 0o600) !== 0o600)
43797
43857
  external_node_fs_.fchmodSync(this.#file(), this.#owner.mode);
@@ -44391,10 +44451,11 @@ async function handleStaleSidecarAdmission(params) {
44391
44451
  throw error;
44392
44452
  }
44393
44453
  // An incomplete owner can still be writing; age is not liveness evidence.
44394
- if (!snapshot || (!params.parserState.parser && snapshot.payload === null) || isIncompleteSidecarLockRecord(snapshot.raw)) {
44454
+ if (!snapshot) {
44395
44455
  await params.waitForRetry();
44396
44456
  return;
44397
44457
  }
44458
+ const incomplete = (!params.parserState.parser && snapshot.payload === null) || isIncompleteSidecarLockRecord(snapshot.raw);
44398
44459
  const staleOptions = params.staleOptionsState;
44399
44460
  try {
44400
44461
  if (!staleOptions.shouldReclaimObserved) {
@@ -44430,7 +44491,7 @@ async function handleStaleSidecarAdmission(params) {
44430
44491
  assertUnheld();
44431
44492
  try {
44432
44493
  if (!shouldReclaim)
44433
- return defaultSidecarLockShouldReclaim(snapshot, params.staleMs, Date.now());
44494
+ return !incomplete && defaultSidecarLockShouldReclaim(snapshot, params.staleMs, Date.now());
44434
44495
  return await Reflect.apply(shouldReclaim, undefined, [{
44435
44496
  lockPath,
44436
44497
  normalizedTargetPath,
@@ -44476,6 +44537,9 @@ async function handleStaleSidecarAdmission(params) {
44476
44537
  await params.waitForRetry();
44477
44538
  return;
44478
44539
  }
44540
+ // Policy may diagnose an incomplete record, but can never authorize its removal.
44541
+ if (incomplete)
44542
+ throw sidecarLockStale(lockPath, normalizedTargetPath);
44479
44543
  if ((staleOptions.staleRecovery ?? "fail-closed") === "remove-if-unchanged") {
44480
44544
  const acquiredGuard = await admission.run(() => tryAcquireSidecarReclaimGuard(params.reclaimGuards, params.reclaimGuardPath, params.lockRoot));
44481
44545
  if (acquiredGuard)
@@ -45184,7 +45248,7 @@ async function acquireSidecarLock(options, context) {
45184
45248
  catch (error) {
45185
45249
  let cause = error;
45186
45250
  for (let depth = 0; depth < 4 && cause && typeof cause === "object"; depth++) {
45187
- if (observation.has(cause, "hardlink") && await rootSidecarPublicationPending(lockRoot, relativeLockPath, true)) {
45251
+ if (observation.has(cause, "hardlink") && await rootSidecarPublicationPending(lockRoot, relativeLockPath, { cleanAbandoned: true })) {
45188
45252
  exclusiveCreateConflict = true;
45189
45253
  throw Object.assign(new Error("sidecar publication in progress"), { code: "EEXIST" });
45190
45254
  }
@@ -46104,7 +46168,7 @@ async function runPinnedStagedWrite(params, parentPath, parentGuard) {
46104
46168
  ((params.mode & 0o400) !== 0 ||
46105
46169
  (process.platform === "linux" && (process.arch === "x64" || process.arch === "arm64")));
46106
46170
  if (shouldPrepareDrvfsRecovery(params.allowDrvfsRenameRecovery)) {
46107
- recoveryParent = retainDrvfsParent(parentPath);
46171
+ recoveryParent = retainDrvfsParent(parentPath, parentGuard.stat.dev);
46108
46172
  if (recoveryParent)
46109
46173
  recoveryIdentity = external_node_fs_.fstatSync(handle.fd, { bigint: true });
46110
46174
  if (recoveryParent && params.input.kind === "buffer")
@@ -46691,16 +46755,26 @@ function openedPathResolutionError(error = new errors_FsSafeError("path-mismatch
46691
46755
  }
46692
46756
  async function recordPreOpenFileChange(error, handle, filePath, before, opened) {
46693
46757
  if (!isFileObservationFailure(error, "identity") || !before?.isFile() || !opened?.isFile() ||
46694
- ![0n, 1n].includes(before.nlink) || ![0n, 1n].includes(opened.nlink))
46758
+ ![0n, 1n].includes(before.nlink) || ![0n, 1n, 2n].includes(opened.nlink))
46695
46759
  return;
46696
46760
  try {
46697
46761
  await strict_file_identity_inspectFileIdentity(async () => before);
46698
- const current = await strict_file_identity_inspectFileIdentity(() => process.platform === "win32"
46762
+ // A fresh exact descriptor distinguishes a completed handoff from a
46763
+ // still-linked generation that needs separate publication proof.
46764
+ const inspectCurrent = () => strict_file_identity_inspectFileIdentity(() => process.platform === "win32"
46699
46765
  ? external_node_fs_.fstatSync(handle.fd, { bigint: true }) : handle.stat({ bigint: true }), opened);
46700
- if (current.isFile() && [0n, 1n].includes(current.nlink) &&
46701
- (before.dev !== current.dev || before.ino !== current.ino)) {
46766
+ let current = await inspectCurrent();
46767
+ let publication = false;
46768
+ if (current.isFile() && current.nlink === 2n) {
46769
+ publication = await observedFilePublicationPending(filePath, current);
46770
+ current = await inspectCurrent();
46771
+ }
46772
+ if (current.isFile() && (before.dev !== current.dev || before.ino !== current.ino)) {
46702
46773
  // A stale pathname sample is not proof that its former inode was unlinked.
46703
- recordFileObservationFailure(error, `changed:${filePath}`);
46774
+ if ([0n, 1n].includes(current.nlink))
46775
+ recordFileObservationFailure(error, `changed:${filePath}`);
46776
+ else if (current.nlink === 2n && publication)
46777
+ recordFileObservationFailure(error, `linked-change:${filePath}`);
46704
46778
  }
46705
46779
  }
46706
46780
  catch {
@@ -46806,7 +46880,7 @@ async function openLocalFileDescriptor(filePath, options) {
46806
46880
  : await strict_file_identity_inspectFileIdentity(async () => inspect(await handle.stat({ bigint: true })), expected);
46807
46881
  }
46808
46882
  catch (error) {
46809
- if (openedIdentity && [0n, 1n].includes(openedIdentity.nlink)) {
46883
+ if (openedIdentity && [0n, 1n, 2n].includes(openedIdentity.nlink)) {
46810
46884
  await recordPreOpenFileChange(error, handle, filePath, preOpenStat, openedIdentity);
46811
46885
  }
46812
46886
  throw error;
@@ -50938,8 +51012,12 @@ async function commitPinnedWriteInRoot(root, pinned, params, input) {
50938
51012
  });
50939
51013
  }
50940
51014
  catch (error) {
50941
- if (error instanceof SidecarFallbackWriteError)
50942
- throw error.failure;
51015
+ if (error instanceof SidecarFallbackWriteError) {
51016
+ // Windows keeps its historical direct-write error identity.
51017
+ if (process.platform === "win32")
51018
+ throw error.failure;
51019
+ error = error.failure;
51020
+ }
50943
51021
  if (verifyingPublication)
50944
51022
  throw error;
50945
51023
  const errorCode = error?.code;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lousy-agents/mcp",
3
- "version": "5.23.8",
3
+ "version": "5.23.10",
4
4
  "description": "MCP server for lousy-agents - provides AI coding assistant tools via the Model Context Protocol",
5
5
  "type": "module",
6
6
  "repository": {