openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 1.63 kB
JavaScript
import{n as e}from"./transcript-sql-connection-CRz-dHXM.mjs";import{t}from"./transcript-session-transcript-cold-error-3WQan6ko.mjs";import{a as n,m as r}from"./transcript-kysely-sync-DQ_Yn8jW.mjs";import{t as i}from"./transcript-zstd-codec-Bwg8OR0e.mjs";const a=4194304,o=`openclaw_transcript_payload_decode`,s=/* @__PURE__ */ new WeakSet,c=new TextDecoder(`utf-8`,{fatal:!0,ignoreBOM:!0});function registerDecoder(e){s.has(e)||(e.function(o,{deterministic:!0,directOnly:!0},decodeCompressedTranscriptPayload),s.add(e))}function decodeCompressedTranscriptPayload(e,n){if(e===null)throw new t;try{if(!(e instanceof Uint8Array)||e.byteLength===0||e.byteLength>4194304||typeof n!=`number`||!Number.isSafeInteger(n)||n<1||n>4194304)throw Error(`Invalid compressed transcript payload bounds`);let t=i().decompress(e,n);if(t.byteLength!==n)throw Error(`Compressed transcript payload length does not match its recorded UTF-8 size`);return c.decode(t)}catch(e){throw Object.assign(Error(`Corrupt transcript body: ${e instanceof Error?e.message:String(e)}. Restore a verified backup and run openclaw doctor.`,{cause:e}),{name:`SessionTranscriptCorruptionError`,code:`TRANSCRIPT_CORRUPT`})}}function readTranscriptPayload(e){return e.event_json??decodeCompressedTranscriptPayload(e.event_zstd,e.event_utf8_bytes)}function transcriptEventJsonSql(t,i=`transcript_events`){if(e(t))return r.ref(`${i}.event_json`);registerDecoder(t);let a=r.ref(`${i}.event_json`),s=r.ref(`${i}.event_zstd`),c=r.ref(`${i}.event_utf8_bytes`),l=n(t).fn(o,[s,c]);return r`coalesce(${a}, ${l})`}export{readTranscriptPayload as n,transcriptEventJsonSql as r,a as t};