/** * Compact Error Envelope * * Per AX-012, provides minimal error shapes with stable hint IDs for token efficiency. * Agents can fetch hint details separately and cache them. * * @module shared/errors/compact-error */ import { z } from "zod"; import type { AXError } from "./ax-error.js"; import { type HintId } from "./hint-registry.js"; /** * Compact error envelope schema * * Uses short field names to reduce token usage: * - err: error details * - msg: message * - retry: whether the error is retryable * - hintId: reference to cacheable hint */ export declare const CompactErrorEnvelopeSchema: z.ZodObject<{ err: z.ZodObject<{ code: z.ZodString; msg: z.ZodString; retry: z.ZodBoolean; hintId: z.ZodOptional; }, z.core.$strip>; }, z.core.$strip>; export type CompactErrorEnvelope = z.infer; /** * Compact error structure (just the error part) */ export interface CompactError { code: string; msg: string; retry: boolean; hintId?: HintId; } /** * Convert an AXError to a compact error */ export declare function toCompactError(error: AXError): CompactError; /** * Convert an MCP error response to a compact error */ export declare function mcpErrorToCompactError(code: string, message: string): CompactError; /** * Create a compact error envelope */ export declare function createCompactErrorEnvelope(error: CompactError): CompactErrorEnvelope; /** * Create a compact error envelope from an AXError */ export declare function axErrorToCompactEnvelope(error: AXError): CompactErrorEnvelope; /** * Create a compact error envelope from MCP error details */ export declare function mcpErrorToCompactEnvelope(code: string, message: string): CompactErrorEnvelope;