@dxos/plugin-assistant 0.8.3 → 0.8.4-main.c1de068
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/ChatContainer-M3IHQLRS.mjs +54 -0
- package/dist/lib/browser/ChatContainer-M3IHQLRS.mjs.map +7 -0
- package/dist/lib/browser/ChatDialog-X6VN6QZI.mjs +72 -0
- package/dist/lib/browser/ChatDialog-X6VN6QZI.mjs.map +7 -0
- package/dist/lib/browser/SequenceContainer-3UDVKWPA.mjs +162 -0
- package/dist/lib/browser/SequenceContainer-3UDVKWPA.mjs.map +7 -0
- package/dist/lib/browser/{TemplateContainer-QQHVOTSI.mjs → TemplateContainer-RPJ2LBOB.mjs} +5 -6
- package/dist/lib/browser/TemplateContainer-RPJ2LBOB.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-E4H5DCOJ.mjs → app-graph-builder-JTXBKE7O.mjs} +34 -36
- package/dist/lib/browser/app-graph-builder-JTXBKE7O.mjs.map +7 -0
- package/dist/lib/browser/chunk-AEAEKWOC.mjs +98 -0
- package/dist/lib/browser/chunk-AEAEKWOC.mjs.map +7 -0
- package/dist/lib/browser/{chunk-BI6AHRNJ.mjs → chunk-EQDW6BYQ.mjs} +19 -68
- package/dist/lib/browser/chunk-EQDW6BYQ.mjs.map +7 -0
- package/dist/lib/{node/chunk-P74TWGMG.cjs → browser/chunk-FDCJSQYF.mjs} +10 -14
- package/dist/lib/{node-esm/chunk-BB2TAT4P.mjs.map → browser/chunk-FDCJSQYF.mjs.map} +1 -1
- package/dist/lib/browser/chunk-JQBVLTM5.mjs +158 -0
- package/dist/lib/browser/chunk-JQBVLTM5.mjs.map +7 -0
- package/dist/lib/browser/chunk-OWY4CUQY.mjs +2245 -0
- package/dist/lib/browser/chunk-OWY4CUQY.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +87 -119
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-resolver-5RMMCMXG.mjs +60 -0
- package/dist/lib/browser/intent-resolver-5RMMCMXG.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-LXCNUSZN.mjs → react-surface-66VY37YQ.mjs} +42 -51
- package/dist/lib/browser/react-surface-66VY37YQ.mjs.map +7 -0
- package/dist/lib/browser/{settings-XRHXVWGB.mjs → settings-2DGP3UTS.mjs} +6 -6
- package/dist/lib/browser/settings-2DGP3UTS.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +4 -20
- package/dist/lib/node-esm/ChatContainer-VZT74PO2.mjs +55 -0
- package/dist/lib/node-esm/ChatContainer-VZT74PO2.mjs.map +7 -0
- package/dist/lib/node-esm/ChatDialog-RJ6FDX4Q.mjs +73 -0
- package/dist/lib/node-esm/ChatDialog-RJ6FDX4Q.mjs.map +7 -0
- package/dist/lib/node-esm/SequenceContainer-RQQH5XOC.mjs +163 -0
- package/dist/lib/node-esm/SequenceContainer-RQQH5XOC.mjs.map +7 -0
- package/dist/lib/node-esm/{TemplateContainer-SOEWY2ZN.mjs → TemplateContainer-A3NAQCZE.mjs} +5 -6
- package/dist/lib/node-esm/TemplateContainer-A3NAQCZE.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-3SY5MBIK.mjs → app-graph-builder-OWSOXFTD.mjs} +34 -36
- package/dist/lib/node-esm/app-graph-builder-OWSOXFTD.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-OYN6HLXZ.mjs → chunk-2XL6MNPE.mjs} +44 -33
- package/dist/lib/node-esm/chunk-2XL6MNPE.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-BISJDTBK.mjs +159 -0
- package/dist/lib/node-esm/chunk-BISJDTBK.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-UCOFKNKN.mjs → chunk-E33DNNDW.mjs} +19 -68
- package/dist/lib/node-esm/chunk-E33DNNDW.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-QN2H2EHV.mjs +41 -0
- package/dist/lib/{browser/chunk-XOZ7YMO3.mjs.map → node-esm/chunk-QN2H2EHV.mjs.map} +1 -1
- package/dist/lib/node-esm/chunk-SENTQAEO.mjs +2246 -0
- package/dist/lib/node-esm/chunk-SENTQAEO.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +87 -119
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intent-resolver-YPPYELY3.mjs +61 -0
- package/dist/lib/node-esm/intent-resolver-YPPYELY3.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-7HA5EDWY.mjs → react-surface-RJMRBR2M.mjs} +42 -51
- package/dist/lib/node-esm/react-surface-RJMRBR2M.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-5IAY6BT4.mjs → settings-47RYZOU4.mjs} +6 -6
- package/dist/lib/node-esm/settings-47RYZOU4.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +4 -20
- 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/index.d.ts +1 -3
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +2 -2
- 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/components/AssistantSettings/AssistantSettings.d.ts +2 -2
- package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -1
- package/dist/types/src/components/Chat/Chat.d.ts +47 -0
- package/dist/types/src/components/Chat/Chat.d.ts.map +1 -0
- package/dist/types/src/components/Chat/events.d.ts +30 -0
- package/dist/types/src/components/Chat/events.d.ts.map +1 -0
- package/dist/types/src/components/Chat/index.d.ts +3 -0
- package/dist/types/src/components/Chat/index.d.ts.map +1 -0
- package/dist/types/src/components/ChatContainer.d.ts +6 -6
- package/dist/types/src/components/ChatContainer.d.ts.map +1 -1
- package/dist/types/src/components/ChatDialog.d.ts +8 -0
- package/dist/types/src/components/ChatDialog.d.ts.map +1 -0
- package/dist/types/src/components/ChatPrompt/ChatActions.d.ts +11 -0
- package/dist/types/src/components/ChatPrompt/ChatActions.d.ts.map +1 -0
- package/dist/types/src/components/ChatPrompt/ChatOptionsMenu.d.ts +9 -0
- package/dist/types/src/components/ChatPrompt/ChatOptionsMenu.d.ts.map +1 -0
- package/dist/types/src/components/ChatPrompt/ChatPresets.d.ts +11 -0
- package/dist/types/src/components/ChatPrompt/ChatPresets.d.ts.map +1 -0
- package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts +11 -0
- package/dist/types/src/components/ChatPrompt/ChatReferences.d.ts.map +1 -0
- package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts +8 -0
- package/dist/types/src/components/ChatPrompt/ChatStatusIndicator.d.ts.map +1 -0
- package/dist/types/src/components/ChatPrompt/index.d.ts +6 -0
- package/dist/types/src/components/ChatPrompt/index.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/ChatMessage.d.ts +17 -0
- package/dist/types/src/components/ChatThread/ChatMessage.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/ChatThread.d.ts +19 -0
- package/dist/types/src/components/ChatThread/ChatThread.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts +241 -0
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/ToolBlock.d.ts +19 -0
- package/dist/types/src/components/ChatThread/ToolBlock.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/index.d.ts +2 -0
- package/dist/types/src/components/ChatThread/index.d.ts.map +1 -0
- package/dist/types/src/components/{Thread → ChatThread}/reducer.d.ts +4 -4
- package/dist/types/src/components/ChatThread/reducer.d.ts.map +1 -0
- package/dist/types/src/components/PromptSettings.d.ts +2 -2
- package/dist/types/src/components/PromptSettings.d.ts.map +1 -1
- package/dist/types/src/components/SequenceContainer.d.ts +8 -0
- package/dist/types/src/components/SequenceContainer.d.ts.map +1 -0
- package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts +13 -0
- package/dist/types/src/components/SequenceEditor/SequenceEditor.d.ts.map +1 -0
- package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts +8 -0
- package/dist/types/src/components/SequenceEditor/SequenceEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/SequenceEditor/index.d.ts +2 -0
- package/dist/types/src/components/SequenceEditor/index.d.ts.map +1 -0
- package/dist/types/src/components/TemplateContainer.d.ts +5 -5
- package/dist/types/src/components/TemplateContainer.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +2 -2
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +3 -3
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +3 -3
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +1 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.d.ts +11 -4
- package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +6 -12
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/events.d.ts.map +1 -1
- package/dist/types/src/hooks/{processor.d.ts → chat-processor.d.ts} +36 -22
- package/dist/types/src/hooks/chat-processor.d.ts.map +1 -0
- package/dist/types/src/hooks/chat-processor.test.d.ts +2 -0
- package/dist/types/src/hooks/chat-processor.test.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +5 -5
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/presets.d.ts +13 -0
- package/dist/types/src/hooks/presets.d.ts.map +1 -0
- package/dist/types/src/hooks/useBlueprints.d.ts +9 -0
- package/dist/types/src/hooks/useBlueprints.d.ts.map +1 -0
- package/dist/types/src/hooks/useChatProcessor.d.ts +20 -8
- package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatServices.d.ts +14 -0
- package/dist/types/src/hooks/useChatServices.d.ts.map +1 -0
- package/dist/types/src/hooks/useReferencesProvider.d.ts +7 -0
- package/dist/types/src/hooks/useReferencesProvider.d.ts.map +1 -0
- package/dist/types/src/parser/index.d.ts +1 -1
- package/dist/types/src/parser/index.d.ts.map +1 -1
- package/dist/types/src/queue-logger.d.ts +5 -5
- package/dist/types/src/queue-logger.d.ts.map +1 -1
- package/dist/types/src/stories/Chat.stories.d.ts +249 -0
- package/dist/types/src/stories/Chat.stories.d.ts.map +1 -0
- 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-sequence.d.ts +8 -0
- package/dist/types/src/testing/test-sequence.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +77 -113
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +1 -3
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +88 -0
- package/dist/types/src/types/schema.d.ts.map +1 -0
- package/dist/types/src/types/service.d.ts +9 -9
- package/dist/types/src/types/service.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +80 -74
- package/src/AssistantPlugin.tsx +20 -47
- package/src/capabilities/app-graph-builder.ts +35 -30
- package/src/capabilities/index.ts +0 -3
- package/src/capabilities/intent-resolver.ts +27 -14
- package/src/capabilities/react-surface.tsx +38 -37
- package/src/capabilities/settings.ts +3 -3
- package/src/components/AssistantSettings/AssistantSettings.tsx +4 -4
- package/src/components/Chat/Chat.tsx +388 -0
- package/src/components/Chat/events.ts +50 -0
- package/src/components/Chat/index.ts +7 -0
- package/src/components/ChatContainer.tsx +26 -20
- package/src/components/ChatDialog.tsx +64 -0
- package/src/components/ChatPrompt/ChatActions.tsx +71 -0
- package/src/components/ChatPrompt/ChatOptionsMenu.tsx +52 -0
- package/src/components/ChatPrompt/ChatPresets.tsx +28 -0
- package/src/components/ChatPrompt/ChatReferences.tsx +53 -0
- package/src/components/ChatPrompt/ChatStatusIndicator.tsx +39 -0
- package/src/components/ChatPrompt/index.ts +9 -0
- package/src/components/ChatThread/ChatMessage.tsx +268 -0
- package/src/components/ChatThread/ChatThread.stories.tsx +143 -0
- package/src/components/ChatThread/ChatThread.tsx +57 -0
- package/src/components/{Thread/ToolInvocations.tsx → ChatThread/ToolBlock.tsx} +36 -21
- package/src/{experimental/transcription → components/ChatThread}/index.ts +2 -0
- package/src/components/{Thread → ChatThread}/reducer.ts +14 -14
- package/src/components/PromptSettings.tsx +43 -45
- package/src/components/SequenceContainer.tsx +132 -0
- package/src/components/SequenceEditor/SequenceEditor.stories.tsx +32 -0
- package/src/components/{BlueprintEditor/BlueprintEditor.tsx → SequenceEditor/SequenceEditor.tsx} +7 -7
- package/src/components/{AmbientDialog → SequenceEditor}/index.ts +1 -1
- package/src/components/TemplateContainer.tsx +8 -7
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +28 -33
- package/src/components/TemplateEditor/TemplateEditor.tsx +32 -19
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +15 -15
- package/src/components/TemplateEditor/TemplateForm.tsx +47 -55
- package/src/components/Toolbox/Toolbox.stories.tsx +5 -6
- package/src/components/Toolbox/Toolbox.tsx +60 -4
- package/src/components/index.ts +4 -5
- package/src/events.ts +2 -2
- package/src/hooks/{processor.test.ts → chat-processor.test.ts} +3 -2
- package/src/hooks/chat-processor.ts +314 -0
- package/src/hooks/index.ts +5 -5
- package/src/hooks/presets.ts +52 -0
- package/src/hooks/useBlueprints.ts +57 -0
- package/src/hooks/useChatProcessor.ts +143 -0
- package/src/hooks/useChatServices.ts +91 -0
- package/src/hooks/{useContextProvider.ts → useReferencesProvider.ts} +14 -14
- package/src/parser/index.ts +1 -1
- package/src/queue-logger.ts +6 -6
- package/src/stories/Chat.stories.tsx +378 -0
- package/src/testing/index.ts +1 -1
- package/src/testing/test-functions.ts +1 -1
- package/src/testing/test-sequence.ts +51 -0
- package/src/tools/openapi.test.ts +11 -11
- package/src/translations.ts +43 -23
- package/src/types/index.ts +1 -3
- package/src/types/schema.ts +95 -0
- package/dist/lib/browser/AssistantDialog-MQOOR364.mjs +0 -47
- package/dist/lib/browser/AssistantDialog-MQOOR364.mjs.map +0 -7
- package/dist/lib/browser/BlueprintContainer-AT5Y7EXG.mjs +0 -321
- package/dist/lib/browser/BlueprintContainer-AT5Y7EXG.mjs.map +0 -7
- package/dist/lib/browser/ChatContainer-C2NEAS3A.mjs +0 -40
- package/dist/lib/browser/ChatContainer-C2NEAS3A.mjs.map +0 -7
- package/dist/lib/browser/TemplateContainer-QQHVOTSI.mjs.map +0 -7
- package/dist/lib/browser/ai-client-MK2ZZII2.mjs +0 -39
- package/dist/lib/browser/ai-client-MK2ZZII2.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-E4H5DCOJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-AAOKC2JN.mjs +0 -208
- package/dist/lib/browser/chunk-AAOKC2JN.mjs.map +0 -7
- package/dist/lib/browser/chunk-BI6AHRNJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-JO4W3MF7.mjs +0 -2101
- package/dist/lib/browser/chunk-JO4W3MF7.mjs.map +0 -7
- package/dist/lib/browser/chunk-JQFUME3B.mjs +0 -87
- package/dist/lib/browser/chunk-JQFUME3B.mjs.map +0 -7
- package/dist/lib/browser/chunk-MEGMOFJB.mjs +0 -16
- package/dist/lib/browser/chunk-MEGMOFJB.mjs.map +0 -7
- package/dist/lib/browser/chunk-Q6UZ4F3H.mjs +0 -96
- package/dist/lib/browser/chunk-Q6UZ4F3H.mjs.map +0 -7
- package/dist/lib/browser/chunk-UE3IZ4PN.mjs +0 -15
- package/dist/lib/browser/chunk-UE3IZ4PN.mjs.map +0 -7
- package/dist/lib/browser/chunk-XOZ7YMO3.mjs +0 -20
- package/dist/lib/browser/intent-resolver-3UICTGPM.mjs +0 -43
- package/dist/lib/browser/intent-resolver-3UICTGPM.mjs.map +0 -7
- package/dist/lib/browser/react-surface-LXCNUSZN.mjs.map +0 -7
- package/dist/lib/browser/settings-XRHXVWGB.mjs.map +0 -7
- package/dist/lib/node/AssistantDialog-AN4Z6YUV.cjs +0 -73
- package/dist/lib/node/AssistantDialog-AN4Z6YUV.cjs.map +0 -7
- package/dist/lib/node/BlueprintContainer-NOWLDYCZ.cjs +0 -344
- package/dist/lib/node/BlueprintContainer-NOWLDYCZ.cjs.map +0 -7
- package/dist/lib/node/ChatContainer-VKYBQHUB.cjs +0 -68
- package/dist/lib/node/ChatContainer-VKYBQHUB.cjs.map +0 -7
- package/dist/lib/node/TemplateContainer-JZF2DCCG.cjs +0 -58
- package/dist/lib/node/TemplateContainer-JZF2DCCG.cjs.map +0 -7
- package/dist/lib/node/ai-client-7HNSMUMT.cjs +0 -53
- package/dist/lib/node/ai-client-7HNSMUMT.cjs.map +0 -7
- package/dist/lib/node/app-graph-builder-PPR5B5KU.cjs +0 -235
- package/dist/lib/node/app-graph-builder-PPR5B5KU.cjs.map +0 -7
- package/dist/lib/node/chunk-4EEWTDQK.cjs +0 -117
- package/dist/lib/node/chunk-4EEWTDQK.cjs.map +0 -7
- package/dist/lib/node/chunk-FUAGEO7Q.cjs +0 -52
- package/dist/lib/node/chunk-FUAGEO7Q.cjs.map +0 -7
- package/dist/lib/node/chunk-HRNIUYVQ.cjs +0 -128
- package/dist/lib/node/chunk-HRNIUYVQ.cjs.map +0 -7
- package/dist/lib/node/chunk-IKZBMHSW.cjs +0 -184
- package/dist/lib/node/chunk-IKZBMHSW.cjs.map +0 -7
- package/dist/lib/node/chunk-LMDJEGZ2.cjs +0 -233
- package/dist/lib/node/chunk-LMDJEGZ2.cjs.map +0 -7
- package/dist/lib/node/chunk-NIDICM57.cjs +0 -2080
- package/dist/lib/node/chunk-NIDICM57.cjs.map +0 -7
- package/dist/lib/node/chunk-P74TWGMG.cjs.map +0 -7
- package/dist/lib/node/chunk-QGPWY6GW.cjs +0 -34
- package/dist/lib/node/chunk-QGPWY6GW.cjs.map +0 -7
- package/dist/lib/node/index.cjs +0 -289
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-QSWGTKON.cjs +0 -58
- package/dist/lib/node/intent-resolver-QSWGTKON.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/lib/node/react-surface-D3NBYRZ6.cjs +0 -172
- package/dist/lib/node/react-surface-D3NBYRZ6.cjs.map +0 -7
- package/dist/lib/node/settings-2JXLKYGE.cjs +0 -36
- package/dist/lib/node/settings-2JXLKYGE.cjs.map +0 -7
- package/dist/lib/node/types/index.cjs +0 -54
- package/dist/lib/node/types/index.cjs.map +0 -7
- package/dist/lib/node-esm/AssistantDialog-6WEMLUPU.mjs +0 -48
- package/dist/lib/node-esm/AssistantDialog-6WEMLUPU.mjs.map +0 -7
- package/dist/lib/node-esm/BlueprintContainer-STOJAVML.mjs +0 -322
- package/dist/lib/node-esm/BlueprintContainer-STOJAVML.mjs.map +0 -7
- package/dist/lib/node-esm/ChatContainer-3MVBTUJN.mjs +0 -41
- package/dist/lib/node-esm/ChatContainer-3MVBTUJN.mjs.map +0 -7
- package/dist/lib/node-esm/TemplateContainer-SOEWY2ZN.mjs.map +0 -7
- package/dist/lib/node-esm/ai-client-XGZBJ6BE.mjs +0 -40
- package/dist/lib/node-esm/ai-client-XGZBJ6BE.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-3SY5MBIK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-34EX6E5Q.mjs +0 -18
- package/dist/lib/node-esm/chunk-34EX6E5Q.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-3UEZLJ2V.mjs +0 -16
- package/dist/lib/node-esm/chunk-3UEZLJ2V.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BB2TAT4P.mjs +0 -22
- package/dist/lib/node-esm/chunk-CDAILLCU.mjs +0 -98
- package/dist/lib/node-esm/chunk-CDAILLCU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-J6UXXZGJ.mjs +0 -209
- package/dist/lib/node-esm/chunk-J6UXXZGJ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-OD574YIU.mjs +0 -2102
- package/dist/lib/node-esm/chunk-OD574YIU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-OYN6HLXZ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UCOFKNKN.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-E6MXTYAU.mjs +0 -44
- package/dist/lib/node-esm/intent-resolver-E6MXTYAU.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-7HA5EDWY.mjs.map +0 -7
- package/dist/lib/node-esm/settings-5IAY6BT4.mjs.map +0 -7
- package/dist/types/src/capabilities/ai-client.d.ts +0 -5
- package/dist/types/src/capabilities/ai-client.d.ts.map +0 -1
- package/dist/types/src/capabilities/capabilities.d.ts +0 -6
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts +0 -10
- package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts.map +0 -1
- package/dist/types/src/components/AmbientDialog/AmbientDialog.stories.d.ts +0 -8
- package/dist/types/src/components/AmbientDialog/AmbientDialog.stories.d.ts.map +0 -1
- package/dist/types/src/components/AmbientDialog/index.d.ts +0 -2
- package/dist/types/src/components/AmbientDialog/index.d.ts.map +0 -1
- package/dist/types/src/components/AssistantDialog.d.ts +0 -7
- package/dist/types/src/components/AssistantDialog.d.ts.map +0 -1
- package/dist/types/src/components/BlueprintContainer.d.ts +0 -9
- package/dist/types/src/components/BlueprintContainer.d.ts.map +0 -1
- package/dist/types/src/components/BlueprintEditor/BlueprintEditor.d.ts +0 -13
- package/dist/types/src/components/BlueprintEditor/BlueprintEditor.d.ts.map +0 -1
- package/dist/types/src/components/BlueprintEditor/BlueprintEditor.stories.d.ts +0 -8
- package/dist/types/src/components/BlueprintEditor/BlueprintEditor.stories.d.ts.map +0 -1
- package/dist/types/src/components/BlueprintEditor/index.d.ts +0 -2
- package/dist/types/src/components/BlueprintEditor/index.d.ts.map +0 -1
- package/dist/types/src/components/Prompt/Prompt.d.ts +0 -23
- package/dist/types/src/components/Prompt/Prompt.d.ts.map +0 -1
- package/dist/types/src/components/Prompt/Prompt.stories.d.ts +0 -13
- package/dist/types/src/components/Prompt/Prompt.stories.d.ts.map +0 -1
- package/dist/types/src/components/Prompt/PromptBar.d.ts +0 -16
- package/dist/types/src/components/Prompt/PromptBar.d.ts.map +0 -1
- package/dist/types/src/components/Prompt/PromptBar.stories.d.ts +0 -9
- package/dist/types/src/components/Prompt/PromptBar.stories.d.ts.map +0 -1
- package/dist/types/src/components/Prompt/autocomplete.d.ts +0 -25
- package/dist/types/src/components/Prompt/autocomplete.d.ts.map +0 -1
- package/dist/types/src/components/Prompt/index.d.ts +0 -3
- package/dist/types/src/components/Prompt/index.d.ts.map +0 -1
- package/dist/types/src/components/Prompt/references.d.ts +0 -30
- package/dist/types/src/components/Prompt/references.d.ts.map +0 -1
- package/dist/types/src/components/Thread/Thread.d.ts +0 -28
- package/dist/types/src/components/Thread/Thread.d.ts.map +0 -1
- package/dist/types/src/components/Thread/Thread.stories.d.ts +0 -11
- package/dist/types/src/components/Thread/Thread.stories.d.ts.map +0 -1
- package/dist/types/src/components/Thread/ThreadContainer.d.ts +0 -13
- package/dist/types/src/components/Thread/ThreadContainer.d.ts.map +0 -1
- package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts +0 -16
- package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts.map +0 -1
- package/dist/types/src/components/Thread/ThreadMessage.d.ts +0 -16
- package/dist/types/src/components/Thread/ThreadMessage.d.ts.map +0 -1
- package/dist/types/src/components/Thread/ToolInvocations.d.ts +0 -13
- package/dist/types/src/components/Thread/ToolInvocations.d.ts.map +0 -1
- package/dist/types/src/components/Thread/index.d.ts +0 -3
- package/dist/types/src/components/Thread/index.d.ts.map +0 -1
- package/dist/types/src/components/Thread/reducer.d.ts.map +0 -1
- package/dist/types/src/experimental/transcription/index.d.ts +0 -1
- package/dist/types/src/experimental/transcription/index.d.ts.map +0 -1
- package/dist/types/src/hooks/processor.d.ts.map +0 -1
- package/dist/types/src/hooks/processor.test.d.ts +0 -2
- package/dist/types/src/hooks/processor.test.d.ts.map +0 -1
- package/dist/types/src/hooks/useContextProvider.d.ts +0 -17
- package/dist/types/src/hooks/useContextProvider.d.ts.map +0 -1
- package/dist/types/src/hooks/useMessageQueue.d.ts +0 -42
- package/dist/types/src/hooks/useMessageQueue.d.ts.map +0 -1
- package/dist/types/src/hooks/useServices.d.ts +0 -7
- package/dist/types/src/hooks/useServices.d.ts.map +0 -1
- package/dist/types/src/hooks/useTextInputEvents.d.ts +0 -13
- package/dist/types/src/hooks/useTextInputEvents.d.ts.map +0 -1
- package/dist/types/src/stories/Prompt.stories.d.ts +0 -8
- package/dist/types/src/stories/Prompt.stories.d.ts.map +0 -1
- package/dist/types/src/stories/Query.stories.d.ts +0 -19
- package/dist/types/src/stories/Query.stories.d.ts.map +0 -1
- package/dist/types/src/stories/Research.stories.d.ts +0 -15
- package/dist/types/src/stories/Research.stories.d.ts.map +0 -1
- package/dist/types/src/stories/test-data.d.ts +0 -3
- package/dist/types/src/stories/test-data.d.ts.map +0 -1
- package/dist/types/src/stories/testing.d.ts +0 -12
- package/dist/types/src/stories/testing.d.ts.map +0 -1
- package/dist/types/src/testing/test-blueprint.d.ts +0 -8
- package/dist/types/src/testing/test-blueprint.d.ts.map +0 -1
- package/dist/types/src/types/chat.d.ts +0 -23
- package/dist/types/src/types/chat.d.ts.map +0 -1
- package/dist/types/src/types/template.d.ts +0 -56
- package/dist/types/src/types/template.d.ts.map +0 -1
- package/dist/types/src/types/types.d.ts +0 -50
- package/dist/types/src/types/types.d.ts.map +0 -1
- package/src/capabilities/ai-client.ts +0 -42
- package/src/capabilities/capabilities.ts +0 -15
- package/src/components/AmbientDialog/AmbientDialog.stories.tsx +0 -84
- package/src/components/AmbientDialog/AmbientDialog.tsx +0 -117
- package/src/components/AssistantDialog.tsx +0 -37
- package/src/components/BlueprintContainer.tsx +0 -148
- package/src/components/BlueprintEditor/BlueprintEditor.stories.tsx +0 -32
- package/src/components/BlueprintEditor/index.ts +0 -5
- package/src/components/Prompt/Prompt.stories.tsx +0 -121
- package/src/components/Prompt/Prompt.tsx +0 -124
- package/src/components/Prompt/PromptBar.stories.tsx +0 -69
- package/src/components/Prompt/PromptBar.tsx +0 -105
- package/src/components/Prompt/autocomplete.ts +0 -218
- package/src/components/Prompt/index.ts +0 -6
- package/src/components/Prompt/references.ts +0 -180
- package/src/components/Thread/Thread.stories.tsx +0 -201
- package/src/components/Thread/Thread.tsx +0 -118
- package/src/components/Thread/ThreadContainer.stories.tsx +0 -283
- package/src/components/Thread/ThreadContainer.tsx +0 -105
- package/src/components/Thread/ThreadMessage.tsx +0 -234
- package/src/components/Thread/index.ts +0 -6
- package/src/hooks/processor.ts +0 -238
- package/src/hooks/useChatProcessor.tsx +0 -97
- package/src/hooks/useMessageQueue.ts +0 -22
- package/src/hooks/useServices.ts +0 -28
- package/src/hooks/useTextInputEvents.ts +0 -49
- package/src/stories/Prompt.stories.tsx +0 -60
- package/src/stories/Query.stories.tsx +0 -514
- package/src/stories/Research.stories.tsx +0 -482
- package/src/stories/test-data.ts +0 -128
- package/src/stories/testing.ts +0 -60
- package/src/testing/test-blueprint.ts +0 -58
- package/src/types/chat.ts +0 -32
- package/src/types/template.ts +0 -66
- package/src/types/types.ts +0 -48
|
@@ -2,36 +2,42 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React
|
|
5
|
+
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import { Capabilities,
|
|
8
|
-
import { type AssociatedArtifact } from '@dxos/
|
|
9
|
-
import {
|
|
7
|
+
import { Capabilities, useCapability } from '@dxos/app-framework';
|
|
8
|
+
import { type AssociatedArtifact } from '@dxos/blueprints';
|
|
9
|
+
import { getSpace } from '@dxos/client/echo';
|
|
10
10
|
import { StackItem } from '@dxos/react-ui-stack';
|
|
11
11
|
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
12
|
+
import { Chat } from './Chat';
|
|
13
|
+
import { useChatProcessor, useChatServices } from '../hooks';
|
|
14
|
+
import { meta } from '../meta';
|
|
15
|
+
import { type Assistant } from '../types';
|
|
15
16
|
|
|
16
17
|
export type ChatContainerProps = {
|
|
17
18
|
role: string;
|
|
18
|
-
chat:
|
|
19
|
-
|
|
19
|
+
chat: Assistant.Chat;
|
|
20
|
+
artifact?: AssociatedArtifact;
|
|
20
21
|
};
|
|
21
22
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
const
|
|
23
|
+
export const ChatContainer = ({ role, chat, artifact }: ChatContainerProps) => {
|
|
24
|
+
const space = getSpace(chat);
|
|
25
|
+
const settings = useCapability(Capabilities.SettingsStore).getStore<Assistant.Settings>(meta.id)?.value;
|
|
26
|
+
const services = useChatServices({ space });
|
|
27
|
+
const processor = useChatProcessor({ chat, services, settings });
|
|
28
|
+
if (!processor) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
26
31
|
|
|
32
|
+
// TODO(burdon): Add attention attributes.
|
|
27
33
|
return (
|
|
28
|
-
<StackItem.Content
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
<StackItem.Content classNames='container-max-width'>
|
|
35
|
+
<Chat.Root chat={chat} processor={processor} artifact={artifact}>
|
|
36
|
+
<Chat.Thread />
|
|
37
|
+
<div className='pbe-4 pis-2 pie-2'>
|
|
38
|
+
<Chat.Prompt classNames='border border-subduedSeparator rounded-md' />
|
|
39
|
+
</div>
|
|
40
|
+
</Chat.Root>
|
|
35
41
|
</StackItem.Content>
|
|
36
42
|
);
|
|
37
43
|
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useCallback, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { useCapability, Capabilities } from '@dxos/app-framework';
|
|
8
|
+
import { getSpace } from '@dxos/client/echo';
|
|
9
|
+
import { useTranslation } from '@dxos/react-ui';
|
|
10
|
+
import { ChatDialog as NativeChatDialog } from '@dxos/react-ui-chat';
|
|
11
|
+
|
|
12
|
+
import { Chat, type ChatRootProps } from './Chat';
|
|
13
|
+
import { useChatProcessor, useChatServices } from '../hooks';
|
|
14
|
+
import { meta } from '../meta';
|
|
15
|
+
import { type Assistant } from '../types';
|
|
16
|
+
|
|
17
|
+
export type ChatDialogProps = {
|
|
18
|
+
chat?: Assistant.Chat;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const ChatDialog = ({ chat }: ChatDialogProps) => {
|
|
22
|
+
const { t } = useTranslation(meta.id);
|
|
23
|
+
|
|
24
|
+
const space = getSpace(chat);
|
|
25
|
+
const settings = useCapability(Capabilities.SettingsStore).getStore<Assistant.Settings>(meta.id)?.value;
|
|
26
|
+
const services = useChatServices({ space });
|
|
27
|
+
const processor = useChatProcessor({ chat, services, settings });
|
|
28
|
+
|
|
29
|
+
// TODO(burdon): Refocus when open.
|
|
30
|
+
const [open, setOpen] = useState(true);
|
|
31
|
+
const [expanded, setExpanded] = useState(false);
|
|
32
|
+
const handleEvent = useCallback<NonNullable<ChatRootProps['onEvent']>>((event) => {
|
|
33
|
+
switch (event.type) {
|
|
34
|
+
case 'submit':
|
|
35
|
+
case 'thread-open':
|
|
36
|
+
setOpen(true);
|
|
37
|
+
setExpanded(true);
|
|
38
|
+
break;
|
|
39
|
+
case 'thread-close':
|
|
40
|
+
setOpen(false);
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}, []);
|
|
44
|
+
|
|
45
|
+
if (!chat || !processor) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<Chat.Root chat={chat} processor={processor} onEvent={handleEvent}>
|
|
51
|
+
<NativeChatDialog.Root open={open} expanded={expanded} onOpenChange={setOpen}>
|
|
52
|
+
<NativeChatDialog.Header title={t('assistant dialog title')} />
|
|
53
|
+
<NativeChatDialog.Content>
|
|
54
|
+
<Chat.Thread />
|
|
55
|
+
</NativeChatDialog.Content>
|
|
56
|
+
<NativeChatDialog.Footer>
|
|
57
|
+
<Chat.Prompt expandable />
|
|
58
|
+
</NativeChatDialog.Footer>
|
|
59
|
+
</NativeChatDialog.Root>
|
|
60
|
+
</Chat.Root>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export default ChatDialog;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { type PropsWithChildren } from 'react';
|
|
6
|
+
|
|
7
|
+
import { IconButton, type ThemedClassName, useTranslation } from '@dxos/react-ui';
|
|
8
|
+
import { mx } from '@dxos/react-ui-theme';
|
|
9
|
+
|
|
10
|
+
import { meta } from '../../meta';
|
|
11
|
+
import { type ChatEvent } from '../Chat';
|
|
12
|
+
|
|
13
|
+
export type ChatActionsProps = ThemedClassName<
|
|
14
|
+
PropsWithChildren<{
|
|
15
|
+
microphone?: boolean;
|
|
16
|
+
recording?: boolean;
|
|
17
|
+
processing?: boolean;
|
|
18
|
+
onEvent?: (event: ChatEvent) => void;
|
|
19
|
+
}>
|
|
20
|
+
>;
|
|
21
|
+
|
|
22
|
+
export const ChatActions = ({ classNames, children, microphone, recording, processing, onEvent }: ChatActionsProps) => {
|
|
23
|
+
const { t } = useTranslation(meta.id);
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div className={mx('flex items-center mie-1', classNames)}>
|
|
27
|
+
{children}
|
|
28
|
+
|
|
29
|
+
{(processing && (
|
|
30
|
+
<IconButton
|
|
31
|
+
disabled={!processing}
|
|
32
|
+
classNames='px-1.5'
|
|
33
|
+
variant='ghost'
|
|
34
|
+
size={5}
|
|
35
|
+
icon='ph--x--regular'
|
|
36
|
+
iconOnly
|
|
37
|
+
label={t('button cancel processing')}
|
|
38
|
+
onClick={() => onEvent?.({ type: 'cancel' })}
|
|
39
|
+
/>
|
|
40
|
+
)) || (
|
|
41
|
+
<IconButton
|
|
42
|
+
disabled
|
|
43
|
+
classNames='px-1.5'
|
|
44
|
+
variant='ghost'
|
|
45
|
+
size={5}
|
|
46
|
+
icon='ph--arrow-down--regular'
|
|
47
|
+
iconOnly
|
|
48
|
+
label={t('button scroll down')}
|
|
49
|
+
onClick={() => onEvent?.({ type: 'scroll-to-bottom' })}
|
|
50
|
+
/>
|
|
51
|
+
)}
|
|
52
|
+
|
|
53
|
+
{microphone && (
|
|
54
|
+
<IconButton
|
|
55
|
+
disabled={!processing}
|
|
56
|
+
classNames={mx('px-1.5', recording && 'bg-primary-500')}
|
|
57
|
+
variant='ghost'
|
|
58
|
+
size={5}
|
|
59
|
+
icon='ph--microphone--regular'
|
|
60
|
+
iconOnly
|
|
61
|
+
noTooltip
|
|
62
|
+
label={t('button microphone')}
|
|
63
|
+
onMouseDown={() => onEvent?.({ type: 'record-start' })}
|
|
64
|
+
onMouseUp={() => onEvent?.({ type: 'record-stop' })}
|
|
65
|
+
onTouchStart={() => onEvent?.({ type: 'record-start' })}
|
|
66
|
+
onTouchEnd={() => onEvent?.({ type: 'record-stop' })}
|
|
67
|
+
/>
|
|
68
|
+
)}
|
|
69
|
+
</div>
|
|
70
|
+
);
|
|
71
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type Blueprint } from '@dxos/blueprints';
|
|
8
|
+
import { DropdownMenu, IconButton, Input, useTranslation } from '@dxos/react-ui';
|
|
9
|
+
|
|
10
|
+
import { meta } from '../../meta';
|
|
11
|
+
|
|
12
|
+
export type ChatOptionsMenuProps = {
|
|
13
|
+
blueprintRegistry?: Blueprint.Registry;
|
|
14
|
+
blueprints?: Blueprint.Blueprint[];
|
|
15
|
+
onChange?: (key: string, active: boolean) => void;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const ChatOptionsMenu = ({ blueprintRegistry, blueprints, onChange }: ChatOptionsMenuProps) => {
|
|
19
|
+
const { t } = useTranslation(meta.id);
|
|
20
|
+
const blueprintOptions = useMemo(
|
|
21
|
+
() => blueprintRegistry?.query().map((blueprint) => ({ key: blueprint.key, label: blueprint.name })),
|
|
22
|
+
[blueprintRegistry],
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<DropdownMenu.Root>
|
|
27
|
+
<DropdownMenu.Trigger asChild disabled={!blueprintOptions?.length}>
|
|
28
|
+
<IconButton icon='ph--plus--regular' variant='ghost' size={5} iconOnly label={t('button add blueprint')} />
|
|
29
|
+
</DropdownMenu.Trigger>
|
|
30
|
+
<DropdownMenu.Portal>
|
|
31
|
+
<DropdownMenu.Content side='left'>
|
|
32
|
+
<DropdownMenu.Viewport>
|
|
33
|
+
{blueprintOptions?.map((option) => (
|
|
34
|
+
<DropdownMenu.Item key={option.key}>
|
|
35
|
+
<Input.Root>
|
|
36
|
+
<Input.Checkbox
|
|
37
|
+
checked={!!blueprints?.find((blueprint) => blueprint.key === option.key)}
|
|
38
|
+
onCheckedChange={(checked) => onChange?.(option.key, !!checked)}
|
|
39
|
+
/>
|
|
40
|
+
{/* TODO(burdon): Remove need for custom margin. */}
|
|
41
|
+
{/* TODO(burdon): Clicking on label doesn't toggle checkbox. */}
|
|
42
|
+
<Input.Label classNames='m-0'>{option.label}</Input.Label>
|
|
43
|
+
</Input.Root>
|
|
44
|
+
</DropdownMenu.Item>
|
|
45
|
+
))}
|
|
46
|
+
</DropdownMenu.Viewport>
|
|
47
|
+
<DropdownMenu.Arrow />
|
|
48
|
+
</DropdownMenu.Content>
|
|
49
|
+
</DropdownMenu.Portal>
|
|
50
|
+
</DropdownMenu.Root>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { Select } from '@dxos/react-ui';
|
|
8
|
+
|
|
9
|
+
export type ChatPresetsProps = {
|
|
10
|
+
presets?: { id: string; label: string }[];
|
|
11
|
+
preset?: string;
|
|
12
|
+
onChange?: (id: string) => void;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const ChatPresets = ({ presets, preset, onChange }: ChatPresetsProps) => {
|
|
16
|
+
return (
|
|
17
|
+
<Select.Root value={preset} onValueChange={onChange}>
|
|
18
|
+
<Select.TriggerButton classNames='text-sm' />
|
|
19
|
+
<Select.Content>
|
|
20
|
+
{presets?.map(({ id, label }) => (
|
|
21
|
+
<Select.Option key={id} value={id} classNames='text-sm'>
|
|
22
|
+
{label}
|
|
23
|
+
</Select.Option>
|
|
24
|
+
))}
|
|
25
|
+
</Select.Content>
|
|
26
|
+
</Select.Root>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useCallback } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type ContextBinder } from '@dxos/assistant';
|
|
8
|
+
import { type Space } from '@dxos/client/echo';
|
|
9
|
+
import { Filter, Obj, Ref } from '@dxos/echo';
|
|
10
|
+
import { type ThemedClassName, useAsyncState, useTranslation } from '@dxos/react-ui';
|
|
11
|
+
import { TagPicker, type TagPickerItemData, type TagPickerOptions } from '@dxos/react-ui-tag-picker';
|
|
12
|
+
import { mx } from '@dxos/react-ui-theme';
|
|
13
|
+
import { isNonNullable } from '@dxos/util';
|
|
14
|
+
|
|
15
|
+
import { meta } from '../../meta';
|
|
16
|
+
|
|
17
|
+
export type ChatReferencesProps = ThemedClassName<{
|
|
18
|
+
space: Space;
|
|
19
|
+
context: ContextBinder;
|
|
20
|
+
onUpdate?: (ids: string[]) => void;
|
|
21
|
+
}>;
|
|
22
|
+
|
|
23
|
+
export const ChatReferences = ({ classNames, space, context, onUpdate }: ChatReferencesProps) => {
|
|
24
|
+
const { t: _t } = useTranslation(meta.id);
|
|
25
|
+
|
|
26
|
+
const [items] = useAsyncState<TagPickerItemData[]>(async () => {
|
|
27
|
+
const objects = await Ref.Array.loadAll(context.objects.value ?? []);
|
|
28
|
+
return objects.filter(isNonNullable).map((obj) => ({ id: obj.id, label: Obj.getLabel(obj) ?? obj.id }));
|
|
29
|
+
}, [context]);
|
|
30
|
+
|
|
31
|
+
const handleSearch = useCallback<NonNullable<TagPickerOptions['onSearch']>>(
|
|
32
|
+
(text, ids) => {
|
|
33
|
+
// TODO(burdon): Filter by Item tag (e.g., exclude "contacts") and Query by object label.
|
|
34
|
+
// TODO(burdon): Change to Filter.text().
|
|
35
|
+
const objects = space.db.query(Filter.everything()).runSync();
|
|
36
|
+
return objects
|
|
37
|
+
.map(({ object }) => ({ id: object.id, label: Obj.getLabel(object) ?? '' }))
|
|
38
|
+
.filter(({ id, label }) => !ids.includes(id) && label.toLocaleLowerCase().includes(text.toLocaleLowerCase()));
|
|
39
|
+
},
|
|
40
|
+
[space],
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<TagPicker
|
|
45
|
+
classNames={mx('h-[1.75rem] text-sm', classNames)}
|
|
46
|
+
mode='multi-select'
|
|
47
|
+
// placeholder={t('context objects placeholder')}
|
|
48
|
+
items={items}
|
|
49
|
+
onSearch={handleSearch}
|
|
50
|
+
onUpdate={onUpdate}
|
|
51
|
+
/>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useEffect, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { Icon, Tooltip, useTimeout } from '@dxos/react-ui';
|
|
8
|
+
import { Spinner } from '@dxos/react-ui-sfx';
|
|
9
|
+
import { errorText } from '@dxos/react-ui-theme';
|
|
10
|
+
|
|
11
|
+
export type ChatStatusIndicatorProps = {
|
|
12
|
+
preset?: string;
|
|
13
|
+
error?: Error;
|
|
14
|
+
processing?: boolean;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const ChatStatusIndicator = ({ preset, error, processing }: ChatStatusIndicatorProps) => {
|
|
18
|
+
const [init, setInit] = useState(false);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
setInit(false);
|
|
21
|
+
}, [preset]);
|
|
22
|
+
useTimeout(
|
|
23
|
+
async () => {
|
|
24
|
+
setInit(true);
|
|
25
|
+
},
|
|
26
|
+
1_500,
|
|
27
|
+
[preset],
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
if (error) {
|
|
31
|
+
return (
|
|
32
|
+
<Tooltip.Trigger content={error.message} delayDuration={0}>
|
|
33
|
+
<Icon icon='ph--warning-circle--regular' classNames={errorText} size={5} />
|
|
34
|
+
</Tooltip.Trigger>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return <Spinner state={!init ? 'flash' : processing ? 'spin' : 'pulse'} />;
|
|
39
|
+
};
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { Fragment, type FC, type PropsWithChildren } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type Tool } from '@dxos/ai';
|
|
8
|
+
import { Surface } from '@dxos/app-framework';
|
|
9
|
+
import { invariant } from '@dxos/invariant';
|
|
10
|
+
import { type Space } from '@dxos/react-client/echo';
|
|
11
|
+
import { Button, Icon, IconButton, useTranslation, type ThemedClassName } from '@dxos/react-ui';
|
|
12
|
+
import {
|
|
13
|
+
MarkdownViewer,
|
|
14
|
+
ToggleContainer as NativeToggleContainer,
|
|
15
|
+
type ToggleContainerProps,
|
|
16
|
+
} from '@dxos/react-ui-components';
|
|
17
|
+
import { mx } from '@dxos/react-ui-theme';
|
|
18
|
+
import { type ContentBlock, type DataType } from '@dxos/schema';
|
|
19
|
+
import { safeParseJson } from '@dxos/util';
|
|
20
|
+
|
|
21
|
+
import { Json, ToolBlock, isToolMessage } from './ToolBlock';
|
|
22
|
+
import { type ChatProcessor } from '../../hooks';
|
|
23
|
+
import { meta } from '../../meta';
|
|
24
|
+
import { type ChatEvent } from '../Chat';
|
|
25
|
+
import { ToolboxContainer } from '../Toolbox';
|
|
26
|
+
|
|
27
|
+
export type ChatMessageProps = ThemedClassName<{
|
|
28
|
+
debug?: boolean;
|
|
29
|
+
space?: Space;
|
|
30
|
+
message: DataType.Message;
|
|
31
|
+
// TODO(burdon): Move to context.
|
|
32
|
+
processor?: ChatProcessor;
|
|
33
|
+
tools?: Tool[];
|
|
34
|
+
onEvent?: (event: ChatEvent) => void;
|
|
35
|
+
}>;
|
|
36
|
+
|
|
37
|
+
export const ChatMessage = ({ classNames, debug, space, message, processor, tools, onEvent }: ChatMessageProps) => {
|
|
38
|
+
const { t } = useTranslation(meta.id);
|
|
39
|
+
const {
|
|
40
|
+
sender: { role },
|
|
41
|
+
blocks,
|
|
42
|
+
} = message;
|
|
43
|
+
|
|
44
|
+
// TODO(burdon): Restructure types to make check unnecessary.
|
|
45
|
+
if (isToolMessage(message)) {
|
|
46
|
+
return (
|
|
47
|
+
<MessageContainer classNames={mx(classNames, 'animate-[fadeIn_0.5s]')}>
|
|
48
|
+
<ToolBlock classNames={panelClasses} message={message} tools={tools} />
|
|
49
|
+
</MessageContainer>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<>
|
|
55
|
+
{debug && (
|
|
56
|
+
<div className={mx('flex justify-end text-subdued', marginClasses)}>
|
|
57
|
+
<pre className='text-xs'>{JSON.stringify({ created: message.created })}</pre>
|
|
58
|
+
</div>
|
|
59
|
+
)}
|
|
60
|
+
|
|
61
|
+
{blocks.map((block, idx) => {
|
|
62
|
+
// TODO(burdon): Filter empty messages.
|
|
63
|
+
if (block._tag === 'text' && block.text.replaceAll(/\s+/g, '').length === 0) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const Component: BlockComponent = components[block._tag] ?? components.default!;
|
|
68
|
+
if (!Component) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<Fragment key={idx}>
|
|
74
|
+
<MessageContainer classNames={classNames} user={block._tag === 'text' && role === 'user'}>
|
|
75
|
+
<Component space={space} processor={processor} block={block} onEvent={onEvent} />
|
|
76
|
+
</MessageContainer>
|
|
77
|
+
{debug && (
|
|
78
|
+
<div className={mx('flex justify-end text-subdued', marginClasses)}>
|
|
79
|
+
<pre className='text-xs'>{JSON.stringify({ block: block._tag })}</pre>
|
|
80
|
+
</div>
|
|
81
|
+
)}
|
|
82
|
+
</Fragment>
|
|
83
|
+
);
|
|
84
|
+
})}
|
|
85
|
+
<div className={mx('flex justify-end pbs-2 pbe-2 opacity-50 hover:opacity-100', marginClasses)}>
|
|
86
|
+
<IconButton
|
|
87
|
+
classNames='animate-[fadeIn_0.5s]'
|
|
88
|
+
icon='ph--trash--regular'
|
|
89
|
+
iconOnly
|
|
90
|
+
label={t('button delete message')}
|
|
91
|
+
onClick={() => onEvent?.({ type: 'delete', id: message.id })}
|
|
92
|
+
/>
|
|
93
|
+
</div>
|
|
94
|
+
</>
|
|
95
|
+
);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
type BlockComponentProps = {
|
|
99
|
+
space?: Space;
|
|
100
|
+
block: ContentBlock.Any;
|
|
101
|
+
/** @deprecated Replace with context */
|
|
102
|
+
processor?: ChatProcessor;
|
|
103
|
+
onEvent?: (event: ChatEvent) => void;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
type BlockComponent = FC<BlockComponentProps>;
|
|
107
|
+
|
|
108
|
+
const components: Partial<Record<ContentBlock.Any['_tag'] | 'default', BlockComponent>> = {
|
|
109
|
+
//
|
|
110
|
+
// Text
|
|
111
|
+
//
|
|
112
|
+
['text' as const]: ({ block }) => {
|
|
113
|
+
invariant(block._tag === 'text');
|
|
114
|
+
// const [open, setOpen] = useState(block.disposition === 'cot' && block.pending);
|
|
115
|
+
const title = block.disposition ? titles[block.disposition] : undefined;
|
|
116
|
+
if (!title) {
|
|
117
|
+
return <MarkdownViewer content={block.text} />;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// TOOD(burdon): Store last time user opened/closed COT.
|
|
121
|
+
// Autoclose when streaming ends.
|
|
122
|
+
// useEffect(() => {
|
|
123
|
+
// if (block.disposition === 'cot' && !block.pending) {
|
|
124
|
+
// setOpen(false);
|
|
125
|
+
// }
|
|
126
|
+
// }, [block.disposition, block.pending]);
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<ToggleContainer
|
|
130
|
+
// open={open}
|
|
131
|
+
defaultOpen={systemDispositions.includes(block.disposition ?? '') && block.pending}
|
|
132
|
+
title={title}
|
|
133
|
+
icon={
|
|
134
|
+
block.pending ? (
|
|
135
|
+
<Icon icon={'ph--circle-notch--regular'} classNames='text-subdued animate-spin' size={4} />
|
|
136
|
+
) : undefined
|
|
137
|
+
}
|
|
138
|
+
>
|
|
139
|
+
<MarkdownViewer
|
|
140
|
+
content={block.text}
|
|
141
|
+
classNames={['pbe-2', systemDispositions.includes(block.disposition ?? '') && 'text-sm text-subdued']}
|
|
142
|
+
/>
|
|
143
|
+
</ToggleContainer>
|
|
144
|
+
);
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
//
|
|
148
|
+
// JSON
|
|
149
|
+
//
|
|
150
|
+
['json' as const]: ({ space, processor, block, onEvent }) => {
|
|
151
|
+
invariant(block._tag === 'json');
|
|
152
|
+
|
|
153
|
+
switch (block.disposition) {
|
|
154
|
+
case 'tool_list': {
|
|
155
|
+
return (
|
|
156
|
+
<ToggleContainer title={titles[block.disposition]} defaultOpen={true}>
|
|
157
|
+
<ToolboxContainer space={space} processor={processor} classNames='pbe-2' />
|
|
158
|
+
</ToggleContainer>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
case 'suggest': {
|
|
163
|
+
const { text = '' }: { text: string } = safeParseJson(block.data ?? '{}') ?? ({} as any);
|
|
164
|
+
return (
|
|
165
|
+
<IconButton icon='ph--lightning--regular' label={text} onClick={() => onEvent?.({ type: 'submit', text })} />
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
case 'select': {
|
|
170
|
+
const { options = [] }: { options: string[] } = safeParseJson(block.data ?? '{}') ?? ({} as any);
|
|
171
|
+
return (
|
|
172
|
+
<div className='flex flex-wrap gap-1'>
|
|
173
|
+
{options.map((text, idx) => (
|
|
174
|
+
<Button
|
|
175
|
+
classNames={'animate-[fadeIn_0.5s] rounded-sm text-sm'}
|
|
176
|
+
key={idx}
|
|
177
|
+
onClick={() => onEvent?.({ type: 'submit', text })}
|
|
178
|
+
>
|
|
179
|
+
{text}
|
|
180
|
+
</Button>
|
|
181
|
+
))}
|
|
182
|
+
</div>
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
case 'graph': {
|
|
187
|
+
return (
|
|
188
|
+
<div className='flex flex-wrap gap-1'>
|
|
189
|
+
<Surface
|
|
190
|
+
role='card'
|
|
191
|
+
data={{ subject: JSON.parse(block.data ?? '{}') }}
|
|
192
|
+
limit={1}
|
|
193
|
+
fallback={<div className='font-mono text-xs text-pre'>{block.data}</div>}
|
|
194
|
+
/>
|
|
195
|
+
{onEvent && (
|
|
196
|
+
<IconButton
|
|
197
|
+
icon='ph--plus--regular'
|
|
198
|
+
label='Add to graph'
|
|
199
|
+
onClick={() => onEvent?.({ type: 'add', object: JSON.parse(block.data ?? '{}') })}
|
|
200
|
+
/>
|
|
201
|
+
)}
|
|
202
|
+
</div>
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
default: {
|
|
207
|
+
const title = block.disposition ? titles[block.disposition] : undefined;
|
|
208
|
+
return (
|
|
209
|
+
<ToggleContainer title={title ?? 'JSON'}>
|
|
210
|
+
<Json data={safeParseJson(block.data ?? block)} />
|
|
211
|
+
</ToggleContainer>
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
|
|
217
|
+
//
|
|
218
|
+
// Default
|
|
219
|
+
//
|
|
220
|
+
default: ({ block }) => {
|
|
221
|
+
let title = titles[block._tag];
|
|
222
|
+
if (block._tag === 'toolCall') {
|
|
223
|
+
title = `Tool [${block.name}]`; // TODO(burdon): Get label from tool.
|
|
224
|
+
} else {
|
|
225
|
+
title = block._tag;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
return (
|
|
229
|
+
<ToggleContainer title={title ?? 'JSON'}>
|
|
230
|
+
<Json data={block} />
|
|
231
|
+
</ToggleContainer>
|
|
232
|
+
);
|
|
233
|
+
},
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
// TODO(burdon): Translations.
|
|
237
|
+
const titles: Record<string, string> = {
|
|
238
|
+
['cot' as const]: 'Chain of thought',
|
|
239
|
+
['artifact' as const]: 'Artifact',
|
|
240
|
+
['tool_use' as const]: 'Tool request',
|
|
241
|
+
['tool_result' as const]: 'Tool result',
|
|
242
|
+
['tool_list' as const]: 'Tools',
|
|
243
|
+
['artifact-update' as const]: 'Artifact(s) changed',
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
const systemDispositions: string[] = ['cot', 'artifact-update'];
|
|
247
|
+
|
|
248
|
+
const panelClasses = 'flex flex-col is-full bg-activeSurface rounded-sm';
|
|
249
|
+
const marginClasses = 'pie-4 pis-4';
|
|
250
|
+
const paddingClasses = 'pis-2 pie-2 pbs-0.5 pbe-0.5';
|
|
251
|
+
|
|
252
|
+
const MessageContainer = ({ classNames, children, user }: ThemedClassName<PropsWithChildren<{ user?: boolean }>>) => {
|
|
253
|
+
if (!children) {
|
|
254
|
+
return null;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return (
|
|
258
|
+
<div role='list-item' className={mx('flex is-full', user && 'justify-end', marginClasses, classNames)}>
|
|
259
|
+
<div className={mx(user ? ['rounded-sm', 'bg-[--user-fill] text-accentSurfaceText', paddingClasses] : 'is-full')}>
|
|
260
|
+
{children}
|
|
261
|
+
</div>
|
|
262
|
+
</div>
|
|
263
|
+
);
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
const ToggleContainer = (props: ToggleContainerProps) => {
|
|
267
|
+
return <NativeToggleContainer {...props} classNames={mx(panelClasses, props.classNames)} />;
|
|
268
|
+
};
|