openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 1.58 kB
JavaScript
import{Et as e,t}from"./disk-budget.worker-subsystem-9qP7ka6r.mjs";import{Nr as n}from"./disk-budget.worker-sqlite-readonly-worker-Bob4L7Jx.mjs";import{an as r,dn as i,fn as a,tn as o}from"./disk-budget.worker-openclaw-agent-db-registry-listing-pnEHqahY.mjs";import{i as s}from"./disk-budget.worker.js";import{t as c}from"./disk-budget.worker-targets-configured-agents-BMHBJDZe.mjs";import l from"node:fs";import"node:fs/promises";import u from"node:path";function mapAgentSessionDirs(e,t,n){return t.filter(e=>e.isDirectory()&&(n?.(e.name)??!0)).map(t=>u.join(e,t.name,`sessions`)).sort((e,t)=>e.localeCompare(t))}function resolveAgentSessionDirsFromAgentsDirSync(t,n){let r;try{r=l.readdirSync(t,{withFileTypes:!0})}catch(t){return e(t)??[]}return mapAgentSessionDirs(t,r,n)}t(`sessions/targets`);function resolveConfiguredSessionStoreTargets(e,t,n){return c(e).map(r=>({agentId:r,storePath:s(e.session?.store,r,t,n)}))}function resolveConfiguredAgentDatabaseCandidatePaths(e,t){let n=c(e);return[.../* @__PURE__ */ new Set([...n.flatMap(n=>a(i(e.session?.store,{agentId:n,env:t.env}),n)),...[.../* @__PURE__ */ new Set([...n,...r(e)])].map(n=>u.join(o(e,n,t.env),`openclaw-agent.sqlite`))])]}function isConfiguredAgentDatabaseTarget(e,t,r){return e.some(e=>(t===void 0||e.agentId===void 0||e.agentId===t)&&(e.path===r||l.statSync(e.path,{throwIfNoEntry:!1})&&l.statSync(r,{throwIfNoEntry:!1})&&n(e.path,r)))}export{isConfiguredAgentDatabaseTarget,resolveConfiguredAgentDatabaseCandidatePaths,resolveConfiguredSessionStoreTargets,resolveAgentSessionDirsFromAgentsDirSync as t};