@dxos/plugin-automation 0.7.5-main.9d26e3a → 0.7.5-main.b19bfc8
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/AssistantDialog-V67OWLRP.mjs +116 -0
- package/dist/lib/browser/AssistantDialog-V67OWLRP.mjs.map +7 -0
- package/dist/lib/browser/AutomationPanel-NCKK3CFN.mjs +8 -0
- package/dist/lib/browser/ChatContainer-5BS6THNV.mjs +33 -0
- package/dist/lib/browser/ChatContainer-5BS6THNV.mjs.map +7 -0
- package/dist/lib/browser/TemplateContainer-HJJV44CE.mjs +23 -0
- package/dist/lib/browser/TemplateContainer-HJJV44CE.mjs.map +7 -0
- package/dist/lib/browser/ai-client-T2PBJISL.mjs +22 -0
- package/dist/lib/browser/ai-client-T2PBJISL.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-IR3CGVM6.mjs +110 -0
- package/dist/lib/browser/app-graph-builder-IR3CGVM6.mjs.map +7 -0
- package/dist/lib/browser/chunk-62E2AEXF.mjs +162 -0
- package/dist/lib/browser/chunk-62E2AEXF.mjs.map +7 -0
- package/dist/lib/browser/chunk-67KDIIM6.mjs +15 -0
- package/dist/lib/browser/chunk-67KDIIM6.mjs.map +7 -0
- package/dist/lib/browser/chunk-BQ4WHY4D.mjs +1818 -0
- package/dist/lib/browser/chunk-BQ4WHY4D.mjs.map +7 -0
- package/dist/lib/browser/{chunk-X5KMOH3I.mjs → chunk-HZSTXZWK.mjs} +6 -4
- package/dist/lib/browser/chunk-HZSTXZWK.mjs.map +7 -0
- package/dist/lib/browser/chunk-LJ7F4KDM.mjs +243 -0
- package/dist/lib/browser/chunk-LJ7F4KDM.mjs.map +7 -0
- package/dist/lib/browser/chunk-QH5E22EL.mjs +108 -0
- package/dist/lib/browser/chunk-QH5E22EL.mjs.map +7 -0
- package/dist/lib/browser/chunk-XAIWETH6.mjs +81 -0
- package/dist/lib/browser/chunk-XAIWETH6.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +210 -467
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-resolver-ICLE6FSI.mjs +44 -0
- package/dist/lib/browser/intent-resolver-ICLE6FSI.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-KEKVLCPQ.mjs +80 -0
- package/dist/lib/browser/react-surface-KEKVLCPQ.mjs.map +7 -0
- package/dist/lib/browser/settings-FE5DDWOE.mjs +22 -0
- package/dist/lib/browser/settings-FE5DDWOE.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +18 -9
- package/dist/lib/node/AssistantDialog-E62O72KI.cjs +140 -0
- package/dist/lib/node/AssistantDialog-E62O72KI.cjs.map +7 -0
- package/dist/lib/node/{meta.cjs → AutomationPanel-6COLKRIB.cjs} +7 -11
- package/dist/lib/node/AutomationPanel-6COLKRIB.cjs.map +7 -0
- package/dist/lib/node/ChatContainer-4QTLL7TH.cjs +61 -0
- package/dist/lib/node/ChatContainer-4QTLL7TH.cjs.map +7 -0
- package/dist/lib/node/TemplateContainer-3YCM6XPU.cjs +53 -0
- package/dist/lib/node/TemplateContainer-3YCM6XPU.cjs.map +7 -0
- package/dist/lib/node/ai-client-L5GUSAER.cjs +38 -0
- package/dist/lib/node/ai-client-L5GUSAER.cjs.map +7 -0
- package/dist/lib/node/app-graph-builder-ECNVGTRT.cjs +122 -0
- package/dist/lib/node/app-graph-builder-ECNVGTRT.cjs.map +7 -0
- package/dist/lib/node/chunk-3QSK6IPK.cjs +133 -0
- package/dist/lib/node/chunk-3QSK6IPK.cjs.map +7 -0
- package/dist/lib/node/chunk-76F5BCJE.cjs +111 -0
- package/dist/lib/node/chunk-76F5BCJE.cjs.map +7 -0
- package/dist/lib/node/chunk-B37JIAOP.cjs +1795 -0
- package/dist/lib/node/chunk-B37JIAOP.cjs.map +7 -0
- package/dist/lib/node/{chunk-DTJ7XVO2.cjs → chunk-BAQRBGOJ.cjs} +11 -8
- package/dist/lib/node/chunk-BAQRBGOJ.cjs.map +7 -0
- package/dist/lib/node/chunk-UVWK2XJE.cjs +183 -0
- package/dist/lib/node/chunk-UVWK2XJE.cjs.map +7 -0
- package/dist/lib/node/chunk-V4L7LTWM.cjs +267 -0
- package/dist/lib/node/chunk-V4L7LTWM.cjs.map +7 -0
- package/dist/lib/node/chunk-VNBYGJ4K.cjs +34 -0
- package/dist/lib/node/chunk-VNBYGJ4K.cjs.map +7 -0
- package/dist/lib/node/index.cjs +201 -473
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/intent-resolver-4MQZULXW.cjs +58 -0
- package/dist/lib/node/intent-resolver-4MQZULXW.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/react-surface-4RVHY6WI.cjs +95 -0
- package/dist/lib/node/react-surface-4RVHY6WI.cjs.map +7 -0
- package/dist/lib/node/settings-GOIB2WJQ.cjs +36 -0
- package/dist/lib/node/settings-GOIB2WJQ.cjs.map +7 -0
- package/dist/lib/node/types/index.cjs +19 -10
- package/dist/lib/node/types/index.cjs.map +2 -2
- package/dist/lib/node-esm/AssistantDialog-IPRBJKWA.mjs +117 -0
- package/dist/lib/node-esm/AssistantDialog-IPRBJKWA.mjs.map +7 -0
- package/dist/lib/node-esm/AutomationPanel-3MPIAO7R.mjs +9 -0
- package/dist/lib/node-esm/ChatContainer-4IWUGMGM.mjs +34 -0
- package/dist/lib/node-esm/ChatContainer-4IWUGMGM.mjs.map +7 -0
- package/dist/lib/node-esm/TemplateContainer-YJIXR24Z.mjs +24 -0
- package/dist/lib/node-esm/TemplateContainer-YJIXR24Z.mjs.map +7 -0
- package/dist/lib/node-esm/ai-client-45LZLW7V.mjs +23 -0
- package/dist/lib/node-esm/ai-client-45LZLW7V.mjs.map +7 -0
- package/dist/lib/node-esm/app-graph-builder-HMRKSZ2X.mjs +111 -0
- package/dist/lib/node-esm/app-graph-builder-HMRKSZ2X.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-5BKKHYO5.mjs +163 -0
- package/dist/lib/node-esm/chunk-5BKKHYO5.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-AWAU4BHR.mjs +244 -0
- package/dist/lib/node-esm/chunk-AWAU4BHR.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-CAWPHOY4.mjs +82 -0
- package/dist/lib/node-esm/chunk-CAWPHOY4.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-I32H7MCF.mjs +109 -0
- package/dist/lib/node-esm/chunk-I32H7MCF.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-HNOBZHWK.mjs → chunk-IG4GSWZN.mjs} +6 -4
- package/dist/lib/node-esm/chunk-IG4GSWZN.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-QHKP5HT2.mjs +1819 -0
- package/dist/lib/node-esm/chunk-QHKP5HT2.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-SS7U6GCX.mjs +16 -0
- package/dist/lib/node-esm/chunk-SS7U6GCX.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +210 -467
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/intent-resolver-ZS7XTYLG.mjs +45 -0
- package/dist/lib/node-esm/intent-resolver-ZS7XTYLG.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/react-surface-5ILD642V.mjs +81 -0
- package/dist/lib/node-esm/react-surface-5ILD642V.mjs.map +7 -0
- package/dist/lib/node-esm/settings-ANNQPPRY.mjs +23 -0
- package/dist/lib/node-esm/settings-ANNQPPRY.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +18 -9
- package/dist/types/src/AutomationPlugin.d.ts +1 -3
- package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/ai-client.d.ts +5 -0
- package/dist/types/src/capabilities/ai-client.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +181 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/capabilities.d.ts +5 -0
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +183 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts +4 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +4 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/settings.d.ts +4 -0
- package/dist/types/src/capabilities/settings.d.ts.map +1 -0
- package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts +7 -0
- package/dist/types/src/components/AmbientDialog/AmbientDialog.d.ts.map +1 -0
- package/dist/types/src/components/AmbientDialog/AmbientDialog.stories.d.ts +8 -0
- package/dist/types/src/components/AmbientDialog/AmbientDialog.stories.d.ts.map +1 -0
- package/dist/types/src/components/AmbientDialog/index.d.ts +2 -0
- package/dist/types/src/components/AmbientDialog/index.d.ts.map +1 -0
- package/dist/types/src/components/AssistantDialog.d.ts +7 -0
- package/dist/types/src/components/AssistantDialog.d.ts.map +1 -0
- 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/AutomationSettings/AutomationSettings.d.ts +5 -0
- package/dist/types/src/components/AutomationSettings/AutomationSettings.d.ts.map +1 -0
- package/dist/types/src/components/AutomationSettings/index.d.ts +2 -0
- package/dist/types/src/components/AutomationSettings/index.d.ts.map +1 -0
- package/dist/types/src/components/ChatContainer.d.ts +7 -0
- package/dist/types/src/components/ChatContainer.d.ts.map +1 -0
- package/dist/types/src/components/Prompt/Prompt.d.ts +17 -0
- package/dist/types/src/components/Prompt/Prompt.d.ts.map +1 -0
- package/dist/types/src/components/Prompt/Prompt.stories.d.ts +9 -0
- package/dist/types/src/components/Prompt/Prompt.stories.d.ts.map +1 -0
- package/dist/types/src/components/Prompt/PromptBar.d.ts +10 -0
- package/dist/types/src/components/Prompt/PromptBar.d.ts.map +1 -0
- package/dist/types/src/components/Prompt/autocomplete.d.ts +21 -0
- package/dist/types/src/components/Prompt/autocomplete.d.ts.map +1 -0
- package/dist/types/src/components/Prompt/index.d.ts +3 -0
- package/dist/types/src/components/Prompt/index.d.ts.map +1 -0
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts +5 -0
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts.map +1 -0
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.stories.d.ts +8 -0
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.stories.d.ts.map +1 -0
- package/dist/types/src/components/ServiceRegistry/index.d.ts +2 -0
- package/dist/types/src/components/ServiceRegistry/index.d.ts.map +1 -0
- package/dist/types/src/components/TemplateContainer.d.ts +7 -0
- package/dist/types/src/components/TemplateContainer.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts +12 -0
- package/dist/types/src/components/TemplateEditor/TemplateEditor.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts +8 -0
- package/dist/types/src/components/TemplateEditor/TemplateEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts +10 -0
- package/dist/types/src/components/TemplateEditor/TemplateForm.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts +8 -0
- package/dist/types/src/components/TemplateEditor/TemplateForm.stories.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/index.d.ts +2 -0
- package/dist/types/src/components/TemplateEditor/index.d.ts.map +1 -0
- package/dist/types/src/components/TemplateEditor/types.d.ts.map +1 -0
- package/dist/types/src/components/Thread/Thread.d.ts +17 -0
- package/dist/types/src/components/Thread/Thread.d.ts.map +1 -0
- package/dist/types/src/components/Thread/Thread.stories.d.ts +11 -0
- package/dist/types/src/components/Thread/Thread.stories.d.ts.map +1 -0
- package/dist/types/src/components/Thread/ThreadContainer.d.ts +10 -0
- package/dist/types/src/components/Thread/ThreadContainer.d.ts.map +1 -0
- package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts +15 -0
- package/dist/types/src/components/Thread/ThreadContainer.stories.d.ts.map +1 -0
- package/dist/types/src/components/Thread/ThreadMessage.d.ts +13 -0
- package/dist/types/src/components/Thread/ThreadMessage.d.ts.map +1 -0
- package/dist/types/src/components/Thread/ToolInvocations.d.ts +13 -0
- package/dist/types/src/components/Thread/ToolInvocations.d.ts.map +1 -0
- package/dist/types/src/components/Thread/index.d.ts +3 -0
- package/dist/types/src/components/Thread/index.d.ts.map +1 -0
- package/dist/types/src/components/Thread/reducer.d.ts +12 -0
- package/dist/types/src/components/Thread/reducer.d.ts.map +1 -0
- package/dist/types/src/components/Toolbox/Toolbox.d.ts +19 -0
- package/dist/types/src/components/Toolbox/Toolbox.d.ts.map +1 -0
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts +8 -0
- package/dist/types/src/components/Toolbox/Toolbox.stories.d.ts.map +1 -0
- package/dist/types/src/components/Toolbox/index.d.ts +2 -0
- package/dist/types/src/components/Toolbox/index.d.ts.map +1 -0
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +1 -3
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +19 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +5 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/processor.d.ts +75 -0
- package/dist/types/src/hooks/processor.d.ts.map +1 -0
- package/dist/types/src/hooks/processor.test.d.ts +2 -0
- package/dist/types/src/hooks/processor.test.d.ts.map +1 -0
- package/dist/types/src/hooks/useChatProcessor.d.ts +8 -0
- package/dist/types/src/hooks/useChatProcessor.d.ts.map +1 -0
- package/dist/types/src/hooks/useMessageQueue.d.ts +41 -0
- package/dist/types/src/hooks/useMessageQueue.d.ts.map +1 -0
- package/dist/types/src/hooks/useServices.d.ts +7 -0
- package/dist/types/src/hooks/useServices.d.ts.map +1 -0
- package/dist/types/src/hooks/useTextInputEvents.d.ts +13 -0
- package/dist/types/src/hooks/useTextInputEvents.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +2 -4
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +2 -1
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/{testing.d.ts → test-functions.d.ts} +3 -1
- package/dist/types/src/testing/test-functions.d.ts.map +1 -0
- package/dist/types/src/testing/test-services.d.ts +5 -0
- package/dist/types/src/testing/test-services.d.ts.map +1 -0
- package/dist/types/src/tools/function.d.ts +5 -0
- package/dist/types/src/tools/function.d.ts.map +1 -0
- package/dist/types/src/tools/index.d.ts +3 -0
- package/dist/types/src/tools/index.d.ts.map +1 -0
- package/dist/types/src/tools/openapi.d.ts +10 -0
- package/dist/types/src/tools/openapi.d.ts.map +1 -0
- package/dist/types/src/tools/openapi.test.d.ts +2 -0
- package/dist/types/src/tools/openapi.test.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +117 -2
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/chat.d.ts +12 -0
- package/dist/types/src/types/chat.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +3 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/service.d.ts +160 -0
- package/dist/types/src/types/service.d.ts.map +1 -0
- package/dist/types/src/types/template.d.ts +40 -0
- package/dist/types/src/types/template.d.ts.map +1 -0
- package/dist/types/src/types/types.d.ts +35 -5
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +62 -48
- package/src/AutomationPlugin.tsx +102 -193
- package/src/capabilities/ai-client.ts +19 -0
- package/src/capabilities/app-graph-builder.ts +99 -0
- package/src/capabilities/capabilities.ts +12 -0
- package/src/capabilities/index.ts +13 -0
- package/src/capabilities/intent-resolver.ts +38 -0
- package/src/capabilities/react-surface.tsx +63 -0
- package/src/capabilities/settings.ts +19 -0
- package/src/components/AmbientDialog/AmbientDialog.stories.tsx +81 -0
- package/src/components/AmbientDialog/AmbientDialog.tsx +103 -0
- package/src/components/AmbientDialog/index.ts +5 -0
- package/src/components/AssistantDialog.tsx +33 -0
- package/src/components/AutomationPanel/AutomationPanel.stories.tsx +2 -2
- package/src/components/AutomationPanel/AutomationPanel.tsx +54 -37
- package/src/components/AutomationSettings/AutomationSettings.tsx +49 -0
- package/src/components/AutomationSettings/index.ts +5 -0
- package/src/components/ChatContainer.tsx +29 -0
- package/src/components/Prompt/Prompt.stories.tsx +79 -0
- package/src/components/Prompt/Prompt.tsx +100 -0
- package/src/components/Prompt/PromptBar.tsx +100 -0
- package/src/components/Prompt/autocomplete.ts +212 -0
- package/src/components/Prompt/index.ts +6 -0
- package/src/components/ServiceRegistry/ServiceRegistry.stories.tsx +49 -0
- package/src/components/ServiceRegistry/ServiceRegistry.tsx +76 -0
- package/src/components/ServiceRegistry/index.ts +5 -0
- package/src/components/TemplateContainer.tsx +21 -0
- package/src/components/TemplateEditor/TemplateEditor.stories.tsx +72 -0
- package/src/components/TemplateEditor/TemplateEditor.tsx +76 -0
- package/src/components/TemplateEditor/TemplateForm.stories.tsx +65 -0
- package/src/components/TemplateEditor/TemplateForm.tsx +184 -0
- package/src/components/{PromptEditor → TemplateEditor}/index.ts +1 -1
- package/src/components/Thread/Thread.stories.tsx +212 -0
- package/src/components/Thread/Thread.tsx +97 -0
- package/src/components/Thread/ThreadContainer.stories.tsx +258 -0
- package/src/components/Thread/ThreadContainer.tsx +78 -0
- package/src/components/Thread/ThreadMessage.tsx +187 -0
- package/src/components/Thread/ToolInvocations.tsx +93 -0
- package/src/components/Thread/index.ts +6 -0
- package/src/components/Thread/reducer.ts +52 -0
- package/src/components/Toolbox/Toolbox.stories.tsx +65 -0
- package/src/components/Toolbox/Toolbox.tsx +117 -0
- package/src/components/Toolbox/index.ts +5 -0
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +2 -2
- package/src/components/TriggerEditor/TriggerEditor.tsx +78 -14
- package/src/components/index.ts +11 -1
- package/src/hooks/index.ts +6 -0
- package/src/hooks/processor.test.ts +15 -0
- package/src/hooks/processor.ts +219 -0
- package/src/hooks/useChatProcessor.tsx +77 -0
- package/src/hooks/useMessageQueue.ts +23 -0
- package/src/hooks/useServices.ts +28 -0
- package/src/hooks/useTextInputEvents.ts +49 -0
- package/src/index.ts +3 -6
- package/src/meta.ts +5 -2
- package/src/testing/index.ts +2 -1
- package/src/testing/{testing.ts → test-functions.ts} +9 -2
- package/src/testing/test-services.ts +131 -0
- package/src/tools/function.ts +47 -0
- package/src/tools/index.ts +6 -0
- package/src/tools/openapi.test.ts +224 -0
- package/src/tools/openapi.ts +331 -0
- package/src/translations.ts +36 -2
- package/src/types/chat.ts +11 -0
- package/src/types/index.ts +3 -1
- package/src/types/service.ts +102 -0
- package/src/types/template.ts +34 -0
- package/src/types/types.ts +34 -20
- package/src/typings.d.ts +9 -0
- package/dist/lib/browser/AssistantPanel-32FH2RA6.mjs +0 -339
- package/dist/lib/browser/AssistantPanel-32FH2RA6.mjs.map +0 -7
- package/dist/lib/browser/AutomationPanel-ABGPG5LE.mjs +0 -151
- package/dist/lib/browser/AutomationPanel-ABGPG5LE.mjs.map +0 -7
- package/dist/lib/browser/chunk-DN5M2QL5.mjs +0 -49
- package/dist/lib/browser/chunk-DN5M2QL5.mjs.map +0 -7
- package/dist/lib/browser/chunk-X5KMOH3I.mjs.map +0 -7
- package/dist/lib/browser/meta.mjs +0 -9
- package/dist/lib/node/AssistantPanel-XANI7YNV.cjs +0 -359
- package/dist/lib/node/AssistantPanel-XANI7YNV.cjs.map +0 -7
- package/dist/lib/node/AutomationPanel-VADY3HMP.cjs +0 -171
- package/dist/lib/node/AutomationPanel-VADY3HMP.cjs.map +0 -7
- package/dist/lib/node/chunk-DTJ7XVO2.cjs.map +0 -7
- package/dist/lib/node/chunk-NIL4TP6U.cjs +0 -73
- package/dist/lib/node/chunk-NIL4TP6U.cjs.map +0 -7
- package/dist/lib/node/meta.cjs.map +0 -7
- package/dist/lib/node-esm/AssistantPanel-5M6O6JV7.mjs +0 -340
- package/dist/lib/node-esm/AssistantPanel-5M6O6JV7.mjs.map +0 -7
- package/dist/lib/node-esm/AutomationPanel-EETYIDPA.mjs +0 -152
- package/dist/lib/node-esm/AutomationPanel-EETYIDPA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GCHXTXVT.mjs +0 -51
- package/dist/lib/node-esm/chunk-GCHXTXVT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HNOBZHWK.mjs.map +0 -7
- package/dist/lib/node-esm/meta.mjs +0 -10
- package/dist/types/src/components/AssistantPanel/AssistantPanel.d.ts +0 -8
- package/dist/types/src/components/AssistantPanel/AssistantPanel.d.ts.map +0 -1
- package/dist/types/src/components/AssistantPanel/index.d.ts +0 -3
- package/dist/types/src/components/AssistantPanel/index.d.ts.map +0 -1
- package/dist/types/src/components/AssistantPanel/system-instructions.d.ts +0 -6
- package/dist/types/src/components/AssistantPanel/system-instructions.d.ts.map +0 -1
- package/dist/types/src/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.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/testing.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -63
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/components/AssistantPanel/AssistantPanel.tsx +0 -230
- package/src/components/AssistantPanel/index.ts +0 -7
- package/src/components/AssistantPanel/system-instructions.ts +0 -166
- package/src/components/PromptEditor/PromptEditor.stories.tsx +0 -64
- package/src/components/PromptEditor/PromptEditor.tsx +0 -222
- package/src/components/PromptEditor/prompt-extension.ts +0 -43
- package/src/presets.ts +0 -248
- package/src/types/schema.ts +0 -38
- /package/dist/lib/browser/{meta.mjs.map → AutomationPanel-NCKK3CFN.mjs.map} +0 -0
- /package/dist/lib/node-esm/{meta.mjs.map → AutomationPanel-3MPIAO7R.mjs.map} +0 -0
- /package/dist/types/src/components/{PromptEditor → TemplateEditor}/types.d.ts +0 -0
- /package/src/components/{PromptEditor → TemplateEditor}/types.tsx +0 -0
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
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
|
+
};
|
|
@@ -16,7 +16,7 @@ import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
|
16
16
|
import { TriggerEditor } from './TriggerEditor';
|
|
17
17
|
import { functions } from '../../testing';
|
|
18
18
|
import translations from '../../translations';
|
|
19
|
-
import {
|
|
19
|
+
import { TemplateType } from '../../types';
|
|
20
20
|
|
|
21
21
|
const DefaultStory = () => {
|
|
22
22
|
const spaces = useSpaces();
|
|
@@ -50,7 +50,7 @@ const meta: Meta = {
|
|
|
50
50
|
withClientProvider({
|
|
51
51
|
createIdentity: true,
|
|
52
52
|
createSpace: true,
|
|
53
|
-
types: [FunctionType, FunctionTrigger,
|
|
53
|
+
types: [FunctionType, FunctionTrigger, TemplateType],
|
|
54
54
|
onSpaceCreated: ({ space }) => {
|
|
55
55
|
for (const fn of functions) {
|
|
56
56
|
space.db.add(create(FunctionType, fn));
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React from 'react';
|
|
5
|
+
import React, { useEffect, useState } from 'react';
|
|
6
6
|
|
|
7
|
+
import { ComputeGraph } from '@dxos/conductor';
|
|
7
8
|
import {
|
|
8
9
|
FunctionType,
|
|
9
10
|
FunctionTriggerSchema,
|
|
@@ -13,22 +14,23 @@ import {
|
|
|
13
14
|
TriggerKind,
|
|
14
15
|
} from '@dxos/functions';
|
|
15
16
|
import { Filter, useQuery, type Space } from '@dxos/react-client/echo';
|
|
16
|
-
import { useTranslation } from '@dxos/react-ui';
|
|
17
|
-
import { Form, SelectInput } from '@dxos/react-ui-form';
|
|
17
|
+
import { IconButton, Input, useTranslation } from '@dxos/react-ui';
|
|
18
|
+
import { Form, SelectInput, TextInput } from '@dxos/react-ui-form';
|
|
18
19
|
|
|
19
20
|
import { AUTOMATION_PLUGIN } from '../../meta';
|
|
20
21
|
|
|
21
22
|
export type TriggerEditorProps = {
|
|
22
23
|
space: Space;
|
|
23
24
|
trigger: FunctionTriggerType;
|
|
24
|
-
storedTrigger?: FunctionTrigger;
|
|
25
25
|
onSave?: (trigger: Omit<FunctionTrigger, 'id'>) => void;
|
|
26
26
|
onCancel?: () => void;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
export const TriggerEditor = ({ space, trigger, onSave, onCancel
|
|
29
|
+
export const TriggerEditor = ({ space, trigger, onSave, onCancel }: TriggerEditorProps) => {
|
|
30
30
|
const { t } = useTranslation(AUTOMATION_PLUGIN);
|
|
31
|
+
|
|
31
32
|
const functions = useQuery(space, Filter.schema(FunctionType));
|
|
33
|
+
const workflows = useQuery(space, Filter.schema(ComputeGraph));
|
|
32
34
|
const scripts = useQuery(space, Filter.schema(ScriptType));
|
|
33
35
|
|
|
34
36
|
const handleSave = (values: FunctionTriggerType) => {
|
|
@@ -39,21 +41,17 @@ export const TriggerEditor = ({ space, trigger, onSave, onCancel, storedTrigger
|
|
|
39
41
|
<Form<FunctionTriggerType>
|
|
40
42
|
schema={FunctionTriggerSchema}
|
|
41
43
|
values={trigger}
|
|
42
|
-
filter={(props) => props.filter((p) => p.name !== 'meta')}
|
|
43
44
|
onSave={handleSave}
|
|
44
45
|
onCancel={onCancel}
|
|
45
46
|
Custom={{
|
|
46
47
|
['function' satisfies keyof FunctionTriggerType]: (props) => (
|
|
47
|
-
<SelectInput
|
|
48
|
+
<SelectInput
|
|
48
49
|
{...props}
|
|
49
|
-
options={
|
|
50
|
-
value: fn.name,
|
|
51
|
-
label: getFunctionName(scripts, fn),
|
|
52
|
-
}))}
|
|
50
|
+
options={getWorkflowOptions(workflows).concat(getFunctionOptions(scripts, functions))}
|
|
53
51
|
/>
|
|
54
52
|
),
|
|
55
53
|
['spec.type' as const]: (props) => (
|
|
56
|
-
<SelectInput
|
|
54
|
+
<SelectInput
|
|
57
55
|
{...props}
|
|
58
56
|
options={Object.values(TriggerKind).map((kind) => ({
|
|
59
57
|
value: kind,
|
|
@@ -61,11 +59,77 @@ export const TriggerEditor = ({ space, trigger, onSave, onCancel, storedTrigger
|
|
|
61
59
|
}))}
|
|
62
60
|
/>
|
|
63
61
|
),
|
|
62
|
+
['meta' as const]: (props) => {
|
|
63
|
+
const meta = props.getValue()!;
|
|
64
|
+
useEffect(() => props.onValueChange('object', { ...meta }), []);
|
|
65
|
+
const [newMetaFieldName, setNewMetaFieldName] = useState('');
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<>
|
|
69
|
+
<div>{props.label}</div>
|
|
70
|
+
{[...Object.keys(meta)].map((key) => {
|
|
71
|
+
const compositeKey: any = `meta.${key}`;
|
|
72
|
+
return (
|
|
73
|
+
<div key={compositeKey} role='none' className='flex items-center mt-2 gap-1'>
|
|
74
|
+
<div role='none' className='flex-1'>
|
|
75
|
+
<TextInput
|
|
76
|
+
{...props}
|
|
77
|
+
getValue={() => (props.getValue() as any)[key]}
|
|
78
|
+
type={'string'}
|
|
79
|
+
label={key}
|
|
80
|
+
/>
|
|
81
|
+
</div>
|
|
82
|
+
<IconButton
|
|
83
|
+
icon='ph--trash--regular'
|
|
84
|
+
iconOnly
|
|
85
|
+
classNames={'mt-6'}
|
|
86
|
+
label={t('trigger meta remove')}
|
|
87
|
+
onClick={() => {
|
|
88
|
+
const newValues: any = { ...props.getValue() };
|
|
89
|
+
delete newValues[key];
|
|
90
|
+
props.onValueChange('object', newValues);
|
|
91
|
+
}}
|
|
92
|
+
/>
|
|
93
|
+
</div>
|
|
94
|
+
);
|
|
95
|
+
})}
|
|
96
|
+
<div role='none' className='flex items-center mt-2 gap-1 plb-1'>
|
|
97
|
+
<div role='none' className='flex-1'>
|
|
98
|
+
<Input.Root>
|
|
99
|
+
<Input.TextInput
|
|
100
|
+
placeholder={t('trigger meta prop name placeholder')}
|
|
101
|
+
value={newMetaFieldName}
|
|
102
|
+
onChange={(event) => setNewMetaFieldName(event.target.value)}
|
|
103
|
+
/>
|
|
104
|
+
</Input.Root>
|
|
105
|
+
</div>
|
|
106
|
+
<IconButton
|
|
107
|
+
icon='ph--plus--regular'
|
|
108
|
+
iconOnly
|
|
109
|
+
label={t('trigger meta add')}
|
|
110
|
+
onClick={() => {
|
|
111
|
+
if (newMetaFieldName.length) {
|
|
112
|
+
const meta = props.getValue() ?? {};
|
|
113
|
+
const metaWithNewProp = { ...meta, [newMetaFieldName]: '' };
|
|
114
|
+
setNewMetaFieldName('');
|
|
115
|
+
props.onValueChange('object', metaWithNewProp);
|
|
116
|
+
}
|
|
117
|
+
}}
|
|
118
|
+
/>
|
|
119
|
+
</div>
|
|
120
|
+
</>
|
|
121
|
+
);
|
|
122
|
+
},
|
|
64
123
|
}}
|
|
65
124
|
/>
|
|
66
125
|
);
|
|
67
126
|
};
|
|
68
127
|
|
|
69
|
-
const
|
|
70
|
-
return
|
|
128
|
+
const getWorkflowOptions = (graphs: ComputeGraph[]) => {
|
|
129
|
+
return graphs.map((graph) => ({ label: `compute-${graph.id}`, value: `dxn:echo:@:${graph.id}` }));
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const getFunctionOptions = (scripts: ScriptType[], functions: FunctionType[]) => {
|
|
133
|
+
const getLabel = (fn: FunctionType) => scripts.find((s) => fn.source?.target?.id === s.id)?.name ?? fn.name;
|
|
134
|
+
return functions.map((fn) => ({ label: getLabel(fn), value: `dxn:worker:${fn.name}` }));
|
|
71
135
|
};
|
package/src/components/index.ts
CHANGED
|
@@ -4,5 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
import { lazy } from 'react';
|
|
6
6
|
|
|
7
|
-
export
|
|
7
|
+
export * from './AutomationPanel';
|
|
8
|
+
export * from './AutomationSettings';
|
|
9
|
+
export * from './ServiceRegistry';
|
|
10
|
+
export * from './TemplateEditor';
|
|
11
|
+
export * from './Thread';
|
|
12
|
+
export * from './TriggerEditor';
|
|
13
|
+
export * from './Toolbox';
|
|
14
|
+
|
|
15
|
+
export const AssistantDialog = lazy(() => import('./AssistantDialog'));
|
|
8
16
|
export const AutomationPanel = lazy(() => import('./AutomationPanel'));
|
|
17
|
+
export const ChatContainer = lazy(() => import('./ChatContainer'));
|
|
18
|
+
export const TemplateContainer = lazy(() => import('./TemplateContainer'));
|
package/src/hooks/index.ts
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,219 @@
|
|
|
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
|
+
}
|