openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 1.64 kB
JavaScript
import{$t as e}from"./openclaw-state-read-sqlite-database-admission-Ck6VG7rE.mjs";import"./openclaw-state-read-openclaw-state-db-cache-BVY8IYkn.mjs";import{n as t}from"./openclaw-state-read-agent-id-DmscQLD6.mjs";import"./openclaw-state-read-session-key-DaKMXMbu.mjs";import{S as n,_ as r,v as i}from"./openclaw-state-read-agent-scope-config-DBTVDK8I.mjs";import{a,n as o,o as s}from"./openclaw-state-read-session-sqlite-target-DOCApy1k.mjs";import{i as c}from"./openclaw-state-read-openclaw-agent-db-registry.read-D1CTFqiu.mjs";import"node:path";import{isDeepStrictEqual as l}from"node:util";function captureCandidates(t){return[...new Set(t.flatMap(e=>i(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,i,l,u,d){if(!i.session?.store?.trim())return;let f=t(l),p=s(i);d&&assertAgentSessionStoreDeletionTargetsCurrent(d);let m=e?c(e.db,e.path,!1):[];for(let e of n(i)){if(t(e)===f)continue;let n=r(i.session.store,{agentId:e,env:u}),s=o(n,{agentId:e,defaultAgentId:p,env:u,registeredDatabases:m}),c=a(s.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};