@lousy-agents/agent-shell 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/index.js +795 -123
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { createRequire as __rspack_createRequire } from "node:module";
|
|
3
3
|
const __rspack_createRequire_require = __rspack_createRequire(import.meta.url);
|
|
4
4
|
var __webpack_modules__ = ({
|
|
5
|
-
|
|
5
|
+
317(__unused_rspack_module, __unused_rspack___webpack_exports__, __webpack_require__) {
|
|
6
6
|
|
|
7
7
|
;// CONCATENATED MODULE: external "node:child_process"
|
|
8
8
|
const external_node_child_process_namespaceObject = __rspack_createRequire_require("node:child_process");
|
|
@@ -222,6 +222,17 @@ function getFsSafeNativeConfig() {
|
|
|
222
222
|
"auto",
|
|
223
223
|
};
|
|
224
224
|
}
|
|
225
|
+
/** Internal provenance; keep the public configuration shape unchanged. */
|
|
226
|
+
function getNativeModeSetting() {
|
|
227
|
+
if (overrideConfig.mode !== undefined)
|
|
228
|
+
return { mode: overrideConfig.mode, source: "programmatic configuration" };
|
|
229
|
+
for (const source of ["FS_SAFE_NATIVE_MODE", "OPENCLAW_FS_SAFE_NATIVE_MODE"]) {
|
|
230
|
+
const mode = parseMode(process.env[source]);
|
|
231
|
+
if (mode !== undefined)
|
|
232
|
+
return { mode, source };
|
|
233
|
+
}
|
|
234
|
+
return { mode: "auto", source: "default" };
|
|
235
|
+
}
|
|
225
236
|
function isFsSafeNativeRequired() {
|
|
226
237
|
return (overrideConfig.mode ??
|
|
227
238
|
parseMode(process.env.FS_SAFE_NATIVE_MODE) ??
|
|
@@ -247,6 +258,62 @@ let native_binding;
|
|
|
247
258
|
let native_loadError;
|
|
248
259
|
let attempted = false;
|
|
249
260
|
let loadBinding = loadBundledBinding;
|
|
261
|
+
let resolvePackage = (name) => native_require.resolve(name);
|
|
262
|
+
let loadOutcome = { reason: "not-probed" };
|
|
263
|
+
let selectedTarget;
|
|
264
|
+
let targetDescription;
|
|
265
|
+
function loadFailure(error, packageName) {
|
|
266
|
+
try {
|
|
267
|
+
return classifyLoadFailure(error, packageName);
|
|
268
|
+
}
|
|
269
|
+
catch {
|
|
270
|
+
// Diagnostic inspection must not replace an arbitrary thrown load value.
|
|
271
|
+
return { reason: "load-failed", code: "UNKNOWN" };
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
function classifyLoadFailure(error, packageName) {
|
|
275
|
+
const code = typeof error === "object" && error !== null && "code" in error ? error.code : undefined;
|
|
276
|
+
// Resolution must fail for the selected package itself. An exception inside
|
|
277
|
+
// an installed package (even one naming this package) is not package omission.
|
|
278
|
+
if (code === "MODULE_NOT_FOUND" && error instanceof Error &&
|
|
279
|
+
error.message.split("\n", 1)[0] === `Cannot find module '${packageName}'`) {
|
|
280
|
+
try {
|
|
281
|
+
resolvePackage(packageName);
|
|
282
|
+
}
|
|
283
|
+
catch (resolutionError) {
|
|
284
|
+
if (resolutionError instanceof Error && "code" in resolutionError &&
|
|
285
|
+
resolutionError.code === "MODULE_NOT_FOUND" &&
|
|
286
|
+
resolutionError.message.split("\n", 1)[0] === `Cannot find module '${packageName}'`) {
|
|
287
|
+
return { reason: "package-missing" };
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
// An allowlist excludes paths, secrets and arbitrary text in exception codes.
|
|
292
|
+
const knownCodes = ["ERR_DLOPEN_FAILED", "MODULE_NOT_FOUND", "ERR_MODULE_NOT_FOUND",
|
|
293
|
+
"ERR_PACKAGE_PATH_NOT_EXPORTED", "ERR_INVALID_PACKAGE_CONFIG", "EACCES", "EPERM", "ENOENT"];
|
|
294
|
+
return { reason: "load-failed", code: typeof code === "string" && knownCodes.includes(code) ? code : "UNKNOWN" };
|
|
295
|
+
}
|
|
296
|
+
/** Internal view of the cached load; never attempts to load an addon. */
|
|
297
|
+
function getNativeFallbackDiagnostic(...capabilities) {
|
|
298
|
+
const setting = getNativeModeSetting();
|
|
299
|
+
const target = targetDescription === undefined ? bundledTarget() : selectedTarget;
|
|
300
|
+
const packageName = target === undefined ? undefined : nativePackageForTarget(target);
|
|
301
|
+
const manifest = native_require("../package.json");
|
|
302
|
+
const expected = {
|
|
303
|
+
target: targetDescription,
|
|
304
|
+
packageName,
|
|
305
|
+
packageVersion: packageName === undefined ? undefined : manifest.optionalDependencies[packageName],
|
|
306
|
+
};
|
|
307
|
+
if (setting.mode === "off")
|
|
308
|
+
return { ...expected, reason: "disabled", source: setting.source };
|
|
309
|
+
const loaded = native_binding;
|
|
310
|
+
if (loaded) {
|
|
311
|
+
const missing = capabilities.filter(name => typeof loaded[name] !== "function");
|
|
312
|
+
if (missing.length)
|
|
313
|
+
return { ...expected, reason: "capability-missing", capabilities: missing };
|
|
314
|
+
}
|
|
315
|
+
return { ...expected, ...loadOutcome };
|
|
316
|
+
}
|
|
250
317
|
function isMuslFilename(file) {
|
|
251
318
|
return file.includes("libc.musl-") || file.includes("ld-musl-");
|
|
252
319
|
}
|
|
@@ -376,7 +443,10 @@ function targetFor(platform, arch, musl) {
|
|
|
376
443
|
return undefined;
|
|
377
444
|
}
|
|
378
445
|
function bundledTarget() {
|
|
379
|
-
|
|
446
|
+
const musl = isMusl();
|
|
447
|
+
selectedTarget = targetFor(process.platform, process.arch, musl);
|
|
448
|
+
targetDescription = selectedTarget ?? `${process.platform}-${process.arch}${process.platform === "linux" ? `-${musl ? "musl" : "gnu"}` : ""}`;
|
|
449
|
+
return selectedTarget;
|
|
380
450
|
}
|
|
381
451
|
function nativePackageForTarget(target) {
|
|
382
452
|
return `@openclaw/fs-safe-${target}`;
|
|
@@ -384,9 +454,13 @@ function nativePackageForTarget(target) {
|
|
|
384
454
|
function loadBundledBinding() {
|
|
385
455
|
const target = bundledTarget();
|
|
386
456
|
if (!target) {
|
|
457
|
+
loadOutcome = { reason: "unsupported-target" };
|
|
387
458
|
throw new Error(`Unsupported OS or architecture: ${process.platform}-${process.arch}`);
|
|
388
459
|
}
|
|
389
460
|
const loaded = runNativeInitialization(() => native_require(nativePackageForTarget(target)));
|
|
461
|
+
if (typeof loaded.closeOwnedFd !== "function") {
|
|
462
|
+
loadOutcome = { reason: "capability-missing", capabilities: ["closeOwnedFd"] };
|
|
463
|
+
}
|
|
390
464
|
captureNativeFdClose(loaded);
|
|
391
465
|
return loaded;
|
|
392
466
|
}
|
|
@@ -428,11 +502,19 @@ function native_getNativeBinding(...capabilities) {
|
|
|
428
502
|
attempted = true;
|
|
429
503
|
try {
|
|
430
504
|
const loaded = loadBinding();
|
|
505
|
+
if (typeof loaded.closeOwnedFd !== "function") {
|
|
506
|
+
loadOutcome = { reason: "capability-missing", capabilities: ["closeOwnedFd"] };
|
|
507
|
+
}
|
|
431
508
|
captureNativeFdClose(loaded);
|
|
432
509
|
native_binding = loaded;
|
|
510
|
+
loadOutcome = { reason: "loaded" };
|
|
433
511
|
}
|
|
434
512
|
catch (error) {
|
|
435
513
|
native_loadError = error;
|
|
514
|
+
if (loadOutcome.reason === "not-probed") {
|
|
515
|
+
selectedTarget ??= bundledTarget();
|
|
516
|
+
loadOutcome = loadFailure(error, nativePackageForTarget(selectedTarget ?? `${process.platform}-${process.arch}`));
|
|
517
|
+
}
|
|
436
518
|
}
|
|
437
519
|
}
|
|
438
520
|
if (native_binding)
|
|
@@ -453,17 +535,25 @@ function native_requireNativeBinding(...capabilities) {
|
|
|
453
535
|
}
|
|
454
536
|
return native;
|
|
455
537
|
}
|
|
456
|
-
function __setNativeLoaderForTest(loader) {
|
|
538
|
+
function __setNativeLoaderForTest(loader, resolver) {
|
|
457
539
|
native_binding = undefined;
|
|
458
540
|
native_loadError = undefined;
|
|
459
541
|
attempted = false;
|
|
460
542
|
loadBinding = loader;
|
|
543
|
+
loadOutcome = { reason: "not-probed" };
|
|
544
|
+
selectedTarget = undefined;
|
|
545
|
+
targetDescription = undefined;
|
|
546
|
+
resolvePackage = resolver ?? ((name) => native_require.resolve(name));
|
|
461
547
|
}
|
|
462
548
|
function __resetNativeLoaderForTest() {
|
|
463
549
|
native_binding = undefined;
|
|
464
550
|
native_loadError = undefined;
|
|
465
551
|
attempted = false;
|
|
466
552
|
loadBinding = loadBundledBinding;
|
|
553
|
+
loadOutcome = { reason: "not-probed" };
|
|
554
|
+
selectedTarget = undefined;
|
|
555
|
+
targetDescription = undefined;
|
|
556
|
+
resolvePackage = (name) => native_require.resolve(name);
|
|
467
557
|
}
|
|
468
558
|
|
|
469
559
|
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/file-observation.js
|
|
@@ -1629,6 +1719,47 @@ function errorCauseOptions(error) {
|
|
|
1629
1719
|
|
|
1630
1720
|
;// CONCATENATED MODULE: external "node:os"
|
|
1631
1721
|
const external_node_os_namespaceObject = __rspack_createRequire_require("node:os");
|
|
1722
|
+
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/windows-appcontainer.js
|
|
1723
|
+
|
|
1724
|
+
|
|
1725
|
+
/** The native owner caches immutable primary-token membership across Workers. */
|
|
1726
|
+
function isWindowsAppContainer(binding) {
|
|
1727
|
+
if (!binding.isWindowsAppContainer)
|
|
1728
|
+
return undefined;
|
|
1729
|
+
try {
|
|
1730
|
+
const membership = binding.isWindowsAppContainer();
|
|
1731
|
+
if (typeof membership !== "boolean")
|
|
1732
|
+
throw new Error("Invalid AppContainer membership");
|
|
1733
|
+
return membership;
|
|
1734
|
+
}
|
|
1735
|
+
catch (cause) {
|
|
1736
|
+
throw new errors_FsSafeError("permission-unverified", "Windows process token membership could not be verified", { cause });
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
function windows_appcontainer_assertWindowsHelperAllowed() {
|
|
1740
|
+
if (process.platform !== "win32")
|
|
1741
|
+
return;
|
|
1742
|
+
const binding = native_getNativeBinding();
|
|
1743
|
+
if (binding && isWindowsAppContainer(binding)) {
|
|
1744
|
+
// Current libuv can hang while creating child-process pipes in a lowbox.
|
|
1745
|
+
throw new errors_FsSafeError("helper-unavailable", "External Windows security helpers are unavailable inside an AppContainer");
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
function assertWindowsAclRemediationAllowed() {
|
|
1749
|
+
if (process.platform !== "win32")
|
|
1750
|
+
return;
|
|
1751
|
+
let binding;
|
|
1752
|
+
try {
|
|
1753
|
+
binding = getNativeBinding();
|
|
1754
|
+
}
|
|
1755
|
+
catch {
|
|
1756
|
+
return;
|
|
1757
|
+
} // Command formatting remains available without an addon.
|
|
1758
|
+
if (binding && isWindowsAppContainer(binding)) {
|
|
1759
|
+
throw new FsSafeError("helper-unavailable", "Windows ACL reset commands are unavailable inside an AppContainer");
|
|
1760
|
+
}
|
|
1761
|
+
}
|
|
1762
|
+
|
|
1632
1763
|
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/realpath.js
|
|
1633
1764
|
|
|
1634
1765
|
|
|
@@ -1636,9 +1767,41 @@ const external_node_os_namespaceObject = __rspack_createRequire_require("node:os
|
|
|
1636
1767
|
|
|
1637
1768
|
|
|
1638
1769
|
|
|
1770
|
+
|
|
1639
1771
|
const runtimePlatform = process.versions.bun ? (0,external_node_os_namespaceObject.platform)() : undefined;
|
|
1640
1772
|
const bunPosix = runtimePlatform === "darwin" || runtimePlatform === "linux" ? runtimePlatform : undefined;
|
|
1641
1773
|
function realpath_resolve(input, native) {
|
|
1774
|
+
if (native && process.platform === "win32") {
|
|
1775
|
+
try {
|
|
1776
|
+
return external_node_fs_namespaceObject.realpathSync.native(input);
|
|
1777
|
+
}
|
|
1778
|
+
catch (error) {
|
|
1779
|
+
if (error.code !== "EPERM" || error.syscall !== "realpath")
|
|
1780
|
+
throw error;
|
|
1781
|
+
let binding;
|
|
1782
|
+
try {
|
|
1783
|
+
binding = native_getNativeBinding();
|
|
1784
|
+
}
|
|
1785
|
+
catch {
|
|
1786
|
+
binding = undefined;
|
|
1787
|
+
}
|
|
1788
|
+
if (!binding || !isWindowsAppContainer(binding))
|
|
1789
|
+
throw error;
|
|
1790
|
+
if (!binding?.resolveWindowsCanonicalPath) {
|
|
1791
|
+
throw new errors_FsSafeError("helper-unavailable", "Windows canonicalization after a denied DOS-name query requires the native binding", { cause: error });
|
|
1792
|
+
}
|
|
1793
|
+
let resolved;
|
|
1794
|
+
try {
|
|
1795
|
+
resolved = binding.resolveWindowsCanonicalPath(input);
|
|
1796
|
+
}
|
|
1797
|
+
catch (cause) {
|
|
1798
|
+
throw new errors_FsSafeError("path-mismatch", "Windows canonical path cannot be verified safely", { cause });
|
|
1799
|
+
}
|
|
1800
|
+
if (resolved === null)
|
|
1801
|
+
throw error;
|
|
1802
|
+
return resolved;
|
|
1803
|
+
}
|
|
1804
|
+
}
|
|
1642
1805
|
if (bunPosix) {
|
|
1643
1806
|
// Bun 1.4.2 normalizes native path components and opens the leaf for reads.
|
|
1644
1807
|
// The Rust OS resolver preserves permissions, locks and physical spelling.
|
|
@@ -1946,6 +2109,15 @@ function assertDirectoryObservationGuardSync(guard) {
|
|
|
1946
2109
|
}
|
|
1947
2110
|
}
|
|
1948
2111
|
|
|
2112
|
+
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/native-stat-identity.js
|
|
2113
|
+
/** Native stat identities are unsigned; Node BigIntStats preserves them as signed bits. */
|
|
2114
|
+
function statIdentityFromNative(value) {
|
|
2115
|
+
return value <= 0x7fffffffffffffffn || process.versions.bun ? value : BigInt.asIntN(64, value);
|
|
2116
|
+
}
|
|
2117
|
+
function isNativeStatIdentity(value) {
|
|
2118
|
+
return typeof value === "bigint" && value >= 0n && value <= 0xffffffffffffffffn;
|
|
2119
|
+
}
|
|
2120
|
+
|
|
1949
2121
|
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/directory-receipt.js
|
|
1950
2122
|
|
|
1951
2123
|
|
|
@@ -2450,6 +2622,7 @@ function createSuppressedError(error, suppressed, message) {
|
|
|
2450
2622
|
|
|
2451
2623
|
|
|
2452
2624
|
|
|
2625
|
+
|
|
2453
2626
|
/** Shared by tree byte copying and per-file copying; never resolves the target. */
|
|
2454
2627
|
async function readCopyLinkTarget(source) {
|
|
2455
2628
|
return await promises_namespaceObject.readlink(source, { encoding: "buffer" });
|
|
@@ -2519,7 +2692,7 @@ async function copyLinkAtParent(params, input, parent, native) {
|
|
|
2519
2692
|
directory_guard_assertSyncDirectoryGuard(parent);
|
|
2520
2693
|
if (native?.binding.createCopySymlink) {
|
|
2521
2694
|
const created = native.binding.createCopySymlink(native.fd, temporaryName, input.target, params.mode, input.preserveMetadata ? input.identity.atimeNs : undefined, input.preserveMetadata ? input.identity.mtimeNs : undefined);
|
|
2522
|
-
identity = created;
|
|
2695
|
+
identity = { dev: statIdentityFromNative(created.dev), ino: statIdentityFromNative(created.ino) };
|
|
2523
2696
|
if (created.errorCode)
|
|
2524
2697
|
throw Object.assign(new Error(created.errorMessage), { code: created.errorCode });
|
|
2525
2698
|
}
|
|
@@ -3245,14 +3418,61 @@ function pinNodeDirectoryForModeSync(dirPath, options = {}) {
|
|
|
3245
3418
|
}
|
|
3246
3419
|
}
|
|
3247
3420
|
|
|
3421
|
+
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/native-guidance.js
|
|
3422
|
+
/** Shared, path-free next steps for status reports and fallback warnings. */
|
|
3423
|
+
function nativeGuidance(reason, modeSource) {
|
|
3424
|
+
switch (reason) {
|
|
3425
|
+
case "disabled": {
|
|
3426
|
+
const enable = modeSource === "programmatic configuration"
|
|
3427
|
+
? 'call configureFsSafeNative({ mode: "auto" }) or configureFsSafeNative({ mode: "require" })'
|
|
3428
|
+
: `set ${modeSource}=auto or ${modeSource}=require`;
|
|
3429
|
+
return `If native loading is intended, ${enable}; keep intentional off settings.`;
|
|
3430
|
+
}
|
|
3431
|
+
case "unsupported-target":
|
|
3432
|
+
return "Portable mode is expected on this target.";
|
|
3433
|
+
case "package-missing":
|
|
3434
|
+
return "Reinstall with optional dependencies included: npm --include=optional, or pnpm without --no-optional / optional=false. Check the lockfile and registry mirror.";
|
|
3435
|
+
case "load-failed":
|
|
3436
|
+
return "Check Node architecture, Linux libc compatibility, package dependencies, and OS code-integrity policy. Reinstalling identical bytes may not help.";
|
|
3437
|
+
case "capability-missing":
|
|
3438
|
+
return "Use matching fs-safe and platform-package versions; some targets intentionally provide only a subset of capabilities.";
|
|
3439
|
+
default:
|
|
3440
|
+
return undefined;
|
|
3441
|
+
}
|
|
3442
|
+
}
|
|
3443
|
+
|
|
3248
3444
|
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/native-fallback-warning.js
|
|
3445
|
+
|
|
3446
|
+
|
|
3447
|
+
|
|
3249
3448
|
const warnedFeatures = new Set();
|
|
3449
|
+
function fallbackReason(capabilities) {
|
|
3450
|
+
const diagnostic = getNativeFallbackDiagnostic(...capabilities);
|
|
3451
|
+
const expected = diagnostic.packageName === undefined
|
|
3452
|
+
? `No native package is published for ${diagnostic.target}.`
|
|
3453
|
+
: `Expected ${diagnostic.packageName}@${diagnostic.packageVersion}.`;
|
|
3454
|
+
const guidance = nativeGuidance(diagnostic.reason, getNativeModeSetting().source);
|
|
3455
|
+
switch (diagnostic.reason) {
|
|
3456
|
+
case "disabled":
|
|
3457
|
+
return `native support is disabled by ${diagnostic.source} (disabled). ${expected} ${guidance}`;
|
|
3458
|
+
case "unsupported-target":
|
|
3459
|
+
return `the target ${diagnostic.target} is unsupported (unsupported-target). ${expected} ${guidance}`;
|
|
3460
|
+
case "package-missing":
|
|
3461
|
+
return `the selected native package could not be resolved (package-missing). ${expected} ${guidance}`;
|
|
3462
|
+
case "load-failed":
|
|
3463
|
+
return `the native package could not be loaded (load-failed: ${diagnostic.code}). ${expected} ${guidance}`;
|
|
3464
|
+
case "capability-missing":
|
|
3465
|
+
return `the native package lacks requested functions (capability-missing: ${diagnostic.capabilities.join(", ")}). ${expected} ${guidance}`;
|
|
3466
|
+
default:
|
|
3467
|
+
return `the requested native operation is unavailable (${diagnostic.reason}). ${expected}`;
|
|
3468
|
+
}
|
|
3469
|
+
}
|
|
3250
3470
|
/** Warn once per capability, without including caller paths or native error text. */
|
|
3251
|
-
function warnNativeFallback(feature, limitation) {
|
|
3471
|
+
function warnNativeFallback(feature, limitation, ...capabilities) {
|
|
3252
3472
|
if (warnedFeatures.has(feature))
|
|
3253
3473
|
return;
|
|
3254
3474
|
warnedFeatures.add(feature);
|
|
3255
|
-
process.emitWarning(`${feature} is using its portable fallback because
|
|
3475
|
+
process.emitWarning(`${feature} is using its portable fallback because ${fallbackReason(capabilities)} ${limitation}`, { code: "FS_SAFE_NATIVE_FALLBACK", type: "FsSafeWarning" });
|
|
3256
3476
|
}
|
|
3257
3477
|
function __resetNativeFallbackWarningsForTest() {
|
|
3258
3478
|
warnedFeatures.clear();
|
|
@@ -3281,6 +3501,7 @@ function shortPath(value) {
|
|
|
3281
3501
|
|
|
3282
3502
|
|
|
3283
3503
|
|
|
3504
|
+
|
|
3284
3505
|
const execFileAsync = (0,external_node_util_namespaceObject.promisify)(external_node_child_process_namespaceObject.execFile);
|
|
3285
3506
|
const DEFAULT_PERMISSION_EXEC_TIMEOUT_MS = 30_000;
|
|
3286
3507
|
function formatPermissionErrorDetail(value) {
|
|
@@ -3458,6 +3679,7 @@ function getPermissionCommandFailure(error, command, durationMs) {
|
|
|
3458
3679
|
return { command, durationMs: Math.round(durationMs), ...detail };
|
|
3459
3680
|
}
|
|
3460
3681
|
async function executePermissionCommand(command, args, timeoutMs = DEFAULT_PERMISSION_EXEC_TIMEOUT_MS) {
|
|
3682
|
+
assertWindowsHelperAllowed();
|
|
3461
3683
|
const startedAt = performance.now();
|
|
3462
3684
|
try {
|
|
3463
3685
|
return (await execFileAsync(command, args, {
|
|
@@ -3481,6 +3703,7 @@ async function executePermissionCommand(command, args, timeoutMs = DEFAULT_PERMI
|
|
|
3481
3703
|
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/windows-security-facts.js
|
|
3482
3704
|
|
|
3483
3705
|
const SID_RE = /^s-\d+-\d+(?:-\d+)+$/;
|
|
3706
|
+
const APP_CONTAINER_SID_RE = /^s-1-15-2(?:-\d+){7,}$/;
|
|
3484
3707
|
const SYSTEM_SID = "s-1-5-18";
|
|
3485
3708
|
const ADMINISTRATORS_SID = "s-1-5-32-544";
|
|
3486
3709
|
const WORLD_SIDS = new Set([
|
|
@@ -3515,6 +3738,7 @@ function validateAce(value, allowUnknownFlags) {
|
|
|
3515
3738
|
function validateDescriptor(value, allowUnknownFlags) {
|
|
3516
3739
|
if (!record(value) || typeof value.ownerSid !== "string" || !SID_RE.test(value.ownerSid) ||
|
|
3517
3740
|
typeof value.currentUserSid !== "string" || !SID_RE.test(value.currentUserSid) ||
|
|
3741
|
+
(value.currentAppContainerSid != null && (typeof value.currentAppContainerSid !== "string" || !APP_CONTAINER_SID_RE.test(value.currentAppContainerSid))) ||
|
|
3518
3742
|
typeof value.daclPresent !== "boolean" || typeof value.isLocal !== "boolean" ||
|
|
3519
3743
|
typeof value.aceListComplete !== "boolean" || !Array.isArray(value.unsupportedAceTypes) ||
|
|
3520
3744
|
!value.unsupportedAceTypes.every(uint32) || !Array.isArray(value.aces) ||
|
|
@@ -3540,6 +3764,8 @@ function summarize(facts) {
|
|
|
3540
3764
|
let groupReadable = false;
|
|
3541
3765
|
let groupWritable = false;
|
|
3542
3766
|
const trusted = new Set([facts.currentUserSid, SYSTEM_SID, ADMINISTRATORS_SID]);
|
|
3767
|
+
if (facts.currentAppContainerSid)
|
|
3768
|
+
trusted.add(facts.currentAppContainerSid);
|
|
3543
3769
|
for (const ace of facts.aces) {
|
|
3544
3770
|
if (ace.aceType !== "allow" || ace.flags.inheritOnly || trusted.has(ace.sid))
|
|
3545
3771
|
continue;
|
|
@@ -3608,6 +3834,7 @@ function windows_security_helper_explainWindowsSecurityHelperFailure(error) {
|
|
|
3608
3834
|
|
|
3609
3835
|
|
|
3610
3836
|
|
|
3837
|
+
|
|
3611
3838
|
const MAX_OUTPUT_BYTES = 1024 * 1024;
|
|
3612
3839
|
const TERMINATION_GRACE_MS = 1_000;
|
|
3613
3840
|
const FULL_IDENTITY = /^[0-9a-f]{16}:[0-9a-f]{32}$/;
|
|
@@ -3710,6 +3937,7 @@ function explainHelperFailure(error, file) {
|
|
|
3710
3937
|
}
|
|
3711
3938
|
}
|
|
3712
3939
|
function executeSync(operation, params) {
|
|
3940
|
+
assertWindowsHelperAllowed();
|
|
3713
3941
|
const { file, args, env } = windows_security_command_command(operation, params);
|
|
3714
3942
|
const startedAt = performance.now();
|
|
3715
3943
|
const result = spawnSync(file, args, {
|
|
@@ -3782,6 +4010,7 @@ function hasUnsettledWindowsSecurityCommand(error) {
|
|
|
3782
4010
|
}
|
|
3783
4011
|
function ignoreLateError() { }
|
|
3784
4012
|
async function execute(operation, params, request) {
|
|
4013
|
+
windows_appcontainer_assertWindowsHelperAllowed();
|
|
3785
4014
|
const selected = request ?? windows_security_command_command(operation, params);
|
|
3786
4015
|
const { file, args, env, input, timeoutMs = (/* inlined export .DEFAULT_PERMISSION_EXEC_TIMEOUT_MS */30000), maxOutputBytes = MAX_OUTPUT_BYTES } = selected;
|
|
3787
4016
|
const startedAt = performance.now();
|
|
@@ -4089,17 +4318,17 @@ function creation_boundary_assertPrivateFileCreationAvailable() {
|
|
|
4089
4318
|
typeof native.verifyPrivateWindowsFile !== "function")
|
|
4090
4319
|
creation_boundary_unavailable();
|
|
4091
4320
|
}
|
|
4092
|
-
function commandFallback() {
|
|
4321
|
+
function commandFallback(capability) {
|
|
4093
4322
|
if (getFsSafeNativeConfig().mode === "require")
|
|
4094
4323
|
creation_boundary_unavailable();
|
|
4095
|
-
warnNativeFallback("windows-private-creation", "Private Windows creation
|
|
4324
|
+
warnNativeFallback("windows-private-creation", "Private Windows creation launches the packaged .NET helper for each check or creation.", capability);
|
|
4096
4325
|
}
|
|
4097
4326
|
function creationOperation(name) {
|
|
4098
4327
|
const native = native_getNativeBinding();
|
|
4099
4328
|
const operation = native?.[name];
|
|
4100
4329
|
if (typeof operation === "function")
|
|
4101
4330
|
return operation.bind(native);
|
|
4102
|
-
commandFallback();
|
|
4331
|
+
commandFallback(name);
|
|
4103
4332
|
return undefined;
|
|
4104
4333
|
}
|
|
4105
4334
|
/** Full Windows identity, with security validation when requested; no repairs. */
|
|
@@ -6428,6 +6657,7 @@ function mergeDenyMutationPolicies(defaultPolicy, callPolicy) {
|
|
|
6428
6657
|
|
|
6429
6658
|
|
|
6430
6659
|
|
|
6660
|
+
|
|
6431
6661
|
function getNativeDirectoryObservationBackend(enabled = true) {
|
|
6432
6662
|
if (!enabled)
|
|
6433
6663
|
return undefined;
|
|
@@ -6437,14 +6667,15 @@ function getNativeDirectoryObservationBackend(enabled = true) {
|
|
|
6437
6667
|
: undefined;
|
|
6438
6668
|
}
|
|
6439
6669
|
function validateNativeDirectoryObservation(observation) {
|
|
6440
|
-
if (!observation ||
|
|
6441
|
-
|
|
6670
|
+
if (!observation || !isNativeStatIdentity(observation.dev) ||
|
|
6671
|
+
!isNativeStatIdentity(observation.ino) ||
|
|
6442
6672
|
typeof observation.realPath !== "string" ||
|
|
6443
6673
|
observation.realPath.includes("\0") ||
|
|
6444
6674
|
(!external_node_path_namespaceObject.isAbsolute(observation.realPath) && !external_node_path_namespaceObject.win32.isAbsolute(observation.realPath))) {
|
|
6445
6675
|
throw new errors_FsSafeError("path-mismatch", "native directory observation is invalid");
|
|
6446
6676
|
}
|
|
6447
|
-
|
|
6677
|
+
const dev = statIdentityFromNative(observation.dev), ino = statIdentityFromNative(observation.ino);
|
|
6678
|
+
return dev === observation.dev && ino === observation.ino ? observation : { ...observation, dev, ino };
|
|
6448
6679
|
}
|
|
6449
6680
|
/** Exact identity, type, and canonical path captured from one retained handle. */
|
|
6450
6681
|
function inspectNativeDirectoryObservation(backend, pathname, expected, platform = process.platform) {
|
|
@@ -6466,6 +6697,7 @@ function isNativeDirectoryObservationGuard(guard) {
|
|
|
6466
6697
|
|
|
6467
6698
|
|
|
6468
6699
|
|
|
6700
|
+
|
|
6469
6701
|
class NativePolicyDirectoryMismatch extends errors_FsSafeError {
|
|
6470
6702
|
constructor(cause) {
|
|
6471
6703
|
super("path-mismatch", "staging directory pathname changed", { cause });
|
|
@@ -6504,8 +6736,8 @@ function native_policy_directory_observation_nativePolicyDirectoryObserver(bindi
|
|
|
6504
6736
|
}
|
|
6505
6737
|
if (getFsSafeNativeConfig().mode !== mode)
|
|
6506
6738
|
return undefined;
|
|
6507
|
-
if (!observed ||
|
|
6508
|
-
|
|
6739
|
+
if (!observed || !isNativeStatIdentity(observed.dev) ||
|
|
6740
|
+
!isNativeStatIdentity(observed.ino) ||
|
|
6509
6741
|
typeof observed.mode !== "bigint" || observed.mode < 0n || observed.mode > 0xffffffffn ||
|
|
6510
6742
|
typeof observed.nlink !== "bigint" || observed.nlink < 0n || observed.nlink > 0xffffffffffffffffn ||
|
|
6511
6743
|
typeof observed.realPath !== "string" || observed.realPath.includes("\0") ||
|
|
@@ -6518,7 +6750,7 @@ function native_policy_directory_observation_nativePolicyDirectoryObserver(bindi
|
|
|
6518
6750
|
return Object.freeze({
|
|
6519
6751
|
canonicalPath: observed.realPath,
|
|
6520
6752
|
identity: Object.freeze({
|
|
6521
|
-
dev: observed.dev, ino: observed.ino, mode: observed.mode, nlink: observed.nlink,
|
|
6753
|
+
dev: statIdentityFromNative(observed.dev), ino: statIdentityFromNative(observed.ino), mode: observed.mode, nlink: observed.nlink,
|
|
6522
6754
|
}),
|
|
6523
6755
|
});
|
|
6524
6756
|
};
|
|
@@ -9308,6 +9540,64 @@ function __setFsSafeTestHooksForTest(hooks) {
|
|
|
9308
9540
|
test_hooks_fsSafeTestHooks = hooks;
|
|
9309
9541
|
}
|
|
9310
9542
|
|
|
9543
|
+
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/root-native-creation-path.js
|
|
9544
|
+
|
|
9545
|
+
|
|
9546
|
+
|
|
9547
|
+
|
|
9548
|
+
|
|
9549
|
+
|
|
9550
|
+
|
|
9551
|
+
|
|
9552
|
+
|
|
9553
|
+
function existingCreationParent(params) {
|
|
9554
|
+
if (params.private || params.policy || params.assertBeforeMutation !== undefined ||
|
|
9555
|
+
getFsSafeTestHooks()?.beforeRootFallbackMutation || !params.originalPath ||
|
|
9556
|
+
params.directory !== external_node_path_namespaceObject.dirname(params.target))
|
|
9557
|
+
return undefined;
|
|
9558
|
+
const segments = params.originalPath.split(external_node_path_namespaceObject.sep === "\\" ? /[\\/]/ : "/");
|
|
9559
|
+
if (segments.some(segment => !isSafePathSegment(segment, { allowDotPrefix: true }) || segment.endsWith(".")) ||
|
|
9560
|
+
external_node_path_namespaceObject.join(params.root.rootReal, ...segments) !== params.target)
|
|
9561
|
+
return undefined;
|
|
9562
|
+
let rootStat;
|
|
9563
|
+
root_context_assertRootIdentityCurrentSync(params.root, stat => { rootStat = stat; });
|
|
9564
|
+
try {
|
|
9565
|
+
const identity = directory_guard_inspectDirectoryIdentitySync(params.directory, undefined, params.directory === params.root.rootReal ? rootStat : undefined);
|
|
9566
|
+
if (realpath_realpathSync.native(windows_path_alias_pathForWindowsFilesystem(params.directory)) !== params.directory)
|
|
9567
|
+
return undefined;
|
|
9568
|
+
return {
|
|
9569
|
+
path: params.directory, identity,
|
|
9570
|
+
relative: external_node_path_namespaceObject.relative(params.root.rootReal, params.directory).split(external_node_path_namespaceObject.sep).join("/"),
|
|
9571
|
+
flags: (nodeDirectorySearchOnlyFlags()?.flags ?? external_node_fs_namespaceObject.constants.O_RDONLY) |
|
|
9572
|
+
(external_node_fs_namespaceObject.constants.O_DIRECTORY ?? 0) | (external_node_fs_namespaceObject.constants.O_NOFOLLOW ?? 0),
|
|
9573
|
+
};
|
|
9574
|
+
}
|
|
9575
|
+
catch {
|
|
9576
|
+
return undefined;
|
|
9577
|
+
}
|
|
9578
|
+
}
|
|
9579
|
+
function probeNativeCreationPath(root, relativePath) {
|
|
9580
|
+
if (typeof relativePath !== "string")
|
|
9581
|
+
return undefined;
|
|
9582
|
+
const segments = relativePath.split(external_node_path_namespaceObject.sep === "\\" ? /[\\/]/ : "/");
|
|
9583
|
+
if (segments.some(segment => !isSafePathSegment(segment, { allowDotPrefix: true }) || segment.endsWith(".")))
|
|
9584
|
+
return undefined;
|
|
9585
|
+
const target = external_node_path_namespaceObject.join(root.rootReal, ...segments);
|
|
9586
|
+
root_context_assertRootIdentityCurrentSync(root);
|
|
9587
|
+
try {
|
|
9588
|
+
if (external_node_fs_namespaceObject.lstatSync(windows_path_alias_pathForWindowsFilesystem(target), { throwIfNoEntry: false }))
|
|
9589
|
+
return undefined;
|
|
9590
|
+
}
|
|
9591
|
+
catch {
|
|
9592
|
+
return undefined;
|
|
9593
|
+
}
|
|
9594
|
+
const parent = existingCreationParent({ root, target, directory: external_node_path_namespaceObject.dirname(target), mkdir: true,
|
|
9595
|
+
originalPath: relativePath, resolveCurrent: async () => target });
|
|
9596
|
+
if (!parent)
|
|
9597
|
+
return undefined;
|
|
9598
|
+
return { rootReal: root.rootReal, rootWithSep: root.rootWithSep, resolved: target, parent };
|
|
9599
|
+
}
|
|
9600
|
+
|
|
9311
9601
|
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/root-create-native.js
|
|
9312
9602
|
var root_create_native_addDisposableResource = (undefined && undefined.__addDisposableResource) || function (env, value, async) {
|
|
9313
9603
|
if (value !== null && value !== void 0) {
|
|
@@ -9385,6 +9675,8 @@ var root_create_native_disposeResources = (undefined && undefined.__disposeResou
|
|
|
9385
9675
|
|
|
9386
9676
|
|
|
9387
9677
|
|
|
9678
|
+
|
|
9679
|
+
|
|
9388
9680
|
|
|
9389
9681
|
|
|
9390
9682
|
|
|
@@ -9394,6 +9686,10 @@ function rootWriteQueueKey(root, relativePath) {
|
|
|
9394
9686
|
function buildAtomicWriteTempPath(targetPath) {
|
|
9395
9687
|
return external_node_path_namespaceObject.join(external_node_path_namespaceObject.dirname(targetPath), `.fs-safe-${(0,external_node_crypto_namespaceObject.randomUUID)()}.tmp`);
|
|
9396
9688
|
}
|
|
9689
|
+
const nativeCreateCollisions = new WeakSet();
|
|
9690
|
+
function isNativeCreateCollision(error) {
|
|
9691
|
+
return typeof error === "object" && error !== null && nativeCreateCollisions.has(error);
|
|
9692
|
+
}
|
|
9397
9693
|
function root_create_native_unavailable() {
|
|
9398
9694
|
throw new errors_FsSafeError("helper-unavailable", "native confined creation is unavailable");
|
|
9399
9695
|
}
|
|
@@ -9401,6 +9697,60 @@ async function withNativeDirectory(params, operation, discard) {
|
|
|
9401
9697
|
const binding = native_getNativeBinding("openBeneath", "mkdirChildBeneath");
|
|
9402
9698
|
if (!binding?.openBeneath || !binding.mkdirChildBeneath || (params.private && process.platform === "win32"))
|
|
9403
9699
|
return root_create_native_unavailable();
|
|
9700
|
+
const existing = params.selectedParent ?? existingCreationParent(params);
|
|
9701
|
+
if (existing) {
|
|
9702
|
+
let pending;
|
|
9703
|
+
try {
|
|
9704
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
9705
|
+
try {
|
|
9706
|
+
const rootOwner = root_create_native_addDisposableResource(env_1, openExactNativeRootSync(binding, {
|
|
9707
|
+
rootPath: params.root.rootReal, rootIdentity: params.root.rootIdentity,
|
|
9708
|
+
}), false);
|
|
9709
|
+
const close = captureNativeFdClose(binding);
|
|
9710
|
+
const borrowed = existing.path === params.root.rootReal;
|
|
9711
|
+
const fd = borrowed ? rootOwner.fd : binding.openBeneath(rootOwner.fd, existing.relative, existing.flags).fd;
|
|
9712
|
+
const parentOwner = root_create_native_addDisposableResource(env_1, { [Symbol.dispose]() { if (!borrowed)
|
|
9713
|
+
close(fd); } }, false);
|
|
9714
|
+
strict_file_identity_inspectFileIdentitySync(() => borrowed ? rootOwner.stat : external_node_fs_namespaceObject.fstatSync(fd, { bigint: true }), existing.identity);
|
|
9715
|
+
verifyMkdirDirectory(binding, fd, existing.path);
|
|
9716
|
+
const guard = { dir: existing.path, realPath: existing.path, stat: existing.identity };
|
|
9717
|
+
const assertCurrent = () => {
|
|
9718
|
+
let currentRoot;
|
|
9719
|
+
root_context_assertRootIdentityCurrentSync(params.root, stat => { currentRoot = stat; });
|
|
9720
|
+
if (borrowed) {
|
|
9721
|
+
// Root and parent are the same name in this synchronous fence.
|
|
9722
|
+
directory_guard_inspectDirectoryIdentitySync(existing.path, existing.identity, currentRoot);
|
|
9723
|
+
if (realpath_realpathSync.native(windows_path_alias_pathForWindowsFilesystem(existing.path)) !== existing.path) {
|
|
9724
|
+
throw new errors_FsSafeError("path-mismatch", "directory changed during operation");
|
|
9725
|
+
}
|
|
9726
|
+
}
|
|
9727
|
+
else {
|
|
9728
|
+
directory_guard_assertSyncDirectoryGuard(guard);
|
|
9729
|
+
}
|
|
9730
|
+
};
|
|
9731
|
+
pending = { value: await operation(binding, fd, assertCurrent) };
|
|
9732
|
+
return pending.value;
|
|
9733
|
+
}
|
|
9734
|
+
catch (e_1) {
|
|
9735
|
+
env_1.error = e_1;
|
|
9736
|
+
env_1.hasError = true;
|
|
9737
|
+
}
|
|
9738
|
+
finally {
|
|
9739
|
+
root_create_native_disposeResources(env_1);
|
|
9740
|
+
}
|
|
9741
|
+
}
|
|
9742
|
+
catch (error) {
|
|
9743
|
+
if (pending && discard) {
|
|
9744
|
+
try {
|
|
9745
|
+
await discard(pending.value);
|
|
9746
|
+
}
|
|
9747
|
+
catch (cleanupError) {
|
|
9748
|
+
throw createSuppressedError(cleanupError, error, "creation handoff and cleanup failed");
|
|
9749
|
+
}
|
|
9750
|
+
}
|
|
9751
|
+
throw error;
|
|
9752
|
+
}
|
|
9753
|
+
}
|
|
9404
9754
|
const directoryTarget = params.directory === params.target;
|
|
9405
9755
|
const canonicalTarget = async (target) => directoryTarget
|
|
9406
9756
|
? await resolvePathViaExistingAncestor(target)
|
|
@@ -9417,14 +9767,14 @@ async function withNativeDirectory(params, operation, discard) {
|
|
|
9417
9767
|
const close = captureNativeFdClose(binding);
|
|
9418
9768
|
let pending;
|
|
9419
9769
|
try {
|
|
9420
|
-
const
|
|
9770
|
+
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
9421
9771
|
try {
|
|
9422
9772
|
const admitted = await openNativeRootAdmission(binding, {
|
|
9423
9773
|
rootPath: params.root.rootReal, rootIdentity: params.root.rootIdentity, operation: "create", reportCloseErrors: true, searchOnly: true,
|
|
9424
9774
|
});
|
|
9425
|
-
const rootOwner = root_create_native_addDisposableResource(
|
|
9775
|
+
const rootOwner = root_create_native_addDisposableResource(env_2, admitted.root, true);
|
|
9426
9776
|
const descriptors = [];
|
|
9427
|
-
const directoryOwner = root_create_native_addDisposableResource(
|
|
9777
|
+
const directoryOwner = root_create_native_addDisposableResource(env_2, { [Symbol.dispose]() {
|
|
9428
9778
|
const errors = [];
|
|
9429
9779
|
for (const fd of descriptors.reverse())
|
|
9430
9780
|
try {
|
|
@@ -9522,12 +9872,12 @@ async function withNativeDirectory(params, operation, discard) {
|
|
|
9522
9872
|
pending = { value: await operation(binding, current, assertCurrent) };
|
|
9523
9873
|
return pending.value;
|
|
9524
9874
|
}
|
|
9525
|
-
catch (
|
|
9526
|
-
|
|
9527
|
-
|
|
9875
|
+
catch (e_2) {
|
|
9876
|
+
env_2.error = e_2;
|
|
9877
|
+
env_2.hasError = true;
|
|
9528
9878
|
}
|
|
9529
9879
|
finally {
|
|
9530
|
-
const result_1 = root_create_native_disposeResources(
|
|
9880
|
+
const result_1 = root_create_native_disposeResources(env_2);
|
|
9531
9881
|
if (result_1)
|
|
9532
9882
|
await result_1;
|
|
9533
9883
|
}
|
|
@@ -9606,33 +9956,77 @@ function verifyMkdirDirectory(binding, fd, pathname) {
|
|
|
9606
9956
|
describePolicyStagedDirectory(fd, pathname);
|
|
9607
9957
|
}
|
|
9608
9958
|
function ensureNativeRootCurrent(root) {
|
|
9609
|
-
|
|
9959
|
+
root_context_assertRootIdentityCurrentSync(root);
|
|
9960
|
+
const binding = native_getNativeBinding("openBeneath", "mkdirChildBeneath");
|
|
9961
|
+
if (!binding?.openBeneath || !binding.mkdirChildBeneath)
|
|
9962
|
+
return root_create_native_unavailable();
|
|
9963
|
+
if (binding.verifyRootDirectory) {
|
|
9964
|
+
const closeNative = captureNativeFdClose(binding);
|
|
9965
|
+
const failure = binding.verifyRootDirectory(root.rootReal, root.rootIdentity.dev, root.rootIdentity.ino);
|
|
9966
|
+
if (failure === null)
|
|
9967
|
+
return;
|
|
9968
|
+
if (failure?.fallbackFd !== undefined && failure.fallbackFd !== null) {
|
|
9969
|
+
const env_3 = { stack: [], error: void 0, hasError: false };
|
|
9970
|
+
try {
|
|
9971
|
+
const fd = failure.fallbackFd;
|
|
9972
|
+
if (!Number.isInteger(fd) || fd < 0)
|
|
9973
|
+
throw new errors_FsSafeError("helper-failed", "invalid root fallback descriptor");
|
|
9974
|
+
const owner = root_create_native_addDisposableResource(env_3, { [Symbol.dispose]() { closeNative(fd); } }, false);
|
|
9975
|
+
if (failure.errorCode || failure.closeErrorCode)
|
|
9976
|
+
throw new errors_FsSafeError("helper-failed", "invalid root verification result");
|
|
9977
|
+
ensureNativeRootCurrentLegacy(root, binding);
|
|
9978
|
+
return;
|
|
9979
|
+
}
|
|
9980
|
+
catch (e_3) {
|
|
9981
|
+
env_3.error = e_3;
|
|
9982
|
+
env_3.hasError = true;
|
|
9983
|
+
}
|
|
9984
|
+
finally {
|
|
9985
|
+
root_create_native_disposeResources(env_3);
|
|
9986
|
+
}
|
|
9987
|
+
}
|
|
9988
|
+
const error = failure?.errorCode ? rootVerificationError(failure.errorCode, failure.errorMessage, failure.errorErrno) : undefined;
|
|
9989
|
+
const closeError = failure?.closeErrorCode ? Object.assign(new Error(failure.closeErrorMessage), {
|
|
9990
|
+
code: failure.closeErrorCode,
|
|
9991
|
+
...(typeof failure.closeErrorErrno === "number" ? { errno: failure.closeErrorErrno } : {}),
|
|
9992
|
+
}) : undefined;
|
|
9993
|
+
if (error && closeError)
|
|
9994
|
+
throw createSuppressedError(closeError, error, "root verification and close failed");
|
|
9995
|
+
if (error || closeError)
|
|
9996
|
+
throw error ?? closeError;
|
|
9997
|
+
throw new errors_FsSafeError("helper-failed", "invalid root verification result");
|
|
9998
|
+
}
|
|
9999
|
+
ensureNativeRootCurrentLegacy(root, binding);
|
|
10000
|
+
}
|
|
10001
|
+
function rootVerificationError(code, message, errno) {
|
|
10002
|
+
const error = Object.assign(new Error(message), { code, ...(typeof errno === "number" ? { errno } : {}) });
|
|
10003
|
+
return code === "path-mismatch" || code === "OBSERVATION_REDIRECTED"
|
|
10004
|
+
? new errors_FsSafeError("path-mismatch", "root identity changed during verification", { cause: error }) : error;
|
|
10005
|
+
}
|
|
10006
|
+
function ensureNativeRootCurrentLegacy(root, binding) {
|
|
10007
|
+
const env_4 = { stack: [], error: void 0, hasError: false };
|
|
9610
10008
|
try {
|
|
9611
|
-
|
|
9612
|
-
const binding = native_getNativeBinding("openBeneath", "mkdirChildBeneath");
|
|
9613
|
-
if (!binding?.openBeneath || !binding.mkdirChildBeneath)
|
|
9614
|
-
return root_create_native_unavailable();
|
|
9615
|
-
const rootOwner = root_create_native_addDisposableResource(env_2, openExactNativeRootSync(binding, {
|
|
10009
|
+
const rootOwner = root_create_native_addDisposableResource(env_4, openExactNativeRootSync(binding, {
|
|
9616
10010
|
rootPath: root.rootReal, rootIdentity: root.rootIdentity,
|
|
9617
10011
|
}), false);
|
|
9618
10012
|
verifyMkdirDirectory(binding, rootOwner.fd, root.rootReal);
|
|
9619
10013
|
root_context_assertRootIdentityCurrentSync(root);
|
|
9620
10014
|
}
|
|
9621
|
-
catch (
|
|
9622
|
-
|
|
9623
|
-
|
|
10015
|
+
catch (e_4) {
|
|
10016
|
+
env_4.error = e_4;
|
|
10017
|
+
env_4.hasError = true;
|
|
9624
10018
|
}
|
|
9625
10019
|
finally {
|
|
9626
|
-
root_create_native_disposeResources(
|
|
10020
|
+
root_create_native_disposeResources(env_4);
|
|
9627
10021
|
}
|
|
9628
10022
|
}
|
|
9629
10023
|
function mkdirNativeRootChild(params) {
|
|
9630
|
-
const
|
|
10024
|
+
const env_5 = { stack: [], error: void 0, hasError: false };
|
|
9631
10025
|
try {
|
|
9632
10026
|
const binding = native_getNativeBinding("openBeneath", "mkdirChildBeneath");
|
|
9633
10027
|
if (!binding?.openBeneath || !binding.mkdirChildBeneath)
|
|
9634
10028
|
return root_create_native_unavailable();
|
|
9635
|
-
const rootOwner = root_create_native_addDisposableResource(
|
|
10029
|
+
const rootOwner = root_create_native_addDisposableResource(env_5, openExactNativeRootSync(binding, {
|
|
9636
10030
|
rootPath: params.root.rootReal, rootIdentity: params.root.rootIdentity,
|
|
9637
10031
|
}), false);
|
|
9638
10032
|
verifyMkdirDirectory(binding, rootOwner.fd, params.root.rootReal);
|
|
@@ -9645,17 +10039,17 @@ function mkdirNativeRootChild(params) {
|
|
|
9645
10039
|
? binding.mkdirOpenChildBeneath(rootOwner.fd, name, 0o777, flags).fd
|
|
9646
10040
|
: (binding.mkdirChildBeneath(rootOwner.fd, name, 0o777), binding.openBeneath(rootOwner.fd, name, flags).fd);
|
|
9647
10041
|
const close = captureNativeFdClose(binding);
|
|
9648
|
-
const childOwner = root_create_native_addDisposableResource(
|
|
10042
|
+
const childOwner = root_create_native_addDisposableResource(env_5, { [Symbol.dispose]() { close(child); } }, false);
|
|
9649
10043
|
root_context_assertRootIdentityCurrentSync(params.root);
|
|
9650
10044
|
verifyMkdirDirectory(binding, child, params.target);
|
|
9651
10045
|
verifyMkdirDirectory(binding, rootOwner.fd, params.root.rootReal);
|
|
9652
10046
|
}
|
|
9653
|
-
catch (
|
|
9654
|
-
|
|
9655
|
-
|
|
10047
|
+
catch (e_5) {
|
|
10048
|
+
env_5.error = e_5;
|
|
10049
|
+
env_5.hasError = true;
|
|
9656
10050
|
}
|
|
9657
10051
|
finally {
|
|
9658
|
-
root_create_native_disposeResources(
|
|
10052
|
+
root_create_native_disposeResources(env_5);
|
|
9659
10053
|
}
|
|
9660
10054
|
}
|
|
9661
10055
|
async function tryOpenCreateRootNative(params) {
|
|
@@ -9677,7 +10071,7 @@ async function tryOpenCreateRootNative(params) {
|
|
|
9677
10071
|
if (creationMode() === undefined)
|
|
9678
10072
|
return root_create_native_unavailable();
|
|
9679
10073
|
return await withNativeDirectory(params, async (binding, parent, assertCurrent) => {
|
|
9680
|
-
const
|
|
10074
|
+
const env_6 = { stack: [], error: void 0, hasError: false };
|
|
9681
10075
|
try {
|
|
9682
10076
|
params.assertBeforeMutation?.();
|
|
9683
10077
|
assertCurrent();
|
|
@@ -9687,13 +10081,21 @@ async function tryOpenCreateRootNative(params) {
|
|
|
9687
10081
|
// Native creation owns the only O_CREAT dispatch. The subsequent Node open
|
|
9688
10082
|
// carries neither O_CREAT nor O_TRUNC and must match this retained inode.
|
|
9689
10083
|
const close = captureNativeFdClose(binding);
|
|
9690
|
-
|
|
10084
|
+
let fd;
|
|
10085
|
+
try {
|
|
10086
|
+
fd = binding.openCreateBeneath(parent, external_node_path_namespaceObject.basename(params.target), params.flags, params.mode & 0o7777);
|
|
10087
|
+
}
|
|
10088
|
+
catch (error) {
|
|
10089
|
+
if (hasNodeErrorCode(error, "EEXIST") && typeof error === "object" && error !== null)
|
|
10090
|
+
nativeCreateCollisions.add(error);
|
|
10091
|
+
throw error;
|
|
10092
|
+
}
|
|
9691
10093
|
let rawOpen = true;
|
|
9692
10094
|
const closeRaw = () => { if (rawOpen) {
|
|
9693
10095
|
rawOpen = false;
|
|
9694
10096
|
close(fd);
|
|
9695
10097
|
} };
|
|
9696
|
-
const owner = root_create_native_addDisposableResource(
|
|
10098
|
+
const owner = root_create_native_addDisposableResource(env_6, { [Symbol.dispose]: closeRaw }, false);
|
|
9697
10099
|
try {
|
|
9698
10100
|
const identity = strict_file_identity_inspectFileIdentitySync(() => external_node_fs_namespaceObject.fstatSync(fd, { bigint: true }));
|
|
9699
10101
|
if (!identity.isFile() || identity.nlink !== 1n)
|
|
@@ -9747,26 +10149,26 @@ async function tryOpenCreateRootNative(params) {
|
|
|
9747
10149
|
throw error;
|
|
9748
10150
|
}
|
|
9749
10151
|
}
|
|
9750
|
-
catch (
|
|
9751
|
-
|
|
9752
|
-
|
|
10152
|
+
catch (e_6) {
|
|
10153
|
+
env_6.error = e_6;
|
|
10154
|
+
env_6.hasError = true;
|
|
9753
10155
|
}
|
|
9754
10156
|
finally {
|
|
9755
|
-
root_create_native_disposeResources(
|
|
10157
|
+
root_create_native_disposeResources(env_6);
|
|
9756
10158
|
}
|
|
9757
10159
|
}, async (created) => {
|
|
9758
|
-
const
|
|
10160
|
+
const env_7 = { stack: [], error: void 0, hasError: false };
|
|
9759
10161
|
try {
|
|
9760
|
-
const handle = root_create_native_addDisposableResource(
|
|
9761
|
-
const parent = root_create_native_addDisposableResource(
|
|
10162
|
+
const handle = root_create_native_addDisposableResource(env_7, created.handle, true);
|
|
10163
|
+
const parent = root_create_native_addDisposableResource(env_7, { [Symbol.dispose]: created.releaseCreationParent }, false);
|
|
9762
10164
|
await created.cleanupCreated();
|
|
9763
10165
|
}
|
|
9764
|
-
catch (
|
|
9765
|
-
|
|
9766
|
-
|
|
10166
|
+
catch (e_7) {
|
|
10167
|
+
env_7.error = e_7;
|
|
10168
|
+
env_7.hasError = true;
|
|
9767
10169
|
}
|
|
9768
10170
|
finally {
|
|
9769
|
-
const result_2 = root_create_native_disposeResources(
|
|
10171
|
+
const result_2 = root_create_native_disposeResources(env_7);
|
|
9770
10172
|
if (result_2)
|
|
9771
10173
|
await result_2;
|
|
9772
10174
|
}
|
|
@@ -10502,7 +10904,7 @@ function privateDirectoryBackend() {
|
|
|
10502
10904
|
if (getFsSafeNativeConfig().mode === "require") {
|
|
10503
10905
|
throw new errors_FsSafeError("helper-unavailable", "private directory creation requires an up-to-date native parent identity capability");
|
|
10504
10906
|
}
|
|
10505
|
-
warnNativeFallback("windows-private-directory", "Private Windows directory creation
|
|
10907
|
+
warnNativeFallback("windows-private-directory", "Private Windows directory creation launches the packaged .NET helper for each check or creation.", "createPrivateDirectoryWithParentIdentity");
|
|
10506
10908
|
return undefined;
|
|
10507
10909
|
}
|
|
10508
10910
|
async function createDirectory(targetPath, options = {}) {
|
|
@@ -16312,6 +16714,247 @@ async function read_opened_file_readOpenedFileSafely(params) {
|
|
|
16312
16714
|
};
|
|
16313
16715
|
}
|
|
16314
16716
|
|
|
16717
|
+
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/root-mkdir-native.js
|
|
16718
|
+
var root_mkdir_native_addDisposableResource = (undefined && undefined.__addDisposableResource) || function (env, value, async) {
|
|
16719
|
+
if (value !== null && value !== void 0) {
|
|
16720
|
+
if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
|
|
16721
|
+
var dispose, inner;
|
|
16722
|
+
if (async) {
|
|
16723
|
+
if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
|
|
16724
|
+
dispose = value[Symbol.asyncDispose];
|
|
16725
|
+
}
|
|
16726
|
+
if (dispose === void 0) {
|
|
16727
|
+
if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
|
|
16728
|
+
dispose = value[Symbol.dispose];
|
|
16729
|
+
if (async) inner = dispose;
|
|
16730
|
+
}
|
|
16731
|
+
if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
|
|
16732
|
+
if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
|
|
16733
|
+
env.stack.push({ value: value, dispose: dispose, async: async });
|
|
16734
|
+
}
|
|
16735
|
+
else if (async) {
|
|
16736
|
+
env.stack.push({ async: true });
|
|
16737
|
+
}
|
|
16738
|
+
return value;
|
|
16739
|
+
};
|
|
16740
|
+
var root_mkdir_native_disposeResources = (undefined && undefined.__disposeResources) || (function (SuppressedError) {
|
|
16741
|
+
return function (env) {
|
|
16742
|
+
function fail(e) {
|
|
16743
|
+
env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
|
|
16744
|
+
env.hasError = true;
|
|
16745
|
+
}
|
|
16746
|
+
var r, s = 0;
|
|
16747
|
+
function next() {
|
|
16748
|
+
while (r = env.stack.pop()) {
|
|
16749
|
+
try {
|
|
16750
|
+
if (!r.async && s === 1) return s = 0, env.stack.push(r), Promise.resolve().then(next);
|
|
16751
|
+
if (r.dispose) {
|
|
16752
|
+
var result = r.dispose.call(r.value);
|
|
16753
|
+
if (r.async) return s |= 2, Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
|
|
16754
|
+
}
|
|
16755
|
+
else s |= 1;
|
|
16756
|
+
}
|
|
16757
|
+
catch (e) {
|
|
16758
|
+
fail(e);
|
|
16759
|
+
}
|
|
16760
|
+
}
|
|
16761
|
+
if (s === 1) return env.hasError ? Promise.reject(env.error) : Promise.resolve();
|
|
16762
|
+
if (env.hasError) throw env.error;
|
|
16763
|
+
}
|
|
16764
|
+
return next();
|
|
16765
|
+
};
|
|
16766
|
+
})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
16767
|
+
var e = new Error(message);
|
|
16768
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
16769
|
+
});
|
|
16770
|
+
|
|
16771
|
+
|
|
16772
|
+
|
|
16773
|
+
|
|
16774
|
+
|
|
16775
|
+
|
|
16776
|
+
|
|
16777
|
+
|
|
16778
|
+
|
|
16779
|
+
|
|
16780
|
+
|
|
16781
|
+
|
|
16782
|
+
|
|
16783
|
+
|
|
16784
|
+
|
|
16785
|
+
|
|
16786
|
+
|
|
16787
|
+
function tryMkdirNativeParents(root, relativePath) {
|
|
16788
|
+
try {
|
|
16789
|
+
return mkdirOrdinaryNativeParents(root, relativePath);
|
|
16790
|
+
}
|
|
16791
|
+
catch (error) {
|
|
16792
|
+
if (hasNodeErrorCode(error, "ENOTDIR"))
|
|
16793
|
+
throw root_errors_directoryComponentNotDirectoryError(error);
|
|
16794
|
+
throw error;
|
|
16795
|
+
}
|
|
16796
|
+
}
|
|
16797
|
+
function mkdirOrdinaryNativeParents(root, relativePath) {
|
|
16798
|
+
if (getFsSafeTestHooks()?.beforeRootFallbackMutation)
|
|
16799
|
+
return false;
|
|
16800
|
+
const segments = relativePath.split(external_node_path_namespaceObject.sep === "\\" ? /[\\/]/ : "/");
|
|
16801
|
+
if (segments.length < 2 || segments.some(segment => !isSafePathSegment(segment, { allowDotPrefix: true }) || segment.endsWith(".")))
|
|
16802
|
+
return false;
|
|
16803
|
+
let rootStat;
|
|
16804
|
+
root_context_assertRootIdentityCurrentSync(root, stat => { rootStat = stat; });
|
|
16805
|
+
const target = external_node_path_namespaceObject.join(root.rootReal, ...segments);
|
|
16806
|
+
const parentPath = external_node_path_namespaceObject.dirname(target);
|
|
16807
|
+
try {
|
|
16808
|
+
const child = external_node_fs_namespaceObject.lstatSync(windows_path_alias_pathForWindowsFilesystem(target), { throwIfNoEntry: false });
|
|
16809
|
+
if (child && (!child.isDirectory() || realpath_realpathSync.native(windows_path_alias_pathForWindowsFilesystem(target)) !== target))
|
|
16810
|
+
return false;
|
|
16811
|
+
}
|
|
16812
|
+
catch {
|
|
16813
|
+
return false;
|
|
16814
|
+
}
|
|
16815
|
+
let parentIdentity;
|
|
16816
|
+
try {
|
|
16817
|
+
parentIdentity = directory_guard_inspectDirectoryIdentitySync(parentPath);
|
|
16818
|
+
}
|
|
16819
|
+
catch (error) {
|
|
16820
|
+
// Reuse this exact Root snapshot and failed parent observation without an
|
|
16821
|
+
// intervening await. All opened ancestors still receive fresh native fences.
|
|
16822
|
+
return hasNodeErrorCode(error, "ENOENT") ? mkdirMissingParents(root, segments, rootStat) : false;
|
|
16823
|
+
}
|
|
16824
|
+
try {
|
|
16825
|
+
if (realpath_realpathSync.native(windows_path_alias_pathForWindowsFilesystem(parentPath)) !== parentPath)
|
|
16826
|
+
return false;
|
|
16827
|
+
}
|
|
16828
|
+
catch {
|
|
16829
|
+
return false;
|
|
16830
|
+
}
|
|
16831
|
+
return mkdirExistingParent(root, segments, parentIdentity);
|
|
16832
|
+
}
|
|
16833
|
+
/** Ordinary missing suffixes need no policy callbacks or repeated path resolution. */
|
|
16834
|
+
function mkdirMissingParents(root, segments, rootStat) {
|
|
16835
|
+
const binding = native_getNativeBinding("openBeneath", "mkdirChildBeneath");
|
|
16836
|
+
if (!binding?.openBeneath || !binding.mkdirOpenChildBeneath)
|
|
16837
|
+
return false;
|
|
16838
|
+
let parentDepth = segments.length - 2;
|
|
16839
|
+
let parentPath;
|
|
16840
|
+
let parentIdentity;
|
|
16841
|
+
for (;;) {
|
|
16842
|
+
parentPath = external_node_path_namespaceObject.join(root.rootReal, ...segments.slice(0, parentDepth));
|
|
16843
|
+
try {
|
|
16844
|
+
parentIdentity = directory_guard_inspectDirectoryIdentitySync(parentPath, undefined, parentDepth === 0 ? rootStat : undefined);
|
|
16845
|
+
if (realpath_realpathSync.native(windows_path_alias_pathForWindowsFilesystem(parentPath)) !== parentPath)
|
|
16846
|
+
return false;
|
|
16847
|
+
break;
|
|
16848
|
+
}
|
|
16849
|
+
catch (error) {
|
|
16850
|
+
if (!hasNodeErrorCode(error, "ENOENT") || parentDepth === 0)
|
|
16851
|
+
return false;
|
|
16852
|
+
parentDepth--;
|
|
16853
|
+
}
|
|
16854
|
+
}
|
|
16855
|
+
try {
|
|
16856
|
+
const env_1 = { stack: [], error: void 0, hasError: false };
|
|
16857
|
+
try {
|
|
16858
|
+
const rootOwner = root_mkdir_native_addDisposableResource(env_1, openExactNativeRootSync(binding, {
|
|
16859
|
+
rootPath: root.rootReal, rootIdentity: root.rootIdentity,
|
|
16860
|
+
}), false);
|
|
16861
|
+
const close = captureNativeFdClose(binding);
|
|
16862
|
+
const directories = [];
|
|
16863
|
+
const directoryOwner = root_mkdir_native_addDisposableResource(env_1, { [Symbol.dispose]() {
|
|
16864
|
+
const errors = [];
|
|
16865
|
+
for (const directory of directories.toReversed()) {
|
|
16866
|
+
try {
|
|
16867
|
+
close(directory.fd);
|
|
16868
|
+
}
|
|
16869
|
+
catch (error) {
|
|
16870
|
+
errors.push(error);
|
|
16871
|
+
}
|
|
16872
|
+
}
|
|
16873
|
+
if (errors.length)
|
|
16874
|
+
throw new AggregateError(errors, "mkdir directory close failed");
|
|
16875
|
+
} }, false);
|
|
16876
|
+
const flags = (nodeDirectorySearchOnlyFlags()?.flags ?? external_node_fs_namespaceObject.constants.O_RDONLY) |
|
|
16877
|
+
(external_node_fs_namespaceObject.constants.O_DIRECTORY ?? 0) | (external_node_fs_namespaceObject.constants.O_NOFOLLOW ?? 0);
|
|
16878
|
+
let current = rootOwner.fd;
|
|
16879
|
+
if (parentDepth > 0) {
|
|
16880
|
+
current = binding.openBeneath(rootOwner.fd, segments.slice(0, parentDepth).join("/"), flags).fd;
|
|
16881
|
+
directories.push({ fd: current, pathname: parentPath });
|
|
16882
|
+
strict_file_identity_inspectFileIdentitySync(() => external_node_fs_namespaceObject.fstatSync(current, { bigint: true }), parentIdentity);
|
|
16883
|
+
}
|
|
16884
|
+
const assertCurrent = () => {
|
|
16885
|
+
root_context_assertRootIdentityCurrentSync(root);
|
|
16886
|
+
for (const directory of directories)
|
|
16887
|
+
verifyMkdirDirectory(binding, directory.fd, directory.pathname);
|
|
16888
|
+
verifyMkdirDirectory(binding, rootOwner.fd, root.rootReal);
|
|
16889
|
+
};
|
|
16890
|
+
assertCurrent();
|
|
16891
|
+
for (const segment of segments.slice(parentDepth)) {
|
|
16892
|
+
const child = binding.mkdirOpenChildBeneath(current, segment, 0o777, flags);
|
|
16893
|
+
parentPath = external_node_path_namespaceObject.join(parentPath, segment);
|
|
16894
|
+
directories.push({ fd: child.fd, pathname: parentPath });
|
|
16895
|
+
// Retain every ancestor until the complete suffix is admitted. The
|
|
16896
|
+
// post-create fence also precedes the next synchronous child mutation.
|
|
16897
|
+
assertCurrent();
|
|
16898
|
+
current = child.fd;
|
|
16899
|
+
}
|
|
16900
|
+
return true;
|
|
16901
|
+
}
|
|
16902
|
+
catch (e_1) {
|
|
16903
|
+
env_1.error = e_1;
|
|
16904
|
+
env_1.hasError = true;
|
|
16905
|
+
}
|
|
16906
|
+
finally {
|
|
16907
|
+
root_mkdir_native_disposeResources(env_1);
|
|
16908
|
+
}
|
|
16909
|
+
}
|
|
16910
|
+
catch (error) {
|
|
16911
|
+
if (hasNodeErrorCode(error, "ENOTDIR"))
|
|
16912
|
+
throw root_errors_directoryComponentNotDirectoryError(error);
|
|
16913
|
+
throw error;
|
|
16914
|
+
}
|
|
16915
|
+
}
|
|
16916
|
+
function mkdirExistingParent(root, segments, parentIdentity) {
|
|
16917
|
+
const env_2 = { stack: [], error: void 0, hasError: false };
|
|
16918
|
+
try {
|
|
16919
|
+
const target = external_node_path_namespaceObject.join(root.rootReal, ...segments);
|
|
16920
|
+
const parentPath = external_node_path_namespaceObject.dirname(target);
|
|
16921
|
+
const binding = native_getNativeBinding("openBeneath", "mkdirChildBeneath");
|
|
16922
|
+
if (!binding?.openBeneath || !binding.mkdirChildBeneath) {
|
|
16923
|
+
throw new errors_FsSafeError("helper-unavailable", "native confined creation is unavailable");
|
|
16924
|
+
}
|
|
16925
|
+
const rootOwner = root_mkdir_native_addDisposableResource(env_2, openExactNativeRootSync(binding, {
|
|
16926
|
+
rootPath: root.rootReal, rootIdentity: root.rootIdentity,
|
|
16927
|
+
}), false);
|
|
16928
|
+
verifyMkdirDirectory(binding, rootOwner.fd, root.rootReal);
|
|
16929
|
+
const flags = (nodeDirectorySearchOnlyFlags()?.flags ?? external_node_fs_namespaceObject.constants.O_RDONLY) |
|
|
16930
|
+
(external_node_fs_namespaceObject.constants.O_DIRECTORY ?? 0) | (external_node_fs_namespaceObject.constants.O_NOFOLLOW ?? 0);
|
|
16931
|
+
const close = captureNativeFdClose(binding);
|
|
16932
|
+
const parent = binding.openBeneath(rootOwner.fd, segments.slice(0, -1).join("/"), flags).fd;
|
|
16933
|
+
const parentOwner = root_mkdir_native_addDisposableResource(env_2, { [Symbol.dispose]() { close(parent); } }, false);
|
|
16934
|
+
strict_file_identity_inspectFileIdentitySync(() => external_node_fs_namespaceObject.fstatSync(parent, { bigint: true }), parentIdentity);
|
|
16935
|
+
verifyMkdirDirectory(binding, parent, parentPath);
|
|
16936
|
+
root_context_assertRootIdentityCurrentSync(root);
|
|
16937
|
+
const name = segments.at(-1);
|
|
16938
|
+
const child = binding.mkdirOpenChildBeneath
|
|
16939
|
+
? binding.mkdirOpenChildBeneath(parent, name, 0o777, flags).fd
|
|
16940
|
+
: (binding.mkdirChildBeneath(parent, name, 0o777), binding.openBeneath(parent, name, flags).fd);
|
|
16941
|
+
const childOwner = root_mkdir_native_addDisposableResource(env_2, { [Symbol.dispose]() { close(child); } }, false);
|
|
16942
|
+
root_context_assertRootIdentityCurrentSync(root);
|
|
16943
|
+
verifyMkdirDirectory(binding, child, target);
|
|
16944
|
+
directory_guard_inspectDirectoryIdentitySync(parentPath, parentIdentity);
|
|
16945
|
+
verifyMkdirDirectory(binding, parent, parentPath);
|
|
16946
|
+
verifyMkdirDirectory(binding, rootOwner.fd, root.rootReal);
|
|
16947
|
+
return true;
|
|
16948
|
+
}
|
|
16949
|
+
catch (e_2) {
|
|
16950
|
+
env_2.error = e_2;
|
|
16951
|
+
env_2.hasError = true;
|
|
16952
|
+
}
|
|
16953
|
+
finally {
|
|
16954
|
+
root_mkdir_native_disposeResources(env_2);
|
|
16955
|
+
}
|
|
16956
|
+
}
|
|
16957
|
+
|
|
16315
16958
|
;// CONCATENATED MODULE: ../../node_modules/@openclaw/fs-safe/dist/write-open-flags.js
|
|
16316
16959
|
|
|
16317
16960
|
|
|
@@ -19384,6 +20027,7 @@ var root_impl_disposeResources = (undefined && undefined.__disposeResources) ||
|
|
|
19384
20027
|
|
|
19385
20028
|
|
|
19386
20029
|
|
|
20030
|
+
|
|
19387
20031
|
|
|
19388
20032
|
|
|
19389
20033
|
function logWarn(message) {
|
|
@@ -19784,7 +20428,9 @@ async function openWritableFileInRoot(root, params, options) {
|
|
|
19784
20428
|
denyMutations: params.denyMutations,
|
|
19785
20429
|
mutationSymlinks: params.mutationSymlinks,
|
|
19786
20430
|
});
|
|
19787
|
-
const
|
|
20431
|
+
const creationProbe = requireNative && !guardedTarget && params.assertBeforeMutation === undefined && options?.createIfMissing !== false
|
|
20432
|
+
? probeNativeCreationPath(root, params.relativePath) : undefined;
|
|
20433
|
+
const { resolved } = creationProbe ?? guardedTarget?.resolvedPath ?? await resolveGuardedWritePathInRoot(root, {
|
|
19788
20434
|
relativePath: params.relativePath,
|
|
19789
20435
|
});
|
|
19790
20436
|
const resolveCurrent = async () => (await resolveGuardedWritePathInRoot(root, {
|
|
@@ -19813,27 +20459,30 @@ async function openWritableFileInRoot(root, params, options) {
|
|
|
19813
20459
|
let ioPath = nativeCreatesParents ? resolved : prepared?.targetPath ?? (params.mkdir === false ? resolved :
|
|
19814
20460
|
await prepareRootWriteTarget(root, resolved, params.assertBeforeMutation));
|
|
19815
20461
|
const operationTargetPath = ioPath;
|
|
19816
|
-
|
|
19817
|
-
|
|
19818
|
-
|
|
19819
|
-
|
|
19820
|
-
|
|
19821
|
-
|
|
19822
|
-
|
|
19823
|
-
|
|
19824
|
-
|
|
19825
|
-
|
|
19826
|
-
|
|
19827
|
-
|
|
19828
|
-
|
|
19829
|
-
|
|
19830
|
-
if (err instanceof errors_FsSafeError) {
|
|
19831
|
-
throw err;
|
|
20462
|
+
let observedMissing = Boolean(creationProbe);
|
|
20463
|
+
if (!creationProbe)
|
|
20464
|
+
try {
|
|
20465
|
+
assertFinalSymlinkRejected(ioPath, params.mutationSymlinks !== undefined);
|
|
20466
|
+
const resolvedRealPath = params.mutationSymlinks === undefined ? realpath_realpathSync.native(ioPath) : ioPath;
|
|
20467
|
+
const admittedRealPath = root_boundary_admitPathInsideRoot({
|
|
20468
|
+
rootPath: root.rootReal,
|
|
20469
|
+
candidatePath: resolvedRealPath,
|
|
20470
|
+
rootIdentity: root.rootIdentity,
|
|
20471
|
+
});
|
|
20472
|
+
if (!admittedRealPath) {
|
|
20473
|
+
throw root_errors_outsideWorkspaceError();
|
|
20474
|
+
}
|
|
20475
|
+
ioPath = admittedRealPath.path;
|
|
19832
20476
|
}
|
|
19833
|
-
|
|
19834
|
-
|
|
20477
|
+
catch (err) {
|
|
20478
|
+
if (err instanceof errors_FsSafeError) {
|
|
20479
|
+
throw err;
|
|
20480
|
+
}
|
|
20481
|
+
if (!path_isNotFoundPathError(err)) {
|
|
20482
|
+
throw err;
|
|
20483
|
+
}
|
|
20484
|
+
observedMissing = true;
|
|
19835
20485
|
}
|
|
19836
|
-
}
|
|
19837
20486
|
assertRootFallbackWritePath(params.expectedWritePath, ioPath);
|
|
19838
20487
|
const mode = params.mode ?? 0o600;
|
|
19839
20488
|
let handle;
|
|
@@ -19847,61 +20496,82 @@ async function openWritableFileInRoot(root, params, options) {
|
|
|
19847
20496
|
writePathSelection = guardedTarget
|
|
19848
20497
|
? await prepareGuardedRootWritePathSelection(guardedTarget, ioPath, operationTargetPath, preparedParent)
|
|
19849
20498
|
: undefined;
|
|
19850
|
-
|
|
19851
|
-
|
|
19852
|
-
|
|
19853
|
-
|
|
19854
|
-
|
|
19855
|
-
|
|
19856
|
-
|
|
19857
|
-
|
|
20499
|
+
const createNative = () => tryOpenCreateRootNative({
|
|
20500
|
+
originalPath: params.relativePath,
|
|
20501
|
+
root, directory: external_node_path_namespaceObject.dirname(ioPath), target: ioPath, mkdir: params.mkdir !== false, policy,
|
|
20502
|
+
selectedParent: creationProbe?.parent,
|
|
20503
|
+
resolveCurrent,
|
|
20504
|
+
assertBeforeMutation: params.assertBeforeMutation !== undefined || writePathSelection !== undefined ? () => {
|
|
20505
|
+
params.assertBeforeMutation?.();
|
|
20506
|
+
if (writePathSelection)
|
|
20507
|
+
assertRootWritePathSelectionSync(root, writePathSelection);
|
|
20508
|
+
} : undefined,
|
|
20509
|
+
flags: createFlags, existingFlags, mode,
|
|
20510
|
+
});
|
|
20511
|
+
let precreated;
|
|
20512
|
+
if (requireNative && observedMissing && !guardedTarget && params.assertBeforeMutation === undefined && options?.createIfMissing !== false) {
|
|
20513
|
+
try {
|
|
20514
|
+
precreated = await createNative();
|
|
19858
20515
|
}
|
|
19859
|
-
|
|
19860
|
-
|
|
20516
|
+
catch (error) {
|
|
20517
|
+
if (!hasNodeErrorCode(error, "EEXIST") || !isNativeCreateCollision(error))
|
|
20518
|
+
throw error;
|
|
19861
20519
|
}
|
|
19862
|
-
|
|
19863
|
-
|
|
19864
|
-
|
|
19865
|
-
|
|
19866
|
-
|
|
19867
|
-
|
|
19868
|
-
|
|
19869
|
-
|
|
19870
|
-
|
|
19871
|
-
|
|
19872
|
-
|
|
19873
|
-
|
|
19874
|
-
}))
|
|
19875
|
-
throw root_errors_outsideWorkspaceError();
|
|
19876
|
-
directory_guard_assertSyncDirectoryGuard(parentGuard);
|
|
19877
|
-
return { missing: true, targetPath: ioPath, parentGuard, writeSelection: writePathSelection };
|
|
20520
|
+
}
|
|
20521
|
+
if (precreated) {
|
|
20522
|
+
handle = precreated.handle;
|
|
20523
|
+
cleanupCreated = precreated.cleanupCreated;
|
|
20524
|
+
releaseCreationParent = precreated.releaseCreationParent;
|
|
20525
|
+
createdForWrite = true;
|
|
20526
|
+
}
|
|
20527
|
+
else {
|
|
20528
|
+
try {
|
|
20529
|
+
if (writePathSelection)
|
|
20530
|
+
assertRootWritePathSelectionSync(root, writePathSelection);
|
|
20531
|
+
handle = await promises_namespaceObject.open(ioPath, existingFlags, mode);
|
|
19878
20532
|
}
|
|
19879
|
-
|
|
19880
|
-
await
|
|
19881
|
-
|
|
19882
|
-
|
|
19883
|
-
|
|
19884
|
-
|
|
20533
|
+
catch (err) {
|
|
20534
|
+
if (await isNonRegularWriteOpenError(err, ioPath, existingFlags)) {
|
|
20535
|
+
throw new errors_FsSafeError("not-file", "path is not a regular file under root");
|
|
20536
|
+
}
|
|
20537
|
+
if (!path_isNotFoundPathError(err)) {
|
|
20538
|
+
throw err;
|
|
20539
|
+
}
|
|
20540
|
+
if (options?.createIfMissing === false) {
|
|
20541
|
+
if (nativeCreatesParents && !guardedTarget)
|
|
20542
|
+
await tryMkdirRootNative({
|
|
20543
|
+
originalPath: params.relativePath,
|
|
20544
|
+
root, directory: external_node_path_namespaceObject.dirname(ioPath), target: ioPath, mkdir: true, policy,
|
|
20545
|
+
resolveCurrent, assertBeforeMutation: params.assertBeforeMutation,
|
|
20546
|
+
});
|
|
20547
|
+
const parentGuard = writePathSelection?.parentGuard ??
|
|
20548
|
+
await directory_guard_createAsyncDirectoryGuard(external_node_path_namespaceObject.dirname(ioPath), { bigint: true });
|
|
20549
|
+
root_context_assertRootIdentityCurrentSync(root);
|
|
20550
|
+
if (!root_boundary_admitPathInsideRoot({
|
|
20551
|
+
rootPath: root.rootReal, candidatePath: parentGuard.realPath, rootIdentity: root.rootIdentity,
|
|
20552
|
+
}))
|
|
20553
|
+
throw root_errors_outsideWorkspaceError();
|
|
20554
|
+
directory_guard_assertSyncDirectoryGuard(parentGuard);
|
|
20555
|
+
return { missing: true, targetPath: ioPath, parentGuard, writeSelection: writePathSelection };
|
|
20556
|
+
}
|
|
20557
|
+
if (writePathSelection)
|
|
20558
|
+
await refreshRootWritePathSelection(writePathSelection);
|
|
20559
|
+
const nativeCreated = requireNative ? await createNative() : undefined;
|
|
20560
|
+
if (nativeCreated)
|
|
20561
|
+
handle = nativeCreated.handle;
|
|
20562
|
+
else {
|
|
19885
20563
|
params.assertBeforeMutation?.();
|
|
19886
20564
|
if (writePathSelection)
|
|
19887
20565
|
assertRootWritePathSelectionSync(root, writePathSelection);
|
|
19888
|
-
|
|
19889
|
-
|
|
19890
|
-
|
|
19891
|
-
|
|
19892
|
-
|
|
19893
|
-
|
|
19894
|
-
|
|
19895
|
-
|
|
19896
|
-
assertRootWritePathSelectionSync(root, writePathSelection);
|
|
19897
|
-
// Windows can follow a dangling symlink even with O_EXCL.
|
|
19898
|
-
if (!SUPPORTS_NOFOLLOW)
|
|
19899
|
-
assertFinalSymlinkRejected(ioPath, true);
|
|
19900
|
-
handle = await promises_namespaceObject.open(ioPath, createFlags, mode);
|
|
20566
|
+
// Windows can follow a dangling symlink even with O_EXCL.
|
|
20567
|
+
if (!SUPPORTS_NOFOLLOW)
|
|
20568
|
+
assertFinalSymlinkRejected(ioPath, true);
|
|
20569
|
+
handle = await promises_namespaceObject.open(ioPath, createFlags, mode);
|
|
20570
|
+
}
|
|
20571
|
+
cleanupCreated = nativeCreated?.cleanupCreated;
|
|
20572
|
+
releaseCreationParent = nativeCreated?.releaseCreationParent;
|
|
20573
|
+
createdForWrite = true;
|
|
19901
20574
|
}
|
|
19902
|
-
cleanupCreated = nativeCreated?.cleanupCreated;
|
|
19903
|
-
releaseCreationParent = nativeCreated?.releaseCreationParent;
|
|
19904
|
-
createdForWrite = true;
|
|
19905
20575
|
}
|
|
19906
20576
|
}
|
|
19907
20577
|
catch (err) {
|
|
@@ -20148,6 +20818,8 @@ async function mkdirPathInRoot(root, params) {
|
|
|
20148
20818
|
}
|
|
20149
20819
|
if (tryMkdirNativeDirectChild(root, params.relativePath))
|
|
20150
20820
|
return;
|
|
20821
|
+
if (tryMkdirNativeParents(root, params.relativePath))
|
|
20822
|
+
return;
|
|
20151
20823
|
}
|
|
20152
20824
|
const resolution = { relativePath: params.relativePath, allowRoot: params.allowRoot, ...policy };
|
|
20153
20825
|
const resolveCurrent = policy
|
|
@@ -33155,4 +33827,4 @@ if (installedChunkData !== 0) { // 0 means "already installed".'
|
|
|
33155
33827
|
// module factories are used so entry inlining is disabled
|
|
33156
33828
|
// startup
|
|
33157
33829
|
// Load entry module and return exports
|
|
33158
|
-
var __webpack_exports__ = __webpack_require__(
|
|
33830
|
+
var __webpack_exports__ = __webpack_require__(317);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lousy-agents/agent-shell",
|
|
3
|
-
"version": "5.22.
|
|
3
|
+
"version": "5.22.2",
|
|
4
4
|
"description": "A flight recorder for npm script execution",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"typecheck": "tsc --noEmit"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@openclaw/fs-safe": "0.26.
|
|
40
|
+
"@openclaw/fs-safe": "0.26.4",
|
|
41
41
|
"zod": "4.5.2"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@github/copilot-sdk": "1.0.
|
|
44
|
+
"@github/copilot-sdk": "1.0.21"
|
|
45
45
|
},
|
|
46
46
|
"peerDependenciesMeta": {
|
|
47
47
|
"@github/copilot-sdk": {
|