/*! * Jodit Editor PRO (https://xdsoft.net/jodit/) * See LICENSE.md in the project root for license information. * Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net/jodit/pro/ */ import type { IDictionary } from "jodit/esm/types/index"; import type { IConversationOptions } from "./conversations"; import type { AIStreamEvent, IAIMessage, IAIResponse } from "./messages"; import type { IToolDefinition } from "./tools"; import type { AIAssistantAPIMode } from "./types"; /** * Selection context to include in AI request */ export interface ISelectionContext { /** HTML content of the selection */ readonly html: string; /** Optional block index if selection is within a specific block */ readonly blockIndex?: number; /** Serialized range information for restoration */ readonly rangeInfo?: { readonly startContainer: string; readonly startOffset: number; readonly endContainer: string; readonly endOffset: number; }; } /** * Request context sent to AI API */ export interface IAIRequestContext { /** API mode being used */ readonly mode: AIAssistantAPIMode; /** Conversation identifier */ readonly conversationId: string; /** Full conversation history (for 'full' mode) or messages since last successful response (for 'incremental' mode) */ readonly messages?: Readonly; /** Parent message ID - ID of last successful assistant response (for 'incremental' mode) */ readonly parentMessageId?: string; /** Available tools the AI can use */ readonly tools: Readonly; /** Current selection contexts */ readonly selectionContexts?: Readonly; /** Conversation-specific settings (model, temperature) */ readonly conversationOptions?: IConversationOptions; /** Instructions for AI assistant (not saved in conversation) */ readonly instructions?: string; /** Additional metadata */ readonly metadata?: IDictionary; } export type IAIAssistantResult = { /** Final response from AI API */ readonly mode: 'final'; readonly response: IAIResponse; } | { /** Streaming response from AI API */ readonly mode: 'stream'; readonly stream: AsyncGenerator; }; /** * Callback function for AI API integration */ export interface IAIAssistantrRequseter { /** * Send request to AI API * @param request - Request context with conversation and tools * @param signal - AbortSignal for request cancellation * @returns Promise resolving to AI response */ (request: IAIRequestContext, signal: AbortSignal): Promise; }