UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 3.14 kB
import{d as e}from"./transcript-plugin-instance-invocation-7y9lfaeO.mjs";import{w as t}from"./transcript-agent-creation-claim-Da8lP1e6.mjs";import{c as n,n as r}from"./transcript-sqlite-worker-identity-CA1Up8Es.mjs";import{ot as i}from"./transcript-sqlite-readonly-worker-cXU3LbpW.mjs";import{a}from"./transcript-paths-CuGliRzI.mjs";import"./transcript-openclaw-agent-db-resources-W6NYYBYU.mjs";import{isMainThread as o}from"node:worker_threads";import s from"node:path";import c from"node:fs";function resolveCapturedSessionStorePath(e,t,n,r,i=`configured`){if(!r)return a(i==="default"?void 0:e,{agentId:t,env:n});let o=r.get(t);if(!o)throw Error(`Session store path was not captured for ${t}`);return o[i]}function captureSessionStoreReadCandidate(t,n){let r=s.resolve(t);return{path:r,physicalPath:n?s.join(e(s.dirname(r)),s.basename(r)):e(r),...n?{scope:n}:{}}}function isSessionStoreReadCandidateCurrent(e){let t=captureSessionStoreReadCandidate(e.path,e.scope).physicalPath;return matchesSessionStoreReadCandidatePhysicalPath(e,t)}function matchesSessionStoreReadCandidatePhysicalPath(e,t){let n=resolveCapturedSessionStoreReadCandidatePhysicalPath(e);return t===n?!0:e.scope||!isSymlinkFreeWindowsShortPath(e.path)&&!isSymlinkFreeWindowsShortPath(e.physicalPath)?!1:matchesWindowsFileAlias(t,n)}function resolveCapturedSessionStoreReadCandidatePhysicalPath(t){return t.scope||!isSymlinkFreeWindowsShortPath(t.physicalPath)?t.physicalPath:e(t.physicalPath)}function isSymlinkFreeWindowsShortPath(e){return process.platform!==`win32`||!/(?:^|[\\/])[^\\/]*~\d+(?=[\\/]|$)/iu.test(e)?!1:isSymlinkFreePath(e)}function isSymlinkFreePath(e){let t=s.resolve(e),n=s.parse(t),r=n.root;for(let e of t.slice(n.root.length).split(s.sep)){r=s.join(r,e);let t=c.lstatSync(r,{throwIfNoEntry:!1});if(!t||t.isSymbolicLink())return!1}return!0}function matchesWindowsFileAlias(e,t){let r=isSymlinkFreeWindowsShortPath(e)?e:isSymlinkFreeWindowsShortPath(t)?t:void 0;if(process.platform!==`win32`||!r||!isSymlinkFreePath(e)||!isSymlinkFreePath(t))return!1;let i=c.statSync(s.dirname(e),{bigint:!0}),a=c.statSync(s.dirname(t),{bigint:!0});if(i.dev!==a.dev||i.ino!==a.ino)return!1;let o=n(e),l=n(t);return o?.key.startsWith(`file:`)===!0&&o.key===l?.key&&o.birthtime===l.birthtime}function assertSessionStoreReadCandidate(n,a){if(o&&i()){let e=a.find(e=>e.identity&&(e.path===s.resolve(n)||e.physicalPath===s.resolve(n)));if(!e)throw Error(`Session inspection requires a worker-prepared physical candidate`);return e.physicalPath}let c=e(n);for(let e of a){let i=!e.scope&&c===resolveCapturedSessionStoreReadCandidatePhysicalPath(e);if((t(e,n)||i||!e.scope&&matchesWindowsFileAlias(e.path,n))&&(!e.scope||t({...e,path:resolveCapturedSessionStoreReadCandidatePhysicalPath(e)},c))&&(!e.scope&&e.path===s.resolve(n)?matchesSessionStoreReadCandidatePhysicalPath(e,c):isSessionStoreReadCandidateCurrent(e)))return e.identity&&r(e.path,e.identity),c}throw Error(`Session database target changed outside captured discovery custody: ${n}`)}export{captureSessionStoreReadCandidate as n,resolveCapturedSessionStorePath as r,assertSessionStoreReadCandidate as t};