@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,77 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type Message } from '@dxos/artifact';
|
|
8
|
+
import { DXN, QueueSubspaceTags } from '@dxos/keys';
|
|
9
|
+
import { getSpace } from '@dxos/react-client/echo';
|
|
10
|
+
import { useEdgeClient, useQueue } from '@dxos/react-edge-client';
|
|
11
|
+
|
|
12
|
+
import { type AIChatType } from '../types';
|
|
13
|
+
|
|
14
|
+
export const useMessageQueue = (chat?: AIChatType) => {
|
|
15
|
+
const space = getSpace(chat);
|
|
16
|
+
const queueDxn = useMemo(() => {
|
|
17
|
+
const dxn = space && chat?.queue.dxn;
|
|
18
|
+
return dxn ? new DXN(DXN.kind.QUEUE, [QueueSubspaceTags.DATA, space.id, dxn.parts.at(-1)!]) : undefined;
|
|
19
|
+
}, [space, chat?.queue.dxn]);
|
|
20
|
+
|
|
21
|
+
const edgeClient = useEdgeClient();
|
|
22
|
+
return useQueue<Message>(edgeClient, queueDxn);
|
|
23
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type Space } from '@dxos/client/echo';
|
|
8
|
+
|
|
9
|
+
import { MockServiceRegistry } from '../testing';
|
|
10
|
+
import { type ServiceType, type ServiceQuery } from '../types';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Retrieves matching services from the registry.
|
|
14
|
+
*/
|
|
15
|
+
export const useServices = (space: Space, query?: ServiceQuery): ServiceType[] => {
|
|
16
|
+
const registry = useMemo(() => new MockServiceRegistry(), []);
|
|
17
|
+
const [services, setServices] = useState<ServiceType[]>([]);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const t = setTimeout(async () => {
|
|
20
|
+
const services = await registry.queryServices(query);
|
|
21
|
+
setServices(services);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
return () => clearTimeout(t);
|
|
25
|
+
}, [query, registry]);
|
|
26
|
+
|
|
27
|
+
return services;
|
|
28
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useState, useCallback, type KeyboardEventHandler, type ChangeEventHandler } from 'react';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Hook that handles text input events.
|
|
9
|
+
*/
|
|
10
|
+
// TODO(burdon): Factor out.
|
|
11
|
+
export const useTextInputEvents = ({
|
|
12
|
+
onEnter,
|
|
13
|
+
onEscape,
|
|
14
|
+
}: {
|
|
15
|
+
onEnter?: (text: string) => boolean | void;
|
|
16
|
+
onEscape?: () => void;
|
|
17
|
+
}) => {
|
|
18
|
+
const [value, setValue] = useState('');
|
|
19
|
+
|
|
20
|
+
const onKeyDown = useCallback<KeyboardEventHandler<HTMLInputElement>>(
|
|
21
|
+
(ev) => {
|
|
22
|
+
switch (ev.key) {
|
|
23
|
+
case 'Escape': {
|
|
24
|
+
onEscape?.();
|
|
25
|
+
setValue('');
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
case 'Enter': {
|
|
30
|
+
const value = (ev.target as HTMLInputElement).value.trim();
|
|
31
|
+
if (value.length > 0) {
|
|
32
|
+
const reset = onEnter?.(value);
|
|
33
|
+
if (reset) {
|
|
34
|
+
setValue('');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
[onEnter, onEscape],
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
const onChange = useCallback<ChangeEventHandler<HTMLInputElement>>((ev) => {
|
|
45
|
+
setValue(ev.target.value);
|
|
46
|
+
}, []);
|
|
47
|
+
|
|
48
|
+
return [{ value, onKeyDown, onChange }, setValue];
|
|
49
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -2,11 +2,8 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { AutomationPlugin } from './AutomationPlugin';
|
|
6
|
-
|
|
7
|
-
export default AutomationPlugin;
|
|
8
|
-
|
|
9
|
-
export * from './AutomationPlugin';
|
|
10
5
|
export * from './components';
|
|
11
|
-
export * from './
|
|
6
|
+
export * from './meta';
|
|
12
7
|
export * from './types';
|
|
8
|
+
|
|
9
|
+
export * from './AutomationPlugin';
|
package/src/meta.ts
CHANGED
|
@@ -6,10 +6,13 @@ import { type PluginMeta } from '@dxos/app-framework';
|
|
|
6
6
|
|
|
7
7
|
export const AUTOMATION_PLUGIN = 'dxos.org/plugin/automation';
|
|
8
8
|
|
|
9
|
-
export
|
|
9
|
+
export const ASSISTANT_DIALOG = `${AUTOMATION_PLUGIN}/assistant/dialog`;
|
|
10
|
+
|
|
11
|
+
export const meta = {
|
|
10
12
|
id: AUTOMATION_PLUGIN,
|
|
11
13
|
name: 'Automation',
|
|
12
|
-
description:
|
|
14
|
+
description:
|
|
15
|
+
'The Automation tab allows you to trigger pre-defined workflows related to the element you are interacting with inside of Composer.',
|
|
13
16
|
icon: 'ph--magic-wand--regular',
|
|
14
17
|
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/experimental/plugin-automation',
|
|
15
18
|
tags: ['experimental'],
|
package/src/testing/index.ts
CHANGED
|
@@ -2,12 +2,19 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { createSystemPrompt } from '@dxos/artifact';
|
|
6
|
+
import { DEFAULT_LLM_MODEL, type GenerateRequest } from '@dxos/assistant';
|
|
5
7
|
import { AST, S, toJsonSchema } from '@dxos/echo-schema';
|
|
6
8
|
|
|
9
|
+
export const createProcessorOptions = (artifacts: string[]): Pick<GenerateRequest, 'model' | 'systemPrompt'> => ({
|
|
10
|
+
model: DEFAULT_LLM_MODEL,
|
|
11
|
+
systemPrompt: createSystemPrompt({ artifacts }),
|
|
12
|
+
});
|
|
13
|
+
|
|
7
14
|
export const functions = [
|
|
8
15
|
{
|
|
9
16
|
name: 'example.com/function/chess',
|
|
10
|
-
version: '0.0
|
|
17
|
+
version: '0.1.0',
|
|
11
18
|
inputSchema: toJsonSchema(
|
|
12
19
|
S.Struct({
|
|
13
20
|
level: S.Number.annotations({
|
|
@@ -18,7 +25,7 @@ export const functions = [
|
|
|
18
25
|
},
|
|
19
26
|
{
|
|
20
27
|
name: 'example.com/function/forex',
|
|
21
|
-
version: '0.0
|
|
28
|
+
version: '0.1.0',
|
|
22
29
|
binding: 'FOREX',
|
|
23
30
|
inputSchema: toJsonSchema(
|
|
24
31
|
S.Struct({
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { createStatic } from '@dxos/echo-schema';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
type ApiAuthorization,
|
|
9
|
+
type BaseServiceRegistry,
|
|
10
|
+
type ServiceQuery,
|
|
11
|
+
ServiceType,
|
|
12
|
+
categoryIcons,
|
|
13
|
+
} from '../types';
|
|
14
|
+
|
|
15
|
+
export class MockServiceRegistry implements BaseServiceRegistry {
|
|
16
|
+
async queryServices(query?: ServiceQuery): Promise<ServiceType[]> {
|
|
17
|
+
return TEST_SERVICES;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// TODO(burdon): Can we generalize credentials?
|
|
22
|
+
|
|
23
|
+
const AMADEUS_AUTH: ApiAuthorization = {
|
|
24
|
+
type: 'oauth',
|
|
25
|
+
clientId: 'BOEnpLd1sMyKjAPGKYeAPFFy60u53QEG',
|
|
26
|
+
clientSecret: 'n4qldSN7usvD57gm',
|
|
27
|
+
tokenUrl: 'https://test.api.amadeus.com/v1/security/oauth2/token',
|
|
28
|
+
grantType: 'client_credentials',
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const VISUAL_CROSSING_CREDENTIALS: ApiAuthorization = {
|
|
32
|
+
type: 'api-key',
|
|
33
|
+
key: 'FDPRVS953KB4GQQLD25GRT975',
|
|
34
|
+
placement: {
|
|
35
|
+
type: 'query',
|
|
36
|
+
name: 'key',
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// Registries:
|
|
41
|
+
// - https://apis.guru
|
|
42
|
+
// - https://rapidapi.com
|
|
43
|
+
// - https://github.com/konfig-sdks/openapi-examples
|
|
44
|
+
// - https://publicapis.io/?utm_source=chatgpt.com
|
|
45
|
+
|
|
46
|
+
// Examples:
|
|
47
|
+
// - https://petstore.swagger.io/v2/swagger.json (testing)
|
|
48
|
+
// - https://lichess.org/api
|
|
49
|
+
// - https://github.com/konfig-sdks/openapi-examples/tree/main/xkcd
|
|
50
|
+
// - https://api.coindesk.com/v1/bpi/currentprice.json
|
|
51
|
+
// - https://www.coingecko.com/en/api/documentation
|
|
52
|
+
|
|
53
|
+
// TODO(burdon): Support yaml endpoints.
|
|
54
|
+
// - e.g., https://github.com/konfig-sdks/openapi-examples/blob/main/xkcd/openapi.yaml
|
|
55
|
+
|
|
56
|
+
const TEST_SERVICES: ServiceType[] = [
|
|
57
|
+
createStatic(ServiceType, {
|
|
58
|
+
serviceId: 'amadeus.com/service/FlightSearch',
|
|
59
|
+
name: 'Amadeus Flight Search',
|
|
60
|
+
description: 'Search for local and international flights.',
|
|
61
|
+
category: 'travel',
|
|
62
|
+
interfaces: [
|
|
63
|
+
{
|
|
64
|
+
kind: 'api',
|
|
65
|
+
schemaUrl: 'https://api.apis.guru/v2/specs/amadeus.com/amadeus-flight-availabilities-search/1.0.2/swagger.json',
|
|
66
|
+
authorization: AMADEUS_AUTH,
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
}),
|
|
70
|
+
|
|
71
|
+
createStatic(ServiceType, {
|
|
72
|
+
serviceId: 'amadeus.com/service/HotelSearch',
|
|
73
|
+
name: 'Amadeus Hotel Search',
|
|
74
|
+
description: 'Search for local and international hotels.',
|
|
75
|
+
category: 'travel',
|
|
76
|
+
interfaces: [
|
|
77
|
+
{
|
|
78
|
+
kind: 'api',
|
|
79
|
+
schemaUrl: 'https://api.apis.guru/v2/specs/amadeus.com/amadeus-hotel-search/3.0.8/swagger.json',
|
|
80
|
+
authorization: AMADEUS_AUTH,
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
}),
|
|
84
|
+
|
|
85
|
+
createStatic(ServiceType, {
|
|
86
|
+
serviceId: 'visualcrossing.com/service/Weather',
|
|
87
|
+
name: 'Visual Crossing Weather',
|
|
88
|
+
description: 'Search for global weather forecasts.',
|
|
89
|
+
category: 'weather',
|
|
90
|
+
interfaces: [
|
|
91
|
+
{
|
|
92
|
+
kind: 'api',
|
|
93
|
+
schemaUrl: 'https://api.apis.guru/v2/specs/visualcrossing.com/weather/4.6/openapi.json',
|
|
94
|
+
authorization: VISUAL_CROSSING_CREDENTIALS,
|
|
95
|
+
},
|
|
96
|
+
],
|
|
97
|
+
}),
|
|
98
|
+
|
|
99
|
+
// TODO(burdon): Needs auth.
|
|
100
|
+
createStatic(ServiceType, {
|
|
101
|
+
serviceId: 'abstractapi.com/service/GeoLocation',
|
|
102
|
+
name: 'Abstract GeoLocation',
|
|
103
|
+
description: 'Get the location of any IP address.',
|
|
104
|
+
category: 'geolocation',
|
|
105
|
+
interfaces: [
|
|
106
|
+
{
|
|
107
|
+
kind: 'api',
|
|
108
|
+
schemaUrl: 'https://api.apis.guru/v2/specs/abstractapi.com/geolocation/1.0.0/openapi.json',
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
}),
|
|
112
|
+
|
|
113
|
+
//
|
|
114
|
+
// Testing
|
|
115
|
+
//
|
|
116
|
+
|
|
117
|
+
...Array.from({ length: 20 }, (_, i) =>
|
|
118
|
+
createStatic(ServiceType, {
|
|
119
|
+
serviceId: `example.com/service/test-${i}`,
|
|
120
|
+
name: `Test ${i}`,
|
|
121
|
+
description: `Test ${i}`,
|
|
122
|
+
category: Object.keys(categoryIcons)[Math.floor(Math.random() * Object.keys(categoryIcons).length)],
|
|
123
|
+
interfaces: [
|
|
124
|
+
{
|
|
125
|
+
kind: 'api',
|
|
126
|
+
schemaUrl: 'https://petstore.swagger.io/v2/swagger.json',
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
}),
|
|
130
|
+
),
|
|
131
|
+
] as const;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { defineTool, ToolResult } from '@dxos/artifact';
|
|
6
|
+
import type { Tool } from '@dxos/artifact';
|
|
7
|
+
import { toEffectSchema } from '@dxos/echo-schema';
|
|
8
|
+
import { getInvocationUrl, getUserFunctionUrlInMetadata } from '@dxos/functions';
|
|
9
|
+
import type { FunctionType } from '@dxos/functions';
|
|
10
|
+
import { log } from '@dxos/log';
|
|
11
|
+
import type { SpaceId } from '@dxos/react-client/echo';
|
|
12
|
+
import { getMeta } from '@dxos/react-client/echo';
|
|
13
|
+
|
|
14
|
+
export const covertFunctionToTool = (
|
|
15
|
+
fn: FunctionType,
|
|
16
|
+
edgeUrl: string,
|
|
17
|
+
spaceId?: SpaceId | undefined,
|
|
18
|
+
): Tool | undefined => {
|
|
19
|
+
if (!fn.description || !fn.inputSchema) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const existingFunctionUrl = getUserFunctionUrlInMetadata(getMeta(fn));
|
|
24
|
+
if (!existingFunctionUrl) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
const url = getInvocationUrl(existingFunctionUrl, edgeUrl, {
|
|
28
|
+
spaceId,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
return defineTool({
|
|
32
|
+
name: fn.name,
|
|
33
|
+
description: fn.description,
|
|
34
|
+
schema: toEffectSchema(fn.inputSchema),
|
|
35
|
+
execute: async (input) => {
|
|
36
|
+
log.info('execute function tool', { name: fn.name, url, input });
|
|
37
|
+
const response = await fetch(url, {
|
|
38
|
+
method: 'POST',
|
|
39
|
+
headers: {
|
|
40
|
+
'Content-Type': 'application/json',
|
|
41
|
+
},
|
|
42
|
+
body: JSON.stringify(input),
|
|
43
|
+
});
|
|
44
|
+
return ToolResult.Success(await response.text());
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
};
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { describe, expect, test } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import { AIServiceClientImpl } from '@dxos/assistant';
|
|
8
|
+
import { AI_SERVICE_ENDPOINT } from '@dxos/assistant/testing';
|
|
9
|
+
import { log } from '@dxos/log';
|
|
10
|
+
|
|
11
|
+
import { createToolsFromApi, resolveAuthorization } from './openapi';
|
|
12
|
+
import { ChatProcessor } from '../hooks';
|
|
13
|
+
import type { ApiAuthorization } from '../types';
|
|
14
|
+
|
|
15
|
+
describe.skip('openapi', () => {
|
|
16
|
+
describe.skip('mapping', () => {
|
|
17
|
+
test('amadeus flight availabilities', async () => {
|
|
18
|
+
const tools = await createToolsFromApi(FLIGHT_SEARCH_API);
|
|
19
|
+
|
|
20
|
+
log.info('tools', { tools });
|
|
21
|
+
// for (const tool of tools) {
|
|
22
|
+
// const schema = tool.parameters;
|
|
23
|
+
// // log.info('schema', { schema });
|
|
24
|
+
// }
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('amadeus hotel search', async () => {
|
|
28
|
+
const tools = await createToolsFromApi(HOTEL_SEARCH_API);
|
|
29
|
+
log.info('tools', { tools });
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('amadeus hotel name autocomplete', async () => {
|
|
33
|
+
const tools = await createToolsFromApi(HOTEL_NAME_AUTOCOMPLETE_API);
|
|
34
|
+
log.info('tools', { tools });
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('weather', async () => {
|
|
38
|
+
const tools = await createToolsFromApi(WEATHER_API, { authorization: VISUAL_CROSSING_CREDENTIALS });
|
|
39
|
+
log.info('tools', { tools });
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe.skip('invoke tools', () => {
|
|
44
|
+
test('amadeus hotel name autocomplete', async () => {
|
|
45
|
+
const tools = await createToolsFromApi(HOTEL_NAME_AUTOCOMPLETE_API, { authorization: AMADEUS_AUTH });
|
|
46
|
+
|
|
47
|
+
const result = await tools[0].execute!({
|
|
48
|
+
keyword: 'William Vale Brooklyn',
|
|
49
|
+
subType: ['HOTEL_LEISURE', 'HOTEL_GDS'],
|
|
50
|
+
countryCode: 'US',
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
log.info('result', { result });
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test('weather API', async () => {
|
|
57
|
+
const tools = await createToolsFromApi(WEATHER_API, { authorization: VISUAL_CROSSING_CREDENTIALS });
|
|
58
|
+
const forecastTool = tools.find((t) => t.name.includes('forecast'));
|
|
59
|
+
|
|
60
|
+
const result = await forecastTool?.execute!({
|
|
61
|
+
locations: 'Brooklyn, NY',
|
|
62
|
+
aggregateHours: '24',
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
log.info('result', { result });
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
describe.skip('AI uses tools', () => {
|
|
70
|
+
test('amadeus flight availabilities', { timeout: 60_000 }, async () => {
|
|
71
|
+
const tools = await createToolsFromApi(FLIGHT_SEARCH_API, {
|
|
72
|
+
authorization: AMADEUS_AUTH,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const client = new AIServiceClientImpl({
|
|
76
|
+
endpoint: AI_SERVICE_ENDPOINT.LOCAL,
|
|
77
|
+
});
|
|
78
|
+
const processor = new ChatProcessor(client, tools);
|
|
79
|
+
const reply = await processor.request(
|
|
80
|
+
`What is the cheapest flight from New York to Paris? going on ${new Date().toISOString()} and returning after a week. 1 adult traveler`,
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
log.info('reply', { reply });
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
// TODO(dmaretskyi): Doesn't work.
|
|
87
|
+
test('amadeus hotel name autocomplete', { timeout: 60_000 }, async () => {
|
|
88
|
+
const tools = await createToolsFromApi(HOTEL_NAME_AUTOCOMPLETE_API, { authorization: AMADEUS_AUTH });
|
|
89
|
+
|
|
90
|
+
const client = new AIServiceClientImpl({
|
|
91
|
+
endpoint: AI_SERVICE_ENDPOINT.LOCAL,
|
|
92
|
+
});
|
|
93
|
+
const processor = new ChatProcessor(client, tools);
|
|
94
|
+
const reply = await processor.request('Find me the William Wale in Brooklyn New York');
|
|
95
|
+
|
|
96
|
+
log.info('reply', { reply });
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
test.only('weather forecast', { timeout: 60_000 }, async () => {
|
|
100
|
+
const tools = await createToolsFromApi(WEATHER_API, {
|
|
101
|
+
authorization: VISUAL_CROSSING_CREDENTIALS,
|
|
102
|
+
instructions: WEATHER_INSTRUCTIONS,
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
const client = new AIServiceClientImpl({
|
|
106
|
+
endpoint: AI_SERVICE_ENDPOINT.LOCAL,
|
|
107
|
+
});
|
|
108
|
+
const processor = new ChatProcessor(client, tools);
|
|
109
|
+
const reply = await processor.request(
|
|
110
|
+
`Today's date is ${new Date().toISOString().split('T')[0]}. Give me weather forecast for Warsaw for next 5 days.`,
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
log.info('reply', { reply });
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
describe.skip('invoke api directly', { timeout: 10_000 }, () => {
|
|
118
|
+
test('amadeus flight availabilities', async () => {
|
|
119
|
+
const response = await fetch('https://test.api.amadeus.com/v1/shopping/availability/flight-availabilities', {
|
|
120
|
+
method: 'POST',
|
|
121
|
+
headers: {
|
|
122
|
+
accept: 'application/vnd.amadeus+json',
|
|
123
|
+
'X-HTTP-Method-Override': 'GET',
|
|
124
|
+
'Content-Type': 'application/vnd.amadeus+json',
|
|
125
|
+
Authorization: await resolveAuthorization(AMADEUS_AUTH),
|
|
126
|
+
},
|
|
127
|
+
body: JSON.stringify({
|
|
128
|
+
originDestinations: [
|
|
129
|
+
{
|
|
130
|
+
departureDateTime: {
|
|
131
|
+
date: new Date().toISOString().split('T')[0],
|
|
132
|
+
time: new Date().toTimeString().split(' ')[0],
|
|
133
|
+
},
|
|
134
|
+
destinationLocationCode: 'MAD',
|
|
135
|
+
id: '1',
|
|
136
|
+
originLocationCode: 'BOS',
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
sources: ['GDS'],
|
|
140
|
+
travelers: [
|
|
141
|
+
{
|
|
142
|
+
id: '1',
|
|
143
|
+
travelerType: 'ADULT',
|
|
144
|
+
},
|
|
145
|
+
],
|
|
146
|
+
}),
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
log.info('response', { status: response.status, body: await response.json() });
|
|
150
|
+
expect(response.status).toBe(200);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
test.only('amadeus hotel name autocomplete', async () => {
|
|
154
|
+
const response = await fetch(
|
|
155
|
+
'https://test.api.amadeus.com/v1/reference-data/locations/hotel?keyword=PARI&subtype=HOTEL_LEISURE,HOTEL_GDS',
|
|
156
|
+
{
|
|
157
|
+
method: 'GET',
|
|
158
|
+
headers: {
|
|
159
|
+
// accept: 'application/vnd.amadeus+json',
|
|
160
|
+
// 'X-HTTP-Method-Override': 'GET',
|
|
161
|
+
Authorization: await resolveAuthorization(AMADEUS_AUTH),
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
log.info('response', { status: response.status, body: await response.json() });
|
|
167
|
+
expect(response.status).toBe(200);
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
describe.skip('rapidapi', () => {
|
|
172
|
+
test('amadeus flight availabilities', async () => {
|
|
173
|
+
const departureDate = new Date().toISOString().split('T')[0];
|
|
174
|
+
const arrivalDate = new Date(new Date().getTime() + 7 * 24 * 60 * 60 * 1000).toISOString().split('T')[0];
|
|
175
|
+
|
|
176
|
+
const url = `https://amadeus-api2.p.rapidapi.com/serpapi-flight-search?departure_id=PEK&arrival_id=AUS&outbound_date=${departureDate}&return_date=${arrivalDate}¤cy=USD&hl=en`;
|
|
177
|
+
const options = {
|
|
178
|
+
method: 'GET',
|
|
179
|
+
headers: {
|
|
180
|
+
'x-rapidapi-key': RAPID_API_CREDENTIALS.key,
|
|
181
|
+
'x-rapidapi-host': 'amadeus-api2.p.rapidapi.com',
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
const response = await fetch(url, options);
|
|
186
|
+
log.info('response', { status: response.status, body: await response.json() });
|
|
187
|
+
expect(response.status).toBe(200);
|
|
188
|
+
});
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
const FLIGHT_SEARCH_API =
|
|
193
|
+
'https://api.apis.guru/v2/specs/amadeus.com/amadeus-flight-availabilities-search/1.0.2/swagger.json';
|
|
194
|
+
const HOTEL_SEARCH_API = 'https://api.apis.guru/v2/specs/amadeus.com/amadeus-hotel-search/3.0.8/swagger.json';
|
|
195
|
+
const HOTEL_NAME_AUTOCOMPLETE_API =
|
|
196
|
+
'https://api.apis.guru/v2/specs/amadeus.com/amadeus-hotel-name-autocomplete/1.0.3/swagger.json';
|
|
197
|
+
const WEATHER_API = 'https://api.apis.guru/v2/specs/visualcrossing.com/weather/4.6/openapi.json';
|
|
198
|
+
|
|
199
|
+
const WEATHER_INSTRUCTIONS = `
|
|
200
|
+
If the user doesn't provide a date, use today's date.
|
|
201
|
+
Make sure to provide the start and end dates when possible to reduce the amount of data returned.
|
|
202
|
+
Use the tool that accepts the date parameters.
|
|
203
|
+
`;
|
|
204
|
+
|
|
205
|
+
const AMADEUS_AUTH: ApiAuthorization = {
|
|
206
|
+
type: 'oauth',
|
|
207
|
+
clientId: 'BOEnpLd1sMyKjAPGKYeAPFFy60u53QEG',
|
|
208
|
+
clientSecret: 'n4qldSN7usvD57gm',
|
|
209
|
+
tokenUrl: 'https://test.api.amadeus.com/v1/security/oauth2/token',
|
|
210
|
+
grantType: 'client_credentials',
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
const VISUAL_CROSSING_CREDENTIALS: ApiAuthorization = {
|
|
214
|
+
type: 'api-key',
|
|
215
|
+
key: 'FDPRVS953KB4GQQLD25GRT975',
|
|
216
|
+
placement: {
|
|
217
|
+
type: 'query',
|
|
218
|
+
name: 'key',
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
const RAPID_API_CREDENTIALS = {
|
|
223
|
+
key: '92271b6740msh32fd821d70f050dp16665bjsna69195c9e838',
|
|
224
|
+
};
|