/** * Typed errors for the public api-store LLM endpoint (feature 472). * * Resolves UI finding U1: applications need a typed, pattern-matchable error * for the structured 400 body produced when `route: "private"` cannot be * honoured on the selected executor. * * The host emits the canonical body shape (see OpenAPI contract): * { * "code": "api_store.private_unavailable", * "requested_route": "private", * "reason": "no_esp32_endpoint" | "firmware_upgrade_required" | …, * "fallback_available": true | false * } * * `apiClient` errors with `code === "api_store.private_unavailable"` are * mapped to a [[PrivateUnavailableError]] instance via [[mapApiErrorBody]]. */ import type { LlmRoute, PrivateUnavailableReason } from "./types"; /** Wire shape of the structured 400 body. */ export interface PrivateUnavailableBody { code: "api_store.private_unavailable"; requested_route: "private"; reason: PrivateUnavailableReason; fallback_available: boolean; } /** Wire shape of the route_mode + execution_preference rejection body. */ export interface InvalidRouteModeCombinationBody { code: "api_store.invalid_route_mode_combination"; route_mode: LlmRoute; execution_preference?: string; hint: string; } /** * Thrown by the SDK when the host rejects a `route: "private"` request * because the selected executor has no custodial-hardware path (or its * firmware is too old, the peer is offline, or the platform is not enabled * by the operator). * * Catch this specifically to either: * - retry with `route: "auto"` (the `fallback_available` field is true when * the host believes a public-path fallback would succeed), or * - surface a precise message to the user explaining which condition * blocked the private path. * * **Honest framing reminder**: Even when the call succeeds with * `route: "private"`, the prompt contents are not masked from the upstream * provider — privacy is about credential isolation and egress device, not * payload secrecy. */ export declare class PrivateUnavailableError extends Error { readonly code: "api_store.private_unavailable"; readonly reason: PrivateUnavailableReason; readonly fallback_available: boolean; constructor(body: PrivateUnavailableBody); } /** * Thrown by the SDK when `route` + `execution_preference` form a rejected * combination per the Routing Truth Table in `data-model.md §4`. */ export declare class InvalidRouteModeCombinationError extends Error { readonly code: "api_store.invalid_route_mode_combination"; readonly route_mode: LlmRoute; readonly execution_preference?: string; readonly hint: string; constructor(body: InvalidRouteModeCombinationBody); } /** * Map a 400 response body (already JSON-parsed) into the typed SDK error * variant, or return `null` to let the caller fall through to the generic * `ApiError` path. * * Used by [[ApiStoreClient]] inside its 400 branch so applications can * `catch (e) { if (e instanceof PrivateUnavailableError) … }` without * having to introspect the wire body themselves. */ export declare function mapApiErrorBody(body: unknown): Error | null;