openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 2.05 kB
JavaScript
import{a as e,i as t}from"./transcript-kysely-sync-DQ_Yn8jW.mjs";import{o as n}from"./transcript-openclaw-agent-db-identity-BwKDyjmN.mjs";import{t as r}from"./transcript-sqlite-number-CpW6Oa2f.mjs";import{r as i}from"./transcript-session-cold-storage-state-kHrIZc-D.mjs";function readSessionStateDeleteSnapshot(n,i){let a=e(n),o=a.selectNoFrom(e=>e.val(i).as(`session_id`)).as(`target`),s=t(n,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:r(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 n(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};