UNPKG

@ckeditor/ckeditor5-ai

Version:

AI features for CKEditor 5.

93 lines (92 loc) 2.91 kB
/** * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options */ /** * @module ai/aicore/model/aicontext * @publicApi */ import type { Editor } from '@ckeditor/ckeditor5-core'; /** * Locates a `data-id` from AI chat document HTML in a specific editor model root (multi-editor / multi-root contexts). */ export type AIDataIdDocumentSource = { editor: Editor; rootName: string; }; /** * One concatenation segment of the AI chat document HTML (single editor model root). The post-AI portion of the merged document that * belongs to this slice is recovered by routing each top-level child via `AIReply#dataIdDocumentSources`, not by index. */ export type AIDocumentContextSlice = { editor: Editor; rootName: string; html: string; version: number; }; /** * The type of context item. * * Available types: * * `'mcp-tool-context'`: a tool-related context item, * * `'file'`: a file (PDF, Word document, etc.), * * `'document'`: a current editor document * (used by {@link module:ai/aichat/model/aichatcontext~AIChatContextConfig#document `config.ai.chat.context.document` option}), * * `'web-resource'`: a URL (web page, blog post, etc.), * * `'text'`: a text (plain text, Markdown, HTML, etc.), * * `'selection'`: a selection of text in the editor * (used by {@link module:ai/aiquickactions/aiquickactions~AIQuickActions AI Quick Actions} that pass the user selection * to the {@link module:ai/aichat/aichat~AIChat AI Chat}). */ export type AIContextItemType = 'mcp-tool-context' | 'file' | 'document' | 'web-resource' | 'text' | 'selection'; /** * The type of text resource. */ export type AIContextTextResourceType = 'text' | 'markdown' | 'html'; /** * A context item. */ export type AIContextItem = AIContextItemRequestData & { label: string; uiId: string; resourceId?: string; isReadOnly?: boolean; version?: number; hidden?: boolean; sessionId?: string | null; selection?: Array<{ start: number; end: number; }>; }; /** * A tool-related context item. */ export type AIToolContextItem = AIContextItem & { type: 'mcp-tool-context'; mcpServerName: string; toolName?: string; data: Record<string, any>; /** * ID length can be between 1 and 21 characters. If not provided, it will be randomly generated 21 characters long string. */ id?: string; }; /** * A context item request data for using in the `AIConnector`. */ export type AIContextItemRequestData = { type: AIContextItemType; content?: string; id?: string; selection?: Array<{ start: number; end: number; }>; }; export type AIToolRequestData = { type: 'mcp-tool-context'; mcpServerName: string; toolName?: string; data: Record<string, any>; };