UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 2.06 kB
import{i as e}from"./transcript-record-coerce-CPLgmAk9.mjs";import{l as t}from"./transcript-string-coerce-DTk-8HSr.mjs";import{n}from"./transcript-transcript-visible-record-BPnefnPg.mjs";function attachOpenClawTranscriptMeta(t,n){let r=e(t);if(!r)return t;let i=e(r.__openclaw)??{};return{...r,__openclaw:{...i,...n}}}function readTranscriptMessageIdempotencyKey(n){return t(e(n)?.idempotencyKey)}function sqliteMessageEventWithSeq(e){return projectTranscriptEntryMessage(e.event,e.seq,e.displayPosition)}function projectTranscriptEntryMessage(t,r,i){if(!n(t))return null;let a=t;if(a.message){let e=typeof a.timestamp==`string`?Date.parse(a.timestamp):typeof a.timestamp==`number`?a.timestamp:NaN,t=readTranscriptMessageIdempotencyKey(a.message);return attachOpenClawTranscriptMeta(a.message,{...typeof a.id==`string`?{id:a.id}:{},...t?{idempotencyKey:t}:{},...Number.isFinite(e)?{recordTimestampMs:e}:{},transcriptPosition:i,seq:r})}let o=typeof a.timestamp==`string`?Date.parse(a.timestamp):NaN;if(a.type===`custom_message`)return attachOpenClawTranscriptMeta({role:`custom`,customType:a.customType,content:a.content,display:a.display,details:a.details,timestamp:o},{...typeof a.id==`string`?{id:a.id}:{},recordTimestampMs:o,transcriptPosition:i,seq:r});if(a.type!==`compaction`&&a.type!==`reset`)return null;let s=a.type,c=s===`compaction`?e(a.__openclaw):void 0;return{role:`system`,content:[{type:`text`,text:s===`compaction`?`Compaction`:`Reset`}],timestamp:Number.isFinite(o)?o:Date.now(),__openclaw:{kind:s,id:typeof a.id==`string`?a.id:void 0,...typeof c?.runId==`string`?{runId:c.runId}:{},...typeof c?.itemId==`string`?{itemId:c.itemId}:{},...s===`compaction`&&typeof a.tokensBefore==`number`&&Number.isFinite(a.tokensBefore)?{tokensBefore:a.tokensBefore}:{},...s===`compaction`&&typeof a.tokensAfter==`number`&&Number.isFinite(a.tokensAfter)?{tokensAfter:a.tokensAfter}:{},transcriptPosition:i,seq:r}}}export{sqliteMessageEventWithSeq as i,projectTranscriptEntryMessage as n,readTranscriptMessageIdempotencyKey as r,attachOpenClawTranscriptMeta as t};