@dxos/plugin-assistant 0.7.5-main.5ae2ba8
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/LICENSE +8 -0
- package/README.md +15 -0
- package/dist/lib/browser/AssistantDialog-TX6YYBUG.mjs +116 -0
- package/dist/lib/browser/AssistantDialog-TX6YYBUG.mjs.map +7 -0
- package/dist/lib/browser/ChatContainer-AT3OAUT3.mjs +33 -0
- package/dist/lib/browser/ChatContainer-AT3OAUT3.mjs.map +7 -0
- package/dist/lib/browser/TemplateContainer-B7MQNUPY.mjs +23 -0
- package/dist/lib/browser/TemplateContainer-B7MQNUPY.mjs.map +7 -0
- package/dist/lib/browser/ai-client-RTCGRKZE.mjs +22 -0
- package/dist/lib/browser/ai-client-RTCGRKZE.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-AXAIFOGV.mjs +110 -0
- package/dist/lib/browser/app-graph-builder-AXAIFOGV.mjs.map +7 -0
- package/dist/lib/browser/chunk-EUMPBC4T.mjs +81 -0
- package/dist/lib/browser/chunk-EUMPBC4T.mjs.map +7 -0
- package/dist/lib/browser/chunk-FRIKXDDQ.mjs +162 -0
- package/dist/lib/browser/chunk-FRIKXDDQ.mjs.map +7 -0
- package/dist/lib/browser/chunk-G7B54APW.mjs +106 -0
- package/dist/lib/browser/chunk-G7B54APW.mjs.map +7 -0
- package/dist/lib/browser/chunk-NFVIZS3B.mjs +1804 -0
- package/dist/lib/browser/chunk-NFVIZS3B.mjs.map +7 -0
- package/dist/lib/browser/chunk-NV7SVHMV.mjs +20 -0
- package/dist/lib/browser/chunk-NV7SVHMV.mjs.map +7 -0
- package/dist/lib/browser/chunk-VZ4W6SHE.mjs +15 -0
- package/dist/lib/browser/chunk-VZ4W6SHE.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +218 -0
- package/dist/lib/browser/index.mjs.map +7 -0
- package/dist/lib/browser/intent-resolver-QRVRZL6K.mjs +44 -0
- package/dist/lib/browser/intent-resolver-QRVRZL6K.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -0
- package/dist/lib/browser/react-surface-JLXNWOI6.mjs +69 -0
- package/dist/lib/browser/react-surface-JLXNWOI6.mjs.map +7 -0
- package/dist/lib/browser/settings-JTT62IHD.mjs +22 -0
- package/dist/lib/browser/settings-JTT62IHD.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +24 -0
- package/dist/lib/browser/types/index.mjs.map +7 -0
- package/dist/lib/node/AssistantDialog-U4GBPZD6.cjs +140 -0
- package/dist/lib/node/AssistantDialog-U4GBPZD6.cjs.map +7 -0
- package/dist/lib/node/ChatContainer-CVHXNHGA.cjs +61 -0
- package/dist/lib/node/ChatContainer-CVHXNHGA.cjs.map +7 -0
- package/dist/lib/node/TemplateContainer-R4BZZP3E.cjs +53 -0
- package/dist/lib/node/TemplateContainer-R4BZZP3E.cjs.map +7 -0
- package/dist/lib/node/ai-client-YANJEPO3.cjs +38 -0
- package/dist/lib/node/ai-client-YANJEPO3.cjs.map +7 -0
- package/dist/lib/node/app-graph-builder-D7SHQTZS.cjs +122 -0
- package/dist/lib/node/app-graph-builder-D7SHQTZS.cjs.map +7 -0
- package/dist/lib/node/chunk-37GI4NYH.cjs +183 -0
- package/dist/lib/node/chunk-37GI4NYH.cjs.map +7 -0
- package/dist/lib/node/chunk-GNPXCHFT.cjs +44 -0
- package/dist/lib/node/chunk-GNPXCHFT.cjs.map +7 -0
- package/dist/lib/node/chunk-IXJCGW7U.cjs +130 -0
- package/dist/lib/node/chunk-IXJCGW7U.cjs.map +7 -0
- package/dist/lib/node/chunk-NV4TQQSU.cjs +111 -0
- package/dist/lib/node/chunk-NV4TQQSU.cjs.map +7 -0
- package/dist/lib/node/chunk-XUTDR7HI.cjs +1781 -0
- package/dist/lib/node/chunk-XUTDR7HI.cjs.map +7 -0
- package/dist/lib/node/chunk-ZGH6F5YA.cjs +34 -0
- package/dist/lib/node/chunk-ZGH6F5YA.cjs.map +7 -0
- package/dist/lib/node/index.cjs +226 -0
- package/dist/lib/node/index.cjs.map +7 -0
- package/dist/lib/node/intent-resolver-YMMAFVOB.cjs +58 -0
- package/dist/lib/node/intent-resolver-YMMAFVOB.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -0
- package/dist/lib/node/react-surface-BSUZQ3HZ.cjs +85 -0
- package/dist/lib/node/react-surface-BSUZQ3HZ.cjs.map +7 -0
- package/dist/lib/node/settings-4YEO7KXF.cjs +36 -0
- package/dist/lib/node/settings-4YEO7KXF.cjs.map +7 -0
- package/dist/lib/node/types/index.cjs +46 -0
- package/dist/lib/node/types/index.cjs.map +7 -0
- package/dist/lib/node-esm/AssistantDialog-5AT5JAZL.mjs +117 -0
- package/dist/lib/node-esm/AssistantDialog-5AT5JAZL.mjs.map +7 -0
- package/dist/lib/node-esm/ChatContainer-VR766C4M.mjs +34 -0
- package/dist/lib/node-esm/ChatContainer-VR766C4M.mjs.map +7 -0
- package/dist/lib/node-esm/TemplateContainer-WSHTZBB5.mjs +24 -0
- package/dist/lib/node-esm/TemplateContainer-WSHTZBB5.mjs.map +7 -0
- package/dist/lib/node-esm/ai-client-66IBZVCX.mjs +23 -0
- package/dist/lib/node-esm/ai-client-66IBZVCX.mjs.map +7 -0
- package/dist/lib/node-esm/app-graph-builder-H2GC2AZA.mjs +111 -0
- package/dist/lib/node-esm/app-graph-builder-H2GC2AZA.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-77ARTFBA.mjs +16 -0
- package/dist/lib/node-esm/chunk-77ARTFBA.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-7JENJTLB.mjs +1805 -0
- package/dist/lib/node-esm/chunk-7JENJTLB.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-7SV6X6XU.mjs +22 -0
- package/dist/lib/node-esm/chunk-7SV6X6XU.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-AMQMVQJO.mjs +107 -0
- package/dist/lib/node-esm/chunk-AMQMVQJO.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-CJ4Y3QW5.mjs +163 -0
- package/dist/lib/node-esm/chunk-CJ4Y3QW5.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-LBQGJE5T.mjs +82 -0
- package/dist/lib/node-esm/chunk-LBQGJE5T.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +219 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/intent-resolver-MR7BOKEW.mjs +45 -0
- package/dist/lib/node-esm/intent-resolver-MR7BOKEW.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/lib/node-esm/react-surface-IGVYAOGL.mjs +70 -0
- package/dist/lib/node-esm/react-surface-IGVYAOGL.mjs.map +7 -0
- package/dist/lib/node-esm/settings-S7P5RWQI.mjs +23 -0
- package/dist/lib/node-esm/settings-S7P5RWQI.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +25 -0
- package/dist/lib/node-esm/types/index.mjs.map +7 -0
- package/dist/types/src/AssistantPlugin.d.ts +2 -0
- package/dist/types/src/AssistantPlugin.d.ts.map +1 -0
- package/dist/types/src/capabilities/ai-client.d.ts +5 -0
- package/dist/types/src/capabilities/ai-client.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +181 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/capabilities.d.ts +5 -0
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +183 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts +4 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +4 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings.d.ts +4 -0
- package/dist/types/src/capabilities/settings.d.ts.map +1 -0
- package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts +7 -0
- package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts.map +1 -0
- package/dist/types/src/components/AmbientDialog/AmbientDialog.stories.d.ts +8 -0
- package/dist/types/src/components/AmbientDialog/AmbientDialog.stories.d.ts.map +1 -0
- package/dist/types/src/components/AmbientDialog/index.d.ts +2 -0
- package/dist/types/src/components/AmbientDialog/index.d.ts.map +1 -0
- package/dist/types/src/components/AssistantDialog.d.ts +7 -0
- package/dist/types/src/components/AssistantDialog.d.ts.map +1 -0
- package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts +5 -0
- package/dist/types/src/components/AssistantSettings/AssistantSettings.d.ts.map +1 -0
- package/dist/types/src/components/AssistantSettings/index.d.ts +2 -0
- package/dist/types/src/components/AssistantSettings/index.d.ts.map +1 -0
- package/dist/types/src/components/ChatContainer.d.ts +7 -0
- package/dist/types/src/components/ChatContainer.d.ts.map +1 -0
- package/dist/types/src/components/Prompt/Prompt.d.ts +17 -0
- package/dist/types/src/components/Prompt/Prompt.d.ts.map +1 -0
- package/dist/types/src/components/Prompt/Prompt.stories.d.ts +9 -0
- package/dist/types/src/components/Prompt/Prompt.stories.d.ts.map +1 -0
- package/dist/types/src/components/Prompt/PromptBar.d.ts +10 -0
- package/dist/types/src/components/Prompt/PromptBar.d.ts.map +1 -0
- package/dist/types/src/components/Prompt/autocomplete.d.ts +21 -0
- package/dist/types/src/components/Prompt/autocomplete.d.ts.map +1 -0
- package/dist/types/src/components/Prompt/index.d.ts +3 -0
- package/dist/types/src/components/Prompt/index.d.ts.map +1 -0
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts +5 -0
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts.map +1 -0
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.stories.d.ts +8 -0
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.stories.d.ts.map +1 -0
- package/dist/types/src/components/ServiceRegistry/index.d.ts +2 -0
- package/dist/types/src/components/ServiceRegistry/index.d.ts.map +1 -0
- package/dist/types/src/components/TemplateContainer.d.ts +7 -0
- package/dist/types/src/components/TemplateContainer.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +12 -0
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +12 -0
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +10 -0
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +8 -0
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/index.d.ts +2 -0
- package/dist/types/src/components/TemplateEditor/index.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/types.d.ts +18 -0
- package/dist/types/src/components/TemplateEditor/types.d.ts.map +1 -0
- package/dist/types/src/components/Thread/Thread.d.ts +17 -0
- package/dist/types/src/components/Thread/Thread.d.ts.map +1 -0
- package/dist/types/src/components/Thread/Thread.stories.d.ts +11 -0
- package/dist/types/src/components/Thread/Thread.stories.d.ts.map +1 -0
- package/dist/types/src/components/Thread/ThreadContainer.d.ts +10 -0
- package/dist/types/src/components/Thread/ThreadContainer.d.ts.map +1 -0
- package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts +15 -0
- package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts.map +1 -0
- package/dist/types/src/components/Thread/ThreadMessage.d.ts +14 -0
- package/dist/types/src/components/Thread/ThreadMessage.d.ts.map +1 -0
- package/dist/types/src/components/Thread/ToolInvocations.d.ts +13 -0
- package/dist/types/src/components/Thread/ToolInvocations.d.ts.map +1 -0
- package/dist/types/src/components/Thread/index.d.ts +3 -0
- package/dist/types/src/components/Thread/index.d.ts.map +1 -0
- package/dist/types/src/components/Thread/reducer.d.ts +12 -0
- package/dist/types/src/components/Thread/reducer.d.ts.map +1 -0
- package/dist/types/src/components/Toolbox/Toolbox.d.ts +19 -0
- package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -0
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +8 -0
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -0
- package/dist/types/src/components/Toolbox/index.d.ts +2 -0
- package/dist/types/src/components/Toolbox/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +17 -0
- package/dist/types/src/components/index.d.ts.map +1 -0
- package/dist/types/src/hooks/email.d.ts +4 -0
- package/dist/types/src/hooks/email.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +7 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/invocation-handler.d.ts +5 -0
- package/dist/types/src/hooks/invocation-handler.d.ts.map +1 -0
- package/dist/types/src/hooks/processor.d.ts +76 -0
- package/dist/types/src/hooks/processor.d.ts.map +1 -0
- package/dist/types/src/hooks/processor.test.d.ts +2 -0
- package/dist/types/src/hooks/processor.test.d.ts.map +1 -0
- package/dist/types/src/hooks/useChatProcessor.d.ts +8 -0
- package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -0
- package/dist/types/src/hooks/useLocalTriggerManager.d.ts +3 -0
- package/dist/types/src/hooks/useLocalTriggerManager.d.ts.map +1 -0
- package/dist/types/src/hooks/useMessageQueue.d.ts +41 -0
- package/dist/types/src/hooks/useMessageQueue.d.ts.map +1 -0
- package/dist/types/src/hooks/useServices.d.ts +7 -0
- package/dist/types/src/hooks/useServices.d.ts.map +1 -0
- package/dist/types/src/hooks/useTextInputEvents.d.ts +13 -0
- package/dist/types/src/hooks/useTextInputEvents.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +5 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +11 -0
- package/dist/types/src/meta.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +3 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/test-functions.d.ts +3 -0
- package/dist/types/src/testing/test-functions.d.ts.map +1 -0
- package/dist/types/src/testing/test-services.d.ts +5 -0
- package/dist/types/src/testing/test-services.d.ts.map +1 -0
- package/dist/types/src/tools/function.d.ts +5 -0
- package/dist/types/src/tools/function.d.ts.map +1 -0
- package/dist/types/src/tools/index.d.ts +3 -0
- package/dist/types/src/tools/index.d.ts.map +1 -0
- package/dist/types/src/tools/openapi.d.ts +10 -0
- package/dist/types/src/tools/openapi.d.ts.map +1 -0
- package/dist/types/src/tools/openapi.test.d.ts +2 -0
- package/dist/types/src/tools/openapi.test.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +82 -0
- package/dist/types/src/translations.d.ts.map +1 -0
- package/dist/types/src/types/chat.d.ts +12 -0
- package/dist/types/src/types/chat.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +5 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/types/service.d.ts +160 -0
- package/dist/types/src/types/service.d.ts.map +1 -0
- package/dist/types/src/types/template.d.ts +40 -0
- package/dist/types/src/types/template.d.ts.map +1 -0
- package/dist/types/src/types/types.d.ts +37 -0
- package/dist/types/src/types/types.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +120 -0
- package/src/AssistantPlugin.tsx +105 -0
- package/src/capabilities/ai-client.ts +19 -0
- package/src/capabilities/app-graph-builder.ts +100 -0
- package/src/capabilities/capabilities.ts +12 -0
- package/src/capabilities/index.ts +13 -0
- package/src/capabilities/intent-resolver.ts +38 -0
- package/src/capabilities/react-surface.tsx +49 -0
- package/src/capabilities/settings.ts +19 -0
- package/src/components/AmbientDialog/AmbientDialog.stories.tsx +81 -0
- package/src/components/AmbientDialog/AmbientDialog.tsx +103 -0
- package/src/components/AmbientDialog/index.ts +5 -0
- package/src/components/AssistantDialog.tsx +31 -0
- package/src/components/AssistantSettings/AssistantSettings.tsx +49 -0
- package/src/components/AssistantSettings/index.ts +5 -0
- package/src/components/ChatContainer.tsx +27 -0
- package/src/components/Prompt/Prompt.stories.tsx +79 -0
- package/src/components/Prompt/Prompt.tsx +100 -0
- package/src/components/Prompt/PromptBar.tsx +100 -0
- package/src/components/Prompt/autocomplete.ts +212 -0
- package/src/components/Prompt/index.ts +6 -0
- package/src/components/ServiceRegistry/ServiceRegistry.stories.tsx +49 -0
- package/src/components/ServiceRegistry/ServiceRegistry.tsx +76 -0
- package/src/components/ServiceRegistry/index.ts +5 -0
- package/src/components/TemplateContainer.tsx +21 -0
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +83 -0
- package/src/components/TemplateEditor/TemplateEditor.tsx +76 -0
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +65 -0
- package/src/components/TemplateEditor/TemplateForm.tsx +184 -0
- package/src/components/TemplateEditor/index.ts +5 -0
- package/src/components/TemplateEditor/types.tsx +28 -0
- package/src/components/Thread/Thread.stories.tsx +212 -0
- package/src/components/Thread/Thread.tsx +97 -0
- package/src/components/Thread/ThreadContainer.stories.tsx +268 -0
- package/src/components/Thread/ThreadContainer.tsx +79 -0
- package/src/components/Thread/ThreadMessage.tsx +188 -0
- package/src/components/Thread/ToolInvocations.tsx +104 -0
- package/src/components/Thread/index.ts +6 -0
- package/src/components/Thread/reducer.ts +52 -0
- package/src/components/Toolbox/Toolbox.stories.tsx +69 -0
- package/src/components/Toolbox/Toolbox.tsx +115 -0
- package/src/components/Toolbox/index.ts +5 -0
- package/src/components/index.ts +15 -0
- package/src/hooks/email.ts +49 -0
- package/src/hooks/index.ts +11 -0
- package/src/hooks/invocation-handler.ts +109 -0
- package/src/hooks/processor.test.ts +15 -0
- package/src/hooks/processor.ts +228 -0
- package/src/hooks/useChatProcessor.tsx +80 -0
- package/src/hooks/useLocalTriggerManager.ts +82 -0
- package/src/hooks/useMessageQueue.ts +23 -0
- package/src/hooks/useServices.ts +28 -0
- package/src/hooks/useTextInputEvents.ts +49 -0
- package/src/index.ts +9 -0
- package/src/meta.ts +18 -0
- package/src/testing/index.ts +6 -0
- package/src/testing/test-functions.ts +11 -0
- package/src/testing/test-services.ts +131 -0
- package/src/tools/function.ts +47 -0
- package/src/tools/index.ts +6 -0
- package/src/tools/openapi.test.ts +224 -0
- package/src/tools/openapi.ts +331 -0
- package/src/translations.ts +49 -0
- package/src/types/chat.ts +11 -0
- package/src/types/index.ts +8 -0
- package/src/types/service.ts +102 -0
- package/src/types/template.ts +34 -0
- package/src/types/types.ts +41 -0
- package/src/typings.d.ts +9 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { Capabilities, contributes, createSurface } from '@dxos/app-framework';
|
|
8
|
+
import { SettingsStore } from '@dxos/local-storage';
|
|
9
|
+
import { getSpace, isSpace } from '@dxos/react-client/echo';
|
|
10
|
+
|
|
11
|
+
import { AssistantDialog, AssistantSettings, ChatContainer, ServiceRegistry, TemplateContainer } from '../components';
|
|
12
|
+
import { ASSISTANT_PLUGIN, ASSISTANT_DIALOG } from '../meta';
|
|
13
|
+
import { AIChatType, type AssistantSettingsProps, TemplateType } from '../types';
|
|
14
|
+
|
|
15
|
+
export default () =>
|
|
16
|
+
contributes(Capabilities.ReactSurface, [
|
|
17
|
+
createSurface({
|
|
18
|
+
id: `${ASSISTANT_PLUGIN}/settings`,
|
|
19
|
+
role: 'article',
|
|
20
|
+
filter: (data): data is { subject: SettingsStore<AssistantSettingsProps> } =>
|
|
21
|
+
data.subject instanceof SettingsStore && data.subject.prefix === ASSISTANT_PLUGIN,
|
|
22
|
+
component: ({ data: { subject } }) => <AssistantSettings settings={subject.value} />,
|
|
23
|
+
}),
|
|
24
|
+
createSurface({
|
|
25
|
+
id: ASSISTANT_DIALOG,
|
|
26
|
+
role: 'dialog',
|
|
27
|
+
filter: (data): data is { props: { chat: AIChatType } } => data.component === ASSISTANT_DIALOG,
|
|
28
|
+
component: ({ data }) => <AssistantDialog {...data.props} />,
|
|
29
|
+
}),
|
|
30
|
+
createSurface({
|
|
31
|
+
id: `${ASSISTANT_PLUGIN}/chat`,
|
|
32
|
+
role: 'article',
|
|
33
|
+
filter: (data): data is { subject: AIChatType } => data.subject instanceof AIChatType,
|
|
34
|
+
component: ({ data, role }) => <ChatContainer role={role} chat={data.subject} />,
|
|
35
|
+
}),
|
|
36
|
+
createSurface({
|
|
37
|
+
id: `${ASSISTANT_PLUGIN}/template`,
|
|
38
|
+
role: 'article',
|
|
39
|
+
filter: (data): data is { subject: TemplateType } => data.subject instanceof TemplateType,
|
|
40
|
+
component: ({ data, role }) => <TemplateContainer role={role} template={data.subject} />,
|
|
41
|
+
}),
|
|
42
|
+
createSurface({
|
|
43
|
+
id: `${ASSISTANT_PLUGIN}/service-registry`,
|
|
44
|
+
role: 'complementary--service-registry',
|
|
45
|
+
component: ({ data }) => (
|
|
46
|
+
<ServiceRegistry space={isSpace(data.subject) ? data.subject : getSpace(data.subject)!} />
|
|
47
|
+
),
|
|
48
|
+
}),
|
|
49
|
+
]);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Capabilities, contributes } from '@dxos/app-framework';
|
|
6
|
+
import { create } from '@dxos/live-object';
|
|
7
|
+
|
|
8
|
+
import { ASSISTANT_PLUGIN } from '../meta';
|
|
9
|
+
import { type AssistantSettingsProps, AssistantSettingsSchema } from '../types';
|
|
10
|
+
|
|
11
|
+
export default () => {
|
|
12
|
+
const settings = create<AssistantSettingsProps>({});
|
|
13
|
+
|
|
14
|
+
return contributes(Capabilities.Settings, {
|
|
15
|
+
schema: AssistantSettingsSchema,
|
|
16
|
+
prefix: ASSISTANT_PLUGIN,
|
|
17
|
+
value: settings,
|
|
18
|
+
});
|
|
19
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxos-theme';
|
|
6
|
+
|
|
7
|
+
import { type StoryObj, type Meta } from '@storybook/react';
|
|
8
|
+
import React, { useState } from 'react';
|
|
9
|
+
|
|
10
|
+
import { IntentPlugin } from '@dxos/app-framework';
|
|
11
|
+
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
12
|
+
import { Config } from '@dxos/client';
|
|
13
|
+
import { faker } from '@dxos/random';
|
|
14
|
+
import { withClientProvider } from '@dxos/react-client/testing';
|
|
15
|
+
import { Dialog, Toolbar, Button } from '@dxos/react-ui';
|
|
16
|
+
import { withTheme, withLayout } from '@dxos/storybook-utils';
|
|
17
|
+
|
|
18
|
+
import { AmbientDialog } from './AmbientDialog';
|
|
19
|
+
import translations from '../../translations';
|
|
20
|
+
|
|
21
|
+
const meta: Meta<typeof AmbientDialog> = {
|
|
22
|
+
title: 'plugins/plugin-automation/AmbientDialog',
|
|
23
|
+
component: AmbientDialog,
|
|
24
|
+
render: () => {
|
|
25
|
+
const [open, setOpen] = useState(true);
|
|
26
|
+
const [items, setItems] = useState<string[]>([]);
|
|
27
|
+
return (
|
|
28
|
+
<>
|
|
29
|
+
<div>
|
|
30
|
+
<Toolbar.Root>
|
|
31
|
+
<Toolbar.Button onClick={() => setOpen(true)}>Open</Toolbar.Button>
|
|
32
|
+
</Toolbar.Root>
|
|
33
|
+
</div>
|
|
34
|
+
<Dialog.Root open={open} onOpenChange={setOpen}>
|
|
35
|
+
<AmbientDialog>
|
|
36
|
+
<div className='flex flex-col h-full overflow-hidden'>
|
|
37
|
+
<div className='flex flex-col h-full gap-2 overflow-auto'>
|
|
38
|
+
{items.map((item) => (
|
|
39
|
+
<div key={item} className='px-2'>
|
|
40
|
+
{item}
|
|
41
|
+
</div>
|
|
42
|
+
))}
|
|
43
|
+
{items.length > 0 && <div className='pbe-2' />}
|
|
44
|
+
</div>
|
|
45
|
+
<div className='shrink-0 h-[40px]'>
|
|
46
|
+
<Button onClick={() => setItems([...items, faker.lorem.word()])}>Add</Button>
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
</AmbientDialog>
|
|
50
|
+
</Dialog.Root>
|
|
51
|
+
</>
|
|
52
|
+
);
|
|
53
|
+
},
|
|
54
|
+
decorators: [
|
|
55
|
+
withClientProvider({
|
|
56
|
+
config: new Config({
|
|
57
|
+
runtime: {
|
|
58
|
+
client: { edgeFeatures: { signaling: true } },
|
|
59
|
+
services: {
|
|
60
|
+
edge: { url: 'https://edge.dxos.workers.dev/' },
|
|
61
|
+
iceProviders: [{ urls: 'https://edge.dxos.workers.dev/ice' }],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
}),
|
|
65
|
+
createIdentity: true,
|
|
66
|
+
createSpace: true,
|
|
67
|
+
}),
|
|
68
|
+
withPluginManager({ plugins: [IntentPlugin()] }),
|
|
69
|
+
withTheme,
|
|
70
|
+
withLayout({ fullscreen: true, tooltips: true }),
|
|
71
|
+
],
|
|
72
|
+
parameters: {
|
|
73
|
+
translations,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export default meta;
|
|
78
|
+
|
|
79
|
+
type Story = StoryObj<typeof AmbientDialog>;
|
|
80
|
+
|
|
81
|
+
export const Default: Story = {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { type PropsWithChildren, useCallback, useEffect, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { Dialog, Icon, IconButton } from '@dxos/react-ui';
|
|
8
|
+
import { resizeAttributes, ResizeHandle, type Size, sizeStyle } from '@dxos/react-ui-dnd';
|
|
9
|
+
import { mx } from '@dxos/react-ui-theme';
|
|
10
|
+
|
|
11
|
+
const preventDefault = (event: Event) => event.preventDefault();
|
|
12
|
+
|
|
13
|
+
const minSize = 5;
|
|
14
|
+
|
|
15
|
+
// TODO(burdon): Factor out.
|
|
16
|
+
export const AmbientDialog = ({
|
|
17
|
+
children,
|
|
18
|
+
open: _open,
|
|
19
|
+
title,
|
|
20
|
+
onOpenChange,
|
|
21
|
+
}: PropsWithChildren<{ open?: boolean; onOpenChange?: (open: boolean) => void; title?: string }>) => {
|
|
22
|
+
const [resizeKey, setReizeKey] = useState(0);
|
|
23
|
+
const [size, setSize] = useState<Size>('min-content');
|
|
24
|
+
const [open, setOpen] = useState(_open);
|
|
25
|
+
|
|
26
|
+
// Update controlled value.
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
setOpen(_open);
|
|
29
|
+
}, [_open]);
|
|
30
|
+
|
|
31
|
+
// Update size and key.
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
setSize(open ? 'min-content' : minSize);
|
|
34
|
+
setReizeKey((key) => key + 1);
|
|
35
|
+
}, [open]);
|
|
36
|
+
|
|
37
|
+
// TODO(burdon): Animate open/close.
|
|
38
|
+
// NOTE: We set the min size to 5rem (80px), and the header and prompt bar to 40px (i.e., the rail-size) each.
|
|
39
|
+
// The dialog has no vertical padding and has box-content so that when closed it collapses to the size of the header and prompt bar.
|
|
40
|
+
const handleToggle = useCallback(() => {
|
|
41
|
+
setOpen((open) => {
|
|
42
|
+
onOpenChange?.(!open);
|
|
43
|
+
return !open;
|
|
44
|
+
});
|
|
45
|
+
}, []);
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<div role='none' className='dx-dialog__overlay bg-transparent pointer-events-none' data-block-align='end'>
|
|
49
|
+
<Dialog.Content
|
|
50
|
+
classNames='relative box-content py-0 px-2 md:is-[35rem] md:max-is-none overflow-hidden pointer-events-auto transition-[block-size] ease-in-out duration-0 [&:not([data-dx-resizing="true"])]:duration-200'
|
|
51
|
+
inOverlayLayout
|
|
52
|
+
{...resizeAttributes}
|
|
53
|
+
style={{
|
|
54
|
+
...sizeStyle(size, 'vertical', true),
|
|
55
|
+
maxBlockSize: 'calc(100dvh - env(safe-area-inset-bottom) - env(safe-area-inset-top) - 8rem)',
|
|
56
|
+
}}
|
|
57
|
+
onInteractOutside={preventDefault}
|
|
58
|
+
>
|
|
59
|
+
<ResizeHandle
|
|
60
|
+
key={resizeKey}
|
|
61
|
+
side='block-start'
|
|
62
|
+
defaultSize='min-content'
|
|
63
|
+
minSize={minSize}
|
|
64
|
+
fallbackSize={minSize}
|
|
65
|
+
iconPosition='center'
|
|
66
|
+
onSizeChange={setSize}
|
|
67
|
+
/>
|
|
68
|
+
|
|
69
|
+
<DialogHeader open={open} title={title} onToggle={handleToggle} />
|
|
70
|
+
|
|
71
|
+
{children}
|
|
72
|
+
</Dialog.Content>
|
|
73
|
+
</div>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Matches same layout grid as PromptBar.
|
|
79
|
+
*/
|
|
80
|
+
const DialogHeader = ({ open, title, onToggle }: { open?: boolean; title?: string; onToggle: () => void }) => {
|
|
81
|
+
return (
|
|
82
|
+
<div className='flex shrink-0 w-full grid grid-cols-[var(--rail-action)_1fr_var(--rail-action)] items-center overflow-hidden'>
|
|
83
|
+
<div className='flex w-[--rail-action] h-[--rail-action] items-center justify-center'>
|
|
84
|
+
<Dialog.Close>
|
|
85
|
+
<Icon icon='ph--x--regular' />
|
|
86
|
+
</Dialog.Close>
|
|
87
|
+
</div>
|
|
88
|
+
<div className='grow'>
|
|
89
|
+
<Dialog.Title classNames='flex justify-center text-xs text-subdued'>{title}</Dialog.Title>
|
|
90
|
+
</div>
|
|
91
|
+
<div className='flex w-[--rail-action] h-[--rail-action] items-center justify-center'>
|
|
92
|
+
<IconButton
|
|
93
|
+
variant='ghost'
|
|
94
|
+
icon={'ph--caret-up--regular'}
|
|
95
|
+
classNames={mx('[&>svg]:transition [&>svg]:duration-200', open && '[&>svg]:rotate-180')}
|
|
96
|
+
iconOnly
|
|
97
|
+
label='Shrink'
|
|
98
|
+
onClick={onToggle}
|
|
99
|
+
/>
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
);
|
|
103
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { type FC, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { useCapability, Capabilities, useCapabilities } from '@dxos/app-framework';
|
|
8
|
+
import { TranscriptionCapabilities } from '@dxos/plugin-transcription';
|
|
9
|
+
import { useTranslation } from '@dxos/react-ui';
|
|
10
|
+
|
|
11
|
+
import { AmbientDialog } from './AmbientDialog';
|
|
12
|
+
import { ThreadContainer } from './Thread';
|
|
13
|
+
import { ASSISTANT_PLUGIN } from '../meta';
|
|
14
|
+
import { type AssistantSettingsProps, type AIChatType } from '../types';
|
|
15
|
+
|
|
16
|
+
export const AssistantDialog: FC<{ chat?: AIChatType }> = ({ chat }) => {
|
|
17
|
+
const { t } = useTranslation(ASSISTANT_PLUGIN);
|
|
18
|
+
const transcription = useCapabilities(TranscriptionCapabilities.Transcription).length > 0;
|
|
19
|
+
const settings = useCapability(Capabilities.SettingsStore).getStore<AssistantSettingsProps>(ASSISTANT_PLUGIN)?.value;
|
|
20
|
+
|
|
21
|
+
// TODO(burdon): Refocus when open.
|
|
22
|
+
const [open, setOpen] = useState(false);
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<AmbientDialog open={open} onOpenChange={setOpen} title={t('assistant dialog title')}>
|
|
26
|
+
<ThreadContainer chat={chat} onOpenChange={setOpen} settings={settings} transcription={transcription} />
|
|
27
|
+
</AmbientDialog>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default AssistantDialog;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { DEFAULT_LLM_MODELS } from '@dxos/assistant';
|
|
8
|
+
import { Input, Select, useTranslation } from '@dxos/react-ui';
|
|
9
|
+
import { DeprecatedFormContainer, DeprecatedFormInput } from '@dxos/react-ui-form';
|
|
10
|
+
|
|
11
|
+
import { ASSISTANT_PLUGIN } from '../../meta';
|
|
12
|
+
import { type AssistantSettingsProps } from '../../types';
|
|
13
|
+
|
|
14
|
+
export const AssistantSettings = ({ settings }: { settings: AssistantSettingsProps }) => {
|
|
15
|
+
const { t } = useTranslation(ASSISTANT_PLUGIN);
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<DeprecatedFormContainer>
|
|
19
|
+
<DeprecatedFormInput label={t('settings custom prompts label')}>
|
|
20
|
+
<Input.Switch
|
|
21
|
+
checked={!!settings.customPrompts}
|
|
22
|
+
onCheckedChange={(checked) => (settings.customPrompts = checked)}
|
|
23
|
+
/>
|
|
24
|
+
</DeprecatedFormInput>
|
|
25
|
+
|
|
26
|
+
<DeprecatedFormInput label={t('settings llm model label')}>
|
|
27
|
+
<Select.Root
|
|
28
|
+
value={settings.llmModel ?? 'default'}
|
|
29
|
+
onValueChange={(value) => {
|
|
30
|
+
settings.llmModel = value;
|
|
31
|
+
}}
|
|
32
|
+
>
|
|
33
|
+
<Select.TriggerButton placeholder={t('settings default llm model label')} />
|
|
34
|
+
<Select.Portal>
|
|
35
|
+
<Select.Content>
|
|
36
|
+
<Select.Viewport>
|
|
37
|
+
{DEFAULT_LLM_MODELS.map((model) => (
|
|
38
|
+
<Select.Option key={model} value={model}>
|
|
39
|
+
{model}
|
|
40
|
+
</Select.Option>
|
|
41
|
+
))}
|
|
42
|
+
</Select.Viewport>
|
|
43
|
+
</Select.Content>
|
|
44
|
+
</Select.Portal>
|
|
45
|
+
</Select.Root>
|
|
46
|
+
</DeprecatedFormInput>
|
|
47
|
+
</DeprecatedFormContainer>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { Capabilities, useCapabilities, useCapability } from '@dxos/app-framework';
|
|
8
|
+
import { TranscriptionCapabilities } from '@dxos/plugin-transcription';
|
|
9
|
+
import { StackItem } from '@dxos/react-ui-stack';
|
|
10
|
+
|
|
11
|
+
import { ThreadContainer } from './Thread';
|
|
12
|
+
import { ASSISTANT_PLUGIN } from '../meta';
|
|
13
|
+
import { type AssistantSettingsProps, type AIChatType } from '../types';
|
|
14
|
+
|
|
15
|
+
// TODO(burdon): Attention.
|
|
16
|
+
export const ChatContainer = ({ chat, role }: { chat: AIChatType; role: string }) => {
|
|
17
|
+
const transcription = useCapabilities(TranscriptionCapabilities.Transcription).length > 0;
|
|
18
|
+
const settings = useCapability(Capabilities.SettingsStore).getStore<AssistantSettingsProps>(ASSISTANT_PLUGIN)?.value;
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<StackItem.Content toolbar={false} role={role} classNames='mli-auto w-full max-w-[50rem]'>
|
|
22
|
+
<ThreadContainer chat={chat} settings={settings} transcription={transcription} />
|
|
23
|
+
</StackItem.Content>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default ChatContainer;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxos-theme';
|
|
6
|
+
|
|
7
|
+
import { type StoryObj, type Meta } from '@storybook/react';
|
|
8
|
+
import React, { useEffect, useState } from 'react';
|
|
9
|
+
|
|
10
|
+
import { withTheme, withLayout } from '@dxos/storybook-utils';
|
|
11
|
+
|
|
12
|
+
import { Prompt } from './Prompt';
|
|
13
|
+
import { PromptBar } from './PromptBar';
|
|
14
|
+
import translations from '../../translations';
|
|
15
|
+
|
|
16
|
+
const meta: Meta<typeof Prompt> = {
|
|
17
|
+
title: 'plugins/plugin-automation/Prompt',
|
|
18
|
+
component: Prompt,
|
|
19
|
+
decorators: [withTheme, withLayout({ tooltips: true })],
|
|
20
|
+
parameters: {
|
|
21
|
+
layout: 'centered',
|
|
22
|
+
translations,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default meta;
|
|
27
|
+
|
|
28
|
+
type Story = StoryObj<typeof Prompt>;
|
|
29
|
+
|
|
30
|
+
export const Default: Story = {
|
|
31
|
+
args: {
|
|
32
|
+
classNames: 'w-96 p-4 rounded outline outline-gray-200',
|
|
33
|
+
autoFocus: true,
|
|
34
|
+
onSubmit: (text) => {
|
|
35
|
+
console.log('onEnter', text);
|
|
36
|
+
},
|
|
37
|
+
onSuggest: (text) => {
|
|
38
|
+
const trimmed = text.trim().toLowerCase();
|
|
39
|
+
if (trimmed.length < 2) {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const suggestions = [
|
|
44
|
+
'Create a kanban board',
|
|
45
|
+
'Create a new project',
|
|
46
|
+
'Find flights to Tokyo',
|
|
47
|
+
"Let's play chess",
|
|
48
|
+
'Show me Paris on a map',
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
return suggestions.filter((s) => s.toLowerCase().startsWith(text));
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const Toolbar: Story = {
|
|
57
|
+
render: (args) => {
|
|
58
|
+
const [processing, setProcessing] = useState(false);
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
let t: NodeJS.Timeout;
|
|
61
|
+
if (processing) {
|
|
62
|
+
t = setTimeout(() => setProcessing(false), 10_000);
|
|
63
|
+
}
|
|
64
|
+
return () => clearTimeout(t);
|
|
65
|
+
}, [processing]);
|
|
66
|
+
console.log('processing', processing);
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<PromptBar
|
|
70
|
+
classNames='w-[25rem] p-1 overflow-hidden border border-gray-200 rounded'
|
|
71
|
+
microphone
|
|
72
|
+
processing={processing}
|
|
73
|
+
onSubmit={() => setProcessing(true)}
|
|
74
|
+
onCancel={() => setProcessing(false)}
|
|
75
|
+
{...args}
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
},
|
|
79
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { forwardRef, useImperativeHandle } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type ThemedClassName, useThemeContext } from '@dxos/react-ui';
|
|
8
|
+
import {
|
|
9
|
+
type BasicExtensionsOptions,
|
|
10
|
+
createBasicExtensions,
|
|
11
|
+
createThemeExtensions,
|
|
12
|
+
keymap,
|
|
13
|
+
useTextEditor,
|
|
14
|
+
type UseTextEditorProps,
|
|
15
|
+
} from '@dxos/react-ui-editor';
|
|
16
|
+
import { mx } from '@dxos/react-ui-theme';
|
|
17
|
+
|
|
18
|
+
import { createAutocompleteExtension, type AutocompleteOptions } from './autocomplete';
|
|
19
|
+
|
|
20
|
+
// TODO(burdon): Handle object references.
|
|
21
|
+
|
|
22
|
+
export interface PromptController {
|
|
23
|
+
focus(): void;
|
|
24
|
+
setText(text: string): void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type PromptProps = ThemedClassName<
|
|
28
|
+
{
|
|
29
|
+
onOpenChange?: (open: boolean) => void;
|
|
30
|
+
} & AutocompleteOptions &
|
|
31
|
+
Pick<UseTextEditorProps, 'autoFocus'> &
|
|
32
|
+
Pick<BasicExtensionsOptions, 'lineWrapping' | 'placeholder'>
|
|
33
|
+
>;
|
|
34
|
+
|
|
35
|
+
export const Prompt = forwardRef<PromptController, PromptProps>(
|
|
36
|
+
({ classNames, autoFocus, lineWrapping = false, placeholder, onSubmit, onSuggest, onOpenChange }, forwardRef) => {
|
|
37
|
+
const { themeMode } = useThemeContext();
|
|
38
|
+
const { parentRef, view } = useTextEditor(
|
|
39
|
+
{
|
|
40
|
+
autoFocus,
|
|
41
|
+
extensions: [
|
|
42
|
+
createBasicExtensions({
|
|
43
|
+
bracketMatching: false,
|
|
44
|
+
lineWrapping,
|
|
45
|
+
placeholder,
|
|
46
|
+
}),
|
|
47
|
+
createThemeExtensions({ themeMode }),
|
|
48
|
+
createAutocompleteExtension({ onSubmit, onSuggest }),
|
|
49
|
+
keymap.of([
|
|
50
|
+
{
|
|
51
|
+
key: 'Alt-ArrowUp',
|
|
52
|
+
preventDefault: true,
|
|
53
|
+
run: (view) => {
|
|
54
|
+
onOpenChange?.(true);
|
|
55
|
+
return true;
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
key: 'Alt-ArrowDown',
|
|
60
|
+
preventDefault: true,
|
|
61
|
+
run: (view) => {
|
|
62
|
+
onOpenChange?.(false);
|
|
63
|
+
return true;
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
]),
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
[themeMode, onSubmit, onSuggest],
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
// Expose editor view.
|
|
73
|
+
useImperativeHandle(
|
|
74
|
+
forwardRef,
|
|
75
|
+
() => {
|
|
76
|
+
return {
|
|
77
|
+
focus: () => {
|
|
78
|
+
view?.focus();
|
|
79
|
+
},
|
|
80
|
+
setText: (text: string) => {
|
|
81
|
+
view?.dispatch({
|
|
82
|
+
changes: {
|
|
83
|
+
from: 0,
|
|
84
|
+
to: view.state.doc.length,
|
|
85
|
+
insert: text,
|
|
86
|
+
},
|
|
87
|
+
selection: {
|
|
88
|
+
anchor: text.length,
|
|
89
|
+
head: text.length,
|
|
90
|
+
},
|
|
91
|
+
});
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
[view, onSubmit],
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
return <div ref={parentRef} className={mx('w-full overflow-hidden', classNames)} />;
|
|
99
|
+
},
|
|
100
|
+
);
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useRef, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { useVoiceInput } from '@dxos/plugin-transcription';
|
|
8
|
+
import { Icon, IconButton, type ThemedClassName, useTranslation } from '@dxos/react-ui';
|
|
9
|
+
import { Spinner } from '@dxos/react-ui-sfx';
|
|
10
|
+
import { errorText, mx } from '@dxos/react-ui-theme';
|
|
11
|
+
|
|
12
|
+
import { Prompt, type PromptController, type PromptProps } from './Prompt';
|
|
13
|
+
import { ASSISTANT_PLUGIN } from '../../meta';
|
|
14
|
+
|
|
15
|
+
export type PromptBarProps = ThemedClassName<
|
|
16
|
+
Pick<PromptProps, 'placeholder' | 'lineWrapping' | 'onSubmit' | 'onSuggest' | 'onOpenChange'> & {
|
|
17
|
+
processing?: boolean;
|
|
18
|
+
error?: Error;
|
|
19
|
+
microphone?: boolean;
|
|
20
|
+
onCancel?: () => void;
|
|
21
|
+
}
|
|
22
|
+
>;
|
|
23
|
+
|
|
24
|
+
export const PromptBar = ({
|
|
25
|
+
classNames,
|
|
26
|
+
placeholder,
|
|
27
|
+
processing,
|
|
28
|
+
error,
|
|
29
|
+
microphone,
|
|
30
|
+
onCancel,
|
|
31
|
+
...props
|
|
32
|
+
}: PromptBarProps) => {
|
|
33
|
+
const { t } = useTranslation(ASSISTANT_PLUGIN);
|
|
34
|
+
|
|
35
|
+
const promptRef = useRef<PromptController>(null);
|
|
36
|
+
|
|
37
|
+
// TODO(burdon): Configure capability in TranscriptionPlugin.
|
|
38
|
+
const [active, setActive] = useState(false);
|
|
39
|
+
const { recording } = useVoiceInput({
|
|
40
|
+
active,
|
|
41
|
+
onUpdate: (text) => {
|
|
42
|
+
promptRef.current?.setText(text);
|
|
43
|
+
promptRef.current?.focus();
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// TODO(burdon): Tooltip for error.
|
|
48
|
+
return (
|
|
49
|
+
<div
|
|
50
|
+
className={mx(
|
|
51
|
+
'flex shrink-0 w-full grid grid-cols-[var(--rail-action)_1fr_var(--rail-action)] overflow-hidden',
|
|
52
|
+
classNames,
|
|
53
|
+
)}
|
|
54
|
+
>
|
|
55
|
+
<div className='flex w-[--rail-action] h-[--rail-action] items-center justify-center'>
|
|
56
|
+
{(error && <Icon icon='ph--warning-circle--regular' classNames={errorText} size={5} />) || (
|
|
57
|
+
<Spinner active={processing} />
|
|
58
|
+
)}
|
|
59
|
+
</div>
|
|
60
|
+
<Prompt
|
|
61
|
+
ref={promptRef}
|
|
62
|
+
autoFocus
|
|
63
|
+
classNames='pbs-2'
|
|
64
|
+
lineWrapping={true}
|
|
65
|
+
placeholder={placeholder ?? t('prompt placeholder')}
|
|
66
|
+
{...props}
|
|
67
|
+
/>
|
|
68
|
+
{(onCancel || microphone) && (
|
|
69
|
+
<div className='flex w-[--rail-action] h-[--rail-action] items-center justify-center'>
|
|
70
|
+
{processing && onCancel && (
|
|
71
|
+
<IconButton
|
|
72
|
+
classNames='px-1.5'
|
|
73
|
+
variant='ghost'
|
|
74
|
+
size={5}
|
|
75
|
+
icon='ph--x--regular'
|
|
76
|
+
iconOnly
|
|
77
|
+
label={t('cancel processing button')}
|
|
78
|
+
onClick={onCancel}
|
|
79
|
+
/>
|
|
80
|
+
)}
|
|
81
|
+
{!processing && microphone && (
|
|
82
|
+
<IconButton
|
|
83
|
+
classNames={mx('px-1.5', recording && 'bg-primary-500')}
|
|
84
|
+
variant='ghost'
|
|
85
|
+
size={5}
|
|
86
|
+
icon='ph--microphone--regular'
|
|
87
|
+
iconOnly
|
|
88
|
+
noTooltip
|
|
89
|
+
label={t('microphone button')}
|
|
90
|
+
onMouseDown={() => setActive(true)}
|
|
91
|
+
onMouseUp={() => setActive(false)}
|
|
92
|
+
onTouchStart={() => setActive(true)}
|
|
93
|
+
onTouchEnd={() => setActive(false)}
|
|
94
|
+
/>
|
|
95
|
+
)}
|
|
96
|
+
</div>
|
|
97
|
+
)}
|
|
98
|
+
</div>
|
|
99
|
+
);
|
|
100
|
+
};
|