@blocknote/xl-ai 0.47.3 → 0.48.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 +2 -2
- package/dist/blocknote-xl-ai.cjs.map +1 -1
- package/dist/blocknote-xl-ai.js +573 -925
- package/dist/blocknote-xl-ai.js.map +1 -1
- package/dist/locales.cjs +2 -2
- package/dist/locales.cjs.map +1 -1
- package/dist/locales.js +1593 -1486
- package/dist/locales.js.map +1 -1
- package/dist/server-Ct45EOTu.cjs +36 -0
- package/dist/server-Ct45EOTu.cjs.map +1 -0
- package/dist/server-JIYg7ELG.js +1630 -0
- package/dist/server-JIYg7ELG.js.map +1 -0
- package/dist/server.cjs +1 -2
- package/dist/server.js +3 -23
- package/dist/style.css +2 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +11 -11
- package/src/api/formats/tests/sharedTestCases.ts +3 -3
- package/src/prosemirror/rebaseTool.ts +1 -1
- package/dist/client-BPNTLm1-.cjs +0 -36
- package/dist/client-BPNTLm1-.cjs.map +0 -1
- package/dist/client-DHVeP6Er.js +0 -2149
- package/dist/client-DHVeP6Er.js.map +0 -1
- package/dist/server.cjs.map +0 -1
- package/dist/server.js.map +0 -1
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{Add heading (h1) and code block_1_21c6ffe4ff4bd18e2a782b926b61618c.json → Add heading (h1) and code block_1_144961d511efe7e04c44ff79ecabf43e.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{add a list (end)_1_d0219ee443d8f6d3563dcffcba160730.json → add a list (end)_1_ca20c0b56ff3bdfe67f76b3e1b3c82bc.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{add a new paragraph (empty doc)_1_0737d0ae03c2d0adf101da14bdef2414.json → add a new paragraph (empty doc)_1_509f796014e0dae8a4a50e1aaab8a378.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{add a new paragraph (end)_1_25717cdb5e0dabfd9e85a28126fc6b5b.json → add a new paragraph (end)_1_f4419c510915474907ca2fb35f92d2b8.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{add a new paragraph (start)_1_8fc8e14082d21bf98623cd9ef57bafff.json → add a new paragraph (start)_1_3426f436a5b272f3b8e26edcec43fdae.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{Add heading (h1) and code block_1_72b3fb10d4b64ad2c57b7e759fb45ea2.json → Add heading (h1) and code block_1_3f0b847de3745c61a82e3a9728770d4d.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{add a list (end)_1_6330fcc2bc48733981e5337c6f38fe08.json → add a list (end)_1_680d0a41316e174365d11814e9df7fda.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{add a new paragraph (empty doc)_1_1df3fb78a5790897b37bfba0ae96be1e.json → add a new paragraph (empty doc)_1_3f2fffcfa733575ca2a6c4f9d1a8f615.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{add a new paragraph (end)_1_13ac6e523b724ec3d4e4113c1f973f7d.json → add a new paragraph (end)_1_04b2bff7b39bfda09c5d3f116cbb53b9.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{add a new paragraph (start)_1_c7a2f3226a4ee862c75a049c92cea98f.json → add a new paragraph (start)_1_45ec5a1e5fa6757f02843c8803e7a334.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{Add heading (h1) and code block_1_a10f3f8e8e6d938c54950352eae2f50f.json → Add heading (h1) and code block_1_ece60088a9ecb6767d83b6584bbec6d9.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{add a list (end)_1_b0a300b9716085d9bfa169d8085d10b7.json → add a list (end)_1_64e60c0c2add32fbfe1da823b8c7990a.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{add a new paragraph (empty doc)_1_9d4f54665e392006af18af614d32e632.json → add a new paragraph (empty doc)_1_100f09592ece8a32c33dff2dc612c649.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{add a new paragraph (end)_1_d862f2761b7f6594f4b571c7f8291820.json → add a new paragraph (end)_1_a2a9884926fbc5218a3f00c9952cefd5.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{add a new paragraph (start)_1_94759353bbdb9e30152eb0164488ba89.json → add a new paragraph (start)_1_c85bbb5cec5410289d652e15b2df6fa3.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{add and update paragraph_1_2dbe9e9945d6cabc0b02e812a6ba1b93.json → add and update paragraph_1_380a0c02b5089b38247457135c044cf7.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{add paragraph and update selection_1_ed2eea810db5ab73a8478e981735f2a6.json → add paragraph and update selection_1_298b51bb28c5f95ab9a00205d4e38460.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{add and update paragraph_1_7a6f24c686aeb896da8088bd8ea14089.json → add and update paragraph_1_f6253c11196abdbeae0f898cc9df85eb.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{add paragraph and update selection_1_9d907341d7a5b18529ccaf20cacbbe6f.json → add paragraph and update selection_1_dc29d735348684d1ec3e290ad8c03a71.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{add and update paragraph_1_a562a7fd96440f9bfac43e04c1bf144a.json → add and update paragraph_1_a27ae10badcc3913a00eb86f77ac64db.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{add paragraph and update selection_1_6bb242aace6ad9ae71bcb369ce8208d4.json → add paragraph and update selection_1_86f10ca461ee44e74ae571fb9f214338.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Delete/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{delete first block_1_71dfbd70fa9bcd8c2378c0b255360279.json → delete first block_1_91346200727a71ab9ad8c5d014835688.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Delete/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{delete first block_1_72e05e8a661b9149b89f8ca9a80a2129.json → delete first block_1_150a539024aa981c9f6bcb068875a6c9.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Delete/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{delete first block_1_f51e5c59768fde7bccc5635d90890452.json → delete first block_1_1b3c4ac85d448677697457098332ceba.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{clear block formatting_1_f3ecead131eac14f117b601ad92bae90.json → clear block formatting_1_fc858b37cc10ed7b65802375977eaf7a.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{drop mark and link and change text within mark_1_6b686110fa540e40d81fd68ee23cde86.json → drop mark and link and change text within mark_1_fe3cac9da9d1e17a20ee8c0c4380d925.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{drop mark and link_1_fee0a33a7c0951dacc8fd9ba02adef0a.json → drop mark and link_1_f6ee881e6d3b4cd9553256523e67683a.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{fix spelling mid-word selection_1_ce6692c22eda2a757e123681118a333d.json → fix spelling mid-word selection_1_360f2cf4db48ef5b92c8e24ed0998167.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{modify nested content_1_1d18b29fde3a6494f2d1df98d0689bcf.json → modify nested content_1_a57d7364de9ba3d72686aca4f3c424e4.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{modify parent content_1_7d96675c4edc13f69084f42983de6d73.json → modify parent content_1_5f7043c9275e742ea47f92b66e65a845.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{plain source block, add mention_1_785d7f53424b53e8b64f4732aa578c61.json → plain source block, add mention_1_ccd752aefdbc2252a5a09bebac393afb.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{standard update_1_c01c22b2bf79f30908ce9ffb0798a79f.json → standard update_1_c44a31a1631a3a10efcd5e17645998f1.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{styles + ic in source block, remove mark_1_66f540dda8b5f8e8713b9c6f0bdd4d3f.json → styles + ic in source block, remove mark_1_df177a6a4f26b0fbcba307c6d21cab76.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{styles + ic in source block, remove mention_1_9111f9b26383721d9186c99d035f44e8.json → styles + ic in source block, remove mention_1_4ba9f3411694f807e85e8e33f4b3c8cd.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{styles + ic in source block, replace content_1_6a2c68962725ab2dc43dc12b5e9e5d8f.json → styles + ic in source block, replace content_1_f5b001d0f8415a00e8b043f3e3e33535.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{styles + ic in source block, update mention prop_1_60f48a7bd81fb6a72b96b284d61c6e53.json → styles + ic in source block, update mention prop_1_c197e3f5ce1dbc1a68765acbd198881a.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{styles + ic in source block, update text_1_284f982ebe3b60bc15c674d63795a879.json → styles + ic in source block, update text_1_a0b93418bb2a5c0049e0a5c896f72191.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{styles + ic in target block, add mark (paragraph)_1_6c8e4ac91518d57e4827481f00ddc38e.json → styles + ic in target block, add mark (paragraph)_1_fb2285b8d362cb8adcf78f6039ad3058.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{styles + ic in target block, add mark (word)_1_06f3ae0ab5b505f03cf8e0c6bd654b1e.json → styles + ic in target block, add mark (word)_1_e0087b91327576eaff9f8d4d368e0a03.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{translate selection_1_1ad7d1a857e525e2d0f5a8c85b645a0e.json → translate selection_1_4706b49daa5ad7afe9dfadded2e335c5.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{turn paragraphs into list_1_0e8f14f06679e951d88ec74919c24b90.json → turn paragraphs into list_1_a3ce79b4f32d1dd6ac04dbe6b69e187b.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{update block prop and content_1_f6c1cfee51cd75204495d3db1d80350e.json → update block prop and content_1_5bb684c9ae46815b5367a39bd42d5257.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{update block prop_1_759983067f25f0daafb42bc9fefcdb64.json → update block prop_1_8469a78802d46f3d9ec74dd1fbf49fd8.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{update block type and content_1_e9d9d699bbe4a3b6e754c530ffe56e2c.json → update block type and content_1_226cc5d7352c8c7e58a15d064543518c.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (streaming)/{update block type_1_ac405ec31a0cb874515b0c5b6aa2eb2d.json → update block type_1_c4cc00889532e0baa73998da5e79c303.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{clear block formatting_1_1b60a2dae45a21cc2916e15e97bfd289.json → clear block formatting_1_6c08229db90214b8a20b0d7dfefb2824.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{drop mark and link and change text within mark_1_a7e99401a3cc86c79b30fdf47b0dc28e.json → drop mark and link and change text within mark_1_e5c77f0f881e77f6ee27a25f203ffdcb.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{drop mark and link_1_75e458d048de9ef0fb1eef34109ec81b.json → drop mark and link_1_b93576392cb38dc57acd85f7fc55c6cd.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{fix spelling mid-word selection_1_8c47595610a6a2d15e1c5c751528e97a.json → fix spelling mid-word selection_1_9c19d479f2d356a48480d5ec5e384229.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{modify nested content_1_f81acd3a9fb46c387163c91724ec4c55.json → modify nested content_1_f42fc26924afc557d18ef6696f36a8fa.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{modify parent content_1_49c9371e221a7966cac554b99ba56b02.json → modify parent content_1_e8424752b43fa146d8575a475924de52.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{plain source block, add mention_1_b2be33e4a07122a85e49b521c20f26db.json → plain source block, add mention_1_b18afae076d7f7f423477f1e1bc5813a.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{standard update_1_08d79a078de070c800627c412f9a0d9f.json → standard update_1_529e09ae665507a31316cb632f5cabcd.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{styles + ic in source block, remove mark_1_0d87ce48c7e9e690bde7fc3668fe735b.json → styles + ic in source block, remove mark_1_20036398e12cf4a20b50024ad5f30018.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{styles + ic in source block, remove mention_1_a96e84a734674ca195c2b40bab34c2fa.json → styles + ic in source block, remove mention_1_ed131f0383e7709a4e5fae2df28af29a.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{styles + ic in source block, replace content_1_f5be35337d2ac3c65ec6363d4f347364.json → styles + ic in source block, replace content_1_51bfdc443e43bbf18599fcc3a16c5683.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{styles + ic in source block, update mention prop_1_a09c043f6d105b1496a7c79ce34e28d3.json → styles + ic in source block, update mention prop_1_7641f5691799d2666855c113b6659b71.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{styles + ic in source block, update text_1_dfc536ede5303a75993dea08764b318e.json → styles + ic in source block, update text_1_8fcb24a91437026c480205de77507871.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{styles + ic in target block, add mark (paragraph)_1_ebbeca51137a25dc54cdb7bafab53bed.json → styles + ic in target block, add mark (paragraph)_1_be126322b804c53145dbd35a6aa1131f.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{styles + ic in target block, add mark (word)_1_d6f14d8cecee690c72107e57eee0efbf.json → styles + ic in target block, add mark (word)_1_ec13a3b1d4f97b79148833b507295ffa.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{translate selection_1_59b3c2f2328276dc62dad98af951d63c.json → translate selection_1_f1a2ffb178b441d40625b8f110e3290f.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{turn paragraphs into list_1_50b1aa228a2b2557dea5026daaef2fad.json → turn paragraphs into list_1_8367ba81813ffe9d2d17f2de266f3039.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{update block prop and content_1_4a65e945b3b6fac5d4a0cf8d623486d3.json → update block prop and content_1_8557c5a4249c324adfff5d243645e3de.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{update block prop_1_83a73dcfd05a6cf6754e1eb24114c1f1.json → update block prop_1_16dda1caa1f43ab624eb28a605179dd3.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{update block type and content_1_7500fd44498888e45aedc9dfa669737c.json → update block type and content_1_8b167672c96bf3c69b9b146eb4f26451.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/{update block type_1_92eb84e55a7b9efe5daf52bef299b4a6.json → update block type_1_7326b3d0db43c8f399aba2bc44c80194.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{clear block formatting_1_21bbf793e092bd207656f933b2274b21.json → clear block formatting_1_651c2e0b4f940c6cece61513462d2ddd.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{drop mark and link and change text within mark_1_70261ec295eec99f6b835af3371749ef.json → drop mark and link and change text within mark_1_94f36faff958747b5d66a185e268bba7.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{drop mark and link_1_45e52fc97822fb0e7573a6603137ab4e.json → drop mark and link_1_60bf97139612cd25b1f99502383df8aa.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{fix spelling mid-word selection_1_74934d888aa5deba8c74b66c12d81443.json → fix spelling mid-word selection_1_db44da41b500c6883e215f2b6d013f58.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{modify nested content_1_bfd4f73138b34375f33d28b5ee48d971.json → modify nested content_1_f3a35d9120c6ff0e02a89548d8349363.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{modify parent content_1_df8380600ae416c0eb70034e41b59701.json → modify parent content_1_7205cf7ec3d86e8ebd9c555028c5db74.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{plain source block, add mention_1_4579057dabcbe2f9f73c9a329a99393d.json → plain source block, add mention_1_d5759fe9868f60a47538d31361c68b3c.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{standard update_1_ede2a6f5b9da689056b55d71d91434fe.json → standard update_1_f6a167a6ea376d70d84dd9aac6ac7bb3.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{styles + ic in source block, remove mark_1_a6d8c670d163bd0cf79a424c6a6054a0.json → styles + ic in source block, remove mark_1_990c696cfe9af87de056328060fd1f93.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{styles + ic in source block, remove mention_1_ea57e8c6df3c134fa91348e7b71e7a57.json → styles + ic in source block, remove mention_1_fd4deb4dce4d79ae14939fda71c510fd.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{styles + ic in source block, replace content_1_24429e5416bc371492edd73611cf3946.json → styles + ic in source block, replace content_1_6cd810cd03bff509578637fe27d13a92.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{styles + ic in source block, update mention prop_1_079714c774da28b17075269c1cdd1696.json → styles + ic in source block, update mention prop_1_f0e30d1d6cbc94e6b7dcb8abb7e0221f.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{styles + ic in source block, update text_1_e0d8184c9829e07f8df2860248818bc8.json → styles + ic in source block, update text_1_1104dff815f18f8f786fb7d4e4522d47.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{styles + ic in target block, add mark (paragraph)_1_6b7d5cf6029aa5db5a9aaad9264795f8.json → styles + ic in target block, add mark (paragraph)_1_e2f4cdb3df42b17c74cd1d2d00d2f8d5.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{styles + ic in target block, add mark (word)_1_ffc7b82f1fb9de2ffacf16dda33c09eb.json → styles + ic in target block, add mark (word)_1_6b5073ce92485be7974a344d50247b4a.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{translate selection_1_b8200b55589e761efded3c08e8709a53.json → translate selection_1_d343e10867cc7b3d9850847c99826b61.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{turn paragraphs into list_1_30410f1a45a0de453f68c27fa57dded9.json → turn paragraphs into list_1_3373025fd96315ed15342f3a3a727771.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{update block prop and content_1_2184f0d7adf54cebd8f2068b93783d8b.json → update block prop and content_1_780bfe04d42dd48e9115cba7c4582c01.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{update block prop_1_56a595216306ecbe9557436eabd778b1.json → update block prop_1_667c03220ba6e678d0c91b9de092484b.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{update block type and content_1_894e0e3aa3fe005922264627bab288ea.json → update block type and content_1_f3c6521f6f12dc50dc16d0bbc277a858.json} +0 -0
- /package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming)/{update block type_1_0bf2510ac3023bb1a62d991c85655cba.json → update block type_1_7c4fbdcabcec0568ade27d2b47afbaab.json} +0 -0
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.
|
|
14
|
+
"version": "0.48.0",
|
|
15
15
|
"files": [
|
|
16
16
|
"dist",
|
|
17
17
|
"types",
|
|
@@ -63,9 +63,9 @@
|
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@ai-sdk/provider-utils": "^4.0.2",
|
|
65
65
|
"@ai-sdk/react": "^3.0.5",
|
|
66
|
-
"@blocknote/core": "0.
|
|
67
|
-
"@blocknote/mantine": "0.
|
|
68
|
-
"@blocknote/react": "0.
|
|
66
|
+
"@blocknote/core": "0.48.0",
|
|
67
|
+
"@blocknote/mantine": "0.48.0",
|
|
68
|
+
"@blocknote/react": "0.48.0",
|
|
69
69
|
"@floating-ui/react": "^0.27.18",
|
|
70
70
|
"@handlewithcare/prosemirror-suggest-changes": "^0.1.8",
|
|
71
71
|
"@tiptap/core": "^3.13.0",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"prosemirror-model": "^1.25.4",
|
|
77
77
|
"prosemirror-state": "^1.4.4",
|
|
78
78
|
"prosemirror-tables": "^1.8.3",
|
|
79
|
-
"prosemirror-transform": "^1.
|
|
79
|
+
"prosemirror-transform": "^1.11.0",
|
|
80
80
|
"prosemirror-view": "^1.41.4",
|
|
81
81
|
"react": "^19.2.3",
|
|
82
82
|
"react-dom": "^19.2.3",
|
|
@@ -101,8 +101,8 @@
|
|
|
101
101
|
"@types/lodash.merge": "^4.6.9",
|
|
102
102
|
"@types/react": "^19.2.3",
|
|
103
103
|
"@types/react-dom": "^19.2.3",
|
|
104
|
-
"@vitejs/plugin-react": "^
|
|
105
|
-
"@vitest/runner": "^
|
|
104
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
105
|
+
"@vitest/runner": "^4.1.2",
|
|
106
106
|
"eslint": "^8.57.1",
|
|
107
107
|
"glob": "^10.5.0",
|
|
108
108
|
"headers-polyfill": "^4.0.3",
|
|
@@ -112,10 +112,10 @@
|
|
|
112
112
|
"rollup-plugin-webpack-stats": "^0.2.6",
|
|
113
113
|
"typescript": "^5.9.3",
|
|
114
114
|
"undici": "^6.22.0",
|
|
115
|
-
"vite": "^
|
|
115
|
+
"vite": "^8.0.3",
|
|
116
116
|
"vite-plugin-eslint": "^1.8.1",
|
|
117
|
-
"vite-plugin-externalize-deps": "^0.
|
|
118
|
-
"vitest": "^
|
|
117
|
+
"vite-plugin-externalize-deps": "^0.10.0",
|
|
118
|
+
"vitest": "^4.1.2"
|
|
119
119
|
},
|
|
120
120
|
"peerDependencies": {
|
|
121
121
|
"react": "^18.0 || ^19.0 || >= 19.0.0-rc",
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
},
|
|
129
129
|
"scripts": {
|
|
130
130
|
"dev": "vite",
|
|
131
|
-
"build": "tsc
|
|
131
|
+
"build": "tsc && vite build",
|
|
132
132
|
"lint": "eslint src --max-warnings 0",
|
|
133
133
|
"test": "NODE_EXTRA_CA_CERTS=\"$(mkcert -CAROOT)/rootCA.pem\" vitest --run",
|
|
134
134
|
"test-watch": "NODE_EXTRA_CA_CERTS=\"$(mkcert -CAROOT)/rootCA.pem\" vitest watch",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Chat, UIMessage } from "@ai-sdk/react";
|
|
2
2
|
import { BlockNoteEditor } from "@blocknote/core";
|
|
3
|
-
import { getCurrentTest,
|
|
3
|
+
import { getCurrentTest, TestContext } from "@vitest/runner";
|
|
4
4
|
import path from "path";
|
|
5
5
|
import { TextSelection } from "prosemirror-state";
|
|
6
6
|
import { describe, expect, it } from "vitest";
|
|
@@ -20,7 +20,7 @@ import { buildAIRequest } from "../../aiRequest/builder.js";
|
|
|
20
20
|
|
|
21
21
|
const BASE_FILE_PATH = path.resolve(__dirname, "__snapshots__");
|
|
22
22
|
|
|
23
|
-
// @ts-
|
|
23
|
+
// @ts-expect-error - unused helper kept for debugging snapshots
|
|
24
24
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
25
25
|
async function matchFileSnapshot(data: any, postFix = "") {
|
|
26
26
|
const t = getCurrentTest()!;
|
|
@@ -44,7 +44,7 @@ export function generateSharedTestCases(
|
|
|
44
44
|
) {
|
|
45
45
|
function skipIfUnsupported(
|
|
46
46
|
test: DocumentOperationTestCase,
|
|
47
|
-
context:
|
|
47
|
+
context: TestContext,
|
|
48
48
|
) {
|
|
49
49
|
if (
|
|
50
50
|
skipTestsRequiringCapabilities &&
|
|
@@ -12,7 +12,7 @@ export function getApplySuggestionsTr(editor: BlockNoteEditor<any, any, any>) {
|
|
|
12
12
|
applySuggestionsTr = tr;
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
-
// @ts-
|
|
15
|
+
// @ts-expect-error - applySuggestionsTr is assigned inside the callback above
|
|
16
16
|
if (!applySuggestionsTr) {
|
|
17
17
|
throw new Error("applySuggestionsTr is not set");
|
|
18
18
|
}
|
package/dist/client-BPNTLm1-.cjs
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";var we=Object.defineProperty;var ge=(t,e,o)=>e in t?we(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o;var L=(t,e,o)=>ge(t,typeof e!="symbol"?e+"":e,o);const P=require("ai"),Te=require("lodash.merge"),J=require("@ai-sdk/provider-utils"),Pe=require("lodash.isequal"),g=require("@blocknote/core"),ve=require("prosemirror-model"),Oe=require("prosemirror-state"),w=require("prosemirror-transform"),q=require("prosemirror-changeset"),Ee=require("@handlewithcare/prosemirror-suggest-changes"),se=t=>t&&typeof t=="object"&&"default"in t?t:{default:t},Z=se(Te),xe=se(Pe);function R(t){return(t.type==="paragraph"||!t.type)&&!t.content||Array.isArray(t.content)&&t.content.length===0}function Be(t,e,o=!0,r=!0){let n=0,a=t.length;if(o)for(;n<a&&e(t[n]);)n++;if(r)for(;a>n&&e(t[a-1]);)a--;return t.slice(n,a)}function E(t,e){return Be(t,r=>R(r)&&(e==null?void 0:e.cursorBlockId)!==r.id,(e==null?void 0:e.trimStart)??!1,(e==null?void 0:e.trimEnd)??!0)}async function Ce(t){const{useSelection:e,deleteEmptyCursorBlock:o,streamToolsProvider:r,documentStateBuilder:n,onStart:a}={useSelection:t.useSelection??!1,deleteEmptyCursorBlock:t.deleteEmptyCursorBlock??!0,streamToolsProvider:t.streamToolsProvider??U.html.getStreamToolsProvider(),documentStateBuilder:t.documentStateBuilder??U.html.defaultDocumentStateBuilder,onStart:t.onStart??(()=>{})},i=e?void 0:t.editor.getTextCursorPosition().block,s=i&&o&&R(i)&&E(t.editor.document).length>0?i.id:void 0,c=e?t.editor.getSelectionCutBlocks(!0):void 0,d=r.getStreamTools(t.editor,c?{from:c._meta.startPos,to:c._meta.endPos}:void 0,t.onBlockUpdated),u={editor:t.editor,selectedBlocks:c==null?void 0:c.blocks,streamTools:d,emptyCursorBlockToDelete:s,onStart:a};return{...u,documentState:await n(u)}}function Ie(t){const{properties:e,required:o,$defs:r,...n}=t.inputSchema;return{schema:{type:"object",description:t.description,properties:{type:{type:"string",enum:[t.name]},...e},required:["type",...o??[]],additionalProperties:!1,...n},$defs:r}}function ae(t){const e=t.map(r=>Ie(r)),o={};for(const r of e)for(const n in r.$defs){if(o[n]&&!xe.default(o[n],r.$defs[n]))throw new Error(`Duplicate, but different definition for ${n}`);o[n]=r.$defs[n]}return{type:"object",properties:{operations:{type:"array",items:{anyOf:e.map(r=>r.schema)}}},additionalProperties:!1,required:["operations"],$defs:Object.keys(o).length>0?o:void 0}}function ie(t){return{applyDocumentOperations:{inputSchema:P.jsonSchema(ae(t)),outputSchema:P.jsonSchema({type:"object"})}}}class H extends Error{constructor(o,r,n){super(o,n);L(this,"aborted");this.chunk=r,this.name="ChunkExecutionError",this.aborted=(n==null?void 0:n.aborted)??!1}}class ce{constructor(e,o){L(this,"stream");this.streamTools=e,this.abortSignal=o,this.stream=this.createStream()}createStream(){let e;const o=new TransformStream({transform:async(s,c)=>{const d=typeof s=="string"?await Me(s,(e==null?void 0:e.isPossiblyPartial)??!1,this.streamTools):s;d&&(e=d,c.enqueue(d))},flush:s=>{e!=null&&e.isPossiblyPartial&&s.error(new Error("stream ended with a partial operation"))}}),r=o.readable.pipeThrough(this.createExecutor()),[n,a]=r.tee(),i=n.pipeTo(new WritableStream);return{writable:o.writable,readable:a,finishPromise:i}}createExecutor(){const e=this.streamTools.map(o=>o.executor());return new TransformStream({transform:async(o,r)=>{var a,i;let n=!1;for(const s of e)try{if(await s.execute(o,this.abortSignal)){r.enqueue({status:"ok",chunk:o}),n=!0;break}}catch(c){r.error(new H(`Tool execution failed: ${J.getErrorMessage(c)}`,o,{cause:c,aborted:((a=this.abortSignal)==null?void 0:a.aborted)??!1}));return}if(!n){const s=((i=o.operation)==null?void 0:i.type)||"unknown";r.error(new Error(`No tool could handle operation of type: ${s}`));return}}})}get writable(){return this.stream.writable}get readable(){return this.stream.readable}async finish(){await this.stream.finishPromise}async executeOperationsArray(e){const o=this.writable.getWriter();for await(const r of e){const n=await P.parsePartialJson(r);if(n.state==="undefined-input"||n.state==="failed-parse"||!n)return;await o.write(r)}await o.close(),await this.finish()}async execute(e){const o=this.writable.getWriter();for await(const r of e)await o.write(r);await o.close(),await this.finish()}async executeOne(e){await this.execute(async function*(){yield{operation:e,isUpdateToPreviousOperation:!1,isPossiblyPartial:!1,metadata:{}}}())}}async function Me(t,e,o){const r=await P.parsePartialJson(t);if(r.state==="undefined-input"||r.state==="failed-parse"||!r)return;const n=o.find(i=>{var s;return i.name===((s=r.value)==null?void 0:s.type)}),a=n&&n.validate(r.value);if(a!=null&&a.ok)return{operation:a.value,isPossiblyPartial:r.state==="repaired-parse",isUpdateToPreviousOperation:e,metadata:void 0}}function le(t){return t.flatMap(e=>{var o;if(e.role==="user"&&((o=e.metadata)!=null&&o.documentState)){const r=e.metadata.documentState;return[{role:"assistant",id:"assistant-document-state-"+e.id,parts:[...r.selection?[{type:"text",text:"This is the latest state of the selection (ignore previous selections, you MUST issue operations against this latest version of the selection):"},{type:"text",text:JSON.stringify(r.selectedBlocks)},{type:"text",text:`This is the latest state of the entire document (INCLUDING the selected text),
|
|
2
|
-
you can use this to find the selected text to understand the context (but you MUST NOT issue operations against this document, you MUST issue operations against the selection):`},{type:"text",text:JSON.stringify(r.blocks)}]:[{type:"text",text:`There is no active selection. This is the latest state of the document (ignore previous documents, you MUST issue operations against this latest version of the document).
|
|
3
|
-
The cursor is BETWEEN two blocks as indicated by cursor: true.
|
|
4
|
-
`+(r.isEmptyDocument?"Because the document is empty, YOU MUST first update the empty block before adding new blocks.":"Prefer updating existing blocks over removing and adding (but this also depends on the user's question).")},{type:"text",text:JSON.stringify(r.blocks)}]]},e]}return[e]})}async function ue(t){const e=await Promise.all(Object.entries(t).map(async([o,r])=>[o,{description:r.description,inputSchema:await P.asSchema(r.inputSchema).jsonSchema,outputSchema:await P.asSchema(r.outputSchema).jsonSchema}]));return Object.fromEntries(e)}function de(t){return Object.fromEntries(Object.entries(t).map(([e,o])=>[e,P.tool({...o,inputSchema:P.jsonSchema(o.inputSchema),outputSchema:P.jsonSchema(o.outputSchema)})]))}const pe={"mistral.chat":{mode:"auto"},"google.generative-ai":{mode:"auto"},"groq.chat":{providerOptions:{groq:{structuredOutputs:!1}}}};function Ne(t){return pe[t.provider]||{}}class Ae{constructor(e){this.opts=e}async streamText(e,o){const{model:r,_additionalOptions:n}=this.opts;return P.streamText({model:r,system:this.opts.systemPrompt,messages:await P.convertToModelMessages(le(e)),tools:o,toolChoice:"required",...n??{}}).toUIMessageStream()}async sendMessages({messages:e,body:o}){const r=this.opts.stream??!0,n=o.toolDefinitions,a=await de(n);if(r)return await this.streamText(e,a);throw new Error("Not implemented (generateText)")}reconnectToStream(){throw new Error("Not implemented")}}function _e(){let t,e=Promise.resolve(),o=!1,r;const n=new Promise((c,d)=>{r=d});n.catch(()=>{});const a=new ReadableStream({start(c){t=c},cancel(c){o=!0,t.error(c),r==null||r(c)}});async function i(c){if(o)throw new Error("Appendable stream canceled, can't append");const d=c.getReader();return e=e.then(async()=>{for(;;)try{const{done:u,value:l}=await Promise.race([d.read(),n]);if(u||o)break;t.enqueue(l)}catch(u){o=!0,t.error(u);break}}),e}async function s(){await e,o||t.close()}return{output:a,append:i,finalize:s}}function $e(t){return new ReadableStream({async start(e){try{for await(const o of t)e.enqueue(o);e.close()}catch(o){e.error(o)}}})}function fe(t){if(t.locked)throw new Error("Stream (source) is already locked and cannot be iterated.");const e=t.pipeThrough(new TransformStream);return e[Symbol.asyncIterator]=()=>{if(e.locked)throw new Error("Stream is already locked and cannot be iterated again.");const o=e.getReader();return{async next(){const{done:r,value:n}=await o.read();return r?{done:!0,value:void 0}:{done:!1,value:n}}}},e}function De(t){return fe($e(t))}async function*je(t,e){var a;let o=0,r=!0,n;for await(const i of t)if((a=i.operations)!=null&&a.length){for(let s=o;s<i.operations.length;s++){const c=i.operations[s];n=c,yield{partialOperation:c,isUpdateToPreviousOperation:s===o&&!r,isPossiblyPartial:s===i.operations.length-1,metadata:e},r=!1}o=i.operations.length-1}if(!n)throw new Error("No operations seen");yield{partialOperation:n,isUpdateToPreviousOperation:!0,isPossiblyPartial:!1,metadata:e}}async function*Le(t,e){let o=!1;for await(const r of t){const n=r.operation;n.ok?(yield{operation:n.value,isUpdateToPreviousOperation:o?!1:r.isUpdateToPreviousOperation,isPossiblyPartial:r.isPossiblyPartial,metadata:r.metadata},o=!1):(o=o||!r.isUpdateToPreviousOperation,e==null||e({...r,operation:n}))}}async function*qe(t,e){for await(const o of t){if(!o.partialOperation.type){yield{operation:{ok:!1,error:"The `type` property of an operation is required."},isUpdateToPreviousOperation:o.isUpdateToPreviousOperation,isPossiblyPartial:o.isPossiblyPartial,metadata:o.metadata};continue}const r=e.find(a=>a.name===o.partialOperation.type);if(!r){yield{operation:{ok:!1,error:`No matching function for ${o.partialOperation.type}`},isUpdateToPreviousOperation:o.isUpdateToPreviousOperation,isPossiblyPartial:o.isPossiblyPartial,metadata:o.metadata};continue}yield{operation:r.validate(o.partialOperation),isUpdateToPreviousOperation:o.isUpdateToPreviousOperation,isPossiblyPartial:o.isPossiblyPartial,metadata:o.metadata}}}async function*Ue(t,e){const o=qe(t,e);yield*Le(o,n=>{if(!n.isPossiblyPartial)throw new H(`Invalid operation. ${J.getErrorMessage(n.operation.error)}`,n,{cause:n.operation.error})})}function me(t,e,o){return De(Ue(je(fe(t),o),e))}async function he(t,e,o,r){const n=new ce(t,r),a=_e(),i=a.output.pipeTo(n.writable),s=new Map;let c=!0;const d=e["~registerMessagesCallback"](()=>{Je(e,b=>{if(!s.has(b.toolCallId)){const y=Re(t,b.toolName,b.toolCallId);a.append(y.operationsStream),s.set(b.toolCallId,y),c&&(c=!1,o==null||o())}return s.get(b.toolCallId)})});await new Promise(b=>{const y=e["~registerStatusCallback"](()=>{(e.status==="ready"||e.status==="error")&&(d(),y(),e.status!=="error"&&h(),b())}),h=e["~registerErrorCallback"](()=>{if(e.error){h();for(const k of s.values())k.complete||k.writer.abort(e.error)}})}),await a.finalize();const l=await Promise.allSettled([n.finish(),i]),f=l[0];if(l[1].status==="rejected"&&(l[0].status!=="rejected"||l[0].reason!==l[1].reason))throw new Error("unexpected, pipeToPromise rejected but executor.finish() doesn't have same error!?");let p;if(f.status==="rejected"){if(f.reason instanceof H)p=f.reason;else if(!e.error)throw new Error("Unexpected: no ChunkExecutionError but also no chat.error (network error?)")}let S=!1;const m=Array.from(s.values().filter(b=>b.complete));return m.forEach((b,y)=>{const h=b.toolCallId===(p==null?void 0:p.chunk.metadata.toolCallId);h&&(S=!0),S?e.addToolOutput({tool:m[y].toolName,toolCallId:m[y].toolCallId,state:"output-error",errorText:JSON.stringify(h?{status:"error",error:J.getErrorMessage(p)}:{status:"not-executed-previous-tool-errored"})}):e.addToolOutput({state:"output-available",tool:m[y].toolName,toolCallId:m[y].toolCallId,output:{status:"ok"}})}),p?{ok:!1,error:p}:{ok:!0,value:void 0}}function Je(t,e){var o;for(const r of((o=t.lastMessage)==null?void 0:o.parts)??[]){if(!P.isToolUIPart(r)||r.type.replace("tool-","")!=="applyDocumentOperations")continue;const a=r.toolCallId,i=e({toolName:r.type.replace("tool-",""),toolCallId:a});He(r,i)}}function Re(t,e,o){const r=new TransformStream,n=me(r.readable,t,{toolCallId:o});return{writer:r.writable.getWriter(),complete:!1,operationsStream:n,toolName:e,toolCallId:o}}function He(t,e){if(t.state==="input-streaming"){const o=t.input;o!==void 0&&e.writer.write(o)}else if(t.state==="input-available"){const o=t.input;if(o===void 0)throw new Error("input is undefined");e.complete||(e.complete=!0,e.writer.write(o),e.writer.close())}}async function ze(t,e,o,r,n){const a=o??t.lastMessage;if(!a)throw new Error("No message to send");a.metadata=Z.default(a.metadata,{documentState:e.documentState});const i=he(e.streamTools,t,e.onStart,n);return r=Z.default(r,{metadata:{source:"blocknote-ai"},body:{toolDefinitions:await ue(ie(e.streamTools))}}),await t.sendMessage(o,r),await i}function ye(t,e){const o=t.getTextCursorPosition(),r=[];for(const n of e){const a=n.id===o.block.id;r.push({id:n.id,block:n.block}),a&&r.push({cursor:!0})}return r}async function A(t,e){return await Promise.all(t.map(async o=>({id:o.id,block:await e(o)})))}function x(t){return t.flatMap(e=>[{...e,children:[]},...x(e.children)])}function z(t){return t.map(e=>typeof e=="object"&&e&&"id"in e?{...e,id:`${e.id}$`}:e)}function D(t){return async e=>e.selectedBlocks?await We(e.editor,t,{selectedBlocks:e.selectedBlocks}):await Fe(e.editor,t,{excludeBlockIds:e.emptyCursorBlockToDelete?[e.emptyCursorBlockToDelete]:void 0})}async function Fe(t,e,o){const r=E(t.document).length===0,n=t.getTextCursorPosition().block.id,a=E(t.document,{cursorBlockId:n}),i=await A(x(a),async u=>e(t,u)),c=ye(t,i).filter(u=>"cursor"in u||!(o.excludeBlockIds||[]).includes(u.id));return{selection:!1,blocks:z(c),isEmptyDocument:r}}async function We(t,e,o){const r=E(t.document).length===0,n=await A(x(o.selectedBlocks),async i=>e(t,i)),a=z(n);return{isEmptyDocument:r,selection:!0,selectedBlocks:a,blocks:(await A(x(t.document),async i=>e(t,i))).map(({block:i})=>({block:i}))}}function Ve(t){let e,o=!1;return t.descendants((r,n)=>o?!1:(r.isText&&(o=!0,e=n),!0)),e}function _(t){var a;const e=g.getPmSchema(t),{modification:o}=e.marks,r=[],n=new w.Transform(t.before);for(let i=0;i<t.steps.length;i++){const s=t.steps[i],c=new w.Mapping(t.mapping.maps.slice(0,i)).invert();if(s.structure){if(s instanceof w.ReplaceStep){if(s.to!==s.from+1||s.slice.openStart!==0||s.slice.openEnd!==1||s.slice.content.size!==2)throw new Error("Structure change is not in expected format (ReplaceStep)")}else if(s instanceof w.ReplaceAroundStep){if(s.insert!==1||s.slice.size!==2||s.gapTo!==s.to-1||s.gapFrom!==s.from+1)throw new Error("Structure change is not in expected format (ReplaceAroundStep)")}else throw new Error("Step is not a ReplaceStep or ReplaceAroundStep");const y=c.map(s.from),h=s.slice.content.firstChild,k=n.doc.resolve(n.mapping.map(y)).nodeAfter;let T=h.marks||[];h.type!==k.type&&(T=o.create({type:"nodeType",previousValue:k.type.name,newValue:h.type.name}).addToSet(T));const C=new Set([...Object.keys(h.attrs),...Object.keys(k.attrs)]);for(const v of C)h.attrs[v]!==k.attrs[v]&&(T=o.create({type:"attr",attrName:v,previousValue:k.attrs[v],newValue:h.attrs[v]}).addToSet(T));const O=n.steps.length;n.setNodeMarkup(n.mapping.map(y),h.type,h.attrs,T),r.push({prosemirrorSteps:n.steps.slice(O),selection:void 0,type:"replace"});continue}if(!(s instanceof w.ReplaceStep))throw new Error("Step is not a ReplaceStep");const d=c.map(s.from),u=c.map(s.to);if(s.slice.openStart>0||s.slice.openEnd>0)throw new Error("Slice has openStart or openEnd > 0, but structure=false");r.push({prosemirrorSteps:[],selection:{anchor:n.mapping.map(d),head:n.mapping.map(u)},type:"select"});const l=s.slice.content.textBetween(0,s.slice.size),f=l===n.doc.textBetween(n.mapping.map(d),n.mapping.map(u));let p;if(f)p=s.slice.content.size;else if(l.length===0)p=s.slice.content.size;else{const y=Ve(s.slice.content);if(y===void 0)throw new Error("unexpected: no first character found");p=y+1}let S=n.mapping.map(u);const m=n.mapping.map(u);let b=!0;for(let y=p;y<=s.slice.content.size;y++){const h=b&&d!==u,k=n.steps.length;if(h){const O=n.doc.resolve(n.mapping.map(d));(a=O.nodeAfter)!=null&&a.isBlock&&n.addNodeMark(O.pos,e.mark("deletion",{})),n.addMark(O.pos,S,e.mark("deletion",{})),S=n.mapping.map(u)}const T=new ve.Slice(s.slice.content.cut(0,y),0,0);n.replace(m,S,T).addMark(m,m+T.content.size,e.mark("insertion",{})),n.doc.nodesBetween(m,m+T.content.size,(O,v)=>v<m||v>m+T.content.size?!0:(O.isBlock&&n.addNodeMark(v,e.mark("insertion",{})),!1)),S=n.mapping.slice(k).map(S);const C=Oe.TextSelection.near(n.doc.resolve(m+T.content.size),-1);r.push({prosemirrorSteps:n.steps.slice(k),selection:{anchor:C.from,head:C.from},type:h?"replace":"insert"}),b=!1}}return r}async function F(t){const e=Math.random()*.3+.85;if(t.type==="select")await new Promise(o=>setTimeout(o,100*e));else if(t.type==="insert")await new Promise(o=>setTimeout(o,10*e));else if(t.type==="replace")await new Promise(o=>setTimeout(o,200*e));else throw new g.UnreachableCaseError(t.type)}function W(t,e){t.setMeta("addToHistory",!1),e.selection&&t.setMeta("aiAgent",{selection:{anchor:e.selection.anchor,head:e.selection.head}});for(const o of e.prosemirrorSteps)if(t.maybeStep(o).failed)throw new Error("failed to apply step");return t}function Ye(t,e,o){const r=new w.Transform(e);for(const i of t){const s=new w.ReplaceStep(r.mapping.map(i.fromA),r.mapping.map(i.toA),o.slice(i.fromB,i.toB));r.step(s)}const n=r.mapping.invert();let a=r.doc.content.findDiffStart(o.content);for(;a!==null;){const i=o.resolve(a).nodeAfter,s=r.doc.resolve(a).nodeAfter;if(!i||!s)throw new Error("diffNode not found");const c=!i.isLeaf&&i.content.eq(s.content),d=c?1:Math.min(i.nodeSize,s.nodeSize),u=a+d,l=n.map(a),f=n.map(u);let p=t.length;for(let m=0;m<t.length;m++)if(t[m].fromA>=f){p=m;break}t.splice(p,0,{fromA:l,toA:f,fromB:a,toB:u,deleted:[],inserted:[],type:c?"node-type-or-attr-update":"mark-update"}),r.step(new w.ReplaceStep(a,u,o.slice(a,u),c));const S=r.doc.content.findDiffStart(o.content);if(S===a)throw new Error("diffStart not moving");a=S}return t}const G=(t,e)=>{const o=new Set,r=new Set;t.descendants(i=>{i.type.name==="tableCell"&&o.add(JSON.stringify(i.toJSON()))}),e.descendants(i=>{i.type.name==="tableCell"&&r.add(JSON.stringify(i.toJSON()))});const n=new Set([...o].filter(i=>r.has(i)));return{encodeCharacter:i=>i,encodeNodeStart:i=>{if(i.type.name==="tableCell"){const s=JSON.stringify(i.toJSON());return n.has(s)?s:i.type.name}return i.type.name},encodeNodeEnd:i=>{if(i.type.name==="tableCell"){const s=JSON.stringify(i.toJSON());return n.has(s)?s:-1}return-1},compareTokens:(i,s)=>i===s}};function j(t,e,o=!1,r,n){const a=g.getNodeById(t.id,e),i=new w.Transform(e);g.updateBlockTr(i,a.posBeforeNode,t.block,r,n);let s=i.doc,c=q.ChangeSet.create(e,void 0,G(e,s));if(c=c.addSteps(s,i.mapping.maps,0),o&&c.changes.length>0){const l=c.changes[c.changes.length-1],f=l.toA-l.fromA,p=l.toB-l.fromB;if(f>p){const S=e.slice(l.fromA+p,l.toA);i.step(new w.ReplaceStep(l.toB,l.toB,S)),s=i.doc,c=q.ChangeSet.create(c.startDoc,void 0,G(c.startDoc,s)),c=c.addSteps(s,i.mapping.maps,0)}}const d=[],u=q.simplifyChanges(c.changes,s);for(let l=0;l<u.length;l++){const f=u[l],p=s.slice(f.fromB,f.toB);if(p.openEnd===1&&p.openStart===0&&(f.type="node-type-or-attr-update",p.size>2)){const S={fromA:f.fromA,toA:f.fromA+1,fromB:f.fromB,toB:f.fromB+1,deleted:[],inserted:[],type:"node-type-or-attr-update"},m={fromA:f.fromA+1,toA:f.toA,fromB:f.fromB+1,toB:f.toB,deleted:[],inserted:[]};u.splice(l,1,S,m),l++}}Ye(u,e,s);for(let l=0;l<u.length;l++){const f=u[l],p=s.slice(f.fromB,f.toB);if(p.openEnd>0&&p.size>1)throw new Error("unexpected, openEnd > 0 and size > 1, this should have been split into two steps");l===u.length-1&&o&&f.type==="mark-update"||d.push(new w.ReplaceStep(f.fromA,f.toA,p,f.type==="node-type-or-attr-update"))}return d}class Se extends Error{constructor(e,o){super(e,o),this.name="AbortError"}}function Xe(t,e){if(!t||!Array.isArray(t)||t.length===0)return{ok:!1,error:"blocks is required"};const o=[];for(const r of t){const n=e(r);if(!n.ok)return{ok:!1,error:`Invalid block: ${n.error}`};o.push(n.value)}return{ok:!0,value:o}}function V(t){return(e,o)=>{const r=typeof t.schema=="function"?t.schema(e):t.schema;return{name:"add",description:t.description,inputSchema:{type:"object",properties:{referenceId:{type:"string",description:"MUST be an id of a block in the document"},position:{type:"string",enum:["before","after"],description:"`after` to add blocks AFTER (below) the block with `referenceId`, `before` to add the block BEFORE (above)"},blocks:{items:r.block,type:"array"}},required:["referenceId","position","blocks"],$defs:r.$defs},validate:n=>{if(n.type!=="add")return{ok:!1,error:"invalid operation type"};if(n.position!=="before"&&n.position!=="after")return{ok:!1,error:"invalid position"};if(!n.referenceId||!n.blocks)return{ok:!1,error:"referenceId and blocks are required"};let a=n.referenceId;if(o.idsSuffixed){if(!(a!=null&&a.endsWith("$")))return{ok:!1,error:"referenceId must end with $"};a=a.slice(0,-1)}if(!e.getBlock(a))return{ok:!1,error:"referenceId not found"};const s=Xe(n.blocks,c=>t.validateBlock(c,e));return s.ok?{ok:!0,value:{type:n.type,referenceId:a,position:n.position,blocks:s.value}}:s},executor:()=>{let n=[];const a={};return{execute:async(i,s)=>{var u;if(i.isUpdateToPreviousOperation||(n=[]),i.operation.type!=="add")return!1;const c=i.operation,d=await t.toJSONToolCall(e,{...i,operation:c});if(!d||i.isPossiblyPartial&&R(d.blocks[d.blocks.length-1]))return!0;for(let l=0;l<d.blocks.length;l++){const f=d.blocks[l],p=e.prosemirrorState.tr;let S=[];if(l<n.length){const m=await t.rebaseTool(n[l],e),y=j({id:n[l],block:f},m.doc,!1).map(h=>h.map(m.invertMap));for(const h of y)p.step(h.map(p.mapping));S=_(p),S=S.filter(h=>h.type!=="select")}else{const m=c.position==="after"?a[c.referenceId]:void 0,b=g.insertBlocks(p,[f],l>0?n[l-1]:m||c.referenceId,l>0?"after":c.position);n.push(...b.map(y=>y.id)),S=_(p)}for(const m of S){if(s!=null&&s.aborted)throw new Se("Operation was aborted");o.withDelays&&await F(m),e.transact(b=>{W(b,m)}),(u=o.onBlockUpdate)==null||u.call(o,n[l])}}return i.isPossiblyPartial||c.position==="after"&&(a[c.referenceId]=n[n.length-1]),!0}}}}}}function Y(t){return(e,o)=>{const r=typeof t.schema=="function"?t.schema(e):t.schema;return{name:"update",description:t.description,inputSchema:{type:"object",properties:{id:{type:"string",description:"id of block to update"},block:r.block},required:["id","block"],$defs:r.$defs},validate:n=>{if(n.type!=="update")return{ok:!1,error:"invalid operation type"};if(!n.id)return{ok:!1,error:"id is required"};let a=n.id;if(o.idsSuffixed){if(!(a!=null&&a.endsWith("$")))return{ok:!1,error:"id must end with $"};a=a.slice(0,-1)}if(!n.block)return{ok:!1,error:"block is required"};const i=e.getBlock(a);if(!i)return{ok:!1,error:new Error("Block not found (update)",{cause:{blockId:a}})};const s=t.validateBlock(n.block,e,i.type);return s.ok?{ok:!0,value:{type:n.type,id:a,block:s.value}}:s},executor:()=>{let a=50;const i=o.updateSelection?{from:g.trackPosition(e,o.updateSelection.from),to:g.trackPosition(e,o.updateSelection.to)}:void 0;return{execute:async(s,c)=>{var h;if(s.operation.type!=="update")return!1;const d=s.operation;if(s.isPossiblyPartial){const k=JSON.stringify(d.block).length;if(k<a)return!0;a=k+50}else a=50;const u=await t.rebaseTool(d.id,e),l=i?u.invertMap.invert().map(i.from()):void 0,f=i?u.invertMap.invert().map(i.to()):void 0,p=await t.toJSONToolCall(e,{...s,operation:d});if(!p)return!0;const S=j(p,u.doc,s.isPossiblyPartial,l,f);if(S.length===1&&s.isPossiblyPartial)return!0;const m=S.map(k=>k.map(u.invertMap)),b=new w.Transform(e.prosemirrorState.doc);for(const k of m)b.step(k.map(b.mapping));const y=_(b);for(const k of y){if(c!=null&&c.aborted)throw new Se("Operation was aborted");o.withDelays&&await F(k),e.transact(T=>{W(T,k)}),(h=o.onBlockUpdate)==null||h.call(o,d.id)}return!0}}}}}}const X=(t,e)=>({name:"delete",description:"Delete a block",inputSchema:{type:"object",properties:{id:{type:"string",description:"id of block to delete"}},required:["id"]},validate:o=>{if(o.type!=="delete")return{ok:!1,error:"invalid operation type"};if(!o.id)return{ok:!1,error:"id is required"};let r=o.id;if(e.idsSuffixed){if(!(r!=null&&r.endsWith("$")))return{ok:!1,error:"id must end with $"};r=r.slice(0,-1)}return t.getBlock(r)?{ok:!0,value:{type:"delete",id:r}}:{ok:!1,error:new Error("Block not found (delete)",{cause:{blockId:r}})}},executor:()=>({execute:async o=>{var i;if(o.operation.type!=="delete")return!1;const r=o.operation,n=t.prosemirrorState.tr;g.removeAndInsertBlocks(n,[r.id],[]);const a=_(n);for(const s of a)e.withDelays&&await F(s),t.transact(c=>{W(c,s)}),(i=e.onBlockUpdate)==null||i.call(e,r.id);return!0}})});function K(t){const e=t.lastIndexOf("<"),o=t.lastIndexOf(">");let r=t;if(e>o&&(r=t.substring(0,e),!r.trim()))return;const n=r.match(/&[a-zA-Z0-9]*$/);n&&(r=r.substring(0,r.length-n[0].length));const s=new DOMParser().parseFromString(`<div>${r}</div>`,"text/html").body.firstChild;return s?s.innerHTML:""}function B(t){let e;if(Ee.applySuggestions(t.prosemirrorState,o=>{e=o}),!e)throw new Error("applySuggestionsTr is not set");return e}function $(t,e){const o=e.mapping.invert();return{doc:e.doc,tr:()=>new w.Transform(e.doc),invertMap:o,rebaseTr:r=>{if(r.steps.length===0)throw new Error("No steps to apply");let n=t.prosemirrorState.tr;for(const a of r.steps){const i=a.map(o);if(!i)throw new Error("Step is not mapped");n=n.step(i)}return n}}}async function Q(t,e){var d;const o=B(e),r=g.getBlock(o.doc,t);if(!r)throw new Error("block not found");const n=await e.blocksToHTMLLossy([{...r,children:[]}]),a=(d=window.__TEST_OPTIONS)==null?void 0:d.mockID,i=await e.tryParseHTMLToBlocks(n);if(window.__TEST_OPTIONS&&(window.__TEST_OPTIONS.mockID=a),i.length!==1)throw new Error("html diff invalid block count");const s=i[0];if(s.id=t,j({id:t,block:s},o.doc).length)throw new Error("html diff",{cause:{html:n,htmlBlock:s}});return $(e,o)}function ee(t){return typeof t!="string"?{ok:!1,error:"block must be a string"}:{ok:!0,value:t}}const I={add:V({description:"Insert new blocks",schema:{block:{type:"string",description:"html of block (MUST be a single, VALID HTML element)"}},validateBlock:ee,rebaseTool:Q,toJSONToolCall:async(t,e)=>{var n;const o=(n=window.__TEST_OPTIONS)==null?void 0:n.mockID,r=(await Promise.all(e.operation.blocks.map(async a=>{const i=e.isPossiblyPartial?K(a):a;return i?(await t.tryParseHTMLToBlocks(i)).map(s=>(delete s.id,s)):[]}))).flat();if(window.__TEST_OPTIONS&&(window.__TEST_OPTIONS.mockID=o),r.length!==0)return{...e.operation,blocks:r}}}),update:Y({description:"Update a block",schema:{block:{type:"string",description:"html of block (MUST be a single HTML element)"}},validateBlock:ee,rebaseTool:Q,toJSONToolCall:async(t,e)=>{const o=e.isPossiblyPartial?K(e.operation.block):e.operation.block;if(!o)return;const r=(await t.tryParseHTMLToBlocks(o))[0];return window.__TEST_OPTIONS&&(window.__TEST_OPTIONS.mockID=void 0),delete r.id,{...e.operation,block:r}}}),delete:X};function Ze(t,e,o,r,n){if(typeof r=="boolean"){const s=r?t.getSelectionCutBlocks(!0):void 0;r=s?{from:s._meta.startPos,to:s._meta.endPos}:void 0}const a=o??{add:!0,update:!0,delete:!0};return[...a.update?[I.update(t,{idsSuffixed:!0,withDelays:e,updateSelection:r,onBlockUpdate:n})]:[],...a.add?[I.add(t,{idsSuffixed:!0,withDelays:e,onBlockUpdate:n})]:[],...a.delete?[I.delete(t,{idsSuffixed:!0,withDelays:e,onBlockUpdate:n})]:[]]}const Ge=`You're manipulating a text document using HTML blocks.
|
|
5
|
-
Make sure to follow the json schema provided. When referencing ids they MUST be EXACTLY the same (including the trailing $).
|
|
6
|
-
List items are 1 block with 1 list item each, so block content \`<ul><li>item1</li></ul>\` is valid, but \`<ul><li>item1</li><li>item2</li></ul>\` is invalid. We'll merge them automatically.
|
|
7
|
-
For code blocks, you can use the \`data-language\` attribute on a <code> block (wrapped with <pre>) to specify the language.
|
|
8
|
-
|
|
9
|
-
If the user requests updates to the document, use the "applyDocumentOperations" tool to update the document.
|
|
10
|
-
---
|
|
11
|
-
IF there is no selection active in the latest state, first, determine what part of the document the user is talking about. You SHOULD probably take cursor info into account if needed.
|
|
12
|
-
EXAMPLE: if user says "below" (without pointing to a specific part of the document) he / she probably indicates the block(s) after the cursor.
|
|
13
|
-
EXAMPLE: If you want to insert content AT the cursor position (UNLESS indicated otherwise by the user), then you need \`referenceId\` to point to the block before the cursor with position \`after\` (or block below and \`before\`
|
|
14
|
-
---
|
|
15
|
-
`,Ke={getStreamToolsProvider:(t={})=>({getStreamTools:(e,o,r)=>Ze(e,t.withDelays??!0,t.defaultStreamTools,o,r)}),systemPrompt:Ge,tools:I,defaultDocumentStateBuilder:D(async(t,e)=>t.blocksToHTMLLossy([e]))};function Qe(t){const e={},o={};return t.forEach(n=>{const{type:a,...i}=n.properties,s=JSON.stringify(i);e[s]?e[s].push(a.enum[0]):(e[s]=[a.enum[0]],o[s]=n)}),Object.keys(e).map(n=>{const a=o[n];return{...a,properties:{...a.properties,type:{type:"string",enum:e[n]}}}})}function et(t){return{type:"object",properties:Object.fromEntries(Object.entries(t).map(([e,o])=>[e,{type:o.propSchema}])),additionalProperties:!1}}function tt(){return{type:"object",properties:{type:{type:"string",enum:["text"]},text:{type:"string"},styles:{$ref:"#/$defs/styles"}},additionalProperties:!1,required:["type","text"]}}function be(t){return{type:"object",properties:Object.fromEntries(Object.entries(t).filter(([e,o])=>o.default!==void 0).map(([e,o])=>[e,{type:typeof o.default,enum:o.values}])),additionalProperties:!1}}function ot(t){return{type:"array",items:{anyOf:Object.entries(t).map(([e,o])=>o==="text"?{$ref:"#/$defs/styledtext"}:o==="link"?{type:"object",properties:{type:{type:"string",enum:["link"]},content:{type:"array",items:{$ref:"#/$defs/styledtext"}},href:{type:"string"}},additionalProperties:!1,required:["type","href","content"]}:{type:"object",properties:{type:{type:"string",enum:[o.type]},content:o.content==="styled"?{type:"array",items:{$ref:"#/$defs/styledtext"}}:void 0,props:be(o.propSchema)},additionalProperties:!1,required:["type",...o.content==="styled"?["content"]:[]]})}}}function rt(t){return{anyOf:Qe(Object.entries(t).map(([e,o])=>({type:"object",properties:{type:{type:"string",enum:[o.type]},content:o.content==="inline"?{$ref:"#/$defs/inlinecontent"}:o.content==="table"?{type:"object",properties:{}}:void 0,props:be(o.propSchema)},additionalProperties:!1,required:["type"]})))}}function nt(t){const e=JSON.parse(JSON.stringify({blockSchema:t.blockSchema,inlineContentSchema:t.inlineContentSchema,styleSchema:t.styleSchema}));return{removeFileBlocks(){return e.blockSchema=Object.fromEntries(Object.entries(e.blockSchema).filter(([o,r])=>{var n;return!((n=t.blockSpecs[r.type].implementation.meta)!=null&&n.fileBlockAccept)})),this},removeDefaultProps(){return e.blockSchema=Object.fromEntries(Object.entries(e.blockSchema).map(([o,r])=>[o,{...r,propSchema:Object.fromEntries(Object.entries(r.propSchema).filter(n=>typeof g.defaultProps[n[0]]>"u"))}])),this},get(){return e}}}function te(t){return t=nt(t).removeFileBlocks().removeDefaultProps().get(),{$defs:{styles:et(t.styleSchema),styledtext:tt(),inlinecontent:ot(t.inlineContentSchema),block:rt(t.blockSchema)}}}function ke(t,e){return!e.schema.inlineContentSchema[t.type]||g.isStyledTextInlineContent(t)&&!("text"in t)?!1:g.isLinkInlineContent(t)?!("content"in t)||!("href"in t)?!1:ke(t.content,e):!0}function oe(t,e,o){const r=t.type||o,n=e.schema.blockSchema[r];if(!n)return{ok:!1,error:"block type not found in editor"};if(t.children,n.content==="none"){if(t.content)return{ok:!1,error:"block content not expected for this block type"}}else{if(!t.content)return{ok:!0,value:t};if(!Array.isArray(t.content))return{ok:!1,error:"block content must be an array"};if(n.content==="table")return{ok:!0,value:t};if(!t.content.every(a=>ke(a,e)))return{ok:!1,error:"block content must be an array of inline content"}}return{ok:!0,value:t}}const M={add:V({description:"Insert new blocks",schema:t=>({block:{$ref:"#/$defs/block"},...te(t.schema)}),validateBlock:oe,rebaseTool:async(t,e)=>$(e,B(e)),toJSONToolCall:async(t,e)=>e.operation}),update:Y({description:"Update a block, the new block will replace the existing block.",schema:t=>({block:{$ref:"#/$defs/block"},...te(t.schema)}),validateBlock:oe,rebaseTool:async(t,e)=>$(e,B(e)),toJSONToolCall:async(t,e)=>{const o=Object.fromEntries(Object.entries(g.defaultProps).map(([r,n])=>[r,n.default]));return{...e.operation,block:{...e.operation.block,props:{...o,...e.operation.block.props}}}}}),delete:X};function st(t,e,o,r,n){if(typeof r=="boolean"){const s=r?t.getSelectionCutBlocks(!0):void 0;r=s?{from:s._meta.startPos,to:s._meta.endPos}:void 0}const a=o??{add:!0,update:!0,delete:!0};return[...a.update?[M.update(t,{idsSuffixed:!0,withDelays:e,updateSelection:r,onBlockUpdate:n})]:[],...a.add?[M.add(t,{idsSuffixed:!0,withDelays:e,onBlockUpdate:n})]:[],...a.delete?[M.delete(t,{idsSuffixed:!0,withDelays:e,onBlockUpdate:n})]:[]]}const at=`You're manipulating a text document using JSON blocks.
|
|
16
|
-
Make sure to follow the json schema provided. When referencing ids they MUST be EXACTLY the same (including the trailing $).
|
|
17
|
-
|
|
18
|
-
If the user requests updates to the document, use the "applyDocumentOperations" tool to update the document.
|
|
19
|
-
---
|
|
20
|
-
IF there is no selection active in the latest state, first, determine what part of the document the user is talking about. You SHOULD probably take cursor info into account if needed.
|
|
21
|
-
EXAMPLE: if user says "below" (without pointing to a specific part of the document) he / she probably indicates the block(s) after the cursor.
|
|
22
|
-
EXAMPLE: If you want to insert content AT the cursor position (UNLESS indicated otherwise by the user), then you need \`referenceId\` to point to the block before the cursor with position \`after\` (or block below and \`before\`
|
|
23
|
-
---
|
|
24
|
-
`,it={getStreamToolsProvider:(t={})=>({getStreamTools:(e,o,r)=>st(e,t.withDelays??!0,t.defaultStreamTools,o,r)}),tools:M,systemPrompt:at,defaultDocumentStateBuilder:D(async(t,e)=>({...e,id:void 0,children:void 0}))};async function re(t,e){const o=B(e),r=await e.blocksToMarkdownLossy([g.getBlock(o.doc,t)]),n=await e.tryParseMarkdownToBlocks(r),a=j({id:t,block:n[0]},o.doc),i=new w.Mapping;for(const s of a){const c=s.map(i);if(!c)throw new Error("Failed to map step");o.step(c),i.appendMap(c.getMap())}return $(e,o)}function ne(t){return typeof t!="string"?{ok:!1,error:"block must be a string"}:{ok:!0,value:t}}const N={add:V({description:"Insert new blocks",schema:{block:{$ref:"#/$defs/block"},$defs:{block:{type:"string",description:"markdown of block"}}},validateBlock:ne,rebaseTool:re,toJSONToolCall:async(t,e)=>{const o=await Promise.all(e.operation.blocks.map(async r=>{const n=(await t.tryParseMarkdownToBlocks(r.trim()))[0];return delete n.id,n}));return window.__TEST_OPTIONS&&(window.__TEST_OPTIONS.mockID=void 0),{...e.operation,blocks:o}}}),update:Y({description:"Update a block, the new block will replace the existing block.",schema:{block:{$ref:"#/$defs/block"},$defs:{block:{type:"string",description:"markdown of block"}}},validateBlock:ne,rebaseTool:re,toJSONToolCall:async(t,e)=>{const o=(await t.tryParseMarkdownToBlocks(e.operation.block.trim()))[0];return delete o.id,window.__TEST_OPTIONS&&(window.__TEST_OPTIONS.mockID=void 0),{...e.operation,block:o}}}),delete:X};function ct(t,e,o,r,n){if(typeof r=="boolean"){const s=r?t.getSelectionCutBlocks(!0):void 0;r=s?{from:s._meta.startPos,to:s._meta.endPos}:void 0}const a=o??{add:!0,update:!0,delete:!0};return[...a.update?[N.update(t,{idsSuffixed:!0,withDelays:e,updateSelection:r,onBlockUpdate:n})]:[],...a.add?[N.add(t,{idsSuffixed:!0,withDelays:e,onBlockUpdate:n})]:[],...a.delete?[N.delete(t,{idsSuffixed:!0,withDelays:e,onBlockUpdate:n})]:[]]}const lt=`You're manipulating a text document using Markdown blocks.
|
|
25
|
-
Make sure to follow the json schema provided. When referencing ids they MUST be EXACTLY the same (including the trailing $).
|
|
26
|
-
List items are 1 block with 1 list item each, so block content \`- item1\` is valid, but \`- item1
|
|
27
|
-
- item2\` is invalid. We'll merge them automatically.
|
|
28
|
-
|
|
29
|
-
If the user requests updates to the document, use the "applyDocumentOperations" tool to update the document.
|
|
30
|
-
---
|
|
31
|
-
IF there is no selection active in the latest state, first, determine what part of the document the user is talking about. You SHOULD probably take cursor info into account if needed.
|
|
32
|
-
EXAMPLE: if user says "below" (without pointing to a specific part of the document) he / she probably indicates the block(s) after the cursor.
|
|
33
|
-
EXAMPLE: If you want to insert content AT the cursor position (UNLESS indicated otherwise by the user), then you need \`referenceId\` to point to the block before the cursor with position \`after\` (or block below and \`before\`
|
|
34
|
-
---
|
|
35
|
-
`,ut={getStreamToolsProvider:(t={})=>({getStreamTools:(e,o,r)=>ct(e,t.withDelays??!0,t.defaultStreamTools,o,r)}),systemPrompt:lt,tools:N,defaultDocumentStateBuilder:D(async(t,e)=>t.blocksToMarkdownLossy([e]))},U={_experimental_json:it,_experimental_markdown:ut,html:Ke},dt={addCursorPosition:ye,flattenBlocks:x,suffixIDs:z,trimEmptyBlocks:E,convertBlocks:A};function pt(t){if(!t.dictionary.ai)throw new Error("AI dictionary not found");return t.dictionary.ai}const ft=t=>async(e,o)=>{const r=new Request(e,o),n=t(r.url),a=new Request(n,{headers:r.headers,body:(o==null?void 0:o.body)||r.body,method:r.method,duplex:"half"});return await fetch(a)};exports.ClientSideTransport=Ae;exports.PROVIDER_OVERRIDES=pe;exports.StreamToolExecutor=ce;exports.aiDocumentFormats=U;exports.buildAIRequest=Ce;exports.createStreamToolsArraySchema=ae;exports.fetchViaProxy=ft;exports.getAIDictionary=pt;exports.getApplySuggestionsTr=B;exports.getProviderOverrides=Ne;exports.injectDocumentStateMessages=le;exports.makeDocumentStateBuilder=D;exports.objectStreamToOperationsResult=me;exports.promptHelpers=dt;exports.sendMessageWithAIRequest=ze;exports.setupToolCallStreaming=he;exports.streamToolsToToolSet=ie;exports.toolDefinitionsToToolSet=de;exports.toolSetToToolDefinitions=ue;
|
|
36
|
-
//# sourceMappingURL=client-BPNTLm1-.cjs.map
|