mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-25 14:31:11 +00:00
* fix: render assistant transcript headers safely Co-authored-by: snowzlmbot <293528334+snowzlmbot@users.noreply.github.com> * fix(markdown): nest crossing annotation spans * fix(markdown): protect final transport projections * refactor(markdown): split transcript render ownership * test(ui): cover assistant transcript render flag * refactor(markdown): keep transcript helpers private * docs(changelog): note assistant transcript headers * chore(plugin-sdk): refresh transcript annotation baseline * fix(markdown): harden final transcript projections * docs(changelog): defer transcript note to release * refactor(markdown): centralize HTML tokenization * fix(markdown): satisfy lint gates --------- Co-authored-by: Peter Steinberger <steipete@gmail.com> Co-authored-by: snowzlmbot <293528334+snowzlmbot@users.noreply.github.com>
23 lines
806 B
TypeScript
23 lines
806 B
TypeScript
import { markdownToIR } from "../../../packages/markdown-core/src/ir.js";
|
|
|
|
type AssistantTranscriptRoleHeaderDetection = {
|
|
kind: "angle_role_header" | "role_timestamp_bracket" | "timestamp_role_colon";
|
|
role: "assistant" | "developer" | "system" | "user";
|
|
};
|
|
|
|
/** Detect transcript-role headers in assistant Markdown through the canonical parser. */
|
|
export function detectAssistantTranscriptRoleHeaderText(
|
|
text: string,
|
|
): AssistantTranscriptRoleHeaderDetection | null {
|
|
const annotation = markdownToIR(text, {
|
|
assistantTranscriptRoleHeaders: true,
|
|
enableSpoilers: true,
|
|
linkify: false,
|
|
tableMode: "off",
|
|
}).annotations?.[0];
|
|
if (!annotation || annotation.type !== "assistant_transcript_role") {
|
|
return null;
|
|
}
|
|
return { kind: annotation.kind, role: annotation.role };
|
|
}
|