SIGN IN SIGN UP

fix: preserve Moonshot API error metadata in HTTP and streaming responses (#19742)

## Background

The published Moonshot provider dropped documented optional error codes
from HTTP APICallError.data and structured SSE errors, reducing
diagnostic information.

## Root Cause

The Moonshot error schema omitted code, so Zod stripped it from parsed
HTTP and SSE envelopes, and the stream-error adapter did not forward
code. The original reproduction confirmed both losses.

## Summary

Added nullable code parsing and forwarding to provider stream errors,
added HTTP/SSE fixtures and regression coverage, and included a patch
changeset.

## Testing

Expanded Moonshot language-model tests to cover coded, nullable-code,
and message-only HTTP errors plus coded SSE errors.

## End-to-end Validation

- `replay_original_reproduction` (`pnpm -C examples/ai-functions exec
tsx src/reproduction/moonshot-error-metadata.ts`) exited successfully
and reported that Moonshot API error metadata was preserved.

## Related Issues

Fixes #19552

Closes #19714

---------

Co-authored-by: ai-sdk-factory <308175966+ai-sdk-factory@users.noreply.github.com>
Co-authored-by: Gregor Martynus <39992+gr2m@users.noreply.github.com>
A
ai-sdk-factory[bot] committed
48c5f461ef63c637cccb5ff9799f12759bbd046e
Parent: 87b49a2
Committed by GitHub <noreply@github.com> on 8/26/2026, 6:57:28 PM