@blocknote/xl-ai 0.51.3 → 0.52.0
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.
- package/dist/blocknote-xl-ai.cjs +1 -1
- package/dist/blocknote-xl-ai.cjs.map +1 -1
- package/dist/blocknote-xl-ai.js +503 -107
- package/dist/blocknote-xl-ai.js.map +1 -1
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js.map +1 -1
- package/dist/{server-JIYg7ELG.js → server-CafGbRLa.js} +35 -31
- package/dist/server-CafGbRLa.js.map +1 -0
- package/dist/server-CxZHspeS.cjs +36 -0
- package/dist/server-CxZHspeS.cjs.map +1 -0
- package/dist/server.cjs +1 -1
- package/dist/server.js +1 -2
- package/dist/style.css +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +12 -25
- package/src/AIExtension.ts +12 -7
- package/src/api/formats/base-tools/createAddBlocksTool.ts +4 -4
- package/src/api/formats/base-tools/createUpdateBlockTool.ts +4 -4
- package/src/api/formats/html-blocks/columnContainerDocumentState.test.ts +1 -1
- package/src/api/formats/html-blocks/htmlBlocks.test.ts +6 -8
- package/src/api/formats/html-blocks/tools/getPartialHTML.test.ts +1 -1
- package/src/api/formats/html-blocks/tools/index.ts +15 -21
- package/src/api/formats/html-blocks/tools/rebaseTool.ts +3 -3
- package/src/api/formats/json/errorHandling.test.ts +8 -1
- package/src/api/formats/json/json.test.ts +1 -1
- package/src/api/formats/json/tools/index.ts +4 -4
- package/src/api/formats/json/tools/jsontools.test.ts +1 -1
- package/src/api/formats/markdown-blocks/markdownBlocks.test.ts +1 -1
- package/src/api/formats/markdown-blocks/tools/index.ts +9 -11
- package/src/api/formats/markdown-blocks/tools/rebaseTool.ts +3 -3
- package/src/api/formats/tests/sharedTestCases.ts +2 -3
- package/src/api/formats/tests/snapshotPath.ts +2 -2
- package/src/api/formats/tests/validateTestEnvironment.test.ts +1 -1
- package/src/api/promptHelpers/suffixIds.ts +1 -1
- package/src/api/schema/__snapshots__/schemaToJSONSchema.test.ts.snap +1 -1
- package/src/api/schema/schemaToJSONSchema.test.ts +3 -3
- package/src/api/schema/schemaToJSONSchema.ts +5 -3
- package/src/components/AIMenu/AIMenuController.tsx +1 -1
- package/src/components/AIMenu/PromptSuggestionMenu.tsx +1 -1
- package/src/plugins/AgentCursorPlugin.ts +8 -1
- package/src/prosemirror/AttributionMarks.ts +204 -0
- package/src/prosemirror/__snapshots__/agent.test.ts.snap +16 -265
- package/src/prosemirror/__snapshots__/rebaseTool.test.ts.snap +4 -4
- package/src/prosemirror/agent.test.ts +8 -10
- package/src/prosemirror/agent.ts +1 -1
- package/src/prosemirror/changeset.test.ts +1 -1
- package/src/prosemirror/fragmentUtil.test.ts +1 -1
- package/src/prosemirror/rebaseTool.test.ts +8 -3
- package/src/server.ts +0 -1
- package/src/streamTool/filterNewOrUpdatedOperations.test.ts +1 -1
- package/src/streamTool/filterValidOperations.test.ts +1 -1
- package/src/streamTool/preprocess.test.ts +1 -1
- package/src/streamTool/toValidatedOperations.test.ts +1 -1
- package/src/streamTool/vercelAiSdk/clientside/ClientSideTransport.ts +8 -5
- package/src/streamTool/vercelAiSdk/util/appendableStream.test.ts +15 -15
- package/src/streamTool/vercelAiSdk/util/chatHandlers.test.ts +10 -1
- package/src/streamTool/vercelAiSdk/util/chatHandlers.ts +7 -7
- package/src/style.css +0 -19
- package/src/testUtil/suggestChangesTestUtil.ts +1 -1
- package/src/util/stream.ts +1 -1
- package/src/vite-env.d.ts +1 -0
- package/types/src/AIExtension.d.ts +4 -0
- package/types/src/api/formats/base-tools/createAddBlocksTool.d.ts +2 -2
- package/types/src/api/formats/base-tools/createUpdateBlockTool.d.ts +2 -2
- package/types/src/api/formats/formats.d.ts +3 -3
- package/types/src/api/formats/html-blocks/tools/rebaseTool.d.ts +2 -2
- package/types/src/api/formats/json/json.d.ts +3 -3
- package/types/src/api/formats/markdown-blocks/tools/rebaseTool.d.ts +2 -2
- package/types/src/api/schema/schemaToJSONSchema.d.ts +3 -3
- package/types/src/prosemirror/AttributionMarks.d.ts +15 -0
- package/types/src/testUtil/cases/editors/blockFormatting.d.ts +17 -17
- package/types/src/testUtil/cases/editors/formattingAndMentions.d.ts +17 -17
- package/types/src/testUtil/cases/editors/simpleEditor.d.ts +51 -51
- package/types/src/testUtil/cases/editors/tables.d.ts +17 -17
- package/types/src/testUtil/cases/schemas/mention.d.ts +17 -17
- package/dist/server-D-Xyj9BS.cjs +0 -36
- package/dist/server-D-Xyj9BS.cjs.map +0 -1
- package/dist/server-JIYg7ELG.js.map +0 -1
|
@@ -97,11 +97,14 @@ function le(e) {
|
|
|
97
97
|
//#endregion
|
|
98
98
|
//#region src/streamTool/ChunkExecutionError.ts
|
|
99
99
|
var D = class extends Error {
|
|
100
|
+
chunk;
|
|
100
101
|
aborted;
|
|
101
102
|
constructor(e, t, n) {
|
|
102
103
|
super(e, n), this.chunk = t, this.name = "ChunkExecutionError", this.aborted = n?.aborted ?? !1;
|
|
103
104
|
}
|
|
104
105
|
}, ue = class {
|
|
106
|
+
streamTools;
|
|
107
|
+
abortSignal;
|
|
105
108
|
stream;
|
|
106
109
|
constructor(e, t) {
|
|
107
110
|
this.streamTools = e, this.abortSignal = t, this.stream = this.createStream();
|
|
@@ -259,6 +262,7 @@ function he(e) {
|
|
|
259
262
|
return O[e.provider] || {};
|
|
260
263
|
}
|
|
261
264
|
var ge = class {
|
|
265
|
+
opts;
|
|
262
266
|
constructor(e) {
|
|
263
267
|
this.opts = e;
|
|
264
268
|
}
|
|
@@ -271,10 +275,10 @@ var ge = class {
|
|
|
271
275
|
tools: t,
|
|
272
276
|
toolChoice: "required",
|
|
273
277
|
...r ?? {}
|
|
274
|
-
}).toUIMessageStream();
|
|
278
|
+
}).toUIMessageStream({ onError: (e) => e instanceof Error ? e.message : String(e) });
|
|
275
279
|
}
|
|
276
280
|
async sendMessages({ messages: e, body: t }) {
|
|
277
|
-
let n = this.opts.stream ?? !0, r = t.toolDefinitions, i =
|
|
281
|
+
let n = this.opts.stream ?? !0, r = t.toolDefinitions, i = me(r);
|
|
278
282
|
if (n) return await this.streamText(e, i);
|
|
279
283
|
throw Error("Not implemented (generateText)");
|
|
280
284
|
}
|
|
@@ -573,7 +577,7 @@ function P(e) {
|
|
|
573
577
|
function F(e) {
|
|
574
578
|
return e.map((e) => typeof e == "object" && e && "id" in e ? {
|
|
575
579
|
...e,
|
|
576
|
-
id: `${e.id}$`
|
|
580
|
+
id: `${String(e.id)}$`
|
|
577
581
|
} : e);
|
|
578
582
|
}
|
|
579
583
|
//#endregion
|
|
@@ -606,7 +610,7 @@ function Ae(e) {
|
|
|
606
610
|
//#endregion
|
|
607
611
|
//#region src/prosemirror/agent.ts
|
|
608
612
|
function L(e) {
|
|
609
|
-
let t = i(e),
|
|
613
|
+
let t = i(e), n = t.marks.modification, r = [], a = new S(e.before);
|
|
610
614
|
for (let i = 0; i < e.steps.length; i++) {
|
|
611
615
|
let o = e.steps[i], s = new re(e.mapping.maps.slice(0, i)).invert();
|
|
612
616
|
if (o.structure) {
|
|
@@ -898,7 +902,7 @@ function W(e) {
|
|
|
898
902
|
let r = [], i = {};
|
|
899
903
|
return { execute: async (o, s) => {
|
|
900
904
|
if (o.isUpdateToPreviousOperation || (r = []), o.operation.type !== "add") return !1;
|
|
901
|
-
let c = o.operation, l =
|
|
905
|
+
let c = o.operation, l = e.toJSONToolCall(t, {
|
|
902
906
|
...o,
|
|
903
907
|
operation: c
|
|
904
908
|
});
|
|
@@ -906,7 +910,7 @@ function W(e) {
|
|
|
906
910
|
for (let o = 0; o < l.blocks.length; o++) {
|
|
907
911
|
let u = l.blocks[o], d = t.prosemirrorState.tr, f = [];
|
|
908
912
|
if (o < r.length) {
|
|
909
|
-
let n =
|
|
913
|
+
let n = e.rebaseTool(r[o], t), i = V({
|
|
910
914
|
id: r[o],
|
|
911
915
|
block: u
|
|
912
916
|
}, n.doc, !1).map((e) => e.map(n.invertMap));
|
|
@@ -998,7 +1002,7 @@ function G(e) {
|
|
|
998
1002
|
if (e < r) return !0;
|
|
999
1003
|
r = e + 50;
|
|
1000
1004
|
} else r = 50;
|
|
1001
|
-
let c =
|
|
1005
|
+
let c = e.rebaseTool(s.id, t), l = i ? c.invertMap.invert().map(i.from()) : void 0, u = i ? c.invertMap.invert().map(i.to()) : void 0, d = e.toJSONToolCall(t, {
|
|
1002
1006
|
...a,
|
|
1003
1007
|
operation: s
|
|
1004
1008
|
});
|
|
@@ -1111,13 +1115,13 @@ function J(e, t) {
|
|
|
1111
1115
|
}
|
|
1112
1116
|
//#endregion
|
|
1113
1117
|
//#region src/api/formats/html-blocks/tools/rebaseTool.ts
|
|
1114
|
-
|
|
1118
|
+
function Pe(e, t) {
|
|
1115
1119
|
let r = q(t), i = n(r.doc, e);
|
|
1116
1120
|
if (!i) throw Error("block not found");
|
|
1117
|
-
let a =
|
|
1121
|
+
let a = t.blocksToHTMLLossy([{
|
|
1118
1122
|
...i,
|
|
1119
1123
|
children: []
|
|
1120
|
-
}]), o = window.__TEST_OPTIONS?.mockID, s =
|
|
1124
|
+
}]), o = window.__TEST_OPTIONS?.mockID, s = t.tryParseHTMLToBlocks(a);
|
|
1121
1125
|
if (window.__TEST_OPTIONS && (window.__TEST_OPTIONS.mockID = o), s.length !== 1) throw Error("html diff invalid block count");
|
|
1122
1126
|
let c = s[0];
|
|
1123
1127
|
if (c.id = e, V({
|
|
@@ -1151,11 +1155,11 @@ var Y = {
|
|
|
1151
1155
|
} },
|
|
1152
1156
|
validateBlock: Fe,
|
|
1153
1157
|
rebaseTool: Pe,
|
|
1154
|
-
toJSONToolCall:
|
|
1155
|
-
let n = window.__TEST_OPTIONS?.mockID, r =
|
|
1158
|
+
toJSONToolCall: (e, t) => {
|
|
1159
|
+
let n = window.__TEST_OPTIONS?.mockID, r = t.operation.blocks.flatMap((n) => {
|
|
1156
1160
|
let r = t.isPossiblyPartial ? Ne(n) : n;
|
|
1157
|
-
return r ?
|
|
1158
|
-
})
|
|
1161
|
+
return r ? e.tryParseHTMLToBlocks(r).map((e) => (delete e.id, e)) : [];
|
|
1162
|
+
});
|
|
1159
1163
|
if (window.__TEST_OPTIONS && (window.__TEST_OPTIONS.mockID = n), r.length !== 0) return {
|
|
1160
1164
|
...t.operation,
|
|
1161
1165
|
blocks: r
|
|
@@ -1170,10 +1174,10 @@ var Y = {
|
|
|
1170
1174
|
} },
|
|
1171
1175
|
validateBlock: Fe,
|
|
1172
1176
|
rebaseTool: Pe,
|
|
1173
|
-
toJSONToolCall:
|
|
1177
|
+
toJSONToolCall: (e, t) => {
|
|
1174
1178
|
let n = t.isPossiblyPartial ? Ne(t.operation.block) : t.operation.block;
|
|
1175
1179
|
if (!n) return;
|
|
1176
|
-
let r =
|
|
1180
|
+
let r = e.tryParseHTMLToBlocks(n)[0];
|
|
1177
1181
|
return window.__TEST_OPTIONS && (window.__TEST_OPTIONS.mockID = void 0), delete r.id, {
|
|
1178
1182
|
...t.operation,
|
|
1179
1183
|
block: r
|
|
@@ -1325,7 +1329,7 @@ function Ue(e) {
|
|
|
1325
1329
|
type: "string",
|
|
1326
1330
|
enum: [t.type]
|
|
1327
1331
|
},
|
|
1328
|
-
content: t.content === "inline" ? { $ref: "#/$defs/inlinecontent" } : t.content === "table" ? {
|
|
1332
|
+
content: t.content === "inline" ? { $ref: "#/$defs/inlinecontent" } : t.content === "plain" ? { type: "string" } : t.content === "table" ? {
|
|
1329
1333
|
type: "object",
|
|
1330
1334
|
properties: {}
|
|
1331
1335
|
} : void 0,
|
|
@@ -1413,8 +1417,8 @@ var Z = {
|
|
|
1413
1417
|
...X(e.schema)
|
|
1414
1418
|
}),
|
|
1415
1419
|
validateBlock: Ke,
|
|
1416
|
-
rebaseTool:
|
|
1417
|
-
toJSONToolCall:
|
|
1420
|
+
rebaseTool: (e, t) => J(t, q(t)),
|
|
1421
|
+
toJSONToolCall: (e, t) => t.operation
|
|
1418
1422
|
}),
|
|
1419
1423
|
update: G({
|
|
1420
1424
|
description: "Update a block, the new block will replace the existing block.",
|
|
@@ -1423,8 +1427,8 @@ var Z = {
|
|
|
1423
1427
|
...X(e.schema)
|
|
1424
1428
|
}),
|
|
1425
1429
|
validateBlock: Ke,
|
|
1426
|
-
rebaseTool:
|
|
1427
|
-
toJSONToolCall:
|
|
1430
|
+
rebaseTool: (e, t) => J(t, q(t)),
|
|
1431
|
+
toJSONToolCall: (e, n) => {
|
|
1428
1432
|
let r = Object.fromEntries(Object.entries(t).map(([e, t]) => [e, t.default]));
|
|
1429
1433
|
return {
|
|
1430
1434
|
...n.operation,
|
|
@@ -1486,10 +1490,10 @@ var Je = {
|
|
|
1486
1490
|
};
|
|
1487
1491
|
//#endregion
|
|
1488
1492
|
//#region src/api/formats/markdown-blocks/tools/rebaseTool.ts
|
|
1489
|
-
|
|
1490
|
-
let r = q(t), i =
|
|
1493
|
+
function Ye(e, t) {
|
|
1494
|
+
let r = q(t), i = t.blocksToMarkdownLossy([n(r.doc, e)]), a = V({
|
|
1491
1495
|
id: e,
|
|
1492
|
-
block:
|
|
1496
|
+
block: t.tryParseMarkdownToBlocks(i)[0]
|
|
1493
1497
|
}, r.doc), o = new re();
|
|
1494
1498
|
for (let e of a) {
|
|
1495
1499
|
let t = e.map(o);
|
|
@@ -1523,11 +1527,11 @@ var Q = {
|
|
|
1523
1527
|
},
|
|
1524
1528
|
validateBlock: Xe,
|
|
1525
1529
|
rebaseTool: Ye,
|
|
1526
|
-
toJSONToolCall:
|
|
1527
|
-
let n =
|
|
1528
|
-
let n =
|
|
1530
|
+
toJSONToolCall: (e, t) => {
|
|
1531
|
+
let n = t.operation.blocks.map((t) => {
|
|
1532
|
+
let n = e.tryParseMarkdownToBlocks(t.trim())[0];
|
|
1529
1533
|
return delete n.id, n;
|
|
1530
|
-
})
|
|
1534
|
+
});
|
|
1531
1535
|
return window.__TEST_OPTIONS && (window.__TEST_OPTIONS.mockID = void 0), {
|
|
1532
1536
|
...t.operation,
|
|
1533
1537
|
blocks: n
|
|
@@ -1545,8 +1549,8 @@ var Q = {
|
|
|
1545
1549
|
},
|
|
1546
1550
|
validateBlock: Xe,
|
|
1547
1551
|
rebaseTool: Ye,
|
|
1548
|
-
toJSONToolCall:
|
|
1549
|
-
let n =
|
|
1552
|
+
toJSONToolCall: (e, t) => {
|
|
1553
|
+
let n = e.tryParseMarkdownToBlocks(t.operation.block.trim())[0];
|
|
1550
1554
|
return delete n.id, window.__TEST_OPTIONS && (window.__TEST_OPTIONS.mockID = void 0), {
|
|
1551
1555
|
...t.operation,
|
|
1552
1556
|
block: n
|
|
@@ -1627,4 +1631,4 @@ var et = (e) => async (t, n) => {
|
|
|
1627
1631
|
//#endregion
|
|
1628
1632
|
export { E as _, q as a, j as c, O as d, he as f, ue as g, fe as h, $ as i, A as l, pe as m, $e as n, I as o, me as p, Qe as r, De as s, et as t, ge as u, le as v, se as y };
|
|
1629
1633
|
|
|
1630
|
-
//# sourceMappingURL=server-
|
|
1634
|
+
//# sourceMappingURL=server-CafGbRLa.js.map
|