@nhtio/adk/batteries/llm/anthropic_messages/error_translation
SDK error → ADK classification for the Anthropic Messages battery.
Remarks
Extracted so the dispatch path (adapter.ts) and the token-count path (count_tokens.ts) share ONE classifier. They previously carried byte-identical private copies, which meant a fix to one silently left the other wrong — exactly what happened with the statusless-APIError bug this module's AnthropicMessagesErrorStatusResolver seam addresses.
Narrowing is STRUCTURAL (isSdkError below), never nominal against a statically imported class. Issue #46: importing @anthropic-ai/sdk/core/error directly gave the bundler a second, inlined copy of the SDK's error classes, and instanceof/constructor-name narrowing against that copy never matched the classes the REAL client (imported from @anthropic-ai/sdk) throws — every HTTP error classified fatal with status 0, so retry and Retry-After never fired. The structural walk requires no class identity at all, so it works under bundling, dualRealm setups, and any future reshuffle of the SDK's internals.
Type Aliases
| Type Alias | Description |
|---|---|
| AnthropicErrorClassification | The outcome of classifying an SDK error. |
Variables
| Variable | Description |
|---|---|
| CONTEXT_OVERFLOW_PHRASE | Body-text marker identifying an Anthropic context-overflow rejection. |
Functions
| Function | Description |
|---|---|
| anthropicErrorHeaders | The response headers of a real SDK HTTP error, or undefined for anything else. |
| translateAnthropicError | Classify an error thrown by the Anthropic SDK into an ADK disposition. |