@dxos/plugin-automation 0.7.5-labs.8a82073 → 0.7.5-labs.a8b535d
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-ITYXSN5Z.mjs +132 -0
- package/dist/lib/browser/AutomationPanel-ITYXSN5Z.mjs.map +7 -0
- package/dist/lib/browser/{chunk-DQ7ZSYJJ.mjs → chunk-OFDNNRLE.mjs} +3 -6
- package/dist/lib/browser/{chunk-DQ7ZSYJJ.mjs.map → chunk-OFDNNRLE.mjs.map} +3 -3
- package/dist/lib/browser/chunk-U7QLNY2S.mjs +8 -0
- package/dist/lib/browser/chunk-U7QLNY2S.mjs.map +7 -0
- package/dist/lib/browser/chunk-WY2C7JY4.mjs +119 -0
- package/dist/lib/browser/chunk-WY2C7JY4.mjs.map +7 -0
- package/dist/lib/browser/complementary-panel-4CPOJL4Y.mjs +56 -0
- package/dist/lib/browser/complementary-panel-4CPOJL4Y.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +21 -373
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-SAPMN4PF.mjs +27 -0
- package/dist/lib/browser/react-surface-SAPMN4PF.mjs.map +7 -0
- package/dist/lib/node/{chunk-IPCNJYQL.cjs → AutomationPanel-X33HHDMQ.cjs} +19 -132
- package/dist/lib/node/AutomationPanel-X33HHDMQ.cjs.map +7 -0
- package/dist/lib/node/chunk-7Q5SNGCL.cjs +148 -0
- package/dist/lib/node/chunk-7Q5SNGCL.cjs.map +7 -0
- package/dist/lib/node/chunk-CB5OB6JH.cjs +40 -0
- package/dist/lib/node/chunk-CB5OB6JH.cjs.map +7 -0
- package/dist/lib/node/{chunk-TQEDPRY5.cjs → chunk-ORMEYEBE.cjs} +6 -9
- package/dist/lib/node/{chunk-TQEDPRY5.cjs.map → chunk-ORMEYEBE.cjs.map} +3 -3
- package/dist/lib/node/complementary-panel-ZYJJ42ZU.cjs +72 -0
- package/dist/lib/node/complementary-panel-ZYJJ42ZU.cjs.map +7 -0
- package/dist/lib/node/index.cjs +36 -374
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-surface-BVZ63QP4.cjs → react-surface-2WRVAPGR.cjs} +9 -28
- package/dist/lib/node/react-surface-2WRVAPGR.cjs.map +7 -0
- package/dist/lib/node-esm/AutomationPanel-HY3GB4BT.mjs +133 -0
- package/dist/lib/node-esm/AutomationPanel-HY3GB4BT.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-JFHI22MF.mjs → chunk-6MUUH67V.mjs} +3 -6
- package/dist/lib/node-esm/{chunk-JFHI22MF.mjs.map → chunk-6MUUH67V.mjs.map} +3 -3
- package/dist/lib/node-esm/chunk-R3P2WPBQ.mjs +10 -0
- package/dist/lib/node-esm/chunk-R3P2WPBQ.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-UDD2VA6G.mjs +120 -0
- package/dist/lib/node-esm/chunk-UDD2VA6G.mjs.map +7 -0
- package/dist/lib/node-esm/complementary-panel-S42RIIAY.mjs +57 -0
- package/dist/lib/node-esm/complementary-panel-S42RIIAY.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +21 -373
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-QWLPOYXO.mjs +28 -0
- package/dist/lib/node-esm/react-surface-QWLPOYXO.mjs.map +7 -0
- package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/{ai-client.d.ts → complementary-panel.d.ts} +2 -3
- package/dist/types/src/capabilities/complementary-panel.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +1 -180
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +1 -2
- 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/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 +1 -11
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +0 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +0 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/test-functions.d.ts +0 -2
- package/dist/types/src/testing/test-functions.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +1 -94
- package/dist/types/src/translations.d.ts.map +1 -1
- package/package.json +23 -73
- package/src/AutomationPlugin.tsx +9 -64
- package/src/capabilities/complementary-panel.ts +56 -0
- package/src/capabilities/index.ts +1 -5
- package/src/capabilities/react-surface.tsx +2 -16
- package/src/components/AutomationPanel/AutomationPanel.stories.tsx +1 -2
- package/src/components/AutomationPanel/AutomationPanel.tsx +56 -49
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +1 -2
- package/src/components/index.ts +0 -7
- package/src/index.ts +2 -3
- package/src/meta.ts +1 -2
- package/src/testing/index.ts +0 -1
- package/src/testing/test-functions.ts +0 -7
- package/src/translations.ts +1 -29
- package/dist/lib/browser/AutomationPanel-CL2TWZT5.mjs +0 -8
- package/dist/lib/browser/AutomationPanel-CL2TWZT5.mjs.map +0 -7
- package/dist/lib/browser/ChatContainer-EJ3IWL7Y.mjs +0 -12
- package/dist/lib/browser/ChatContainer-EJ3IWL7Y.mjs.map +0 -7
- package/dist/lib/browser/ai-client-UJLNYP7B.mjs +0 -22
- package/dist/lib/browser/ai-client-UJLNYP7B.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-3H5TCRG4.mjs +0 -162
- package/dist/lib/browser/app-graph-builder-3H5TCRG4.mjs.map +0 -7
- package/dist/lib/browser/chunk-43WRHV2L.mjs +0 -150
- package/dist/lib/browser/chunk-43WRHV2L.mjs.map +0 -7
- package/dist/lib/browser/chunk-4M74P6YW.mjs +0 -284
- package/dist/lib/browser/chunk-4M74P6YW.mjs.map +0 -7
- package/dist/lib/browser/chunk-6KJRL5KV.mjs +0 -243
- package/dist/lib/browser/chunk-6KJRL5KV.mjs.map +0 -7
- package/dist/lib/browser/chunk-BQHXJZ4K.mjs +0 -15
- package/dist/lib/browser/chunk-BQHXJZ4K.mjs.map +0 -7
- package/dist/lib/browser/chunk-N4SSCQ7P.mjs +0 -1602
- package/dist/lib/browser/chunk-N4SSCQ7P.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-5YVZJFS3.mjs +0 -29
- package/dist/lib/browser/intent-resolver-5YVZJFS3.mjs.map +0 -7
- package/dist/lib/browser/react-surface-RRTZFTKR.mjs +0 -50
- package/dist/lib/browser/react-surface-RRTZFTKR.mjs.map +0 -7
- package/dist/lib/browser/types/index.mjs +0 -24
- package/dist/lib/browser/types/index.mjs.map +0 -7
- package/dist/lib/node/AutomationPanel-BCEY3YXO.cjs +0 -26
- package/dist/lib/node/AutomationPanel-BCEY3YXO.cjs.map +0 -7
- package/dist/lib/node/ChatContainer-QUWFEBTI.cjs +0 -33
- package/dist/lib/node/ChatContainer-QUWFEBTI.cjs.map +0 -7
- package/dist/lib/node/ai-client-AOB6TLNW.cjs +0 -38
- package/dist/lib/node/ai-client-AOB6TLNW.cjs.map +0 -7
- package/dist/lib/node/app-graph-builder-CDEQJEHY.cjs +0 -178
- package/dist/lib/node/app-graph-builder-CDEQJEHY.cjs.map +0 -7
- package/dist/lib/node/chunk-AWZVJZ2I.cjs +0 -34
- package/dist/lib/node/chunk-AWZVJZ2I.cjs.map +0 -7
- package/dist/lib/node/chunk-DKGNORZK.cjs +0 -1586
- package/dist/lib/node/chunk-DKGNORZK.cjs.map +0 -7
- package/dist/lib/node/chunk-H3RSMGJG.cjs +0 -173
- package/dist/lib/node/chunk-H3RSMGJG.cjs.map +0 -7
- package/dist/lib/node/chunk-IPCNJYQL.cjs.map +0 -7
- package/dist/lib/node/chunk-LC6KNDPQ.cjs +0 -302
- package/dist/lib/node/chunk-LC6KNDPQ.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-MJFZT5IU.cjs +0 -44
- package/dist/lib/node/intent-resolver-MJFZT5IU.cjs.map +0 -7
- package/dist/lib/node/react-surface-BVZ63QP4.cjs.map +0 -7
- package/dist/lib/node/types/index.cjs +0 -46
- package/dist/lib/node/types/index.cjs.map +0 -7
- package/dist/lib/node-esm/AutomationPanel-YTIZ74RI.mjs +0 -9
- package/dist/lib/node-esm/AutomationPanel-YTIZ74RI.mjs.map +0 -7
- package/dist/lib/node-esm/ChatContainer-QSMDZRDU.mjs +0 -13
- package/dist/lib/node-esm/ChatContainer-QSMDZRDU.mjs.map +0 -7
- package/dist/lib/node-esm/ai-client-RUCCJ7JZ.mjs +0 -23
- package/dist/lib/node-esm/ai-client-RUCCJ7JZ.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-GR3URVNX.mjs +0 -163
- package/dist/lib/node-esm/app-graph-builder-GR3URVNX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-7JO77AAS.mjs +0 -151
- package/dist/lib/node-esm/chunk-7JO77AAS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CQPQXIJP.mjs +0 -285
- package/dist/lib/node-esm/chunk-CQPQXIJP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CZXU4CFK.mjs +0 -244
- package/dist/lib/node-esm/chunk-CZXU4CFK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-D7RARVTS.mjs +0 -1603
- package/dist/lib/node-esm/chunk-D7RARVTS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-LSSWQIQD.mjs +0 -16
- package/dist/lib/node-esm/chunk-LSSWQIQD.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-FCKNRTKQ.mjs +0 -30
- package/dist/lib/node-esm/intent-resolver-FCKNRTKQ.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-Y5LQHUQN.mjs +0 -51
- package/dist/lib/node-esm/react-surface-Y5LQHUQN.mjs.map +0 -7
- package/dist/lib/node-esm/types/index.mjs +0 -25
- package/dist/lib/node-esm/types/index.mjs.map +0 -7
- package/dist/types/src/artifacts.stories.d.ts +0 -16
- package/dist/types/src/artifacts.stories.d.ts.map +0 -1
- package/dist/types/src/capabilities/ai-client.d.ts.map +0 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -180
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/capabilities.d.ts +0 -5
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/components/Box/StatusLine.d.ts +0 -11
- package/dist/types/src/components/Box/StatusLine.d.ts.map +0 -1
- package/dist/types/src/components/Box/StatusLine.stories.d.ts +0 -9
- package/dist/types/src/components/Box/StatusLine.stories.d.ts.map +0 -1
- package/dist/types/src/components/Box/Tabbed.d.ts +0 -15
- package/dist/types/src/components/Box/Tabbed.d.ts.map +0 -1
- package/dist/types/src/components/Box/Tabbed.stories.d.ts +0 -8
- package/dist/types/src/components/Box/Tabbed.stories.d.ts.map +0 -1
- package/dist/types/src/components/Box/ToggleContainer.d.ts +0 -13
- package/dist/types/src/components/Box/ToggleContainer.d.ts.map +0 -1
- package/dist/types/src/components/Box/ToggleContainer.stories.d.ts +0 -9
- package/dist/types/src/components/Box/ToggleContainer.stories.d.ts.map +0 -1
- package/dist/types/src/components/Box/index.d.ts +0 -4
- package/dist/types/src/components/Box/index.d.ts.map +0 -1
- package/dist/types/src/components/ChatContainer/ChatContainer.d.ts +0 -7
- package/dist/types/src/components/ChatContainer/ChatContainer.d.ts.map +0 -1
- package/dist/types/src/components/ChatContainer/index.d.ts +0 -4
- package/dist/types/src/components/ChatContainer/index.d.ts.map +0 -1
- package/dist/types/src/components/MarkdownViewer/MarkdownViewer.d.ts +0 -14
- package/dist/types/src/components/MarkdownViewer/MarkdownViewer.d.ts.map +0 -1
- package/dist/types/src/components/MarkdownViewer/MarkdownViewer.stories.d.ts +0 -8
- package/dist/types/src/components/MarkdownViewer/MarkdownViewer.stories.d.ts.map +0 -1
- package/dist/types/src/components/MarkdownViewer/index.d.ts +0 -2
- package/dist/types/src/components/MarkdownViewer/index.d.ts.map +0 -1
- package/dist/types/src/components/Prompt/Prompt.d.ts +0 -7
- package/dist/types/src/components/Prompt/Prompt.d.ts.map +0 -1
- package/dist/types/src/components/Prompt/Prompt.stories.d.ts +0 -8
- package/dist/types/src/components/Prompt/Prompt.stories.d.ts.map +0 -1
- package/dist/types/src/components/Prompt/index.d.ts +0 -2
- package/dist/types/src/components/Prompt/index.d.ts.map +0 -1
- package/dist/types/src/components/Prompt/prompt-autocomplete.d.ts +0 -20
- package/dist/types/src/components/Prompt/prompt-autocomplete.d.ts.map +0 -1
- package/dist/types/src/components/PromptEditor/PromptEditor.d.ts +0 -10
- package/dist/types/src/components/PromptEditor/PromptEditor.d.ts.map +0 -1
- package/dist/types/src/components/PromptEditor/PromptEditor.stories.d.ts +0 -6
- package/dist/types/src/components/PromptEditor/PromptEditor.stories.d.ts.map +0 -1
- package/dist/types/src/components/PromptEditor/index.d.ts +0 -2
- package/dist/types/src/components/PromptEditor/index.d.ts.map +0 -1
- package/dist/types/src/components/PromptEditor/prompt-extension.d.ts +0 -4
- package/dist/types/src/components/PromptEditor/prompt-extension.d.ts.map +0 -1
- package/dist/types/src/components/PromptEditor/types.d.ts +0 -18
- package/dist/types/src/components/PromptEditor/types.d.ts.map +0 -1
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts +0 -6
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts.map +0 -1
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.stories.d.ts +0 -8
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.stories.d.ts.map +0 -1
- package/dist/types/src/components/ServiceRegistry/index.d.ts +0 -2
- package/dist/types/src/components/ServiceRegistry/index.d.ts.map +0 -1
- package/dist/types/src/components/Thread/Thread.d.ts +0 -11
- package/dist/types/src/components/Thread/Thread.d.ts.map +0 -1
- package/dist/types/src/components/Thread/Thread.stories.d.ts +0 -11
- package/dist/types/src/components/Thread/Thread.stories.d.ts.map +0 -1
- package/dist/types/src/components/Thread/ThreadMessage.d.ts +0 -12
- package/dist/types/src/components/Thread/ThreadMessage.d.ts.map +0 -1
- package/dist/types/src/components/Thread/index.d.ts +0 -2
- package/dist/types/src/components/Thread/index.d.ts.map +0 -1
- package/dist/types/src/hooks/email.d.ts +0 -4
- package/dist/types/src/hooks/email.d.ts.map +0 -1
- package/dist/types/src/hooks/index.d.ts +0 -6
- package/dist/types/src/hooks/index.d.ts.map +0 -1
- package/dist/types/src/hooks/invocation-handler.d.ts +0 -5
- package/dist/types/src/hooks/invocation-handler.d.ts.map +0 -1
- package/dist/types/src/hooks/processor.d.ts +0 -70
- package/dist/types/src/hooks/processor.d.ts.map +0 -1
- package/dist/types/src/hooks/processor.test.d.ts +0 -2
- package/dist/types/src/hooks/processor.test.d.ts.map +0 -1
- package/dist/types/src/hooks/useChatProcessor.d.ts +0 -7
- package/dist/types/src/hooks/useChatProcessor.d.ts.map +0 -1
- package/dist/types/src/hooks/useLocalTriggerManager.d.ts +0 -3
- package/dist/types/src/hooks/useLocalTriggerManager.d.ts.map +0 -1
- package/dist/types/src/hooks/useMessageQueue.d.ts +0 -41
- package/dist/types/src/hooks/useMessageQueue.d.ts.map +0 -1
- package/dist/types/src/hooks/useServices.d.ts +0 -7
- package/dist/types/src/hooks/useServices.d.ts.map +0 -1
- package/dist/types/src/presets.d.ts +0 -9
- package/dist/types/src/presets.d.ts.map +0 -1
- package/dist/types/src/testing/test-services.d.ts +0 -5
- package/dist/types/src/testing/test-services.d.ts.map +0 -1
- package/dist/types/src/tools/function.d.ts +0 -5
- package/dist/types/src/tools/function.d.ts.map +0 -1
- package/dist/types/src/tools/index.d.ts +0 -3
- package/dist/types/src/tools/index.d.ts.map +0 -1
- package/dist/types/src/tools/openapi.d.ts +0 -10
- package/dist/types/src/tools/openapi.d.ts.map +0 -1
- package/dist/types/src/tools/openapi.test.d.ts +0 -2
- package/dist/types/src/tools/openapi.test.d.ts.map +0 -1
- package/dist/types/src/types/index.d.ts +0 -4
- package/dist/types/src/types/index.d.ts.map +0 -1
- package/dist/types/src/types/registry.d.ts +0 -10
- package/dist/types/src/types/registry.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -221
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/dist/types/src/types/types.d.ts +0 -18
- package/dist/types/src/types/types.d.ts.map +0 -1
- package/src/artifacts.stories.tsx +0 -241
- package/src/capabilities/ai-client.ts +0 -19
- package/src/capabilities/app-graph-builder.ts +0 -156
- package/src/capabilities/capabilities.ts +0 -12
- package/src/capabilities/intent-resolver.ts +0 -27
- package/src/components/Box/StatusLine.stories.tsx +0 -52
- package/src/components/Box/StatusLine.tsx +0 -76
- package/src/components/Box/Tabbed.stories.tsx +0 -51
- package/src/components/Box/Tabbed.tsx +0 -89
- package/src/components/Box/ToggleContainer.stories.tsx +0 -110
- package/src/components/Box/ToggleContainer.tsx +0 -108
- package/src/components/Box/index.ts +0 -7
- package/src/components/ChatContainer/ChatContainer.tsx +0 -52
- package/src/components/ChatContainer/index.ts +0 -8
- package/src/components/MarkdownViewer/MarkdownViewer.stories.tsx +0 -56
- package/src/components/MarkdownViewer/MarkdownViewer.tsx +0 -79
- package/src/components/MarkdownViewer/index.ts +0 -5
- package/src/components/Prompt/Prompt.stories.tsx +0 -50
- package/src/components/Prompt/Prompt.tsx +0 -36
- package/src/components/Prompt/index.ts +0 -5
- package/src/components/Prompt/prompt-autocomplete.ts +0 -200
- package/src/components/PromptEditor/PromptEditor.stories.tsx +0 -64
- package/src/components/PromptEditor/PromptEditor.tsx +0 -222
- package/src/components/PromptEditor/index.ts +0 -5
- package/src/components/PromptEditor/prompt-extension.ts +0 -43
- package/src/components/PromptEditor/types.tsx +0 -28
- package/src/components/ServiceRegistry/ServiceRegistry.stories.tsx +0 -49
- package/src/components/ServiceRegistry/ServiceRegistry.tsx +0 -75
- package/src/components/ServiceRegistry/index.ts +0 -5
- package/src/components/Thread/Thread.stories.tsx +0 -197
- package/src/components/Thread/Thread.tsx +0 -156
- package/src/components/Thread/ThreadMessage.tsx +0 -225
- package/src/components/Thread/index.ts +0 -5
- package/src/hooks/email.ts +0 -49
- package/src/hooks/index.ts +0 -10
- package/src/hooks/invocation-handler.ts +0 -109
- package/src/hooks/processor.test.ts +0 -15
- package/src/hooks/processor.ts +0 -210
- package/src/hooks/useChatProcessor.tsx +0 -86
- package/src/hooks/useLocalTriggerManager.ts +0 -82
- package/src/hooks/useMessageQueue.ts +0 -23
- package/src/hooks/useServices.ts +0 -28
- package/src/presets.ts +0 -248
- package/src/testing/test-services.ts +0 -131
- package/src/tools/function.ts +0 -47
- package/src/tools/index.ts +0 -6
- package/src/tools/openapi.test.ts +0 -227
- package/src/tools/openapi.ts +0 -331
- package/src/types/index.ts +0 -7
- package/src/types/registry.ts +0 -26
- package/src/types/schema.ts +0 -132
- package/src/types/types.ts +0 -21
|
@@ -1,197 +0,0 @@
|
|
|
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-base'>
|
|
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
|
-
};
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { type KeyboardEventHandler, useCallback, useMemo, useRef, useState } from 'react';
|
|
6
|
-
|
|
7
|
-
import { type Message } from '@dxos/artifact';
|
|
8
|
-
import { IconButton, Input, useTranslation } from '@dxos/react-ui';
|
|
9
|
-
import { ScrollContainer, type ScrollController } from '@dxos/react-ui-components';
|
|
10
|
-
import { Spinner } from '@dxos/react-ui-sfx';
|
|
11
|
-
import { mx } from '@dxos/react-ui-theme';
|
|
12
|
-
|
|
13
|
-
import { ThreadMessage, type ThreadMessageProps } from './ThreadMessage';
|
|
14
|
-
import { AUTOMATION_PLUGIN } from '../../meta';
|
|
15
|
-
|
|
16
|
-
export type ThreadProps = {
|
|
17
|
-
messages?: Message[];
|
|
18
|
-
streaming?: boolean;
|
|
19
|
-
onSubmit?: (message: string) => void;
|
|
20
|
-
onStop?: () => void;
|
|
21
|
-
} & Pick<ThreadMessageProps, 'collapse' | 'debug' | 'onSuggest' | 'onDelete'>;
|
|
22
|
-
|
|
23
|
-
// TODO(burdon): Factor out scroll logic.
|
|
24
|
-
export const Thread = ({
|
|
25
|
-
messages,
|
|
26
|
-
streaming,
|
|
27
|
-
collapse,
|
|
28
|
-
debug,
|
|
29
|
-
onSubmit,
|
|
30
|
-
onStop,
|
|
31
|
-
onSuggest,
|
|
32
|
-
onDelete,
|
|
33
|
-
}: ThreadProps) => {
|
|
34
|
-
const { t } = useTranslation(AUTOMATION_PLUGIN);
|
|
35
|
-
const scroller = useRef<ScrollController>(null);
|
|
36
|
-
|
|
37
|
-
const [text, setText] = useState('');
|
|
38
|
-
const handleKeyDown = useCallback<KeyboardEventHandler<HTMLInputElement>>(
|
|
39
|
-
(ev) => {
|
|
40
|
-
switch (ev.key) {
|
|
41
|
-
case 'Escape': {
|
|
42
|
-
setText('');
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
case 'Enter': {
|
|
47
|
-
const value = text.trim();
|
|
48
|
-
if (value.length > 0) {
|
|
49
|
-
scroller.current?.scrollToBottom();
|
|
50
|
-
onSubmit?.(value);
|
|
51
|
-
setText('');
|
|
52
|
-
}
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
[text],
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Reduce message blocks into collections of messages that contain related contiguous blocks.
|
|
62
|
-
* For example, collapse all tool request/response pairs into a single message.
|
|
63
|
-
*/
|
|
64
|
-
// TODO(dmaretskyi): This needs to be a separate type: `id` is not a valid ObjectId, this needs to accommodate messageId for deletion.
|
|
65
|
-
const { messages: lines = [] } = useMemo(() => {
|
|
66
|
-
if (!collapse) {
|
|
67
|
-
return { messages: messages ?? [] };
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return (messages ?? []).reduce<{ messages: Message[]; current?: Message }>(
|
|
71
|
-
({ current, messages }, message) => {
|
|
72
|
-
let i = 0;
|
|
73
|
-
for (const block of message.content) {
|
|
74
|
-
switch (block.type) {
|
|
75
|
-
case 'tool_use':
|
|
76
|
-
case 'tool_result': {
|
|
77
|
-
if (current) {
|
|
78
|
-
current.content.push(block);
|
|
79
|
-
} else {
|
|
80
|
-
current = {
|
|
81
|
-
id: [message.id, i].join('_'),
|
|
82
|
-
role: message.role,
|
|
83
|
-
content: [block],
|
|
84
|
-
};
|
|
85
|
-
messages.push(current);
|
|
86
|
-
}
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
case 'text':
|
|
91
|
-
default: {
|
|
92
|
-
current = undefined;
|
|
93
|
-
messages.push({
|
|
94
|
-
id: [message.id, i].join('_'),
|
|
95
|
-
role: message.role,
|
|
96
|
-
content: [block],
|
|
97
|
-
});
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
i++;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
return { current, messages };
|
|
106
|
-
},
|
|
107
|
-
{ messages: [] as Message[] },
|
|
108
|
-
);
|
|
109
|
-
}, [messages, collapse]);
|
|
110
|
-
|
|
111
|
-
return (
|
|
112
|
-
<div className='flex flex-col grow overflow-hidden'>
|
|
113
|
-
<ScrollContainer ref={scroller} classNames='py-2 gap-2 overflow-x-hidden'>
|
|
114
|
-
{lines.map((message) => (
|
|
115
|
-
<ThreadMessage
|
|
116
|
-
key={message.id}
|
|
117
|
-
classNames='px-4'
|
|
118
|
-
message={message}
|
|
119
|
-
collapse={collapse}
|
|
120
|
-
debug={debug}
|
|
121
|
-
onSuggest={onSuggest}
|
|
122
|
-
onDelete={onDelete}
|
|
123
|
-
/>
|
|
124
|
-
))}
|
|
125
|
-
</ScrollContainer>
|
|
126
|
-
|
|
127
|
-
{onSubmit && (
|
|
128
|
-
<div className='flex p-4 gap-3 items-center'>
|
|
129
|
-
<Spinner active={streaming} />
|
|
130
|
-
<Input.Root>
|
|
131
|
-
<Input.TextInput
|
|
132
|
-
autoFocus
|
|
133
|
-
classNames='px-2 baseSurface rounded'
|
|
134
|
-
placeholder={t('chat input placeholder')}
|
|
135
|
-
value={text}
|
|
136
|
-
onChange={(ev) => setText(ev.target.value)}
|
|
137
|
-
onKeyDown={handleKeyDown}
|
|
138
|
-
/>
|
|
139
|
-
</Input.Root>
|
|
140
|
-
{onStop && (
|
|
141
|
-
<IconButton
|
|
142
|
-
disabled={!streaming}
|
|
143
|
-
classNames={mx('!p-1 !opacity-20 transition', streaming && '!opacity-80')}
|
|
144
|
-
variant='ghost'
|
|
145
|
-
size={5}
|
|
146
|
-
onClick={onStop}
|
|
147
|
-
icon='ph--x--regular'
|
|
148
|
-
label={t('chat stop')}
|
|
149
|
-
iconOnly
|
|
150
|
-
/>
|
|
151
|
-
)}
|
|
152
|
-
</div>
|
|
153
|
-
)}
|
|
154
|
-
</div>
|
|
155
|
-
);
|
|
156
|
-
};
|
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { useEffect, useRef, useState, type FC } from 'react';
|
|
6
|
-
|
|
7
|
-
import { type MessageContentBlock, type Message } from '@dxos/artifact';
|
|
8
|
-
import { invariant } from '@dxos/invariant';
|
|
9
|
-
import { log } from '@dxos/log';
|
|
10
|
-
import { Button, ButtonGroup, Icon, type ThemedClassName } from '@dxos/react-ui';
|
|
11
|
-
import { Json } from '@dxos/react-ui-syntax-highlighter';
|
|
12
|
-
import { mx } from '@dxos/react-ui-theme';
|
|
13
|
-
import { safeParseJson } from '@dxos/util';
|
|
14
|
-
|
|
15
|
-
import { ToggleContainer, StatusLine, Tabs } from '../Box';
|
|
16
|
-
import { MarkdownViewer } from '../MarkdownViewer';
|
|
17
|
-
|
|
18
|
-
export type ThreadMessageProps = ThemedClassName<{
|
|
19
|
-
message: Message;
|
|
20
|
-
collapse?: boolean;
|
|
21
|
-
debug?: boolean;
|
|
22
|
-
onSuggest?: (text: string) => void;
|
|
23
|
-
onDelete?: (id: string) => void;
|
|
24
|
-
}>;
|
|
25
|
-
|
|
26
|
-
export const ThreadMessage: FC<ThreadMessageProps> = ({
|
|
27
|
-
classNames,
|
|
28
|
-
message,
|
|
29
|
-
collapse,
|
|
30
|
-
debug,
|
|
31
|
-
onSuggest,
|
|
32
|
-
onDelete,
|
|
33
|
-
}) => {
|
|
34
|
-
if (typeof message !== 'object') {
|
|
35
|
-
return <div className={mx(classNames)}>{message}</div>;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const { role, content = [] } = message;
|
|
39
|
-
|
|
40
|
-
// TODO(burdon): Factor out tool blocks.
|
|
41
|
-
const toolBlocks = content.filter((block) => block.type === 'tool_use' || block.type === 'tool_result');
|
|
42
|
-
if (collapse && toolBlocks.length > 0) {
|
|
43
|
-
let request: (MessageContentBlock & { type: 'tool_use' }) | undefined;
|
|
44
|
-
const items = toolBlocks.map((block) => {
|
|
45
|
-
switch (block.type) {
|
|
46
|
-
case 'tool_use': {
|
|
47
|
-
request = block;
|
|
48
|
-
// TODO(burdon): Get plugin name.
|
|
49
|
-
return { title: `Calling ${block.name}...`, block };
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
case 'tool_result': {
|
|
53
|
-
if (!request) {
|
|
54
|
-
log.warn('unexpected message', { block });
|
|
55
|
-
return { title: 'Error', block };
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return { title: `Processed ${request.name}`, block };
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
default: {
|
|
62
|
-
request = undefined;
|
|
63
|
-
return { title: 'Error', block };
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
return (
|
|
69
|
-
<div className={mx('flex', classNames)}>
|
|
70
|
-
<div className='w-full p-1 px-2 overflow-hidden rounded-md bg-baseSurface'>
|
|
71
|
-
<TabbedContainer items={items} />
|
|
72
|
-
</div>
|
|
73
|
-
</div>
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return (
|
|
78
|
-
<div className={mx('flex flex-col shrink-0 gap-2')}>
|
|
79
|
-
{debug && (
|
|
80
|
-
<div className='text-xs text-subdued'>
|
|
81
|
-
{message.id}{' '}
|
|
82
|
-
{onDelete && (
|
|
83
|
-
<span className='cursor-pointer underline' onClick={() => onDelete(message.id)}>
|
|
84
|
-
delete
|
|
85
|
-
</span>
|
|
86
|
-
)}
|
|
87
|
-
</div>
|
|
88
|
-
)}
|
|
89
|
-
{content.map((block, idx) => (
|
|
90
|
-
<div key={idx} className={mx('flex', classNames, block.type === 'text' && role === 'user' && 'justify-end')}>
|
|
91
|
-
<Block role={role} block={block} onSuggest={onSuggest ?? (() => {})} />
|
|
92
|
-
</div>
|
|
93
|
-
))}
|
|
94
|
-
</div>
|
|
95
|
-
);
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const Block = ({
|
|
99
|
-
block,
|
|
100
|
-
role,
|
|
101
|
-
onSuggest,
|
|
102
|
-
}: Pick<Message, 'role'> & { block: MessageContentBlock; onSuggest: (text: string) => void }) => {
|
|
103
|
-
const Component = componentMap[block.type] ?? componentMap.default;
|
|
104
|
-
return (
|
|
105
|
-
<div
|
|
106
|
-
className={mx(
|
|
107
|
-
'p-1 px-2 overflow-hidden rounded-md',
|
|
108
|
-
(block.type !== 'text' || block.disposition) && 'w-full bg-baseSurface',
|
|
109
|
-
block.type === 'text' && role === 'user' && 'bg-primary-200 dark:bg-primary-500',
|
|
110
|
-
)}
|
|
111
|
-
>
|
|
112
|
-
<Component block={block} onSuggest={onSuggest} />
|
|
113
|
-
</div>
|
|
114
|
-
);
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
const titles: Record<string, string> = {
|
|
118
|
-
['cot' as const]: 'Chain of thought',
|
|
119
|
-
['artifact' as const]: 'Artifact',
|
|
120
|
-
['tool_use' as const]: 'Tool request',
|
|
121
|
-
['tool_result' as const]: 'Tool result',
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
type BlockComponent = FC<{ block: MessageContentBlock; onSuggest: (text: string) => void }>;
|
|
125
|
-
|
|
126
|
-
const componentMap: Record<string, BlockComponent> = {
|
|
127
|
-
text: ({ block }) => {
|
|
128
|
-
invariant(block.type === 'text');
|
|
129
|
-
const title = block.disposition ? titles[block.disposition] : undefined;
|
|
130
|
-
if (!title) {
|
|
131
|
-
return (
|
|
132
|
-
<MarkdownViewer content={block.text} classNames={[block.disposition === 'cot' && 'text-sm text-subdued']} />
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return (
|
|
137
|
-
<ToggleContainer
|
|
138
|
-
title={title}
|
|
139
|
-
icon={
|
|
140
|
-
block.pending ? (
|
|
141
|
-
<Icon icon={'ph--circle-notch--regular'} classNames='text-subdued ml-2 animate-spin' size={4} />
|
|
142
|
-
) : undefined
|
|
143
|
-
}
|
|
144
|
-
open={block.disposition === 'cot'}
|
|
145
|
-
>
|
|
146
|
-
<MarkdownViewer content={block.text} classNames={[block.disposition === 'cot' && 'text-sm text-subdued']} />
|
|
147
|
-
</ToggleContainer>
|
|
148
|
-
);
|
|
149
|
-
},
|
|
150
|
-
|
|
151
|
-
json: ({ block, onSuggest }) => {
|
|
152
|
-
invariant(block.type === 'json');
|
|
153
|
-
|
|
154
|
-
switch (block.disposition) {
|
|
155
|
-
case 'suggest': {
|
|
156
|
-
const { text = '' }: { text: string } = safeParseJson(block.json ?? '{}') ?? ({} as any);
|
|
157
|
-
return <Button onClick={() => onSuggest(text)}>{text}</Button>;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
case 'select': {
|
|
161
|
-
const { options = [] }: { options: string[] } = safeParseJson(block.json ?? '{}') ?? ({} as any);
|
|
162
|
-
return (
|
|
163
|
-
<ButtonGroup>
|
|
164
|
-
{options.map((option) => (
|
|
165
|
-
<Button key={option} onClick={() => onSuggest(option)}>
|
|
166
|
-
{option}
|
|
167
|
-
</Button>
|
|
168
|
-
))}
|
|
169
|
-
</ButtonGroup>
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
default: {
|
|
174
|
-
const title = block.disposition ? titles[block.disposition] : undefined;
|
|
175
|
-
return (
|
|
176
|
-
<ToggleContainer title={title ?? 'JSON'}>
|
|
177
|
-
<Json data={safeParseJson(block.json ?? block)} classNames='!p-1 text-xs' />
|
|
178
|
-
</ToggleContainer>
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
|
|
184
|
-
default: ({ block }) => {
|
|
185
|
-
let title = titles[block.type];
|
|
186
|
-
if (block.type === 'tool_use') {
|
|
187
|
-
title = `Tool [${block.name}]`; // TODO(burdon): Get label from tool.
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
return (
|
|
191
|
-
<ToggleContainer title={title ?? 'JSON'}>
|
|
192
|
-
<Json data={block} classNames='!p-1 text-xs' />
|
|
193
|
-
</ToggleContainer>
|
|
194
|
-
);
|
|
195
|
-
},
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
const TabbedContainer = ({ items }: { items: { title: string; block: any }[] }) => {
|
|
199
|
-
const lines = items.map((item) => item.title);
|
|
200
|
-
const tabsRef = useRef<HTMLDivElement>(null);
|
|
201
|
-
const [selected, setSelected] = useState(0);
|
|
202
|
-
const [open, setOpen] = useState(false);
|
|
203
|
-
useEffect(() => {
|
|
204
|
-
if (open) {
|
|
205
|
-
tabsRef.current?.focus();
|
|
206
|
-
}
|
|
207
|
-
}, [open]);
|
|
208
|
-
|
|
209
|
-
const handleSelect = (index: number) => {
|
|
210
|
-
if (index === selected) {
|
|
211
|
-
setOpen(false);
|
|
212
|
-
} else {
|
|
213
|
-
setSelected(index);
|
|
214
|
-
}
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
return (
|
|
218
|
-
<ToggleContainer title={<StatusLine lines={lines} autoAdvance />} open={open} onChangeOpen={setOpen}>
|
|
219
|
-
<div className='flex gap-2 w-full'>
|
|
220
|
-
<Tabs ref={tabsRef} length={items.length} selected={selected} onSelect={handleSelect} />
|
|
221
|
-
<Json data={items[selected].block} classNames='!p-1 text-xs' />
|
|
222
|
-
</div>
|
|
223
|
-
</ToggleContainer>
|
|
224
|
-
);
|
|
225
|
-
};
|
package/src/hooks/email.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { findObjectWithForeignKey } from '@dxos/echo-db';
|
|
6
|
-
import { foreignKey } from '@dxos/echo-schema';
|
|
7
|
-
import { log } from '@dxos/log';
|
|
8
|
-
import { MailboxType } from '@dxos/plugin-inbox/types';
|
|
9
|
-
import { MessageType } from '@dxos/plugin-space/types';
|
|
10
|
-
import { type Space, Filter, create, makeRef } from '@dxos/react-client/echo';
|
|
11
|
-
|
|
12
|
-
export const SOURCE_ID = 'hub.dxos.network/api/mailbox';
|
|
13
|
-
|
|
14
|
-
export const handleEmail = async (space: Space, data: any) => {
|
|
15
|
-
const { messages } = data;
|
|
16
|
-
|
|
17
|
-
// Create mailbox if doesn't exist.
|
|
18
|
-
const { objects: mailboxes } = await space.db.query(Filter.schema(MailboxType)).run();
|
|
19
|
-
const mailbox = mailboxes[0] ?? space.db.add(create(MailboxType, { messages: [] }));
|
|
20
|
-
|
|
21
|
-
log.info('messages', { count: messages.length, existingMailbox: mailboxes.length > 0 });
|
|
22
|
-
|
|
23
|
-
const { objects } = await space.db.query(Filter.schema(MessageType)).run();
|
|
24
|
-
for (const message of messages) {
|
|
25
|
-
let object = findObjectWithForeignKey(objects, { source: SOURCE_ID, id: String(message.id) });
|
|
26
|
-
if (!object) {
|
|
27
|
-
object = space.db.add(
|
|
28
|
-
create(
|
|
29
|
-
MessageType,
|
|
30
|
-
{
|
|
31
|
-
sender: { email: message.from },
|
|
32
|
-
timestamp: new Date(message.created).toISOString(),
|
|
33
|
-
text: message.body,
|
|
34
|
-
properties: {
|
|
35
|
-
subject: message.subject,
|
|
36
|
-
to: [{ email: message.to }],
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
keys: [foreignKey(SOURCE_ID, String(message.id))],
|
|
41
|
-
},
|
|
42
|
-
),
|
|
43
|
-
);
|
|
44
|
-
mailbox.messages?.push(makeRef(object));
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return 200;
|
|
49
|
-
};
|