/** * @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/aidocumentprocessing/aidocumentprocessinggateway * @publicApi */ import { ContextPlugin, type PluginDependenciesOf } from "@ckeditor/ckeditor5-core"; import type { AIEditorRoot } from "../aicore/model/aieditorroot.js"; import { AIConnector } from "../aicore/aiconnector.js"; import { AICore } from "../aicore/aicore.js"; import { type AIModels } from "../aicore/model/aimodels.js"; import { AIEditing } from "../aicore/aiediting.js"; import { AIGateway, type AIRunBaseOptions, type AIGatewayApplyOptions } from "../aicore/aigateway.js"; import { type AICapabilitiesConfigAdvanced } from "../aicore/model/aicapabilities.js"; import { AIDocumentProcessingRunResult } from "./model/aidocumentprocessingrunresult.js"; import { AIRunResult } from "../aicore/model/airunresult.js"; export type AIDocumentProcessingRunOptions = AIRunBaseOptions & { /** * The model that will be used to run the document processing request. * The IDs of an AI models can be acquired * via {@link module:ai/aicore/model/aimodels~AIModels#getAvailableModels} call. */ model: string; /** * The roots to process. When omitted, every non-`$graveyard` root across every editor in the current * {@link module:core/context~Context `Context`} is processed. When provided, only the listed roots are * processed; the order of entries in `roots` is treated as a set-membership filter and does not affect * the payload order. * * Each entry's `channelId` must match the `collaboration.channelId` config of the target editor instance. * `rootName` must match an existing, non-`$graveyard` root within that editor. */ roots?: Array; /** * Per-call AI capability directives. `webSearch` toggles web search; `reasoning` toggles reasoning and * optionally selects a level * (see {@link module:ai/aicore/model/aicapabilities~AIReasoningLevel AIReasoningLevel}). * Omitting the option or leaving all flags falsy disables both capabilities for this call. */ capabilities?: AICapabilitiesConfigAdvanced; }; /** * Headless, stateless API for performing AI-powered transformations on entire documents through the `/documents/process` endpoint. * Similar to sending a single message through the {@link module:ai/aichat/aichat~AIChat AI Chat plugin}. * * This API provides a simple document-processing workflow: a single `prompt` is applied to one or more documents, * producing transformed documents with all AI-generated changes already applied. * * By default, every non-`$graveyard` root across every editor in the context is processed. To restrict a run to a * subset of roots, pass the `roots` option to * {@link module:ai/aidocumentprocessing/aidocumentprocessinggateway~AIDocumentProcessingGateway#processDocument}. */ export declare class AIDocumentProcessingGateway extends ContextPlugin { /** * @inheritDoc */ static get pluginName(): "AIDocumentProcessingGateway"; /** * @inheritDoc */ static get requires(): PluginDependenciesOf<[AIConnector, AIEditing, AIGateway, AICore]>; /** * The shared model registry. Exposed here so headless gateways are self-sufficient — integrators can * discover and resolve models (`getAvailableModels()`, `getModel()`, `resolveModel()`, …) without * reaching for the `AICore` plugin directly. * * @experimental **Experimental:** This is a production-ready API but may change in minor releases * without the standard deprecation policy. Check the changelog for migration guidance. */ get models(): AIModels; /** * @inheritDoc */ static override get isOfficialPlugin(): true; /** * @inheritDoc */ static override get isPremiumPlugin(): true; /** * Runs the document processing request and returns an * {@link module:ai/aicore/model/airunresult~AIRunResult AIRunResult} — a container with one * {@link module:ai/aidocumentprocessing/model/aidocumentprocessingrunresult~AIDocumentProcessingRunResult * AIDocumentProcessingRunResult} per root and whole-run `status` / `error`. * * The result can then be applied to the editor via {@link #applyResult}. Transport, parsing, and merge failures * are surfaced via `status: 'error'` plus the `error` field, not thrown. Aborts (via `options.signal`) are reported * as `status: 'aborted'`. * * @experimental **Experimental:** This is a production-ready API but may change in minor releases * without the standard deprecation policy. Check the changelog for migration guidance. * @param prompt The prompt to run against the document. * @param options Run options: required `model`, optional `roots` to restrict the run to a subset of roots, optional `signal` * to abort the run, and optional `capabilities` asking the AI service to use web search or reasoning for this call. */ processDocument(prompt: string, options: AIDocumentProcessingRunOptions): Promise>; /** * Applies the document processing result (produced by {@link #processDocument}) to the editor content, either as direct * changes or as track changes suggestions. * * This is a proxy to {@link module:ai/aicore/aigateway~AIGateway#apply}. * * @experimental **Experimental:** This is a production-ready API but may change in minor releases * without the standard deprecation policy. Check the changelog for migration guidance. * @param result The result of a completed run. * @param applyOptions Options for applying the changes to the editor content. */ applyResult(result: AIRunResult, applyOptions: AIGatewayApplyOptions): void; }