UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 98.2 kB
import{createRequire as e}from"node:module";import t from"node:path";import{createHash as n}from"node:crypto";import r,{closeSync as i,openSync as a,readSync as o,readdirSync as s}from"node:fs";import c from"node:fs/promises";import l,{platform as u}from"node:os";import{URL as d,fileURLToPath as f}from"node:url";import{getSystemErrorName as p}from"node:util";import{AsyncLocalStorage as m}from"node:async_hooks";function identityFromReceipt(e){if(`exactIdentity`in e){let t=e.exactIdentity,n=t?.dev,r=t?.ino;return typeof n==`bigint`&&typeof r==`bigint`?{dev:n,ino:r}:{dev:NaN,ino:NaN}}return e}function hasSafeFileIdentity(e){return isExactStatValue(e.dev)&&isExactStatValue(e.ino)}function isExactStatValue(e){return typeof e==`bigint`||Number.isSafeInteger(e)}function isZero(e){return e===0||e===0n}function sameStatValue(e,t){return typeof e==typeof t?e===t:BigInt(e)===BigInt(t)}function isStatValueProvablyDifferent(e,t,n){return sameStatValue(e,t)?!1:n!==`win32`||!isZero(e)&&!isZero(t)}function sha256Hex(e,t){let r=typeof e==`string`?Buffer.from(e,t??`utf8`):e;return n(`sha256`).update(r).digest(`hex`)}function sameFileIdentity(e,t,n=process.platform){e=identityFromReceipt(e),t=identityFromReceipt(t);let r=e.dev,i=e.ino,a=t.dev,o=t.ino;return isExactStatValue(r)&&isExactStatValue(i)&&isExactStatValue(a)&&isExactStatValue(o)&&!isStatValueProvablyDifferent(r,a,n)&&!isStatValueProvablyDifferent(i,o,n)}function sameCleanupStatValue(e,t){return!isExactStatValue(e)||!isExactStatValue(t)?!1:sameStatValue(e,t)}function sameFileIdentityForCleanup(e,t,n=process.platform){if(n!==`win32`)return sameCleanupStatValue(e.dev,t.dev)&&sameCleanupStatValue(e.ino,t.ino);let r=e.dev;if(isZero(r))return!1;let i=e.ino;if(isZero(i))return!1;let a=t.dev;if(isZero(a))return!1;let o=t.ino;return!isZero(o)&&sameCleanupStatValue(r,a)&&sameCleanupStatValue(i,o)}function normalizeMaxBytes(e,t={}){let n=e===void 0?t.defaultValue:e;if(n===void 0||n===1/0)return n;if(!Number.isSafeInteger(n)||n<0)throw RangeError(`maxBytes must be a non-negative safe integer or Infinity`);return n}const h=/* @__PURE__ */ new Set([`helper-failed`,`helper-unavailable`,`not-empty`,`not-found`,`not-removable`,`permission-denied`,`permission-unverified`,`read-failed`,`timeout`,`unsupported-platform`]);function categorizeFsSafeError(e){return h.has(e)?`operational`:`policy`}var FsSafeError=class extends Error{code;category;details;constructor(e,t,n={}){super(t,n),this.name=`FsSafeError`,this.code=e,this.category=categorizeFsSafeError(e),this.details=n.details}};const g=new m;function recordFileObservationFailure(e,t){let n=g.getStore();if(!n)return;let r=n.get(e);r||n.set(e,r=/* @__PURE__ */ new Set),r.add(t)}function isFileObservationFailure(e,t){return g.getStore()?.get(e)?.has(t)===!0}function fileObservation(){let e=/* @__PURE__ */ new Map;return{run(t){return g.run(e,t)},has(t,n){return e.get(t)?.has(n)===!0}}}function fileIdentityMismatchError(){let e=new FsSafeError(`path-mismatch`,`file identity changed or could not be verified`);return recordFileObservationFailure(e,`identity`),e}function identityCheck(e,t){let n={},check=e=>{let r=!0;for(let i of[`dev`,`ino`]){let a=e[i];if(typeof a!=`bigint`)throw fileIdentityMismatchError();if(t===`win32`&&a===0n)r=!1;else{if(n[i]!==void 0&&n[i]!==a)throw fileIdentityMismatchError();n[i]=a}}return r};if(e&&!check(e))throw fileIdentityMismatchError();return check}async function inspectFileIdentity(e,t,n=process.platform){let r=identityCheck(t,n);for(let t=0;t<2;t++){let t=await e();if(r(t))return t}throw fileIdentityMismatchError()}function inspectFileIdentitySync(e,t,n=process.platform,r=fileIdentityMismatchError){let i,a;if(t&&(i=t.dev,typeof i!=`bigint`||(a=t.ino,typeof a!=`bigint`)||n===`win32`&&(i===0n||a===0n)))throw r();for(let t=0;t<2;t++){let t=e(),o=!0,s=t.dev;if(typeof s!=`bigint`)throw r();if(n===`win32`&&s===0n)o=!1;else{if(i!==void 0&&i!==s)throw r();i=s}let c=t.ino;if(typeof c!=`bigint`)throw r();if(n===`win32`&&c===0n)o=!1;else{if(a!==void 0&&a!==c)throw r();a=c}if(o)return t}throw r()}function captureNativeFdClose(e){if(typeof e.closeOwnedFd!=`function`)throw new FsSafeError(`helper-unavailable`,`native descriptor ownership is unavailable`);return e.closeOwnedFd.bind(e)}let _={};function parseMode(e){if(!e)return;let t=e.trim().toLowerCase();if(t===`0`||t===`false`||t===`off`||t===`never`)return`off`;if(t===`1`||t===`true`||t===`on`||t===`auto`)return`auto`;if(t===`required`||t===`require`)return`require`}function rejectLegacyMode(){for(let e of[`FS_SAFE_PYTHON_MODE`,`OPENCLAW_FS_SAFE_PYTHON_MODE`]){if(process.env[e]===void 0)continue;let t=parseMode(process.env[e])??`auto`;throw Error(`${e} has been removed. Set FS_SAFE_NATIVE_MODE=${t} or configureFsSafeNative({ mode: "${t}" }) before using fs-safe, then remove ${e}. Legacy mode settings no longer select native policy.`)}return`auto`}function getFsSafeNativeConfig(){return{mode:_.mode??parseMode(process.env.FS_SAFE_NATIVE_MODE)??parseMode(process.env.OPENCLAW_FS_SAFE_NATIVE_MODE)??rejectLegacyMode()}}function getNativeModeSetting(){if(_.mode!==void 0)return{mode:_.mode,source:`programmatic configuration`};for(let e of[`FS_SAFE_NATIVE_MODE`,`OPENCLAW_FS_SAFE_NATIVE_MODE`]){let t=parseMode(process.env[e]);if(t!==void 0)return{mode:t,source:e}}return{mode:rejectLegacyMode(),source:`default`}}function isFsSafeNativeRequired(){return(_.mode??parseMode(process.env.FS_SAFE_NATIVE_MODE)??parseMode(process.env.OPENCLAW_FS_SAFE_NATIVE_MODE)??rejectLegacyMode())===`require`}const v=e(new URL(`dist/native.js`,import.meta.resolve(`@openclaw/fs-safe/package.json`)).href),y=m.snapshot();let b,x,S=!1,C=loadBundledBinding,resolvePackage=e=>v.resolve(e),w={reason:`not-probed`},T,E;function loadFailure(e,t){try{return classifyLoadFailure(e,t)}catch{return{reason:`load-failed`,code:`UNKNOWN`}}}function classifyLoadFailure(e,t){let n=typeof e==`object`&&e&&`code`in e?e.code:void 0;if(n===`MODULE_NOT_FOUND`&&e instanceof Error&&e.message.split(`
`,1)[0]===`Cannot find module '${t}'`)try{resolvePackage(t)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`MODULE_NOT_FOUND`&&e.message.split(`
`,1)[0]===`Cannot find module '${t}'`)return{reason:`package-missing`}}return{reason:`load-failed`,code:typeof n==`string`&&[`ERR_DLOPEN_FAILED`,`MODULE_NOT_FOUND`,`ERR_MODULE_NOT_FOUND`,`ERR_PACKAGE_PATH_NOT_EXPORTED`,`ERR_INVALID_PACKAGE_CONFIG`,`EACCES`,`EPERM`,`ENOENT`].includes(n)?n:`UNKNOWN`}}function getNativeFallbackDiagnostic(...e){let t=getNativeModeSetting(),n=E===void 0?bundledTarget():T,r=n===void 0?void 0:nativePackageForTarget(n),i=v("@openclaw/fs-safe/package.json"),a={target:E,packageName:r,packageVersion:r===void 0?void 0:i.optionalDependencies[r]};if(t.mode===`off`)return{...a,reason:`disabled`,source:t.source};let o=b;if(o){let t=e.filter(e=>typeof o[e]!=`function`);if(t.length)return{...a,reason:`capability-missing`,capabilities:t}}return{...a,...w}}function isMuslFilename(e){return e.includes(`libc.musl-`)||e.includes(`ld-musl-`)}function isMuslFromReport(){try{if(!process.report||typeof process.report.getReport!=`function`)return;let e=process.report.getReport();if(e.header?.glibcVersionRuntime)return!1;if(e.sharedObjects?.some(isMuslFilename))return!0}catch{}}function isMuslFromFilesystem(){for(let e of[`/lib`,`/usr/lib`])try{if(s(e).some(isMuslFilename))return!0}catch{}}function readUInt(e,t,n,r){if(t<0||t+n>e.length)return;if(n===2)return r?e.readUInt16LE(t):e.readUInt16BE(t);if(n===4)return r?e.readUInt32LE(t):e.readUInt32BE(t);let i=r?e.readBigUInt64LE(t):e.readBigUInt64BE(t);return i<=BigInt(2**53-1)?Number(i):void 0}function isMuslFromElfInterpreter(){let e;try{e=a(process.execPath,`r`);let t=Buffer.alloc(64);if(o(e,t,0,t.length,0)<52||!t.subarray(0,4).equals(Buffer.from([127,69,76,70])))return;let n=t[4],r=t[5];if(n!==1&&n!==2||r!==1&&r!==2)return;let i=r===1,s=n===2,c=readUInt(t,s?32:28,s?8:4,i),l=readUInt(t,s?54:42,2,i),u=readUInt(t,s?56:44,2,i);if(c===void 0||l===void 0||u===void 0||l<(s?56:32)||u>1024)return;let d=Buffer.alloc(l);for(let t=0;t<u;t+=1){let n=c+t*l;if(o(e,d,0,l,n)!==l)return;if(readUInt(d,0,4,i)!==3)continue;let r=readUInt(d,s?8:4,s?8:4,i),a=readUInt(d,s?32:16,s?8:4,i);if(r===void 0||a===void 0||a<1||a>4096)return;let u=Buffer.alloc(a);return o(e,u,0,a,r)===a?isMuslFilename(u.toString(`utf8`)):void 0}}catch{return}finally{if(e!==void 0)try{i(e)}catch{}}}function isMusl(){if(process.platform!==`linux`)return!1;for(let e of[isMuslFromReport,isMuslFromElfInterpreter,isMuslFromFilesystem]){let t=e();if(t!==void 0)return t}return!1}function targetFor(e,t,n){if(e===`win32`&&(t===`x64`||t===`arm64`))return`win32-${t}-msvc`;if(e===`darwin`&&t===`x64`)return`darwin-x64`;if(e===`darwin`&&t===`arm64`)return`darwin-arm64`;if(e===`freebsd`&&(t===`x64`||t===`arm64`))return`freebsd-${t}`;if(e===`linux`&&(t===`x64`||t===`arm64`))return`linux-${t}-${n?`musl`:`gnu`}`}function bundledTarget(){let e=isMusl();return T=targetFor(process.platform,process.arch,e),E=T??`${process.platform}-${process.arch}${process.platform===`linux`?`-${e?`musl`:`gnu`}`:``}`,T}function nativePackageForTarget(e){return`@openclaw/fs-safe-${e}`}function loadBundledBinding(){let e=bundledTarget();if(!e)throw w={reason:`unsupported-target`},Error(`Unsupported OS or architecture: ${process.platform}-${process.arch}`);let t=y(()=>v(nativePackageForTarget(e)));return typeof t.closeOwnedFd!=`function`&&(w={reason:`capability-missing`,capabilities:[`closeOwnedFd`]}),captureNativeFdClose(t),t}function selectNativeBinding(e,...t){if(!e)return;let n=t.filter(t=>typeof e[t]!=`function`);if(n.length===0)return e;if(getFsSafeNativeConfig().mode===`require`)throw new FsSafeError(`helper-unavailable`,`native fs-safe capabilities unavailable: ${n.join(`, `)}`)}function assertNativeCapabilities(e,...t){let n=t.filter(t=>typeof e[t]!=`function`);if(n.length)throw new FsSafeError(`helper-unavailable`,`native fs-safe capabilities unavailable: ${n.join(`, `)}`)}function getNativeBinding(...e){let{mode:t}=getFsSafeNativeConfig();if(t!==`off`){if(!S){S=!0;try{let e=C();typeof e.closeOwnedFd!=`function`&&(w={reason:`capability-missing`,capabilities:[`closeOwnedFd`]}),captureNativeFdClose(e),b=e,w={reason:`loaded`}}catch(e){x=e,w.reason===`not-probed`&&(T??=bundledTarget(),w=loadFailure(e,nativePackageForTarget(T??`${process.platform}-${process.arch}`)))}}if(b)return selectNativeBinding(b,...e);if(t===`require`)throw new FsSafeError(`helper-unavailable`,`native fs-safe helper is unavailable`,{cause:x})}}function requireNativeBinding(...e){let t=getNativeBinding(...e);if(!t)throw new FsSafeError(`helper-unavailable`,`native fs-safe helper is unavailable`,{cause:x});return t}function isWindowsAppContainer(e){if(e.isWindowsAppContainer)try{let t=e.isWindowsAppContainer();if(typeof t!=`boolean`)throw Error(`Invalid AppContainer membership`);return t}catch(e){throw new FsSafeError(`permission-unverified`,`Windows process token membership could not be verified`,{cause:e})}}function assertWindowsHelperAllowed(){if(process.platform!==`win32`)return;let e=getNativeBinding();if(e&&isWindowsAppContainer(e))throw new FsSafeError(`helper-unavailable`,`External Windows security helpers are unavailable inside an AppContainer`)}const D=process.versions.bun?u():void 0,O=D===`darwin`||D===`linux`?D:void 0;function resolve(e,t){if(t&&process.platform===`win32`)try{return r.realpathSync.native(e)}catch(t){if(t.code!==`EPERM`||t.syscall!==`realpath`)throw t;let n;try{n=getNativeBinding()}catch{n=void 0}if(!n||!isWindowsAppContainer(n))throw t;if(!n?.resolveWindowsCanonicalPath)throw new FsSafeError(`helper-unavailable`,`Windows canonicalization after a denied DOS-name query requires the native binding`,{cause:t});let r;try{r=n.resolveWindowsCanonicalPath(e)}catch(e){throw new FsSafeError(`path-mismatch`,`Windows canonical path cannot be verified safely`,{cause:e})}if(r===null)throw t;return r}if(O){if(e.includes(`\0`))throw Object.assign(/* @__PURE__ */ TypeError(`realpath input must not contain null bytes`),{code:`ERR_INVALID_ARG_VALUE`});let n=getNativeBinding();if(n?.canonicalizePath){let r=n.canonicalizePath(e,!t);if(r.path!==void 0)return r.path;let i=-r.errno,a=p(i);throw Object.assign(/* @__PURE__ */ Error(`${a}: realpath '${e}'`),{code:a,errno:i,syscall:`realpath`,path:e})}if(getFsSafeNativeConfig().mode===`require`)throw new FsSafeError(`helper-unavailable`,`native fs-safe canonicalization is unavailable`)}return t?r.realpathSync.native(e):r.realpathSync(e)}const k=Object.assign(e=>resolve(e,!1),{native:e=>resolve(e,!0)});async function realpathNative(e){if(O)return k.native(e);try{return await c.realpath(e)}catch(t){if(process.platform!==`win32`||t.code!==`EPERM`||t.syscall!==`realpath`)throw t;return k.native(e)}}function normalizeNullableString(e){return typeof e==`string`&&e.trim()||null}function normalizeOptionalString(e){return normalizeNullableString(e)??void 0}function normalizeOptionalLowercaseString(e){return normalizeOptionalString(e)?.toLowerCase()}function normalizeLowercaseStringOrEmpty(e){return normalizeOptionalLowercaseString(e)??``}function isWindowsSeparator(e,t){let n=e.charCodeAt(t);return n===47||n===92}function hasWindowsDrivePrefix(e,t=0){let n=e.charCodeAt(t)|32;return n>=97&&n<=122&&e.charCodeAt(t+1)===58}function windowsNamespaceMarker(e){let t=e[2];return(t===`.`||t===`?`)&&isWindowsSeparator(e,0)&&isWindowsSeparator(e,1)&&isWindowsSeparator(e,3)?t:void 0}function rootedWindowsDriveColonIndex(e){let t=hasWindowsDrivePrefix(e)?1:windowsNamespaceMarker(e)!==void 0&&hasWindowsDrivePrefix(e,4)?5:-1;return t>=0&&isWindowsSeparator(e,t+1)?t:-1}function asciiLowercase(e){return e.replace(/[A-Z]/g,e=>String.fromCharCode(e.charCodeAt(0)+32))}function windowsSegmentsClimbAbove(e){let t=0;for(let n of e)if(n!==``&&n!==`.`&&(t+=/^[. ]+$/.test(n)?-1:1,t<0))return!0;return!1}function windowsShareOrDeviceRoot(e){if(!isWindowsSeparator(e,0)||!isWindowsSeparator(e,1))return;let n=e.replaceAll(`/`,`\\`);if(windowsNamespaceMarker(n)===void 0)return asciiLowercase(t.win32.parse(n).root.replace(/\\+$/,``));let r=n.slice(4).split(`\\`),i=asciiLowercase(r[0]??``),a=i===`unc`?r.slice(0,3):r.slice(0,1);if(i===`globalroot`||i===`global`||a.length<(i===`unc`?3:1)||a.some(e=>e===``||/[. ]$/.test(e))||windowsSegmentsClimbAbove(r.slice(a.length)))return null;if(rootedWindowsDriveColonIndex(e)!==5)return asciiLowercase(i===`unc`?`\\\\${a[1]}\\${a[2]}`:`${n.slice(0,4)}${a[0]}`)}function isExactlyUnderWindowsPath(e,t){let n=e.replaceAll(`/`,`\\`).replace(/(?<=.)\\+$/,``),r=t.replaceAll(`/`,`\\`);return r!==n&&!r.startsWith(n.endsWith(`\\`)?n:`${n}\\`)?!1:!windowsSegmentsClimbAbove(r.slice(n.length).split(`\\`))}function isForeignWindowsShareOrDevicePath(e,t,n=process.platform){if(n!==`win32`)return!1;let r=windowsShareOrDeviceRoot(e);return r!==void 0&&!t.some(t=>t!==void 0&&(r!==null&&windowsShareOrDeviceRoot(t)===r||isExactlyUnderWindowsPath(t,e)))}function isBareWindowsNamespaceDrive(e){return e.length===6&&windowsNamespaceMarker(e)!==void 0&&hasWindowsDrivePrefix(e,4)}function anchorWindowsDriveRelativePath(e){if(process.platform!==`win32`||t.isAbsolute(e)||!hasWindowsDrivePrefix(e))return e;let n=e.slice(0,2);return`${t.resolve(n)}${t.sep}${e.slice(2)}`}function resolvePathPreservingWindowsRoot(e){return e.length===7&&process.platform===`win32`&&rootedWindowsDriveColonIndex(e)===5?e.includes(`/`)?e.replaceAll(`/`,`\\`):e:repairResolvedWindowsRoot(e,t.resolve(e))}function repairResolvedWindowsRoot(e,t){return t.length===6&&process.platform===`win32`&&isBareWindowsNamespaceDrive(t)&&!hasWindowsPathAlias(e,`filesystem`)?`${t}\\`:t}function resolvePathFromBasePreservingWindowsRoot(e,...n){let r=t.resolve(e,...n);return r.length!==6||process.platform!==`win32`||!isBareWindowsNamespaceDrive(r)||hasWindowsPathAlias(e,`filesystem`)||n.some(e=>hasWindowsPathAlias(e,`filesystem`))?r:`${r}\\`}function pathForWindowsFilesystem(e){if(process.platform!==`win32`||rootedWindowsDriveColonIndex(e)!==5)return e;if(e.length===7)return`${e[4]}:\\`;let n=t.resolve(e);return isBareWindowsNamespaceDrive(n)&&!hasWindowsPathAlias(e,`filesystem`)?`${n[4]}:\\`:e}function hasWindowsPathAlias(e,t,n=process.platform){if(n!==`win32`)return!1;let r=e.indexOf(`:`);return r===-1?!1:t===`relative`||r!==rootedWindowsDriveColonIndex(e)||e.indexOf(`:`,r+1)!==-1}function assertNoWindowsPathAliasForPlatform(e,t,n,r){if(hasWindowsPathAlias(e,t,r))throw new FsSafeError(`invalid-path`,n,{details:{reason:`windows-path-alias`}})}function assertNoWindowsPathAlias(e,t=`filesystem`,n=`path uses a Windows filesystem namespace alias`,r=process.platform){assertNoWindowsPathAliasForPlatform(e,t,n,r)}function admitStandalonePublicationPath(e,t){let n=anchorWindowsDriveRelativePath(e);return assertNoWindowsPathAlias(n,`filesystem`,t),n}const A=/%(?:2f|5c)/i,j=/^file:\/\//i;function isFileUrl(e){return j.test(e)}function hasEncodedFileUrlSeparator(e){return A.test(e)}function isWindowsNetworkPath(e,t=process.platform){return t===`win32`&&isWindowsSeparator(e,0)&&isWindowsSeparator(e,1)&&(windowsNamespaceMarker(e)!==`?`||rootedWindowsDriveColonIndex(e)!==5)}function safeFileURLToPath(e,t=process.platform){let n;try{n=new d(e)}catch{throw Error(`Invalid file:// URL: ${e}`)}if(n.protocol!==`file:`)throw Error(`Invalid file:// URL: ${e}`);let r=normalizeLowercaseStringOrEmpty(n.hostname);if(r!==``&&r!==`localhost`)throw Error(`file:// URLs with remote hosts are not allowed: ${e}`);if(hasEncodedFileUrlSeparator(n.pathname))throw Error(`file:// URLs cannot encode path separators: ${e}`);let i=f(n,{windows:t===`win32`});if(hasWindowsPathAlias(i,`filesystem`,t))throw Error(`Local file URL cannot use Windows filesystem namespace aliases: ${i}`);if(isWindowsNetworkPath(i,t))throw Error(`Local file URL cannot use Windows network paths: ${i}`);return i}function trySafeFileURLToPath(e,t=process.platform){try{return safeFileURLToPath(e,t)}catch{return}}const M=/* @__PURE__ */ new Set([`/dev/zero`,`/dev/random`,`/dev/urandom`,`/dev/full`,`/dev/stdin`,`/dev/stdout`,`/dev/stderr`,`/dev/tty`,`/dev/console`]),N=/* @__PURE__ */ new Set(/* @__PURE__ */ `CON.PRN.AUX.NUL.CLOCK$.CONIN$.CONOUT$.COM1.COM2.COM3.COM4.COM5.COM6.COM7.COM8.COM9.COM¹.COM².COM³.LPT1.LPT2.LPT3.LPT4.LPT5.LPT6.LPT7.LPT8.LPT9.LPT¹.LPT².LPT³`.split(`.`));function trimTrailingWindowsSeparators(e){let t=e.length;for(;t>0&&e.charCodeAt(t-1)===92;)--t;return t===e.length?e:e.slice(0,t)}function trimTrailingWindowsIgnoredChars(e){let t=e.length;for(;t>0;){let n=e.charCodeAt(t-1);if(n!==32&&n!==46)break;--t}return t===e.length?e:e.slice(0,t)}function candidateReadPaths(e,t){if(!isFileUrl(e))return[e];let n=trySafeFileURLToPath(e,t);return n===void 0?[e]:[e,n]}function normalizePosixPath(e,n){if(t.posix.isAbsolute(e))return t.posix.normalize(e);let r=n&&t.posix.isAbsolute(n)?n:process.cwd();return t.posix.resolve(r,e)}function matchPosixDeviceReadPath(e,t){let n=normalizePosixPath(e,t);if(M.has(n))return{path:n,reason:`posix-device`};if(n===`/dev/fd`||n.startsWith(`/dev/fd/`)||/^\/proc\/(?:self|thread-self|\d+)\/fd(?:\/|$)/.test(n))return{path:n,reason:`posix-fd`}}function normalizeWindowsDeviceBaseName(e){let t=trimTrailingWindowsSeparators(e.replace(/\//g,`\\`)),n=t.lastIndexOf(`\\`)+1,r=t.indexOf(`:`,n),i=t.indexOf(`.`,n),a=Math.min(r<0?t.length:r,i<0?t.length:i);return trimTrailingWindowsIgnoredChars(t.slice(n,a)).toUpperCase()}function isWindowsReservedDeviceName(e){return e.length>0&&N.has(normalizeWindowsDeviceBaseName(e))}function matchWindowsDeviceReadPath(e){let t=e.replace(/\//g,`\\`);if(/^\\\\\.\\/.test(t)||/^\\\\\?\\GLOBALROOT\\Device\\/i.test(t))return{path:t,reason:`windows-device`};let n=normalizeWindowsDeviceBaseName(e);if(N.has(n))return{path:t,reason:`windows-device`}}function matchUnsafeDeviceReadPath(e,t={}){let n=t.platform??process.platform;for(let r of candidateReadPaths(e,n)){let e=n===`win32`?matchWindowsDeviceReadPath(r):matchPosixDeviceReadPath(r,t.cwd);if(e)return e}}function isUnsafeDeviceReadPath(e,t){return matchUnsafeDeviceReadPath(e,t)!==void 0}function assertNoUnsafeDeviceReadPath(e,t){if(matchUnsafeDeviceReadPath(e,t))throw new FsSafeError(`device-path`,`file reads from unsafe device paths are not allowed: ${e}`)}const P=/^[A-Za-z0-9_-][A-Za-z0-9._-]*$/,F=/^[A-Za-z0-9._-]+$/,I=/^[A-Za-z]:(?![\\/])/,L=/(?:^|\/)[A-Za-z]:(?!\\)/;function isDriveRelativePath(e){return I.test(e)}function assertNoDriveRelativePathSegments(e,t){if(L.test(e))throw new FsSafeError(`invalid-path`,`${t} must not contain a drive letter`);return e}function isSafePathSegment(e,t={}){return e!==``&&e!==`.`&&e!==`..`&&!e.includes(`/`)&&!e.includes(`\\`)&&!e.includes(`\0`)&&!isWindowsReservedDeviceName(e)&&(t.allowDotPrefix===!0||!e.startsWith(`.`))&&(t.allowDotPrefix===!0?F.test(e):P.test(e))}function assertSafePathSegment(e,t={}){if(!isSafePathSegment(e,t))throw new FsSafeError(`invalid-path`,`${t.label??`path segment`} must be a safe path segment`);return e}function assertSafePathPrefix(e,t={}){return e.includes(`/`)||e.includes(`\\`)||e.includes(`\0`)?assertSafePathSegment(e,{allowDotPrefix:!0,...t,label:t.label??`path prefix`}):assertSafePathSegment(e.replace(/[^A-Za-z0-9._-]+/g,`-`),{allowDotPrefix:!0,...t,label:t.label??`path prefix`})}const R=/* @__PURE__ */ new Set([`ENOENT`,`ENOTDIR`]),z=/* @__PURE__ */ new Set([`ELOOP`,`EINVAL`,`ENOTSUP`]);function normalizeWindowsPathForComparison(e){let n=t.win32.normalize(e);return n.startsWith(`\\\\?\\`)&&(n=n.slice(4),n.toUpperCase().startsWith(`UNC\\`)&&(n=`\\\\${n.slice(4)}`)),n.replaceAll(`/`,`\\`).toLowerCase()}function resolveWindowsPathForComparison(e){let n=t.win32.resolve(e);return n[1]===`:`&&t.win32.isAbsolute(n)?n.toLowerCase():normalizeWindowsPathForComparison(n.length===6?resolvePathPreservingWindowsRoot(e):n)}function isNodeError(e){return!!(e&&typeof e==`object`&&`code`in e)}function hasNodeErrorCode(e,t){return isNodeError(e)&&e.code===t}function assertNoNulPathInput(e,t=`path contains a NUL byte`){if(e.includes(`\0`))throw new FsSafeError(`invalid-path`,t)}function isNotFoundPathError(e){return isNodeError(e)&&typeof e.code==`string`&&R.has(e.code)}function isSymlinkOpenError(e){return isNodeError(e)&&typeof e.code==`string`&&z.has(e.code)}function isPathInside(e,n){if(process.platform===`win32`){if(isForeignWindowsShareOrDevicePath(n,[e]))return!1;let r=resolveWindowsPathForComparison(e),i=resolveWindowsPathForComparison(n);if(r[1]===`:`&&t.win32.isAbsolute(r)&&!i.includes(`:`,2)&&(i===r||i.startsWith(r)&&(r.endsWith(`\\`)||i[r.length]===`\\`)))return!0;let a=t.win32.relative(r,i),o=a.split(t.win32.sep)[0];return a===``||o!==`..`&&!t.win32.isAbsolute(a)}if(e.length>0&&e.charCodeAt(0)===47&&n.length>=e.length&&n.charCodeAt(0)===47&&!n.includes(`/..`)&&(n===e||n.startsWith(e)&&(e.charCodeAt(e.length-1)===47||n.charCodeAt(e.length)===47)))return!0;let r=t.resolve(e),i=t.resolve(n),a=t.relative(r,i),o=a.split(t.posix.sep)[0];return a===``||o!==`..`&&!t.isAbsolute(a)}function isPathRelativeEscape(e){if(t.isAbsolute(e))return!0;let n=0,r=e.split(process.platform===`win32`?/[/\\]/:/\//);for(let e of r)if(e===`..`){if(n===0)return!0;--n}else e!==``&&e!==`.`&&(n+=1);return!1}const B=/* @__PURE__ */ new Set([`ENOTEMPTY`,`EEXIST`]),V=/* @__PURE__ */ new Map([[`EACCES`,`permission denied`],[`EPERM`,`permission denied`],[`EROFS`,`read-only filesystem`],[`ENOSPC`,`no space left on device`]]);function fileNotFoundError(e,t){return e===void 0?new FsSafeError(`not-found`,`file not found`,{details:t}):new FsSafeError(`not-found`,`file not found`,{cause:e,details:t})}function outsideWorkspaceError(){return new FsSafeError(`outside-workspace`,`file is outside workspace root`)}function pathTraversalPermissionError(e,t){return e instanceof FsSafeError?e.code===`permission-denied`?e:void 0:!hasNodeErrorCode(e,`EACCES`)&&!hasNodeErrorCode(e,`EPERM`)?void 0:new FsSafeError(`permission-denied`,`permission denied while resolving ${isNodeError(e)&&typeof e.path==`string`?e.path:t}`,errorCauseOptions(e))}function rootPathChangedError(e){return new FsSafeError(`path-mismatch`,`root path changed during operation`,{cause:e})}function directoryComponentNotDirectoryError(e){return e===void 0?new FsSafeError(`not-file`,`directory component must be a directory`):new FsSafeError(`not-file`,`directory component must be a directory`,{cause:e})}function hardlinkedPathNotAllowedError(){return new FsSafeError(`hardlink`,`hardlinked path not allowed`)}function isAlreadyExistsError(e){return hasNodeErrorCode(e,`EEXIST`)||/File exists|EEXIST/i.test(String(e))}function resourceExhaustion(e){let t=[e],n,r,i=/* @__PURE__ */ new Set;for(;t.length;){let e=t.pop();if(!(e instanceof Error)||i.has(e))continue;if(i.add(e),e instanceof FsSafeError&&e.code!==`helper-failed`&&e.code!==`not-removable`)return;let a=e;e instanceof FsSafeError&&(!n||e.details?.cleanup)&&(n=e.details??n),a.code===`EMFILE`||a.code===`ENFILE`?(!r||r===`ENOSPC`)&&(r=a.code):a.code===`ENOSPC`&&(r??=a.code),a.name===`SuppressedError`&&t.push(a.suppressed,a.error),e instanceof AggregateError&&t.push(...e.errors),t.push(e.cause)}if(!r||r===`ENOSPC`&&e instanceof FsSafeError)return;let a=n?.cleanup,o=n?.publication,s=a?.status===`preserved`&&o?.status===`indeterminate`,c=r===`ENOSPC`?V.get(r):`filesystem write failed: too many open files`;return new FsSafeError(r===`ENOSPC`?`invalid-path`:`helper-failed`,`${c} (${r})${s?`; publication outcome is indeterminate; staged file preserved`:``}`,{cause:e,details:n})}function normalizePinnedWriteError(e){let t=resourceExhaustion(e);if(t)return t;let n=e,r=/* @__PURE__ */ new Set;try{for(;n instanceof Error&&n.name===`SuppressedError`&&!r.has(n);)r.add(n),n=n.suppressed;if(n!==e&&n instanceof FsSafeError&&n.details?.phase===`publish`)return new FsSafeError(n.code,n.message,{cause:e,details:n.details})}catch{}if(e instanceof FsSafeError)return e;if(isNotFoundPathError(e))return fileNotFoundError(e instanceof Error?e:void 0);let i=isNodeError(e)&&typeof e.code==`string`&&/^E[A-Z0-9_]+$/.test(e.code)?e.code:void 0;return new FsSafeError(`invalid-path`,i?`${V.get(i)??`filesystem write failed`} (${i})`:`path is not a regular file under root`,errorCauseOptions(e))}function normalizePinnedPathError(e,t){return e instanceof FsSafeError?e:new FsSafeError(`path-alias`,`path is not under root`,{cause:e instanceof Error?e:void 0,details:t})}function normalizeRemoveGuardError(e,t){return e instanceof FsSafeError?e:isNotFoundPathError(e)?fileNotFoundError(e instanceof Error?e:void 0,t):normalizePinnedPathError(e,t)}function normalizeRemovePathError(e,t){if(e instanceof FsSafeError)return e;if(!isNodeError(e)||typeof e.code!=`string`)return normalizePinnedPathError(e,t);let n=e instanceof Error?e:void 0;return isNotFoundPathError(e)?fileNotFoundError(n,t):B.has(e.code)?new FsSafeError(`not-empty`,`directory is not empty`,{cause:n,details:t}):new FsSafeError(`not-removable`,`path could not be removed`,{cause:n,details:t})}function errorCauseOptions(e){return{cause:e instanceof Error?e:void 0}}function directoryEntryPath(e,n=process.platform){let r=n===`win32`;if(typeof e==`string`){let t=e[e.length-1];if(t!==`/`&&(!r||t!==`\\`))return e}let i=(r?t.win32:t.posix).parse(e).root.length;if(r&&/^[\\/]{2}[?.][\\/]UNC[\\/]/i.test(e)){let n=t.win32.parse(`\\\\${e.slice(8)}`).root;n.length>1&&(i=Math.max(i,n.length+6))}let a=e.length;for(;a>i&&(e[a-1]===`/`||r&&e[a-1]===`\\`);)a--;return a===i||a===e.length?e:e.slice(0,a)}function safeNumber(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function safeExpected(e){return typeof e.dev==`bigint`&&typeof e.ino==`bigint`&&e.dev>=0n&&e.ino>=0n&&e.dev<=9007199254740991n&&e.ino<=9007199254740991n}function observeStatSync(e,t,n,r=process.platform,i){if(r===`win32`||!n&&t&&!safeExpected(t)){let a=inspectFileIdentitySync(()=>{let t=n;return n=void 0,t??e(!0)},t,r);return i?{stat:a,identity:t??{dev:a.dev,ino:a.ino}}:a}let a=n??e(!1),{dev:o,ino:s}=a,c=safeNumber(o),l=safeNumber(s),u=c?BigInt(o):typeof o==`bigint`?o:void 0,d=l?BigInt(s):typeof s==`bigint`?s:void 0;if(t&&(u!==void 0&&u!==t.dev||d!==void 0&&d!==t.ino))throw fileIdentityMismatchError();if(c&&l)return i?{stat:a,identity:t??{dev:u,ino:d}}:a;let f=inspectFileIdentitySync(()=>{let t=e(!0);if(u!==void 0&&t.dev!==u||d!==void 0&&t.ino!==d)throw fileIdentityMismatchError();return t},t,r);return i?{stat:f,identity:t??{dev:f.dev,ino:f.ino}}:f}function inspectStatObservationSync(e,t,n,r=process.platform){return observeStatSync(e,t,n,r,!0)}function assertStatObservationSync(e,t,n,r=process.platform){return observeStatSync(e,t,n,r,!1)}const H=/* @__PURE__ */ new WeakMap;function assertDirectoryIdentitySync(e,t){let n=directoryOperationPath(e),r=t.dev,i=t.ino,a=t.realPath;if(a!==void 0&&assertNoWindowsPathAlias(a,`filesystem`),inspectDirectoryIdentityAtPathSync(n,{dev:r,ino:i}),a===void 0)return;let o=k.native(n);if(assertNoWindowsPathAlias(o,`filesystem`),o!==a)throw new FsSafeError(`path-mismatch`,`directory changed during operation`)}async function createAsyncDirectoryGuard(e,t){return captureDirectoryGuard(e,`native`,t)}function captureDirectoryGuard(e,t,n){let i=directoryOperationPath(e),a=n?.bigint?inspectDirectoryIdentityAtPathSync(i,void 0,n.initial):r.lstatSync(i);if(a.isSymbolicLink()||!a.isDirectory())throw directoryComponentNotDirectoryError();let o;if(!hasSafeFileIdentity(a)){let e=r.lstatSync(i,{bigint:!0});if(e.isSymbolicLink()||!e.isDirectory())throw directoryComponentNotDirectoryError();o={dev:e.dev,ino:e.ino}}let s=t===`native`?k.native(i):k(i);assertNoWindowsPathAlias(s,`filesystem`);let c={dir:e,realPath:s,stat:a};return o&&H.set(c,o),c}async function assertAsyncDirectoryGuard(e){assertDirectoryGuard(e,`native`)}function assertSyncDirectoryGuard(e){assertDirectoryGuard(e,`normalized`)}function assertDirectoryGuard(e,t){let n=e.dir,i=directoryOperationPath(n),a=e.realPath;assertNoWindowsPathAlias(a,`filesystem`);let o=e.stat,s={dev:o.dev,ino:o.ino},c=H.get(e),l=c??s,u=typeof l.dev==`bigint`&&typeof l.ino==`bigint`?c?r.lstatSync(i,{bigint:!0}):inspectDirectoryIdentityAtPathSync(i,{dev:l.dev,ino:l.ino}):r.lstatSync(i);if(u.isSymbolicLink()||!u.isDirectory())throw directoryComponentNotDirectoryError();if(t===`native`&&!sameFileIdentity(u,l))throw new FsSafeError(`path-mismatch`,`directory changed during operation`);let d=t===`native`||typeof s.ino==`bigint`?k.native(i):k(i);if(assertNoWindowsPathAlias(d,`filesystem`),t===`normalized`&&!sameFileIdentity(u,l)||d!==a)throw new FsSafeError(`path-mismatch`,`directory changed during operation`)}async function createNearestExistingDirectoryGuard(e,n,r={bigint:!1}){assertNoWindowsPathAlias(e,`filesystem`),assertNoWindowsPathAlias(n,`filesystem`);let i=resolvePathPreservingWindowsRoot(n),a=resolvePathPreservingWindowsRoot(e);for(;i!==a;)try{return captureDirectoryGuard(i,`native`,r)}catch(e){if(!isNotFoundPathError(e))throw e;i=t.dirname(i)}return captureDirectoryGuard(a,`native`,r)}async function inspectDirectoryIdentity(e,t){return inspectDirectoryIdentitySync(e,t)}function directoryOperationPath(e){return assertNoWindowsPathAlias(e,`filesystem`),pathForWindowsFilesystem(directoryEntryPath(e))}function inspectDirectoryIdentitySync(e,t,n,r=process.platform){return inspectDirectoryIdentityAtPathSync(directoryOperationPath(e),t===void 0?void 0:{dev:t.dev,ino:t.ino},n,r)}function inspectDirectoryIdentityAtPathSync(e,t,n,i=process.platform){return inspectFileIdentitySync(()=>{let t=n??r.lstatSync(e,{bigint:!0});if(n=void 0,t.isSymbolicLink()||!t.isDirectory())throw directoryComponentNotDirectoryError();return t},t,i)}function extendDirectoryObservationGuard(e,t,n){let r=e;return r.dir=t,r.realPath=n,r}function inspectDirectoryObservationSync(e,t){let n=directoryOperationPath(e);return inspectStatObservationSync(e=>{let t=e?r.lstatSync(n,{bigint:!0}):r.lstatSync(n);if(t.isSymbolicLink()||!t.isDirectory())throw directoryComponentNotDirectoryError();return t},t)}function assertDirectoryObservationSync(e,t){let n=directoryOperationPath(e);return assertStatObservationSync(e=>{let t=e?r.lstatSync(n,{bigint:!0}):r.lstatSync(n);if(t.isSymbolicLink()||!t.isDirectory())throw directoryComponentNotDirectoryError();return t},t)}function assertDirectoryObservationGuardSync(e){let t=e.dir,n=e.realPath;assertNoWindowsPathAlias(n,`filesystem`),assertDirectoryObservationSync(t,e.identity);let r=k.native(directoryOperationPath(t));if(assertNoWindowsPathAlias(r,`filesystem`),r!==n)throw new FsSafeError(`path-mismatch`,`directory changed during operation`)}const U=65536;function createInitialBuffer(e,t,n=Buffer.allocUnsafe){return n(Math.min(e,t,16777216)+1)}function createScratchBuffer(e,t=Buffer.allocUnsafe){return t(Math.min(U,e+1))}function growReadBuffer(e,t,n=Buffer.allocUnsafe){let r=n(Math.min(t+1,Math.max(U,e.length*2)));return e.copy(r),r}function finishReadBuffer(e,t,n){if(t===0)return Buffer.alloc(0);let r=e.subarray(0,t);if(t>=e.length/2)return r;if(!n)return Buffer.from(r);let i=n(t);return r.copy(i),i}function addReadBytes(e,t,n,r){let i=e+t;if(i>n)throw r?r():new FsSafeError(`too-large`,`file exceeds limit of ${n} bytes (got at least ${i})`);return i}async function readBoundedAsync(e,t,n={}){normalizeMaxBytes(e);let r=0,{observeRegularFileSize:i,createLimitError:a}=n,o=n.unpooled?Buffer.allocUnsafeSlow:void 0,s=n.initialSize??i?.(),c=s===void 0?createScratchBuffer(e,o):createInitialBuffer(e,s,o);if(s!==void 0){let n=await t(c,c.length);if(n===0)return finishReadBuffer(c,0,o);let s=n<c.length?i?.():void 0;if(r=addReadBytes(r,n,e,a),s!==void 0&&s>0&&n>=s)return finishReadBuffer(c,r,o)}for(;;){r===c.length&&(c=growReadBuffer(c,e,o));let n=c.subarray(r),i=await t(n,n.length);if(i===0)return finishReadBuffer(c,r,o);r=addReadBytes(r,i,e,a)}}async function readFileHandleBounded(e,t){return await readFileHandleBoundedWithSize(e,t)}function readFileHandleBoundedWithSize(e,t,n){normalizeMaxBytes(t);let r=`fd`in e&&typeof e.fd==`number`?e.fd:void 0;return readBoundedAsync(t,async(t,n)=>(await e.read(t,0,n,null)).bytesRead,{initialSize:n,observeRegularFileSize:r===void 0?void 0:()=>regularFileSize(r)})}function regularFileSize(e){try{let t=r.fstatSync(e);return t.isFile()&&Number.isSafeInteger(t.size)&&t.size>=0?t.size:void 0}catch{return}}function readBoundedSync(e,t,n={}){normalizeMaxBytes(e);let r=0,{observeRegularFileSize:i,createLimitError:a}=n,o=n.initialSize??i?.(),s=o===void 0?createScratchBuffer(e):createInitialBuffer(e,o);if(o!==void 0){let n=t(s,s.length);if(n===0)return finishReadBuffer(s,0);let o=n<s.length?i?.():void 0;if(r=addReadBytes(r,n,e,a),o!==void 0&&o>0&&n>=o)return finishReadBuffer(s,r)}for(;;){r===s.length&&(s=growReadBuffer(s,e));let n=s.subarray(r),i=t(n,n.length);if(i===0)return finishReadBuffer(s,r);r=addReadBytes(r,i,e,a)}}function readFileDescriptorBoundedSync(e,t){return readBoundedSync(t,(t,n)=>r.readSync(e,t,0,n,null),{initialSize:t<=U?t:void 0,observeRegularFileSize:()=>regularFileSize(e)})}const W=/[\u0000-\u001f\u007f-\u009f\u2028\u2029]/gu;function formatErrorDetail(e){return e.replace(W,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`)}function shortPath(e){let n=l.homedir(),r=n.endsWith(t.sep)?n:`${n}${t.sep}`;return formatErrorDetail(e===n?`~`:e.startsWith(r)?`~${t.sep}${e.slice(r.length)}`:e)}function sameNormalizedPathSpelling(e,n){return t.resolve(e)===t.resolve(n)}function windowsComparisonSpelling(e){return/^\\\\\?\\UNC\\/i.test(e)?`\\\\${e.slice(8)}`:e.startsWith(`\\\\?\\`)?e.slice(4):e}function trimWindowsTrailingSeparators(e){let n=t.win32.parse(e).root.length,r=e.length;for(;r>n&&e[r-1]===`\\`;)--r;return e.slice(0,r)}function trimWindowsLeadingSeparators(e){let t=0;for(;e[t]===`\\`;)t+=1;return e.slice(t)}function exactWindowsRootPrefix(e,t){let n=trimWindowsTrailingSeparators(e.replaceAll(`/`,`\\`)),r=t.replaceAll(`/`,`\\`),i;if(r===n)i=``;else{let e=n.endsWith(`\\`)?n:`${n}\\`;if(!r.startsWith(e))return;i=trimWindowsLeadingSeparators(r.slice(e.length))}return{admission:`exact`,candidateRootPath:n,path:i===``?n:`${n}${n.endsWith(`\\`)?``:`\\`}${i}`,relativePath:i}}function windowsRootPrefix(e,n){let r=exactWindowsRootPrefix(e,n);if(r)return r;let i=t.win32.normalize(e.replaceAll(`/`,`\\`)),a=windowsComparisonSpelling(i),o=n.replaceAll(`/`,`\\`),s=windowsComparisonSpelling(o),c=trimWindowsTrailingSeparators(i),l=trimWindowsTrailingSeparators(a);if(!t.win32.isAbsolute(o))return;let u,d,f;if(s===l)u=``,d=o,f=`exact`;else if(s.toLowerCase()===l.toLowerCase())u=``,d=o,f=`identity`;else{let e=l.endsWith(`\\`)?l:`${l}\\`,t=s.slice(0,e.length);if(t===e)f=`exact`;else if(t.toLowerCase()===e.toLowerCase())f=`identity`;else return;u=trimWindowsLeadingSeparators(s.slice(e.length)),d=o.slice(0,l.length+(o.length-s.length))}let p=u===``?c:`${c}${c.endsWith(`\\`)?``:`\\`}${u}`;return{candidateRootPath:d,path:p,relativePath:u,admission:f}}function exactRootIdentity(e,t){if(typeof t?.dev==`bigint`&&typeof t.ino==`bigint`)return{dev:t.dev,ino:t.ino};let n=inspectDirectoryIdentitySync(e);return{dev:n.dev,ino:n.ino}}function admitPathInsideRoot(e){if(process.platform!==`win32`||t.sep===`/`&&e.rootPath.startsWith(`/`)&&e.rootPath[1]!==`/`&&e.rootPath[1]!==`\\`){if(e.rootPath.startsWith(`/`)&&e.candidatePath.startsWith(`/`)&&!e.candidatePath.includes(`/..`)&&(e.candidatePath===e.rootPath||e.candidatePath.startsWith(e.rootPath)&&(e.rootPath.endsWith(`/`)||e.candidatePath[e.rootPath.length]===`/`))){let t=e.rootPath.endsWith(`/`)?e.rootPath.length:e.rootPath.length+1;return{admission:`exact`,path:e.candidatePath,relativePath:e.candidatePath===e.rootPath?``:e.candidatePath.slice(t)}}let n=t.resolve(e.rootPath),r=t.resolve(e.candidatePath),i=t.relative(n,r);return isPathRelativeEscape(i)?void 0:{path:r,relativePath:i===`.`?``:i,admission:`exact`}}let n=windowsRootPrefix(e.rootPath,e.candidatePath);if(!n)return;let admitted=()=>({admission:n.admission,path:n.path,relativePath:n.relativePath});if(n.admission===`exact`)return admitted();let r=e.identityCache?.get(n.candidateRootPath);if(r!==void 0)return r?admitted():void 0;try{let t=exactRootIdentity(e.rootPath,e.rootIdentity),r=e.resolveCandidateRoot?k.native(n.candidateRootPath):n.candidateRootPath;return e.inspectCandidateRoot?e.inspectCandidateRoot(r,t):inspectDirectoryIdentitySync(r,t),e.identityCache?.set(n.candidateRootPath,!0),admitted()}catch{e.identityCache?.set(n.candidateRootPath,!1);return}}const G=process.platform===`win32`,K=G?runSync:runAsync;function absolutePathWithRawSegments(e){if(t.sep!==`\\`){if(t.isAbsolute(e))return e;let n=process.cwd();return`${n}${n.endsWith(t.sep)?``:t.sep}${e}`}let n=t.sep===`\\`?e.replaceAll(`/`,`\\`):e,r=t.isAbsolute(n);if(r&&n[0]!==`\\`)return n;let i=t.parse(n).root;if(r&&i!==`\\`)return n;let a=i?t.resolve(i):process.cwd();return`${a}${a.endsWith(t.sep)?``:t.sep}${n.slice(i.length)}`}function*rawPathRelativeToCanonicalRoot(e,n,i={},a=!0){assertNoWindowsPathAlias(e),assertNoWindowsPathAlias(n);let o=absolutePathWithRawSegments(e),s=process.platform===`win32`?o.replaceAll(`/`,t.sep):o;if(isForeignWindowsShareOrDevicePath(s,[n]))return;let l=t.parse(s).root,u=s.slice(l.length).split(t.sep),d=u.findLastIndex(e=>e!==``&&e!==`.`),f=l,p=!1,m=process.platform===`win32`?/* @__PURE__ */ new Map:void 0;for(let o=0;o<u.length;o+=1){f+=`${f.endsWith(t.sep)?``:t.sep}${u[o]}`;let s,l=!1;try{let t=pathForWindowsFilesystem(f),m=a?r.lstatSync(t):yield*wait(c.lstat(t));if(l=m.isSymbolicLink(),l&&i.rejectFinalSymlink&&o===d)throw new FsSafeError(`symlink`,`final symlink not allowed`);if(!l&&!m.isDirectory()&&o<u.length-1||(p||=l,s=a?k.native(t):yield*wait(realpathNative(t)),assertNoWindowsPathAlias(s),l&&o<u.length-1&&!(a?r.statSync(pathForWindowsFilesystem(s)):yield*wait(c.stat(pathForWindowsFilesystem(s)))).isDirectory()))return;if(l&&!isPathInside(n,s)&&!isPathInside(s,n))throw new FsSafeError(`outside-workspace`,`symlink prefix resolves outside the root ancestry: ${formatErrorDetail(e)}`)}catch(e){if(e instanceof FsSafeError)throw e;if(l)return;continue}let h=admitPathInsideRoot({rootPath:n,candidatePath:s,rootIdentity:i.rootIdentity,identityCache:m});if(h){if(i.rejectSymlinks&&p)throw new FsSafeError(`symlink`,`symlink path component not allowed`);return[h.relativePath,...u.slice(o+1)].filter(Boolean).join(t.sep)}}}function*pathExists(e,t){try{return(t?r.lstatSync(pathForWindowsFilesystem(e),{throwIfNoEntry:!1}):yield*wait(c.lstat(pathForWindowsFilesystem(e))))!==void 0}catch(e){if(isNotFoundPathError(e))return!1;throw e}}async function resolvePathViaExistingAncestor(e){return K(resolveExistingAncestorProcedure(e,`native`,G))}function*ordinaryExists(e){return r.existsSync(pathForWindowsFilesystem(e))}function resolvePathViaExistingAncestorSync(e){return resolveExistingAncestor(e,`ordinary`)}function resolveExistingAncestor(e,t,n=!1,r=64){return runSync(resolveExistingAncestorProcedure(e,t,!0,n,r))}function*resolveExistingAncestorProcedure(e,n,r,i=!1,a=64){let exists=e=>n===`native`||i?pathExists(e,r):ordinaryExists(e);assertNoWindowsPathAlias(e);let o=resolvePathPreservingWindowsRoot(e);assertNoWindowsPathAlias(o);let s=i?absolutePathWithRawSegments(e):o,c=s,l=t.parse(s).root;for(;c!==l&&!(yield*exists(c));)c=t.dirname(c);if(!(yield*exists(c)))return o;let u;try{u=r?k.native(pathForWindowsFilesystem(c)):yield*wait(realpathNative(pathForWindowsFilesystem(c)))}catch(e){if(!i)return o;if(!isNotFoundPathError(e))throw e;u=yield*resolveSymlinkHopPath(c,n,!1,a,r)}assertNoWindowsPathAlias(u);let d=resolvePathPreservingWindowsRoot(u);assertNoWindowsPathAlias(d);let f=s.slice(c.length);if(i&&f.split(t.sep).includes(`..`))throw new FsSafeError(`symlink`,`symlink target has an unresolved parent component`);let p=c===s?d:t.resolve(d,`.${t.sep}${f}`);return assertNoWindowsPathAlias(p),p}function*resolveSymlinkHopPath(e,n,i,a=64,o=!0){try{let t=o?k.native(e):yield*wait(realpathNative(e));assertNoWindowsPathAlias(t,`filesystem`,`resolved symlink path uses a Windows filesystem namespace alias`);let n=resolvePathPreservingWindowsRoot(t);return assertNoWindowsPathAlias(n,`filesystem`,`resolved symlink path uses a Windows filesystem namespace alias`),n}catch(s){if(isSymlinkOpenError(s)||i&&isNotFoundPathError(s))throw new FsSafeError(`symlink`,`symlink path could not be resolved`,errorCauseOptions(s));if(!isNotFoundPathError(s))throw s;if(a<=0)throw new FsSafeError(`symlink`,`too many unresolved symlink hops`);let l=o?r.readlinkSync(e):yield*wait(c.readlink(e));assertNoWindowsPathAlias(l,`filesystem`,`symlink target uses a Windows filesystem namespace alias`);let u=resolvePathPreservingWindowsRoot(t.dirname(e)),d=yield*resolveExistingAncestorProcedure(t.isAbsolute(l)?l:t.parse(l).root?resolvePathFromBasePreservingWindowsRoot(u,l):`${u}${t.sep}${l}`,n,o,!0,a-1);return assertNoWindowsPathAlias(d,`filesystem`,`resolved symlink path uses a Windows filesystem namespace alias`),d}}const q=!!process.versions.bun&&u()===`win32`;function recursiveMkdirPath(e){return q?absolutePathWithRawSegments(e):e}const J=2**31-1;function scheduleTimeout(e,t){let n;if(Number.isFinite(t)&&t>J){let r=performance.now(),tick=()=>{let i=t-(performance.now()-r);i<=0?e():n=setTimeout(tick,Math.min(i,J))};n=setTimeout(tick,J)}else n=setTimeout(e,t);return()=>clearTimeout(n)}function sleep(e){return new Promise(t=>{scheduleTimeout(t,e)})}function sleepSync(e){e<=0||Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e)}function assertExclusiveCreateStat(e,t){if(t.isSymbolicLink())throw Object.assign(/* @__PURE__ */ Error(`exclusive creation target already exists`),{code:`EEXIST`,syscall:`open`,path:e})}function assertExclusiveCreateLeaf(e){if(process.platform===`win32`)try{assertExclusiveCreateStat(e,r.lstatSync(e))}catch(e){if(!hasNodeErrorCode(e,`ENOENT`))throw e}}function*wait(e){return yield e}async function runAsync(e){let t=e.next();for(;!t.done;){let n;try{n=await t.value}catch(n){t=e.throw(n);continue}t=e.next(n)}return t.value}function runSync(e){let t=e.next();for(;!t.done;)t=e.next(t.value);return t.value}function inspectAtomicIdentity(e,t,n,r=!1,i){return e.asynchronous&&!r?inspectFileIdentity(i?async()=>{let e=await t();return i(e),e}:t,n):inspectFileIdentitySync(i?()=>{let e=t();return i(e),e}:t,n)}var Y=class AtomicIo{asyncFs;syncFs;fchmodSync;asynchronous;constructor(e,t,n){this.asyncFs=e,this.syncFs=t,this.fchmodSync=n,this.asynchronous=e!==void 0}static async(e){return new AtomicIo(e,void 0)}static sync(e,t){return new AtomicIo(void 0,e,t)}wrap(e){return new AtomicFile(this,e)}*open(e,t,n){let i=arguments.length>2,a=r.constants.O_CREAT|r.constants.O_EXCL;if(process.platform===`win32`&&(typeof t==`string`?t.includes(`x`):(t&a)===a))try{assertExclusiveCreateStat(e,yield*this.lstat(e))}catch(e){if(!hasNodeErrorCode(e,`ENOENT`))throw e}let o=this.asyncFs?yield*wait(i?this.asyncFs.open(e,t,n):this.asyncFs.open(e,t)):i?this.syncFs.openSync(e,t,n):this.syncFs.openSync(e,t);return this.wrap(o)}*lstat(e){return this.asyncFs?this.asyncFs===c?r.lstatSync(e):yield*wait(this.asyncFs.lstat(e)):this.syncFs.lstatSync(e)}lstatExact(e,t=!0){return this.asyncFs?t&&this.asyncFs===c?r.lstatSync(e,{bigint:!0}):this.asyncFs.lstat(e,{bigint:!0}):this.syncFs.lstatSync(e,{bigint:!0})}*mkdir(e,t){if(this.asyncFs){let n=this.asyncFs===c?recursiveMkdirPath(e):e;yield*wait(this.asyncFs.mkdir(n,{recursive:!0,mode:t}))}else{let n=this.syncFs===r?recursiveMkdirPath(e):e;this.syncFs.mkdirSync(n,{recursive:!0,mode:t})}}*mkdirExclusive(e,t){this.asyncFs?yield*wait(this.asyncFs.mkdir(e,{recursive:!1,mode:t})):this.syncFs.mkdirSync(e,{recursive:!1,mode:t})}*rename(e,t){this.asyncFs?yield*wait(this.asyncFs.rename(e,t)):this.syncFs.renameSync(e,t)}*remove(e){this.asyncFs?yield*wait(this.asyncFs.rm(e,{force:!0})):this.syncFs.rmSync(e,{force:!0})}*unlink(e){this.asyncFs?yield*wait(this.asyncFs.unlink(e)):this.syncFs.unlinkSync(e)}*delay(e){this.asynchronous?yield*wait(sleep(e)):sleepSync(e)}},AtomicFile=class{io;resource;constructor(e,t){this.io=e,this.resource=t}get fd(){return typeof this.resource==`number`?this.resource:this.resource.fd}*stat(){return typeof this.resource==`number`?this.io.syncFs.fstatSync(this.resource):this.io.asyncFs===c?r.fstatSync(this.resource.fd):yield*wait(this.resource.stat())}statExact(){return typeof this.resource==`number`?this.io.syncFs.fstatSync(this.resource,{bigint:!0}):this.io.asyncFs===c?r.fstatSync(this.resource.fd,{bigint:!0}):this.resource.stat({bigint:!0})}close(){if(typeof this.resource==`number`)this.io.syncFs.closeSync(this.resource);else return this.resource.close()}*sync(){typeof this.resource==`number`?this.io.syncFs.fsyncSync(this.resource):yield*wait(this.resource.sync())}*syncBestEffort(){try{yield*this.sync()}catch(e){if(e?.code!==`EPERM`)throw e}}chmod(e){if(typeof this.resource==`number`){let t=this.io.fchmodSync;t?.(this.resource,e)}else return this.resource.chmod(e)}writeFile(e,t=!1){if(typeof this.resource==`number`)this.io.syncFs.writeFileSync(this.resource,e);else if(t)return this.io.asyncFs.writeFile(this.resource,e);else return this.resource.writeFile(e)}*readFile(e){if(typeof this.resource!=`number`)return yield*wait(readFileHandleBounded(this.resource,1/0));if(e===void 0)return this.io.syncFs.readFileSync(this.resource);let t=this.resource,n=0;return readBoundedSync(1/0,(e,r)=>{let i=this.io.syncFs.readSync(t,e,0,r,n);return n+=i,i},{initialSize:Number.isSafeInteger(e)&&e>=0?e:void 0})}read(e,t,n,r){return typeof this.resource==`number`?this.io.syncFs.readSync(this.resource,e,t,n,r):this.resource.read(e,t,n,r)}write(e,t,n,r){if(typeof this.resource==`number`){let i=this.io.syncFs.writeSync(this.resource,e,t,n,r);if(i===0)throw Error(`Copy fallback write made no progress`);return i}return this.resource.write(e,t,n,r)}*truncate(e){typeof this.resource==`number`?this.io.syncFs.ftruncateSync(this.resource,e):yield*wait(this.resource.truncate(e))}};const X=/* @__PURE__ */ new WeakSet;function rootPathEscapeError(e){let t=Error(e);return X.add(t),t}function isRootPathEscapeError(e){return e instanceof Error&&X.has(e)}function sanitizeRootPathError(e){return e instanceof Error&&(e.message=formatErrorDetail(e.message)),e}function pathEscapeError(e){return rootPathEscapeError(`Path escapes ${e.boundaryLabel} (${shortPath(e.rootPath)}): ${shortPath(e.absolutePath)}`)}function symlinkEscapeError(e){return rootPathEscapeError(`Symlink escapes ${e.boundaryLabel} (${shortPath(e.rootCanonicalPath)}): ${shortPath(e.symlinkPath)}`)}function statIdentityFromNative(e){return e<=9223372036854775807n||process.versions.bun?e:BigInt.asIntN(64,e)}function isNativeStatIdentity(e){return typeof e==`bigint`&&e>=0n&&e<=18446744073709551615n}function getNativeDirectoryObservationBackend(e=!0){if(!e)return;let t=getNativeBinding(`observeDirectory`);return t&&typeof t.observeDirectory==`function`?t:void 0}function validateNativeDirectoryObservation(e){if(!e||!isNativeStatIdentity(e.dev)||!isNativeStatIdentity(e.ino)||typeof e.realPath!=`string`||e.realPath.includes(`\0`)||!t.isAbsolute(e.realPath)&&!t.win32.isAbsolute(e.realPath))throw new FsSafeError(`path-mismatch`,`native directory observation is invalid`);let n=statIdentityFromNative(e.dev),r=statIdentityFromNative(e.ino);return n===e.dev&&r===e.ino?e:{...e,dev:n,ino:r}}function inspectNativeDirectoryObservation(e,t,n,r=process.platform){return inspectFileIdentitySync(()=>validateNativeDirectoryObservation(e.observeDirectory(t)),n,r)}function extendNativeDirectoryObservationGuard(e,t){let n=e;return n.dir=t,n.identity=n,n.nativeDirectoryObservation=!0,n}function isNativeDirectoryObservationGuard(e){return typeof e==`object`&&!!e&&e.nativeDirectoryObservation===!0}var RootPathObservationError=class extends Error{error;parentReceipt;traversalFailure;constructor(e,t,n=!1){super(`root path observation failed`,{cause:e}),this.error=e,this.parentReceipt=t,this.traversalFailure=n,this.name=`RootPathObservationError`}};function straightTraversalPath(e){if(e.length===0)return!1;let t=process.platform===`win32`,n=0;for(let r=0;r<=e.length;r+=1){if(!(r===e.length||e[r]===`/`||t&&e[r]===`\\`))continue;let i=r-n;if(i===0||i===1&&e.charCodeAt(n)===46||i===2&&e.charCodeAt(n)===46&&e.charCodeAt(n+1)===46)return!1;n=r+1}return!0}function createRootPathTraversalObservation(e,t){let{state:n}=e,r=n.finalComponentIndex<0&&(n.relativePath===``||n.relativePath===`.`);if(!t||!e.observationEligible||t.rootGuard.dir!==e.rootCanonicalPath||t.rootGuard.realPath!==e.rootCanonicalPath||e.rootPath!==e.rootCanonicalPath||!r&&!straightTraversalPath(n.relativePath)||!r&&n.finalComponentIndex!==n.segments.length-1)return;if(n.finalComponentIndex>=0){let e=t.kind===`stat`?n.finalComponentIndex-1:n.finalComponentIndex;return{enabled:!0,request:t,targetIndex:n.finalComponentIndex,directoryIndex:e,directoryGuard:e<0?t.rootGuard:void 0,directoryObserver:e<0?void 0:t.directoryObserver}}if(!r)return;let i=t.rootGuard,a=t.kind===`stat`?void 0:t.directoryObserver;if(t.kind===`directory`){if(a)try{let n=inspectNativeDirectoryObservation(a,t.rootGuard.dir,t.rootGuard.identity),r=admitPathInsideRoot({rootPath:e.rootCanonicalPath,candidatePath:n.realPath,rootIdentity:e.resolveParams.rootIdentity});if(!r||r.relativePath!==``)throw new FsSafeError(`path-mismatch`,`root path changed during operation`);n.realPath=r.path,i=extendNativeDirectoryObservationGuard(n,t.rootGuard.dir)}catch(e){if(e instanceof FsSafeError&&e.code===`path-mismatch`)throw new RootPathObservationError(e);a=void 0}if(!a)try{let n=admitPathInsideRoot({rootPath:e.rootCanonicalPath,candidatePath:k.native(t.rootGuard.dir),rootIdentity:e.resolveParams.rootIdentity});if(!n||n.relativePath!==``)throw new FsSafeError(`path-mismatch`,`root path changed during operation`)}catch(e){throw new RootPathObservationError(e)}}return{enabled:!0,request:t,targetIndex:-1,directoryIndex:-1,directoryGuard:i,directoryObserver:a,targetPath:e.rootCanonicalPath,target:i}}function inspectRootPathTraversalEntry(e,t,n){if(t&&n.directoryObserver)try{return extendNativeDirectoryObservationGuard(inspectNativeDirectoryObservation(n.directoryObserver,e),e)}catch{n.directoryObserver=void 0}let i=process.platform===`win32`?r.lstatSync(e,{bigint:!0}):r.lstatSync(e);if(i.isSymbolicLink()||t&&!i.isDirectory())return{stat:i};try{return inspectStatObservationSync(t=>t?r.lstatSync(e,{bigint:!0}):r.lstatSync(e),void 0,i)}catch(e){throw e instanceof FsSafeError&&e.code===`path-mismatch`?new RootPathObservationError(e):e}}function captureRootPathObservedDirectory(e,t,n,r,i,a){if(!isNativeDirectoryObservationGuard(t)&&!t.stat.isDirectory())return!1;let o;try{o=isNativeDirectoryObservationGuard(t)?t.realPath:k.native(r)}catch(e){throw new RootPathObservationError(e)}let s=admitPathInsideRoot({rootPath:i,candidatePath:o,rootIdentity:a});if(!s)throw new RootPathObservationError(new FsSafeError(`outside-workspace`,`directory is outside workspace root`));return isNativeDirectoryObservationGuard(t)?(t.dir=n,t.realPath=s.path,e.directoryGuard=t):e.directoryGuard=extendDirectoryObservationGuard(t,n,s.path),!0}const Z={strict:Object.freeze({allowFinalSymlinkForUnlink:!1,allowFinalHardlinkForUnlink:!1}),unlinkTarget:Object.freeze({allowFinalSymlinkForUnlink:!0,allowFinalHardlinkForUnlink:!0})};async function resolveRootPath(e){return K(resolveRootPathInternal(e))}async function resolveRootPathWithObservation(e,t){let n={request:t},r=G?runSync(resolveRootPathInternal(e,{observation:n})):await K(resolveRootPathInternal(e,{observation:n}));return n.receipt?{resolved:r,receipt:n.receipt}:{resolved:r}}async function resolveRootPathForRemoval(e,t){return runSync(resolveRootPathInternal(e,{removalReceipts:t},!0))}function resolveRootPathSync(e){return runSync(resolveRootPathInternal(e,{mode:`ordinary`},!0))}function resolveRootPathSyncWithCanonicalRootObservation(e,t){return runSync(resolveRootPathInternal(e,{mode:`ordinary`,observeRoot:t},!0))}function*resolveRootPathInternal(e,t={},n=G){try{return yield*traverseRootPath(e,t,n)}catch(e){throw sanitizeRootPathError(e)}}function*prepareRootTraversal(e,n,r,i,a,o){let s=a,c=!1;if(isForeignWindowsShareOrDevicePath(s,[n,r]))throw pathEscapeError({rootPath:n,absolutePath:s,boundaryLabel:e.boundaryLabel});let l=admitRawPathInsideRoot(n,s,e.rootIdentity);if(l)s=l.path,c=l.admission===`identity`;else{let i=admitRawPathInsideRoot(r,s,e.rootIdentity),a=i?.relativePath??(yield*rawPathRelativeToCanonicalRoot(s,r,e,o));if(a===void 0)throw pathEscapeError({rootPath:n,absolutePath:s,boundaryLabel:e.boundaryLabel});c=i?.admission===`identity`,s=a===``?n:`${n}${t.sep}${a}`}return{params:e,rawAbsolutePath:s,rootPath:n,rootCanonicalPath:r,absolutePath:c?resolvePathPreservingWindowsRoot(s):i,observationEligible:s===a&&!c}}function captureValidRootPathInputs(e){let t=e.rootPath;assertNoNulPathInput(t,`root path contains a NUL byte`);let n=e.absolutePath;assertNoNulPathInput(n,`absolute path contains a NUL byte`),assertNoWindowsPathAlias(t,`filesystem`,`root path uses a Windows filesystem namespace alias`),assertNoWindowsPathAlias(n,`filesystem`,`absolute path uses a Windows filesystem namespace alias`),assertNoEmbeddedDriveRelativeSegment(t,`root path`),assertNoEmbeddedDriveRelativeSegment(n,`absolute path`);let r=e.rootCanonicalPath;r!==void 0&&(assertNoNulPathInput(r,`canonical root path contains a NUL byte`),assertNoWindowsPathAlias(r,`filesystem`,`canonical root path uses a Windows filesystem namespace alias`),assertNoEmbeddedDriveRelativeSegment(r,`canonical root path`));let i=e.policy,a=e.rootIdentity;return{rootPath:t,absolutePath:n,rootCanonicalPath:r,rootIdentity:a==null?void 0:{dev:a.dev,ino:a.ino},boundaryLabel:e.boundaryLabel,policy:i==null?void 0:{allowFinalSymlinkForUnlink:i.allowFinalSymlinkForUnlink},rejectSymlinks:e.rejectSymlinks,rejectFinalSymlink:e.rejectFinalSymlink,rejectUnresolvedSymlinks:e.rejectUnresolvedSymlinks}}function assertNoEmbeddedDriveRelativeSegment(e,n){if(process.platform!==`win32`)return;let r=t.parse(e).root;assertNoDriveRelativePathSegments(e.slice(r.length).replaceAll(`\\`,`/`),n)}function createLexicalTraversalContext(e){let t=admitRawPathInsideRoot(e.rootPath,e.rawAbsolutePath,e.params.rootIdentity)?.relativePath;if(t===void 0)throw Error(`Path traversal must begin at the root`);let n=splitTraversalSegments(t);return{state:{segments:n,relativePath:t,reuseLexicalCanonical:!1,finalComponentIndex:n.findLastIndex(e=>e!==`.`),allowFinalSymlink:e.params.policy?.allowFinalSymlinkForUnlink===!0,canonicalCursor:e.rootCanonicalPath,lexicalCursor:e.rootPath,preserveFinalSymlink:!1,missingDepth:0},resolveParams:e.params,rootPath:e.rootPath,rootCanonicalPath:e.rootCanonicalPath,absolutePath:e.absolutePath,observationEligible:e.observationEligible}}function createLexicalTraversalObservation(e,t){let n=createRootPathTraversalObservation(e,t);return n&&n.targetIndex>=0&&(e.state.reuseLexicalCanonical=!0),n}function splitTraversalSegments(e){let t=e.split(process.platform===`win32`?/[\\/]+/:/\/+/).filter(Boolean);return(e.endsWith(`/`)||process.platform===`win32`&&e.endsWith(`\\`))&&t.push(`.`),t}function admitRawPathInsideRoot(e,n,r){if(!t.isAbsolute(n))return;let i=e,a=process.platform===`win32`?n.replaceAll(`/`,t.sep):n;if(process.platform===`win32`)return admitPathInsideRoot({rootPath:i,candidatePath:a,rootIdentity:r});if(a===i)return{admission:`exact`,path:a,relativePath:``};let o=i.endsWith(t.sep)?i:`${i}${t.sep}`;return a.slice(0,o.length)===o?{admission:`exact`,path:a,relativePath:a.slice(o.length)}:void 0}function assertLexicalCursorInsideBoundary(e,t){return assertInsideBoundary({boundaryLabel:e.resolveParams.boundaryLabel,rootCanonicalPath:e.rootCanonicalPath,rootIdentity:e.resolveParams.rootIdentity,candidatePath:t,absolutePath:e.absolutePath})}function advanceCanonicalCursorForSegment(e,t){let n=e.state.reuseLexicalCanonical?e.state.lexicalCursor:resolvePathFromBasePreservingWindowsRoot(e.state.canonicalCursor,t);e.state.canonicalCursor=assertLexicalCursorInsideBoundary(e,n)}function disableLexicalTraversalObservation(e,t){t.enabled=!1,e.state.reuseLexicalCanonical=!1}function finalizeLexicalResolution(e,t){return e.state.canonicalCursor=assertLexicalCursorInsideBoundary(e,e.state.canonicalCursor),{absolutePath:e.absolutePath,canonicalPath:e.state.canonicalCursor,rootPath:e.rootPath,rootCanonicalPath:e.rootCanonicalPath,relativePath:relativeInsideRoot(e.rootCanonicalPath,e.state.canonicalCursor),exists:t!==`missing`,kind:t}}function applyResolvedSymlinkHop(e,t){let n;try{n=assertLexicalCursorInsideBoundary(e,t)}catch{throw symlinkEscapeError({boundaryLabel:e.resolveParams.boundaryLabel,rootCanonicalPath:e.rootCanonicalPath,symlinkPath:e.state.lexicalCursor})}e.state.canonicalCursor=n,e.state.lexicalCursor=n}function applyParentTraversalStep(e){e.state.lexicalCursor=resolvePathFromBasePreservingWindowsRoot(e.state.lexicalCursor,`..`),advanceCanonicalCursorForSegment(e,`..`),e.state.missingDepth>0&&--e.state.missingDepth}function assertDirectoryBeforeMoreSegments(e,t,n){if(!n&&!e.isDirectory())throw Object.assign(/* @__PURE__ */ Error(`Path component is not a directory: ${t}`),{code:`ENOTDIR`})}function*assertResolvedLinkDirectory(e,t,n){t||assertDirectoryBeforeMoreSegments(n?r.statSync(pathForWindowsFilesystem(e)):yield*wait(c.stat(pathForWindowsFilesystem(e))),e,t)}function*traverseRootPath(e,{mode:n=`native`,observation:i,observeRoot:a,removalReceipts:o},s){let l=captureValidRootPathInputs(e),u=absolutePathWithRawSegments(l.absolutePath),d=resolvePathPreservingWindowsRoot(l.rootPath),f=resolvePathPreservingWindowsRoot(u),p=l.rootCanonicalPath?resolvePathPreservingWindowsRoot(l.rootCanonicalPath):yield*resolveExistingAncestorProcedure(d,n,s);assertNoWindowsPathAlias(d),assertNoWindowsPathAlias(f),assertNoWindowsPathAlias(p),a?.(p);let m=createLexicalTraversalContext(yield*prepareRootTraversal(l,d,p,f,u,s)),{state:h}=m,g=createLexicalTraversalObservation(m,i?.request);for(let e=0;e<h.segments.length;e+=1){let i=h.segments[e]??``,a=e===h.segments.length-1;if(i===`.`)continue;if(i===`..`){applyParentTraversalStep(m);continue}if(h.lexicalCursor=t.join(h.lexicalCursor,i),h.missingDepth>0){advanceCanonicalCursorForSegment(m,i),h.missingDepth+=1;continue}let l,u;try{if(o&&!a){let e=r.lstatSync(pathForWindowsFilesystem(h.lexicalCursor),{bigint:!0});e.isDirectory()&&!e.isSymbolicLink()&&o.observeDirectory(h.lexicalCursor,e),l=e}else{let t=g?.enabled===!0&&e===g.directoryIndex,n=g?.enabled===!0&&e===g.targetIndex;(t||n)&&(u=inspectRootPathTraversalEntry(h.lexicalCursor,t,g)),l=isNativeDirectoryObservationGuard(u)?void 0:u?.stat??(s?r.lstatSync(h.lexicalCursor):yield*wait(c.lstat(h.lexicalCursor)))}}catch(t){if(g?.enabled&&g.request.kind===`stat`&&e===g.targetIndex&&g.directoryGuard){let e={kind:`stat-parent`,rootGuard:g.request.rootGuard,directoryGuard:g.directoryGuard,directoryObserver:g.directoryObserver,targetPath:h.lexicalCursor};throw new RootPathObservationError(t instanceof RootPathObservationError?t.error:sanitizeRootPathError(t),e,!(t instanceof RootPathObservationError))}if(!isNotFoundPathError(t))throw t;advanceCanonicalCursorForSegment(m,i),h.missingDepth=1;continue}if(isNativeDirectoryObservationGuard(u)){advanceCanonicalCursorForSegment(m,i),captureRootPathObservedDirectory(g,u,h.lexicalCursor,h.canonicalCursor,m.rootCanonicalPath,m.resolveParams.rootIdentity),e===g.targetIndex&&(g.targetPath=h.canonicalCursor,g.target=u);continue}if(!l)throw Error(`directory observation did not return metadata`);let d=l.isSymbolicLink();if(d||assertDirectoryBeforeMoreSegments(l,h.lexicalCursor,a),d&&(m.resolveParams.rejectFinalSymlink===!0&&e===h.finalComponentIndex||m.resolveParams.rejectSymlinks===!0&&a))throw new FsSafeError(`symlink`,`symlink path component not allowed`);let f=d&&h.allowFinalSymlink&&a;if(!d||f){if(h.preserveFinalSymlink=f,advanceCanonicalCursorForSegment(m,i),g?.enabled&&d&&disableLexicalTraversalObservation(m,g),g?.enabled&&e===g.directoryIndex&&(u?.identity&&captureRootPathObservedDirectory(g,u,h.canonicalCursor,h.canonicalCursor,m.rootCanonicalPath,m.resolveParams.rootIdentity)||disableLexicalTraversalObservation(m,g)),g?.enabled&&e===g.targetIndex&&(g.targetPath=h.canonicalCursor,g.target=u?.identity?u:void 0),h.preserveFinalSymlink)break;continue}g?.enabled&&disableLexicalTraversalObservation(m,g);let p=yield*resolveSymlinkHopPath(h.lexicalCursor,n,m.resolveParams.rejectUnresolvedSymlinks,64,s);if(applyResolvedSymlinkHop(m,p),m.resolveParams.rejectSymlinks===!0)throw new FsSafeError(`symlink`,`symlink path component not allowed`);yield*assertResolvedLinkDirectory(p,a,s)}let _=g?.enabled===!0&&g.directoryGuard!==void 0&&g.targetPath===h.canonicalCursor&&g.target!==void 0,v=_?isNativeDirectoryObservationGuard(g.target)?`directory`:toResolvedKind(g.target.stat):yield*getPathKind(h.canonicalCursor,h.preserveFinalSymlink,s);return _&&i&&(i.receipt={kind:g.request.kind,rootGuard:g.request.rootGuard,directoryGuard:g.directoryGuard,directoryObserver:g.directoryObserver,targetPath:g.targetPath,target:g.target}),finalizeLexicalResolution(m,v)}function*getPathKind(e,t,n){try{let i=pathForWindowsFilesystem(e);return toResolvedKind(t?n?r.lstatSync(i):yield*wait(c.lstat(i)):n?r.statSync(i):yield*wait(c.stat(i)))}catch(e){if(isNotFoundPathError(e))return`missing`;throw e}}function toResolvedKind(e){return e.isFile()?`file`:e.isDirectory()?`directory`:e.isSymbolicLink()?`symlink`:`other`}function relativeInsideRoot(e,n){let r=t.relative(resolvePathPreservingWindowsRoot(e),resolvePathPreservingWindowsRoot(n));return!r||r===`.`||isPathRelativeEscape(r)?``:r}function assertInsideBoundary(e){let t=admitPathInsideRoot({rootPath:e.rootCanonicalPath,candidatePath:e.candidatePath,rootIdentity:e.rootIdentity});if(t)return t.path;throw Error(`Path resolves outside ${e.boundaryLabel} (${shortPath(e.rootCanonicalPath)}): ${shortPath(e.absolutePath)}`)}function resolveReadOpenFlags(e){let t=e?.constants??r.constants,n=process.platform!==`win32`&&e?.followSymlinks!==!0&&typeof t.O_NOFOLLOW==`number`?t.O_NOFOLLOW:0,i=process.platform!==`win32`&&typeof t.O_NONBLOCK==`number`?t.O_NONBLOCK:0;return t.O_RDONLY|n|i}function exactFileIdentity(e){let{dev:t,ino:n}=e;if(typeof t!=`bigint`&&!Number.isSafeInteger(t)||typeof n!=`bigint`&&!Number.isSafeInteger(n))throw new FsSafeError(`path-mismatch`,`file identity is not exact`);return Object.freeze({dev:BigInt(t),ino:BigInt(n)})}function numberStatScalar(e){return Number(typeof e==`bigint`?BigInt.asUintN(64,e):e)}function numberStats(e){let t=Object.create(r.Stats.prototype);for(let n of[`dev`,`mode`,`nlink`,`uid`,`gid`,`rdev`,`blksize`,`ino`,`size`,`blocks`])t[n]=numberStatScalar(e[n]);for(let n of[`atime`,`mtime`,`ctime`,`birthtime`]){let r=e[`${n}Ns`],i=(r%1000000000n+1000000000n)%1000000000n;t[`${n}Ms`]=Number((r-i)/1000000000n)*1e3+Number(i)/1e6}return t}function readSymlinkResolution(e){return{rejectSymlinks:e!==`follow-within-root`&&e!==`follow-parents-within-root`,rejectFinalSymlink:e===`follow-parents-within-root`}}function mutationSymlinkResolution(e){if(e!==void 0&&e!==`reject`&&e!==`follow-parents-within-root`)throw RangeError(`mutationSymlinks must be reject or follow-parents-within-root`);return{rejectSymlinks:e===`reject`,rejectFinalSymlink:e!==void 0,resolveCanonical:e!==void 0}}function assertFinalSymlinkRejected(e,t,n){if(t)try{if(r.lstatSync(e).isSymbolicLink())throw new FsSafeError(`symlink`,`final symlink not allowed`,{details:n})}catch(e){if(!isNotFoundPathError(e))throw e}}function isExpectedPathError(e){let t=typeof e==`object`&&e&&`code`in e?String(e.code):``;return t===`ENOENT`||t===`ENOTDIR`||t===`ELOOP`}function openPinnedFileSync(e){let t=e.filePath,n=e.resolvedPath,i=e.ioFs??r,a=e.allowedType??`file`,o=e.rejectPathSymlink===!0,s={rejectHardlinks:e.rejectHardlinks,rejectLeafSymlinks:e.rejectLeafSymlinks,maxBytes:e.maxBytes},c=resolveReadOpenFlags({constants:i.constants}),l=e.admittedFd??null;try{if(assertNoWindowsPathAlias(t,`filesystem`,`file path uses a Windows filesystem namespace alias`),n!==void 0&&assertNoWindowsPathAlias(n,`filesystem`,`resolved path uses a Windows filesystem namespace alias`),isUnsafeDeviceReadPath(t)||o&&i.lstatSync(t).isSymbolicLink())return{ok:!1,reason:`validation`};let u=n??(i===r?k(t):i.realpathSync(t));if(assertNoWindowsPathAlias(u,`filesystem`,`resolved path uses a Windows filesystem namespace alias`),isUnsafeDeviceReadPath(u))return{ok:!1,reason:`validation`};let d=inspectFileIdentitySync(()=>{let e=i.lstatSync(u,{bigint:!0});return assertAllowedStat(e,a,s),e});l??=i.openSync(u,c);let f=inspectFileIdentitySync(()=>{let e=i.fstatSync(l,{bigint:!0});return assertAllowedStat(e,a,s),e},d);inspectFileIdentitySync(()=>{let e=i.lstatSync(u,{bigint:!0});return assertAllowedStat(e,a,s),e},f);let p=e.finalAdmission?.({path:u,descriptorIdentity:f})??u,m=numberStats(f),h={ok:!0,path:p,fd:l,stat:m,identity:f};return l=null,h}catch(e){return e instanceof FsSafeError?{ok:!1,reason:`validation`,error:e}:isExpectedPathError(e)?{ok:!1,reason:`path`,error:e}:{ok:!1,reason:`io`,error:e}}finally{if(l!==null)try{i.closeSync(l)}catch{}}}function assertAllowedStat(e,t,n){if(e.isSymbolicLink()&&n.rejectLeafSymlinks)throw new FsSafeError(`symlink`,`symlink not allowed`);if(e.isSymbolicLink()||!(t===`directory`?e.isDirectory():e.isFile()))throw new FsSafeError(`not-file`,`path does not have the required file type`);if(n.rejectHardlinks&&e.isFile()&&e.nlink>1n)throw new FsSafeError(`hardlink`,`path must not be hardlinked`);if(n.maxBytes!==void 0&&e.isFile()&&e.size>n.maxBytes)throw new FsSafeError(`too-large`,`file exceeds byte limit`)}function rootIdentityMismatch(e){return new FsSafeError(`path-mismatch`,`canonical root directory identity changed or could not be verified`,e===void 0?{}:{cause:e})}function inspectCanonicalRoot(e,t,n){try{assertNoWindowsPathAlias(t);let i=e===r?pathForWindowsFilesystem(t):t;return inspectFileIdentitySync(()=>{let t=e.lstatSync(i,{bigint:!0});if(!t.isDirectory()||t.isSymbolicLink())throw rootIdentityMismatch();return t},n)}catch(e){throw n&&isExpectedPathError(e)?rootIdentityMismatch(e):e}}function observeCanonicalRoot(e,t){try{let n=inspectCanonicalRoot(e,t),i=Object.freeze({dev:n.dev,ino:n.ino}),a=t;return e===r&&(a=k.native(pathForWindowsFilesystem(t)),a!==t&&inspectCanonicalRoot(e,a,i)),{ok:!0,path:a,identity:i}}catch(e){return{ok:!1,error:e}}}function resolveConsumedPath(e,t){return e===r?k.native(t):e.realpathSync(t)}function createRootFileFinalAdmission(e,t,n,r=!0){let inspectRoot=(t,n)=>{inspectCanonicalRoot(e,t,n)};return({path:i,descriptorIdentity:a})=>{inspectCanonicalRoot(e,t.path,t.identity);let o=resolveConsumedPath(e,i);assertNoWindowsPathAlias(o,`filesystem`,`resolved file path uses a Windows filesystem namespace alias`);let s=admitPathInsideRoot({rootPath:t.path,candidatePath:o,rootIdentity:t.identity,inspectCandidateRoot:inspectRoot});if(!s)throw new FsSafeError(`outside-workspace`,`resolved path escapes ${n}`);try{let t=inspectFileIdentitySync(()=>e.lstatSync(s.path,{bigint:!0}),a);if(r&&t.isFile()&&t.nlink>1n)throw hardlinkedPathNotAllowedError()}catch(e){throw isExpectedPathError(e)?new FsSafeError(`path-mismatch`,`canonical file identity changed or could not be verified`,{cause:e}):e}return inspectCanonicalRoot(e,t.path,t.identity),s.path}}function canUseRootFileOpen(e){return typeof e.openSync==`function`&&typeof e.closeSync==`function`&&typeof e.fstatSync==`function`&&typeof e.lstatSync==`function`&&typeof e.realpathSync==`function`&&typeof e.readFileSync==`function`&&typeof e.constants==`object`&&e.constants!==null}function absoluteRootFilePath(e){if(t.isAbsolute(e))return e;let n=t.parse(e).root;return`${n?t.resolve(n):process.cwd()}${t.sep}${e.slice(n.length)}`}function openRootFileSync(e){let t=e.ioFs??r,n=e.absolutePath,i;try{let r=absoluteRootFilePath(n);assertNoWindowsPathAlias(r);let a=e.rootPath,o=e.rootRealPath,s=e.boundaryLabel,c;i=mapResolvedRootPath(r,s,resolveRootPathSyncWithCanonicalRootObservation({absolutePath:r,rootPath:a,rootCanonicalPath:o,boundaryLabel:s,...readSymlinkResolution(e.symlinks??(e.rejectSymlinks===!1?`follow-within-root`:`reject`)),skipLexicalRootCheck:e.skipLexicalRootCheck},e=>{c=observeCanonicalRoot(t,e)}),c)}catch(e){i=toBoundaryValidationError(e)}return finalizeRootFileOpen({resolved:i,maxBytes:e.maxBytes,rejectHardlinks:e.rejectHardlinks,allowedType:e.allowedType,ioFs:t})}function finalizeRootFileOpen(e){if(`ok`in e.resolved)return e.resolved;let t=e.resolved,n=e.rejectHardlinks??!0,r=openPinnedFileSync({filePath:t.absolutePath,resolvedPath:t.resolvedPath,rejectHardlinks:n,maxBytes:e.maxBytes,allowedType:e.allowedType,ioFs:e.ioFs,admittedFd:e.admittedFd,rejectLeafSymlinks:e.rejectLeafSymlinks,finalAdmission:createRootFileFinalAdmission(e.ioFs,t.rootObservation,t.boundaryLabel,n)});return r.ok?{ok:!0,path:r.path,fd:r.fd,stat:r.stat,exactIdentity:exactFileIdentity(r.identity),rootRealPath:t.rootRealPath}:r}function toBoundaryValidationError(e){return{ok:!1,reason:`validation`,error:e}}function mapResolvedRootPath(e,t,n,r){return r?r.ok?{absolutePath:e,resolvedPath:n.canonicalPath,rootRealPath:r.path,boundaryLabel:t,rootObservation:r}:toRootObservationError(r.error):toBoundaryValidationError(new FsSafeError(`path-mismatch`,`canonical root identity was not observed`))}function toRootObservationError(e){return e instanceof FsSafeError?toBoundaryValidationError(e):isExpectedPathError(e)?{ok:!1,reason:`path`,error:e}:{ok:!1,reason:`io`,error:e}}const Q=2147e6;function createAbortError(e,t){let n=Error(e,t);return n.name=`AbortError`,n}function racePromiseWithAbortSignal(e,t,n=e=>createAbortError(`Operation aborted`,{cause:e.reason})){let run=()=>{try{return typeof e==`function`?e():e}catch(e){return Promise.reject(e)}};if(!t)return run();let abortError=()=>n(t);if(t.aborted){let t=Promise.reject(abortError());return typeof e==`function`?t:Promise.race([t,e])}let onAbort,r=new Promise((e,n)=>{onAbort=()=>n(abortError()),t.addEventListener(`abort`,onAbort,{once:!0})});return Promise.race([run(),r]).finally(()=>{t.removeEventListener(`abort`,onAbort)})}async function raceWithTimeout(e,t,n,r={}){let i,onAbort;try{let a=new Promise((e,a)=>{let settle=t=>{try{e(t())}catch(e){a(e)}};i=setTimeout(()=>settle(n),t),r.ref===!1&&i.unref?.();let o=r.signal;o&&(onAbort=()=>settle(()=>{if(r.onAbort)return r.onAbort(o);throw createAbortError(`Operation aborted`,{cause:o.reason})}),o.addEventListener(`abort`,onAbort,{once:!0}),o.aborted&&onAbort())}),o;try{o=typeof e==`function`?e():e}catch(e){throw a.catch(()=>{}),e}return await Promise.race([o,a])}finally{clearTimeout(i),onAbort&&r.signal?.removeEventListener(`abort`,onAbort)}}function resolveSleepDelayMs(e){return Number.isFinite(e)&&e>0?Math.min(Math.max(Math.floor(e),1),Q):0}async function sleepWithAbort(e,t,n={}){let r=resolveSleepDelayMs(e);r!==0&&await new Promise((e,i)=>{let cleanup=()=>t?.removeEventListener(`abort`,onAbort),a=setTimeout(()=>{cleanup(),e()},r),onAbort=()=>{clearTimeout(a),cleanup(),i(createAbortError(`aborted`,{cause:t?.reason??/* @__PURE__ */ Error(`aborted`)}))};t?.addEventListener(`abort`,onAbort,{once:!0}),t?.aborted?onAbort():n.ref===!1&&a.unref?.()})}const $={attempts:3,minDelayMs:300,maxDelayMs:3e4,jitter:0},defaultSleep=async e=>{let t=e;do{let e=Math.min(t,Q);await new Promise(t=>{setTimeout(t,e)}),t-=e}while(t>0)};function clampNumber(e,t,n,r){return typeof e!=`number`||!Number.isFinite(e)?t:Math.min(Math.max(e,n??-1/0),r??1/0)}function resolveRetryDelayMs(e){return Math.min(Math.max(Math.round(e===1/0?Q:Number.isFinite(e)?e:0),0),Q)}function resolveRetryConfig(e=$,t){let n=Math.max(1,Math.round(clampNumber(t?.attempts,e.attempts))),r=resolveRetryDelayMs(clampNumber(t?.minDelayMs,e.minDelayMs,0)),i=Math.max(r,resolveRetryDelayMs(clampNumber(t?.maxDelayMs,e.maxDelayMs,0))),a=t?.jitter,o=e.jitter;return{attempts:n,minDelayMs:r,maxDelayMs:i,jitter:a===`full`?a:typeof a==`number`&&Number.isFinite(a)?Math.min(Math.max(a,0),1):o}}function applyJitter(e,t,n,r){if(t===`full`)return n===`symmetric`?Math.max(0,Math.round(e*(.5+r()*.5))):Math.max(0,Math.ceil(e*(1+r())));if(t<=0)return n===`positive`?Math.ceil(e):e;let i=r(),a=e*(1+(n===`positive`?i*t:(i*2-1)*t));return Math.max(0,n===`positive`?Math.ceil(a):Math.round(a))}function toRetryError(e,t=`Non-Error thrown`){if(e instanceof Error)return e;if(typeof e==`string`)return Error(e);let n=Error(t,{cause:e});return(typeof e==`object`&&e||typeof e==`function`)&&Object.assign(n,e),n}function createRetryRunner(e={}){let t=e.sleep??defaultSleep,n=e.random??Math.random,r=e.createFailure??(e=>toRetryError(e.at(-1)??/* @__PURE__ */ Error(`Retry failed`)));return async function(i,a=3,o=300){let s=[],c=typeof a==`number`,l=typeof a==`number`?{attempts:a}:a,u=resolveRetryConfig($,l),d=u.attempts,f=u.minDelayMs,p=u.maxDelayMs>0?u.maxDelayMs:1/0,m=l.retryAfterMaxDelayMs===void 0?p:Math.max(f,resolveRetryDelayMs(clampNumber(l.retryAfterMaxDelayMs,p,0))),h=l.random??n,g=l.sleep??t,_=l.shouldRetry??(()=>!0);for(let n=1;n<=d;n+=1)try{return await i()}catch(r){if(s.push(r),n>=d||e.shouldRetry?.(r)===!1||!_(r,n))break;if(c){await t(resolveRetryDelayMs(o*2**(n-1)));continue}let i={attempt:n,maxAttempts:d,err:r,label:l.label},a=l.retryAfterMs?.(r),v=typeof a==`number`&&Number.isFinite(a),y=typeof l.delayMs==`function`?l.delayMs(i):l.delayMs,b=y===void 0?void 0:resolveRetryDelayMs(y),x=v?Math.max(a,f):b===void 0?f*2**(n-1):Math.max(b,f),S=v?m:p,C=Math.min(x,S),w=v&&(a??0)<=S,T=u.jitter===`full`&&!v||w;C=applyJitter(C,u.jitter,T?`positive`:`symmetric`,h),C=Math.min(Math.max(C,f),S),await l.onRetry?.({...i,delayMs:C}),C>0&&await g(C)}throw r(s)}}createRetryRunner();function createRuntimeProcessEntrypoints(e){function runtimeProcessEntrypoint(t,n=t,r=`.js`,i){return{currentModuleUrl:e,sourceModulePath:`src/${t}${i??`.ts`}`,sourceExtension:i,sourceWorkerName:t.startsWith(`infra/`)?t.slice(6):`../${t}`,distWorkerPath:`${n}${r}`}}let loaderFreeEntrypoint=e=>runtimeProcessEntrypoint(e,void 0,void 0,`.mjs`);return{daemonRuntimeProbe:runtimeProcessEntrypoint(`infra/daemon-runtime-probe.entry`),pluginToolsServe:runtimeProcessEntrypoint(`mcp/plugin-tools-serve`),openclawToolsServe:runtimeProcessEntrypoint(`mcp/openclaw-tools-serve`),repositoryPublicationRestore:loaderFreeEntrypoint(`gateway/repository-publication-restore.generated.worker`),nodeWorkspacePublicationSnapshot:loaderFreeEntrypoint(`node-host/node-worker-publication-snapshot.generated.worker`),nodeWorkspaceManifest:loaderFreeEntrypoint(`node-host/node-worker-workspace-manifest.generated.worker`),nodeWorkspaceGitHistory:loaderFreeEntrypoint(`node-host/node-worker-workspace-git-history.generated.worker`),doctorDatabaseEngineInspection:runtimeProcessEntrypoint(`commands/doctor-database-engine-inspection.worker`),backupDatabaseDiscovery:runtimeProcessEntrypoint(`infra/backup-database-discovery.worker`),sqliteHeaderProbe:runtimeProcessEntrypoint(`infra/sqlite-header-probe.worker`),databaseBackup:runtimeProcessEntrypoint(`snapshot/database-backup.worker`),managedHandoffEngine:runtimeProcessEntrypoint(`infra/update-managed-service-handoff-engine.worker`),updatePostgresState:runtimeProcessEntrypoint(`infra/update-candidate-state.postgres.worker`),databasePortCommand:runtimeProcessEntrypoint(`infra/database-engine/port-command.entry.worker`),systemCaWarmup:runtimeProcessEntrypoint(`gateway/system-ca-warmup.worker`),shutdownHardExit:loaderFreeEntrypoint(`cli/gateway-cli/shutdown-hard-exit.worker`),packageIntegrityHasher:runtimeProcessEntrypoint(`infra/package-update-integrity-hasher.worker`),packageLocalOverrides:runtimeProcessEntrypoint(`infra/package-local-overrides.worker`),directoryWatchHost:runtimeProcessEntrypoint(`infra/directory-watch-host.worker`),directoryWatchParent:runtimeProcessEntrypoint(`infra/directory-watch-parent.worker`),workspaceQuiescenceAcquire:loaderFreeEntrypoint(`gateway/worker-environments/workspace-quiescence-acquire.generated.worker`),workspaceQuiescenceRenew:loaderFreeEntrypoint(`gateway/worker-environments/workspace-quiescence-renew.generated.worker`),workspaceQuiescenceRelease:loaderFreeEntrypoint(`gateway/worker-environments/workspace-quiescence-release.generated.worker`),packageActivationRecovery:runtimeProcessEntrypoint(`infra/package-update-activation-sealed`,`package-update-activation-recovery`,`.mjs`),managedHandoffPostgresBridge:runtimeProcessEntrypoint(`infra/update-managed-service-handoff-postgres.worker`,`managed-handoff-postgres-bridge.worker`,`.mjs`),managedHandoffRuntime:runtimeProcessEntrypoint(`infra/update-managed-service-handoff-sealed`,`managed-handoff-runtime`,`.mjs`),sqliteVector:runtimeProcessEntrypoint(`infra/database-engine/sqlite-vector.child`),postgresBridge:runtimeProcessEntrypoint(`infra/postgres-sync/bridge.worker`),secretEgressProxy:runtimeProcessEntrypoint(`secrets/egress-proxy/proxy.worker`),codeModeNode:runtimeProcessEntrypoint(`agents/code-mode-node.worker`),cronReadOnly:runtimeProcessEntrypoint(`cron/store/read-only.worker`),stateRead:runtimeProcessEntrypoint(`state/openclaw-state-read.worker`),workerNativeLifecycle:runtimeProcessEntrypoint(`infra/worker-native-lifecycle.worker`),spawnBroker:runtimeProcessEntrypoint(`process/spawn-broker/worker`),cronStreamMatcher:runtimeProcessEntrypoint(`gateway/cron-stream-matcher.worker`),controlUiFile:runtimeProcessEntrypoint(`gateway/control-ui-file.worker`),publicSessionCard:runtimeProcessEntrypoint(`gateway/control-ui-public-session-card.worker`),nodeBootstrapArtifact:runtimeProcessEntrypoint(`gateway/worker-environments/node-bootstrap-artifact.worker`),nativeHookRelayClient:runtimeProcessEntrypoint(`agents/harness/native-hook-relay-client.worker`),computerHost:runtimeProcessEntrypoint(`gateway/desktop/computer.worker`),imageProcessor:runtimeProcessEntrypoint(`media/image-processor.worker`),fileToolPlanning:runtimeProcessEntrypoint(`agents/sessions/tools/file-tool-planning.worker`),fileToolRead:runtimeProcessEntrypoint(`agents/sessions/tools/read-file.worker`),attachmentProcessor:runtimeProcessEntrypoint(`media/attachment-processor.worker`),widgetScriptSyntax:runtimeProcessEntrypoint(`canvas/widget-script-syntax.worker`),gitOperations:runtimeProcessEntrypoint(`infra/git-operation.worker`),gitPackCleanup:runtimeProcessEntrypoint(`agents/worktrees/git-pack-cleanup.worker`),fsSafeCopy:runtimeProcessEntrypoint(`infra/fs-safe-copy.worker`),sharedStateStore:runtimeProcessEntrypoint(`state/openclaw-state.worker`),clientCredentials:runtimeProcessEntrypoint(`infra/client-credential.worker`),ttsPreferences:runtimeProcessEntrypoint(`tts/tts-settings-write.worker`),authProfileInlineUsage:runtimeProcessEntrypoint(`agents/auth-profiles/inline-usage.worker`),pluginModelCatalogRead:runtimeProcessEntrypoint(`agents/plugin-model-catalog-read.worker`),pluginModelCatalogCredentials:runtimeProcessEntrypoint(`agents/plugin-model-catalog.worker`),pluginCaptureNativeResource:runtimeProcessEntrypoint(`plugins/plugin-capture-native-resource`),pluginGenerationPreparation:runtimeProcessEntrypoint(`plugins/plugin-generation-preparation.worker`),agentDatabaseExecution:runtimeProcessEntrypoint(`state/openclaw-agent-execution.worker`),workspaceMemory:runtimeProcessEntrypoint(`worker/memory-worker-entry`,`agents/workspace-memory.worker`),localAgentAvatar:runtimeProcessEntrypoint(`agents/identity-avatar-file.worker`),identityFile:runtimeProcessEntrypoint(`agents/identity-file.worker`),workspaceSkills:runtimeProcessEntrypoint(`worker/skills-worker-entry`,`agents/workspace-skills.worker`),skillsDiscovery:runtimeProcessEntrypoint(`skills/runtime/discovery.worker`),boardStore:runtimeProcessEntrypoint(`boards/sqlite-board-store.worker`),progressCardStore:runtimeProcessEntrypoint(`session-cards/progress-card-store.worker`),sessionSharingStore:runtimeProcessEntrypoint(`config/sessions/session-sharing-store.worker`),sessionForkDomain:runtimeProcessEntrypoint(`config/sessions/session-fork-domain.worker`),sessionGoalOperations:runtimeProcessEntrypoint(`config/sessions/goals-operations.worker`),sessionLifecyclePlanningDomain:runtimeProcessEntrypoint(`config/sessions/session-lifecycle-projection.worker`),sessionMessageRewriteDomain:runtimeProcessEntrypoint(`config/sessions/session-message-rewrite.worker`),sessionDiskBudget:runtimeProcessEntrypoint(`config/sessions/disk-budget.worker`),contextEngineTurnOutbox:runtimeProcessEntrypoint(`agents/harness/context-engine-turn-outbox.worker`),sqliteStore:runtimeProcessEntrypoint(`infra/sqlite-store.worker`),sqliteWriterAdmission:runtimeProcessEntrypoint(`infra/sqlite-writer-admission.worker`),agentSchemaInspection:runtimeProcessEntrypoint(`state/openclaw-agent-schema-inspection.worker`),stateMigrationSnapshot:runtimeProcessEntrypoint(`infra/state-migrations.snapshot.worker`),githubExec:runtimeProcessEntrypoint(`agents/github-exec-launcher`),shellSnapshotEnvironment:runtimeProcessEntrypoint(`agents/shell-snapshot-env.worker`),sqliteReadOnly:runtimeProcessEntrypoint(`infra/sqlite-readonly-location.worker`),sqliteSnapshotStaging:runtimeProcessEntrypoint(`infra/sqlite-snapshot-staging.worker`),sqliteReadOnlyNativeResource:runtimeProcessEntrypoint(`infra/sqlite-readonly-native-resource`),sqliteSourceRevision:runtimeProcessEntrypoint(`infra/sqlite-source-revision.worker`),sqliteIntegrity:runtimeProcessEntrypoint(`infra/sqlite-integrity.worker`),sqliteCloseProbe:runtimeProcessEntrypoint(`infra/bun-sqlite-close-probe.worker`),preparedModelCatalog:runtimeProcessEntrypoint(`agents/prepared-model-catalog.worker`),providerPromptState:runtimeProcessEntrypoint(`agents/embedded-agent-runner/provider-prompt-state.worker`),retiredWorktreeCleanup:runtimeProcessEntrypoint(`agents/worktrees/retired-worktree-cleanup.worker`),updateNativeGate:runtimeProcessEntrypoint(`cli/update-cli/update-command-native-gate.worker`),updateStateSizes:runtimeProcessEntrypoint(`infra/update-state-sizes.entry`),updateRepair:runtimeProcessEntrypoint(`infra/update-repair.worker`),immutableBuild:runtimeProcessEntrypoint(`infra/update-immutable-build.worker`),updateMigratedFinalize:runtimeProcessEntrypoint(`infra/update-migrated-finalize.worker`),updateAutomaticCleanup:runtimeProcessEntrypoint(`infra/update-automatic-cleanup.worker`),updateCandidateState:runtimeProcessEntrypoint(`infra/update-candidate-state.worker`),doctorLint:runtimeProcessEntrypoint(`commands/doctor-lint.worker`),doctor:runtimeProcessEntrypoint(`commands/doctor.worker`),databaseVerify:runtimeProcessEntrypoint(`state/openclaw-database-verify.worker`),stateOwnership:runtimeProcessEntrypoint(`state/openclaw-state-ownership.worker`),stateLeaseHeartbeat:runtimeProcessEntrypoint(`state/openclaw-state-lease-heartbeat.worker`),gatewayStateOwnerHeartbeat:runtimeProcessEntrypoint(`infra/gateway-state-owner-heartbeat.worker`),sessionTranscriptArchive:runtimeProcessEntrypoint(`config/sessions/session-accessor.sqlite-archive.worker`),sessionTranscript:runtimeProcessEntrypoint(`config/sessions/session-transcript.worker`),usageOverview:runtimeProcessEntrypoint(`infra/session-cost-usage-overview-report.worker`),workerTranscriptCommit:runtimeProcessEntrypoint(`gateway/worker-environments/transcript-commit.worker`),sessionManagerMetadata:runtimeProcessEntrypoint(`agents/sessions/session-manager-metadata.worker`),sessionTranscriptProjectionPublication:runtimeProcessEntrypoint(`config/sessions/session-transcript-projection-publication.worker`),sessionTranscriptReports:runtimeProcessEntrypoint(`config/sessions/session-accessor.sqlite-transcript-reports.worker`),sessionTranscriptReconcile:runtimeProcessEntrypoint(`config/sessions/session-transcript-reconcile.worker`),tailscaleRouteOwner:runtimeProcessEntrypoint(`infra/tailscale-route-owner.worker`),serviceChildRelay:runtimeProcessEntrypoint(`process/supervisor/service-child-relay`),terminalPty:runtimeProcessEntrypoint(`process/terminal-pty-worker`),serviceChildGroupAnchor:runtimeProcessEntrypoint(`process/supervisor/service-child-group-anchor`),serviceChildWindowsJobAnchor:runtimeProcessEntrypoint(`process/supervisor/service-child-windows-job-anchor`),bunSqliteLibrary:runtimeProcessEntrypoint(`infra/bun-sqlite-library`)}}function pluginRuntimeProcess(e,t,n){return{plugin:e,ownerSource:`extensions/${e}/${t}.ts`,sourceWorkerName:n,distWorkerPath:`extensions/${e}/${n}.js`,package:{name:`@openclaw/${e}`,distWorkerPath:`${n}.js`}}}const ee={browserNativeHost:{...pluginRuntimeProcess(`browser`,`native-host-entry`,`native-host-entry`),package:{name:`@openclaw/browser-plugin`,distWorkerPath:`native-host-entry.js`}},browserRelayDaemon:{...pluginRuntimeProcess(`browser`,`native-host-entry`,`relay-daemon-entry`),package:{name:`@openclaw/browser-plugin`,distWorkerPath:`relay-daemon-entry.js`}},browserSetup:{...pluginRuntimeProcess(`browser`,`setup-entry`,`setup-entry`),package:{name:`@openclaw/browser-plugin`,distWorkerPath:`setup-entry.js`}},quickJsCodeMode:{...pluginRuntimeProcess(`code-mode-quickjs`,`src/executor`,`src/code-mode.worker`),sourceWorkerName:`code-mode.worker`},codexStdio:pluginRuntimeProcess(`codex`,`stdio-worker-entrypoint`,`stdio.worker`),codexCatalogPage:pluginRuntimeProcess(`codex`,`catalog-page-worker-entrypoint`,`catalog-page.worker`),codexSessionHistory:pluginRuntimeProcess(`codex`,`session-history-worker-entrypoint`,`session-history.worker`),discordAudio:{...pluginRuntimeProcess(`discord`,`src/voice/audio-worker-thread`,`src/voice/audio-worker.runtime`),sourceWorkerName:`audio-worker.runtime`},documentExtractor:{...pluginRuntimeProcess(`document-extract`,`document-extractor-worker-entrypoint`,`document-extractor.worker`),package:{name:`@openclaw/document-extract-plugin`,distWorkerPath:`document-extractor.worker.js`}},webReadability:{...pluginRuntimeProcess(`web-readability`,`web-content-extractor-worker.runtime`,`web-content-extractor.worker`),package:{name:`@openclaw/web-readability-plugin`,distWorkerPath:`web-content-extractor.worker.js`}},fileTransferDirFetch:{plugin:`file-transfer`,ownerSource:`extensions/file-transfer/src/node-host/dir-fetch-archive.ts`,sourceWorkerName:`dir-fetch-archive.worker`,distWorkerPath:`extensions/file-transfer/src/node-host/dir-fetch-archive.worker.js`,package:{name:`@openclaw/file-transfer`,distWorkerPath:`src/node-host/dir-fetch-archive.worker.js`}},fileTransferDirList:{plugin:`file-transfer`,ownerSource:`extensions/file-transfer/src/node-host/dir-list-worker-command.ts`,sourceWorkerName:`dir-list.worker`,distWorkerPath:`extensions/file-transfer/src/node-host/dir-list.worker.js`,package:{name:`@openclaw/file-transfer`,distWorkerPath:`src/node-host/dir-list.worker.js`}},iMessageChatDb:{...pluginRuntimeProcess(`imessage`,`src/chat-db`,`src/chat-db.worker`),sourceWorkerName:`chat-db.worker`},knowledgeRegistry:{...pluginRuntimeProcess(`knowledge`,`src/registry-client`,`src/registry-worker`),sourceWorkerName:`registry-worker`},knowledgeStorage:{...pluginRuntimeProcess(`knowledge`,`src/storage-client`,`src/storage-worker`),sourceWorkerName:`storage-worker`},mxcLauncher:{plugin:`mxc`,ownerSource:`extensions/mxc/src/plugin-root.ts`,sourceWorkerName:`mxc-spawn-launcher`,sourceExtension:`.mjs`,build:`static-asset`,distWorkerPath:`extensions/mxc/mxc-spawn-launcher.mjs`,package:{name:`@openclaw/mxc-sandbox`,distWorkerPath:`mxc-spawn-launcher.mjs`}},onePasswordSecretResolver:{plugin:`onepassword`,ownerSource:`extensions/onepassword/onepassword-secret-ref-resolver.js`,sourceWorkerName:`onepassword-secret-ref-resolver`,sourceExtension:`.js`,build:`static-asset`,distWorkerPath:`extensions/onepassword/onepassword-secret-ref-resolver.js`,package:{name:`@openclaw/onepassword`,distWorkerPath:`onepassword-secret-ref-resolver.js`}},vaultSecretResolver:{plugin:`vault`,ownerSource:`extensions/vault/vault-secret-ref-resolver.js`,sourceWorkerName:`vault-secret-ref-resolver`,sourceExtension:`.js`,build:`static-asset`,distWorkerPath:`extensions/vault/vault-secret-ref-resolver.js`,package:{name:`@openclaw/vault`,distWorkerPath:`vault-secret-ref-resolver.js`}},memorySearch:{...pluginRuntimeProcess(`memory-core`,`src/memory/manager-cpu-entrypoints`,`src/memory/manager-search.worker`),sourceWorkerName:`manager-search.worker`,distWorkerPath:`extensions/memory-core/memory-search.worker.js`},memoryIndex:{...pluginRuntimeProcess(`memory-core`,`src/memory/manager-cpu-entrypoints`,`src/memory/manager-index.worker`),sourceWorkerName:`manager-index.worker`,distWorkerPath:`extensions/memory-core/memory-index.worker.js`},memoryPublication:{...pluginRuntimeProcess(`memory-core`,`src/memory/manager-cpu-entrypoints`,`src/memory/manager-publication.worker`),sourceWorkerName:`manager-publication.worker`,distWorkerPath:`extensions/memory-core/memory-publication.worker.js`},memoryStandingIntents:{...pluginRuntimeProcess(`memory-core`,`src/memory/manager-cpu-entrypoints`,`src/standing-intents.worker`),sourceWorkerName:`../standing-intents.worker`,distWorkerPath:`extensions/memory-core/standing-intents.worker.js`},memoryEntryOrigins:{...pluginRuntimeProcess(`memory-core`,`src/memory/manager-cpu-entrypoints`,`src/memory-entry-origins.worker`),sourceWorkerName:`../memory-entry-origins.worker`,distWorkerPath:`extensions/memory-core/memory-entry-origins.worker.js`},memoryStatsRuntime:pluginRuntimeProcess(`memory-lancedb`,`memory-stats-entrypoint`,`memory-stats.worker`),memoryWikiQuery:{...pluginRuntimeProcess(`memory-wiki`,`src/query-reader`,`src/query-reader.worker`),sourceWorkerName:`query-reader.worker`},openAiRealtimeAudio:{...pluginRuntimeProcess(`openai`,`realtime-quicksilver-peer.runtime`,`realtime-quicksilver-audio.worker`),package:{name:`@openclaw/openai-provider`,distWorkerPath:`realtime-quicksilver-audio.worker.js`}},openAiRealtimeSocket:{...pluginRuntimeProcess(`openai`,`realtime-quicksilver-socket`,`realtime-quicksilver-socket.worker`),package:{name:`@openclaw/openai-provider`,distWorkerPath:`realtime-quicksilver-socket.worker.js`}},qaExecutionIdentityInspection:{...pluginRuntimeProcess(`qa-lab`,`src/execution-identity-storage-inspection`,`src/execution-identity-storage-inspection.worker`),sourceWorkerName:`execution-identity-storage-inspection.worker`},telegramIngress:{...pluginRuntimeProcess(`telegram`,`src/telegram-ingress-worker`,`src/telegram-ingress-worker.runtime`),sourceWorkerName:`telegram-ingress-worker.runtime`,distWorkerPath:`telegram-ingress-worker.runtime.js`},telegramWidgetCheck:{...pluginRuntimeProcess(`telegram`,`src/widgets/widget-check`,`src/widgets/widget-check.worker`),sourceWorkerName:`widget-check.worker`},onnxInference:pluginRuntimeProcess(`onnx`,`index`,`src/inference.worker`),teamReportsStore:pluginRuntimeProcess(`team-reports`,`index`,`src/store.worker`),teamReportsRun:pluginRuntimeProcess(`team-reports`,`index`,`src/run.worker`),logbookStore:pluginRuntimeProcess(`logbook`,`index`,`src/store.worker`),workboardSqlite:pluginRuntimeProcess(`workboard`,`index`,`src/sqlite-store.worker`)},te={bunSqliteLibraryProbe:{buildSource:`src/infra/bun-sqlite-library-probe.entry.ts`,sourceModule:`src/infra/bun-sqlite-library-probe.generated.ts`,sourceBinding:`BUN_SQLITE_LIBRARY_PROBE_SOURCE`,kind:`file`,fileName:`bun-sqlite-library-probe.mjs`,materialize:!0},packageCliNodeProbe:{buildSource:`scripts/lib/package-cli-node-probe.entry.mjs`,sourceModule:`scripts/lib/package-cli-node-probe.generated.mjs`,sourceBinding:`PACKAGE_CLI_NODE_PROBE_SOURCE`,kind:`file`,fileName:`package-cli-node-probe.mjs`,materialize:!0},fsSafeNpmCliPreload:{buildSource:`scripts/lib/fs-safe-npm-cli-preload.entry.mjs`,sourceModule:`scripts/lib/fs-safe-npm-cli-preload.generated.mjs`,sourceBinding:`FS_SAFE_NPM_CLI_PRELOAD_DATA_URL`,kind:`data-url`},repositoryPublicationRestoreRemote:{sourceModule:`src/gateway/github-repository-publication-restore.ts`,sourceBinding:`RESTORE_PUBLICATION_INDEX_JS`,kind:`source`},nodeRuntimeProbe:{buildSource:`src/infra/node-runtime-probe.entry.ts`,sourceModule:`src/infra/node-runtime-probe.generated.mjs`,sourceBinding:`NODE_RUNTIME_PROBE_SOURCE`,kind:`file`,fileName:`node-runtime-probe.mjs`,materialize:!0},daemonRuntimeProbe:{buildSource:`src/infra/daemon-runtime-probe.entry.ts`,sourceModule:`src/infra/daemon-runtime-probe.generated.mjs`,sourceBinding:`DAEMON_RUNTIME_PROBE_SOURCE`,kind:`file`,fileName:`daemon-runtime-probe.mjs`,materialize:!0,runtimeEntrypoint:`daemonRuntimeProbe`},updateStateSizes:{sourceModule:`src/infra/update-state-sizes.generated.mjs`,sourceBinding:`UPDATE_STATE_SIZES_SOURCE`,kind:`file`,fileName:`update-state-sizes.mjs`,materialize:!0,runtimeEntrypoint:`updateStateSizes`},updateNativeGate:{sourceModule:`src/cli/update-cli/update-command-native-gate.generated.ts`,sourceBinding:`UPDATE_NATIVE_GATE_SOURCE`,kind:`file`,fileName:`update-native-gate.mjs`},managedUpdateHandoff:{sourceModule:`src/infra/update-managed-service-handoff.ts`,sourceBinding:`HANDOFF_SCRIPT`,kind:`file`,fileName:`handoff.cjs`},workspaceQuiescence:{sourceModule:`src/gateway/worker-environments/workspace-quiescence-scripts.ts`,export:`workspaceQuiescenceArgv`,kind:`argv`}};export{assertDirectoryGuard as $,getFsSafeNativeConfig as $t,Y as A,isSymlinkOpenError as At,resolveExistingAncestor as B,assertNoWindowsPathAlias as Bt,RootPathObservationError as C,rootPathChangedError as Ct,isNativeStatIdentity as D,isNotFoundPathError as Dt,isNativeDirectoryObservationGuard as E,isNodeError as Et,assertExclusiveCreateLeaf as F,N as Ft,formatErrorDetail as G,realpathNative as Gt,resolvePathViaExistingAncestorSync as H,pathForWindowsFilesystem as Ht,sleep as I,assertNoUnsafeDeviceReadPath as It,readBoundedSync as J,assertNativeCapabilities as Jt,shortPath as K,k as Kt,sleepSync as L,isWindowsReservedDeviceName as Lt,runAsync as M,assertSafePathPrefix as Mt,runSync as N,isDriveRelativePath as Nt,statIdentityFromNative as O,isPathInside as Ot,wait as P,isSafePathSegment as Pt,assertAsyncDirectoryGuard as Q,selectNativeBinding as Qt,recursiveMkdirPath as R,admitStandalonePublicationPath as Rt,resolveRootPathWithObservation as S,pathTraversalPermissionError as St,inspectNativeDirectoryObservation as T,hasNodeErrorCode as Tt,admitPathInsideRoot as U,resolvePathFromBasePreservingWindowsRoot as Ut,resolvePathViaExistingAncestor as V,hasWindowsPathAlias as Vt,sameNormalizedPathSpelling as W,resolvePathPreservingWindowsRoot as Wt,readFileHandleBounded as X,getNativeFallbackDiagnostic as Xt,readFileDescriptorBoundedSync as Y,getNativeBinding as Yt,readFileHandleBoundedWithSize as Z,requireNativeBinding as Zt,resolveReadOpenFlags as _,normalizePinnedPathError as _t,racePromiseWithAbortSignal as a,fileObservation as an,createAsyncDirectoryGuard as at,resolveRootPathForRemoval as b,normalizeRemovePathError as bt,toRetryError as c,FsSafeError as cn,inspectDirectoryIdentity as ct,assertFinalSymlinkRejected as d,identityFromReceipt as dn,assertStatObservationSync as dt,getNativeModeSetting as en,assertDirectoryIdentitySync as et,mutationSymlinkResolution as f,sameFileIdentity as fn,directoryComponentNotDirectoryError as ft,numberStats as g,isAlreadyExistsError as gt,numberStatScalar as h,hardlinkedPathNotAllowedError as ht,createRetryRunner as i,inspectFileIdentitySync as in,captureDirectoryGuard as it,inspectAtomicIdentity as j,normalizeWindowsPathForComparison as jt,isRootPathEscapeError as k,isPathRelativeEscape as kt,canUseRootFileOpen as l,normalizeMaxBytes as ln,inspectDirectoryIdentitySync as lt,exactFileIdentity as m,sha256Hex as mn,fileNotFoundError as mt,ee as n,captureNativeFdClose as nn,assertDirectoryObservationSync as nt,raceWithTimeout as o,isFileObservationFailure as on,createNearestExistingDirectoryGuard as ot,readSymlinkResolution as p,sameFileIdentityForCleanup as pn,errorCauseOptions as pt,readBoundedAsync as q,assertWindowsHelperAllowed as qt,te as r,inspectFileIdentity as rn,assertSyncDirectoryGuard as rt,sleepWithAbort as s,recordFileObservationFailure as sn,extendDirectoryObservationGuard as st,createRuntimeProcessEntrypoints as t,isFsSafeNativeRequired as tn,assertDirectoryObservationGuardSync as tt,openRootFileSync as u,hasSafeFileIdentity as un,inspectDirectoryObservationSync as ut,Z as v,normalizePinnedWriteError as vt,getNativeDirectoryObservationBackend as w,assertNoNulPathInput as wt,resolveRootPathSync as x,outsideWorkspaceError as xt,resolveRootPath as y,normalizeRemoveGuardError as yt,absolutePathWithRawSegments as z,anchorWindowsDriveRelativePath as zt};