@dxos/plugin-assistant 0.8.4-main.406dc2a → 0.8.4-main.548089c
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/lib/browser/BlueprintArticle-UGPRZRBG.mjs +36 -0
- package/dist/lib/browser/BlueprintArticle-UGPRZRBG.mjs.map +7 -0
- package/dist/lib/browser/{ChatCompanion-BDZ55ZRF.mjs → ChatCompanion-BZGANK56.mjs} +58 -50
- package/dist/lib/browser/ChatCompanion-BZGANK56.mjs.map +7 -0
- package/dist/lib/browser/{ChatContainer-RYGNN73X.mjs → ChatContainer-OG6Y3NHI.mjs} +22 -18
- package/dist/lib/browser/ChatContainer-OG6Y3NHI.mjs.map +7 -0
- package/dist/lib/browser/{ChatDialog-MVHH2U66.mjs → ChatDialog-NKNUCC3R.mjs} +8 -4
- package/dist/lib/browser/ChatDialog-NKNUCC3R.mjs.map +7 -0
- package/dist/lib/browser/PromptArticle-QNJAXD5Y.mjs +89 -0
- package/dist/lib/browser/PromptArticle-QNJAXD5Y.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-2U7SLCRX.mjs → app-graph-builder-CJ5ZUG5I.mjs} +62 -17
- package/dist/lib/browser/app-graph-builder-CJ5ZUG5I.mjs.map +7 -0
- package/dist/lib/browser/{blueprint-definition-NSJARW5U.mjs → blueprint-definition-5FT5JGPY.mjs} +4 -4
- package/dist/lib/browser/chunk-AO6XHMQ7.mjs +262 -0
- package/dist/lib/browser/chunk-AO6XHMQ7.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FP56WB24.mjs → chunk-BNTPFZ7O.mjs} +30 -13
- package/dist/lib/browser/chunk-BNTPFZ7O.mjs.map +7 -0
- package/dist/lib/browser/chunk-FJQ4ZRYJ.mjs +335 -0
- package/dist/lib/browser/chunk-FJQ4ZRYJ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-2CE2KPKZ.mjs → chunk-IXIIS4QA.mjs} +37 -36
- package/dist/lib/browser/chunk-IXIIS4QA.mjs.map +7 -0
- package/dist/lib/browser/{chunk-5EGXHCAZ.mjs → chunk-LRE4VEZV.mjs} +2 -2
- package/dist/lib/browser/chunk-LRE4VEZV.mjs.map +7 -0
- package/dist/lib/browser/chunk-WBG5PTSX.mjs +23 -0
- package/dist/lib/browser/chunk-WBG5PTSX.mjs.map +7 -0
- package/dist/lib/browser/{chunk-WRJGOT5P.mjs → chunk-Y4C2CMME.mjs} +772 -620
- package/dist/lib/browser/chunk-Y4C2CMME.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +78 -62
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-3GOJMBXJ.mjs → intent-resolver-42A4SLIQ.mjs} +49 -20
- package/dist/lib/browser/intent-resolver-42A4SLIQ.mjs.map +7 -0
- package/dist/lib/browser/{local-model-resolver-GO6ZEMLL.mjs → local-model-resolver-34MVHRKD.mjs} +2 -2
- package/dist/lib/browser/{local-model-resolver-GO6ZEMLL.mjs.map → local-model-resolver-34MVHRKD.mjs.map} +2 -2
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-FTKCE6GG.mjs → react-surface-TULJF2Y3.mjs} +22 -31
- package/dist/lib/browser/react-surface-TULJF2Y3.mjs.map +7 -0
- package/dist/lib/browser/{settings-HBF32KV6.mjs → settings-NYJGNQ5I.mjs} +3 -3
- package/dist/lib/browser/{state-LXTS54DI.mjs → state-GG7Z3NB7.mjs} +7 -3
- package/dist/lib/browser/{state-LXTS54DI.mjs.map → state-GG7Z3NB7.mjs.map} +3 -3
- package/dist/lib/browser/toolkit-VYDAWNE4.mjs +17 -0
- package/dist/lib/browser/toolkit-VYDAWNE4.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +2 -2
- package/dist/lib/node-esm/BlueprintArticle-RPZ2363K.mjs +37 -0
- package/dist/lib/node-esm/BlueprintArticle-RPZ2363K.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatCompanion-XFNXVZIP.mjs → ChatCompanion-LKWZTSCI.mjs} +58 -50
- package/dist/lib/node-esm/ChatCompanion-LKWZTSCI.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatContainer-UTJGCQXF.mjs → ChatContainer-HGAAKVB3.mjs} +22 -18
- package/dist/lib/node-esm/ChatContainer-HGAAKVB3.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatDialog-QEYZ4IOV.mjs → ChatDialog-QA545GGB.mjs} +8 -4
- package/dist/lib/node-esm/ChatDialog-QA545GGB.mjs.map +7 -0
- package/dist/lib/node-esm/PromptArticle-JW46XL4M.mjs +90 -0
- package/dist/lib/node-esm/PromptArticle-JW46XL4M.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-OKNLR7H2.mjs → app-graph-builder-XPQLG755.mjs} +62 -17
- package/dist/lib/node-esm/app-graph-builder-XPQLG755.mjs.map +7 -0
- package/dist/lib/node-esm/{blueprint-definition-WD2IVMAI.mjs → blueprint-definition-XW6QQVLV.mjs} +4 -4
- package/dist/lib/node-esm/chunk-3YVWS6OI.mjs +264 -0
- package/dist/lib/node-esm/chunk-3YVWS6OI.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-TNR46C3L.mjs → chunk-AB74FOA2.mjs} +30 -13
- package/dist/lib/node-esm/chunk-AB74FOA2.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-KJGD4EBJ.mjs +336 -0
- package/dist/lib/node-esm/chunk-KJGD4EBJ.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-U2NYUS2N.mjs → chunk-UXTUHH24.mjs} +37 -36
- package/dist/lib/node-esm/chunk-UXTUHH24.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-UFKLCEAE.mjs → chunk-VI6S3Q5H.mjs} +772 -620
- package/dist/lib/node-esm/chunk-VI6S3Q5H.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-73ABYRYX.mjs → chunk-WE6KTH72.mjs} +7 -2
- package/dist/lib/node-esm/chunk-WE6KTH72.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-XQGWSZ4T.mjs → chunk-YWFWT57N.mjs} +2 -2
- package/dist/lib/node-esm/chunk-YWFWT57N.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +78 -62
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-6XLVTRDJ.mjs → intent-resolver-Y6I3IDSI.mjs} +49 -20
- package/dist/lib/node-esm/intent-resolver-Y6I3IDSI.mjs.map +7 -0
- package/dist/lib/node-esm/{local-model-resolver-WOQ2D2R2.mjs → local-model-resolver-TP2NTSAX.mjs} +2 -2
- package/dist/lib/node-esm/{local-model-resolver-WOQ2D2R2.mjs.map → local-model-resolver-TP2NTSAX.mjs.map} +2 -2
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-K7ZXQLAP.mjs → react-surface-C4WY3WRR.mjs} +22 -31
- package/dist/lib/node-esm/react-surface-C4WY3WRR.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-CWP6MTWP.mjs → settings-RRHYI5KO.mjs} +3 -3
- package/dist/lib/node-esm/{state-BO6GUFLB.mjs → state-FSUHFMDM.mjs} +7 -3
- package/dist/lib/node-esm/{state-BO6GUFLB.mjs.map → state-FSUHFMDM.mjs.map} +3 -3
- package/dist/lib/node-esm/toolkit-HFJZLVIR.mjs +18 -0
- package/dist/lib/node-esm/toolkit-HFJZLVIR.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +2 -2
- package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/capabilities.d.ts +2 -3
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/state.d.ts.map +1 -1
- package/dist/types/src/capabilities/toolkit.d.ts +1 -1
- package/dist/types/src/capabilities/toolkit.d.ts.map +1 -1
- package/dist/types/src/components/BlueprintArticle.d.ts +7 -0
- package/dist/types/src/components/BlueprintArticle.d.ts.map +1 -0
- package/dist/types/src/components/Chat/Chat.d.ts +18 -8
- package/dist/types/src/components/Chat/Chat.d.ts.map +1 -1
- package/dist/types/src/components/Chat/events.d.ts +4 -0
- package/dist/types/src/components/Chat/events.d.ts.map +1 -1
- package/dist/types/src/components/ChatCompanion.d.ts +2 -2
- package/dist/types/src/components/ChatCompanion.d.ts.map +1 -1
- package/dist/types/src/components/ChatContainer.d.ts +7 -4
- package/dist/types/src/components/ChatContainer.d.ts.map +1 -1
- package/dist/types/src/components/ChatDialog.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatActions.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.d.ts +6 -9
- package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +123 -70
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/reducers.d.ts +5 -5
- package/dist/types/src/components/ChatThread/reducers.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/sync.d.ts +12 -6
- package/dist/types/src/components/ChatThread/sync.d.ts.map +1 -1
- package/dist/types/src/components/PromptArticle.d.ts +7 -0
- package/dist/types/src/components/PromptArticle.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +2 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +111 -61
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +111 -61
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/extensions/handlebars-extension.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/extensions/index.d.ts +3 -0
- package/dist/types/src/components/TemplateEditor/extensions/index.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/extensions/xml-extension.d.ts +8 -0
- package/dist/types/src/components/TemplateEditor/extensions/xml-extension.d.ts.map +1 -0
- package/dist/types/src/components/ToolBlock/ToolBlock.d.ts +9 -7
- package/dist/types/src/components/ToolBlock/ToolBlock.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.d.ts +2 -2
- package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +111 -60
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +4 -9
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/functions/index.d.ts +2 -2
- package/dist/types/src/functions/index.d.ts.map +1 -1
- package/dist/types/src/functions/{list.d.ts → object-list.d.ts} +1 -1
- package/dist/types/src/functions/object-list.d.ts.map +1 -0
- package/dist/types/src/functions/{load.d.ts → object-load.d.ts} +1 -1
- package/dist/types/src/functions/object-load.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +1 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatProcessor.d.ts +3 -1
- package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatServices.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatToolbarActions.d.ts +8 -0
- package/dist/types/src/hooks/useChatToolbarActions.d.ts.map +1 -0
- package/dist/types/src/hooks/useContextBinder.d.ts +2 -2
- package/dist/types/src/hooks/useContextBinder.d.ts.map +1 -1
- package/dist/types/src/hooks/useReferencesProvider.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/processor/index.d.ts +1 -0
- package/dist/types/src/processor/index.d.ts.map +1 -1
- package/dist/types/src/processor/processor.d.ts +6 -6
- package/dist/types/src/processor/processor.d.ts.map +1 -1
- package/dist/types/src/processor/update-name.d.ts +10 -0
- package/dist/types/src/processor/update-name.d.ts.map +1 -0
- package/dist/types/src/queue-logger.d.ts.map +1 -1
- package/dist/types/src/testing/test-generator.d.ts +2 -2
- package/dist/types/src/testing/test-generator.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +239 -26
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Assistant.d.ts +0 -3
- package/dist/types/src/types/Assistant.d.ts.map +1 -1
- package/dist/types/src/types/AssistantAction.d.ts +29 -4
- package/dist/types/src/types/AssistantAction.d.ts.map +1 -1
- package/dist/types/src/types/service.d.ts +9 -6
- package/dist/types/src/types/service.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +78 -73
- package/src/AssistantPlugin.tsx +20 -2
- package/src/capabilities/app-graph-builder.ts +62 -15
- package/src/capabilities/blueprint-definition.ts +38 -36
- package/src/capabilities/capabilities.ts +2 -3
- package/src/capabilities/intent-resolver.ts +66 -15
- package/src/capabilities/local-model-resolver.ts +1 -1
- package/src/capabilities/react-surface.tsx +16 -20
- package/src/capabilities/state.ts +2 -0
- package/src/capabilities/toolkit.ts +9 -160
- package/src/components/BlueprintArticle.tsx +29 -0
- package/src/components/Chat/Chat.tsx +112 -58
- package/src/components/Chat/events.ts +6 -0
- package/src/components/ChatCompanion.tsx +62 -43
- package/src/components/ChatContainer.tsx +27 -17
- package/src/components/ChatDialog.tsx +9 -2
- package/src/components/ChatProgress/ChatProgress.tsx +1 -1
- package/src/components/ChatPrompt/ChatActions.tsx +2 -4
- package/src/components/ChatPrompt/ChatOptions.tsx +26 -23
- package/src/components/ChatPrompt/ChatReferences.tsx +2 -2
- package/src/components/ChatThread/ChatThread.stories.tsx +45 -26
- package/src/components/ChatThread/ChatThread.tsx +25 -35
- package/src/components/ChatThread/reducers.ts +6 -6
- package/src/components/ChatThread/registry.tsx +23 -33
- package/src/components/ChatThread/sync.test.ts +20 -12
- package/src/components/ChatThread/sync.ts +47 -12
- package/src/components/ChatThread/testing/thread.md +37 -0
- package/src/components/PromptArticle.tsx +85 -0
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +14 -4
- package/src/components/TemplateEditor/TemplateEditor.tsx +17 -8
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +2 -2
- package/src/components/TemplateEditor/TemplateForm.tsx +1 -1
- package/src/components/TemplateEditor/extensions/handlebars-extension.ts +269 -0
- package/src/components/TemplateEditor/extensions/index.ts +6 -0
- package/src/components/TemplateEditor/extensions/xml-extension.ts +64 -0
- package/src/components/ToolBlock/ToolBlock.tsx +33 -42
- package/src/components/Toolbox/Toolbox.stories.tsx +2 -2
- package/src/components/Toolbox/Toolbox.tsx +5 -5
- package/src/components/index.ts +2 -5
- package/src/functions/analysis.ts +1 -1
- package/src/functions/index.ts +2 -2
- package/src/functions/{list.ts → object-list.ts} +4 -4
- package/src/functions/{load.ts → object-load.ts} +3 -4
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useBlueprintRegistry.ts +2 -1
- package/src/hooks/useChatProcessor.ts +12 -12
- package/src/hooks/useChatServices.ts +7 -5
- package/src/hooks/useChatToolbarActions.ts +122 -0
- package/src/hooks/useContextBinder.ts +6 -6
- package/src/hooks/useReferencesProvider.ts +2 -1
- package/src/meta.ts +6 -1
- package/src/processor/index.ts +1 -0
- package/src/processor/presets.ts +1 -1
- package/src/processor/processor.test.ts +8 -18
- package/src/processor/processor.ts +14 -39
- package/src/processor/update-name.ts +56 -0
- package/src/queue-logger.ts +4 -8
- package/src/testing/test-generator.ts +10 -10
- package/src/translations.ts +24 -16
- package/src/types/Assistant.ts +4 -5
- package/src/types/AssistantAction.ts +21 -4
- package/src/types/service.ts +2 -2
- package/dist/lib/browser/BlueprintContainer-WX2SSDVI.mjs +0 -28
- package/dist/lib/browser/BlueprintContainer-WX2SSDVI.mjs.map +0 -7
- package/dist/lib/browser/ChatCompanion-BDZ55ZRF.mjs.map +0 -7
- package/dist/lib/browser/ChatContainer-RYGNN73X.mjs.map +0 -7
- package/dist/lib/browser/ChatDialog-MVHH2U66.mjs.map +0 -7
- package/dist/lib/browser/SequenceContainer-2FEWMQGW.mjs +0 -150
- package/dist/lib/browser/SequenceContainer-2FEWMQGW.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-2U7SLCRX.mjs.map +0 -7
- package/dist/lib/browser/chunk-2CE2KPKZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-43I2LR6O.mjs +0 -216
- package/dist/lib/browser/chunk-43I2LR6O.mjs.map +0 -7
- package/dist/lib/browser/chunk-5EGXHCAZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-5RICKAMN.mjs +0 -18
- package/dist/lib/browser/chunk-5RICKAMN.mjs.map +0 -7
- package/dist/lib/browser/chunk-CQ7UHYTT.mjs +0 -296
- package/dist/lib/browser/chunk-CQ7UHYTT.mjs.map +0 -7
- package/dist/lib/browser/chunk-FP56WB24.mjs.map +0 -7
- package/dist/lib/browser/chunk-JZRZVB2A.mjs +0 -170
- package/dist/lib/browser/chunk-JZRZVB2A.mjs.map +0 -7
- package/dist/lib/browser/chunk-WRJGOT5P.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-3GOJMBXJ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-FTKCE6GG.mjs.map +0 -7
- package/dist/lib/browser/toolkit-NQ2GXCF5.mjs +0 -199
- package/dist/lib/browser/toolkit-NQ2GXCF5.mjs.map +0 -7
- package/dist/lib/node-esm/BlueprintContainer-4MKN6ZRB.mjs +0 -29
- package/dist/lib/node-esm/BlueprintContainer-4MKN6ZRB.mjs.map +0 -7
- package/dist/lib/node-esm/ChatCompanion-XFNXVZIP.mjs.map +0 -7
- package/dist/lib/node-esm/ChatContainer-UTJGCQXF.mjs.map +0 -7
- package/dist/lib/node-esm/ChatDialog-QEYZ4IOV.mjs.map +0 -7
- package/dist/lib/node-esm/SequenceContainer-PGGJUQ46.mjs +0 -151
- package/dist/lib/node-esm/SequenceContainer-PGGJUQ46.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-OKNLR7H2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-73ABYRYX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-DSE2IILK.mjs +0 -217
- package/dist/lib/node-esm/chunk-DSE2IILK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-E2WXZND7.mjs +0 -297
- package/dist/lib/node-esm/chunk-E2WXZND7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HXIBCBH4.mjs +0 -171
- package/dist/lib/node-esm/chunk-HXIBCBH4.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-TNR46C3L.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-U2NYUS2N.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UFKLCEAE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-XQGWSZ4T.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-6XLVTRDJ.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-K7ZXQLAP.mjs.map +0 -7
- package/dist/lib/node-esm/toolkit-V57PRJNG.mjs +0 -200
- package/dist/lib/node-esm/toolkit-V57PRJNG.mjs.map +0 -7
- package/dist/types/src/components/BlueprintContainer.d.ts +0 -8
- package/dist/types/src/components/BlueprintContainer.d.ts.map +0 -1
- package/dist/types/src/components/PromptSettings.d.ts +0 -6
- package/dist/types/src/components/PromptSettings.d.ts.map +0 -1
- package/dist/types/src/components/SequenceContainer.d.ts +0 -8
- package/dist/types/src/components/SequenceContainer.d.ts.map +0 -1
- package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts +0 -13
- package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts.map +0 -1
- package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts +0 -269
- package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts.map +0 -1
- package/dist/types/src/components/SequenceEditor/index.d.ts +0 -2
- package/dist/types/src/components/SequenceEditor/index.d.ts.map +0 -1
- package/dist/types/src/components/TemplateEditor/handlebars-extension.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +0 -5
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/index.d.ts +0 -2
- package/dist/types/src/components/Toolbar/index.d.ts.map +0 -1
- package/dist/types/src/components/Toolbar/useChatToolbarActions.d.ts +0 -11
- package/dist/types/src/components/Toolbar/useChatToolbarActions.d.ts.map +0 -1
- package/dist/types/src/functions/list.d.ts.map +0 -1
- package/dist/types/src/functions/load.d.ts.map +0 -1
- package/src/components/BlueprintContainer.tsx +0 -24
- package/src/components/PromptSettings.tsx +0 -90
- package/src/components/SequenceContainer.tsx +0 -131
- package/src/components/SequenceEditor/SequenceEditor.stories.tsx +0 -35
- package/src/components/SequenceEditor/SequenceEditor.tsx +0 -50
- package/src/components/SequenceEditor/index.ts +0 -5
- package/src/components/TemplateEditor/handlebars-extension.ts +0 -165
- package/src/components/Toolbar/Toolbar.tsx +0 -21
- package/src/components/Toolbar/index.ts +0 -5
- package/src/components/Toolbar/useChatToolbarActions.ts +0 -126
- /package/dist/lib/browser/{blueprint-definition-NSJARW5U.mjs.map → blueprint-definition-5FT5JGPY.mjs.map} +0 -0
- /package/dist/lib/browser/{settings-HBF32KV6.mjs.map → settings-NYJGNQ5I.mjs.map} +0 -0
- /package/dist/lib/node-esm/{blueprint-definition-WD2IVMAI.mjs.map → blueprint-definition-XW6QQVLV.mjs.map} +0 -0
- /package/dist/lib/node-esm/{settings-CWP6MTWP.mjs.map → settings-RRHYI5KO.mjs.map} +0 -0
- /package/dist/types/src/components/TemplateEditor/{handlebars-extension.d.ts → extensions/handlebars-extension.d.ts} +0 -0
|
@@ -2,22 +2,14 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, {
|
|
6
|
-
type CSSProperties,
|
|
7
|
-
forwardRef,
|
|
8
|
-
useCallback,
|
|
9
|
-
useEffect,
|
|
10
|
-
useImperativeHandle,
|
|
11
|
-
useMemo,
|
|
12
|
-
useState,
|
|
13
|
-
} from 'react';
|
|
5
|
+
import React, { type CSSProperties, forwardRef, useCallback, useEffect, useMemo } from 'react';
|
|
14
6
|
|
|
15
7
|
import { PublicKey } from '@dxos/keys';
|
|
16
8
|
import { type Identity } from '@dxos/react-client/halo';
|
|
17
|
-
import { type ThemedClassName } from '@dxos/react-ui';
|
|
9
|
+
import { type ThemedClassName, useForwardedRef } from '@dxos/react-ui';
|
|
18
10
|
import { MarkdownStream, type MarkdownStreamController, type MarkdownStreamProps } from '@dxos/react-ui-components';
|
|
19
11
|
import { mx } from '@dxos/react-ui-theme';
|
|
20
|
-
import { type
|
|
12
|
+
import { type Message } from '@dxos/types';
|
|
21
13
|
import { keyToFallback } from '@dxos/util';
|
|
22
14
|
|
|
23
15
|
import { type ChatEvent } from '../Chat';
|
|
@@ -25,30 +17,28 @@ import { type ChatEvent } from '../Chat';
|
|
|
25
17
|
import { blockToMarkdown, componentRegistry } from './registry';
|
|
26
18
|
import { MessageSyncer } from './sync';
|
|
27
19
|
|
|
28
|
-
export type ChatThreadController = Pick<MarkdownStreamController, 'setContext' | 'scrollToBottom'>;
|
|
29
|
-
|
|
30
20
|
export type ChatThreadProps = ThemedClassName<
|
|
31
21
|
{
|
|
32
22
|
identity?: Identity;
|
|
33
|
-
messages?:
|
|
23
|
+
messages?: Message.Message[];
|
|
34
24
|
error?: Error;
|
|
35
|
-
overscroll?: number;
|
|
36
25
|
onEvent?: (event: ChatEvent) => void;
|
|
37
|
-
} & Pick<MarkdownStreamProps, 'cursor' | 'fadeIn' | '
|
|
26
|
+
} & Pick<MarkdownStreamProps, 'cursor' | 'fadeIn' | 'debug'>
|
|
38
27
|
>;
|
|
39
28
|
|
|
40
|
-
|
|
29
|
+
// TODO(burdon): Memo thread position.
|
|
30
|
+
export const ChatThread = forwardRef<MarkdownStreamController, ChatThreadProps>(
|
|
41
31
|
(
|
|
42
|
-
{ classNames, identity, messages = [], error, cursor = false, fadeIn = true,
|
|
32
|
+
{ classNames, identity, messages = [], error, cursor = false, fadeIn = true, debug = false, onEvent },
|
|
43
33
|
forwardedRef,
|
|
44
34
|
) => {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
}, [identity]);
|
|
35
|
+
const controllerRef = useForwardedRef(forwardedRef);
|
|
36
|
+
const controller = controllerRef.current;
|
|
48
37
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
38
|
+
const userHue = useMemo(
|
|
39
|
+
() => identity?.profile?.data?.hue || keyToFallback(identity?.identityKey ?? PublicKey.random()).hue,
|
|
40
|
+
[identity],
|
|
41
|
+
);
|
|
52
42
|
|
|
53
43
|
// Show error.
|
|
54
44
|
useEffect(() => {
|
|
@@ -58,19 +48,18 @@ export const ChatThread = forwardRef<ChatThreadController | null, ChatThreadProp
|
|
|
58
48
|
// Update document.
|
|
59
49
|
const syncer = useMemo(() => controller && new MessageSyncer(controller, blockToMarkdown), [controller]);
|
|
60
50
|
useEffect(() => {
|
|
61
|
-
syncer?.
|
|
51
|
+
const reset = syncer?.append(messages, true);
|
|
52
|
+
if (reset) {
|
|
53
|
+
controller?.scrollToBottom('instant');
|
|
54
|
+
}
|
|
62
55
|
}, [syncer, messages]);
|
|
63
56
|
|
|
64
|
-
// Event
|
|
57
|
+
// Event adapter.
|
|
65
58
|
const handleEvent = useCallback<NonNullable<MarkdownStreamProps['onEvent']>>(
|
|
66
|
-
(
|
|
67
|
-
switch (
|
|
59
|
+
({ type, value }) => {
|
|
60
|
+
switch (type) {
|
|
68
61
|
case 'submit': {
|
|
69
|
-
|
|
70
|
-
onEvent?.({
|
|
71
|
-
type: 'submit',
|
|
72
|
-
text: ev.value,
|
|
73
|
-
});
|
|
62
|
+
value && onEvent?.({ type, text: value });
|
|
74
63
|
break;
|
|
75
64
|
}
|
|
76
65
|
}
|
|
@@ -80,15 +69,16 @@ export const ChatThread = forwardRef<ChatThreadController | null, ChatThreadProp
|
|
|
80
69
|
|
|
81
70
|
return (
|
|
82
71
|
<div
|
|
72
|
+
role='none'
|
|
83
73
|
className={mx('flex bs-full is-full justify-center overflow-hidden', classNames)}
|
|
84
74
|
style={{ '--user-fill': `var(--dx-${userHue}Fill)` } as CSSProperties}
|
|
85
75
|
>
|
|
86
76
|
<MarkdownStream
|
|
87
|
-
ref={
|
|
77
|
+
ref={controllerRef}
|
|
88
78
|
registry={componentRegistry}
|
|
89
79
|
cursor={cursor}
|
|
90
80
|
fadeIn={fadeIn}
|
|
91
|
-
|
|
81
|
+
debug={debug}
|
|
92
82
|
onEvent={handleEvent}
|
|
93
83
|
/>
|
|
94
84
|
</div>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type ContentBlock, type
|
|
5
|
+
import { type ContentBlock, type Message } from '@dxos/types';
|
|
6
6
|
|
|
7
7
|
type Reducer<R, I> = (acc: R, value: I, idx: number) => R;
|
|
8
8
|
|
|
@@ -38,12 +38,12 @@ type Reducer<R, I> = (acc: R, value: I, idx: number) => R;
|
|
|
38
38
|
*/
|
|
39
39
|
export const reduceMessages: Reducer<
|
|
40
40
|
{
|
|
41
|
-
messages:
|
|
42
|
-
current?:
|
|
41
|
+
messages: Message.Message[];
|
|
42
|
+
current?: Message.Message;
|
|
43
43
|
toolBlock?: boolean;
|
|
44
|
-
assistantMessages?:
|
|
44
|
+
assistantMessages?: Message.Message[];
|
|
45
45
|
},
|
|
46
|
-
|
|
46
|
+
Message.Message
|
|
47
47
|
> = ({ messages, current, toolBlock, assistantMessages = [] }, message) => {
|
|
48
48
|
// Treat tool calls as assistant messages.
|
|
49
49
|
let assistant = message?.sender.role === 'assistant';
|
|
@@ -111,7 +111,7 @@ export const reduceMessages: Reducer<
|
|
|
111
111
|
/**
|
|
112
112
|
* Accumulate token counts from all summary blocks in pending messages.
|
|
113
113
|
*/
|
|
114
|
-
const reduceSummary = (messages:
|
|
114
|
+
const reduceSummary = (messages: Message.Message[]): ContentBlock.Summary => {
|
|
115
115
|
let start: number | undefined;
|
|
116
116
|
return messages.reduce<ContentBlock.Summary>(
|
|
117
117
|
(acc, msg) => {
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from '@dxos/react-ui-components';
|
|
16
16
|
import { type XmlWidgetProps, type XmlWidgetRegistry, getXmlTextChild } from '@dxos/react-ui-editor';
|
|
17
17
|
import { Json } from '@dxos/react-ui-syntax-highlighter';
|
|
18
|
-
import { ContentBlock, type
|
|
18
|
+
import { ContentBlock, type Message } from '@dxos/types';
|
|
19
19
|
|
|
20
20
|
import { ToolBlock } from '../ToolBlock';
|
|
21
21
|
|
|
@@ -42,22 +42,22 @@ export const componentRegistry: XmlWidgetRegistry = {
|
|
|
42
42
|
|
|
43
43
|
['prompt' as const]: {
|
|
44
44
|
block: true,
|
|
45
|
-
factory: (
|
|
46
|
-
const text = getXmlTextChild(
|
|
45
|
+
factory: ({ children }) => {
|
|
46
|
+
const text = getXmlTextChild(children);
|
|
47
47
|
return text ? new PromptWidget(text) : null;
|
|
48
48
|
},
|
|
49
49
|
},
|
|
50
50
|
['reference' as const]: {
|
|
51
51
|
block: false,
|
|
52
|
-
factory: (
|
|
53
|
-
const text = getXmlTextChild(
|
|
54
|
-
return text &&
|
|
52
|
+
factory: ({ children, ref }) => {
|
|
53
|
+
const text = getXmlTextChild(children);
|
|
54
|
+
return text && ref ? new ReferenceWidget(text, ref) : null;
|
|
55
55
|
},
|
|
56
56
|
},
|
|
57
57
|
['select' as const]: {
|
|
58
58
|
block: true,
|
|
59
|
-
factory: (
|
|
60
|
-
const options =
|
|
59
|
+
factory: ({ children }) => {
|
|
60
|
+
const options = children
|
|
61
61
|
?.map((option: any) => option._tag === 'option' && getXmlTextChild(option.children))
|
|
62
62
|
.filter(Boolean);
|
|
63
63
|
return options?.length ? new SelectWidget(options) : null;
|
|
@@ -65,15 +65,15 @@ export const componentRegistry: XmlWidgetRegistry = {
|
|
|
65
65
|
},
|
|
66
66
|
['suggestion' as const]: {
|
|
67
67
|
block: true,
|
|
68
|
-
factory: (
|
|
69
|
-
const text = getXmlTextChild(
|
|
68
|
+
factory: ({ children }) => {
|
|
69
|
+
const text = getXmlTextChild(children);
|
|
70
70
|
return text ? new SuggestionWidget(text) : null;
|
|
71
71
|
},
|
|
72
72
|
},
|
|
73
73
|
['summary' as const]: {
|
|
74
74
|
block: true,
|
|
75
|
-
factory: (
|
|
76
|
-
const text = getXmlTextChild(
|
|
75
|
+
factory: ({ children }) => {
|
|
76
|
+
const text = getXmlTextChild(children);
|
|
77
77
|
return text ? new SummaryWidget(text) : null;
|
|
78
78
|
},
|
|
79
79
|
},
|
|
@@ -110,10 +110,10 @@ export const componentRegistry: XmlWidgetRegistry = {
|
|
|
110
110
|
*/
|
|
111
111
|
export const blockToMarkdown: BlockRenderer = (
|
|
112
112
|
context: MessageThreadContext,
|
|
113
|
-
message:
|
|
113
|
+
message: Message.Message,
|
|
114
114
|
block: ContentBlock.Any,
|
|
115
115
|
) => {
|
|
116
|
-
let str =
|
|
116
|
+
let str = blockToMarkdownImpl(context, message, block);
|
|
117
117
|
if (str && !block.pending) {
|
|
118
118
|
return (str += '\n');
|
|
119
119
|
}
|
|
@@ -121,12 +121,12 @@ export const blockToMarkdown: BlockRenderer = (
|
|
|
121
121
|
return str;
|
|
122
122
|
};
|
|
123
123
|
|
|
124
|
-
const
|
|
124
|
+
const blockToMarkdownImpl = (context: MessageThreadContext, message: Message.Message, block: ContentBlock.Any) => {
|
|
125
125
|
log('blockToMarkdown', { block: JSON.stringify(block) });
|
|
126
126
|
switch (block._tag) {
|
|
127
127
|
case 'text': {
|
|
128
128
|
if (message.sender.role === 'user') {
|
|
129
|
-
return
|
|
129
|
+
return `<prompt>${block.text}</prompt>`;
|
|
130
130
|
} else {
|
|
131
131
|
const text = block.text.trim();
|
|
132
132
|
if (text.length > 0) {
|
|
@@ -135,7 +135,10 @@ const _blockToMarkdown = (context: MessageThreadContext, message: DataType.Messa
|
|
|
135
135
|
}
|
|
136
136
|
break;
|
|
137
137
|
}
|
|
138
|
-
|
|
138
|
+
case 'reference': {
|
|
139
|
+
const dxn = block.reference.dxn;
|
|
140
|
+
return `<reference ref="${dxn.toString()}">${context.getObjectLabel(dxn)}</reference>`;
|
|
141
|
+
}
|
|
139
142
|
case 'suggestion': {
|
|
140
143
|
if (block.pending) {
|
|
141
144
|
return;
|
|
@@ -146,38 +149,25 @@ const _blockToMarkdown = (context: MessageThreadContext, message: DataType.Messa
|
|
|
146
149
|
if (block.pending || block.options.length === 0) {
|
|
147
150
|
return;
|
|
148
151
|
}
|
|
149
|
-
|
|
150
152
|
return `<select>${block.options.map((option) => `<option>${option}</option>`).join('')}</select>`;
|
|
151
153
|
}
|
|
152
|
-
|
|
153
|
-
// TODO(burdon): Need label.
|
|
154
|
-
case 'reference': {
|
|
155
|
-
return `<reference ref="${block.reference.dxn.toString()}">Ref</reference>`;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// case 'toolkit': {
|
|
159
|
-
// return `<toolkit />`;
|
|
160
|
-
// }
|
|
161
|
-
|
|
162
154
|
case 'toolCall': {
|
|
163
|
-
context.updateWidget(block.toolCallId, {
|
|
155
|
+
context.updateWidget<{ blocks: ContentBlock.Any[] }>(block.toolCallId, {
|
|
164
156
|
blocks: [block],
|
|
165
157
|
});
|
|
166
158
|
return `<toolCall id="${block.toolCallId}" />`;
|
|
167
159
|
}
|
|
168
160
|
case 'toolResult': {
|
|
169
|
-
context.updateWidget(block.toolCallId, ({ blocks = [] }
|
|
161
|
+
context.updateWidget<{ blocks: ContentBlock.Any[] }>(block.toolCallId, ({ blocks = [] }) => ({
|
|
170
162
|
blocks: [...blocks, block],
|
|
171
163
|
}));
|
|
172
164
|
break;
|
|
173
165
|
}
|
|
174
|
-
|
|
175
166
|
case 'summary': {
|
|
176
167
|
return `<summary>${ContentBlock.createSummaryMessage(block)}</summary>`;
|
|
177
168
|
}
|
|
178
|
-
|
|
179
|
-
// TODO(burdon): Need stable ID.
|
|
180
169
|
default: {
|
|
170
|
+
// TODO(burdon): Needs stable ID.
|
|
181
171
|
return `<json id="${message.id}">\n${JSON.stringify(block)}\n</json>`;
|
|
182
172
|
}
|
|
183
173
|
}
|
|
@@ -6,7 +6,7 @@ import { EditorView } from '@codemirror/view';
|
|
|
6
6
|
import { describe, it } from '@effect/vitest';
|
|
7
7
|
import * as Effect from 'effect/Effect';
|
|
8
8
|
|
|
9
|
-
import { type ContentBlock } from '@dxos/
|
|
9
|
+
import { type ContentBlock } from '@dxos/types';
|
|
10
10
|
|
|
11
11
|
import { createMessage } from '../../testing';
|
|
12
12
|
|
|
@@ -16,16 +16,24 @@ import { MessageSyncer, type TextModel } from './sync';
|
|
|
16
16
|
class TestDocument implements TextModel {
|
|
17
17
|
private readonly _view = new EditorView({ extensions: [] });
|
|
18
18
|
|
|
19
|
+
get view() {
|
|
20
|
+
return this._view;
|
|
21
|
+
}
|
|
22
|
+
|
|
19
23
|
get content() {
|
|
20
24
|
return this._view.state.doc.toString();
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
async reset(text: string) {
|
|
24
|
-
this._view.dispatch({
|
|
28
|
+
this._view.dispatch({
|
|
29
|
+
changes: { from: 0, to: this._view.state.doc.length, insert: text },
|
|
30
|
+
});
|
|
25
31
|
}
|
|
26
32
|
|
|
27
33
|
async append(text: string) {
|
|
28
|
-
this._view.dispatch({
|
|
34
|
+
this._view.dispatch({
|
|
35
|
+
changes: { from: this._view.state.doc.length, insert: text },
|
|
36
|
+
});
|
|
29
37
|
}
|
|
30
38
|
|
|
31
39
|
updateWidget(_id: string, _value: any) {}
|
|
@@ -43,12 +51,12 @@ describe('reducers', () => {
|
|
|
43
51
|
createMessage('assistant', [{ _tag: 'text', text: 'Hi there!' }]),
|
|
44
52
|
];
|
|
45
53
|
|
|
46
|
-
syncer.
|
|
47
|
-
expect(doc.content).toEqual(['
|
|
54
|
+
syncer.append(messages);
|
|
55
|
+
expect(doc.content).toEqual(['<prompt>Hello</prompt>', 'Hi there!', ''].join('\n'));
|
|
48
56
|
|
|
49
57
|
messages[1].blocks.push({ _tag: 'text', text: 'How can I help?' });
|
|
50
|
-
syncer.
|
|
51
|
-
expect(doc.content).toEqual(['
|
|
58
|
+
syncer.append(messages);
|
|
59
|
+
expect(doc.content).toEqual(['<prompt>Hello</prompt>', 'Hi there!', 'How can I help?', ''].join('\n'));
|
|
52
60
|
}),
|
|
53
61
|
);
|
|
54
62
|
|
|
@@ -63,18 +71,18 @@ describe('reducers', () => {
|
|
|
63
71
|
createMessage('assistant', [{ _tag: 'text', text: 'Hi there!', pending: true }]),
|
|
64
72
|
];
|
|
65
73
|
|
|
66
|
-
syncer.
|
|
67
|
-
expect(doc.content).toEqual(['
|
|
74
|
+
syncer.append(messages);
|
|
75
|
+
expect(doc.content).toEqual(['<prompt>Hello</prompt>', 'Hi there!'].join('\n'));
|
|
68
76
|
|
|
69
77
|
const block = messages[1].blocks[0] as ContentBlock.Text;
|
|
70
78
|
block.text = 'Hi there! How are you?';
|
|
71
79
|
block.pending = false;
|
|
72
|
-
syncer.
|
|
80
|
+
syncer.append(messages);
|
|
73
81
|
|
|
74
82
|
messages[1].blocks.push({ _tag: 'text', text: 'How can I help?' });
|
|
75
|
-
syncer.
|
|
83
|
+
syncer.append(messages);
|
|
76
84
|
expect(doc.content).toEqual(
|
|
77
|
-
['
|
|
85
|
+
['<prompt>Hello</prompt>', 'Hi there! How are you?', 'How can I help?', ''].join('\n'),
|
|
78
86
|
);
|
|
79
87
|
}),
|
|
80
88
|
);
|
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { type DXN } from '@dxos/echo';
|
|
5
6
|
import { log } from '@dxos/log';
|
|
6
7
|
import { type MarkdownStreamController } from '@dxos/react-ui-components';
|
|
7
|
-
import { type XmlWidgetStateManager } from '@dxos/react-ui-editor';
|
|
8
|
-
import { type ContentBlock, type
|
|
8
|
+
import { type StateDispatch, type XmlWidgetStateManager } from '@dxos/react-ui-editor';
|
|
9
|
+
import { type ContentBlock, type Message } from '@dxos/types';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Update document.
|
|
12
13
|
*/
|
|
13
|
-
export type TextModel = Pick<MarkdownStreamController, 'reset' | 'append' | 'updateWidget'>;
|
|
14
|
+
export type TextModel = Pick<MarkdownStreamController, 'view' | 'reset' | 'append' | 'updateWidget'>;
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Thread context passed to renderer.
|
|
@@ -18,9 +19,14 @@ export type TextModel = Pick<MarkdownStreamController, 'reset' | 'append' | 'upd
|
|
|
18
19
|
export class MessageThreadContext implements Pick<MarkdownStreamController, 'updateWidget'> {
|
|
19
20
|
constructor(private readonly _widgetState?: XmlWidgetStateManager) {}
|
|
20
21
|
|
|
21
|
-
updateWidget<T>(id: string, value: T) {
|
|
22
|
+
updateWidget<T>(id: string, value: StateDispatch<T>) {
|
|
22
23
|
this._widgetState?.updateWidget(id, value);
|
|
23
24
|
}
|
|
25
|
+
|
|
26
|
+
// TODO(burdon): Resolve from hypergraph.
|
|
27
|
+
getObjectLabel(_id: DXN) {
|
|
28
|
+
return 'Object';
|
|
29
|
+
}
|
|
24
30
|
}
|
|
25
31
|
|
|
26
32
|
/**
|
|
@@ -28,7 +34,7 @@ export class MessageThreadContext implements Pick<MarkdownStreamController, 'upd
|
|
|
28
34
|
*/
|
|
29
35
|
export type BlockRenderer = (
|
|
30
36
|
context: MessageThreadContext,
|
|
31
|
-
message:
|
|
37
|
+
message: Message.Message,
|
|
32
38
|
block: ContentBlock.Any,
|
|
33
39
|
) => string | undefined;
|
|
34
40
|
|
|
@@ -63,17 +69,46 @@ export class MessageSyncer {
|
|
|
63
69
|
void this._model.reset('');
|
|
64
70
|
}
|
|
65
71
|
|
|
66
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Syncs messages with the editor.
|
|
74
|
+
*/
|
|
75
|
+
append(messages: Message.Message[], flush = false): boolean {
|
|
76
|
+
// Check if new set of messages.
|
|
77
|
+
if (this._initialMessageId !== messages[0]?.id) {
|
|
78
|
+
this.reset();
|
|
79
|
+
this._initialMessageId = messages[0]?.id;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (flush && this._model.view?.state.doc.length === 0) {
|
|
83
|
+
const buffer: string[] = [];
|
|
84
|
+
this.process(messages, (content) => {
|
|
85
|
+
buffer.push(content);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
const content = buffer.join('');
|
|
89
|
+
this._model.view?.dispatch({
|
|
90
|
+
changes: [{ from: 0, to: this._model.view?.state.doc.length ?? 0, insert: content }],
|
|
91
|
+
selection: { anchor: content.length },
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
return true;
|
|
95
|
+
} else {
|
|
96
|
+
this.process(messages, (content) => {
|
|
97
|
+
void this._model.append(content);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
private process(messages: Message.Message[], append: (content: string) => void) {
|
|
67
105
|
log('sync', {
|
|
106
|
+
doc: this._model.view?.state.doc.length,
|
|
68
107
|
messages: messages.map((message) => message.blocks.length),
|
|
69
108
|
currentMessageIndex: this._currentMessageIndex,
|
|
70
109
|
currentBlockIndex: this._currentBlockIndex,
|
|
71
110
|
currentBlockContent: this._currentBlockContent,
|
|
72
111
|
});
|
|
73
|
-
if (this._initialMessageId !== messages[0]?.id) {
|
|
74
|
-
this.reset();
|
|
75
|
-
this._initialMessageId = messages[0]?.id;
|
|
76
|
-
}
|
|
77
112
|
|
|
78
113
|
let i = this._currentMessageIndex;
|
|
79
114
|
for (const message of messages.slice(this._currentMessageIndex)) {
|
|
@@ -94,9 +129,9 @@ export class MessageSyncer {
|
|
|
94
129
|
content = currentBlockContent;
|
|
95
130
|
}
|
|
96
131
|
|
|
97
|
-
void this._model.append(content);
|
|
98
|
-
this._currentBlockContent = currentBlockContent;
|
|
99
132
|
log('append', { message: i, block: j, content });
|
|
133
|
+
this._currentBlockContent = currentBlockContent;
|
|
134
|
+
append(content);
|
|
100
135
|
}
|
|
101
136
|
|
|
102
137
|
if (block.pending) {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<prompt>hi</prompt>
|
|
2
|
+
Hi! I'm Kai, your AI assistant powered by DXOS. I see you have a document in your context. Let me take a look at it to see how I can help you.
|
|
3
|
+
<toolCall id="toolu_012MB5XWrQhsyjUBoBCr7jXB" />
|
|
4
|
+
|
|
5
|
+
<summary>OK (1 tool uses · 2.62k tokens · 4.8s)</summary>
|
|
6
|
+
I can see you have a comprehensive welcome document for Composer by DXOS. This document explains what Composer is - an extensible collaborative application with features like documents, diagrams, tables, and sheets.
|
|
7
|
+
|
|
8
|
+
Here are some suggestions based on what's available:
|
|
9
|
+
<suggestion>Create a new document</suggestion>
|
|
10
|
+
<suggestion>Edit the welcome document</suggestion>
|
|
11
|
+
<suggestion>Create a table to organize information</suggestion>
|
|
12
|
+
<suggestion>Create a sketch for diagrams</suggestion>
|
|
13
|
+
<suggestion>Learn about collaboration features</suggestion>
|
|
14
|
+
|
|
15
|
+
Is there something specific you'd like to do with this document or would you like to explore other features of Composer?
|
|
16
|
+
|
|
17
|
+
<summary>OK (3.91k tokens · 7.0s)</summary>
|
|
18
|
+
<prompt>Create a table to organize information</prompt>
|
|
19
|
+
I'll help you create a table to organize information. Let me check what table creation tools are available.
|
|
20
|
+
<toolCall id="toolu_01Gk8ZNGYQEczAjGkbDZ9n1D" />
|
|
21
|
+
<summary>OK (1 tool uses · 3.99k tokens · 3.4s)</summary>
|
|
22
|
+
I need to check what artifact definitions are available for creating tables. Based on the blueprint instructions, I should first query for available artifact definitions to see what table-related tools I can use.
|
|
23
|
+
|
|
24
|
+
However, I notice that the function definitions provided don't include the artifact-related tools mentioned in the blueprint (like `require_artifact_definitions` or table creation tools). The available functions are focused on document operations (open, diff, add-to-context, open-item) and analysis mode.
|
|
25
|
+
|
|
26
|
+
Let me work with what's available. Since I can't directly create a table artifact with the current tools, I can help you create a table structure within a markdown document instead.
|
|
27
|
+
|
|
28
|
+
Would you like me to:
|
|
29
|
+
|
|
30
|
+
1. Create a simple markdown table structure in a new document that you can use to organize your information?
|
|
31
|
+
2. Or would you prefer to use Composer's built-in Tables plugin (as mentioned in the welcome document) by creating one through the Composer interface?
|
|
32
|
+
|
|
33
|
+
What kind of information are you looking to organize? This will help me suggest the best table structure for your needs.
|
|
34
|
+
<toolCall id="toolu_01CQXUsyLw2uoV3k1mPLqFee" />
|
|
35
|
+
|
|
36
|
+
<summary>OK (1 tool uses · 4.28k tokens · 11.1s)</summary>
|
|
37
|
+
<summary>OK (4.30k tokens · 1.6s)</summary>
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Cause from 'effect/Cause';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
import * as Exit from 'effect/Exit';
|
|
8
|
+
import React, { useMemo } from 'react';
|
|
9
|
+
|
|
10
|
+
import { type SurfaceComponentProps } from '@dxos/app-framework/react';
|
|
11
|
+
import { Agent } from '@dxos/assistant-toolkit';
|
|
12
|
+
import { type Prompt } from '@dxos/blueprints';
|
|
13
|
+
import { Obj } from '@dxos/echo';
|
|
14
|
+
import { FunctionInvocationService } from '@dxos/functions';
|
|
15
|
+
import { InvocationTracer, TracingServiceExt } from '@dxos/functions-runtime';
|
|
16
|
+
import { log } from '@dxos/log';
|
|
17
|
+
import { useComputeRuntimeCallback } from '@dxos/plugin-automation';
|
|
18
|
+
import { getSpace } from '@dxos/react-client/echo';
|
|
19
|
+
import { Toolbar, useTranslation } from '@dxos/react-ui';
|
|
20
|
+
import { useAttention } from '@dxos/react-ui-attention';
|
|
21
|
+
import { StackItem } from '@dxos/react-ui-stack';
|
|
22
|
+
|
|
23
|
+
import { meta } from '../meta';
|
|
24
|
+
|
|
25
|
+
import { TemplateEditor } from './TemplateEditor';
|
|
26
|
+
|
|
27
|
+
export type PromptArticleProps = SurfaceComponentProps<Prompt.Prompt>;
|
|
28
|
+
|
|
29
|
+
export const PromptArticle = ({ object }: PromptArticleProps) => {
|
|
30
|
+
const { t } = useTranslation(meta.id);
|
|
31
|
+
const space = getSpace(object);
|
|
32
|
+
const { hasAttention } = useAttention(Obj.getDXN(object).toString());
|
|
33
|
+
|
|
34
|
+
const inputData = useMemo(
|
|
35
|
+
() =>
|
|
36
|
+
object && {
|
|
37
|
+
prompt: space?.db.ref(Obj.getDXN(object)),
|
|
38
|
+
input: {},
|
|
39
|
+
},
|
|
40
|
+
[object, space],
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
// TODO(wittjosiah): Factor out.
|
|
44
|
+
const handleRun = useComputeRuntimeCallback(
|
|
45
|
+
space,
|
|
46
|
+
Effect.fnUntraced(function* () {
|
|
47
|
+
const tracer = yield* InvocationTracer;
|
|
48
|
+
const trace = yield* tracer.traceInvocationStart({
|
|
49
|
+
target: undefined,
|
|
50
|
+
payload: {
|
|
51
|
+
data: {},
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// Invoke the function.
|
|
56
|
+
const result = yield* FunctionInvocationService.invokeFunction(Agent.prompt, inputData).pipe(
|
|
57
|
+
Effect.provide(TracingServiceExt.layerQueue(trace.invocationTraceQueue)),
|
|
58
|
+
Effect.exit,
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
if (Exit.isFailure(result)) {
|
|
62
|
+
const error = Cause.prettyErrors(result.cause)[0];
|
|
63
|
+
log.error(error.message, error.cause ?? error.stack);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
yield* tracer.traceInvocationEnd({
|
|
67
|
+
trace,
|
|
68
|
+
// TODO(dmaretskyi): Might miss errors.
|
|
69
|
+
exception: Exit.isFailure(result) ? Cause.prettyErrors(result.cause)[0] : undefined,
|
|
70
|
+
});
|
|
71
|
+
}),
|
|
72
|
+
[inputData],
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<StackItem.Content toolbar>
|
|
77
|
+
<Toolbar.Root disabled={!hasAttention} onClick={handleRun}>
|
|
78
|
+
<Toolbar.IconButton iconOnly icon='ph--play--regular' label={t('run prompt label')} onClick={handleRun} />
|
|
79
|
+
</Toolbar.Root>
|
|
80
|
+
<TemplateEditor id={object.id} template={object.instructions} classNames='container-max-width' />
|
|
81
|
+
</StackItem.Content>
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export default PromptArticle;
|
|
@@ -9,26 +9,36 @@ import { createSystemPrompt } from '@dxos/assistant';
|
|
|
9
9
|
import { Blueprint, Template } from '@dxos/blueprints';
|
|
10
10
|
import { useClient } from '@dxos/react-client';
|
|
11
11
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
12
|
-
import { withTheme } from '@dxos/react-ui/testing';
|
|
12
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
13
13
|
import { trim } from '@dxos/util';
|
|
14
14
|
|
|
15
15
|
import { translations } from '../../translations';
|
|
16
16
|
|
|
17
17
|
import { TemplateEditor, type TemplateEditorProps } from './TemplateEditor';
|
|
18
18
|
|
|
19
|
+
const FENCE = '```';
|
|
20
|
+
|
|
19
21
|
const TEMPLATE = trim`
|
|
20
22
|
{{! System Prompt }}
|
|
21
23
|
|
|
22
|
-
You are
|
|
24
|
+
You are an expert chess player.
|
|
23
25
|
The move history of the current game is: {{history}}.
|
|
24
26
|
If asked to suggest a move explain why it is a good move.
|
|
25
27
|
|
|
26
28
|
{{#each artifacts}}
|
|
27
|
-
|
|
29
|
+
{{this}}
|
|
28
30
|
{{/each}}
|
|
29
31
|
|
|
32
|
+
Reponse in the format: <suggestion>SUGGESTION</suggestion>
|
|
33
|
+
|
|
34
|
+
@dxn:queue:data:B6INSIBY3CBEF4M5VZRYBCMAHQMPYK5AJ:01K24XMVHSZHS97SG1VTVQDM5Z:01K24XPK464FSCKVQJAB2H662M
|
|
35
|
+
|
|
30
36
|
---
|
|
31
37
|
|
|
38
|
+
${FENCE}ts
|
|
39
|
+
const x = 100;
|
|
40
|
+
${FENCE}
|
|
41
|
+
|
|
32
42
|
{{input}}
|
|
33
43
|
`;
|
|
34
44
|
|
|
@@ -60,6 +70,7 @@ const meta = {
|
|
|
60
70
|
render: DefaultStory,
|
|
61
71
|
decorators: [
|
|
62
72
|
withTheme,
|
|
73
|
+
withLayout({ container: 'column' }),
|
|
63
74
|
withClientProvider({
|
|
64
75
|
types: [Blueprint.Blueprint],
|
|
65
76
|
createIdentity: true,
|
|
@@ -67,7 +78,6 @@ const meta = {
|
|
|
67
78
|
}),
|
|
68
79
|
],
|
|
69
80
|
parameters: {
|
|
70
|
-
layout: 'column',
|
|
71
81
|
translations,
|
|
72
82
|
},
|
|
73
83
|
} satisfies Meta<typeof DefaultStory>;
|