@dxos/plugin-automation 0.7.5-main.b19bfc8 → 0.7.5-main.d9d2d4e
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-HZSTXZWK.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 +17 -199
- 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-V4L7LTWM.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/{TemplateContainer-3YCM6XPU.cjs → chunk-CB5OB6JH.cjs} +8 -21
- package/dist/lib/node/chunk-CB5OB6JH.cjs.map +7 -0
- package/dist/lib/node/{chunk-BAQRBGOJ.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 +32 -198
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{ChatContainer-4QTLL7TH.cjs → react-surface-2WRVAPGR.cjs} +20 -30
- 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-IG4GSWZN.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 +17 -199
- 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 -181
- 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.map +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.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 +0 -17
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -1
- 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 -127
- package/dist/types/src/translations.d.ts.map +1 -1
- package/package.json +21 -77
- package/src/AutomationPlugin.tsx +7 -86
- package/src/capabilities/complementary-panel.ts +56 -0
- package/src/capabilities/index.ts +1 -6
- package/src/capabilities/react-surface.tsx +3 -44
- 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 -9
- package/src/index.ts +0 -1
- 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 -47
- package/dist/lib/browser/AssistantDialog-V67OWLRP.mjs +0 -116
- package/dist/lib/browser/AssistantDialog-V67OWLRP.mjs.map +0 -7
- package/dist/lib/browser/AutomationPanel-NCKK3CFN.mjs +0 -8
- package/dist/lib/browser/AutomationPanel-NCKK3CFN.mjs.map +0 -7
- package/dist/lib/browser/ChatContainer-5BS6THNV.mjs +0 -33
- package/dist/lib/browser/ChatContainer-5BS6THNV.mjs.map +0 -7
- package/dist/lib/browser/TemplateContainer-HJJV44CE.mjs +0 -23
- package/dist/lib/browser/TemplateContainer-HJJV44CE.mjs.map +0 -7
- package/dist/lib/browser/ai-client-T2PBJISL.mjs +0 -22
- package/dist/lib/browser/ai-client-T2PBJISL.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-IR3CGVM6.mjs +0 -110
- package/dist/lib/browser/app-graph-builder-IR3CGVM6.mjs.map +0 -7
- package/dist/lib/browser/chunk-62E2AEXF.mjs +0 -162
- package/dist/lib/browser/chunk-62E2AEXF.mjs.map +0 -7
- package/dist/lib/browser/chunk-67KDIIM6.mjs +0 -15
- package/dist/lib/browser/chunk-67KDIIM6.mjs.map +0 -7
- package/dist/lib/browser/chunk-BQ4WHY4D.mjs +0 -1818
- package/dist/lib/browser/chunk-BQ4WHY4D.mjs.map +0 -7
- package/dist/lib/browser/chunk-HZSTXZWK.mjs.map +0 -7
- package/dist/lib/browser/chunk-LJ7F4KDM.mjs +0 -243
- package/dist/lib/browser/chunk-LJ7F4KDM.mjs.map +0 -7
- package/dist/lib/browser/chunk-QH5E22EL.mjs +0 -108
- package/dist/lib/browser/chunk-QH5E22EL.mjs.map +0 -7
- package/dist/lib/browser/chunk-XAIWETH6.mjs +0 -81
- package/dist/lib/browser/chunk-XAIWETH6.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-ICLE6FSI.mjs +0 -44
- package/dist/lib/browser/intent-resolver-ICLE6FSI.mjs.map +0 -7
- package/dist/lib/browser/react-surface-KEKVLCPQ.mjs +0 -80
- package/dist/lib/browser/react-surface-KEKVLCPQ.mjs.map +0 -7
- package/dist/lib/browser/settings-FE5DDWOE.mjs +0 -22
- package/dist/lib/browser/settings-FE5DDWOE.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/AssistantDialog-E62O72KI.cjs +0 -140
- package/dist/lib/node/AssistantDialog-E62O72KI.cjs.map +0 -7
- package/dist/lib/node/AutomationPanel-6COLKRIB.cjs +0 -26
- package/dist/lib/node/AutomationPanel-6COLKRIB.cjs.map +0 -7
- package/dist/lib/node/ChatContainer-4QTLL7TH.cjs.map +0 -7
- package/dist/lib/node/TemplateContainer-3YCM6XPU.cjs.map +0 -7
- package/dist/lib/node/ai-client-L5GUSAER.cjs +0 -38
- package/dist/lib/node/ai-client-L5GUSAER.cjs.map +0 -7
- package/dist/lib/node/app-graph-builder-ECNVGTRT.cjs +0 -122
- package/dist/lib/node/app-graph-builder-ECNVGTRT.cjs.map +0 -7
- package/dist/lib/node/chunk-3QSK6IPK.cjs +0 -133
- package/dist/lib/node/chunk-3QSK6IPK.cjs.map +0 -7
- package/dist/lib/node/chunk-76F5BCJE.cjs +0 -111
- package/dist/lib/node/chunk-76F5BCJE.cjs.map +0 -7
- package/dist/lib/node/chunk-B37JIAOP.cjs +0 -1795
- package/dist/lib/node/chunk-B37JIAOP.cjs.map +0 -7
- package/dist/lib/node/chunk-BAQRBGOJ.cjs.map +0 -7
- package/dist/lib/node/chunk-UVWK2XJE.cjs +0 -183
- package/dist/lib/node/chunk-UVWK2XJE.cjs.map +0 -7
- package/dist/lib/node/chunk-V4L7LTWM.cjs.map +0 -7
- package/dist/lib/node/chunk-VNBYGJ4K.cjs +0 -34
- package/dist/lib/node/chunk-VNBYGJ4K.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-4MQZULXW.cjs +0 -58
- package/dist/lib/node/intent-resolver-4MQZULXW.cjs.map +0 -7
- package/dist/lib/node/react-surface-4RVHY6WI.cjs +0 -95
- package/dist/lib/node/react-surface-4RVHY6WI.cjs.map +0 -7
- package/dist/lib/node/settings-GOIB2WJQ.cjs +0 -36
- package/dist/lib/node/settings-GOIB2WJQ.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/AssistantDialog-IPRBJKWA.mjs +0 -117
- package/dist/lib/node-esm/AssistantDialog-IPRBJKWA.mjs.map +0 -7
- package/dist/lib/node-esm/AutomationPanel-3MPIAO7R.mjs +0 -9
- package/dist/lib/node-esm/AutomationPanel-3MPIAO7R.mjs.map +0 -7
- package/dist/lib/node-esm/ChatContainer-4IWUGMGM.mjs +0 -34
- package/dist/lib/node-esm/ChatContainer-4IWUGMGM.mjs.map +0 -7
- package/dist/lib/node-esm/TemplateContainer-YJIXR24Z.mjs +0 -24
- package/dist/lib/node-esm/TemplateContainer-YJIXR24Z.mjs.map +0 -7
- package/dist/lib/node-esm/ai-client-45LZLW7V.mjs +0 -23
- package/dist/lib/node-esm/ai-client-45LZLW7V.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-HMRKSZ2X.mjs +0 -111
- package/dist/lib/node-esm/app-graph-builder-HMRKSZ2X.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-5BKKHYO5.mjs +0 -163
- package/dist/lib/node-esm/chunk-5BKKHYO5.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AWAU4BHR.mjs +0 -244
- package/dist/lib/node-esm/chunk-AWAU4BHR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CAWPHOY4.mjs +0 -82
- package/dist/lib/node-esm/chunk-CAWPHOY4.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-I32H7MCF.mjs +0 -109
- package/dist/lib/node-esm/chunk-I32H7MCF.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IG4GSWZN.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-QHKP5HT2.mjs +0 -1819
- package/dist/lib/node-esm/chunk-QHKP5HT2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-SS7U6GCX.mjs +0 -16
- package/dist/lib/node-esm/chunk-SS7U6GCX.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-ZS7XTYLG.mjs +0 -45
- package/dist/lib/node-esm/intent-resolver-ZS7XTYLG.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-5ILD642V.mjs +0 -81
- package/dist/lib/node-esm/react-surface-5ILD642V.mjs.map +0 -7
- package/dist/lib/node-esm/settings-ANNQPPRY.mjs +0 -23
- package/dist/lib/node-esm/settings-ANNQPPRY.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/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/capabilities/settings.d.ts +0 -4
- package/dist/types/src/capabilities/settings.d.ts.map +0 -1
- package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts +0 -7
- package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts.map +0 -1
- package/dist/types/src/components/AmbientDialog/AmbientDialog.stories.d.ts +0 -8
- package/dist/types/src/components/AmbientDialog/AmbientDialog.stories.d.ts.map +0 -1
- package/dist/types/src/components/AmbientDialog/index.d.ts +0 -2
- package/dist/types/src/components/AmbientDialog/index.d.ts.map +0 -1
- package/dist/types/src/components/AssistantDialog.d.ts +0 -7
- package/dist/types/src/components/AssistantDialog.d.ts.map +0 -1
- package/dist/types/src/components/AutomationSettings/AutomationSettings.d.ts +0 -5
- package/dist/types/src/components/AutomationSettings/AutomationSettings.d.ts.map +0 -1
- package/dist/types/src/components/AutomationSettings/index.d.ts +0 -2
- package/dist/types/src/components/AutomationSettings/index.d.ts.map +0 -1
- package/dist/types/src/components/ChatContainer.d.ts +0 -7
- package/dist/types/src/components/ChatContainer.d.ts.map +0 -1
- package/dist/types/src/components/Prompt/Prompt.d.ts +0 -17
- package/dist/types/src/components/Prompt/Prompt.d.ts.map +0 -1
- package/dist/types/src/components/Prompt/Prompt.stories.d.ts +0 -9
- package/dist/types/src/components/Prompt/Prompt.stories.d.ts.map +0 -1
- package/dist/types/src/components/Prompt/PromptBar.d.ts +0 -10
- package/dist/types/src/components/Prompt/PromptBar.d.ts.map +0 -1
- package/dist/types/src/components/Prompt/autocomplete.d.ts +0 -21
- package/dist/types/src/components/Prompt/autocomplete.d.ts.map +0 -1
- package/dist/types/src/components/Prompt/index.d.ts +0 -3
- package/dist/types/src/components/Prompt/index.d.ts.map +0 -1
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts +0 -5
- 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/TemplateContainer.d.ts +0 -7
- package/dist/types/src/components/TemplateContainer.d.ts.map +0 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +0 -12
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +0 -1
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +0 -8
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +0 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +0 -10
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +0 -1
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +0 -8
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +0 -1
- package/dist/types/src/components/TemplateEditor/index.d.ts +0 -2
- package/dist/types/src/components/TemplateEditor/index.d.ts.map +0 -1
- package/dist/types/src/components/TemplateEditor/types.d.ts +0 -18
- package/dist/types/src/components/TemplateEditor/types.d.ts.map +0 -1
- package/dist/types/src/components/Thread/Thread.d.ts +0 -17
- 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/ThreadContainer.d.ts +0 -10
- package/dist/types/src/components/Thread/ThreadContainer.d.ts.map +0 -1
- package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts +0 -15
- package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts.map +0 -1
- package/dist/types/src/components/Thread/ThreadMessage.d.ts +0 -13
- package/dist/types/src/components/Thread/ThreadMessage.d.ts.map +0 -1
- package/dist/types/src/components/Thread/ToolInvocations.d.ts +0 -13
- package/dist/types/src/components/Thread/ToolInvocations.d.ts.map +0 -1
- package/dist/types/src/components/Thread/index.d.ts +0 -3
- package/dist/types/src/components/Thread/index.d.ts.map +0 -1
- package/dist/types/src/components/Thread/reducer.d.ts +0 -12
- package/dist/types/src/components/Thread/reducer.d.ts.map +0 -1
- package/dist/types/src/components/Toolbox/Toolbox.d.ts +0 -19
- package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +0 -1
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +0 -8
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +0 -1
- package/dist/types/src/components/Toolbox/index.d.ts +0 -2
- package/dist/types/src/components/Toolbox/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 -7
- 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 -75
- 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 -8
- 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/hooks/useTextInputEvents.d.ts +0 -13
- package/dist/types/src/hooks/useTextInputEvents.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/chat.d.ts +0 -12
- package/dist/types/src/types/chat.d.ts.map +0 -1
- package/dist/types/src/types/index.d.ts +0 -5
- package/dist/types/src/types/index.d.ts.map +0 -1
- package/dist/types/src/types/service.d.ts +0 -160
- package/dist/types/src/types/service.d.ts.map +0 -1
- package/dist/types/src/types/template.d.ts +0 -40
- package/dist/types/src/types/template.d.ts.map +0 -1
- package/dist/types/src/types/types.d.ts +0 -37
- package/dist/types/src/types/types.d.ts.map +0 -1
- package/src/capabilities/ai-client.ts +0 -19
- package/src/capabilities/app-graph-builder.ts +0 -99
- package/src/capabilities/capabilities.ts +0 -12
- package/src/capabilities/intent-resolver.ts +0 -38
- package/src/capabilities/settings.ts +0 -19
- package/src/components/AmbientDialog/AmbientDialog.stories.tsx +0 -81
- package/src/components/AmbientDialog/AmbientDialog.tsx +0 -103
- package/src/components/AmbientDialog/index.ts +0 -5
- package/src/components/AssistantDialog.tsx +0 -33
- package/src/components/AutomationSettings/AutomationSettings.tsx +0 -49
- package/src/components/AutomationSettings/index.ts +0 -5
- package/src/components/ChatContainer.tsx +0 -29
- package/src/components/Prompt/Prompt.stories.tsx +0 -79
- package/src/components/Prompt/Prompt.tsx +0 -100
- package/src/components/Prompt/PromptBar.tsx +0 -100
- package/src/components/Prompt/autocomplete.ts +0 -212
- package/src/components/Prompt/index.ts +0 -6
- package/src/components/ServiceRegistry/ServiceRegistry.stories.tsx +0 -49
- package/src/components/ServiceRegistry/ServiceRegistry.tsx +0 -76
- package/src/components/ServiceRegistry/index.ts +0 -5
- package/src/components/TemplateContainer.tsx +0 -21
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +0 -72
- package/src/components/TemplateEditor/TemplateEditor.tsx +0 -76
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +0 -65
- package/src/components/TemplateEditor/TemplateForm.tsx +0 -184
- package/src/components/TemplateEditor/index.ts +0 -5
- package/src/components/TemplateEditor/types.tsx +0 -28
- package/src/components/Thread/Thread.stories.tsx +0 -212
- package/src/components/Thread/Thread.tsx +0 -97
- package/src/components/Thread/ThreadContainer.stories.tsx +0 -258
- package/src/components/Thread/ThreadContainer.tsx +0 -78
- package/src/components/Thread/ThreadMessage.tsx +0 -187
- package/src/components/Thread/ToolInvocations.tsx +0 -93
- package/src/components/Thread/index.ts +0 -6
- package/src/components/Thread/reducer.ts +0 -52
- package/src/components/Toolbox/Toolbox.stories.tsx +0 -65
- package/src/components/Toolbox/Toolbox.tsx +0 -117
- package/src/components/Toolbox/index.ts +0 -5
- package/src/hooks/email.ts +0 -49
- package/src/hooks/index.ts +0 -11
- package/src/hooks/invocation-handler.ts +0 -109
- package/src/hooks/processor.test.ts +0 -15
- package/src/hooks/processor.ts +0 -219
- package/src/hooks/useChatProcessor.tsx +0 -77
- package/src/hooks/useLocalTriggerManager.ts +0 -82
- package/src/hooks/useMessageQueue.ts +0 -23
- package/src/hooks/useServices.ts +0 -28
- package/src/hooks/useTextInputEvents.ts +0 -49
- 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 -224
- package/src/tools/openapi.ts +0 -331
- package/src/types/chat.ts +0 -11
- package/src/types/index.ts +0 -8
- package/src/types/service.ts +0 -102
- package/src/types/template.ts +0 -34
- package/src/types/types.ts +0 -41
- package/src/typings.d.ts +0 -9
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
|
-
import { type Meta } from '@storybook/react';
|
|
8
|
-
import React from 'react';
|
|
9
|
-
|
|
10
|
-
import { IntentPlugin, Capabilities, useCapabilities, SettingsPlugin } from '@dxos/app-framework';
|
|
11
|
-
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
12
|
-
import { capabilities } from '@dxos/artifact-testing';
|
|
13
|
-
import { ChessPlugin } from '@dxos/plugin-chess';
|
|
14
|
-
import { ClientPlugin } from '@dxos/plugin-client';
|
|
15
|
-
import { MapPlugin } from '@dxos/plugin-map';
|
|
16
|
-
import { SpacePlugin } from '@dxos/plugin-space';
|
|
17
|
-
import { TablePlugin } from '@dxos/plugin-table';
|
|
18
|
-
import { withLayout, withSignals, withTheme } from '@dxos/storybook-utils';
|
|
19
|
-
|
|
20
|
-
import { Toolbox } from './Toolbox';
|
|
21
|
-
|
|
22
|
-
const Render = () => {
|
|
23
|
-
const artifactDefinitions = useCapabilities(Capabilities.ArtifactDefinition);
|
|
24
|
-
return (
|
|
25
|
-
<Toolbox artifacts={artifactDefinitions} classNames='w-[30rem] h-[15rem] rounded-md border border-separator' />
|
|
26
|
-
);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const meta: Meta<typeof Toolbox> = {
|
|
30
|
-
title: 'plugins/plugin-automation/Toolbox',
|
|
31
|
-
component: Toolbox,
|
|
32
|
-
render: Render,
|
|
33
|
-
decorators: [
|
|
34
|
-
withSignals,
|
|
35
|
-
withPluginManager({
|
|
36
|
-
plugins: [
|
|
37
|
-
ClientPlugin({
|
|
38
|
-
onClientInitialized: async (_, client) => {
|
|
39
|
-
await client.halo.createIdentity();
|
|
40
|
-
},
|
|
41
|
-
}),
|
|
42
|
-
SpacePlugin({ observability: false }),
|
|
43
|
-
SettingsPlugin(),
|
|
44
|
-
IntentPlugin(),
|
|
45
|
-
ChessPlugin(),
|
|
46
|
-
MapPlugin(),
|
|
47
|
-
TablePlugin(),
|
|
48
|
-
],
|
|
49
|
-
capabilities,
|
|
50
|
-
}),
|
|
51
|
-
withTheme,
|
|
52
|
-
withLayout({ tooltips: true }),
|
|
53
|
-
],
|
|
54
|
-
parameters: {
|
|
55
|
-
layout: 'centered',
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export default meta;
|
|
60
|
-
|
|
61
|
-
type Story = Meta<typeof Toolbox>;
|
|
62
|
-
|
|
63
|
-
export const Default: Story = {
|
|
64
|
-
args: {},
|
|
65
|
-
};
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { useState, useEffect, Fragment } from 'react';
|
|
6
|
-
|
|
7
|
-
import { Capabilities, useCapabilities } from '@dxos/app-framework';
|
|
8
|
-
import { type ArtifactDefinition, type Tool } from '@dxos/artifact';
|
|
9
|
-
import { FunctionType } from '@dxos/functions';
|
|
10
|
-
import { log } from '@dxos/log';
|
|
11
|
-
import { Filter, type Space, useQuery } from '@dxos/react-client/echo';
|
|
12
|
-
import { type ThemedClassName } from '@dxos/react-ui';
|
|
13
|
-
import { mx } from '@dxos/react-ui-theme';
|
|
14
|
-
|
|
15
|
-
import { createToolsFromService } from '../../tools';
|
|
16
|
-
import { ServiceType } from '../../types';
|
|
17
|
-
|
|
18
|
-
export type ToolboxProps = ThemedClassName<{
|
|
19
|
-
artifacts?: ArtifactDefinition[];
|
|
20
|
-
functions?: FunctionType[];
|
|
21
|
-
services?: { service: ServiceType; tools: Tool[] }[];
|
|
22
|
-
striped?: boolean;
|
|
23
|
-
}>;
|
|
24
|
-
|
|
25
|
-
const stripeClassNames = 'odd:bg-neutral-50 dark:odd:bg-neutral-800';
|
|
26
|
-
|
|
27
|
-
export const Toolbox = ({ classNames, artifacts, functions, services, striped }: ToolboxProps) => {
|
|
28
|
-
const gridClassNames = 'grid grid-cols-[8rem_8rem_1fr]';
|
|
29
|
-
const subGridClassNames = mx('col-span-full grid grid-cols-subgrid text-xs px-2', striped && stripeClassNames);
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<div className={mx('flex flex-col overflow-y-auto box-content', classNames)}>
|
|
33
|
-
{artifacts && artifacts.length > 0 && (
|
|
34
|
-
<div>
|
|
35
|
-
<h1 className='px-2 text-sm'>Artifacts</h1>
|
|
36
|
-
<div className={gridClassNames}>
|
|
37
|
-
{artifacts.map(({ id, description, tools }) => (
|
|
38
|
-
<Fragment key={id}>
|
|
39
|
-
<div className={subGridClassNames}>
|
|
40
|
-
<div className='text-primary-500 truncate'>{id}</div>
|
|
41
|
-
<div className='col-span-2 line-clamp-2'>{description}</div>
|
|
42
|
-
</div>
|
|
43
|
-
{tools.map(({ name, description }, i) => (
|
|
44
|
-
<div key={`${name}-${i}`} className={subGridClassNames}>
|
|
45
|
-
<div />
|
|
46
|
-
<div className='truncate'>{name}</div>
|
|
47
|
-
<div className='text-subdued line-clamp-3'>{description}</div>
|
|
48
|
-
</div>
|
|
49
|
-
))}
|
|
50
|
-
</Fragment>
|
|
51
|
-
))}
|
|
52
|
-
</div>
|
|
53
|
-
</div>
|
|
54
|
-
)}
|
|
55
|
-
|
|
56
|
-
{services && services.length > 0 && (
|
|
57
|
-
<div>
|
|
58
|
-
<h1 className='px-2 text-sm'>Services</h1>
|
|
59
|
-
<div className={gridClassNames}>
|
|
60
|
-
{services.map(({ service, tools }) => (
|
|
61
|
-
<Fragment key={service.serviceId}>
|
|
62
|
-
<div className={subGridClassNames}>
|
|
63
|
-
<div className='text-primary-500 truncate'>{service.name ?? service.serviceId}</div>
|
|
64
|
-
<div className='col-span-2 line-clamp-2'>{service.description}</div>
|
|
65
|
-
</div>
|
|
66
|
-
{tools.map(({ name, description }, i) => (
|
|
67
|
-
<div key={name} className={mx(subGridClassNames, striped && stripeClassNames)}>
|
|
68
|
-
<div className='text-primary-500 truncate'>{i === 0 && service.serviceId}</div>
|
|
69
|
-
<div className='truncate'>{name}</div>
|
|
70
|
-
<div className='truncate'>{description}</div>
|
|
71
|
-
</div>
|
|
72
|
-
))}
|
|
73
|
-
</Fragment>
|
|
74
|
-
))}
|
|
75
|
-
</div>
|
|
76
|
-
</div>
|
|
77
|
-
)}
|
|
78
|
-
|
|
79
|
-
{functions && functions.length > 0 && (
|
|
80
|
-
<div>
|
|
81
|
-
<h1 className='px-2 text-sm'>Functions</h1>
|
|
82
|
-
<div className={gridClassNames}>
|
|
83
|
-
{functions.map(({ name, description }) => (
|
|
84
|
-
<div key={name} className={mx(subGridClassNames, striped && stripeClassNames)}>
|
|
85
|
-
<div className='text-primary-500 truncate'>function</div>
|
|
86
|
-
<div className='truncate'>{name}</div>
|
|
87
|
-
<div className='truncate'>{description}</div>
|
|
88
|
-
</div>
|
|
89
|
-
))}
|
|
90
|
-
</div>
|
|
91
|
-
</div>
|
|
92
|
-
)}
|
|
93
|
-
</div>
|
|
94
|
-
);
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
export const ToolboxContainer = ({ classNames, space }: ThemedClassName<{ space?: Space }>) => {
|
|
98
|
-
const artifactDefinitions = useCapabilities(Capabilities.ArtifactDefinition);
|
|
99
|
-
const functions = useQuery(space, Filter.schema(FunctionType));
|
|
100
|
-
const services = useQuery(space, Filter.schema(ServiceType));
|
|
101
|
-
|
|
102
|
-
const [serviceTools, setServiceTools] = useState<{ service: ServiceType; tools: Tool[] }[]>([]);
|
|
103
|
-
useEffect(() => {
|
|
104
|
-
log('creating service tools...');
|
|
105
|
-
queueMicrotask(async () => {
|
|
106
|
-
const tools = await Promise.all(
|
|
107
|
-
services.map(async (service) => ({ service, tools: await createToolsFromService(service) })),
|
|
108
|
-
);
|
|
109
|
-
|
|
110
|
-
setServiceTools(tools);
|
|
111
|
-
});
|
|
112
|
-
}, [services]);
|
|
113
|
-
|
|
114
|
-
return (
|
|
115
|
-
<Toolbox classNames={classNames} artifacts={artifactDefinitions} functions={functions} services={serviceTools} />
|
|
116
|
-
);
|
|
117
|
-
};
|
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,11 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
export * from './processor';
|
|
6
|
-
|
|
7
|
-
export * from './useChatProcessor';
|
|
8
|
-
export * from './useLocalTriggerManager';
|
|
9
|
-
export * from './useMessageQueue';
|
|
10
|
-
export * from './useServices';
|
|
11
|
-
export * from './useTextInputEvents';
|
|
@@ -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
|
-
});
|
package/src/hooks/processor.ts
DELETED
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { type Signal, batch, computed, signal } from '@preact/signals-core';
|
|
6
|
-
|
|
7
|
-
import { type PromiseIntentDispatcher } from '@dxos/app-framework';
|
|
8
|
-
import { type Tool, Message, type MessageContentBlock } from '@dxos/artifact';
|
|
9
|
-
import {
|
|
10
|
-
isToolUse,
|
|
11
|
-
runTools,
|
|
12
|
-
type AIServiceClientImpl,
|
|
13
|
-
type GenerateRequest,
|
|
14
|
-
type GenerationStream,
|
|
15
|
-
MixedStreamParser,
|
|
16
|
-
DEFAULT_LLM_MODEL,
|
|
17
|
-
} from '@dxos/assistant';
|
|
18
|
-
import { createStatic } from '@dxos/echo-schema';
|
|
19
|
-
import { invariant } from '@dxos/invariant';
|
|
20
|
-
import { log } from '@dxos/log';
|
|
21
|
-
import { type Space } from '@dxos/react-client/echo';
|
|
22
|
-
|
|
23
|
-
// TODO(burdon): Factor out.
|
|
24
|
-
declare global {
|
|
25
|
-
interface ToolContextExtensions {
|
|
26
|
-
space?: Space;
|
|
27
|
-
dispatch?: PromiseIntentDispatcher;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
type RequestOptions = {
|
|
32
|
-
history?: Message[];
|
|
33
|
-
onComplete?: (messages: Message[]) => void;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export type ChatProcessorOptions = Pick<GenerateRequest, 'model' | 'systemPrompt'>;
|
|
37
|
-
|
|
38
|
-
const defaultOptions: ChatProcessorOptions = {
|
|
39
|
-
model: DEFAULT_LLM_MODEL,
|
|
40
|
-
systemPrompt: 'you are a helpful assistant',
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Handles interactions with the AI service.
|
|
45
|
-
* Maintains a queue of messages and handles streaming responses from the AI service.
|
|
46
|
-
* Executes tools based on AI responses.
|
|
47
|
-
* Supports cancellation of in-progress requests.
|
|
48
|
-
*/
|
|
49
|
-
export class ChatProcessor {
|
|
50
|
-
/** SSE stream parser. */
|
|
51
|
-
private readonly _parser = new MixedStreamParser();
|
|
52
|
-
|
|
53
|
-
/** Current streaming response (iterator). */
|
|
54
|
-
private _stream: GenerationStream | undefined;
|
|
55
|
-
|
|
56
|
-
/** Pending messages (incl. the user request). */
|
|
57
|
-
private readonly _pending: Signal<Message[]> = signal([]);
|
|
58
|
-
|
|
59
|
-
/** Current streaming block (from the AI service). */
|
|
60
|
-
private readonly _block: Signal<MessageContentBlock | undefined> = signal(undefined);
|
|
61
|
-
|
|
62
|
-
/** Prior history from queue. */
|
|
63
|
-
private _history: Message[] = [];
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Streaming state.
|
|
67
|
-
* @reactive
|
|
68
|
-
*/
|
|
69
|
-
public readonly streaming: Signal<boolean> = computed(() => this._block.value !== undefined);
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Last error.
|
|
73
|
-
* @reactive
|
|
74
|
-
*/
|
|
75
|
-
public readonly error: Signal<Error | undefined> = signal(undefined);
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Array of Messages (incl. the current message being streamed).
|
|
79
|
-
* @reactive
|
|
80
|
-
*/
|
|
81
|
-
public readonly messages: Signal<Message[]> = computed(() => {
|
|
82
|
-
const messages = [...this._pending.value];
|
|
83
|
-
if (this._block.value) {
|
|
84
|
-
const current = messages.pop();
|
|
85
|
-
invariant(current);
|
|
86
|
-
const { content, ...rest } = current;
|
|
87
|
-
const message = { ...rest, content: [...content, this._block.value] };
|
|
88
|
-
messages.push(message);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return messages;
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
constructor(
|
|
95
|
-
private readonly _client: AIServiceClientImpl,
|
|
96
|
-
private _tools?: Tool[],
|
|
97
|
-
private readonly _extensions?: ToolContextExtensions,
|
|
98
|
-
private readonly _options: ChatProcessorOptions = defaultOptions,
|
|
99
|
-
) {
|
|
100
|
-
// Message complete.
|
|
101
|
-
this._parser.message.on((message) => {
|
|
102
|
-
batch(() => {
|
|
103
|
-
this._pending.value = [...this._pending.value, message];
|
|
104
|
-
this._block.value = undefined;
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
// Streaming update (happens before message complete).
|
|
109
|
-
this._parser.update.on((block) => {
|
|
110
|
-
batch(() => {
|
|
111
|
-
this._block.value = block;
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Update tools.
|
|
118
|
-
*/
|
|
119
|
-
setTools(tools: Tool[]) {
|
|
120
|
-
this._tools = tools;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Make GPT request.
|
|
125
|
-
*/
|
|
126
|
-
async request(message: string, options: RequestOptions = {}): Promise<Message[]> {
|
|
127
|
-
batch(() => {
|
|
128
|
-
this._history = options.history ?? [];
|
|
129
|
-
this._pending.value = [
|
|
130
|
-
createStatic(Message, {
|
|
131
|
-
role: 'user',
|
|
132
|
-
content: [{ type: 'text', text: message }],
|
|
133
|
-
}),
|
|
134
|
-
];
|
|
135
|
-
this._block.value = undefined;
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
await this._generate();
|
|
139
|
-
options.onComplete?.(this._pending.value);
|
|
140
|
-
return this._reset();
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Cancel pending requests.
|
|
145
|
-
* @returns Pending requests (incl. the request message).
|
|
146
|
-
*/
|
|
147
|
-
async cancel(): Promise<Message[]> {
|
|
148
|
-
log.info('cancelling...');
|
|
149
|
-
this._stream?.abort();
|
|
150
|
-
return this._reset();
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
private async _reset(): Promise<Message[]> {
|
|
154
|
-
const messages = this._pending.value;
|
|
155
|
-
batch(() => {
|
|
156
|
-
this._history = [];
|
|
157
|
-
this._pending.value = [];
|
|
158
|
-
this._block.value = undefined;
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
return messages;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
* Generate a response from the AI service.
|
|
166
|
-
* Iterates over tool requests.
|
|
167
|
-
*/
|
|
168
|
-
private async _generate() {
|
|
169
|
-
try {
|
|
170
|
-
let more = false;
|
|
171
|
-
do {
|
|
172
|
-
log.info('requesting', { history: this._history.length, messages: this._pending.value.length });
|
|
173
|
-
this._stream = await this._client.generate({
|
|
174
|
-
...this._options,
|
|
175
|
-
// TODO(burdon): Rename messages or separate history/message.
|
|
176
|
-
history: [...this._history, ...this._pending.value],
|
|
177
|
-
tools: this._tools,
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
// Wait until complete.
|
|
181
|
-
await this._parser.parse(this._stream);
|
|
182
|
-
await this._stream.complete();
|
|
183
|
-
|
|
184
|
-
// Add messages.
|
|
185
|
-
log.info('response', { messages: this._pending.value });
|
|
186
|
-
|
|
187
|
-
// Resolve tool use locally.
|
|
188
|
-
more = false;
|
|
189
|
-
const message = this._pending.value.at(-1);
|
|
190
|
-
invariant(message);
|
|
191
|
-
if (isToolUse(message)) {
|
|
192
|
-
log.info('tool request...');
|
|
193
|
-
const response = await runTools({
|
|
194
|
-
message: this._pending.value.at(-1)!,
|
|
195
|
-
tools: this._tools ?? [],
|
|
196
|
-
extensions: this._extensions,
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
log.info('tool response', { response });
|
|
200
|
-
switch (response.type) {
|
|
201
|
-
case 'continue': {
|
|
202
|
-
this._pending.value = [...this._pending.value, response.message];
|
|
203
|
-
more = true;
|
|
204
|
-
break;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
} while (more);
|
|
209
|
-
|
|
210
|
-
log.info('done');
|
|
211
|
-
} catch (err) {
|
|
212
|
-
log.catch(err);
|
|
213
|
-
this.error.value = new Error('AI service error', { cause: err });
|
|
214
|
-
} finally {
|
|
215
|
-
this._stream = undefined;
|
|
216
|
-
this.error.value = undefined;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { useEffect, useMemo, useState } from 'react';
|
|
6
|
-
|
|
7
|
-
import { Capabilities, useCapabilities, useCapability, useIntentDispatcher } from '@dxos/app-framework';
|
|
8
|
-
import { createSystemPrompt, type Tool } from '@dxos/artifact';
|
|
9
|
-
import { DEFAULT_LLM_MODEL } from '@dxos/assistant';
|
|
10
|
-
import { FunctionType } from '@dxos/functions';
|
|
11
|
-
import { log } from '@dxos/log';
|
|
12
|
-
import { useConfig } from '@dxos/react-client';
|
|
13
|
-
import { Filter, type Space, useQuery } from '@dxos/react-client/echo';
|
|
14
|
-
import { isNonNullable } from '@dxos/util';
|
|
15
|
-
|
|
16
|
-
import { AutomationCapabilities } from '../capabilities';
|
|
17
|
-
import { ChatProcessor } from '../hooks';
|
|
18
|
-
import { covertFunctionToTool, createToolsFromService } from '../tools';
|
|
19
|
-
import { type AutomationSettingsProps, ServiceType } from '../types';
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Configure and create ChatProcessor.
|
|
23
|
-
*/
|
|
24
|
-
export const useChatProcessor = (space?: Space, settings?: AutomationSettingsProps): ChatProcessor => {
|
|
25
|
-
const aiClient = useCapability(AutomationCapabilities.AiClient);
|
|
26
|
-
const globalTools = useCapabilities(Capabilities.Tools);
|
|
27
|
-
const artifactDefinitions = useCapabilities(Capabilities.ArtifactDefinition);
|
|
28
|
-
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
29
|
-
|
|
30
|
-
// Services.
|
|
31
|
-
const services = useQuery(space, Filter.schema(ServiceType));
|
|
32
|
-
const [serviceTools, setServiceTools] = useState<Tool[]>([]);
|
|
33
|
-
useEffect(() => {
|
|
34
|
-
log('creating service tools...');
|
|
35
|
-
queueMicrotask(async () => {
|
|
36
|
-
const tools = await Promise.all(services.map((service) => createToolsFromService(service)));
|
|
37
|
-
setServiceTools(tools.flat());
|
|
38
|
-
});
|
|
39
|
-
}, [services]);
|
|
40
|
-
|
|
41
|
-
// Tools and context.
|
|
42
|
-
const config = useConfig();
|
|
43
|
-
const functions = useQuery(space, Filter.schema(FunctionType));
|
|
44
|
-
const [tools, extensions] = useMemo(() => {
|
|
45
|
-
log('creating tools...');
|
|
46
|
-
const tools = [
|
|
47
|
-
...globalTools.flat(),
|
|
48
|
-
...artifactDefinitions.flatMap((definition) => definition.tools),
|
|
49
|
-
...serviceTools,
|
|
50
|
-
...functions
|
|
51
|
-
.map((fn) => covertFunctionToTool(fn, config.values.runtime?.services?.edge?.url ?? '', space?.id))
|
|
52
|
-
.filter(isNonNullable),
|
|
53
|
-
];
|
|
54
|
-
const extensions = { space, dispatch };
|
|
55
|
-
return [tools, extensions];
|
|
56
|
-
}, [dispatch, globalTools, artifactDefinitions, space, serviceTools, functions]);
|
|
57
|
-
|
|
58
|
-
// Prompt.
|
|
59
|
-
const systemPrompt = useMemo(
|
|
60
|
-
() => createSystemPrompt({ artifacts: artifactDefinitions.map((definition) => definition.instructions) }),
|
|
61
|
-
[artifactDefinitions],
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
// Create processor.
|
|
65
|
-
// TODO(burdon): Updated on each query update above. Should just update current processor.
|
|
66
|
-
const processor = useMemo(() => {
|
|
67
|
-
log('creating processor...', { settings });
|
|
68
|
-
return new ChatProcessor(aiClient, tools, extensions, {
|
|
69
|
-
// TODO(burdon): Remove defualt (let backend decide if not specified).
|
|
70
|
-
model: settings?.llmModel ?? DEFAULT_LLM_MODEL,
|
|
71
|
-
// TOOD(burdon): Query.
|
|
72
|
-
systemPrompt,
|
|
73
|
-
});
|
|
74
|
-
}, [aiClient, tools, extensions, systemPrompt, settings?.llmModel]);
|
|
75
|
-
|
|
76
|
-
return processor;
|
|
77
|
-
};
|