@blocknote/xl-ai 0.39.1 → 0.41.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 +7 -17
- package/dist/blocknote-xl-ai.cjs.map +1 -1
- package/dist/blocknote-xl-ai.js +1860 -1319
- package/dist/blocknote-xl-ai.js.map +1 -1
- package/dist/webpack-stats.json +1 -1
- package/package.json +14 -12
- package/src/AIExtension.ts +165 -98
- package/src/api/aiRequest/defaultAIRequestSender.ts +42 -0
- package/src/api/aiRequest/execute.ts +92 -0
- package/src/api/aiRequest/index.ts +3 -0
- package/src/api/aiRequest/types.ts +52 -0
- package/src/api/formats/PromptBuilder.ts +16 -40
- package/src/api/formats/base-tools/createAddBlocksTool.ts +90 -85
- package/src/api/formats/base-tools/createUpdateBlockTool.ts +67 -75
- package/src/api/formats/base-tools/delete.ts +23 -21
- 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_2b1987665a8c6b76ea1cc84255389571.json +15 -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_d09f092a3a86410797b84afbe6a05773.json +15 -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_ca2502e6ccea5088da25c3f548a88adc.json +15 -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_97ed001b6f5aed92d99361bc27ca0de9.json +15 -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_83b238d8e21398ee970fac58c746fe19.json +15 -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_138de1ba18f0c4a7c084805a95d8aced.json +15 -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_e8b5b0d45734575f7ba8e685f6787aca.json +15 -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_1ac8c5c60083d88192ef7e84254cb786.json +15 -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_a33718ee9e8c30a7679da0e2ea5443bf.json +15 -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_9b1a71da901951950261005a76c3444a.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/Add heading (h1) and code block_1_d64b87442b874d6c9d4a16dcc4f0df14.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/add a list (end)_1_acd39fdc6762628fe6f6f97d96d70a78.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/add a new paragraph (empty doc)_1_3912ffdff061476f701b59e0f28a5515.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/add a new paragraph (end)_1_f047b5323417dfe603d6f28a0f063aa2.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/add a new paragraph (start)_1_6e56df97b3441430062e0b5d979d53c9.json +15 -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_787274f40054195631a7e1b7f70b88f0.json +15 -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_ac04492f6c52be72c3dc24214a0cf744.json +15 -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_5b51dd620d4b53f36159ec97780b2929.json +15 -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_17d834e2d1cae83d1da0998fdfb46c08.json +15 -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_fded5061f67d6e01b6704bcaf1181daa.json +15 -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_c859fc3e363e6b44c406982880adeaf8.json +15 -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_a721c27bc0944c3390dbcf6cbc4aa30d.json +15 -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_fc80a600d06d9b0a834b3a8dc062d077.json +15 -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_ea6525e3996561d49f3baaa53e5f4367.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/add and update paragraph_1_a6ed8e1b1d7287f11052e60d21aa3c61.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/add paragraph and update selection_1_3f688e4336780f36c03fe2e06fb38ae1.json +15 -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_2ac4e99d05838a4666b65cfe9ffceee9.json +15 -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_dafc9c956b17f814f2e5daf2effc4612.json +15 -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_24119724ddeddbe1d724375ad7546eef.json +15 -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_fd0a1c180a2d6c7165823af96ca7a444.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Delete/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/delete first block_1_5c60f0de80e4a010dcf6e7b2f534b1d7.json +15 -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_9ee58319810833bcc30596aa06091958.json +15 -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_327facc19973ed5bf5dfbb06bc842f58.json +15 -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_68d51d1950b2878e08616f9effbee616.json +15 -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_1acc3cfa3a758ee4118f48b99e56f7b5.json +15 -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_9158921bdd72e8f26eed1d4a3ccff6a4.json +15 -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_a2946c73d9c3eeca81e4b4b08213a8a2.json +15 -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_91c94c8501e2f1d5d25c8e9c360dd3d1.json +15 -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_adde6c9d6144449d4c436ed39a9afcb1.json +15 -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_4d2b9b00dc36b2bb12aae561adde829e.json +15 -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_06ade1c91064a7b257315d7cfb3dae1c.json +15 -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_24881d7683d6ecbd852f58f6580259f4.json +15 -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_1c9a4f955e0248798e87ab2412de660d.json +15 -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_9e3a8c2b7c0c40aa89c4b52ccf040007.json +15 -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_d4c19bfff5993efff243e799e4055cc9.json +15 -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_e31071ae9ad80a23786ec0afc5106c32.json +15 -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_efc8d37a125c48a5d0af15ecaf8e4b20.json +15 -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_3ba9845d9c519b43ddbadaddb122d431.json +15 -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_4f6fdb800f1928aed2629f707b95b0da.json +15 -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_b25dd6e47055e54d58f1fd1f18feb14d.json +15 -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_de3f09510d3c3eee14653fe5799dbae7.json +15 -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_d805af33ab12e1bf8f2cb1a055a91fbd.json +15 -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_3b802465d0bbbdbbcb387b14492eefcc.json +15 -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_1138449389739970ddab00e2ca2b4bca.json +15 -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_2f40ee8072a0c34e771a2bd001d04b3a.json +15 -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_3d19c192afee48b2656b6bdf3ac80415.json +15 -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_88d6bccbefaf007c2c02e7e007c0f70b.json +15 -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_89cf6c28cb2ec992330f7c1bdc342068.json +15 -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_b300195a352d5bddf97a0136eeb314e6.json +15 -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_008db1a44c8ee4e4d98c2e62c05f1906.json +15 -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_9a1800c42b72be41038a25622ff00709.json +15 -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_0463e82390d623aec168d4e483a8e7c1.json +15 -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_cf6b0ebb12aa86b848af40e9fa5aa4c6.json +15 -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_2b8a7aa1c2a0945eb657e1784120dabc.json +15 -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_7f14399291525650d7f05c5015dd3b59.json +15 -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_710f89bc66a6352e1c21328e600f2536.json +15 -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_d2ee0ac3b245b97f7a730d85a4575ac3.json +15 -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_d2eeb79d3f7120d2c9d698e3b82c7362.json +15 -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_e22ef915ccf69ed6d2eb9f1a04b86c20.json +15 -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_6d4c550d09a7bfdb440308f277b85a11.json +15 -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_2448cba67be91338d1977d4a980761a6.json +15 -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_88fade9a250bf912d8d65f9db17e6de7.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/clear block formatting_1_67c4abf409c5217946a8fd26353f3d5c.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/drop mark and link and change text within mark_1_4d1645603f58ac95cefa5802e9d0b576.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/drop mark and link_1_8235f32b241ce454e355284db306f2b5.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/modify nested content_1_1e7e3f801e8b2fcad2e947f25b842d59.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/modify parent content_1_06951fbd3511111eb460efd853b4c6ee.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/plain source block, add mention_1_d27b598add3108097cd76a3113395221.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/standard update_1_3e742ef6a27c2a70d6a34483f81b80cd.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/styles + ic in source block, remove mark_1_3157ee5ddce8f578c94b14a1d8ee0694.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/styles + ic in source block, remove mention_1_53046bb3c98a3ecc79d2ccc9f9ee1f88.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/styles + ic in source block, replace content_1_d2aedab8bc5dae6b29a5dd2da56165d7.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/styles + ic in source block, update mention prop_1_fddbbf8781b8c27f9e51a3f0183f370c.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/styles + ic in source block, update text_1_350896c5ea1c2ae3930e8300d37eb670.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/styles + ic in target block, add mark (paragraph)_1_da57da0afcca08a77da5df430ef1db17.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/styles + ic in target block, add mark (word)_1_717f43f6e3302767b191ed31d11b1dd6.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/translate selection_1_0e4c67cc4858f5dfe2f2004e598cdfbd.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/turn paragraphs into list_1_03c3d437686de6faba00429649340a81.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/update block prop and content_1_dd58f52c343818059aa71a9676a172d2.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/update block prop_1_a4f7c3617705406313b619c566afef36.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/update block type and content_1_9b630368d36a8a4420b20bd1e82e455d.json +15 -0
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.responses/gpt-4o-2024-08-06 (streaming + generateObject)/update block type_1_5da70d5932f66c0ba6f5b15bbb05f68e.json +15 -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_ec9d93709e473574521d55108aa27f8f.json +15 -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_6b7b58db82605ee0f2fe5146738274dd.json +15 -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_4fa98468d00af0302fb35faba6aa2823.json +15 -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_e761f6071dd9550f02555f17668007d5.json +15 -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_57bc2951494344f4cd0062fefce14e5f.json +15 -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_88263a5a62758f9c809abbab15d1c4c7.json +15 -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_a68854dc4dee1520292cf8b8816d3bf1.json +15 -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_44bcd73901e9f2eef1a454db1dd3a05d.json +15 -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_89aa084ced0d3526355fa9ec0a7a0f38.json +15 -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_3f251996dcb01d2a4adcb6b548554cc5.json +15 -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_61b231ae85994a3eec1c2eaabb2b3e80.json +15 -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_3fd6871badc2f924056864cd76a571c0.json +15 -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_728e83ee8b26541816af7dcf417e127b.json +15 -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_abd0a85b8c45cfa0b4449a382dc81602.json +15 -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_c0b30a449a94314760b815a202ee6f64.json +15 -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_cfbaa99fe0298f4754b6bdd81c0a9601.json +15 -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_a560a1761f87da8f3bdb7b42357ba4ec.json +15 -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_d959d9e97f6cf99760b26b7d17c11244.json +15 -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_649d6a7338cc6b674c4b4c38184c1037.json +15 -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_9cbb96117eed2b41fee6c0802fe00bb2.json +15 -0
- package/src/api/formats/html-blocks/defaultHTMLPromptBuilder.ts +158 -141
- package/src/api/formats/html-blocks/htmlBlocks.test.ts +71 -16
- package/src/api/formats/html-blocks/htmlBlocks.ts +62 -22
- package/src/api/formats/html-blocks/htmlPromptData.ts +36 -0
- package/src/api/formats/index.ts +72 -0
- package/src/api/formats/json/defaultJSONPromptBuilder.ts +145 -118
- package/src/api/formats/json/errorHandling.test.ts +75 -63
- package/src/api/formats/json/json.test.ts +19 -10
- package/src/api/formats/json/json.ts +70 -27
- package/src/api/formats/json/jsonPromptData.ts +34 -0
- package/src/api/formats/json/tools/jsontools.test.ts +7 -16
- package/src/api/formats/markdown-blocks/defaultMarkdownPromptBuilder.ts +150 -89
- package/src/api/formats/markdown-blocks/markdownBlocks.test.ts +20 -15
- package/src/api/formats/markdown-blocks/markdownBlocks.ts +70 -27
- package/src/api/formats/markdown-blocks/markdownPromptData.ts +38 -1
- package/src/api/formats/tests/sharedTestCases.ts +33 -8
- package/src/api/formats/tests/validateTestEnvironment.test.ts +8 -2
- package/src/api/index.ts +2 -44
- package/src/api/schema/__snapshots__/schemaToJSONSchema.test.ts.snap +2 -55
- package/src/api/schema/schemaToJSONSchema.ts +1 -0
- package/src/blocknoteAIClient/client.ts +14 -70
- package/src/components/AIMenu/AIMenu.tsx +1 -1
- package/src/components/AIMenu/getDefaultAIMenuItems.tsx +49 -36
- package/src/index.ts +2 -3
- package/src/streamTool/StreamToolExecutor.ts +261 -0
- package/src/streamTool/filterNewOrUpdatedOperations.test.ts +17 -4
- package/src/streamTool/filterNewOrUpdatedOperations.ts +5 -1
- package/src/streamTool/filterValidOperations.test.ts +5 -0
- package/src/streamTool/filterValidOperations.ts +4 -0
- package/src/streamTool/index.ts +6 -0
- package/src/streamTool/jsonSchema.ts +3 -1
- package/src/streamTool/preprocess.test.ts +8 -0
- package/src/streamTool/preprocess.ts +7 -0
- package/src/streamTool/streamTool.ts +11 -14
- package/src/streamTool/toValidatedOperations.test.ts +1 -0
- package/src/streamTool/toValidatedOperations.ts +4 -0
- package/src/streamTool/toolDefinitionsToToolSet.ts +24 -0
- package/src/streamTool/vercelAiSdk/clientside/ClientSideTransport.ts +219 -0
- package/src/streamTool/vercelAiSdk/util/UIMessageStreamToOperationsResult.ts +51 -0
- package/src/streamTool/vercelAiSdk/util/chatHandlers.ts +314 -0
- package/src/streamTool/vercelAiSdk/util/partialObjectStreamUtil.ts +120 -0
- package/src/testUtil/cases/editors/blockFormatting.ts +1 -5
- package/src/testUtil/cases/editors/emptyEditor.ts +1 -5
- package/src/testUtil/cases/editors/formattingAndMentions.ts +1 -5
- package/src/testUtil/cases/editors/simpleEditor.ts +2 -10
- package/src/testUtil/cases/editors/tables.ts +1 -5
- package/src/testUtil/cases/updateOperationTestCases.ts +3 -15
- package/src/testUtil/testAIModels.ts +11 -14
- package/src/types.ts +63 -0
- package/src/util/stream.ts +4 -4
- package/types/src/AIExtension.d.ts +14 -42
- package/types/src/api/aiRequest/defaultAIRequestSender.d.ts +4 -0
- package/types/src/api/aiRequest/execute.d.ts +31 -0
- package/types/src/api/aiRequest/index.d.ts +3 -0
- package/types/src/api/aiRequest/types.d.ts +42 -0
- package/types/src/api/formats/PromptBuilder.d.ts +13 -27
- package/types/src/api/formats/base-tools/createUpdateBlockTool.d.ts +2 -2
- package/types/src/api/formats/html-blocks/defaultHTMLPromptBuilder.d.ts +2 -1
- package/types/src/api/formats/html-blocks/htmlBlocks.d.ts +36 -15
- package/types/src/api/formats/html-blocks/htmlPromptData.d.ts +9 -0
- package/types/src/api/formats/index.d.ts +166 -0
- package/types/src/api/formats/json/defaultJSONPromptBuilder.d.ts +3 -2
- package/types/src/api/formats/json/json.d.ts +39 -17
- package/types/src/api/formats/json/jsonPromptData.d.ts +42 -0
- package/types/src/api/formats/markdown-blocks/defaultMarkdownPromptBuilder.d.ts +3 -2
- package/types/src/api/formats/markdown-blocks/markdownBlocks.d.ts +39 -16
- package/types/src/api/formats/markdown-blocks/markdownPromptData.d.ts +30 -0
- package/types/src/api/formats/tests/sharedTestCases.d.ts +2 -6
- package/types/src/api/index.d.ts +2 -74
- package/types/src/blocknoteAIClient/client.d.ts +1 -38
- package/types/src/index.d.ts +2 -1
- package/types/src/streamTool/StreamToolExecutor.d.ts +80 -0
- package/types/src/streamTool/filterNewOrUpdatedOperations.d.ts +2 -1
- package/types/src/streamTool/filterValidOperations.d.ts +3 -0
- package/types/src/streamTool/index.d.ts +6 -0
- package/types/src/streamTool/preprocess.d.ts +7 -0
- package/types/src/streamTool/streamTool.d.ts +14 -15
- package/types/src/streamTool/toValidatedOperations.d.ts +2 -0
- package/types/src/streamTool/toolDefinitionsToToolSet.d.ts +9 -0
- package/types/src/streamTool/vercelAiSdk/clientside/ClientSideTransport.d.ts +109 -0
- package/types/src/streamTool/vercelAiSdk/util/UIMessageStreamToOperationsResult.d.ts +29 -0
- package/types/src/streamTool/vercelAiSdk/util/chatHandlers.d.ts +23 -0
- package/types/src/streamTool/vercelAiSdk/util/partialObjectStreamUtil.d.ts +30 -0
- package/types/src/testUtil/cases/editors/blockFormatting.d.ts +2 -1
- package/types/src/testUtil/cases/editors/formattingAndMentions.d.ts +2 -1
- package/types/src/testUtil/cases/editors/simpleEditor.d.ts +4 -2
- package/types/src/testUtil/cases/editors/tables.d.ts +2 -1
- package/types/src/testUtil/cases/schemas/mention.d.ts +2 -1
- package/types/src/testUtil/testAIModels.d.ts +2 -6
- package/types/src/types.d.ts +56 -0
- package/src/api/LLMRequest.ts +0 -252
- package/src/api/LLMResponse.ts +0 -64
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/Add heading (h1) and code block_1_8bae9cb9166097523db851068d6504ba.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/add a list (end)_1_bec242b33b36b7c791d5079283365125.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/add a new paragraph (empty doc)_1_8d2756d2f902e1a1c5aac5be1490fb37.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/add a new paragraph (end)_1_6065d512019d0bdadfbee0a55778b67e.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/add a new paragraph (start)_1_93f7ef1fdcca3d62f9696e7365cd5065.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/Add heading (h1) and code block_1_306ab5e8c98c3d3fdac6887befcd68fd.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/add a list (end)_1_273d3fdf2847715db07f6462f96e1028.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/add a new paragraph (empty doc)_1_ac8c75b2c0398b6ef7ad81d742349eca.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/add a new paragraph (end)_1_afed58570a68bee9f3eaaeb74bd21481.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/add a new paragraph (start)_1_de9dcee4f9fd594c076066ca9b57ff54.json +0 -15
- 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_300c17e9dfe4cc39a90237be3727f6c5.json +0 -15
- 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_6b4064d98eeaa07a10831d3a5830dbad.json +0 -15
- 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_fe59ff1267687115e7e961232d04f24b.json +0 -15
- 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_1979d1c04b36b4f2eca4cf56d08fa9ff.json +0 -15
- 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_33324c5fa9ff0b55906bc80f2cf29a01.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/Add heading (h1) and code block_1_43fe8c4fb5a1c4ab65bba37dbacdc34d.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/add a list (end)_1_d8165fc89a6e7197e2d91a383efd4b02.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/add a new paragraph (empty doc)_1_f995fb9d1a58b0de101fa3438590e799.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/add a new paragraph (end)_1_dd2333070a2d51e4e3578ac10c3a8939.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/add a new paragraph (start)_1_8f937c4bf5f38d40b8adf2bf35830c82.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/Add heading (h1) and code block_1_00c42d9142f46a774249f0ea4c83087e.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/add a list (end)_1_893055235ef87ad63966a8c0356f9ed2.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/add a new paragraph (empty doc)_1_7af724b09a7de255b40b070289b6dd5c.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/add a new paragraph (end)_1_101445be13e5db1922d2422ca47b6666.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Add/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/add a new paragraph (start)_1_f162fc6430cd63574f46ab6d4fcc9276.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/add and update paragraph_1_0e188d2a921d6dac6d6e40274fb58e46.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/add paragraph and update selection_1_5f7ae491c3449ea3417bff42c10f4c5f.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/add and update paragraph_1_2d61c5a123cae75fe48d74bf26f033a3.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/add paragraph and update selection_1_e1aca3374c81381183ce604542843900.json +0 -15
- 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_607d4d9f46629e45f3851adc6d41d4c2.json +0 -15
- 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_8d3b49c53bee6f8c6b3ec838d43e9443.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/add and update paragraph_1_01e68b70cd8cdf6436f9b06f75ac269d.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/add paragraph and update selection_1_96437051f6bbcb1c7a6e75501a1c3693.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/add and update paragraph_1_4b4bc6bf80353f21d3b81a63e9f3ef54.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Combined/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/add paragraph and update selection_1_40c00fd5cd485b1554b63a856d0ca2b3.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Delete/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/delete first block_1_be4abe78f0900318e7f02b64cd567b48.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Delete/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/delete first block_1_12e70268f615c2e6a251a0c822f5c852.json +0 -15
- 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_af6efe0bca3582e6c8ff21ffc13eba7b.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Delete/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/delete first block_1_732c937802aaa089d01c37b91dcac697.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Delete/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/delete first block_1_30efafef9e27f70713ac6d216c71f723.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/clear block formatting_1_301b672f7c4cbdd034fe74e9c3166861.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/drop mark and link and change text within mark_1_d428f1cf0fef38221f6d7b182d72628d.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/drop mark and link_1_db4f1c714b34a8689f89cf2ea74dd9b1.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/modify nested content_1_48b77b898cf959d0320e944dbf863c00.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/modify parent content_1_7cf017978ca14c4655c187b808add49e.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/plain source block, add mention_1_5ff3afb37a8323d9237d5b95694febb8.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/standard update_1_1b5ea158fc3d646a0ce222198ec31837.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/styles + ic in source block, remove mark_1_ec0dc498f9751250aea1a983b178f851.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/styles + ic in source block, remove mention_1_a3b05a1abb86f585d47c391999382e50.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/styles + ic in source block, replace content_1_b2084dd7f9c0ddf8d8069245f9724d2e.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/styles + ic in source block, update mention prop_1_d36fe6fd5c56cbb5720b8b5f0f1af4de.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/styles + ic in source block, update text_1_29398a2d44edd12095a50d62bd1bf720.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/styles + ic in target block, add mark (paragraph)_1_664975f8855764c9de57ed1aef74e740.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/styles + ic in target block, add mark (word)_1_6f48d6dae797621870e22e8e0f572003.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/translate selection_1_093561699e181778eacfcf52c5b5bce5.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/turn paragraphs into list_1_905c360a779f6015e47aa4f76bb82b6e.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/update block prop and content_1_67f8ed4835e5bf0e13830ee0fa1cf8c8.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/update block prop_1_b37458e2a024cdda800f9b97dfbb7d95.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/update block type and content_1_1eecd846715894269bcff0f0c8809dab.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/anthropic.messages/claude-3-7-sonnet-latest (non-streaming)/update block type_1_8196a2ed33ecf8a9e47b5faf61fcc937.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/clear block formatting_1_350ecafb238090fa055692a72ae42198.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/drop mark and link and change text within mark_1_4c51960ed572671e7cf73db4566e3d99.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/drop mark and link_1_7a6d23fe91e74cf9675ae6e6124fd126.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/modify nested content_1_2535147f7b24a35891e156c4b19d8ffe.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/modify parent content_1_70beec3279ca4894a71d425293fc3ead.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/plain source block, add mention_1_01fbf08ac456e3dbbd64103c41f21a4d.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/standard update_1_51020afd3498ab35dc016c36e1e0c6b8.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/styles + ic in source block, remove mark_1_ad61d6ba098240616fe2106324f993e4.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/styles + ic in source block, remove mention_1_75f14cc4df749a9a1a0a838d62ae2678.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/styles + ic in source block, replace content_1_35f272b43423355f2a5dbbd1e49b4366.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/styles + ic in source block, update mention prop_1_f60fdbb256106a235e820360bc2195ca.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/styles + ic in source block, update text_1_5853e0d779926ddd5b628ed248c652f0.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/styles + ic in target block, add mark (paragraph)_1_865f7c1246731fba1044fe8d23bfab53.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/styles + ic in target block, add mark (word)_1_c9082ff81f975fcc97a7b4564ed31cf6.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/translate selection_1_e40023b9b9cf64ea508c42520ce54a92.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/turn paragraphs into list_1_739c4ae60051cce107204609e30188d6.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/update block prop and content_1_5a277f291beced18ef6642e6452c04f8.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/update block prop_1_8194a0fd672e45b8537bb497f8ad3bb0.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/update block type and content_1_808d14b549ccb577b7baa1c33e8433d1.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (non-streaming)/update block type_1_16f9143c5a28bfa65954cba662a9e644.json +0 -15
- 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_2f6f4db35e78d9a8094fa7f0cc5a6fef.json +0 -15
- 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_f67f3cef3589a8792080e7fb090b1226.json +0 -15
- 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_9056181b23b2cd23325d52c3eeb6ee16.json +0 -15
- 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_85a23c1da349e0f8dac714957ed75c79.json +0 -15
- 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_5ef368a4d58c5d3af10ffe058545324d.json +0 -15
- 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_5ac53cae2b0994f5de466affabaad58e.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/standard update_1_a534dfa8d9008a473a02fcb64bd645c7.json +0 -15
- 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_db0b2afe5c635db1fbd2fd9e5c66c2a6.json +0 -15
- 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_698e87bd13c88c31da2b4d97ed62aa8a.json +0 -15
- 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_54e5c87345fd2adc7bc1aa015fb7ed49.json +0 -15
- 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_fc03fd7d02657b4546b13e3e8a3a2bee.json +0 -15
- 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_ae27bd5c696279c7555747ebab7f882e.json +0 -15
- 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_ad1bbdc50acb8c57cbcb55e00134b956.json +0 -15
- 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_f65378b4068dbaa6e4b2f12247582a3d.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/groq.chat/llama-3.3-70b-versatile (streaming)/translate selection_1_a4057cb73ed9ba6b58bfc3440182ab52.json +0 -15
- 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_d193ecd4799fc5ca01c16b383bbfae8e.json +0 -15
- 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_cd366ecb6835f6ad416e56246d772258.json +0 -15
- 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_dcd828e95a6f35a02dc80f83ce865246.json +0 -15
- 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_b409676f3c38fab14dbfcf469c084b61.json +0 -15
- 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_8035279de2d825570eb857243ac085d3.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/clear block formatting_1_4220ed611dd1396b8eaefaef1a93aa3d.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/drop mark and link and change text within mark_1_5752bbf6a6ab425496886ae0c16fa252.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/drop mark and link_1_fc4c8d212e083aeb086ecc97f89172cc.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/modify nested content_1_07027383a583a8622324d5fb3c6b47ef.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/modify parent content_1_432effc8a8203853eed4a05822cfb1c0.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/plain source block, add mention_1_a5a6fbbb73ac75d5318976205c211175.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/standard update_1_55ce5796bcf58df91ac364bf5da3c062.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/styles + ic in source block, remove mark_1_fd35ea1690888e3b9fdd6cd7e3cdf21d.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/styles + ic in source block, remove mention_1_f08ba8bc1f3562acc7d724c17d5f78c5.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/styles + ic in source block, replace content_1_90cbcfafa2e6f6897e82793db3d31620.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/styles + ic in source block, update mention prop_1_1f44d9313ad815027c9c904006e12c1f.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/styles + ic in source block, update text_1_412767e25cd81b316089d06262ab5f8f.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/styles + ic in target block, add mark (paragraph)_1_357e3e9924f91ecb50a561b8373474f2.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/styles + ic in target block, add mark (word)_1_0912f446c3f834669ba44c0666b7ad8a.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/translate selection_1_169e840a93c457a3980841bce584f8b4.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/turn paragraphs into list_1_46c8a46a056cc6f89953c4402d583718.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/update block prop and content_1_3121104fb353eb2bca2395575f057107.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/update block prop_1_fe9102e572088ab37c69a84ef83a452c.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/update block type and content_1_62527380200c30745a8e04e2aa459e3d.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (non-streaming)/update block type_1_3236a5c1b691839e51b0cd3787a7947f.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/clear block formatting_1_43253dee16b03b1f16101ced5bddfc93.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/drop mark and link and change text within mark_1_92fde43139365369266b63a2b6e2d0b2.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/drop mark and link_1_8336a355b6037db27d810a3f3a2fdb9c.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/modify nested content_1_0e25723621acc3c5e0fa98bbbc1b8426.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/modify parent content_1_329ea2aac9bc7887fb77b9165483286c.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/plain source block, add mention_1_fb00f31bc9fd64a65ead6c56df2a6f46.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/standard update_1_aed8c5658597a148c7fe740ef98aa03d.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/styles + ic in source block, remove mark_1_bd46c569d016618aeacaa2514b6f4906.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/styles + ic in source block, remove mention_1_e25641c56a8cc1fdca49a1d3ff5db2b4.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/styles + ic in source block, replace content_1_1ba1a4b5441db5f015f9ef75218f87a3.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/styles + ic in source block, update mention prop_1_4ae245b2bc01d569f87f98827e4ca6b1.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/styles + ic in source block, update text_1_97807fd69b67c1c3e79e678fba3ecfcd.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/styles + ic in target block, add mark (paragraph)_1_d6c7f981af0a2837c6cd85da3d297974.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/styles + ic in target block, add mark (word)_1_8ead2588e1bc1366b02cfded465fc8d4.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/translate selection_1_c2c3a06cd8eb6901e2007575eca77530.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/turn paragraphs into list_1_8ae508a1ba8354be0703f5bc89561691.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/update block prop and content_1_e0330a1df29640d9ff657ad9037bc203.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/update block prop_1_673b8e9ca4d59db999abd61ed34ec305.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/update block type and content_1_605daff442fc8684c6d126269f2aba3b.json +0 -15
- package/src/api/formats/html-blocks/__snapshots__/htmlBlocks.test.ts/Update/__msw_snapshots__/openai.chat/gpt-4o-2024-08-06 (streaming)/update block type_1_78e5c1f637c725aef379fd2b7f7551bf.json +0 -15
- package/src/streamTool/asTool.ts +0 -44
- package/src/streamTool/callLLMWithStreamTools.ts +0 -362
- package/types/src/api/LLMRequest.d.ts +0 -116
- package/types/src/api/LLMResponse.d.ts +0 -51
- package/types/src/streamTool/asTool.d.ts +0 -15
- package/types/src/streamTool/callLLMWithStreamTools.d.ts +0 -74
package/dist/blocknote-xl-ai.js
CHANGED
|
@@ -1,35 +1,37 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
1
|
+
var ot = Object.defineProperty;
|
|
2
|
+
var rt = (e, t, o) => t in e ? ot(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
|
|
3
|
+
var M = (e, t, o) => rt(e, typeof t != "symbol" ? t + "" : t, o);
|
|
4
|
+
import { Chat as nt } from "@ai-sdk/react";
|
|
5
|
+
import { getPmSchema as st, UnreachableCaseError as Be, getNodeById as Me, updateBlockTr as it, insertBlocks as at, trackPosition as ae, removeAndInsertBlocks as lt, getBlock as Ee, defaultProps as _e, isStyledTextInlineContent as ct, isLinkInlineContent as ut, BlockNoteExtension as dt, filterSuggestionItems as pt, mergeCSSClasses as mt } from "@blocknote/core";
|
|
6
|
+
import { applySuggestions as Ne, suggestChanges as ft, revertSuggestions as le } from "@blocknote/prosemirror-suggest-changes";
|
|
7
|
+
import { Slice as G, Fragment as ce } from "prosemirror-model";
|
|
8
|
+
import { TextSelection as ht, Plugin as Le, PluginKey as Ae } from "prosemirror-state";
|
|
9
|
+
import { fixTablesKey as yt } from "prosemirror-tables";
|
|
10
|
+
import { DecorationSet as ue, Decoration as de } from "prosemirror-view";
|
|
11
|
+
import { defaultSelectionBuilder as gt } from "y-prosemirror";
|
|
9
12
|
import bt from "lodash.isequal";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
const de = (e) => {
|
|
13
|
+
import { getErrorMessage as K } from "@ai-sdk/provider-utils";
|
|
14
|
+
import { parsePartialJson as De, isToolUIPart as kt, tool as St, jsonSchema as pe, generateObject as wt, convertToModelMessages as Y, streamObject as Tt, streamText as xt } from "ai";
|
|
15
|
+
import { Transform as D, Mapping as je, ReplaceStep as N, ReplaceAroundStep as vt } from "prosemirror-transform";
|
|
16
|
+
import { ChangeSet as me, simplifyChanges as Pt } from "prosemirror-changeset";
|
|
17
|
+
import { jsxs as Ct, jsx as y } from "react/jsx-runtime";
|
|
18
|
+
import { useBlockNoteContext as Ot, useComponentsContext as X, useSuggestionMenuKeyboardHandler as It, useBlockNoteEditor as Q, useUIElementPositioning as Bt } from "@blocknote/react";
|
|
19
|
+
import E, { useState as $e, useCallback as $, useMemo as A, useEffect as He } from "react";
|
|
20
|
+
import { useStore as qe } from "zustand";
|
|
21
|
+
import { offset as Mt, size as Et, autoUpdate as _t } from "@floating-ui/react";
|
|
22
|
+
const fe = (e) => {
|
|
21
23
|
let t;
|
|
22
|
-
const o = /* @__PURE__ */ new Set(), r = (
|
|
23
|
-
const
|
|
24
|
-
if (!Object.is(
|
|
25
|
-
const
|
|
26
|
-
t =
|
|
24
|
+
const o = /* @__PURE__ */ new Set(), r = (c, u) => {
|
|
25
|
+
const m = typeof c == "function" ? c(t) : c;
|
|
26
|
+
if (!Object.is(m, t)) {
|
|
27
|
+
const p = t;
|
|
28
|
+
t = u ?? (typeof m != "object" || m === null) ? m : Object.assign({}, t, m), o.forEach((d) => d(t, p));
|
|
27
29
|
}
|
|
28
|
-
}, n = () => t, i = { setState: r, getState: n, getInitialState: () =>
|
|
30
|
+
}, n = () => t, i = { setState: r, getState: n, getInitialState: () => l, subscribe: (c) => (o.add(c), () => o.delete(c)) }, l = t = e(r, n, i);
|
|
29
31
|
return i;
|
|
30
|
-
},
|
|
31
|
-
function
|
|
32
|
-
const { properties: t, required: o, $defs: r, ...n } = e.
|
|
32
|
+
}, he = (e) => e ? fe(e) : fe;
|
|
33
|
+
function Nt(e) {
|
|
34
|
+
const { properties: t, required: o, $defs: r, ...n } = e.inputSchema;
|
|
33
35
|
return {
|
|
34
36
|
schema: {
|
|
35
37
|
type: "object",
|
|
@@ -48,8 +50,8 @@ function Lt(e) {
|
|
|
48
50
|
$defs: r
|
|
49
51
|
};
|
|
50
52
|
}
|
|
51
|
-
function
|
|
52
|
-
const t = e.map((r) =>
|
|
53
|
+
function Lt(e) {
|
|
54
|
+
const t = e.map((r) => Nt(r)), o = {};
|
|
53
55
|
for (const r of t)
|
|
54
56
|
for (const n in r.$defs) {
|
|
55
57
|
if (o[n] && !bt(o[n], r.$defs[n]))
|
|
@@ -60,6 +62,8 @@ function je(e) {
|
|
|
60
62
|
type: "object",
|
|
61
63
|
properties: {
|
|
62
64
|
operations: {
|
|
65
|
+
//description:
|
|
66
|
+
// "Operations to apply to the document. Put all operations in this array in ONE tool call / function call. DO NOT use multiple operation arrays with parallel tool calls.",
|
|
63
67
|
type: "array",
|
|
64
68
|
items: {
|
|
65
69
|
anyOf: t.map((r) => r.schema)
|
|
@@ -71,7 +75,170 @@ function je(e) {
|
|
|
71
75
|
$defs: Object.keys(o).length > 0 ? o : void 0
|
|
72
76
|
};
|
|
73
77
|
}
|
|
74
|
-
function
|
|
78
|
+
function At(e, t) {
|
|
79
|
+
return {
|
|
80
|
+
async sendAIRequest(o, r) {
|
|
81
|
+
const n = await t(o);
|
|
82
|
+
return await e(o.chat.messages, n), o.chat.sendMessage(void 0, {
|
|
83
|
+
...r,
|
|
84
|
+
body: {
|
|
85
|
+
...(r == null ? void 0 : r.body) ?? {},
|
|
86
|
+
toolDefinitions: {
|
|
87
|
+
applyDocumentOperations: {
|
|
88
|
+
name: "applyDocumentOperations",
|
|
89
|
+
inputSchema: Lt(o.streamTools),
|
|
90
|
+
outputSchema: { type: "object" }
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
// we pass the promptData as metadata
|
|
95
|
+
// so the transport can decide whether or not to submit this to the server
|
|
96
|
+
// (DefaultChatTransport will not)
|
|
97
|
+
metadata: { promptData: n }
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
class ze extends Error {
|
|
103
|
+
constructor(t, o, r) {
|
|
104
|
+
super(t, r), this.chunk = o, this.name = "ChunkExecutionError";
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
class Dt {
|
|
108
|
+
/**
|
|
109
|
+
* @param streamTools - The StreamTools to use to apply the StreamToolCalls
|
|
110
|
+
*/
|
|
111
|
+
constructor(t) {
|
|
112
|
+
M(this, "stream");
|
|
113
|
+
this.streamTools = t, this.stream = this.createStream();
|
|
114
|
+
}
|
|
115
|
+
createStream() {
|
|
116
|
+
let t;
|
|
117
|
+
const o = new TransformStream({
|
|
118
|
+
transform: async (i, l) => {
|
|
119
|
+
const c = typeof i == "string" ? await jt(
|
|
120
|
+
i,
|
|
121
|
+
(t == null ? void 0 : t.isPossiblyPartial) ?? !1,
|
|
122
|
+
this.streamTools
|
|
123
|
+
) : i;
|
|
124
|
+
c && (t = c, l.enqueue(c));
|
|
125
|
+
},
|
|
126
|
+
flush: (i) => {
|
|
127
|
+
t != null && t.isPossiblyPartial && i.error(new Error("stream ended with a partial operation"));
|
|
128
|
+
}
|
|
129
|
+
}), r = o.readable.pipeThrough(this.createExecutor()), [n, s] = r.tee(), a = n.pipeTo(new WritableStream());
|
|
130
|
+
return {
|
|
131
|
+
writable: o.writable,
|
|
132
|
+
// expose externalReadable to the consumer
|
|
133
|
+
readable: s,
|
|
134
|
+
finishPromise: a
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
createExecutor() {
|
|
138
|
+
const t = this.streamTools.map((o) => o.executor());
|
|
139
|
+
return new TransformStream({
|
|
140
|
+
transform: async (o, r) => {
|
|
141
|
+
var s;
|
|
142
|
+
let n = !1;
|
|
143
|
+
for (const a of t)
|
|
144
|
+
try {
|
|
145
|
+
if (await a.execute(o)) {
|
|
146
|
+
r.enqueue({ status: "ok", chunk: o }), n = !0;
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
} catch (i) {
|
|
150
|
+
throw new ze(
|
|
151
|
+
`Tool execution failed: ${K(i)}`,
|
|
152
|
+
o,
|
|
153
|
+
{
|
|
154
|
+
cause: i
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
if (!n) {
|
|
159
|
+
const a = ((s = o.operation) == null ? void 0 : s.type) || "unknown";
|
|
160
|
+
throw new Error(
|
|
161
|
+
`No tool could handle operation of type: ${a}`
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Returns a WritableStream that can be used to write StreamToolCalls to the executor.
|
|
169
|
+
*
|
|
170
|
+
* The WriteableStream accepts JSON strings or Operation objects.
|
|
171
|
+
*
|
|
172
|
+
* Make sure to call `close` on the StreamToolExecutor instead of on the writable returned here!
|
|
173
|
+
*/
|
|
174
|
+
get writable() {
|
|
175
|
+
return this.stream.writable;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Returns a ReadableStream that can be used to read the results of the executor.
|
|
179
|
+
*/
|
|
180
|
+
get readable() {
|
|
181
|
+
return this.stream.readable;
|
|
182
|
+
}
|
|
183
|
+
async finish() {
|
|
184
|
+
await this.stream.finishPromise;
|
|
185
|
+
}
|
|
186
|
+
async executeOperationsArray(t) {
|
|
187
|
+
const o = this.writable.getWriter();
|
|
188
|
+
for await (const r of t) {
|
|
189
|
+
const n = await De(r);
|
|
190
|
+
if (n.state === "undefined-input" || n.state === "failed-parse" || !n)
|
|
191
|
+
return;
|
|
192
|
+
await o.write(r);
|
|
193
|
+
}
|
|
194
|
+
await o.close(), await this.finish();
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Accepts an async iterable and writes each chunk to the internal stream.
|
|
198
|
+
*
|
|
199
|
+
* (alternative to writing to the writable stream using {@link writable})
|
|
200
|
+
*/
|
|
201
|
+
async execute(t) {
|
|
202
|
+
const o = this.writable.getWriter();
|
|
203
|
+
for await (const r of t)
|
|
204
|
+
await o.write(r);
|
|
205
|
+
await o.close(), await this.finish();
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Accepts a single chunk and processes it using the same logic.
|
|
209
|
+
*
|
|
210
|
+
* (alternative to writing to the writable stream using {@link writable})
|
|
211
|
+
*/
|
|
212
|
+
async executeOne(t) {
|
|
213
|
+
await this.execute(
|
|
214
|
+
async function* () {
|
|
215
|
+
yield {
|
|
216
|
+
operation: t,
|
|
217
|
+
isUpdateToPreviousOperation: !1,
|
|
218
|
+
isPossiblyPartial: !1,
|
|
219
|
+
metadata: {}
|
|
220
|
+
};
|
|
221
|
+
}()
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
async function jt(e, t, o) {
|
|
226
|
+
const r = await De(e);
|
|
227
|
+
if (r.state === "undefined-input" || r.state === "failed-parse" || !r)
|
|
228
|
+
return;
|
|
229
|
+
const n = o.find((a) => {
|
|
230
|
+
var i;
|
|
231
|
+
return a.name === ((i = r.value) == null ? void 0 : i.type);
|
|
232
|
+
}), s = n && n.validate(r.value);
|
|
233
|
+
if (s != null && s.ok)
|
|
234
|
+
return {
|
|
235
|
+
operation: s.value,
|
|
236
|
+
isPossiblyPartial: r.state === "repaired-parse",
|
|
237
|
+
isUpdateToPreviousOperation: t,
|
|
238
|
+
metadata: void 0
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
function $t(e) {
|
|
75
242
|
return new ReadableStream({
|
|
76
243
|
async start(t) {
|
|
77
244
|
try {
|
|
@@ -84,7 +251,7 @@ function _t(e) {
|
|
|
84
251
|
}
|
|
85
252
|
});
|
|
86
253
|
}
|
|
87
|
-
function
|
|
254
|
+
function Je(e) {
|
|
88
255
|
if (e.locked)
|
|
89
256
|
throw new Error(
|
|
90
257
|
"Stream (source) is already locked and cannot be iterated."
|
|
@@ -102,47 +269,50 @@ function N(e) {
|
|
|
102
269
|
};
|
|
103
270
|
}, t;
|
|
104
271
|
}
|
|
105
|
-
function
|
|
106
|
-
return
|
|
107
|
-
}
|
|
108
|
-
async function*
|
|
109
|
-
var
|
|
110
|
-
let
|
|
111
|
-
for await (const
|
|
112
|
-
if ((
|
|
113
|
-
for (let
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
partialOperation:
|
|
117
|
-
isUpdateToPreviousOperation:
|
|
118
|
-
isPossiblyPartial:
|
|
119
|
-
|
|
272
|
+
function Ht(e) {
|
|
273
|
+
return Je($t(e));
|
|
274
|
+
}
|
|
275
|
+
async function* qt(e, t) {
|
|
276
|
+
var s;
|
|
277
|
+
let o = 0, r = !0, n;
|
|
278
|
+
for await (const a of e)
|
|
279
|
+
if ((s = a.operations) != null && s.length) {
|
|
280
|
+
for (let i = o; i < a.operations.length; i++) {
|
|
281
|
+
const l = a.operations[i];
|
|
282
|
+
n = l, yield {
|
|
283
|
+
partialOperation: l,
|
|
284
|
+
isUpdateToPreviousOperation: i === o && !r,
|
|
285
|
+
isPossiblyPartial: i === a.operations.length - 1,
|
|
286
|
+
metadata: t
|
|
287
|
+
}, r = !1;
|
|
120
288
|
}
|
|
121
|
-
|
|
289
|
+
o = a.operations.length - 1;
|
|
122
290
|
}
|
|
123
|
-
if (!
|
|
291
|
+
if (!n)
|
|
124
292
|
throw new Error("No operations seen");
|
|
125
293
|
yield {
|
|
126
|
-
partialOperation:
|
|
294
|
+
partialOperation: n,
|
|
127
295
|
isUpdateToPreviousOperation: !0,
|
|
128
|
-
isPossiblyPartial: !1
|
|
296
|
+
isPossiblyPartial: !1,
|
|
297
|
+
metadata: t
|
|
129
298
|
};
|
|
130
299
|
}
|
|
131
|
-
async function*
|
|
300
|
+
async function* zt(e, t) {
|
|
132
301
|
let o = !1;
|
|
133
302
|
for await (const r of e) {
|
|
134
303
|
const n = r.operation;
|
|
135
304
|
n.ok ? (yield {
|
|
136
305
|
operation: n.value,
|
|
137
306
|
isUpdateToPreviousOperation: o ? !1 : r.isUpdateToPreviousOperation,
|
|
138
|
-
isPossiblyPartial: r.isPossiblyPartial
|
|
307
|
+
isPossiblyPartial: r.isPossiblyPartial,
|
|
308
|
+
metadata: r.metadata
|
|
139
309
|
}, o = !1) : (o = o || !r.isUpdateToPreviousOperation, t == null || t({
|
|
140
310
|
...r,
|
|
141
311
|
operation: n
|
|
142
312
|
}));
|
|
143
313
|
}
|
|
144
314
|
}
|
|
145
|
-
async function*
|
|
315
|
+
async function* Jt(e, t) {
|
|
146
316
|
for await (const o of e) {
|
|
147
317
|
const r = t.find(
|
|
148
318
|
(s) => s.name === o.partialOperation.type
|
|
@@ -154,23 +324,25 @@ async function* Re(e, t) {
|
|
|
154
324
|
error: `No matching function for ${o.partialOperation.type}`
|
|
155
325
|
},
|
|
156
326
|
isUpdateToPreviousOperation: o.isUpdateToPreviousOperation,
|
|
157
|
-
isPossiblyPartial: o.isPossiblyPartial
|
|
327
|
+
isPossiblyPartial: o.isPossiblyPartial,
|
|
328
|
+
metadata: o.metadata
|
|
158
329
|
};
|
|
159
330
|
continue;
|
|
160
331
|
}
|
|
161
332
|
yield {
|
|
162
333
|
operation: r.validate(o.partialOperation),
|
|
163
334
|
isUpdateToPreviousOperation: o.isUpdateToPreviousOperation,
|
|
164
|
-
isPossiblyPartial: o.isPossiblyPartial
|
|
335
|
+
isPossiblyPartial: o.isPossiblyPartial,
|
|
336
|
+
metadata: o.metadata
|
|
165
337
|
};
|
|
166
338
|
}
|
|
167
339
|
}
|
|
168
|
-
async function*
|
|
169
|
-
const o =
|
|
340
|
+
async function* Ut(e, t) {
|
|
341
|
+
const o = Jt(
|
|
170
342
|
e,
|
|
171
343
|
t
|
|
172
344
|
);
|
|
173
|
-
yield*
|
|
345
|
+
yield* zt(
|
|
174
346
|
o,
|
|
175
347
|
(n) => {
|
|
176
348
|
if (!n.isPossiblyPartial)
|
|
@@ -178,225 +350,147 @@ async function* Et(e, t) {
|
|
|
178
350
|
}
|
|
179
351
|
);
|
|
180
352
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
353
|
+
function Vt(e, t, o) {
|
|
354
|
+
return Ht(
|
|
355
|
+
Ut(
|
|
356
|
+
qt(
|
|
357
|
+
Je(e),
|
|
358
|
+
o
|
|
359
|
+
),
|
|
360
|
+
t
|
|
361
|
+
)
|
|
191
362
|
);
|
|
192
363
|
}
|
|
193
|
-
async function
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
364
|
+
async function Ft(e, t, o) {
|
|
365
|
+
const r = new Dt(e), n = Rt();
|
|
366
|
+
n.output.pipeTo(r.writable);
|
|
367
|
+
const s = /* @__PURE__ */ new Map();
|
|
368
|
+
let a = !0;
|
|
369
|
+
const i = t["~registerMessagesCallback"](() => {
|
|
370
|
+
Zt(t, (d) => {
|
|
371
|
+
if (!s.has(d.toolCallId)) {
|
|
372
|
+
const h = Wt(
|
|
373
|
+
e,
|
|
374
|
+
d.toolName,
|
|
375
|
+
d.toolCallId
|
|
376
|
+
);
|
|
377
|
+
n.append(h.operationsStream), s.set(d.toolCallId, h), a && (a = !1, o == null || o());
|
|
378
|
+
}
|
|
379
|
+
return s.get(d.toolCallId);
|
|
380
|
+
});
|
|
381
|
+
});
|
|
382
|
+
await new Promise((d) => {
|
|
383
|
+
const h = t["~registerStatusCallback"](() => {
|
|
384
|
+
(t.status === "ready" || t.status === "error") && (i(), h(), t.status !== "error" && f(), d());
|
|
385
|
+
}), f = t["~registerErrorCallback"](() => {
|
|
386
|
+
if (t.error) {
|
|
387
|
+
f();
|
|
388
|
+
for (const k of s.values())
|
|
389
|
+
k.complete || k.writer.abort(t.error);
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
}), await n.finalize();
|
|
393
|
+
const c = (await Promise.allSettled([r.finish()]))[0];
|
|
394
|
+
let u;
|
|
395
|
+
if (c.status === "rejected") {
|
|
396
|
+
if (c.reason instanceof ze)
|
|
397
|
+
u = c.reason;
|
|
398
|
+
else if (!t.error)
|
|
399
|
+
throw new Error(
|
|
400
|
+
"Unexpected: no ChunkExecutionError but also no chat.error (network error?)"
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
let m = !1;
|
|
404
|
+
const p = Array.from(
|
|
405
|
+
s.values().filter((d) => d.complete)
|
|
406
|
+
);
|
|
407
|
+
if (p.forEach((d, h) => {
|
|
408
|
+
const f = d.toolCallId === (u == null ? void 0 : u.chunk.metadata.toolCallId);
|
|
409
|
+
f && (m = !0), t.addToolResult({
|
|
410
|
+
tool: p[h].toolName,
|
|
411
|
+
toolCallId: p[h].toolCallId,
|
|
412
|
+
output: m === !1 ? { status: "ok" } : f ? { status: "error", error: K(u) } : { status: "not-executed-previous-tool-errored" }
|
|
413
|
+
});
|
|
414
|
+
}), u)
|
|
415
|
+
throw u;
|
|
416
|
+
if (t.error)
|
|
417
|
+
throw t.error;
|
|
418
|
+
}
|
|
419
|
+
function Rt() {
|
|
420
|
+
let e, t = Promise.resolve(), o = !1;
|
|
421
|
+
const r = new ReadableStream({
|
|
422
|
+
start(a) {
|
|
423
|
+
e = a;
|
|
225
424
|
},
|
|
226
|
-
|
|
227
|
-
|
|
425
|
+
cancel(a) {
|
|
426
|
+
o = !0, e.error(a);
|
|
228
427
|
}
|
|
229
|
-
};
|
|
428
|
+
});
|
|
429
|
+
async function n(a) {
|
|
430
|
+
if (o)
|
|
431
|
+
throw new Error("Appendable stream canceled, can't append");
|
|
432
|
+
const i = a.getReader();
|
|
433
|
+
return t = t.then(async () => {
|
|
434
|
+
for (; ; )
|
|
435
|
+
try {
|
|
436
|
+
const { done: l, value: c } = await i.read();
|
|
437
|
+
if (l || o)
|
|
438
|
+
break;
|
|
439
|
+
e.enqueue(c);
|
|
440
|
+
} catch (l) {
|
|
441
|
+
o = !0, e.error(l);
|
|
442
|
+
break;
|
|
443
|
+
}
|
|
444
|
+
}), t;
|
|
445
|
+
}
|
|
446
|
+
async function s() {
|
|
447
|
+
await t, o || e.close();
|
|
448
|
+
}
|
|
449
|
+
return { output: r, append: n, finalize: s };
|
|
230
450
|
}
|
|
231
|
-
function
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
partialOperation: r,
|
|
242
|
-
isUpdateToPreviousOperation: !1,
|
|
243
|
-
isPossiblyPartial: !1
|
|
244
|
-
};
|
|
451
|
+
function Zt(e, t) {
|
|
452
|
+
var o;
|
|
453
|
+
for (const r of ((o = e.lastMessage) == null ? void 0 : o.parts) ?? []) {
|
|
454
|
+
if (!kt(r) || r.type.replace("tool-", "") !== "applyDocumentOperations")
|
|
455
|
+
continue;
|
|
456
|
+
const s = r.toolCallId, a = t({
|
|
457
|
+
toolName: r.type.replace("tool-", ""),
|
|
458
|
+
toolCallId: s
|
|
459
|
+
});
|
|
460
|
+
Yt(r, a);
|
|
245
461
|
}
|
|
246
|
-
return {
|
|
247
|
-
ok: !0,
|
|
248
|
-
value: o()
|
|
249
|
-
};
|
|
250
462
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
// non-overridable options for streamObject
|
|
258
|
-
output: "object",
|
|
259
|
-
schema: xe(je(e)),
|
|
260
|
-
// configurable options for streamObject
|
|
261
|
-
// - optional, with defaults
|
|
262
|
-
// mistral somehow needs "auto", while groq/llama needs "tool"
|
|
263
|
-
// google needs "auto" because https://github.com/vercel/ai/issues/6959
|
|
264
|
-
// TODO: further research this and / or make configurable
|
|
265
|
-
// for now stick to "tool" by default as this has been tested mostly
|
|
266
|
-
mode: n.model.provider === "mistral.chat" || n.model.provider === "google.generative-ai" ? "auto" : "tool",
|
|
267
|
-
// - mandatory ones:
|
|
268
|
-
...n,
|
|
269
|
-
// extra options for streamObject
|
|
270
|
-
...t._streamObjectOptions ?? {}
|
|
271
|
-
}, i = pt(a);
|
|
272
|
-
let c;
|
|
273
|
-
const [u, p] = i.fullStream.tee(), l = (async () => {
|
|
274
|
-
let f = {
|
|
275
|
-
operations: []
|
|
276
|
-
};
|
|
277
|
-
const m = N(
|
|
278
|
-
Ht(p)
|
|
279
|
-
);
|
|
280
|
-
for await (const h of m)
|
|
281
|
-
h && typeof h == "object" && "operations" in h && (f = h);
|
|
282
|
-
return f;
|
|
283
|
-
})();
|
|
463
|
+
function Wt(e, t, o) {
|
|
464
|
+
const r = new TransformStream(), n = Vt(
|
|
465
|
+
r.readable,
|
|
466
|
+
e,
|
|
467
|
+
{ toolCallId: o }
|
|
468
|
+
);
|
|
284
469
|
return {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
Rt(
|
|
293
|
-
N(u)
|
|
294
|
-
),
|
|
295
|
-
o
|
|
296
|
-
)
|
|
297
|
-
),
|
|
298
|
-
e
|
|
299
|
-
)
|
|
300
|
-
)), c;
|
|
301
|
-
},
|
|
302
|
-
async getGeneratedOperations() {
|
|
303
|
-
return l;
|
|
304
|
-
}
|
|
470
|
+
// stream,
|
|
471
|
+
writer: r.writable.getWriter(),
|
|
472
|
+
complete: !1,
|
|
473
|
+
// executor,
|
|
474
|
+
operationsStream: n,
|
|
475
|
+
toolName: t,
|
|
476
|
+
toolCallId: o
|
|
305
477
|
};
|
|
306
478
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
o &&
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
switch (t.type) {
|
|
318
|
-
case "object":
|
|
319
|
-
o.enqueue(t.object);
|
|
320
|
-
break;
|
|
321
|
-
case "text-delta":
|
|
322
|
-
case "finish":
|
|
323
|
-
break;
|
|
324
|
-
case "error":
|
|
325
|
-
o.error(t.error);
|
|
326
|
-
break;
|
|
327
|
-
default: {
|
|
328
|
-
const r = t;
|
|
329
|
-
throw new Error(`Unsupported chunk type: ${r}`);
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
})
|
|
334
|
-
)
|
|
335
|
-
);
|
|
336
|
-
}
|
|
337
|
-
function Ht(e) {
|
|
338
|
-
return N(
|
|
339
|
-
e.pipeThrough(
|
|
340
|
-
new TransformStream({
|
|
341
|
-
transform(t, o) {
|
|
342
|
-
switch (t.type) {
|
|
343
|
-
case "object":
|
|
344
|
-
o.enqueue(t.object);
|
|
345
|
-
break;
|
|
346
|
-
case "text-delta":
|
|
347
|
-
case "finish":
|
|
348
|
-
break;
|
|
349
|
-
case "error":
|
|
350
|
-
break;
|
|
351
|
-
default: {
|
|
352
|
-
const r = t;
|
|
353
|
-
throw new Error(`Unsupported chunk type: ${r}`);
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
})
|
|
358
|
-
)
|
|
359
|
-
);
|
|
479
|
+
function Yt(e, t) {
|
|
480
|
+
if (e.state === "input-streaming") {
|
|
481
|
+
const o = e.input;
|
|
482
|
+
o !== void 0 && t.writer.write(o);
|
|
483
|
+
} else if (e.state === "input-available") {
|
|
484
|
+
const o = e.input;
|
|
485
|
+
if (o === void 0)
|
|
486
|
+
throw new Error("input is undefined");
|
|
487
|
+
t.complete || (t.complete = !0, t.writer.write(o), t.writer.close());
|
|
488
|
+
}
|
|
360
489
|
}
|
|
361
|
-
function
|
|
490
|
+
function ee(e) {
|
|
362
491
|
return (e.type === "paragraph" || !e.type) && !e.content || Array.isArray(e.content) && e.content.length === 0;
|
|
363
492
|
}
|
|
364
|
-
|
|
365
|
-
/**
|
|
366
|
-
* @internal
|
|
367
|
-
*/
|
|
368
|
-
constructor(t, o, r) {
|
|
369
|
-
this.messages = t, this.llmResult = o, this.streamTools = r;
|
|
370
|
-
}
|
|
371
|
-
/**
|
|
372
|
-
* Apply the operations to the editor and return a stream of results.
|
|
373
|
-
*
|
|
374
|
-
* (this method consumes underlying streams in `llmResult`)
|
|
375
|
-
*/
|
|
376
|
-
async *applyToolCalls() {
|
|
377
|
-
let t = this.llmResult.operationsSource;
|
|
378
|
-
for (const o of this.streamTools)
|
|
379
|
-
t = o.execute(t);
|
|
380
|
-
yield* t;
|
|
381
|
-
}
|
|
382
|
-
/**
|
|
383
|
-
* Helper method to apply all operations to the editor if you're not interested in intermediate operations and results.
|
|
384
|
-
*
|
|
385
|
-
* (this method consumes underlying streams in `llmResult`)
|
|
386
|
-
*/
|
|
387
|
-
async execute() {
|
|
388
|
-
for await (const t of this.applyToolCalls())
|
|
389
|
-
;
|
|
390
|
-
}
|
|
391
|
-
/**
|
|
392
|
-
* @internal
|
|
393
|
-
*/
|
|
394
|
-
async _logToolCalls() {
|
|
395
|
-
for await (const t of this.llmResult.operationsSource)
|
|
396
|
-
console.log(JSON.stringify(t, null, 2));
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
function Ut(e, t, o = !0, r = !0) {
|
|
493
|
+
function Gt(e, t, o = !0, r = !0) {
|
|
400
494
|
let n = 0, s = e.length;
|
|
401
495
|
if (o)
|
|
402
496
|
for (; n < s && t(e[n]); )
|
|
@@ -406,15 +500,208 @@ function Ut(e, t, o = !0, r = !0) {
|
|
|
406
500
|
s--;
|
|
407
501
|
return e.slice(n, s);
|
|
408
502
|
}
|
|
409
|
-
function
|
|
410
|
-
return
|
|
503
|
+
function w(e, t) {
|
|
504
|
+
return Gt(
|
|
411
505
|
e,
|
|
412
|
-
(r) =>
|
|
506
|
+
(r) => ee(r) && (t == null ? void 0 : t.cursorBlockId) !== r.id,
|
|
413
507
|
(t == null ? void 0 : t.trimStart) ?? !1,
|
|
414
508
|
(t == null ? void 0 : t.trimEnd) ?? !0
|
|
415
509
|
);
|
|
416
510
|
}
|
|
417
|
-
function
|
|
511
|
+
function Kt(e) {
|
|
512
|
+
const { useSelection: t, deleteEmptyCursorBlock: o, streamToolsProvider: r } = {
|
|
513
|
+
useSelection: e.useSelection ?? !1,
|
|
514
|
+
deleteEmptyCursorBlock: e.deleteEmptyCursorBlock ?? !0,
|
|
515
|
+
streamToolsProvider: e.streamToolsProvider ?? O.html.getStreamToolsProvider()
|
|
516
|
+
}, n = t ? void 0 : e.editor.getTextCursorPosition().block, s = n && o && ee(n) && w(e.editor.document).length > 0 ? n.id : void 0, a = t ? e.editor.getSelectionCutBlocks() : void 0, i = r.getStreamTools(
|
|
517
|
+
e.editor,
|
|
518
|
+
a ? {
|
|
519
|
+
from: a._meta.startPos,
|
|
520
|
+
to: a._meta.endPos
|
|
521
|
+
} : void 0,
|
|
522
|
+
e.onBlockUpdated
|
|
523
|
+
);
|
|
524
|
+
return {
|
|
525
|
+
editor: e.editor,
|
|
526
|
+
chat: e.chat,
|
|
527
|
+
userPrompt: e.userPrompt,
|
|
528
|
+
selectedBlocks: a == null ? void 0 : a.blocks,
|
|
529
|
+
streamTools: i,
|
|
530
|
+
emptyCursorBlockToDelete: s
|
|
531
|
+
};
|
|
532
|
+
}
|
|
533
|
+
async function Xt(e) {
|
|
534
|
+
const { aiRequest: t, sender: o, chatRequestOptions: r, onStart: n } = e, s = Ft(
|
|
535
|
+
t.streamTools,
|
|
536
|
+
t.chat,
|
|
537
|
+
() => {
|
|
538
|
+
n == null || n(), t.emptyCursorBlockToDelete && t.editor.getBlock(t.emptyCursorBlockToDelete) && t.editor.removeBlocks([t.emptyCursorBlockToDelete]);
|
|
539
|
+
}
|
|
540
|
+
);
|
|
541
|
+
await o.sendAIRequest(t, r), await s;
|
|
542
|
+
}
|
|
543
|
+
function Qt(e, t) {
|
|
544
|
+
e.length > 0 && e.push(
|
|
545
|
+
{
|
|
546
|
+
role: "assistant",
|
|
547
|
+
id: "document-state-" + e.length,
|
|
548
|
+
parts: [
|
|
549
|
+
{
|
|
550
|
+
type: "text",
|
|
551
|
+
text: "This is the latest state of the selection (ignore previous selections, you MUST issue operations against this latest version of the selection):"
|
|
552
|
+
},
|
|
553
|
+
{
|
|
554
|
+
type: "text",
|
|
555
|
+
text: JSON.stringify(t.htmlSelectedBlocks)
|
|
556
|
+
},
|
|
557
|
+
{
|
|
558
|
+
type: "text",
|
|
559
|
+
text: "This is the latest state of the document (INCLUDING the selected text), find the selected text in there to understand the context:"
|
|
560
|
+
},
|
|
561
|
+
{
|
|
562
|
+
type: "text",
|
|
563
|
+
text: JSON.stringify(t.htmlDocument)
|
|
564
|
+
}
|
|
565
|
+
]
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
role: "user",
|
|
569
|
+
id: "user-prompt-" + e.length,
|
|
570
|
+
parts: [
|
|
571
|
+
{
|
|
572
|
+
type: "text",
|
|
573
|
+
text: "The user asks you to do the following:"
|
|
574
|
+
},
|
|
575
|
+
{
|
|
576
|
+
type: "text",
|
|
577
|
+
text: t.userPrompt
|
|
578
|
+
}
|
|
579
|
+
]
|
|
580
|
+
}
|
|
581
|
+
), e.push(
|
|
582
|
+
{
|
|
583
|
+
role: "system",
|
|
584
|
+
id: "document-state-intro",
|
|
585
|
+
parts: [
|
|
586
|
+
{
|
|
587
|
+
type: "text",
|
|
588
|
+
text: "You're manipulating a selected part of a text document using HTML blocks. \n Make sure to follow the json schema provided and always include the trailing $ in ids.\n 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.\n This is the selection as an array of html blocks:"
|
|
589
|
+
}
|
|
590
|
+
]
|
|
591
|
+
},
|
|
592
|
+
{
|
|
593
|
+
role: "system",
|
|
594
|
+
id: "document-state-selection",
|
|
595
|
+
parts: [
|
|
596
|
+
{
|
|
597
|
+
type: "text",
|
|
598
|
+
text: JSON.stringify(t.htmlSelectedBlocks)
|
|
599
|
+
}
|
|
600
|
+
]
|
|
601
|
+
},
|
|
602
|
+
{
|
|
603
|
+
role: "system",
|
|
604
|
+
id: "document-state-context",
|
|
605
|
+
parts: [
|
|
606
|
+
{
|
|
607
|
+
type: "text",
|
|
608
|
+
text: "This is the entire document (INCLUDING the selected text), find the selected text in there to understand the context:"
|
|
609
|
+
},
|
|
610
|
+
{
|
|
611
|
+
type: "text",
|
|
612
|
+
text: JSON.stringify(t.htmlDocument)
|
|
613
|
+
}
|
|
614
|
+
]
|
|
615
|
+
},
|
|
616
|
+
{
|
|
617
|
+
role: "user",
|
|
618
|
+
id: "user-prompt",
|
|
619
|
+
parts: [
|
|
620
|
+
{
|
|
621
|
+
type: "text",
|
|
622
|
+
text: t.userPrompt
|
|
623
|
+
}
|
|
624
|
+
]
|
|
625
|
+
}
|
|
626
|
+
);
|
|
627
|
+
}
|
|
628
|
+
function eo(e, t) {
|
|
629
|
+
if (e.length > 0) {
|
|
630
|
+
e.push(
|
|
631
|
+
{
|
|
632
|
+
role: "assistant",
|
|
633
|
+
id: "document-state-" + e.length,
|
|
634
|
+
parts: [
|
|
635
|
+
{
|
|
636
|
+
type: "text",
|
|
637
|
+
text: "This is the latest state of the document (ignore previous documents, you MUST issue operations against this latest version of the document):"
|
|
638
|
+
},
|
|
639
|
+
{
|
|
640
|
+
type: "text",
|
|
641
|
+
text: JSON.stringify(t.htmlBlocks)
|
|
642
|
+
}
|
|
643
|
+
]
|
|
644
|
+
},
|
|
645
|
+
{
|
|
646
|
+
role: "user",
|
|
647
|
+
id: "user-prompt-" + e.length,
|
|
648
|
+
parts: [
|
|
649
|
+
{
|
|
650
|
+
type: "text",
|
|
651
|
+
text: t.userPrompt
|
|
652
|
+
}
|
|
653
|
+
]
|
|
654
|
+
}
|
|
655
|
+
);
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
e.push(
|
|
659
|
+
{
|
|
660
|
+
role: "system",
|
|
661
|
+
id: "document-state-intro",
|
|
662
|
+
parts: [
|
|
663
|
+
{
|
|
664
|
+
type: "text",
|
|
665
|
+
text: "You're manipulating a text document using HTML blocks. \n Make sure to follow the json schema provided. When referencing ids they MUST be EXACTLY the same (including the trailing $). \n 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.\n For code blocks, you can use the `data-language` attribute on a <code> block (wrapped with <pre>) to specify the language.\n This is the initial document as an array of html blocks (the cursor is BETWEEN two blocks as indicated by cursor: true):"
|
|
666
|
+
}
|
|
667
|
+
]
|
|
668
|
+
},
|
|
669
|
+
{
|
|
670
|
+
role: "system",
|
|
671
|
+
id: "document-state-data",
|
|
672
|
+
parts: [
|
|
673
|
+
{
|
|
674
|
+
type: "text",
|
|
675
|
+
text: JSON.stringify(t.htmlBlocks)
|
|
676
|
+
}
|
|
677
|
+
]
|
|
678
|
+
},
|
|
679
|
+
{
|
|
680
|
+
role: "system",
|
|
681
|
+
id: "extended-instructions",
|
|
682
|
+
parts: [
|
|
683
|
+
{
|
|
684
|
+
type: "text",
|
|
685
|
+
text: 'First, determine what part of the document the user is talking about. You SHOULD probably take cursor info into account if needed.\n EXAMPLE: if user says "below" (without pointing to a specific part of the document) he / she probably indicates the block(s) after the cursor. \n EXAMPLE: If you want to insert content AT the cursor position (UNLESS indicated otherwise by the user), \n then you need `referenceId` to point to the block before the cursor with position `after` (or block below and `before`).\n \n ' + (t.isEmptyDocument ? "Because the document is empty, 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).")
|
|
686
|
+
}
|
|
687
|
+
]
|
|
688
|
+
},
|
|
689
|
+
{
|
|
690
|
+
role: "user",
|
|
691
|
+
id: "user-prompt",
|
|
692
|
+
parts: [
|
|
693
|
+
{
|
|
694
|
+
type: "text",
|
|
695
|
+
text: t.userPrompt
|
|
696
|
+
}
|
|
697
|
+
]
|
|
698
|
+
}
|
|
699
|
+
);
|
|
700
|
+
}
|
|
701
|
+
const to = async (e, t) => {
|
|
702
|
+
t.selection ? Qt(e, t) : eo(e, t);
|
|
703
|
+
};
|
|
704
|
+
function Z(e, t) {
|
|
418
705
|
const o = e.getTextCursorPosition(), r = [];
|
|
419
706
|
for (const n of t) {
|
|
420
707
|
const s = n.id === o.block.id;
|
|
@@ -427,7 +714,7 @@ function F(e, t) {
|
|
|
427
714
|
}
|
|
428
715
|
return r;
|
|
429
716
|
}
|
|
430
|
-
async function
|
|
717
|
+
async function P(e, t) {
|
|
431
718
|
return await Promise.all(e.map(async (o) => ({
|
|
432
719
|
id: o.id,
|
|
433
720
|
block: await t(o)
|
|
@@ -442,215 +729,109 @@ function T(e) {
|
|
|
442
729
|
...T(t.children)
|
|
443
730
|
]);
|
|
444
731
|
}
|
|
445
|
-
function
|
|
732
|
+
function _(e) {
|
|
446
733
|
return e.map((t) => typeof t == "object" && t && "id" in t ? {
|
|
447
734
|
...t,
|
|
448
735
|
id: `${t.id}$`
|
|
449
736
|
} : t);
|
|
450
737
|
}
|
|
451
|
-
async function
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
738
|
+
async function oo(e) {
|
|
739
|
+
return e.selectedBlocks ? {
|
|
740
|
+
...await Ve(e.editor, {
|
|
741
|
+
selectedBlocks: e.selectedBlocks
|
|
742
|
+
}),
|
|
743
|
+
userPrompt: e.userPrompt
|
|
744
|
+
} : {
|
|
745
|
+
...await Ue(e.editor, {
|
|
746
|
+
excludeBlockIds: e.emptyCursorBlockToDelete ? [e.emptyCursorBlockToDelete] : void 0
|
|
747
|
+
}),
|
|
748
|
+
userPrompt: e.userPrompt
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
async function Ue(e, t) {
|
|
752
|
+
const o = w(e.document).length === 0, r = e.getTextCursorPosition().block.id, n = w(e.document, {
|
|
753
|
+
cursorBlockId: r
|
|
754
|
+
}), s = await P(
|
|
755
|
+
T(n),
|
|
456
756
|
async (c) => e.blocksToHTMLLossy([c])
|
|
457
|
-
),
|
|
757
|
+
), i = Z(e, s).filter(
|
|
458
758
|
(c) => "cursor" in c || !(t.excludeBlockIds || []).includes(c.id)
|
|
459
759
|
);
|
|
460
760
|
return {
|
|
461
|
-
|
|
761
|
+
selection: !1,
|
|
762
|
+
htmlBlocks: _(i),
|
|
763
|
+
isEmptyDocument: o
|
|
462
764
|
};
|
|
463
765
|
}
|
|
464
|
-
async function
|
|
465
|
-
const o = await
|
|
766
|
+
async function Ve(e, t) {
|
|
767
|
+
const o = w(e.document).length === 0, r = await P(
|
|
466
768
|
T(t.selectedBlocks),
|
|
467
|
-
async (
|
|
468
|
-
);
|
|
769
|
+
async (s) => e.blocksToHTMLLossy([s])
|
|
770
|
+
), n = _(r);
|
|
469
771
|
return {
|
|
470
|
-
|
|
471
|
-
|
|
772
|
+
isEmptyDocument: o,
|
|
773
|
+
selection: !0,
|
|
774
|
+
htmlSelectedBlocks: n,
|
|
775
|
+
htmlDocument: (await P(T(e.document), async (s) => e.blocksToHTMLLossy([s]))).map(({ block: s }) => ({ block: s }))
|
|
472
776
|
// strip ids so LLM can't accidentally issue updates to ids not in selection
|
|
473
777
|
};
|
|
474
778
|
}
|
|
475
|
-
function
|
|
476
|
-
return [
|
|
477
|
-
{
|
|
478
|
-
role: "system",
|
|
479
|
-
content: "You're manipulating a selected part of a text document using HTML blocks. \n Make sure to follow the json schema provided and always include the trailing $ in ids. \n 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.\n This is the selection as an array of html blocks:"
|
|
480
|
-
},
|
|
481
|
-
{
|
|
482
|
-
role: "system",
|
|
483
|
-
content: JSON.stringify(e.htmlSelectedBlocks)
|
|
484
|
-
},
|
|
485
|
-
{
|
|
486
|
-
role: "system",
|
|
487
|
-
content: "This is the entire document (INCLUDING the selected text), find the selected text in there to understand the context:"
|
|
488
|
-
},
|
|
489
|
-
{
|
|
490
|
-
role: "system",
|
|
491
|
-
content: JSON.stringify(e.htmlDocument)
|
|
492
|
-
},
|
|
493
|
-
{
|
|
494
|
-
role: "system",
|
|
495
|
-
content: "The user asks you to do the following:"
|
|
496
|
-
},
|
|
497
|
-
{
|
|
498
|
-
role: "user",
|
|
499
|
-
content: e.userPrompt
|
|
500
|
-
}
|
|
501
|
-
];
|
|
502
|
-
}
|
|
503
|
-
function Ft(e) {
|
|
504
|
-
return [
|
|
505
|
-
{
|
|
506
|
-
role: "system",
|
|
507
|
-
content: "You're manipulating a text document using HTML blocks. \n Make sure to follow the json schema provided. When referencing ids they MUST be EXACTLY the same (including the trailing $). \n 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.\n For code blocks, you can use the `data-language` attribute on a code block to specify the language.\n This is the document as an array of html blocks (the cursor is BETWEEN two blocks as indicated by cursor: true):"
|
|
508
|
-
},
|
|
509
|
-
{
|
|
510
|
-
role: "system",
|
|
511
|
-
content: JSON.stringify(e.htmlBlocks)
|
|
512
|
-
},
|
|
513
|
-
{
|
|
514
|
-
role: "system",
|
|
515
|
-
content: 'First, determine what part of the document the user is talking about. You SHOULD probably take cursor info into account if needed.\n EXAMPLE: if user says "below" (without pointing to a specific part of the document) he / she probably indicates the block(s) after the cursor. \n EXAMPLE: If you want to insert content AT the cursor position (UNLESS indicated otherwise by the user), \n then you need `referenceId` to point to the block before the cursor with position `after` (or block below and `before`).\n \n ' + (e.isEmptyDocument ? "Because the document is empty, 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).")
|
|
516
|
-
},
|
|
517
|
-
{
|
|
518
|
-
role: "system",
|
|
519
|
-
content: "The user asks you to do the following:"
|
|
520
|
-
},
|
|
521
|
-
{
|
|
522
|
-
role: "user",
|
|
523
|
-
content: e.userPrompt
|
|
524
|
-
}
|
|
525
|
-
];
|
|
526
|
-
}
|
|
527
|
-
const Jt = async (e, t) => {
|
|
528
|
-
const o = x(e.document).length === 0;
|
|
529
|
-
if (t.selectedBlocks) {
|
|
530
|
-
const r = await qe(e, {
|
|
531
|
-
selectedBlocks: t.selectedBlocks
|
|
532
|
-
});
|
|
533
|
-
return t.previousMessages ? [
|
|
534
|
-
...t.previousMessages,
|
|
535
|
-
{
|
|
536
|
-
role: "system",
|
|
537
|
-
content: `After processing the previous response, this is the updated selection.
|
|
538
|
-
Ignore previous documents, you MUST issue operations against this latest version of the document:`
|
|
539
|
-
},
|
|
540
|
-
{
|
|
541
|
-
role: "system",
|
|
542
|
-
content: JSON.stringify(r.htmlSelectedBlocks)
|
|
543
|
-
},
|
|
544
|
-
{
|
|
545
|
-
role: "system",
|
|
546
|
-
content: "This is the updated entire document:"
|
|
547
|
-
},
|
|
548
|
-
{
|
|
549
|
-
role: "system",
|
|
550
|
-
content: JSON.stringify(r.htmlDocument)
|
|
551
|
-
},
|
|
552
|
-
{
|
|
553
|
-
role: "system",
|
|
554
|
-
content: `You SHOULD use "update" operations to update blocks you added / edited previously
|
|
555
|
-
(unless the user explicitly asks you otherwise to add or delete other blocks).
|
|
556
|
-
|
|
557
|
-
The user now asks you to do the following:`
|
|
558
|
-
},
|
|
559
|
-
{
|
|
560
|
-
role: "user",
|
|
561
|
-
content: t.userPrompt
|
|
562
|
-
}
|
|
563
|
-
] : zt({
|
|
564
|
-
...r,
|
|
565
|
-
userPrompt: t.userPrompt
|
|
566
|
-
});
|
|
567
|
-
} else {
|
|
568
|
-
const r = await He(e, t);
|
|
569
|
-
return t.previousMessages ? [
|
|
570
|
-
...t.previousMessages,
|
|
571
|
-
{
|
|
572
|
-
role: "system",
|
|
573
|
-
content: `After processing the previous response, this is the updated document.
|
|
574
|
-
Ignore previous documents, you MUST issue operations against this latest version of the document:`
|
|
575
|
-
},
|
|
576
|
-
{
|
|
577
|
-
role: "system",
|
|
578
|
-
content: JSON.stringify(r.htmlBlocks)
|
|
579
|
-
},
|
|
580
|
-
{
|
|
581
|
-
role: "system",
|
|
582
|
-
content: `You SHOULD use "update" operations to update blocks you added / edited previously
|
|
583
|
-
(unless the user explicitly asks you otherwise to add or delete other blocks).
|
|
584
|
-
|
|
585
|
-
The user now asks you to do the following:`
|
|
586
|
-
},
|
|
587
|
-
{
|
|
588
|
-
role: "user",
|
|
589
|
-
content: t.userPrompt
|
|
590
|
-
}
|
|
591
|
-
] : Ft({
|
|
592
|
-
...r,
|
|
593
|
-
userPrompt: t.userPrompt,
|
|
594
|
-
isEmptyDocument: o
|
|
595
|
-
});
|
|
596
|
-
}
|
|
597
|
-
};
|
|
598
|
-
function Vt(e) {
|
|
779
|
+
function ro(e) {
|
|
599
780
|
let t, o = !1;
|
|
600
781
|
return e.descendants((r, n) => o ? !1 : (r.isText && (o = !0, t = n), !0)), t;
|
|
601
782
|
}
|
|
602
|
-
function
|
|
783
|
+
function J(e) {
|
|
603
784
|
var s;
|
|
604
|
-
const t =
|
|
785
|
+
const t = st(e), { modification: o } = t.marks, r = [], n = new D(e.before);
|
|
605
786
|
for (let a = 0; a < e.steps.length; a++) {
|
|
606
|
-
const i = e.steps[a],
|
|
787
|
+
const i = e.steps[a], l = new je(e.mapping.maps.slice(0, a)).invert();
|
|
607
788
|
if (i.structure) {
|
|
608
|
-
if (i instanceof
|
|
789
|
+
if (i instanceof N) {
|
|
609
790
|
if (i.to !== i.from + 1 || i.slice.openStart !== 0 || i.slice.openEnd !== 1 || i.slice.content.size !== 2)
|
|
610
791
|
throw new Error(
|
|
611
792
|
"Structure change is not in expected format (ReplaceStep)"
|
|
612
793
|
);
|
|
613
|
-
} else if (i instanceof
|
|
794
|
+
} else if (i instanceof vt) {
|
|
614
795
|
if (i.insert !== 1 || i.slice.size !== 2 || i.gapTo !== i.to - 1 || i.gapFrom !== i.from + 1)
|
|
615
796
|
throw new Error(
|
|
616
797
|
"Structure change is not in expected format (ReplaceAroundStep)"
|
|
617
798
|
);
|
|
618
799
|
} else
|
|
619
800
|
throw new Error("Step is not a ReplaceStep or ReplaceAroundStep");
|
|
620
|
-
const b =
|
|
621
|
-
let
|
|
622
|
-
g.type !==
|
|
801
|
+
const b = l.map(i.from), g = i.slice.content.firstChild, v = n.doc.resolve(n.mapping.map(b)).nodeAfter;
|
|
802
|
+
let S = g.marks || [];
|
|
803
|
+
g.type !== v.type && (S = o.create({
|
|
623
804
|
type: "nodeType",
|
|
624
|
-
previousValue:
|
|
805
|
+
previousValue: v.type.name,
|
|
625
806
|
newValue: g.type.name
|
|
626
|
-
}).addToSet(
|
|
807
|
+
}).addToSet(S));
|
|
627
808
|
const j = /* @__PURE__ */ new Set([
|
|
628
809
|
...Object.keys(g.attrs),
|
|
629
|
-
...Object.keys(
|
|
810
|
+
...Object.keys(v.attrs)
|
|
630
811
|
]);
|
|
631
|
-
for (const
|
|
632
|
-
g.attrs[
|
|
812
|
+
for (const C of j)
|
|
813
|
+
g.attrs[C] !== v.attrs[C] && (S = o.create({
|
|
633
814
|
type: "attr",
|
|
634
|
-
attrName:
|
|
635
|
-
previousValue:
|
|
636
|
-
newValue: g.attrs[
|
|
637
|
-
}).addToSet(
|
|
638
|
-
const
|
|
815
|
+
attrName: C,
|
|
816
|
+
previousValue: v.attrs[C],
|
|
817
|
+
newValue: g.attrs[C]
|
|
818
|
+
}).addToSet(S));
|
|
819
|
+
const B = n.steps.length;
|
|
639
820
|
n.setNodeMarkup(
|
|
640
821
|
n.mapping.map(b),
|
|
641
822
|
g.type,
|
|
642
823
|
g.attrs,
|
|
643
|
-
|
|
824
|
+
S
|
|
644
825
|
), r.push({
|
|
645
|
-
prosemirrorSteps: n.steps.slice(
|
|
826
|
+
prosemirrorSteps: n.steps.slice(B),
|
|
646
827
|
selection: void 0,
|
|
647
828
|
type: "replace"
|
|
648
829
|
});
|
|
649
830
|
continue;
|
|
650
831
|
}
|
|
651
|
-
if (!(i instanceof
|
|
832
|
+
if (!(i instanceof N))
|
|
652
833
|
throw new Error("Step is not a ReplaceStep");
|
|
653
|
-
const
|
|
834
|
+
const c = l.map(i.from), u = l.map(i.to);
|
|
654
835
|
if (i.slice.openStart > 0 || i.slice.openEnd > 0)
|
|
655
836
|
throw new Error(
|
|
656
837
|
"Slice has openStart or openEnd > 0, but structure=false"
|
|
@@ -658,60 +839,60 @@ function R(e) {
|
|
|
658
839
|
r.push({
|
|
659
840
|
prosemirrorSteps: [],
|
|
660
841
|
selection: {
|
|
661
|
-
anchor: n.mapping.map(
|
|
662
|
-
head: n.mapping.map(
|
|
842
|
+
anchor: n.mapping.map(c),
|
|
843
|
+
head: n.mapping.map(u)
|
|
663
844
|
},
|
|
664
845
|
type: "select"
|
|
665
846
|
});
|
|
666
|
-
const
|
|
667
|
-
let
|
|
668
|
-
if (
|
|
669
|
-
|
|
670
|
-
else if (
|
|
671
|
-
|
|
847
|
+
const m = i.slice.content.textBetween(0, i.slice.size), p = m === n.doc.textBetween(n.mapping.map(c), n.mapping.map(u));
|
|
848
|
+
let d;
|
|
849
|
+
if (p)
|
|
850
|
+
d = i.slice.content.size;
|
|
851
|
+
else if (m.length === 0)
|
|
852
|
+
d = i.slice.content.size;
|
|
672
853
|
else {
|
|
673
|
-
const b =
|
|
854
|
+
const b = ro(i.slice.content);
|
|
674
855
|
if (b === void 0)
|
|
675
856
|
throw new Error("unexpected: no first character found");
|
|
676
|
-
|
|
857
|
+
d = b + 1;
|
|
677
858
|
}
|
|
678
|
-
let h = n.mapping.map(
|
|
679
|
-
const
|
|
680
|
-
let
|
|
681
|
-
for (let b =
|
|
682
|
-
const g =
|
|
859
|
+
let h = n.mapping.map(u);
|
|
860
|
+
const f = n.mapping.map(u);
|
|
861
|
+
let k = !0;
|
|
862
|
+
for (let b = d; b <= i.slice.content.size; b++) {
|
|
863
|
+
const g = k && c !== u, v = n.steps.length;
|
|
683
864
|
if (g) {
|
|
684
|
-
const
|
|
685
|
-
(s =
|
|
865
|
+
const B = n.doc.resolve(n.mapping.map(c));
|
|
866
|
+
(s = B.nodeAfter) != null && s.isBlock && n.addNodeMark(B.pos, t.mark("deletion", {})), n.addMark(B.pos, h, t.mark("deletion", {})), h = n.mapping.map(u);
|
|
686
867
|
}
|
|
687
|
-
const
|
|
688
|
-
n.replace(
|
|
689
|
-
|
|
690
|
-
|
|
868
|
+
const S = new G(i.slice.content.cut(0, b), 0, 0);
|
|
869
|
+
n.replace(f, h, S).addMark(
|
|
870
|
+
f,
|
|
871
|
+
f + S.content.size,
|
|
691
872
|
t.mark("insertion", {})
|
|
692
873
|
), n.doc.nodesBetween(
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
(
|
|
696
|
-
), h = n.mapping.slice(
|
|
697
|
-
const j =
|
|
698
|
-
n.doc.resolve(
|
|
874
|
+
f,
|
|
875
|
+
f + S.content.size,
|
|
876
|
+
(B, C) => C < f || C > f + S.content.size ? !0 : (B.isBlock && n.addNodeMark(C, t.mark("insertion", {})), !1)
|
|
877
|
+
), h = n.mapping.slice(v).map(h);
|
|
878
|
+
const j = ht.near(
|
|
879
|
+
n.doc.resolve(f + S.content.size),
|
|
699
880
|
-1
|
|
700
881
|
);
|
|
701
882
|
r.push({
|
|
702
|
-
prosemirrorSteps: n.steps.slice(
|
|
883
|
+
prosemirrorSteps: n.steps.slice(v),
|
|
703
884
|
selection: {
|
|
704
885
|
anchor: j.from,
|
|
705
886
|
head: j.from
|
|
706
887
|
},
|
|
707
888
|
type: g ? "replace" : "insert"
|
|
708
889
|
// 3. Insert the replacement character by character
|
|
709
|
-
}),
|
|
890
|
+
}), k = !1;
|
|
710
891
|
}
|
|
711
892
|
}
|
|
712
893
|
return r;
|
|
713
894
|
}
|
|
714
|
-
async function
|
|
895
|
+
async function te(e) {
|
|
715
896
|
const t = Math.random() * 0.3 + 0.85;
|
|
716
897
|
if (e.type === "select")
|
|
717
898
|
await new Promise((o) => setTimeout(o, 100 * t));
|
|
@@ -720,9 +901,9 @@ async function Q(e) {
|
|
|
720
901
|
else if (e.type === "replace")
|
|
721
902
|
await new Promise((o) => setTimeout(o, 200 * t));
|
|
722
903
|
else
|
|
723
|
-
throw new
|
|
904
|
+
throw new Be(e.type);
|
|
724
905
|
}
|
|
725
|
-
function
|
|
906
|
+
function oe(e, t) {
|
|
726
907
|
e.setMeta("addToHistory", !1), t.selection && e.setMeta("aiAgent", {
|
|
727
908
|
selection: {
|
|
728
909
|
anchor: t.selection.anchor,
|
|
@@ -734,10 +915,10 @@ function ee(e, t) {
|
|
|
734
915
|
throw new Error("failed to apply step");
|
|
735
916
|
return e;
|
|
736
917
|
}
|
|
737
|
-
function
|
|
738
|
-
const r = new
|
|
918
|
+
function no(e, t, o) {
|
|
919
|
+
const r = new D(t);
|
|
739
920
|
for (const a of e) {
|
|
740
|
-
const i = new
|
|
921
|
+
const i = new N(
|
|
741
922
|
r.mapping.map(a.fromA),
|
|
742
923
|
r.mapping.map(a.toA),
|
|
743
924
|
o.slice(a.fromB, a.toB)
|
|
@@ -750,27 +931,27 @@ function Zt(e, t, o) {
|
|
|
750
931
|
const a = o.resolve(s).nodeAfter, i = r.doc.resolve(s).nodeAfter;
|
|
751
932
|
if (!a || !i)
|
|
752
933
|
throw new Error("diffNode not found");
|
|
753
|
-
const
|
|
754
|
-
let
|
|
755
|
-
for (let
|
|
756
|
-
if (e[
|
|
757
|
-
|
|
934
|
+
const l = !a.isLeaf && a.content.eq(i.content), c = l ? 1 : Math.min(a.nodeSize, i.nodeSize), u = s + c, m = n.map(s), p = n.map(u);
|
|
935
|
+
let d = e.length;
|
|
936
|
+
for (let f = 0; f < e.length; f++)
|
|
937
|
+
if (e[f].fromA >= p) {
|
|
938
|
+
d = f;
|
|
758
939
|
break;
|
|
759
940
|
}
|
|
760
|
-
e.splice(
|
|
761
|
-
fromA:
|
|
762
|
-
toA:
|
|
941
|
+
e.splice(d, 0, {
|
|
942
|
+
fromA: m,
|
|
943
|
+
toA: p,
|
|
763
944
|
fromB: s,
|
|
764
|
-
toB:
|
|
945
|
+
toB: u,
|
|
765
946
|
deleted: [],
|
|
766
947
|
inserted: [],
|
|
767
|
-
type:
|
|
948
|
+
type: l ? "node-type-or-attr-update" : "mark-update"
|
|
768
949
|
}), r.step(
|
|
769
|
-
new
|
|
950
|
+
new N(
|
|
770
951
|
s,
|
|
771
|
-
|
|
772
|
-
o.slice(s,
|
|
773
|
-
|
|
952
|
+
u,
|
|
953
|
+
o.slice(s, u),
|
|
954
|
+
l
|
|
774
955
|
)
|
|
775
956
|
);
|
|
776
957
|
const h = r.doc.content.findDiffStart(o.content);
|
|
@@ -780,7 +961,7 @@ function Zt(e, t, o) {
|
|
|
780
961
|
}
|
|
781
962
|
return e;
|
|
782
963
|
}
|
|
783
|
-
const
|
|
964
|
+
const ye = (e, t) => {
|
|
784
965
|
const o = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
|
|
785
966
|
e.descendants((a) => {
|
|
786
967
|
a.type.name === "tableCell" && o.add(JSON.stringify(a.toJSON()));
|
|
@@ -809,81 +990,81 @@ const pe = (e, t) => {
|
|
|
809
990
|
compareTokens: (a, i) => a === i
|
|
810
991
|
};
|
|
811
992
|
};
|
|
812
|
-
function
|
|
813
|
-
const s =
|
|
814
|
-
|
|
993
|
+
function W(e, t, o = !1, r, n) {
|
|
994
|
+
const s = Me(e.id, t), a = new D(t);
|
|
995
|
+
it(
|
|
815
996
|
a,
|
|
816
997
|
s.posBeforeNode,
|
|
817
998
|
e.block,
|
|
818
999
|
r,
|
|
819
1000
|
n
|
|
820
1001
|
);
|
|
821
|
-
let i = a.doc,
|
|
1002
|
+
let i = a.doc, l = me.create(
|
|
822
1003
|
t,
|
|
823
1004
|
void 0,
|
|
824
|
-
|
|
1005
|
+
ye(t, i)
|
|
825
1006
|
);
|
|
826
|
-
if (
|
|
827
|
-
const
|
|
828
|
-
if (
|
|
1007
|
+
if (l = l.addSteps(i, a.mapping.maps, 0), o && l.changes.length > 0) {
|
|
1008
|
+
const m = l.changes[l.changes.length - 1], p = m.toA - m.fromA, d = m.toB - m.fromB;
|
|
1009
|
+
if (p > d) {
|
|
829
1010
|
const h = t.slice(
|
|
830
|
-
|
|
831
|
-
|
|
1011
|
+
m.fromA + d,
|
|
1012
|
+
m.toA
|
|
832
1013
|
);
|
|
833
1014
|
a.step(
|
|
834
|
-
new
|
|
835
|
-
), i = a.doc,
|
|
836
|
-
|
|
1015
|
+
new N(m.toB, m.toB, h)
|
|
1016
|
+
), i = a.doc, l = me.create(
|
|
1017
|
+
l.startDoc,
|
|
837
1018
|
void 0,
|
|
838
|
-
|
|
839
|
-
),
|
|
1019
|
+
ye(l.startDoc, i)
|
|
1020
|
+
), l = l.addSteps(i, a.mapping.maps, 0);
|
|
840
1021
|
}
|
|
841
1022
|
}
|
|
842
|
-
const
|
|
843
|
-
|
|
1023
|
+
const c = [], u = Pt(
|
|
1024
|
+
l.changes,
|
|
844
1025
|
i
|
|
845
1026
|
);
|
|
846
|
-
for (let
|
|
847
|
-
const
|
|
848
|
-
if (
|
|
1027
|
+
for (let m = 0; m < u.length; m++) {
|
|
1028
|
+
const p = u[m], d = i.slice(p.fromB, p.toB);
|
|
1029
|
+
if (d.openEnd === 1 && d.openStart === 0 && (p.type = "node-type-or-attr-update", d.size > 2)) {
|
|
849
1030
|
const h = {
|
|
850
|
-
fromA:
|
|
851
|
-
toA:
|
|
852
|
-
fromB:
|
|
853
|
-
toB:
|
|
1031
|
+
fromA: p.fromA,
|
|
1032
|
+
toA: p.fromA + 1,
|
|
1033
|
+
fromB: p.fromB,
|
|
1034
|
+
toB: p.fromB + 1,
|
|
854
1035
|
deleted: [],
|
|
855
1036
|
inserted: [],
|
|
856
1037
|
type: "node-type-or-attr-update"
|
|
857
|
-
},
|
|
858
|
-
fromA:
|
|
859
|
-
toA:
|
|
860
|
-
fromB:
|
|
861
|
-
toB:
|
|
1038
|
+
}, f = {
|
|
1039
|
+
fromA: p.fromA + 1,
|
|
1040
|
+
toA: p.toA,
|
|
1041
|
+
fromB: p.fromB + 1,
|
|
1042
|
+
toB: p.toB,
|
|
862
1043
|
deleted: [],
|
|
863
1044
|
inserted: []
|
|
864
1045
|
};
|
|
865
|
-
|
|
1046
|
+
u.splice(m, 1, h, f), m++;
|
|
866
1047
|
}
|
|
867
1048
|
}
|
|
868
|
-
|
|
869
|
-
for (let
|
|
870
|
-
const
|
|
871
|
-
if (
|
|
1049
|
+
no(u, t, i);
|
|
1050
|
+
for (let m = 0; m < u.length; m++) {
|
|
1051
|
+
const p = u[m], d = i.slice(p.fromB, p.toB);
|
|
1052
|
+
if (d.openEnd > 0 && d.size > 1)
|
|
872
1053
|
throw new Error(
|
|
873
1054
|
"unexpected, openEnd > 0 and size > 1, this should have been split into two steps"
|
|
874
1055
|
);
|
|
875
|
-
|
|
876
|
-
new
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
1056
|
+
m === u.length - 1 && o && p.type === "mark-update" || c.push(
|
|
1057
|
+
new N(
|
|
1058
|
+
p.fromA,
|
|
1059
|
+
p.toA,
|
|
1060
|
+
d,
|
|
1061
|
+
p.type === "node-type-or-attr-update"
|
|
881
1062
|
)
|
|
882
1063
|
);
|
|
883
1064
|
}
|
|
884
|
-
return
|
|
1065
|
+
return c;
|
|
885
1066
|
}
|
|
886
|
-
function
|
|
1067
|
+
function so(e, t) {
|
|
887
1068
|
if (!e || !Array.isArray(e) || e.length === 0)
|
|
888
1069
|
return {
|
|
889
1070
|
ok: !1,
|
|
@@ -904,13 +1085,13 @@ function Wt(e, t) {
|
|
|
904
1085
|
value: o
|
|
905
1086
|
};
|
|
906
1087
|
}
|
|
907
|
-
function
|
|
1088
|
+
function re(e) {
|
|
908
1089
|
return (t, o) => {
|
|
909
1090
|
const r = typeof e.schema == "function" ? e.schema(t) : e.schema;
|
|
910
1091
|
return {
|
|
911
1092
|
name: "add",
|
|
912
1093
|
description: e.description,
|
|
913
|
-
|
|
1094
|
+
inputSchema: {
|
|
914
1095
|
type: "object",
|
|
915
1096
|
properties: {
|
|
916
1097
|
referenceId: {
|
|
@@ -960,9 +1141,9 @@ function te(e) {
|
|
|
960
1141
|
ok: !1,
|
|
961
1142
|
error: "referenceId not found"
|
|
962
1143
|
};
|
|
963
|
-
const i =
|
|
1144
|
+
const i = so(
|
|
964
1145
|
n.blocks,
|
|
965
|
-
(
|
|
1146
|
+
(l) => e.validateBlock(l, t)
|
|
966
1147
|
);
|
|
967
1148
|
return i.ok ? {
|
|
968
1149
|
ok: !0,
|
|
@@ -976,66 +1157,67 @@ function te(e) {
|
|
|
976
1157
|
},
|
|
977
1158
|
// Note: functionality mostly tested in jsontools.test.ts
|
|
978
1159
|
// would be nicer to add a direct unit test
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
for (let
|
|
996
|
-
const
|
|
997
|
-
let
|
|
998
|
-
if (
|
|
999
|
-
const
|
|
1160
|
+
executor: () => {
|
|
1161
|
+
let n = [];
|
|
1162
|
+
const s = {};
|
|
1163
|
+
return {
|
|
1164
|
+
execute: async (a) => {
|
|
1165
|
+
var c;
|
|
1166
|
+
if (a.isUpdateToPreviousOperation || (n = []), a.operation.type !== "add")
|
|
1167
|
+
return !1;
|
|
1168
|
+
const i = a.operation, l = await e.toJSONToolCall(t, {
|
|
1169
|
+
...a,
|
|
1170
|
+
operation: i
|
|
1171
|
+
});
|
|
1172
|
+
if (!l || a.isPossiblyPartial && ee(
|
|
1173
|
+
l.blocks[l.blocks.length - 1]
|
|
1174
|
+
))
|
|
1175
|
+
return !0;
|
|
1176
|
+
for (let u = 0; u < l.blocks.length; u++) {
|
|
1177
|
+
const m = l.blocks[u], p = t.prosemirrorState.tr;
|
|
1178
|
+
let d = [];
|
|
1179
|
+
if (u < n.length) {
|
|
1180
|
+
const h = await e.rebaseTool(n[u], t), k = W(
|
|
1000
1181
|
{
|
|
1001
|
-
id:
|
|
1002
|
-
block:
|
|
1182
|
+
id: n[u],
|
|
1183
|
+
block: m
|
|
1003
1184
|
},
|
|
1004
|
-
|
|
1185
|
+
h.doc,
|
|
1005
1186
|
!1
|
|
1006
|
-
).map((
|
|
1007
|
-
for (const
|
|
1008
|
-
|
|
1009
|
-
|
|
1187
|
+
).map((b) => b.map(h.invertMap));
|
|
1188
|
+
for (const b of k)
|
|
1189
|
+
p.step(b.map(p.mapping));
|
|
1190
|
+
d = J(p), d = d.filter(
|
|
1191
|
+
(b) => b.type !== "select"
|
|
1192
|
+
);
|
|
1010
1193
|
} else {
|
|
1011
|
-
const
|
|
1012
|
-
|
|
1013
|
-
[
|
|
1014
|
-
|
|
1015
|
-
|
|
1194
|
+
const h = i.position === "after" ? s[i.referenceId] : void 0, f = at(
|
|
1195
|
+
p,
|
|
1196
|
+
[m],
|
|
1197
|
+
u > 0 ? n[u - 1] : h || i.referenceId,
|
|
1198
|
+
u > 0 ? "after" : i.position
|
|
1016
1199
|
);
|
|
1017
|
-
|
|
1200
|
+
n.push(...f.map((k) => k.id)), d = J(p);
|
|
1018
1201
|
}
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
}), (i = o.onBlockUpdate) == null || i.call(o, s[l]);
|
|
1202
|
+
for (const h of d)
|
|
1203
|
+
o.withDelays && await te(h), t.transact((f) => {
|
|
1204
|
+
oe(f, h);
|
|
1205
|
+
}), (c = o.onBlockUpdate) == null || c.call(o, n[u]);
|
|
1024
1206
|
}
|
|
1025
|
-
|
|
1207
|
+
return a.isPossiblyPartial || i.position === "after" && (s[i.referenceId] = n[n.length - 1]), !0;
|
|
1026
1208
|
}
|
|
1027
|
-
}
|
|
1209
|
+
};
|
|
1028
1210
|
}
|
|
1029
1211
|
};
|
|
1030
1212
|
};
|
|
1031
1213
|
}
|
|
1032
|
-
function
|
|
1214
|
+
function ne(e) {
|
|
1033
1215
|
return (t, o) => {
|
|
1034
1216
|
const r = typeof e.schema == "function" ? e.schema(t) : e.schema;
|
|
1035
1217
|
return {
|
|
1036
1218
|
name: "update",
|
|
1037
1219
|
description: e.description,
|
|
1038
|
-
|
|
1220
|
+
inputSchema: {
|
|
1039
1221
|
type: "object",
|
|
1040
1222
|
properties: {
|
|
1041
1223
|
id: {
|
|
@@ -1090,55 +1272,59 @@ function oe(e) {
|
|
|
1090
1272
|
},
|
|
1091
1273
|
// Note: functionality mostly tested in jsontools.test.ts
|
|
1092
1274
|
// would be nicer to add a direct unit test
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
to: se(t, o.updateSelection.to)
|
|
1275
|
+
executor: () => {
|
|
1276
|
+
let s = 50;
|
|
1277
|
+
const a = o.updateSelection ? {
|
|
1278
|
+
from: ae(t, o.updateSelection.from),
|
|
1279
|
+
to: ae(t, o.updateSelection.to)
|
|
1099
1280
|
} : void 0;
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1281
|
+
return {
|
|
1282
|
+
execute: async (i) => {
|
|
1283
|
+
var b;
|
|
1284
|
+
if (i.operation.type !== "update")
|
|
1285
|
+
return !1;
|
|
1286
|
+
const l = i.operation;
|
|
1287
|
+
if (i.isPossiblyPartial) {
|
|
1288
|
+
const g = JSON.stringify(l.block).length;
|
|
1289
|
+
if (g < s)
|
|
1290
|
+
return !0;
|
|
1291
|
+
s = g + 50;
|
|
1292
|
+
} else
|
|
1293
|
+
s = 50;
|
|
1294
|
+
const c = await e.rebaseTool(l.id, t), u = a ? c.invertMap.invert().map(a.from()) : void 0, m = a ? c.invertMap.invert().map(a.to()) : void 0, p = await e.toJSONToolCall(t, {
|
|
1295
|
+
...i,
|
|
1296
|
+
operation: l
|
|
1297
|
+
});
|
|
1298
|
+
if (!p)
|
|
1299
|
+
return !0;
|
|
1300
|
+
const d = W(
|
|
1301
|
+
p,
|
|
1302
|
+
c.doc,
|
|
1303
|
+
i.isPossiblyPartial,
|
|
1304
|
+
u,
|
|
1305
|
+
m
|
|
1306
|
+
);
|
|
1307
|
+
if (d.length === 1 && i.isPossiblyPartial)
|
|
1308
|
+
return !0;
|
|
1309
|
+
const h = d.map((g) => g.map(c.invertMap)), f = new D(t.prosemirrorState.doc);
|
|
1310
|
+
for (const g of h)
|
|
1311
|
+
f.step(g.map(f.mapping));
|
|
1312
|
+
const k = J(f);
|
|
1313
|
+
for (const g of k)
|
|
1314
|
+
o.withDelays && await te(g), t.transact((v) => {
|
|
1315
|
+
oe(v, g);
|
|
1316
|
+
}), (b = o.onBlockUpdate) == null || b.call(o, l.id);
|
|
1317
|
+
return !0;
|
|
1104
1318
|
}
|
|
1105
|
-
|
|
1106
|
-
if (u.isPossiblyPartial) {
|
|
1107
|
-
const k = JSON.stringify(p.block).length;
|
|
1108
|
-
if (k < a)
|
|
1109
|
-
continue;
|
|
1110
|
-
a = k + 50;
|
|
1111
|
-
} else
|
|
1112
|
-
a = 50;
|
|
1113
|
-
const l = await e.rebaseTool(p.id, t), f = i ? l.invertMap.invert().map(i.from()) : void 0, m = i ? l.invertMap.invert().map(i.to()) : void 0, h = await e.toJSONToolCall(t, u);
|
|
1114
|
-
if (!h)
|
|
1115
|
-
continue;
|
|
1116
|
-
const d = J(
|
|
1117
|
-
h,
|
|
1118
|
-
l.doc,
|
|
1119
|
-
u.isPossiblyPartial,
|
|
1120
|
-
f,
|
|
1121
|
-
m
|
|
1122
|
-
);
|
|
1123
|
-
if (d.length === 1 && u.isPossiblyPartial)
|
|
1124
|
-
continue;
|
|
1125
|
-
const S = d.map((k) => k.map(l.invertMap)), b = new A(t.prosemirrorState.doc);
|
|
1126
|
-
for (const k of S)
|
|
1127
|
-
b.step(k.map(b.mapping));
|
|
1128
|
-
const g = R(b);
|
|
1129
|
-
for (const k of g)
|
|
1130
|
-
o.withDelays && await Q(k), t.transact((w) => {
|
|
1131
|
-
ee(w, k);
|
|
1132
|
-
}), (c = o.onBlockUpdate) == null || c.call(o, p.id);
|
|
1133
|
-
}
|
|
1319
|
+
};
|
|
1134
1320
|
}
|
|
1135
1321
|
};
|
|
1136
1322
|
};
|
|
1137
1323
|
}
|
|
1138
|
-
const
|
|
1324
|
+
const se = (e, t) => ({
|
|
1139
1325
|
name: "delete",
|
|
1140
1326
|
description: "Delete a block",
|
|
1141
|
-
|
|
1327
|
+
inputSchema: {
|
|
1142
1328
|
type: "object",
|
|
1143
1329
|
properties: {
|
|
1144
1330
|
id: {
|
|
@@ -1181,24 +1367,23 @@ const re = (e, t) => ({
|
|
|
1181
1367
|
},
|
|
1182
1368
|
// Note: functionality mostly tested in jsontools.test.ts
|
|
1183
1369
|
// would be nicer to add a direct unit test
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
if (
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
const s = n
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
t.
|
|
1196
|
-
|
|
1197
|
-
}), (r = t.onBlockUpdate) == null || r.call(t, s.id);
|
|
1370
|
+
executor: () => ({
|
|
1371
|
+
execute: async (o) => {
|
|
1372
|
+
var a;
|
|
1373
|
+
if (o.operation.type !== "delete")
|
|
1374
|
+
return !1;
|
|
1375
|
+
const r = o.operation, n = e.prosemirrorState.tr;
|
|
1376
|
+
lt(n, [r.id], []);
|
|
1377
|
+
const s = J(n);
|
|
1378
|
+
for (const i of s)
|
|
1379
|
+
t.withDelays && await te(i), e.transact((l) => {
|
|
1380
|
+
oe(l, i);
|
|
1381
|
+
}), (a = t.onBlockUpdate) == null || a.call(t, r.id);
|
|
1382
|
+
return !0;
|
|
1198
1383
|
}
|
|
1199
|
-
}
|
|
1384
|
+
})
|
|
1200
1385
|
});
|
|
1201
|
-
function
|
|
1386
|
+
function ge(e) {
|
|
1202
1387
|
const t = e.lastIndexOf("<"), o = e.lastIndexOf(">");
|
|
1203
1388
|
let r = e;
|
|
1204
1389
|
if (t > o && (r = e.substring(0, t), !r.trim()))
|
|
@@ -1214,15 +1399,15 @@ function fe(e) {
|
|
|
1214
1399
|
).body.firstChild;
|
|
1215
1400
|
return i ? i.innerHTML : "";
|
|
1216
1401
|
}
|
|
1217
|
-
function
|
|
1402
|
+
function U(e) {
|
|
1218
1403
|
let t;
|
|
1219
|
-
if (
|
|
1404
|
+
if (Ne(e.prosemirrorState, (o) => {
|
|
1220
1405
|
t = o;
|
|
1221
1406
|
}), !t)
|
|
1222
1407
|
throw new Error("applySuggestionsTr is not set");
|
|
1223
1408
|
return t;
|
|
1224
1409
|
}
|
|
1225
|
-
function
|
|
1410
|
+
function V(e, t) {
|
|
1226
1411
|
const o = t.mapping.invert();
|
|
1227
1412
|
return {
|
|
1228
1413
|
doc: t.doc,
|
|
@@ -1230,7 +1415,7 @@ function q(e, t) {
|
|
|
1230
1415
|
* Return a new transform that has the projection applied.
|
|
1231
1416
|
* You can add new operations to this transform and later rebase those on the original document with `rebaseTr`
|
|
1232
1417
|
*/
|
|
1233
|
-
tr: () => new
|
|
1418
|
+
tr: () => new D(t.doc),
|
|
1234
1419
|
/**
|
|
1235
1420
|
* Invert map created by the projection.
|
|
1236
1421
|
* You can use this to map positions on the "clean" document (the projection) to positions on the original document
|
|
@@ -1254,9 +1439,9 @@ function q(e, t) {
|
|
|
1254
1439
|
}
|
|
1255
1440
|
};
|
|
1256
1441
|
}
|
|
1257
|
-
async function
|
|
1258
|
-
var
|
|
1259
|
-
const o =
|
|
1442
|
+
async function be(e, t) {
|
|
1443
|
+
var c;
|
|
1444
|
+
const o = U(t), r = Ee(o.doc, e);
|
|
1260
1445
|
if (!r)
|
|
1261
1446
|
throw new Error("block not found");
|
|
1262
1447
|
const n = await t.blocksToHTMLLossy([
|
|
@@ -1264,11 +1449,11 @@ async function he(e, t) {
|
|
|
1264
1449
|
...r,
|
|
1265
1450
|
children: []
|
|
1266
1451
|
}
|
|
1267
|
-
]), s = (
|
|
1452
|
+
]), s = (c = window.__TEST_OPTIONS) == null ? void 0 : c.mockID, a = await t.tryParseHTMLToBlocks(n);
|
|
1268
1453
|
if (window.__TEST_OPTIONS && (window.__TEST_OPTIONS.mockID = s), a.length !== 1)
|
|
1269
1454
|
throw new Error("html diff invalid block count");
|
|
1270
1455
|
const i = a[0];
|
|
1271
|
-
if (i.id = e,
|
|
1456
|
+
if (i.id = e, W(
|
|
1272
1457
|
{
|
|
1273
1458
|
id: e,
|
|
1274
1459
|
block: i
|
|
@@ -1276,9 +1461,9 @@ async function he(e, t) {
|
|
|
1276
1461
|
o.doc
|
|
1277
1462
|
).length)
|
|
1278
1463
|
throw new Error("html diff");
|
|
1279
|
-
return
|
|
1464
|
+
return V(t, o);
|
|
1280
1465
|
}
|
|
1281
|
-
function
|
|
1466
|
+
function ke(e) {
|
|
1282
1467
|
return typeof e != "string" ? {
|
|
1283
1468
|
ok: !1,
|
|
1284
1469
|
error: "block must be a string"
|
|
@@ -1287,8 +1472,8 @@ function ye(e) {
|
|
|
1287
1472
|
value: e
|
|
1288
1473
|
};
|
|
1289
1474
|
}
|
|
1290
|
-
const
|
|
1291
|
-
add:
|
|
1475
|
+
const H = {
|
|
1476
|
+
add: re({
|
|
1292
1477
|
description: "Insert new blocks",
|
|
1293
1478
|
schema: {
|
|
1294
1479
|
block: {
|
|
@@ -1296,13 +1481,13 @@ const V = {
|
|
|
1296
1481
|
description: "html of block (MUST be a single, VALID HTML element)"
|
|
1297
1482
|
}
|
|
1298
1483
|
},
|
|
1299
|
-
validateBlock:
|
|
1300
|
-
rebaseTool:
|
|
1484
|
+
validateBlock: ke,
|
|
1485
|
+
rebaseTool: be,
|
|
1301
1486
|
toJSONToolCall: async (e, t) => {
|
|
1302
1487
|
var n;
|
|
1303
1488
|
const o = (n = window.__TEST_OPTIONS) == null ? void 0 : n.mockID, r = (await Promise.all(
|
|
1304
1489
|
t.operation.blocks.map(async (s) => {
|
|
1305
|
-
const a = t.isPossiblyPartial ?
|
|
1490
|
+
const a = t.isPossiblyPartial ? ge(s) : s;
|
|
1306
1491
|
return a ? (await e.tryParseHTMLToBlocks(a)).map(
|
|
1307
1492
|
(i) => (delete i.id, i)
|
|
1308
1493
|
) : [];
|
|
@@ -1315,7 +1500,7 @@ const V = {
|
|
|
1315
1500
|
};
|
|
1316
1501
|
}
|
|
1317
1502
|
}),
|
|
1318
|
-
update:
|
|
1503
|
+
update: ne({
|
|
1319
1504
|
description: "Update a block",
|
|
1320
1505
|
schema: {
|
|
1321
1506
|
block: {
|
|
@@ -1323,10 +1508,10 @@ const V = {
|
|
|
1323
1508
|
description: "html of block (MUST be a single HTML element)"
|
|
1324
1509
|
}
|
|
1325
1510
|
},
|
|
1326
|
-
validateBlock:
|
|
1327
|
-
rebaseTool:
|
|
1511
|
+
validateBlock: ke,
|
|
1512
|
+
rebaseTool: be,
|
|
1328
1513
|
toJSONToolCall: async (e, t) => {
|
|
1329
|
-
const o = t.isPossiblyPartial ?
|
|
1514
|
+
const o = t.isPossiblyPartial ? ge(t.operation.block) : t.operation.block;
|
|
1330
1515
|
if (!o)
|
|
1331
1516
|
return;
|
|
1332
1517
|
const r = (await e.tryParseHTMLToBlocks(o))[0];
|
|
@@ -1336,244 +1521,115 @@ const V = {
|
|
|
1336
1521
|
};
|
|
1337
1522
|
}
|
|
1338
1523
|
}),
|
|
1339
|
-
delete:
|
|
1524
|
+
delete: se
|
|
1340
1525
|
};
|
|
1341
|
-
function
|
|
1342
|
-
|
|
1526
|
+
function io(e, t, o, r, n) {
|
|
1527
|
+
if (typeof r == "boolean") {
|
|
1528
|
+
const i = r ? e.getSelectionCutBlocks() : void 0;
|
|
1529
|
+
r = i ? {
|
|
1530
|
+
from: i._meta.startPos,
|
|
1531
|
+
to: i._meta.endPos
|
|
1532
|
+
} : void 0;
|
|
1533
|
+
}
|
|
1534
|
+
const s = o ?? {
|
|
1343
1535
|
add: !0,
|
|
1344
1536
|
update: !0,
|
|
1345
|
-
delete: !0
|
|
1346
|
-
...o
|
|
1537
|
+
delete: !0
|
|
1347
1538
|
};
|
|
1348
1539
|
return [
|
|
1349
1540
|
...s.update ? [
|
|
1350
|
-
|
|
1541
|
+
H.update(e, {
|
|
1351
1542
|
idsSuffixed: !0,
|
|
1352
1543
|
withDelays: t,
|
|
1353
1544
|
updateSelection: r,
|
|
1354
1545
|
onBlockUpdate: n
|
|
1355
1546
|
})
|
|
1356
1547
|
] : [],
|
|
1357
|
-
...s.add ? [
|
|
1358
|
-
...s.delete ? [
|
|
1548
|
+
...s.add ? [H.add(e, { idsSuffixed: !0, withDelays: t, onBlockUpdate: n })] : [],
|
|
1549
|
+
...s.delete ? [H.delete(e, { idsSuffixed: !0, withDelays: t, onBlockUpdate: n })] : []
|
|
1359
1550
|
];
|
|
1360
1551
|
}
|
|
1361
|
-
const
|
|
1552
|
+
const ao = {
|
|
1362
1553
|
/**
|
|
1363
1554
|
* Function to get the stream tools that can apply HTML block updates to the editor
|
|
1364
1555
|
*/
|
|
1365
|
-
|
|
1556
|
+
getStreamToolsProvider: (e = {}) => ({
|
|
1557
|
+
getStreamTools: (t, o, r) => io(
|
|
1558
|
+
t,
|
|
1559
|
+
e.withDelays ?? !0,
|
|
1560
|
+
e.defaultStreamTools,
|
|
1561
|
+
o,
|
|
1562
|
+
r
|
|
1563
|
+
)
|
|
1564
|
+
}),
|
|
1565
|
+
tools: H,
|
|
1366
1566
|
/**
|
|
1367
1567
|
* The default PromptBuilder that determines how a userPrompt is converted to an array of
|
|
1368
1568
|
* LLM Messages (CoreMessage[])
|
|
1369
1569
|
*/
|
|
1370
|
-
defaultPromptBuilder:
|
|
1570
|
+
defaultPromptBuilder: to,
|
|
1571
|
+
/**
|
|
1572
|
+
* The default PromptInputDataBuilder that can take an editor and user request and convert it to the input required for the PromptBuilder
|
|
1573
|
+
*/
|
|
1574
|
+
defaultPromptInputDataBuilder: oo,
|
|
1371
1575
|
/**
|
|
1372
1576
|
* Helper functions which can be used when implementing a custom PromptBuilder
|
|
1373
1577
|
*/
|
|
1374
1578
|
promptHelpers: {
|
|
1375
|
-
getDataForPromptNoSelection:
|
|
1376
|
-
getDataForPromptWithSelection:
|
|
1579
|
+
getDataForPromptNoSelection: Ue,
|
|
1580
|
+
getDataForPromptWithSelection: Ve
|
|
1377
1581
|
}
|
|
1378
1582
|
};
|
|
1379
|
-
async function
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
}
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
}, l = t.promptBuilder ?? c.defaultPromptBuilder, f = c.getStreamTools, m = r ? void 0 : e.getTextCursorPosition().block, h = m && n && X(m) && x(e.document).length > 0 ? m.id : void 0, d = r ? e.getSelectionCutBlocks() : void 0;
|
|
1398
|
-
let S;
|
|
1399
|
-
u && (S = u.messages.map((w) => w.role === "user" && typeof w.content == "string" ? {
|
|
1400
|
-
role: "system",
|
|
1401
|
-
content: `USER_MESSAGE: ${w.content}`
|
|
1402
|
-
} : w), S.push({
|
|
1403
|
-
role: "system",
|
|
1404
|
-
// using "assistant" here doesn't work with gemini because we can't mix system / assistant messages
|
|
1405
|
-
content: `ASSISTANT_MESSAGE: These are the operations returned by a previous LLM call:
|
|
1406
|
-
` + JSON.stringify(
|
|
1407
|
-
await u.llmResult.getGeneratedOperations()
|
|
1408
|
-
)
|
|
1409
|
-
}));
|
|
1410
|
-
const b = await l(e, {
|
|
1411
|
-
selectedBlocks: d == null ? void 0 : d.blocks,
|
|
1412
|
-
userPrompt: o,
|
|
1413
|
-
excludeBlockIds: h ? [h] : void 0,
|
|
1414
|
-
previousMessages: S
|
|
1415
|
-
}), g = f(
|
|
1416
|
-
e,
|
|
1417
|
-
i,
|
|
1418
|
-
t.defaultStreamTools,
|
|
1419
|
-
d ? { from: d._meta.startPos, to: d._meta.endPos } : void 0,
|
|
1420
|
-
t.onBlockUpdate
|
|
1421
|
-
);
|
|
1422
|
-
let k;
|
|
1423
|
-
return s ? k = await Dt(
|
|
1424
|
-
g,
|
|
1425
|
-
{
|
|
1426
|
-
messages: b,
|
|
1427
|
-
...p
|
|
1428
|
-
},
|
|
1429
|
-
() => {
|
|
1430
|
-
h && e.getBlock(h) && e.removeBlocks([h]), a == null || a();
|
|
1431
|
-
}
|
|
1432
|
-
) : (k = await At(g, {
|
|
1433
|
-
messages: b,
|
|
1434
|
-
...p
|
|
1435
|
-
}), h && e.getBlock(h) && e.removeBlocks([h]), a == null || a()), new qt(b, k, g);
|
|
1436
|
-
}
|
|
1437
|
-
async function ze(e, t) {
|
|
1438
|
-
const o = e.getTextCursorPosition().block.id, r = x(e.document, {
|
|
1439
|
-
cursorBlockId: o
|
|
1440
|
-
}), n = await C(
|
|
1441
|
-
T(r),
|
|
1583
|
+
async function lo(e) {
|
|
1584
|
+
return e.selectedBlocks ? {
|
|
1585
|
+
...await Re(e.editor, {
|
|
1586
|
+
selectedBlocks: e.selectedBlocks
|
|
1587
|
+
}),
|
|
1588
|
+
userPrompt: e.userPrompt
|
|
1589
|
+
} : {
|
|
1590
|
+
...await Fe(e.editor, {
|
|
1591
|
+
excludeBlockIds: e.emptyCursorBlockToDelete ? [e.emptyCursorBlockToDelete] : void 0
|
|
1592
|
+
}),
|
|
1593
|
+
userPrompt: e.userPrompt
|
|
1594
|
+
};
|
|
1595
|
+
}
|
|
1596
|
+
async function Fe(e, t) {
|
|
1597
|
+
const o = w(e.document).length === 0, r = e.getTextCursorPosition().block.id, n = w(e.document, {
|
|
1598
|
+
cursorBlockId: r
|
|
1599
|
+
}), s = await P(
|
|
1600
|
+
T(n),
|
|
1442
1601
|
async (c) => ({
|
|
1443
1602
|
...c,
|
|
1444
1603
|
children: void 0
|
|
1445
1604
|
})
|
|
1446
|
-
),
|
|
1605
|
+
), i = Z(e, s).filter(
|
|
1447
1606
|
(c) => "cursor" in c || !(t.excludeBlockIds || []).includes(c.id)
|
|
1448
1607
|
);
|
|
1449
1608
|
return {
|
|
1450
|
-
|
|
1609
|
+
selection: !1,
|
|
1610
|
+
jsonBlocks: _(i),
|
|
1611
|
+
isEmptyDocument: o
|
|
1451
1612
|
};
|
|
1452
1613
|
}
|
|
1453
|
-
async function
|
|
1454
|
-
const o = await
|
|
1614
|
+
async function Re(e, t) {
|
|
1615
|
+
const o = w(e.document).length === 0, r = await P(
|
|
1455
1616
|
T(t.selectedBlocks),
|
|
1456
|
-
async (
|
|
1457
|
-
);
|
|
1617
|
+
async (s) => s
|
|
1618
|
+
), n = _(r);
|
|
1458
1619
|
return {
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1620
|
+
isEmptyDocument: o,
|
|
1621
|
+
selection: !0,
|
|
1622
|
+
jsonSelectedBlocks: n,
|
|
1623
|
+
jsonDocument: (await P(T(e.document), async (s) => ({
|
|
1624
|
+
...s,
|
|
1462
1625
|
id: void 0,
|
|
1463
1626
|
// don't pass id, because LLM should use `jsonSelectedBlocks` for this
|
|
1464
1627
|
children: void 0
|
|
1465
|
-
}))).map(({ block:
|
|
1628
|
+
}))).map(({ block: s }) => ({ block: s }))
|
|
1466
1629
|
// strip ids so LLM can't accidentally issue updates to ids not in selection
|
|
1467
1630
|
};
|
|
1468
1631
|
}
|
|
1469
|
-
function
|
|
1470
|
-
return [
|
|
1471
|
-
{
|
|
1472
|
-
role: "system",
|
|
1473
|
-
content: `You're manipulating a selected part of a text document using JSON blocks.
|
|
1474
|
-
Make sure to follow the json schema provided and always include the trailing $ in ids.
|
|
1475
|
-
This is the selection as an array of JSON blocks:`
|
|
1476
|
-
},
|
|
1477
|
-
{
|
|
1478
|
-
role: "system",
|
|
1479
|
-
content: JSON.stringify(e.jsonSelectedBlocks)
|
|
1480
|
-
},
|
|
1481
|
-
{
|
|
1482
|
-
role: "system",
|
|
1483
|
-
content: "This is the entire document (INCLUDING the selected text), find the selected text in there to understand the context:"
|
|
1484
|
-
},
|
|
1485
|
-
{
|
|
1486
|
-
role: "system",
|
|
1487
|
-
content: JSON.stringify(e.jsonDocument)
|
|
1488
|
-
},
|
|
1489
|
-
{
|
|
1490
|
-
role: "system",
|
|
1491
|
-
content: "The user asks you to do the following:"
|
|
1492
|
-
},
|
|
1493
|
-
{
|
|
1494
|
-
role: "user",
|
|
1495
|
-
content: e.userPrompt
|
|
1496
|
-
}
|
|
1497
|
-
];
|
|
1498
|
-
}
|
|
1499
|
-
function Xt(e) {
|
|
1500
|
-
return [
|
|
1501
|
-
{
|
|
1502
|
-
role: "system",
|
|
1503
|
-
content: `You're manipulating a text document using JSON blocks.
|
|
1504
|
-
Make sure to follow the json schema provided. When referencing ids they MUST be EXACTLY the same (including the trailing $).
|
|
1505
|
-
This is the document as an array of JSON blocks (the cursor is BETWEEN two blocks as indicated by cursor: true):`
|
|
1506
|
-
},
|
|
1507
|
-
{
|
|
1508
|
-
role: "system",
|
|
1509
|
-
content: JSON.stringify(e.jsonBlocks)
|
|
1510
|
-
},
|
|
1511
|
-
...e.isEmptyDocument ? [
|
|
1512
|
-
{
|
|
1513
|
-
role: "system",
|
|
1514
|
-
content: "Because the actual document is empty, this is an example document to understand the schema:"
|
|
1515
|
-
},
|
|
1516
|
-
{
|
|
1517
|
-
role: "system",
|
|
1518
|
-
content: JSON.stringify({
|
|
1519
|
-
id: "ref3",
|
|
1520
|
-
type: "paragraph",
|
|
1521
|
-
content: [
|
|
1522
|
-
{
|
|
1523
|
-
type: "text",
|
|
1524
|
-
text: "Hello, world! ",
|
|
1525
|
-
styles: {}
|
|
1526
|
-
},
|
|
1527
|
-
{
|
|
1528
|
-
type: "text",
|
|
1529
|
-
text: "Bold text. ",
|
|
1530
|
-
styles: {
|
|
1531
|
-
bold: !0
|
|
1532
|
-
}
|
|
1533
|
-
},
|
|
1534
|
-
{
|
|
1535
|
-
type: "link",
|
|
1536
|
-
href: "https://www.w3.org",
|
|
1537
|
-
content: "Link."
|
|
1538
|
-
}
|
|
1539
|
-
]
|
|
1540
|
-
})
|
|
1541
|
-
}
|
|
1542
|
-
] : [],
|
|
1543
|
-
{
|
|
1544
|
-
role: "system",
|
|
1545
|
-
content: "The user asks you to do the following:"
|
|
1546
|
-
},
|
|
1547
|
-
{
|
|
1548
|
-
role: "system",
|
|
1549
|
-
content: 'First, determine what part of the document the user is talking about. You SHOULD probably take cursor info into account if needed.\n EXAMPLE: if user says "below" (without pointing to a specific part of the document) he / she probably indicates the block(s) after the cursor. \n 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`).\n \n ' + (e.isEmptyDocument ? "Because the document is empty, 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).")
|
|
1550
|
-
},
|
|
1551
|
-
{
|
|
1552
|
-
role: "user",
|
|
1553
|
-
content: e.userPrompt
|
|
1554
|
-
}
|
|
1555
|
-
];
|
|
1556
|
-
}
|
|
1557
|
-
const Qt = async (e, t) => {
|
|
1558
|
-
const o = x(e.document).length === 0;
|
|
1559
|
-
if (t.selectedBlocks) {
|
|
1560
|
-
const r = await Fe(e, {
|
|
1561
|
-
selectedBlocks: t.selectedBlocks
|
|
1562
|
-
});
|
|
1563
|
-
return Kt({
|
|
1564
|
-
...r,
|
|
1565
|
-
userPrompt: t.userPrompt
|
|
1566
|
-
});
|
|
1567
|
-
} else {
|
|
1568
|
-
const r = await ze(e, t);
|
|
1569
|
-
return Xt({
|
|
1570
|
-
...r,
|
|
1571
|
-
userPrompt: t.userPrompt,
|
|
1572
|
-
isEmptyDocument: o
|
|
1573
|
-
});
|
|
1574
|
-
}
|
|
1575
|
-
};
|
|
1576
|
-
function eo(e) {
|
|
1632
|
+
function co(e) {
|
|
1577
1633
|
const t = {}, o = {};
|
|
1578
1634
|
return e.forEach((n) => {
|
|
1579
1635
|
const { type: s, ...a } = n.properties, i = JSON.stringify(a);
|
|
@@ -1594,7 +1650,7 @@ function eo(e) {
|
|
|
1594
1650
|
};
|
|
1595
1651
|
});
|
|
1596
1652
|
}
|
|
1597
|
-
function
|
|
1653
|
+
function uo(e) {
|
|
1598
1654
|
return {
|
|
1599
1655
|
type: "object",
|
|
1600
1656
|
properties: Object.fromEntries(
|
|
@@ -1608,7 +1664,7 @@ function to(e) {
|
|
|
1608
1664
|
additionalProperties: !1
|
|
1609
1665
|
};
|
|
1610
1666
|
}
|
|
1611
|
-
function
|
|
1667
|
+
function po() {
|
|
1612
1668
|
return {
|
|
1613
1669
|
type: "object",
|
|
1614
1670
|
properties: {
|
|
@@ -1627,7 +1683,7 @@ function oo() {
|
|
|
1627
1683
|
required: ["type", "text"]
|
|
1628
1684
|
};
|
|
1629
1685
|
}
|
|
1630
|
-
function
|
|
1686
|
+
function Ze(e) {
|
|
1631
1687
|
return {
|
|
1632
1688
|
type: "object",
|
|
1633
1689
|
properties: Object.fromEntries(
|
|
@@ -1642,7 +1698,7 @@ function Je(e) {
|
|
|
1642
1698
|
additionalProperties: !1
|
|
1643
1699
|
};
|
|
1644
1700
|
}
|
|
1645
|
-
function
|
|
1701
|
+
function mo(e) {
|
|
1646
1702
|
return {
|
|
1647
1703
|
type: "array",
|
|
1648
1704
|
items: {
|
|
@@ -1680,7 +1736,7 @@ function ro(e) {
|
|
|
1680
1736
|
$ref: "#/$defs/styledtext"
|
|
1681
1737
|
}
|
|
1682
1738
|
} : void 0,
|
|
1683
|
-
props:
|
|
1739
|
+
props: Ze(o.propSchema)
|
|
1684
1740
|
},
|
|
1685
1741
|
additionalProperties: !1,
|
|
1686
1742
|
required: ["type", ...o.content === "styled" ? ["content"] : []]
|
|
@@ -1688,9 +1744,9 @@ function ro(e) {
|
|
|
1688
1744
|
}
|
|
1689
1745
|
};
|
|
1690
1746
|
}
|
|
1691
|
-
function
|
|
1747
|
+
function fo(e) {
|
|
1692
1748
|
return {
|
|
1693
|
-
anyOf:
|
|
1749
|
+
anyOf: co(
|
|
1694
1750
|
Object.entries(e).map(([t, o]) => ({
|
|
1695
1751
|
type: "object",
|
|
1696
1752
|
properties: {
|
|
@@ -1700,7 +1756,7 @@ function no(e) {
|
|
|
1700
1756
|
},
|
|
1701
1757
|
content: o.content === "inline" ? { $ref: "#/$defs/inlinecontent" } : o.content === "table" ? { type: "object", properties: {} } : void 0,
|
|
1702
1758
|
// filter out default props (TODO: make option)
|
|
1703
|
-
props:
|
|
1759
|
+
props: Ze(o.propSchema)
|
|
1704
1760
|
// Object.fromEntries(
|
|
1705
1761
|
// Object.entries(val.propSchema).filter(
|
|
1706
1762
|
// (key) => typeof (defaultProps as any)[key[0]] === "undefined"
|
|
@@ -1715,7 +1771,7 @@ function no(e) {
|
|
|
1715
1771
|
)
|
|
1716
1772
|
};
|
|
1717
1773
|
}
|
|
1718
|
-
function
|
|
1774
|
+
function ho(e) {
|
|
1719
1775
|
const t = JSON.parse(
|
|
1720
1776
|
JSON.stringify({
|
|
1721
1777
|
blockSchema: e.blockSchema,
|
|
@@ -1724,6 +1780,7 @@ function so(e) {
|
|
|
1724
1780
|
})
|
|
1725
1781
|
);
|
|
1726
1782
|
return {
|
|
1783
|
+
// TODO
|
|
1727
1784
|
removeFileBlocks() {
|
|
1728
1785
|
return t.blockSchema = Object.fromEntries(
|
|
1729
1786
|
Object.entries(t.blockSchema).filter(
|
|
@@ -1742,7 +1799,7 @@ function so(e) {
|
|
|
1742
1799
|
...r,
|
|
1743
1800
|
propSchema: Object.fromEntries(
|
|
1744
1801
|
Object.entries(r.propSchema).filter(
|
|
1745
|
-
(n) => typeof
|
|
1802
|
+
(n) => typeof _e[n[0]] > "u"
|
|
1746
1803
|
)
|
|
1747
1804
|
)
|
|
1748
1805
|
}
|
|
@@ -1754,22 +1811,22 @@ function so(e) {
|
|
|
1754
1811
|
}
|
|
1755
1812
|
};
|
|
1756
1813
|
}
|
|
1757
|
-
function
|
|
1758
|
-
return e =
|
|
1814
|
+
function Se(e) {
|
|
1815
|
+
return e = ho(e).removeFileBlocks().removeDefaultProps().get(), {
|
|
1759
1816
|
$defs: {
|
|
1760
|
-
styles:
|
|
1761
|
-
styledtext:
|
|
1762
|
-
inlinecontent:
|
|
1817
|
+
styles: uo(e.styleSchema),
|
|
1818
|
+
styledtext: po(),
|
|
1819
|
+
inlinecontent: mo(
|
|
1763
1820
|
e.inlineContentSchema
|
|
1764
1821
|
),
|
|
1765
|
-
block:
|
|
1822
|
+
block: fo(e.blockSchema)
|
|
1766
1823
|
}
|
|
1767
1824
|
};
|
|
1768
1825
|
}
|
|
1769
|
-
function
|
|
1770
|
-
return !t.schema.inlineContentSchema[e.type] ||
|
|
1826
|
+
function We(e, t) {
|
|
1827
|
+
return !t.schema.inlineContentSchema[e.type] || ct(e) && !("text" in e) ? !1 : ut(e) ? !("content" in e) || !("href" in e) ? !1 : We(e.content, t) : !0;
|
|
1771
1828
|
}
|
|
1772
|
-
function
|
|
1829
|
+
function we(e, t, o) {
|
|
1773
1830
|
const r = e.type || o, n = t.schema.blockSchema[r];
|
|
1774
1831
|
if (!n)
|
|
1775
1832
|
return {
|
|
@@ -1798,7 +1855,7 @@ function ke(e, t, o) {
|
|
|
1798
1855
|
ok: !0,
|
|
1799
1856
|
value: e
|
|
1800
1857
|
};
|
|
1801
|
-
if (!e.content.every((s) =>
|
|
1858
|
+
if (!e.content.every((s) => We(s, t)))
|
|
1802
1859
|
return {
|
|
1803
1860
|
ok: !1,
|
|
1804
1861
|
error: "block content must be an array of inline content"
|
|
@@ -1809,32 +1866,32 @@ function ke(e, t, o) {
|
|
|
1809
1866
|
value: e
|
|
1810
1867
|
};
|
|
1811
1868
|
}
|
|
1812
|
-
const
|
|
1813
|
-
add:
|
|
1869
|
+
const q = {
|
|
1870
|
+
add: re({
|
|
1814
1871
|
description: "Insert new blocks",
|
|
1815
1872
|
schema: (e) => ({
|
|
1816
1873
|
block: {
|
|
1817
1874
|
$ref: "#/$defs/block"
|
|
1818
1875
|
},
|
|
1819
|
-
...
|
|
1876
|
+
...Se(e.schema)
|
|
1820
1877
|
}),
|
|
1821
|
-
validateBlock:
|
|
1822
|
-
rebaseTool: async (e, t) =>
|
|
1878
|
+
validateBlock: we,
|
|
1879
|
+
rebaseTool: async (e, t) => V(t, U(t)),
|
|
1823
1880
|
toJSONToolCall: async (e, t) => t.operation
|
|
1824
1881
|
}),
|
|
1825
|
-
update:
|
|
1882
|
+
update: ne({
|
|
1826
1883
|
description: "Update a block, the new block will replace the existing block.",
|
|
1827
1884
|
schema: (e) => ({
|
|
1828
1885
|
block: {
|
|
1829
1886
|
$ref: "#/$defs/block"
|
|
1830
1887
|
},
|
|
1831
|
-
...
|
|
1888
|
+
...Se(e.schema)
|
|
1832
1889
|
}),
|
|
1833
|
-
validateBlock:
|
|
1834
|
-
rebaseTool: async (e, t) =>
|
|
1890
|
+
validateBlock: we,
|
|
1891
|
+
rebaseTool: async (e, t) => V(t, U(t)),
|
|
1835
1892
|
toJSONToolCall: async (e, t) => {
|
|
1836
1893
|
const o = Object.fromEntries(
|
|
1837
|
-
Object.entries(
|
|
1894
|
+
Object.entries(_e).map(([r, n]) => [r, n.default])
|
|
1838
1895
|
);
|
|
1839
1896
|
return {
|
|
1840
1897
|
...t.operation,
|
|
@@ -1848,159 +1905,264 @@ const Z = {
|
|
|
1848
1905
|
};
|
|
1849
1906
|
}
|
|
1850
1907
|
}),
|
|
1851
|
-
delete:
|
|
1908
|
+
delete: se
|
|
1909
|
+
};
|
|
1910
|
+
function yo(e, t) {
|
|
1911
|
+
e.length > 0 && e.push(
|
|
1912
|
+
{
|
|
1913
|
+
role: "assistant",
|
|
1914
|
+
id: "document-state-" + e.length,
|
|
1915
|
+
parts: [
|
|
1916
|
+
{
|
|
1917
|
+
type: "text",
|
|
1918
|
+
text: "This is the latest state of the selection (ignore previous selections, you MUST issue operations against this latest version of the selection):"
|
|
1919
|
+
},
|
|
1920
|
+
{
|
|
1921
|
+
type: "text",
|
|
1922
|
+
text: JSON.stringify(t.jsonSelectedBlocks)
|
|
1923
|
+
},
|
|
1924
|
+
{
|
|
1925
|
+
type: "text",
|
|
1926
|
+
text: "This is the latest state of the document (INCLUDING the selected text), find the selected text in there to understand the context:"
|
|
1927
|
+
},
|
|
1928
|
+
{
|
|
1929
|
+
type: "text",
|
|
1930
|
+
text: JSON.stringify(t.jsonDocument)
|
|
1931
|
+
}
|
|
1932
|
+
]
|
|
1933
|
+
},
|
|
1934
|
+
{
|
|
1935
|
+
role: "user",
|
|
1936
|
+
id: "user-prompt-" + e.length,
|
|
1937
|
+
parts: [
|
|
1938
|
+
{
|
|
1939
|
+
type: "text",
|
|
1940
|
+
text: "The user asks you to do the following:"
|
|
1941
|
+
},
|
|
1942
|
+
{
|
|
1943
|
+
type: "text",
|
|
1944
|
+
text: t.userPrompt
|
|
1945
|
+
}
|
|
1946
|
+
]
|
|
1947
|
+
}
|
|
1948
|
+
), e.push(
|
|
1949
|
+
{
|
|
1950
|
+
role: "system",
|
|
1951
|
+
id: "document-state-intro",
|
|
1952
|
+
parts: [
|
|
1953
|
+
{
|
|
1954
|
+
type: "text",
|
|
1955
|
+
text: `You're manipulating a selected part of a text document using JSON blocks.
|
|
1956
|
+
Make sure to follow the json schema provided and always include the trailing $ in ids.
|
|
1957
|
+
This is the selection as an array of JSON blocks:`
|
|
1958
|
+
},
|
|
1959
|
+
{
|
|
1960
|
+
type: "text",
|
|
1961
|
+
text: JSON.stringify(t.jsonSelectedBlocks)
|
|
1962
|
+
},
|
|
1963
|
+
{
|
|
1964
|
+
type: "text",
|
|
1965
|
+
text: "This is the entire document (INCLUDING the selected text), find the selected text in there to understand the context:"
|
|
1966
|
+
},
|
|
1967
|
+
{
|
|
1968
|
+
type: "text",
|
|
1969
|
+
text: JSON.stringify(t.jsonDocument)
|
|
1970
|
+
}
|
|
1971
|
+
]
|
|
1972
|
+
},
|
|
1973
|
+
{
|
|
1974
|
+
role: "user",
|
|
1975
|
+
id: "user-prompt",
|
|
1976
|
+
parts: [
|
|
1977
|
+
{
|
|
1978
|
+
type: "text",
|
|
1979
|
+
text: t.userPrompt
|
|
1980
|
+
}
|
|
1981
|
+
]
|
|
1982
|
+
}
|
|
1983
|
+
);
|
|
1984
|
+
}
|
|
1985
|
+
function go(e, t) {
|
|
1986
|
+
if (e.length > 0) {
|
|
1987
|
+
e.push(
|
|
1988
|
+
{
|
|
1989
|
+
role: "assistant",
|
|
1990
|
+
id: "document-state-" + e.length,
|
|
1991
|
+
parts: [
|
|
1992
|
+
{
|
|
1993
|
+
type: "text",
|
|
1994
|
+
text: "This is the latest state of the document (ignore previous documents, you MUST issue operations against this latest version of the document):"
|
|
1995
|
+
},
|
|
1996
|
+
{
|
|
1997
|
+
type: "text",
|
|
1998
|
+
text: JSON.stringify(t.jsonBlocks)
|
|
1999
|
+
}
|
|
2000
|
+
]
|
|
2001
|
+
},
|
|
2002
|
+
{
|
|
2003
|
+
role: "user",
|
|
2004
|
+
id: "user-prompt-" + e.length,
|
|
2005
|
+
parts: [
|
|
2006
|
+
{
|
|
2007
|
+
type: "text",
|
|
2008
|
+
text: t.userPrompt
|
|
2009
|
+
}
|
|
2010
|
+
]
|
|
2011
|
+
}
|
|
2012
|
+
);
|
|
2013
|
+
return;
|
|
2014
|
+
}
|
|
2015
|
+
e.push(
|
|
2016
|
+
{
|
|
2017
|
+
role: "system",
|
|
2018
|
+
id: "document-state",
|
|
2019
|
+
parts: [
|
|
2020
|
+
{
|
|
2021
|
+
type: "text",
|
|
2022
|
+
text: `You're manipulating a text document using JSON blocks.
|
|
2023
|
+
Make sure to follow the json schema provided. When referencing ids they MUST be EXACTLY the same (including the trailing $).
|
|
2024
|
+
This is the initial document as an array of JSON blocks (the cursor is BETWEEN two blocks as indicated by cursor: true):`
|
|
2025
|
+
},
|
|
2026
|
+
{
|
|
2027
|
+
type: "text",
|
|
2028
|
+
text: JSON.stringify(t.jsonBlocks)
|
|
2029
|
+
},
|
|
2030
|
+
{
|
|
2031
|
+
type: "text",
|
|
2032
|
+
text: 'First, determine what part of the document the user is talking about. You SHOULD probably take cursor info into account if needed.\n EXAMPLE: if user says "below" (without pointing to a specific part of the document) he / she probably indicates the block(s) after the cursor. \n EXAMPLE: If you want to insert content AT the cursor position (UNLESS indicated otherwise by the user), \n then you need `referenceId` to point to the block before the cursor with position `after` (or block below and `before`).\n \n ' + (t.isEmptyDocument ? "Because the document is empty, 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).")
|
|
2033
|
+
}
|
|
2034
|
+
]
|
|
2035
|
+
},
|
|
2036
|
+
{
|
|
2037
|
+
role: "user",
|
|
2038
|
+
id: "user-prompt",
|
|
2039
|
+
parts: [
|
|
2040
|
+
{
|
|
2041
|
+
type: "text",
|
|
2042
|
+
text: t.userPrompt
|
|
2043
|
+
}
|
|
2044
|
+
]
|
|
2045
|
+
}
|
|
2046
|
+
);
|
|
2047
|
+
}
|
|
2048
|
+
const bo = async (e, t) => {
|
|
2049
|
+
t.selection ? yo(e, t) : go(e, t);
|
|
1852
2050
|
};
|
|
1853
|
-
function
|
|
1854
|
-
|
|
2051
|
+
function ko(e, t, o, r, n) {
|
|
2052
|
+
if (typeof r == "boolean") {
|
|
2053
|
+
const i = r ? e.getSelectionCutBlocks() : void 0;
|
|
2054
|
+
r = i ? {
|
|
2055
|
+
from: i._meta.startPos,
|
|
2056
|
+
to: i._meta.endPos
|
|
2057
|
+
} : void 0;
|
|
2058
|
+
}
|
|
2059
|
+
const s = o ?? {
|
|
1855
2060
|
add: !0,
|
|
1856
2061
|
update: !0,
|
|
1857
|
-
delete: !0
|
|
1858
|
-
...o
|
|
2062
|
+
delete: !0
|
|
1859
2063
|
};
|
|
1860
2064
|
return [
|
|
1861
|
-
...
|
|
1862
|
-
|
|
2065
|
+
...s.update ? [
|
|
2066
|
+
q.update(e, {
|
|
1863
2067
|
idsSuffixed: !0,
|
|
1864
2068
|
withDelays: t,
|
|
1865
|
-
updateSelection: r
|
|
2069
|
+
updateSelection: r,
|
|
2070
|
+
onBlockUpdate: n
|
|
1866
2071
|
})
|
|
1867
2072
|
] : [],
|
|
1868
|
-
...
|
|
1869
|
-
...
|
|
2073
|
+
...s.add ? [q.add(e, { idsSuffixed: !0, withDelays: t, onBlockUpdate: n })] : [],
|
|
2074
|
+
...s.delete ? [q.delete(e, { idsSuffixed: !0, withDelays: t, onBlockUpdate: n })] : []
|
|
1870
2075
|
];
|
|
1871
2076
|
}
|
|
1872
|
-
const
|
|
2077
|
+
const So = {
|
|
1873
2078
|
/**
|
|
1874
|
-
* Function to get the stream tools that can apply
|
|
2079
|
+
* Function to get the stream tools that can apply JSON block updates to the editor
|
|
1875
2080
|
*/
|
|
1876
|
-
|
|
2081
|
+
getStreamToolsProvider: (e = {}) => ({
|
|
2082
|
+
getStreamTools: (t, o, r) => ko(
|
|
2083
|
+
t,
|
|
2084
|
+
e.withDelays ?? !0,
|
|
2085
|
+
e.defaultStreamTools,
|
|
2086
|
+
o,
|
|
2087
|
+
r
|
|
2088
|
+
)
|
|
2089
|
+
}),
|
|
2090
|
+
tools: q,
|
|
1877
2091
|
/**
|
|
1878
2092
|
* The default PromptBuilder that determines how a userPrompt is converted to an array of
|
|
1879
2093
|
* LLM Messages (CoreMessage[])
|
|
1880
2094
|
*/
|
|
1881
|
-
defaultPromptBuilder:
|
|
2095
|
+
defaultPromptBuilder: bo,
|
|
2096
|
+
/**
|
|
2097
|
+
* The default PromptInputDataBuilder that can take an editor and user request and convert it to the input required for the PromptBuilder
|
|
2098
|
+
*/
|
|
2099
|
+
defaultPromptInputDataBuilder: lo,
|
|
1882
2100
|
/**
|
|
1883
2101
|
* Helper functions which can be used when implementing a custom PromptBuilder
|
|
1884
2102
|
*/
|
|
1885
2103
|
promptHelpers: {
|
|
1886
|
-
getDataForPromptNoSelection:
|
|
1887
|
-
getDataForPromptWithSelection:
|
|
2104
|
+
getDataForPromptNoSelection: Fe,
|
|
2105
|
+
getDataForPromptWithSelection: Re
|
|
1888
2106
|
}
|
|
1889
2107
|
};
|
|
1890
|
-
async function
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
2108
|
+
async function wo(e) {
|
|
2109
|
+
return e.selectedBlocks ? {
|
|
2110
|
+
...await Ge(e.editor, {
|
|
2111
|
+
selectedBlocks: e.selectedBlocks
|
|
2112
|
+
}),
|
|
2113
|
+
userPrompt: e.userPrompt
|
|
2114
|
+
} : {
|
|
2115
|
+
...await Ye(e.editor, {
|
|
2116
|
+
excludeBlockIds: e.emptyCursorBlockToDelete ? [e.emptyCursorBlockToDelete] : void 0
|
|
2117
|
+
}),
|
|
2118
|
+
userPrompt: e.userPrompt
|
|
2119
|
+
};
|
|
2120
|
+
}
|
|
2121
|
+
async function Ye(e, t) {
|
|
2122
|
+
const o = w(e.document).length === 0, r = e.getTextCursorPosition().block.id, n = w(e.document, {
|
|
2123
|
+
cursorBlockId: r
|
|
2124
|
+
}), s = await P(
|
|
2125
|
+
T(n),
|
|
1895
2126
|
async (c) => e.blocksToMarkdownLossy([c])
|
|
1896
|
-
),
|
|
2127
|
+
), i = Z(e, s).filter(
|
|
1897
2128
|
(c) => "cursor" in c || !(t.excludeBlockIds || []).includes(c.id)
|
|
1898
2129
|
);
|
|
1899
2130
|
return {
|
|
1900
|
-
|
|
2131
|
+
selection: !1,
|
|
2132
|
+
markdownBlocks: _(i),
|
|
2133
|
+
isEmptyDocument: o
|
|
1901
2134
|
};
|
|
1902
2135
|
}
|
|
1903
|
-
async function
|
|
1904
|
-
const o = await
|
|
2136
|
+
async function Ge(e, t) {
|
|
2137
|
+
const o = w(e.document).length === 0, r = await P(
|
|
1905
2138
|
T(t.selectedBlocks),
|
|
1906
|
-
async (
|
|
1907
|
-
);
|
|
2139
|
+
async (s) => e.blocksToMarkdownLossy([s])
|
|
2140
|
+
), n = _(r);
|
|
1908
2141
|
return {
|
|
1909
|
-
|
|
1910
|
-
|
|
2142
|
+
isEmptyDocument: o,
|
|
2143
|
+
selection: !0,
|
|
2144
|
+
markdownSelectedBlocks: n,
|
|
2145
|
+
markdownDocument: (await P(T(e.document), async (s) => e.blocksToMarkdownLossy([s]))).map(({ block: s }) => ({ block: s }))
|
|
1911
2146
|
// strip ids so LLM can't accidentally issue updates to ids not in selection
|
|
1912
2147
|
};
|
|
1913
2148
|
}
|
|
1914
|
-
function
|
|
1915
|
-
|
|
1916
|
-
{
|
|
1917
|
-
role: "system",
|
|
1918
|
-
content: `You're manipulating a selected part of a text document using markdown blocks.
|
|
1919
|
-
Make sure to follow the json schema provided and always include the trailing $ in ids.
|
|
1920
|
-
This is the selection as an array of markdown blocks:`
|
|
1921
|
-
},
|
|
1922
|
-
{
|
|
1923
|
-
role: "system",
|
|
1924
|
-
content: JSON.stringify(e.markdownSelectedBlocks)
|
|
1925
|
-
},
|
|
1926
|
-
{
|
|
1927
|
-
role: "system",
|
|
1928
|
-
content: "This is the entire document (INCLUDING the selected text), find the selected text in there to understand the context:"
|
|
1929
|
-
},
|
|
1930
|
-
{
|
|
1931
|
-
role: "system",
|
|
1932
|
-
content: JSON.stringify(e.markdownDocument)
|
|
1933
|
-
},
|
|
1934
|
-
{
|
|
1935
|
-
role: "system",
|
|
1936
|
-
content: "The user asks you to do the following:"
|
|
1937
|
-
},
|
|
1938
|
-
{
|
|
1939
|
-
role: "user",
|
|
1940
|
-
content: e.userPrompt
|
|
1941
|
-
}
|
|
1942
|
-
];
|
|
1943
|
-
}
|
|
1944
|
-
function lo(e) {
|
|
1945
|
-
return [
|
|
1946
|
-
{
|
|
1947
|
-
role: "system",
|
|
1948
|
-
content: `You're manipulating a text document using markdown blocks.
|
|
1949
|
-
Make sure to follow the json schema provided. When referencing ids they MUST be EXACTLY the same (including the trailing $).
|
|
1950
|
-
This is the document as an array of markdown blocks (the cursor is BETWEEN two blocks as indicated by cursor: true):`
|
|
1951
|
-
},
|
|
1952
|
-
{
|
|
1953
|
-
role: "system",
|
|
1954
|
-
content: JSON.stringify(e.markdownBlocks)
|
|
1955
|
-
},
|
|
1956
|
-
{
|
|
1957
|
-
role: "system",
|
|
1958
|
-
content: "The user asks you to do the following:"
|
|
1959
|
-
},
|
|
1960
|
-
{
|
|
1961
|
-
role: "user",
|
|
1962
|
-
content: e.userPrompt
|
|
1963
|
-
},
|
|
1964
|
-
{
|
|
1965
|
-
role: "system",
|
|
1966
|
-
content: 'First, determine what part of the document the user is talking about. You SHOULD probably take cursor info into account if needed.\n EXAMPLE: if user says "below" (without pointing to a specific part of the document) he / she probably indicates the block(s) after the cursor. \n 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`).\n \n Prefer updating blocks over adding or removing (but this also depends on the user\'s question).'
|
|
1967
|
-
}
|
|
1968
|
-
];
|
|
1969
|
-
}
|
|
1970
|
-
const uo = async (e, t) => {
|
|
1971
|
-
if (t.selectedBlocks) {
|
|
1972
|
-
const o = await We(e, {
|
|
1973
|
-
selectedBlocks: t.selectedBlocks
|
|
1974
|
-
});
|
|
1975
|
-
return co({
|
|
1976
|
-
...o,
|
|
1977
|
-
userPrompt: t.userPrompt
|
|
1978
|
-
});
|
|
1979
|
-
} else {
|
|
1980
|
-
const o = await Ze(e, t);
|
|
1981
|
-
return lo({
|
|
1982
|
-
...o,
|
|
1983
|
-
userPrompt: t.userPrompt
|
|
1984
|
-
});
|
|
1985
|
-
}
|
|
1986
|
-
};
|
|
1987
|
-
async function be(e, t) {
|
|
1988
|
-
const o = H(t), r = await t.blocksToMarkdownLossy([Oe(o.doc, e)]), n = await t.tryParseMarkdownToBlocks(r), s = J(
|
|
2149
|
+
async function Te(e, t) {
|
|
2150
|
+
const o = U(t), r = await t.blocksToMarkdownLossy([Ee(o.doc, e)]), n = await t.tryParseMarkdownToBlocks(r), s = W(
|
|
1989
2151
|
{
|
|
1990
2152
|
id: e,
|
|
1991
2153
|
block: n[0]
|
|
1992
2154
|
},
|
|
1993
2155
|
o.doc
|
|
1994
|
-
), a = new
|
|
2156
|
+
), a = new je();
|
|
1995
2157
|
for (const i of s) {
|
|
1996
|
-
const
|
|
1997
|
-
if (!
|
|
2158
|
+
const l = i.map(a);
|
|
2159
|
+
if (!l)
|
|
1998
2160
|
throw new Error("Failed to map step");
|
|
1999
|
-
o.step(
|
|
2161
|
+
o.step(l), a.appendMap(l.getMap());
|
|
2000
2162
|
}
|
|
2001
|
-
return
|
|
2163
|
+
return V(t, o);
|
|
2002
2164
|
}
|
|
2003
|
-
function
|
|
2165
|
+
function xe(e) {
|
|
2004
2166
|
return typeof e != "string" ? {
|
|
2005
2167
|
ok: !1,
|
|
2006
2168
|
error: "block must be a string"
|
|
@@ -2009,8 +2171,8 @@ function Se(e) {
|
|
|
2009
2171
|
value: e
|
|
2010
2172
|
};
|
|
2011
2173
|
}
|
|
2012
|
-
const
|
|
2013
|
-
add:
|
|
2174
|
+
const z = {
|
|
2175
|
+
add: re({
|
|
2014
2176
|
description: "Insert new blocks",
|
|
2015
2177
|
schema: {
|
|
2016
2178
|
block: {
|
|
@@ -2020,8 +2182,8 @@ const W = {
|
|
|
2020
2182
|
block: { type: "string", description: "markdown of block" }
|
|
2021
2183
|
}
|
|
2022
2184
|
},
|
|
2023
|
-
validateBlock:
|
|
2024
|
-
rebaseTool:
|
|
2185
|
+
validateBlock: xe,
|
|
2186
|
+
rebaseTool: Te,
|
|
2025
2187
|
toJSONToolCall: async (e, t) => {
|
|
2026
2188
|
const o = await Promise.all(
|
|
2027
2189
|
t.operation.blocks.map(async (r) => {
|
|
@@ -2035,7 +2197,7 @@ const W = {
|
|
|
2035
2197
|
};
|
|
2036
2198
|
}
|
|
2037
2199
|
}),
|
|
2038
|
-
update:
|
|
2200
|
+
update: ne({
|
|
2039
2201
|
description: "Update a block, the new block will replace the existing block.",
|
|
2040
2202
|
schema: {
|
|
2041
2203
|
block: {
|
|
@@ -2045,8 +2207,8 @@ const W = {
|
|
|
2045
2207
|
block: { type: "string", description: "markdown of block" }
|
|
2046
2208
|
}
|
|
2047
2209
|
},
|
|
2048
|
-
validateBlock:
|
|
2049
|
-
rebaseTool:
|
|
2210
|
+
validateBlock: xe,
|
|
2211
|
+
rebaseTool: Te,
|
|
2050
2212
|
toJSONToolCall: async (e, t) => {
|
|
2051
2213
|
const o = (await e.tryParseMarkdownToBlocks(t.operation.block.trim()))[0];
|
|
2052
2214
|
return delete o.id, window.__TEST_OPTIONS && (window.__TEST_OPTIONS.mockID = void 0), {
|
|
@@ -2055,58 +2217,219 @@ const W = {
|
|
|
2055
2217
|
};
|
|
2056
2218
|
}
|
|
2057
2219
|
}),
|
|
2058
|
-
delete:
|
|
2220
|
+
delete: se
|
|
2221
|
+
};
|
|
2222
|
+
function To(e, t) {
|
|
2223
|
+
e.length > 0 && e.push(
|
|
2224
|
+
{
|
|
2225
|
+
role: "assistant",
|
|
2226
|
+
id: "document-state-" + e.length,
|
|
2227
|
+
parts: [
|
|
2228
|
+
{
|
|
2229
|
+
type: "text",
|
|
2230
|
+
text: "This is the latest state of the selection (ignore previous selections, you MUST issue operations against this latest version of the selection):"
|
|
2231
|
+
},
|
|
2232
|
+
{
|
|
2233
|
+
type: "text",
|
|
2234
|
+
text: JSON.stringify(t.markdownSelectedBlocks)
|
|
2235
|
+
},
|
|
2236
|
+
{
|
|
2237
|
+
type: "text",
|
|
2238
|
+
text: "This is the latest state of the document (INCLUDING the selected text), find the selected text in there to understand the context:"
|
|
2239
|
+
},
|
|
2240
|
+
{
|
|
2241
|
+
type: "text",
|
|
2242
|
+
text: JSON.stringify(t.markdownDocument)
|
|
2243
|
+
}
|
|
2244
|
+
]
|
|
2245
|
+
},
|
|
2246
|
+
{
|
|
2247
|
+
role: "user",
|
|
2248
|
+
id: "user-prompt-" + e.length,
|
|
2249
|
+
parts: [
|
|
2250
|
+
{
|
|
2251
|
+
type: "text",
|
|
2252
|
+
text: "The user asks you to do the following:"
|
|
2253
|
+
},
|
|
2254
|
+
{
|
|
2255
|
+
type: "text",
|
|
2256
|
+
text: t.userPrompt
|
|
2257
|
+
}
|
|
2258
|
+
]
|
|
2259
|
+
}
|
|
2260
|
+
), e.push(
|
|
2261
|
+
{
|
|
2262
|
+
role: "system",
|
|
2263
|
+
id: "document-state-intro",
|
|
2264
|
+
parts: [
|
|
2265
|
+
{
|
|
2266
|
+
type: "text",
|
|
2267
|
+
text: `You're manipulating a selected part of a text document using Markdown blocks.
|
|
2268
|
+
Make sure to follow the json schema provided and always include the trailing $ in ids.
|
|
2269
|
+
This is the selection as an array of Markdown blocks:`
|
|
2270
|
+
},
|
|
2271
|
+
{
|
|
2272
|
+
type: "text",
|
|
2273
|
+
text: JSON.stringify(t.markdownSelectedBlocks)
|
|
2274
|
+
},
|
|
2275
|
+
{
|
|
2276
|
+
type: "text",
|
|
2277
|
+
text: "This is the entire document (INCLUDING the selected text), find the selected text in there to understand the context:"
|
|
2278
|
+
},
|
|
2279
|
+
{
|
|
2280
|
+
type: "text",
|
|
2281
|
+
text: JSON.stringify(t.markdownDocument)
|
|
2282
|
+
}
|
|
2283
|
+
]
|
|
2284
|
+
},
|
|
2285
|
+
{
|
|
2286
|
+
role: "user",
|
|
2287
|
+
id: "user-prompt",
|
|
2288
|
+
parts: [
|
|
2289
|
+
{
|
|
2290
|
+
type: "text",
|
|
2291
|
+
text: t.userPrompt
|
|
2292
|
+
}
|
|
2293
|
+
]
|
|
2294
|
+
}
|
|
2295
|
+
);
|
|
2296
|
+
}
|
|
2297
|
+
function xo(e, t) {
|
|
2298
|
+
if (e.length > 0) {
|
|
2299
|
+
e.push(
|
|
2300
|
+
{
|
|
2301
|
+
role: "assistant",
|
|
2302
|
+
id: "document-state-" + e.length,
|
|
2303
|
+
parts: [
|
|
2304
|
+
{
|
|
2305
|
+
type: "text",
|
|
2306
|
+
text: "This is the latest state of the document (ignore previous documents, you MUST issue operations against this latest version of the document):"
|
|
2307
|
+
},
|
|
2308
|
+
{
|
|
2309
|
+
type: "text",
|
|
2310
|
+
text: JSON.stringify(t.markdownBlocks)
|
|
2311
|
+
}
|
|
2312
|
+
]
|
|
2313
|
+
},
|
|
2314
|
+
{
|
|
2315
|
+
role: "user",
|
|
2316
|
+
id: "user-prompt-" + e.length,
|
|
2317
|
+
parts: [
|
|
2318
|
+
{
|
|
2319
|
+
type: "text",
|
|
2320
|
+
text: t.userPrompt
|
|
2321
|
+
}
|
|
2322
|
+
]
|
|
2323
|
+
}
|
|
2324
|
+
);
|
|
2325
|
+
return;
|
|
2326
|
+
}
|
|
2327
|
+
e.push(
|
|
2328
|
+
{
|
|
2329
|
+
role: "system",
|
|
2330
|
+
id: "document-state",
|
|
2331
|
+
parts: [
|
|
2332
|
+
{
|
|
2333
|
+
type: "text",
|
|
2334
|
+
text: `You're manipulating a text document using Markdown blocks.
|
|
2335
|
+
Make sure to follow the json schema provided. When referencing ids they MUST be EXACTLY the same (including the trailing $).
|
|
2336
|
+
This is the initial document as an array of Markdown blocks (the cursor is BETWEEN two blocks as indicated by cursor: true):`
|
|
2337
|
+
},
|
|
2338
|
+
{
|
|
2339
|
+
type: "text",
|
|
2340
|
+
text: JSON.stringify(t.markdownBlocks)
|
|
2341
|
+
},
|
|
2342
|
+
{
|
|
2343
|
+
type: "text",
|
|
2344
|
+
text: 'First, determine what part of the document the user is talking about. You SHOULD probably take cursor info into account if needed.\n EXAMPLE: if user says "below" (without pointing to a specific part of the document) he / she probably indicates the block(s) after the cursor. \n EXAMPLE: If you want to insert content AT the cursor position (UNLESS indicated otherwise by the user), \n then you need `referenceId` to point to the block before the cursor with position `after` (or block below and `before`).\n \n ' + (t.isEmptyDocument ? "Because the document is empty, 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).")
|
|
2345
|
+
}
|
|
2346
|
+
]
|
|
2347
|
+
},
|
|
2348
|
+
{
|
|
2349
|
+
role: "user",
|
|
2350
|
+
id: "user-prompt",
|
|
2351
|
+
parts: [
|
|
2352
|
+
{
|
|
2353
|
+
type: "text",
|
|
2354
|
+
text: t.userPrompt
|
|
2355
|
+
}
|
|
2356
|
+
]
|
|
2357
|
+
}
|
|
2358
|
+
);
|
|
2359
|
+
}
|
|
2360
|
+
const vo = async (e, t) => {
|
|
2361
|
+
t.selection ? To(e, t) : xo(e, t);
|
|
2059
2362
|
};
|
|
2060
|
-
function
|
|
2061
|
-
|
|
2363
|
+
function Po(e, t, o, r, n) {
|
|
2364
|
+
if (typeof r == "boolean") {
|
|
2365
|
+
const i = r ? e.getSelectionCutBlocks() : void 0;
|
|
2366
|
+
r = i ? {
|
|
2367
|
+
from: i._meta.startPos,
|
|
2368
|
+
to: i._meta.endPos
|
|
2369
|
+
} : void 0;
|
|
2370
|
+
}
|
|
2371
|
+
const s = o ?? {
|
|
2062
2372
|
add: !0,
|
|
2063
2373
|
update: !0,
|
|
2064
|
-
delete: !0
|
|
2065
|
-
...o
|
|
2374
|
+
delete: !0
|
|
2066
2375
|
};
|
|
2067
2376
|
return [
|
|
2068
|
-
...
|
|
2069
|
-
|
|
2377
|
+
...s.update ? [
|
|
2378
|
+
z.update(e, {
|
|
2070
2379
|
idsSuffixed: !0,
|
|
2071
2380
|
withDelays: t,
|
|
2072
|
-
updateSelection: r
|
|
2381
|
+
updateSelection: r,
|
|
2382
|
+
onBlockUpdate: n
|
|
2073
2383
|
})
|
|
2074
2384
|
] : [],
|
|
2075
|
-
...
|
|
2076
|
-
...
|
|
2385
|
+
...s.add ? [z.add(e, { idsSuffixed: !0, withDelays: t, onBlockUpdate: n })] : [],
|
|
2386
|
+
...s.delete ? [z.delete(e, { idsSuffixed: !0, withDelays: t, onBlockUpdate: n })] : []
|
|
2077
2387
|
];
|
|
2078
2388
|
}
|
|
2079
|
-
const
|
|
2389
|
+
const Co = {
|
|
2080
2390
|
/**
|
|
2081
|
-
* Function to get the stream tools that can apply
|
|
2391
|
+
* Function to get the stream tools that can apply Markdown block updates to the editor
|
|
2082
2392
|
*/
|
|
2083
|
-
|
|
2393
|
+
getStreamToolsProvider: (e = {}) => ({
|
|
2394
|
+
getStreamTools: (t, o, r) => Po(
|
|
2395
|
+
t,
|
|
2396
|
+
e.withDelays ?? !0,
|
|
2397
|
+
e.defaultStreamTools,
|
|
2398
|
+
o,
|
|
2399
|
+
r
|
|
2400
|
+
)
|
|
2401
|
+
}),
|
|
2402
|
+
tools: z,
|
|
2084
2403
|
/**
|
|
2085
2404
|
* The default PromptBuilder that determines how a userPrompt is converted to an array of
|
|
2086
2405
|
* LLM Messages (CoreMessage[])
|
|
2087
2406
|
*/
|
|
2088
|
-
defaultPromptBuilder:
|
|
2407
|
+
defaultPromptBuilder: vo,
|
|
2408
|
+
/**
|
|
2409
|
+
* The default PromptInputDataBuilder that can take an editor and user request and convert it to the input required for the PromptBuilder
|
|
2410
|
+
*/
|
|
2411
|
+
defaultPromptInputDataBuilder: wo,
|
|
2089
2412
|
/**
|
|
2090
2413
|
* Helper functions which can be used when implementing a custom PromptBuilder
|
|
2091
2414
|
*/
|
|
2092
2415
|
promptHelpers: {
|
|
2093
|
-
getDataForPromptNoSelection:
|
|
2094
|
-
getDataForPromptWithSelection:
|
|
2416
|
+
getDataForPromptNoSelection: Ye,
|
|
2417
|
+
getDataForPromptWithSelection: Ge
|
|
2095
2418
|
}
|
|
2096
|
-
},
|
|
2097
|
-
|
|
2419
|
+
}, O = {
|
|
2420
|
+
_experimental_json: So,
|
|
2421
|
+
_experimental_markdown: Co,
|
|
2422
|
+
html: ao
|
|
2423
|
+
}, xr = {
|
|
2424
|
+
addCursorPosition: Z,
|
|
2098
2425
|
flattenBlocks: T,
|
|
2099
|
-
suffixIDs:
|
|
2100
|
-
trimEmptyBlocks:
|
|
2101
|
-
convertBlocks:
|
|
2102
|
-
},
|
|
2103
|
-
|
|
2104
|
-
_experimental_markdown: po,
|
|
2105
|
-
html: Ue
|
|
2106
|
-
}, we = new _e("blocknote-agent-cursor");
|
|
2107
|
-
function ho(e) {
|
|
2426
|
+
suffixIDs: _,
|
|
2427
|
+
trimEmptyBlocks: w,
|
|
2428
|
+
convertBlocks: P
|
|
2429
|
+
}, ve = new Ae("blocknote-agent-cursor");
|
|
2430
|
+
function Oo(e) {
|
|
2108
2431
|
return new Le({
|
|
2109
|
-
key:
|
|
2432
|
+
key: ve,
|
|
2110
2433
|
view: (t) => ({}),
|
|
2111
2434
|
state: {
|
|
2112
2435
|
init: () => ({
|
|
@@ -2123,67 +2446,79 @@ function ho(e) {
|
|
|
2123
2446
|
},
|
|
2124
2447
|
props: {
|
|
2125
2448
|
decorations: (t) => {
|
|
2126
|
-
const { doc: o } = t, { selection: r } =
|
|
2449
|
+
const { doc: o } = t, { selection: r } = ve.getState(t), n = [];
|
|
2127
2450
|
if (!r)
|
|
2128
|
-
return
|
|
2451
|
+
return ue.create(o, []);
|
|
2129
2452
|
n.push(
|
|
2130
|
-
|
|
2453
|
+
de.widget(r.head, () => Io(e), {
|
|
2131
2454
|
key: "agent-cursor",
|
|
2132
2455
|
side: 10
|
|
2133
2456
|
})
|
|
2134
2457
|
);
|
|
2135
2458
|
const s = Math.min(r.anchor, r.head), a = Math.max(r.anchor, r.head);
|
|
2136
2459
|
return n.push(
|
|
2137
|
-
|
|
2460
|
+
de.inline(s, a, gt(e), {
|
|
2138
2461
|
inclusiveEnd: !0,
|
|
2139
2462
|
inclusiveStart: !1
|
|
2140
2463
|
})
|
|
2141
|
-
),
|
|
2464
|
+
), ue.create(o, n);
|
|
2142
2465
|
}
|
|
2143
2466
|
}
|
|
2144
2467
|
});
|
|
2145
2468
|
}
|
|
2146
|
-
const
|
|
2469
|
+
const Io = (e) => {
|
|
2147
2470
|
const t = document.createElement("span");
|
|
2148
2471
|
t.classList.add("bn-collaboration-cursor__base"), t.setAttribute("data-active", "true");
|
|
2149
2472
|
const o = document.createElement("span");
|
|
2150
2473
|
o.setAttribute("contentedEditable", "false"), o.classList.add("bn-collaboration-cursor__caret"), o.setAttribute("style", `background-color: ${e.color}`);
|
|
2151
2474
|
const r = document.createElement("span");
|
|
2152
2475
|
return r.classList.add("bn-collaboration-cursor__label"), r.setAttribute("style", `background-color: ${e.color}`), r.insertBefore(document.createTextNode(e.name), null), o.insertBefore(r, null), t.insertBefore(document.createTextNode(""), null), t.insertBefore(o, null), t.insertBefore(document.createTextNode(""), null), t;
|
|
2153
|
-
},
|
|
2154
|
-
class
|
|
2476
|
+
}, Bo = new Ae("blocknote-ai-plugin");
|
|
2477
|
+
class Ke extends dt {
|
|
2155
2478
|
/**
|
|
2156
2479
|
* @internal use `createAIExtension` instead
|
|
2157
2480
|
*/
|
|
2158
2481
|
constructor(o, r) {
|
|
2159
2482
|
super();
|
|
2160
|
-
|
|
2483
|
+
M(this, "chatSession");
|
|
2484
|
+
M(this, "scrollInProgress", !1);
|
|
2485
|
+
M(this, "autoScroll", !1);
|
|
2161
2486
|
// internal store including setters
|
|
2162
|
-
|
|
2487
|
+
M(this, "_store", he()((o) => ({
|
|
2163
2488
|
aiMenuState: "closed"
|
|
2164
2489
|
})));
|
|
2165
2490
|
/**
|
|
2166
2491
|
* Returns a zustand store with the global configuration of the AI Extension.
|
|
2167
|
-
* These options are used by default across all LLM calls when calling {@link
|
|
2492
|
+
* These options are used by default across all LLM calls when calling {@link executeLLMRequest}
|
|
2168
2493
|
*/
|
|
2169
|
-
|
|
2170
|
-
this.editor = o, this.options =
|
|
2171
|
-
dataFormat: fo.html,
|
|
2172
|
-
stream: !0,
|
|
2494
|
+
M(this, "options");
|
|
2495
|
+
this.editor = o, this.options = he()((n) => ({
|
|
2173
2496
|
...r
|
|
2174
2497
|
})), this.addProsemirrorPlugin(
|
|
2175
2498
|
new Le({
|
|
2176
|
-
key:
|
|
2499
|
+
key: Bo,
|
|
2177
2500
|
filterTransaction: (n) => {
|
|
2178
2501
|
var a;
|
|
2179
2502
|
const s = this.store.getState().aiMenuState;
|
|
2180
|
-
return !(s !== "closed" && s.status === "ai-writing" && (a = n.getMeta(
|
|
2503
|
+
return !(s !== "closed" && s.status === "ai-writing" && (a = n.getMeta(yt)) != null && a.fixTables);
|
|
2181
2504
|
}
|
|
2182
2505
|
})
|
|
2183
|
-
), this.addProsemirrorPlugin(
|
|
2184
|
-
|
|
2506
|
+
), this.addProsemirrorPlugin(ft()), this.addProsemirrorPlugin(
|
|
2507
|
+
Oo(
|
|
2185
2508
|
r.agentCursor || { name: "AI", color: "#8bc6ff" }
|
|
2186
2509
|
)
|
|
2510
|
+
), document.addEventListener(
|
|
2511
|
+
"scroll",
|
|
2512
|
+
() => {
|
|
2513
|
+
this.scrollInProgress && (this.autoScroll = !1), this.scrollInProgress = !0;
|
|
2514
|
+
},
|
|
2515
|
+
!0
|
|
2516
|
+
), document.addEventListener(
|
|
2517
|
+
"scrollend",
|
|
2518
|
+
() => {
|
|
2519
|
+
this.scrollInProgress = !1;
|
|
2520
|
+
},
|
|
2521
|
+
!0
|
|
2187
2522
|
);
|
|
2188
2523
|
}
|
|
2189
2524
|
static key() {
|
|
@@ -2199,21 +2534,25 @@ class Ye extends lt {
|
|
|
2199
2534
|
* Open the AI menu at a specific block
|
|
2200
2535
|
*/
|
|
2201
2536
|
openAIMenuAtBlock(o) {
|
|
2537
|
+
var n;
|
|
2202
2538
|
this.editor.setForceSelectionVisible(!0), this.editor.isEditable = !1, this._store.setState({
|
|
2203
2539
|
aiMenuState: {
|
|
2204
2540
|
blockId: o,
|
|
2205
2541
|
status: "user-input"
|
|
2206
2542
|
}
|
|
2207
2543
|
});
|
|
2544
|
+
const r = (n = this.editor.domElement) == null ? void 0 : n.querySelector(
|
|
2545
|
+
`[data-node-type="blockContainer"][data-id="${o}"]`
|
|
2546
|
+
);
|
|
2547
|
+
r == null || r.scrollIntoView({ block: "center" });
|
|
2208
2548
|
}
|
|
2209
2549
|
/**
|
|
2210
2550
|
* Close the AI menu
|
|
2211
2551
|
*/
|
|
2212
2552
|
closeAIMenu() {
|
|
2213
|
-
this.
|
|
2214
|
-
aiMenuState: "closed"
|
|
2215
|
-
|
|
2216
|
-
}), this.editor.setForceSelectionVisible(!1), this.editor.isEditable = !0, this.editor.focus();
|
|
2553
|
+
this._store.setState({
|
|
2554
|
+
aiMenuState: "closed"
|
|
2555
|
+
}), this.chatSession = void 0, this.editor.setForceSelectionVisible(!1), this.editor.isEditable = !0, this.editor.focus();
|
|
2217
2556
|
}
|
|
2218
2557
|
/**
|
|
2219
2558
|
* Accept the changes made by the LLM
|
|
@@ -2221,22 +2560,22 @@ class Ye extends lt {
|
|
|
2221
2560
|
acceptChanges() {
|
|
2222
2561
|
var r;
|
|
2223
2562
|
const o = this.editor.prosemirrorState.doc;
|
|
2224
|
-
this.editor.exec((n, s) =>
|
|
2563
|
+
this.editor.exec((n, s) => le(n, (a) => {
|
|
2225
2564
|
s == null || s(a.setMeta("addToHistory", !1));
|
|
2226
2565
|
})), this.editor.exec((n, s) => {
|
|
2227
2566
|
const a = n.tr;
|
|
2228
2567
|
a.replace(
|
|
2229
2568
|
0,
|
|
2230
2569
|
a.doc.content.size,
|
|
2231
|
-
new
|
|
2570
|
+
new G(ce.from(o), 0, 0)
|
|
2232
2571
|
);
|
|
2233
2572
|
const i = n.apply(a);
|
|
2234
|
-
return
|
|
2573
|
+
return Ne(i, (l) => {
|
|
2235
2574
|
s == null || s(
|
|
2236
2575
|
a.replace(
|
|
2237
2576
|
0,
|
|
2238
2577
|
a.doc.content.size,
|
|
2239
|
-
new
|
|
2578
|
+
new G(ce.from(l.doc), 0, 0)
|
|
2240
2579
|
)
|
|
2241
2580
|
);
|
|
2242
2581
|
});
|
|
@@ -2247,7 +2586,7 @@ class Ye extends lt {
|
|
|
2247
2586
|
*/
|
|
2248
2587
|
rejectChanges() {
|
|
2249
2588
|
var o;
|
|
2250
|
-
this.editor.exec((r, n) =>
|
|
2589
|
+
this.editor.exec((r, n) => le(r, (s) => {
|
|
2251
2590
|
n == null || n(s.setMeta("addToHistory", !1));
|
|
2252
2591
|
})), (o = this.editor.forkYDocPlugin) == null || o.merge({ keepChanges: !1 }), this.closeAIMenu();
|
|
2253
2592
|
}
|
|
@@ -2257,32 +2596,31 @@ class Ye extends lt {
|
|
|
2257
2596
|
* Only valid if the current status is "error"
|
|
2258
2597
|
*/
|
|
2259
2598
|
async retry() {
|
|
2260
|
-
|
|
2261
|
-
|
|
2599
|
+
var r;
|
|
2600
|
+
const { aiMenuState: o } = this.store.getState();
|
|
2601
|
+
if (o === "closed" || o.status !== "error" || !this.chatSession)
|
|
2262
2602
|
throw new Error("retry() is only valid when a previous response failed");
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
});
|
|
2271
|
-
}
|
|
2603
|
+
return ((r = this.chatSession) == null ? void 0 : r.chat.status) === "error" ? this.invokeAI({
|
|
2604
|
+
...this.chatSession.previousRequestOptions,
|
|
2605
|
+
userPrompt: "An error occured in the previous request. Please retry to accomplish the last user prompt."
|
|
2606
|
+
}) : this.invokeAI({
|
|
2607
|
+
...this.chatSession.previousRequestOptions,
|
|
2608
|
+
userPrompt: "An error occured while executing the previous tool call. Please retry to accomplish the last user prompt."
|
|
2609
|
+
});
|
|
2272
2610
|
}
|
|
2273
2611
|
/**
|
|
2274
2612
|
* Update the status of a call to an LLM
|
|
2275
2613
|
*
|
|
2276
2614
|
* @warning This method should usually only be used for advanced use-cases
|
|
2277
2615
|
* if you want to implement how an LLM call is executed. Usually, you should
|
|
2278
|
-
* use {@link
|
|
2616
|
+
* use {@link executeLLMRequest} instead which will handle the status updates for you.
|
|
2279
2617
|
*/
|
|
2280
2618
|
setAIResponseStatus(o) {
|
|
2281
2619
|
const r = this.store.getState().aiMenuState;
|
|
2282
2620
|
if (r !== "closed")
|
|
2283
2621
|
if (o === "ai-writing" && this.editor.setForceSelectionVisible(!1), typeof o == "object") {
|
|
2284
2622
|
if (o.status !== "error")
|
|
2285
|
-
throw new
|
|
2623
|
+
throw new Be(o.status);
|
|
2286
2624
|
this._store.setState({
|
|
2287
2625
|
aiMenuState: {
|
|
2288
2626
|
status: o.status,
|
|
@@ -2299,104 +2637,107 @@ class Ye extends lt {
|
|
|
2299
2637
|
});
|
|
2300
2638
|
}
|
|
2301
2639
|
/**
|
|
2302
|
-
*
|
|
2640
|
+
* @deprecated Use {@link invokeAI} instead
|
|
2303
2641
|
*/
|
|
2304
2642
|
async callLLM(o) {
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2643
|
+
return this.invokeAI(o);
|
|
2644
|
+
}
|
|
2645
|
+
/**
|
|
2646
|
+
* Execute a call to an LLM and apply the result to the editor
|
|
2647
|
+
*/
|
|
2648
|
+
async invokeAI(o) {
|
|
2649
|
+
var r, n;
|
|
2650
|
+
this.setAIResponseStatus("thinking"), (r = this.editor.forkYDocPlugin) == null || r.fork();
|
|
2308
2651
|
try {
|
|
2309
|
-
|
|
2652
|
+
this.chatSession ? this.chatSession.previousRequestOptions = o : this.chatSession = {
|
|
2653
|
+
previousRequestOptions: o,
|
|
2654
|
+
chat: new nt({
|
|
2655
|
+
sendAutomaticallyWhen: () => !1,
|
|
2656
|
+
transport: o.transport || this.options.getState().transport
|
|
2657
|
+
})
|
|
2658
|
+
};
|
|
2659
|
+
const s = this.chatSession.chat;
|
|
2660
|
+
o = {
|
|
2310
2661
|
...this.options.getState(),
|
|
2311
|
-
...o
|
|
2312
|
-
previousResponse: this.store.getState().llmResponse
|
|
2662
|
+
...o
|
|
2313
2663
|
};
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2664
|
+
const i = o.aiRequestSender ?? At(
|
|
2665
|
+
O.html.defaultPromptBuilder,
|
|
2666
|
+
O.html.defaultPromptInputDataBuilder
|
|
2667
|
+
), l = Kt({
|
|
2668
|
+
editor: this.editor,
|
|
2669
|
+
chat: s,
|
|
2670
|
+
userPrompt: o.userPrompt,
|
|
2671
|
+
useSelection: o.useSelection,
|
|
2672
|
+
deleteEmptyCursorBlock: o.deleteEmptyCursorBlock,
|
|
2673
|
+
streamToolsProvider: o.streamToolsProvider,
|
|
2674
|
+
onBlockUpdated: (c) => {
|
|
2675
|
+
if (this._store.setState({
|
|
2323
2676
|
aiMenuState: {
|
|
2324
|
-
blockId:
|
|
2677
|
+
blockId: c,
|
|
2325
2678
|
status: "ai-writing"
|
|
2326
2679
|
}
|
|
2327
|
-
}),
|
|
2680
|
+
}), !this.autoScroll)
|
|
2681
|
+
return;
|
|
2682
|
+
const u = this._store.getState().aiMenuState, m = u === "closed" ? void 0 : u;
|
|
2683
|
+
if (!m || m.status !== "ai-writing")
|
|
2684
|
+
return;
|
|
2685
|
+
const p = Me(
|
|
2686
|
+
m.blockId,
|
|
2687
|
+
this.editor.prosemirrorState.doc
|
|
2688
|
+
);
|
|
2689
|
+
if (!p)
|
|
2690
|
+
return;
|
|
2691
|
+
this.editor.prosemirrorView.domAtPos(
|
|
2692
|
+
p.posBeforeNode + 1
|
|
2693
|
+
).node.scrollIntoView({
|
|
2694
|
+
block: "center"
|
|
2695
|
+
});
|
|
2696
|
+
}
|
|
2697
|
+
});
|
|
2698
|
+
await Xt({
|
|
2699
|
+
aiRequest: l,
|
|
2700
|
+
sender: i,
|
|
2701
|
+
chatRequestOptions: o.chatRequestOptions,
|
|
2702
|
+
onStart: () => {
|
|
2703
|
+
this.autoScroll = !0, this.setAIResponseStatus("ai-writing");
|
|
2328
2704
|
}
|
|
2329
|
-
}), this.
|
|
2330
|
-
llmResponse: r
|
|
2331
|
-
}), await r.execute(), this.setAIResponseStatus("user-reviewing");
|
|
2705
|
+
}), this.setAIResponseStatus("user-reviewing");
|
|
2332
2706
|
} catch (s) {
|
|
2333
2707
|
this.setAIResponseStatus({
|
|
2334
2708
|
status: "error",
|
|
2335
2709
|
error: s
|
|
2336
|
-
}), console.warn("Error calling LLM", s);
|
|
2710
|
+
}), console.warn("Error calling LLM", s, (n = this.chatSession) == null ? void 0 : n.chat.messages);
|
|
2337
2711
|
}
|
|
2338
|
-
return r;
|
|
2339
2712
|
}
|
|
2340
2713
|
}
|
|
2341
|
-
function
|
|
2342
|
-
return (t) => new
|
|
2343
|
-
}
|
|
2344
|
-
function O(e) {
|
|
2345
|
-
return e.extension(Ye);
|
|
2714
|
+
function vr(e) {
|
|
2715
|
+
return (t) => new Ke(t, e);
|
|
2346
2716
|
}
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
);
|
|
2361
|
-
try {
|
|
2362
|
-
return await fetch(s);
|
|
2363
|
-
} catch (a) {
|
|
2364
|
-
throw new TypeError("fetch failed", {
|
|
2365
|
-
cause: a
|
|
2366
|
-
});
|
|
2367
|
-
}
|
|
2717
|
+
function I(e) {
|
|
2718
|
+
return e.extension(Ke);
|
|
2719
|
+
}
|
|
2720
|
+
const Pr = (e) => async (t, o) => {
|
|
2721
|
+
const r = new Request(t, o), n = e(r.url), s = new Request(n, {
|
|
2722
|
+
headers: r.headers,
|
|
2723
|
+
// if we just pass request.body, it's a readablestream which is not visible in chrome inspector,
|
|
2724
|
+
// so use init?.body instead if it's available to make debugging easier
|
|
2725
|
+
body: (o == null ? void 0 : o.body) || r.body,
|
|
2726
|
+
method: r.method,
|
|
2727
|
+
duplex: "half"
|
|
2728
|
+
});
|
|
2729
|
+
return await fetch(s);
|
|
2368
2730
|
};
|
|
2369
|
-
|
|
2370
|
-
return {
|
|
2371
|
-
/**
|
|
2372
|
-
* Get settings for AI SDK providers. Pass the returned objects when creating the AI SDK provider, e.g.:
|
|
2373
|
-
*
|
|
2374
|
-
* createOpenAI({
|
|
2375
|
-
* ...client.getProviderSettings("openai"),
|
|
2376
|
-
* })("gpt-4o-2024-08-06", {});
|
|
2377
|
-
*
|
|
2378
|
-
* Explanation: we override the `fetch` and `apiKey` parameters of the AI SDK provider to instead
|
|
2379
|
-
* use the BlockNote AI server to proxy requests to the provider.
|
|
2380
|
-
*
|
|
2381
|
-
* Note: the `apiKey` is the API key for the @blocknote/xl-ai-server AI server, not the model provider.
|
|
2382
|
-
* The correct API key for the model provider will be added by the BlockNote AI server.
|
|
2383
|
-
*/
|
|
2384
|
-
getProviderSettings: (t) => ({
|
|
2385
|
-
apiKey: e.apiKey,
|
|
2386
|
-
fetch: ko(e.baseURL, t)
|
|
2387
|
-
})
|
|
2388
|
-
};
|
|
2389
|
-
}
|
|
2390
|
-
var Ge = {
|
|
2731
|
+
var Xe = {
|
|
2391
2732
|
color: void 0,
|
|
2392
2733
|
size: void 0,
|
|
2393
2734
|
className: void 0,
|
|
2394
2735
|
style: void 0,
|
|
2395
2736
|
attr: void 0
|
|
2396
|
-
},
|
|
2397
|
-
function
|
|
2737
|
+
}, Pe = E.createContext && /* @__PURE__ */ E.createContext(Xe), Mo = ["attr", "size", "title"];
|
|
2738
|
+
function Eo(e, t) {
|
|
2398
2739
|
if (e == null) return {};
|
|
2399
|
-
var o =
|
|
2740
|
+
var o = _o(e, t), r, n;
|
|
2400
2741
|
if (Object.getOwnPropertySymbols) {
|
|
2401
2742
|
var s = Object.getOwnPropertySymbols(e);
|
|
2402
2743
|
for (n = 0; n < s.length; n++)
|
|
@@ -2404,7 +2745,7 @@ function So(e, t) {
|
|
|
2404
2745
|
}
|
|
2405
2746
|
return o;
|
|
2406
2747
|
}
|
|
2407
|
-
function
|
|
2748
|
+
function _o(e, t) {
|
|
2408
2749
|
if (e == null) return {};
|
|
2409
2750
|
var o = {};
|
|
2410
2751
|
for (var r in e)
|
|
@@ -2414,17 +2755,17 @@ function wo(e, t) {
|
|
|
2414
2755
|
}
|
|
2415
2756
|
return o;
|
|
2416
2757
|
}
|
|
2417
|
-
function
|
|
2418
|
-
return
|
|
2758
|
+
function F() {
|
|
2759
|
+
return F = Object.assign ? Object.assign.bind() : function(e) {
|
|
2419
2760
|
for (var t = 1; t < arguments.length; t++) {
|
|
2420
2761
|
var o = arguments[t];
|
|
2421
2762
|
for (var r in o)
|
|
2422
2763
|
Object.prototype.hasOwnProperty.call(o, r) && (e[r] = o[r]);
|
|
2423
2764
|
}
|
|
2424
2765
|
return e;
|
|
2425
|
-
},
|
|
2766
|
+
}, F.apply(this, arguments);
|
|
2426
2767
|
}
|
|
2427
|
-
function
|
|
2768
|
+
function Ce(e, t) {
|
|
2428
2769
|
var o = Object.keys(e);
|
|
2429
2770
|
if (Object.getOwnPropertySymbols) {
|
|
2430
2771
|
var r = Object.getOwnPropertySymbols(e);
|
|
@@ -2434,25 +2775,25 @@ function ve(e, t) {
|
|
|
2434
2775
|
}
|
|
2435
2776
|
return o;
|
|
2436
2777
|
}
|
|
2437
|
-
function
|
|
2778
|
+
function R(e) {
|
|
2438
2779
|
for (var t = 1; t < arguments.length; t++) {
|
|
2439
2780
|
var o = arguments[t] != null ? arguments[t] : {};
|
|
2440
|
-
t % 2 ?
|
|
2441
|
-
|
|
2442
|
-
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(o)) :
|
|
2781
|
+
t % 2 ? Ce(Object(o), !0).forEach(function(r) {
|
|
2782
|
+
No(e, r, o[r]);
|
|
2783
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(o)) : Ce(Object(o)).forEach(function(r) {
|
|
2443
2784
|
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(o, r));
|
|
2444
2785
|
});
|
|
2445
2786
|
}
|
|
2446
2787
|
return e;
|
|
2447
2788
|
}
|
|
2448
|
-
function
|
|
2449
|
-
return t =
|
|
2789
|
+
function No(e, t, o) {
|
|
2790
|
+
return t = Lo(t), t in e ? Object.defineProperty(e, t, { value: o, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = o, e;
|
|
2450
2791
|
}
|
|
2451
|
-
function
|
|
2452
|
-
var t =
|
|
2792
|
+
function Lo(e) {
|
|
2793
|
+
var t = Ao(e, "string");
|
|
2453
2794
|
return typeof t == "symbol" ? t : t + "";
|
|
2454
2795
|
}
|
|
2455
|
-
function
|
|
2796
|
+
function Ao(e, t) {
|
|
2456
2797
|
if (typeof e != "object" || !e) return e;
|
|
2457
2798
|
var o = e[Symbol.toPrimitive];
|
|
2458
2799
|
if (o !== void 0) {
|
|
@@ -2462,102 +2803,102 @@ function Co(e, t) {
|
|
|
2462
2803
|
}
|
|
2463
2804
|
return (t === "string" ? String : Number)(e);
|
|
2464
2805
|
}
|
|
2465
|
-
function
|
|
2466
|
-
return e && e.map((t, o) => /* @__PURE__ */
|
|
2806
|
+
function Qe(e) {
|
|
2807
|
+
return e && e.map((t, o) => /* @__PURE__ */ E.createElement(t.tag, R({
|
|
2467
2808
|
key: o
|
|
2468
|
-
}, t.attr),
|
|
2809
|
+
}, t.attr), Qe(t.child)));
|
|
2469
2810
|
}
|
|
2470
|
-
function
|
|
2471
|
-
return (t) => /* @__PURE__ */
|
|
2472
|
-
attr:
|
|
2473
|
-
}, t),
|
|
2811
|
+
function x(e) {
|
|
2812
|
+
return (t) => /* @__PURE__ */ E.createElement(Do, F({
|
|
2813
|
+
attr: R({}, e.attr)
|
|
2814
|
+
}, t), Qe(e.child));
|
|
2474
2815
|
}
|
|
2475
|
-
function
|
|
2816
|
+
function Do(e) {
|
|
2476
2817
|
var t = (o) => {
|
|
2477
2818
|
var {
|
|
2478
2819
|
attr: r,
|
|
2479
2820
|
size: n,
|
|
2480
2821
|
title: s
|
|
2481
|
-
} = e, a =
|
|
2482
|
-
return o.className && (
|
|
2822
|
+
} = e, a = Eo(e, Mo), i = n || o.size || "1em", l;
|
|
2823
|
+
return o.className && (l = o.className), e.className && (l = (l ? l + " " : "") + e.className), /* @__PURE__ */ E.createElement("svg", F({
|
|
2483
2824
|
stroke: "currentColor",
|
|
2484
2825
|
fill: "currentColor",
|
|
2485
2826
|
strokeWidth: "0"
|
|
2486
2827
|
}, o.attr, r, a, {
|
|
2487
|
-
className:
|
|
2488
|
-
style:
|
|
2828
|
+
className: l,
|
|
2829
|
+
style: R(R({
|
|
2489
2830
|
color: e.color || o.color
|
|
2490
2831
|
}, o.style), e.style),
|
|
2491
2832
|
height: i,
|
|
2492
2833
|
width: i,
|
|
2493
2834
|
xmlns: "http://www.w3.org/2000/svg"
|
|
2494
|
-
}), s && /* @__PURE__ */
|
|
2835
|
+
}), s && /* @__PURE__ */ E.createElement("title", null, s), e.children);
|
|
2495
2836
|
};
|
|
2496
|
-
return
|
|
2837
|
+
return Pe !== void 0 ? /* @__PURE__ */ E.createElement(Pe.Consumer, null, (o) => t(o)) : t(Xe);
|
|
2497
2838
|
}
|
|
2498
|
-
function
|
|
2499
|
-
return
|
|
2839
|
+
function et(e) {
|
|
2840
|
+
return x({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M8 7V11L2 6L8 1V5H13C17.4183 5 21 8.58172 21 13C21 17.4183 17.4183 21 13 21H4V19H13C16.3137 19 19 16.3137 19 13C19 9.68629 16.3137 7 13 7H8Z" }, child: [] }] })(e);
|
|
2500
2841
|
}
|
|
2501
|
-
function
|
|
2502
|
-
return
|
|
2842
|
+
function Oe(e) {
|
|
2843
|
+
return x({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M17.8492 11.6983L17.1421 10.9912L7.24264 20.8907H3V16.648L14.3137 5.33432L19.9706 10.9912C20.3611 11.3817 20.3611 12.0149 19.9706 12.4054L12.8995 19.4765L11.4853 18.0622L17.8492 11.6983ZM15.7279 9.57696L14.3137 8.16274L5 17.4765V18.8907H6.41421L15.7279 9.57696ZM18.5563 2.50589L21.3848 5.33432C21.7753 5.72484 21.7753 6.35801 21.3848 6.74853L19.9706 8.16274L15.7279 3.9201L17.1421 2.50589C17.5327 2.11537 18.1658 2.11537 18.5563 2.50589Z" }, child: [] }] })(e);
|
|
2503
2844
|
}
|
|
2504
|
-
function
|
|
2505
|
-
return
|
|
2845
|
+
function jo(e) {
|
|
2846
|
+
return x({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M15.1986 9.94447C14.7649 9.5337 14.4859 8.98613 14.4085 8.39384L14.0056 5.31138L11.275 6.79724C10.7503 7.08274 10.1433 7.17888 9.55608 7.06948L6.49998 6.50015L7.06931 9.55625C7.17871 10.1435 7.08257 10.7505 6.79707 11.2751L5.31121 14.0057L8.39367 14.4086C8.98596 14.4861 9.53353 14.7651 9.94431 15.1987L12.0821 17.4557L13.4178 14.6486C13.6745 14.1092 14.109 13.6747 14.6484 13.418L17.4555 12.0823L15.1986 9.94447ZM15.2238 15.5079L13.0111 20.1581C12.8687 20.4573 12.5107 20.5844 12.2115 20.442C12.1448 20.4103 12.0845 20.3665 12.0337 20.3129L8.49229 16.5741C8.39749 16.474 8.27113 16.4096 8.13445 16.3918L3.02816 15.7243C2.69958 15.6814 2.46804 15.3802 2.51099 15.0516C2.52056 14.9784 2.54359 14.9075 2.5789 14.8426L5.04031 10.3192C5.1062 10.1981 5.12839 10.058 5.10314 9.92253L4.16 4.85991C4.09931 4.53414 4.3142 4.22086 4.63997 4.16017C4.7126 4.14664 4.78711 4.14664 4.85974 4.16017L9.92237 5.10331C10.0579 5.12855 10.198 5.10637 10.319 5.04048L14.8424 2.57907C15.1335 2.42068 15.4979 2.52825 15.6562 2.81931C15.6916 2.88421 15.7146 2.95507 15.7241 3.02833L16.3916 8.13462C16.4095 8.2713 16.4739 8.39766 16.5739 8.49245L20.3127 12.0338C20.5533 12.2617 20.5636 12.6415 20.3357 12.8821C20.2849 12.9357 20.2246 12.9795 20.1579 13.0112L15.5078 15.224C15.3833 15.2832 15.283 15.3835 15.2238 15.5079ZM16.0206 17.435L17.4348 16.0208L21.6775 20.2634L20.2633 21.6776L16.0206 17.435Z" }, child: [] }] })(e);
|
|
2506
2847
|
}
|
|
2507
|
-
function
|
|
2508
|
-
return
|
|
2848
|
+
function $o(e) {
|
|
2849
|
+
return x({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M8.00008 6V9H5.00008V6H8.00008ZM3.00008 4V11H10.0001V4H3.00008ZM13.0001 4H21.0001V6H13.0001V4ZM13.0001 11H21.0001V13H13.0001V11ZM13.0001 18H21.0001V20H13.0001V18ZM10.7072 16.2071L9.29297 14.7929L6.00008 18.0858L4.20718 16.2929L2.79297 17.7071L6.00008 20.9142L10.7072 16.2071Z" }, child: [] }] })(e);
|
|
2509
2850
|
}
|
|
2510
|
-
function
|
|
2511
|
-
return
|
|
2851
|
+
function Ho(e) {
|
|
2852
|
+
return x({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M15 18H16.5C17.8807 18 19 16.8807 19 15.5C19 14.1193 17.8807 13 16.5 13H3V11H16.5C18.9853 11 21 13.0147 21 15.5C21 17.9853 18.9853 20 16.5 20H15V22L11 19L15 16V18ZM3 4H21V6H3V4ZM9 18V20H3V18H9Z" }, child: [] }] })(e);
|
|
2512
2853
|
}
|
|
2513
|
-
function
|
|
2514
|
-
return
|
|
2854
|
+
function qo(e) {
|
|
2855
|
+
return x({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M13 6V21H11V6H5V4H19V6H13Z" }, child: [] }] })(e);
|
|
2515
2856
|
}
|
|
2516
|
-
function
|
|
2517
|
-
return
|
|
2857
|
+
function zo(e) {
|
|
2858
|
+
return x({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M6.23509 6.45329C4.85101 7.89148 4 9.84636 4 12C4 16.4183 7.58172 20 12 20C13.0808 20 14.1116 19.7857 15.0521 19.3972C15.1671 18.6467 14.9148 17.9266 14.8116 17.6746C14.582 17.115 13.8241 16.1582 12.5589 14.8308C12.2212 14.4758 12.2429 14.2035 12.3636 13.3943L12.3775 13.3029C12.4595 12.7486 12.5971 12.4209 14.4622 12.1248C15.4097 11.9746 15.6589 12.3533 16.0043 12.8777C16.0425 12.9358 16.0807 12.9928 16.1198 13.0499C16.4479 13.5297 16.691 13.6394 17.0582 13.8064C17.2227 13.881 17.428 13.9751 17.7031 14.1314C18.3551 14.504 18.3551 14.9247 18.3551 15.8472V15.9518C18.3551 16.3434 18.3168 16.6872 18.2566 16.9859C19.3478 15.6185 20 13.8854 20 12C20 8.70089 18.003 5.8682 15.1519 4.64482C14.5987 5.01813 13.8398 5.54726 13.575 5.91C13.4396 6.09538 13.2482 7.04166 12.6257 7.11976C12.4626 7.14023 12.2438 7.12589 12.012 7.11097C11.3905 7.07058 10.5402 7.01606 10.268 7.75495C10.0952 8.2232 10.0648 9.49445 10.6239 10.1543C10.7134 10.2597 10.7307 10.4547 10.6699 10.6735C10.59 10.9608 10.4286 11.1356 10.3783 11.1717C10.2819 11.1163 10.0896 10.8931 9.95938 10.7412C9.64554 10.3765 9.25405 9.92233 8.74797 9.78176C8.56395 9.73083 8.36166 9.68867 8.16548 9.64736C7.6164 9.53227 6.99443 9.40134 6.84992 9.09302C6.74442 8.8672 6.74488 8.55621 6.74529 8.22764C6.74529 7.8112 6.74529 7.34029 6.54129 6.88256C6.46246 6.70541 6.35689 6.56446 6.23509 6.45329ZM12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22Z" }, child: [] }] })(e);
|
|
2518
2859
|
}
|
|
2519
|
-
function
|
|
2520
|
-
return
|
|
2860
|
+
function Jo(e) {
|
|
2861
|
+
return x({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M9.9997 15.1709L19.1921 5.97852L20.6063 7.39273L9.9997 17.9993L3.63574 11.6354L5.04996 10.2212L9.9997 15.1709Z" }, child: [] }] })(e);
|
|
2521
2862
|
}
|
|
2522
|
-
function
|
|
2523
|
-
return
|
|
2863
|
+
function Uo(e) {
|
|
2864
|
+
return x({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M9.9997 15.1709L19.1921 5.97852L20.6063 7.39273L9.9997 17.9993L3.63574 11.6354L5.04996 10.2212L9.9997 15.1709Z" }, child: [] }] })(e);
|
|
2524
2865
|
}
|
|
2525
|
-
function
|
|
2526
|
-
return
|
|
2866
|
+
function Vo(e) {
|
|
2867
|
+
return x({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M12 4C9.4095 4 7.10606 5.23053 5.64274 7.14274L8 9.5H2V3.5L4.21863 5.71863C6.05061 3.452 8.85558 2 12 2 17.5228 2 22 6.47715 22 12H20C20 7.58172 16.4183 4 12 4ZM4 12C4 16.4183 7.58172 20 12 20 14.5905 20 16.894 18.7695 18.3573 16.8573L16 14.5 22 14.5V20.5L19.7814 18.2814C17.9494 20.548 15.1444 22 12 22 6.47715 22 2 17.5228 2 12H4Z" }, child: [] }] })(e);
|
|
2527
2868
|
}
|
|
2528
|
-
function
|
|
2529
|
-
return
|
|
2869
|
+
function ie(e) {
|
|
2870
|
+
return x({ attr: { viewBox: "0 0 24 24", fill: "currentColor" }, child: [{ tag: "path", attr: { d: "M17.0007 1.20825 18.3195 3.68108 20.7923 4.99992 18.3195 6.31876 17.0007 8.79159 15.6818 6.31876 13.209 4.99992 15.6818 3.68108 17.0007 1.20825ZM8.00065 4.33325 10.6673 9.33325 15.6673 11.9999 10.6673 14.6666 8.00065 19.6666 5.33398 14.6666.333984 11.9999 5.33398 9.33325 8.00065 4.33325ZM19.6673 16.3333 18.0007 13.2083 16.334 16.3333 13.209 17.9999 16.334 19.6666 18.0007 22.7916 19.6673 19.6666 22.7923 17.9999 19.6673 16.3333Z" }, child: [] }] })(e);
|
|
2530
2871
|
}
|
|
2531
|
-
function
|
|
2872
|
+
function L(e) {
|
|
2532
2873
|
if (!e.dictionary.ai)
|
|
2533
2874
|
throw new Error("AI dictionary not found");
|
|
2534
2875
|
return e.dictionary.ai;
|
|
2535
2876
|
}
|
|
2536
|
-
function
|
|
2537
|
-
const e =
|
|
2538
|
-
return
|
|
2877
|
+
function tt() {
|
|
2878
|
+
const e = Ot();
|
|
2879
|
+
return L(e.editor);
|
|
2539
2880
|
}
|
|
2540
|
-
const
|
|
2541
|
-
const t =
|
|
2542
|
-
async (
|
|
2543
|
-
|
|
2881
|
+
const Fo = (e) => {
|
|
2882
|
+
const t = X(), { onManualPromptSubmit: o, promptText: r, onPromptTextChange: n } = e, [s, a] = $e(""), i = r || s, l = $(
|
|
2883
|
+
async (f) => {
|
|
2884
|
+
f.key === "Enter" && o(i);
|
|
2544
2885
|
},
|
|
2545
2886
|
[i, o]
|
|
2546
|
-
),
|
|
2547
|
-
(
|
|
2548
|
-
const
|
|
2549
|
-
n && n(
|
|
2887
|
+
), c = $(
|
|
2888
|
+
(f) => {
|
|
2889
|
+
const k = f.currentTarget.value;
|
|
2890
|
+
n && n(k), r === void 0 && a(k);
|
|
2550
2891
|
},
|
|
2551
2892
|
[n, a, r]
|
|
2552
|
-
),
|
|
2553
|
-
(
|
|
2554
|
-
|
|
2893
|
+
), u = A(() => pt(e.items, i), [i, e.items]), { selectedIndex: m, setSelectedIndex: p, handler: d } = It(u, (f) => f.onItemClick()), h = $(
|
|
2894
|
+
(f) => {
|
|
2895
|
+
f.key === "Enter" ? u.length > 0 ? d(f) : l(f) : d(f);
|
|
2555
2896
|
},
|
|
2556
|
-
[
|
|
2897
|
+
[l, d, u.length]
|
|
2557
2898
|
);
|
|
2558
|
-
return
|
|
2559
|
-
|
|
2560
|
-
}, [i,
|
|
2899
|
+
return He(() => {
|
|
2900
|
+
p(0);
|
|
2901
|
+
}, [i, p]), /* @__PURE__ */ Ct("div", { className: "bn-combobox", children: [
|
|
2561
2902
|
/* @__PURE__ */ y(t.Generic.Form.Root, { children: /* @__PURE__ */ y(
|
|
2562
2903
|
t.Generic.Form.TextInput,
|
|
2563
2904
|
{
|
|
@@ -2570,7 +2911,7 @@ const No = (e) => {
|
|
|
2570
2911
|
placeholder: e.placeholder,
|
|
2571
2912
|
disabled: e.disabled,
|
|
2572
2913
|
onKeyDown: h,
|
|
2573
|
-
onChange:
|
|
2914
|
+
onChange: c,
|
|
2574
2915
|
autoComplete: "off",
|
|
2575
2916
|
rightSection: e.rightSection
|
|
2576
2917
|
},
|
|
@@ -2581,41 +2922,43 @@ const No = (e) => {
|
|
|
2581
2922
|
{
|
|
2582
2923
|
className: "bn-combobox-items",
|
|
2583
2924
|
id: "ai-suggestion-menu",
|
|
2584
|
-
children:
|
|
2925
|
+
children: u.map((f, k) => /* @__PURE__ */ y(
|
|
2585
2926
|
t.SuggestionMenu.Item,
|
|
2586
2927
|
{
|
|
2587
|
-
className:
|
|
2928
|
+
className: mt(
|
|
2588
2929
|
"bn-suggestion-menu-item",
|
|
2589
|
-
|
|
2930
|
+
f.size === "small" ? "bn-suggestion-menu-item-small" : ""
|
|
2590
2931
|
),
|
|
2591
|
-
id: `bn-suggestion-menu-item-${
|
|
2592
|
-
isSelected:
|
|
2593
|
-
onClick:
|
|
2594
|
-
item:
|
|
2932
|
+
id: `bn-suggestion-menu-item-${k}`,
|
|
2933
|
+
isSelected: k === m,
|
|
2934
|
+
onClick: f.onItemClick,
|
|
2935
|
+
item: f
|
|
2595
2936
|
},
|
|
2596
|
-
|
|
2937
|
+
f.title
|
|
2597
2938
|
))
|
|
2598
2939
|
}
|
|
2599
2940
|
)
|
|
2600
2941
|
] });
|
|
2601
2942
|
};
|
|
2602
|
-
function
|
|
2603
|
-
const t =
|
|
2943
|
+
function Ro(e) {
|
|
2944
|
+
const t = L(e), o = I(e);
|
|
2604
2945
|
return [
|
|
2605
2946
|
{
|
|
2606
2947
|
key: "continue_writing",
|
|
2607
2948
|
title: t.ai_default_commands.continue_writing.title,
|
|
2608
2949
|
aliases: t.ai_default_commands.continue_writing.aliases,
|
|
2609
|
-
icon: /* @__PURE__ */ y(
|
|
2950
|
+
icon: /* @__PURE__ */ y(Oe, { size: 18 }),
|
|
2610
2951
|
onItemClick: async () => {
|
|
2611
|
-
await o.
|
|
2952
|
+
await o.invokeAI({
|
|
2612
2953
|
userPrompt: "Continue writing at the current cursor position related to the previous text. Add multiple blocks if needed. If the document looks like a template / draft, follow the template. Be extensive if needed.",
|
|
2613
2954
|
// By default, LLM will be able to add / update / delete blocks. For "continue writing", we only want to allow adding new blocks.
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2955
|
+
streamToolsProvider: O.html.getStreamToolsProvider({
|
|
2956
|
+
defaultStreamTools: {
|
|
2957
|
+
add: !0,
|
|
2958
|
+
delete: !1,
|
|
2959
|
+
update: !1
|
|
2960
|
+
}
|
|
2961
|
+
})
|
|
2619
2962
|
});
|
|
2620
2963
|
},
|
|
2621
2964
|
size: "small"
|
|
@@ -2624,16 +2967,18 @@ function Ao(e) {
|
|
|
2624
2967
|
key: "summarize",
|
|
2625
2968
|
title: t.ai_default_commands.summarize.title,
|
|
2626
2969
|
aliases: t.ai_default_commands.summarize.aliases,
|
|
2627
|
-
icon: /* @__PURE__ */ y(
|
|
2970
|
+
icon: /* @__PURE__ */ y(Ho, { size: 18 }),
|
|
2628
2971
|
onItemClick: async () => {
|
|
2629
|
-
await o.
|
|
2972
|
+
await o.invokeAI({
|
|
2630
2973
|
userPrompt: "Summarize",
|
|
2631
2974
|
// By default, LLM will be able to add / update / delete blocks. For "summarize", we only want to allow adding new blocks.
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2975
|
+
streamToolsProvider: O.html.getStreamToolsProvider({
|
|
2976
|
+
defaultStreamTools: {
|
|
2977
|
+
add: !0,
|
|
2978
|
+
delete: !1,
|
|
2979
|
+
update: !1
|
|
2980
|
+
}
|
|
2981
|
+
})
|
|
2637
2982
|
});
|
|
2638
2983
|
},
|
|
2639
2984
|
size: "small"
|
|
@@ -2642,16 +2987,18 @@ function Ao(e) {
|
|
|
2642
2987
|
key: "action_items",
|
|
2643
2988
|
title: t.ai_default_commands.add_action_items.title,
|
|
2644
2989
|
aliases: t.ai_default_commands.add_action_items.aliases,
|
|
2645
|
-
icon: /* @__PURE__ */ y(
|
|
2990
|
+
icon: /* @__PURE__ */ y($o, { size: 18 }),
|
|
2646
2991
|
onItemClick: async () => {
|
|
2647
|
-
await o.
|
|
2992
|
+
await o.invokeAI({
|
|
2648
2993
|
userPrompt: "Add action items",
|
|
2649
2994
|
// By default, LLM will be able to add / update / delete blocks. For "summarize", we only want to allow adding new blocks.
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2995
|
+
streamToolsProvider: O.html.getStreamToolsProvider({
|
|
2996
|
+
defaultStreamTools: {
|
|
2997
|
+
add: !0,
|
|
2998
|
+
delete: !1,
|
|
2999
|
+
update: !1
|
|
3000
|
+
}
|
|
3001
|
+
})
|
|
2655
3002
|
});
|
|
2656
3003
|
},
|
|
2657
3004
|
size: "small"
|
|
@@ -2660,7 +3007,7 @@ function Ao(e) {
|
|
|
2660
3007
|
key: "write_anything",
|
|
2661
3008
|
title: t.ai_default_commands.write_anything.title,
|
|
2662
3009
|
aliases: t.ai_default_commands.write_anything.aliases,
|
|
2663
|
-
icon: /* @__PURE__ */ y(
|
|
3010
|
+
icon: /* @__PURE__ */ y(Oe, { size: 18 }),
|
|
2664
3011
|
onItemClick: (r) => {
|
|
2665
3012
|
r(t.ai_default_commands.write_anything.prompt_placeholder);
|
|
2666
3013
|
},
|
|
@@ -2668,24 +3015,26 @@ function Ao(e) {
|
|
|
2668
3015
|
}
|
|
2669
3016
|
];
|
|
2670
3017
|
}
|
|
2671
|
-
function
|
|
2672
|
-
const t =
|
|
3018
|
+
function Zo(e) {
|
|
3019
|
+
const t = L(e), o = I(e);
|
|
2673
3020
|
return [
|
|
2674
3021
|
{
|
|
2675
3022
|
key: "improve_writing",
|
|
2676
3023
|
title: t.ai_default_commands.improve_writing.title,
|
|
2677
3024
|
aliases: t.ai_default_commands.improve_writing.aliases,
|
|
2678
|
-
icon: /* @__PURE__ */ y(
|
|
3025
|
+
icon: /* @__PURE__ */ y(qo, { size: 18 }),
|
|
2679
3026
|
onItemClick: async () => {
|
|
2680
|
-
await o.
|
|
3027
|
+
await o.invokeAI({
|
|
2681
3028
|
useSelection: !0,
|
|
2682
3029
|
userPrompt: "Improve writing",
|
|
2683
3030
|
// By default, LLM will be able to add / update / delete blocks. For "summarize", we only want to allow adding new blocks.
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
3031
|
+
streamToolsProvider: O.html.getStreamToolsProvider({
|
|
3032
|
+
defaultStreamTools: {
|
|
3033
|
+
add: !1,
|
|
3034
|
+
delete: !1,
|
|
3035
|
+
update: !0
|
|
3036
|
+
}
|
|
3037
|
+
})
|
|
2689
3038
|
});
|
|
2690
3039
|
},
|
|
2691
3040
|
size: "small"
|
|
@@ -2694,17 +3043,19 @@ function jo(e) {
|
|
|
2694
3043
|
key: "fix_spelling",
|
|
2695
3044
|
title: t.ai_default_commands.fix_spelling.title,
|
|
2696
3045
|
aliases: t.ai_default_commands.fix_spelling.aliases,
|
|
2697
|
-
icon: /* @__PURE__ */ y(
|
|
3046
|
+
icon: /* @__PURE__ */ y(Uo, { size: 18 }),
|
|
2698
3047
|
onItemClick: async () => {
|
|
2699
|
-
await o.
|
|
3048
|
+
await o.invokeAI({
|
|
2700
3049
|
useSelection: !0,
|
|
2701
3050
|
userPrompt: "Fix spelling",
|
|
2702
3051
|
// By default, LLM will be able to add / update / delete blocks. For "summarize", we only want to allow adding new blocks.
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
3052
|
+
streamToolsProvider: O.html.getStreamToolsProvider({
|
|
3053
|
+
defaultStreamTools: {
|
|
3054
|
+
add: !1,
|
|
3055
|
+
delete: !1,
|
|
3056
|
+
update: !0
|
|
3057
|
+
}
|
|
3058
|
+
})
|
|
2708
3059
|
});
|
|
2709
3060
|
},
|
|
2710
3061
|
size: "small"
|
|
@@ -2713,7 +3064,7 @@ function jo(e) {
|
|
|
2713
3064
|
key: "translate",
|
|
2714
3065
|
title: t.ai_default_commands.translate.title,
|
|
2715
3066
|
aliases: t.ai_default_commands.translate.aliases,
|
|
2716
|
-
icon: /* @__PURE__ */ y(
|
|
3067
|
+
icon: /* @__PURE__ */ y(zo, { size: 18 }),
|
|
2717
3068
|
onItemClick: (r) => {
|
|
2718
3069
|
r(t.ai_default_commands.translate.prompt_placeholder);
|
|
2719
3070
|
},
|
|
@@ -2723,31 +3074,33 @@ function jo(e) {
|
|
|
2723
3074
|
key: "simplify",
|
|
2724
3075
|
title: t.ai_default_commands.simplify.title,
|
|
2725
3076
|
aliases: t.ai_default_commands.simplify.aliases,
|
|
2726
|
-
icon: /* @__PURE__ */ y(
|
|
3077
|
+
icon: /* @__PURE__ */ y(jo, { size: 18 }),
|
|
2727
3078
|
onItemClick: async () => {
|
|
2728
|
-
await o.
|
|
3079
|
+
await o.invokeAI({
|
|
2729
3080
|
useSelection: !0,
|
|
2730
3081
|
userPrompt: "Simplify",
|
|
2731
3082
|
// By default, LLM will be able to add / update / delete blocks. For "summarize", we only want to allow adding new blocks.
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
3083
|
+
streamToolsProvider: O.html.getStreamToolsProvider({
|
|
3084
|
+
defaultStreamTools: {
|
|
3085
|
+
add: !1,
|
|
3086
|
+
delete: !1,
|
|
3087
|
+
update: !0
|
|
3088
|
+
}
|
|
3089
|
+
})
|
|
2737
3090
|
});
|
|
2738
3091
|
},
|
|
2739
3092
|
size: "small"
|
|
2740
3093
|
}
|
|
2741
3094
|
];
|
|
2742
3095
|
}
|
|
2743
|
-
function
|
|
2744
|
-
const t =
|
|
3096
|
+
function Wo(e) {
|
|
3097
|
+
const t = L(e), o = I(e);
|
|
2745
3098
|
return [
|
|
2746
3099
|
{
|
|
2747
3100
|
key: "accept",
|
|
2748
3101
|
title: t.ai_menu.actions.accept.title,
|
|
2749
3102
|
aliases: t.ai_menu.actions.accept.aliases,
|
|
2750
|
-
icon: /* @__PURE__ */ y(
|
|
3103
|
+
icon: /* @__PURE__ */ y(Jo, { size: 18 }),
|
|
2751
3104
|
onItemClick: () => {
|
|
2752
3105
|
o.acceptChanges();
|
|
2753
3106
|
},
|
|
@@ -2757,7 +3110,7 @@ function Do(e) {
|
|
|
2757
3110
|
key: "revert",
|
|
2758
3111
|
title: t.ai_menu.actions.revert.title,
|
|
2759
3112
|
aliases: t.ai_menu.actions.revert.aliases,
|
|
2760
|
-
icon: /* @__PURE__ */ y(
|
|
3113
|
+
icon: /* @__PURE__ */ y(et, { size: 18 }),
|
|
2761
3114
|
onItemClick: () => {
|
|
2762
3115
|
o.rejectChanges();
|
|
2763
3116
|
},
|
|
@@ -2765,14 +3118,14 @@ function Do(e) {
|
|
|
2765
3118
|
}
|
|
2766
3119
|
];
|
|
2767
3120
|
}
|
|
2768
|
-
function
|
|
2769
|
-
const t =
|
|
3121
|
+
function Yo(e) {
|
|
3122
|
+
const t = L(e), o = I(e);
|
|
2770
3123
|
return [
|
|
2771
3124
|
{
|
|
2772
3125
|
key: "retry",
|
|
2773
3126
|
title: t.ai_menu.actions.retry.title,
|
|
2774
3127
|
aliases: t.ai_menu.actions.retry.aliases,
|
|
2775
|
-
icon: /* @__PURE__ */ y(
|
|
3128
|
+
icon: /* @__PURE__ */ y(Vo, { size: 18 }),
|
|
2776
3129
|
onItemClick: async () => {
|
|
2777
3130
|
await o.retry();
|
|
2778
3131
|
},
|
|
@@ -2782,7 +3135,7 @@ function $o(e) {
|
|
|
2782
3135
|
key: "cancel",
|
|
2783
3136
|
title: t.ai_menu.actions.cancel.title,
|
|
2784
3137
|
aliases: t.ai_menu.actions.cancel.aliases,
|
|
2785
|
-
icon: /* @__PURE__ */ y(
|
|
3138
|
+
icon: /* @__PURE__ */ y(et, { size: 18 }),
|
|
2786
3139
|
onItemClick: () => {
|
|
2787
3140
|
o.rejectChanges();
|
|
2788
3141
|
},
|
|
@@ -2790,34 +3143,34 @@ function $o(e) {
|
|
|
2790
3143
|
}
|
|
2791
3144
|
];
|
|
2792
3145
|
}
|
|
2793
|
-
function
|
|
2794
|
-
return t === "user-input" ? e.getSelection() ?
|
|
3146
|
+
function Go(e, t) {
|
|
3147
|
+
return t === "user-input" ? e.getSelection() ? Zo(e) : Ro(e) : t === "user-reviewing" ? Wo(e) : t === "error" ? Yo(e) : [];
|
|
2795
3148
|
}
|
|
2796
|
-
const
|
|
2797
|
-
const t =
|
|
3149
|
+
const Ko = (e) => {
|
|
3150
|
+
const t = Q(), [o, r] = $e(""), n = tt(), s = X(), a = I(t), i = qe(
|
|
2798
3151
|
a.store,
|
|
2799
|
-
(
|
|
2800
|
-
), { items:
|
|
2801
|
-
let
|
|
2802
|
-
return
|
|
3152
|
+
(d) => d.aiMenuState !== "closed" ? d.aiMenuState.status : "closed"
|
|
3153
|
+
), { items: l } = e, c = A(() => {
|
|
3154
|
+
let d = [];
|
|
3155
|
+
return l ? d = l(t, i) : d = Go(t, i), d.map((h) => ({
|
|
2803
3156
|
...h,
|
|
2804
3157
|
onItemClick: () => {
|
|
2805
3158
|
h.onItemClick(r);
|
|
2806
3159
|
}
|
|
2807
3160
|
}));
|
|
2808
|
-
}, [
|
|
2809
|
-
async (
|
|
2810
|
-
await a.
|
|
2811
|
-
userPrompt:
|
|
3161
|
+
}, [l, i, t]), u = $(
|
|
3162
|
+
async (d) => {
|
|
3163
|
+
await a.invokeAI({
|
|
3164
|
+
userPrompt: d,
|
|
2812
3165
|
useSelection: t.getSelection() !== void 0
|
|
2813
3166
|
});
|
|
2814
3167
|
},
|
|
2815
3168
|
[a, t]
|
|
2816
3169
|
);
|
|
2817
|
-
|
|
3170
|
+
He(() => {
|
|
2818
3171
|
(i === "user-reviewing" || i === "error") && r("");
|
|
2819
3172
|
}, [i]);
|
|
2820
|
-
const
|
|
3173
|
+
const m = A(() => i === "thinking" ? n.ai_menu.status.thinking : i === "ai-writing" ? n.ai_menu.status.editing : i === "error" ? n.ai_menu.status.error : n.ai_menu.input_placeholder, [i, n]), p = A(() => {
|
|
2821
3174
|
if (i === "thinking" || i === "ai-writing")
|
|
2822
3175
|
return /* @__PURE__ */ y(
|
|
2823
3176
|
s.SuggestionMenu.Loader,
|
|
@@ -2839,23 +3192,23 @@ const Ho = (e) => {
|
|
|
2839
3192
|
) });
|
|
2840
3193
|
}, [s, i]);
|
|
2841
3194
|
return /* @__PURE__ */ y(
|
|
2842
|
-
|
|
3195
|
+
Fo,
|
|
2843
3196
|
{
|
|
2844
|
-
onManualPromptSubmit: e.onManualPromptSubmit ||
|
|
2845
|
-
items:
|
|
3197
|
+
onManualPromptSubmit: e.onManualPromptSubmit || u,
|
|
3198
|
+
items: c,
|
|
2846
3199
|
promptText: o,
|
|
2847
3200
|
onPromptTextChange: r,
|
|
2848
|
-
placeholder:
|
|
3201
|
+
placeholder: m,
|
|
2849
3202
|
disabled: i === "thinking" || i === "ai-writing",
|
|
2850
|
-
icon: /* @__PURE__ */ y("div", { className: "bn-combobox-icon", children: /* @__PURE__ */ y(
|
|
2851
|
-
rightSection:
|
|
3203
|
+
icon: /* @__PURE__ */ y("div", { className: "bn-combobox-icon", children: /* @__PURE__ */ y(ie, {}) }),
|
|
3204
|
+
rightSection: p
|
|
2852
3205
|
}
|
|
2853
3206
|
);
|
|
2854
|
-
},
|
|
2855
|
-
const t = e.blockID ? document.querySelector(`[data-id="${e.blockID}"]`) : void 0, o =
|
|
3207
|
+
}, Xo = (e) => {
|
|
3208
|
+
const t = e.blockID ? document.querySelector(`[data-id="${e.blockID}"]`) : void 0, o = A(() => t ? {
|
|
2856
3209
|
getBoundingClientRect: () => t.getBoundingClientRect(),
|
|
2857
3210
|
contextElement: t
|
|
2858
|
-
} : null, [t]), { isMounted: r, ref: n, style: s, getFloatingProps: a, isPositioned: i } =
|
|
3211
|
+
} : null, [t]), { isMounted: r, ref: n, style: s, getFloatingProps: a, isPositioned: i } = Bt(!!t, o, 3e3, {
|
|
2859
3212
|
canDismiss: {
|
|
2860
3213
|
enabled: !0,
|
|
2861
3214
|
escapeKey: !0,
|
|
@@ -2865,16 +3218,16 @@ const Ho = (e) => {
|
|
|
2865
3218
|
middleware: [
|
|
2866
3219
|
Mt(10),
|
|
2867
3220
|
// flip(),
|
|
2868
|
-
|
|
2869
|
-
apply({ rects:
|
|
2870
|
-
Object.assign(
|
|
2871
|
-
width: `${
|
|
3221
|
+
Et({
|
|
3222
|
+
apply({ rects: l, elements: c }) {
|
|
3223
|
+
Object.assign(c.floating.style, {
|
|
3224
|
+
width: `${l.reference.width}px`
|
|
2872
3225
|
});
|
|
2873
3226
|
}
|
|
2874
3227
|
})
|
|
2875
3228
|
],
|
|
2876
3229
|
onOpenChange: e.onOpenChange,
|
|
2877
|
-
whileElementsMounted: (c, u
|
|
3230
|
+
whileElementsMounted: (l, c, u) => _t(l, c, u, {
|
|
2878
3231
|
animationFrame: !0
|
|
2879
3232
|
}),
|
|
2880
3233
|
...e.floatingOptions
|
|
@@ -2890,10 +3243,10 @@ const Ho = (e) => {
|
|
|
2890
3243
|
children: i && e.children
|
|
2891
3244
|
}
|
|
2892
3245
|
) : null;
|
|
2893
|
-
},
|
|
2894
|
-
const t =
|
|
3246
|
+
}, Cr = (e) => {
|
|
3247
|
+
const t = Q(), o = I(t), r = qe(o.store, (a) => a.aiMenuState), n = r === "closed" ? void 0 : r.blockId, s = e.aiMenu || Ko;
|
|
2895
3248
|
return /* @__PURE__ */ y(
|
|
2896
|
-
|
|
3249
|
+
Xo,
|
|
2897
3250
|
{
|
|
2898
3251
|
canDismissViaOutsidePress: r === "closed" || r.status === "user-input",
|
|
2899
3252
|
blockID: n,
|
|
@@ -2903,8 +3256,8 @@ const Ho = (e) => {
|
|
|
2903
3256
|
children: /* @__PURE__ */ y(s, {})
|
|
2904
3257
|
}
|
|
2905
3258
|
);
|
|
2906
|
-
},
|
|
2907
|
-
const e =
|
|
3259
|
+
}, Or = () => {
|
|
3260
|
+
const e = tt(), t = X(), o = Q(), r = I(o), n = () => {
|
|
2908
3261
|
o.formattingToolbar.closeMenu();
|
|
2909
3262
|
const s = o.getSelection();
|
|
2910
3263
|
if (!s)
|
|
@@ -2918,15 +3271,15 @@ const Ho = (e) => {
|
|
|
2918
3271
|
className: "bn-button",
|
|
2919
3272
|
label: e.formatting_toolbar.ai.tooltip,
|
|
2920
3273
|
mainTooltip: e.formatting_toolbar.ai.tooltip,
|
|
2921
|
-
icon: /* @__PURE__ */ y(
|
|
3274
|
+
icon: /* @__PURE__ */ y(ie, {}),
|
|
2922
3275
|
onClick: n
|
|
2923
3276
|
}
|
|
2924
3277
|
) : null;
|
|
2925
|
-
},
|
|
2926
|
-
AI:
|
|
3278
|
+
}, Qo = {
|
|
3279
|
+
AI: ie
|
|
2927
3280
|
};
|
|
2928
|
-
function
|
|
2929
|
-
const t =
|
|
3281
|
+
function Ir(e) {
|
|
3282
|
+
const t = I(e);
|
|
2930
3283
|
return [
|
|
2931
3284
|
{
|
|
2932
3285
|
key: "ai",
|
|
@@ -2935,26 +3288,214 @@ function dr(e) {
|
|
|
2935
3288
|
r.block.content && Array.isArray(r.block.content) && // isarray check not ideal
|
|
2936
3289
|
r.block.content.length === 0 && r.prevBlock ? t.openAIMenuAtBlock(r.prevBlock.id) : t.openAIMenuAtBlock(r.block.id);
|
|
2937
3290
|
},
|
|
2938
|
-
...
|
|
2939
|
-
icon: /* @__PURE__ */ y(
|
|
3291
|
+
...L(e).slash_menu.ai,
|
|
3292
|
+
icon: /* @__PURE__ */ y(Qo.AI, {})
|
|
2940
3293
|
}
|
|
2941
3294
|
];
|
|
2942
3295
|
}
|
|
3296
|
+
function er(e) {
|
|
3297
|
+
return Object.fromEntries(
|
|
3298
|
+
Object.entries(e).map(([t, o]) => [
|
|
3299
|
+
t,
|
|
3300
|
+
St({
|
|
3301
|
+
...o,
|
|
3302
|
+
inputSchema: pe(o.inputSchema),
|
|
3303
|
+
outputSchema: pe(o.outputSchema)
|
|
3304
|
+
})
|
|
3305
|
+
])
|
|
3306
|
+
);
|
|
3307
|
+
}
|
|
3308
|
+
function tr(e, t) {
|
|
3309
|
+
let o = "";
|
|
3310
|
+
return e.pipeThrough(
|
|
3311
|
+
new TransformStream({
|
|
3312
|
+
start(r) {
|
|
3313
|
+
r.enqueue({ type: "start" }), r.enqueue({ type: "start-step" }), r.enqueue({
|
|
3314
|
+
type: "tool-input-start",
|
|
3315
|
+
toolCallId: "call_object_1",
|
|
3316
|
+
toolName: t
|
|
3317
|
+
});
|
|
3318
|
+
},
|
|
3319
|
+
transform(r, n) {
|
|
3320
|
+
switch (r.type) {
|
|
3321
|
+
case "text-delta":
|
|
3322
|
+
o += r.textDelta, n.enqueue({
|
|
3323
|
+
type: "tool-input-delta",
|
|
3324
|
+
toolCallId: "call_object_1",
|
|
3325
|
+
inputTextDelta: r.textDelta
|
|
3326
|
+
});
|
|
3327
|
+
break;
|
|
3328
|
+
case "object":
|
|
3329
|
+
case "finish":
|
|
3330
|
+
break;
|
|
3331
|
+
case "error":
|
|
3332
|
+
n.enqueue({
|
|
3333
|
+
type: "error",
|
|
3334
|
+
errorText: K(r.error)
|
|
3335
|
+
});
|
|
3336
|
+
break;
|
|
3337
|
+
default: {
|
|
3338
|
+
const s = r;
|
|
3339
|
+
throw new Error(`Unsupported chunk type: ${s}`);
|
|
3340
|
+
}
|
|
3341
|
+
}
|
|
3342
|
+
},
|
|
3343
|
+
async flush(r) {
|
|
3344
|
+
r.enqueue({
|
|
3345
|
+
type: "tool-input-available",
|
|
3346
|
+
toolCallId: "call_object_1",
|
|
3347
|
+
toolName: t,
|
|
3348
|
+
input: JSON.parse(o)
|
|
3349
|
+
}), r.enqueue({ type: "finish-step" }), r.enqueue({ type: "finish" });
|
|
3350
|
+
}
|
|
3351
|
+
})
|
|
3352
|
+
);
|
|
3353
|
+
}
|
|
3354
|
+
function or(e, t) {
|
|
3355
|
+
return new ReadableStream({
|
|
3356
|
+
start(r) {
|
|
3357
|
+
r.enqueue({ type: "start" }), r.enqueue({ type: "start-step" }), r.enqueue({
|
|
3358
|
+
type: "tool-input-start",
|
|
3359
|
+
toolCallId: "call_object_1",
|
|
3360
|
+
toolName: t
|
|
3361
|
+
}), r.enqueue({
|
|
3362
|
+
type: "tool-input-delta",
|
|
3363
|
+
toolCallId: "call_object_1",
|
|
3364
|
+
inputTextDelta: JSON.stringify(e)
|
|
3365
|
+
}), r.enqueue({
|
|
3366
|
+
type: "tool-input-available",
|
|
3367
|
+
toolCallId: "call_object_1",
|
|
3368
|
+
toolName: t,
|
|
3369
|
+
input: e
|
|
3370
|
+
}), r.enqueue({ type: "finish-step" }), r.enqueue({ type: "finish" }), r.close();
|
|
3371
|
+
}
|
|
3372
|
+
});
|
|
3373
|
+
}
|
|
3374
|
+
const rr = {
|
|
3375
|
+
"mistral.chat": {
|
|
3376
|
+
mode: "auto"
|
|
3377
|
+
},
|
|
3378
|
+
"google.generative-ai": {
|
|
3379
|
+
mode: "auto"
|
|
3380
|
+
},
|
|
3381
|
+
"groq.chat": {
|
|
3382
|
+
providerOptions: {
|
|
3383
|
+
groq: {
|
|
3384
|
+
structuredOutputs: !1
|
|
3385
|
+
}
|
|
3386
|
+
}
|
|
3387
|
+
}
|
|
3388
|
+
};
|
|
3389
|
+
function Ie(e) {
|
|
3390
|
+
return rr[e.provider] || {};
|
|
3391
|
+
}
|
|
3392
|
+
class Br {
|
|
3393
|
+
constructor(t) {
|
|
3394
|
+
this.opts = t;
|
|
3395
|
+
}
|
|
3396
|
+
/**
|
|
3397
|
+
* Calls an LLM with StreamTools, using the `generateObject` of the AI SDK.
|
|
3398
|
+
*
|
|
3399
|
+
* This is the non-streaming version.
|
|
3400
|
+
*/
|
|
3401
|
+
async generateObject(t, o) {
|
|
3402
|
+
const { model: r, _additionalOptions: n } = this.opts;
|
|
3403
|
+
if (typeof r == "string")
|
|
3404
|
+
throw new Error("model must be a LanguageModelV2");
|
|
3405
|
+
const s = Object.keys(o)[0], a = o[s].inputSchema, i = await wt({
|
|
3406
|
+
output: "object",
|
|
3407
|
+
schema: a,
|
|
3408
|
+
model: r,
|
|
3409
|
+
mode: "tool",
|
|
3410
|
+
messages: Y(t),
|
|
3411
|
+
...Ie(r),
|
|
3412
|
+
...n ?? {}
|
|
3413
|
+
});
|
|
3414
|
+
return or(i.object, s);
|
|
3415
|
+
}
|
|
3416
|
+
/**
|
|
3417
|
+
* Calls an LLM with StreamTools, using the `streamObject` of the AI SDK.
|
|
3418
|
+
*
|
|
3419
|
+
* This is the streaming version.
|
|
3420
|
+
*/
|
|
3421
|
+
async streamObject(t, o) {
|
|
3422
|
+
const { model: r, _additionalOptions: n } = this.opts;
|
|
3423
|
+
if (typeof r == "string")
|
|
3424
|
+
throw new Error("model must be a LanguageModelV2");
|
|
3425
|
+
const s = Object.keys(o)[0], a = o[s].inputSchema, i = Tt({
|
|
3426
|
+
output: "object",
|
|
3427
|
+
schema: a,
|
|
3428
|
+
model: r,
|
|
3429
|
+
mode: "tool",
|
|
3430
|
+
messages: Y(t),
|
|
3431
|
+
...Ie(r),
|
|
3432
|
+
...n ?? {}
|
|
3433
|
+
});
|
|
3434
|
+
return tr(
|
|
3435
|
+
i.fullStream,
|
|
3436
|
+
s
|
|
3437
|
+
);
|
|
3438
|
+
}
|
|
3439
|
+
/**
|
|
3440
|
+
* Calls an LLM with StreamTools, using the `streamText` of the AI SDK.
|
|
3441
|
+
*
|
|
3442
|
+
* This is the streaming version.
|
|
3443
|
+
*/
|
|
3444
|
+
async streamText(t, o) {
|
|
3445
|
+
const { model: r, _additionalOptions: n } = this.opts;
|
|
3446
|
+
return xt({
|
|
3447
|
+
model: r,
|
|
3448
|
+
messages: Y(t),
|
|
3449
|
+
tools: o,
|
|
3450
|
+
toolChoice: "required",
|
|
3451
|
+
// extra options for streamObject
|
|
3452
|
+
...n ?? {}
|
|
3453
|
+
// activeTools: ["applyDocumentOperations"],
|
|
3454
|
+
}).toUIMessageStream();
|
|
3455
|
+
}
|
|
3456
|
+
async sendMessages({
|
|
3457
|
+
messages: t,
|
|
3458
|
+
body: o
|
|
3459
|
+
// metadata,
|
|
3460
|
+
}) {
|
|
3461
|
+
const r = this.opts.stream ?? !0, n = o.toolDefinitions, s = er(n);
|
|
3462
|
+
if (this.opts.objectGeneration)
|
|
3463
|
+
return r ? this.streamObject(t, s) : this.generateObject(t, s);
|
|
3464
|
+
if (r)
|
|
3465
|
+
return await this.streamText(t, s);
|
|
3466
|
+
throw new Error("Not implemented (generateText)");
|
|
3467
|
+
}
|
|
3468
|
+
reconnectToStream() {
|
|
3469
|
+
throw new Error("Not implemented");
|
|
3470
|
+
}
|
|
3471
|
+
}
|
|
2943
3472
|
export {
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
O as
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
3473
|
+
Ke as AIExtension,
|
|
3474
|
+
Ko as AIMenu,
|
|
3475
|
+
Cr as AIMenuController,
|
|
3476
|
+
Or as AIToolbarButton,
|
|
3477
|
+
Xo as BlockPositioner,
|
|
3478
|
+
ze as ChunkExecutionError,
|
|
3479
|
+
Br as ClientSideTransport,
|
|
3480
|
+
rr as PROVIDER_OVERRIDES,
|
|
3481
|
+
Fo as PromptSuggestionMenu,
|
|
3482
|
+
Dt as StreamToolExecutor,
|
|
3483
|
+
O as aiDocumentFormats,
|
|
3484
|
+
Kt as buildAIRequest,
|
|
3485
|
+
vr as createAIExtension,
|
|
3486
|
+
Lt as createStreamToolsArraySchema,
|
|
3487
|
+
At as defaultAIRequestSender,
|
|
3488
|
+
Xt as executeAIRequest,
|
|
3489
|
+
Pr as fetchViaProxy,
|
|
3490
|
+
L as getAIDictionary,
|
|
3491
|
+
I as getAIExtension,
|
|
3492
|
+
Ir as getAISlashMenuItems,
|
|
3493
|
+
Go as getDefaultAIMenuItems,
|
|
3494
|
+
Ie as getProviderOverrides,
|
|
3495
|
+
or as objectAsToolCallInUIMessageStream,
|
|
3496
|
+
Vt as objectStreamToOperationsResult,
|
|
3497
|
+
tr as partialObjectStreamAsToolCallInUIMessageStream,
|
|
3498
|
+
xr as promptHelpers,
|
|
3499
|
+
er as toolDefinitionsToToolSet
|
|
2959
3500
|
};
|
|
2960
3501
|
//# sourceMappingURL=blocknote-xl-ai.js.map
|