@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
|
@@ -3,69 +3,86 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import * as Array from 'effect/Array';
|
|
6
|
-
import * as Effect from 'effect/Effect';
|
|
7
6
|
import * as Function from 'effect/Function';
|
|
8
7
|
import * as Option from 'effect/Option';
|
|
9
|
-
import React, { useMemo } from 'react';
|
|
8
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
10
9
|
|
|
11
|
-
import { Capabilities, createIntent
|
|
10
|
+
import { Capabilities, createIntent } from '@dxos/app-framework';
|
|
11
|
+
import { useCapabilities, useIntentDispatcher } from '@dxos/app-framework/react';
|
|
12
12
|
import { Blueprint } from '@dxos/blueprints';
|
|
13
13
|
import { getSpace } from '@dxos/client/echo';
|
|
14
|
-
import { Filter, Obj,
|
|
15
|
-
import { DatabaseService } from '@dxos/functions';
|
|
14
|
+
import { Filter, Obj, Ref } from '@dxos/echo';
|
|
16
15
|
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
17
16
|
import { useQuery } from '@dxos/react-client/echo';
|
|
18
17
|
import { useAsyncEffect } from '@dxos/react-ui';
|
|
19
18
|
|
|
20
|
-
import { ChatContainer } from '../components';
|
|
19
|
+
import { ChatContainer, type ChatEvent } from '../components';
|
|
21
20
|
import { useBlueprintRegistry, useContextBinder } from '../hooks';
|
|
22
21
|
import { Assistant, AssistantAction } from '../types';
|
|
23
22
|
|
|
24
23
|
export type ChatCompanionProps = {
|
|
25
24
|
role?: string;
|
|
26
|
-
data: {
|
|
25
|
+
data: { subject: Assistant.Chat | 'assistant-chat'; companionTo: Obj.Any };
|
|
27
26
|
};
|
|
28
27
|
|
|
29
28
|
export const ChatCompanion = ({ role, data }: ChatCompanionProps) => {
|
|
29
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
30
|
+
const blueprintRegistry = useBlueprintRegistry();
|
|
30
31
|
const companionTo = data.companionTo;
|
|
32
|
+
|
|
31
33
|
const space = getSpace(companionTo);
|
|
32
|
-
const chat = data.subject === 'assistant-chat' ? undefined : data.subject;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
const [chat, setChat] = useState(data.subject === 'assistant-chat' ? undefined : data.subject);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
setChat(data.subject === 'assistant-chat' ? undefined : data.subject);
|
|
37
|
+
}, [data.subject]);
|
|
38
|
+
|
|
39
|
+
const chatQueue = space && chat ? space.queues.get(chat.queue.dxn) : undefined;
|
|
40
|
+
const binder = useContextBinder(chatQueue);
|
|
36
41
|
|
|
37
|
-
// Initialize companion chat if it doesn't exist.
|
|
42
|
+
// Initialize companion chat if it doesn't exist, but don't add it to the space immediately.
|
|
38
43
|
useAsyncEffect(async () => {
|
|
39
|
-
if (
|
|
44
|
+
if (!space || chat) {
|
|
40
45
|
return;
|
|
41
46
|
}
|
|
42
47
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
48
|
+
const { data } = await dispatch(createIntent(AssistantAction.CreateChat, { space }));
|
|
49
|
+
setChat(data?.object);
|
|
50
|
+
}, [chat, space]);
|
|
51
|
+
|
|
52
|
+
// Add chat to space when user submits the first message.
|
|
53
|
+
const handleEvent = useCallback(
|
|
54
|
+
async (event: ChatEvent) => {
|
|
55
|
+
const chatInSpace = !!getSpace(chat);
|
|
56
|
+
if (chatInSpace || !chat || !space) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (event.type === 'submit') {
|
|
61
|
+
await dispatch(
|
|
62
|
+
createIntent(SpaceAction.AddObject, {
|
|
63
|
+
object: chat,
|
|
64
|
+
target: space,
|
|
65
|
+
hidden: true,
|
|
66
|
+
}),
|
|
67
|
+
);
|
|
68
|
+
await dispatch(
|
|
57
69
|
createIntent(SpaceAction.AddRelation, {
|
|
58
70
|
space,
|
|
59
71
|
schema: Assistant.CompanionTo,
|
|
60
|
-
source:
|
|
61
|
-
target:
|
|
72
|
+
source: chat,
|
|
73
|
+
target: companionTo,
|
|
74
|
+
}),
|
|
75
|
+
);
|
|
76
|
+
await dispatch(
|
|
77
|
+
createIntent(AssistantAction.SetCurrentChat, {
|
|
78
|
+
companionTo,
|
|
79
|
+
chat,
|
|
62
80
|
}),
|
|
63
81
|
);
|
|
64
82
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}, [space, chat, companionTo]);
|
|
83
|
+
},
|
|
84
|
+
[chat, space, companionTo, dispatch],
|
|
85
|
+
);
|
|
69
86
|
|
|
70
87
|
const metadata = useCapabilities(Capabilities.Metadata);
|
|
71
88
|
const blueprintKeys = useMemo(
|
|
@@ -73,8 +90,12 @@ export const ChatCompanion = ({ role, data }: ChatCompanionProps) => {
|
|
|
73
90
|
Function.pipe(
|
|
74
91
|
metadata,
|
|
75
92
|
Array.findFirst(
|
|
76
|
-
(
|
|
77
|
-
capability
|
|
93
|
+
(
|
|
94
|
+
capability,
|
|
95
|
+
): capability is {
|
|
96
|
+
id: string;
|
|
97
|
+
metadata: { blueprints?: string[] };
|
|
98
|
+
} => capability.id === Obj.getTypename(companionTo),
|
|
78
99
|
),
|
|
79
100
|
Option.flatMap((c) => Option.fromNullable(c.metadata.blueprints)),
|
|
80
101
|
Option.getOrElse(() => [] as string[]),
|
|
@@ -111,12 +132,14 @@ export const ChatCompanion = ({ role, data }: ChatCompanionProps) => {
|
|
|
111
132
|
}, [space, blueprintRegistry, blueprintKeys]);
|
|
112
133
|
|
|
113
134
|
useAsyncEffect(async () => {
|
|
114
|
-
if (!binder) {
|
|
135
|
+
if (!binder?.isOpen) {
|
|
115
136
|
return;
|
|
116
137
|
}
|
|
117
138
|
|
|
118
139
|
if (pluginBlueprints.length > 0) {
|
|
119
|
-
await binder.bind({
|
|
140
|
+
await binder.bind({
|
|
141
|
+
blueprints: pluginBlueprints.map((blueprint) => Ref.make(blueprint)),
|
|
142
|
+
});
|
|
120
143
|
}
|
|
121
144
|
|
|
122
145
|
if (Obj.instanceOf(Blueprint.Blueprint, companionTo)) {
|
|
@@ -124,13 +147,9 @@ export const ChatCompanion = ({ role, data }: ChatCompanionProps) => {
|
|
|
124
147
|
} else {
|
|
125
148
|
await binder.bind({ objects: [Ref.make(companionTo)] });
|
|
126
149
|
}
|
|
127
|
-
}, [binder, companionTo,
|
|
128
|
-
|
|
129
|
-
if (!chat) {
|
|
130
|
-
return null;
|
|
131
|
-
}
|
|
150
|
+
}, [binder, companionTo, blueprintKeys]);
|
|
132
151
|
|
|
133
|
-
return <ChatContainer role={role} chat={chat} companionTo={companionTo} />;
|
|
152
|
+
return <ChatContainer role={role} space={space} chat={chat} companionTo={companionTo} onEvent={handleEvent} />;
|
|
134
153
|
};
|
|
135
154
|
|
|
136
155
|
export default ChatCompanion;
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import { Capabilities
|
|
8
|
-
import {
|
|
7
|
+
import { Capabilities } from '@dxos/app-framework';
|
|
8
|
+
import { useCapability } from '@dxos/app-framework/react';
|
|
9
|
+
import { type Space, getSpace } from '@dxos/client/echo';
|
|
9
10
|
import { type Obj } from '@dxos/echo';
|
|
10
11
|
import { StackItem } from '@dxos/react-ui-stack';
|
|
11
12
|
|
|
@@ -13,36 +14,45 @@ import { useBlueprintRegistry, useChatProcessor, useChatServices, useOnline, use
|
|
|
13
14
|
import { meta } from '../meta';
|
|
14
15
|
import { type Assistant } from '../types';
|
|
15
16
|
|
|
16
|
-
import { Chat } from './Chat';
|
|
17
|
-
import { Toolbar } from './Toolbar';
|
|
17
|
+
import { Chat, type ChatRootProps } from './Chat';
|
|
18
18
|
|
|
19
19
|
export type ChatContainerProps = {
|
|
20
|
-
chat: Assistant.Chat;
|
|
21
|
-
companionTo?: Obj.Any;
|
|
22
20
|
role?: string;
|
|
23
|
-
|
|
21
|
+
space?: Space;
|
|
22
|
+
chat?: Assistant.Chat;
|
|
23
|
+
companionTo?: Obj.Any;
|
|
24
|
+
} & Pick<ChatRootProps, 'onEvent'>;
|
|
24
25
|
|
|
25
|
-
export const ChatContainer = ({ chat, companionTo }: ChatContainerProps) => {
|
|
26
|
-
const space = getSpace(chat);
|
|
26
|
+
export const ChatContainer = ({ space: spaceProp, chat, companionTo, onEvent }: ChatContainerProps) => {
|
|
27
|
+
const space = spaceProp ?? getSpace(chat);
|
|
27
28
|
const settings = useCapability(Capabilities.SettingsStore).getStore<Assistant.Settings>(meta.id)?.value;
|
|
28
29
|
const services = useChatServices({ space, chat });
|
|
29
30
|
const [online, setOnline] = useOnline();
|
|
30
31
|
const { preset, ...chatProps } = usePresets(online);
|
|
31
32
|
const blueprintRegistry = useBlueprintRegistry();
|
|
32
|
-
const processor = useChatProcessor({
|
|
33
|
+
const processor = useChatProcessor({
|
|
34
|
+
space,
|
|
35
|
+
chat,
|
|
36
|
+
preset,
|
|
37
|
+
services,
|
|
38
|
+
blueprintRegistry,
|
|
39
|
+
settings,
|
|
40
|
+
});
|
|
33
41
|
|
|
34
42
|
if (!processor) {
|
|
35
43
|
return null;
|
|
36
44
|
}
|
|
37
45
|
|
|
38
46
|
return (
|
|
39
|
-
<StackItem.Content toolbar
|
|
40
|
-
{
|
|
41
|
-
|
|
42
|
-
<Chat.
|
|
43
|
-
|
|
44
|
-
<
|
|
45
|
-
|
|
47
|
+
<StackItem.Content toolbar>
|
|
48
|
+
<Chat.Root space={space} chat={chat} processor={processor} onEvent={onEvent}>
|
|
49
|
+
<Chat.Toolbar companionTo={companionTo} />
|
|
50
|
+
<Chat.Viewport classNames='container-max-width'>
|
|
51
|
+
<Chat.Thread />
|
|
52
|
+
<div role='none' className='p-4'>
|
|
53
|
+
<Chat.Prompt {...chatProps} outline preset={preset?.id} online={online} onOnlineChange={setOnline} />
|
|
54
|
+
</div>
|
|
55
|
+
</Chat.Viewport>
|
|
46
56
|
</Chat.Root>
|
|
47
57
|
</StackItem.Content>
|
|
48
58
|
);
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useCallback, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import { Capabilities
|
|
7
|
+
import { Capabilities } from '@dxos/app-framework';
|
|
8
|
+
import { useCapability } from '@dxos/app-framework/react';
|
|
8
9
|
import { getSpace } from '@dxos/client/echo';
|
|
9
10
|
import { useTranslation } from '@dxos/react-ui';
|
|
10
11
|
import { ChatDialog as NaturalChatDialog } from '@dxos/react-ui-chat';
|
|
@@ -28,7 +29,13 @@ export const ChatDialog = ({ chat }: ChatDialogProps) => {
|
|
|
28
29
|
const [online, setOnline] = useOnline();
|
|
29
30
|
const { preset, ...chatProps } = usePresets(online);
|
|
30
31
|
const blueprintRegistry = useBlueprintRegistry();
|
|
31
|
-
const processor = useChatProcessor({
|
|
32
|
+
const processor = useChatProcessor({
|
|
33
|
+
chat,
|
|
34
|
+
preset,
|
|
35
|
+
services,
|
|
36
|
+
blueprintRegistry,
|
|
37
|
+
settings,
|
|
38
|
+
});
|
|
32
39
|
|
|
33
40
|
// TODO(burdon): Refocus when open.
|
|
34
41
|
const [open, setOpen] = useState(true);
|
|
@@ -61,7 +61,7 @@ export const ChatProgress = ({ chat }: ChatProgressProps) => {
|
|
|
61
61
|
return (
|
|
62
62
|
<Flex column tabIndex={0} ref={ref} classNames='outline-none'>
|
|
63
63
|
<ProgressBar nodes={nodes} index={index} onSelect={handleSelect} />
|
|
64
|
-
<TextCrawl
|
|
64
|
+
<TextCrawl classNames='pis-4 text-sm text-description' lines={lines} autoAdvance />
|
|
65
65
|
</Flex>
|
|
66
66
|
);
|
|
67
67
|
};
|
|
@@ -29,10 +29,9 @@ export const ChatActions = ({ classNames, children, microphone, recording, proce
|
|
|
29
29
|
<IconButton
|
|
30
30
|
disabled={!processing}
|
|
31
31
|
variant='ghost'
|
|
32
|
-
size={5}
|
|
33
32
|
icon='ph--x--regular'
|
|
34
33
|
iconOnly
|
|
35
|
-
label={t('
|
|
34
|
+
label={t('cancel processing button')}
|
|
36
35
|
onClick={() => onEvent?.({ type: 'cancel' })}
|
|
37
36
|
/>
|
|
38
37
|
|
|
@@ -41,11 +40,10 @@ export const ChatActions = ({ classNames, children, microphone, recording, proce
|
|
|
41
40
|
disabled={!processing}
|
|
42
41
|
classNames={mx(recording && 'bg-primary-500')}
|
|
43
42
|
variant='ghost'
|
|
44
|
-
size={5}
|
|
45
43
|
icon='ph--microphone--regular'
|
|
46
44
|
iconOnly
|
|
47
45
|
noTooltip
|
|
48
|
-
label={t('button
|
|
46
|
+
label={t('microphone button')}
|
|
49
47
|
onMouseDown={() => onEvent?.({ type: 'record-start' })}
|
|
50
48
|
onMouseUp={() => onEvent?.({ type: 'record-stop' })}
|
|
51
49
|
onTouchStart={() => onEvent?.({ type: 'record-start' })}
|
|
@@ -40,14 +40,16 @@ export const ChatOptions = ({
|
|
|
40
40
|
const { t } = useTranslation(meta.id);
|
|
41
41
|
|
|
42
42
|
return (
|
|
43
|
-
<div role='none' className='flex
|
|
43
|
+
<div role='none' className='flex'>
|
|
44
44
|
<Popover.Root>
|
|
45
45
|
<Popover.Trigger asChild>
|
|
46
|
-
<IconButton variant='ghost' icon='ph--plus--regular' iconOnly
|
|
46
|
+
<IconButton variant='ghost' icon='ph--plus--regular' iconOnly label={t('context objects button')} />
|
|
47
47
|
</Popover.Trigger>
|
|
48
48
|
<Popover.Portal>
|
|
49
49
|
<Popover.Content side='top' classNames={panelClassNames}>
|
|
50
|
-
<
|
|
50
|
+
<Popover.Viewport>
|
|
51
|
+
<ObjectsPanel space={space} context={context} />
|
|
52
|
+
</Popover.Viewport>
|
|
51
53
|
<Popover.Arrow />
|
|
52
54
|
</Popover.Content>
|
|
53
55
|
</Popover.Portal>
|
|
@@ -59,30 +61,31 @@ export const ChatOptions = ({
|
|
|
59
61
|
variant='ghost'
|
|
60
62
|
icon='ph--sliders-horizontal--regular'
|
|
61
63
|
iconOnly
|
|
62
|
-
|
|
63
|
-
label={t('button context settings')}
|
|
64
|
+
label={t('context settings button')}
|
|
64
65
|
/>
|
|
65
66
|
</Popover.Trigger>
|
|
66
67
|
<Popover.Portal>
|
|
67
68
|
<Popover.Content side='top' classNames={panelClassNames}>
|
|
68
|
-
<
|
|
69
|
-
<Tabs.
|
|
70
|
-
<Tabs.
|
|
71
|
-
<
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
<
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
<Tabs.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
69
|
+
<Popover.Viewport>
|
|
70
|
+
<Tabs.Root orientation='horizontal' defaultValue='blueprints' defaultActivePart='list' tabIndex={-1}>
|
|
71
|
+
<Tabs.Viewport classNames='max-bs-[--radix-popover-content-available-height] grid grid-rows-[1fr_min-content] [&_[cmdk-root]]:contents [&_[role="tabpanel"]]:grid [&_[role="tabpanel"]]:grid-rows-[1fr_min-content] [&_[role="listbox"]]:min-bs-0 [&_[role="listbox"]]:overflow-y-auto [&_[role="tabpanel"]]:min-bs-0 [&_[role="tabpanel"]]:pli-cardSpacingChrome [&_[role="tabpanel"][data-state="active"]]:order-first [&_[role="tabpanel"][data-state="inactive"]]:hidden'>
|
|
72
|
+
<Tabs.Tabpanel value='blueprints' tabIndex={-1} classNames='dx-focus-ring-inset'>
|
|
73
|
+
<BlueprintsPanel blueprintRegistry={blueprintRegistry} space={space} context={context} />
|
|
74
|
+
</Tabs.Tabpanel>
|
|
75
|
+
<Tabs.Tabpanel value='model' tabIndex={-1} classNames='dx-focus-ring-inset !pli-0'>
|
|
76
|
+
<ModelsPanel presets={presets} preset={preset} onPresetChange={onPresetChange} />
|
|
77
|
+
</Tabs.Tabpanel>
|
|
78
|
+
<Tabs.Tablist classNames='sm:overflow-x-hidden justify-center p-[--dx-cardSpacingChrome] border-bs border-subduedSeparator order-last'>
|
|
79
|
+
<Tabs.IconTab
|
|
80
|
+
value='blueprints'
|
|
81
|
+
icon='ph--blueprint--regular'
|
|
82
|
+
label={t('blueprints in context title')}
|
|
83
|
+
/>
|
|
84
|
+
<Tabs.IconTab value='model' label={t('chat model title')} icon='ph--cpu--regular' />
|
|
85
|
+
</Tabs.Tablist>
|
|
86
|
+
</Tabs.Viewport>
|
|
87
|
+
</Tabs.Root>
|
|
88
|
+
</Popover.Viewport>
|
|
86
89
|
<Popover.Arrow />
|
|
87
90
|
</Popover.Content>
|
|
88
91
|
</Popover.Portal>
|
|
@@ -23,7 +23,7 @@ export const ChatReferences = ({ classNames, context, space }: ChatReferencesPro
|
|
|
23
23
|
const { objects, onUpdateObject } = useContextObjects({ space, context });
|
|
24
24
|
|
|
25
25
|
return (
|
|
26
|
-
<ul className={mx('flex
|
|
26
|
+
<ul className={mx('flex', classNames)}>
|
|
27
27
|
{objects.map((obj) => {
|
|
28
28
|
const dxn = Obj.getDXN(obj);
|
|
29
29
|
const typename = Obj.getTypename(obj);
|
|
@@ -32,12 +32,12 @@ export const ChatReferences = ({ classNames, context, space }: ChatReferencesPro
|
|
|
32
32
|
<li key={dxn.toString()} className='dx-tag plb-0 pis-2 flex items-center' data-hue='neutral'>
|
|
33
33
|
{toLocalizedString(label, t)}
|
|
34
34
|
<IconButton
|
|
35
|
+
icon='ph--x--bold'
|
|
35
36
|
iconOnly
|
|
36
37
|
variant='ghost'
|
|
37
38
|
label={t('remove object in context label')}
|
|
38
39
|
classNames='p-0 hover:bg-transparent'
|
|
39
40
|
size={3}
|
|
40
|
-
icon='ph--x--bold'
|
|
41
41
|
onClick={() => onUpdateObject?.(dxn, false)}
|
|
42
42
|
/>
|
|
43
43
|
</li>
|
|
@@ -6,33 +6,38 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
|
6
6
|
import * as Effect from 'effect/Effect';
|
|
7
7
|
import * as Fiber from 'effect/Fiber';
|
|
8
8
|
import * as Layer from 'effect/Layer';
|
|
9
|
-
import React, { useEffect, useMemo, useState } from 'react';
|
|
9
|
+
import React, { type CSSProperties, useEffect, useMemo, useState } from 'react';
|
|
10
10
|
|
|
11
11
|
import { ContextQueueService, DatabaseService } from '@dxos/functions';
|
|
12
12
|
import { faker } from '@dxos/random';
|
|
13
13
|
import { useQueue, useSpace } from '@dxos/react-client/echo';
|
|
14
14
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
15
15
|
import { Popover } from '@dxos/react-ui';
|
|
16
|
-
import { withTheme } from '@dxos/react-ui/testing';
|
|
16
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
17
|
+
import { MarkdownStream } from '@dxos/react-ui-components';
|
|
17
18
|
import { PreviewPopoverProvider, usePreviewPopover } from '@dxos/react-ui-editor/testing';
|
|
18
19
|
import { Card } from '@dxos/react-ui-stack';
|
|
19
|
-
import {
|
|
20
|
+
import { render } from '@dxos/storybook-utils';
|
|
21
|
+
import { type Message, Organization, Person } from '@dxos/types';
|
|
20
22
|
|
|
21
23
|
import { createMessageGenerator } from '../../testing';
|
|
22
24
|
import { translations } from '../../translations';
|
|
23
25
|
|
|
24
|
-
import { ChatThread, type
|
|
26
|
+
import { ChatThread, type ChatThreadProps } from './ChatThread';
|
|
27
|
+
import { componentRegistry } from './registry';
|
|
28
|
+
import TEXT from './testing/thread.md?raw';
|
|
25
29
|
|
|
26
30
|
faker.seed(1);
|
|
27
31
|
|
|
28
32
|
type MessageGenerator = Effect.Effect<void, never, DatabaseService | ContextQueueService>;
|
|
29
33
|
|
|
30
|
-
type StoryProps =
|
|
34
|
+
type StoryProps = { generator?: MessageGenerator[]; delay?: number; wait?: boolean } & ChatThreadProps;
|
|
31
35
|
|
|
32
|
-
const DefaultStory = ({ generator = [], delay = 0, ...props }: StoryProps) => {
|
|
36
|
+
const DefaultStory = ({ generator = [], delay = 0, wait, ...props }: StoryProps) => {
|
|
33
37
|
const space = useSpace();
|
|
34
38
|
const queueDxn = useMemo(() => space?.queues.create().dxn, [space]);
|
|
35
|
-
const queue = useQueue<
|
|
39
|
+
const queue = useQueue<Message.Message>(queueDxn);
|
|
40
|
+
const [done, setDone] = useState(false);
|
|
36
41
|
|
|
37
42
|
// Generate messages.
|
|
38
43
|
useEffect(() => {
|
|
@@ -48,6 +53,7 @@ const DefaultStory = ({ generator = [], delay = 0, ...props }: StoryProps) => {
|
|
|
48
53
|
yield* Effect.sleep(delay);
|
|
49
54
|
}
|
|
50
55
|
}
|
|
56
|
+
setDone(true);
|
|
51
57
|
}).pipe(Effect.provide(Layer.mergeAll(DatabaseService.layer(space.db), ContextQueueService.layer(queue)))),
|
|
52
58
|
);
|
|
53
59
|
|
|
@@ -56,27 +62,18 @@ const DefaultStory = ({ generator = [], delay = 0, ...props }: StoryProps) => {
|
|
|
56
62
|
};
|
|
57
63
|
}, [space, queue, generator]);
|
|
58
64
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
// controller?.setContext({ timestamp: Date.now() });
|
|
63
|
-
}, [controller]);
|
|
65
|
+
if (wait && !done) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
64
68
|
|
|
65
|
-
// TODO(burdon): Elsewhere PreviewProvider is implemented via the plugin-preview.
|
|
66
69
|
return (
|
|
67
|
-
<PreviewPopoverProvider
|
|
68
|
-
|
|
69
|
-
return { label, text: ref };
|
|
70
|
-
}}
|
|
71
|
-
>
|
|
72
|
-
<ChatThread {...props} messages={queue?.objects ?? []} ref={setController} />
|
|
70
|
+
<PreviewPopoverProvider onLookup={async ({ label, ref }) => ({ label, text: ref })}>
|
|
71
|
+
<ChatThread {...props} messages={queue?.objects} />
|
|
73
72
|
<PreviewCard />
|
|
74
73
|
</PreviewPopoverProvider>
|
|
75
74
|
);
|
|
76
75
|
};
|
|
77
76
|
|
|
78
|
-
// TODO(burdon): Factor out.
|
|
79
|
-
// TODO(burdon): Provide renderer for preview extension.
|
|
80
77
|
const PreviewCard = () => {
|
|
81
78
|
const { target } = usePreviewPopover('PreviewCard');
|
|
82
79
|
|
|
@@ -98,32 +95,54 @@ const PreviewCard = () => {
|
|
|
98
95
|
const meta = {
|
|
99
96
|
title: 'plugins/plugin-assistant/ChatThread',
|
|
100
97
|
component: ChatThread,
|
|
101
|
-
render: DefaultStory,
|
|
98
|
+
render: render(DefaultStory),
|
|
102
99
|
decorators: [
|
|
103
100
|
withTheme,
|
|
104
|
-
|
|
101
|
+
withLayout({ container: 'column' }),
|
|
102
|
+
withClientProvider({
|
|
103
|
+
createIdentity: true,
|
|
104
|
+
createSpace: true,
|
|
105
|
+
types: [Organization.Organization, Person.Person],
|
|
106
|
+
}),
|
|
105
107
|
],
|
|
106
108
|
parameters: {
|
|
107
109
|
layout: 'fullscreen',
|
|
108
110
|
translations,
|
|
109
111
|
},
|
|
110
|
-
} satisfies Meta<
|
|
112
|
+
} satisfies Meta<StoryProps>;
|
|
111
113
|
|
|
112
114
|
export default meta;
|
|
113
115
|
|
|
114
|
-
type Story = StoryObj<
|
|
116
|
+
type Story = StoryObj<StoryProps>;
|
|
115
117
|
|
|
116
118
|
export const Default: Story = {
|
|
117
119
|
args: {
|
|
118
120
|
generator: createMessageGenerator(),
|
|
121
|
+
wait: true,
|
|
119
122
|
},
|
|
120
123
|
};
|
|
121
124
|
|
|
122
125
|
export const Delayed: Story = {
|
|
123
126
|
args: {
|
|
124
127
|
generator: createMessageGenerator(),
|
|
125
|
-
delay:
|
|
128
|
+
delay: 1_000,
|
|
126
129
|
fadeIn: true,
|
|
127
130
|
cursor: false,
|
|
128
131
|
},
|
|
129
132
|
};
|
|
133
|
+
|
|
134
|
+
export const Raw: Story = {
|
|
135
|
+
render: () => (
|
|
136
|
+
<div className='contents' style={{ '--user-fill': 'var(--dx-amberFill)' } as CSSProperties}>
|
|
137
|
+
<MarkdownStream content={TEXT} />
|
|
138
|
+
</div>
|
|
139
|
+
),
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export const Static: Story = {
|
|
143
|
+
render: () => (
|
|
144
|
+
<div className='contents' style={{ '--user-fill': 'var(--dx-amberFill)' } as CSSProperties}>
|
|
145
|
+
<MarkdownStream content={TEXT} registry={componentRegistry} />
|
|
146
|
+
</div>
|
|
147
|
+
),
|
|
148
|
+
};
|