/** * Parse provider error payloads from pi-ai assistant errorMessage strings. */ import type { AssistantMessage } from '@earendil-works/pi-ai/compat'; import { formatGeminiThoughtSignatureErrorMessage, isGeminiThoughtSignatureAssistantError, isGeminiThoughtSignatureError } from '../../infra/gemini-provider.js'; export { formatGeminiThoughtSignatureErrorMessage, isGeminiThoughtSignatureAssistantError, isGeminiThoughtSignatureError, }; export interface ParsedProviderError { readonly statusCode?: number; readonly code?: string; readonly message?: string; } /** * Extract HTTP status / error code from JSON provider error blobs. */ export declare function parseProviderError(errorMessage: string): ParsedProviderError | undefined; export declare function parseAssistantMessageError(message: AssistantMessage): ParsedProviderError | undefined; export declare function isInfraAssistantError(message: AssistantMessage): boolean; /** Output tokens at or below this count are treated as no usable generation. */ export declare const NEGLIGIBLE_OUTPUT_TOKEN_MAX = 4; /** Input ratio of context window that signals context pressure on length stops. */ export declare const LENGTH_STOP_CONTEXT_PRESSURE_RATIO = 0.99; export type LengthStopKind = 'context_pressure' | 'output_truncation'; export interface LengthStopHints { readonly contextWindow?: number; } export declare function isNegligibleOutputTokens(outputTokens: number): boolean; /** * Classify a `stopReason: length` assistant message as context pressure vs output truncation. */ export declare function classifyLengthStop(message: AssistantMessage, hints?: LengthStopHints): LengthStopKind | undefined; /** * User-facing text for length stops — distinct wording for context pressure vs truncation. */ export declare function formatLengthStopMessage(message: AssistantMessage, hints?: LengthStopHints): string; /** * Rewrite context-pressure length stops as errors so pi surfaces the overflow message. */ export declare function sanitizeLengthStopMessage(message: AssistantMessage, hints?: LengthStopHints): AssistantMessage; /** * Format a provider error blob for user-facing display (terminal/session). * Never returns raw nested JSON. */ export declare function formatProviderErrorMessage(errorMessage: string): string; //# sourceMappingURL=provider-error.d.ts.map