@lousy-agents/mcp 5.23.0 → 5.23.2

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 +114 -87
  2. package/package.json +1 -1
@@ -29226,18 +29226,16 @@ async function writeAllToFile(target, data, options = {}) {
29226
29226
  const length = Math.min(WRITE_CHUNK_BYTES, buffer.byteLength - offset);
29227
29227
  const position = options.position === undefined ? null : options.position + offset;
29228
29228
  options.assertBeforeMutation?.();
29229
- const written = typeof target === "number" && options.synchronous
29230
- ? external_node_fs_.writeSync(target, buffer, offset, length, position)
29231
- : typeof target === "number"
29232
- ? await new Promise((resolve, reject) => {
29233
- external_node_fs_.write(target, buffer, offset, length, position, (error, bytesWritten) => {
29234
- if (error)
29235
- reject(error);
29236
- else
29237
- resolve(bytesWritten);
29238
- });
29239
- })
29240
- : (await target.write(buffer, offset, length, position)).bytesWritten;
29229
+ const written = typeof target === "number"
29230
+ ? await new Promise((resolve, reject) => {
29231
+ external_node_fs_.write(target, buffer, offset, length, position, (error, bytesWritten) => {
29232
+ if (error)
29233
+ reject(error);
29234
+ else
29235
+ resolve(bytesWritten);
29236
+ });
29237
+ })
29238
+ : (await target.write(buffer, offset, length, position)).bytesWritten;
29241
29239
  if (written <= 0) {
29242
29240
  throw new errors_FsSafeError("helper-failed", "file write made no progress");
29243
29241
  }
@@ -30285,6 +30283,7 @@ function assertWindowsAclRemediationAllowed() {
30285
30283
 
30286
30284
 
30287
30285
 
30286
+
30288
30287
  const runtimePlatform = process.versions.bun ? (0,external_node_os_.platform)() : undefined;
30289
30288
  const bunPosix = runtimePlatform === "darwin" || runtimePlatform === "linux" ? runtimePlatform : undefined;
30290
30289
  function realpath_resolve(input, native) {
@@ -30353,6 +30352,21 @@ function realpath_resolve(input, native) {
30353
30352
  const realpath_realpathSync = Object.assign((input) => realpath_resolve(input, false), {
30354
30353
  native: (input) => realpath_resolve(input, true),
30355
30354
  });
30355
+ /** Async on Node; retain runtime-specific native canonicalization guarantees. */
30356
+ async function realpath_realpathNative(input) {
30357
+ if (bunPosix)
30358
+ return realpath_realpathSync.native(input);
30359
+ try {
30360
+ return await promises_.realpath(input);
30361
+ }
30362
+ catch (error) {
30363
+ if (process.platform !== "win32" || error.code !== "EPERM" ||
30364
+ error.syscall !== "realpath")
30365
+ throw error;
30366
+ // AppContainer DOS-name translation still belongs to the native sync owner.
30367
+ return realpath_realpathSync.native(input);
30368
+ }
30369
+ }
30356
30370
 
30357
30371
  ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/directory-entry-path.js
30358
30372
 
@@ -31563,7 +31577,7 @@ async function resolveAbsolutePathForRead(filePath, options = {}) {
31563
31577
  const normalized = assertAbsolutePathInput(filePath);
31564
31578
  let canonicalPath;
31565
31579
  try {
31566
- canonicalPath = realpathSync.native(pathForWindowsFilesystem(normalized));
31580
+ canonicalPath = await realpathNative(pathForWindowsFilesystem(normalized));
31567
31581
  assertNoWindowsPathAlias(canonicalPath);
31568
31582
  }
31569
31583
  catch (err) {
@@ -33496,6 +33510,12 @@ function root_boundary_admitPathInsideRoot(params) {
33496
33510
 
33497
33511
 
33498
33512
 
33513
+
33514
+
33515
+ // Windows native realpath denies delete sharing. Preserve read/publication
33516
+ // scheduling until canonicalization can safely overlap replacement.
33517
+ const synchronousRootTraversal = process.platform === "win32";
33518
+ const root_path_existing_runRootTraversal = synchronousRootTraversal ? atomic_io_runSync : runAsync;
33499
33519
  function absolutePathWithRawSegments(candidate) {
33500
33520
  if (external_node_path_.sep !== "\\") {
33501
33521
  if (external_node_path_.isAbsolute(candidate))
@@ -33513,7 +33533,7 @@ function absolutePathWithRawSegments(candidate) {
33513
33533
  const base = drive ? external_node_path_.resolve(drive) : process.cwd();
33514
33534
  return `${base}${base.endsWith(external_node_path_.sep) ? "" : external_node_path_.sep}${raw.slice(drive.length)}`;
33515
33535
  }
33516
- function rawPathRelativeToCanonicalRoot(candidate, rootCanonicalPath, options = {}) {
33536
+ function* rawPathRelativeToCanonicalRoot(candidate, rootCanonicalPath, options = {}, synchronous = true) {
33517
33537
  windows_path_alias_assertNoWindowsPathAlias(candidate);
33518
33538
  windows_path_alias_assertNoWindowsPathAlias(rootCanonicalPath);
33519
33539
  const absolute = absolutePathWithRawSegments(candidate);
@@ -33532,7 +33552,7 @@ function rawPathRelativeToCanonicalRoot(candidate, rootCanonicalPath, options =
33532
33552
  let isSymlink = false;
33533
33553
  try {
33534
33554
  const operationPath = windows_path_alias_pathForWindowsFilesystem(prefix);
33535
- const stat = external_node_fs_.lstatSync(operationPath);
33555
+ const stat = synchronous ? external_node_fs_.lstatSync(operationPath) : yield* wait(promises_.lstat(operationPath));
33536
33556
  isSymlink = stat.isSymbolicLink();
33537
33557
  // Check the original leaf before canonicalization can erase an entry alias.
33538
33558
  if (isSymlink && options.rejectFinalSymlink && index === finalComponentIndex) {
@@ -33541,10 +33561,11 @@ function rawPathRelativeToCanonicalRoot(candidate, rootCanonicalPath, options =
33541
33561
  if (!isSymlink && !stat.isDirectory() && index < segments.length - 1)
33542
33562
  return undefined;
33543
33563
  traversedSymlink ||= isSymlink;
33544
- canonical = realpath_realpathSync.native(operationPath);
33564
+ canonical = synchronous ? realpath_realpathSync.native(operationPath) : yield* wait(realpath_realpathNative(operationPath));
33545
33565
  windows_path_alias_assertNoWindowsPathAlias(canonical);
33546
33566
  if (isSymlink && index < segments.length - 1 &&
33547
- !external_node_fs_.statSync(windows_path_alias_pathForWindowsFilesystem(canonical)).isDirectory())
33567
+ !(synchronous ? external_node_fs_.statSync(windows_path_alias_pathForWindowsFilesystem(canonical))
33568
+ : yield* wait(promises_.stat(windows_path_alias_pathForWindowsFilesystem(canonical)))).isDirectory())
33548
33569
  return undefined;
33549
33570
  if (isSymlink && !isPathInside(rootCanonicalPath, canonical) && !isPathInside(canonical, rootCanonicalPath)) {
33550
33571
  throw new errors_FsSafeError("outside-workspace", `symlink prefix resolves outside the root ancestry: ${formatErrorDetail(candidate)}`);
@@ -33573,9 +33594,10 @@ function rawPathRelativeToCanonicalRoot(candidate, rootCanonicalPath, options =
33573
33594
  }
33574
33595
  return undefined;
33575
33596
  }
33576
- function root_path_existing_pathExists(targetPath) {
33597
+ function* root_path_existing_pathExists(targetPath, synchronous) {
33577
33598
  try {
33578
- return external_node_fs_.lstatSync(windows_path_alias_pathForWindowsFilesystem(targetPath), { throwIfNoEntry: false }) !== undefined;
33599
+ return (synchronous ? external_node_fs_.lstatSync(windows_path_alias_pathForWindowsFilesystem(targetPath), { throwIfNoEntry: false })
33600
+ : yield* wait(promises_.lstat(windows_path_alias_pathForWindowsFilesystem(targetPath)))) !== undefined;
33579
33601
  }
33580
33602
  catch (error) {
33581
33603
  if (path_isNotFoundPathError(error)) {
@@ -33585,17 +33607,20 @@ function root_path_existing_pathExists(targetPath) {
33585
33607
  }
33586
33608
  }
33587
33609
  async function resolvePathViaExistingAncestor(targetPath) {
33588
- return resolveExistingAncestor(targetPath, "native");
33610
+ return root_path_existing_runRootTraversal(resolveExistingAncestorProcedure(targetPath, "native", synchronousRootTraversal));
33589
33611
  }
33590
- function pathExistsSync(targetPath) {
33612
+ function* ordinaryExists(targetPath) {
33591
33613
  return external_node_fs_.existsSync(windows_path_alias_pathForWindowsFilesystem(targetPath));
33592
33614
  }
33593
33615
  function resolvePathViaExistingAncestorSync(targetPath) {
33594
33616
  return resolveExistingAncestor(targetPath, "ordinary");
33595
33617
  }
33596
33618
  function resolveExistingAncestor(targetPath, mode, preserveRawSegments = false, remainingHops = 64) {
33597
- const exists = mode === "native" || preserveRawSegments ? root_path_existing_pathExists : pathExistsSync;
33598
- const canonicalize = realpath_realpathSync.native;
33619
+ return atomic_io_runSync(resolveExistingAncestorProcedure(targetPath, mode, true, preserveRawSegments, remainingHops));
33620
+ }
33621
+ function* resolveExistingAncestorProcedure(targetPath, mode, synchronous, preserveRawSegments = false, remainingHops = 64) {
33622
+ const exists = (pathname) => mode === "native" || preserveRawSegments
33623
+ ? root_path_existing_pathExists(pathname, synchronous) : ordinaryExists(pathname);
33599
33624
  windows_path_alias_assertNoWindowsPathAlias(targetPath);
33600
33625
  const normalized = windows_path_alias_resolvePathPreservingWindowsRoot(targetPath);
33601
33626
  windows_path_alias_assertNoWindowsPathAlias(normalized);
@@ -33603,22 +33628,23 @@ function resolveExistingAncestor(targetPath, mode, preserveRawSegments = false,
33603
33628
  let cursor = candidate;
33604
33629
  const filesystemRoot = external_node_path_.parse(candidate).root;
33605
33630
  while (cursor !== filesystemRoot &&
33606
- !exists(cursor)) {
33631
+ !(yield* exists(cursor))) {
33607
33632
  cursor = external_node_path_.dirname(cursor);
33608
33633
  }
33609
- if (!exists(cursor)) {
33634
+ if (!(yield* exists(cursor))) {
33610
33635
  return normalized;
33611
33636
  }
33612
33637
  let rawResolvedAncestor;
33613
33638
  try {
33614
- rawResolvedAncestor = canonicalize(windows_path_alias_pathForWindowsFilesystem(cursor));
33639
+ rawResolvedAncestor = synchronous ? realpath_realpathSync.native(windows_path_alias_pathForWindowsFilesystem(cursor))
33640
+ : yield* wait(realpath_realpathNative(windows_path_alias_pathForWindowsFilesystem(cursor)));
33615
33641
  }
33616
33642
  catch (error) {
33617
33643
  if (!preserveRawSegments)
33618
33644
  return normalized;
33619
33645
  if (!path_isNotFoundPathError(error))
33620
33646
  throw error;
33621
- rawResolvedAncestor = resolveSymlinkHopPath(cursor, mode, false, remainingHops);
33647
+ rawResolvedAncestor = yield* resolveSymlinkHopPath(cursor, mode, false, remainingHops, synchronous);
33622
33648
  }
33623
33649
  windows_path_alias_assertNoWindowsPathAlias(rawResolvedAncestor);
33624
33650
  const resolvedAncestor = windows_path_alias_resolvePathPreservingWindowsRoot(rawResolvedAncestor);
@@ -33634,10 +33660,10 @@ function resolveExistingAncestor(targetPath, mode, preserveRawSegments = false,
33634
33660
  windows_path_alias_assertNoWindowsPathAlias(resolved);
33635
33661
  return resolved;
33636
33662
  }
33637
- function resolveSymlinkHopPath(symlinkPath, mode, rejectUnresolved, remainingHops = 64) {
33663
+ function* resolveSymlinkHopPath(symlinkPath, mode, rejectUnresolved, remainingHops = 64, synchronous = true) {
33638
33664
  try {
33639
- const canonicalize = realpath_realpathSync.native;
33640
- const rawRealPath = canonicalize(symlinkPath);
33665
+ const rawRealPath = synchronous ? realpath_realpathSync.native(symlinkPath)
33666
+ : yield* wait(realpath_realpathNative(symlinkPath));
33641
33667
  windows_path_alias_assertNoWindowsPathAlias(rawRealPath, "filesystem", "resolved symlink path uses a Windows filesystem namespace alias");
33642
33668
  const realPath = windows_path_alias_resolvePathPreservingWindowsRoot(rawRealPath);
33643
33669
  windows_path_alias_assertNoWindowsPathAlias(realPath, "filesystem", "resolved symlink path uses a Windows filesystem namespace alias");
@@ -33651,14 +33677,14 @@ function resolveSymlinkHopPath(symlinkPath, mode, rejectUnresolved, remainingHop
33651
33677
  throw error;
33652
33678
  if (remainingHops <= 0)
33653
33679
  throw new errors_FsSafeError("symlink", "too many unresolved symlink hops");
33654
- const linkTarget = external_node_fs_.readlinkSync(symlinkPath);
33680
+ const linkTarget = synchronous ? external_node_fs_.readlinkSync(symlinkPath) : yield* wait(promises_.readlink(symlinkPath));
33655
33681
  windows_path_alias_assertNoWindowsPathAlias(linkTarget, "filesystem", "symlink target uses a Windows filesystem namespace alias");
33656
33682
  const linkDir = windows_path_alias_resolvePathPreservingWindowsRoot(external_node_path_.dirname(symlinkPath));
33657
33683
  // Keep parent segments until the kernel has resolved the existing prefix.
33658
33684
  const targetPath = external_node_path_.isAbsolute(linkTarget) ? linkTarget
33659
33685
  : external_node_path_.parse(linkTarget).root ? windows_path_alias_resolvePathFromBasePreservingWindowsRoot(linkDir, linkTarget)
33660
33686
  : `${linkDir}${external_node_path_.sep}${linkTarget}`;
33661
- const resolved = resolveExistingAncestor(targetPath, mode, true, remainingHops - 1);
33687
+ const resolved = yield* resolveExistingAncestorProcedure(targetPath, mode, synchronous, true, remainingHops - 1);
33662
33688
  windows_path_alias_assertNoWindowsPathAlias(resolved, "filesystem", "resolved symlink path uses a Windows filesystem namespace alias");
33663
33689
  return resolved;
33664
33690
  }
@@ -33786,7 +33812,7 @@ async function runAsync(procedure) {
33786
33812
  }
33787
33813
  return step.value;
33788
33814
  }
33789
- function runSync(procedure) {
33815
+ function atomic_io_runSync(procedure) {
33790
33816
  let step = procedure.next();
33791
33817
  // Sync adapters retain their ordinary return values; this driver never reads then.
33792
33818
  while (!step.done)
@@ -34737,21 +34763,21 @@ function probeTemporaryEntry(directory) {
34737
34763
  const owner = new AtomicTempOwner(external_node_path_.join(directory, name), io);
34738
34764
  try {
34739
34765
  owner.start();
34740
- owner.adopt(runSync(writeTempFile(io, {
34766
+ owner.adopt(atomic_io_runSync(writeTempFile(io, {
34741
34767
  tempPath: owner.pathname,
34742
34768
  content: "",
34743
34769
  mode: 0o600,
34744
34770
  sync: false,
34745
34771
  onIdentity: owner.onIdentity,
34746
34772
  })));
34747
- runSync(owner.assertCurrent());
34773
+ atomic_io_runSync(owner.assertCurrent());
34748
34774
  const observed = probeEntry(directory, name, new Set(external_node_fs_.readdirSync(directory)));
34749
- runSync(owner.assertCurrent());
34775
+ atomic_io_runSync(owner.assertCurrent());
34750
34776
  return observed;
34751
34777
  }
34752
34778
  finally {
34753
34779
  // Failed cleanup invalidates the observation; the existing owner retains its exit retry.
34754
- runSync(owner.finish({ throwOnCleanupError: true }));
34780
+ atomic_io_runSync(owner.finish({ throwOnCleanupError: true }));
34755
34781
  }
34756
34782
  }
34757
34783
  function probeDirectory(directory, allowTemporaryProbe, preferredName) {
@@ -37412,6 +37438,8 @@ function captureRootPathObservedDirectory(observation, observed, publicPath, can
37412
37438
 
37413
37439
 
37414
37440
 
37441
+
37442
+
37415
37443
  const ROOT_PATH_ALIAS_POLICIES = {
37416
37444
  strict: Object.freeze({
37417
37445
  allowFinalSymlinkForUnlink: false,
@@ -37423,36 +37451,38 @@ const ROOT_PATH_ALIAS_POLICIES = {
37423
37451
  }),
37424
37452
  };
37425
37453
  async function root_path_resolveRootPath(params) {
37426
- return resolveRootPathInternal(params);
37454
+ return root_path_existing_runRootTraversal(resolveRootPathInternal(params));
37427
37455
  }
37428
37456
  async function resolveRootPathWithCanonicalRootObservation(params, observeRoot) {
37429
- return resolveRootPathInternal(params, { observeRoot });
37457
+ return runRootTraversal(resolveRootPathInternal(params, { observeRoot }));
37430
37458
  }
37431
37459
  async function resolveRootPathWithObservation(params, request) {
37432
37460
  const observation = { request };
37433
- const resolved = resolveRootPathInternal(params, { observation });
37461
+ const resolved = synchronousRootTraversal
37462
+ ? atomic_io_runSync(resolveRootPathInternal(params, { observation }))
37463
+ : await root_path_existing_runRootTraversal(resolveRootPathInternal(params, { observation }));
37434
37464
  return observation.receipt ? { resolved, receipt: observation.receipt } : { resolved };
37435
37465
  }
37436
37466
  // Removal receipts are separate from metadata observations and canonical-root
37437
- // callbacks; the public resolver's options and result remain unchanged.
37467
+ // callbacks; retain their synchronous admission and mutation-fence owner.
37438
37468
  async function resolveRootPathForRemoval(params, receipts) {
37439
- return resolveRootPathInternal(params, { removalReceipts: receipts });
37469
+ return atomic_io_runSync(resolveRootPathInternal(params, { removalReceipts: receipts }, true));
37440
37470
  }
37441
37471
  function root_path_resolveRootPathSync(params) {
37442
- return resolveRootPathInternal(params, { mode: "ordinary" });
37472
+ return atomic_io_runSync(resolveRootPathInternal(params, { mode: "ordinary" }, true));
37443
37473
  }
37444
37474
  function resolveRootPathSyncWithCanonicalRootObservation(params, observeRoot) {
37445
- return resolveRootPathInternal(params, { mode: "ordinary", observeRoot });
37475
+ return runSync(resolveRootPathInternal(params, { mode: "ordinary", observeRoot }, true));
37446
37476
  }
37447
- function resolveRootPathInternal(params, options = {}) {
37477
+ function* resolveRootPathInternal(params, options = {}, synchronous = synchronousRootTraversal) {
37448
37478
  try {
37449
- return traverseRootPath(params, options);
37479
+ return yield* traverseRootPath(params, options, synchronous);
37450
37480
  }
37451
37481
  catch (error) {
37452
37482
  throw sanitizeRootPathError(error);
37453
37483
  }
37454
37484
  }
37455
- function prepareRootTraversal(params, rootPath, rootCanonicalPath, absolutePath, rawAbsolutePath) {
37485
+ function* prepareRootTraversal(params, rootPath, rootCanonicalPath, absolutePath, rawAbsolutePath, synchronous) {
37456
37486
  let raw = rawAbsolutePath;
37457
37487
  let trustedAbsolutePath = false;
37458
37488
  // Even a metadata lookup on a foreign share contacts that host, including the
@@ -37468,7 +37498,7 @@ function prepareRootTraversal(params, rootPath, rootCanonicalPath, absolutePath,
37468
37498
  else {
37469
37499
  const canonical = admitRawPathInsideRoot(rootCanonicalPath, raw, params.rootIdentity);
37470
37500
  const relative = canonical?.relativePath
37471
- ?? rawPathRelativeToCanonicalRoot(raw, rootCanonicalPath, params);
37501
+ ?? (yield* rawPathRelativeToCanonicalRoot(raw, rootCanonicalPath, params, synchronous));
37472
37502
  if (relative === undefined) {
37473
37503
  throw pathEscapeError({ rootPath, absolutePath: raw, boundaryLabel: params.boundaryLabel });
37474
37504
  }
@@ -37649,27 +37679,28 @@ function assertDirectoryBeforeMoreSegments(stat, pathname, isLast) {
37649
37679
  throw Object.assign(new Error(`Path component is not a directory: ${pathname}`), { code: "ENOTDIR" });
37650
37680
  }
37651
37681
  }
37652
- function assertResolvedLinkDirectory(pathname, isLast) {
37682
+ function* assertResolvedLinkDirectory(pathname, isLast, synchronous) {
37653
37683
  if (isLast)
37654
37684
  return;
37655
- const stat = external_node_fs_.statSync(windows_path_alias_pathForWindowsFilesystem(pathname));
37685
+ const stat = synchronous ? external_node_fs_.statSync(windows_path_alias_pathForWindowsFilesystem(pathname))
37686
+ : yield* wait(promises_.stat(windows_path_alias_pathForWindowsFilesystem(pathname)));
37656
37687
  assertDirectoryBeforeMoreSegments(stat, pathname, isLast);
37657
37688
  }
37658
- // Both public APIs use kernel canonicalization and synchronous metadata; only
37659
- // ancestor existence differs. Promise wrappers preserve asynchronous rejection.
37660
- function traverseRootPath(params, { mode = "native", observation: observationOutput, observeRoot, removalReceipts }) {
37689
+ // Both drivers share containment policy. Observation receipts and platform-specific
37690
+ // native guards retain their existing synchronous owners.
37691
+ function* traverseRootPath(params, { mode = "native", observation: observationOutput, observeRoot, removalReceipts }, synchronous) {
37661
37692
  const input = captureValidRootPathInputs(params);
37662
37693
  const rawAbsolutePath = absolutePathWithRawSegments(input.absolutePath);
37663
37694
  const rootPath = windows_path_alias_resolvePathPreservingWindowsRoot(input.rootPath);
37664
37695
  const absolutePath = windows_path_alias_resolvePathPreservingWindowsRoot(rawAbsolutePath);
37665
37696
  const rootCanonicalPath = input.rootCanonicalPath
37666
37697
  ? windows_path_alias_resolvePathPreservingWindowsRoot(input.rootCanonicalPath)
37667
- : resolveExistingAncestor(rootPath, mode);
37698
+ : yield* resolveExistingAncestorProcedure(rootPath, mode, synchronous);
37668
37699
  windows_path_alias_assertNoWindowsPathAlias(rootPath);
37669
37700
  windows_path_alias_assertNoWindowsPathAlias(absolutePath);
37670
37701
  windows_path_alias_assertNoWindowsPathAlias(rootCanonicalPath);
37671
37702
  observeRoot?.(rootCanonicalPath);
37672
- const context = createLexicalTraversalContext(prepareRootTraversal(input, rootPath, rootCanonicalPath, absolutePath, rawAbsolutePath));
37703
+ const context = createLexicalTraversalContext(yield* prepareRootTraversal(input, rootPath, rootCanonicalPath, absolutePath, rawAbsolutePath, synchronous));
37673
37704
  const { state } = context;
37674
37705
  const observation = createLexicalTraversalObservation(context, observationOutput?.request);
37675
37706
  for (let idx = 0; idx < state.segments.length; idx += 1) {
@@ -37706,7 +37737,8 @@ function traverseRootPath(params, { mode = "native", observation: observationOut
37706
37737
  }
37707
37738
  stat = isNativeDirectoryObservationGuard(observed)
37708
37739
  ? undefined
37709
- : observed?.stat ?? external_node_fs_.lstatSync(state.lexicalCursor);
37740
+ : observed?.stat ?? (synchronous ? external_node_fs_.lstatSync(state.lexicalCursor)
37741
+ : yield* wait(promises_.lstat(state.lexicalCursor)));
37710
37742
  }
37711
37743
  }
37712
37744
  catch (error) {
@@ -37769,12 +37801,12 @@ function traverseRootPath(params, { mode = "native", observation: observationOut
37769
37801
  }
37770
37802
  if (observation?.enabled)
37771
37803
  disableLexicalTraversalObservation(context, observation);
37772
- const linkCanonical = resolveSymlinkHopPath(state.lexicalCursor, mode, context.resolveParams.rejectUnresolvedSymlinks);
37804
+ const linkCanonical = yield* resolveSymlinkHopPath(state.lexicalCursor, mode, context.resolveParams.rejectUnresolvedSymlinks, 64, synchronous);
37773
37805
  applyResolvedSymlinkHop(context, linkCanonical);
37774
37806
  if (context.resolveParams.rejectSymlinks === true) {
37775
37807
  throw new errors_FsSafeError("symlink", "symlink path component not allowed");
37776
37808
  }
37777
- assertResolvedLinkDirectory(linkCanonical, isLast);
37809
+ yield* assertResolvedLinkDirectory(linkCanonical, isLast, synchronous);
37778
37810
  }
37779
37811
  const completeObservation = observation?.enabled === true && observation.directoryGuard !== undefined &&
37780
37812
  observation.targetPath === state.canonicalCursor && observation.target !== undefined;
@@ -37782,7 +37814,7 @@ function traverseRootPath(params, { mode = "native", observation: observationOut
37782
37814
  ? isNativeDirectoryObservationGuard(observation.target)
37783
37815
  ? "directory"
37784
37816
  : toResolvedKind(observation.target.stat)
37785
- : getPathKindSync(state.canonicalCursor, state.preserveFinalSymlink);
37817
+ : yield* getPathKind(state.canonicalCursor, state.preserveFinalSymlink, synchronous);
37786
37818
  if (completeObservation && observationOutput) {
37787
37819
  observationOutput.receipt = {
37788
37820
  kind: observation.request.kind,
@@ -37795,12 +37827,12 @@ function traverseRootPath(params, { mode = "native", observation: observationOut
37795
37827
  }
37796
37828
  return finalizeLexicalResolution(context, kind);
37797
37829
  }
37798
- function getPathKindSync(absolutePath, preserveFinalSymlink) {
37830
+ function* getPathKind(absolutePath, preserveFinalSymlink, synchronous) {
37799
37831
  try {
37800
37832
  const operationPath = windows_path_alias_pathForWindowsFilesystem(absolutePath);
37801
37833
  const stat = preserveFinalSymlink
37802
- ? external_node_fs_.lstatSync(operationPath)
37803
- : external_node_fs_.statSync(operationPath);
37834
+ ? synchronous ? external_node_fs_.lstatSync(operationPath) : yield* wait(promises_.lstat(operationPath))
37835
+ : synchronous ? external_node_fs_.statSync(operationPath) : yield* wait(promises_.stat(operationPath));
37804
37836
  return toResolvedKind(stat);
37805
37837
  }
37806
37838
  catch (error) {
@@ -40864,7 +40896,6 @@ function replayPinnedInput(fd, input) {
40864
40896
  })() };
40865
40897
  }
40866
40898
  const pinned_write_input_isUint8Array = external_node_util_.types.isUint8Array;
40867
- const SMALL_BUFFER_BYTES = 64 * 1024;
40868
40899
  function streamChunkBytes(chunk) {
40869
40900
  if (Buffer.isBuffer(chunk))
40870
40901
  return chunk;
@@ -40879,16 +40910,6 @@ async function writePinnedInput(target, input, maxBytes, assertBeforeMutation) {
40879
40910
  await writeCopyFileToFd(typeof target === "number" ? target : target.fd, input, maxBytes, assertBeforeMutation);
40880
40911
  return;
40881
40912
  }
40882
- if (typeof target === "number" && input.kind === "buffer" &&
40883
- input.stageBeforePublish !== false && !assertBeforeMutation) {
40884
- const data = typeof input.data === "string" ? Buffer.from(input.data, input.encoding ?? "utf8") : input.data;
40885
- if (data.byteLength <= SMALL_BUFFER_BYTES) {
40886
- if (maxBytes !== undefined && data.byteLength > maxBytes) {
40887
- throw new errors_FsSafeError("too-large", `file exceeds limit of ${maxBytes} bytes (got at least ${data.byteLength})`);
40888
- }
40889
- return writeAllToFile(target, data, { synchronous: true });
40890
- }
40891
- }
40892
40913
  let bytes = 0;
40893
40914
  const write = async (data) => {
40894
40915
  bytes += data.byteLength;
@@ -41380,8 +41401,8 @@ function assertNativeStaging(binding) {
41380
41401
  binding.createStagedFile,
41381
41402
  binding.stagedFileMatches,
41382
41403
  binding.removeStagedFile,
41383
- binding.renameReplace,
41384
- binding.renameNoReplace,
41404
+ binding.renameReplaceAsync,
41405
+ binding.renameNoReplaceAsync,
41385
41406
  ].some((fn) => typeof fn !== "function")) {
41386
41407
  throw new errors_FsSafeError("helper-unavailable", "native retained-directory staging is unavailable");
41387
41408
  }
@@ -41401,7 +41422,7 @@ class NativeStagedFile {
41401
41422
  #verifyMode;
41402
41423
  #state = { status: "open", publication: NOT_PUBLISHED };
41403
41424
  #receipt;
41404
- #publicationFlush;
41425
+ #publicationTask;
41405
41426
  #rejectFinalSymlink = false;
41406
41427
  #unsupportedNoReplace;
41407
41428
  #fallbackCleanup;
@@ -41592,7 +41613,7 @@ class NativeStagedFile {
41592
41613
  if (this.#private)
41593
41614
  assertDarwinCreationAcl(this.#owner.parentFd, "file");
41594
41615
  try {
41595
- state.fileFd = this.#owner.binding.createStagedFile(this.#owner.parentFd, this.#owner.name);
41616
+ state.fileFd = await this.#owner.binding.createStagedFile(this.#owner.parentFd, this.#owner.name);
41596
41617
  }
41597
41618
  catch (error) {
41598
41619
  annotateReadOnlyOpenError(error, external_node_path_.join(this.#owner.directory.realPath, this.#owner.name));
@@ -41641,7 +41662,14 @@ class NativeStagedFile {
41641
41662
  async assertCurrent() {
41642
41663
  this.#assertCurrent();
41643
41664
  }
41644
- async publish(basename, options, onPublished) {
41665
+ publish(basename, options, onPublished) {
41666
+ if (this.#publicationTask)
41667
+ return Promise.reject(stagedFailure("file", new errors_FsSafeError("helper-failed", "staged file publication is pending"), { phase: "publish", publication: this.#state.status === "closed" ? this.#state.receipt.publication : this.#state.publication }));
41668
+ // Claim the operation before yielding so cleanup cannot recycle a worker's fds.
41669
+ return this.#publicationTask = Promise.resolve().then(() => this.#publish(basename, options, onPublished))
41670
+ .finally(() => { this.#publicationTask = undefined; });
41671
+ }
41672
+ async #publish(basename, options, onPublished) {
41645
41673
  const overwrite = options?.overwrite;
41646
41674
  try {
41647
41675
  const state = this.#open();
@@ -41658,10 +41686,10 @@ class NativeStagedFile {
41658
41686
  }
41659
41687
  try {
41660
41688
  if (overwrite) {
41661
- this.#owner.binding.renameReplace(this.#owner.parentFd, this.#owner.name, this.#owner.parentFd, basename);
41689
+ await this.#owner.binding.renameReplaceAsync(this.#owner.parentFd, this.#owner.name, this.#owner.parentFd, basename);
41662
41690
  }
41663
41691
  else {
41664
- this.#owner.binding.renameNoReplace(this.#owner.parentFd, this.#owner.name, this.#owner.parentFd, basename);
41692
+ await this.#owner.binding.renameNoReplaceAsync(this.#owner.parentFd, this.#owner.name, this.#owner.parentFd, basename);
41665
41693
  }
41666
41694
  }
41667
41695
  catch (error) {
@@ -41716,14 +41744,13 @@ class NativeStagedFile {
41716
41744
  };
41717
41745
  if (this.#owner.sync === false)
41718
41746
  return verify();
41719
- this.#publicationFlush = Promise.resolve().then(async () => {
41747
+ return Promise.resolve().then(async () => {
41720
41748
  if ((this.#owner.mode & 0o600) !== 0o600 || (stagedMode & ~this.#owner.mode) !== 0) {
41721
41749
  await (this.#owner.strictFileSync ? syncFile(fd) : syncFileBestEffort(fd));
41722
41750
  }
41723
41751
  await syncFileBestEffort(this.#owner.parentFd);
41724
41752
  return verify();
41725
- }).finally(() => { this.#publicationFlush = undefined; });
41726
- return this.#publicationFlush;
41753
+ });
41727
41754
  }
41728
41755
  #finalize() {
41729
41756
  if (this.#state.status === "closed") {
@@ -41778,9 +41805,9 @@ class NativeStagedFile {
41778
41805
  return this.#state;
41779
41806
  }
41780
41807
  async cleanup() {
41781
- // Native descriptors cannot close or be recycled while libuv is synchronizing them.
41782
- if (this.#publicationFlush)
41783
- await this.#publicationFlush.catch(() => { });
41808
+ // Native descriptors stay owned through the rename and all durability fences.
41809
+ if (this.#publicationTask)
41810
+ await this.#publicationTask.catch(() => { });
41784
41811
  const closed = this.#finalize();
41785
41812
  if (closed.error) {
41786
41813
  throw closed.error;
@@ -41878,7 +41905,7 @@ var native_pinned_write_disposeResources = (undefined && undefined.__disposeReso
41878
41905
 
41879
41906
 
41880
41907
  const writeCapabilities = ["openBeneath", "mkdirBeneath", "renameNoReplace", "renameReplace"];
41881
- const posixWriteCapabilities = [...writeCapabilities, "createStagedFile", "stagedFileMatches", "removeStagedFile"];
41908
+ const posixWriteCapabilities = [...writeCapabilities, "createStagedFile", "stagedFileMatches", "removeStagedFile", "renameReplaceAsync", "renameNoReplaceAsync"];
41882
41909
  function pinnedWriteCapabilities(params) {
41883
41910
  const windows = process.platform === "win32";
41884
41911
  const capabilities = windows ? [...writeCapabilities, "fstatIdentity"] : posixWriteCapabilities;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lousy-agents/mcp",
3
- "version": "5.23.0",
3
+ "version": "5.23.2",
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": {