@ckeditor/ckeditor5-ai 48.4.0 → 48.5.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/dist/aiactions/aiactions.d.ts +2 -2
  2. package/dist/aiactions/model/aiactionsinteraction.d.ts +3 -4
  3. package/dist/aichat/aichatcontroller.d.ts +11 -2
  4. package/dist/aichat/model/aichatcontext.d.ts +18 -8
  5. package/dist/aichat/model/aichatconversation.d.ts +4 -0
  6. package/dist/aicore/aiconnector.d.ts +6 -6
  7. package/dist/aicore/aierrorreporter.d.ts +29 -1
  8. package/dist/aicore/aigateway.d.ts +2 -2
  9. package/dist/aicore/model/aicontextref.d.ts +2 -1
  10. package/dist/aicore/utils/geteditorconfig.d.ts +2 -0
  11. package/dist/aicore/utils/getoperationsfordocumentsuggestions.d.ts +4 -4
  12. package/dist/aicore/utils/markoperationsasai.d.ts +2 -4
  13. package/dist/aireviewcore/aireviewcoreediting.d.ts +2 -2
  14. package/dist/aireviewcore/model/aireviewcheckrun.d.ts +2 -2
  15. package/dist/aireviewmode/model/aireviewcustomcheckrun.d.ts +2 -2
  16. package/dist/aisdk/dataidassigner.d.ts +20 -0
  17. package/dist/aisdk/documentchanges.d.ts +165 -0
  18. package/dist/aisdk/documentchangesutils.d.ts +15 -0
  19. package/dist/aisdk/documentcompare.d.ts +171 -0
  20. package/dist/aisdk/documentcompareutils.d.ts +16 -0
  21. package/dist/aisdk/documentsnapshot.d.ts +48 -0
  22. package/dist/aisdk/extractselectionfromhtml.d.ts +27 -0
  23. package/dist/aisdk/validateoperations.d.ts +43 -0
  24. package/dist/aitranslate/model/aitranslatecheckrun.d.ts +2 -2
  25. package/dist/index.d.ts +3 -0
  26. package/dist/index.js +19 -19
  27. package/dist/translations/af.js +1 -1
  28. package/dist/translations/af.umd.js +1 -1
  29. package/dist/translations/ar.js +1 -1
  30. package/dist/translations/ar.umd.js +1 -1
  31. package/dist/translations/ast.js +1 -1
  32. package/dist/translations/ast.umd.js +1 -1
  33. package/dist/translations/az.js +1 -1
  34. package/dist/translations/az.umd.js +1 -1
  35. package/dist/translations/be.js +1 -1
  36. package/dist/translations/be.umd.js +1 -1
  37. package/dist/translations/bg.js +1 -1
  38. package/dist/translations/bg.umd.js +1 -1
  39. package/dist/translations/bn.js +1 -1
  40. package/dist/translations/bn.umd.js +1 -1
  41. package/dist/translations/bs.js +1 -1
  42. package/dist/translations/bs.umd.js +1 -1
  43. package/dist/translations/ca.js +1 -1
  44. package/dist/translations/ca.umd.js +1 -1
  45. package/dist/translations/cs.js +1 -1
  46. package/dist/translations/cs.umd.js +1 -1
  47. package/dist/translations/da.js +1 -1
  48. package/dist/translations/da.umd.js +1 -1
  49. package/dist/translations/de-ch.js +1 -1
  50. package/dist/translations/de-ch.umd.js +1 -1
  51. package/dist/translations/de.js +1 -1
  52. package/dist/translations/de.umd.js +1 -1
  53. package/dist/translations/el.js +1 -1
  54. package/dist/translations/el.umd.js +1 -1
  55. package/dist/translations/en-au.js +1 -1
  56. package/dist/translations/en-au.umd.js +1 -1
  57. package/dist/translations/en-gb.js +1 -1
  58. package/dist/translations/en-gb.umd.js +1 -1
  59. package/dist/translations/en.js +1 -1
  60. package/dist/translations/en.umd.js +1 -1
  61. package/dist/translations/eo.js +1 -1
  62. package/dist/translations/eo.umd.js +1 -1
  63. package/dist/translations/es-co.js +1 -1
  64. package/dist/translations/es-co.umd.js +1 -1
  65. package/dist/translations/es.js +1 -1
  66. package/dist/translations/es.umd.js +1 -1
  67. package/dist/translations/et.js +1 -1
  68. package/dist/translations/et.umd.js +1 -1
  69. package/dist/translations/eu.js +1 -1
  70. package/dist/translations/eu.umd.js +1 -1
  71. package/dist/translations/fa.js +1 -1
  72. package/dist/translations/fa.umd.js +1 -1
  73. package/dist/translations/fi.js +1 -1
  74. package/dist/translations/fi.umd.js +1 -1
  75. package/dist/translations/fr.js +1 -1
  76. package/dist/translations/fr.umd.js +1 -1
  77. package/dist/translations/gl.js +1 -1
  78. package/dist/translations/gl.umd.js +1 -1
  79. package/dist/translations/gu.js +1 -1
  80. package/dist/translations/gu.umd.js +1 -1
  81. package/dist/translations/he.js +1 -1
  82. package/dist/translations/he.umd.js +1 -1
  83. package/dist/translations/hi.js +1 -1
  84. package/dist/translations/hi.umd.js +1 -1
  85. package/dist/translations/hr.js +1 -1
  86. package/dist/translations/hr.umd.js +1 -1
  87. package/dist/translations/hu.js +1 -1
  88. package/dist/translations/hu.umd.js +1 -1
  89. package/dist/translations/hy.js +1 -1
  90. package/dist/translations/hy.umd.js +1 -1
  91. package/dist/translations/id.js +1 -1
  92. package/dist/translations/id.umd.js +1 -1
  93. package/dist/translations/it.js +1 -1
  94. package/dist/translations/it.umd.js +1 -1
  95. package/dist/translations/ja.js +1 -1
  96. package/dist/translations/ja.umd.js +1 -1
  97. package/dist/translations/jv.js +1 -1
  98. package/dist/translations/jv.umd.js +1 -1
  99. package/dist/translations/kk.js +1 -1
  100. package/dist/translations/kk.umd.js +1 -1
  101. package/dist/translations/km.js +1 -1
  102. package/dist/translations/km.umd.js +1 -1
  103. package/dist/translations/kn.js +1 -1
  104. package/dist/translations/kn.umd.js +1 -1
  105. package/dist/translations/ko.js +1 -1
  106. package/dist/translations/ko.umd.js +1 -1
  107. package/dist/translations/ku.js +1 -1
  108. package/dist/translations/ku.umd.js +1 -1
  109. package/dist/translations/lt.js +1 -1
  110. package/dist/translations/lt.umd.js +1 -1
  111. package/dist/translations/lv.js +1 -1
  112. package/dist/translations/lv.umd.js +1 -1
  113. package/dist/translations/ms.js +1 -1
  114. package/dist/translations/ms.umd.js +1 -1
  115. package/dist/translations/nb.js +1 -1
  116. package/dist/translations/nb.umd.js +1 -1
  117. package/dist/translations/ne.js +1 -1
  118. package/dist/translations/ne.umd.js +1 -1
  119. package/dist/translations/nl.js +1 -1
  120. package/dist/translations/nl.umd.js +1 -1
  121. package/dist/translations/no.js +1 -1
  122. package/dist/translations/no.umd.js +1 -1
  123. package/dist/translations/oc.js +1 -1
  124. package/dist/translations/oc.umd.js +1 -1
  125. package/dist/translations/pl.js +1 -1
  126. package/dist/translations/pl.umd.js +1 -1
  127. package/dist/translations/pt-br.js +1 -1
  128. package/dist/translations/pt-br.umd.js +1 -1
  129. package/dist/translations/pt.js +1 -1
  130. package/dist/translations/pt.umd.js +1 -1
  131. package/dist/translations/ro.js +1 -1
  132. package/dist/translations/ro.umd.js +1 -1
  133. package/dist/translations/ru.js +1 -1
  134. package/dist/translations/ru.umd.js +1 -1
  135. package/dist/translations/si.js +1 -1
  136. package/dist/translations/si.umd.js +1 -1
  137. package/dist/translations/sk.js +1 -1
  138. package/dist/translations/sk.umd.js +1 -1
  139. package/dist/translations/sl.js +1 -1
  140. package/dist/translations/sl.umd.js +1 -1
  141. package/dist/translations/sq.js +1 -1
  142. package/dist/translations/sq.umd.js +1 -1
  143. package/dist/translations/sr-latn.js +1 -1
  144. package/dist/translations/sr-latn.umd.js +1 -1
  145. package/dist/translations/sr.js +1 -1
  146. package/dist/translations/sr.umd.js +1 -1
  147. package/dist/translations/sv.js +1 -1
  148. package/dist/translations/sv.umd.js +1 -1
  149. package/dist/translations/th.js +1 -1
  150. package/dist/translations/th.umd.js +1 -1
  151. package/dist/translations/ti.js +1 -1
  152. package/dist/translations/ti.umd.js +1 -1
  153. package/dist/translations/tk.js +1 -1
  154. package/dist/translations/tk.umd.js +1 -1
  155. package/dist/translations/tr.js +1 -1
  156. package/dist/translations/tr.umd.js +1 -1
  157. package/dist/translations/tt.js +1 -1
  158. package/dist/translations/tt.umd.js +1 -1
  159. package/dist/translations/ug.js +1 -1
  160. package/dist/translations/ug.umd.js +1 -1
  161. package/dist/translations/uk.js +1 -1
  162. package/dist/translations/uk.umd.js +1 -1
  163. package/dist/translations/ur.js +1 -1
  164. package/dist/translations/ur.umd.js +1 -1
  165. package/dist/translations/uz.js +1 -1
  166. package/dist/translations/uz.umd.js +1 -1
  167. package/dist/translations/vi.js +1 -1
  168. package/dist/translations/vi.umd.js +1 -1
  169. package/dist/translations/zh-cn.js +1 -1
  170. package/dist/translations/zh-cn.umd.js +1 -1
  171. package/dist/translations/zh.js +1 -1
  172. package/dist/translations/zh.umd.js +1 -1
  173. package/package.json +30 -29
  174. package/dist/aicore/utils/tocontextrefrequestdata.d.ts +0 -1
