import assert from 'node:assert/strict'; import { test } from 'vitest'; import { createDsmlArtifactTextSuppressor, createToolCallTextSuppressor, } from '../../src/artifacts/text-suppression.js'; test('DSML artifact suppressor preserves non-DSML tags at the start of a chunk', () => { const suppressor = createDsmlArtifactTextSuppressor(); assert.equal( suppressor.strip(''), '', ); assert.equal(suppressor.flush(), ''); }); test('DSML artifact suppressor preserves partial non-DSML tags at the start of a chunk', () => { const suppressor = createDsmlArtifactTextSuppressor(); assert.equal(suppressor.strip(' { const suppressor = createDsmlArtifactTextSuppressor(); assert.equal( suppressor.strip('Done\n\n< | DSML artifact identifier="page" type="text/html">'), 'Done\n\n', ); assert.equal( suppressor.strip('\n\nTail'), 'Tail', ); assert.deepEqual(suppressor.stats(), { suppressedChars: '< | DSML artifact identifier="page" type="text/html">'.length + '\n\n'.length, suppressedChunks: 2, openedBlocks: 1, closedBlocks: 1, pendingCandidateChars: 0, suppressing: false, }); }); test('DSML artifact suppressor strips legacy artifact blocks', () => { const suppressor = createDsmlArtifactTextSuppressor(); assert.equal( suppressor.strip('Done\n\n'), 'Done\n\n', ); assert.equal( suppressor.strip('\n\nTail'), 'Tail', ); }); test('DSML artifact suppressor strips split legacy artifact close tags', () => { const suppressor = createDsmlArtifactTextSuppressor(); assert.equal( suppressor.strip('Done\n\nraw'), 'Done\n\n', ); assert.equal(suppressor.strip('Tail'), 'Tail'); }); test('DSML artifact suppressor strips split legacy artifact open tags', () => { const suppressor = createDsmlArtifactTextSuppressor(); assert.equal(suppressor.strip('Done\n\n\n'), '', ); assert.equal(suppressor.strip('Tail'), 'Tail'); }); test('tool call suppressor strips edit XML blocks', () => { const suppressor = createToolCallTextSuppressor(); assert.equal(suppressor.strip('Before\n'), 'Before\n'); assert.equal(suppressor.strip('/tmp/index.html'), ''); assert.equal(suppressor.strip('
...
'), ''); assert.equal(suppressor.strip('\nAfter'), 'After'); assert.deepEqual(suppressor.stats(), { suppressedChars: ''.length + '/tmp/index.html'.length + '
...
'.length + '\n'.length, suppressedChunks: 4, openedBlocks: 1, closedBlocks: 1, pendingCandidateChars: 0, suppressing: false, }); }); test('tool call suppressor preserves OD UI markup', () => { const suppressor = createToolCallTextSuppressor(); assert.equal( suppressor.strip('{"summary":"x"}'), '{"summary":"x"}', ); });