openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 4.29 kB
JavaScript
import{M as e}from"./transcript-chat-message-content-Cx-VPFHv.mjs";import{p as t}from"./transcript-sqlite-error-diagnostics-Bzt01wuM.mjs";import{t as n}from"./transcript-session-canonical-key-error-BMfMRBaI.mjs";import{a as r,i}from"./transcript-agent-id-DmscQLD6.mjs";import"./transcript-openclaw-agent-db.paths-5mfY5--s.mjs";import{r as a}from"./transcript-session-key-normalization-CxaUSpng.mjs";import"./transcript-session-key-DI46891-.mjs";import{t as o}from"./transcript-sqlite-transaction-BxeoS_ke.mjs";import{i as s,o as c}from"./transcript-openclaw-agent-db-identity-BwKDyjmN.mjs";import{S as l,x as u}from"./transcript-openclaw-agent-db-validation-cache-CPj39b9d.mjs";import"./transcript-openclaw-agent-db-readonly-scope-BsN_9OGD.mjs";import{r as d}from"./transcript-openclaw-agent-db-readonly-DE1r7rt-.mjs";import{i as f}from"./transcript-session-accessor.sqlite-scope-helpers-B6vEQkYq.mjs";import"./transcript-session-canonical-row-BcxrMawA.mjs";import{a as p,t as m}from"./transcript-session-canonical-key-lAtCaW1s.mjs";import{u as h}from"./transcript-session-accessor.sqlite-entry-read-DATS7lGC.mjs";import{o as g}from"./transcript-session-accessor.sqlite-read-scope-rOh2g4nl.mjs";import"./transcript-session-entry-read-source--xIPKZO-.mjs";import"./transcript-session-actor-storage-binding-B0Dp9xe6.mjs";import{t as _}from"./transcript-session-accessor.memory-exact-read-DAiqPgaf.mjs";var v=/* @__PURE__ */ e({loadSessionEntryReadOnlyInScope:()=>loadSessionEntryReadOnlyInScope,loadSessionEntryReadOnlyResultInScope:()=>loadSessionEntryReadOnlyResultInScope,resolveSessionEntryReadOnly:()=>resolveSessionEntryReadOnly,resolveSessionEntryWithDatabase:()=>resolveSessionEntryWithDatabase});function loadSessionEntryReadOnlyInScope(e){return resolveSessionEntryReadOnly(e,{databaseAgentId:e.databaseAgentId,projection:e.projection}).existing}function resolveSessionEntryWithDatabase(e,t,r){let i=_({...e,agentId:t.databaseAgentId??e.agentId});if(i){let n=e.sessionKey.trim(),r=i.read(n,t.readOnly?t.projection:`full`);return i.source&&t.onReadSource?.(i.source),{existing:r,legacyKeys:[],normalizedKey:n}}let o=t.databaseAgentId&&e.storePath?{...g({...e,agentId:e.agentId??a(e.sessionKey)?.agentId??t.databaseAgentId,storePath:void 0}),path:e.storePath,databaseAgentId:t.databaseAgentId}:g(e);t.databaseAgentId&&(o.databaseAgentId=t.databaseAgentId);let read=e=>{let r,i;if(t.onReadError&&!t.readFacts)try{m(e)}catch(e){if(!(e instanceof n))throw e;i={error:e}}if(!i)try{let n=t.readOnly?t.projection:`full`;if(t.readFacts){let i=t.readFacts(e,o.sessionKey,n);r=i?{entry:i,row:{session_key:o.sessionKey}}:void 0}else r=h(e,o.agentId,o.sessionKey,{keyFormat:t.keyFormat,allowCanonicalMove:t.allowCanonicalMove,projection:n})}catch(e){if(!t.onReadError)throw e;i={error:e}}if(t.onReadSource){let n=c(e);if(!s(e))throw Error(`Session database physical identity changed during read`);t.onReadSource({agentId:e.agentId,path:e.path,databaseIdentity:n.identity,databaseBirthtime:n.birthtime})}return i&&t.onReadError(i.error,e.db),{existing:r?.entry??void 0,legacyKeys:[],normalizedKey:r?.row.session_key??o.sessionKey}},readOperation=read;if(t.readOnly&&(readOperation=e=>t.readFacts?read(e):p(e,t.continuation,()=>read(e)),t.capturedDatabase))return readOperation(t.capturedDatabase);let l=r(readOperation,f(o));return l.found?l.value:{existing:void 0,legacyKeys:[],normalizedKey:o.sessionKey}}function resolveSessionEntryReadOnly(e,t={}){return resolveSessionEntryWithDatabase(e,{...t,readOnly:!0},d)}var SessionEntryDataReadError=class extends Error{constructor(e,n){let r=t(e)===1?u(n,e):e;super(`Session entry data read failed`,{cause:r}),this.database=n,this.readError=r}assertSettled(){if(o(this.database),this.database.isOpen&&this.database.isTransaction)throw this.readError}};function loadSessionEntryReadOnlyResultInScope(e,t,n,a,o){try{return r(resolveSessionEntryReadOnly(e,{databaseAgentId:e.databaseAgentId,projection:e.projection,continuation:t,onReadSource:n,readFacts:a,capturedDatabase:o,onReadError(e,t){throw new SessionEntryDataReadError(e,t)}}).existing)}catch(e){if(e instanceof SessionEntryDataReadError)return e.assertSettled(),i(e.readError);if(l(e))return i(e);throw e}}export{resolveSessionEntryReadOnly as n,v as r,loadSessionEntryReadOnlyResultInScope as t};