UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

34 lines (33 loc) • 1.57 kB
import { a as asOptionalRecord } from "./record-coerce-CVPuDqcc.mjs"; import { a as isAssistantTextContentBlockType, c as parseAssistantTextSignature, s as normalizeAssistantPhase } from "./chat-message-content-DNUdbbJ8.mjs"; import { r as isInsideCode } from "./code-ranges-2XaqsF-S.mjs"; import "./code-regions-CfNY0afj.mjs"; import { n as findMarkdownCodeRegions } from "./reasoning-tags-DL3sP_9k.mjs"; import { t as toolCallXmlTextFilter } from "./tool-call-xml-DSl4fabj.mjs"; //#region src/shared/text/native-tool-marker.ts /** Display-only text groups; the source message and native calls remain unchanged. */ function findNativeToolMarkerTextBlocks(e) { const t = /* @__PURE__ */ new Set(); const n = asOptionalRecord(e); if (n?.role !== "assistant" || normalizeAssistantPhase(n.phase) || !Array.isArray(n.content)) return t; let r = 0; let i = ""; let a = ""; let o = false; for (let e = 0; e <= n.content.length; e++) { const s = asOptionalRecord(n.content[e]); if (s && isAssistantTextContentBlockType(s.type) && typeof s.text === "string") { i += s.text; o ||= Boolean(parseAssistantTextSignature(s)?.phase); continue; } if (s?.type === "toolCall" && !o && i.includes("<") && !toolCallXmlTextFilter({ stripFunctionCallsXmlPayloads: true }, true).transform(i.trimEnd()).trim() && !isInsideCode(a.length + i.indexOf("<"), findMarkdownCodeRegions(a + i))) for (let n = r; n < e; n++) t.add(n); a = o ? "" : `${a}${i}\n`; r = e + 1; i = ""; o = false; } return t; } //#endregion export { findNativeToolMarkerTextBlocks as t };