@blocknote/xl-ai 0.44.1 → 0.44.2

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.
@@ -1 +1 @@
1
- {"builtAt":1765213028742,"assets":[{"name":"server.cjs","size":1351},{"name":"blocknote-xl-ai.cjs","size":25714},{"name":"locales.cjs","size":23791},{"name":"client-DrruPiJu.cjs","size":39783},{"name":"client-DrruPiJu.cjs.map","size":202339},{"name":"server.cjs.map","size":91},{"name":"locales.cjs.map","size":55283},{"name":"blocknote-xl-ai.cjs.map","size":2215776}],"chunks":[{"id":"91fd206","entry":true,"initial":true,"files":["server.cjs"],"names":["server"]},{"id":"a1ee98a","entry":true,"initial":true,"files":["blocknote-xl-ai.cjs"],"names":["blocknote-xl-ai"]},{"id":"842df4c","entry":true,"initial":true,"files":["locales.cjs"],"names":["locales"]},{"id":"8392e5f","entry":false,"initial":true,"files":["client-DrruPiJu.cjs"],"names":["client"]}],"modules":[{"name":"./src/server.ts","size":0,"chunks":["91fd206"]},{"name":"./src/style.css","size":0,"chunks":["a1ee98a"]},{"name":"./src/plugins/AgentCursorPlugin.ts","size":2444,"chunks":["a1ee98a"]},{"name":"./src/AIExtension.ts","size":10954,"chunks":["a1ee98a"]},{"name":"../../node_modules/.pnpm/react-icons@5.5.0_react@19.2.1/node_modules/react-icons/lib/iconContext.mjs","size":251,"chunks":["a1ee98a"]},{"name":"../../node_modules/.pnpm/react-icons@5.5.0_react@19.2.1/node_modules/react-icons/lib/iconBase.mjs","size":4003,"chunks":["a1ee98a"]},{"name":"../../node_modules/.pnpm/react-icons@5.5.0_react@19.2.1/node_modules/react-icons/ri/index.mjs","size":6747,"chunks":["a1ee98a"]},{"name":"./src/hooks/useAIDictionary.ts","size":120,"chunks":["a1ee98a"]},{"name":"./src/components/AIMenu/PromptSuggestionMenu.tsx","size":2911,"chunks":["a1ee98a"]},{"name":"./src/components/AIMenu/getDefaultAIMenuItems.tsx","size":7846,"chunks":["a1ee98a"]},{"name":"./src/components/AIMenu/AIMenu.tsx","size":3596,"chunks":["a1ee98a"]},{"name":"./src/components/AIMenu/AIMenuController.tsx","size":2417,"chunks":["a1ee98a"]},{"name":"./src/components/FormattingToolbar/AIToolbarButton.tsx","size":960,"chunks":["a1ee98a"]},{"name":"./src/components/SuggestionMenu/getAISlashMenuItems.tsx","size":728,"chunks":["a1ee98a"]},{"name":"./src/index.ts","size":0,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/ar.ts","size":1531,"chunks":["842df4c"]},{"name":"./src/i18n/locales/de.ts","size":1585,"chunks":["842df4c"]},{"name":"./src/i18n/locales/en.ts","size":1483,"chunks":["842df4c"]},{"name":"./src/i18n/locales/es.ts","size":1553,"chunks":["842df4c"]},{"name":"./src/i18n/locales/fr.ts","size":1569,"chunks":["842df4c"]},{"name":"./src/i18n/locales/he.ts","size":1401,"chunks":["842df4c"]},{"name":"./src/i18n/locales/hr.ts","size":1494,"chunks":["842df4c"]},{"name":"./src/i18n/locales/is.ts","size":1562,"chunks":["842df4c"]},{"name":"./src/i18n/locales/it.ts","size":1555,"chunks":["842df4c"]},{"name":"./src/i18n/locales/ja.ts","size":1372,"chunks":["842df4c"]},{"name":"./src/i18n/locales/ko.ts","size":1394,"chunks":["842df4c"]},{"name":"./src/i18n/locales/nl.ts","size":1536,"chunks":["842df4c"]},{"name":"./src/i18n/locales/no.ts","size":1509,"chunks":["842df4c"]},{"name":"./src/i18n/locales/pl.ts","size":1510,"chunks":["842df4c"]},{"name":"./src/i18n/locales/pt.ts","size":1548,"chunks":["842df4c"]},{"name":"./src/i18n/locales/ru.ts","size":1549,"chunks":["842df4c"]},{"name":"./src/i18n/locales/sk.ts","size":1511,"chunks":["842df4c"]},{"name":"./src/i18n/locales/uk.ts","size":1556,"chunks":["842df4c"]},{"name":"./src/i18n/locales/vi.ts","size":1506,"chunks":["842df4c"]},{"name":"./src/i18n/locales/zh-tw.ts","size":1345,"chunks":["842df4c"]},{"name":"./src/i18n/locales/zh.ts","size":1340,"chunks":["842df4c"]},{"name":"./src/i18n/locales/index.ts","size":0,"chunks":["842df4c"]},{"name":"./src/util/emptyBlock.ts","size":170,"chunks":["8392e5f"]},{"name":"./src/util/trimArray.ts","size":327,"chunks":["8392e5f"]},{"name":"./src/api/promptHelpers/trimEmptyBlocks.ts","size":272,"chunks":["8392e5f"]},{"name":"./src/api/aiRequest/builder.ts","size":1343,"chunks":["8392e5f"]},{"name":"./src/streamTool/jsonSchema.ts","size":1630,"chunks":["8392e5f"]},{"name":"./src/streamTool/ChunkExecutionError.ts","size":237,"chunks":["8392e5f"]},{"name":"./src/streamTool/StreamToolExecutor.ts","size":4984,"chunks":["8392e5f"]},{"name":"./src/streamTool/vercelAiSdk/util/injectDocumentStateMessages.ts","size":2819,"chunks":["8392e5f"]},{"name":"./src/streamTool/vercelAiSdk/util/partialObjectStreamUtil.ts","size":2350,"chunks":["8392e5f"]},{"name":"./src/streamTool/vercelAiSdk/util/toolDefinitions.ts","size":680,"chunks":["8392e5f"]},{"name":"./src/streamTool/vercelAiSdk/clientside/ClientSideTransport.ts","size":3291,"chunks":["8392e5f"]},{"name":"./src/streamTool/vercelAiSdk/util/appendableStream.ts","size":1196,"chunks":["8392e5f"]},{"name":"./src/util/stream.ts","size":1069,"chunks":["8392e5f"]},{"name":"./src/streamTool/filterNewOrUpdatedOperations.ts","size":933,"chunks":["8392e5f"]},{"name":"./src/streamTool/filterValidOperations.ts","size":681,"chunks":["8392e5f"]},{"name":"./src/streamTool/toValidatedOperations.ts","size":819,"chunks":["8392e5f"]},{"name":"./src/streamTool/preprocess.ts","size":467,"chunks":["8392e5f"]},{"name":"./src/streamTool/vercelAiSdk/util/UIMessageStreamToOperationsResult.ts","size":306,"chunks":["8392e5f"]},{"name":"./src/streamTool/vercelAiSdk/util/chatHandlers.ts","size":4645,"chunks":["8392e5f"]},{"name":"./src/api/aiRequest/sendMessageWithAIRequest.ts","size":813,"chunks":["8392e5f"]},{"name":"./src/api/promptHelpers/addCursorPosition.ts","size":390,"chunks":["8392e5f"]},{"name":"./src/api/promptHelpers/convertBlocks.ts","size":183,"chunks":["8392e5f"]},{"name":"./src/api/promptHelpers/flattenBlocks.ts","size":162,"chunks":["8392e5f"]},{"name":"./src/api/promptHelpers/suffixIds.ts","size":204,"chunks":["8392e5f"]},{"name":"./src/api/formats/DocumentStateBuilder.ts","size":1985,"chunks":["8392e5f"]},{"name":"./src/prosemirror/fragmentUtil.ts","size":262,"chunks":["8392e5f"]},{"name":"./src/prosemirror/agent.ts","size":6220,"chunks":["8392e5f"]},{"name":"./src/prosemirror/changeset.ts","size":6000,"chunks":["8392e5f"]},{"name":"./src/streamTool/streamTool.ts","size":48,"chunks":["8392e5f"]},{"name":"./src/util/AbortError.ts","size":131,"chunks":["8392e5f"]},{"name":"./src/api/formats/base-tools/util/validateBlockArray.ts","size":574,"chunks":["8392e5f"]},{"name":"./src/api/formats/base-tools/createAddBlocksTool.ts","size":5549,"chunks":["8392e5f"]},{"name":"./src/api/formats/base-tools/createUpdateBlockTool.ts","size":4362,"chunks":["8392e5f"]},{"name":"./src/api/formats/base-tools/delete.ts","size":1781,"chunks":["8392e5f"]},{"name":"./src/api/formats/html-blocks/tools/getPartialHTML.ts","size":699,"chunks":["8392e5f"]},{"name":"./src/prosemirror/rebaseTool.ts","size":1508,"chunks":["8392e5f"]},{"name":"./src/api/formats/html-blocks/tools/rebaseTool.ts","size":829,"chunks":["8392e5f"]},{"name":"./src/api/formats/html-blocks/tools/validate.ts","size":204,"chunks":["8392e5f"]},{"name":"./src/api/formats/html-blocks/tools/index.ts","size":1886,"chunks":["8392e5f"]},{"name":"./src/api/formats/html-blocks/htmlBlocks.ts","size":2886,"chunks":["8392e5f"]},{"name":"./src/api/schema/mergeSchema.ts","size":829,"chunks":["8392e5f"]},{"name":"./src/api/schema/schemaToJSONSchema.ts","size":4910,"chunks":["8392e5f"]},{"name":"./src/api/formats/json/tools/validate.ts","size":1603,"chunks":["8392e5f"]},{"name":"./src/api/formats/json/tools/index.ts","size":1324,"chunks":["8392e5f"]},{"name":"./src/api/formats/json/json.ts","size":2546,"chunks":["8392e5f"]},{"name":"./src/api/formats/markdown-blocks/tools/rebaseTool.ts","size":633,"chunks":["8392e5f"]},{"name":"./src/api/formats/markdown-blocks/tools/validate.ts","size":202,"chunks":["8392e5f"]},{"name":"./src/api/formats/markdown-blocks/tools/index.ts","size":1505,"chunks":["8392e5f"]},{"name":"./src/api/formats/markdown-blocks/markdownBlocks.ts","size":2559,"chunks":["8392e5f"]},{"name":"./src/api/formats/formats.ts","size":149,"chunks":["8392e5f"]},{"name":"./src/api/promptHelpers/index.ts","size":112,"chunks":["8392e5f"]},{"name":"./src/i18n/dictionary.ts","size":150,"chunks":["8392e5f"]},{"name":"./src/blocknoteAIClient/client.ts","size":533,"chunks":["8392e5f"]}]}
1
+ {"builtAt":1765295243986,"assets":[{"name":"server.cjs","size":1351},{"name":"blocknote-xl-ai.cjs","size":25759},{"name":"locales.cjs","size":23791},{"name":"client-wMB2zJXh.cjs","size":40071},{"name":"client-wMB2zJXh.cjs.map","size":202276},{"name":"server.cjs.map","size":91},{"name":"locales.cjs.map","size":55283},{"name":"blocknote-xl-ai.cjs.map","size":2216055}],"chunks":[{"id":"91fd206","entry":true,"initial":true,"files":["server.cjs"],"names":["server"]},{"id":"a1ee98a","entry":true,"initial":true,"files":["blocknote-xl-ai.cjs"],"names":["blocknote-xl-ai"]},{"id":"842df4c","entry":true,"initial":true,"files":["locales.cjs"],"names":["locales"]},{"id":"8392e5f","entry":false,"initial":true,"files":["client-wMB2zJXh.cjs"],"names":["client"]}],"modules":[{"name":"./src/server.ts","size":0,"chunks":["91fd206"]},{"name":"./src/style.css","size":0,"chunks":["a1ee98a"]},{"name":"./src/plugins/AgentCursorPlugin.ts","size":2444,"chunks":["a1ee98a"]},{"name":"./src/AIExtension.ts","size":11062,"chunks":["a1ee98a"]},{"name":"../../node_modules/.pnpm/react-icons@5.5.0_react@19.2.1/node_modules/react-icons/lib/iconContext.mjs","size":251,"chunks":["a1ee98a"]},{"name":"../../node_modules/.pnpm/react-icons@5.5.0_react@19.2.1/node_modules/react-icons/lib/iconBase.mjs","size":4003,"chunks":["a1ee98a"]},{"name":"../../node_modules/.pnpm/react-icons@5.5.0_react@19.2.1/node_modules/react-icons/ri/index.mjs","size":6747,"chunks":["a1ee98a"]},{"name":"./src/hooks/useAIDictionary.ts","size":120,"chunks":["a1ee98a"]},{"name":"./src/components/AIMenu/PromptSuggestionMenu.tsx","size":2911,"chunks":["a1ee98a"]},{"name":"./src/components/AIMenu/getDefaultAIMenuItems.tsx","size":7846,"chunks":["a1ee98a"]},{"name":"./src/components/AIMenu/AIMenu.tsx","size":3596,"chunks":["a1ee98a"]},{"name":"./src/components/AIMenu/AIMenuController.tsx","size":2417,"chunks":["a1ee98a"]},{"name":"./src/components/FormattingToolbar/AIToolbarButton.tsx","size":960,"chunks":["a1ee98a"]},{"name":"./src/components/SuggestionMenu/getAISlashMenuItems.tsx","size":728,"chunks":["a1ee98a"]},{"name":"./src/index.ts","size":0,"chunks":["a1ee98a"]},{"name":"./src/i18n/locales/ar.ts","size":1531,"chunks":["842df4c"]},{"name":"./src/i18n/locales/de.ts","size":1585,"chunks":["842df4c"]},{"name":"./src/i18n/locales/en.ts","size":1483,"chunks":["842df4c"]},{"name":"./src/i18n/locales/es.ts","size":1553,"chunks":["842df4c"]},{"name":"./src/i18n/locales/fr.ts","size":1569,"chunks":["842df4c"]},{"name":"./src/i18n/locales/he.ts","size":1401,"chunks":["842df4c"]},{"name":"./src/i18n/locales/hr.ts","size":1494,"chunks":["842df4c"]},{"name":"./src/i18n/locales/is.ts","size":1562,"chunks":["842df4c"]},{"name":"./src/i18n/locales/it.ts","size":1555,"chunks":["842df4c"]},{"name":"./src/i18n/locales/ja.ts","size":1372,"chunks":["842df4c"]},{"name":"./src/i18n/locales/ko.ts","size":1394,"chunks":["842df4c"]},{"name":"./src/i18n/locales/nl.ts","size":1536,"chunks":["842df4c"]},{"name":"./src/i18n/locales/no.ts","size":1509,"chunks":["842df4c"]},{"name":"./src/i18n/locales/pl.ts","size":1510,"chunks":["842df4c"]},{"name":"./src/i18n/locales/pt.ts","size":1548,"chunks":["842df4c"]},{"name":"./src/i18n/locales/ru.ts","size":1549,"chunks":["842df4c"]},{"name":"./src/i18n/locales/sk.ts","size":1511,"chunks":["842df4c"]},{"name":"./src/i18n/locales/uk.ts","size":1556,"chunks":["842df4c"]},{"name":"./src/i18n/locales/vi.ts","size":1506,"chunks":["842df4c"]},{"name":"./src/i18n/locales/zh-tw.ts","size":1345,"chunks":["842df4c"]},{"name":"./src/i18n/locales/zh.ts","size":1340,"chunks":["842df4c"]},{"name":"./src/i18n/locales/index.ts","size":0,"chunks":["842df4c"]},{"name":"./src/util/emptyBlock.ts","size":170,"chunks":["8392e5f"]},{"name":"./src/util/trimArray.ts","size":327,"chunks":["8392e5f"]},{"name":"./src/api/promptHelpers/trimEmptyBlocks.ts","size":272,"chunks":["8392e5f"]},{"name":"./src/api/aiRequest/builder.ts","size":1343,"chunks":["8392e5f"]},{"name":"./src/streamTool/jsonSchema.ts","size":1630,"chunks":["8392e5f"]},{"name":"./src/streamTool/ChunkExecutionError.ts","size":237,"chunks":["8392e5f"]},{"name":"./src/streamTool/StreamToolExecutor.ts","size":4984,"chunks":["8392e5f"]},{"name":"./src/streamTool/vercelAiSdk/util/injectDocumentStateMessages.ts","size":2819,"chunks":["8392e5f"]},{"name":"./src/streamTool/vercelAiSdk/util/partialObjectStreamUtil.ts","size":2350,"chunks":["8392e5f"]},{"name":"./src/streamTool/vercelAiSdk/util/toolDefinitions.ts","size":680,"chunks":["8392e5f"]},{"name":"./src/streamTool/vercelAiSdk/clientside/ClientSideTransport.ts","size":3291,"chunks":["8392e5f"]},{"name":"./src/streamTool/vercelAiSdk/util/appendableStream.ts","size":1196,"chunks":["8392e5f"]},{"name":"./src/util/stream.ts","size":1069,"chunks":["8392e5f"]},{"name":"./src/streamTool/filterNewOrUpdatedOperations.ts","size":933,"chunks":["8392e5f"]},{"name":"./src/streamTool/filterValidOperations.ts","size":681,"chunks":["8392e5f"]},{"name":"./src/streamTool/toValidatedOperations.ts","size":1182,"chunks":["8392e5f"]},{"name":"./src/streamTool/preprocess.ts","size":594,"chunks":["8392e5f"]},{"name":"./src/streamTool/vercelAiSdk/util/UIMessageStreamToOperationsResult.ts","size":306,"chunks":["8392e5f"]},{"name":"./src/streamTool/vercelAiSdk/util/chatHandlers.ts","size":4645,"chunks":["8392e5f"]},{"name":"./src/api/aiRequest/sendMessageWithAIRequest.ts","size":813,"chunks":["8392e5f"]},{"name":"./src/api/promptHelpers/addCursorPosition.ts","size":390,"chunks":["8392e5f"]},{"name":"./src/api/promptHelpers/convertBlocks.ts","size":183,"chunks":["8392e5f"]},{"name":"./src/api/promptHelpers/flattenBlocks.ts","size":162,"chunks":["8392e5f"]},{"name":"./src/api/promptHelpers/suffixIds.ts","size":204,"chunks":["8392e5f"]},{"name":"./src/api/formats/DocumentStateBuilder.ts","size":1985,"chunks":["8392e5f"]},{"name":"./src/prosemirror/fragmentUtil.ts","size":262,"chunks":["8392e5f"]},{"name":"./src/prosemirror/agent.ts","size":6220,"chunks":["8392e5f"]},{"name":"./src/prosemirror/changeset.ts","size":6000,"chunks":["8392e5f"]},{"name":"./src/streamTool/streamTool.ts","size":48,"chunks":["8392e5f"]},{"name":"./src/util/AbortError.ts","size":131,"chunks":["8392e5f"]},{"name":"./src/api/formats/base-tools/util/validateBlockArray.ts","size":574,"chunks":["8392e5f"]},{"name":"./src/api/formats/base-tools/createAddBlocksTool.ts","size":5549,"chunks":["8392e5f"]},{"name":"./src/api/formats/base-tools/createUpdateBlockTool.ts","size":4362,"chunks":["8392e5f"]},{"name":"./src/api/formats/base-tools/delete.ts","size":1781,"chunks":["8392e5f"]},{"name":"./src/api/formats/html-blocks/tools/getPartialHTML.ts","size":699,"chunks":["8392e5f"]},{"name":"./src/prosemirror/rebaseTool.ts","size":1508,"chunks":["8392e5f"]},{"name":"./src/api/formats/html-blocks/tools/rebaseTool.ts","size":829,"chunks":["8392e5f"]},{"name":"./src/api/formats/html-blocks/tools/validate.ts","size":204,"chunks":["8392e5f"]},{"name":"./src/api/formats/html-blocks/tools/index.ts","size":1886,"chunks":["8392e5f"]},{"name":"./src/api/formats/html-blocks/htmlBlocks.ts","size":2886,"chunks":["8392e5f"]},{"name":"./src/api/schema/mergeSchema.ts","size":829,"chunks":["8392e5f"]},{"name":"./src/api/schema/schemaToJSONSchema.ts","size":4910,"chunks":["8392e5f"]},{"name":"./src/api/formats/json/tools/validate.ts","size":1603,"chunks":["8392e5f"]},{"name":"./src/api/formats/json/tools/index.ts","size":1324,"chunks":["8392e5f"]},{"name":"./src/api/formats/json/json.ts","size":2546,"chunks":["8392e5f"]},{"name":"./src/api/formats/markdown-blocks/tools/rebaseTool.ts","size":633,"chunks":["8392e5f"]},{"name":"./src/api/formats/markdown-blocks/tools/validate.ts","size":202,"chunks":["8392e5f"]},{"name":"./src/api/formats/markdown-blocks/tools/index.ts","size":1505,"chunks":["8392e5f"]},{"name":"./src/api/formats/markdown-blocks/markdownBlocks.ts","size":2559,"chunks":["8392e5f"]},{"name":"./src/api/formats/formats.ts","size":149,"chunks":["8392e5f"]},{"name":"./src/api/promptHelpers/index.ts","size":112,"chunks":["8392e5f"]},{"name":"./src/i18n/dictionary.ts","size":150,"chunks":["8392e5f"]},{"name":"./src/blocknoteAIClient/client.ts","size":533,"chunks":["8392e5f"]}]}
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "directory": "packages/xl-ai"
12
12
  },
13
13
  "license": "GPL-3.0 OR PROPRIETARY",
14
- "version": "0.44.1",
14
+ "version": "0.44.2",
15
15
  "files": [
16
16
  "dist",
17
17
  "types",
@@ -63,11 +63,11 @@
63
63
  "dependencies": {
64
64
  "@ai-sdk/provider-utils": "^3.0.17",
65
65
  "@ai-sdk/react": "^2.0.102",
66
- "@blocknote/core": "0.44.1",
67
- "@blocknote/mantine": "0.44.1",
68
- "@blocknote/prosemirror-suggest-changes": "^0.1.3",
69
- "@blocknote/react": "0.44.1",
66
+ "@blocknote/core": "0.44.2",
67
+ "@blocknote/mantine": "0.44.2",
68
+ "@blocknote/react": "0.44.2",
70
69
  "@floating-ui/react": "^0.26.28",
70
+ "@handlewithcare/prosemirror-suggest-changes": "^0.1.8",
71
71
  "@tiptap/core": "^3.11.0",
72
72
  "ai": "^5.0.102",
73
73
  "lodash.isequal": "^4.5.0",
@@ -14,7 +14,7 @@ import {
14
14
  applySuggestions,
15
15
  revertSuggestions,
16
16
  suggestChanges,
17
- } from "@blocknote/prosemirror-suggest-changes";
17
+ } from "@handlewithcare/prosemirror-suggest-changes";
18
18
  import { UIMessage } from "ai";
19
19
  import { Fragment, Slice } from "prosemirror-model";
20
20
  import { Plugin, PluginKey } from "prosemirror-state";
@@ -75,6 +75,10 @@ export const AIExtension = createExtension(
75
75
  | undefined;
76
76
  let autoScroll = false;
77
77
 
78
+ const suggestChangesPlugin = suggestChanges();
79
+ // disable decorations for suggest changes, not needed
80
+ // (and the pilcrows are ugly)
81
+ suggestChangesPlugin.props.decorations = undefined;
78
82
  return {
79
83
  key: "ai",
80
84
  options,
@@ -129,7 +133,7 @@ export const AIExtension = createExtension(
129
133
  return true;
130
134
  },
131
135
  }),
132
- suggestChanges(),
136
+ suggestChangesPlugin,
133
137
  createAgentCursorPlugin(
134
138
  editorOptions?.agentCursor || { name: "AI", color: "#8bc6ff" },
135
139
  ),
@@ -1,5 +1,5 @@
1
1
  import { BlockNoteEditor } from "@blocknote/core";
2
- import { applySuggestions } from "@blocknote/prosemirror-suggest-changes";
2
+ import { applySuggestions } from "@handlewithcare/prosemirror-suggest-changes";
3
3
  import { Transaction } from "prosemirror-state";
4
4
  import { Transform } from "prosemirror-transform";
5
5
 
@@ -29,6 +29,7 @@ export async function* filterValidOperations<T>(
29
29
  let forceNewOperation = false;
30
30
  for await (const chunk of operationsStream) {
31
31
  const operation = chunk.operation;
32
+
32
33
  if (operation.ok) {
33
34
  yield {
34
35
  operation: operation.value,
@@ -1,10 +1,7 @@
1
1
  import { BlockNoteEditor } from "@blocknote/core";
2
2
  import { beforeEach, describe, expect, it } from "vitest";
3
3
  import { tools } from "../api/formats/json/tools/index.js";
4
- import {
5
- preprocessOperationsNonStreaming,
6
- preprocessOperationsStreaming,
7
- } from "./preprocess.js";
4
+ import { preprocessOperationsStreaming } from "./preprocess.js";
8
5
  import { StreamTool } from "./streamTool.js";
9
6
 
10
7
  const addOperationValid = {
@@ -148,68 +145,37 @@ describe("preprocess", () => {
148
145
  });
149
146
  });
150
147
 
151
- describe("preprocessOperationsNonStreaming", () => {
152
- it("should pass valid operations", async () => {
153
- async function* mockStream() {
154
- yield {
155
- partialOperation: addOperationValid,
156
- isUpdateToPreviousOperation: false,
157
- isPossiblyPartial: false,
158
- metadata: undefined,
159
- };
160
- }
161
-
162
- const results = await collectStreamToArray(
163
- preprocessOperationsNonStreaming(mockStream(), streamTools),
164
- );
165
-
166
- expect(results.length).toBe(1);
167
- });
168
-
169
- it("should throw an error on invalid operations (invalid id)", async () => {
170
- async function* mockStream() {
171
- yield {
172
- partialOperation: addOperationInvalidId,
173
- isUpdateToPreviousOperation: false,
174
- isPossiblyPartial: false,
175
- metadata: undefined,
176
- };
177
- }
178
-
179
- await expect(
180
- collectStreamToArray(
181
- preprocessOperationsNonStreaming(mockStream(), streamTools),
182
- ),
183
- ).rejects.toThrow();
184
- });
185
-
186
- it("should throw an error on invalid operations (invalid type)", async () => {
187
- async function* mockStream() {
188
- yield {
189
- partialOperation: invalidOperationType,
190
- isUpdateToPreviousOperation: false,
191
- isPossiblyPartial: false,
192
- metadata: undefined,
193
- };
194
- }
195
-
196
- await expect(
197
- collectStreamToArray(
198
- preprocessOperationsNonStreaming(mockStream(), streamTools),
199
- ),
200
- ).rejects.toThrow();
201
- });
202
-
203
- it("should handle empty operation streams", async () => {
204
- async function* mockStream() {
205
- // Empty stream
206
- }
207
-
208
- const results = await collectStreamToArray(
209
- preprocessOperationsNonStreaming(mockStream(), streamTools),
210
- );
148
+ it("should throw an error on invalid operations (invalid id)", async () => {
149
+ async function* mockStream() {
150
+ yield {
151
+ partialOperation: addOperationInvalidId,
152
+ isUpdateToPreviousOperation: false,
153
+ isPossiblyPartial: false,
154
+ metadata: undefined,
155
+ };
156
+ }
157
+
158
+ await expect(
159
+ collectStreamToArray(
160
+ preprocessOperationsStreaming(mockStream(), streamTools),
161
+ ),
162
+ ).rejects.toThrow();
163
+ });
211
164
 
212
- expect(results).toHaveLength(0);
213
- });
165
+ it("should throw an error on invalid operations (invalid type)", async () => {
166
+ async function* mockStream() {
167
+ yield {
168
+ partialOperation: invalidOperationType,
169
+ isUpdateToPreviousOperation: false,
170
+ isPossiblyPartial: false,
171
+ metadata: undefined,
172
+ };
173
+ }
174
+
175
+ await expect(
176
+ collectStreamToArray(
177
+ preprocessOperationsStreaming(mockStream(), streamTools),
178
+ ),
179
+ ).rejects.toThrow();
214
180
  });
215
181
  });
@@ -1,3 +1,4 @@
1
+ import { getErrorMessage } from "@ai-sdk/provider-utils";
1
2
  import { ChunkExecutionError } from "./ChunkExecutionError.js";
2
3
  import { filterValidOperations } from "./filterValidOperations.js";
3
4
  import { StreamTool, StreamToolCall } from "./streamTool.js";
@@ -36,47 +37,16 @@ export async function* preprocessOperationsStreaming<
36
37
  (chunk) => {
37
38
  if (!chunk.isPossiblyPartial) {
38
39
  // only throw if the operation is not possibly partial
39
-
40
- throw new ChunkExecutionError("invalid operation: " + chunk.operation.error, chunk);
40
+ throw new ChunkExecutionError(
41
+ `Invalid operation. ${getErrorMessage(chunk.operation.error)}`,
42
+ chunk,
43
+ {
44
+ cause: chunk.operation.error,
45
+ },
46
+ );
41
47
  }
42
48
  },
43
49
  );
44
50
 
45
51
  yield* validOperationsStream;
46
52
  }
47
-
48
- /**
49
- * Validates an stream of operations and throws an error if an invalid operation is found.
50
- *
51
- * TODO: remove
52
- *
53
- * @deprecated
54
- */
55
- export async function* preprocessOperationsNonStreaming<
56
- T extends StreamTool<any>[],
57
- >(
58
- operationsStream: AsyncIterable<{
59
- partialOperation: any;
60
- isUpdateToPreviousOperation: boolean;
61
- isPossiblyPartial: boolean;
62
- metadata: any;
63
- }>,
64
- streamTools: T,
65
- ): AsyncGenerator<PreprocessOperationResult<T>> {
66
- // from partial operations to valid / invalid operations
67
- const validatedOperationsStream = toValidatedOperations(
68
- operationsStream,
69
- streamTools,
70
- );
71
-
72
- // filter valid operations, invalid operations should throw an error
73
- const validOperationsStream = filterValidOperations(
74
- validatedOperationsStream,
75
- (chunk) => {
76
- throw new Error("invalid operation: " + chunk.operation.error);
77
- },
78
- );
79
-
80
- // yield results
81
- yield* validOperationsStream;
82
- }
@@ -22,6 +22,18 @@ export async function* toValidatedOperations<T extends StreamTool<any>[]>(
22
22
  metadata: any;
23
23
  }> {
24
24
  for await (const chunk of partialObjectStream) {
25
+ if (!chunk.partialOperation.type) {
26
+ yield {
27
+ operation: {
28
+ ok: false,
29
+ error: "The `type` property of an operation is required.",
30
+ },
31
+ isUpdateToPreviousOperation: chunk.isUpdateToPreviousOperation,
32
+ isPossiblyPartial: chunk.isPossiblyPartial,
33
+ metadata: chunk.metadata,
34
+ };
35
+ continue;
36
+ }
25
37
  const func = streamTools.find(
26
38
  (f) => f.name === chunk.partialOperation.type,
27
39
  )!;
@@ -129,6 +129,8 @@ export async function setupToolCallStreaming(
129
129
 
130
130
  if (result.status === "rejected") {
131
131
  if (result.reason instanceof ChunkExecutionError) {
132
+ // all errors thrown in the pipeline should be ChunkExecutionErrors,
133
+ // so we can retrieve the chunk that caused the error
132
134
  error = result.reason;
133
135
  } else {
134
136
  if (!chat.error) {
@@ -1,5 +1,5 @@
1
1
  import { BlockNoteEditor } from "@blocknote/core";
2
- import { revertSuggestions } from "@blocknote/prosemirror-suggest-changes";
2
+ import { revertSuggestions } from "@handlewithcare/prosemirror-suggest-changes";
3
3
  import { Node } from "prosemirror-model";
4
4
  import { expect } from "vitest";
5
5
 
@@ -14,16 +14,3 @@ export declare function preprocessOperationsStreaming<T extends StreamTool<any>[
14
14
  isPossiblyPartial: boolean;
15
15
  metadata: any;
16
16
  }>, streamTools: T): AsyncGenerator<PreprocessOperationResult<T>>;
17
- /**
18
- * Validates an stream of operations and throws an error if an invalid operation is found.
19
- *
20
- * TODO: remove
21
- *
22
- * @deprecated
23
- */
24
- export declare function preprocessOperationsNonStreaming<T extends StreamTool<any>[]>(operationsStream: AsyncIterable<{
25
- partialOperation: any;
26
- isUpdateToPreviousOperation: boolean;
27
- isPossiblyPartial: boolean;
28
- metadata: any;
29
- }>, streamTools: T): AsyncGenerator<PreprocessOperationResult<T>>;