import { describe, it, expect } from 'vitest';
import { toDcpMessages, fromDcpMessages } from '../messages.js';

describe('toDcpMessages', () => {
  it('converts user messages', () => {
    const result = toDcpMessages([{ role: 'user', content: 'hello' }]);
    expect(result[0].role).toBe('user');
    expect(result[0].content).toBe('hello');
  });

  it('marks Error: content as isError', () => {
    const result = toDcpMessages([{ role: 'tool', content: 'Error: file not found', tool_call_id: '1' }]);
    expect(result[0].isError).toBe(true);
  });
});

describe('fromDcpMessages', () => {
  it('round-trips messages', () => {
    const original = [{ role: 'user', content: 'hello' }];
    expect(fromDcpMessages(toDcpMessages(original))).toEqual(original);
  });
});