@@ -13,7 +13,7 @@ import { Dialog } from "@ckeditor/ckeditor5-ui";
13
13
  import { AIEditing } from "../aicore/aiediting.js";
14
14
  import { type AIContextRef } from "../aicore/model/aicontextref.js";
15
15
  import { AIBalloon } from "../aiballoon/aiballoon.js";
16
- import { DocumentCompare } from "@ckeditor/ckeditor5-collaboration-core";
16
+ import { DocumentChanges } from "../aisdk/documentchanges.js";
17
17
  /**
18
18
  * @experimental **Experimental:** Some methods of this class are production-ready but experimental and may change
19
19
  * in minor releases without the standard deprecation policy. Check the changelog for migration guidance.
@@ -22,7 +22,7 @@ export declare class AIActions extends Plugin {
22
22
  /**
23
23
  * @inheritDoc
24
24
  */
25
- static get requires(): PluginDependenciesOf<[AIConnector, AIErrorSink, Dialog, AIEditing, AIBalloon, DocumentCompare]>;
25
+ static get requires(): PluginDependenciesOf<[AIConnector, AIErrorSink, Dialog, AIEditing, AIBalloon, DocumentChanges]>;
26
26
  /**
27
27
  * @inheritDoc
28
28
  */
@@ -8,8 +8,7 @@
8
8
  import { AIInteraction, type AIInteractionOptions } from "../../aicore/model/aiinteraction.js";
