UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

32 lines (31 loc) • 1.34 kB
import { a as asOptionalRecord, l as isRecord } from "./record-coerce-CVPuDqcc.mjs"; //#region src/shared/assistant-display-content.ts const ASSISTANT_DISPLAY_CONTENT_FIELD = "openclawDisplayContent"; function isAssistantModelContentBlock(e) { const t = asOptionalRecord(e); if (!t) return false; if (t.type === "text") return typeof t.text === "string"; if (t.type === "thinking") return typeof t.thinking === "string"; return t.type === "toolCall" && typeof t.id === "string" && typeof t.name === "string" && asOptionalRecord(t.arguments) !== void 0; } function retainAssistantModelContent(e) { return e.filter(isAssistantModelContentBlock).map((e) => Object.assign({}, e)); } function readAssistantDisplayContent(e) { const t = asOptionalRecord(e); if (!t) return []; const n = t[ASSISTANT_DISPLAY_CONTENT_FIELD]; const r = Array.isArray(n) ? n : t.content; return Array.isArray(r) ? r.filter(isRecord) : []; } function projectAssistantDisplayContent(e) { const t = e[ASSISTANT_DISPLAY_CONTENT_FIELD]; if (e.role !== "assistant" || !Array.isArray(t)) return e; const { [ASSISTANT_DISPLAY_CONTENT_FIELD]: n, ...r } = e; return { ...r, content: t }; } //#endregion export { retainAssistantModelContent as i, projectAssistantDisplayContent as n, readAssistantDisplayContent as r, ASSISTANT_DISPLAY_CONTENT_FIELD as t };