@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,200 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Prec, type Extension } from '@codemirror/state';
|
|
6
|
+
import {
|
|
7
|
+
EditorView,
|
|
8
|
+
Decoration,
|
|
9
|
+
ViewPlugin,
|
|
10
|
+
keymap,
|
|
11
|
+
type DecorationSet,
|
|
12
|
+
type ViewUpdate,
|
|
13
|
+
WidgetType,
|
|
14
|
+
} from '@codemirror/view';
|
|
15
|
+
|
|
16
|
+
export type AutocompleteOptions = {
|
|
17
|
+
/**
|
|
18
|
+
* Callback triggered when Enter is pressed.
|
|
19
|
+
* @param text The current text in the editor
|
|
20
|
+
*/
|
|
21
|
+
onEnter?: (text: string) => void;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Function that returns a list of suggestions based on the current text.
|
|
25
|
+
* @param text The current text before the cursor
|
|
26
|
+
* @returns Array of suggestion strings
|
|
27
|
+
*/
|
|
28
|
+
onSuggest?: (text: string) => string[];
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
class InlineSuggestionWidget extends WidgetType {
|
|
32
|
+
constructor(private suffix: string) {
|
|
33
|
+
super();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
override toDOM() {
|
|
37
|
+
const span = document.createElement('span');
|
|
38
|
+
span.textContent = this.suffix;
|
|
39
|
+
span.className = 'cm-inline-suggestion';
|
|
40
|
+
return span;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
override eq(other: InlineSuggestionWidget) {
|
|
44
|
+
return other.suffix === this.suffix;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Creates an autocomplete extension that shows inline suggestions.
|
|
50
|
+
* Pressing Tab will complete the suggestion.
|
|
51
|
+
*/
|
|
52
|
+
export const createAutocompleteExtension = ({ onEnter, onSuggest }: AutocompleteOptions): Extension => {
|
|
53
|
+
const suggestionPlugin = ViewPlugin.fromClass(
|
|
54
|
+
class {
|
|
55
|
+
_decorations: DecorationSet;
|
|
56
|
+
_currentSuggestion: string | null = null;
|
|
57
|
+
|
|
58
|
+
constructor(view: EditorView) {
|
|
59
|
+
this._decorations = this.computeDecorations(view);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
update(update: ViewUpdate) {
|
|
63
|
+
if (update.docChanged || update.selectionSet) {
|
|
64
|
+
this._decorations = this.computeDecorations(update.view);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
private computeDecorations(view: EditorView): DecorationSet {
|
|
69
|
+
const text = view.state.doc.toString();
|
|
70
|
+
const suggestions = onSuggest?.(text) ?? [];
|
|
71
|
+
if (!suggestions.length) {
|
|
72
|
+
this._currentSuggestion = null;
|
|
73
|
+
return Decoration.none;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Get the first suggestion.
|
|
77
|
+
this._currentSuggestion = suggestions[0];
|
|
78
|
+
const suffix = this._currentSuggestion.slice(text.length);
|
|
79
|
+
if (!suffix) {
|
|
80
|
+
return Decoration.none;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Always show ghost text at the end of the document.
|
|
84
|
+
return Decoration.set([
|
|
85
|
+
Decoration.widget({
|
|
86
|
+
widget: new InlineSuggestionWidget(suffix),
|
|
87
|
+
side: 1,
|
|
88
|
+
}).range(view.state.doc.length),
|
|
89
|
+
]);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
completeSuggestion(view: EditorView): boolean {
|
|
93
|
+
if (!this._currentSuggestion) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const text = view.state.doc.toString();
|
|
98
|
+
const suffix = this._currentSuggestion.slice(text.length);
|
|
99
|
+
if (!suffix) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
view.dispatch({
|
|
104
|
+
changes: {
|
|
105
|
+
from: view.state.doc.length,
|
|
106
|
+
insert: suffix,
|
|
107
|
+
},
|
|
108
|
+
selection: {
|
|
109
|
+
anchor: view.state.doc.length + suffix.length,
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
decorations: (v) => v._decorations,
|
|
118
|
+
},
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
return [
|
|
122
|
+
suggestionPlugin,
|
|
123
|
+
EditorView.theme({
|
|
124
|
+
'.cm-inline-suggestion': {
|
|
125
|
+
opacity: 0.4,
|
|
126
|
+
},
|
|
127
|
+
}),
|
|
128
|
+
|
|
129
|
+
// Accept the current suggestion.
|
|
130
|
+
Prec.highest(
|
|
131
|
+
keymap.of([
|
|
132
|
+
{
|
|
133
|
+
key: 'Tab',
|
|
134
|
+
run: (view) => {
|
|
135
|
+
const plugin = view.plugin(suggestionPlugin);
|
|
136
|
+
return plugin?.completeSuggestion(view) ?? false;
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
key: 'ArrowRight',
|
|
141
|
+
run: (view) => {
|
|
142
|
+
// Only complete if cursor is at the end
|
|
143
|
+
if (view.state.selection.main.head !== view.state.doc.length) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
const plugin = view.plugin(suggestionPlugin);
|
|
148
|
+
return plugin?.completeSuggestion(view) ?? false;
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
key: 'Enter',
|
|
153
|
+
preventDefault: true,
|
|
154
|
+
run: (view) => {
|
|
155
|
+
const text = view.state.doc.toString();
|
|
156
|
+
if (onEnter) {
|
|
157
|
+
onEnter(text);
|
|
158
|
+
// Clear the document after calling onEnter
|
|
159
|
+
view.dispatch({
|
|
160
|
+
changes: {
|
|
161
|
+
from: 0,
|
|
162
|
+
to: view.state.doc.length,
|
|
163
|
+
insert: '',
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
return true;
|
|
167
|
+
}
|
|
168
|
+
return false;
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
key: 'Shift-Enter',
|
|
173
|
+
run: (view) => {
|
|
174
|
+
view.dispatch({
|
|
175
|
+
changes: {
|
|
176
|
+
from: view.state.selection.main.head,
|
|
177
|
+
insert: '\n',
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
return true;
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
key: 'Escape',
|
|
185
|
+
run: (view) => {
|
|
186
|
+
// Clear the entire document.
|
|
187
|
+
view.dispatch({
|
|
188
|
+
changes: {
|
|
189
|
+
from: 0,
|
|
190
|
+
to: view.state.doc.length,
|
|
191
|
+
insert: '',
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
return true;
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
]),
|
|
198
|
+
),
|
|
199
|
+
];
|
|
200
|
+
};
|
|
@@ -7,7 +7,7 @@ import '@dxos-theme';
|
|
|
7
7
|
import { type Meta } from '@storybook/react';
|
|
8
8
|
import React, { useState } from 'react';
|
|
9
9
|
|
|
10
|
-
import { create } from '@dxos/live-object';
|
|
10
|
+
import { create, makeRef } from '@dxos/live-object';
|
|
11
11
|
import { useClient } from '@dxos/react-client';
|
|
12
12
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
13
13
|
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
@@ -28,20 +28,20 @@ const template = [
|
|
|
28
28
|
'{input}',
|
|
29
29
|
].join('\n');
|
|
30
30
|
|
|
31
|
-
const
|
|
31
|
+
const Render = () => {
|
|
32
32
|
const client = useClient();
|
|
33
33
|
const [chain] = useState(() => {
|
|
34
34
|
const space = client.spaces.default;
|
|
35
35
|
return space.db.add(
|
|
36
36
|
create(ChainType, {
|
|
37
|
-
prompts: [create(ChainPromptType, { command: 'test', template, inputs: [] })],
|
|
37
|
+
prompts: [makeRef(create(ChainPromptType, { command: 'test', template, inputs: [] }))],
|
|
38
38
|
}),
|
|
39
39
|
);
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
return (
|
|
43
43
|
<div role='none' className='flex w-[350px] border border-separator overflow-hidden'>
|
|
44
|
-
<PromptEditor prompt={chain.prompts![0]!} />
|
|
44
|
+
<PromptEditor prompt={chain.prompts![0]!.target!} />
|
|
45
45
|
</div>
|
|
46
46
|
);
|
|
47
47
|
};
|
|
@@ -49,8 +49,8 @@ const DefaultStory = () => {
|
|
|
49
49
|
export const Default = {};
|
|
50
50
|
|
|
51
51
|
const meta: Meta = {
|
|
52
|
-
title: 'plugins/plugin-automation/
|
|
53
|
-
render:
|
|
52
|
+
title: 'plugins/plugin-automation/PromptEditor',
|
|
53
|
+
render: Render,
|
|
54
54
|
decorators: [
|
|
55
55
|
withClientProvider({ createIdentity: true, createSpace: true, types: [ChainType, ChainPromptType] }),
|
|
56
56
|
withLayout({ fullscreen: true, classNames: 'flex justify-center m-2' }),
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
useTextEditor,
|
|
15
15
|
} from '@dxos/react-ui-editor';
|
|
16
16
|
import { attentionSurface, groupBorder, mx } from '@dxos/react-ui-theme';
|
|
17
|
-
import {
|
|
17
|
+
import { isNonNullable } from '@dxos/util';
|
|
18
18
|
|
|
19
19
|
import { nameRegex, promptExtension } from './prompt-extension';
|
|
20
20
|
import { AUTOMATION_PLUGIN } from '../../meta';
|
|
@@ -69,7 +69,7 @@ const usePromptInputs = (prompt: ChainPromptType) => {
|
|
|
69
69
|
|
|
70
70
|
// Create map of unclaimed inputs.
|
|
71
71
|
const unclaimed = new Map<string, ChainInput>(
|
|
72
|
-
prompt.inputs?.filter(
|
|
72
|
+
prompt.inputs?.filter(isNonNullable).map((input) => [input.name, input]),
|
|
73
73
|
);
|
|
74
74
|
const missing: string[] = [];
|
|
75
75
|
Array.from(variables.values()).forEach((name) => {
|
|
@@ -161,7 +161,7 @@ export const PromptEditor = ({ prompt, commandEditable = true }: PromptEditorPro
|
|
|
161
161
|
{/* TODO(zan): Improve layout with grid */}
|
|
162
162
|
<table className='w-full table-fixed border-collapse my-2'>
|
|
163
163
|
<tbody>
|
|
164
|
-
{prompt.inputs?.filter(
|
|
164
|
+
{prompt.inputs?.filter(isNonNullable).map((input) => (
|
|
165
165
|
<tr key={input.name}>
|
|
166
166
|
<td className='w-[160px] p-1 font-mono text-sm whitespace-nowrap truncate'>
|
|
167
167
|
<code className='px-2'>{input.name}</code>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxos-theme';
|
|
6
|
+
|
|
7
|
+
import { type Meta, type StoryObj } from '@storybook/react';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
|
|
10
|
+
import { useSpace } from '@dxos/react-client/echo';
|
|
11
|
+
import { withClientProvider } from '@dxos/react-client/testing';
|
|
12
|
+
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
13
|
+
|
|
14
|
+
import { ServiceRegistry } from './ServiceRegistry';
|
|
15
|
+
import { ServiceType } from '../../types';
|
|
16
|
+
|
|
17
|
+
const meta: Meta<typeof ServiceRegistry> = {
|
|
18
|
+
title: 'plugins/plugin-automation/ServiceRegistry',
|
|
19
|
+
component: ServiceRegistry,
|
|
20
|
+
render: ({ space: _ignore, ...args }) => {
|
|
21
|
+
const space = useSpace();
|
|
22
|
+
if (!space) {
|
|
23
|
+
return <div />;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<div className='h-full w-[300px] overflow-hidden'>
|
|
28
|
+
<ServiceRegistry space={space} {...args} />
|
|
29
|
+
</div>
|
|
30
|
+
);
|
|
31
|
+
},
|
|
32
|
+
decorators: [
|
|
33
|
+
withClientProvider({
|
|
34
|
+
createIdentity: true,
|
|
35
|
+
createSpace: true,
|
|
36
|
+
types: [ServiceType],
|
|
37
|
+
}),
|
|
38
|
+
withLayout({ fullscreen: true, tooltips: true, classNames: 'flex justify-center' }),
|
|
39
|
+
withTheme,
|
|
40
|
+
],
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default meta;
|
|
44
|
+
|
|
45
|
+
type Story = StoryObj<typeof ServiceRegistry>;
|
|
46
|
+
|
|
47
|
+
export const Default: Story = {
|
|
48
|
+
args: {},
|
|
49
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
import { Filter, type Space } from '@dxos/client/echo';
|
|
8
|
+
import { useQuery } from '@dxos/react-client/echo';
|
|
9
|
+
import { Icon, Input, List, ListItem } from '@dxos/react-ui';
|
|
10
|
+
|
|
11
|
+
import { useServices } from '../../hooks';
|
|
12
|
+
import { categoryIcons, ServiceType } from '../../types';
|
|
13
|
+
|
|
14
|
+
// TODO(burdon): Option to show all/enabled/filter.
|
|
15
|
+
export const ServiceRegistry = ({ space }: { space: Space }) => {
|
|
16
|
+
const matchingServices = useServices(space);
|
|
17
|
+
const enabledServices = useQuery(space, Filter.schema(ServiceType));
|
|
18
|
+
|
|
19
|
+
// Join matching services with enabled services.
|
|
20
|
+
const services = useMemo(() => {
|
|
21
|
+
return matchingServices.map((service) => enabledServices.find((s) => s.serviceId === service.serviceId) ?? service);
|
|
22
|
+
}, [matchingServices, enabledServices]);
|
|
23
|
+
|
|
24
|
+
// TODO(burdon): Reaplce with SpacePlugin intent.
|
|
25
|
+
const handleSetEnabled = (service: ServiceType, enabled: boolean) => {
|
|
26
|
+
if (enabled) {
|
|
27
|
+
space.db.add(service);
|
|
28
|
+
} else {
|
|
29
|
+
// TODO(burdon): Remove or disable?
|
|
30
|
+
space.db.remove(service);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<List classNames='h-full grid auto-rows-[5rem] gap-2 p-2 pis-2 pie-2 overflow-y-auto scrollbar-thin'>
|
|
36
|
+
{services.map((service) => (
|
|
37
|
+
<ServiceItem
|
|
38
|
+
key={service.serviceId}
|
|
39
|
+
service={service}
|
|
40
|
+
enabled={service.enabled}
|
|
41
|
+
setEnabled={(enabled) => handleSetEnabled(service, enabled)}
|
|
42
|
+
/>
|
|
43
|
+
))}
|
|
44
|
+
</List>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const ServiceItem = ({
|
|
49
|
+
service,
|
|
50
|
+
enabled,
|
|
51
|
+
setEnabled,
|
|
52
|
+
}: {
|
|
53
|
+
service: ServiceType;
|
|
54
|
+
enabled?: boolean;
|
|
55
|
+
setEnabled?: (enabled: boolean) => void;
|
|
56
|
+
}) => {
|
|
57
|
+
return (
|
|
58
|
+
<ListItem.Root classNames='flex flex-col gap-1 p-1 overflow-hidden rounded-md border border-separator'>
|
|
59
|
+
<div className='grid grid-cols-[40px_1fr_40px]'>
|
|
60
|
+
<div className='flex gow justify-center items-center'>
|
|
61
|
+
<Icon icon={categoryIcons[service.category ?? 'default'] ?? 'ph--placeholder--regular'} size={6} />
|
|
62
|
+
</div>
|
|
63
|
+
<div className='grow items-center truncate mie-2'>{service.name}</div>
|
|
64
|
+
<div className='flex gow justify-center items-center'>
|
|
65
|
+
<Input.Root>
|
|
66
|
+
<Input.Switch checked={enabled} onClick={() => setEnabled?.(!enabled)} />
|
|
67
|
+
</Input.Root>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
<div className='grid grid-cols-[40px_1fr]'>
|
|
71
|
+
<div />
|
|
72
|
+
<div className='text-sm text-subdued line-clamp-2 mie-1'>{service.description}</div>
|
|
73
|
+
</div>
|
|
74
|
+
</ListItem.Root>
|
|
75
|
+
);
|
|
76
|
+
};
|
|
@@ -0,0 +1,197 @@
|
|
|
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, { useCallback, useEffect, useState } from 'react';
|
|
9
|
+
|
|
10
|
+
import { type Message } from '@dxos/artifact';
|
|
11
|
+
import { ObjectId } from '@dxos/echo-schema';
|
|
12
|
+
import { faker } from '@dxos/random';
|
|
13
|
+
import { withLayout, withSignals, withTheme } from '@dxos/storybook-utils';
|
|
14
|
+
|
|
15
|
+
import { Thread, type ThreadProps } from './Thread';
|
|
16
|
+
import translations from '../../translations';
|
|
17
|
+
|
|
18
|
+
faker.seed(1);
|
|
19
|
+
|
|
20
|
+
const Render = ({ messages: _messages, ...props }: ThreadProps) => {
|
|
21
|
+
const [streaming, setStreaming] = useState(false);
|
|
22
|
+
const [messages, setMessages] = useState<Message[]>(_messages ?? []);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
setMessages(_messages ?? []);
|
|
25
|
+
}, [_messages]);
|
|
26
|
+
|
|
27
|
+
const handleSubmit = useCallback(
|
|
28
|
+
(text: string) => {
|
|
29
|
+
const request: Message = { id: ObjectId.random(), role: 'user', content: [{ type: 'text', text }] };
|
|
30
|
+
const response: Message = {
|
|
31
|
+
id: ObjectId.random(),
|
|
32
|
+
role: 'assistant',
|
|
33
|
+
content: [{ type: 'text', disposition: 'cot', pending: true, text: faker.lorem.paragraphs(1) }],
|
|
34
|
+
};
|
|
35
|
+
setMessages([...messages, request, response]);
|
|
36
|
+
setStreaming(true);
|
|
37
|
+
setTimeout(() => {
|
|
38
|
+
response.content[0].pending = false;
|
|
39
|
+
setMessages([
|
|
40
|
+
...messages,
|
|
41
|
+
request,
|
|
42
|
+
response,
|
|
43
|
+
{
|
|
44
|
+
id: ObjectId.random(),
|
|
45
|
+
role: 'assistant',
|
|
46
|
+
content: [{ type: 'text', text: faker.lorem.paragraphs(1) }],
|
|
47
|
+
},
|
|
48
|
+
]);
|
|
49
|
+
setStreaming(false);
|
|
50
|
+
}, 3_000);
|
|
51
|
+
},
|
|
52
|
+
[messages],
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<div className='flex grow justify-center overflow-center bg-baseSurface'>
|
|
57
|
+
<div className='flex w-[500px] bg-white dark:bg-black'>
|
|
58
|
+
<Thread {...props} messages={messages} streaming={streaming} onSubmit={handleSubmit} onStop={() => {}} />
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const meta: Meta<ThreadProps> = {
|
|
65
|
+
title: 'plugins/plugin-automation/Thread',
|
|
66
|
+
render: Render,
|
|
67
|
+
component: Thread,
|
|
68
|
+
decorators: [withSignals, withTheme, withLayout({ fullscreen: true, tooltips: true })],
|
|
69
|
+
parameters: {
|
|
70
|
+
translations,
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export default meta;
|
|
75
|
+
|
|
76
|
+
type Story = StoryObj<ThreadProps>;
|
|
77
|
+
|
|
78
|
+
const TEST_MESSAGES: Message[] = [
|
|
79
|
+
{
|
|
80
|
+
id: ObjectId.random(),
|
|
81
|
+
role: 'user',
|
|
82
|
+
content: [
|
|
83
|
+
{
|
|
84
|
+
type: 'text',
|
|
85
|
+
text: faker.lorem.sentence(5),
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
id: ObjectId.random(),
|
|
91
|
+
role: 'assistant',
|
|
92
|
+
content: [
|
|
93
|
+
{
|
|
94
|
+
type: 'text',
|
|
95
|
+
disposition: 'cot',
|
|
96
|
+
text: Array.from({ length: faker.number.int({ min: 3, max: 5 }) })
|
|
97
|
+
.map((_, idx) => `${idx + 1}. ${faker.lorem.paragraph()}`)
|
|
98
|
+
.join('\n'),
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
type: 'text',
|
|
102
|
+
text: Array.from({ length: faker.number.int({ min: 2, max: 5 }) })
|
|
103
|
+
.map(() => faker.lorem.paragraphs())
|
|
104
|
+
.join('\n\n'),
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
type: 'tool_use',
|
|
108
|
+
id: '1234',
|
|
109
|
+
name: 'search',
|
|
110
|
+
input: {},
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
id: ObjectId.random(),
|
|
116
|
+
role: 'user',
|
|
117
|
+
content: [
|
|
118
|
+
{
|
|
119
|
+
type: 'tool_result',
|
|
120
|
+
toolUseId: '1234',
|
|
121
|
+
content: 'This is a tool result.',
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
id: ObjectId.random(),
|
|
127
|
+
role: 'assistant',
|
|
128
|
+
content: [
|
|
129
|
+
{
|
|
130
|
+
type: 'tool_use',
|
|
131
|
+
id: '4567',
|
|
132
|
+
name: 'create',
|
|
133
|
+
input: {},
|
|
134
|
+
},
|
|
135
|
+
],
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
id: ObjectId.random(),
|
|
139
|
+
role: 'user',
|
|
140
|
+
content: [
|
|
141
|
+
{
|
|
142
|
+
type: 'tool_result',
|
|
143
|
+
toolUseId: '4567',
|
|
144
|
+
content: 'This is a tool result.',
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
id: ObjectId.random(),
|
|
150
|
+
role: 'assistant',
|
|
151
|
+
content: [
|
|
152
|
+
{
|
|
153
|
+
type: 'text',
|
|
154
|
+
text: faker.lorem.paragraphs(1),
|
|
155
|
+
},
|
|
156
|
+
],
|
|
157
|
+
},
|
|
158
|
+
];
|
|
159
|
+
|
|
160
|
+
export const Default: Story = {
|
|
161
|
+
args: {
|
|
162
|
+
// debug: true,
|
|
163
|
+
messages: TEST_MESSAGES,
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
export const Input: Story = {
|
|
168
|
+
args: {
|
|
169
|
+
streaming: true,
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
export const Collapse: Story = {
|
|
174
|
+
args: {
|
|
175
|
+
collapse: true,
|
|
176
|
+
messages: TEST_MESSAGES,
|
|
177
|
+
},
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
export const Incremental: Story = {
|
|
181
|
+
render: () => {
|
|
182
|
+
const [messages, setMessages] = useState<Message[]>([]);
|
|
183
|
+
useEffect(() => {
|
|
184
|
+
let i = 0;
|
|
185
|
+
const interval = setInterval(() => {
|
|
186
|
+
setMessages((messages) => [...messages, TEST_MESSAGES[i++]]);
|
|
187
|
+
if (i >= TEST_MESSAGES.length) {
|
|
188
|
+
clearInterval(interval);
|
|
189
|
+
}
|
|
190
|
+
}, 2_000);
|
|
191
|
+
|
|
192
|
+
return () => clearInterval(interval);
|
|
193
|
+
}, []);
|
|
194
|
+
|
|
195
|
+
return <Render messages={messages} collapse />;
|
|
196
|
+
},
|
|
197
|
+
};
|