import test from 'node:test'; import assert from 'node:assert/strict'; import { parseCompletion, splitThinking, toMiniMessages, fitContext } from '../src/protocol.mjs'; import { createWorkspace } from '../src/workspace.mjs'; import { renderMarkdown } from '../src/markdown.mjs'; const { tools } = createWorkspace(); test('read results identify the real file through relative paths and symlinks', async () => { const workspace = createWorkspace(); await workspace.write('nested/name%20#é.txt', ''); await workspace.bash.exec("ln -s 'nested/name%20#é.txt' link.txt"); const read = workspace.tools.find(tool => tool.name === 'read'); const result = await read.execute('read-path', { path: './link.txt' }); assert.equal(result.details.path, '/workspace/nested/name%20#é.txt'); assert.equal(result.content[0].text, ''); await assert.rejects(read.execute('missing', { path: 'missing.txt' })); }); test('model Markdown cannot execute HTML or request remote images', () => { const html = renderMarkdown('\n![secret](https://example.com/track)\n[x](javascript:alert(1))'); assert(!html.includes('