openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 1.96 kB
JavaScript
import{s as e}from"./transcript-openclaw-root-MOWp8O-B.mjs";import{r as t}from"./transcript-session-accessor.sqlite-scope-helpers-LCM13IZK.mjs";import{i as n}from"./transcript-session-entry-snapshots-B1SDC3sn.mjs";import{t as r}from"./transcript-internal-session-key-aELBBJcF.mjs";import{r as i,t as a}from"./transcript-session-actor-storage-binding-BeZZBFjA.mjs";import"node:path";function captureMemoryExactSessionReader(o,s){let c=e(),assertCurrent=()=>{c?.throwIfAborted(),s?.()},l=a(o,{assertCurrent,authorize:assertCurrent});if(!l)return;let{owner:u,authority:d,agentId:f}=l,p=l.binding?.agentId===f&&l.binding.path===l.path?l.binding:void 0,m=u?.identity??p?.actor.target.database,h=m?.kind===`memory`?{agentId:f,path:l.path,databaseIdentity:m.incarnation}:void 0,entries=e=>u?u.listSessionEntries(d,e):p?.actor.storage?.readCurrent({type:`session.entries.read`,input:{projection:e}},d)??[];return{source:h,agentId:f,path:l.path,read(e,r){let a=i(l,t(e,f));return a&&n(a,{},r)},readById(e,t,r){let i=u?u.readSessionById(e,d,{currentOnly:!0,orderBy:r}):p?.actor.storage?.readCurrent({type:`session.entry.readById`,input:{sessionId:e,currentOnly:!0}},d);return i&&{sessionKey:i.sessionKey,entry:n(i.entry,{},t)}},entries,children(e,n){let i=new Set(e.map(e=>t(e,f)));return entries(n).filter(({sessionKey:e,entry:t})=>!r(e)&&!i.has(e)&&(i.has(t.parentSessionKey??``)||i.has(t.spawnedBy??``))).toSorted((e,t)=>e.sessionKey<t.sessionKey?-1:+(e.sessionKey>t.sessionKey))},facts(e){if(u){let t=u.readSession(e,d);return{members:t?.members??[],participants:t?.participants??[]}}return p?.actor.target.sessionKey===e?{members:p.actor.storage?.readCurrent({type:`session.members.read`,input:{}},d).members??[],participants:p.actor.storage?.readCurrent({type:`session.participants.read`,input:{}},d)??[]}:{members:[],participants:[]}},assertCurrent(){u?.assertCurrent(),!u&&p&&p.actor.assertReadable(),d.assertCurrent()}}}export{captureMemoryExactSessionReader as t};