UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 21.2 kB
import{$t as e,Ct as t,D as n,It as r,Kt as i,Lt as a,Nt as o,O as s,Pt as c,Q as l,Qt as u,R as d,St as f,Ut as p,V as m,Xt as h,_ as g,at as _,bt as v,ct as y,d as b,dt as x,en as S,g as C,j as w,jt as T,nn as E,pn as D,st as O,u as k,ut as A,xt as j,y as M,yt as N}from"./openclaw-state-read-src-RL5xtYG2.mjs";import{B as P,K as F,M as I}from"./openclaw-state-read-sidecar-lock-registration-XTuJQFHg.mjs";import L from"node:fs";import R from"node:path";import z from"node:os";import{randomUUID as B}from"node:crypto";const ensureTrailingSep=e=>e.endsWith(R.sep)?e:e+R.sep;function assertValidRootRelativePath(e){o(e,`relative path contains a NUL byte`),h(e,`filesystem`,`relative path uses a Windows filesystem namespace alias`)}function assertValidRootDestinationPath(e){if(assertValidRootRelativePath(e),p(e))throw new D(`invalid-path`,`relative path must not start with a drive letter`)}let V;const H=/(?:^|\/)\.\.(?:\/|$)/,U=/(?:^|[\\/])\.\.(?:[\\/]|$)/;async function expandRelativePathWithHome(e){let t=e===`~`,n=e.startsWith(`~/`)||R.sep===`\\`&&e.startsWith(`~\\`);if(!t&&!n)return h(e,`filesystem`,`relative path uses a Windows filesystem namespace alias`),e;let r=process.env.HOME||process.env.USERPROFILE||z.homedir();if(h(r,`filesystem`,`home path uses a Windows filesystem namespace alias`),V?.raw!==r){let e=r;try{e=E.native(u(r))}catch{}V={raw:r,real:e}}if(t)return h(V.real,`filesystem`,`home path uses a Windows filesystem namespace alias`),V.real;let i=`${ensureTrailingSep(V.real)}${e.slice(2)}`;return h(i,`filesystem`,`expanded path uses a Windows filesystem namespace alias`),i}async function resolveRootContext(e){o(e,`root dir contains a NUL byte`),h(e,`filesystem`,`root dir uses a Windows filesystem namespace alias`);let t=S(e);h(t,`filesystem`,`root dir uses a Windows filesystem namespace alias`);let n,i,a;try{n=E.native(u(e)),h(n,`filesystem`,`canonical root path uses a Windows filesystem namespace alias`),i=await f(()=>{let e=L.statSync(n,{bigint:!0});if(!e.isDirectory())throw new D(`invalid-path`,`root dir is not a directory`);return e}),a={dev:i.dev,ino:i.ino}}catch(e){throw e instanceof D?e:r(e)?new D(`not-found`,`root dir not found`):e}return{rootDir:t,rootGuard:{dir:n,realPath:n,stat:i},rootIdentity:a,rootReal:n,rootWithSep:ensureTrailingSep(n)}}function rootRelativeReadPath(e,t){if(!R.isAbsolute(t))return t;let n=process.platform===`win32`?t.replaceAll(`/`,R.sep):t,r=e.rootDir===e.rootReal?[e.rootReal]:[e.rootDir,e.rootReal];for(let t of r){if(process.platform===`win32`){let r=m({rootPath:t,candidatePath:n,rootIdentity:e.rootIdentity,resolveCandidateRoot:t===e.rootDir&&e.rootDir!==e.rootReal});if(r)return`.${R.sep}${r.relativePath}`;continue}let r=ensureTrailingSep(t);if(n.startsWith(r)){let e=r.length;for(;n[e]===R.sep;)e+=1;return`.${R.sep}${n.slice(e)}`}}return n}function assertRootIdentityCurrentSync(e,t){try{let n=O(e.rootReal,{dev:e.rootIdentity.dev,ino:e.rootIdentity.ino});t?.(n)}catch(e){throw j(e instanceof Error?e:void 0)}}async function assertRootIdentityCurrent(e,t){assertRootIdentityCurrentSync(e,t)}async function createRootObservationGuard(e){let t=e.rootIdentity;if(typeof t?.dev!=`bigint`||typeof t.ino!=`bigint`)throw j();try{let n=await y(e.rootReal,t);return _(n,e.rootReal,e.rootReal)}catch(e){throw j(e instanceof Error?e:void 0)}}async function resolvePathInRoot(t,n,r){assertValidRootRelativePath(n),await assertRootIdentityCurrent(t);let o=await expandRelativePathWithHome(n);h(o,`filesystem`,`expanded path uses a Windows filesystem namespace alias`);let s=e(t.rootWithSep,o);if(h(s,`filesystem`,`resolved path uses a Windows filesystem namespace alias`),!r?.resolveCanonical&&!a(t.rootWithSep,s))throw N();r?.rejectUnsafeDeviceReads===!0&&i(s);let l=R.isAbsolute(o)?o:`${t.rootWithSep}${o}`;h(l,`filesystem`,`resolved path uses a Windows filesystem namespace alias`);try{let e={absolutePath:l,rootPath:t.rootReal,rootCanonicalPath:t.rootReal,rootIdentity:t.rootIdentity,boundaryLabel:`root`,policy:r?.allowFinalSymlink?C.unlinkTarget:void 0,rejectSymlinks:r?.rejectSymlinks,rejectFinalSymlink:r?.rejectFinalSymlink},n=await g(e),i=process.platform===`win32`?U:H;if(r?.rejectAmbiguousParents&&i.test(o)&&R.relative(n.canonicalPath,s)!==``){let t=await g({...e,absolutePath:s});if(R.relative(n.canonicalPath,t.canonicalPath)!==``)throw new D(`path-alias`,`parent traversal resolves differently through a symlink`)}if(r?.resolveCanonical)s=n.canonicalPath;else{let e=m({rootPath:t.rootReal,candidatePath:n.absolutePath,rootIdentity:t.rootIdentity});if(!e)throw N();s=e.path}}catch(e){let t=v(e,l);if(t)throw t;if(e instanceof D&&e.code===`symlink`)throw e;if(c(e,`ENAMETOOLONG`))throw new D(`invalid-path`,`relative path is too long`,x(e));let n=r?.aliasErrorCode??`outside-workspace`;throw new D(n,n===`path-alias`?`path alias escape blocked`:`file is outside workspace root`,x(e))}return{rootReal:t.rootReal,rootWithSep:t.rootWithSep,resolved:s}}const W=Symbol(`checked mutation directory observation`),G=/* @__PURE__ */ new WeakMap;function identity(e){return Object.freeze({dev:e.dev,ino:e.ino,mode:e.mode,nlink:e.nlink})}function sameIdentity(e,t,n=!1){return e.dev===t.dev&&e.ino===t.ino&&e.mode===t.mode&&(n||e.nlink===t.nlink)}function directoryMode(e){return(e&61440n)==16384n}function absent(e){try{return L.lstatSync(e,{throwIfNoEntry:!1})===void 0}catch(e){return r(e)&&e.code===`ENOENT`}}function missingMutationSegments(e){return e.missingSegments.length-e.missingOffset}function nextMissingMutationPath(e){let t=e.missingSegments[e.missingOffset];return t===void 0?void 0:R.join(e.ancestor,t)}function checkedMutationDirectory(e,t,n,r){if(!directoryMode(n.mode))throw TypeError(`mutation directory evidence must describe a real directory`);let i=Object.freeze({path:e,canonicalPath:t,identity:identity(n),[W]:!0});return r&&G.set(i,r),i}function checkedDirectory(e){return e[W]===!0&&R.isAbsolute(e.path)&&R.isAbsolute(e.canonicalPath)&&directoryMode(e.identity.mode)}function mutationObservationUsesDirectory(e,t){return checkedDirectory(t)&&e.ancestor===t.path&&e.canonicalAncestor===t.canonicalPath&&sameIdentity(e.entry,t.identity)&&sameIdentity(e.identity,t.identity)}function observeMutationPath(e){try{let n=e,r=[];for(;absent(n);){let e=R.dirname(n);if(e===n)return;r.push(R.basename(n)),n=e}r.reverse();let i=Object.freeze(r),a=t(()=>L.lstatSync(n,{bigint:!0})),o=E.native(n),s=o===n?a:t(()=>L.lstatSync(o,{bigint:!0}));if(s.isSymbolicLink()||i.length>0&&!s.isDirectory())return;let c=Object.freeze({path:e,ancestor:n,canonicalAncestor:o,canonicalPath:R.join(o,...i),entry:identity(a),identity:identity(s),missingSegments:i,missingOffset:0});return mutationObservationCurrent(c)?c:void 0}catch{return}}function mutationObservationCurrent(e){try{let n=t(()=>L.lstatSync(e.ancestor,{bigint:!0}));if(!sameIdentity(e.entry,n,n.isDirectory())||E.native(e.ancestor)!==e.canonicalAncestor)return!1;let r=e.canonicalAncestor===e.ancestor?n:t(()=>L.lstatSync(e.canonicalAncestor,{bigint:!0}));return sameIdentity(e.identity,r,r.isDirectory())&&(missingMutationSegments(e)===0||r.isDirectory()&&absent(nextMissingMutationPath(e)))}catch{return!1}}function mutationObservationsCurrent(e,n){let r=/* @__PURE__ */ new Map,groupFor=e=>{let t=r.get(e);return t||(t={observations:[],directories:[]},r.set(e,t)),t};try{for(let t of e)if(t.ancestor!==t.canonicalAncestor){if(!mutationObservationCurrent(t))return!1}else groupFor(t.ancestor).observations.push(t);for(let e of n){if(!checkedDirectory(e))return!1;groupFor(e.path).directories.push(e)}let current=(e,n)=>{let r=new Set(n.observations.flatMap(e=>{let t=nextMissingMutationPath(e);return t===void 0?[]:[t]}));if(n.directories.length&&![...r].every(absent))return!1;let i=n.directories.length?G.get(n.directories[0])?.():void 0,a=i?.identity??t(()=>L.lstatSync(e,{bigint:!0})),o=i?.canonicalPath??E.native(e),s=directoryMode(a.mode);return!n.observations.every(e=>o===e.canonicalAncestor&&sameIdentity(e.entry,a,s)&&sameIdentity(e.identity,a,s)&&(missingMutationSegments(e)===0||s))||!n.directories.every(e=>s&&sameIdentity(e.identity,a)&&o===e.canonicalPath)?!1:n.directories.length>0||[...r].every(absent)};for(let[e,t]of r)if(!t.directories.length&&!current(e,t))return!1;let i=/* @__PURE__ */ new Set;for(let e of n)if(!i.has(e.path)){if(!current(e.path,r.get(e.path)))return!1;i.add(e.path)}return!0}catch{return!1}}function advanceMutationObservation(e,t,n){let r=nextMissingMutationPath(e);if(r===void 0||r!==n.path)return e;if(checkedDirectory(t)&&checkedDirectory(n)&&e.ancestor===t.path&&e.canonicalAncestor===t.canonicalPath&&sameIdentity(e.entry,t.identity,!0)&&sameIdentity(e.identity,t.identity,!0)&&t.path===t.canonicalPath&&n.path===n.canonicalPath&&R.dirname(n.path)===t.path)return Object.freeze({...e,ancestor:n.path,canonicalAncestor:n.canonicalPath,entry:n.identity,identity:n.identity,missingOffset:e.missingOffset+1})}function swapAsciiCase(e){return e.replace(/[A-Za-z]/g,e=>{let t=e.toLowerCase();return e===t?e.toUpperCase():t})}function probeEntry(e,n,i){let a=swapAsciiCase(n);if(a===n)return;let o=i.has(n)&&i.has(a),s=R.join(e,n),c,l;try{c=t(()=>L.lstatSync(s,{bigint:!0}));try{let r=t(()=>L.lstatSync(R.join(e,a),{bigint:!0})),i=T(c,r);if(i||o){let t=new Set(L.readdirSync(e)),r=t.has(n)&&t.has(a);if(o&&!r)return;l=i&&!r}else l=!1}catch(e){if(o||!r(e))return;l=!1}}catch{return}return t(()=>L.lstatSync(s,{bigint:!0}),c),l}function probeTemporaryEntry(e){let t=`.fs-safe-case-probe-${B()}`,n=s.sync(L),r=new I(R.join(e,t),n);try{r.start(),r.adopt(w(P(n,{tempPath:r.pathname,content:``,mode:384,sync:!1,onIdentity:r.onIdentity}))),w(r.assertCurrent());let i=probeEntry(e,t,new Set(L.readdirSync(e)));return w(r.assertCurrent()),i}finally{w(r.finish({throwOnCleanupError:!0}))}}function probeDirectory(e,t,n){let r=E.native(e),i=O(r),a=new Set(L.readdirSync(r)),o=n===void 0?void 0:probeEntry(r,n,a);for(let e of a){if(o!==void 0)break;o=probeEntry(r,e,a)}return o===void 0&&t&&(o=probeTemporaryEntry(r)),l(r,i),E.native(e)===r?o:void 0}function probePathCaseInsensitiveSync(e,t={}){let n=R.resolve(e),i=t.allowTemporaryProbe!==!1,a=!0;try{L.lstatSync(n)}catch(e){if(!r(e))return;a=!1}if(a)try{return probeDirectory(R.dirname(n),i,R.basename(n))}catch{return}let o=R.dirname(n);for(;;){let e=!1;try{e=L.statSync(o).isDirectory()}catch{}if(e)try{return probeDirectory(o,i)}catch{return}let t=R.dirname(o);if(t===o)return;o=t}}function foldedName(e){return e.normalize(`NFD`).replace(/[^\u0131]+/gu,e=>e.toLowerCase().toUpperCase().toLowerCase()).normalize(`NFC`)}function asciiCasePair(e,t){return/^[\x00-\x7f]*$/.test(e)&&/^[\x00-\x7f]*$/.test(t)&&e.toLowerCase()===t.toLowerCase()}function createMutationDenyMatcher(){let e=/* @__PURE__ */ new Map,t=/* @__PURE__ */ new Map,observe=t=>(e.has(t)||e.set(t,observeMutationPath(t)),e.get(t)),prospectiveInside=(e,n)=>{let r=R.parse(e).root;if(r!==R.parse(n).root)return!1;let i=e.slice(r.length).split(R.sep),a=n.slice(r.length).split(R.sep).slice(0,i.length);if(i.length!==a.length||!i.every((e,t)=>foldedName(e)===foldedName(a[t]))||i.every((e,t)=>e===a[t]))return!1;let o=R.join(r,...a),s=observe(e),c=observe(o);if(!s||!c)return!0;if(s.canonicalAncestor!==c.canonicalAncestor||s.missingSegments.length===0||s.missingSegments.length!==c.missingSegments.length)return!1;let l=s.missingSegments,u=c.missingSegments;if(!l.every((e,t)=>foldedName(e)===foldedName(u[t])))return!1;let d=l.findIndex((e,t)=>e!==u[t]);return d===-1||!(d===0&&asciiCasePair(l[0],u[0])&&(t.has(s.canonicalAncestor)||t.set(s.canonicalAncestor,probePathCaseInsensitiveSync(R.join(s.canonicalAncestor,l[0]),{allowTemporaryProbe:!1})),t.get(s.canonicalAncestor)===!1))};return(e,t,n,r=!1)=>a(t,e)&&(n||a(e,t))||r&&a(e,t)?!0:(n||e.split(R.sep).length===t.split(R.sep).length)&&prospectiveInside(t,e)||r&&prospectiveInside(e,t)}function resolveMutationComparablePaths(e){o(e,`path contains a NUL byte`),h(e,`filesystem`,`mutation path uses a Windows filesystem namespace alias`);let t=S(e);h(t,`filesystem`,`mutation path uses a Windows filesystem namespace alias`);let n=d(t,`native`);return h(n,`filesystem`,`mutation path uses a Windows filesystem namespace alias`),/* @__PURE__ */ new Set([t,n])}function strictMutationComparablePaths(e){let t=S(e);h(t,`filesystem`,`mutation path uses a Windows filesystem namespace alias`);let n=t,i=R.parse(t).root;for(;n!==i;)try{L.lstatSync(u(n));break}catch(e){if(!r(e))throw e;n=R.dirname(n)}let a=E.native(u(n));h(a,`filesystem`,`mutation path uses a Windows filesystem namespace alias`);let o=n===t?a:R.resolve(a,`.${R.sep}${t.slice(n.length)}`);return h(o,`filesystem`,`mutation path uses a Windows filesystem namespace alias`),R.relative(R.resolve(t),R.resolve(o))===``?[t]:[t,o]}function policyPathEntries(e,t){let n=[];for(let r of e??[]){if(t&&(!r||!R.isAbsolute(r)))throw new D(`invalid-path`,`deny mutation paths must be non-empty absolute paths`);if(r.length===0)throw new D(`invalid-path`,`deny mutation paths must be non-empty`);if(o(r,`deny mutation path contains a NUL byte`),h(r,`filesystem`,`deny mutation path uses a Windows filesystem namespace alias`),!t&&!R.isAbsolute(r))throw new D(`invalid-path`,`deny mutation paths must be absolute`);n.push(t?S(r):r)}return n}function assertMutationNotDenied(e,t,n={},r=`root`){if(!t?.paths?.length&&!t?.prefixes?.length)return;let i=r===`sync-root-lock`,a=i?strictMutationComparablePaths:resolveMutationComparablePaths,o=a(e),s=createMutationDenyMatcher();for(let e of[`paths`,`prefixes`])for(let r of policyPathEntries(t[e],i)){let t=a(r);for(let r of o)for(let i of t)if(s(r,i,e===`prefixes`,n.protectAncestors))throw new D(`denied-path`,`path is denied by denyMutations policy`)}}function mergeDenyMutationPolicies(e,t){return e?t?{paths:[...e.paths??[],...t.paths??[]],prefixes:[...e.prefixes??[],...t.prefixes??[]]}:e:t}function sameAbsolutePath(e,t){return R.relative(R.resolve(e),R.resolve(t))===``}function createPathSegmentRoute(e){let t=Array(e.length+1),n=0;for(let r=0;r<e.length;r+=1)t[r]=n,n+=e[r].length,r+1<e.length&&(n+=R.sep.length);return t[e.length]=n,Object.freeze({joined:e.join(R.sep),offsets:Object.freeze(t)})}function joinPathSegmentRoute(e,t,n,r){let i=t.offsets[n];if(i===void 0)throw RangeError(`path segment offset is outside the route`);let a=t.joined.slice(i);return a?r===void 0?R.join(e,a):R.join(e,a,r):r===void 0?e:R.join(e,r)}const K=/* @__PURE__ */ new WeakMap,q=/* @__PURE__ */ new WeakMap;function registerFileLockSyncRootAdapter(e,t,n){let r=t.rootIdentity;typeof r.dev==`bigint`&&typeof r.ino==`bigint`&&(K.set(e,t),q.set(e,n))}function snapshotPolicy(e){if(e===void 0)return;let t=e.paths,n=e.prefixes;return Object.freeze({paths:t===void 0?void 0:Object.freeze([...t]),prefixes:n===void 0?void 0:Object.freeze([...n])})}function captureFileLockSyncRootAuthority(e){let t=e,n=K.get(t),r=q.get(t);if(!n||!r)throw new D(`helper-unavailable`,`synchronous Root-backed file locks require a genuine fs-safe Root handle`);let i=n.rootIdentity;if(typeof i.dev!=`bigint`||typeof i.ino!=`bigint`)throw new D(`helper-unavailable`,`synchronous Root identity is unavailable`);let a=Object.freeze({rootDir:n.rootDir,rootGuard:n.rootGuard,rootIdentity:Object.freeze({dev:i.dev,ino:i.ino}),rootReal:n.rootReal,rootWithSep:n.rootWithSep}),o=r,s=o.assertBeforeMutation,c=snapshotPolicy(o.denyMutations),l=o.hardlinks,u=o.mutationSymlinks,d=o.symlinks;assertRootIdentityCurrentSync(a);let f=k(u),p=Object.freeze({rejectSymlinks:f.rejectSymlinks,rejectFinalSymlink:f.rejectFinalSymlink,rejectUnresolvedSymlinks:!0}),m=Object.freeze({...b(d),rejectUnresolvedSymlinks:!0});return Object.freeze({adapter:t,context:a,assertBeforeMutation:s,denyMutations:c,hardlinks:l,mutationPolicy:p,readPolicy:m,policiesMatch:p.rejectSymlinks===m.rejectSymlinks&&p.rejectFinalSymlink===m.rejectFinalSymlink})}function invokeFileLockSyncRootMutationAuthority(e){let t=e.assertBeforeMutation;return t?(F(t(),`assertBeforeMutation`),!0):!1}function absoluteRootPath(e,t){let n=t.split(R.posix.sep),r=R.join(e.context.rootReal,...n);return h(r,`filesystem`,`sidecar lock path uses a Windows filesystem namespace alias`),r}function assertFileLockSyncRootMutationAllowed(e,t,n=!1){assertMutationNotDenied(e,t,{protectAncestors:n},`sync-root-lock`)}function resolveAdmittedPath(e,t,r,i){let a=e.context,o;try{o=M({absolutePath:t,rootPath:i,rootCanonicalPath:a.rootReal,rootIdentity:a.rootIdentity,boundaryLabel:`sidecar lock root`,...r})}catch(e){throw n(e)?new D(`outside-workspace`,`sidecar lock path is outside lockRoot`,{cause:e}):e}let s=m({rootPath:a.rootReal,candidatePath:o.canonicalPath,rootIdentity:a.rootIdentity});if(!s||s.relativePath===``||sameAbsolutePath(s.path,a.rootReal))throw N();return{path:s.path,relativePath:s.relativePath.split(R.sep).join(R.posix.sep)}}function resolveBothPolicies(e,t,n){let{mutationPolicy:r,readPolicy:i,policiesMatch:a}=e,o=resolveAdmittedPath(e,t,r,n),s=a?o:resolveAdmittedPath(e,t,i,n);if(!sameAbsolutePath(o.path,s.path))throw new D(`path-mismatch`,`sidecar read and mutation paths resolve differently`);return assertFileLockSyncRootMutationAllowed(o.path,e.denyMutations),o}function admitRequestedRootPrefix(e,t){let n=e.context,r=process.platform===`win32`?/* @__PURE__ */ new Map:void 0,i=m({rootPath:n.rootDir,candidatePath:t,rootIdentity:n.rootIdentity,resolveCandidateRoot:n.rootDir!==n.rootReal,identityCache:r});if(i&&i.relativePath!==``)return{path:i.path,rootPath:n.rootDir};let a=n.rootDir===n.rootReal?void 0:m({rootPath:n.rootReal,candidatePath:t,rootIdentity:n.rootIdentity,identityCache:r});if(!a||a.relativePath===``)throw N();return{path:a.path,rootPath:n.rootReal}}function admitFileLockSyncRootPath(e,t){o(t,`sidecar lock path contains a NUL byte`);let n=S(t);h(n,`filesystem`,`sidecar lock path uses a Windows filesystem namespace alias`),assertRootIdentityCurrentSync(e.context);let r=admitRequestedRootPrefix(e,n),i=resolveBothPolicies(e,r.path,r.rootPath);assertRootIdentityCurrentSync(e.context);let a=Object.freeze({authority:e,path:i.path,relativePath:i.relativePath});return assertMissingParentMutationsAllowed(a),a}function assertFileLockSyncRootResolvedPathCurrent(e){if(!sameAbsolutePath(resolveBothPolicies(e.authority,absoluteRootPath(e.authority,e.relativePath),e.authority.context.rootReal).path,e.path))throw new D(`path-mismatch`,`sidecar lock path changed during operation`)}function assertMissingParentMutationsAllowed(e){let t=e.authority,n=t.context,i=R.posix.dirname(e.relativePath),a=i===`.`?``:i,o=n.rootReal,s=!1;for(let e of a.split(R.posix.sep).filter(Boolean)){if(o=R.join(o,e),!s)try{let e=L.lstatSync(u(o),{bigint:!0});if(e.isSymbolicLink()||!e.isDirectory())throw A()}catch(e){if(!r(e))throw e;s=!0}s&&assertFileLockSyncRootMutationAllowed(o,t.denyMutations)}}function assertFileLockSyncRootPathsCurrent(e){let t=e[0]?.authority;for(let n of e)if(t&&n.authority!==t)throw new D(`path-mismatch`,`sidecar paths use different Root authority`);if(t&&invokeFileLockSyncRootMutationAuthority(t)){assertRootIdentityCurrentSync(t.context);for(let t of e)assertFileLockSyncRootResolvedPathCurrent(t),assertMissingParentMutationsAllowed(t);assertRootIdentityCurrentSync(t.context)}}function resolveTargetPathViaExistingAncestorSync(e){let t=S(e),n=process.platform===`win32`?E.native:E,i=t,a;for(;;){try{L.lstatSync(u(i));try{a=n(u(i));break}catch(e){if(!r(e))throw e}}catch(e){if(!r(e))throw e}let e=R.dirname(i);if(e===i){a=n(u(i));break}i=e}return h(a,`filesystem`,`file-lock target ancestor uses a Windows filesystem namespace alias`),S(i===t?a:R.resolve(a,`.${R.sep}${t.slice(i.length)}`))}function normalizeFileLockSyncTargetWithRoot(e,t){o(t,`file-lock target contains a NUL byte`),h(t,`filesystem`,`file-lock target uses a Windows filesystem namespace alias`),assertRootIdentityCurrentSync(e.context);let n=process.platform===`win32`?resolveTargetPathViaExistingAncestorSync(t):R.join(resolveTargetPathViaExistingAncestorSync(R.dirname(t)),R.basename(t));return h(n,`filesystem`,`file-lock target uses a Windows filesystem namespace alias`),assertRootIdentityCurrentSync(e.context),n}export{expandRelativePathWithHome as A,observeMutationPath as C,assertValidRootRelativePath as D,assertValidRootDestinationPath as E,resolveRootContext as M,rootRelativeReadPath as N,createRootObservationGuard as O,nextMissingMutationPath as S,assertRootIdentityCurrentSync as T,checkedMutationDirectory as _,captureFileLockSyncRootAuthority as a,mutationObservationUsesDirectory as b,registerFileLockSyncRootAdapter as c,sameAbsolutePath as d,assertMutationNotDenied as f,advanceMutationObservation as g,probePathCaseInsensitiveSync as h,assertFileLockSyncRootResolvedPathCurrent as i,resolvePathInRoot as j,ensureTrailingSep as k,createPathSegmentRoute as l,createMutationDenyMatcher as m,assertFileLockSyncRootMutationAllowed as n,invokeFileLockSyncRootMutationAuthority as o,mergeDenyMutationPolicies as p,assertFileLockSyncRootPathsCurrent as r,normalizeFileLockSyncTargetWithRoot as s,admitFileLockSyncRootPath as t,joinPathSegmentRoute as u,missingMutationSegments as v,assertRootIdentityCurrent as w,mutationObservationsCurrent as x,mutationObservationCurrent as y};