import { ElicitationResponse } from './elicitation'; import { Dto } from './client'; import { paths } from './schema'; import { DictationMint } from '../dictation/dictation-session'; import { WidgetConfig } from '../types/widget-config'; import { AgentTurnMessagesDto, ResolveSessionDto, SendMessageDto, VoteInputDto } from '../types/dtos'; type ConnectionStartResult = NonNullable['responses'][201]['content']['application/json']; type ConnectionAttemptStatus = NonNullable['responses'][200]['content']['application/json']['status']; export declare class ConnectionRequestExpiredError extends Error { constructor(); } export declare class ConnectionAttemptUnavailableError extends Error { constructor(); } export declare class ApiCaller { private client; private config; private userToken; constructor({ config }: { config: WidgetConfig; }); private constructClientOptions; private createOpenAPIClient; listApprovalPreferences: () => Promise<{ key: string; serverId: string; serverName: string; message: string; toolName: string; }[]>; revokeApprovalPreference: (serverId: string, key: string) => Promise; listElicitations: (sessionId: string, signal?: AbortSignal) => Promise<{ id: string; serverId: string; serverName: string; expiresAt: number; form: { message: string; requestedSchema: { properties: Record; required?: string[] | undefined; }; }; approvalKey?: string | undefined; }[]>; answerElicitation: (sessionId: string, requestId: string, answer: ElicitationResponse) => Promise; listConnections: (signal?: AbortSignal) => Promise<{ server_id: string; name: string; status: "not_connected" | "connected" | "reconnect_required"; }[]>; startConnection: (serverId: string, requestId: string, signal?: AbortSignal) => Promise; getConnectionAttempt: (serverId: string, attemptId: string, signal?: AbortSignal) => Promise; disconnectConnection: (serverId: string) => Promise; setAuthToken: (token: string) => void; /** * AUTH headers only (X-Bot-Token / Authorization), stripped of * content-type/accept. The transport sets its own Content-Type, and a second * (case-differing) copy gets COMBINED by the Headers init into * "application/json, application/json" — which the server rejects (415). Also * reused for the reconnect/stop control calls (empty-body POST/GET). */ private getStreamAuthContext; /** * Wiring for the agent-chat streaming adapter: the send endpoint, the * session-scoped reconnect endpoint, and the shared auth headers. * Computed lazily so a later `setAuthToken` is always reflected. */ getStreamTransportOptions: () => { api: string; reconnectApi: (sessionId: string) => string; headers: Record; }; /** * Stop / interrupt the session's in-flight streamed turn. With resumable * streams on, a client abort is treated as a disconnect (the stream * survives), so a real "stop" is this explicit call — the backend cancels * generation and clears the resume pointer. Throws on failure — the caller * decides how to react, so a failed cancel is never mistaken for an ACKed * one. */ stopStream: (sessionId: string) => Promise; /** * What actually happened on the page, back to the turn that is waiting for * it. The widget does the thing, looks at the result, and says so; until * this call lands the agent only knows that it asked. * * Never throws and never blocks anything the visitor is doing: a lost * answer costs the tool call its timeout, which the server already handles, * and a browser stuck on this would be a browser that cannot get on with * the page. */ sendPageReply: (sessionId: string, reply: { callId: string; outcome: "done" | "covered" | "gone" | "hidden" | "unsupported" | "no_change" | "declined"; detail?: string; controls?: { ref: string; role: string; name: string; disabled?: boolean; }[]; truncated?: boolean; }) => Promise; /** * The session's settled agent turns with their final UIMessage parts and * the transcript rows each produced — the reload-fidelity read (widget v5). * Returns null on any failure: the caller then keeps the plain-row * rendering, exactly the pre-feature behavior. */ getAgentTurnMessages: (sessionId: string, presentation?: WidgetConfig["presentation"]) => Promise; /** * Mint a short-lived transcription token for voice dictation (widget v5). * Org-gated server-side; throws on any failure so the caller can surface * "dictation unavailable" instead of hanging with an open mic. */ createDictationSession: ({ language, }: { language?: string | undefined; }) => Promise; getExternalWidgetConfig: () => Promise>; sendMessage: (body: SendMessageDto, abortSignal?: AbortSignal) => Promise>; createUnverifiedContact: (body: Dto["CreateUnverifiedContactDto"]) => Promise>; createSession: (body: Dto["CreateWidgetSessionDto"], abortSignal?: AbortSignal) => Promise>; pollSessionAndHistory: ({ sessionId, abortSignal, }: { sessionId: string; abortSignal: AbortSignal; }) => Promise>; /** The visitor is looking at this session right now. */ markSessionRead: ({ sessionId, abortSignal, }: { sessionId: string; abortSignal?: AbortSignal; }) => Promise>; getSessions: ({ cursor, filters, abortSignal, }: { /** Opaque pagination token: the `next` value from the previous page (the backend paginates by `offset`). */ cursor: string | undefined; filters: Record; abortSignal?: AbortSignal; }) => Promise>; /** * openapi-fetch usually works fine for file uploads, but this time around it parses the payload in a weird way and results in 413 errors (payload too large) * Anyway, good old XHR even does it better with progress events */ uploadFile: ({ file, abortSignal, onProgress, }: { file: File; abortSignal: AbortSignal; onProgress?: (percentage: number) => void; }) => Promise; vote: (body: VoteInputDto) => Promise>; resolveSession: (body: ResolveSessionDto, abortSignal?: AbortSignal) => Promise>; createStateCheckpoint: (body: Dto["WidgetCreateStateCheckpointInputDto"]) => Promise>; submitCsat: (body: Dto["WidgetSubmitCsatInputDto"]) => Promise>; } export {}; //# sourceMappingURL=api-caller.d.ts.map