// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../../core/resource'; import * as MessageAPI from '../../message/message'; import * as TasksAPI from './tasks'; import { TaskDeleteParams, TaskDeleteResponse, TaskListParams, TaskListResponse, TaskStatus, Tasks, } from './tasks'; import { APIPromise } from '../../../core/api-promise'; import { type Uploadable } from '../../../core/uploads'; import { buildHeaders } from '../../../internal/headers'; import { RequestOptions } from '../../../internal/request-options'; import { multipartFormRequestOptions } from '../../../internal/uploads'; import { path } from '../../../internal/utils/path'; export class Message extends APIResource { tasks: TasksAPI.Tasks = new TasksAPI.Tasks(this._client); /** * Create an async message processing task */ create(params: MessageCreateParams, options?: RequestOptions): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat, ...body } = params; return this._client.post( '/v3/messages', multipartFormRequestOptions( { body, ...options, headers: buildHeaders([ { ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }, this._client, ), ); } /** * Stream async message task events via Server-Sent Events (SSE) */ stream( taskID: string, params: MessageStreamResourceParams | null | undefined = {}, options?: RequestOptions, ): APIPromise { const { 'Accept-Language': acceptLanguage, 'X-Error-Format': xErrorFormat, ...query } = params ?? {}; return this._client.get(path`/v3/messages/tasks/${taskID}/stream`, { query, ...options, headers: buildHeaders([ { Accept: '*/*', ...(acceptLanguage != null ? { 'Accept-Language': acceptLanguage } : undefined), ...(xErrorFormat != null ? { 'X-Error-Format': xErrorFormat } : undefined), }, options?.headers, ]), }); } } /** * Response model for task creation. */ export interface MessageCreateResponse { created_at: string; task_id: string; /** * Task status enumeration. */ status?: TasksAPI.TaskStatus; } export interface MessageCreateParams { /** * Body param */ chatbot_id: string; /** * Body param */ agent_ids?: string; /** * Body param */ anonymize_em?: boolean | null; /** * Body param */ anonymize_lm?: boolean | null; /** * Body param */ assistant_message_id?: string | null; /** * Body param */ chat_history?: string | null; /** * Body param */ connectors?: string; /** * Body param */ conversation_id?: string | null; /** * Body param */ digital_employee_id?: string | null; /** * Body param */ exclude_events?: Array; /** * Body param */ exclude_prefix?: boolean; /** * Body param */ files?: Array; /** * Body param */ filters?: string | null; /** * Body param */ include_pipeline_trace?: boolean; /** * Body param */ include_states?: boolean; /** * Body param */ is_edited?: boolean; /** * Body param */ is_regenerated?: boolean; /** * Body param */ is_retried?: boolean; /** * Body param */ message?: string | null; /** * Body param */ metadata?: string | null; /** * Body param */ model_name?: string | null; /** * Body param */ parent_id?: string | null; /** * Body param */ quote?: string | null; /** * Body param */ regenerated_message_id?: string | null; /** * Body param: The type of search to perform. * * Attributes: NORMAL: Get answer from chatbot knowledge. SEARCH: Get answer from * various connectors. SQL_SEARCH: Get answer from SQL-based database. * AGENT_CONNECTOR: Execute a scoped glaip coordinator with per-request connector * selection. No request_connector or connector_management tooling — missing * connectors yield a plain-text response from the coordinator. WEB: Get more * relevant information from the web. (DEPRECATED) Web Search uses real-time data. * Agent selection isn't available in this mode. DEEP_RESEARCH: Get answer from * Deep Research Agent. ESSENTIALS_DEEP_RESEARCH: Get answer from Deep Research * with Essentials mode. Provides key points and core insights without noise, * optimized for speed and clarity. Ideal for quick decision-making support and * fast orientation. COMPREHENSIVE_DEEP_RESEARCH: Get answer from Deep Research * with Comprehensive mode. Delivers the full picture with depth and thoroughness, * covering all relevant angles, details, and supporting data. Suitable for * professional research tasks where precision matters more than speed. * PRIVATE_DEEP_RESEARCH: Get answer from Deep Research with private deep research * providers. INTERNAL_DEEP_RESEARCH: Retrieves answers using Deep Research with * internal data sources. (DEPRECATED) Accesses internal repositories such as * Google Drive and utilizes the same processing engine as Essentials Deep Research * mode. */ search_type?: MessageAPI.SearchType | null; /** * Body param */ skill_ids?: string; /** * Body param */ smart_mode?: boolean; /** * Body param */ source?: string | null; /** * Body param */ stream?: boolean; /** * Body param */ stream_id?: string | null; /** * Body param */ stream_message_only?: boolean; /** * Body param */ temporary_file_ids?: string | null; /** * Body param */ use_cache?: boolean | null; /** * Body param */ user_id?: string | null; /** * Body param */ user_message_id?: string | null; /** * Header param */ 'Accept-Language'?: string; /** * Header param: Set to `structured` to receive errors in the structured envelope. * Omit it to keep the legacy error body. */ 'X-Error-Format'?: string; } export interface MessageStreamResourceParams { /** * Query param: User ID to use when current_user.id is None */ user_id?: string | null; /** * Header param */ 'Accept-Language'?: string; /** * Header param: Set to `structured` to receive errors in the structured envelope. * Omit it to keep the legacy error body. */ 'X-Error-Format'?: string; } Message.Tasks = Tasks; export declare namespace Message { export { type MessageCreateResponse as MessageCreateResponse, type MessageCreateParams as MessageCreateParams, type MessageStreamResourceParams as MessageStreamResourceParams, }; export { Tasks as Tasks, type TaskStatus as TaskStatus, type TaskListResponse as TaskListResponse, type TaskDeleteResponse as TaskDeleteResponse, type TaskListParams as TaskListParams, type TaskDeleteParams as TaskDeleteParams, }; }