openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 1.65 kB
JavaScript
import{Vt as e}from"./openclaw-state-read-sqlite-database-admission-CrkztOzk.mjs";import"./openclaw-state-read-openclaw-state-db-cache-DyomEqgV.mjs";import{n as t}from"./openclaw-state-read-agent-id-DmscQLD6.mjs";import"./openclaw-state-read-session-key-H2_GWFw8.mjs";import{C as n,D as r,S as i}from"./openclaw-state-read-openclaw-state-db-readonly-Bv32Owin.mjs";import{c as a,n as o,s}from"./openclaw-state-read-session-sqlite-target-jiQWMtoW.mjs";import{r as c}from"./openclaw-state-read-openclaw-agent-db-registry.read-DCfsbJGg.mjs";import"node:path";import{isDeepStrictEqual as l}from"node:util";function captureCandidates(t){return[...new Set(t.flatMap(e=>n(e)))].toSorted().map(t=>({path:t,identity:e(t)}))}function assertAgentSessionStoreDeletionTargetsCurrent(e){if(!l(captureCandidates(e.stores),e.candidates))throw Error(`Agent session database changed during deletion planning.`)}function findAgentSessionStoreDeletionBlocker(e,n,l,u,d){if(!n.session?.store?.trim())return;let f=t(l),p=a(n);d&&assertAgentSessionStoreDeletionTargetsCurrent(d);let m=e?c(e.db,e.path,!1):[];for(let e of r(n)){if(t(e)===f)continue;let r=i(n.session.store,{agentId:e,env:u}),a=o(r,{agentId:e,defaultAgentId:p,env:u,registeredDatabases:m}),c=s(a.path);if(c.status===`owned`&&c.agentId===f)return d&&assertAgentSessionStoreDeletionTargetsCurrent(d),e}d&&assertAgentSessionStoreDeletionTargetsCurrent(d)}const u={"agentDeletion.sessionStoreBlocker":(e,t)=>({type:`agentDeletion.sessionStoreBlocker`,blocker:findAgentSessionStoreDeletionBlocker({db:t,path:e.databasePath},e.config,e.agentId,e.env,e.targets)})};export{u as agentDeletionSessionStoreReadOperations};