@lousy-agents/mcp 5.22.0 → 5.22.1

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 +713 -123
  2. package/package.json +1 -1
@@ -6559,7 +6559,7 @@ function escapeJsonPtr(str) {
6559
6559
 
6560
6560
 
6561
6561
  },
6562
- 2473(__unused_rspack_module, __unused_rspack___webpack_exports__, __webpack_require__) {
6562
+ 4010(__unused_rspack_module, __unused_rspack___webpack_exports__, __webpack_require__) {
6563
6563
  // NAMESPACE OBJECT: ../../node_modules/micromark/lib/constructs.js
6564
6564
  var constructs_namespaceObject = {};
6565
6565
  __webpack_require__.r(constructs_namespaceObject);
@@ -37588,6 +37588,17 @@ function getFsSafeNativeConfig() {
37588
37588
  "auto",
37589
37589
  };
37590
37590
  }
37591
+ /** Internal provenance; keep the public configuration shape unchanged. */
37592
+ function getNativeModeSetting() {
37593
+ if (overrideConfig.mode !== undefined)
37594
+ return { mode: overrideConfig.mode, source: "programmatic configuration" };
37595
+ for (const source of ["FS_SAFE_NATIVE_MODE", "OPENCLAW_FS_SAFE_NATIVE_MODE"]) {
37596
+ const mode = parseMode(process.env[source]);
37597
+ if (mode !== undefined)
37598
+ return { mode, source };
37599
+ }
37600
+ return { mode: "auto", source: "default" };
37601
+ }
37591
37602
  function isFsSafeNativeRequired() {
37592
37603
  return (overrideConfig.mode ??
37593
37604
  parseMode(process.env.FS_SAFE_NATIVE_MODE) ??
@@ -37613,6 +37624,62 @@ let native_binding;
37613
37624
  let loadError;
37614
37625
  let attempted = false;
37615
37626
  let loadBinding = loadBundledBinding;
37627
+ let resolvePackage = (name) => native_require.resolve(name);
37628
+ let loadOutcome = { reason: "not-probed" };
37629
+ let selectedTarget;
37630
+ let targetDescription;
37631
+ function loadFailure(error, packageName) {
37632
+ try {
37633
+ return classifyLoadFailure(error, packageName);
37634
+ }
37635
+ catch {
37636
+ // Diagnostic inspection must not replace an arbitrary thrown load value.
37637
+ return { reason: "load-failed", code: "UNKNOWN" };
37638
+ }
37639
+ }
37640
+ function classifyLoadFailure(error, packageName) {
37641
+ const code = typeof error === "object" && error !== null && "code" in error ? error.code : undefined;
37642
+ // Resolution must fail for the selected package itself. An exception inside
37643
+ // an installed package (even one naming this package) is not package omission.
37644
+ if (code === "MODULE_NOT_FOUND" && error instanceof Error &&
37645
+ error.message.split("\n", 1)[0] === `Cannot find module '${packageName}'`) {
37646
+ try {
37647
+ resolvePackage(packageName);
37648
+ }
37649
+ catch (resolutionError) {
37650
+ if (resolutionError instanceof Error && "code" in resolutionError &&
37651
+ resolutionError.code === "MODULE_NOT_FOUND" &&
37652
+ resolutionError.message.split("\n", 1)[0] === `Cannot find module '${packageName}'`) {
37653
+ return { reason: "package-missing" };
37654
+ }
37655
+ }
37656
+ }
37657
+ // An allowlist excludes paths, secrets and arbitrary text in exception codes.
37658
+ const knownCodes = ["ERR_DLOPEN_FAILED", "MODULE_NOT_FOUND", "ERR_MODULE_NOT_FOUND",
37659
+ "ERR_PACKAGE_PATH_NOT_EXPORTED", "ERR_INVALID_PACKAGE_CONFIG", "EACCES", "EPERM", "ENOENT"];
37660
+ return { reason: "load-failed", code: typeof code === "string" && knownCodes.includes(code) ? code : "UNKNOWN" };
37661
+ }
37662
+ /** Internal view of the cached load; never attempts to load an addon. */
37663
+ function getNativeFallbackDiagnostic(...capabilities) {
37664
+ const setting = getNativeModeSetting();
37665
+ const target = targetDescription === undefined ? bundledTarget() : selectedTarget;
37666
+ const packageName = target === undefined ? undefined : nativePackageForTarget(target);
37667
+ const manifest = native_require("../package.json");
37668
+ const expected = {
37669
+ target: targetDescription,
37670
+ packageName,
37671
+ packageVersion: packageName === undefined ? undefined : manifest.optionalDependencies[packageName],
37672
+ };
37673
+ if (setting.mode === "off")
37674
+ return { ...expected, reason: "disabled", source: setting.source };
37675
+ const loaded = native_binding;
37676
+ if (loaded) {
37677
+ const missing = capabilities.filter(name => typeof loaded[name] !== "function");
37678
+ if (missing.length)
37679
+ return { ...expected, reason: "capability-missing", capabilities: missing };
37680
+ }
37681
+ return { ...expected, ...loadOutcome };
37682
+ }
37616
37683
  function isMuslFilename(file) {
37617
37684
  return file.includes("libc.musl-") || file.includes("ld-musl-");
37618
37685
  }
@@ -37742,7 +37809,10 @@ function targetFor(platform, arch, musl) {
37742
37809
  return undefined;
37743
37810
  }
37744
37811
  function bundledTarget() {
37745
- return targetFor(process.platform, process.arch, isMusl());
37812
+ const musl = isMusl();
37813
+ selectedTarget = targetFor(process.platform, process.arch, musl);
37814
+ targetDescription = selectedTarget ?? `${process.platform}-${process.arch}${process.platform === "linux" ? `-${musl ? "musl" : "gnu"}` : ""}`;
37815
+ return selectedTarget;
37746
37816
  }
37747
37817
  function nativePackageForTarget(target) {
37748
37818
  return `@openclaw/fs-safe-${target}`;
@@ -37750,9 +37820,13 @@ function nativePackageForTarget(target) {
37750
37820
  function loadBundledBinding() {
37751
37821
  const target = bundledTarget();
37752
37822
  if (!target) {
37823
+ loadOutcome = { reason: "unsupported-target" };
37753
37824
  throw new Error(`Unsupported OS or architecture: ${process.platform}-${process.arch}`);
37754
37825
  }
37755
37826
  const loaded = runNativeInitialization(() => native_require(nativePackageForTarget(target)));
37827
+ if (typeof loaded.closeOwnedFd !== "function") {
37828
+ loadOutcome = { reason: "capability-missing", capabilities: ["closeOwnedFd"] };
37829
+ }
37756
37830
  captureNativeFdClose(loaded);
37757
37831
  return loaded;
37758
37832
  }
@@ -37794,11 +37868,19 @@ function native_getNativeBinding(...capabilities) {
37794
37868
  attempted = true;
37795
37869
  try {
37796
37870
  const loaded = loadBinding();
37871
+ if (typeof loaded.closeOwnedFd !== "function") {
37872
+ loadOutcome = { reason: "capability-missing", capabilities: ["closeOwnedFd"] };
37873
+ }
37797
37874
  captureNativeFdClose(loaded);
37798
37875
  native_binding = loaded;
37876
+ loadOutcome = { reason: "loaded" };
37799
37877
  }
37800
37878
  catch (error) {
37801
37879
  loadError = error;
37880
+ if (loadOutcome.reason === "not-probed") {
37881
+ selectedTarget ??= bundledTarget();
37882
+ loadOutcome = loadFailure(error, nativePackageForTarget(selectedTarget ?? `${process.platform}-${process.arch}`));
37883
+ }
37802
37884
  }
37803
37885
  }
37804
37886
  if (native_binding)
@@ -37819,17 +37901,25 @@ function native_requireNativeBinding(...capabilities) {
37819
37901
  }
37820
37902
  return native;
37821
37903
  }
37822
- function __setNativeLoaderForTest(loader) {
37904
+ function __setNativeLoaderForTest(loader, resolver) {
37823
37905
  native_binding = undefined;
37824
37906
  loadError = undefined;
37825
37907
  attempted = false;
37826
37908
  loadBinding = loader;
37909
+ loadOutcome = { reason: "not-probed" };
37910
+ selectedTarget = undefined;
37911
+ targetDescription = undefined;
37912
+ resolvePackage = resolver ?? ((name) => native_require.resolve(name));
37827
37913
  }
37828
37914
  function __resetNativeLoaderForTest() {
37829
37915
  native_binding = undefined;
37830
37916
  loadError = undefined;
37831
37917
  attempted = false;
37832
37918
  loadBinding = loadBundledBinding;
37919
+ loadOutcome = { reason: "not-probed" };
37920
+ selectedTarget = undefined;
37921
+ targetDescription = undefined;
37922
+ resolvePackage = (name) => native_require.resolve(name);
37833
37923
  }
37834
37924
 
37835
37925
  ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/file-observation.js
@@ -39314,6 +39404,15 @@ function assertDirectoryObservationGuardSync(guard) {
39314
39404
  }
39315
39405
  }
39316
39406
 
39407
+ ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/native-stat-identity.js
39408
+ /** Native stat identities are unsigned; Node BigIntStats preserves them as signed bits. */
39409
+ function statIdentityFromNative(value) {
39410
+ return value <= 0x7fffffffffffffffn || process.versions.bun ? value : BigInt.asIntN(64, value);
39411
+ }
39412
+ function isNativeStatIdentity(value) {
39413
+ return typeof value === "bigint" && value >= 0n && value <= 0xffffffffffffffffn;
39414
+ }
39415
+
39317
39416
  ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/directory-receipt.js
39318
39417
 
39319
39418
 
@@ -39818,6 +39917,7 @@ function createSuppressedError(error, suppressed, message) {
39818
39917
 
39819
39918
 
39820
39919
 
39920
+
39821
39921
  /** Shared by tree byte copying and per-file copying; never resolves the target. */
39822
39922
  async function readCopyLinkTarget(source) {
39823
39923
  return await promises_.readlink(source, { encoding: "buffer" });
@@ -39887,7 +39987,7 @@ async function copyLinkAtParent(params, input, parent, native) {
39887
39987
  directory_guard_assertSyncDirectoryGuard(parent);
39888
39988
  if (native?.binding.createCopySymlink) {
39889
39989
  const created = native.binding.createCopySymlink(native.fd, temporaryName, input.target, params.mode, input.preserveMetadata ? input.identity.atimeNs : undefined, input.preserveMetadata ? input.identity.mtimeNs : undefined);
39890
- identity = created;
39990
+ identity = { dev: statIdentityFromNative(created.dev), ino: statIdentityFromNative(created.ino) };
39891
39991
  if (created.errorCode)
39892
39992
  throw Object.assign(new Error(created.errorMessage), { code: created.errorCode });
39893
39993
  }
@@ -40613,14 +40713,61 @@ function pinNodeDirectoryForModeSync(dirPath, options = {}) {
40613
40713
  }
40614
40714
  }
40615
40715
 
40716
+ ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/native-guidance.js
40717
+ /** Shared, path-free next steps for status reports and fallback warnings. */
40718
+ function nativeGuidance(reason, modeSource) {
40719
+ switch (reason) {
40720
+ case "disabled": {
40721
+ const enable = modeSource === "programmatic configuration"
40722
+ ? 'call configureFsSafeNative({ mode: "auto" }) or configureFsSafeNative({ mode: "require" })'
40723
+ : `set ${modeSource}=auto or ${modeSource}=require`;
40724
+ return `If native loading is intended, ${enable}; keep intentional off settings.`;
40725
+ }
40726
+ case "unsupported-target":
40727
+ return "Portable mode is expected on this target.";
40728
+ case "package-missing":
40729
+ return "Reinstall with optional dependencies included: npm --include=optional, or pnpm without --no-optional / optional=false. Check the lockfile and registry mirror.";
40730
+ case "load-failed":
40731
+ return "Check Node architecture, Linux libc compatibility, package dependencies, and OS code-integrity policy. Reinstalling identical bytes may not help.";
40732
+ case "capability-missing":
40733
+ return "Use matching fs-safe and platform-package versions; some targets intentionally provide only a subset of capabilities.";
40734
+ default:
40735
+ return undefined;
40736
+ }
40737
+ }
40738
+
40616
40739
  ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/native-fallback-warning.js
40740
+
40741
+
40742
+
40617
40743
  const warnedFeatures = new Set();
40744
+ function fallbackReason(capabilities) {
40745
+ const diagnostic = getNativeFallbackDiagnostic(...capabilities);
40746
+ const expected = diagnostic.packageName === undefined
40747
+ ? `No native package is published for ${diagnostic.target}.`
40748
+ : `Expected ${diagnostic.packageName}@${diagnostic.packageVersion}.`;
40749
+ const guidance = nativeGuidance(diagnostic.reason, getNativeModeSetting().source);
40750
+ switch (diagnostic.reason) {
40751
+ case "disabled":
40752
+ return `native support is disabled by ${diagnostic.source} (disabled). ${expected} ${guidance}`;
40753
+ case "unsupported-target":
40754
+ return `the target ${diagnostic.target} is unsupported (unsupported-target). ${expected} ${guidance}`;
40755
+ case "package-missing":
40756
+ return `the selected native package could not be resolved (package-missing). ${expected} ${guidance}`;
40757
+ case "load-failed":
40758
+ return `the native package could not be loaded (load-failed: ${diagnostic.code}). ${expected} ${guidance}`;
40759
+ case "capability-missing":
40760
+ return `the native package lacks requested functions (capability-missing: ${diagnostic.capabilities.join(", ")}). ${expected} ${guidance}`;
40761
+ default:
40762
+ return `the requested native operation is unavailable (${diagnostic.reason}). ${expected}`;
40763
+ }
40764
+ }
40618
40765
  /** Warn once per capability, without including caller paths or native error text. */
40619
- function warnNativeFallback(feature, limitation) {
40766
+ function warnNativeFallback(feature, limitation, ...capabilities) {
40620
40767
  if (warnedFeatures.has(feature))
40621
40768
  return;
40622
40769
  warnedFeatures.add(feature);
40623
- process.emitWarning(`${feature} is using its portable fallback because native support is unavailable or disabled. ${limitation}`, { code: "FS_SAFE_NATIVE_FALLBACK", type: "FsSafeWarning" });
40770
+ process.emitWarning(`${feature} is using its portable fallback because ${fallbackReason(capabilities)} ${limitation}`, { code: "FS_SAFE_NATIVE_FALLBACK", type: "FsSafeWarning" });
40624
40771
  }
40625
40772
  function __resetNativeFallbackWarningsForTest() {
40626
40773
  warnedFeatures.clear();
@@ -41459,17 +41606,17 @@ function creation_boundary_assertPrivateFileCreationAvailable() {
41459
41606
  typeof native.verifyPrivateWindowsFile !== "function")
41460
41607
  creation_boundary_unavailable();
41461
41608
  }
41462
- function commandFallback() {
41609
+ function commandFallback(capability) {
41463
41610
  if (getFsSafeNativeConfig().mode === "require")
41464
41611
  creation_boundary_unavailable();
41465
- warnNativeFallback("windows-private-creation", "Private Windows creation uses a slower built-in system command.");
41612
+ warnNativeFallback("windows-private-creation", "Private Windows creation launches the packaged .NET helper for each check or creation.", capability);
41466
41613
  }
41467
41614
  function creationOperation(name) {
41468
41615
  const native = native_getNativeBinding();
41469
41616
  const operation = native?.[name];
41470
41617
  if (typeof operation === "function")
41471
41618
  return operation.bind(native);
41472
- commandFallback();
41619
+ commandFallback(name);
41473
41620
  return undefined;
41474
41621
  }
41475
41622
  /** Full Windows identity, with security validation when requested; no repairs. */
@@ -43798,6 +43945,7 @@ function mergeDenyMutationPolicies(defaultPolicy, callPolicy) {
43798
43945
 
43799
43946
 
43800
43947
 
43948
+
43801
43949
  function getNativeDirectoryObservationBackend(enabled = true) {
43802
43950
  if (!enabled)
43803
43951
  return undefined;
@@ -43807,14 +43955,15 @@ function getNativeDirectoryObservationBackend(enabled = true) {
43807
43955
  : undefined;
43808
43956
  }
43809
43957
  function validateNativeDirectoryObservation(observation) {
43810
- if (!observation || typeof observation.dev !== "bigint" || observation.dev < 0n ||
43811
- typeof observation.ino !== "bigint" || observation.ino < 0n ||
43958
+ if (!observation || !isNativeStatIdentity(observation.dev) ||
43959
+ !isNativeStatIdentity(observation.ino) ||
43812
43960
  typeof observation.realPath !== "string" ||
43813
43961
  observation.realPath.includes("\0") ||
43814
43962
  (!external_node_path_.isAbsolute(observation.realPath) && !external_node_path_.win32.isAbsolute(observation.realPath))) {
43815
43963
  throw new errors_FsSafeError("path-mismatch", "native directory observation is invalid");
43816
43964
  }
43817
- return observation;
43965
+ const dev = statIdentityFromNative(observation.dev), ino = statIdentityFromNative(observation.ino);
43966
+ return dev === observation.dev && ino === observation.ino ? observation : { ...observation, dev, ino };
43818
43967
  }
43819
43968
  /** Exact identity, type, and canonical path captured from one retained handle. */
43820
43969
  function inspectNativeDirectoryObservation(backend, pathname, expected, platform = process.platform) {
@@ -43836,6 +43985,7 @@ function isNativeDirectoryObservationGuard(guard) {
43836
43985
 
43837
43986
 
43838
43987
 
43988
+
43839
43989
  class NativePolicyDirectoryMismatch extends errors_FsSafeError {
43840
43990
  constructor(cause) {
43841
43991
  super("path-mismatch", "staging directory pathname changed", { cause });
@@ -43874,8 +44024,8 @@ function native_policy_directory_observation_nativePolicyDirectoryObserver(bindi
43874
44024
  }
43875
44025
  if (getFsSafeNativeConfig().mode !== mode)
43876
44026
  return undefined;
43877
- if (!observed || typeof observed.dev !== "bigint" || observed.dev < 0n || observed.dev > 0xffffffffffffffffn ||
43878
- typeof observed.ino !== "bigint" || observed.ino < 0n || observed.ino > 0xffffffffffffffffn ||
44027
+ if (!observed || !isNativeStatIdentity(observed.dev) ||
44028
+ !isNativeStatIdentity(observed.ino) ||
43879
44029
  typeof observed.mode !== "bigint" || observed.mode < 0n || observed.mode > 0xffffffffn ||
43880
44030
  typeof observed.nlink !== "bigint" || observed.nlink < 0n || observed.nlink > 0xffffffffffffffffn ||
43881
44031
  typeof observed.realPath !== "string" || observed.realPath.includes("\0") ||
@@ -43888,7 +44038,7 @@ function native_policy_directory_observation_nativePolicyDirectoryObserver(bindi
43888
44038
  return Object.freeze({
43889
44039
  canonicalPath: observed.realPath,
43890
44040
  identity: Object.freeze({
43891
- dev: observed.dev, ino: observed.ino, mode: observed.mode, nlink: observed.nlink,
44041
+ dev: statIdentityFromNative(observed.dev), ino: statIdentityFromNative(observed.ino), mode: observed.mode, nlink: observed.nlink,
43892
44042
  }),
43893
44043
  });
43894
44044
  };
@@ -46678,6 +46828,64 @@ function __setFsSafeTestHooksForTest(hooks) {
46678
46828
  test_hooks_fsSafeTestHooks = hooks;
46679
46829
  }
46680
46830
 
46831
+ ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/root-native-creation-path.js
46832
+
46833
+
46834
+
46835
+
46836
+
46837
+
46838
+
46839
+
46840
+
46841
+ function existingCreationParent(params) {
46842
+ if (params.private || params.policy || params.assertBeforeMutation !== undefined ||
46843
+ getFsSafeTestHooks()?.beforeRootFallbackMutation || !params.originalPath ||
46844
+ params.directory !== external_node_path_.dirname(params.target))
46845
+ return undefined;
46846
+ const segments = params.originalPath.split(external_node_path_.sep === "\\" ? /[\\/]/ : "/");
46847
+ if (segments.some(segment => !isSafePathSegment(segment, { allowDotPrefix: true }) || segment.endsWith(".")) ||
46848
+ external_node_path_.join(params.root.rootReal, ...segments) !== params.target)
46849
+ return undefined;
46850
+ let rootStat;
46851
+ root_context_assertRootIdentityCurrentSync(params.root, stat => { rootStat = stat; });
46852
+ try {
46853
+ const identity = directory_guard_inspectDirectoryIdentitySync(params.directory, undefined, params.directory === params.root.rootReal ? rootStat : undefined);
46854
+ if (realpath_realpathSync.native(windows_path_alias_pathForWindowsFilesystem(params.directory)) !== params.directory)
46855
+ return undefined;
46856
+ return {
46857
+ path: params.directory, identity,
46858
+ relative: external_node_path_.relative(params.root.rootReal, params.directory).split(external_node_path_.sep).join("/"),
46859
+ flags: (nodeDirectorySearchOnlyFlags()?.flags ?? external_node_fs_.constants.O_RDONLY) |
46860
+ (external_node_fs_.constants.O_DIRECTORY ?? 0) | (external_node_fs_.constants.O_NOFOLLOW ?? 0),
46861
+ };
46862
+ }
46863
+ catch {
46864
+ return undefined;
46865
+ }
46866
+ }
46867
+ function probeNativeCreationPath(root, relativePath) {
46868
+ if (typeof relativePath !== "string")
46869
+ return undefined;
46870
+ const segments = relativePath.split(external_node_path_.sep === "\\" ? /[\\/]/ : "/");
46871
+ if (segments.some(segment => !isSafePathSegment(segment, { allowDotPrefix: true }) || segment.endsWith(".")))
46872
+ return undefined;
46873
+ const target = external_node_path_.join(root.rootReal, ...segments);
46874
+ root_context_assertRootIdentityCurrentSync(root);
46875
+ try {
46876
+ if (external_node_fs_.lstatSync(windows_path_alias_pathForWindowsFilesystem(target), { throwIfNoEntry: false }))
46877
+ return undefined;
46878
+ }
46879
+ catch {
46880
+ return undefined;
46881
+ }
46882
+ const parent = existingCreationParent({ root, target, directory: external_node_path_.dirname(target), mkdir: true,
46883
+ originalPath: relativePath, resolveCurrent: async () => target });
46884
+ if (!parent)
46885
+ return undefined;
46886
+ return { rootReal: root.rootReal, rootWithSep: root.rootWithSep, resolved: target, parent };
46887
+ }
46888
+
46681
46889
  ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/root-create-native.js
46682
46890
  var root_create_native_addDisposableResource = (undefined && undefined.__addDisposableResource) || function (env, value, async) {
46683
46891
  if (value !== null && value !== void 0) {
@@ -46755,6 +46963,8 @@ var root_create_native_disposeResources = (undefined && undefined.__disposeResou
46755
46963
 
46756
46964
 
46757
46965
 
46966
+
46967
+
46758
46968
 
46759
46969
 
46760
46970
 
@@ -46764,6 +46974,10 @@ function rootWriteQueueKey(root, relativePath) {
46764
46974
  function buildAtomicWriteTempPath(targetPath) {
46765
46975
  return external_node_path_.join(external_node_path_.dirname(targetPath), `.fs-safe-${(0,external_node_crypto_.randomUUID)()}.tmp`);
46766
46976
  }
46977
+ const nativeCreateCollisions = new WeakSet();
46978
+ function isNativeCreateCollision(error) {
46979
+ return typeof error === "object" && error !== null && nativeCreateCollisions.has(error);
46980
+ }
46767
46981
  function root_create_native_unavailable() {
46768
46982
  throw new errors_FsSafeError("helper-unavailable", "native confined creation is unavailable");
46769
46983
  }
@@ -46771,6 +46985,60 @@ async function withNativeDirectory(params, operation, discard) {
46771
46985
  const binding = native_getNativeBinding("openBeneath", "mkdirChildBeneath");
46772
46986
  if (!binding?.openBeneath || !binding.mkdirChildBeneath || (params.private && process.platform === "win32"))
46773
46987
  return root_create_native_unavailable();
46988
+ const existing = params.selectedParent ?? existingCreationParent(params);
46989
+ if (existing) {
46990
+ let pending;
46991
+ try {
46992
+ const env_1 = { stack: [], error: void 0, hasError: false };
46993
+ try {
46994
+ const rootOwner = root_create_native_addDisposableResource(env_1, openExactNativeRootSync(binding, {
46995
+ rootPath: params.root.rootReal, rootIdentity: params.root.rootIdentity,
46996
+ }), false);
46997
+ const close = captureNativeFdClose(binding);
46998
+ const borrowed = existing.path === params.root.rootReal;
46999
+ const fd = borrowed ? rootOwner.fd : binding.openBeneath(rootOwner.fd, existing.relative, existing.flags).fd;
47000
+ const parentOwner = root_create_native_addDisposableResource(env_1, { [Symbol.dispose]() { if (!borrowed)
47001
+ close(fd); } }, false);
47002
+ strict_file_identity_inspectFileIdentitySync(() => borrowed ? rootOwner.stat : external_node_fs_.fstatSync(fd, { bigint: true }), existing.identity);
47003
+ verifyMkdirDirectory(binding, fd, existing.path);
47004
+ const guard = { dir: existing.path, realPath: existing.path, stat: existing.identity };
47005
+ const assertCurrent = () => {
47006
+ let currentRoot;
47007
+ root_context_assertRootIdentityCurrentSync(params.root, stat => { currentRoot = stat; });
47008
+ if (borrowed) {
47009
+ // Root and parent are the same name in this synchronous fence.
47010
+ directory_guard_inspectDirectoryIdentitySync(existing.path, existing.identity, currentRoot);
47011
+ if (realpath_realpathSync.native(windows_path_alias_pathForWindowsFilesystem(existing.path)) !== existing.path) {
47012
+ throw new errors_FsSafeError("path-mismatch", "directory changed during operation");
47013
+ }
47014
+ }
47015
+ else {
47016
+ directory_guard_assertSyncDirectoryGuard(guard);
47017
+ }
47018
+ };
47019
+ pending = { value: await operation(binding, fd, assertCurrent) };
47020
+ return pending.value;
47021
+ }
47022
+ catch (e_1) {
47023
+ env_1.error = e_1;
47024
+ env_1.hasError = true;
47025
+ }
47026
+ finally {
47027
+ root_create_native_disposeResources(env_1);
47028
+ }
47029
+ }
47030
+ catch (error) {
47031
+ if (pending && discard) {
47032
+ try {
47033
+ await discard(pending.value);
47034
+ }
47035
+ catch (cleanupError) {
47036
+ throw createSuppressedError(cleanupError, error, "creation handoff and cleanup failed");
47037
+ }
47038
+ }
47039
+ throw error;
47040
+ }
47041
+ }
46774
47042
  const directoryTarget = params.directory === params.target;
46775
47043
  const canonicalTarget = async (target) => directoryTarget
46776
47044
  ? await resolvePathViaExistingAncestor(target)
@@ -46787,14 +47055,14 @@ async function withNativeDirectory(params, operation, discard) {
46787
47055
  const close = captureNativeFdClose(binding);
46788
47056
  let pending;
46789
47057
  try {
46790
- const env_1 = { stack: [], error: void 0, hasError: false };
47058
+ const env_2 = { stack: [], error: void 0, hasError: false };
46791
47059
  try {
46792
47060
  const admitted = await openNativeRootAdmission(binding, {
46793
47061
  rootPath: params.root.rootReal, rootIdentity: params.root.rootIdentity, operation: "create", reportCloseErrors: true, searchOnly: true,
46794
47062
  });
46795
- const rootOwner = root_create_native_addDisposableResource(env_1, admitted.root, true);
47063
+ const rootOwner = root_create_native_addDisposableResource(env_2, admitted.root, true);
46796
47064
  const descriptors = [];
46797
- const directoryOwner = root_create_native_addDisposableResource(env_1, { [Symbol.dispose]() {
47065
+ const directoryOwner = root_create_native_addDisposableResource(env_2, { [Symbol.dispose]() {
46798
47066
  const errors = [];
46799
47067
  for (const fd of descriptors.reverse())
46800
47068
  try {
@@ -46892,12 +47160,12 @@ async function withNativeDirectory(params, operation, discard) {
46892
47160
  pending = { value: await operation(binding, current, assertCurrent) };
46893
47161
  return pending.value;
46894
47162
  }
46895
- catch (e_1) {
46896
- env_1.error = e_1;
46897
- env_1.hasError = true;
47163
+ catch (e_2) {
47164
+ env_2.error = e_2;
47165
+ env_2.hasError = true;
46898
47166
  }
46899
47167
  finally {
46900
- const result_1 = root_create_native_disposeResources(env_1);
47168
+ const result_1 = root_create_native_disposeResources(env_2);
46901
47169
  if (result_1)
46902
47170
  await result_1;
46903
47171
  }
@@ -46976,33 +47244,77 @@ function verifyMkdirDirectory(binding, fd, pathname) {
46976
47244
  describePolicyStagedDirectory(fd, pathname);
46977
47245
  }
46978
47246
  function ensureNativeRootCurrent(root) {
46979
- const env_2 = { stack: [], error: void 0, hasError: false };
47247
+ root_context_assertRootIdentityCurrentSync(root);
47248
+ const binding = native_getNativeBinding("openBeneath", "mkdirChildBeneath");
47249
+ if (!binding?.openBeneath || !binding.mkdirChildBeneath)
47250
+ return root_create_native_unavailable();
47251
+ if (binding.verifyRootDirectory) {
47252
+ const closeNative = captureNativeFdClose(binding);
47253
+ const failure = binding.verifyRootDirectory(root.rootReal, root.rootIdentity.dev, root.rootIdentity.ino);
47254
+ if (failure === null)
47255
+ return;
47256
+ if (failure?.fallbackFd !== undefined && failure.fallbackFd !== null) {
47257
+ const env_3 = { stack: [], error: void 0, hasError: false };
47258
+ try {
47259
+ const fd = failure.fallbackFd;
47260
+ if (!Number.isInteger(fd) || fd < 0)
47261
+ throw new errors_FsSafeError("helper-failed", "invalid root fallback descriptor");
47262
+ const owner = root_create_native_addDisposableResource(env_3, { [Symbol.dispose]() { closeNative(fd); } }, false);
47263
+ if (failure.errorCode || failure.closeErrorCode)
47264
+ throw new errors_FsSafeError("helper-failed", "invalid root verification result");
47265
+ ensureNativeRootCurrentLegacy(root, binding);
47266
+ return;
47267
+ }
47268
+ catch (e_3) {
47269
+ env_3.error = e_3;
47270
+ env_3.hasError = true;
47271
+ }
47272
+ finally {
47273
+ root_create_native_disposeResources(env_3);
47274
+ }
47275
+ }
47276
+ const error = failure?.errorCode ? rootVerificationError(failure.errorCode, failure.errorMessage, failure.errorErrno) : undefined;
47277
+ const closeError = failure?.closeErrorCode ? Object.assign(new Error(failure.closeErrorMessage), {
47278
+ code: failure.closeErrorCode,
47279
+ ...(typeof failure.closeErrorErrno === "number" ? { errno: failure.closeErrorErrno } : {}),
47280
+ }) : undefined;
47281
+ if (error && closeError)
47282
+ throw createSuppressedError(closeError, error, "root verification and close failed");
47283
+ if (error || closeError)
47284
+ throw error ?? closeError;
47285
+ throw new errors_FsSafeError("helper-failed", "invalid root verification result");
47286
+ }
47287
+ ensureNativeRootCurrentLegacy(root, binding);
47288
+ }
47289
+ function rootVerificationError(code, message, errno) {
47290
+ const error = Object.assign(new Error(message), { code, ...(typeof errno === "number" ? { errno } : {}) });
47291
+ return code === "path-mismatch" || code === "OBSERVATION_REDIRECTED"
47292
+ ? new errors_FsSafeError("path-mismatch", "root identity changed during verification", { cause: error }) : error;
47293
+ }
47294
+ function ensureNativeRootCurrentLegacy(root, binding) {
47295
+ const env_4 = { stack: [], error: void 0, hasError: false };
46980
47296
  try {
46981
- root_context_assertRootIdentityCurrentSync(root);
46982
- const binding = native_getNativeBinding("openBeneath", "mkdirChildBeneath");
46983
- if (!binding?.openBeneath || !binding.mkdirChildBeneath)
46984
- return root_create_native_unavailable();
46985
- const rootOwner = root_create_native_addDisposableResource(env_2, openExactNativeRootSync(binding, {
47297
+ const rootOwner = root_create_native_addDisposableResource(env_4, openExactNativeRootSync(binding, {
46986
47298
  rootPath: root.rootReal, rootIdentity: root.rootIdentity,
46987
47299
  }), false);
46988
47300
  verifyMkdirDirectory(binding, rootOwner.fd, root.rootReal);
46989
47301
  root_context_assertRootIdentityCurrentSync(root);
46990
47302
  }
46991
- catch (e_2) {
46992
- env_2.error = e_2;
46993
- env_2.hasError = true;
47303
+ catch (e_4) {
47304
+ env_4.error = e_4;
47305
+ env_4.hasError = true;
46994
47306
  }
46995
47307
  finally {
46996
- root_create_native_disposeResources(env_2);
47308
+ root_create_native_disposeResources(env_4);
46997
47309
  }
46998
47310
  }
46999
47311
  function mkdirNativeRootChild(params) {
47000
- const env_3 = { stack: [], error: void 0, hasError: false };
47312
+ const env_5 = { stack: [], error: void 0, hasError: false };
47001
47313
  try {
47002
47314
  const binding = native_getNativeBinding("openBeneath", "mkdirChildBeneath");
47003
47315
  if (!binding?.openBeneath || !binding.mkdirChildBeneath)
47004
47316
  return root_create_native_unavailable();
47005
- const rootOwner = root_create_native_addDisposableResource(env_3, openExactNativeRootSync(binding, {
47317
+ const rootOwner = root_create_native_addDisposableResource(env_5, openExactNativeRootSync(binding, {
47006
47318
  rootPath: params.root.rootReal, rootIdentity: params.root.rootIdentity,
47007
47319
  }), false);
47008
47320
  verifyMkdirDirectory(binding, rootOwner.fd, params.root.rootReal);
@@ -47015,17 +47327,17 @@ function mkdirNativeRootChild(params) {
47015
47327
  ? binding.mkdirOpenChildBeneath(rootOwner.fd, name, 0o777, flags).fd
47016
47328
  : (binding.mkdirChildBeneath(rootOwner.fd, name, 0o777), binding.openBeneath(rootOwner.fd, name, flags).fd);
47017
47329
  const close = captureNativeFdClose(binding);
47018
- const childOwner = root_create_native_addDisposableResource(env_3, { [Symbol.dispose]() { close(child); } }, false);
47330
+ const childOwner = root_create_native_addDisposableResource(env_5, { [Symbol.dispose]() { close(child); } }, false);
47019
47331
  root_context_assertRootIdentityCurrentSync(params.root);
47020
47332
  verifyMkdirDirectory(binding, child, params.target);
47021
47333
  verifyMkdirDirectory(binding, rootOwner.fd, params.root.rootReal);
47022
47334
  }
47023
- catch (e_3) {
47024
- env_3.error = e_3;
47025
- env_3.hasError = true;
47335
+ catch (e_5) {
47336
+ env_5.error = e_5;
47337
+ env_5.hasError = true;
47026
47338
  }
47027
47339
  finally {
47028
- root_create_native_disposeResources(env_3);
47340
+ root_create_native_disposeResources(env_5);
47029
47341
  }
47030
47342
  }
47031
47343
  async function tryOpenCreateRootNative(params) {
@@ -47047,7 +47359,7 @@ async function tryOpenCreateRootNative(params) {
47047
47359
  if (creationMode() === undefined)
47048
47360
  return root_create_native_unavailable();
47049
47361
  return await withNativeDirectory(params, async (binding, parent, assertCurrent) => {
47050
- const env_4 = { stack: [], error: void 0, hasError: false };
47362
+ const env_6 = { stack: [], error: void 0, hasError: false };
47051
47363
  try {
47052
47364
  params.assertBeforeMutation?.();
47053
47365
  assertCurrent();
@@ -47057,13 +47369,21 @@ async function tryOpenCreateRootNative(params) {
47057
47369
  // Native creation owns the only O_CREAT dispatch. The subsequent Node open
47058
47370
  // carries neither O_CREAT nor O_TRUNC and must match this retained inode.
47059
47371
  const close = captureNativeFdClose(binding);
47060
- const fd = binding.openCreateBeneath(parent, external_node_path_.basename(params.target), params.flags, params.mode & 0o7777);
47372
+ let fd;
47373
+ try {
47374
+ fd = binding.openCreateBeneath(parent, external_node_path_.basename(params.target), params.flags, params.mode & 0o7777);
47375
+ }
47376
+ catch (error) {
47377
+ if (hasNodeErrorCode(error, "EEXIST") && typeof error === "object" && error !== null)
47378
+ nativeCreateCollisions.add(error);
47379
+ throw error;
47380
+ }
47061
47381
  let rawOpen = true;
47062
47382
  const closeRaw = () => { if (rawOpen) {
47063
47383
  rawOpen = false;
47064
47384
  close(fd);
47065
47385
  } };
47066
- const owner = root_create_native_addDisposableResource(env_4, { [Symbol.dispose]: closeRaw }, false);
47386
+ const owner = root_create_native_addDisposableResource(env_6, { [Symbol.dispose]: closeRaw }, false);
47067
47387
  try {
47068
47388
  const identity = strict_file_identity_inspectFileIdentitySync(() => external_node_fs_.fstatSync(fd, { bigint: true }));
47069
47389
  if (!identity.isFile() || identity.nlink !== 1n)
@@ -47117,26 +47437,26 @@ async function tryOpenCreateRootNative(params) {
47117
47437
  throw error;
47118
47438
  }
47119
47439
  }
47120
- catch (e_4) {
47121
- env_4.error = e_4;
47122
- env_4.hasError = true;
47440
+ catch (e_6) {
47441
+ env_6.error = e_6;
47442
+ env_6.hasError = true;
47123
47443
  }
47124
47444
  finally {
47125
- root_create_native_disposeResources(env_4);
47445
+ root_create_native_disposeResources(env_6);
47126
47446
  }
47127
47447
  }, async (created) => {
47128
- const env_5 = { stack: [], error: void 0, hasError: false };
47448
+ const env_7 = { stack: [], error: void 0, hasError: false };
47129
47449
  try {
47130
- const handle = root_create_native_addDisposableResource(env_5, created.handle, true);
47131
- const parent = root_create_native_addDisposableResource(env_5, { [Symbol.dispose]: created.releaseCreationParent }, false);
47450
+ const handle = root_create_native_addDisposableResource(env_7, created.handle, true);
47451
+ const parent = root_create_native_addDisposableResource(env_7, { [Symbol.dispose]: created.releaseCreationParent }, false);
47132
47452
  await created.cleanupCreated();
47133
47453
  }
47134
- catch (e_5) {
47135
- env_5.error = e_5;
47136
- env_5.hasError = true;
47454
+ catch (e_7) {
47455
+ env_7.error = e_7;
47456
+ env_7.hasError = true;
47137
47457
  }
47138
47458
  finally {
47139
- const result_2 = root_create_native_disposeResources(env_5);
47459
+ const result_2 = root_create_native_disposeResources(env_7);
47140
47460
  if (result_2)
47141
47461
  await result_2;
47142
47462
  }
@@ -47872,7 +48192,7 @@ function privateDirectoryBackend() {
47872
48192
  if (getFsSafeNativeConfig().mode === "require") {
47873
48193
  throw new errors_FsSafeError("helper-unavailable", "private directory creation requires an up-to-date native parent identity capability");
47874
48194
  }
47875
- warnNativeFallback("windows-private-directory", "Private Windows directory creation uses a slower built-in system command.");
48195
+ warnNativeFallback("windows-private-directory", "Private Windows directory creation launches the packaged .NET helper for each check or creation.", "createPrivateDirectoryWithParentIdentity");
47876
48196
  return undefined;
47877
48197
  }
47878
48198
  async function createDirectory(targetPath, options = {}) {
@@ -53682,6 +54002,247 @@ async function read_opened_file_readOpenedFileSafely(params) {
53682
54002
  };
53683
54003
  }
53684
54004
 
54005
+ ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/root-mkdir-native.js
54006
+ var root_mkdir_native_addDisposableResource = (undefined && undefined.__addDisposableResource) || function (env, value, async) {
54007
+ if (value !== null && value !== void 0) {
54008
+ if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
54009
+ var dispose, inner;
54010
+ if (async) {
54011
+ if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
54012
+ dispose = value[Symbol.asyncDispose];
54013
+ }
54014
+ if (dispose === void 0) {
54015
+ if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
54016
+ dispose = value[Symbol.dispose];
54017
+ if (async) inner = dispose;
54018
+ }
54019
+ if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
54020
+ if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
54021
+ env.stack.push({ value: value, dispose: dispose, async: async });
54022
+ }
54023
+ else if (async) {
54024
+ env.stack.push({ async: true });
54025
+ }
54026
+ return value;
54027
+ };
54028
+ var root_mkdir_native_disposeResources = (undefined && undefined.__disposeResources) || (function (SuppressedError) {
54029
+ return function (env) {
54030
+ function fail(e) {
54031
+ env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
54032
+ env.hasError = true;
54033
+ }
54034
+ var r, s = 0;
54035
+ function next() {
54036
+ while (r = env.stack.pop()) {
54037
+ try {
54038
+ if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
54039
+ if (r.dispose) {
54040
+ var result = r.dispose.call(r.value);
54041
+ if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
54042
+ }
54043
+ else s |= 1;
54044
+ }
54045
+ catch (e) {
54046
+ fail(e);
54047
+ }
54048
+ }
54049
+ if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
54050
+ if (env.hasError) throw env.error;
54051
+ }
54052
+ return next();
54053
+ };
54054
+ })(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
54055
+ var e = new Error(message);
54056
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
54057
+ });
54058
+
54059
+
54060
+
54061
+
54062
+
54063
+
54064
+
54065
+
54066
+
54067
+
54068
+
54069
+
54070
+
54071
+
54072
+
54073
+
54074
+
54075
+ function tryMkdirNativeParents(root, relativePath) {
54076
+ try {
54077
+ return mkdirOrdinaryNativeParents(root, relativePath);
54078
+ }
54079
+ catch (error) {
54080
+ if (hasNodeErrorCode(error, "ENOTDIR"))
54081
+ throw root_errors_directoryComponentNotDirectoryError(error);
54082
+ throw error;
54083
+ }
54084
+ }
54085
+ function mkdirOrdinaryNativeParents(root, relativePath) {
54086
+ if (getFsSafeTestHooks()?.beforeRootFallbackMutation)
54087
+ return false;
54088
+ const segments = relativePath.split(external_node_path_.sep === "\\" ? /[\\/]/ : "/");
54089
+ if (segments.length < 2 || segments.some(segment => !isSafePathSegment(segment, { allowDotPrefix: true }) || segment.endsWith(".")))
54090
+ return false;
54091
+ let rootStat;
54092
+ root_context_assertRootIdentityCurrentSync(root, stat => { rootStat = stat; });
54093
+ const target = external_node_path_.join(root.rootReal, ...segments);
54094
+ const parentPath = external_node_path_.dirname(target);
54095
+ try {
54096
+ const child = external_node_fs_.lstatSync(windows_path_alias_pathForWindowsFilesystem(target), { throwIfNoEntry: false });
54097
+ if (child && (!child.isDirectory() || realpath_realpathSync.native(windows_path_alias_pathForWindowsFilesystem(target)) !== target))
54098
+ return false;
54099
+ }
54100
+ catch {
54101
+ return false;
54102
+ }
54103
+ let parentIdentity;
54104
+ try {
54105
+ parentIdentity = directory_guard_inspectDirectoryIdentitySync(parentPath);
54106
+ }
54107
+ catch (error) {
54108
+ // Reuse this exact Root snapshot and failed parent observation without an
54109
+ // intervening await. All opened ancestors still receive fresh native fences.
54110
+ return hasNodeErrorCode(error, "ENOENT") ? mkdirMissingParents(root, segments, rootStat) : false;
54111
+ }
54112
+ try {
54113
+ if (realpath_realpathSync.native(windows_path_alias_pathForWindowsFilesystem(parentPath)) !== parentPath)
54114
+ return false;
54115
+ }
54116
+ catch {
54117
+ return false;
54118
+ }
54119
+ return mkdirExistingParent(root, segments, parentIdentity);
54120
+ }
54121
+ /** Ordinary missing suffixes need no policy callbacks or repeated path resolution. */
54122
+ function mkdirMissingParents(root, segments, rootStat) {
54123
+ const binding = native_getNativeBinding("openBeneath", "mkdirChildBeneath");
54124
+ if (!binding?.openBeneath || !binding.mkdirOpenChildBeneath)
54125
+ return false;
54126
+ let parentDepth = segments.length - 2;
54127
+ let parentPath;
54128
+ let parentIdentity;
54129
+ for (;;) {
54130
+ parentPath = external_node_path_.join(root.rootReal, ...segments.slice(0, parentDepth));
54131
+ try {
54132
+ parentIdentity = directory_guard_inspectDirectoryIdentitySync(parentPath, undefined, parentDepth === 0 ? rootStat : undefined);
54133
+ if (realpath_realpathSync.native(windows_path_alias_pathForWindowsFilesystem(parentPath)) !== parentPath)
54134
+ return false;
54135
+ break;
54136
+ }
54137
+ catch (error) {
54138
+ if (!hasNodeErrorCode(error, "ENOENT") || parentDepth === 0)
54139
+ return false;
54140
+ parentDepth--;
54141
+ }
54142
+ }
54143
+ try {
54144
+ const env_1 = { stack: [], error: void 0, hasError: false };
54145
+ try {
54146
+ const rootOwner = root_mkdir_native_addDisposableResource(env_1, openExactNativeRootSync(binding, {
54147
+ rootPath: root.rootReal, rootIdentity: root.rootIdentity,
54148
+ }), false);
54149
+ const close = captureNativeFdClose(binding);
54150
+ const directories = [];
54151
+ const directoryOwner = root_mkdir_native_addDisposableResource(env_1, { [Symbol.dispose]() {
54152
+ const errors = [];
54153
+ for (const directory of directories.toReversed()) {
54154
+ try {
54155
+ close(directory.fd);
54156
+ }
54157
+ catch (error) {
54158
+ errors.push(error);
54159
+ }
54160
+ }
54161
+ if (errors.length)
54162
+ throw new AggregateError(errors, "mkdir directory close failed");
54163
+ } }, false);
54164
+ const flags = (nodeDirectorySearchOnlyFlags()?.flags ?? external_node_fs_.constants.O_RDONLY) |
54165
+ (external_node_fs_.constants.O_DIRECTORY ?? 0) | (external_node_fs_.constants.O_NOFOLLOW ?? 0);
54166
+ let current = rootOwner.fd;
54167
+ if (parentDepth > 0) {
54168
+ current = binding.openBeneath(rootOwner.fd, segments.slice(0, parentDepth).join("/"), flags).fd;
54169
+ directories.push({ fd: current, pathname: parentPath });
54170
+ strict_file_identity_inspectFileIdentitySync(() => external_node_fs_.fstatSync(current, { bigint: true }), parentIdentity);
54171
+ }
54172
+ const assertCurrent = () => {
54173
+ root_context_assertRootIdentityCurrentSync(root);
54174
+ for (const directory of directories)
54175
+ verifyMkdirDirectory(binding, directory.fd, directory.pathname);
54176
+ verifyMkdirDirectory(binding, rootOwner.fd, root.rootReal);
54177
+ };
54178
+ assertCurrent();
54179
+ for (const segment of segments.slice(parentDepth)) {
54180
+ const child = binding.mkdirOpenChildBeneath(current, segment, 0o777, flags);
54181
+ parentPath = external_node_path_.join(parentPath, segment);
54182
+ directories.push({ fd: child.fd, pathname: parentPath });
54183
+ // Retain every ancestor until the complete suffix is admitted. The
54184
+ // post-create fence also precedes the next synchronous child mutation.
54185
+ assertCurrent();
54186
+ current = child.fd;
54187
+ }
54188
+ return true;
54189
+ }
54190
+ catch (e_1) {
54191
+ env_1.error = e_1;
54192
+ env_1.hasError = true;
54193
+ }
54194
+ finally {
54195
+ root_mkdir_native_disposeResources(env_1);
54196
+ }
54197
+ }
54198
+ catch (error) {
54199
+ if (hasNodeErrorCode(error, "ENOTDIR"))
54200
+ throw root_errors_directoryComponentNotDirectoryError(error);
54201
+ throw error;
54202
+ }
54203
+ }
54204
+ function mkdirExistingParent(root, segments, parentIdentity) {
54205
+ const env_2 = { stack: [], error: void 0, hasError: false };
54206
+ try {
54207
+ const target = external_node_path_.join(root.rootReal, ...segments);
54208
+ const parentPath = external_node_path_.dirname(target);
54209
+ const binding = native_getNativeBinding("openBeneath", "mkdirChildBeneath");
54210
+ if (!binding?.openBeneath || !binding.mkdirChildBeneath) {
54211
+ throw new errors_FsSafeError("helper-unavailable", "native confined creation is unavailable");
54212
+ }
54213
+ const rootOwner = root_mkdir_native_addDisposableResource(env_2, openExactNativeRootSync(binding, {
54214
+ rootPath: root.rootReal, rootIdentity: root.rootIdentity,
54215
+ }), false);
54216
+ verifyMkdirDirectory(binding, rootOwner.fd, root.rootReal);
54217
+ const flags = (nodeDirectorySearchOnlyFlags()?.flags ?? external_node_fs_.constants.O_RDONLY) |
54218
+ (external_node_fs_.constants.O_DIRECTORY ?? 0) | (external_node_fs_.constants.O_NOFOLLOW ?? 0);
54219
+ const close = captureNativeFdClose(binding);
54220
+ const parent = binding.openBeneath(rootOwner.fd, segments.slice(0, -1).join("/"), flags).fd;
54221
+ const parentOwner = root_mkdir_native_addDisposableResource(env_2, { [Symbol.dispose]() { close(parent); } }, false);
54222
+ strict_file_identity_inspectFileIdentitySync(() => external_node_fs_.fstatSync(parent, { bigint: true }), parentIdentity);
54223
+ verifyMkdirDirectory(binding, parent, parentPath);
54224
+ root_context_assertRootIdentityCurrentSync(root);
54225
+ const name = segments.at(-1);
54226
+ const child = binding.mkdirOpenChildBeneath
54227
+ ? binding.mkdirOpenChildBeneath(parent, name, 0o777, flags).fd
54228
+ : (binding.mkdirChildBeneath(parent, name, 0o777), binding.openBeneath(parent, name, flags).fd);
54229
+ const childOwner = root_mkdir_native_addDisposableResource(env_2, { [Symbol.dispose]() { close(child); } }, false);
54230
+ root_context_assertRootIdentityCurrentSync(root);
54231
+ verifyMkdirDirectory(binding, child, target);
54232
+ directory_guard_inspectDirectoryIdentitySync(parentPath, parentIdentity);
54233
+ verifyMkdirDirectory(binding, parent, parentPath);
54234
+ verifyMkdirDirectory(binding, rootOwner.fd, root.rootReal);
54235
+ return true;
54236
+ }
54237
+ catch (e_2) {
54238
+ env_2.error = e_2;
54239
+ env_2.hasError = true;
54240
+ }
54241
+ finally {
54242
+ root_mkdir_native_disposeResources(env_2);
54243
+ }
54244
+ }
54245
+
53685
54246
  ;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/write-open-flags.js
53686
54247
 
53687
54248
 
@@ -56754,6 +57315,7 @@ var root_impl_disposeResources = (undefined && undefined.__disposeResources) ||
56754
57315
 
56755
57316
 
56756
57317
 
57318
+
56757
57319
 
56758
57320
 
56759
57321
  function logWarn(message) {
@@ -57154,7 +57716,9 @@ async function openWritableFileInRoot(root, params, options) {
57154
57716
  denyMutations: params.denyMutations,
57155
57717
  mutationSymlinks: params.mutationSymlinks,
57156
57718
  });
57157
- const { resolved } = guardedTarget?.resolvedPath ?? await resolveGuardedWritePathInRoot(root, {
57719
+ const creationProbe = requireNative && !guardedTarget && params.assertBeforeMutation === undefined && options?.createIfMissing !== false
57720
+ ? probeNativeCreationPath(root, params.relativePath) : undefined;
57721
+ const { resolved } = creationProbe ?? guardedTarget?.resolvedPath ?? await resolveGuardedWritePathInRoot(root, {
57158
57722
  relativePath: params.relativePath,
57159
57723
  });
57160
57724
  const resolveCurrent = async () => (await resolveGuardedWritePathInRoot(root, {
@@ -57183,27 +57747,30 @@ async function openWritableFileInRoot(root, params, options) {
57183
57747
  let ioPath = nativeCreatesParents ? resolved : prepared?.targetPath ?? (params.mkdir === false ? resolved :
57184
57748
  await prepareRootWriteTarget(root, resolved, params.assertBeforeMutation));
57185
57749
  const operationTargetPath = ioPath;
57186
- try {
57187
- assertFinalSymlinkRejected(ioPath, params.mutationSymlinks !== undefined);
57188
- const resolvedRealPath = params.mutationSymlinks === undefined ? realpath_realpathSync.native(ioPath) : ioPath;
57189
- const admittedRealPath = root_boundary_admitPathInsideRoot({
57190
- rootPath: root.rootReal,
57191
- candidatePath: resolvedRealPath,
57192
- rootIdentity: root.rootIdentity,
57193
- });
57194
- if (!admittedRealPath) {
57195
- throw root_errors_outsideWorkspaceError();
57196
- }
57197
- ioPath = admittedRealPath.path;
57198
- }
57199
- catch (err) {
57200
- if (err instanceof errors_FsSafeError) {
57201
- throw err;
57750
+ let observedMissing = Boolean(creationProbe);
57751
+ if (!creationProbe)
57752
+ try {
57753
+ assertFinalSymlinkRejected(ioPath, params.mutationSymlinks !== undefined);
57754
+ const resolvedRealPath = params.mutationSymlinks === undefined ? realpath_realpathSync.native(ioPath) : ioPath;
57755
+ const admittedRealPath = root_boundary_admitPathInsideRoot({
57756
+ rootPath: root.rootReal,
57757
+ candidatePath: resolvedRealPath,
57758
+ rootIdentity: root.rootIdentity,
57759
+ });
57760
+ if (!admittedRealPath) {
57761
+ throw root_errors_outsideWorkspaceError();
57762
+ }
57763
+ ioPath = admittedRealPath.path;
57202
57764
  }
57203
- if (!path_isNotFoundPathError(err)) {
57204
- throw err;
57765
+ catch (err) {
57766
+ if (err instanceof errors_FsSafeError) {
57767
+ throw err;
57768
+ }
57769
+ if (!path_isNotFoundPathError(err)) {
57770
+ throw err;
57771
+ }
57772
+ observedMissing = true;
57205
57773
  }
57206
- }
57207
57774
  assertRootFallbackWritePath(params.expectedWritePath, ioPath);
57208
57775
  const mode = params.mode ?? 0o600;
57209
57776
  let handle;
@@ -57217,61 +57784,82 @@ async function openWritableFileInRoot(root, params, options) {
57217
57784
  writePathSelection = guardedTarget
57218
57785
  ? await prepareGuardedRootWritePathSelection(guardedTarget, ioPath, operationTargetPath, preparedParent)
57219
57786
  : undefined;
57220
- try {
57221
- if (writePathSelection)
57222
- assertRootWritePathSelectionSync(root, writePathSelection);
57223
- handle = await promises_.open(ioPath, existingFlags, mode);
57224
- }
57225
- catch (err) {
57226
- if (await isNonRegularWriteOpenError(err, ioPath, existingFlags)) {
57227
- throw new errors_FsSafeError("not-file", "path is not a regular file under root");
57787
+ const createNative = () => tryOpenCreateRootNative({
57788
+ originalPath: params.relativePath,
57789
+ root, directory: external_node_path_.dirname(ioPath), target: ioPath, mkdir: params.mkdir !== false, policy,
57790
+ selectedParent: creationProbe?.parent,
57791
+ resolveCurrent,
57792
+ assertBeforeMutation: params.assertBeforeMutation !== undefined || writePathSelection !== undefined ? () => {
57793
+ params.assertBeforeMutation?.();
57794
+ if (writePathSelection)
57795
+ assertRootWritePathSelectionSync(root, writePathSelection);
57796
+ } : undefined,
57797
+ flags: createFlags, existingFlags, mode,
57798
+ });
57799
+ let precreated;
57800
+ if (requireNative && observedMissing && !guardedTarget && params.assertBeforeMutation === undefined && options?.createIfMissing !== false) {
57801
+ try {
57802
+ precreated = await createNative();
57228
57803
  }
57229
- if (!path_isNotFoundPathError(err)) {
57230
- throw err;
57804
+ catch (error) {
57805
+ if (!hasNodeErrorCode(error, "EEXIST") || !isNativeCreateCollision(error))
57806
+ throw error;
57231
57807
  }
57232
- if (options?.createIfMissing === false) {
57233
- if (nativeCreatesParents && !guardedTarget)
57234
- await tryMkdirRootNative({
57235
- originalPath: params.relativePath,
57236
- root, directory: external_node_path_.dirname(ioPath), target: ioPath, mkdir: true, policy,
57237
- resolveCurrent, assertBeforeMutation: params.assertBeforeMutation,
57238
- });
57239
- const parentGuard = writePathSelection?.parentGuard ??
57240
- await directory_guard_createAsyncDirectoryGuard(external_node_path_.dirname(ioPath), { bigint: true });
57241
- root_context_assertRootIdentityCurrentSync(root);
57242
- if (!root_boundary_admitPathInsideRoot({
57243
- rootPath: root.rootReal, candidatePath: parentGuard.realPath, rootIdentity: root.rootIdentity,
57244
- }))
57245
- throw root_errors_outsideWorkspaceError();
57246
- directory_guard_assertSyncDirectoryGuard(parentGuard);
57247
- return { missing: true, targetPath: ioPath, parentGuard, writeSelection: writePathSelection };
57808
+ }
57809
+ if (precreated) {
57810
+ handle = precreated.handle;
57811
+ cleanupCreated = precreated.cleanupCreated;
57812
+ releaseCreationParent = precreated.releaseCreationParent;
57813
+ createdForWrite = true;
57814
+ }
57815
+ else {
57816
+ try {
57817
+ if (writePathSelection)
57818
+ assertRootWritePathSelectionSync(root, writePathSelection);
57819
+ handle = await promises_.open(ioPath, existingFlags, mode);
57248
57820
  }
57249
- if (writePathSelection)
57250
- await refreshRootWritePathSelection(writePathSelection);
57251
- const nativeCreated = requireNative ? await tryOpenCreateRootNative({
57252
- originalPath: params.relativePath,
57253
- root, directory: external_node_path_.dirname(ioPath), target: ioPath, mkdir: params.mkdir !== false, policy,
57254
- resolveCurrent, assertBeforeMutation() {
57821
+ catch (err) {
57822
+ if (await isNonRegularWriteOpenError(err, ioPath, existingFlags)) {
57823
+ throw new errors_FsSafeError("not-file", "path is not a regular file under root");
57824
+ }
57825
+ if (!path_isNotFoundPathError(err)) {
57826
+ throw err;
57827
+ }
57828
+ if (options?.createIfMissing === false) {
57829
+ if (nativeCreatesParents && !guardedTarget)
57830
+ await tryMkdirRootNative({
57831
+ originalPath: params.relativePath,
57832
+ root, directory: external_node_path_.dirname(ioPath), target: ioPath, mkdir: true, policy,
57833
+ resolveCurrent, assertBeforeMutation: params.assertBeforeMutation,
57834
+ });
57835
+ const parentGuard = writePathSelection?.parentGuard ??
57836
+ await directory_guard_createAsyncDirectoryGuard(external_node_path_.dirname(ioPath), { bigint: true });
57837
+ root_context_assertRootIdentityCurrentSync(root);
57838
+ if (!root_boundary_admitPathInsideRoot({
57839
+ rootPath: root.rootReal, candidatePath: parentGuard.realPath, rootIdentity: root.rootIdentity,
57840
+ }))
57841
+ throw root_errors_outsideWorkspaceError();
57842
+ directory_guard_assertSyncDirectoryGuard(parentGuard);
57843
+ return { missing: true, targetPath: ioPath, parentGuard, writeSelection: writePathSelection };
57844
+ }
57845
+ if (writePathSelection)
57846
+ await refreshRootWritePathSelection(writePathSelection);
57847
+ const nativeCreated = requireNative ? await createNative() : undefined;
57848
+ if (nativeCreated)
57849
+ handle = nativeCreated.handle;
57850
+ else {
57255
57851
  params.assertBeforeMutation?.();
57256
57852
  if (writePathSelection)
57257
57853
  assertRootWritePathSelectionSync(root, writePathSelection);
57258
- },
57259
- flags: createFlags, existingFlags, mode,
57260
- }) : undefined;
57261
- if (nativeCreated)
57262
- handle = nativeCreated.handle;
57263
- else {
57264
- params.assertBeforeMutation?.();
57265
- if (writePathSelection)
57266
- assertRootWritePathSelectionSync(root, writePathSelection);
57267
- // Windows can follow a dangling symlink even with O_EXCL.
57268
- if (!SUPPORTS_NOFOLLOW)
57269
- assertFinalSymlinkRejected(ioPath, true);
57270
- handle = await promises_.open(ioPath, createFlags, mode);
57854
+ // Windows can follow a dangling symlink even with O_EXCL.
57855
+ if (!SUPPORTS_NOFOLLOW)
57856
+ assertFinalSymlinkRejected(ioPath, true);
57857
+ handle = await promises_.open(ioPath, createFlags, mode);
57858
+ }
57859
+ cleanupCreated = nativeCreated?.cleanupCreated;
57860
+ releaseCreationParent = nativeCreated?.releaseCreationParent;
57861
+ createdForWrite = true;
57271
57862
  }
57272
- cleanupCreated = nativeCreated?.cleanupCreated;
57273
- releaseCreationParent = nativeCreated?.releaseCreationParent;
57274
- createdForWrite = true;
57275
57863
  }
57276
57864
  }
57277
57865
  catch (err) {
@@ -57518,6 +58106,8 @@ async function mkdirPathInRoot(root, params) {
57518
58106
  }
57519
58107
  if (tryMkdirNativeDirectChild(root, params.relativePath))
57520
58108
  return;
58109
+ if (tryMkdirNativeParents(root, params.relativePath))
58110
+ return;
57521
58111
  }
57522
58112
  const resolution = { relativePath: params.relativePath, allowRoot: params.allowRoot, ...policy };
57523
58113
  const resolveCurrent = policy
@@ -108008,4 +108598,4 @@ if (installedChunkData !== 0) { // 0 means "already installed".'
108008
108598
  // module factories are used so entry inlining is disabled
108009
108599
  // startup
108010
108600
  // Load entry module and return exports
108011
- var __webpack_exports__ = __webpack_require__(2473);
108601
+ var __webpack_exports__ = __webpack_require__(4010);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lousy-agents/mcp",
3
- "version": "5.22.0",
3
+ "version": "5.22.1",
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": {