import { test } from "node:test";
import assert from "node:assert/strict";
import { classifyAnswerPrefix } from "@bitbaum/ai-kit";
test("a narrated XML call never becomes visible prose, across every chunk boundary", () => {
const text =
" room ";
for (let boundary = 0; boundary < text.length; boundary++) {
const first = classifyAnswerPrefix(text.slice(0, boundary));
assert.notEqual(first, "answer", `protocol leaked at boundary ${boundary}`);
}
assert.equal(classifyAnswerPrefix(text), "protocol");
});
test("recognises the function form, plural wrapper and whitespace without executing anything", () => {
for (const text of ["", "", " \n"])
assert.equal(classifyAnswerPrefix(text), "protocol");
for (const text of ["", " \n", "<", " {
for (const text of [
"Open your project’s room.",
"Hello
",
" is a name",
"```xml\n\n```",
"Tool: a hammer",
])
assert.equal(classifyAnswerPrefix(text), "answer");
});