/** * @octomil/browser — Chat namespace client * * Provides `client.chat.create()` and `client.chat.stream()` as the * namespaced API surface required by the SDK facade contract. * * Delegates to the ResponsesClient under the hood, converting between * ChatMessage[]/ChatOptions and the ResponseRequest format. */ import { ResponsesClient } from "./responses.js"; import { ServerApiClient, type QueryValue } from "./server-api.js"; import type { ChatChunk, ChatMessage, ChatOptions, ChatResponse } from "./types.js"; export interface ChatClientOptions { model: string; serverUrl?: string; apiKey?: string; /** Whether the shared ResponsesClient can handle this model locally. */ canRunLocally?: () => boolean; /** Lazily resolved ResponsesClient — shared with OctomilClient. */ getResponses: () => ResponsesClient; /** Guard: throws if the client is closed or not loaded. */ ensureReady: () => void; } export interface ChatThread { id: string; title?: string; model: string; createdAt: string; updatedAt: string; metadata?: Record; } export interface ChatTurnRequest { input: string; inputParts?: unknown[] | null; config?: { maxTokens?: number; temperature?: number; topP?: number; stop?: string[]; }; } export type ChatThreadMessage = Record; declare class ChatApiClient extends ServerApiClient { constructor(serverUrl?: string, apiKey?: string); requestJson(path: string, init?: RequestInit, query?: Record): Promise; } export declare class ChatThreadsClient { private readonly api; constructor(api: ChatApiClient); create(request: { model: string; title?: string; metadata?: Record; }): Promise; get(threadId: string): Promise; list(query?: { limit?: number; order?: "asc" | "desc"; }): Promise; } export declare class ChatTurnClient { private readonly createTurnInternal; private readonly streamTurnInternal; constructor(createTurnInternal: (threadId: string, request: ChatTurnRequest) => Promise, streamTurnInternal: (threadId: string, request: ChatTurnRequest) => AsyncGenerator); create(threadId: string, request: ChatTurnRequest): Promise; stream(threadId: string, request: ChatTurnRequest): AsyncGenerator; } /** * Namespaced chat API: * * ```ts * const response = await client.chat.create(messages, options); * for await (const chunk of client.chat.stream(messages, options)) { ... } * ``` */ export declare class ChatClient { private readonly model; private readonly serverUrl; private readonly apiKey; private readonly canRunLocally; private readonly getResponses; private readonly ensureReadyFn; private readonly api; readonly threads: ChatThreadsClient; readonly turn: ChatTurnClient; constructor(options: ChatClientOptions); /** * Non-streaming chat completion. * * Equivalent to the deprecated `client.chat()` direct method. */ create(messages: ChatMessage[], options?: ChatOptions): Promise; /** * Streaming chat completion — yields chunks as they arrive. * * Equivalent to the deprecated `client.chatStream()` direct method. */ stream(messages: ChatMessage[], options?: ChatOptions): AsyncGenerator; private requireServerUrl; private createTurn; private streamTurn; } /** * Convert ChatMessage[] to ResponseRequest fields. * Extracts system messages as `instructions`, remaining as `input`. */ export declare function messagesToResponseInput(messages: ChatMessage[]): { instructions?: string; input: string; }; export {}; //# sourceMappingURL=chat.d.ts.map