/** * @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/aicontextlibrary * @publicApi */ import { type AIConnector, type AIContextData } from "../aiconnector.js"; import { type AIContextRef } from "./aicontextref.js"; import { type AIContext } from "./aicontext.js"; import { type AIDefaultContext, type AIDefaultContextFeature } from "./aidefaultcontext.js"; /** * Stores the list of contexts available to the current token, acquired from the AI connector. * * A single instance is shared across all AI features (see {@link module:ai/aicore/aicore~AICore#contextLibrary}), * so the context list is fetched once and reused instead of each feature requesting it separately. */ export declare class AIContextLibrary { /** * @inheritDoc */ constructor({ connector, defaultContext }: { connector: AIConnector; defaultContext?: AIDefaultContext; }); /** * Returns the list of all contexts available to the current token. */ getAllContexts(): Promise>; /** * Returns the list of contexts that features may offer as user-selectable, which corresponds to * {@link #getAllContexts all contexts} narrowed down by the global `ai.defaultContext` configuration. * * Any context referenced by `ai.defaultContext` is treated as config-managed and is **not** offered as a * manually-selectable item. The exclusion is by context ID regardless of the reference granularity or which * features the entry targets: an entry configured only for another feature (for example `features: { review: true }`) * is still excluded from every picker, even where it is not attached automatically. This is deliberate - default * contexts are owned by the configuration, not offered as picker items anywhere. Integrators who want a context * available in a feature's picker simply leave it out of `ai.defaultContext`. */ getAvailableContexts(): Promise>; /** * Adds the context resolved for a feature invocation to the given context and returns it. * * It resolves the entries of the global `ai.defaultContext` configuration that apply to the given `feature` (narrowed * by `ids` where a feature uses a `RegExp` filter), appends any `extraContexts` the caller supplies (for example a * quick action's or review check's own `context`, or the contexts injected into a chat conversation), and adds the * result to `context`. * * The caller passes its own context model, so a feature can resolve straight into it - for example * {@link module:ai/aichat/model/aichatcontext~AIChatContext} for chat, or a fresh * {@link module:ai/aicore/model/aicontext~AIContext} for review, translate and quick actions. * * @param options Options of the resolution. * @param options.feature The feature the context is resolved for. * @param options.ids The IDs matched against a feature's `RegExp` filter. * @param options.extraContexts References to append after the resolved default context, in order. * @param options.idScopedOnly When set, resolves only the entries that the given `IDs` make applicable. * Used to add the id-specific increment to a context that already carries the * always-applicable default context. * @param options.context The context to add the resolved references to. Returned as-is for chaining. */ resolveContext({ feature, ids, extraContexts, idScopedOnly, context }: { feature: AIDefaultContextFeature; ids?: Array; extraContexts?: Array; idScopedOnly?: boolean; context: T; }): T; }