@dxos/plugin-automation 0.7.5-labs.ff2ff30 → 0.7.5-main.6a330ac
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-R4JH4TLE.mjs → chunk-OFDNNRLE.mjs} +3 -8
- package/dist/lib/browser/chunk-OFDNNRLE.mjs.map +7 -0
- 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 -377
- 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-QXIHYOMF.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-EQYHOTGG.cjs → chunk-ORMEYEBE.cjs} +6 -12
- package/dist/lib/node/chunk-ORMEYEBE.cjs.map +7 -0
- 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 -378
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-surface-LWDY7SQG.cjs → react-surface-2WRVAPGR.cjs} +9 -34
- 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-EMVA6QUT.mjs → chunk-6MUUH67V.mjs} +3 -8
- package/dist/lib/node-esm/chunk-6MUUH67V.mjs.map +7 -0
- 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 -377
- 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 -12
- 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 -2
- 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 +3 -23
- 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 -8
- package/src/index.ts +2 -3
- package/src/meta.ts +1 -4
- 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-VW2XIUPU.mjs +0 -8
- package/dist/lib/browser/AutomationPanel-VW2XIUPU.mjs.map +0 -7
- package/dist/lib/browser/ChatContainer-5TAVTN3T.mjs +0 -12
- package/dist/lib/browser/ChatContainer-5TAVTN3T.mjs.map +0 -7
- package/dist/lib/browser/ai-client-5CNY6JBF.mjs +0 -22
- package/dist/lib/browser/ai-client-5CNY6JBF.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-FZGK55G7.mjs +0 -197
- package/dist/lib/browser/app-graph-builder-FZGK55G7.mjs.map +0 -7
- package/dist/lib/browser/chunk-2H2EUYXL.mjs +0 -15
- package/dist/lib/browser/chunk-2H2EUYXL.mjs.map +0 -7
- package/dist/lib/browser/chunk-DVE33EZL.mjs +0 -1602
- package/dist/lib/browser/chunk-DVE33EZL.mjs.map +0 -7
- package/dist/lib/browser/chunk-MJK7GL5P.mjs +0 -307
- package/dist/lib/browser/chunk-MJK7GL5P.mjs.map +0 -7
- package/dist/lib/browser/chunk-NQFZ6XRX.mjs +0 -243
- package/dist/lib/browser/chunk-NQFZ6XRX.mjs.map +0 -7
- package/dist/lib/browser/chunk-Q4IMHYGH.mjs +0 -150
- package/dist/lib/browser/chunk-Q4IMHYGH.mjs.map +0 -7
- package/dist/lib/browser/chunk-R4JH4TLE.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-BWAXKT27.mjs +0 -29
- package/dist/lib/browser/intent-resolver-BWAXKT27.mjs.map +0 -7
- package/dist/lib/browser/react-surface-ILBDBZCN.mjs +0 -58
- package/dist/lib/browser/react-surface-ILBDBZCN.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-G6EDDYWW.cjs +0 -26
- package/dist/lib/node/AutomationPanel-G6EDDYWW.cjs.map +0 -7
- package/dist/lib/node/ChatContainer-EN24W3K4.cjs +0 -33
- package/dist/lib/node/ChatContainer-EN24W3K4.cjs.map +0 -7
- package/dist/lib/node/ai-client-FKLPDELV.cjs +0 -38
- package/dist/lib/node/ai-client-FKLPDELV.cjs.map +0 -7
- package/dist/lib/node/app-graph-builder-T76NYV42.cjs +0 -212
- package/dist/lib/node/app-graph-builder-T76NYV42.cjs.map +0 -7
- package/dist/lib/node/chunk-CJGJXNY3.cjs +0 -1586
- package/dist/lib/node/chunk-CJGJXNY3.cjs.map +0 -7
- package/dist/lib/node/chunk-EQYHOTGG.cjs.map +0 -7
- package/dist/lib/node/chunk-GB7245FH.cjs +0 -173
- package/dist/lib/node/chunk-GB7245FH.cjs.map +0 -7
- package/dist/lib/node/chunk-HMBKP6VG.cjs +0 -324
- package/dist/lib/node/chunk-HMBKP6VG.cjs.map +0 -7
- package/dist/lib/node/chunk-QXIHYOMF.cjs.map +0 -7
- package/dist/lib/node/chunk-U5Z7LFWB.cjs +0 -34
- package/dist/lib/node/chunk-U5Z7LFWB.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-C6OKFVEW.cjs +0 -44
- package/dist/lib/node/intent-resolver-C6OKFVEW.cjs.map +0 -7
- package/dist/lib/node/react-surface-LWDY7SQG.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-V3IWQAMO.mjs +0 -9
- package/dist/lib/node-esm/AutomationPanel-V3IWQAMO.mjs.map +0 -7
- package/dist/lib/node-esm/ChatContainer-CNTY3C2D.mjs +0 -13
- package/dist/lib/node-esm/ChatContainer-CNTY3C2D.mjs.map +0 -7
- package/dist/lib/node-esm/ai-client-XGNA6SJ5.mjs +0 -23
- package/dist/lib/node-esm/ai-client-XGNA6SJ5.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-IJQEN7WT.mjs +0 -198
- package/dist/lib/node-esm/app-graph-builder-IJQEN7WT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-6HLBYDUI.mjs +0 -244
- package/dist/lib/node-esm/chunk-6HLBYDUI.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-DNCXRGAF.mjs +0 -151
- package/dist/lib/node-esm/chunk-DNCXRGAF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-EMVA6QUT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IJRTDSKN.mjs +0 -16
- package/dist/lib/node-esm/chunk-IJRTDSKN.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-QP47VJT6.mjs +0 -1603
- package/dist/lib/node-esm/chunk-QP47VJT6.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ZLIAMW45.mjs +0 -308
- package/dist/lib/node-esm/chunk-ZLIAMW45.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-DCP4ZDBA.mjs +0 -30
- package/dist/lib/node-esm/intent-resolver-DCP4ZDBA.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-SBDXFVIN.mjs +0 -59
- package/dist/lib/node-esm/react-surface-SBDXFVIN.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 -181
- 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/AmbientChatDialog/AmbientChatDialog.d.ts +0 -3
- package/dist/types/src/components/AmbientChatDialog/AmbientChatDialog.d.ts.map +0 -1
- package/dist/types/src/components/AmbientChatDialog/index.d.ts +0 -2
- package/dist/types/src/components/AmbientChatDialog/index.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 -187
- package/src/capabilities/capabilities.ts +0 -12
- package/src/capabilities/intent-resolver.ts +0 -27
- package/src/components/AmbientChatDialog/AmbientChatDialog.tsx +0 -26
- package/src/components/AmbientChatDialog/index.ts +0 -5
- 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,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
|
-
};
|
package/src/hooks/index.ts
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { sleep } from '@dxos/async';
|
|
6
|
-
import { getObjectCore, ResultFormat } from '@dxos/echo-db';
|
|
7
|
-
import { type AnyObjectData } from '@dxos/echo-schema';
|
|
8
|
-
import { FunctionType } from '@dxos/functions';
|
|
9
|
-
import { type FunctionTrigger } from '@dxos/functions';
|
|
10
|
-
import { invariant } from '@dxos/invariant';
|
|
11
|
-
import { DXN, LOCAL_SPACE_TAG } from '@dxos/keys';
|
|
12
|
-
import { log } from '@dxos/log';
|
|
13
|
-
import { type Client, type Config } from '@dxos/react-client';
|
|
14
|
-
import { type Space } from '@dxos/react-client/echo';
|
|
15
|
-
|
|
16
|
-
const MAX_RETRIES = 3;
|
|
17
|
-
const RETRY_DELAY = 1_000;
|
|
18
|
-
|
|
19
|
-
const callFunction = async (funcUrl: string, trigger: any, data: any) => {
|
|
20
|
-
const body = { event: 'trigger', trigger, data };
|
|
21
|
-
|
|
22
|
-
let retryCount = 0;
|
|
23
|
-
while (retryCount < MAX_RETRIES) {
|
|
24
|
-
log.info('exec', { funcUrl, body, retryCount });
|
|
25
|
-
const response = await fetch(funcUrl, {
|
|
26
|
-
method: 'POST',
|
|
27
|
-
headers: {
|
|
28
|
-
'Content-Type': 'application/json',
|
|
29
|
-
},
|
|
30
|
-
body: JSON.stringify(body),
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
const data = await response.text();
|
|
34
|
-
log.info('response', { status: response.status, body: data });
|
|
35
|
-
if (response.status === 409) {
|
|
36
|
-
retryCount++;
|
|
37
|
-
await sleep(RETRY_DELAY * Math.min(retryCount, 2));
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return { status: response.status, data };
|
|
42
|
-
}
|
|
43
|
-
return { status: 500 };
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export const invokeFunction = async (client: Client, space: Space, trigger: FunctionTrigger, data: any) => {
|
|
47
|
-
try {
|
|
48
|
-
invariant(trigger.spec);
|
|
49
|
-
invariant(trigger.function);
|
|
50
|
-
|
|
51
|
-
const script = await space.db.query({ id: trigger.function }, { format: ResultFormat.Plain }).first();
|
|
52
|
-
const { objects: functions } = await space.db
|
|
53
|
-
.query({ __typename: FunctionType.typename }, { format: ResultFormat.Plain })
|
|
54
|
-
.run();
|
|
55
|
-
const func = functions.find((fn) => referenceEquals(fn.source, trigger.function!)) as AnyObjectData | undefined;
|
|
56
|
-
const funcSlug = func?.__meta.keys.find((key) => key.source === USERFUNCTIONS_META_KEY)?.id;
|
|
57
|
-
if (!funcSlug) {
|
|
58
|
-
log.warn('function not deployed', { scriptId: script.id, name: script.name });
|
|
59
|
-
return 404;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const funcUrl = getFunctionUrl(client.config, funcSlug, space.id);
|
|
63
|
-
const triggerData: AnyObjectData = {
|
|
64
|
-
...getObjectCore(trigger).toPlainObject(),
|
|
65
|
-
// TODO: Remove when functions can query by DXN.
|
|
66
|
-
promptId: trigger.meta?.prompt?.id,
|
|
67
|
-
};
|
|
68
|
-
// TODO: Remove when functions can add objects and easily modify collections (push, splice).
|
|
69
|
-
return (await callFunction(funcUrl, triggerData, data)).status;
|
|
70
|
-
} catch (err) {
|
|
71
|
-
return 400;
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const USERFUNCTIONS_META_KEY = 'dxos.org/service/function';
|
|
76
|
-
|
|
77
|
-
const getFunctionUrl = (config: Config, slug: string, spaceId?: string) => {
|
|
78
|
-
const baseUrl = new URL('functions/', config.values.runtime?.services?.edge?.url);
|
|
79
|
-
|
|
80
|
-
// Leading slashes cause the URL to be treated as an absolute path.
|
|
81
|
-
const relativeUrl = slug.replace(/^\//, '');
|
|
82
|
-
const url = new URL(`./${relativeUrl}`, baseUrl.toString());
|
|
83
|
-
spaceId && url.searchParams.set('spaceId', spaceId);
|
|
84
|
-
url.protocol = 'https';
|
|
85
|
-
return url.toString();
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
// TODO(dmaretskyi): Factor out.
|
|
89
|
-
|
|
90
|
-
type ReferenceLike = { '/': string } | string;
|
|
91
|
-
|
|
92
|
-
const referenceEquals = (a: ReferenceLike, b: ReferenceLike): boolean => {
|
|
93
|
-
const aDXN = toDXN(a);
|
|
94
|
-
const bDXN = toDXN(b);
|
|
95
|
-
return aDXN.toString() === bDXN.toString();
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const toDXN = (ref: ReferenceLike): DXN => {
|
|
99
|
-
if (typeof ref === 'string') {
|
|
100
|
-
if (ref.startsWith('dxn:')) {
|
|
101
|
-
return DXN.parse(ref);
|
|
102
|
-
} else {
|
|
103
|
-
return new DXN(DXN.kind.ECHO, [LOCAL_SPACE_TAG, ref]);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
invariant(typeof ref['/'] === 'string');
|
|
108
|
-
return DXN.parse(ref['/']);
|
|
109
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { describe, it } from 'vitest';
|
|
6
|
-
|
|
7
|
-
import { ChatProcessor } from './processor';
|
|
8
|
-
|
|
9
|
-
describe('ChatProcessor', () => {
|
|
10
|
-
it('should be instantiable', ({ expect }) => {
|
|
11
|
-
const client = {} as any; // TODO(burdon): Create mock.
|
|
12
|
-
const processor = new ChatProcessor(client);
|
|
13
|
-
expect(processor).toBeDefined();
|
|
14
|
-
});
|
|
15
|
-
});
|