import type { ConsultationDomain } from "./consultation-domain-registry.ts"; export type ReplyTheme = ConsultationDomain; import type { ConsultationReplyMetadata } from "./consultation-reply-metadata.ts"; function readTitle(value: string): string | undefined { const title = value.replace(/\s+/g, " ").trim(); if (!title || /[\d\p{P}\p{S}]/u.test(title)) return undefined; if (/\p{Script=Han}/u.test(title)) { const length = Array.from(title.replace(/\s/g, "")).length; return length >= 6 && length <= 14 ? title : undefined; } const words = title.split(" ").filter(Boolean); return words.length >= 3 && words.length <= 7 && title.length <= 64 ? title : undefined; } // AYANAM_SUGGESTIONS blocks are no longer produced anywhere, but stored answers from // before the follow-up chips were removed still carry them, so they stay strippable // rather than leaking a raw HTML comment into a replayed transcript. function stripAgentReplyMetadata(value: string) { let title: string | undefined; const text = value .replace(//g, "") .replace(//g, (_, rawTitle: string) => { title = readTitle(rawTitle); return ""; }) .replace(/