UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 2.05 kB
import{a as e,i as t}from"./transcript-kysely-sync-CAP5xe3V.mjs";import{t as n}from"./transcript-sqlite-number-5mfxKD9j.mjs";import{a as r}from"./transcript-openclaw-agent-db-identity-BPgUuROx.mjs";import{r as i}from"./transcript-session-cold-storage-state-BxQ0_xF8.mjs";function readSessionStateDeleteSnapshot(r,i){let a=e(r),o=a.selectNoFrom(e=>e.val(i).as(`session_id`)).as(`target`),s=t(r,a.selectFrom(o).leftJoin(`session_windows as window`,`window.session_id`,`target.session_id`).leftJoin(`transcript_rewrite_watermarks as watermark`,`watermark.session_id`,`target.session_id`).select([`window.session_key`,`window.transcript_updated_at`,`window.updated_at`,`watermark.generation`]).select(e=>[e.selectFrom(`transcript_events`).select(`seq`).whereRef(`transcript_events.session_id`,`=`,`target.session_id`).orderBy(`seq`,`desc`).limit(1).as(`last_seq`),e.selectFrom(`trajectory_runtime_events`).select(`seq`).whereRef(`trajectory_runtime_events.session_id`,`=`,`target.session_id`).orderBy(`seq`,`desc`).limit(1).as(`trajectory_last_seq`),e.selectFrom(`acp_parent_stream_events`).select(e=>e.fn.countAll().as(`event_count`)).whereRef(`acp_parent_stream_events.session_id`,`=`,`target.session_id`).as(`acp_parent_stream_event_count`)]));return{acpParentStreamEventCount:n(s?.acp_parent_stream_event_count??0),generation:s?.generation??null,lastSeq:s?.last_seq??null,sessionKey:s?.session_key??null,sessionUpdatedAt:s?.updated_at??null,trajectoryLastSeq:s?.trajectory_last_seq??null,transcriptUpdatedAt:s?.transcript_updated_at??null}}function planSessionStateDeleteIfUnreferenced(e){return e.referencedSessionIds.has(e.sessionId)||i(e.database.db,e.sessionId)?null:{agentId:e.database.agentId,archiveDirectory:e.archiveDirectory,archiveTranscript:e.archiveTranscript!==!1&&typeof r(e.database).identity==`string`,databasePath:e.database.path,reason:e.reason??`deleted`,sessionId:e.sessionId,snapshot:readSessionStateDeleteSnapshot(e.database.db,e.sessionId)}}export{readSessionStateDeleteSnapshot as n,planSessionStateDeleteIfUnreferenced as t};