UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 3.02 kB
import{Yt as e}from"./openclaw-state-read-sqlite-database-admission-Ck6VG7rE.mjs";import{a as t,o as n}from"./openclaw-state-read-tmp-openclaw-dir-C3Ynn93H.mjs";import{et as r}from"./openclaw-state-read-logger-Ix7jXPG1.mjs";import{v as i,x as a}from"./openclaw-state-read-read-open-flags-CtNL1rJs.mjs";import{i as o}from"./openclaw-state-read-path-existence-Bp_sxI9A.mjs";import{statSync as s}from"node:fs";import c from"node:path";const l=new n(64);function resolveDatabasePath(t={}){return t.path===void 0?resolveOpenClawStateSqlitePath(t.env??process.env):e(c.resolve(t.path))}function existingPathOrUndefined(e){try{return s(e),e}catch(e){if(i(e,`ENOENT`))return;throw e}}function resolveOpenClawStateSqliteDir(e=process.env){return c.dirname(resolveOpenClawStateSqlitePath(e))}function resolveOpenClawStateSqlitePath(n=process.env){let r=t(n),i=l.peek(r);if(i!==void 0)return i;let a=e(c.join(r,`state`,`openclaw.sqlite`));return l.set(r,a),a}function resolveOpenClawStateDirForDatabasePath(e){let t=c.dirname(c.resolve(e));return c.basename(t)===`state`?c.dirname(t):t}function resolveQuarantineStorePath(e){return c.join(resolveOpenClawStateSqliteDir(e),`openclaw-quarantine.sqlite`)}function resolveOpenClawAgentDatabaseStoredPath(e,t){let n=process.platform===`win32`,i=resolveOpenClawStateDirForDatabasePath(e),s=n?r(i):i,l=n&&c.isAbsolute(t)?t:c.resolve(t),u=n?r(l):l;if(!c.isAbsolute(s)||!c.isAbsolute(u))return l;let d=c.relative(s,u),f=d.startsWith(`..`)||c.isAbsolute(d)||n&&!a(i,l);if(f){let e=o(s);if(n&&!a(e,l)||(s=n?r(e):e,!c.isAbsolute(s)))return l;d=c.relative(s,u)}if(d.startsWith(`..`)||c.isAbsolute(d))return l;if(f&&!n)return d;let p=[s,c.toNamespacedPath(s)].map(e=>`${e}${e.endsWith(c.sep)?``:c.sep}`).find(e=>t.startsWith(e));return c.isAbsolute(t)&&p!==void 0?t.slice(p.length):d}function resolveOpenClawRegisteredAgentDatabasePath(e,t){return c.isAbsolute(t)?t:`${resolveOpenClawStateDirForDatabasePath(e)}${c.sep}${t}`}function describeAgentPathMigration(e){let{relativized:t,reanchored:n,deleted:r}=e;if(t===0&&n.length===0&&r.length===0)return[];let i=n.length+r.length,a=[`${t} relativized`,n.length>0&&`${n.length} re-anchored`,r.length>0&&`${r.length} removed`].filter(Boolean);return[`Migrated agent database registry paths to state-relative storage${i>0?` (${a.join(`, `)})`:``}`,...n.map(e=>`Re-anchored agent database registry path ${e} to the current state directory`),...r.map(e=>`Removed duplicate agent database registry path ${e}`)]}function warnAgentPathMigration(e,t,n){(t.reanchored.length!==0||t.deleted.length!==0)&&e.warn(`agent database registry rows re-anchored or removed during v9 migration`,{reanchored:t.reanchored,deleted:t.deleted,path:n})}export{resolveOpenClawRegisteredAgentDatabasePath as a,resolveQuarantineStorePath as c,resolveOpenClawAgentDatabaseStoredPath as i,warnAgentPathMigration as l,existingPathOrUndefined as n,resolveOpenClawStateDirForDatabasePath as o,resolveDatabasePath as r,resolveOpenClawStateSqlitePath as s,describeAgentPathMigration as t};