@dxos/plugin-assistant 0.8.3 → 0.8.4-main.28f8d3d
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/{TemplateContainer-QQHVOTSI.mjs → BlueprintContainer-H7H4BQ2C.mjs} +11 -10
- package/dist/lib/browser/BlueprintContainer-H7H4BQ2C.mjs.map +7 -0
- package/dist/lib/browser/ChatContainer-OUVSX5V5.mjs +76 -0
- package/dist/lib/browser/ChatContainer-OUVSX5V5.mjs.map +7 -0
- package/dist/lib/browser/ChatDialog-P4FLEOHG.mjs +86 -0
- package/dist/lib/browser/ChatDialog-P4FLEOHG.mjs.map +7 -0
- package/dist/lib/browser/SequenceContainer-627OQ557.mjs +163 -0
- package/dist/lib/browser/SequenceContainer-627OQ557.mjs.map +7 -0
- package/dist/lib/browser/ai-service-7KJ5LXBT.mjs +22 -0
- package/dist/lib/browser/ai-service-7KJ5LXBT.mjs.map +7 -0
- package/dist/lib/browser/{app-graph-builder-E4H5DCOJ.mjs → app-graph-builder-AVHHQ3KV.mjs} +30 -89
- package/dist/lib/browser/app-graph-builder-AVHHQ3KV.mjs.map +7 -0
- package/dist/lib/browser/blueprint-definition-CMGIZAOW.mjs +146 -0
- package/dist/lib/browser/blueprint-definition-CMGIZAOW.mjs.map +7 -0
- package/dist/lib/browser/chunk-BRLHDHOF.mjs +244 -0
- package/dist/lib/browser/chunk-BRLHDHOF.mjs.map +7 -0
- package/dist/lib/browser/chunk-HRLMD35M.mjs +191 -0
- package/dist/lib/browser/chunk-HRLMD35M.mjs.map +7 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/browser/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/browser/{chunk-XOZ7YMO3.mjs → chunk-LKP65RPA.mjs} +2 -2
- package/dist/lib/browser/{chunk-JQFUME3B.mjs → chunk-NZDCKQ6W.mjs} +36 -34
- package/dist/lib/browser/chunk-NZDCKQ6W.mjs.map +7 -0
- package/dist/lib/browser/chunk-QB7OVS6Z.mjs +16 -0
- package/dist/lib/browser/chunk-QB7OVS6Z.mjs.map +7 -0
- package/dist/lib/browser/chunk-VEBVAHNM.mjs +2231 -0
- package/dist/lib/browser/chunk-VEBVAHNM.mjs.map +7 -0
- package/dist/lib/browser/edge-model-resolver-2HB4PCWH.mjs +24 -0
- package/dist/lib/browser/edge-model-resolver-2HB4PCWH.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +141 -128
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/intent-resolver-MVOIEJXZ.mjs +81 -0
- package/dist/lib/browser/intent-resolver-MVOIEJXZ.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-LXCNUSZN.mjs → react-surface-4HXS3YLT.mjs} +66 -62
- package/dist/lib/browser/react-surface-4HXS3YLT.mjs.map +7 -0
- package/dist/lib/browser/{settings-XRHXVWGB.mjs → settings-G2EZXMWT.mjs} +7 -6
- package/dist/lib/browser/settings-G2EZXMWT.mjs.map +7 -0
- package/dist/lib/browser/toolkit-IW4FBLLB.mjs +105 -0
- package/dist/lib/browser/toolkit-IW4FBLLB.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +7 -20
- package/dist/lib/node-esm/{TemplateContainer-SOEWY2ZN.mjs → BlueprintContainer-VH4EE4CM.mjs} +11 -10
- package/dist/lib/node-esm/BlueprintContainer-VH4EE4CM.mjs.map +7 -0
- package/dist/lib/node-esm/ChatContainer-D5FABDNE.mjs +77 -0
- package/dist/lib/node-esm/ChatContainer-D5FABDNE.mjs.map +7 -0
- package/dist/lib/node-esm/ChatDialog-NKWVXHJP.mjs +87 -0
- package/dist/lib/node-esm/ChatDialog-NKWVXHJP.mjs.map +7 -0
- package/dist/lib/node-esm/SequenceContainer-EQ5NP2PG.mjs +164 -0
- package/dist/lib/node-esm/SequenceContainer-EQ5NP2PG.mjs.map +7 -0
- package/dist/lib/node-esm/ai-service-LDD32477.mjs +23 -0
- package/dist/lib/node-esm/ai-service-LDD32477.mjs.map +7 -0
- package/dist/lib/node-esm/{app-graph-builder-3SY5MBIK.mjs → app-graph-builder-RMOUJMMG.mjs} +30 -89
- package/dist/lib/node-esm/app-graph-builder-RMOUJMMG.mjs.map +7 -0
- package/dist/lib/node-esm/blueprint-definition-AEWYMW6I.mjs +147 -0
- package/dist/lib/node-esm/blueprint-definition-AEWYMW6I.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-3SOC5GOP.mjs +2232 -0
- package/dist/lib/node-esm/chunk-3SOC5GOP.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-F7RXCX5Y.mjs +192 -0
- package/dist/lib/node-esm/chunk-F7RXCX5Y.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-OYN6HLXZ.mjs → chunk-GAWXJ7K5.mjs} +36 -34
- package/dist/lib/node-esm/chunk-GAWXJ7K5.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
- package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-BB2TAT4P.mjs → chunk-KOC6ESG7.mjs} +2 -2
- package/dist/lib/node-esm/chunk-RD755HN3.mjs +245 -0
- package/dist/lib/node-esm/chunk-RD755HN3.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-X6AANUHZ.mjs +17 -0
- package/dist/lib/node-esm/chunk-X6AANUHZ.mjs.map +7 -0
- package/dist/lib/node-esm/edge-model-resolver-UDDR2IA6.mjs +25 -0
- package/dist/lib/node-esm/edge-model-resolver-UDDR2IA6.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +141 -128
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/intent-resolver-DTDNCX3C.mjs +82 -0
- package/dist/lib/node-esm/intent-resolver-DTDNCX3C.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-7HA5EDWY.mjs → react-surface-V6JNEZVO.mjs} +66 -62
- package/dist/lib/node-esm/react-surface-V6JNEZVO.mjs.map +7 -0
- package/dist/lib/node-esm/{settings-5IAY6BT4.mjs → settings-AIP5FOJG.mjs} +7 -6
- package/dist/lib/node-esm/settings-AIP5FOJG.mjs.map +7 -0
- package/dist/lib/node-esm/toolkit-2VNUL77B.mjs +106 -0
- package/dist/lib/node-esm/toolkit-2VNUL77B.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +7 -20
- package/dist/types/src/AssistantPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/ai-service.d.ts +5 -0
- package/dist/types/src/capabilities/ai-service.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/blueprint-definition.d.ts +3 -0
- package/dist/types/src/capabilities/blueprint-definition.d.ts.map +1 -0
- package/dist/types/src/capabilities/capabilities.d.ts +8 -3
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
- package/dist/types/src/capabilities/edge-model-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/edge-model-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +6 -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/capabilities/toolkit.d.ts +5 -0
- package/dist/types/src/capabilities/toolkit.d.ts.map +1 -0
- 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/BlueprintContainer.d.ts +5 -6
- package/dist/types/src/components/BlueprintContainer.d.ts.map +1 -1
- package/dist/types/src/components/Chat/Chat.d.ts +45 -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 +8 -7
- 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/ChatOptions.d.ts +13 -0
- package/dist/types/src/components/ChatPrompt/ChatOptions.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 +18 -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 +226 -0
- package/dist/types/src/components/ChatThread/ChatThread.stories.d.ts.map +1 -0
- package/dist/types/src/components/ChatThread/Link.d.ts +9 -0
- package/dist/types/src/components/ChatThread/Link.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/TemplateEditor/TemplateEditor.d.ts +4 -3
- 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 +5 -4
- 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/Timeline/Timeline.d.ts +24 -0
- package/dist/types/src/components/Timeline/Timeline.d.ts.map +1 -0
- package/dist/types/src/components/Timeline/Timeline.stories.d.ts +9 -0
- package/dist/types/src/components/Timeline/Timeline.stories.d.ts.map +1 -0
- package/dist/types/src/components/Timeline/index.d.ts +2 -0
- package/dist/types/src/components/Timeline/index.d.ts.map +1 -0
- package/dist/types/src/components/Toolbox/Toolbox.d.ts +10 -6
- package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -1
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +2 -3
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +7 -12
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/events.d.ts +1 -1
- package/dist/types/src/events.d.ts.map +1 -1
- package/dist/types/src/functions/analysis.d.ts +5 -0
- package/dist/types/src/functions/analysis.d.ts.map +1 -0
- package/dist/types/src/functions/index.d.ts +4 -0
- package/dist/types/src/functions/index.d.ts.map +1 -0
- package/dist/types/src/functions/list.d.ts +10 -0
- package/dist/types/src/functions/list.d.ts.map +1 -0
- package/dist/types/src/functions/load.d.ts +8 -0
- package/dist/types/src/functions/load.d.ts.map +1 -0
- package/dist/types/src/hooks/chat-processor.d.ts +72 -0
- package/dist/types/src/hooks/chat-processor.d.ts.map +1 -0
- package/dist/types/src/hooks/errors.d.ts +4 -0
- package/dist/types/src/hooks/errors.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +9 -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/useBlueprintRegistry.d.ts +21 -0
- package/dist/types/src/hooks/useBlueprintRegistry.d.ts.map +1 -0
- package/dist/types/src/hooks/useChatProcessor.d.ts +16 -11
- package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatServices.d.ts +13 -0
- package/dist/types/src/hooks/useChatServices.d.ts.map +1 -0
- package/dist/types/src/hooks/useOnline.d.ts +3 -0
- package/dist/types/src/hooks/useOnline.d.ts.map +1 -0
- package/dist/types/src/hooks/usePresets.d.ts +7 -0
- package/dist/types/src/hooks/usePresets.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/hooks/useResolveRef.d.ts +4 -0
- package/dist/types/src/hooks/useResolveRef.d.ts.map +1 -0
- package/dist/types/src/parser/filter-generator.d.ts.map +1 -1
- 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/parser/query-parser.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 +268 -0
- package/dist/types/src/stories/Chat.stories.d.ts.map +1 -0
- package/dist/types/src/stories/components/BlueprintContainer.d.ts +5 -0
- package/dist/types/src/stories/components/BlueprintContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/ChatContainer.d.ts +5 -0
- package/dist/types/src/stories/components/ChatContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/GraphContainer.d.ts +6 -0
- package/dist/types/src/stories/components/GraphContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/LoggingContainer.d.ts +5 -0
- package/dist/types/src/stories/components/LoggingContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/SurfaceContainer.d.ts +8 -0
- package/dist/types/src/stories/components/SurfaceContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/TasksContainer.d.ts +5 -0
- package/dist/types/src/stories/components/TasksContainer.d.ts.map +1 -0
- package/dist/types/src/stories/components/index.d.ts +8 -0
- package/dist/types/src/stories/components/index.d.ts.map +1 -0
- package/dist/types/src/stories/components/types.d.ts +7 -0
- package/dist/types/src/stories/components/types.d.ts.map +1 -0
- package/dist/types/src/stories/hooks/index.d.ts +3 -0
- package/dist/types/src/stories/hooks/index.d.ts.map +1 -0
- package/dist/types/src/stories/hooks/useFlush.d.ts +6 -0
- package/dist/types/src/stories/hooks/useFlush.d.ts.map +1 -0
- package/dist/types/src/stories/hooks/useMatcherExtension.d.ts +3 -0
- package/dist/types/src/stories/hooks/useMatcherExtension.d.ts.map +1 -0
- package/dist/types/src/stories/testing/data.d.ts +142 -0
- package/dist/types/src/stories/testing/data.d.ts.map +1 -0
- package/dist/types/src/stories/testing/index.d.ts +3 -0
- package/dist/types/src/stories/testing/index.d.ts.map +1 -0
- package/dist/types/src/stories/testing/testing.d.ts +26 -0
- package/dist/types/src/stories/testing/testing.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-functions.d.ts +5 -2
- package/dist/types/src/testing/test-functions.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/tools/function.d.ts.map +1 -1
- package/dist/types/src/tools/openapi.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +73 -113
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/{chat.d.ts → Assistant.d.ts} +20 -3
- package/dist/types/src/types/Assistant.d.ts.map +1 -0
- package/dist/types/src/types/AssistantAction.d.ts +90 -0
- package/dist/types/src/types/AssistantAction.d.ts.map +1 -0
- package/dist/types/src/types/defs.d.ts +2 -0
- package/dist/types/src/types/defs.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +3 -3
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/service.d.ts +12 -12
- package/dist/types/src/types/service.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +86 -74
- package/src/AssistantPlugin.tsx +63 -43
- package/src/capabilities/ai-service.ts +28 -0
- package/src/capabilities/app-graph-builder.ts +28 -107
- package/src/capabilities/blueprint-definition.ts +32 -0
- package/src/capabilities/capabilities.ts +12 -5
- package/src/capabilities/edge-model-resolver.ts +29 -0
- package/src/capabilities/index.ts +6 -3
- package/src/capabilities/intent-resolver.ts +40 -12
- package/src/capabilities/react-surface.tsx +54 -46
- package/src/capabilities/settings.ts +3 -3
- package/src/capabilities/toolkit.ts +106 -0
- package/src/components/AssistantSettings/AssistantSettings.tsx +4 -4
- package/src/components/BlueprintContainer.tsx +9 -133
- package/src/components/Chat/Chat.tsx +401 -0
- package/src/components/Chat/events.ts +50 -0
- package/src/components/Chat/index.ts +7 -0
- package/src/components/ChatContainer.tsx +51 -21
- package/src/components/ChatDialog.tsx +68 -0
- package/src/components/ChatPrompt/ChatActions.tsx +71 -0
- package/src/components/ChatPrompt/ChatOptions.tsx +59 -0
- package/src/components/ChatPrompt/ChatPresets.tsx +28 -0
- package/src/components/ChatPrompt/ChatReferences.tsx +55 -0
- package/src/components/ChatPrompt/ChatStatusIndicator.tsx +39 -0
- package/src/components/ChatPrompt/index.ts +9 -0
- package/src/components/ChatThread/ChatMessage.tsx +282 -0
- package/src/components/ChatThread/ChatThread.stories.tsx +260 -0
- package/src/components/ChatThread/ChatThread.tsx +57 -0
- package/src/components/ChatThread/Link.tsx +39 -0
- package/src/components/ChatThread/ToolBlock.tsx +125 -0
- package/src/components/{AmbientDialog → ChatThread}/index.ts +1 -1
- package/src/components/{Thread → ChatThread}/reducer.ts +14 -14
- package/src/components/PromptSettings.tsx +43 -45
- package/src/components/SequenceContainer.tsx +133 -0
- package/src/components/SequenceEditor/SequenceEditor.stories.tsx +33 -0
- package/src/components/{BlueprintEditor/BlueprintEditor.tsx → SequenceEditor/SequenceEditor.tsx} +8 -8
- package/src/components/SequenceEditor/index.ts +5 -0
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +38 -36
- package/src/components/TemplateEditor/TemplateEditor.tsx +41 -25
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +24 -17
- package/src/components/TemplateEditor/TemplateForm.tsx +51 -57
- package/src/components/Timeline/Timeline.stories.tsx +53 -0
- package/src/components/Timeline/Timeline.tsx +159 -0
- package/src/{experimental/transcription → components/Timeline}/index.ts +2 -0
- package/src/components/Toolbox/Toolbox.stories.tsx +9 -16
- package/src/components/Toolbox/Toolbox.tsx +49 -17
- package/src/components/index.ts +4 -8
- package/src/events.ts +3 -3
- package/src/functions/analysis.ts +20 -0
- package/src/functions/index.ts +7 -0
- package/src/functions/list.ts +42 -0
- package/src/functions/load.ts +43 -0
- package/src/hooks/chat-processor.ts +260 -0
- package/src/hooks/errors.ts +8 -0
- package/src/hooks/index.ts +9 -5
- package/src/hooks/presets.ts +53 -0
- package/src/hooks/useBlueprintRegistry.ts +79 -0
- package/src/hooks/useChatProcessor.ts +81 -0
- package/src/hooks/useChatServices.ts +72 -0
- package/src/hooks/useOnline.ts +10 -0
- package/src/hooks/usePresets.ts +45 -0
- package/src/hooks/{useContextProvider.ts → useReferencesProvider.ts} +22 -20
- package/src/hooks/useResolveRef.ts +33 -0
- package/src/parser/filter-generator.ts +6 -13
- package/src/parser/index.ts +1 -1
- package/src/parser/query-parser.ts +1 -1
- package/src/queue-logger.ts +11 -11
- package/src/stories/Chat.stories.tsx +317 -0
- package/src/stories/components/BlueprintContainer.tsx +34 -0
- package/src/stories/components/ChatContainer.tsx +80 -0
- package/src/stories/components/GraphContainer.tsx +118 -0
- package/src/stories/components/LoggingContainer.tsx +22 -0
- package/src/stories/components/SurfaceContainer.tsx +62 -0
- package/src/stories/components/TasksContainer.tsx +51 -0
- package/src/stories/components/index.ts +12 -0
- package/src/stories/components/types.ts +11 -0
- package/src/stories/hooks/index.ts +6 -0
- package/src/stories/hooks/useFlush.ts +35 -0
- package/src/stories/hooks/useMatcherExtension.ts +45 -0
- package/src/stories/{test-data.ts → testing/data.ts} +10 -8
- package/src/stories/testing/index.ts +6 -0
- package/src/stories/testing/testing.tsx +162 -0
- package/src/testing/index.ts +1 -1
- package/src/testing/test-functions.ts +9 -4
- package/src/testing/test-sequence.ts +51 -0
- package/src/tools/function.ts +4 -1
- package/src/tools/openapi.test.ts +14 -12
- package/src/tools/openapi.ts +4 -1
- package/src/translations.ts +46 -28
- package/src/types/Assistant.ts +59 -0
- package/src/types/AssistantAction.ts +54 -0
- package/src/types/defs.ts +5 -0
- package/src/types/index.ts +4 -3
- 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 +0 -157
- 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.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/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 +0 -44
- 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-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 +0 -158
- 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/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/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/TemplateContainer.d.ts +0 -8
- package/dist/types/src/components/TemplateContainer.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 +0 -72
- 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.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/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/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/TemplateContainer.tsx +0 -23
- 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/ToolInvocations.tsx +0 -106
- package/src/components/Thread/index.ts +0 -6
- package/src/hooks/processor.test.ts +0 -15
- 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/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
- /package/dist/lib/browser/{chunk-XOZ7YMO3.mjs.map → chunk-LKP65RPA.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-BB2TAT4P.mjs.map → chunk-KOC6ESG7.mjs.map} +0 -0
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Extension, Prec } from '@codemirror/state';
|
|
6
|
+
import { keymap } from '@codemirror/view';
|
|
7
|
+
import { Result, useRxValue } from '@effect-rx/rx-react';
|
|
8
|
+
import { createContext } from '@radix-ui/react-context';
|
|
9
|
+
import { Array, Option } from 'effect';
|
|
10
|
+
import React, { type PropsWithChildren, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
11
|
+
|
|
12
|
+
import { Event } from '@dxos/async';
|
|
13
|
+
import { DXN, Obj, Ref } from '@dxos/echo';
|
|
14
|
+
import { log } from '@dxos/log';
|
|
15
|
+
import { useVoiceInput } from '@dxos/plugin-transcription';
|
|
16
|
+
import { type Space, getSpace, useQueue } from '@dxos/react-client/echo';
|
|
17
|
+
import { useIdentity } from '@dxos/react-client/halo';
|
|
18
|
+
import { Input, type ThemedClassName, useTranslation } from '@dxos/react-ui';
|
|
19
|
+
import { ChatEditor, type ChatEditorController, type ChatEditorProps, references } from '@dxos/react-ui-chat';
|
|
20
|
+
import { type ScrollController } from '@dxos/react-ui-components';
|
|
21
|
+
import { mx } from '@dxos/react-ui-theme';
|
|
22
|
+
import { DataType } from '@dxos/schema';
|
|
23
|
+
import { isNotFalsy } from '@dxos/util';
|
|
24
|
+
|
|
25
|
+
import { type AiChatProcessor, useBlueprintHandlers, useReferencesProvider } from '../../hooks';
|
|
26
|
+
import { meta } from '../../meta';
|
|
27
|
+
import { type Assistant } from '../../types';
|
|
28
|
+
import {
|
|
29
|
+
ChatActions,
|
|
30
|
+
type ChatActionsProps,
|
|
31
|
+
ChatOptions,
|
|
32
|
+
ChatPresets,
|
|
33
|
+
type ChatPresetsProps,
|
|
34
|
+
ChatReferences,
|
|
35
|
+
type ChatReferencesProps,
|
|
36
|
+
ChatStatusIndicator,
|
|
37
|
+
} from '../ChatPrompt';
|
|
38
|
+
import { ChatThread as NativeChatThread, type ChatThreadProps as NativeChatThreadProps } from '../ChatThread';
|
|
39
|
+
|
|
40
|
+
import { type ChatEvent } from './events';
|
|
41
|
+
|
|
42
|
+
// TODO(burdon): Factor out.
|
|
43
|
+
const Endcap = ({ children }: PropsWithChildren) => {
|
|
44
|
+
return (
|
|
45
|
+
<div className='grid w-[var(--rail-action)] h-[var(--rail-action)] items-center justify-center'>{children}</div>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
//
|
|
50
|
+
// Context
|
|
51
|
+
// NOTE: The context should not be exported. It is only used internally.
|
|
52
|
+
// Components outside of this Radix-style group shuld define their own APIs.
|
|
53
|
+
//
|
|
54
|
+
|
|
55
|
+
// TODO(burdon): Inject via effect layer.
|
|
56
|
+
type ChatContextValue = {
|
|
57
|
+
debug?: boolean;
|
|
58
|
+
event: Event<ChatEvent>;
|
|
59
|
+
space: Space;
|
|
60
|
+
chat: Assistant.Chat;
|
|
61
|
+
messages: DataType.Message[];
|
|
62
|
+
processor: AiChatProcessor;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// NOTE: Do not export.
|
|
66
|
+
const [ChatContextProvider, useChatContext] = createContext<ChatContextValue>('Chat');
|
|
67
|
+
|
|
68
|
+
//
|
|
69
|
+
// Root
|
|
70
|
+
//
|
|
71
|
+
|
|
72
|
+
type ChatRootProps = ThemedClassName<
|
|
73
|
+
PropsWithChildren<
|
|
74
|
+
Pick<ChatContextValue, 'chat' | 'processor'> & {
|
|
75
|
+
onEvent?: (event: ChatEvent) => void;
|
|
76
|
+
}
|
|
77
|
+
>
|
|
78
|
+
>;
|
|
79
|
+
|
|
80
|
+
const ChatRoot = ({ classNames, children, chat, processor, onEvent, ...props }: ChatRootProps) => {
|
|
81
|
+
const [debug, setDebug] = useState(false);
|
|
82
|
+
const space = getSpace(chat);
|
|
83
|
+
|
|
84
|
+
// Messages.
|
|
85
|
+
const queue = useQueue<DataType.Message>(chat?.queue.dxn);
|
|
86
|
+
const pending = useRxValue(processor.messages);
|
|
87
|
+
const streaming = useRxValue(processor.streaming);
|
|
88
|
+
|
|
89
|
+
const messages = useMemo(() => {
|
|
90
|
+
const queueMessages = queue?.objects?.filter(Obj.instanceOf(DataType.Message)) ?? [];
|
|
91
|
+
return Result.match(pending, {
|
|
92
|
+
onInitial: () => queueMessages,
|
|
93
|
+
onSuccess: (pending) => Array.dedupeWith([...queueMessages, ...pending.value], (a, b) => a.id === b.id),
|
|
94
|
+
onFailure: () => queueMessages,
|
|
95
|
+
});
|
|
96
|
+
}, [queue?.objects, pending]);
|
|
97
|
+
|
|
98
|
+
// TODO(burdon): Replace with tool to select artifact.
|
|
99
|
+
// const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
100
|
+
// useEffect(() => {
|
|
101
|
+
// if (!processor?.streaming.value && queue?.objects) {
|
|
102
|
+
// const message = queue.objects[queue.objects.length - 1];
|
|
103
|
+
// if (dispatch && space && chat && message) {
|
|
104
|
+
// void dispatch(
|
|
105
|
+
// createIntent(CollaborationActions.InsertContent, {
|
|
106
|
+
// target: artifact,
|
|
107
|
+
// object: Ref.fromDXN(new DXN(DXN.kind.QUEUE, [...chat.queue.dxn.parts, message.id])),
|
|
108
|
+
// label: 'View proposal',
|
|
109
|
+
// }),
|
|
110
|
+
// );
|
|
111
|
+
// }
|
|
112
|
+
// }
|
|
113
|
+
// }, [queue, processor?.streaming.value]);
|
|
114
|
+
|
|
115
|
+
// Events.
|
|
116
|
+
const event = useMemo(() => new Event<ChatEvent>(), []);
|
|
117
|
+
useEffect(() => {
|
|
118
|
+
return event.on((event) => {
|
|
119
|
+
switch (event.type) {
|
|
120
|
+
case 'toggle-debug': {
|
|
121
|
+
setDebug((current) => {
|
|
122
|
+
const debug = !current;
|
|
123
|
+
log.info('toggle-debug', { debug });
|
|
124
|
+
// log.config({ filter: debug ? 'assistant:debug' : 'info' });
|
|
125
|
+
return debug;
|
|
126
|
+
});
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
case 'submit': {
|
|
131
|
+
if (!streaming) {
|
|
132
|
+
void processor.request(event.text);
|
|
133
|
+
}
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
case 'cancel': {
|
|
138
|
+
void processor.cancel();
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
default: {
|
|
143
|
+
onEvent?.(event);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}, [event, onEvent, processor, streaming]);
|
|
148
|
+
|
|
149
|
+
if (!space) {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return (
|
|
154
|
+
<ChatContextProvider
|
|
155
|
+
debug={debug}
|
|
156
|
+
event={event}
|
|
157
|
+
chat={chat}
|
|
158
|
+
space={space}
|
|
159
|
+
processor={processor}
|
|
160
|
+
messages={messages}
|
|
161
|
+
{...props}
|
|
162
|
+
>
|
|
163
|
+
<div role='none' className={mx('flex flex-col h-full overflow-hidden', classNames)}>
|
|
164
|
+
{children}
|
|
165
|
+
</div>
|
|
166
|
+
</ChatContextProvider>
|
|
167
|
+
);
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
ChatRoot.displayName = 'Chat.Root';
|
|
171
|
+
|
|
172
|
+
//
|
|
173
|
+
// Thread
|
|
174
|
+
//
|
|
175
|
+
|
|
176
|
+
type ChatThreadProps = Omit<NativeChatThreadProps, 'identity' | 'space' | 'messages' | 'tools' | 'onEvent'>;
|
|
177
|
+
|
|
178
|
+
const ChatThread = (props: ChatThreadProps) => {
|
|
179
|
+
const { debug, event, space, messages } = useChatContext(ChatThread.displayName);
|
|
180
|
+
const identity = useIdentity();
|
|
181
|
+
|
|
182
|
+
const scrollerRef = useRef<ScrollController>(null);
|
|
183
|
+
useEffect(() => {
|
|
184
|
+
return event.on((event) => {
|
|
185
|
+
switch (event.type) {
|
|
186
|
+
case 'submit':
|
|
187
|
+
case 'scroll-to-bottom':
|
|
188
|
+
scrollerRef.current?.scrollToBottom('smooth');
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
}, [event]);
|
|
193
|
+
|
|
194
|
+
if (!identity) {
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return (
|
|
199
|
+
<NativeChatThread
|
|
200
|
+
{...props}
|
|
201
|
+
ref={scrollerRef}
|
|
202
|
+
debug={debug}
|
|
203
|
+
identity={identity}
|
|
204
|
+
space={space}
|
|
205
|
+
messages={messages}
|
|
206
|
+
onEvent={(ev) => event.emit(ev)}
|
|
207
|
+
/>
|
|
208
|
+
);
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
ChatThread.displayName = 'Chat.Thread';
|
|
212
|
+
|
|
213
|
+
//
|
|
214
|
+
// Prompt
|
|
215
|
+
//
|
|
216
|
+
|
|
217
|
+
type ChatPromptProps = ThemedClassName<
|
|
218
|
+
Pick<ChatEditorProps, 'placeholder'> &
|
|
219
|
+
Omit<ChatPresetsProps, 'onChange'> & {
|
|
220
|
+
expandable?: boolean;
|
|
221
|
+
online?: boolean;
|
|
222
|
+
onChangeOnline?: (online: boolean) => void;
|
|
223
|
+
onChangePreset?: ChatPresetsProps['onChange'];
|
|
224
|
+
}
|
|
225
|
+
>;
|
|
226
|
+
|
|
227
|
+
const ChatPrompt = ({
|
|
228
|
+
classNames,
|
|
229
|
+
placeholder,
|
|
230
|
+
expandable,
|
|
231
|
+
online,
|
|
232
|
+
presets,
|
|
233
|
+
preset,
|
|
234
|
+
onChangePreset,
|
|
235
|
+
onChangeOnline,
|
|
236
|
+
}: ChatPromptProps) => {
|
|
237
|
+
const { t } = useTranslation(meta.id);
|
|
238
|
+
const { space, event, processor } = useChatContext(ChatPrompt.displayName);
|
|
239
|
+
const streaming = useRxValue(processor.streaming);
|
|
240
|
+
const error = useRxValue(processor.error).pipe(Option.getOrUndefined);
|
|
241
|
+
|
|
242
|
+
const [active, setActive] = useState(false);
|
|
243
|
+
useEffect(() => {
|
|
244
|
+
return event.on((event) => {
|
|
245
|
+
switch (event.type) {
|
|
246
|
+
case 'record-start':
|
|
247
|
+
setActive(true);
|
|
248
|
+
break;
|
|
249
|
+
case 'record-stop':
|
|
250
|
+
setActive(false);
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
}, [event]);
|
|
255
|
+
|
|
256
|
+
const editorRef = useRef<ChatEditorController>(null);
|
|
257
|
+
|
|
258
|
+
// TODO(burdon): Configure capability in TranscriptionPlugin.
|
|
259
|
+
const { recording } = useVoiceInput({
|
|
260
|
+
active,
|
|
261
|
+
onUpdate: (text) => {
|
|
262
|
+
editorRef.current?.setText(text);
|
|
263
|
+
editorRef.current?.focus();
|
|
264
|
+
},
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
// TODO(burdon): Reconcile with object tags.
|
|
268
|
+
const referencesProvider = useReferencesProvider(space);
|
|
269
|
+
const extensions = useMemo<Extension[]>(() => {
|
|
270
|
+
return [
|
|
271
|
+
referencesProvider && references({ provider: referencesProvider }),
|
|
272
|
+
Prec.highest(
|
|
273
|
+
keymap.of(
|
|
274
|
+
[
|
|
275
|
+
{
|
|
276
|
+
key: 'cmd-d',
|
|
277
|
+
preventDefault: true,
|
|
278
|
+
run: () => {
|
|
279
|
+
event.emit({ type: 'toggle-debug' });
|
|
280
|
+
return true;
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
expandable && {
|
|
284
|
+
key: 'cmd-ArrowUp',
|
|
285
|
+
preventDefault: true,
|
|
286
|
+
run: () => {
|
|
287
|
+
event.emit({ type: 'thread-open' });
|
|
288
|
+
return true;
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
expandable && {
|
|
292
|
+
key: 'cmd-ArrowDown',
|
|
293
|
+
preventDefault: true,
|
|
294
|
+
run: () => {
|
|
295
|
+
event.emit({ type: 'thread-close' });
|
|
296
|
+
return true;
|
|
297
|
+
},
|
|
298
|
+
},
|
|
299
|
+
].filter(isNotFalsy),
|
|
300
|
+
),
|
|
301
|
+
),
|
|
302
|
+
].filter(isNotFalsy);
|
|
303
|
+
}, [event, expandable, referencesProvider]);
|
|
304
|
+
|
|
305
|
+
const handleSubmit = useCallback<NonNullable<ChatEditorProps['onSubmit']>>(
|
|
306
|
+
(text) => {
|
|
307
|
+
if (!streaming) {
|
|
308
|
+
event.emit({ type: 'submit', text });
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
[streaming, event],
|
|
313
|
+
);
|
|
314
|
+
|
|
315
|
+
const handleEvent = useCallback<NonNullable<ChatActionsProps['onEvent']>>(
|
|
316
|
+
(ev) => {
|
|
317
|
+
event.emit(ev);
|
|
318
|
+
},
|
|
319
|
+
[event],
|
|
320
|
+
);
|
|
321
|
+
|
|
322
|
+
const handleUpdateReferences = useCallback<NonNullable<ChatReferencesProps['onUpdate']>>((dxns) => {
|
|
323
|
+
log.info('update', { dxns });
|
|
324
|
+
void processor.context.bind({ objects: dxns.map((dxn) => Ref.fromDXN(DXN.parse(dxn))) });
|
|
325
|
+
}, []);
|
|
326
|
+
|
|
327
|
+
const { onUpdateBlueprint } = useBlueprintHandlers({
|
|
328
|
+
space,
|
|
329
|
+
context: processor.context,
|
|
330
|
+
blueprintRegistry: processor.blueprintRegistry,
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
return (
|
|
334
|
+
<div
|
|
335
|
+
className={mx(
|
|
336
|
+
'is-full grid grid-cols-[var(--rail-action)_1fr_var(--rail-action)] grid-rows-[min-content_min-content_min-content]',
|
|
337
|
+
classNames,
|
|
338
|
+
)}
|
|
339
|
+
>
|
|
340
|
+
<Endcap>
|
|
341
|
+
<ChatStatusIndicator preset={preset} error={error} processing={streaming} />
|
|
342
|
+
</Endcap>
|
|
343
|
+
|
|
344
|
+
<ChatEditor
|
|
345
|
+
ref={editorRef}
|
|
346
|
+
autoFocus
|
|
347
|
+
lineWrapping
|
|
348
|
+
classNames='col-span-2 pis-1 pbs-2'
|
|
349
|
+
placeholder={placeholder ?? t('prompt placeholder')}
|
|
350
|
+
extensions={extensions}
|
|
351
|
+
onSubmit={handleSubmit}
|
|
352
|
+
/>
|
|
353
|
+
|
|
354
|
+
<div />
|
|
355
|
+
<ChatReferences
|
|
356
|
+
classNames='col-span-2 flex pis-1 items-center'
|
|
357
|
+
space={space}
|
|
358
|
+
context={processor.context}
|
|
359
|
+
onUpdate={handleUpdateReferences}
|
|
360
|
+
/>
|
|
361
|
+
|
|
362
|
+
<ChatOptions
|
|
363
|
+
blueprintRegistry={processor.blueprintRegistry}
|
|
364
|
+
context={processor.context}
|
|
365
|
+
onUpdateBlueprint={onUpdateBlueprint}
|
|
366
|
+
/>
|
|
367
|
+
|
|
368
|
+
<ChatActions
|
|
369
|
+
classNames='col-span-2'
|
|
370
|
+
microphone={true}
|
|
371
|
+
recording={recording}
|
|
372
|
+
processing={streaming}
|
|
373
|
+
onEvent={handleEvent}
|
|
374
|
+
>
|
|
375
|
+
<>
|
|
376
|
+
<div className='grow' />
|
|
377
|
+
{presets && <ChatPresets preset={preset} presets={presets} onChange={onChangePreset} />}
|
|
378
|
+
{online !== undefined && (
|
|
379
|
+
<Input.Root>
|
|
380
|
+
<Input.Switch classNames='mis-2 mie-2' checked={online} onCheckedChange={onChangeOnline} />
|
|
381
|
+
</Input.Root>
|
|
382
|
+
)}
|
|
383
|
+
</>
|
|
384
|
+
</ChatActions>
|
|
385
|
+
</div>
|
|
386
|
+
);
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
ChatPrompt.displayName = 'Chat.Prompt';
|
|
390
|
+
|
|
391
|
+
//
|
|
392
|
+
// Chat
|
|
393
|
+
//
|
|
394
|
+
|
|
395
|
+
export const Chat = {
|
|
396
|
+
Root: ChatRoot,
|
|
397
|
+
Thread: ChatThread,
|
|
398
|
+
Prompt: ChatPrompt,
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
export type { ChatRootProps, ChatThreadProps, ChatPromptProps, ChatEvent };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Obj } from '@dxos/echo';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The main `ChatRoot` manages the `ChatContextValue` which contains an `event` property that subcomponents
|
|
9
|
+
* can subscribe to and submit events. Unhandled events are passed to the external `onEvent` callback.
|
|
10
|
+
*/
|
|
11
|
+
export type ChatEvent =
|
|
12
|
+
| {
|
|
13
|
+
type: 'toggle-debug';
|
|
14
|
+
}
|
|
15
|
+
//
|
|
16
|
+
// Thread
|
|
17
|
+
//
|
|
18
|
+
| {
|
|
19
|
+
type: 'submit';
|
|
20
|
+
text: string;
|
|
21
|
+
}
|
|
22
|
+
| {
|
|
23
|
+
type: 'cancel';
|
|
24
|
+
}
|
|
25
|
+
| {
|
|
26
|
+
type: 'delete';
|
|
27
|
+
id: string;
|
|
28
|
+
}
|
|
29
|
+
| {
|
|
30
|
+
type: 'add';
|
|
31
|
+
object: Obj.Any;
|
|
32
|
+
}
|
|
33
|
+
//
|
|
34
|
+
// UX
|
|
35
|
+
//
|
|
36
|
+
| {
|
|
37
|
+
type: 'scroll-to-bottom';
|
|
38
|
+
}
|
|
39
|
+
| {
|
|
40
|
+
type: 'thread-open';
|
|
41
|
+
}
|
|
42
|
+
| {
|
|
43
|
+
type: 'thread-close';
|
|
44
|
+
}
|
|
45
|
+
| {
|
|
46
|
+
type: 'record-start';
|
|
47
|
+
}
|
|
48
|
+
| {
|
|
49
|
+
type: 'record-stop';
|
|
50
|
+
};
|
|
@@ -2,36 +2,66 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, {
|
|
5
|
+
import React, { useEffect } from 'react';
|
|
6
6
|
|
|
7
|
-
import { Capabilities,
|
|
8
|
-
import {
|
|
9
|
-
import { TranscriptionCapabilities } from '@dxos/plugin-transcription';
|
|
7
|
+
import { Capabilities, useCapability } from '@dxos/app-framework';
|
|
8
|
+
import { getSpace } from '@dxos/client/echo';
|
|
10
9
|
import { StackItem } from '@dxos/react-ui-stack';
|
|
10
|
+
import { type MaybePromise } from '@dxos/util';
|
|
11
11
|
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
import {
|
|
13
|
+
type AiChatProcessor,
|
|
14
|
+
useBlueprintRegistry,
|
|
15
|
+
useChatProcessor,
|
|
16
|
+
useChatServices,
|
|
17
|
+
useOnline,
|
|
18
|
+
usePresets,
|
|
19
|
+
} from '../hooks';
|
|
20
|
+
import { meta } from '../meta';
|
|
21
|
+
import { type Assistant } from '../types';
|
|
22
|
+
|
|
23
|
+
import { Chat } from './Chat';
|
|
15
24
|
|
|
16
25
|
export type ChatContainerProps = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
26
|
+
chat: Assistant.Chat;
|
|
27
|
+
role?: string;
|
|
28
|
+
onProcessorReady?: (processor: AiChatProcessor) => MaybePromise<void>;
|
|
20
29
|
};
|
|
21
30
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
const
|
|
31
|
+
export const ChatContainer = ({ chat, onProcessorReady }: ChatContainerProps) => {
|
|
32
|
+
const space = getSpace(chat);
|
|
33
|
+
const settings = useCapability(Capabilities.SettingsStore).getStore<Assistant.Settings>(meta.id)?.value;
|
|
34
|
+
const services = useChatServices({ space });
|
|
35
|
+
const [online, setOnline] = useOnline();
|
|
36
|
+
const { preset, ...chatProps } = usePresets(online);
|
|
37
|
+
const blueprintRegistry = useBlueprintRegistry();
|
|
38
|
+
const processor = useChatProcessor({ space, chat, preset, services, blueprintRegistry, settings });
|
|
39
|
+
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (processor && onProcessorReady) {
|
|
42
|
+
const timeout = setTimeout(() => onProcessorReady(processor));
|
|
43
|
+
return () => clearTimeout(timeout);
|
|
44
|
+
}
|
|
45
|
+
}, [processor, onProcessorReady]);
|
|
46
|
+
|
|
47
|
+
if (!chat || !processor) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
26
50
|
|
|
27
51
|
return (
|
|
28
|
-
<StackItem.Content
|
|
29
|
-
<
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
52
|
+
<StackItem.Content classNames='container-max-width'>
|
|
53
|
+
<Chat.Root chat={chat} processor={processor}>
|
|
54
|
+
<Chat.Thread />
|
|
55
|
+
<div className='p-2'>
|
|
56
|
+
<Chat.Prompt
|
|
57
|
+
{...chatProps}
|
|
58
|
+
classNames='p-2 border border-transparent rounded-md'
|
|
59
|
+
preset={preset?.id}
|
|
60
|
+
online={online}
|
|
61
|
+
onChangeOnline={setOnline}
|
|
62
|
+
/>
|
|
63
|
+
</div>
|
|
64
|
+
</Chat.Root>
|
|
35
65
|
</StackItem.Content>
|
|
36
66
|
);
|
|
37
67
|
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useCallback, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { Capabilities, useCapability } 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 { useBlueprintRegistry, useChatProcessor, useChatServices, useOnline, usePresets } from '../hooks';
|
|
13
|
+
import { meta } from '../meta';
|
|
14
|
+
import { type Assistant } from '../types';
|
|
15
|
+
|
|
16
|
+
import { Chat, type ChatRootProps } from './Chat';
|
|
17
|
+
|
|
18
|
+
export type ChatDialogProps = {
|
|
19
|
+
chat?: Assistant.Chat;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const ChatDialog = ({ chat }: ChatDialogProps) => {
|
|
23
|
+
const { t } = useTranslation(meta.id);
|
|
24
|
+
|
|
25
|
+
const space = getSpace(chat);
|
|
26
|
+
const settings = useCapability(Capabilities.SettingsStore).getStore<Assistant.Settings>(meta.id)?.value;
|
|
27
|
+
const services = useChatServices({ space });
|
|
28
|
+
const [online, setOnline] = useOnline();
|
|
29
|
+
const { preset, ...chatProps } = usePresets(online);
|
|
30
|
+
const blueprintRegistry = useBlueprintRegistry();
|
|
31
|
+
const processor = useChatProcessor({ space, chat, preset, services, blueprintRegistry, settings });
|
|
32
|
+
|
|
33
|
+
// TODO(burdon): Refocus when open.
|
|
34
|
+
const [open, setOpen] = useState(true);
|
|
35
|
+
const [expanded, setExpanded] = useState(false);
|
|
36
|
+
const handleEvent = useCallback<NonNullable<ChatRootProps['onEvent']>>((event) => {
|
|
37
|
+
switch (event.type) {
|
|
38
|
+
case 'submit':
|
|
39
|
+
case 'thread-open':
|
|
40
|
+
setOpen(true);
|
|
41
|
+
setExpanded(true);
|
|
42
|
+
break;
|
|
43
|
+
case 'thread-close':
|
|
44
|
+
setOpen(false);
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}, []);
|
|
48
|
+
|
|
49
|
+
if (!chat || !processor) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<Chat.Root chat={chat} processor={processor} onEvent={handleEvent}>
|
|
55
|
+
<NativeChatDialog.Root open={open} expanded={expanded} onOpenChange={setOpen}>
|
|
56
|
+
<NativeChatDialog.Header title={t('assistant dialog title')} />
|
|
57
|
+
<NativeChatDialog.Content>
|
|
58
|
+
<Chat.Thread />
|
|
59
|
+
</NativeChatDialog.Content>
|
|
60
|
+
<NativeChatDialog.Footer>
|
|
61
|
+
<Chat.Prompt {...chatProps} preset={preset?.id} online={online} onChangeOnline={setOnline} expandable />
|
|
62
|
+
</NativeChatDialog.Footer>
|
|
63
|
+
</NativeChatDialog.Root>
|
|
64
|
+
</Chat.Root>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
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
|
+
};
|