9
9
  import { type AIConnectorRequest } from "../../aicore/aiconnector.js";
10
10
  import { type AIActionsNames, type AIActionDefinition } from "../aiactions.js";
11
- import { type AIContextItem } from "../../aicore/model/aicontext.js";
12
- import { type AIContextRef } from "../../aicore/model/aicontextref.js";
11
+ import { AIContext, type AIContextItem } from "../../aicore/model/aicontext.js";
13
12
  import type { Editor } from "@ckeditor/ckeditor5-core";
14
13
  import { AIActionsReply } from "./aiactionsreply.js";
15
14
  export declare class AIActionsInteraction extends AIInteraction {
@@ -38,10 +37,10 @@ export declare class AIActionsInteraction extends AIInteraction {
38
37
  */
39
38
  readonly model?: string;
40
39
  /**
41
- * Context references attached to the request. Combines the global `ai.defaultContext` entries that apply to the
40
+ * The context attached to the request. Combines the global `ai.defaultContext` entries that apply to the
42
41
  * invoked action with the action's own context.
43
42
  */
44
- readonly contexts?: Array<AIContextRef>;
43
+ readonly context: AIContext;
45
44
  hasError: boolean;
46
45
  /**
47
46
  * Set when this interaction fires `interactionStopped` (see {@link module:ai/aicore/model/aiinteraction~AIInteraction#stop}).
@@ -14,7 +14,7 @@ import { type AIInteractionReplyCreatedEvent, type AIToolData } from "../aicore/
14
14
  import { type AIContextRef } from "../aicore/model/aicontextref.js";
15
15
  import { type AIChatInteraction } from "./model/aichatinteraction.js";
16
16
  import { AICore } from "../aicore/aicore.js";
17
- import { DocumentCompare } from "@ckeditor/ckeditor5-collaboration-core";
17
+ import { DocumentChanges } from "../aisdk/documentchanges.js";
18
18
  import { type AIChatFeedCustomElementView } from "./ui/feed/aichatfeedcustomelementview.js";
19
19
  /**
20
20
  * Implements integration layer between AI Chat feature UI and logic.
@@ -38,7 +38,7 @@ export declare class AIChatController extends ContextPlugin {
38
38
  /**
39
39
  * @inheritDoc
40
40
  */
41
- static get requires(): PluginDependenciesOf<[AIConnector, AIErrorSink, DocumentCompare, AICore]>;
41
+ static get requires(): PluginDependenciesOf<[AIConnector, AIErrorSink, DocumentChanges, AICore]>;
42
42
  /**
43
43
  * @inheritDoc
44
44
  */
@@ -148,6 +148,15 @@ export declare class AIChatController extends ContextPlugin {
148
148
  */
149
149
  removeSelectionFromChatContext(): void;
150
150
  /**
151
+ * Adds a reference to an admin-managed context from the Context Library to the conversation context.
152
+ *
153
+ * @experimental **Experimental:** This is a production-ready API but may change in minor releases
154
+ * without the standard deprecation policy. Check the changelog for migration guidance.
155
+ * @param libraryContextId The identifier of the context to attach.
156
+ * @param [label] The label displayed on the context chip. Defaults to `libraryContextId`.
157
+ */
158
+ addLibraryContextToChatContext(libraryContextId: string, label?: string): void;
159
+ /**
151
160
  * Moves focus to the AI Chat prompt input field.
152
161
  *
153
162
  * @experimental **Experimental:** This is a production-ready API but may change in minor releases
@@ -43,6 +43,9 @@ export declare class AIChatContext extends AIContext {
43
43
  * (notably by `AIReply`) to route modifications back to the source editor and root; non-document content items
44
44
  * are turned into one context item each.
45
45
  *
46
+ * The context references carried by the message are restored as pending items, so they keep being attached to
47
+ * every following message the way they were before the conversation was read back from history.
48
+ *
46
49
  * Returns the assembled context items together with `unmatchedDocumentIds` — the IDs of documents that could
47
50
  * not be matched to a live editor root via `attributes.channelId` (compared against the editor's
48
51
  * `collaboration.channelId` config) and `attributes.rootName`. Callers resolve a per-document outdated reason
@@ -80,11 +83,9 @@ export declare class AIChatContext extends AIContext {
80
83
  */
81
84
  removeFromContext(uiId: string): void;
82
85
  /**
83
- * Clears all pending context items and adds the current document to the conversation context if it exists.
84
- *
85
- * Context references (`type: 'context'`) are non-persistent and are skipped here: the backend does not store them
86
- * in the conversation state, so they must be re-attached to every message for as long as the user keeps them
87
- * selected. Skipping them also keeps their chips visible and removable.
86
+ * Clears all pending context items, then re-adds the current document and the context references
87
+ * (`type: 'context'`) as read-only and hidden pending items, so that they are sent with the following messages.
88
+ * A context reference that is already read-only and hidden is left untouched.
88
89
  *
89
90
  * @experimental **Experimental:** This is a production-ready API but may change in minor releases
90
91
  * without the standard deprecation policy. Check the changelog for migration guidance.
@@ -93,9 +94,9 @@ export declare class AIChatContext extends AIContext {
93
94
  /**
94
95
  * Adds context items to the conversation context and clears the pending context items.
95
96
  *
96
- * Context references (`type: 'context'`) are non-persistent and never become conversation items: the backend does
97
- * not store them in the conversation state (they are re-attached to every message while selected), and tracking
98
- * them here would keep reporting the resource as in context after the user removes its chip.
97
+ * A context reference never becomes a conversation item. It stays pending for as long as it is attached, which is
98
+ * what keeps it sent with every message and reported as being in context, so a second record of it could only go
99
+ * stale once it stops being attached.
99
100
  *
100
101
  * @experimental **Experimental:** This is a production-ready API but may change in minor releases
101
102
  * without the standard deprecation policy. Check the changelog for migration guidance.
@@ -171,6 +172,15 @@ export declare class AIChatContext extends AIContext {
171
172
  */
172
173
  removeSelectionFromContext(): void;
173
174
  /**
175
+ * Adds a reference to an admin-managed context from the Context Library to the pending context items.
176
+ *
177
+ * @experimental **Experimental:** This is a production-ready API but may change in minor releases
178
+ * without the standard deprecation policy. Check the changelog for migration guidance.
179
+ * @param libraryContextId The identifier of the context to attach.
180
+ * @param [label] The label displayed on the context chip. Defaults to `libraryContextId`.
181
+ */
182
+ addLibraryContextToContext(libraryContextId: string, label?: string): void;
183
+ /**
174
184
  * Adds a URL to the context by uploading it and creating a context item.
175
185
  * This method handles URL upload with proper error handling and progress tracking.
176
186
  *
@@ -150,6 +150,10 @@ export declare class AIChatConversation extends AIChatConversationBase {
150
150
  */
151
151
  addToolItemToContext(item: AIToolContextItem): void;
152
152
  /**
153
+ * Adds a reference to an admin-managed context from the Context Library to the context.
154
+ */
155
+ addLibraryContextToContext(libraryContextId: string, label?: string): void;
156
+ /**
153
157
  * Adds a resource from a source provider to the context.
154
158
  */
155
159
  addResourceToContext(source: AIContextProvider, resource: AIContextResource): void;
@@ -5,7 +5,7 @@
5
5
  import { type Editor, type Context, ContextPlugin, type PluginDependenciesOf } from "@ckeditor/ckeditor5-core";
6
6
  import { CloudServices } from "@ckeditor/ckeditor5-cloud-services";
7
7
  import { type AIContextRequestPart, type AIContextItemType } from "./model/aicontext.js";
8
- import { type AIContextRef, type AIContextRefRequestData } from "./model/aicontextref.js";
8
+ import { type AIContextRefRequestData } from "./model/aicontextref.js";
9
9
  import { type AICapabilitiesRequestData } from "./model/aicapabilities.js";
10
10
  import type { AIActionsNames } from "../aiactions/aiactions.js";
11
11
  import { type AIEditorConfig } from "./utils/geteditorconfig.js";
@@ -475,7 +475,7 @@ export type AIConnectorExecuteCustomActionData = {
475
475
  message?: string;
476
476
  model: string;
477
477
  outputFormat: "plainText" | "html";
478
- contexts?: Array<AIContextRef>;
478
+ contexts?: Array<AIContextRefRequestData>;
479
479
  };
480
480
  export type AIConnectorExecuteActionData = {
481
481
  actionName: AIActionsNames;
@@ -483,7 +483,7 @@ export type AIConnectorExecuteActionData = {
483
483
  args?: {
484
484
  language?: string;
485
485
  };
486
- contexts?: Array<AIContextRef>;
486
+ contexts?: Array<AIContextRefRequestData>;
487
487
  };
488
488
  export type AIConnectorSystemReviewData = {
489
489
  reviewName: string;
@@ -491,13 +491,13 @@ export type AIConnectorSystemReviewData = {
491
491
  args?: {
492
492
  language?: string;
493
493
  };
494
- contexts?: Array<AIContextRef>;
494
+ contexts?: Array<AIContextRefRequestData>;
495
495
  };
496
496
  export type AIConnectorCustomReviewData = {
497
497
  content: string;
498
498
  prompt?: string;
499
499
  model: string;
500
- contexts?: Array<AIContextRef>;
500
+ contexts?: Array<AIContextRefRequestData>;
501
501
  };
502
502
  export type AIConnectorProcessDocumentContentDocument = {
503
503
  type: "document";
@@ -512,7 +512,7 @@ export type AIConnectorProcessDocumentData = {
512
512
  prompt: string;
513
513
  model: string;
514
514
  capabilities?: AICapabilitiesRequestData;
515
- contexts?: Array<AIContextRef>;
515
+ contexts?: Array<AIContextRefRequestData>;
516
516
  };
517
517
  export type AIConnectorProcessDocumentReply = {
518
518
  documents: Array<{
@@ -7,12 +7,39 @@
7
7
  * @publicApi
8
8
  */
9
9
  import { ContextPlugin } from "@ckeditor/ckeditor5-core";
10
+ import { type AICoreErrorSeverity, type AICoreErrorType } from "./errors/aicoreerror.js";
10
11
  /**
11
12
  * Payload of the {@link module:ai/aicore/aierrorreporter~AIErrorSinkErrorEvent} sink event.
13
+ *
14
+ * Error reporting services serialize only `name`, `message` and `stack` of an `Error`, so everything a
15
+ * reported {@link module:ai/aicore/errors/aicoreerror~AICoreError} carries as its own properties is
16
+ * flattened here. A subscriber can therefore classify and forward the failure without inspecting the
17
+ * error itself.
12
18
  */
13
19
  export interface AIErrorSinkEventData {
14
20
  error: unknown;
15
21
  component: string;
22
+ /**
23
+ * {@link module:ai/aicore/errors/aicoreerror~AICoreError#code Code} of the reported error, for example
24
+ * `'ai-chat-file-upload-failed'`. `undefined` for errors that are not an `AICoreError`.
25
+ */
26
+ code?: string;
27
+ /**
28
+ * {@link module:ai/aicore/errors/aicoreerror~AICoreError#type Classification} of the reported error.
29
+ * Use it to skip the failures that are not actionable telemetry: `'user'` (surfaced via UI) and
30
+ * `'network'` (transient). `undefined` for errors that are not an `AICoreError`.
31
+ */
32
+ type?: AICoreErrorType;
33
+ /**
34
+ * {@link module:ai/aicore/errors/aicoreerror~AICoreError#severity Severity} of the reported error.
35
+ * `undefined` for errors that are not an `AICoreError`.
36
+ */
37
+ severity?: AICoreErrorSeverity;
38
+ /**
39
+ * Metadata carried by the reported {@link module:ai/aicore/errors/aicoreerror~AICoreError#context error}
40
+ * merged with the catch-site {@link module:ai/aicore/aierrorreporter~AIErrorReporterOptions#context context},
41
+ * the latter winning on key conflicts. `undefined` when neither is present.
42
+ */
16
43
  context?: Record<string, unknown>;
17
44
  }
18
45
  /**
@@ -20,7 +47,8 @@ export interface AIErrorSinkEventData {
20
47
  */
21
48
  export interface AIErrorReporterOptions {
22
49
  /**
23
- * Catch-site context (operation labels, interaction/conversation IDs, etc.).
50
+ * Catch-site context (operation labels, interaction/conversation IDs, etc.). Merged over the
51
+ * context of the reported error.
24
52
  */
25
53
  context?: Record<string, unknown>;
26
54
  }
@@ -7,7 +7,7 @@
7
7
  * @publicApi
8
8
  */
9
9
  import { ContextPlugin, type PluginDependenciesOf, type Editor } from "@ckeditor/ckeditor5-core";
10
- import { DocumentCompare } from "@ckeditor/ckeditor5-collaboration-core";
10
+ import { DocumentChanges } from "../aisdk/documentchanges.js";
11
11
  import { AICore } from "./aicore.js";
12
12
  import { type AIModels } from "./model/aimodels.js";
13
13
  import { AIResponseApplier } from "./pipeline/airesponseapplier.js";
@@ -81,7 +81,7 @@ export declare class AIGateway extends ContextPlugin {
81
81
  /**
82
82
  * @inheritDoc
83
83
  */
84
- static get requires(): PluginDependenciesOf<[DocumentCompare, AICore]>;
84
+ static get requires(): PluginDependenciesOf<[DocumentChanges, AICore]>;
85
85
  /**
86
86
  * The shared model registry. Exposed here so headless gateways are self-sufficient — integrators can
87
87
  * discover and resolve models (`getAvailableModels()`, `getModel()`, `resolveModel()`, …) without
@@ -26,7 +26,8 @@ export type AIContextRef = {
26
26
  * The request shape of a {@link module:ai/aicore/model/aicontextref~AIContextRef context reference}.
27
27
  *
28
28
  * The AI service expects a `type` discriminator, as a reference can share a request array with entries of other
29
- * types. It is added when the request is built, so it is not part of the reference shape the integrator provides.
29
+ * types. It is added by {@link module:ai/aicore/model/aicontext~AIContext} when the request payload is built, so it is
30
+ * not part of the reference shape the integrator provides.
30
31
  *
31
32
  * @experimental **Experimental:** This is a production-ready API but may change in minor releases
32
33
  * without the standard deprecation policy. Check the changelog for migration guidance.
@@ -24,6 +24,7 @@ import { type MultiLevelListConfig } from "@ckeditor/ckeditor5-list-multi-level"
24
24
  import { type StyleConfig } from "@ckeditor/ckeditor5-style";
25
25
  import { type TableConfig } from "@ckeditor/ckeditor5-table";
26
26
  import { type MediaEmbedConfig } from "@ckeditor/ckeditor5-media-embed";
27
+ import { type GeneralHtmlSupportConfig } from "@ckeditor/ckeditor5-html-support";
27
28
  /**
28
29
  * Builds a compact, serializable snapshot of the editor's feature capabilities for the AI agent.
29
30
  *
@@ -53,6 +54,7 @@ export interface AIEditorConfig {
53
54
  fontFamily?: FontFamilyConfig;
54
55
  fontSize?: FontSizeConfig;
55
56
  footnotes?: FootnotesConfig;
57
+ htmlSupport?: GeneralHtmlSupportConfig;
56
58
  heading?: HeadingConfig;
57
59
  highlight?: HighlightConfig;
58
60
  image?: ImageConfig;
@@ -5,16 +5,16 @@
5
5
  /**
6
6
  * @module ai/aicore/utils/getoperationsfordocumentsuggestions
7
7
  */
8
- import { type DocumentCompare, type DocumentCompareOptions } from "@ckeditor/ckeditor5-collaboration-core";
8
+ import { type DocumentChanges, type DocumentChangesOptions } from "../../aisdk/documentchanges.js";
9
9
  import { type Operation } from "@ckeditor/ckeditor5-engine";
10
10
  import type { DocumentSuggestions } from "./builddocumentsuggestionsmap.js";
11
11
  /**
12
12
  * Returns operations that need to be applied to the editor documents to apply the AI reply.
13
13
  * The result is a `Map` keyed by `documentId`, each entry holding the operations for that document.
14
14
  */
15
- export declare function getOperationsForDocumentSuggestions({ documentSuggestions, transform, documentCompare, documentCompareOptions }: {
15
+ export declare function getOperationsForDocumentSuggestions({ documentSuggestions, transform, documentChanges, documentChangesOptions }: {
16
16
  documentSuggestions: Map<string, DocumentSuggestions>;
17
17
  transform: boolean;
18
- documentCompare: DocumentCompare;
19
- documentCompareOptions: DocumentCompareOptions;
18
+ documentChanges: DocumentChanges;
19
+ documentChangesOptions: DocumentChangesOptions;
20
20
  }): Map<string, Array<Operation>>;
@@ -6,10 +6,8 @@
6
6
  * @module ai/aicore/utils/markoperationsasai
7
7
  */
8
8
  import type { Operation } from "@ckeditor/ckeditor5-engine";
9
- /**
10
- * Identifiers used by built-in AI features when tagging the operations they produce.
11
- */
12
- export type AIOperationSource = "chat" | "quickActions" | "api" | "review" | "translate" | (string & {});
9
+ import type { AIOperationSource } from "@ckeditor/ckeditor5-collaboration-core";
10
+ export type { AIOperationSource };
13
11
  /**
14
12
  * Sets the AI source identifier on a list of operations. After this call, every non-no-op operation has its
15
13
  * `_aiSource` field set to `source` and is preserved through collaborative transmission.
@@ -8,7 +8,7 @@
8
8
  import { InsertOperation, MarkerOperation, ModelDocumentFragment, ModelPosition, ModelRange, type Operation } from "@ckeditor/ckeditor5-engine";
9
9
  import { type Emitter } from "@ckeditor/ckeditor5-utils";
10
10
  import { ContextPlugin, Editor, type Context, type PluginDependenciesOf } from "@ckeditor/ckeditor5-core";
11
- import { DocumentCompare } from "@ckeditor/ckeditor5-collaboration-core";
11
+ import { DocumentChanges } from "../aisdk/documentchanges.js";
12
12
  import { type AIReviewCheckResultChange } from "./model/aireviewcheckresultchange.js";
13
13
  import { AIEditing } from "../aicore/aiediting.js";
14
14
  import { type AIEditorRoot } from "../aicore/model/aieditorroot.js";
@@ -19,7 +19,7 @@ export declare class AIReviewCoreEditing extends ContextPlugin {
19
19
  /**
20
20
  * @inheritDoc
21
21
  */
22
- static get requires(): PluginDependenciesOf<[DocumentCompare, AIEditing]>;
22
+ static get requires(): PluginDependenciesOf<[DocumentChanges, AIEditing]>;
23
23
  /**
24
24
  * @inheritDoc
25
25
  */
@@ -11,7 +11,7 @@ import { AIReviewCheckResultChange } from "./aireviewcheckresultchange.js";
11
11
  import { type AIReviewCheck } from "./aireviewcheck.js";
12
12
  import { type AIReviewCoreChangeData, type AIDocumentData } from "../aireviewcoreediting.js";
13
13
  import { type AIConnector } from "../../aicore/aiconnector.js";
14
- import { type AIContextRef } from "../../aicore/model/aicontextref.js";
14
+ import { AIContext } from "../../aicore/model/aicontext.js";
15
15
  import { type Editor } from "@ckeditor/ckeditor5-core";
16
16
  declare const AIReviewCheckRunBase: ObservableMixinConstructor;
17
17
  /**
@@ -30,7 +30,7 @@ export declare abstract class AIReviewCheckRun extends AIReviewCheckRunBase {
30
30
  * The call ID returned by the AI API when the check run is started.
31
31
  */
32
32
  callId?: string;
33
- constructor(documentData: AIDocumentData, sourceCheck: AIReviewCheck, connector: AIConnector, params?: Array<string>, args?: Record<string, any>, contexts?: Array<AIContextRef>);
33
+ constructor(documentData: AIDocumentData, sourceCheck: AIReviewCheck, connector: AIConnector, params?: Array<string>, args?: Record<string, any>, context?: AIContext);
34
34
  /**
35
35
  * Returns the document data obtained at the time of the check run.
36
36
  */
@@ -9,13 +9,13 @@ import { AIReviewCheckRun } from "../../aireviewcore/model/aireviewcheckrun.js";
9
9
  import { type AIConnector } from "../../aicore/aiconnector.js";
10
10
  import { type AIDocumentData } from "../../aireviewcore/aireviewcoreediting.js";
11
11
  import { type AIReviewCheck } from "../../aireviewcore/model/aireviewcheck.js";
12
- import { type AIContextRef } from "../../aicore/model/aicontextref.js";
12
+ import { type AIContext } from "../../aicore/model/aicontext.js";
13
13
  /**
14
14
  * Represents a single custom review check
15
15
  * ({@link module:ai/aireviewmode/model/aireviewcheckcustom~AIReviewCheckCustom}) run and its results.
16
16
  */
17
17
  export declare class AIReviewCustomCheckRun extends AIReviewCheckRun {
18
- constructor(prompt: string | undefined, model: string, documentData: AIDocumentData, sourceCheck: AIReviewCheck, connector: AIConnector, contexts?: Array<AIContextRef>);
18
+ constructor(prompt: string | undefined, model: string, documentData: AIDocumentData, sourceCheck: AIReviewCheck, connector: AIConnector, context?: AIContext);
19
19
  /**
20
20
  * @inheritDoc
21
21
  */
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
+ /**
6
+ * @module ai/aisdk/dataidassigner
7
+ */
8
+ import { type Editor } from "@ckeditor/ckeditor5-core";
9
+ import { type ViewDocumentFragment, type ViewElement } from "@ckeditor/ckeditor5-engine";
10
+ /**
11
+ * Assigns a unique `data-id` to the structural view elements that lack one — container, empty and raw elements, plus
12
+ * any element containing an id-bearing descendant (skipping `<br>`). Existing ids are preserved.
13
+ */
14
+ export declare class DataIdAssigner {
15
+ constructor(editor: Editor);
16
+ /**
17
+ * Assigns the missing `data-id`s across the given view fragment (or element).
18
+ */
19
+ assign(view: ViewElement | ViewDocumentFragment): void;
20
+ }
@@ -0,0 +1,165 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
+ /**
6
+ * @module ai/aisdk/documentchanges
7
+ */
8
+ import { ContextPlugin, Editor, type PluginDependenciesOf } from "@ckeditor/ckeditor5-core";
9
+ import { ModelPosition, type ModelWriter, type ModelDocumentFragment, type ModelElement, type Operation } from "@ckeditor/ckeditor5-engine";
10
+ import { DocumentChangesUtils } from "./documentchangesutils.js";
11
+ export declare const DATA_ID_MODEL_ATTRIBUTE = "$elementId";
12
+ export declare const DATA_ID_VIEW_ATTRIBUTE = "data-id";
13
+ /**
14
+ * The `DocumentChanges` plugin provides utilities to compare two documents or documents fragments, and provide set of operations
15
+ * which need to be executed to transform one document into the other.
16
+ */
17
+ export declare class DocumentChanges extends ContextPlugin {
18
+ /**
19
+ * @inheritDoc
20
+ */
21
+ static get pluginName(): "DocumentChanges";
22
+ /**
23
+ * @inheritDoc
24
+ */
25
+ static override get isOfficialPlugin(): true;
26
+ /**
27
+ * @inheritDoc
28
+ */
29
+ static override get isPremiumPlugin(): true;
30
+ static get requires(): PluginDependenciesOf<[DocumentChangesUtils]>;
31
+ init(): Promise<void>;
32
+ get editor(): Editor;
33
+ /**
34
+ * Compares two HTML strings and returns the operations that transform `dataBefore` into `dataAfter`.
35
+ *
36
+ * @param dataBefore The HTML to transform from.
37
+ * @param dataAfter The HTML to transform into.
38
+ * @param options Diffing options.
39
+ * @returns Operations that need to be applied to transform `dataBefore` into `dataAfter`.
40
+ */
41
+ getDiff(dataBefore: string, dataAfter: string, options?: DocumentChangesOptions): Array<Operation>;
42
+ /**
43
+ * Returns `true` if given `operation` is an operation that marks a content to be removed. This kind of operations can be
44
+ * returned by {@link module:ai/aisdk/documentchanges~DocumentChanges#getOperations} if `markedDeletions` mode is enabled.
45
+ *
46
+ * @param operation
47
+ */
48
+ isMarkedRemoveOperation(operation: Operation): boolean;
49
+ /**
50
+ * Applies the given operations (for example, the result of comparing two documents) to the model.
51
+ *
52
+ * Beyond applying the operations, this method reproduces the marker bookkeeping that the editing pipeline normally
53
+ * performs, so that existing markers behave the same as during regular editing:
54
+ *
55
+ * * markers affected by a move or merge are anchored, so they can be restored on undo;
56
+ * * marker operations have their `oldRange` reconciled with the live marker, as operations coming from a comparison
57
+ * have it set to `null`.
58
+ *
59
+ * Must be called inside a model change block; the operations are added to the given `writer`'s batch.
60
+ *
61
+ * @param writer Writer of the change block the operations are applied within.
62
+ * @param operations Operations to apply, in order.
63
+ */
64
+ applyOperations(writer: ModelWriter, operations: Array<Operation>): void;
65
+ }
66
+ export interface DocumentChangesOptions {
67
+ anchor?: string | ModelPosition;
68
+ markDeletions: boolean;
69
+ /**
70
+ * The editor whose model/schema should be used for parsing and for resolving a string `anchor` (e.g. multi-root root names).
71
+ */
72
+ targetEditor?: Editor;
73
+ }
74
+ export interface InsertOperationData {
75
+ type: "insert";
76
+ path: Path;
77
+ tokens: Array<ModelToken>;
78
+ }
79
+ export interface RemoveOperationData {
80
+ type: "remove";
81
+ path: Path;
82
+ howMany: number;
83
+ }
84
+ export interface SplitOperationData {
85
+ type: "split";
86
+ path: Path;
87
+ }
88
+ export interface MergeOperationData {
89
+ type: "merge";
90
+ path: Path;
91
+ }
92
+ export interface RenameOperationData {
93
+ type: "rename";
94
+ path: Path;
95
+ oldName: string;
96
+ newName: string;
97
+ }
98
+ export interface AttributeOperationData {
99
+ type: "attribute";
100
+ path: Path;
101
+ howMany: number;
102
+ key: string;
103
+ oldValue: string;
104
+ newValue: string;
105
+ }
106
+ export interface MarkerOperationData {
107
+ type: "marker";
108
+ name: string;
109
+ range: null | {
110
+ start: Path;
111
+ end: Path;
112
+ };
113
+ }
114
+ export interface UnwrapOperationData {
115
+ type: "unwrap";
116
+ path: Path;
117
+ howMany: number;
118
+ }
119
+ export interface WrapOperationData {
120
+ type: "wrap";
121
+ token: ModelElementToken;
122
+ range: {
123
+ start: Path;
124
+ end: Path;
125
+ };
126
+ }
127
+ export interface MarkedRemoveData {
128
+ type: "markedRemove";
129
+ range: {
130
+ start: Path;
131
+ end: Path;
132
+ };
133
+ }
134
+ export type OperationData = InsertOperationData | RemoveOperationData | SplitOperationData | MergeOperationData | RenameOperationData | AttributeOperationData | MarkerOperationData | UnwrapOperationData | WrapOperationData | MarkedRemoveData;
135
+ export type ModelToken = ModelElementToken | ModelTextToken;
136
+ export interface ModelElementToken {
137
+ type: "element";
138
+ element: ModelElement;
139
+ elementId: string;
140
+ /**
141
+ * Elements category.
142
+ *
143
+ * Describes how the element behaves and how it can change. It is used when comparing lists of model tokens to create a better diff.
144
+ *
145
+ * * `block` - elements like paragraphs, lists, or headings. Can be renamed. Can be created by splitting. Can be removed by merging.
146
+ * Its contents can be "moved around" by splitting or merging.
147
+ *
148
+ * * `container` - elements like blockquote. Cannot be renamed. Can be created by wrapping. Can be removed by unwrapping. Can be
149
+ * "resized" by having other elements be moved into or out of them.
150
+ *
151
+ * * `solid` - limit-like elements like table or image. Cannot be renamed, split or merged. Can be added by insertion and removed by
152
+ * deletion. If added or removed, all their content also should be treated as added or removed.
153
+ */
154
+ category: "block" | "container" | "solid";
155
+ isStart: boolean;
156
+ limitId: string;
157
+ }
158
+ export interface ModelTextToken {
159
+ type: "text";
160
+ data: string;
161
+ parent: ModelElement | ModelDocumentFragment;
162
+ offset: number;
163
+ limitId: string;
164
+ }
165
+ export type Path = Array<number>;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
+ */
5
+ /**
6
+ * @module ai/aisdk/documentchangesutils
7
+ */
8
+ import { ContextPlugin } from "@ckeditor/ckeditor5-core";
9
+ export declare class DocumentChangesUtils extends ContextPlugin {
10
+ static get pluginName(): "DocumentChangesUtils";
11
+ static override get isOfficialPlugin(): true;
12
+ static override get isPremiumPlugin(): true;
13
+ init(): void;
14
+ override destroy(): void;
15
+ }