conversation.spec.ts 1021 B

1234567891011121314151617181920212223
  1. /** Assistant block classifier (moved here with sessions/conversation.ts). */
  2. import { describe, expect, it } from 'vitest'
  3. import type { ContentBlock } from '@deepseek-ai/dsh-client-connection/client'
  4. import { toAssistantBlock, toAssistantBlocks } from '../src/client/sessions/conversation.ts'
  5. describe('toAssistantBlock', () => {
  6. it('classifies the four block shapes', () => {
  7. const blocks: ContentBlock[] = [
  8. { type: 'text', text: '正文' },
  9. { type: 'reasoning', text: '思考' },
  10. { type: 'tool-call', id: 'c1', name: 'echo', arguments: '{}' } as ContentBlock,
  11. { type: 'image', data: 'x' } as unknown as ContentBlock,
  12. ]
  13. expect(toAssistantBlocks(blocks)).toEqual([
  14. { kind: 'text', text: '正文' },
  15. { kind: 'reasoning', text: '思考' },
  16. { kind: 'tool-call', callId: 'c1', name: 'echo', argsRaw: '{}' },
  17. { kind: 'other', block: blocks[3] },
  18. ])
  19. expect(toAssistantBlock(blocks[0] as ContentBlock)).toEqual({ kind: 'text', text: '正文' })
  20. })
  21. })