@lousy-agents/mcp 5.22.0 → 5.22.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.
- package/dist/mcp-server.js +795 -123
- package/package.json +1 -1
package/dist/mcp-server.js
CHANGED
|
@@ -6559,7 +6559,7 @@ function escapeJsonPtr(str) {
|
|
|
6559
6559
|
|
|
6560
6560
|
|
|
6561
6561
|
},
|
|
6562
|
-
|
|
6562
|
+
7046(__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
|
-
|
|
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
|
|
@@ -38997,6 +39087,47 @@ function errorCauseOptions(error) {
|
|
|
38997
39087
|
|
|
38998
39088
|
// EXTERNAL MODULE: external "node:os"
|
|
38999
39089
|
var external_node_os_ = __webpack_require__(8161);
|
|
39090
|
+
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/windows-appcontainer.js
|
|
39091
|
+
|
|
39092
|
+
|
|
39093
|
+
/** The native owner caches immutable primary-token membership across Workers. */
|
|
39094
|
+
function isWindowsAppContainer(binding) {
|
|
39095
|
+
if (!binding.isWindowsAppContainer)
|
|
39096
|
+
return undefined;
|
|
39097
|
+
try {
|
|
39098
|
+
const membership = binding.isWindowsAppContainer();
|
|
39099
|
+
if (typeof membership !== "boolean")
|
|
39100
|
+
throw new Error("Invalid AppContainer membership");
|
|
39101
|
+
return membership;
|
|
39102
|
+
}
|
|
39103
|
+
catch (cause) {
|
|
39104
|
+
throw new errors_FsSafeError("permission-unverified", "Windows process token membership could not be verified", { cause });
|
|
39105
|
+
}
|
|
39106
|
+
}
|
|
39107
|
+
function windows_appcontainer_assertWindowsHelperAllowed() {
|
|
39108
|
+
if (process.platform !== "win32")
|
|
39109
|
+
return;
|
|
39110
|
+
const binding = native_getNativeBinding();
|
|
39111
|
+
if (binding && isWindowsAppContainer(binding)) {
|
|
39112
|
+
// Current libuv can hang while creating child-process pipes in a lowbox.
|
|
39113
|
+
throw new errors_FsSafeError("helper-unavailable", "External Windows security helpers are unavailable inside an AppContainer");
|
|
39114
|
+
}
|
|
39115
|
+
}
|
|
39116
|
+
function assertWindowsAclRemediationAllowed() {
|
|
39117
|
+
if (process.platform !== "win32")
|
|
39118
|
+
return;
|
|
39119
|
+
let binding;
|
|
39120
|
+
try {
|
|
39121
|
+
binding = getNativeBinding();
|
|
39122
|
+
}
|
|
39123
|
+
catch {
|
|
39124
|
+
return;
|
|
39125
|
+
} // Command formatting remains available without an addon.
|
|
39126
|
+
if (binding && isWindowsAppContainer(binding)) {
|
|
39127
|
+
throw new FsSafeError("helper-unavailable", "Windows ACL reset commands are unavailable inside an AppContainer");
|
|
39128
|
+
}
|
|
39129
|
+
}
|
|
39130
|
+
|
|
39000
39131
|
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/realpath.js
|
|
39001
39132
|
|
|
39002
39133
|
|
|
@@ -39004,9 +39135,41 @@ var external_node_os_ = __webpack_require__(8161);
|
|
|
39004
39135
|
|
|
39005
39136
|
|
|
39006
39137
|
|
|
39138
|
+
|
|
39007
39139
|
const runtimePlatform = process.versions.bun ? (0,external_node_os_.platform)() : undefined;
|
|
39008
39140
|
const bunPosix = runtimePlatform === "darwin" || runtimePlatform === "linux" ? runtimePlatform : undefined;
|
|
39009
39141
|
function realpath_resolve(input, native) {
|
|
39142
|
+
if (native && process.platform === "win32") {
|
|
39143
|
+
try {
|
|
39144
|
+
return external_node_fs_.realpathSync.native(input);
|
|
39145
|
+
}
|
|
39146
|
+
catch (error) {
|
|
39147
|
+
if (error.code !== "EPERM" || error.syscall !== "realpath")
|
|
39148
|
+
throw error;
|
|
39149
|
+
let binding;
|
|
39150
|
+
try {
|
|
39151
|
+
binding = native_getNativeBinding();
|
|
39152
|
+
}
|
|
39153
|
+
catch {
|
|
39154
|
+
binding = undefined;
|
|
39155
|
+
}
|
|
39156
|
+
if (!binding || !isWindowsAppContainer(binding))
|
|
39157
|
+
throw error;
|
|
39158
|
+
if (!binding?.resolveWindowsCanonicalPath) {
|
|
39159
|
+
throw new errors_FsSafeError("helper-unavailable", "Windows canonicalization after a denied DOS-name query requires the native binding", { cause: error });
|
|
39160
|
+
}
|
|
39161
|
+
let resolved;
|
|
39162
|
+
try {
|
|
39163
|
+
resolved = binding.resolveWindowsCanonicalPath(input);
|
|
39164
|
+
}
|
|
39165
|
+
catch (cause) {
|
|
39166
|
+
throw new errors_FsSafeError("path-mismatch", "Windows canonical path cannot be verified safely", { cause });
|
|
39167
|
+
}
|
|
39168
|
+
if (resolved === null)
|
|
39169
|
+
throw error;
|
|
39170
|
+
return resolved;
|
|
39171
|
+
}
|
|
39172
|
+
}
|
|
39010
39173
|
if (bunPosix) {
|
|
39011
39174
|
// Bun 1.4.2 normalizes native path components and opens the leaf for reads.
|
|
39012
39175
|
// The Rust OS resolver preserves permissions, locks and physical spelling.
|
|
@@ -39314,6 +39477,15 @@ function assertDirectoryObservationGuardSync(guard) {
|
|
|
39314
39477
|
}
|
|
39315
39478
|
}
|
|
39316
39479
|
|
|
39480
|
+
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/native-stat-identity.js
|
|
39481
|
+
/** Native stat identities are unsigned; Node BigIntStats preserves them as signed bits. */
|
|
39482
|
+
function statIdentityFromNative(value) {
|
|
39483
|
+
return value <= 0x7fffffffffffffffn || process.versions.bun ? value : BigInt.asIntN(64, value);
|
|
39484
|
+
}
|
|
39485
|
+
function isNativeStatIdentity(value) {
|
|
39486
|
+
return typeof value === "bigint" && value >= 0n && value <= 0xffffffffffffffffn;
|
|
39487
|
+
}
|
|
39488
|
+
|
|
39317
39489
|
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/directory-receipt.js
|
|
39318
39490
|
|
|
39319
39491
|
|
|
@@ -39818,6 +39990,7 @@ function createSuppressedError(error, suppressed, message) {
|
|
|
39818
39990
|
|
|
39819
39991
|
|
|
39820
39992
|
|
|
39993
|
+
|
|
39821
39994
|
/** Shared by tree byte copying and per-file copying; never resolves the target. */
|
|
39822
39995
|
async function readCopyLinkTarget(source) {
|
|
39823
39996
|
return await promises_.readlink(source, { encoding: "buffer" });
|
|
@@ -39887,7 +40060,7 @@ async function copyLinkAtParent(params, input, parent, native) {
|
|
|
39887
40060
|
directory_guard_assertSyncDirectoryGuard(parent);
|
|
39888
40061
|
if (native?.binding.createCopySymlink) {
|
|
39889
40062
|
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;
|
|
40063
|
+
identity = { dev: statIdentityFromNative(created.dev), ino: statIdentityFromNative(created.ino) };
|
|
39891
40064
|
if (created.errorCode)
|
|
39892
40065
|
throw Object.assign(new Error(created.errorMessage), { code: created.errorCode });
|
|
39893
40066
|
}
|
|
@@ -40613,14 +40786,61 @@ function pinNodeDirectoryForModeSync(dirPath, options = {}) {
|
|
|
40613
40786
|
}
|
|
40614
40787
|
}
|
|
40615
40788
|
|
|
40789
|
+
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/native-guidance.js
|
|
40790
|
+
/** Shared, path-free next steps for status reports and fallback warnings. */
|
|
40791
|
+
function nativeGuidance(reason, modeSource) {
|
|
40792
|
+
switch (reason) {
|
|
40793
|
+
case "disabled": {
|
|
40794
|
+
const enable = modeSource === "programmatic configuration"
|
|
40795
|
+
? 'call configureFsSafeNative({ mode: "auto" }) or configureFsSafeNative({ mode: "require" })'
|
|
40796
|
+
: `set ${modeSource}=auto or ${modeSource}=require`;
|
|
40797
|
+
return `If native loading is intended, ${enable}; keep intentional off settings.`;
|
|
40798
|
+
}
|
|
40799
|
+
case "unsupported-target":
|
|
40800
|
+
return "Portable mode is expected on this target.";
|
|
40801
|
+
case "package-missing":
|
|
40802
|
+
return "Reinstall with optional dependencies included: npm --include=optional, or pnpm without --no-optional / optional=false. Check the lockfile and registry mirror.";
|
|
40803
|
+
case "load-failed":
|
|
40804
|
+
return "Check Node architecture, Linux libc compatibility, package dependencies, and OS code-integrity policy. Reinstalling identical bytes may not help.";
|
|
40805
|
+
case "capability-missing":
|
|
40806
|
+
return "Use matching fs-safe and platform-package versions; some targets intentionally provide only a subset of capabilities.";
|
|
40807
|
+
default:
|
|
40808
|
+
return undefined;
|
|
40809
|
+
}
|
|
40810
|
+
}
|
|
40811
|
+
|
|
40616
40812
|
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/native-fallback-warning.js
|
|
40813
|
+
|
|
40814
|
+
|
|
40815
|
+
|
|
40617
40816
|
const warnedFeatures = new Set();
|
|
40817
|
+
function fallbackReason(capabilities) {
|
|
40818
|
+
const diagnostic = getNativeFallbackDiagnostic(...capabilities);
|
|
40819
|
+
const expected = diagnostic.packageName === undefined
|
|
40820
|
+
? `No native package is published for ${diagnostic.target}.`
|
|
40821
|
+
: `Expected ${diagnostic.packageName}@${diagnostic.packageVersion}.`;
|
|
40822
|
+
const guidance = nativeGuidance(diagnostic.reason, getNativeModeSetting().source);
|
|
40823
|
+
switch (diagnostic.reason) {
|
|
40824
|
+
case "disabled":
|
|
40825
|
+
return `native support is disabled by ${diagnostic.source} (disabled). ${expected} ${guidance}`;
|
|
40826
|
+
case "unsupported-target":
|
|
40827
|
+
return `the target ${diagnostic.target} is unsupported (unsupported-target). ${expected} ${guidance}`;
|
|
40828
|
+
case "package-missing":
|
|
40829
|
+
return `the selected native package could not be resolved (package-missing). ${expected} ${guidance}`;
|
|
40830
|
+
case "load-failed":
|
|
40831
|
+
return `the native package could not be loaded (load-failed: ${diagnostic.code}). ${expected} ${guidance}`;
|
|
40832
|
+
case "capability-missing":
|
|
40833
|
+
return `the native package lacks requested functions (capability-missing: ${diagnostic.capabilities.join(", ")}). ${expected} ${guidance}`;
|
|
40834
|
+
default:
|
|
40835
|
+
return `the requested native operation is unavailable (${diagnostic.reason}). ${expected}`;
|
|
40836
|
+
}
|
|
40837
|
+
}
|
|
40618
40838
|
/** Warn once per capability, without including caller paths or native error text. */
|
|
40619
|
-
function warnNativeFallback(feature, limitation) {
|
|
40839
|
+
function warnNativeFallback(feature, limitation, ...capabilities) {
|
|
40620
40840
|
if (warnedFeatures.has(feature))
|
|
40621
40841
|
return;
|
|
40622
40842
|
warnedFeatures.add(feature);
|
|
40623
|
-
process.emitWarning(`${feature} is using its portable fallback because
|
|
40843
|
+
process.emitWarning(`${feature} is using its portable fallback because ${fallbackReason(capabilities)} ${limitation}`, { code: "FS_SAFE_NATIVE_FALLBACK", type: "FsSafeWarning" });
|
|
40624
40844
|
}
|
|
40625
40845
|
function __resetNativeFallbackWarningsForTest() {
|
|
40626
40846
|
warnedFeatures.clear();
|
|
@@ -40651,6 +40871,7 @@ function shortPath(value) {
|
|
|
40651
40871
|
|
|
40652
40872
|
|
|
40653
40873
|
|
|
40874
|
+
|
|
40654
40875
|
const execFileAsync = (0,external_node_util_.promisify)(external_node_child_process_.execFile);
|
|
40655
40876
|
const DEFAULT_PERMISSION_EXEC_TIMEOUT_MS = 30_000;
|
|
40656
40877
|
function formatPermissionErrorDetail(value) {
|
|
@@ -40828,6 +41049,7 @@ function getPermissionCommandFailure(error, command, durationMs) {
|
|
|
40828
41049
|
return { command, durationMs: Math.round(durationMs), ...detail };
|
|
40829
41050
|
}
|
|
40830
41051
|
async function executePermissionCommand(command, args, timeoutMs = DEFAULT_PERMISSION_EXEC_TIMEOUT_MS) {
|
|
41052
|
+
assertWindowsHelperAllowed();
|
|
40831
41053
|
const startedAt = performance.now();
|
|
40832
41054
|
try {
|
|
40833
41055
|
return (await execFileAsync(command, args, {
|
|
@@ -40851,6 +41073,7 @@ async function executePermissionCommand(command, args, timeoutMs = DEFAULT_PERMI
|
|
|
40851
41073
|
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/windows-security-facts.js
|
|
40852
41074
|
|
|
40853
41075
|
const SID_RE = /^s-\d+-\d+(?:-\d+)+$/;
|
|
41076
|
+
const APP_CONTAINER_SID_RE = /^s-1-15-2(?:-\d+){7,}$/;
|
|
40854
41077
|
const SYSTEM_SID = "s-1-5-18";
|
|
40855
41078
|
const ADMINISTRATORS_SID = "s-1-5-32-544";
|
|
40856
41079
|
const WORLD_SIDS = new Set([
|
|
@@ -40885,6 +41108,7 @@ function validateAce(value, allowUnknownFlags) {
|
|
|
40885
41108
|
function validateDescriptor(value, allowUnknownFlags) {
|
|
40886
41109
|
if (!windows_security_facts_record(value) || typeof value.ownerSid !== "string" || !SID_RE.test(value.ownerSid) ||
|
|
40887
41110
|
typeof value.currentUserSid !== "string" || !SID_RE.test(value.currentUserSid) ||
|
|
41111
|
+
(value.currentAppContainerSid != null && (typeof value.currentAppContainerSid !== "string" || !APP_CONTAINER_SID_RE.test(value.currentAppContainerSid))) ||
|
|
40888
41112
|
typeof value.daclPresent !== "boolean" || typeof value.isLocal !== "boolean" ||
|
|
40889
41113
|
typeof value.aceListComplete !== "boolean" || !Array.isArray(value.unsupportedAceTypes) ||
|
|
40890
41114
|
!value.unsupportedAceTypes.every(windows_security_facts_uint32) || !Array.isArray(value.aces) ||
|
|
@@ -40910,6 +41134,8 @@ function summarize(facts) {
|
|
|
40910
41134
|
let groupReadable = false;
|
|
40911
41135
|
let groupWritable = false;
|
|
40912
41136
|
const trusted = new Set([facts.currentUserSid, SYSTEM_SID, ADMINISTRATORS_SID]);
|
|
41137
|
+
if (facts.currentAppContainerSid)
|
|
41138
|
+
trusted.add(facts.currentAppContainerSid);
|
|
40913
41139
|
for (const ace of facts.aces) {
|
|
40914
41140
|
if (ace.aceType !== "allow" || ace.flags.inheritOnly || trusted.has(ace.sid))
|
|
40915
41141
|
continue;
|
|
@@ -40978,6 +41204,7 @@ function windows_security_helper_explainWindowsSecurityHelperFailure(error) {
|
|
|
40978
41204
|
|
|
40979
41205
|
|
|
40980
41206
|
|
|
41207
|
+
|
|
40981
41208
|
const MAX_OUTPUT_BYTES = 1024 * 1024;
|
|
40982
41209
|
const TERMINATION_GRACE_MS = 1_000;
|
|
40983
41210
|
const FULL_IDENTITY = /^[0-9a-f]{16}:[0-9a-f]{32}$/;
|
|
@@ -41080,6 +41307,7 @@ function explainHelperFailure(error, file) {
|
|
|
41080
41307
|
}
|
|
41081
41308
|
}
|
|
41082
41309
|
function executeSync(operation, params) {
|
|
41310
|
+
assertWindowsHelperAllowed();
|
|
41083
41311
|
const { file, args, env } = windows_security_command_command(operation, params);
|
|
41084
41312
|
const startedAt = performance.now();
|
|
41085
41313
|
const result = spawnSync(file, args, {
|
|
@@ -41152,6 +41380,7 @@ function hasUnsettledWindowsSecurityCommand(error) {
|
|
|
41152
41380
|
}
|
|
41153
41381
|
function ignoreLateError() { }
|
|
41154
41382
|
async function execute(operation, params, request) {
|
|
41383
|
+
windows_appcontainer_assertWindowsHelperAllowed();
|
|
41155
41384
|
const selected = request ?? windows_security_command_command(operation, params);
|
|
41156
41385
|
const { file, args, env, input, timeoutMs = (/* inlined export .DEFAULT_PERMISSION_EXEC_TIMEOUT_MS */30000), maxOutputBytes = MAX_OUTPUT_BYTES } = selected;
|
|
41157
41386
|
const startedAt = performance.now();
|
|
@@ -41459,17 +41688,17 @@ function creation_boundary_assertPrivateFileCreationAvailable() {
|
|
|
41459
41688
|
typeof native.verifyPrivateWindowsFile !== "function")
|
|
41460
41689
|
creation_boundary_unavailable();
|
|
41461
41690
|
}
|
|
41462
|
-
function commandFallback() {
|
|
41691
|
+
function commandFallback(capability) {
|
|
41463
41692
|
if (getFsSafeNativeConfig().mode === "require")
|
|
41464
41693
|
creation_boundary_unavailable();
|
|
41465
|
-
warnNativeFallback("windows-private-creation", "Private Windows creation
|
|
41694
|
+
warnNativeFallback("windows-private-creation", "Private Windows creation launches the packaged .NET helper for each check or creation.", capability);
|
|
41466
41695
|
}
|
|
41467
41696
|
function creationOperation(name) {
|
|
41468
41697
|
const native = native_getNativeBinding();
|
|
41469
41698
|
const operation = native?.[name];
|
|
41470
41699
|
if (typeof operation === "function")
|
|
41471
41700
|
return operation.bind(native);
|
|
41472
|
-
commandFallback();
|
|
41701
|
+
commandFallback(name);
|
|
41473
41702
|
return undefined;
|
|
41474
41703
|
}
|
|
41475
41704
|
/** Full Windows identity, with security validation when requested; no repairs. */
|
|
@@ -43798,6 +44027,7 @@ function mergeDenyMutationPolicies(defaultPolicy, callPolicy) {
|
|
|
43798
44027
|
|
|
43799
44028
|
|
|
43800
44029
|
|
|
44030
|
+
|
|
43801
44031
|
function getNativeDirectoryObservationBackend(enabled = true) {
|
|
43802
44032
|
if (!enabled)
|
|
43803
44033
|
return undefined;
|
|
@@ -43807,14 +44037,15 @@ function getNativeDirectoryObservationBackend(enabled = true) {
|
|
|
43807
44037
|
: undefined;
|
|
43808
44038
|
}
|
|
43809
44039
|
function validateNativeDirectoryObservation(observation) {
|
|
43810
|
-
if (!observation ||
|
|
43811
|
-
|
|
44040
|
+
if (!observation || !isNativeStatIdentity(observation.dev) ||
|
|
44041
|
+
!isNativeStatIdentity(observation.ino) ||
|
|
43812
44042
|
typeof observation.realPath !== "string" ||
|
|
43813
44043
|
observation.realPath.includes("\0") ||
|
|
43814
44044
|
(!external_node_path_.isAbsolute(observation.realPath) && !external_node_path_.win32.isAbsolute(observation.realPath))) {
|
|
43815
44045
|
throw new errors_FsSafeError("path-mismatch", "native directory observation is invalid");
|
|
43816
44046
|
}
|
|
43817
|
-
|
|
44047
|
+
const dev = statIdentityFromNative(observation.dev), ino = statIdentityFromNative(observation.ino);
|
|
44048
|
+
return dev === observation.dev && ino === observation.ino ? observation : { ...observation, dev, ino };
|
|
43818
44049
|
}
|
|
43819
44050
|
/** Exact identity, type, and canonical path captured from one retained handle. */
|
|
43820
44051
|
function inspectNativeDirectoryObservation(backend, pathname, expected, platform = process.platform) {
|
|
@@ -43836,6 +44067,7 @@ function isNativeDirectoryObservationGuard(guard) {
|
|
|
43836
44067
|
|
|
43837
44068
|
|
|
43838
44069
|
|
|
44070
|
+
|
|
43839
44071
|
class NativePolicyDirectoryMismatch extends errors_FsSafeError {
|
|
43840
44072
|
constructor(cause) {
|
|
43841
44073
|
super("path-mismatch", "staging directory pathname changed", { cause });
|
|
@@ -43874,8 +44106,8 @@ function native_policy_directory_observation_nativePolicyDirectoryObserver(bindi
|
|
|
43874
44106
|
}
|
|
43875
44107
|
if (getFsSafeNativeConfig().mode !== mode)
|
|
43876
44108
|
return undefined;
|
|
43877
|
-
if (!observed ||
|
|
43878
|
-
|
|
44109
|
+
if (!observed || !isNativeStatIdentity(observed.dev) ||
|
|
44110
|
+
!isNativeStatIdentity(observed.ino) ||
|
|
43879
44111
|
typeof observed.mode !== "bigint" || observed.mode < 0n || observed.mode > 0xffffffffn ||
|
|
43880
44112
|
typeof observed.nlink !== "bigint" || observed.nlink < 0n || observed.nlink > 0xffffffffffffffffn ||
|
|
43881
44113
|
typeof observed.realPath !== "string" || observed.realPath.includes("\0") ||
|
|
@@ -43888,7 +44120,7 @@ function native_policy_directory_observation_nativePolicyDirectoryObserver(bindi
|
|
|
43888
44120
|
return Object.freeze({
|
|
43889
44121
|
canonicalPath: observed.realPath,
|
|
43890
44122
|
identity: Object.freeze({
|
|
43891
|
-
dev: observed.dev, ino: observed.ino, mode: observed.mode, nlink: observed.nlink,
|
|
44123
|
+
dev: statIdentityFromNative(observed.dev), ino: statIdentityFromNative(observed.ino), mode: observed.mode, nlink: observed.nlink,
|
|
43892
44124
|
}),
|
|
43893
44125
|
});
|
|
43894
44126
|
};
|
|
@@ -46678,6 +46910,64 @@ function __setFsSafeTestHooksForTest(hooks) {
|
|
|
46678
46910
|
test_hooks_fsSafeTestHooks = hooks;
|
|
46679
46911
|
}
|
|
46680
46912
|
|
|
46913
|
+
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/root-native-creation-path.js
|
|
46914
|
+
|
|
46915
|
+
|
|
46916
|
+
|
|
46917
|
+
|
|
46918
|
+
|
|
46919
|
+
|
|
46920
|
+
|
|
46921
|
+
|
|
46922
|
+
|
|
46923
|
+
function existingCreationParent(params) {
|
|
46924
|
+
if (params.private || params.policy || params.assertBeforeMutation !== undefined ||
|
|
46925
|
+
getFsSafeTestHooks()?.beforeRootFallbackMutation || !params.originalPath ||
|
|
46926
|
+
params.directory !== external_node_path_.dirname(params.target))
|
|
46927
|
+
return undefined;
|
|
46928
|
+
const segments = params.originalPath.split(external_node_path_.sep === "\\" ? /[\\/]/ : "/");
|
|
46929
|
+
if (segments.some(segment => !isSafePathSegment(segment, { allowDotPrefix: true }) || segment.endsWith(".")) ||
|
|
46930
|
+
external_node_path_.join(params.root.rootReal, ...segments) !== params.target)
|
|
46931
|
+
return undefined;
|
|
46932
|
+
let rootStat;
|
|
46933
|
+
root_context_assertRootIdentityCurrentSync(params.root, stat => { rootStat = stat; });
|
|
46934
|
+
try {
|
|
46935
|
+
const identity = directory_guard_inspectDirectoryIdentitySync(params.directory, undefined, params.directory === params.root.rootReal ? rootStat : undefined);
|
|
46936
|
+
if (realpath_realpathSync.native(windows_path_alias_pathForWindowsFilesystem(params.directory)) !== params.directory)
|
|
46937
|
+
return undefined;
|
|
46938
|
+
return {
|
|
46939
|
+
path: params.directory, identity,
|
|
46940
|
+
relative: external_node_path_.relative(params.root.rootReal, params.directory).split(external_node_path_.sep).join("/"),
|
|
46941
|
+
flags: (nodeDirectorySearchOnlyFlags()?.flags ?? external_node_fs_.constants.O_RDONLY) |
|
|
46942
|
+
(external_node_fs_.constants.O_DIRECTORY ?? 0) | (external_node_fs_.constants.O_NOFOLLOW ?? 0),
|
|
46943
|
+
};
|
|
46944
|
+
}
|
|
46945
|
+
catch {
|
|
46946
|
+
return undefined;
|
|
46947
|
+
}
|
|
46948
|
+
}
|
|
46949
|
+
function probeNativeCreationPath(root, relativePath) {
|
|
46950
|
+
if (typeof relativePath !== "string")
|
|
46951
|
+
return undefined;
|
|
46952
|
+
const segments = relativePath.split(external_node_path_.sep === "\\" ? /[\\/]/ : "/");
|
|
46953
|
+
if (segments.some(segment => !isSafePathSegment(segment, { allowDotPrefix: true }) || segment.endsWith(".")))
|
|
46954
|
+
return undefined;
|
|
46955
|
+
const target = external_node_path_.join(root.rootReal, ...segments);
|
|
46956
|
+
root_context_assertRootIdentityCurrentSync(root);
|
|
46957
|
+
try {
|
|
46958
|
+
if (external_node_fs_.lstatSync(windows_path_alias_pathForWindowsFilesystem(target), { throwIfNoEntry: false }))
|
|
46959
|
+
return undefined;
|
|
46960
|
+
}
|
|
46961
|
+
catch {
|
|
46962
|
+
return undefined;
|
|
46963
|
+
}
|
|
46964
|
+
const parent = existingCreationParent({ root, target, directory: external_node_path_.dirname(target), mkdir: true,
|
|
46965
|
+
originalPath: relativePath, resolveCurrent: async () => target });
|
|
46966
|
+
if (!parent)
|
|
46967
|
+
return undefined;
|
|
46968
|
+
return { rootReal: root.rootReal, rootWithSep: root.rootWithSep, resolved: target, parent };
|
|
46969
|
+
}
|
|
46970
|
+
|
|
46681
46971
|
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/root-create-native.js
|
|
46682
46972
|
var root_create_native_addDisposableResource = (undefined && undefined.__addDisposableResource) || function (env, value, async) {
|
|
46683
46973
|
if (value !== null && value !== void 0) {
|
|
@@ -46755,6 +47045,8 @@ var root_create_native_disposeResources = (undefined && undefined.__disposeResou
|
|
|
46755
47045
|
|
|
46756
47046
|
|
|
46757
47047
|
|
|
47048
|
+
|
|
47049
|
+
|
|
46758
47050
|
|
|
46759
47051
|
|
|
46760
47052
|
|
|
@@ -46764,6 +47056,10 @@ function rootWriteQueueKey(root, relativePath) {
|
|
|
46764
47056
|
function buildAtomicWriteTempPath(targetPath) {
|
|
46765
47057
|
return external_node_path_.join(external_node_path_.dirname(targetPath), `.fs-safe-${(0,external_node_crypto_.randomUUID)()}.tmp`);
|
|
46766
47058
|
}
|
|
47059
|
+
const nativeCreateCollisions = new WeakSet();
|
|
47060
|
+
function isNativeCreateCollision(error) {
|
|
47061
|
+
return typeof error === "object" && error !== null && nativeCreateCollisions.has(error);
|
|
47062
|
+
}
|
|
46767
47063
|
function root_create_native_unavailable() {
|
|
46768
47064
|
throw new errors_FsSafeError("helper-unavailable", "native confined creation is unavailable");
|
|
46769
47065
|
}
|
|
@@ -46771,6 +47067,60 @@ async function withNativeDirectory(params, operation, discard) {
|
|
|
46771
47067
|
const binding = native_getNativeBinding("openBeneath", "mkdirChildBeneath");
|
|
46772
47068
|
if (!binding?.openBeneath || !binding.mkdirChildBeneath || (params.private && process.platform === "win32"))
|
|
46773
47069
|
return root_create_native_unavailable();
|
|
47070
|
+
const existing = params.selectedParent ?? existingCreationParent(params);
|
|
47071
|
+
if (existing) {
|
|
47072
|
+
let pending;
|
|
47073
|
+
try {
|
|
47074
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
47075
|
+
try {
|
|
47076
|
+
const rootOwner = root_create_native_addDisposableResource(env_1, openExactNativeRootSync(binding, {
|
|
47077
|
+
rootPath: params.root.rootReal, rootIdentity: params.root.rootIdentity,
|
|
47078
|
+
}), false);
|
|
47079
|
+
const close = captureNativeFdClose(binding);
|
|
47080
|
+
const borrowed = existing.path === params.root.rootReal;
|
|
47081
|
+
const fd = borrowed ? rootOwner.fd : binding.openBeneath(rootOwner.fd, existing.relative, existing.flags).fd;
|
|
47082
|
+
const parentOwner = root_create_native_addDisposableResource(env_1, { [Symbol.dispose]() { if (!borrowed)
|
|
47083
|
+
close(fd); } }, false);
|
|
47084
|
+
strict_file_identity_inspectFileIdentitySync(() => borrowed ? rootOwner.stat : external_node_fs_.fstatSync(fd, { bigint: true }), existing.identity);
|
|
47085
|
+
verifyMkdirDirectory(binding, fd, existing.path);
|
|
47086
|
+
const guard = { dir: existing.path, realPath: existing.path, stat: existing.identity };
|
|
47087
|
+
const assertCurrent = () => {
|
|
47088
|
+
let currentRoot;
|
|
47089
|
+
root_context_assertRootIdentityCurrentSync(params.root, stat => { currentRoot = stat; });
|
|
47090
|
+
if (borrowed) {
|
|
47091
|
+
// Root and parent are the same name in this synchronous fence.
|
|
47092
|
+
directory_guard_inspectDirectoryIdentitySync(existing.path, existing.identity, currentRoot);
|
|
47093
|
+
if (realpath_realpathSync.native(windows_path_alias_pathForWindowsFilesystem(existing.path)) !== existing.path) {
|
|
47094
|
+
throw new errors_FsSafeError("path-mismatch", "directory changed during operation");
|
|
47095
|
+
}
|
|
47096
|
+
}
|
|
47097
|
+
else {
|
|
47098
|
+
directory_guard_assertSyncDirectoryGuard(guard);
|
|
47099
|
+
}
|
|
47100
|
+
};
|
|
47101
|
+
pending = { value: await operation(binding, fd, assertCurrent) };
|
|
47102
|
+
return pending.value;
|
|
47103
|
+
}
|
|
47104
|
+
catch (e_1) {
|
|
47105
|
+
env_1.error = e_1;
|
|
47106
|
+
env_1.hasError = true;
|
|
47107
|
+
}
|
|
47108
|
+
finally {
|
|
47109
|
+
root_create_native_disposeResources(env_1);
|
|
47110
|
+
}
|
|
47111
|
+
}
|
|
47112
|
+
catch (error) {
|
|
47113
|
+
if (pending && discard) {
|
|
47114
|
+
try {
|
|
47115
|
+
await discard(pending.value);
|
|
47116
|
+
}
|
|
47117
|
+
catch (cleanupError) {
|
|
47118
|
+
throw createSuppressedError(cleanupError, error, "creation handoff and cleanup failed");
|
|
47119
|
+
}
|
|
47120
|
+
}
|
|
47121
|
+
throw error;
|
|
47122
|
+
}
|
|
47123
|
+
}
|
|
46774
47124
|
const directoryTarget = params.directory === params.target;
|
|
46775
47125
|
const canonicalTarget = async (target) => directoryTarget
|
|
46776
47126
|
? await resolvePathViaExistingAncestor(target)
|
|
@@ -46787,14 +47137,14 @@ async function withNativeDirectory(params, operation, discard) {
|
|
|
46787
47137
|
const close = captureNativeFdClose(binding);
|
|
46788
47138
|
let pending;
|
|
46789
47139
|
try {
|
|
46790
|
-
const
|
|
47140
|
+
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
46791
47141
|
try {
|
|
46792
47142
|
const admitted = await openNativeRootAdmission(binding, {
|
|
46793
47143
|
rootPath: params.root.rootReal, rootIdentity: params.root.rootIdentity, operation: "create", reportCloseErrors: true, searchOnly: true,
|
|
46794
47144
|
});
|
|
46795
|
-
const rootOwner = root_create_native_addDisposableResource(
|
|
47145
|
+
const rootOwner = root_create_native_addDisposableResource(env_2, admitted.root, true);
|
|
46796
47146
|
const descriptors = [];
|
|
46797
|
-
const directoryOwner = root_create_native_addDisposableResource(
|
|
47147
|
+
const directoryOwner = root_create_native_addDisposableResource(env_2, { [Symbol.dispose]() {
|
|
46798
47148
|
const errors = [];
|
|
46799
47149
|
for (const fd of descriptors.reverse())
|
|
46800
47150
|
try {
|
|
@@ -46892,12 +47242,12 @@ async function withNativeDirectory(params, operation, discard) {
|
|
|
46892
47242
|
pending = { value: await operation(binding, current, assertCurrent) };
|
|
46893
47243
|
return pending.value;
|
|
46894
47244
|
}
|
|
46895
|
-
catch (
|
|
46896
|
-
|
|
46897
|
-
|
|
47245
|
+
catch (e_2) {
|
|
47246
|
+
env_2.error = e_2;
|
|
47247
|
+
env_2.hasError = true;
|
|
46898
47248
|
}
|
|
46899
47249
|
finally {
|
|
46900
|
-
const result_1 = root_create_native_disposeResources(
|
|
47250
|
+
const result_1 = root_create_native_disposeResources(env_2);
|
|
46901
47251
|
if (result_1)
|
|
46902
47252
|
await result_1;
|
|
46903
47253
|
}
|
|
@@ -46976,33 +47326,77 @@ function verifyMkdirDirectory(binding, fd, pathname) {
|
|
|
46976
47326
|
describePolicyStagedDirectory(fd, pathname);
|
|
46977
47327
|
}
|
|
46978
47328
|
function ensureNativeRootCurrent(root) {
|
|
46979
|
-
|
|
47329
|
+
root_context_assertRootIdentityCurrentSync(root);
|
|
47330
|
+
const binding = native_getNativeBinding("openBeneath", "mkdirChildBeneath");
|
|
47331
|
+
if (!binding?.openBeneath || !binding.mkdirChildBeneath)
|
|
47332
|
+
return root_create_native_unavailable();
|
|
47333
|
+
if (binding.verifyRootDirectory) {
|
|
47334
|
+
const closeNative = captureNativeFdClose(binding);
|
|
47335
|
+
const failure = binding.verifyRootDirectory(root.rootReal, root.rootIdentity.dev, root.rootIdentity.ino);
|
|
47336
|
+
if (failure === null)
|
|
47337
|
+
return;
|
|
47338
|
+
if (failure?.fallbackFd !== undefined && failure.fallbackFd !== null) {
|
|
47339
|
+
const env_3 = { stack: [], error: void 0, hasError: false };
|
|
47340
|
+
try {
|
|
47341
|
+
const fd = failure.fallbackFd;
|
|
47342
|
+
if (!Number.isInteger(fd) || fd < 0)
|
|
47343
|
+
throw new errors_FsSafeError("helper-failed", "invalid root fallback descriptor");
|
|
47344
|
+
const owner = root_create_native_addDisposableResource(env_3, { [Symbol.dispose]() { closeNative(fd); } }, false);
|
|
47345
|
+
if (failure.errorCode || failure.closeErrorCode)
|
|
47346
|
+
throw new errors_FsSafeError("helper-failed", "invalid root verification result");
|
|
47347
|
+
ensureNativeRootCurrentLegacy(root, binding);
|
|
47348
|
+
return;
|
|
47349
|
+
}
|
|
47350
|
+
catch (e_3) {
|
|
47351
|
+
env_3.error = e_3;
|
|
47352
|
+
env_3.hasError = true;
|
|
47353
|
+
}
|
|
47354
|
+
finally {
|
|
47355
|
+
root_create_native_disposeResources(env_3);
|
|
47356
|
+
}
|
|
47357
|
+
}
|
|
47358
|
+
const error = failure?.errorCode ? rootVerificationError(failure.errorCode, failure.errorMessage, failure.errorErrno) : undefined;
|
|
47359
|
+
const closeError = failure?.closeErrorCode ? Object.assign(new Error(failure.closeErrorMessage), {
|
|
47360
|
+
code: failure.closeErrorCode,
|
|
47361
|
+
...(typeof failure.closeErrorErrno === "number" ? { errno: failure.closeErrorErrno } : {}),
|
|
47362
|
+
}) : undefined;
|
|
47363
|
+
if (error && closeError)
|
|
47364
|
+
throw createSuppressedError(closeError, error, "root verification and close failed");
|
|
47365
|
+
if (error || closeError)
|
|
47366
|
+
throw error ?? closeError;
|
|
47367
|
+
throw new errors_FsSafeError("helper-failed", "invalid root verification result");
|
|
47368
|
+
}
|
|
47369
|
+
ensureNativeRootCurrentLegacy(root, binding);
|
|
47370
|
+
}
|
|
47371
|
+
function rootVerificationError(code, message, errno) {
|
|
47372
|
+
const error = Object.assign(new Error(message), { code, ...(typeof errno === "number" ? { errno } : {}) });
|
|
47373
|
+
return code === "path-mismatch" || code === "OBSERVATION_REDIRECTED"
|
|
47374
|
+
? new errors_FsSafeError("path-mismatch", "root identity changed during verification", { cause: error }) : error;
|
|
47375
|
+
}
|
|
47376
|
+
function ensureNativeRootCurrentLegacy(root, binding) {
|
|
47377
|
+
const env_4 = { stack: [], error: void 0, hasError: false };
|
|
46980
47378
|
try {
|
|
46981
|
-
|
|
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, {
|
|
47379
|
+
const rootOwner = root_create_native_addDisposableResource(env_4, openExactNativeRootSync(binding, {
|
|
46986
47380
|
rootPath: root.rootReal, rootIdentity: root.rootIdentity,
|
|
46987
47381
|
}), false);
|
|
46988
47382
|
verifyMkdirDirectory(binding, rootOwner.fd, root.rootReal);
|
|
46989
47383
|
root_context_assertRootIdentityCurrentSync(root);
|
|
46990
47384
|
}
|
|
46991
|
-
catch (
|
|
46992
|
-
|
|
46993
|
-
|
|
47385
|
+
catch (e_4) {
|
|
47386
|
+
env_4.error = e_4;
|
|
47387
|
+
env_4.hasError = true;
|
|
46994
47388
|
}
|
|
46995
47389
|
finally {
|
|
46996
|
-
root_create_native_disposeResources(
|
|
47390
|
+
root_create_native_disposeResources(env_4);
|
|
46997
47391
|
}
|
|
46998
47392
|
}
|
|
46999
47393
|
function mkdirNativeRootChild(params) {
|
|
47000
|
-
const
|
|
47394
|
+
const env_5 = { stack: [], error: void 0, hasError: false };
|
|
47001
47395
|
try {
|
|
47002
47396
|
const binding = native_getNativeBinding("openBeneath", "mkdirChildBeneath");
|
|
47003
47397
|
if (!binding?.openBeneath || !binding.mkdirChildBeneath)
|
|
47004
47398
|
return root_create_native_unavailable();
|
|
47005
|
-
const rootOwner = root_create_native_addDisposableResource(
|
|
47399
|
+
const rootOwner = root_create_native_addDisposableResource(env_5, openExactNativeRootSync(binding, {
|
|
47006
47400
|
rootPath: params.root.rootReal, rootIdentity: params.root.rootIdentity,
|
|
47007
47401
|
}), false);
|
|
47008
47402
|
verifyMkdirDirectory(binding, rootOwner.fd, params.root.rootReal);
|
|
@@ -47015,17 +47409,17 @@ function mkdirNativeRootChild(params) {
|
|
|
47015
47409
|
? binding.mkdirOpenChildBeneath(rootOwner.fd, name, 0o777, flags).fd
|
|
47016
47410
|
: (binding.mkdirChildBeneath(rootOwner.fd, name, 0o777), binding.openBeneath(rootOwner.fd, name, flags).fd);
|
|
47017
47411
|
const close = captureNativeFdClose(binding);
|
|
47018
|
-
const childOwner = root_create_native_addDisposableResource(
|
|
47412
|
+
const childOwner = root_create_native_addDisposableResource(env_5, { [Symbol.dispose]() { close(child); } }, false);
|
|
47019
47413
|
root_context_assertRootIdentityCurrentSync(params.root);
|
|
47020
47414
|
verifyMkdirDirectory(binding, child, params.target);
|
|
47021
47415
|
verifyMkdirDirectory(binding, rootOwner.fd, params.root.rootReal);
|
|
47022
47416
|
}
|
|
47023
|
-
catch (
|
|
47024
|
-
|
|
47025
|
-
|
|
47417
|
+
catch (e_5) {
|
|
47418
|
+
env_5.error = e_5;
|
|
47419
|
+
env_5.hasError = true;
|
|
47026
47420
|
}
|
|
47027
47421
|
finally {
|
|
47028
|
-
root_create_native_disposeResources(
|
|
47422
|
+
root_create_native_disposeResources(env_5);
|
|
47029
47423
|
}
|
|
47030
47424
|
}
|
|
47031
47425
|
async function tryOpenCreateRootNative(params) {
|
|
@@ -47047,7 +47441,7 @@ async function tryOpenCreateRootNative(params) {
|
|
|
47047
47441
|
if (creationMode() === undefined)
|
|
47048
47442
|
return root_create_native_unavailable();
|
|
47049
47443
|
return await withNativeDirectory(params, async (binding, parent, assertCurrent) => {
|
|
47050
|
-
const
|
|
47444
|
+
const env_6 = { stack: [], error: void 0, hasError: false };
|
|
47051
47445
|
try {
|
|
47052
47446
|
params.assertBeforeMutation?.();
|
|
47053
47447
|
assertCurrent();
|
|
@@ -47057,13 +47451,21 @@ async function tryOpenCreateRootNative(params) {
|
|
|
47057
47451
|
// Native creation owns the only O_CREAT dispatch. The subsequent Node open
|
|
47058
47452
|
// carries neither O_CREAT nor O_TRUNC and must match this retained inode.
|
|
47059
47453
|
const close = captureNativeFdClose(binding);
|
|
47060
|
-
|
|
47454
|
+
let fd;
|
|
47455
|
+
try {
|
|
47456
|
+
fd = binding.openCreateBeneath(parent, external_node_path_.basename(params.target), params.flags, params.mode & 0o7777);
|
|
47457
|
+
}
|
|
47458
|
+
catch (error) {
|
|
47459
|
+
if (hasNodeErrorCode(error, "EEXIST") && typeof error === "object" && error !== null)
|
|
47460
|
+
nativeCreateCollisions.add(error);
|
|
47461
|
+
throw error;
|
|
47462
|
+
}
|
|
47061
47463
|
let rawOpen = true;
|
|
47062
47464
|
const closeRaw = () => { if (rawOpen) {
|
|
47063
47465
|
rawOpen = false;
|
|
47064
47466
|
close(fd);
|
|
47065
47467
|
} };
|
|
47066
|
-
const owner = root_create_native_addDisposableResource(
|
|
47468
|
+
const owner = root_create_native_addDisposableResource(env_6, { [Symbol.dispose]: closeRaw }, false);
|
|
47067
47469
|
try {
|
|
47068
47470
|
const identity = strict_file_identity_inspectFileIdentitySync(() => external_node_fs_.fstatSync(fd, { bigint: true }));
|
|
47069
47471
|
if (!identity.isFile() || identity.nlink !== 1n)
|
|
@@ -47117,26 +47519,26 @@ async function tryOpenCreateRootNative(params) {
|
|
|
47117
47519
|
throw error;
|
|
47118
47520
|
}
|
|
47119
47521
|
}
|
|
47120
|
-
catch (
|
|
47121
|
-
|
|
47122
|
-
|
|
47522
|
+
catch (e_6) {
|
|
47523
|
+
env_6.error = e_6;
|
|
47524
|
+
env_6.hasError = true;
|
|
47123
47525
|
}
|
|
47124
47526
|
finally {
|
|
47125
|
-
root_create_native_disposeResources(
|
|
47527
|
+
root_create_native_disposeResources(env_6);
|
|
47126
47528
|
}
|
|
47127
47529
|
}, async (created) => {
|
|
47128
|
-
const
|
|
47530
|
+
const env_7 = { stack: [], error: void 0, hasError: false };
|
|
47129
47531
|
try {
|
|
47130
|
-
const handle = root_create_native_addDisposableResource(
|
|
47131
|
-
const parent = root_create_native_addDisposableResource(
|
|
47532
|
+
const handle = root_create_native_addDisposableResource(env_7, created.handle, true);
|
|
47533
|
+
const parent = root_create_native_addDisposableResource(env_7, { [Symbol.dispose]: created.releaseCreationParent }, false);
|
|
47132
47534
|
await created.cleanupCreated();
|
|
47133
47535
|
}
|
|
47134
|
-
catch (
|
|
47135
|
-
|
|
47136
|
-
|
|
47536
|
+
catch (e_7) {
|
|
47537
|
+
env_7.error = e_7;
|
|
47538
|
+
env_7.hasError = true;
|
|
47137
47539
|
}
|
|
47138
47540
|
finally {
|
|
47139
|
-
const result_2 = root_create_native_disposeResources(
|
|
47541
|
+
const result_2 = root_create_native_disposeResources(env_7);
|
|
47140
47542
|
if (result_2)
|
|
47141
47543
|
await result_2;
|
|
47142
47544
|
}
|
|
@@ -47872,7 +48274,7 @@ function privateDirectoryBackend() {
|
|
|
47872
48274
|
if (getFsSafeNativeConfig().mode === "require") {
|
|
47873
48275
|
throw new errors_FsSafeError("helper-unavailable", "private directory creation requires an up-to-date native parent identity capability");
|
|
47874
48276
|
}
|
|
47875
|
-
warnNativeFallback("windows-private-directory", "Private Windows directory creation
|
|
48277
|
+
warnNativeFallback("windows-private-directory", "Private Windows directory creation launches the packaged .NET helper for each check or creation.", "createPrivateDirectoryWithParentIdentity");
|
|
47876
48278
|
return undefined;
|
|
47877
48279
|
}
|
|
47878
48280
|
async function createDirectory(targetPath, options = {}) {
|
|
@@ -53682,6 +54084,247 @@ async function read_opened_file_readOpenedFileSafely(params) {
|
|
|
53682
54084
|
};
|
|
53683
54085
|
}
|
|
53684
54086
|
|
|
54087
|
+
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/root-mkdir-native.js
|
|
54088
|
+
var root_mkdir_native_addDisposableResource = (undefined && undefined.__addDisposableResource) || function (env, value, async) {
|
|
54089
|
+
if (value !== null && value !== void 0) {
|
|
54090
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
54091
|
+
var dispose, inner;
|
|
54092
|
+
if (async) {
|
|
54093
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
54094
|
+
dispose = value[Symbol.asyncDispose];
|
|
54095
|
+
}
|
|
54096
|
+
if (dispose === void 0) {
|
|
54097
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
54098
|
+
dispose = value[Symbol.dispose];
|
|
54099
|
+
if (async) inner = dispose;
|
|
54100
|
+
}
|
|
54101
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
54102
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
54103
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
54104
|
+
}
|
|
54105
|
+
else if (async) {
|
|
54106
|
+
env.stack.push({ async: true });
|
|
54107
|
+
}
|
|
54108
|
+
return value;
|
|
54109
|
+
};
|
|
54110
|
+
var root_mkdir_native_disposeResources = (undefined && undefined.__disposeResources) || (function (SuppressedError) {
|
|
54111
|
+
return function (env) {
|
|
54112
|
+
function fail(e) {
|
|
54113
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
54114
|
+
env.hasError = true;
|
|
54115
|
+
}
|
|
54116
|
+
var r, s = 0;
|
|
54117
|
+
function next() {
|
|
54118
|
+
while (r = env.stack.pop()) {
|
|
54119
|
+
try {
|
|
54120
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
54121
|
+
if (r.dispose) {
|
|
54122
|
+
var result = r.dispose.call(r.value);
|
|
54123
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
54124
|
+
}
|
|
54125
|
+
else s |= 1;
|
|
54126
|
+
}
|
|
54127
|
+
catch (e) {
|
|
54128
|
+
fail(e);
|
|
54129
|
+
}
|
|
54130
|
+
}
|
|
54131
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
54132
|
+
if (env.hasError) throw env.error;
|
|
54133
|
+
}
|
|
54134
|
+
return next();
|
|
54135
|
+
};
|
|
54136
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
54137
|
+
var e = new Error(message);
|
|
54138
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
54139
|
+
});
|
|
54140
|
+
|
|
54141
|
+
|
|
54142
|
+
|
|
54143
|
+
|
|
54144
|
+
|
|
54145
|
+
|
|
54146
|
+
|
|
54147
|
+
|
|
54148
|
+
|
|
54149
|
+
|
|
54150
|
+
|
|
54151
|
+
|
|
54152
|
+
|
|
54153
|
+
|
|
54154
|
+
|
|
54155
|
+
|
|
54156
|
+
|
|
54157
|
+
function tryMkdirNativeParents(root, relativePath) {
|
|
54158
|
+
try {
|
|
54159
|
+
return mkdirOrdinaryNativeParents(root, relativePath);
|
|
54160
|
+
}
|
|
54161
|
+
catch (error) {
|
|
54162
|
+
if (hasNodeErrorCode(error, "ENOTDIR"))
|
|
54163
|
+
throw root_errors_directoryComponentNotDirectoryError(error);
|
|
54164
|
+
throw error;
|
|
54165
|
+
}
|
|
54166
|
+
}
|
|
54167
|
+
function mkdirOrdinaryNativeParents(root, relativePath) {
|
|
54168
|
+
if (getFsSafeTestHooks()?.beforeRootFallbackMutation)
|
|
54169
|
+
return false;
|
|
54170
|
+
const segments = relativePath.split(external_node_path_.sep === "\\" ? /[\\/]/ : "/");
|
|
54171
|
+
if (segments.length < 2 || segments.some(segment => !isSafePathSegment(segment, { allowDotPrefix: true }) || segment.endsWith(".")))
|
|
54172
|
+
return false;
|
|
54173
|
+
let rootStat;
|
|
54174
|
+
root_context_assertRootIdentityCurrentSync(root, stat => { rootStat = stat; });
|
|
54175
|
+
const target = external_node_path_.join(root.rootReal, ...segments);
|
|
54176
|
+
const parentPath = external_node_path_.dirname(target);
|
|
54177
|
+
try {
|
|
54178
|
+
const child = external_node_fs_.lstatSync(windows_path_alias_pathForWindowsFilesystem(target), { throwIfNoEntry: false });
|
|
54179
|
+
if (child && (!child.isDirectory() || realpath_realpathSync.native(windows_path_alias_pathForWindowsFilesystem(target)) !== target))
|
|
54180
|
+
return false;
|
|
54181
|
+
}
|
|
54182
|
+
catch {
|
|
54183
|
+
return false;
|
|
54184
|
+
}
|
|
54185
|
+
let parentIdentity;
|
|
54186
|
+
try {
|
|
54187
|
+
parentIdentity = directory_guard_inspectDirectoryIdentitySync(parentPath);
|
|
54188
|
+
}
|
|
54189
|
+
catch (error) {
|
|
54190
|
+
// Reuse this exact Root snapshot and failed parent observation without an
|
|
54191
|
+
// intervening await. All opened ancestors still receive fresh native fences.
|
|
54192
|
+
return hasNodeErrorCode(error, "ENOENT") ? mkdirMissingParents(root, segments, rootStat) : false;
|
|
54193
|
+
}
|
|
54194
|
+
try {
|
|
54195
|
+
if (realpath_realpathSync.native(windows_path_alias_pathForWindowsFilesystem(parentPath)) !== parentPath)
|
|
54196
|
+
return false;
|
|
54197
|
+
}
|
|
54198
|
+
catch {
|
|
54199
|
+
return false;
|
|
54200
|
+
}
|
|
54201
|
+
return mkdirExistingParent(root, segments, parentIdentity);
|
|
54202
|
+
}
|
|
54203
|
+
/** Ordinary missing suffixes need no policy callbacks or repeated path resolution. */
|
|
54204
|
+
function mkdirMissingParents(root, segments, rootStat) {
|
|
54205
|
+
const binding = native_getNativeBinding("openBeneath", "mkdirChildBeneath");
|
|
54206
|
+
if (!binding?.openBeneath || !binding.mkdirOpenChildBeneath)
|
|
54207
|
+
return false;
|
|
54208
|
+
let parentDepth = segments.length - 2;
|
|
54209
|
+
let parentPath;
|
|
54210
|
+
let parentIdentity;
|
|
54211
|
+
for (;;) {
|
|
54212
|
+
parentPath = external_node_path_.join(root.rootReal, ...segments.slice(0, parentDepth));
|
|
54213
|
+
try {
|
|
54214
|
+
parentIdentity = directory_guard_inspectDirectoryIdentitySync(parentPath, undefined, parentDepth === 0 ? rootStat : undefined);
|
|
54215
|
+
if (realpath_realpathSync.native(windows_path_alias_pathForWindowsFilesystem(parentPath)) !== parentPath)
|
|
54216
|
+
return false;
|
|
54217
|
+
break;
|
|
54218
|
+
}
|
|
54219
|
+
catch (error) {
|
|
54220
|
+
if (!hasNodeErrorCode(error, "ENOENT") || parentDepth === 0)
|
|
54221
|
+
return false;
|
|
54222
|
+
parentDepth--;
|
|
54223
|
+
}
|
|
54224
|
+
}
|
|
54225
|
+
try {
|
|
54226
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
54227
|
+
try {
|
|
54228
|
+
const rootOwner = root_mkdir_native_addDisposableResource(env_1, openExactNativeRootSync(binding, {
|
|
54229
|
+
rootPath: root.rootReal, rootIdentity: root.rootIdentity,
|
|
54230
|
+
}), false);
|
|
54231
|
+
const close = captureNativeFdClose(binding);
|
|
54232
|
+
const directories = [];
|
|
54233
|
+
const directoryOwner = root_mkdir_native_addDisposableResource(env_1, { [Symbol.dispose]() {
|
|
54234
|
+
const errors = [];
|
|
54235
|
+
for (const directory of directories.toReversed()) {
|
|
54236
|
+
try {
|
|
54237
|
+
close(directory.fd);
|
|
54238
|
+
}
|
|
54239
|
+
catch (error) {
|
|
54240
|
+
errors.push(error);
|
|
54241
|
+
}
|
|
54242
|
+
}
|
|
54243
|
+
if (errors.length)
|
|
54244
|
+
throw new AggregateError(errors, "mkdir directory close failed");
|
|
54245
|
+
} }, false);
|
|
54246
|
+
const flags = (nodeDirectorySearchOnlyFlags()?.flags ?? external_node_fs_.constants.O_RDONLY) |
|
|
54247
|
+
(external_node_fs_.constants.O_DIRECTORY ?? 0) | (external_node_fs_.constants.O_NOFOLLOW ?? 0);
|
|
54248
|
+
let current = rootOwner.fd;
|
|
54249
|
+
if (parentDepth > 0) {
|
|
54250
|
+
current = binding.openBeneath(rootOwner.fd, segments.slice(0, parentDepth).join("/"), flags).fd;
|
|
54251
|
+
directories.push({ fd: current, pathname: parentPath });
|
|
54252
|
+
strict_file_identity_inspectFileIdentitySync(() => external_node_fs_.fstatSync(current, { bigint: true }), parentIdentity);
|
|
54253
|
+
}
|
|
54254
|
+
const assertCurrent = () => {
|
|
54255
|
+
root_context_assertRootIdentityCurrentSync(root);
|
|
54256
|
+
for (const directory of directories)
|
|
54257
|
+
verifyMkdirDirectory(binding, directory.fd, directory.pathname);
|
|
54258
|
+
verifyMkdirDirectory(binding, rootOwner.fd, root.rootReal);
|
|
54259
|
+
};
|
|
54260
|
+
assertCurrent();
|
|
54261
|
+
for (const segment of segments.slice(parentDepth)) {
|
|
54262
|
+
const child = binding.mkdirOpenChildBeneath(current, segment, 0o777, flags);
|
|
54263
|
+
parentPath = external_node_path_.join(parentPath, segment);
|
|
54264
|
+
directories.push({ fd: child.fd, pathname: parentPath });
|
|
54265
|
+
// Retain every ancestor until the complete suffix is admitted. The
|
|
54266
|
+
// post-create fence also precedes the next synchronous child mutation.
|
|
54267
|
+
assertCurrent();
|
|
54268
|
+
current = child.fd;
|
|
54269
|
+
}
|
|
54270
|
+
return true;
|
|
54271
|
+
}
|
|
54272
|
+
catch (e_1) {
|
|
54273
|
+
env_1.error = e_1;
|
|
54274
|
+
env_1.hasError = true;
|
|
54275
|
+
}
|
|
54276
|
+
finally {
|
|
54277
|
+
root_mkdir_native_disposeResources(env_1);
|
|
54278
|
+
}
|
|
54279
|
+
}
|
|
54280
|
+
catch (error) {
|
|
54281
|
+
if (hasNodeErrorCode(error, "ENOTDIR"))
|
|
54282
|
+
throw root_errors_directoryComponentNotDirectoryError(error);
|
|
54283
|
+
throw error;
|
|
54284
|
+
}
|
|
54285
|
+
}
|
|
54286
|
+
function mkdirExistingParent(root, segments, parentIdentity) {
|
|
54287
|
+
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
54288
|
+
try {
|
|
54289
|
+
const target = external_node_path_.join(root.rootReal, ...segments);
|
|
54290
|
+
const parentPath = external_node_path_.dirname(target);
|
|
54291
|
+
const binding = native_getNativeBinding("openBeneath", "mkdirChildBeneath");
|
|
54292
|
+
if (!binding?.openBeneath || !binding.mkdirChildBeneath) {
|
|
54293
|
+
throw new errors_FsSafeError("helper-unavailable", "native confined creation is unavailable");
|
|
54294
|
+
}
|
|
54295
|
+
const rootOwner = root_mkdir_native_addDisposableResource(env_2, openExactNativeRootSync(binding, {
|
|
54296
|
+
rootPath: root.rootReal, rootIdentity: root.rootIdentity,
|
|
54297
|
+
}), false);
|
|
54298
|
+
verifyMkdirDirectory(binding, rootOwner.fd, root.rootReal);
|
|
54299
|
+
const flags = (nodeDirectorySearchOnlyFlags()?.flags ?? external_node_fs_.constants.O_RDONLY) |
|
|
54300
|
+
(external_node_fs_.constants.O_DIRECTORY ?? 0) | (external_node_fs_.constants.O_NOFOLLOW ?? 0);
|
|
54301
|
+
const close = captureNativeFdClose(binding);
|
|
54302
|
+
const parent = binding.openBeneath(rootOwner.fd, segments.slice(0, -1).join("/"), flags).fd;
|
|
54303
|
+
const parentOwner = root_mkdir_native_addDisposableResource(env_2, { [Symbol.dispose]() { close(parent); } }, false);
|
|
54304
|
+
strict_file_identity_inspectFileIdentitySync(() => external_node_fs_.fstatSync(parent, { bigint: true }), parentIdentity);
|
|
54305
|
+
verifyMkdirDirectory(binding, parent, parentPath);
|
|
54306
|
+
root_context_assertRootIdentityCurrentSync(root);
|
|
54307
|
+
const name = segments.at(-1);
|
|
54308
|
+
const child = binding.mkdirOpenChildBeneath
|
|
54309
|
+
? binding.mkdirOpenChildBeneath(parent, name, 0o777, flags).fd
|
|
54310
|
+
: (binding.mkdirChildBeneath(parent, name, 0o777), binding.openBeneath(parent, name, flags).fd);
|
|
54311
|
+
const childOwner = root_mkdir_native_addDisposableResource(env_2, { [Symbol.dispose]() { close(child); } }, false);
|
|
54312
|
+
root_context_assertRootIdentityCurrentSync(root);
|
|
54313
|
+
verifyMkdirDirectory(binding, child, target);
|
|
54314
|
+
directory_guard_inspectDirectoryIdentitySync(parentPath, parentIdentity);
|
|
54315
|
+
verifyMkdirDirectory(binding, parent, parentPath);
|
|
54316
|
+
verifyMkdirDirectory(binding, rootOwner.fd, root.rootReal);
|
|
54317
|
+
return true;
|
|
54318
|
+
}
|
|
54319
|
+
catch (e_2) {
|
|
54320
|
+
env_2.error = e_2;
|
|
54321
|
+
env_2.hasError = true;
|
|
54322
|
+
}
|
|
54323
|
+
finally {
|
|
54324
|
+
root_mkdir_native_disposeResources(env_2);
|
|
54325
|
+
}
|
|
54326
|
+
}
|
|
54327
|
+
|
|
53685
54328
|
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/write-open-flags.js
|
|
53686
54329
|
|
|
53687
54330
|
|
|
@@ -56754,6 +57397,7 @@ var root_impl_disposeResources = (undefined && undefined.__disposeResources) ||
|
|
|
56754
57397
|
|
|
56755
57398
|
|
|
56756
57399
|
|
|
57400
|
+
|
|
56757
57401
|
|
|
56758
57402
|
|
|
56759
57403
|
function logWarn(message) {
|
|
@@ -57154,7 +57798,9 @@ async function openWritableFileInRoot(root, params, options) {
|
|
|
57154
57798
|
denyMutations: params.denyMutations,
|
|
57155
57799
|
mutationSymlinks: params.mutationSymlinks,
|
|
57156
57800
|
});
|
|
57157
|
-
const
|
|
57801
|
+
const creationProbe = requireNative && !guardedTarget && params.assertBeforeMutation === undefined && options?.createIfMissing !== false
|
|
57802
|
+
? probeNativeCreationPath(root, params.relativePath) : undefined;
|
|
57803
|
+
const { resolved } = creationProbe ?? guardedTarget?.resolvedPath ?? await resolveGuardedWritePathInRoot(root, {
|
|
57158
57804
|
relativePath: params.relativePath,
|
|
57159
57805
|
});
|
|
57160
57806
|
const resolveCurrent = async () => (await resolveGuardedWritePathInRoot(root, {
|
|
@@ -57183,27 +57829,30 @@ async function openWritableFileInRoot(root, params, options) {
|
|
|
57183
57829
|
let ioPath = nativeCreatesParents ? resolved : prepared?.targetPath ?? (params.mkdir === false ? resolved :
|
|
57184
57830
|
await prepareRootWriteTarget(root, resolved, params.assertBeforeMutation));
|
|
57185
57831
|
const operationTargetPath = ioPath;
|
|
57186
|
-
|
|
57187
|
-
|
|
57188
|
-
|
|
57189
|
-
|
|
57190
|
-
|
|
57191
|
-
|
|
57192
|
-
|
|
57193
|
-
|
|
57194
|
-
|
|
57195
|
-
|
|
57196
|
-
|
|
57197
|
-
|
|
57198
|
-
|
|
57199
|
-
|
|
57200
|
-
if (err instanceof errors_FsSafeError) {
|
|
57201
|
-
throw err;
|
|
57832
|
+
let observedMissing = Boolean(creationProbe);
|
|
57833
|
+
if (!creationProbe)
|
|
57834
|
+
try {
|
|
57835
|
+
assertFinalSymlinkRejected(ioPath, params.mutationSymlinks !== undefined);
|
|
57836
|
+
const resolvedRealPath = params.mutationSymlinks === undefined ? realpath_realpathSync.native(ioPath) : ioPath;
|
|
57837
|
+
const admittedRealPath = root_boundary_admitPathInsideRoot({
|
|
57838
|
+
rootPath: root.rootReal,
|
|
57839
|
+
candidatePath: resolvedRealPath,
|
|
57840
|
+
rootIdentity: root.rootIdentity,
|
|
57841
|
+
});
|
|
57842
|
+
if (!admittedRealPath) {
|
|
57843
|
+
throw root_errors_outsideWorkspaceError();
|
|
57844
|
+
}
|
|
57845
|
+
ioPath = admittedRealPath.path;
|
|
57202
57846
|
}
|
|
57203
|
-
|
|
57204
|
-
|
|
57847
|
+
catch (err) {
|
|
57848
|
+
if (err instanceof errors_FsSafeError) {
|
|
57849
|
+
throw err;
|
|
57850
|
+
}
|
|
57851
|
+
if (!path_isNotFoundPathError(err)) {
|
|
57852
|
+
throw err;
|
|
57853
|
+
}
|
|
57854
|
+
observedMissing = true;
|
|
57205
57855
|
}
|
|
57206
|
-
}
|
|
57207
57856
|
assertRootFallbackWritePath(params.expectedWritePath, ioPath);
|
|
57208
57857
|
const mode = params.mode ?? 0o600;
|
|
57209
57858
|
let handle;
|
|
@@ -57217,61 +57866,82 @@ async function openWritableFileInRoot(root, params, options) {
|
|
|
57217
57866
|
writePathSelection = guardedTarget
|
|
57218
57867
|
? await prepareGuardedRootWritePathSelection(guardedTarget, ioPath, operationTargetPath, preparedParent)
|
|
57219
57868
|
: undefined;
|
|
57220
|
-
|
|
57221
|
-
|
|
57222
|
-
|
|
57223
|
-
|
|
57224
|
-
|
|
57225
|
-
|
|
57226
|
-
|
|
57227
|
-
|
|
57869
|
+
const createNative = () => tryOpenCreateRootNative({
|
|
57870
|
+
originalPath: params.relativePath,
|
|
57871
|
+
root, directory: external_node_path_.dirname(ioPath), target: ioPath, mkdir: params.mkdir !== false, policy,
|
|
57872
|
+
selectedParent: creationProbe?.parent,
|
|
57873
|
+
resolveCurrent,
|
|
57874
|
+
assertBeforeMutation: params.assertBeforeMutation !== undefined || writePathSelection !== undefined ? () => {
|
|
57875
|
+
params.assertBeforeMutation?.();
|
|
57876
|
+
if (writePathSelection)
|
|
57877
|
+
assertRootWritePathSelectionSync(root, writePathSelection);
|
|
57878
|
+
} : undefined,
|
|
57879
|
+
flags: createFlags, existingFlags, mode,
|
|
57880
|
+
});
|
|
57881
|
+
let precreated;
|
|
57882
|
+
if (requireNative && observedMissing && !guardedTarget && params.assertBeforeMutation === undefined && options?.createIfMissing !== false) {
|
|
57883
|
+
try {
|
|
57884
|
+
precreated = await createNative();
|
|
57228
57885
|
}
|
|
57229
|
-
|
|
57230
|
-
|
|
57886
|
+
catch (error) {
|
|
57887
|
+
if (!hasNodeErrorCode(error, "EEXIST") || !isNativeCreateCollision(error))
|
|
57888
|
+
throw error;
|
|
57231
57889
|
}
|
|
57232
|
-
|
|
57233
|
-
|
|
57234
|
-
|
|
57235
|
-
|
|
57236
|
-
|
|
57237
|
-
|
|
57238
|
-
|
|
57239
|
-
|
|
57240
|
-
|
|
57241
|
-
|
|
57242
|
-
|
|
57243
|
-
|
|
57244
|
-
}))
|
|
57245
|
-
throw root_errors_outsideWorkspaceError();
|
|
57246
|
-
directory_guard_assertSyncDirectoryGuard(parentGuard);
|
|
57247
|
-
return { missing: true, targetPath: ioPath, parentGuard, writeSelection: writePathSelection };
|
|
57890
|
+
}
|
|
57891
|
+
if (precreated) {
|
|
57892
|
+
handle = precreated.handle;
|
|
57893
|
+
cleanupCreated = precreated.cleanupCreated;
|
|
57894
|
+
releaseCreationParent = precreated.releaseCreationParent;
|
|
57895
|
+
createdForWrite = true;
|
|
57896
|
+
}
|
|
57897
|
+
else {
|
|
57898
|
+
try {
|
|
57899
|
+
if (writePathSelection)
|
|
57900
|
+
assertRootWritePathSelectionSync(root, writePathSelection);
|
|
57901
|
+
handle = await promises_.open(ioPath, existingFlags, mode);
|
|
57248
57902
|
}
|
|
57249
|
-
|
|
57250
|
-
await
|
|
57251
|
-
|
|
57252
|
-
|
|
57253
|
-
|
|
57254
|
-
|
|
57903
|
+
catch (err) {
|
|
57904
|
+
if (await isNonRegularWriteOpenError(err, ioPath, existingFlags)) {
|
|
57905
|
+
throw new errors_FsSafeError("not-file", "path is not a regular file under root");
|
|
57906
|
+
}
|
|
57907
|
+
if (!path_isNotFoundPathError(err)) {
|
|
57908
|
+
throw err;
|
|
57909
|
+
}
|
|
57910
|
+
if (options?.createIfMissing === false) {
|
|
57911
|
+
if (nativeCreatesParents && !guardedTarget)
|
|
57912
|
+
await tryMkdirRootNative({
|
|
57913
|
+
originalPath: params.relativePath,
|
|
57914
|
+
root, directory: external_node_path_.dirname(ioPath), target: ioPath, mkdir: true, policy,
|
|
57915
|
+
resolveCurrent, assertBeforeMutation: params.assertBeforeMutation,
|
|
57916
|
+
});
|
|
57917
|
+
const parentGuard = writePathSelection?.parentGuard ??
|
|
57918
|
+
await directory_guard_createAsyncDirectoryGuard(external_node_path_.dirname(ioPath), { bigint: true });
|
|
57919
|
+
root_context_assertRootIdentityCurrentSync(root);
|
|
57920
|
+
if (!root_boundary_admitPathInsideRoot({
|
|
57921
|
+
rootPath: root.rootReal, candidatePath: parentGuard.realPath, rootIdentity: root.rootIdentity,
|
|
57922
|
+
}))
|
|
57923
|
+
throw root_errors_outsideWorkspaceError();
|
|
57924
|
+
directory_guard_assertSyncDirectoryGuard(parentGuard);
|
|
57925
|
+
return { missing: true, targetPath: ioPath, parentGuard, writeSelection: writePathSelection };
|
|
57926
|
+
}
|
|
57927
|
+
if (writePathSelection)
|
|
57928
|
+
await refreshRootWritePathSelection(writePathSelection);
|
|
57929
|
+
const nativeCreated = requireNative ? await createNative() : undefined;
|
|
57930
|
+
if (nativeCreated)
|
|
57931
|
+
handle = nativeCreated.handle;
|
|
57932
|
+
else {
|
|
57255
57933
|
params.assertBeforeMutation?.();
|
|
57256
57934
|
if (writePathSelection)
|
|
57257
57935
|
assertRootWritePathSelectionSync(root, writePathSelection);
|
|
57258
|
-
|
|
57259
|
-
|
|
57260
|
-
|
|
57261
|
-
|
|
57262
|
-
|
|
57263
|
-
|
|
57264
|
-
|
|
57265
|
-
|
|
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);
|
|
57936
|
+
// Windows can follow a dangling symlink even with O_EXCL.
|
|
57937
|
+
if (!SUPPORTS_NOFOLLOW)
|
|
57938
|
+
assertFinalSymlinkRejected(ioPath, true);
|
|
57939
|
+
handle = await promises_.open(ioPath, createFlags, mode);
|
|
57940
|
+
}
|
|
57941
|
+
cleanupCreated = nativeCreated?.cleanupCreated;
|
|
57942
|
+
releaseCreationParent = nativeCreated?.releaseCreationParent;
|
|
57943
|
+
createdForWrite = true;
|
|
57271
57944
|
}
|
|
57272
|
-
cleanupCreated = nativeCreated?.cleanupCreated;
|
|
57273
|
-
releaseCreationParent = nativeCreated?.releaseCreationParent;
|
|
57274
|
-
createdForWrite = true;
|
|
57275
57945
|
}
|
|
57276
57946
|
}
|
|
57277
57947
|
catch (err) {
|
|
@@ -57518,6 +58188,8 @@ async function mkdirPathInRoot(root, params) {
|
|
|
57518
58188
|
}
|
|
57519
58189
|
if (tryMkdirNativeDirectChild(root, params.relativePath))
|
|
57520
58190
|
return;
|
|
58191
|
+
if (tryMkdirNativeParents(root, params.relativePath))
|
|
58192
|
+
return;
|
|
57521
58193
|
}
|
|
57522
58194
|
const resolution = { relativePath: params.relativePath, allowRoot: params.allowRoot, ...policy };
|
|
57523
58195
|
const resolveCurrent = policy
|
|
@@ -108008,4 +108680,4 @@ if (installedChunkData !== 0) { // 0 means "already installed".'
|
|
|
108008
108680
|
// module factories are used so entry inlining is disabled
|
|
108009
108681
|
// startup
|
|
108010
108682
|
// Load entry module and return exports
|
|
108011
|
-
var __webpack_exports__ = __webpack_require__(
|
|
108683
|
+
var __webpack_exports__ = __webpack_require__(7046);
|