co-mono/packages/ai/test
Mario Zechner 4e7a340460 Add Unicode surrogate sanitization for all providers
Fixes issue where unpaired Unicode surrogates in tool results cause JSON serialization errors in API providers, particularly Anthropic.

- Add sanitizeSurrogates() utility function to remove unpaired surrogates
- Apply sanitization in all provider convertMessages() functions:
  - User message text content (string and text blocks)
  - Assistant message text and thinking blocks
  - Tool result output
  - System prompts
- Valid emoji (properly paired surrogates) are preserved
- Add comprehensive test suite covering all 8 providers

Previously only Google and Groq handled unpaired surrogates correctly.
Now all providers (Anthropic, OpenAI Completions/Responses, Google, xAI, Groq, Cerebras, zAI) sanitize text before API submission.
2025-10-13 14:26:54 +02:00
..
data feat(ai): Add image input tests for vision-capable models 2025-08-30 18:37:17 +02:00
abort.test.ts refactor(ai): improve error handling and stop reason types 2025-09-18 19:57:13 +02:00
agent.test.ts Add ToolRenderResult interface for custom tool rendering 2025-10-11 04:40:42 +02:00
empty.test.ts refactor(ai): improve error handling and stop reason types 2025-09-18 19:57:13 +02:00
enum-test.ts refactor(ai): improve error handling and stop reason types 2025-09-18 19:57:13 +02:00
handoff.test.ts refactor(ai): improve error handling and stop reason types 2025-09-18 19:57:13 +02:00
stream.test.ts refactor(ai): improve error handling and stop reason types 2025-09-18 19:57:13 +02:00
tool-call-without-result.test.ts Remove tool calls for which there are no results in subsequent user messages. 2025-10-01 22:18:30 +02:00
tool-validation.test.ts Fix NodeJS compat 2025-09-16 02:19:47 +02:00
unicode-surrogate.test.ts Add Unicode surrogate sanitization for all providers 2025-10-13 14:26:54 +02:00