/** * Type surface for the employees.* namespace. * * One namespace covers both chatflows and agentflows — TORUK-CORE serves * them through the same endpoint (`POST /api/v1/prediction/:id`), so the * SDK does not distinguish at the call site. See ENGINEERING-PROPOSAL.md * §10 for the authoritative SDK↔TORUK-CORE wire mapping. */ /** Engine-passthrough message history entry. */ export type ChatHistoryItem = { role: 'user' | 'apiMessage' | 'userMessage' | string; content: string; [key: string]: unknown; }; /** JSON upload metadata (distinct from multipart file uploads). */ export type EmployeeUpload = { name?: string; mime?: string; type?: string; data?: string; [key: string]: unknown; }; /** humanInput / agentflow action continuation payload. */ export type EmployeeAction = Record; /** Input for non-streaming execution (employees.execute). */ export type EmployeeExecuteInput = { deploymentId?: string; /** User message. Mapped to TORUK-CORE wire field `question`. */ message: string; chatId?: string; /** Engine-side passthrough (sessionId fallback, variable overrides, etc.). */ overrideConfig?: Record; history?: ChatHistoryItem[]; uploads?: EmployeeUpload[]; leadEmail?: string; action?: EmployeeAction; /** * Structured form submission for a flow whose start node is a `formInput`. * Sent verbatim as the wire field `form`, alongside `question`. */ form?: Record; /** * Answer to a paused human-input step, resuming an agentflow run. Sent * verbatim as the wire field `humanInput`. */ humanInput?: Record; /** Per-call AbortSignal. */ signal?: AbortSignal; /** Per-call custom headers (merged with client-config headers). */ headers?: Record; }; /** Input for streaming execution (employees.stream). Same as execute + callbacks. */ export type EmployeeStreamInput = EmployeeExecuteInput & import('../streaming/sse-events').StreamCallbacks & { /** Reserved — streams always set `streaming: true` on the wire. */ stream?: boolean; /** * Ask Core for a specific streaming protocol. `'agui'` selects the AG-UI wire, which is * what carries Dynamic UI components; omit it for the legacy wire. Core downgrades on its * own when Dynamic UI is disabled server-side, so setting it is safe against any Core * version — unrecognised frames arrive on `onEvent` as `aguiFrame`. */ streamProtocol?: string; }; /** * Non-streaming execution result (TORUK-CORE returns a bare object; * the SDK wraps in TorukSuccessResponse — see §10.4 mapping). * * Catch-all index allows engine-specific fields (agentReasoning, * agentFlowExecutedData, etc.) to pass through without losing type * safety on the known fields. */ export type EmployeeExecuteResult = { chatId: string; text?: string; /** Renamed from TORUK-CORE wire field `chatMessageId` per §10.4. */ messageId?: string; sourceDocuments?: unknown[]; usedTools?: unknown[]; agentReasoning?: unknown; [key: string]: unknown; }; /** Public chatbot config (passthrough; shape depends on the employee). */ export type EmployeeConfig = Record; /** GET /api/v1/chatflows-streaming/:id response. */ export type StreamAvailability = { isStreaming: boolean; }; /** * Feedback creation input. * * `rating` carries Core's `ChatMessageRatingType` enum values verbatim. * The SDK previously declared them camelCase, which Core's validation * rejects — so a rating sent through this client could never persist. The * widget's own copy was already correct. */ export type EmployeeFeedbackInput = { deploymentId?: string; chatId: string; messageId: string; rating: 'THUMBS_UP' | 'THUMBS_DOWN'; content?: string; headers?: Record; signal?: AbortSignal; }; /** Adding free-text content (or changing the rating) on existing feedback. */ export type EmployeeUpdateFeedbackInput = { deploymentId?: string; /** Returned by `employees.feedback()`. */ feedbackId: string; content?: string; rating?: 'THUMBS_UP' | 'THUMBS_DOWN'; headers?: Record; signal?: AbortSignal; }; /** Lead-capture submission. */ export type EmployeeCreateLeadInput = { deploymentId?: string; chatId: string; name?: string; email?: string; phone?: string; headers?: Record; signal?: AbortSignal; }; /** Downloading a file stored during a conversation. */ export type EmployeeDownloadUploadInput = { deploymentId?: string; chatId: string; fileName: string; headers?: Record; signal?: AbortSignal; }; /** Speech synthesis request. */ export type EmployeeSpeechInput = { deploymentId?: string; /** Rejected with 400 above `capabilities.textToSpeech.maxInputChars`. */ text: string; /** Conversation key, for provider usage metering. Not an authorization credential. */ chatId?: string; headers?: Record; signal?: AbortSignal; }; /** Transcribing a recorded voice clip to text. */ export type EmployeeTranscribeInput = { deploymentId?: string; /** Base64 audio **data URI** — must start `data:audio/`. */ audio: string; /** Overrides the MIME parsed from the data URI header. */ mime?: string; /** Conversation key, for provider usage metering. Not an authorization credential. */ chatId?: string; headers?: Record; signal?: AbortSignal; }; /** Cancelling an in-flight prediction. */ export type EmployeeAbortInput = { deploymentId?: string; chatId: string; headers?: Record; signal?: AbortSignal; }; /** Attachment upload input. */ export type EmployeeAttachInput = { deploymentId?: string; chatId: string; files: File[]; headers?: Record; signal?: AbortSignal; }; /** Vector upsert input. */ export type EmployeeVectorUpsertInput = { deploymentId?: string; files: File[]; /** Additional form fields passed through to the upsert endpoint. */ fields?: Record; headers?: Record; signal?: AbortSignal; };