Files
2026-07-13 13:20:22 +08:00

41 lines
1.2 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import type { IMessageAcpToolCall } from '@/common/chat/chatLib';
import { normalizeAcpToolCall } from '@/common/chat/normalizeToolCall';
describe('normalizeToolCall', () => {
it('normalizes compact snake_case acp tool calls from history responses', () => {
const result = normalizeAcpToolCall({
id: 'message-1',
conversation_id: 'conversation-1',
type: 'acp_tool_call',
content: {
_compact: {
truncated: true,
original_size: 90000,
preview_chars: 4096,
},
update: {
session_update: 'tool_call',
tool_call_id: 'tool-1',
status: 'completed',
title: 'rg',
kind: 'search',
raw_input: { pattern: 'needle', path: '.' },
content: [{ type: 'content', content: { type: 'text', text: 'preview' } }],
},
},
} as unknown as IMessageAcpToolCall);
expect(result).toMatchObject({
key: 'tool-1',
name: 'rg',
status: 'completed',
description: '"needle" in .',
output: 'preview',
truncated: true,
messageId: 'message-1',
conversationId: 'conversation-1',
});
});
});