/** * TypeScript consumer SDK client for the public api-store LLM endpoint * (feature 472). * * Wraps the host's `/api/v2/public/api_store/llm/{call,stream}` endpoints * with a typed surface that threads the `route` field (LlmRoute) through * every call method and surfaces the structured 400 body as typed errors. * * This client is dependency-injection-friendly: the constructor takes a * `fetcher` callback so applications can plug in their existing `apiClient` * singleton (which already handles JWT auth, token refresh, and L402 * payment cycles) without the SDK reaching into application HTTP plumbing * directly. * * **Honest framing reminder** (S5/U4): `route: "private"` isolates the * upstream provider's API credentials and routes egress through a separate * device — it does NOT mask prompt contents from the upstream provider or * anonymize the user. */ import { PrivateUnavailableError, InvalidRouteModeCombinationError } from "./errors"; import type { ExecuteBestModelRequest, ExecuteChatRequest, ExecuteChatResponse, ExecuteRequest, LlmRoute, StreamChatChunk, StreamChatRequest } from "./types"; /** * Minimal fetcher interface — narrow enough that the project's existing * `apiClient` satisfies it directly. The fetcher MUST throw for non-2xx * responses with the raw body attached as `error.body` so the SDK can * decode the structured 400 shapes. */ export interface ApiStoreFetcher { post(path: string, body: TIn): Promise; /** * Streaming POST — returns an async iterable of parsed chunks. The * fetcher owns the SSE parser; the SDK only orchestrates request shape * + error mapping. */ postStream(path: string, body: TIn): AsyncIterable; } /** Consumer client for the public api-store LLM endpoint. */ export declare class ApiStoreClient { private readonly fetcher; constructor(fetcher: ApiStoreFetcher); /** Unary execute call (single-message). */ execute(request: ExecuteRequest): Promise; /** Unary execute_chat call. */ executeChat(request: ExecuteChatRequest): Promise; /** Unary execute_best_model call. */ executeBestModel(request: ExecuteBestModelRequest): Promise; /** * Streaming chat call. Yields chunks in order; the final chunk is always * either an `end` event (carrying execution_route + token usage + cost) or * an `error` event (FR-016 / S3 invariant — no silent fallback to direct * provider). Consumers MUST handle the `error` variant explicitly. */ streamChat(request: StreamChatRequest): AsyncGenerator; private callWithRoute; } export { PrivateUnavailableError, InvalidRouteModeCombinationError }; export type { ExecuteBestModelRequest, ExecuteChatRequest, ExecuteChatResponse, ExecuteRequest, LlmRoute, StreamChatChunk, StreamChatRequest, };