openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 1.32 kB
JavaScript
import{i as e}from"./transcript-record-coerce-CPLgmAk9.mjs";import{t}from"./transcript-code-points-CsbrXIfx.mjs";import{t as n}from"./transcript-chat-message-content-DeOIjx3p.mjs";import{t as r}from"./transcript-markdown-plain-text-Ct_dwbIM.mjs";import{t as i}from"./transcript-transcript-navigation-fields-vfHJn9Ud.mjs";function projectSessionBranchEntry(t,n){let r=e(t);if(!r)return;let a=e(r.message)?.role,o={seq:n,headlineCandidate:r.type===`message`&&(a===`user`||a===`assistant`),...i(r)};return typeof r.timestamp==`string`&&r.timestamp.trim()&&(o.timestamp=r.timestamp),o}function extractSessionBranchHeadline(t){let n=e(t),r=n?.type===`message`?extractHeadlineText(n.message):void 0;return r===void 0?void 0:truncateBranchHeadline(r)}function extractHeadlineText(t){let i=e(t);if(i?.role!==`user`&&i?.role!==`assistant`)return;let a=i.role===`assistant`?n(i):extractEditorText(i.content??i.text);return(a?r(a):void 0)||void 0}function truncateBranchHeadline(e){let n=t(e,120);return n.length===e.length?n:`${t(n,119)}…`}function extractEditorText(t){if(typeof t==`string`)return t;if(Array.isArray(t))return t.flatMap(t=>{let n=e(t);return n?.type===`text`&&typeof n.text==`string`?[n.text]:[]}).join(``)||void 0}export{extractSessionBranchHeadline as n,projectSessionBranchEntry as r,extractEditorText as t};