@tanstack/ai
Version:
Type-safe TypeScript AI SDK for streaming chat, tool calling, agents, structured outputs, and multimodal generation.
23 lines (22 loc) • 924 B
TypeScript
import { StreamChunk } from '../types.js';
/**
* Best-effort extraction of a human-readable message from an unknown thrown
* value, returning `undefined` when none can be found.
*
* Used by `otelMiddleware` so error reporting stays identical across chat and
* media spans.
*/
export declare function errorMessage(err: unknown): string | undefined;
/**
* Best-effort extraction of an error's type name (used for the `error.type`
* metric attribute), falling back to `'Error'` when no name is available.
*/
export declare function errorTypeName(err: unknown): string;
/**
* Convert an AG-UI RUN_ERROR event to the Error shape exposed to consumers.
* Preserves the provider code and sanitized raw event when available, while
* accepting the deprecated nested error payload for backward compatibility.
*/
export declare function runErrorEventToError(chunk: Extract<StreamChunk, {
type: 'RUN_ERROR';
}>): Error;