import { describe, expect, test } from 'bun:test' import type { UIMessage } from 'ai' import { conversationTitle, sanitizeAgentMessages } from './pascal-agent-conversations' describe('Pascal agent conversation history', () => { test('keeps text and compact tool activity while dropping tool payloads', () => { const messages = [ { id: 'assistant-1', role: 'assistant', parts: [ { type: 'text', text: '正在建模' }, { type: 'tool-create_room', state: 'output-available', toolCallId: 'call-1', input: { width: 10 }, output: { graph: { veryLarge: true } }, }, ], }, ] as UIMessage[] expect(sanitizeAgentMessages(messages)).toEqual([ { id: 'assistant-1', role: 'assistant', parts: [ { type: 'text', text: '正在建模' }, { type: 'data-pascal-tool-activity', data: { toolName: 'create_room', state: 'output-available' }, }, ], }, ]) }) test('derives a concise title from the first user message', () => { const messages = [ { id: 'user-1', role: 'user', parts: [{ type: 'text', text: ' 设计一个\n两室一厅住宅 ' }], }, ] as UIMessage[] expect(conversationTitle(messages)).toBe('设计一个 两室一厅住宅') }) })