@dxos/plugin-automation 0.7.4 → 0.7.5-labs.401163d
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/AutomationPanel-VW2XIUPU.mjs +8 -0
- package/dist/lib/browser/ChatContainer-OLRZNGWK.mjs +12 -0
- package/dist/lib/browser/ai-client-5CNY6JBF.mjs +22 -0
- package/dist/lib/browser/ai-client-5CNY6JBF.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-6H7MDCXE.mjs +197 -0
- package/dist/lib/browser/app-graph-builder-6H7MDCXE.mjs.map +7 -0
- package/dist/lib/browser/chunk-2H2EUYXL.mjs +15 -0
- package/dist/lib/browser/chunk-2H2EUYXL.mjs.map +7 -0
- package/dist/lib/browser/chunk-ITG6CBKL.mjs +1602 -0
- package/dist/lib/browser/chunk-ITG6CBKL.mjs.map +7 -0
- package/dist/lib/browser/chunk-MRBC5J4T.mjs +518 -0
- package/dist/lib/browser/chunk-MRBC5J4T.mjs.map +7 -0
- package/dist/lib/browser/chunk-NQFZ6XRX.mjs +243 -0
- package/dist/lib/browser/chunk-NQFZ6XRX.mjs.map +7 -0
- package/dist/lib/browser/chunk-Q4IMHYGH.mjs +150 -0
- package/dist/lib/browser/chunk-Q4IMHYGH.mjs.map +7 -0
- package/dist/lib/browser/{chunk-X5KMOH3I.mjs → chunk-R4JH4TLE.mjs} +6 -4
- package/dist/lib/browser/chunk-R4JH4TLE.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +157 -252
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-resolver-BWAXKT27.mjs +29 -0
- package/dist/lib/browser/intent-resolver-BWAXKT27.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-O6SHIBCA.mjs +58 -0
- package/dist/lib/browser/react-surface-O6SHIBCA.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +12 -3
- package/dist/lib/node/{meta.cjs → AutomationPanel-G6EDDYWW.cjs} +7 -11
- package/dist/lib/node/AutomationPanel-G6EDDYWW.cjs.map +7 -0
- package/dist/lib/node/ChatContainer-GRZDJIG5.cjs +33 -0
- package/dist/lib/node/ChatContainer-GRZDJIG5.cjs.map +7 -0
- package/dist/lib/node/ai-client-FKLPDELV.cjs +38 -0
- package/dist/lib/node/ai-client-FKLPDELV.cjs.map +7 -0
- package/dist/lib/node/app-graph-builder-7JMJLZIE.cjs +212 -0
- package/dist/lib/node/app-graph-builder-7JMJLZIE.cjs.map +7 -0
- package/dist/lib/node/chunk-CFBERLTN.cjs +1586 -0
- package/dist/lib/node/chunk-CFBERLTN.cjs.map +7 -0
- package/dist/lib/node/{chunk-DTJ7XVO2.cjs → chunk-EQYHOTGG.cjs} +11 -8
- package/dist/lib/node/chunk-EQYHOTGG.cjs.map +7 -0
- package/dist/lib/node/chunk-FQUY77HT.cjs +527 -0
- package/dist/lib/node/chunk-FQUY77HT.cjs.map +7 -0
- package/dist/lib/node/chunk-GB7245FH.cjs +173 -0
- package/dist/lib/node/chunk-GB7245FH.cjs.map +7 -0
- package/dist/lib/node/chunk-QXIHYOMF.cjs +267 -0
- package/dist/lib/node/chunk-QXIHYOMF.cjs.map +7 -0
- package/dist/lib/node/chunk-U5Z7LFWB.cjs +34 -0
- package/dist/lib/node/chunk-U5Z7LFWB.cjs.map +7 -0
- package/dist/lib/node/index.cjs +174 -282
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/intent-resolver-C6OKFVEW.cjs +44 -0
- package/dist/lib/node/intent-resolver-C6OKFVEW.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/react-surface-JT6SVCPK.cjs +76 -0
- package/dist/lib/node/react-surface-JT6SVCPK.cjs.map +7 -0
- package/dist/lib/node/types/index.cjs +16 -7
- package/dist/lib/node/types/index.cjs.map +2 -2
- package/dist/lib/node-esm/AutomationPanel-V3IWQAMO.mjs +9 -0
- package/dist/lib/node-esm/AutomationPanel-V3IWQAMO.mjs.map +7 -0
- package/dist/lib/node-esm/ChatContainer-ORVWQPJO.mjs +13 -0
- package/dist/lib/node-esm/ChatContainer-ORVWQPJO.mjs.map +7 -0
- package/dist/lib/node-esm/ai-client-XGNA6SJ5.mjs +23 -0
- package/dist/lib/node-esm/ai-client-XGNA6SJ5.mjs.map +7 -0
- package/dist/lib/node-esm/app-graph-builder-C6NUQGCU.mjs +198 -0
- package/dist/lib/node-esm/app-graph-builder-C6NUQGCU.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-2OKJZ4ZW.mjs +519 -0
- package/dist/lib/node-esm/chunk-2OKJZ4ZW.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-6HLBYDUI.mjs +244 -0
- package/dist/lib/node-esm/chunk-6HLBYDUI.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-7VPT3OO3.mjs +1603 -0
- package/dist/lib/node-esm/chunk-7VPT3OO3.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-DNCXRGAF.mjs +151 -0
- package/dist/lib/node-esm/chunk-DNCXRGAF.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-HNOBZHWK.mjs → chunk-EMVA6QUT.mjs} +6 -4
- package/dist/lib/node-esm/chunk-EMVA6QUT.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-IJRTDSKN.mjs +16 -0
- package/dist/lib/node-esm/chunk-IJRTDSKN.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +157 -252
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intent-resolver-DCP4ZDBA.mjs +30 -0
- package/dist/lib/node-esm/intent-resolver-DCP4ZDBA.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-DSVM33SA.mjs +59 -0
- package/dist/lib/node-esm/react-surface-DSVM33SA.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +12 -3
- package/dist/types/src/AutomationPlugin.d.ts +1 -3
- package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
- package/dist/types/src/artifacts.stories.d.ts +16 -0
- package/dist/types/src/artifacts.stories.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 +182 -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/components/AmbientChatDialog/AmbientChatDialog.d.ts +3 -0
- package/dist/types/src/components/AmbientChatDialog/AmbientChatDialog.d.ts.map +1 -0
- package/dist/types/src/components/AmbientChatDialog/AmbientChatDialog.stories.d.ts +8 -0
- package/dist/types/src/components/AmbientChatDialog/AmbientChatDialog.stories.d.ts.map +1 -0
- package/dist/types/src/components/AmbientChatDialog/index.d.ts +2 -0
- package/dist/types/src/components/AmbientChatDialog/index.d.ts.map +1 -0
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts.map +1 -1
- package/dist/types/src/components/Box/StatusLine.d.ts +11 -0
- package/dist/types/src/components/Box/StatusLine.d.ts.map +1 -0
- package/dist/types/src/components/Box/StatusLine.stories.d.ts +9 -0
- package/dist/types/src/components/Box/StatusLine.stories.d.ts.map +1 -0
- package/dist/types/src/components/Box/Tabbed.d.ts +15 -0
- package/dist/types/src/components/Box/Tabbed.d.ts.map +1 -0
- package/dist/types/src/components/Box/Tabbed.stories.d.ts +8 -0
- package/dist/types/src/components/Box/Tabbed.stories.d.ts.map +1 -0
- package/dist/types/src/components/Box/ToggleContainer.d.ts +13 -0
- package/dist/types/src/components/Box/ToggleContainer.d.ts.map +1 -0
- package/dist/types/src/components/Box/ToggleContainer.stories.d.ts +9 -0
- package/dist/types/src/components/Box/ToggleContainer.stories.d.ts.map +1 -0
- package/dist/types/src/components/Box/index.d.ts +4 -0
- package/dist/types/src/components/Box/index.d.ts.map +1 -0
- package/dist/types/src/components/ChatContainer/ChatContainer.d.ts +7 -0
- package/dist/types/src/components/ChatContainer/ChatContainer.d.ts.map +1 -0
- package/dist/types/src/components/ChatContainer/index.d.ts +4 -0
- package/dist/types/src/components/ChatContainer/index.d.ts.map +1 -0
- package/dist/types/src/components/MarkdownViewer/MarkdownViewer.d.ts +14 -0
- package/dist/types/src/components/MarkdownViewer/MarkdownViewer.d.ts.map +1 -0
- package/dist/types/src/components/MarkdownViewer/MarkdownViewer.stories.d.ts +8 -0
- package/dist/types/src/components/MarkdownViewer/MarkdownViewer.stories.d.ts.map +1 -0
- package/dist/types/src/components/MarkdownViewer/index.d.ts +2 -0
- package/dist/types/src/components/MarkdownViewer/index.d.ts.map +1 -0
- package/dist/types/src/components/Prompt/Prompt.d.ts +7 -0
- package/dist/types/src/components/Prompt/Prompt.d.ts.map +1 -0
- package/dist/types/src/components/Prompt/Prompt.stories.d.ts +8 -0
- package/dist/types/src/components/Prompt/Prompt.stories.d.ts.map +1 -0
- package/dist/types/src/components/Prompt/index.d.ts +2 -0
- package/dist/types/src/components/Prompt/index.d.ts.map +1 -0
- package/dist/types/src/components/Prompt/prompt-autocomplete.d.ts +20 -0
- package/dist/types/src/components/Prompt/prompt-autocomplete.d.ts.map +1 -0
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts +6 -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/Thread/Thread.d.ts +11 -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/ThreadMessage.d.ts +12 -0
- package/dist/types/src/components/Thread/ThreadMessage.d.ts.map +1 -0
- package/dist/types/src/components/Thread/index.d.ts +2 -0
- package/dist/types/src/components/Thread/index.d.ts.map +1 -0
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +1 -2
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +13 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/email.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +4 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/invocation-handler.d.ts.map +1 -1
- package/dist/types/src/hooks/processor.d.ts +70 -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 +7 -0
- package/dist/types/src/hooks/useChatProcessor.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/index.d.ts +1 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +2 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/{testing.d.ts → test-functions.d.ts} +3 -1
- 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 +84 -2
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +1 -0
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/registry.d.ts +10 -0
- package/dist/types/src/types/registry.d.ts.map +1 -0
- package/dist/types/src/types/schema.d.ts +189 -39
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +16 -5
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +57 -48
- package/src/AutomationPlugin.tsx +77 -194
- package/src/artifacts.stories.tsx +241 -0
- package/src/capabilities/ai-client.ts +19 -0
- package/src/capabilities/app-graph-builder.ts +187 -0
- package/src/capabilities/capabilities.ts +12 -0
- package/src/capabilities/index.ts +12 -0
- package/src/capabilities/intent-resolver.ts +27 -0
- package/src/capabilities/react-surface.tsx +42 -0
- package/src/components/AmbientChatDialog/AmbientChatDialog.stories.tsx +44 -0
- package/src/components/AmbientChatDialog/AmbientChatDialog.tsx +63 -0
- package/src/components/AmbientChatDialog/index.ts +5 -0
- package/src/components/AutomationPanel/AutomationPanel.stories.tsx +1 -2
- package/src/components/AutomationPanel/AutomationPanel.tsx +61 -39
- package/src/components/Box/StatusLine.stories.tsx +52 -0
- package/src/components/Box/StatusLine.tsx +76 -0
- package/src/components/Box/Tabbed.stories.tsx +51 -0
- package/src/components/Box/Tabbed.tsx +89 -0
- package/src/components/Box/ToggleContainer.stories.tsx +110 -0
- package/src/components/Box/ToggleContainer.tsx +108 -0
- package/src/components/Box/index.ts +7 -0
- package/src/components/ChatContainer/ChatContainer.tsx +52 -0
- package/src/components/ChatContainer/index.ts +8 -0
- package/src/components/MarkdownViewer/MarkdownViewer.stories.tsx +56 -0
- package/src/components/MarkdownViewer/MarkdownViewer.tsx +79 -0
- package/src/components/MarkdownViewer/index.ts +5 -0
- package/src/components/Prompt/Prompt.stories.tsx +50 -0
- package/src/components/Prompt/Prompt.tsx +39 -0
- package/src/components/Prompt/index.ts +5 -0
- package/src/components/Prompt/prompt-autocomplete.ts +200 -0
- package/src/components/PromptEditor/PromptEditor.stories.tsx +6 -6
- package/src/components/PromptEditor/PromptEditor.tsx +3 -3
- 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/Thread/Thread.stories.tsx +197 -0
- package/src/components/Thread/Thread.tsx +156 -0
- package/src/components/Thread/ThreadMessage.tsx +225 -0
- package/src/components/Thread/index.ts +5 -0
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +1 -2
- package/src/components/TriggerEditor/TriggerEditor.tsx +86 -16
- package/src/components/index.ts +10 -1
- package/src/hooks/email.ts +2 -2
- package/src/hooks/index.ts +5 -0
- package/src/hooks/invocation-handler.ts +2 -2
- package/src/hooks/processor.test.ts +15 -0
- package/src/hooks/processor.ts +210 -0
- package/src/hooks/useChatProcessor.tsx +86 -0
- package/src/hooks/useMessageQueue.ts +23 -0
- package/src/hooks/useServices.ts +28 -0
- package/src/index.ts +1 -4
- package/src/meta.ts +5 -2
- package/src/testing/index.ts +2 -1
- package/src/testing/{testing.ts → test-functions.ts} +9 -2
- 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 +18 -2
- package/src/types/index.ts +1 -0
- package/src/types/registry.ts +26 -0
- package/src/types/schema.ts +96 -2
- package/src/types/types.ts +15 -21
- package/dist/lib/browser/AssistantPanel-N3QSALKY.mjs +0 -341
- package/dist/lib/browser/AssistantPanel-N3QSALKY.mjs.map +0 -7
- package/dist/lib/browser/AutomationPanel-AQMN2CQR.mjs +0 -153
- package/dist/lib/browser/AutomationPanel-AQMN2CQR.mjs.map +0 -7
- package/dist/lib/browser/chunk-7KB4UMXO.mjs +0 -49
- package/dist/lib/browser/chunk-7KB4UMXO.mjs.map +0 -7
- package/dist/lib/browser/chunk-X5KMOH3I.mjs.map +0 -7
- package/dist/lib/browser/meta.mjs +0 -9
- package/dist/lib/node/AssistantPanel-RIA4TI3B.cjs +0 -361
- package/dist/lib/node/AssistantPanel-RIA4TI3B.cjs.map +0 -7
- package/dist/lib/node/AutomationPanel-HZS5WKI5.cjs +0 -173
- package/dist/lib/node/AutomationPanel-HZS5WKI5.cjs.map +0 -7
- package/dist/lib/node/chunk-CUCUWUAF.cjs +0 -73
- package/dist/lib/node/chunk-CUCUWUAF.cjs.map +0 -7
- package/dist/lib/node/chunk-DTJ7XVO2.cjs.map +0 -7
- package/dist/lib/node/meta.cjs.map +0 -7
- package/dist/lib/node-esm/AssistantPanel-72YH43CH.mjs +0 -342
- package/dist/lib/node-esm/AssistantPanel-72YH43CH.mjs.map +0 -7
- package/dist/lib/node-esm/AutomationPanel-JUHOWQWW.mjs +0 -154
- package/dist/lib/node-esm/AutomationPanel-JUHOWQWW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-23LY7DYS.mjs +0 -51
- package/dist/lib/node-esm/chunk-23LY7DYS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HNOBZHWK.mjs.map +0 -7
- package/dist/lib/node-esm/meta.mjs +0 -10
- package/dist/types/src/components/AssistantPanel/AssistantPanel.d.ts +0 -8
- package/dist/types/src/components/AssistantPanel/AssistantPanel.d.ts.map +0 -1
- package/dist/types/src/components/AssistantPanel/index.d.ts +0 -3
- package/dist/types/src/components/AssistantPanel/index.d.ts.map +0 -1
- package/dist/types/src/components/AssistantPanel/system-instructions.d.ts +0 -6
- package/dist/types/src/components/AssistantPanel/system-instructions.d.ts.map +0 -1
- package/dist/types/src/testing/testing.d.ts.map +0 -1
- package/src/components/AssistantPanel/AssistantPanel.tsx +0 -230
- package/src/components/AssistantPanel/index.ts +0 -7
- package/src/components/AssistantPanel/system-instructions.ts +0 -166
- /package/dist/lib/browser/{meta.mjs.map → AutomationPanel-VW2XIUPU.mjs.map} +0 -0
- /package/dist/lib/{node-esm/meta.mjs.map → browser/ChatContainer-OLRZNGWK.mjs.map} +0 -0
|
@@ -0,0 +1,51 @@
|
|
|
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 { faker } from '@dxos/random';
|
|
11
|
+
import { withLayout, withTheme, withSignals } from '@dxos/storybook-utils';
|
|
12
|
+
|
|
13
|
+
import { Tabs } from './Tabbed';
|
|
14
|
+
import { ToggleContainer } from './ToggleContainer';
|
|
15
|
+
|
|
16
|
+
const content = Array.from({ length: 4 }, (_, i) => ({
|
|
17
|
+
title: faker.lorem.paragraph(),
|
|
18
|
+
content: faker.lorem.paragraphs(3),
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
const meta: Meta<typeof Tabs> = {
|
|
22
|
+
title: 'plugins/plugin-automation/Tabbed',
|
|
23
|
+
component: Tabs,
|
|
24
|
+
decorators: [withSignals, withTheme, withLayout({ fullscreen: true, classNames: 'justify-center' })],
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default meta;
|
|
28
|
+
|
|
29
|
+
type Story = StoryObj<typeof Tabs>;
|
|
30
|
+
|
|
31
|
+
export const Default: Story = {
|
|
32
|
+
render: () => {
|
|
33
|
+
const [selected, setSelected] = useState(0);
|
|
34
|
+
return (
|
|
35
|
+
<div className='flex flex-col w-[500px] p-4 bg-attention'>
|
|
36
|
+
<ToggleContainer
|
|
37
|
+
open
|
|
38
|
+
title={content[selected].title}
|
|
39
|
+
classNames='p-1 rounded-lg bg-baseSurface border border-neutral-500'
|
|
40
|
+
>
|
|
41
|
+
<div className='flex w-full overflow-hidden'>
|
|
42
|
+
<Tabs length={content.length} selected={selected} onSelect={setSelected} />
|
|
43
|
+
<div className='flex-1 pis-2 pie-2 overflow-y-auto'>
|
|
44
|
+
<div>{content[selected].content}</div>
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
</ToggleContainer>
|
|
48
|
+
</div>
|
|
49
|
+
);
|
|
50
|
+
},
|
|
51
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { forwardRef } from 'react';
|
|
6
|
+
|
|
7
|
+
import { Icon, type ThemedClassName } from '@dxos/react-ui';
|
|
8
|
+
import { mx } from '@dxos/react-ui-theme';
|
|
9
|
+
|
|
10
|
+
const numbers = [
|
|
11
|
+
{ regular: 'ph--number-circle-zero--thin', active: 'ph--number-circle-zero--duotone' },
|
|
12
|
+
{ regular: 'ph--number-circle-one--thin', active: 'ph--number-circle-one--duotone' },
|
|
13
|
+
{ regular: 'ph--number-circle-two--thin', active: 'ph--number-circle-two--duotone' },
|
|
14
|
+
{ regular: 'ph--number-circle-three--thin', active: 'ph--number-circle-three--duotone' },
|
|
15
|
+
{ regular: 'ph--number-circle-four--thin', active: 'ph--number-circle-four--duotone' },
|
|
16
|
+
{ regular: 'ph--number-circle-five--thin', active: 'ph--number-circle-five--duotone' },
|
|
17
|
+
{ regular: 'ph--number-circle-six--thin', active: 'ph--number-circle-six--duotone' },
|
|
18
|
+
{ regular: 'ph--number-circle-seven--thin', active: 'ph--number-circle-seven--duotone' },
|
|
19
|
+
{ regular: 'ph--number-circle-eight--thin', active: 'ph--number-circle-eight--duotone' },
|
|
20
|
+
{ regular: 'ph--number-circle-nine--thin', active: 'ph--number-circle-nine--duotone' },
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
export type TabsProps = ThemedClassName<{
|
|
24
|
+
length: number;
|
|
25
|
+
selected?: number;
|
|
26
|
+
onSelect?: (index: number) => void;
|
|
27
|
+
}>;
|
|
28
|
+
|
|
29
|
+
export const Tabs = forwardRef<HTMLDivElement, TabsProps>(
|
|
30
|
+
({ classNames, length, selected = 0, onSelect }, forwardedRef) => {
|
|
31
|
+
return (
|
|
32
|
+
<div
|
|
33
|
+
ref={forwardedRef}
|
|
34
|
+
className={mx('flex flex-col overflow-hidden outline-none', classNames)}
|
|
35
|
+
tabIndex={-1}
|
|
36
|
+
onKeyDown={(ev) => {
|
|
37
|
+
// TODO(burdon): Focus when open Toggle.
|
|
38
|
+
switch (ev.key) {
|
|
39
|
+
case 'ArrowDown':
|
|
40
|
+
case 'ArrowRight': {
|
|
41
|
+
ev.preventDefault();
|
|
42
|
+
ev.stopPropagation();
|
|
43
|
+
if (selected < length - 1) {
|
|
44
|
+
onSelect?.(selected + 1);
|
|
45
|
+
}
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
case 'ArrowUp':
|
|
49
|
+
case 'ArrowLeft': {
|
|
50
|
+
ev.preventDefault();
|
|
51
|
+
ev.stopPropagation();
|
|
52
|
+
if (selected > 0) {
|
|
53
|
+
onSelect?.(selected - 1);
|
|
54
|
+
}
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
case 'Enter': {
|
|
59
|
+
ev.preventDefault();
|
|
60
|
+
ev.stopPropagation();
|
|
61
|
+
onSelect?.(selected);
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}}
|
|
66
|
+
>
|
|
67
|
+
{Array.from({ length }).map((_, i) => {
|
|
68
|
+
const icon = numbers[i + 1];
|
|
69
|
+
return (
|
|
70
|
+
<div
|
|
71
|
+
key={i}
|
|
72
|
+
className={mx(
|
|
73
|
+
'relative flex w-[24px] h-[28px] justify-center cursor-pointer text-subdued',
|
|
74
|
+
selected === i && '!text-cyan-550 !dark:text-cyan-300',
|
|
75
|
+
)}
|
|
76
|
+
>
|
|
77
|
+
{i < length - 1 && <div className='absolute left-[11.5px] top-[21px] w-[1px] h-[10px] bg-neutral-400' />}
|
|
78
|
+
<Icon
|
|
79
|
+
icon={selected === i ? icon.regular : icon.regular}
|
|
80
|
+
classNames='z-10 !p-0 !w-[24px] !h-[24px] outline-none'
|
|
81
|
+
onClick={() => onSelect?.(i)}
|
|
82
|
+
/>
|
|
83
|
+
</div>
|
|
84
|
+
);
|
|
85
|
+
})}
|
|
86
|
+
</div>
|
|
87
|
+
);
|
|
88
|
+
},
|
|
89
|
+
);
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxos-theme';
|
|
6
|
+
|
|
7
|
+
import { computed, type ReadonlySignal, signal } from '@preact/signals-core';
|
|
8
|
+
import { type StoryObj, type Meta } from '@storybook/react';
|
|
9
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
10
|
+
|
|
11
|
+
import { faker } from '@dxos/random';
|
|
12
|
+
import { Icon, Input, Toolbar } from '@dxos/react-ui';
|
|
13
|
+
import { mx } from '@dxos/react-ui-theme';
|
|
14
|
+
import { withLayout, withTheme, withSignals } from '@dxos/storybook-utils';
|
|
15
|
+
|
|
16
|
+
import { ToggleContainer, type ToggleContainerProps } from './ToggleContainer';
|
|
17
|
+
import { MarkdownViewer } from '../MarkdownViewer';
|
|
18
|
+
|
|
19
|
+
class Generator {
|
|
20
|
+
private readonly _current = signal<string>(faker.lorem.sentence(5));
|
|
21
|
+
private readonly _lines = signal<string[]>([]);
|
|
22
|
+
private _running: NodeJS.Timeout | undefined;
|
|
23
|
+
|
|
24
|
+
readonly count = computed(() => this._lines.value.length);
|
|
25
|
+
readonly text: ReadonlySignal<string[]> = computed(() => [...this._lines.value, this._current.value]);
|
|
26
|
+
|
|
27
|
+
start() {
|
|
28
|
+
this.stop();
|
|
29
|
+
this._running = setInterval(() => {
|
|
30
|
+
if (this._current.value.length > 0) {
|
|
31
|
+
this._current.value += ' ';
|
|
32
|
+
}
|
|
33
|
+
this._current.value += faker.lorem.words(Math.ceil(Math.random() * 2));
|
|
34
|
+
if (Math.random() > 0.95) {
|
|
35
|
+
this._lines.value = [...this._lines.value, this._current.value + '.'];
|
|
36
|
+
this._current.value = '';
|
|
37
|
+
}
|
|
38
|
+
}, 100);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
stop() {
|
|
42
|
+
if (this._running) {
|
|
43
|
+
clearInterval(this._running);
|
|
44
|
+
this._running = undefined;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const Render = ({ shrinkX, ...props }: ToggleContainerProps) => {
|
|
50
|
+
const generator = useMemo(() => new Generator(), []);
|
|
51
|
+
const [running, setRunning] = useState(false);
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (running) {
|
|
54
|
+
generator.start();
|
|
55
|
+
} else {
|
|
56
|
+
generator.stop();
|
|
57
|
+
}
|
|
58
|
+
}, [running]);
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<div className='flex flex-col w-[500px]'>
|
|
62
|
+
<Toolbar.Root classNames='p-4'>
|
|
63
|
+
<Input.Root>
|
|
64
|
+
<Input.Switch checked={running} onCheckedChange={(checked) => setRunning(checked)} />
|
|
65
|
+
</Input.Root>
|
|
66
|
+
<div className='grow' />
|
|
67
|
+
<div>{generator.count.value}</div>
|
|
68
|
+
</Toolbar.Root>
|
|
69
|
+
<div className='flex p-4'>
|
|
70
|
+
<div className={mx('border border-border rounded-md p-2', !shrinkX && 'w-full')}>
|
|
71
|
+
<ToggleContainer
|
|
72
|
+
{...props}
|
|
73
|
+
shrinkX={shrinkX}
|
|
74
|
+
icon={
|
|
75
|
+
running ? (
|
|
76
|
+
<Icon icon={'ph--circle-notch--regular'} classNames='text-subdued ml-2 animate-spin' size={4} />
|
|
77
|
+
) : undefined
|
|
78
|
+
}
|
|
79
|
+
>
|
|
80
|
+
<MarkdownViewer classNames='text-sm' content={generator.text.value.join('\n\n')} />
|
|
81
|
+
</ToggleContainer>
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|
|
84
|
+
</div>
|
|
85
|
+
);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const meta: Meta<typeof ToggleContainer> = {
|
|
89
|
+
title: 'plugins/plugin-automation/ToggleContainer',
|
|
90
|
+
component: ToggleContainer,
|
|
91
|
+
render: Render,
|
|
92
|
+
decorators: [withSignals, withTheme, withLayout({ fullscreen: true, classNames: 'justify-center bg-baseSurface' })],
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export default meta;
|
|
96
|
+
|
|
97
|
+
type Story = StoryObj<typeof ToggleContainer>;
|
|
98
|
+
|
|
99
|
+
export const Default: Story = {
|
|
100
|
+
args: {
|
|
101
|
+
title: 'Markdown',
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export const Shrink: Story = {
|
|
106
|
+
args: {
|
|
107
|
+
title: 'Markdown',
|
|
108
|
+
shrinkX: true,
|
|
109
|
+
},
|
|
110
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { type JSX, type PropsWithChildren, useEffect, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { Icon, useControlledState, type ThemedClassName } from '@dxos/react-ui';
|
|
8
|
+
import { mx } from '@dxos/react-ui-theme';
|
|
9
|
+
|
|
10
|
+
export type ToggleContainerProps = ThemedClassName<
|
|
11
|
+
PropsWithChildren<{
|
|
12
|
+
title?: string | JSX.Element;
|
|
13
|
+
icon?: JSX.Element;
|
|
14
|
+
open?: boolean;
|
|
15
|
+
duration?: number;
|
|
16
|
+
/** Should shrink the width when closed. */
|
|
17
|
+
shrinkX?: boolean;
|
|
18
|
+
onChangeOpen?: (open: boolean) => void;
|
|
19
|
+
}>
|
|
20
|
+
>;
|
|
21
|
+
|
|
22
|
+
export const ToggleContainer = ({
|
|
23
|
+
classNames,
|
|
24
|
+
title,
|
|
25
|
+
icon,
|
|
26
|
+
open: _open,
|
|
27
|
+
duration = 400,
|
|
28
|
+
shrinkX = false,
|
|
29
|
+
children,
|
|
30
|
+
onChangeOpen,
|
|
31
|
+
}: ToggleContainerProps) => {
|
|
32
|
+
const [open, setOpen] = useControlledState(_open);
|
|
33
|
+
const [expandX, setExpandX] = useState(shrinkX ? open : true);
|
|
34
|
+
const [expandY, setExpandY] = useState(open);
|
|
35
|
+
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
let t: NodeJS.Timeout;
|
|
38
|
+
if (open) {
|
|
39
|
+
if (shrinkX) {
|
|
40
|
+
setExpandX(true);
|
|
41
|
+
}
|
|
42
|
+
t = setTimeout(
|
|
43
|
+
() => {
|
|
44
|
+
setExpandY(true);
|
|
45
|
+
},
|
|
46
|
+
shrinkX ? duration : 0,
|
|
47
|
+
);
|
|
48
|
+
} else {
|
|
49
|
+
setExpandY(false);
|
|
50
|
+
if (shrinkX) {
|
|
51
|
+
t = setTimeout(() => {
|
|
52
|
+
setExpandX(false);
|
|
53
|
+
}, duration);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return () => clearTimeout(t);
|
|
58
|
+
}, [open]);
|
|
59
|
+
|
|
60
|
+
const handleToggle = () => {
|
|
61
|
+
if (onChangeOpen) {
|
|
62
|
+
onChangeOpen(!open);
|
|
63
|
+
} else {
|
|
64
|
+
setOpen((open) => !open);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<div className={mx('overflow-hidden', classNames)}>
|
|
70
|
+
{title && (
|
|
71
|
+
<div
|
|
72
|
+
className='flex gap-1 py-1 items-center text-sm text-subdued cursor-pointer select-none'
|
|
73
|
+
onClick={handleToggle}
|
|
74
|
+
>
|
|
75
|
+
<div className='flex w-[24px] h-[24px] items-center justify-center'>
|
|
76
|
+
<Icon
|
|
77
|
+
size={4}
|
|
78
|
+
icon={'ph--caret-right--regular'}
|
|
79
|
+
style={{ transitionDuration: `${shrinkX ? duration * 2 : duration}ms` }}
|
|
80
|
+
classNames={['transition transition-transform ease-in-out', open ? 'rotate-90' : 'transform-none']}
|
|
81
|
+
/>
|
|
82
|
+
</div>
|
|
83
|
+
<div className='flex-1 pis-1 pie-1 truncate'>{title}</div>
|
|
84
|
+
{icon}
|
|
85
|
+
</div>
|
|
86
|
+
)}
|
|
87
|
+
<div
|
|
88
|
+
style={{ transitionDuration: `${duration}ms` }}
|
|
89
|
+
className={mx(
|
|
90
|
+
'grid transition-[grid-template-columns] ease-in-out',
|
|
91
|
+
expandX ? 'grid-cols-[1fr]' : 'grid-cols-[0fr]',
|
|
92
|
+
)}
|
|
93
|
+
>
|
|
94
|
+
<div className='overflow-hidden'>
|
|
95
|
+
<div
|
|
96
|
+
style={{ transitionDuration: `${duration}ms` }}
|
|
97
|
+
className={mx(
|
|
98
|
+
'grid transition-[grid-template-rows] ease-in-out',
|
|
99
|
+
expandY ? 'grid-rows-[1fr]' : 'grid-rows-[0fr]',
|
|
100
|
+
)}
|
|
101
|
+
>
|
|
102
|
+
<div className={mx('flex overflow-hidden transition-opacity')}>{children}</div>
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
</div>
|
|
107
|
+
);
|
|
108
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useCallback } from 'react';
|
|
6
|
+
|
|
7
|
+
import { invariant } from '@dxos/invariant';
|
|
8
|
+
import { StackItem } from '@dxos/react-ui-stack';
|
|
9
|
+
|
|
10
|
+
import { useChatProcessor, useMessageQueue } from '../../hooks';
|
|
11
|
+
import { type AIChatType } from '../../types';
|
|
12
|
+
import { Thread } from '../Thread';
|
|
13
|
+
|
|
14
|
+
export const ChatContainer = ({ chat, role }: { chat: AIChatType; role: string }) => {
|
|
15
|
+
const processor = useChatProcessor(chat);
|
|
16
|
+
const messageQueue = useMessageQueue(chat);
|
|
17
|
+
const messages = [...(messageQueue?.items ?? []), ...processor.messages.value];
|
|
18
|
+
|
|
19
|
+
const handleSubmit = useCallback(
|
|
20
|
+
async (text: string) => {
|
|
21
|
+
if (processor.streaming.value) {
|
|
22
|
+
await processor.cancel();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
invariant(messageQueue);
|
|
26
|
+
await processor.request(text, {
|
|
27
|
+
history: messageQueue.items,
|
|
28
|
+
onComplete: (messages) => messageQueue.append(messages),
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
[processor, messageQueue],
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const handleStop = useCallback(() => {
|
|
35
|
+
if (processor.streaming.value) {
|
|
36
|
+
void processor.cancel();
|
|
37
|
+
}
|
|
38
|
+
}, [processor]);
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<StackItem.Content toolbar={false} role={role}>
|
|
42
|
+
<Thread
|
|
43
|
+
messages={messages}
|
|
44
|
+
streaming={processor.streaming.value}
|
|
45
|
+
collapse={true}
|
|
46
|
+
onSubmit={handleSubmit}
|
|
47
|
+
onSuggest={handleSubmit}
|
|
48
|
+
onStop={handleStop}
|
|
49
|
+
/>
|
|
50
|
+
</StackItem.Content>
|
|
51
|
+
);
|
|
52
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxos-theme';
|
|
6
|
+
|
|
7
|
+
import { type StoryObj, type Meta } from '@storybook/react';
|
|
8
|
+
|
|
9
|
+
import { faker } from '@dxos/random';
|
|
10
|
+
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
11
|
+
|
|
12
|
+
import { MarkdownViewer } from './MarkdownViewer';
|
|
13
|
+
|
|
14
|
+
faker.seed(0);
|
|
15
|
+
|
|
16
|
+
const meta: Meta<typeof MarkdownViewer> = {
|
|
17
|
+
title: 'plugins/plugin-automation/MarkdownViewer',
|
|
18
|
+
component: MarkdownViewer,
|
|
19
|
+
decorators: [withTheme, withLayout({ fullscreen: true, classNames: 'justify-center' })],
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default meta;
|
|
23
|
+
|
|
24
|
+
type Story = StoryObj<typeof MarkdownViewer>;
|
|
25
|
+
|
|
26
|
+
const content = `
|
|
27
|
+
# Hello, world!
|
|
28
|
+
|
|
29
|
+
${faker.lorem.paragraphs(1)}
|
|
30
|
+
|
|
31
|
+
Here's a JSON block:
|
|
32
|
+
|
|
33
|
+
~~~json
|
|
34
|
+
{
|
|
35
|
+
"hello": "world"
|
|
36
|
+
}
|
|
37
|
+
~~~
|
|
38
|
+
|
|
39
|
+
And some code:
|
|
40
|
+
|
|
41
|
+
~~~ts
|
|
42
|
+
const App = () => {
|
|
43
|
+
const title = 'Hello, world!';
|
|
44
|
+
return <div>{title}</div>;
|
|
45
|
+
};
|
|
46
|
+
~~~
|
|
47
|
+
|
|
48
|
+
${faker.lorem.paragraphs(1)}
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
export const Default: Story = {
|
|
52
|
+
args: {
|
|
53
|
+
classNames: 'w-[500px] border border-border rounded-md p-4',
|
|
54
|
+
content,
|
|
55
|
+
},
|
|
56
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { type FC } from 'react';
|
|
6
|
+
import ReactMarkdown from 'react-markdown';
|
|
7
|
+
|
|
8
|
+
import { type ThemedClassName } from '@dxos/react-ui';
|
|
9
|
+
import { SyntaxHighlighter } from '@dxos/react-ui-syntax-highlighter';
|
|
10
|
+
import { mx } from '@dxos/react-ui-theme';
|
|
11
|
+
import { omit } from '@dxos/util';
|
|
12
|
+
|
|
13
|
+
type MarkdownViewerProps = ThemedClassName<{
|
|
14
|
+
content?: string;
|
|
15
|
+
}>;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Transform text into react elements.
|
|
19
|
+
*
|
|
20
|
+
* https://github.com/remarkjs/react-markdown
|
|
21
|
+
* markdown -> remark -> [mdast -> remark plugins] -> [hast -> rehype plugins] -> components -> react elements.
|
|
22
|
+
*/
|
|
23
|
+
// TODO(burdon): Styles.
|
|
24
|
+
// TODO(burdon): Factor out (react-ui-syntax-highlighter).
|
|
25
|
+
export const MarkdownViewer: FC<MarkdownViewerProps> = ({ classNames, content = '' }) => {
|
|
26
|
+
return (
|
|
27
|
+
<div className={mx('space-y-2', classNames)}>
|
|
28
|
+
<ReactMarkdown
|
|
29
|
+
components={{
|
|
30
|
+
a: ({ node, children, href, ...props }) => (
|
|
31
|
+
<a
|
|
32
|
+
href={href}
|
|
33
|
+
className='text-primary-500 hover:text-primary-500'
|
|
34
|
+
target='_blank'
|
|
35
|
+
rel='noopener noreferrer'
|
|
36
|
+
{...props}
|
|
37
|
+
>
|
|
38
|
+
{children}
|
|
39
|
+
</a>
|
|
40
|
+
),
|
|
41
|
+
ol: ({ node, children, ...props }) => (
|
|
42
|
+
<ol className='leading-tight list-decimal pl-6' {...omit(props, ['ordered'])}>
|
|
43
|
+
{children}
|
|
44
|
+
</ol>
|
|
45
|
+
),
|
|
46
|
+
ul: ({ node, children, ...props }) => (
|
|
47
|
+
<ul className='leading-tight list-disc pl-6' {...omit(props, ['ordered'])}>
|
|
48
|
+
{children}
|
|
49
|
+
</ul>
|
|
50
|
+
),
|
|
51
|
+
li: ({ node, children, ...props }) => (
|
|
52
|
+
<li className='' {...omit(props, ['ordered'])}>
|
|
53
|
+
{children}
|
|
54
|
+
</li>
|
|
55
|
+
),
|
|
56
|
+
blockquote: ({ node, children, ...props }) => (
|
|
57
|
+
<blockquote className='border-l-4 border-primary-500 pl-4 my-4 text-primary-500' {...props}>
|
|
58
|
+
{children}
|
|
59
|
+
</blockquote>
|
|
60
|
+
),
|
|
61
|
+
code: ({ children, className }) => {
|
|
62
|
+
const [_, language] = /language-(\w+)/.exec(className || '') || [];
|
|
63
|
+
return (
|
|
64
|
+
<SyntaxHighlighter PreTag='div' language={language} className='p-0'>
|
|
65
|
+
{children}
|
|
66
|
+
</SyntaxHighlighter>
|
|
67
|
+
);
|
|
68
|
+
},
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
{content}
|
|
72
|
+
</ReactMarkdown>
|
|
73
|
+
</div>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// const Cursor = () => {
|
|
78
|
+
// return <span className='animate-[pulse_1s_steps(1)_infinite] text-primary-500'>▊</span>;
|
|
79
|
+
// };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxos-theme';
|
|
6
|
+
|
|
7
|
+
import { type StoryObj, type Meta } from '@storybook/react';
|
|
8
|
+
|
|
9
|
+
import { withTheme } from '@dxos/storybook-utils';
|
|
10
|
+
|
|
11
|
+
import { Prompt } from './Prompt';
|
|
12
|
+
|
|
13
|
+
const meta: Meta<typeof Prompt> = {
|
|
14
|
+
title: 'plugins/plugin-automation/Prompt',
|
|
15
|
+
component: Prompt,
|
|
16
|
+
decorators: [withTheme],
|
|
17
|
+
parameters: {
|
|
18
|
+
layout: 'centered',
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default meta;
|
|
23
|
+
|
|
24
|
+
type Story = StoryObj<typeof Prompt>;
|
|
25
|
+
|
|
26
|
+
export const Default: Story = {
|
|
27
|
+
args: {
|
|
28
|
+
classNames: 'w-96 p-4 rounded outline outline-gray-200',
|
|
29
|
+
autoFocus: true,
|
|
30
|
+
onEnter: (text) => {
|
|
31
|
+
console.log('onEnter', text);
|
|
32
|
+
},
|
|
33
|
+
onSuggest: (text) => {
|
|
34
|
+
const trimmed = text.trim().toLowerCase();
|
|
35
|
+
if (trimmed.length < 2) {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const suggestions = [
|
|
40
|
+
'Create a CRM',
|
|
41
|
+
'Create a new project',
|
|
42
|
+
'Find flights to Tokyo',
|
|
43
|
+
"Let's play chess",
|
|
44
|
+
'Show me Paris on a map',
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
return suggestions.filter((s) => s.toLowerCase().startsWith(text));
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React from 'react';
|
|
6
|
+
|
|
7
|
+
import { type ThemedClassName, useThemeContext } from '@dxos/react-ui';
|
|
8
|
+
import {
|
|
9
|
+
type BasicExtensionsOptions,
|
|
10
|
+
createBasicExtensions,
|
|
11
|
+
createThemeExtensions,
|
|
12
|
+
useTextEditor,
|
|
13
|
+
type UseTextEditorProps,
|
|
14
|
+
} from '@dxos/react-ui-editor';
|
|
15
|
+
import { mx } from '@dxos/react-ui-theme';
|
|
16
|
+
|
|
17
|
+
import { createAutocompleteExtension, type AutocompleteOptions } from './prompt-autocomplete';
|
|
18
|
+
|
|
19
|
+
export type PromptProps = ThemedClassName<
|
|
20
|
+
AutocompleteOptions & Pick<UseTextEditorProps, 'autoFocus'> & Pick<BasicExtensionsOptions, 'lineWrapping'>
|
|
21
|
+
>;
|
|
22
|
+
|
|
23
|
+
export const Prompt = ({ classNames, autoFocus, lineWrapping = false, onEnter, onSuggest }: PromptProps) => {
|
|
24
|
+
const { themeMode } = useThemeContext();
|
|
25
|
+
const { parentRef } = useTextEditor({
|
|
26
|
+
autoFocus,
|
|
27
|
+
extensions: [
|
|
28
|
+
createBasicExtensions({
|
|
29
|
+
bracketMatching: false,
|
|
30
|
+
lineWrapping,
|
|
31
|
+
placeholder: 'Ask a question...',
|
|
32
|
+
}),
|
|
33
|
+
createThemeExtensions({ themeMode }),
|
|
34
|
+
createAutocompleteExtension({ onEnter, onSuggest }),
|
|
35
|
+
],
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
return <div ref={parentRef} className={mx(classNames)} />;
|
|
39
|
+
};
|