import type { FileUpload, IAction } from '@/widget/types'; export type IncomingInput = { question?: string; form?: Record; uploads?: FileUpload[]; overrideConfig?: Record; socketIOClientId?: string; chatId?: string; fileName?: string; leadEmail?: string; action?: IAction; humanInput?: Record; /** * Conversation context to build this turn on, used when regenerating an answer. * * Core's prediction body already carries this — its own regenerate and edit both * re-send with a truncated history — and the deployment runtime endpoint the * widget posts to shares the orchestrator and the passthrough body validator * with Core's, so the engine consumes it identically (`prependMessages` in * `buildChatflow`). * * The shape follows the engine's declared `IMessage`: `{ message, type }` with * type `'userMessage' | 'apiMessage'`. Note Core's own `buildPredictionHistory` * emits `'user' | 'assistant'` instead, which does not match that interface — * this sends what the engine declares. */ history?: { message: string; type: 'userMessage' | 'apiMessage'; }[]; /** * Wire format for the prediction stream. `'agui'` asks Core for AG-UI frames, which is what * carries Dynamic UI components live; Core falls back to the legacy `{event,data}` wire when * Dynamic UI is disabled server-side. */ streamProtocol?: 'legacy' | 'agui'; }; type BaseRequest = { apiHost?: string; onRequest?: (request: RequestInit) => Promise; }; export type MessageRequest = BaseRequest & { deploymentId?: string; body?: IncomingInput; }; export type FeedbackRatingType = 'THUMBS_UP' | 'THUMBS_DOWN'; export type FeedbackInput = { chatId: string; messageId: string; rating: FeedbackRatingType; content?: string; }; export type CreateFeedbackRequest = BaseRequest & { deploymentId?: string; body?: FeedbackInput; }; export type UpdateFeedbackRequest = BaseRequest & { id: string; deploymentId?: string; body?: Partial; }; export type UpsertRequest = BaseRequest & { deploymentId: string; apiHost?: string; formData: FormData; }; export type LeadCaptureInput = { deploymentId: string; chatId: string; name?: string; email?: string; phone?: string; }; export type LeadCaptureRequest = BaseRequest & { body: Partial; }; export type GenerateTTSRequest = BaseRequest & { body: { chatId: string; chatflowId: string; chatMessageId: string; text: string; }; signal?: AbortSignal; }; export type AbortPredictionRequest = BaseRequest & { deploymentId?: string; /** The conversation whose run should be cancelled. */ chatId: string; }; export type AbortTTSRequest = BaseRequest & { body: { chatflowId: string; chatId: string; chatMessageId: string; }; }; /** * Every call below delegates to `client.employees.*` — the same typed client an * npm consumer gets, built once per `(apiHost, deploymentId)` by * `getWidgetClient`. The widget therefore inherits auth, retries, error * normalization, visitor identity and envelope unwrapping instead of * re-deriving each of them. * * The previous implementation went through a second transport, `sendRequest`, * which had its own header logic, its own envelope handling (none) and its own * error shape — one product with two HTTP stacks that agreed only by accident. * That function is gone. * * These wrappers keep their old names and result shape (`{ data?, error?, * status? }`) so no component changed. They are an adapter over the client, not * a second implementation of it. */ type QueryResult = { data?: T; error?: Error; status?: number; }; export declare const sendFeedbackQuery: ({ deploymentId, apiHost, body, onRequest }: CreateFeedbackRequest) => Promise>; export declare const updateFeedbackQuery: ({ id, deploymentId, apiHost, body, onRequest }: UpdateFeedbackRequest) => Promise>; export declare const createAttachmentWithFormData: ({ deploymentId, apiHost, formData, onRequest }: UpsertRequest) => Promise>; export declare const upsertVectorStoreWithFormData: () => Promise<{ data: undefined; error: Error; }>; export declare const getChatbotConfig: ({ deploymentId, apiHost, onRequest }: MessageRequest) => Promise>; /** Same route as `getChatbotConfig` — the config carries `isStreaming`. */ export declare const isStreamAvailableQuery: ({ deploymentId, apiHost, onRequest }: MessageRequest) => Promise>; /** * Download a conversation file as a Blob. * * Goes through the client so the visitor identity header is presented — a bare * URL in `` cannot carry one, which is why a private deployment rejects * it. */ export declare const sendFileDownloadQuery: ({ deploymentId, apiHost, body, onRequest }: MessageRequest) => Promise>; export declare const addLeadQuery: ({ apiHost, body, onRequest }: LeadCaptureRequest) => Promise>; /** * Cancel an in-flight prediction server-side. * * Until this existed, pressing stop only changed local state: the run continued * to completion and kept billing for output nobody would read. */ export declare const abortPredictionQuery: ({ deploymentId, apiHost, chatId, onRequest }: AbortPredictionRequest) => Promise>; /** * Synthesize speech for a message. * * `body.chatflowId` is the deployment id — the field name is a legacy holdover * kept so existing callers are unchanged. */ export declare const generateTTSQuery: ({ apiHost, body, onRequest }: GenerateTTSRequest) => Promise>; /** * @deprecated Unused since 0.7.0 and retained only so an existing caller keeps * compiling. * * Stopping speech is entirely a client concern: CORE synthesizes in one buffered * upstream call, so by the time a listener presses stop the provider has already * been billed and there is nothing left to cancel. CORE keeps * `DELETE :deploymentId/tts` only so shipped SDK versions that call it still get * a 200 — it acknowledges and does nothing. Resolves without a request. */ export declare const abortTTSQuery: (_request: AbortTTSRequest) => Promise>; export {};