@dxos/plugin-assistant 0.8.4-main.28f8d3d → 0.8.4-main.2c6827d
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-IMCR3642.mjs +36 -0
- package/dist/lib/browser/BlueprintArticle-IMCR3642.mjs.map +7 -0
- package/dist/lib/browser/ChatCompanion-4MS4NMZY.mjs +158 -0
- package/dist/lib/browser/ChatCompanion-4MS4NMZY.mjs.map +7 -0
- package/dist/lib/browser/{ChatContainer-OUVSX5V5.mjs → ChatContainer-GJZN3SIJ.mjs} +27 -26
- package/dist/lib/browser/ChatContainer-GJZN3SIJ.mjs.map +7 -0
- package/dist/lib/browser/{ChatDialog-P4FLEOHG.mjs → ChatDialog-E2X6DTDX.mjs} +17 -13
- package/dist/lib/browser/ChatDialog-E2X6DTDX.mjs.map +7 -0
- package/dist/lib/browser/PromptArticle-45QX25Y5.mjs +59 -0
- package/dist/lib/browser/PromptArticle-45QX25Y5.mjs.map +7 -0
- package/dist/lib/browser/ai-service-ERTZBTP3.mjs +19 -0
- package/dist/lib/browser/ai-service-ERTZBTP3.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-AVHHQ3KV.mjs → app-graph-builder-VZEXMDTY.mjs} +72 -39
- package/dist/lib/browser/app-graph-builder-VZEXMDTY.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-5FT5JGPY.mjs +12 -0
- package/dist/lib/browser/blueprint-definition-5FT5JGPY.mjs.map +7 -0
- package/dist/lib/browser/chunk-2BOE3OTW.mjs +262 -0
- package/dist/lib/browser/chunk-2BOE3OTW.mjs.map +7 -0
- package/dist/lib/browser/{chunk-HRLMD35M.mjs → chunk-BNTPFZ7O.mjs} +60 -22
- 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/{blueprint-definition-CMGIZAOW.mjs → chunk-IXIIS4QA.mjs} +78 -48
- package/dist/lib/browser/chunk-IXIIS4QA.mjs.map +7 -0
- package/dist/lib/browser/chunk-LRE4VEZV.mjs +16 -0
- package/dist/lib/browser/chunk-LRE4VEZV.mjs.map +7 -0
- package/dist/lib/browser/chunk-TCAQJ26D.mjs +1929 -0
- package/dist/lib/browser/chunk-TCAQJ26D.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/edge-model-resolver-O6OFYIO2.mjs +18 -0
- package/dist/lib/browser/edge-model-resolver-O6OFYIO2.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +162 -73
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-resolver-AK5O4GUW.mjs +143 -0
- package/dist/lib/browser/intent-resolver-AK5O4GUW.mjs.map +7 -0
- package/dist/lib/browser/local-model-resolver-34MVHRKD.mjs +17 -0
- package/dist/lib/browser/local-model-resolver-34MVHRKD.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-XWAR5ZVL.mjs +98 -0
- package/dist/lib/browser/react-surface-XWAR5ZVL.mjs.map +7 -0
- package/dist/lib/browser/{settings-G2EZXMWT.mjs → settings-NYJGNQ5I.mjs} +5 -5
- package/dist/lib/browser/{settings-G2EZXMWT.mjs.map → settings-NYJGNQ5I.mjs.map} +1 -1
- package/dist/lib/browser/state-GG7Z3NB7.mjs +25 -0
- package/dist/lib/browser/state-GG7Z3NB7.mjs.map +7 -0
- 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-OL2HUY6Q.mjs +37 -0
- package/dist/lib/node-esm/BlueprintArticle-OL2HUY6Q.mjs.map +7 -0
- package/dist/lib/node-esm/ChatCompanion-TYRR7BXD.mjs +159 -0
- package/dist/lib/node-esm/ChatCompanion-TYRR7BXD.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatContainer-D5FABDNE.mjs → ChatContainer-MT4INE7Z.mjs} +27 -26
- package/dist/lib/node-esm/ChatContainer-MT4INE7Z.mjs.map +7 -0
- package/dist/lib/node-esm/{ChatDialog-NKWVXHJP.mjs → ChatDialog-G4EWBIJM.mjs} +17 -13
- package/dist/lib/node-esm/ChatDialog-G4EWBIJM.mjs.map +7 -0
- package/dist/lib/node-esm/PromptArticle-OUKFSJQV.mjs +60 -0
- package/dist/lib/node-esm/PromptArticle-OUKFSJQV.mjs.map +7 -0
- package/dist/lib/node-esm/ai-service-MUYLV3NT.mjs +20 -0
- package/dist/lib/node-esm/ai-service-MUYLV3NT.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-RMOUJMMG.mjs → app-graph-builder-VRN6ESRR.mjs} +72 -39
- package/dist/lib/node-esm/app-graph-builder-VRN6ESRR.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-XW6QQVLV.mjs +13 -0
- package/dist/lib/node-esm/blueprint-definition-XW6QQVLV.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-3Q22TTXW.mjs +264 -0
- package/dist/lib/node-esm/chunk-3Q22TTXW.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-F7RXCX5Y.mjs → chunk-AB74FOA2.mjs} +60 -22
- 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-KM24SYPM.mjs +1930 -0
- package/dist/lib/node-esm/chunk-KM24SYPM.mjs.map +7 -0
- package/dist/lib/node-esm/{blueprint-definition-AEWYMW6I.mjs → chunk-UXTUHH24.mjs} +78 -47
- package/dist/lib/node-esm/chunk-UXTUHH24.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-WE6KTH72.mjs +25 -0
- package/dist/lib/node-esm/chunk-WE6KTH72.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-X6AANUHZ.mjs → chunk-YWFWT57N.mjs} +4 -4
- package/dist/lib/node-esm/chunk-YWFWT57N.mjs.map +7 -0
- package/dist/lib/node-esm/edge-model-resolver-2ARXDOYS.mjs +19 -0
- package/dist/lib/node-esm/edge-model-resolver-2ARXDOYS.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +162 -73
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intent-resolver-L2F3N45L.mjs +144 -0
- package/dist/lib/node-esm/intent-resolver-L2F3N45L.mjs.map +7 -0
- package/dist/lib/node-esm/local-model-resolver-TP2NTSAX.mjs +18 -0
- package/dist/lib/node-esm/local-model-resolver-TP2NTSAX.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-JXB7Q6QR.mjs +99 -0
- package/dist/lib/node-esm/react-surface-JXB7Q6QR.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-AIP5FOJG.mjs → settings-RRHYI5KO.mjs} +5 -5
- package/dist/lib/node-esm/{settings-AIP5FOJG.mjs.map → settings-RRHYI5KO.mjs.map} +1 -1
- package/dist/lib/node-esm/state-FSUHFMDM.mjs +26 -0
- package/dist/lib/node-esm/state-FSUHFMDM.mjs.map +7 -0
- 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 +1 -1
- package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/ai-service.d.ts +2 -3
- package/dist/types/src/capabilities/ai-service.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +5 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -1
- package/dist/types/src/capabilities/capabilities.d.ts +7 -8
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
- package/dist/types/src/capabilities/edge-model-resolver.d.ts +2 -3
- package/dist/types/src/capabilities/edge-model-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +7 -4
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/local-model-resolver.d.ts +10 -0
- package/dist/types/src/capabilities/local-model-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/settings.d.ts +1 -1
- package/dist/types/src/capabilities/state.d.ts +4 -0
- package/dist/types/src/capabilities/state.d.ts.map +1 -0
- package/dist/types/src/capabilities/toolkit.d.ts +2 -3
- package/dist/types/src/capabilities/toolkit.d.ts.map +1 -1
- package/dist/types/src/components/AssistantSettings/AssistantSettings.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 +32 -16
- package/dist/types/src/components/Chat/Chat.d.ts.map +1 -1
- package/dist/types/src/components/Chat/events.d.ts +9 -0
- package/dist/types/src/components/Chat/events.d.ts.map +1 -1
- package/dist/types/src/components/ChatCompanion.d.ts +13 -0
- package/dist/types/src/components/ChatCompanion.d.ts.map +1 -0
- package/dist/types/src/components/ChatContainer.d.ts +8 -6
- 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/ChatProgress/ChatProgress.d.ts +7 -0
- package/dist/types/src/components/ChatProgress/ChatProgress.d.ts.map +1 -0
- package/dist/types/src/components/ChatProgress/index.d.ts +2 -0
- package/dist/types/src/components/ChatProgress/index.d.ts.map +1 -0
- package/dist/types/src/components/ChatPrompt/ChatActions.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts +11 -4
- package/dist/types/src/components/ChatPrompt/ChatOptions.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatPresets.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts +3 -4
- package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts.map +1 -1
- package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts +6 -4
- package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.d.ts +12 -10
- package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +191 -82
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/Link.d.ts.map +1 -1
- package/dist/types/src/components/ChatThread/reducers.d.ts +40 -0
- package/dist/types/src/components/ChatThread/reducers.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/registry.d.ts +11 -0
- package/dist/types/src/components/ChatThread/registry.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/sync.d.ts +42 -0
- package/dist/types/src/components/ChatThread/sync.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/sync.test.d.ts +2 -0
- package/dist/types/src/components/ChatThread/sync.test.d.ts.map +1 -0
- 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 -6
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +312 -7
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +309 -2
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/extensions/handlebars-extension.d.ts +12 -0
- 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 +21 -0
- package/dist/types/src/components/ToolBlock/ToolBlock.d.ts.map +1 -0
- package/dist/types/src/components/ToolBlock/ToolBlockWidget.d.ts +2 -0
- package/dist/types/src/components/ToolBlock/ToolBlockWidget.d.ts.map +1 -0
- package/dist/types/src/components/ToolBlock/index.d.ts +3 -0
- package/dist/types/src/components/ToolBlock/index.d.ts.map +1 -0
- package/dist/types/src/components/Toolbox/Toolbox.d.ts +3 -5
- package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +314 -5
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +4 -7
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/functions/analysis.d.ts +1 -1
- package/dist/types/src/functions/analysis.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} +2 -2
- package/dist/types/src/functions/object-list.d.ts.map +1 -0
- package/dist/types/src/functions/{load.d.ts → object-load.d.ts} +3 -3
- package/dist/types/src/functions/object-load.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +5 -4
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts +5 -1
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatProcessor.d.ts +3 -7
- package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatServices.d.ts +5 -5
- 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 +4 -0
- package/dist/types/src/hooks/useContextBinder.d.ts.map +1 -0
- package/dist/types/src/hooks/useContextObjects.d.ts +15 -0
- package/dist/types/src/hooks/useContextObjects.d.ts.map +1 -0
- package/dist/types/src/hooks/useFlush.d.ts.map +1 -0
- package/dist/types/src/hooks/useItemTypes.d.ts +4 -0
- package/dist/types/src/hooks/useItemTypes.d.ts.map +1 -0
- package/dist/types/src/hooks/usePresets.d.ts +2 -2
- package/dist/types/src/hooks/usePresets.d.ts.map +1 -1
- package/dist/types/src/hooks/useReferencesProvider.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +1 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/processor/index.d.ts +4 -0
- package/dist/types/src/processor/index.d.ts.map +1 -0
- package/dist/types/src/{hooks → processor}/presets.d.ts +1 -1
- package/dist/types/src/processor/presets.d.ts.map +1 -0
- package/dist/types/src/processor/processor.d.ts +74 -0
- package/dist/types/src/processor/processor.d.ts.map +1 -0
- package/dist/types/src/processor/processor.test.d.ts +2 -0
- package/dist/types/src/processor/processor.test.d.ts.map +1 -0
- 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/index.d.ts +1 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-generator.d.ts +7 -0
- package/dist/types/src/testing/test-generator.d.ts.map +1 -0
- package/dist/types/src/testing/test-sequence.d.ts +0 -4
- package/dist/types/src/testing/test-sequence.d.ts.map +1 -1
- package/dist/types/src/testing/test-services.d.ts +2 -2
- package/dist/types/src/testing/test-services.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +257 -33
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Assistant.d.ts +15 -7
- package/dist/types/src/types/Assistant.d.ts.map +1 -1
- package/dist/types/src/types/AssistantAction.d.ts +49 -7
- package/dist/types/src/types/AssistantAction.d.ts.map +1 -1
- package/dist/types/src/types/service.d.ts +21 -12
- package/dist/types/src/types/service.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +96 -97
- package/src/AssistantPlugin.tsx +156 -116
- package/src/capabilities/ai-service.ts +6 -7
- package/src/capabilities/app-graph-builder.ts +95 -54
- package/src/capabilities/blueprint-definition.ts +56 -22
- package/src/capabilities/capabilities.ts +7 -12
- package/src/capabilities/edge-model-resolver.ts +17 -21
- package/src/capabilities/index.ts +5 -2
- package/src/capabilities/intent-resolver.ts +91 -17
- package/src/capabilities/local-model-resolver.ts +30 -0
- package/src/capabilities/react-surface.tsx +23 -81
- package/src/capabilities/state.ts +22 -0
- package/src/capabilities/toolkit.ts +9 -98
- package/src/components/AssistantSettings/AssistantSettings.tsx +82 -75
- package/src/components/BlueprintArticle.tsx +29 -0
- package/src/components/Chat/Chat.tsx +252 -222
- package/src/components/Chat/events.ts +13 -0
- package/src/components/ChatCompanion.tsx +155 -0
- package/src/components/ChatContainer.tsx +33 -41
- package/src/components/ChatDialog.tsx +19 -12
- package/src/components/ChatProgress/ChatProgress.tsx +67 -0
- package/src/components/{Timeline → ChatProgress}/index.ts +1 -1
- package/src/components/ChatPrompt/ChatActions.tsx +10 -26
- package/src/components/ChatPrompt/ChatOptions.tsx +203 -34
- package/src/components/ChatPrompt/ChatPresets.tsx +1 -0
- package/src/components/ChatPrompt/ChatReferences.tsx +29 -36
- package/src/components/ChatPrompt/ChatStatusIndicator.tsx +25 -22
- package/src/components/ChatThread/ChatThread.stories.tsx +92 -204
- package/src/components/ChatThread/ChatThread.tsx +65 -35
- package/src/components/ChatThread/Link.tsx +8 -21
- package/src/components/ChatThread/reducers.ts +151 -0
- package/src/components/ChatThread/registry.tsx +174 -0
- package/src/components/ChatThread/sync.test.ts +89 -0
- package/src/components/ChatThread/sync.ts +148 -0
- package/src/components/ChatThread/testing/thread.md +37 -0
- package/src/components/PromptArticle.tsx +51 -0
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +29 -15
- package/src/components/TemplateEditor/TemplateEditor.tsx +28 -53
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +7 -9
- package/src/components/TemplateEditor/TemplateForm.tsx +3 -2
- 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 +143 -0
- package/src/components/ToolBlock/ToolBlockWidget.tsx +5 -0
- package/src/components/ToolBlock/index.ts +6 -0
- package/src/components/Toolbox/Toolbox.stories.tsx +11 -14
- package/src/components/Toolbox/Toolbox.tsx +15 -21
- package/src/components/index.ts +3 -4
- package/src/functions/analysis.ts +5 -3
- package/src/functions/index.ts +2 -2
- package/src/functions/{list.ts → object-list.ts} +11 -5
- package/src/functions/{load.ts → object-load.ts} +9 -7
- package/src/hooks/index.ts +5 -5
- package/src/hooks/useBlueprintRegistry.ts +26 -10
- package/src/hooks/useChatProcessor.ts +26 -33
- package/src/hooks/useChatServices.ts +32 -53
- package/src/hooks/useChatToolbarActions.ts +122 -0
- package/src/hooks/useContextBinder.ts +30 -0
- package/src/hooks/useContextObjects.ts +58 -0
- package/src/hooks/useItemTypes.ts +37 -0
- package/src/hooks/usePresets.ts +4 -5
- package/src/hooks/useReferencesProvider.ts +2 -1
- package/src/index.ts +2 -0
- package/src/meta.ts +9 -6
- package/src/processor/index.ts +7 -0
- package/src/{hooks → processor}/presets.ts +11 -4
- package/src/processor/processor.test.ts +71 -0
- package/src/processor/processor.ts +277 -0
- package/src/processor/update-name.ts +56 -0
- package/src/queue-logger.ts +9 -13
- package/src/testing/index.ts +1 -1
- package/src/testing/test-generator.ts +261 -0
- package/src/testing/test-sequence.ts +1 -26
- package/src/testing/test-services.ts +2 -8
- package/src/translations.ts +44 -24
- package/src/types/Assistant.ts +11 -7
- package/src/types/AssistantAction.ts +31 -6
- package/src/types/service.ts +17 -9
- package/src/vite-env.d.ts +30 -0
- package/dist/lib/browser/BlueprintContainer-H7H4BQ2C.mjs +0 -29
- package/dist/lib/browser/BlueprintContainer-H7H4BQ2C.mjs.map +0 -7
- package/dist/lib/browser/ChatContainer-OUVSX5V5.mjs.map +0 -7
- package/dist/lib/browser/ChatDialog-P4FLEOHG.mjs.map +0 -7
- package/dist/lib/browser/SequenceContainer-627OQ557.mjs +0 -163
- package/dist/lib/browser/SequenceContainer-627OQ557.mjs.map +0 -7
- package/dist/lib/browser/ai-service-7KJ5LXBT.mjs +0 -22
- package/dist/lib/browser/ai-service-7KJ5LXBT.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-AVHHQ3KV.mjs.map +0 -7
- package/dist/lib/browser/blueprint-definition-CMGIZAOW.mjs.map +0 -7
- package/dist/lib/browser/chunk-BRLHDHOF.mjs +0 -244
- package/dist/lib/browser/chunk-BRLHDHOF.mjs.map +0 -7
- package/dist/lib/browser/chunk-HRLMD35M.mjs.map +0 -7
- package/dist/lib/browser/chunk-LKP65RPA.mjs +0 -20
- package/dist/lib/browser/chunk-LKP65RPA.mjs.map +0 -7
- package/dist/lib/browser/chunk-NZDCKQ6W.mjs +0 -89
- package/dist/lib/browser/chunk-NZDCKQ6W.mjs.map +0 -7
- package/dist/lib/browser/chunk-QB7OVS6Z.mjs +0 -16
- package/dist/lib/browser/chunk-QB7OVS6Z.mjs.map +0 -7
- package/dist/lib/browser/chunk-VEBVAHNM.mjs +0 -2231
- package/dist/lib/browser/chunk-VEBVAHNM.mjs.map +0 -7
- package/dist/lib/browser/edge-model-resolver-2HB4PCWH.mjs +0 -24
- package/dist/lib/browser/edge-model-resolver-2HB4PCWH.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-MVOIEJXZ.mjs +0 -81
- package/dist/lib/browser/intent-resolver-MVOIEJXZ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-4HXS3YLT.mjs +0 -163
- package/dist/lib/browser/react-surface-4HXS3YLT.mjs.map +0 -7
- package/dist/lib/browser/toolkit-IW4FBLLB.mjs +0 -105
- package/dist/lib/browser/toolkit-IW4FBLLB.mjs.map +0 -7
- package/dist/lib/node-esm/BlueprintContainer-VH4EE4CM.mjs +0 -30
- package/dist/lib/node-esm/BlueprintContainer-VH4EE4CM.mjs.map +0 -7
- package/dist/lib/node-esm/ChatContainer-D5FABDNE.mjs.map +0 -7
- package/dist/lib/node-esm/ChatDialog-NKWVXHJP.mjs.map +0 -7
- package/dist/lib/node-esm/SequenceContainer-EQ5NP2PG.mjs +0 -164
- package/dist/lib/node-esm/SequenceContainer-EQ5NP2PG.mjs.map +0 -7
- package/dist/lib/node-esm/ai-service-LDD32477.mjs +0 -23
- package/dist/lib/node-esm/ai-service-LDD32477.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-RMOUJMMG.mjs.map +0 -7
- package/dist/lib/node-esm/blueprint-definition-AEWYMW6I.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-3SOC5GOP.mjs +0 -2232
- package/dist/lib/node-esm/chunk-3SOC5GOP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-F7RXCX5Y.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GAWXJ7K5.mjs +0 -90
- package/dist/lib/node-esm/chunk-GAWXJ7K5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-KOC6ESG7.mjs +0 -22
- package/dist/lib/node-esm/chunk-KOC6ESG7.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-RD755HN3.mjs +0 -245
- package/dist/lib/node-esm/chunk-RD755HN3.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-X6AANUHZ.mjs.map +0 -7
- package/dist/lib/node-esm/edge-model-resolver-UDDR2IA6.mjs +0 -25
- package/dist/lib/node-esm/edge-model-resolver-UDDR2IA6.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-DTDNCX3C.mjs +0 -82
- package/dist/lib/node-esm/intent-resolver-DTDNCX3C.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-V6JNEZVO.mjs +0 -164
- package/dist/lib/node-esm/react-surface-V6JNEZVO.mjs.map +0 -7
- package/dist/lib/node-esm/toolkit-2VNUL77B.mjs +0 -106
- package/dist/lib/node-esm/toolkit-2VNUL77B.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/ChatThread/ChatMessage.d.ts +0 -18
- package/dist/types/src/components/ChatThread/ChatMessage.d.ts.map +0 -1
- package/dist/types/src/components/ChatThread/ToolBlock.d.ts +0 -19
- package/dist/types/src/components/ChatThread/ToolBlock.d.ts.map +0 -1
- package/dist/types/src/components/ChatThread/reducer.d.ts +0 -12
- package/dist/types/src/components/ChatThread/reducer.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 -8
- 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/Timeline/Timeline.d.ts +0 -24
- package/dist/types/src/components/Timeline/Timeline.d.ts.map +0 -1
- package/dist/types/src/components/Timeline/Timeline.stories.d.ts +0 -9
- package/dist/types/src/components/Timeline/Timeline.stories.d.ts.map +0 -1
- package/dist/types/src/components/Timeline/index.d.ts +0 -2
- package/dist/types/src/components/Timeline/index.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/dist/types/src/hooks/chat-processor.d.ts +0 -72
- package/dist/types/src/hooks/chat-processor.d.ts.map +0 -1
- package/dist/types/src/hooks/errors.d.ts +0 -4
- package/dist/types/src/hooks/errors.d.ts.map +0 -1
- package/dist/types/src/hooks/presets.d.ts.map +0 -1
- package/dist/types/src/hooks/useResolveRef.d.ts +0 -4
- package/dist/types/src/hooks/useResolveRef.d.ts.map +0 -1
- package/dist/types/src/parser/filter-generator.d.ts +0 -4
- package/dist/types/src/parser/filter-generator.d.ts.map +0 -1
- package/dist/types/src/parser/filter-generator.test.d.ts +0 -2
- package/dist/types/src/parser/filter-generator.test.d.ts.map +0 -1
- package/dist/types/src/parser/index.d.ts +0 -4
- package/dist/types/src/parser/index.d.ts.map +0 -1
- package/dist/types/src/parser/query-parser.d.ts +0 -15
- package/dist/types/src/parser/query-parser.d.ts.map +0 -1
- package/dist/types/src/parser/query-parser.test.d.ts +0 -2
- package/dist/types/src/parser/query-parser.test.d.ts.map +0 -1
- package/dist/types/src/parser/types.d.ts +0 -24
- package/dist/types/src/parser/types.d.ts.map +0 -1
- package/dist/types/src/stories/Chat.stories.d.ts +0 -268
- package/dist/types/src/stories/Chat.stories.d.ts.map +0 -1
- package/dist/types/src/stories/components/BlueprintContainer.d.ts +0 -5
- package/dist/types/src/stories/components/BlueprintContainer.d.ts.map +0 -1
- package/dist/types/src/stories/components/ChatContainer.d.ts +0 -5
- package/dist/types/src/stories/components/ChatContainer.d.ts.map +0 -1
- package/dist/types/src/stories/components/GraphContainer.d.ts +0 -6
- package/dist/types/src/stories/components/GraphContainer.d.ts.map +0 -1
- package/dist/types/src/stories/components/LoggingContainer.d.ts +0 -5
- package/dist/types/src/stories/components/LoggingContainer.d.ts.map +0 -1
- package/dist/types/src/stories/components/SurfaceContainer.d.ts +0 -8
- package/dist/types/src/stories/components/SurfaceContainer.d.ts.map +0 -1
- package/dist/types/src/stories/components/TasksContainer.d.ts +0 -5
- package/dist/types/src/stories/components/TasksContainer.d.ts.map +0 -1
- package/dist/types/src/stories/components/index.d.ts +0 -8
- package/dist/types/src/stories/components/index.d.ts.map +0 -1
- package/dist/types/src/stories/components/types.d.ts +0 -7
- package/dist/types/src/stories/components/types.d.ts.map +0 -1
- package/dist/types/src/stories/hooks/index.d.ts +0 -3
- package/dist/types/src/stories/hooks/index.d.ts.map +0 -1
- package/dist/types/src/stories/hooks/useFlush.d.ts.map +0 -1
- package/dist/types/src/stories/hooks/useMatcherExtension.d.ts +0 -3
- package/dist/types/src/stories/hooks/useMatcherExtension.d.ts.map +0 -1
- package/dist/types/src/stories/testing/data.d.ts +0 -142
- package/dist/types/src/stories/testing/data.d.ts.map +0 -1
- package/dist/types/src/stories/testing/index.d.ts +0 -3
- package/dist/types/src/stories/testing/index.d.ts.map +0 -1
- package/dist/types/src/stories/testing/testing.d.ts +0 -26
- package/dist/types/src/stories/testing/testing.d.ts.map +0 -1
- package/dist/types/src/testing/test-functions.d.ts +0 -6
- package/dist/types/src/testing/test-functions.d.ts.map +0 -1
- package/dist/types/src/tools/function.d.ts +0 -5
- package/dist/types/src/tools/function.d.ts.map +0 -1
- package/dist/types/src/tools/index.d.ts +0 -3
- package/dist/types/src/tools/index.d.ts.map +0 -1
- package/dist/types/src/tools/openapi.d.ts +0 -10
- package/dist/types/src/tools/openapi.d.ts.map +0 -1
- package/dist/types/src/tools/openapi.test.d.ts +0 -2
- package/dist/types/src/tools/openapi.test.d.ts.map +0 -1
- package/src/components/BlueprintContainer.tsx +0 -24
- package/src/components/ChatThread/ChatMessage.tsx +0 -282
- package/src/components/ChatThread/ToolBlock.tsx +0 -125
- package/src/components/ChatThread/reducer.ts +0 -52
- package/src/components/PromptSettings.tsx +0 -89
- package/src/components/SequenceContainer.tsx +0 -133
- package/src/components/SequenceEditor/SequenceEditor.stories.tsx +0 -33
- package/src/components/SequenceEditor/SequenceEditor.tsx +0 -50
- package/src/components/SequenceEditor/index.ts +0 -5
- package/src/components/Timeline/Timeline.stories.tsx +0 -53
- package/src/components/Timeline/Timeline.tsx +0 -159
- package/src/hooks/chat-processor.ts +0 -260
- package/src/hooks/errors.ts +0 -8
- package/src/hooks/useResolveRef.ts +0 -33
- package/src/parser/filter-generator.test.ts +0 -32
- package/src/parser/filter-generator.ts +0 -74
- package/src/parser/index.ts +0 -7
- package/src/parser/query-parser.test.ts +0 -139
- package/src/parser/query-parser.ts +0 -199
- package/src/parser/types.ts +0 -34
- package/src/shims.d.ts +0 -8
- package/src/stories/Chat.stories.tsx +0 -317
- package/src/stories/components/BlueprintContainer.tsx +0 -34
- package/src/stories/components/ChatContainer.tsx +0 -80
- package/src/stories/components/GraphContainer.tsx +0 -118
- package/src/stories/components/LoggingContainer.tsx +0 -22
- package/src/stories/components/SurfaceContainer.tsx +0 -62
- package/src/stories/components/TasksContainer.tsx +0 -51
- package/src/stories/components/index.ts +0 -12
- package/src/stories/components/types.ts +0 -11
- package/src/stories/hooks/index.ts +0 -6
- package/src/stories/hooks/useMatcherExtension.ts +0 -45
- package/src/stories/testing/data.ts +0 -130
- package/src/stories/testing/index.ts +0 -6
- package/src/stories/testing/testing.tsx +0 -162
- package/src/testing/test-functions.ts +0 -16
- package/src/tools/function.ts +0 -49
- package/src/tools/index.ts +0 -6
- package/src/tools/openapi.test.ts +0 -219
- package/src/tools/openapi.ts +0 -341
- package/src/typings.d.ts +0 -9
- /package/dist/types/src/{stories/hooks → hooks}/useFlush.d.ts +0 -0
- /package/src/{stories/hooks → hooks}/useFlush.ts +0 -0
|
@@ -2,259 +2,147 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
|
-
import
|
|
9
|
-
import
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
import * as Fiber from 'effect/Fiber';
|
|
8
|
+
import * as Layer from 'effect/Layer';
|
|
9
|
+
import React, { type CSSProperties, useEffect, useMemo, useState } from 'react';
|
|
10
10
|
|
|
11
|
-
import { Obj } from '@dxos/echo';
|
|
12
11
|
import { ContextQueueService, DatabaseService } from '@dxos/functions';
|
|
13
12
|
import { faker } from '@dxos/random';
|
|
14
13
|
import { useQueue, useSpace } from '@dxos/react-client/echo';
|
|
15
14
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
|
|
15
|
+
import { Popover } from '@dxos/react-ui';
|
|
16
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
17
|
+
import { MarkdownStream } from '@dxos/react-ui-components';
|
|
18
|
+
import { EditorPreviewProvider, useEditorPreview } from '@dxos/react-ui-editor';
|
|
19
|
+
import { Card } from '@dxos/react-ui-stack';
|
|
20
|
+
import { render } from '@dxos/storybook-utils';
|
|
21
|
+
import { type Message, Organization, Person } from '@dxos/types';
|
|
22
|
+
|
|
23
|
+
import { createMessageGenerator } from '../../testing';
|
|
19
24
|
import { translations } from '../../translations';
|
|
20
25
|
|
|
21
|
-
import { renderObjectLink } from './ChatMessage';
|
|
22
26
|
import { ChatThread, type ChatThreadProps } from './ChatThread';
|
|
27
|
+
import { componentRegistry } from './registry';
|
|
28
|
+
import TEXT from './testing/thread.md?raw';
|
|
23
29
|
|
|
24
30
|
faker.seed(1);
|
|
25
31
|
|
|
26
|
-
|
|
32
|
+
type MessageGenerator = Effect.Effect<void, never, DatabaseService | ContextQueueService>;
|
|
33
|
+
|
|
34
|
+
type StoryProps = { generator?: MessageGenerator[]; delay?: number; wait?: boolean } & ChatThreadProps;
|
|
35
|
+
|
|
36
|
+
const DefaultStory = ({ generator = [], delay = 0, wait, ...props }: StoryProps) => {
|
|
27
37
|
const space = useSpace();
|
|
28
38
|
const queueDxn = useMemo(() => space?.queues.create().dxn, [space]);
|
|
29
|
-
const queue = useQueue<
|
|
39
|
+
const queue = useQueue<Message.Message>(queueDxn);
|
|
40
|
+
const [done, setDone] = useState(false);
|
|
41
|
+
|
|
42
|
+
// Generate messages.
|
|
30
43
|
useEffect(() => {
|
|
31
44
|
if (!space || !queue) {
|
|
32
45
|
return;
|
|
33
46
|
}
|
|
34
47
|
|
|
35
|
-
|
|
48
|
+
const fiber = Effect.runFork(
|
|
36
49
|
Effect.gen(function* () {
|
|
37
|
-
for (const step of
|
|
50
|
+
for (const step of generator) {
|
|
38
51
|
yield* step;
|
|
39
|
-
|
|
52
|
+
if (delay) {
|
|
53
|
+
yield* Effect.sleep(delay);
|
|
54
|
+
}
|
|
40
55
|
}
|
|
41
|
-
|
|
42
|
-
return queue;
|
|
56
|
+
setDone(true);
|
|
43
57
|
}).pipe(Effect.provide(Layer.mergeAll(DatabaseService.layer(space.db), ContextQueueService.layer(queue)))),
|
|
44
58
|
);
|
|
45
|
-
}, [space, queue]);
|
|
46
59
|
|
|
47
|
-
|
|
60
|
+
return () => {
|
|
61
|
+
void Effect.runPromise(Fiber.interrupt(fiber));
|
|
62
|
+
};
|
|
63
|
+
}, [space, queue, generator]);
|
|
64
|
+
|
|
65
|
+
if (wait && !done) {
|
|
48
66
|
return null;
|
|
49
67
|
}
|
|
50
68
|
|
|
51
69
|
return (
|
|
52
|
-
<
|
|
70
|
+
<EditorPreviewProvider onLookup={async ({ label, ref }) => ({ label, text: ref })}>
|
|
71
|
+
<ChatThread {...props} messages={queue?.objects} />
|
|
72
|
+
<PreviewCard />
|
|
73
|
+
</EditorPreviewProvider>
|
|
53
74
|
);
|
|
54
75
|
};
|
|
55
76
|
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
created: new Date().toISOString(),
|
|
59
|
-
sender: { role },
|
|
60
|
-
blocks,
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const MESSAGES: Effect.Effect<void, never, DatabaseService | ContextQueueService>[] = [
|
|
65
|
-
Effect.gen(function* () {
|
|
66
|
-
const { queue } = yield* ContextQueueService;
|
|
67
|
-
yield* Effect.promise(() =>
|
|
68
|
-
queue.append([
|
|
69
|
-
createMessage('user', [
|
|
70
|
-
{
|
|
71
|
-
_tag: 'text',
|
|
72
|
-
text: faker.lorem.sentence(5),
|
|
73
|
-
},
|
|
74
|
-
]),
|
|
75
|
-
]),
|
|
76
|
-
);
|
|
77
|
-
}),
|
|
78
|
-
|
|
79
|
-
Effect.gen(function* () {
|
|
80
|
-
const { queue } = yield* ContextQueueService;
|
|
81
|
-
yield* Effect.promise(() =>
|
|
82
|
-
queue.append([
|
|
83
|
-
createMessage('assistant', [
|
|
84
|
-
{
|
|
85
|
-
_tag: 'suggest',
|
|
86
|
-
text: 'Search...',
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
_tag: 'suggest',
|
|
90
|
-
text: faker.lorem.paragraphs(1),
|
|
91
|
-
},
|
|
92
|
-
]),
|
|
93
|
-
createMessage('assistant', [
|
|
94
|
-
{
|
|
95
|
-
_tag: 'text',
|
|
96
|
-
text: 'Select an option:',
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
_tag: 'select',
|
|
100
|
-
options: ['Option 1', 'Option 2', 'Option 3'],
|
|
101
|
-
},
|
|
102
|
-
]),
|
|
103
|
-
]),
|
|
104
|
-
);
|
|
105
|
-
}),
|
|
106
|
-
|
|
107
|
-
Effect.gen(function* () {
|
|
108
|
-
const { queue } = yield* ContextQueueService;
|
|
109
|
-
const { db } = yield* DatabaseService;
|
|
110
|
-
const obj1 = db.add(Obj.make(DataType.Organization, { name: 'DXOS' }));
|
|
111
|
-
const obj2 = db.add(Obj.make(DataType.Person, { fullName: 'Alice' }));
|
|
112
|
-
const obj3 = db.add(Obj.make(DataType.Person, { fullName: 'Bob' }));
|
|
113
|
-
const obj4 = db.add(Obj.make(DataType.Person, { fullName: 'Charlie' }));
|
|
114
|
-
yield* Effect.promise(() =>
|
|
115
|
-
queue.append([
|
|
116
|
-
createMessage('assistant', [
|
|
117
|
-
// Inline tag.
|
|
118
|
-
{
|
|
119
|
-
_tag: 'text',
|
|
120
|
-
text: [faker.lorem.paragraph(), renderObjectLink(obj1), faker.lorem.paragraph()].join(' '),
|
|
121
|
-
},
|
|
122
|
-
// Inline cards.
|
|
123
|
-
...[obj2, obj3, obj4].map(
|
|
124
|
-
(obj) =>
|
|
125
|
-
({
|
|
126
|
-
_tag: 'text',
|
|
127
|
-
text: renderObjectLink(obj),
|
|
128
|
-
}) satisfies ContentBlock.Text,
|
|
129
|
-
),
|
|
130
|
-
]),
|
|
131
|
-
]),
|
|
132
|
-
);
|
|
133
|
-
}),
|
|
134
|
-
|
|
135
|
-
Effect.gen(function* () {
|
|
136
|
-
const { queue } = yield* ContextQueueService;
|
|
137
|
-
yield* Effect.promise(() =>
|
|
138
|
-
queue.append([
|
|
139
|
-
createMessage('assistant', [
|
|
140
|
-
{
|
|
141
|
-
_tag: 'text',
|
|
142
|
-
text: faker.lorem.paragraphs(1),
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
_tag: 'toolkit',
|
|
146
|
-
},
|
|
147
|
-
]),
|
|
148
|
-
]),
|
|
149
|
-
);
|
|
150
|
-
}),
|
|
151
|
-
|
|
152
|
-
Effect.gen(function* () {
|
|
153
|
-
const { queue } = yield* ContextQueueService;
|
|
154
|
-
yield* Effect.promise(() =>
|
|
155
|
-
queue.append([
|
|
156
|
-
createMessage('assistant', [
|
|
157
|
-
{
|
|
158
|
-
_tag: 'text',
|
|
159
|
-
disposition: 'cot',
|
|
160
|
-
text: Array.from({ length: faker.number.int({ min: 3, max: 5 }) })
|
|
161
|
-
.map((_, idx) => `${idx + 1}. ${faker.lorem.paragraph()}`)
|
|
162
|
-
.join('\n'),
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
_tag: 'toolCall',
|
|
166
|
-
toolCallId: '1234',
|
|
167
|
-
name: 'search',
|
|
168
|
-
input: {},
|
|
169
|
-
},
|
|
170
|
-
]),
|
|
171
|
-
createMessage('user', [
|
|
172
|
-
{
|
|
173
|
-
_tag: 'toolResult',
|
|
174
|
-
toolCallId: '1234',
|
|
175
|
-
name: 'search',
|
|
176
|
-
result: 'This is a tool result.',
|
|
177
|
-
},
|
|
178
|
-
]),
|
|
179
|
-
]),
|
|
180
|
-
);
|
|
181
|
-
}),
|
|
77
|
+
const PreviewCard = () => {
|
|
78
|
+
const { target } = useEditorPreview('PreviewCard');
|
|
182
79
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
_tag: 'toolResult',
|
|
198
|
-
toolCallId: '4567',
|
|
199
|
-
name: 'create',
|
|
200
|
-
result: 'This is a tool result.',
|
|
201
|
-
},
|
|
202
|
-
]),
|
|
203
|
-
createMessage('assistant', [
|
|
204
|
-
{
|
|
205
|
-
_tag: 'text',
|
|
206
|
-
text: Array.from({ length: faker.number.int({ min: 2, max: 3 }) })
|
|
207
|
-
.map(() => faker.lorem.paragraphs())
|
|
208
|
-
.join('\n\n'),
|
|
209
|
-
},
|
|
210
|
-
]),
|
|
211
|
-
]),
|
|
212
|
-
);
|
|
213
|
-
}),
|
|
214
|
-
|
|
215
|
-
Effect.gen(function* () {
|
|
216
|
-
const { queue } = yield* ContextQueueService;
|
|
217
|
-
yield* Effect.promise(() =>
|
|
218
|
-
queue.append([
|
|
219
|
-
createMessage('assistant', [
|
|
220
|
-
{
|
|
221
|
-
_tag: 'text',
|
|
222
|
-
text: faker.lorem.paragraphs(2),
|
|
223
|
-
},
|
|
224
|
-
]),
|
|
225
|
-
]),
|
|
226
|
-
);
|
|
227
|
-
}),
|
|
228
|
-
];
|
|
80
|
+
return (
|
|
81
|
+
<Popover.Portal>
|
|
82
|
+
<Popover.Content onOpenAutoFocus={(event) => event.preventDefault()}>
|
|
83
|
+
<Popover.Viewport>
|
|
84
|
+
<Card.SurfaceRoot role='card--popover'>
|
|
85
|
+
<Card.Heading>{target?.label}</Card.Heading>
|
|
86
|
+
{target && <Card.Text classNames='truncate line-clamp-3'>{target.text}</Card.Text>}
|
|
87
|
+
</Card.SurfaceRoot>
|
|
88
|
+
</Popover.Viewport>
|
|
89
|
+
<Popover.Arrow />
|
|
90
|
+
</Popover.Content>
|
|
91
|
+
</Popover.Portal>
|
|
92
|
+
);
|
|
93
|
+
};
|
|
229
94
|
|
|
230
95
|
const meta = {
|
|
231
96
|
title: 'plugins/plugin-assistant/ChatThread',
|
|
232
97
|
component: ChatThread,
|
|
233
|
-
render: render(
|
|
98
|
+
render: render(DefaultStory),
|
|
234
99
|
decorators: [
|
|
100
|
+
withTheme,
|
|
101
|
+
withLayout({ container: 'column' }),
|
|
235
102
|
withClientProvider({
|
|
236
103
|
createIdentity: true,
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
withTheme,
|
|
240
|
-
withLayout({
|
|
241
|
-
Container: ColumnContainer,
|
|
242
|
-
classNames: 'is-[40rem]',
|
|
104
|
+
createSpace: true,
|
|
105
|
+
types: [Organization.Organization, Person.Person],
|
|
243
106
|
}),
|
|
244
107
|
],
|
|
245
108
|
parameters: {
|
|
109
|
+
layout: 'fullscreen',
|
|
246
110
|
translations,
|
|
247
111
|
},
|
|
248
|
-
} satisfies Meta<
|
|
112
|
+
} satisfies Meta<StoryProps>;
|
|
249
113
|
|
|
250
114
|
export default meta;
|
|
251
115
|
|
|
252
|
-
type Story = StoryObj<
|
|
116
|
+
type Story = StoryObj<StoryProps>;
|
|
253
117
|
|
|
254
|
-
export const Default = {
|
|
118
|
+
export const Default: Story = {
|
|
119
|
+
args: {
|
|
120
|
+
generator: createMessageGenerator(),
|
|
121
|
+
wait: true,
|
|
122
|
+
},
|
|
123
|
+
};
|
|
255
124
|
|
|
256
|
-
export const Delayed = {
|
|
125
|
+
export const Delayed: Story = {
|
|
257
126
|
args: {
|
|
258
|
-
|
|
127
|
+
generator: createMessageGenerator(),
|
|
128
|
+
delay: 1_000,
|
|
129
|
+
fadeIn: true,
|
|
130
|
+
cursor: false,
|
|
259
131
|
},
|
|
260
|
-
}
|
|
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
|
+
};
|
|
@@ -2,56 +2,86 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, { type CSSProperties, forwardRef, useMemo } from 'react';
|
|
5
|
+
import React, { type CSSProperties, forwardRef, useCallback, useEffect, useMemo } from 'react';
|
|
6
6
|
|
|
7
7
|
import { PublicKey } from '@dxos/keys';
|
|
8
8
|
import { type Identity } from '@dxos/react-client/halo';
|
|
9
|
-
import { type ThemedClassName } from '@dxos/react-ui';
|
|
10
|
-
import {
|
|
9
|
+
import { type ThemedClassName, useForwardedRef } from '@dxos/react-ui';
|
|
10
|
+
import { MarkdownStream, type MarkdownStreamController, type MarkdownStreamProps } from '@dxos/react-ui-components';
|
|
11
11
|
import { mx } from '@dxos/react-ui-theme';
|
|
12
|
-
import { type
|
|
12
|
+
import { type Message } from '@dxos/types';
|
|
13
13
|
import { keyToFallback } from '@dxos/util';
|
|
14
14
|
|
|
15
|
-
import {
|
|
16
|
-
|
|
15
|
+
import { type ChatEvent } from '../Chat';
|
|
16
|
+
|
|
17
|
+
import { blockToMarkdown, componentRegistry } from './registry';
|
|
18
|
+
import { MessageSyncer } from './sync';
|
|
17
19
|
|
|
18
20
|
export type ChatThreadProps = ThemedClassName<
|
|
19
21
|
{
|
|
20
22
|
identity?: Identity;
|
|
21
|
-
messages?:
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
messages?: Message.Message[];
|
|
24
|
+
error?: Error;
|
|
25
|
+
onEvent?: (event: ChatEvent) => void;
|
|
26
|
+
} & Pick<MarkdownStreamProps, 'cursor' | 'fadeIn' | 'debug'>
|
|
24
27
|
>;
|
|
25
28
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
// TODO(burdon): Memo thread position.
|
|
30
|
+
export const ChatThread = forwardRef<MarkdownStreamController, ChatThreadProps>(
|
|
31
|
+
(
|
|
32
|
+
{ classNames, identity, messages = [], error, cursor = false, fadeIn = true, debug = false, onEvent },
|
|
33
|
+
forwardedRef,
|
|
34
|
+
) => {
|
|
35
|
+
const controllerRef = useForwardedRef(forwardedRef);
|
|
36
|
+
const controller = controllerRef.current;
|
|
37
|
+
|
|
38
|
+
const userHue = useMemo(
|
|
39
|
+
() => identity?.profile?.data?.hue || keyToFallback(identity?.identityKey ?? PublicKey.random()).hue,
|
|
40
|
+
[identity],
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
// Show error.
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
controller?.scrollToBottom();
|
|
46
|
+
}, [controller, error]);
|
|
47
|
+
|
|
48
|
+
// Update document.
|
|
49
|
+
const syncer = useMemo(() => controller && new MessageSyncer(controller, blockToMarkdown), [controller]);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
const reset = syncer?.append(messages, true);
|
|
52
|
+
if (reset) {
|
|
53
|
+
controller?.scrollToBottom('instant');
|
|
40
54
|
}
|
|
41
|
-
}, [
|
|
55
|
+
}, [syncer, messages]);
|
|
56
|
+
|
|
57
|
+
// Event adapter.
|
|
58
|
+
const handleEvent = useCallback<NonNullable<MarkdownStreamProps['onEvent']>>(
|
|
59
|
+
({ type, value }) => {
|
|
60
|
+
switch (type) {
|
|
61
|
+
case 'submit': {
|
|
62
|
+
value && onEvent?.({ type, text: value });
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
[onEvent],
|
|
68
|
+
);
|
|
42
69
|
|
|
43
70
|
return (
|
|
44
|
-
<
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
{
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
71
|
+
<div
|
|
72
|
+
role='none'
|
|
73
|
+
className={mx('flex bs-full is-full justify-center overflow-hidden', classNames)}
|
|
74
|
+
style={{ '--user-fill': `var(--dx-${userHue}Fill)` } as CSSProperties}
|
|
75
|
+
>
|
|
76
|
+
<MarkdownStream
|
|
77
|
+
ref={controllerRef}
|
|
78
|
+
registry={componentRegistry}
|
|
79
|
+
cursor={cursor}
|
|
80
|
+
fadeIn={fadeIn}
|
|
81
|
+
debug={debug}
|
|
82
|
+
onEvent={handleEvent}
|
|
83
|
+
/>
|
|
84
|
+
</div>
|
|
55
85
|
);
|
|
56
86
|
},
|
|
57
87
|
);
|
|
@@ -2,38 +2,25 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React from 'react';
|
|
5
|
+
import React, { useMemo } from 'react';
|
|
6
6
|
|
|
7
7
|
import { type Space } from '@dxos/client/echo';
|
|
8
|
-
import { Obj
|
|
8
|
+
import { Obj } from '@dxos/echo';
|
|
9
9
|
import { type DXN } from '@dxos/keys';
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
import { useResolvedRef } from '../../hooks';
|
|
10
|
+
import { DxAnchor } from '@dxos/lit-ui/react';
|
|
13
11
|
|
|
14
12
|
export type ObjectLinkProps = {
|
|
15
13
|
space: Space;
|
|
16
14
|
dxn: DXN;
|
|
17
15
|
};
|
|
18
16
|
|
|
19
|
-
// TODO(burdon): Factor out.
|
|
20
17
|
export const ObjectLink = ({ space, dxn }: ObjectLinkProps) => {
|
|
21
|
-
const
|
|
22
|
-
const title = Obj.getLabel(object) ?? object?.id ?? dxn.toString();
|
|
18
|
+
const ref = useMemo(() => space.db.ref(dxn), [space, dxn.toString()]);
|
|
23
19
|
|
|
20
|
+
const title = Obj.getLabel(ref.target) ?? ref.target?.id ?? ref.dxn.toString();
|
|
24
21
|
return (
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
className={mx(
|
|
29
|
-
// TODO(burdon): Use style for tags.
|
|
30
|
-
'inline-flex items-center max-w-[16rem] px-1.5 overflow-hidden',
|
|
31
|
-
'border border-separator rounded whitespace-nowrap text-ellipsis text-primary-500 hover:text-primary-500 hover:border-primary-500 cursor-pointer',
|
|
32
|
-
)}
|
|
33
|
-
target='_blank'
|
|
34
|
-
rel='noopener noreferrer'
|
|
35
|
-
>
|
|
36
|
-
<span className='truncate'>{title}</span>
|
|
37
|
-
</a>
|
|
22
|
+
<DxAnchor rootclassname='dx-tag--anchor' refid={dxn.toString()}>
|
|
23
|
+
{title}
|
|
24
|
+
</DxAnchor>
|
|
38
25
|
);
|
|
39
26
|
};
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type ContentBlock, type Message } from '@dxos/types';
|
|
6
|
+
|
|
7
|
+
type Reducer<R, I> = (acc: R, value: I, idx: number) => R;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Reducer that collapses related message blocks into single messages.
|
|
11
|
+
* For example, combines tool request/response pairs into a single message.
|
|
12
|
+
*
|
|
13
|
+
* Typical order:
|
|
14
|
+
* - message 0
|
|
15
|
+
* - text
|
|
16
|
+
* - message 1
|
|
17
|
+
* - text
|
|
18
|
+
* - toolCall
|
|
19
|
+
* - summary
|
|
20
|
+
* - message 2
|
|
21
|
+
* - toolResult
|
|
22
|
+
* - message 3
|
|
23
|
+
* - text
|
|
24
|
+
* - summary
|
|
25
|
+
*
|
|
26
|
+
* Coverts to:
|
|
27
|
+
* - message 0
|
|
28
|
+
* - text
|
|
29
|
+
* - message 1
|
|
30
|
+
* - text
|
|
31
|
+
* - message 2
|
|
32
|
+
* - toolCall
|
|
33
|
+
* - toolResult
|
|
34
|
+
* - summary
|
|
35
|
+
* - message 3
|
|
36
|
+
* - text
|
|
37
|
+
* - summary
|
|
38
|
+
*/
|
|
39
|
+
export const reduceMessages: Reducer<
|
|
40
|
+
{
|
|
41
|
+
messages: Message.Message[];
|
|
42
|
+
current?: Message.Message;
|
|
43
|
+
toolBlock?: boolean;
|
|
44
|
+
assistantMessages?: Message.Message[];
|
|
45
|
+
},
|
|
46
|
+
Message.Message
|
|
47
|
+
> = ({ messages, current, toolBlock, assistantMessages = [] }, message) => {
|
|
48
|
+
// Treat tool calls as assistant messages.
|
|
49
|
+
let assistant = message?.sender.role === 'assistant';
|
|
50
|
+
let i = 0;
|
|
51
|
+
for (const block of message.blocks) {
|
|
52
|
+
switch (block._tag) {
|
|
53
|
+
// TODO(burdon): Preserve call tool title.
|
|
54
|
+
case 'toolCall': {
|
|
55
|
+
assistant = true;
|
|
56
|
+
if (!toolBlock) {
|
|
57
|
+
current = {
|
|
58
|
+
...message,
|
|
59
|
+
id: [message.id, i++].join('_'),
|
|
60
|
+
blocks: [block],
|
|
61
|
+
};
|
|
62
|
+
messages.push(current);
|
|
63
|
+
toolBlock = true;
|
|
64
|
+
} else {
|
|
65
|
+
current!.blocks.push(block);
|
|
66
|
+
}
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
case 'toolResult': {
|
|
71
|
+
assistant = true;
|
|
72
|
+
if (toolBlock) {
|
|
73
|
+
current!.blocks.push(block);
|
|
74
|
+
}
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
case 'summary': {
|
|
79
|
+
assistant = true;
|
|
80
|
+
if (toolBlock) {
|
|
81
|
+
current!.blocks.push(block);
|
|
82
|
+
} else {
|
|
83
|
+
const summary = reduceSummary([...assistantMessages, message]);
|
|
84
|
+
current!.blocks.push(summary);
|
|
85
|
+
}
|
|
86
|
+
break;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
default: {
|
|
90
|
+
assistant = message.sender.role === 'assistant';
|
|
91
|
+
current = {
|
|
92
|
+
...message,
|
|
93
|
+
id: [message.id, i++].join('_'),
|
|
94
|
+
blocks: [block],
|
|
95
|
+
};
|
|
96
|
+
messages.push(current);
|
|
97
|
+
toolBlock = false;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return {
|
|
104
|
+
messages,
|
|
105
|
+
current,
|
|
106
|
+
toolBlock,
|
|
107
|
+
assistantMessages: assistant ? [...assistantMessages, message] : undefined,
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Accumulate token counts from all summary blocks in pending messages.
|
|
113
|
+
*/
|
|
114
|
+
const reduceSummary = (messages: Message.Message[]): ContentBlock.Summary => {
|
|
115
|
+
let start: number | undefined;
|
|
116
|
+
return messages.reduce<ContentBlock.Summary>(
|
|
117
|
+
(acc, msg) => {
|
|
118
|
+
const time = new Date(msg.created).getTime();
|
|
119
|
+
if (!start) {
|
|
120
|
+
start = time;
|
|
121
|
+
}
|
|
122
|
+
msg.blocks.forEach((block) => {
|
|
123
|
+
switch (block._tag) {
|
|
124
|
+
case 'toolCall': {
|
|
125
|
+
acc.toolCalls = (acc.toolCalls ?? 0) + 1;
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
case 'summary': {
|
|
129
|
+
acc.model = block.model;
|
|
130
|
+
if (block.usage) {
|
|
131
|
+
acc.message = block.message;
|
|
132
|
+
acc.usage = {
|
|
133
|
+
inputTokens: (acc.usage?.inputTokens ?? 0) + (block.usage.inputTokens ?? 0),
|
|
134
|
+
outputTokens: (acc.usage?.outputTokens ?? 0) + (block.usage.outputTokens ?? 0),
|
|
135
|
+
totalTokens: (acc.usage?.totalTokens ?? 0) + (block.usage.totalTokens ?? 0),
|
|
136
|
+
};
|
|
137
|
+
acc.duration = time - (start ?? time);
|
|
138
|
+
}
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
return acc;
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
_tag: 'summary',
|
|
148
|
+
duration: 0,
|
|
149
|
+
} satisfies ContentBlock.Summary,
|
|
150
|
+
);
|
|
151
|
+
};
|