openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 1.3 kB
JavaScript
import{a as e}from"./transcript-record-coerce-CPLgmAk9.mjs";import{s as t,t as n}from"./transcript-chat-message-content-DeOIjx3p.mjs";function readAssistantDeliveryFacts(t){if(!e(t))return;let n={};if(t.audioAsVoice===!0&&(n.audioAsVoice=!0),typeof t.replyToId==`string`&&t.replyToId.trim()?n.replyToId=t.replyToId:t.replyToCurrent===!0&&(n.replyToCurrent=!0),Array.isArray(t.mediaUrls)){let e=t.mediaUrls.filter(e=>typeof e==`string`&&e.trim().length>0);e.length&&(n.mediaUrls=e)}if(e(t.tts)&&t.tts.tagged===!0){let r={tagged:!0};typeof t.tts.text==`string`&&(r.text=t.tts.text),Array.isArray(t.tts.directives)&&(r.directives=t.tts.directives.flatMap(t=>{if(!e(t)||!e(t.values))return[];let n=Object.entries(t.values);if(!n.every(e=>typeof e[1]==`string`))return[];let r=Object.fromEntries(n);return[{...typeof t.provider==`string`?{provider:t.provider}:{},values:r}]})),n.tts=r}return Object.keys(n).length?n:void 0}function projectAssistantTranscriptText(r,i){if(!e(r)||r.role!==`assistant`)return;let a=t(r,n(r));if(!a?.trim())return;let o=readAssistantDeliveryFacts(r.openclawDelivery);return{...typeof i==`string`&&i?{id:i}:{},text:a,...typeof r.timestamp==`number`&&Number.isFinite(r.timestamp)?{timestamp:r.timestamp}:{},...o?{openclawDelivery:o}:{}}}export{projectAssistantTranscriptText as t};