UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 3.68 kB
import{r as e}from"./transcript-chat-message-content-Cx-VPFHv.mjs";import{i as t,o as n}from"./transcript-record-coerce-eN4p5mcq.mjs";import{n as r}from"./transcript-assistant-display-content-JhF22vyd.mjs";import{i,r as a}from"./transcript-transcript-events-CeN2k8Gr.mjs";import{h as o}from"./transcript-transcript-payload-C58U6XNI.mjs";import{o as s,s as c}from"./transcript-transcript-only-openclaw-assistant-CxIarIin.mjs";import{t as l}from"./transcript-session-entry-navigation-Cr345jH-.mjs";const u=`openclaw.code-mode-store`;function readCodeModeStoreKey(e){if(typeof e!=`string`||e.length===0||e.length>256)throw TypeError(`Code Mode store key must be a non-empty string of at most 256 characters.`);return e}function collectCodeModeStoreWrites(e,t=!1){let r=/* @__PURE__ */ new Map;for(let i of e){if(!n(i)||i.type!==`custom`||i.customType!==`openclaw.code-mode-store`)continue;let e=i.data;if(!n(e)||!n(e.set)||!Array.isArray(e.delete)||!n(e.networkContent))throw Error(`Code Mode session store contains an invalid transcript entry; repair the session before using store/load.`);for(let[t,n]of Object.entries(e.set)){let i=e.networkContent[t];if(typeof i!=`boolean`)throw Error(`Code Mode session store contains invalid content provenance; repair the session before using store/load.`);r.set(readCodeModeStoreKey(t),{value:n,networkContent:i})}for(let n of e.delete){let e=readCodeModeStoreKey(n);t?r.set(e,null):r.delete(e)}}return r}function selectTranscriptMaintenanceSuffix(e,n,r,i){let a=n.leafEntryId,s=0,c=0,l=[];for(let n of e){if(c+=n.bytes,++s>256||c>1048576)return;let e=o(n.event);if(e.kind!==`canonical`||!e.hasParentId||e.entry.parentId!==a||e.entry.appendMode===`side`||e.entry.type===`reset`||e.entry.type===`label`)return;a=e.entry.id;let r=t(n.event);e.entry.type===`custom`&&r.customType===i&&l.push(r)}return a===r?l:void 0}function assistantReportUpdate(e,t){return e?.appended?{messageId:e.messageId,messageSeq:e.anchor?e.anchor.activeMessagePosition+1:void 0,lifecycleRevision:t}:void 0}var TranscriptReportNavigation=class extends l{constructor(e){super();for(let{seq:t,facts:n}of e)switch(n.kind){case`canonical`:this.appendCanonicalNavigationEntry({...n.entry,parentId:n.entry.parentId??null,seq:t},n.hasParentId);break;case`leaf`:this.appendOpaqueNavigationRecord({...n.entry,type:`leaf`});break;case`link`:this.appendOpaqueNavigationRecord(n)}this.finishNavigation()}facts(){return{appendParentId:this.appendParentId,path:this.getBranch()}}readCustomBranch(e,t,n){if(e===null)return[];if(!this.byId.has(e))return;let r=this.getBranch(e);return(function*(){for(let e of r){if(e.type!==`custom`)continue;let r=n(e.seq);r?.customType===t&&(yield r)}})()}};function latestCustomReport(e,t,n){for(let r of e.path.toReversed()){if(r.type!==`custom_message`||r.customType===void 0||!n.includes(r.customType))continue;let e=t(r.seq);if(e)return{customType:r.customType,content:e.content,details:e.details}}}function selectTranscriptReport(e,t,n){let r=n.kind===`assistant`&&e.path.some(e=>e.assistantResponseId===n.responseId);return{appendParentId:e.appendParentId,suppressed:r,latest:n.kind===`custom`&&!r?latestCustomReport(e,t,n.customTypes):void 0}}function hasSettledTranscriptAssistant(o,l,u){return o.path.toReversed().some(o=>{if(o.assistantRunId!==u)return!1;let d=l(o.seq)?.message;if(!n(d)||a(d)!==u||i(d,u)===void 0||s(d)||c(d))return!1;let f=t(d.__openclaw);return(f?.mirrorOrigin===void 0||f.runTerminal===!0)&&!!e(r(d))?.trim()})}export{selectTranscriptMaintenanceSuffix as a,selectTranscriptReport as i,assistantReportUpdate as n,u as o,hasSettledTranscriptAssistant as r,collectCodeModeStoreWrites as s,TranscriptReportNavigation as t};