import type { AgentMessage } from "@earendil-works/pi-agent-core"; import { mapText } from "../utils/message-content.ts"; // 1. Complete paired tags: content const DCP_COMPLETE_PAIR = /]*)?>[\s\S]*?<\/dcp[-\w]*>/gi; // 2. Truncated pair (no final > on close): content]*)?>[\s\S]*?<\/dcp[-\w]*/gi; // 3. Lone unpaired tags: or const DCP_UNPAIRED_TAG = /<\/?dcp[-\w]*(?:\s[^>]*)?>/gi; // 4. Partial tag at end of line/string: { if (msg.role !== "assistant") return msg; return mapText(msg, stripHallucinationsFromString); }); }