@lousy-agents/cli 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/api/copilot-with-fastify/.devcontainer/devcontainer.json +1 -1
- package/api/copilot-with-fastify/package-lock.json +49 -49
- package/api/copilot-with-fastify/package.json +5 -5
- package/cli/copilot-with-citty/.devcontainer/devcontainer.json +1 -1
- package/cli/copilot-with-citty/package.json +2 -2
- package/dist/index.js +797 -125
- package/package.json +1 -1
- package/ui/copilot-with-react/.devcontainer/devcontainer.json +1 -1
- package/ui/copilot-with-react/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -3053,7 +3053,7 @@ exports.basename = (path, { windows } = {}) => {
|
|
|
3053
3053
|
|
|
3054
3054
|
|
|
3055
3055
|
},
|
|
3056
|
-
|
|
3056
|
+
3699(__unused_rspack_module, __unused_rspack___webpack_exports__, __webpack_require__) {
|
|
3057
3057
|
// NAMESPACE OBJECT: ../../node_modules/micromark/lib/constructs.js
|
|
3058
3058
|
var constructs_namespaceObject = {};
|
|
3059
3059
|
__webpack_require__.r(constructs_namespaceObject);
|
|
@@ -3220,6 +3220,17 @@ function getFsSafeNativeConfig() {
|
|
|
3220
3220
|
"auto",
|
|
3221
3221
|
};
|
|
3222
3222
|
}
|
|
3223
|
+
/** Internal provenance; keep the public configuration shape unchanged. */
|
|
3224
|
+
function getNativeModeSetting() {
|
|
3225
|
+
if (overrideConfig.mode !== undefined)
|
|
3226
|
+
return { mode: overrideConfig.mode, source: "programmatic configuration" };
|
|
3227
|
+
for (const source of ["FS_SAFE_NATIVE_MODE", "OPENCLAW_FS_SAFE_NATIVE_MODE"]) {
|
|
3228
|
+
const mode = parseMode(process.env[source]);
|
|
3229
|
+
if (mode !== undefined)
|
|
3230
|
+
return { mode, source };
|
|
3231
|
+
}
|
|
3232
|
+
return { mode: "auto", source: "default" };
|
|
3233
|
+
}
|
|
3223
3234
|
function isFsSafeNativeRequired() {
|
|
3224
3235
|
return (overrideConfig.mode ??
|
|
3225
3236
|
parseMode(process.env.FS_SAFE_NATIVE_MODE) ??
|
|
@@ -3245,6 +3256,62 @@ let native_binding;
|
|
|
3245
3256
|
let loadError;
|
|
3246
3257
|
let attempted = false;
|
|
3247
3258
|
let loadBinding = loadBundledBinding;
|
|
3259
|
+
let resolvePackage = (name) => native_require.resolve(name);
|
|
3260
|
+
let loadOutcome = { reason: "not-probed" };
|
|
3261
|
+
let selectedTarget;
|
|
3262
|
+
let targetDescription;
|
|
3263
|
+
function loadFailure(error, packageName) {
|
|
3264
|
+
try {
|
|
3265
|
+
return classifyLoadFailure(error, packageName);
|
|
3266
|
+
}
|
|
3267
|
+
catch {
|
|
3268
|
+
// Diagnostic inspection must not replace an arbitrary thrown load value.
|
|
3269
|
+
return { reason: "load-failed", code: "UNKNOWN" };
|
|
3270
|
+
}
|
|
3271
|
+
}
|
|
3272
|
+
function classifyLoadFailure(error, packageName) {
|
|
3273
|
+
const code = typeof error === "object" && error !== null && "code" in error ? error.code : undefined;
|
|
3274
|
+
// Resolution must fail for the selected package itself. An exception inside
|
|
3275
|
+
// an installed package (even one naming this package) is not package omission.
|
|
3276
|
+
if (code === "MODULE_NOT_FOUND" && error instanceof Error &&
|
|
3277
|
+
error.message.split("\n", 1)[0] === `Cannot find module '${packageName}'`) {
|
|
3278
|
+
try {
|
|
3279
|
+
resolvePackage(packageName);
|
|
3280
|
+
}
|
|
3281
|
+
catch (resolutionError) {
|
|
3282
|
+
if (resolutionError instanceof Error && "code" in resolutionError &&
|
|
3283
|
+
resolutionError.code === "MODULE_NOT_FOUND" &&
|
|
3284
|
+
resolutionError.message.split("\n", 1)[0] === `Cannot find module '${packageName}'`) {
|
|
3285
|
+
return { reason: "package-missing" };
|
|
3286
|
+
}
|
|
3287
|
+
}
|
|
3288
|
+
}
|
|
3289
|
+
// An allowlist excludes paths, secrets and arbitrary text in exception codes.
|
|
3290
|
+
const knownCodes = ["ERR_DLOPEN_FAILED", "MODULE_NOT_FOUND", "ERR_MODULE_NOT_FOUND",
|
|
3291
|
+
"ERR_PACKAGE_PATH_NOT_EXPORTED", "ERR_INVALID_PACKAGE_CONFIG", "EACCES", "EPERM", "ENOENT"];
|
|
3292
|
+
return { reason: "load-failed", code: typeof code === "string" && knownCodes.includes(code) ? code : "UNKNOWN" };
|
|
3293
|
+
}
|
|
3294
|
+
/** Internal view of the cached load; never attempts to load an addon. */
|
|
3295
|
+
function getNativeFallbackDiagnostic(...capabilities) {
|
|
3296
|
+
const setting = getNativeModeSetting();
|
|
3297
|
+
const target = targetDescription === undefined ? bundledTarget() : selectedTarget;
|
|
3298
|
+
const packageName = target === undefined ? undefined : nativePackageForTarget(target);
|
|
3299
|
+
const manifest = native_require("../package.json");
|
|
3300
|
+
const expected = {
|
|
3301
|
+
target: targetDescription,
|
|
3302
|
+
packageName,
|
|
3303
|
+
packageVersion: packageName === undefined ? undefined : manifest.optionalDependencies[packageName],
|
|
3304
|
+
};
|
|
3305
|
+
if (setting.mode === "off")
|
|
3306
|
+
return { ...expected, reason: "disabled", source: setting.source };
|
|
3307
|
+
const loaded = native_binding;
|
|
3308
|
+
if (loaded) {
|
|
3309
|
+
const missing = capabilities.filter(name => typeof loaded[name] !== "function");
|
|
3310
|
+
if (missing.length)
|
|
3311
|
+
return { ...expected, reason: "capability-missing", capabilities: missing };
|
|
3312
|
+
}
|
|
3313
|
+
return { ...expected, ...loadOutcome };
|
|
3314
|
+
}
|
|
3248
3315
|
function isMuslFilename(file) {
|
|
3249
3316
|
return file.includes("libc.musl-") || file.includes("ld-musl-");
|
|
3250
3317
|
}
|
|
@@ -3374,7 +3441,10 @@ function targetFor(platform, arch, musl) {
|
|
|
3374
3441
|
return undefined;
|
|
3375
3442
|
}
|
|
3376
3443
|
function bundledTarget() {
|
|
3377
|
-
|
|
3444
|
+
const musl = isMusl();
|
|
3445
|
+
selectedTarget = targetFor(process.platform, process.arch, musl);
|
|
3446
|
+
targetDescription = selectedTarget ?? `${process.platform}-${process.arch}${process.platform === "linux" ? `-${musl ? "musl" : "gnu"}` : ""}`;
|
|
3447
|
+
return selectedTarget;
|
|
3378
3448
|
}
|
|
3379
3449
|
function nativePackageForTarget(target) {
|
|
3380
3450
|
return `@openclaw/fs-safe-${target}`;
|
|
@@ -3382,9 +3452,13 @@ function nativePackageForTarget(target) {
|
|
|
3382
3452
|
function loadBundledBinding() {
|
|
3383
3453
|
const target = bundledTarget();
|
|
3384
3454
|
if (!target) {
|
|
3455
|
+
loadOutcome = { reason: "unsupported-target" };
|
|
3385
3456
|
throw new Error(`Unsupported OS or architecture: ${process.platform}-${process.arch}`);
|
|
3386
3457
|
}
|
|
3387
3458
|
const loaded = runNativeInitialization(() => native_require(nativePackageForTarget(target)));
|
|
3459
|
+
if (typeof loaded.closeOwnedFd !== "function") {
|
|
3460
|
+
loadOutcome = { reason: "capability-missing", capabilities: ["closeOwnedFd"] };
|
|
3461
|
+
}
|
|
3388
3462
|
captureNativeFdClose(loaded);
|
|
3389
3463
|
return loaded;
|
|
3390
3464
|
}
|
|
@@ -3426,11 +3500,19 @@ function native_getNativeBinding(...capabilities) {
|
|
|
3426
3500
|
attempted = true;
|
|
3427
3501
|
try {
|
|
3428
3502
|
const loaded = loadBinding();
|
|
3503
|
+
if (typeof loaded.closeOwnedFd !== "function") {
|
|
3504
|
+
loadOutcome = { reason: "capability-missing", capabilities: ["closeOwnedFd"] };
|
|
3505
|
+
}
|
|
3429
3506
|
captureNativeFdClose(loaded);
|
|
3430
3507
|
native_binding = loaded;
|
|
3508
|
+
loadOutcome = { reason: "loaded" };
|
|
3431
3509
|
}
|
|
3432
3510
|
catch (error) {
|
|
3433
3511
|
loadError = error;
|
|
3512
|
+
if (loadOutcome.reason === "not-probed") {
|
|
3513
|
+
selectedTarget ??= bundledTarget();
|
|
3514
|
+
loadOutcome = loadFailure(error, nativePackageForTarget(selectedTarget ?? `${process.platform}-${process.arch}`));
|
|
3515
|
+
}
|
|
3434
3516
|
}
|
|
3435
3517
|
}
|
|
3436
3518
|
if (native_binding)
|
|
@@ -3451,17 +3533,25 @@ function native_requireNativeBinding(...capabilities) {
|
|
|
3451
3533
|
}
|
|
3452
3534
|
return native;
|
|
3453
3535
|
}
|
|
3454
|
-
function __setNativeLoaderForTest(loader) {
|
|
3536
|
+
function __setNativeLoaderForTest(loader, resolver) {
|
|
3455
3537
|
native_binding = undefined;
|
|
3456
3538
|
loadError = undefined;
|
|
3457
3539
|
attempted = false;
|
|
3458
3540
|
loadBinding = loader;
|
|
3541
|
+
loadOutcome = { reason: "not-probed" };
|
|
3542
|
+
selectedTarget = undefined;
|
|
3543
|
+
targetDescription = undefined;
|
|
3544
|
+
resolvePackage = resolver ?? ((name) => native_require.resolve(name));
|
|
3459
3545
|
}
|
|
3460
3546
|
function __resetNativeLoaderForTest() {
|
|
3461
3547
|
native_binding = undefined;
|
|
3462
3548
|
loadError = undefined;
|
|
3463
3549
|
attempted = false;
|
|
3464
3550
|
loadBinding = loadBundledBinding;
|
|
3551
|
+
loadOutcome = { reason: "not-probed" };
|
|
3552
|
+
selectedTarget = undefined;
|
|
3553
|
+
targetDescription = undefined;
|
|
3554
|
+
resolvePackage = (name) => native_require.resolve(name);
|
|
3465
3555
|
}
|
|
3466
3556
|
|
|
3467
3557
|
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/file-observation.js
|
|
@@ -4627,6 +4717,47 @@ function errorCauseOptions(error) {
|
|
|
4627
4717
|
|
|
4628
4718
|
// EXTERNAL MODULE: external "node:os"
|
|
4629
4719
|
var external_node_os_ = __webpack_require__(8161);
|
|
4720
|
+
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/windows-appcontainer.js
|
|
4721
|
+
|
|
4722
|
+
|
|
4723
|
+
/** The native owner caches immutable primary-token membership across Workers. */
|
|
4724
|
+
function isWindowsAppContainer(binding) {
|
|
4725
|
+
if (!binding.isWindowsAppContainer)
|
|
4726
|
+
return undefined;
|
|
4727
|
+
try {
|
|
4728
|
+
const membership = binding.isWindowsAppContainer();
|
|
4729
|
+
if (typeof membership !== "boolean")
|
|
4730
|
+
throw new Error("Invalid AppContainer membership");
|
|
4731
|
+
return membership;
|
|
4732
|
+
}
|
|
4733
|
+
catch (cause) {
|
|
4734
|
+
throw new errors_FsSafeError("permission-unverified", "Windows process token membership could not be verified", { cause });
|
|
4735
|
+
}
|
|
4736
|
+
}
|
|
4737
|
+
function windows_appcontainer_assertWindowsHelperAllowed() {
|
|
4738
|
+
if (process.platform !== "win32")
|
|
4739
|
+
return;
|
|
4740
|
+
const binding = native_getNativeBinding();
|
|
4741
|
+
if (binding && isWindowsAppContainer(binding)) {
|
|
4742
|
+
// Current libuv can hang while creating child-process pipes in a lowbox.
|
|
4743
|
+
throw new errors_FsSafeError("helper-unavailable", "External Windows security helpers are unavailable inside an AppContainer");
|
|
4744
|
+
}
|
|
4745
|
+
}
|
|
4746
|
+
function assertWindowsAclRemediationAllowed() {
|
|
4747
|
+
if (process.platform !== "win32")
|
|
4748
|
+
return;
|
|
4749
|
+
let binding;
|
|
4750
|
+
try {
|
|
4751
|
+
binding = getNativeBinding();
|
|
4752
|
+
}
|
|
4753
|
+
catch {
|
|
4754
|
+
return;
|
|
4755
|
+
} // Command formatting remains available without an addon.
|
|
4756
|
+
if (binding && isWindowsAppContainer(binding)) {
|
|
4757
|
+
throw new FsSafeError("helper-unavailable", "Windows ACL reset commands are unavailable inside an AppContainer");
|
|
4758
|
+
}
|
|
4759
|
+
}
|
|
4760
|
+
|
|
4630
4761
|
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/realpath.js
|
|
4631
4762
|
|
|
4632
4763
|
|
|
@@ -4634,9 +4765,41 @@ var external_node_os_ = __webpack_require__(8161);
|
|
|
4634
4765
|
|
|
4635
4766
|
|
|
4636
4767
|
|
|
4768
|
+
|
|
4637
4769
|
const runtimePlatform = process.versions.bun ? (0,external_node_os_.platform)() : undefined;
|
|
4638
4770
|
const bunPosix = runtimePlatform === "darwin" || runtimePlatform === "linux" ? runtimePlatform : undefined;
|
|
4639
4771
|
function realpath_resolve(input, native) {
|
|
4772
|
+
if (native && process.platform === "win32") {
|
|
4773
|
+
try {
|
|
4774
|
+
return external_node_fs_.realpathSync.native(input);
|
|
4775
|
+
}
|
|
4776
|
+
catch (error) {
|
|
4777
|
+
if (error.code !== "EPERM" || error.syscall !== "realpath")
|
|
4778
|
+
throw error;
|
|
4779
|
+
let binding;
|
|
4780
|
+
try {
|
|
4781
|
+
binding = native_getNativeBinding();
|
|
4782
|
+
}
|
|
4783
|
+
catch {
|
|
4784
|
+
binding = undefined;
|
|
4785
|
+
}
|
|
4786
|
+
if (!binding || !isWindowsAppContainer(binding))
|
|
4787
|
+
throw error;
|
|
4788
|
+
if (!binding?.resolveWindowsCanonicalPath) {
|
|
4789
|
+
throw new errors_FsSafeError("helper-unavailable", "Windows canonicalization after a denied DOS-name query requires the native binding", { cause: error });
|
|
4790
|
+
}
|
|
4791
|
+
let resolved;
|
|
4792
|
+
try {
|
|
4793
|
+
resolved = binding.resolveWindowsCanonicalPath(input);
|
|
4794
|
+
}
|
|
4795
|
+
catch (cause) {
|
|
4796
|
+
throw new errors_FsSafeError("path-mismatch", "Windows canonical path cannot be verified safely", { cause });
|
|
4797
|
+
}
|
|
4798
|
+
if (resolved === null)
|
|
4799
|
+
throw error;
|
|
4800
|
+
return resolved;
|
|
4801
|
+
}
|
|
4802
|
+
}
|
|
4640
4803
|
if (bunPosix) {
|
|
4641
4804
|
// Bun 1.4.2 normalizes native path components and opens the leaf for reads.
|
|
4642
4805
|
// The Rust OS resolver preserves permissions, locks and physical spelling.
|
|
@@ -4944,6 +5107,15 @@ function assertDirectoryObservationGuardSync(guard) {
|
|
|
4944
5107
|
}
|
|
4945
5108
|
}
|
|
4946
5109
|
|
|
5110
|
+
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/native-stat-identity.js
|
|
5111
|
+
/** Native stat identities are unsigned; Node BigIntStats preserves them as signed bits. */
|
|
5112
|
+
function statIdentityFromNative(value) {
|
|
5113
|
+
return value <= 0x7fffffffffffffffn || process.versions.bun ? value : BigInt.asIntN(64, value);
|
|
5114
|
+
}
|
|
5115
|
+
function isNativeStatIdentity(value) {
|
|
5116
|
+
return typeof value === "bigint" && value >= 0n && value <= 0xffffffffffffffffn;
|
|
5117
|
+
}
|
|
5118
|
+
|
|
4947
5119
|
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/directory-receipt.js
|
|
4948
5120
|
|
|
4949
5121
|
|
|
@@ -5448,6 +5620,7 @@ function createSuppressedError(error, suppressed, message) {
|
|
|
5448
5620
|
|
|
5449
5621
|
|
|
5450
5622
|
|
|
5623
|
+
|
|
5451
5624
|
/** Shared by tree byte copying and per-file copying; never resolves the target. */
|
|
5452
5625
|
async function readCopyLinkTarget(source) {
|
|
5453
5626
|
return await promises_.readlink(source, { encoding: "buffer" });
|
|
@@ -5517,7 +5690,7 @@ async function copyLinkAtParent(params, input, parent, native) {
|
|
|
5517
5690
|
directory_guard_assertSyncDirectoryGuard(parent);
|
|
5518
5691
|
if (native?.binding.createCopySymlink) {
|
|
5519
5692
|
const created = native.binding.createCopySymlink(native.fd, temporaryName, input.target, params.mode, input.preserveMetadata ? input.identity.atimeNs : undefined, input.preserveMetadata ? input.identity.mtimeNs : undefined);
|
|
5520
|
-
identity = created;
|
|
5693
|
+
identity = { dev: statIdentityFromNative(created.dev), ino: statIdentityFromNative(created.ino) };
|
|
5521
5694
|
if (created.errorCode)
|
|
5522
5695
|
throw Object.assign(new Error(created.errorMessage), { code: created.errorCode });
|
|
5523
5696
|
}
|
|
@@ -6243,14 +6416,61 @@ function pinNodeDirectoryForModeSync(dirPath, options = {}) {
|
|
|
6243
6416
|
}
|
|
6244
6417
|
}
|
|
6245
6418
|
|
|
6419
|
+
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/native-guidance.js
|
|
6420
|
+
/** Shared, path-free next steps for status reports and fallback warnings. */
|
|
6421
|
+
function nativeGuidance(reason, modeSource) {
|
|
6422
|
+
switch (reason) {
|
|
6423
|
+
case "disabled": {
|
|
6424
|
+
const enable = modeSource === "programmatic configuration"
|
|
6425
|
+
? 'call configureFsSafeNative({ mode: "auto" }) or configureFsSafeNative({ mode: "require" })'
|
|
6426
|
+
: `set ${modeSource}=auto or ${modeSource}=require`;
|
|
6427
|
+
return `If native loading is intended, ${enable}; keep intentional off settings.`;
|
|
6428
|
+
}
|
|
6429
|
+
case "unsupported-target":
|
|
6430
|
+
return "Portable mode is expected on this target.";
|
|
6431
|
+
case "package-missing":
|
|
6432
|
+
return "Reinstall with optional dependencies included: npm --include=optional, or pnpm without --no-optional / optional=false. Check the lockfile and registry mirror.";
|
|
6433
|
+
case "load-failed":
|
|
6434
|
+
return "Check Node architecture, Linux libc compatibility, package dependencies, and OS code-integrity policy. Reinstalling identical bytes may not help.";
|
|
6435
|
+
case "capability-missing":
|
|
6436
|
+
return "Use matching fs-safe and platform-package versions; some targets intentionally provide only a subset of capabilities.";
|
|
6437
|
+
default:
|
|
6438
|
+
return undefined;
|
|
6439
|
+
}
|
|
6440
|
+
}
|
|
6441
|
+
|
|
6246
6442
|
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/native-fallback-warning.js
|
|
6443
|
+
|
|
6444
|
+
|
|
6445
|
+
|
|
6247
6446
|
const warnedFeatures = new Set();
|
|
6447
|
+
function fallbackReason(capabilities) {
|
|
6448
|
+
const diagnostic = getNativeFallbackDiagnostic(...capabilities);
|
|
6449
|
+
const expected = diagnostic.packageName === undefined
|
|
6450
|
+
? `No native package is published for ${diagnostic.target}.`
|
|
6451
|
+
: `Expected ${diagnostic.packageName}@${diagnostic.packageVersion}.`;
|
|
6452
|
+
const guidance = nativeGuidance(diagnostic.reason, getNativeModeSetting().source);
|
|
6453
|
+
switch (diagnostic.reason) {
|
|
6454
|
+
case "disabled":
|
|
6455
|
+
return `native support is disabled by ${diagnostic.source} (disabled). ${expected} ${guidance}`;
|
|
6456
|
+
case "unsupported-target":
|
|
6457
|
+
return `the target ${diagnostic.target} is unsupported (unsupported-target). ${expected} ${guidance}`;
|
|
6458
|
+
case "package-missing":
|
|
6459
|
+
return `the selected native package could not be resolved (package-missing). ${expected} ${guidance}`;
|
|
6460
|
+
case "load-failed":
|
|
6461
|
+
return `the native package could not be loaded (load-failed: ${diagnostic.code}). ${expected} ${guidance}`;
|
|
6462
|
+
case "capability-missing":
|
|
6463
|
+
return `the native package lacks requested functions (capability-missing: ${diagnostic.capabilities.join(", ")}). ${expected} ${guidance}`;
|
|
6464
|
+
default:
|
|
6465
|
+
return `the requested native operation is unavailable (${diagnostic.reason}). ${expected}`;
|
|
6466
|
+
}
|
|
6467
|
+
}
|
|
6248
6468
|
/** Warn once per capability, without including caller paths or native error text. */
|
|
6249
|
-
function warnNativeFallback(feature, limitation) {
|
|
6469
|
+
function warnNativeFallback(feature, limitation, ...capabilities) {
|
|
6250
6470
|
if (warnedFeatures.has(feature))
|
|
6251
6471
|
return;
|
|
6252
6472
|
warnedFeatures.add(feature);
|
|
6253
|
-
process.emitWarning(`${feature} is using its portable fallback because
|
|
6473
|
+
process.emitWarning(`${feature} is using its portable fallback because ${fallbackReason(capabilities)} ${limitation}`, { code: "FS_SAFE_NATIVE_FALLBACK", type: "FsSafeWarning" });
|
|
6254
6474
|
}
|
|
6255
6475
|
function __resetNativeFallbackWarningsForTest() {
|
|
6256
6476
|
warnedFeatures.clear();
|
|
@@ -6281,6 +6501,7 @@ function shortPath(value) {
|
|
|
6281
6501
|
|
|
6282
6502
|
|
|
6283
6503
|
|
|
6504
|
+
|
|
6284
6505
|
const execFileAsync = (0,external_node_util_.promisify)(external_node_child_process_.execFile);
|
|
6285
6506
|
const DEFAULT_PERMISSION_EXEC_TIMEOUT_MS = 30_000;
|
|
6286
6507
|
function formatPermissionErrorDetail(value) {
|
|
@@ -6458,6 +6679,7 @@ function getPermissionCommandFailure(error, command, durationMs) {
|
|
|
6458
6679
|
return { command, durationMs: Math.round(durationMs), ...detail };
|
|
6459
6680
|
}
|
|
6460
6681
|
async function executePermissionCommand(command, args, timeoutMs = DEFAULT_PERMISSION_EXEC_TIMEOUT_MS) {
|
|
6682
|
+
assertWindowsHelperAllowed();
|
|
6461
6683
|
const startedAt = performance.now();
|
|
6462
6684
|
try {
|
|
6463
6685
|
return (await execFileAsync(command, args, {
|
|
@@ -6481,6 +6703,7 @@ async function executePermissionCommand(command, args, timeoutMs = DEFAULT_PERMI
|
|
|
6481
6703
|
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/windows-security-facts.js
|
|
6482
6704
|
|
|
6483
6705
|
const SID_RE = /^s-\d+-\d+(?:-\d+)+$/;
|
|
6706
|
+
const APP_CONTAINER_SID_RE = /^s-1-15-2(?:-\d+){7,}$/;
|
|
6484
6707
|
const SYSTEM_SID = "s-1-5-18";
|
|
6485
6708
|
const ADMINISTRATORS_SID = "s-1-5-32-544";
|
|
6486
6709
|
const WORLD_SIDS = new Set([
|
|
@@ -6515,6 +6738,7 @@ function validateAce(value, allowUnknownFlags) {
|
|
|
6515
6738
|
function validateDescriptor(value, allowUnknownFlags) {
|
|
6516
6739
|
if (!windows_security_facts_record(value) || typeof value.ownerSid !== "string" || !SID_RE.test(value.ownerSid) ||
|
|
6517
6740
|
typeof value.currentUserSid !== "string" || !SID_RE.test(value.currentUserSid) ||
|
|
6741
|
+
(value.currentAppContainerSid != null && (typeof value.currentAppContainerSid !== "string" || !APP_CONTAINER_SID_RE.test(value.currentAppContainerSid))) ||
|
|
6518
6742
|
typeof value.daclPresent !== "boolean" || typeof value.isLocal !== "boolean" ||
|
|
6519
6743
|
typeof value.aceListComplete !== "boolean" || !Array.isArray(value.unsupportedAceTypes) ||
|
|
6520
6744
|
!value.unsupportedAceTypes.every(uint32) || !Array.isArray(value.aces) ||
|
|
@@ -6540,6 +6764,8 @@ function summarize(facts) {
|
|
|
6540
6764
|
let groupReadable = false;
|
|
6541
6765
|
let groupWritable = false;
|
|
6542
6766
|
const trusted = new Set([facts.currentUserSid, SYSTEM_SID, ADMINISTRATORS_SID]);
|
|
6767
|
+
if (facts.currentAppContainerSid)
|
|
6768
|
+
trusted.add(facts.currentAppContainerSid);
|
|
6543
6769
|
for (const ace of facts.aces) {
|
|
6544
6770
|
if (ace.aceType !== "allow" || ace.flags.inheritOnly || trusted.has(ace.sid))
|
|
6545
6771
|
continue;
|
|
@@ -6608,6 +6834,7 @@ function windows_security_helper_explainWindowsSecurityHelperFailure(error) {
|
|
|
6608
6834
|
|
|
6609
6835
|
|
|
6610
6836
|
|
|
6837
|
+
|
|
6611
6838
|
const MAX_OUTPUT_BYTES = 1024 * 1024;
|
|
6612
6839
|
const TERMINATION_GRACE_MS = 1_000;
|
|
6613
6840
|
const FULL_IDENTITY = /^[0-9a-f]{16}:[0-9a-f]{32}$/;
|
|
@@ -6710,6 +6937,7 @@ function explainHelperFailure(error, file) {
|
|
|
6710
6937
|
}
|
|
6711
6938
|
}
|
|
6712
6939
|
function executeSync(operation, params) {
|
|
6940
|
+
assertWindowsHelperAllowed();
|
|
6713
6941
|
const { file, args, env } = windows_security_command_command(operation, params);
|
|
6714
6942
|
const startedAt = performance.now();
|
|
6715
6943
|
const result = spawnSync(file, args, {
|
|
@@ -6782,6 +7010,7 @@ function hasUnsettledWindowsSecurityCommand(error) {
|
|
|
6782
7010
|
}
|
|
6783
7011
|
function ignoreLateError() { }
|
|
6784
7012
|
async function execute(operation, params, request) {
|
|
7013
|
+
windows_appcontainer_assertWindowsHelperAllowed();
|
|
6785
7014
|
const selected = request ?? windows_security_command_command(operation, params);
|
|
6786
7015
|
const { file, args, env, input, timeoutMs = (/* inlined export .DEFAULT_PERMISSION_EXEC_TIMEOUT_MS */30000), maxOutputBytes = MAX_OUTPUT_BYTES } = selected;
|
|
6787
7016
|
const startedAt = performance.now();
|
|
@@ -7089,17 +7318,17 @@ function creation_boundary_assertPrivateFileCreationAvailable() {
|
|
|
7089
7318
|
typeof native.verifyPrivateWindowsFile !== "function")
|
|
7090
7319
|
creation_boundary_unavailable();
|
|
7091
7320
|
}
|
|
7092
|
-
function commandFallback() {
|
|
7321
|
+
function commandFallback(capability) {
|
|
7093
7322
|
if (getFsSafeNativeConfig().mode === "require")
|
|
7094
7323
|
creation_boundary_unavailable();
|
|
7095
|
-
warnNativeFallback("windows-private-creation", "Private Windows creation
|
|
7324
|
+
warnNativeFallback("windows-private-creation", "Private Windows creation launches the packaged .NET helper for each check or creation.", capability);
|
|
7096
7325
|
}
|
|
7097
7326
|
function creationOperation(name) {
|
|
7098
7327
|
const native = native_getNativeBinding();
|
|
7099
7328
|
const operation = native?.[name];
|
|
7100
7329
|
if (typeof operation === "function")
|
|
7101
7330
|
return operation.bind(native);
|
|
7102
|
-
commandFallback();
|
|
7331
|
+
commandFallback(name);
|
|
7103
7332
|
return undefined;
|
|
7104
7333
|
}
|
|
7105
7334
|
/** Full Windows identity, with security validation when requested; no repairs. */
|
|
@@ -9428,6 +9657,7 @@ function mergeDenyMutationPolicies(defaultPolicy, callPolicy) {
|
|
|
9428
9657
|
|
|
9429
9658
|
|
|
9430
9659
|
|
|
9660
|
+
|
|
9431
9661
|
function getNativeDirectoryObservationBackend(enabled = true) {
|
|
9432
9662
|
if (!enabled)
|
|
9433
9663
|
return undefined;
|
|
@@ -9437,14 +9667,15 @@ function getNativeDirectoryObservationBackend(enabled = true) {
|
|
|
9437
9667
|
: undefined;
|
|
9438
9668
|
}
|
|
9439
9669
|
function validateNativeDirectoryObservation(observation) {
|
|
9440
|
-
if (!observation ||
|
|
9441
|
-
|
|
9670
|
+
if (!observation || !isNativeStatIdentity(observation.dev) ||
|
|
9671
|
+
!isNativeStatIdentity(observation.ino) ||
|
|
9442
9672
|
typeof observation.realPath !== "string" ||
|
|
9443
9673
|
observation.realPath.includes("\0") ||
|
|
9444
9674
|
(!external_node_path_.isAbsolute(observation.realPath) && !external_node_path_.win32.isAbsolute(observation.realPath))) {
|
|
9445
9675
|
throw new errors_FsSafeError("path-mismatch", "native directory observation is invalid");
|
|
9446
9676
|
}
|
|
9447
|
-
|
|
9677
|
+
const dev = statIdentityFromNative(observation.dev), ino = statIdentityFromNative(observation.ino);
|
|
9678
|
+
return dev === observation.dev && ino === observation.ino ? observation : { ...observation, dev, ino };
|
|
9448
9679
|
}
|
|
9449
9680
|
/** Exact identity, type, and canonical path captured from one retained handle. */
|
|
9450
9681
|
function inspectNativeDirectoryObservation(backend, pathname, expected, platform = process.platform) {
|
|
@@ -9466,6 +9697,7 @@ function isNativeDirectoryObservationGuard(guard) {
|
|
|
9466
9697
|
|
|
9467
9698
|
|
|
9468
9699
|
|
|
9700
|
+
|
|
9469
9701
|
class NativePolicyDirectoryMismatch extends errors_FsSafeError {
|
|
9470
9702
|
constructor(cause) {
|
|
9471
9703
|
super("path-mismatch", "staging directory pathname changed", { cause });
|
|
@@ -9504,8 +9736,8 @@ function native_policy_directory_observation_nativePolicyDirectoryObserver(bindi
|
|
|
9504
9736
|
}
|
|
9505
9737
|
if (getFsSafeNativeConfig().mode !== mode)
|
|
9506
9738
|
return undefined;
|
|
9507
|
-
if (!observed ||
|
|
9508
|
-
|
|
9739
|
+
if (!observed || !isNativeStatIdentity(observed.dev) ||
|
|
9740
|
+
!isNativeStatIdentity(observed.ino) ||
|
|
9509
9741
|
typeof observed.mode !== "bigint" || observed.mode < 0n || observed.mode > 0xffffffffn ||
|
|
9510
9742
|
typeof observed.nlink !== "bigint" || observed.nlink < 0n || observed.nlink > 0xffffffffffffffffn ||
|
|
9511
9743
|
typeof observed.realPath !== "string" || observed.realPath.includes("\0") ||
|
|
@@ -9518,7 +9750,7 @@ function native_policy_directory_observation_nativePolicyDirectoryObserver(bindi
|
|
|
9518
9750
|
return Object.freeze({
|
|
9519
9751
|
canonicalPath: observed.realPath,
|
|
9520
9752
|
identity: Object.freeze({
|
|
9521
|
-
dev: observed.dev, ino: observed.ino, mode: observed.mode, nlink: observed.nlink,
|
|
9753
|
+
dev: statIdentityFromNative(observed.dev), ino: statIdentityFromNative(observed.ino), mode: observed.mode, nlink: observed.nlink,
|
|
9522
9754
|
}),
|
|
9523
9755
|
});
|
|
9524
9756
|
};
|
|
@@ -12308,6 +12540,64 @@ function __setFsSafeTestHooksForTest(hooks) {
|
|
|
12308
12540
|
test_hooks_fsSafeTestHooks = hooks;
|
|
12309
12541
|
}
|
|
12310
12542
|
|
|
12543
|
+
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/root-native-creation-path.js
|
|
12544
|
+
|
|
12545
|
+
|
|
12546
|
+
|
|
12547
|
+
|
|
12548
|
+
|
|
12549
|
+
|
|
12550
|
+
|
|
12551
|
+
|
|
12552
|
+
|
|
12553
|
+
function existingCreationParent(params) {
|
|
12554
|
+
if (params.private || params.policy || params.assertBeforeMutation !== undefined ||
|
|
12555
|
+
getFsSafeTestHooks()?.beforeRootFallbackMutation || !params.originalPath ||
|
|
12556
|
+
params.directory !== external_node_path_.dirname(params.target))
|
|
12557
|
+
return undefined;
|
|
12558
|
+
const segments = params.originalPath.split(external_node_path_.sep === "\\" ? /[\\/]/ : "/");
|
|
12559
|
+
if (segments.some(segment => !isSafePathSegment(segment, { allowDotPrefix: true }) || segment.endsWith(".")) ||
|
|
12560
|
+
external_node_path_.join(params.root.rootReal, ...segments) !== params.target)
|
|
12561
|
+
return undefined;
|
|
12562
|
+
let rootStat;
|
|
12563
|
+
root_context_assertRootIdentityCurrentSync(params.root, stat => { rootStat = stat; });
|
|
12564
|
+
try {
|
|
12565
|
+
const identity = directory_guard_inspectDirectoryIdentitySync(params.directory, undefined, params.directory === params.root.rootReal ? rootStat : undefined);
|
|
12566
|
+
if (realpath_realpathSync.native(windows_path_alias_pathForWindowsFilesystem(params.directory)) !== params.directory)
|
|
12567
|
+
return undefined;
|
|
12568
|
+
return {
|
|
12569
|
+
path: params.directory, identity,
|
|
12570
|
+
relative: external_node_path_.relative(params.root.rootReal, params.directory).split(external_node_path_.sep).join("/"),
|
|
12571
|
+
flags: (nodeDirectorySearchOnlyFlags()?.flags ?? external_node_fs_.constants.O_RDONLY) |
|
|
12572
|
+
(external_node_fs_.constants.O_DIRECTORY ?? 0) | (external_node_fs_.constants.O_NOFOLLOW ?? 0),
|
|
12573
|
+
};
|
|
12574
|
+
}
|
|
12575
|
+
catch {
|
|
12576
|
+
return undefined;
|
|
12577
|
+
}
|
|
12578
|
+
}
|
|
12579
|
+
function probeNativeCreationPath(root, relativePath) {
|
|
12580
|
+
if (typeof relativePath !== "string")
|
|
12581
|
+
return undefined;
|
|
12582
|
+
const segments = relativePath.split(external_node_path_.sep === "\\" ? /[\\/]/ : "/");
|
|
12583
|
+
if (segments.some(segment => !isSafePathSegment(segment, { allowDotPrefix: true }) || segment.endsWith(".")))
|
|
12584
|
+
return undefined;
|
|
12585
|
+
const target = external_node_path_.join(root.rootReal, ...segments);
|
|
12586
|
+
root_context_assertRootIdentityCurrentSync(root);
|
|
12587
|
+
try {
|
|
12588
|
+
if (external_node_fs_.lstatSync(windows_path_alias_pathForWindowsFilesystem(target), { throwIfNoEntry: false }))
|
|
12589
|
+
return undefined;
|
|
12590
|
+
}
|
|
12591
|
+
catch {
|
|
12592
|
+
return undefined;
|
|
12593
|
+
}
|
|
12594
|
+
const parent = existingCreationParent({ root, target, directory: external_node_path_.dirname(target), mkdir: true,
|
|
12595
|
+
originalPath: relativePath, resolveCurrent: async () => target });
|
|
12596
|
+
if (!parent)
|
|
12597
|
+
return undefined;
|
|
12598
|
+
return { rootReal: root.rootReal, rootWithSep: root.rootWithSep, resolved: target, parent };
|
|
12599
|
+
}
|
|
12600
|
+
|
|
12311
12601
|
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/root-create-native.js
|
|
12312
12602
|
var root_create_native_addDisposableResource = (undefined && undefined.__addDisposableResource) || function (env, value, async) {
|
|
12313
12603
|
if (value !== null && value !== void 0) {
|
|
@@ -12385,6 +12675,8 @@ var root_create_native_disposeResources = (undefined && undefined.__disposeResou
|
|
|
12385
12675
|
|
|
12386
12676
|
|
|
12387
12677
|
|
|
12678
|
+
|
|
12679
|
+
|
|
12388
12680
|
|
|
12389
12681
|
|
|
12390
12682
|
|
|
@@ -12394,6 +12686,10 @@ function rootWriteQueueKey(root, relativePath) {
|
|
|
12394
12686
|
function buildAtomicWriteTempPath(targetPath) {
|
|
12395
12687
|
return external_node_path_.join(external_node_path_.dirname(targetPath), `.fs-safe-${(0,external_node_crypto_.randomUUID)()}.tmp`);
|
|
12396
12688
|
}
|
|
12689
|
+
const nativeCreateCollisions = new WeakSet();
|
|
12690
|
+
function isNativeCreateCollision(error) {
|
|
12691
|
+
return typeof error === "object" && error !== null && nativeCreateCollisions.has(error);
|
|
12692
|
+
}
|
|
12397
12693
|
function root_create_native_unavailable() {
|
|
12398
12694
|
throw new errors_FsSafeError("helper-unavailable", "native confined creation is unavailable");
|
|
12399
12695
|
}
|
|
@@ -12401,6 +12697,60 @@ async function withNativeDirectory(params, operation, discard) {
|
|
|
12401
12697
|
const binding = native_getNativeBinding("openBeneath", "mkdirChildBeneath");
|
|
12402
12698
|
if (!binding?.openBeneath || !binding.mkdirChildBeneath || (params.private && process.platform === "win32"))
|
|
12403
12699
|
return root_create_native_unavailable();
|
|
12700
|
+
const existing = params.selectedParent ?? existingCreationParent(params);
|
|
12701
|
+
if (existing) {
|
|
12702
|
+
let pending;
|
|
12703
|
+
try {
|
|
12704
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
12705
|
+
try {
|
|
12706
|
+
const rootOwner = root_create_native_addDisposableResource(env_1, openExactNativeRootSync(binding, {
|
|
12707
|
+
rootPath: params.root.rootReal, rootIdentity: params.root.rootIdentity,
|
|
12708
|
+
}), false);
|
|
12709
|
+
const close = captureNativeFdClose(binding);
|
|
12710
|
+
const borrowed = existing.path === params.root.rootReal;
|
|
12711
|
+
const fd = borrowed ? rootOwner.fd : binding.openBeneath(rootOwner.fd, existing.relative, existing.flags).fd;
|
|
12712
|
+
const parentOwner = root_create_native_addDisposableResource(env_1, { [Symbol.dispose]() { if (!borrowed)
|
|
12713
|
+
close(fd); } }, false);
|
|
12714
|
+
strict_file_identity_inspectFileIdentitySync(() => borrowed ? rootOwner.stat : external_node_fs_.fstatSync(fd, { bigint: true }), existing.identity);
|
|
12715
|
+
verifyMkdirDirectory(binding, fd, existing.path);
|
|
12716
|
+
const guard = { dir: existing.path, realPath: existing.path, stat: existing.identity };
|
|
12717
|
+
const assertCurrent = () => {
|
|
12718
|
+
let currentRoot;
|
|
12719
|
+
root_context_assertRootIdentityCurrentSync(params.root, stat => { currentRoot = stat; });
|
|
12720
|
+
if (borrowed) {
|
|
12721
|
+
// Root and parent are the same name in this synchronous fence.
|
|
12722
|
+
directory_guard_inspectDirectoryIdentitySync(existing.path, existing.identity, currentRoot);
|
|
12723
|
+
if (realpath_realpathSync.native(windows_path_alias_pathForWindowsFilesystem(existing.path)) !== existing.path) {
|
|
12724
|
+
throw new errors_FsSafeError("path-mismatch", "directory changed during operation");
|
|
12725
|
+
}
|
|
12726
|
+
}
|
|
12727
|
+
else {
|
|
12728
|
+
directory_guard_assertSyncDirectoryGuard(guard);
|
|
12729
|
+
}
|
|
12730
|
+
};
|
|
12731
|
+
pending = { value: await operation(binding, fd, assertCurrent) };
|
|
12732
|
+
return pending.value;
|
|
12733
|
+
}
|
|
12734
|
+
catch (e_1) {
|
|
12735
|
+
env_1.error = e_1;
|
|
12736
|
+
env_1.hasError = true;
|
|
12737
|
+
}
|
|
12738
|
+
finally {
|
|
12739
|
+
root_create_native_disposeResources(env_1);
|
|
12740
|
+
}
|
|
12741
|
+
}
|
|
12742
|
+
catch (error) {
|
|
12743
|
+
if (pending && discard) {
|
|
12744
|
+
try {
|
|
12745
|
+
await discard(pending.value);
|
|
12746
|
+
}
|
|
12747
|
+
catch (cleanupError) {
|
|
12748
|
+
throw createSuppressedError(cleanupError, error, "creation handoff and cleanup failed");
|
|
12749
|
+
}
|
|
12750
|
+
}
|
|
12751
|
+
throw error;
|
|
12752
|
+
}
|
|
12753
|
+
}
|
|
12404
12754
|
const directoryTarget = params.directory === params.target;
|
|
12405
12755
|
const canonicalTarget = async (target) => directoryTarget
|
|
12406
12756
|
? await resolvePathViaExistingAncestor(target)
|
|
@@ -12417,14 +12767,14 @@ async function withNativeDirectory(params, operation, discard) {
|
|
|
12417
12767
|
const close = captureNativeFdClose(binding);
|
|
12418
12768
|
let pending;
|
|
12419
12769
|
try {
|
|
12420
|
-
const
|
|
12770
|
+
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
12421
12771
|
try {
|
|
12422
12772
|
const admitted = await openNativeRootAdmission(binding, {
|
|
12423
12773
|
rootPath: params.root.rootReal, rootIdentity: params.root.rootIdentity, operation: "create", reportCloseErrors: true, searchOnly: true,
|
|
12424
12774
|
});
|
|
12425
|
-
const rootOwner = root_create_native_addDisposableResource(
|
|
12775
|
+
const rootOwner = root_create_native_addDisposableResource(env_2, admitted.root, true);
|
|
12426
12776
|
const descriptors = [];
|
|
12427
|
-
const directoryOwner = root_create_native_addDisposableResource(
|
|
12777
|
+
const directoryOwner = root_create_native_addDisposableResource(env_2, { [Symbol.dispose]() {
|
|
12428
12778
|
const errors = [];
|
|
12429
12779
|
for (const fd of descriptors.reverse())
|
|
12430
12780
|
try {
|
|
@@ -12522,12 +12872,12 @@ async function withNativeDirectory(params, operation, discard) {
|
|
|
12522
12872
|
pending = { value: await operation(binding, current, assertCurrent) };
|
|
12523
12873
|
return pending.value;
|
|
12524
12874
|
}
|
|
12525
|
-
catch (
|
|
12526
|
-
|
|
12527
|
-
|
|
12875
|
+
catch (e_2) {
|
|
12876
|
+
env_2.error = e_2;
|
|
12877
|
+
env_2.hasError = true;
|
|
12528
12878
|
}
|
|
12529
12879
|
finally {
|
|
12530
|
-
const result_1 = root_create_native_disposeResources(
|
|
12880
|
+
const result_1 = root_create_native_disposeResources(env_2);
|
|
12531
12881
|
if (result_1)
|
|
12532
12882
|
await result_1;
|
|
12533
12883
|
}
|
|
@@ -12606,33 +12956,77 @@ function verifyMkdirDirectory(binding, fd, pathname) {
|
|
|
12606
12956
|
describePolicyStagedDirectory(fd, pathname);
|
|
12607
12957
|
}
|
|
12608
12958
|
function ensureNativeRootCurrent(root) {
|
|
12609
|
-
|
|
12959
|
+
root_context_assertRootIdentityCurrentSync(root);
|
|
12960
|
+
const binding = native_getNativeBinding("openBeneath", "mkdirChildBeneath");
|
|
12961
|
+
if (!binding?.openBeneath || !binding.mkdirChildBeneath)
|
|
12962
|
+
return root_create_native_unavailable();
|
|
12963
|
+
if (binding.verifyRootDirectory) {
|
|
12964
|
+
const closeNative = captureNativeFdClose(binding);
|
|
12965
|
+
const failure = binding.verifyRootDirectory(root.rootReal, root.rootIdentity.dev, root.rootIdentity.ino);
|
|
12966
|
+
if (failure === null)
|
|
12967
|
+
return;
|
|
12968
|
+
if (failure?.fallbackFd !== undefined && failure.fallbackFd !== null) {
|
|
12969
|
+
const env_3 = { stack: [], error: void 0, hasError: false };
|
|
12970
|
+
try {
|
|
12971
|
+
const fd = failure.fallbackFd;
|
|
12972
|
+
if (!Number.isInteger(fd) || fd < 0)
|
|
12973
|
+
throw new errors_FsSafeError("helper-failed", "invalid root fallback descriptor");
|
|
12974
|
+
const owner = root_create_native_addDisposableResource(env_3, { [Symbol.dispose]() { closeNative(fd); } }, false);
|
|
12975
|
+
if (failure.errorCode || failure.closeErrorCode)
|
|
12976
|
+
throw new errors_FsSafeError("helper-failed", "invalid root verification result");
|
|
12977
|
+
ensureNativeRootCurrentLegacy(root, binding);
|
|
12978
|
+
return;
|
|
12979
|
+
}
|
|
12980
|
+
catch (e_3) {
|
|
12981
|
+
env_3.error = e_3;
|
|
12982
|
+
env_3.hasError = true;
|
|
12983
|
+
}
|
|
12984
|
+
finally {
|
|
12985
|
+
root_create_native_disposeResources(env_3);
|
|
12986
|
+
}
|
|
12987
|
+
}
|
|
12988
|
+
const error = failure?.errorCode ? rootVerificationError(failure.errorCode, failure.errorMessage, failure.errorErrno) : undefined;
|
|
12989
|
+
const closeError = failure?.closeErrorCode ? Object.assign(new Error(failure.closeErrorMessage), {
|
|
12990
|
+
code: failure.closeErrorCode,
|
|
12991
|
+
...(typeof failure.closeErrorErrno === "number" ? { errno: failure.closeErrorErrno } : {}),
|
|
12992
|
+
}) : undefined;
|
|
12993
|
+
if (error && closeError)
|
|
12994
|
+
throw createSuppressedError(closeError, error, "root verification and close failed");
|
|
12995
|
+
if (error || closeError)
|
|
12996
|
+
throw error ?? closeError;
|
|
12997
|
+
throw new errors_FsSafeError("helper-failed", "invalid root verification result");
|
|
12998
|
+
}
|
|
12999
|
+
ensureNativeRootCurrentLegacy(root, binding);
|
|
13000
|
+
}
|
|
13001
|
+
function rootVerificationError(code, message, errno) {
|
|
13002
|
+
const error = Object.assign(new Error(message), { code, ...(typeof errno === "number" ? { errno } : {}) });
|
|
13003
|
+
return code === "path-mismatch" || code === "OBSERVATION_REDIRECTED"
|
|
13004
|
+
? new errors_FsSafeError("path-mismatch", "root identity changed during verification", { cause: error }) : error;
|
|
13005
|
+
}
|
|
13006
|
+
function ensureNativeRootCurrentLegacy(root, binding) {
|
|
13007
|
+
const env_4 = { stack: [], error: void 0, hasError: false };
|
|
12610
13008
|
try {
|
|
12611
|
-
|
|
12612
|
-
const binding = native_getNativeBinding("openBeneath", "mkdirChildBeneath");
|
|
12613
|
-
if (!binding?.openBeneath || !binding.mkdirChildBeneath)
|
|
12614
|
-
return root_create_native_unavailable();
|
|
12615
|
-
const rootOwner = root_create_native_addDisposableResource(env_2, openExactNativeRootSync(binding, {
|
|
13009
|
+
const rootOwner = root_create_native_addDisposableResource(env_4, openExactNativeRootSync(binding, {
|
|
12616
13010
|
rootPath: root.rootReal, rootIdentity: root.rootIdentity,
|
|
12617
13011
|
}), false);
|
|
12618
13012
|
verifyMkdirDirectory(binding, rootOwner.fd, root.rootReal);
|
|
12619
13013
|
root_context_assertRootIdentityCurrentSync(root);
|
|
12620
13014
|
}
|
|
12621
|
-
catch (
|
|
12622
|
-
|
|
12623
|
-
|
|
13015
|
+
catch (e_4) {
|
|
13016
|
+
env_4.error = e_4;
|
|
13017
|
+
env_4.hasError = true;
|
|
12624
13018
|
}
|
|
12625
13019
|
finally {
|
|
12626
|
-
root_create_native_disposeResources(
|
|
13020
|
+
root_create_native_disposeResources(env_4);
|
|
12627
13021
|
}
|
|
12628
13022
|
}
|
|
12629
13023
|
function mkdirNativeRootChild(params) {
|
|
12630
|
-
const
|
|
13024
|
+
const env_5 = { stack: [], error: void 0, hasError: false };
|
|
12631
13025
|
try {
|
|
12632
13026
|
const binding = native_getNativeBinding("openBeneath", "mkdirChildBeneath");
|
|
12633
13027
|
if (!binding?.openBeneath || !binding.mkdirChildBeneath)
|
|
12634
13028
|
return root_create_native_unavailable();
|
|
12635
|
-
const rootOwner = root_create_native_addDisposableResource(
|
|
13029
|
+
const rootOwner = root_create_native_addDisposableResource(env_5, openExactNativeRootSync(binding, {
|
|
12636
13030
|
rootPath: params.root.rootReal, rootIdentity: params.root.rootIdentity,
|
|
12637
13031
|
}), false);
|
|
12638
13032
|
verifyMkdirDirectory(binding, rootOwner.fd, params.root.rootReal);
|
|
@@ -12645,17 +13039,17 @@ function mkdirNativeRootChild(params) {
|
|
|
12645
13039
|
? binding.mkdirOpenChildBeneath(rootOwner.fd, name, 0o777, flags).fd
|
|
12646
13040
|
: (binding.mkdirChildBeneath(rootOwner.fd, name, 0o777), binding.openBeneath(rootOwner.fd, name, flags).fd);
|
|
12647
13041
|
const close = captureNativeFdClose(binding);
|
|
12648
|
-
const childOwner = root_create_native_addDisposableResource(
|
|
13042
|
+
const childOwner = root_create_native_addDisposableResource(env_5, { [Symbol.dispose]() { close(child); } }, false);
|
|
12649
13043
|
root_context_assertRootIdentityCurrentSync(params.root);
|
|
12650
13044
|
verifyMkdirDirectory(binding, child, params.target);
|
|
12651
13045
|
verifyMkdirDirectory(binding, rootOwner.fd, params.root.rootReal);
|
|
12652
13046
|
}
|
|
12653
|
-
catch (
|
|
12654
|
-
|
|
12655
|
-
|
|
13047
|
+
catch (e_5) {
|
|
13048
|
+
env_5.error = e_5;
|
|
13049
|
+
env_5.hasError = true;
|
|
12656
13050
|
}
|
|
12657
13051
|
finally {
|
|
12658
|
-
root_create_native_disposeResources(
|
|
13052
|
+
root_create_native_disposeResources(env_5);
|
|
12659
13053
|
}
|
|
12660
13054
|
}
|
|
12661
13055
|
async function tryOpenCreateRootNative(params) {
|
|
@@ -12677,7 +13071,7 @@ async function tryOpenCreateRootNative(params) {
|
|
|
12677
13071
|
if (creationMode() === undefined)
|
|
12678
13072
|
return root_create_native_unavailable();
|
|
12679
13073
|
return await withNativeDirectory(params, async (binding, parent, assertCurrent) => {
|
|
12680
|
-
const
|
|
13074
|
+
const env_6 = { stack: [], error: void 0, hasError: false };
|
|
12681
13075
|
try {
|
|
12682
13076
|
params.assertBeforeMutation?.();
|
|
12683
13077
|
assertCurrent();
|
|
@@ -12687,13 +13081,21 @@ async function tryOpenCreateRootNative(params) {
|
|
|
12687
13081
|
// Native creation owns the only O_CREAT dispatch. The subsequent Node open
|
|
12688
13082
|
// carries neither O_CREAT nor O_TRUNC and must match this retained inode.
|
|
12689
13083
|
const close = captureNativeFdClose(binding);
|
|
12690
|
-
|
|
13084
|
+
let fd;
|
|
13085
|
+
try {
|
|
13086
|
+
fd = binding.openCreateBeneath(parent, external_node_path_.basename(params.target), params.flags, params.mode & 0o7777);
|
|
13087
|
+
}
|
|
13088
|
+
catch (error) {
|
|
13089
|
+
if (hasNodeErrorCode(error, "EEXIST") && typeof error === "object" && error !== null)
|
|
13090
|
+
nativeCreateCollisions.add(error);
|
|
13091
|
+
throw error;
|
|
13092
|
+
}
|
|
12691
13093
|
let rawOpen = true;
|
|
12692
13094
|
const closeRaw = () => { if (rawOpen) {
|
|
12693
13095
|
rawOpen = false;
|
|
12694
13096
|
close(fd);
|
|
12695
13097
|
} };
|
|
12696
|
-
const owner = root_create_native_addDisposableResource(
|
|
13098
|
+
const owner = root_create_native_addDisposableResource(env_6, { [Symbol.dispose]: closeRaw }, false);
|
|
12697
13099
|
try {
|
|
12698
13100
|
const identity = strict_file_identity_inspectFileIdentitySync(() => external_node_fs_.fstatSync(fd, { bigint: true }));
|
|
12699
13101
|
if (!identity.isFile() || identity.nlink !== 1n)
|
|
@@ -12747,26 +13149,26 @@ async function tryOpenCreateRootNative(params) {
|
|
|
12747
13149
|
throw error;
|
|
12748
13150
|
}
|
|
12749
13151
|
}
|
|
12750
|
-
catch (
|
|
12751
|
-
|
|
12752
|
-
|
|
13152
|
+
catch (e_6) {
|
|
13153
|
+
env_6.error = e_6;
|
|
13154
|
+
env_6.hasError = true;
|
|
12753
13155
|
}
|
|
12754
13156
|
finally {
|
|
12755
|
-
root_create_native_disposeResources(
|
|
13157
|
+
root_create_native_disposeResources(env_6);
|
|
12756
13158
|
}
|
|
12757
13159
|
}, async (created) => {
|
|
12758
|
-
const
|
|
13160
|
+
const env_7 = { stack: [], error: void 0, hasError: false };
|
|
12759
13161
|
try {
|
|
12760
|
-
const handle = root_create_native_addDisposableResource(
|
|
12761
|
-
const parent = root_create_native_addDisposableResource(
|
|
13162
|
+
const handle = root_create_native_addDisposableResource(env_7, created.handle, true);
|
|
13163
|
+
const parent = root_create_native_addDisposableResource(env_7, { [Symbol.dispose]: created.releaseCreationParent }, false);
|
|
12762
13164
|
await created.cleanupCreated();
|
|
12763
13165
|
}
|
|
12764
|
-
catch (
|
|
12765
|
-
|
|
12766
|
-
|
|
13166
|
+
catch (e_7) {
|
|
13167
|
+
env_7.error = e_7;
|
|
13168
|
+
env_7.hasError = true;
|
|
12767
13169
|
}
|
|
12768
13170
|
finally {
|
|
12769
|
-
const result_2 = root_create_native_disposeResources(
|
|
13171
|
+
const result_2 = root_create_native_disposeResources(env_7);
|
|
12770
13172
|
if (result_2)
|
|
12771
13173
|
await result_2;
|
|
12772
13174
|
}
|
|
@@ -13502,7 +13904,7 @@ function privateDirectoryBackend() {
|
|
|
13502
13904
|
if (getFsSafeNativeConfig().mode === "require") {
|
|
13503
13905
|
throw new errors_FsSafeError("helper-unavailable", "private directory creation requires an up-to-date native parent identity capability");
|
|
13504
13906
|
}
|
|
13505
|
-
warnNativeFallback("windows-private-directory", "Private Windows directory creation
|
|
13907
|
+
warnNativeFallback("windows-private-directory", "Private Windows directory creation launches the packaged .NET helper for each check or creation.", "createPrivateDirectoryWithParentIdentity");
|
|
13506
13908
|
return undefined;
|
|
13507
13909
|
}
|
|
13508
13910
|
async function createDirectory(targetPath, options = {}) {
|
|
@@ -19312,6 +19714,247 @@ async function read_opened_file_readOpenedFileSafely(params) {
|
|
|
19312
19714
|
};
|
|
19313
19715
|
}
|
|
19314
19716
|
|
|
19717
|
+
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/root-mkdir-native.js
|
|
19718
|
+
var root_mkdir_native_addDisposableResource = (undefined && undefined.__addDisposableResource) || function (env, value, async) {
|
|
19719
|
+
if (value !== null && value !== void 0) {
|
|
19720
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
19721
|
+
var dispose, inner;
|
|
19722
|
+
if (async) {
|
|
19723
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
19724
|
+
dispose = value[Symbol.asyncDispose];
|
|
19725
|
+
}
|
|
19726
|
+
if (dispose === void 0) {
|
|
19727
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
19728
|
+
dispose = value[Symbol.dispose];
|
|
19729
|
+
if (async) inner = dispose;
|
|
19730
|
+
}
|
|
19731
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
19732
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
19733
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
19734
|
+
}
|
|
19735
|
+
else if (async) {
|
|
19736
|
+
env.stack.push({ async: true });
|
|
19737
|
+
}
|
|
19738
|
+
return value;
|
|
19739
|
+
};
|
|
19740
|
+
var root_mkdir_native_disposeResources = (undefined && undefined.__disposeResources) || (function (SuppressedError) {
|
|
19741
|
+
return function (env) {
|
|
19742
|
+
function fail(e) {
|
|
19743
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
19744
|
+
env.hasError = true;
|
|
19745
|
+
}
|
|
19746
|
+
var r, s = 0;
|
|
19747
|
+
function next() {
|
|
19748
|
+
while (r = env.stack.pop()) {
|
|
19749
|
+
try {
|
|
19750
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
19751
|
+
if (r.dispose) {
|
|
19752
|
+
var result = r.dispose.call(r.value);
|
|
19753
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
19754
|
+
}
|
|
19755
|
+
else s |= 1;
|
|
19756
|
+
}
|
|
19757
|
+
catch (e) {
|
|
19758
|
+
fail(e);
|
|
19759
|
+
}
|
|
19760
|
+
}
|
|
19761
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
19762
|
+
if (env.hasError) throw env.error;
|
|
19763
|
+
}
|
|
19764
|
+
return next();
|
|
19765
|
+
};
|
|
19766
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
19767
|
+
var e = new Error(message);
|
|
19768
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
19769
|
+
});
|
|
19770
|
+
|
|
19771
|
+
|
|
19772
|
+
|
|
19773
|
+
|
|
19774
|
+
|
|
19775
|
+
|
|
19776
|
+
|
|
19777
|
+
|
|
19778
|
+
|
|
19779
|
+
|
|
19780
|
+
|
|
19781
|
+
|
|
19782
|
+
|
|
19783
|
+
|
|
19784
|
+
|
|
19785
|
+
|
|
19786
|
+
|
|
19787
|
+
function tryMkdirNativeParents(root, relativePath) {
|
|
19788
|
+
try {
|
|
19789
|
+
return mkdirOrdinaryNativeParents(root, relativePath);
|
|
19790
|
+
}
|
|
19791
|
+
catch (error) {
|
|
19792
|
+
if (hasNodeErrorCode(error, "ENOTDIR"))
|
|
19793
|
+
throw root_errors_directoryComponentNotDirectoryError(error);
|
|
19794
|
+
throw error;
|
|
19795
|
+
}
|
|
19796
|
+
}
|
|
19797
|
+
function mkdirOrdinaryNativeParents(root, relativePath) {
|
|
19798
|
+
if (getFsSafeTestHooks()?.beforeRootFallbackMutation)
|
|
19799
|
+
return false;
|
|
19800
|
+
const segments = relativePath.split(external_node_path_.sep === "\\" ? /[\\/]/ : "/");
|
|
19801
|
+
if (segments.length < 2 || segments.some(segment => !isSafePathSegment(segment, { allowDotPrefix: true }) || segment.endsWith(".")))
|
|
19802
|
+
return false;
|
|
19803
|
+
let rootStat;
|
|
19804
|
+
root_context_assertRootIdentityCurrentSync(root, stat => { rootStat = stat; });
|
|
19805
|
+
const target = external_node_path_.join(root.rootReal, ...segments);
|
|
19806
|
+
const parentPath = external_node_path_.dirname(target);
|
|
19807
|
+
try {
|
|
19808
|
+
const child = external_node_fs_.lstatSync(windows_path_alias_pathForWindowsFilesystem(target), { throwIfNoEntry: false });
|
|
19809
|
+
if (child && (!child.isDirectory() || realpath_realpathSync.native(windows_path_alias_pathForWindowsFilesystem(target)) !== target))
|
|
19810
|
+
return false;
|
|
19811
|
+
}
|
|
19812
|
+
catch {
|
|
19813
|
+
return false;
|
|
19814
|
+
}
|
|
19815
|
+
let parentIdentity;
|
|
19816
|
+
try {
|
|
19817
|
+
parentIdentity = directory_guard_inspectDirectoryIdentitySync(parentPath);
|
|
19818
|
+
}
|
|
19819
|
+
catch (error) {
|
|
19820
|
+
// Reuse this exact Root snapshot and failed parent observation without an
|
|
19821
|
+
// intervening await. All opened ancestors still receive fresh native fences.
|
|
19822
|
+
return hasNodeErrorCode(error, "ENOENT") ? mkdirMissingParents(root, segments, rootStat) : false;
|
|
19823
|
+
}
|
|
19824
|
+
try {
|
|
19825
|
+
if (realpath_realpathSync.native(windows_path_alias_pathForWindowsFilesystem(parentPath)) !== parentPath)
|
|
19826
|
+
return false;
|
|
19827
|
+
}
|
|
19828
|
+
catch {
|
|
19829
|
+
return false;
|
|
19830
|
+
}
|
|
19831
|
+
return mkdirExistingParent(root, segments, parentIdentity);
|
|
19832
|
+
}
|
|
19833
|
+
/** Ordinary missing suffixes need no policy callbacks or repeated path resolution. */
|
|
19834
|
+
function mkdirMissingParents(root, segments, rootStat) {
|
|
19835
|
+
const binding = native_getNativeBinding("openBeneath", "mkdirChildBeneath");
|
|
19836
|
+
if (!binding?.openBeneath || !binding.mkdirOpenChildBeneath)
|
|
19837
|
+
return false;
|
|
19838
|
+
let parentDepth = segments.length - 2;
|
|
19839
|
+
let parentPath;
|
|
19840
|
+
let parentIdentity;
|
|
19841
|
+
for (;;) {
|
|
19842
|
+
parentPath = external_node_path_.join(root.rootReal, ...segments.slice(0, parentDepth));
|
|
19843
|
+
try {
|
|
19844
|
+
parentIdentity = directory_guard_inspectDirectoryIdentitySync(parentPath, undefined, parentDepth === 0 ? rootStat : undefined);
|
|
19845
|
+
if (realpath_realpathSync.native(windows_path_alias_pathForWindowsFilesystem(parentPath)) !== parentPath)
|
|
19846
|
+
return false;
|
|
19847
|
+
break;
|
|
19848
|
+
}
|
|
19849
|
+
catch (error) {
|
|
19850
|
+
if (!hasNodeErrorCode(error, "ENOENT") || parentDepth === 0)
|
|
19851
|
+
return false;
|
|
19852
|
+
parentDepth--;
|
|
19853
|
+
}
|
|
19854
|
+
}
|
|
19855
|
+
try {
|
|
19856
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
19857
|
+
try {
|
|
19858
|
+
const rootOwner = root_mkdir_native_addDisposableResource(env_1, openExactNativeRootSync(binding, {
|
|
19859
|
+
rootPath: root.rootReal, rootIdentity: root.rootIdentity,
|
|
19860
|
+
}), false);
|
|
19861
|
+
const close = captureNativeFdClose(binding);
|
|
19862
|
+
const directories = [];
|
|
19863
|
+
const directoryOwner = root_mkdir_native_addDisposableResource(env_1, { [Symbol.dispose]() {
|
|
19864
|
+
const errors = [];
|
|
19865
|
+
for (const directory of directories.toReversed()) {
|
|
19866
|
+
try {
|
|
19867
|
+
close(directory.fd);
|
|
19868
|
+
}
|
|
19869
|
+
catch (error) {
|
|
19870
|
+
errors.push(error);
|
|
19871
|
+
}
|
|
19872
|
+
}
|
|
19873
|
+
if (errors.length)
|
|
19874
|
+
throw new AggregateError(errors, "mkdir directory close failed");
|
|
19875
|
+
} }, false);
|
|
19876
|
+
const flags = (nodeDirectorySearchOnlyFlags()?.flags ?? external_node_fs_.constants.O_RDONLY) |
|
|
19877
|
+
(external_node_fs_.constants.O_DIRECTORY ?? 0) | (external_node_fs_.constants.O_NOFOLLOW ?? 0);
|
|
19878
|
+
let current = rootOwner.fd;
|
|
19879
|
+
if (parentDepth > 0) {
|
|
19880
|
+
current = binding.openBeneath(rootOwner.fd, segments.slice(0, parentDepth).join("/"), flags).fd;
|
|
19881
|
+
directories.push({ fd: current, pathname: parentPath });
|
|
19882
|
+
strict_file_identity_inspectFileIdentitySync(() => external_node_fs_.fstatSync(current, { bigint: true }), parentIdentity);
|
|
19883
|
+
}
|
|
19884
|
+
const assertCurrent = () => {
|
|
19885
|
+
root_context_assertRootIdentityCurrentSync(root);
|
|
19886
|
+
for (const directory of directories)
|
|
19887
|
+
verifyMkdirDirectory(binding, directory.fd, directory.pathname);
|
|
19888
|
+
verifyMkdirDirectory(binding, rootOwner.fd, root.rootReal);
|
|
19889
|
+
};
|
|
19890
|
+
assertCurrent();
|
|
19891
|
+
for (const segment of segments.slice(parentDepth)) {
|
|
19892
|
+
const child = binding.mkdirOpenChildBeneath(current, segment, 0o777, flags);
|
|
19893
|
+
parentPath = external_node_path_.join(parentPath, segment);
|
|
19894
|
+
directories.push({ fd: child.fd, pathname: parentPath });
|
|
19895
|
+
// Retain every ancestor until the complete suffix is admitted. The
|
|
19896
|
+
// post-create fence also precedes the next synchronous child mutation.
|
|
19897
|
+
assertCurrent();
|
|
19898
|
+
current = child.fd;
|
|
19899
|
+
}
|
|
19900
|
+
return true;
|
|
19901
|
+
}
|
|
19902
|
+
catch (e_1) {
|
|
19903
|
+
env_1.error = e_1;
|
|
19904
|
+
env_1.hasError = true;
|
|
19905
|
+
}
|
|
19906
|
+
finally {
|
|
19907
|
+
root_mkdir_native_disposeResources(env_1);
|
|
19908
|
+
}
|
|
19909
|
+
}
|
|
19910
|
+
catch (error) {
|
|
19911
|
+
if (hasNodeErrorCode(error, "ENOTDIR"))
|
|
19912
|
+
throw root_errors_directoryComponentNotDirectoryError(error);
|
|
19913
|
+
throw error;
|
|
19914
|
+
}
|
|
19915
|
+
}
|
|
19916
|
+
function mkdirExistingParent(root, segments, parentIdentity) {
|
|
19917
|
+
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
19918
|
+
try {
|
|
19919
|
+
const target = external_node_path_.join(root.rootReal, ...segments);
|
|
19920
|
+
const parentPath = external_node_path_.dirname(target);
|
|
19921
|
+
const binding = native_getNativeBinding("openBeneath", "mkdirChildBeneath");
|
|
19922
|
+
if (!binding?.openBeneath || !binding.mkdirChildBeneath) {
|
|
19923
|
+
throw new errors_FsSafeError("helper-unavailable", "native confined creation is unavailable");
|
|
19924
|
+
}
|
|
19925
|
+
const rootOwner = root_mkdir_native_addDisposableResource(env_2, openExactNativeRootSync(binding, {
|
|
19926
|
+
rootPath: root.rootReal, rootIdentity: root.rootIdentity,
|
|
19927
|
+
}), false);
|
|
19928
|
+
verifyMkdirDirectory(binding, rootOwner.fd, root.rootReal);
|
|
19929
|
+
const flags = (nodeDirectorySearchOnlyFlags()?.flags ?? external_node_fs_.constants.O_RDONLY) |
|
|
19930
|
+
(external_node_fs_.constants.O_DIRECTORY ?? 0) | (external_node_fs_.constants.O_NOFOLLOW ?? 0);
|
|
19931
|
+
const close = captureNativeFdClose(binding);
|
|
19932
|
+
const parent = binding.openBeneath(rootOwner.fd, segments.slice(0, -1).join("/"), flags).fd;
|
|
19933
|
+
const parentOwner = root_mkdir_native_addDisposableResource(env_2, { [Symbol.dispose]() { close(parent); } }, false);
|
|
19934
|
+
strict_file_identity_inspectFileIdentitySync(() => external_node_fs_.fstatSync(parent, { bigint: true }), parentIdentity);
|
|
19935
|
+
verifyMkdirDirectory(binding, parent, parentPath);
|
|
19936
|
+
root_context_assertRootIdentityCurrentSync(root);
|
|
19937
|
+
const name = segments.at(-1);
|
|
19938
|
+
const child = binding.mkdirOpenChildBeneath
|
|
19939
|
+
? binding.mkdirOpenChildBeneath(parent, name, 0o777, flags).fd
|
|
19940
|
+
: (binding.mkdirChildBeneath(parent, name, 0o777), binding.openBeneath(parent, name, flags).fd);
|
|
19941
|
+
const childOwner = root_mkdir_native_addDisposableResource(env_2, { [Symbol.dispose]() { close(child); } }, false);
|
|
19942
|
+
root_context_assertRootIdentityCurrentSync(root);
|
|
19943
|
+
verifyMkdirDirectory(binding, child, target);
|
|
19944
|
+
directory_guard_inspectDirectoryIdentitySync(parentPath, parentIdentity);
|
|
19945
|
+
verifyMkdirDirectory(binding, parent, parentPath);
|
|
19946
|
+
verifyMkdirDirectory(binding, rootOwner.fd, root.rootReal);
|
|
19947
|
+
return true;
|
|
19948
|
+
}
|
|
19949
|
+
catch (e_2) {
|
|
19950
|
+
env_2.error = e_2;
|
|
19951
|
+
env_2.hasError = true;
|
|
19952
|
+
}
|
|
19953
|
+
finally {
|
|
19954
|
+
root_mkdir_native_disposeResources(env_2);
|
|
19955
|
+
}
|
|
19956
|
+
}
|
|
19957
|
+
|
|
19315
19958
|
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/write-open-flags.js
|
|
19316
19959
|
|
|
19317
19960
|
|
|
@@ -22384,6 +23027,7 @@ var root_impl_disposeResources = (undefined && undefined.__disposeResources) ||
|
|
|
22384
23027
|
|
|
22385
23028
|
|
|
22386
23029
|
|
|
23030
|
+
|
|
22387
23031
|
|
|
22388
23032
|
|
|
22389
23033
|
function logWarn(message) {
|
|
@@ -22784,7 +23428,9 @@ async function openWritableFileInRoot(root, params, options) {
|
|
|
22784
23428
|
denyMutations: params.denyMutations,
|
|
22785
23429
|
mutationSymlinks: params.mutationSymlinks,
|
|
22786
23430
|
});
|
|
22787
|
-
const
|
|
23431
|
+
const creationProbe = requireNative && !guardedTarget && params.assertBeforeMutation === undefined && options?.createIfMissing !== false
|
|
23432
|
+
? probeNativeCreationPath(root, params.relativePath) : undefined;
|
|
23433
|
+
const { resolved } = creationProbe ?? guardedTarget?.resolvedPath ?? await resolveGuardedWritePathInRoot(root, {
|
|
22788
23434
|
relativePath: params.relativePath,
|
|
22789
23435
|
});
|
|
22790
23436
|
const resolveCurrent = async () => (await resolveGuardedWritePathInRoot(root, {
|
|
@@ -22813,27 +23459,30 @@ async function openWritableFileInRoot(root, params, options) {
|
|
|
22813
23459
|
let ioPath = nativeCreatesParents ? resolved : prepared?.targetPath ?? (params.mkdir === false ? resolved :
|
|
22814
23460
|
await prepareRootWriteTarget(root, resolved, params.assertBeforeMutation));
|
|
22815
23461
|
const operationTargetPath = ioPath;
|
|
22816
|
-
|
|
22817
|
-
|
|
22818
|
-
|
|
22819
|
-
|
|
22820
|
-
|
|
22821
|
-
|
|
22822
|
-
|
|
22823
|
-
|
|
22824
|
-
|
|
22825
|
-
|
|
22826
|
-
|
|
22827
|
-
|
|
22828
|
-
|
|
22829
|
-
|
|
22830
|
-
if (err instanceof errors_FsSafeError) {
|
|
22831
|
-
throw err;
|
|
23462
|
+
let observedMissing = Boolean(creationProbe);
|
|
23463
|
+
if (!creationProbe)
|
|
23464
|
+
try {
|
|
23465
|
+
assertFinalSymlinkRejected(ioPath, params.mutationSymlinks !== undefined);
|
|
23466
|
+
const resolvedRealPath = params.mutationSymlinks === undefined ? realpath_realpathSync.native(ioPath) : ioPath;
|
|
23467
|
+
const admittedRealPath = root_boundary_admitPathInsideRoot({
|
|
23468
|
+
rootPath: root.rootReal,
|
|
23469
|
+
candidatePath: resolvedRealPath,
|
|
23470
|
+
rootIdentity: root.rootIdentity,
|
|
23471
|
+
});
|
|
23472
|
+
if (!admittedRealPath) {
|
|
23473
|
+
throw root_errors_outsideWorkspaceError();
|
|
23474
|
+
}
|
|
23475
|
+
ioPath = admittedRealPath.path;
|
|
22832
23476
|
}
|
|
22833
|
-
|
|
22834
|
-
|
|
23477
|
+
catch (err) {
|
|
23478
|
+
if (err instanceof errors_FsSafeError) {
|
|
23479
|
+
throw err;
|
|
23480
|
+
}
|
|
23481
|
+
if (!path_isNotFoundPathError(err)) {
|
|
23482
|
+
throw err;
|
|
23483
|
+
}
|
|
23484
|
+
observedMissing = true;
|
|
22835
23485
|
}
|
|
22836
|
-
}
|
|
22837
23486
|
assertRootFallbackWritePath(params.expectedWritePath, ioPath);
|
|
22838
23487
|
const mode = params.mode ?? 0o600;
|
|
22839
23488
|
let handle;
|
|
@@ -22847,61 +23496,82 @@ async function openWritableFileInRoot(root, params, options) {
|
|
|
22847
23496
|
writePathSelection = guardedTarget
|
|
22848
23497
|
? await prepareGuardedRootWritePathSelection(guardedTarget, ioPath, operationTargetPath, preparedParent)
|
|
22849
23498
|
: undefined;
|
|
22850
|
-
|
|
22851
|
-
|
|
22852
|
-
|
|
22853
|
-
|
|
22854
|
-
|
|
22855
|
-
|
|
22856
|
-
|
|
22857
|
-
|
|
23499
|
+
const createNative = () => tryOpenCreateRootNative({
|
|
23500
|
+
originalPath: params.relativePath,
|
|
23501
|
+
root, directory: external_node_path_.dirname(ioPath), target: ioPath, mkdir: params.mkdir !== false, policy,
|
|
23502
|
+
selectedParent: creationProbe?.parent,
|
|
23503
|
+
resolveCurrent,
|
|
23504
|
+
assertBeforeMutation: params.assertBeforeMutation !== undefined || writePathSelection !== undefined ? () => {
|
|
23505
|
+
params.assertBeforeMutation?.();
|
|
23506
|
+
if (writePathSelection)
|
|
23507
|
+
assertRootWritePathSelectionSync(root, writePathSelection);
|
|
23508
|
+
} : undefined,
|
|
23509
|
+
flags: createFlags, existingFlags, mode,
|
|
23510
|
+
});
|
|
23511
|
+
let precreated;
|
|
23512
|
+
if (requireNative && observedMissing && !guardedTarget && params.assertBeforeMutation === undefined && options?.createIfMissing !== false) {
|
|
23513
|
+
try {
|
|
23514
|
+
precreated = await createNative();
|
|
22858
23515
|
}
|
|
22859
|
-
|
|
22860
|
-
|
|
23516
|
+
catch (error) {
|
|
23517
|
+
if (!hasNodeErrorCode(error, "EEXIST") || !isNativeCreateCollision(error))
|
|
23518
|
+
throw error;
|
|
22861
23519
|
}
|
|
22862
|
-
|
|
22863
|
-
|
|
22864
|
-
|
|
22865
|
-
|
|
22866
|
-
|
|
22867
|
-
|
|
22868
|
-
|
|
22869
|
-
|
|
22870
|
-
|
|
22871
|
-
|
|
22872
|
-
|
|
22873
|
-
|
|
22874
|
-
}))
|
|
22875
|
-
throw root_errors_outsideWorkspaceError();
|
|
22876
|
-
directory_guard_assertSyncDirectoryGuard(parentGuard);
|
|
22877
|
-
return { missing: true, targetPath: ioPath, parentGuard, writeSelection: writePathSelection };
|
|
23520
|
+
}
|
|
23521
|
+
if (precreated) {
|
|
23522
|
+
handle = precreated.handle;
|
|
23523
|
+
cleanupCreated = precreated.cleanupCreated;
|
|
23524
|
+
releaseCreationParent = precreated.releaseCreationParent;
|
|
23525
|
+
createdForWrite = true;
|
|
23526
|
+
}
|
|
23527
|
+
else {
|
|
23528
|
+
try {
|
|
23529
|
+
if (writePathSelection)
|
|
23530
|
+
assertRootWritePathSelectionSync(root, writePathSelection);
|
|
23531
|
+
handle = await promises_.open(ioPath, existingFlags, mode);
|
|
22878
23532
|
}
|
|
22879
|
-
|
|
22880
|
-
await
|
|
22881
|
-
|
|
22882
|
-
|
|
22883
|
-
|
|
22884
|
-
|
|
23533
|
+
catch (err) {
|
|
23534
|
+
if (await isNonRegularWriteOpenError(err, ioPath, existingFlags)) {
|
|
23535
|
+
throw new errors_FsSafeError("not-file", "path is not a regular file under root");
|
|
23536
|
+
}
|
|
23537
|
+
if (!path_isNotFoundPathError(err)) {
|
|
23538
|
+
throw err;
|
|
23539
|
+
}
|
|
23540
|
+
if (options?.createIfMissing === false) {
|
|
23541
|
+
if (nativeCreatesParents && !guardedTarget)
|
|
23542
|
+
await tryMkdirRootNative({
|
|
23543
|
+
originalPath: params.relativePath,
|
|
23544
|
+
root, directory: external_node_path_.dirname(ioPath), target: ioPath, mkdir: true, policy,
|
|
23545
|
+
resolveCurrent, assertBeforeMutation: params.assertBeforeMutation,
|
|
23546
|
+
});
|
|
23547
|
+
const parentGuard = writePathSelection?.parentGuard ??
|
|
23548
|
+
await directory_guard_createAsyncDirectoryGuard(external_node_path_.dirname(ioPath), { bigint: true });
|
|
23549
|
+
root_context_assertRootIdentityCurrentSync(root);
|
|
23550
|
+
if (!root_boundary_admitPathInsideRoot({
|
|
23551
|
+
rootPath: root.rootReal, candidatePath: parentGuard.realPath, rootIdentity: root.rootIdentity,
|
|
23552
|
+
}))
|
|
23553
|
+
throw root_errors_outsideWorkspaceError();
|
|
23554
|
+
directory_guard_assertSyncDirectoryGuard(parentGuard);
|
|
23555
|
+
return { missing: true, targetPath: ioPath, parentGuard, writeSelection: writePathSelection };
|
|
23556
|
+
}
|
|
23557
|
+
if (writePathSelection)
|
|
23558
|
+
await refreshRootWritePathSelection(writePathSelection);
|
|
23559
|
+
const nativeCreated = requireNative ? await createNative() : undefined;
|
|
23560
|
+
if (nativeCreated)
|
|
23561
|
+
handle = nativeCreated.handle;
|
|
23562
|
+
else {
|
|
22885
23563
|
params.assertBeforeMutation?.();
|
|
22886
23564
|
if (writePathSelection)
|
|
22887
23565
|
assertRootWritePathSelectionSync(root, writePathSelection);
|
|
22888
|
-
|
|
22889
|
-
|
|
22890
|
-
|
|
22891
|
-
|
|
22892
|
-
|
|
22893
|
-
|
|
22894
|
-
|
|
22895
|
-
|
|
22896
|
-
assertRootWritePathSelectionSync(root, writePathSelection);
|
|
22897
|
-
// Windows can follow a dangling symlink even with O_EXCL.
|
|
22898
|
-
if (!SUPPORTS_NOFOLLOW)
|
|
22899
|
-
assertFinalSymlinkRejected(ioPath, true);
|
|
22900
|
-
handle = await promises_.open(ioPath, createFlags, mode);
|
|
23566
|
+
// Windows can follow a dangling symlink even with O_EXCL.
|
|
23567
|
+
if (!SUPPORTS_NOFOLLOW)
|
|
23568
|
+
assertFinalSymlinkRejected(ioPath, true);
|
|
23569
|
+
handle = await promises_.open(ioPath, createFlags, mode);
|
|
23570
|
+
}
|
|
23571
|
+
cleanupCreated = nativeCreated?.cleanupCreated;
|
|
23572
|
+
releaseCreationParent = nativeCreated?.releaseCreationParent;
|
|
23573
|
+
createdForWrite = true;
|
|
22901
23574
|
}
|
|
22902
|
-
cleanupCreated = nativeCreated?.cleanupCreated;
|
|
22903
|
-
releaseCreationParent = nativeCreated?.releaseCreationParent;
|
|
22904
|
-
createdForWrite = true;
|
|
22905
23575
|
}
|
|
22906
23576
|
}
|
|
22907
23577
|
catch (err) {
|
|
@@ -23148,6 +23818,8 @@ async function mkdirPathInRoot(root, params) {
|
|
|
23148
23818
|
}
|
|
23149
23819
|
if (tryMkdirNativeDirectChild(root, params.relativePath))
|
|
23150
23820
|
return;
|
|
23821
|
+
if (tryMkdirNativeParents(root, params.relativePath))
|
|
23822
|
+
return;
|
|
23151
23823
|
}
|
|
23152
23824
|
const resolution = { relativePath: params.relativePath, allowRoot: params.allowRoot, ...policy };
|
|
23153
23825
|
const resolveCurrent = policy
|
|
@@ -71024,7 +71696,7 @@ function initializeFlow(effects) {
|
|
|
71024
71696
|
*/
|
|
71025
71697
|
|
|
71026
71698
|
|
|
71027
|
-
const
|
|
71699
|
+
const text_resolver = {
|
|
71028
71700
|
resolveAll: text_createResolver()
|
|
71029
71701
|
};
|
|
71030
71702
|
const text_string = initializeFactory('string');
|
|
@@ -79195,7 +79867,7 @@ const constructs_text = {
|
|
|
79195
79867
|
|
|
79196
79868
|
/** @satisfies {Extension['insideSpan']} */
|
|
79197
79869
|
const insideSpan = {
|
|
79198
|
-
null: [attention_attention,
|
|
79870
|
+
null: [attention_attention, text_resolver]
|
|
79199
79871
|
};
|
|
79200
79872
|
|
|
79201
79873
|
/** @satisfies {Extension['attentionMarkers']} */
|
|
@@ -110395,4 +111067,4 @@ if (installedChunkData !== 0) { // 0 means "already installed".'
|
|
|
110395
111067
|
// module factories are used so entry inlining is disabled
|
|
110396
111068
|
// startup
|
|
110397
111069
|
// Load entry module and return exports
|
|
110398
|
-
var __webpack_exports__ = __webpack_require__(
|
|
111070
|
+
var __webpack_exports__ = __webpack_require__(3699);
|