openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 1.37 kB
JavaScript
import{l as normalizeOptionalString}from"./string-coerce-CpTFcSwY.mjs";import{d as normalizeMediaFacts,h as resolveMediaFactKind}from"./media-facts-03ZYaqC1.mjs";import{assertNoWindowsNetworkPath,safeFileURLToPath}from"@openclaw/fs-safe/advanced";
//!src/media-understanding/attachments.normalize.ts
function normalizeAttachmentPath(e){const t=normalizeOptionalString(e);if(!t)return;if(/^file:/iu.test(t))try{return safeFileURLToPath(t)}catch{return}try{assertNoWindowsNetworkPath(t,`Attachment path`)}catch{return}return t}function normalizeAttachments(e){return normalizeMediaFacts(e.media).map((e,t)=>{const n={path:e.path,url:e.url,mime:e.contentType,index:t,alreadyTranscribed:e.transcribed===true};const r=e.fileName?resolveMediaFactKind(e)??e.kind:e.kind;if(r)n.kind=r;if(e.fileName)n.fileName=e.fileName;if(e.workspaceDir)n.workspaceDir=e.workspaceDir;return n}).filter(e=>Boolean(e.path??e.url))}function resolveAttachmentKind(e){const t=resolveMediaFactKind({path:e.path,url:e.url,contentType:e.mime,kind:e.kind});return t===`sticker`?`image`:t===`document`?`unknown`:t??`unknown`}function isAudioAttachment(e){return resolveAttachmentKind(e)===`audio`}function isImageAttachment(e){return resolveAttachmentKind(e)===`image`}export{resolveAttachmentKind as a,normalizeAttachments as i,isImageAttachment as n,normalizeAttachmentPath as r,isAudioAttachment as t};