@dxos/plugin-automation 0.7.5-labs.5f04cf6 → 0.7.5-labs.8a82073
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/AutomationPanel-CL2TWZT5.mjs +8 -0
- package/dist/lib/browser/AutomationPanel-CL2TWZT5.mjs.map +7 -0
- package/dist/lib/browser/ChatContainer-EJ3IWL7Y.mjs +12 -0
- package/dist/lib/browser/ChatContainer-EJ3IWL7Y.mjs.map +7 -0
- package/dist/lib/browser/{ai-client-6CRYUC6D.mjs → ai-client-UJLNYP7B.mjs} +4 -4
- package/dist/lib/browser/{ai-client-6CRYUC6D.mjs.map → ai-client-UJLNYP7B.mjs.map} +3 -3
- package/dist/lib/browser/{app-graph-builder-IJTTULDP.mjs → app-graph-builder-3H5TCRG4.mjs} +33 -2
- package/dist/lib/browser/{app-graph-builder-IJTTULDP.mjs.map → app-graph-builder-3H5TCRG4.mjs.map} +3 -3
- package/dist/lib/browser/chunk-43WRHV2L.mjs +150 -0
- package/dist/lib/browser/chunk-43WRHV2L.mjs.map +7 -0
- package/dist/lib/browser/{chunk-EKJVAFT2.mjs → chunk-4M74P6YW.mjs} +66 -8
- package/dist/lib/browser/{chunk-EKJVAFT2.mjs.map → chunk-4M74P6YW.mjs.map} +4 -4
- package/dist/lib/browser/chunk-6KJRL5KV.mjs +243 -0
- package/dist/lib/browser/chunk-6KJRL5KV.mjs.map +7 -0
- package/dist/lib/browser/{chunk-HZ4TA7HY.mjs → chunk-BQHXJZ4K.mjs} +2 -2
- package/dist/lib/browser/{chunk-HKX3D3ZP.mjs → chunk-DQ7ZSYJJ.mjs} +2 -2
- package/dist/lib/browser/{chunk-HKX3D3ZP.mjs.map → chunk-DQ7ZSYJJ.mjs.map} +2 -2
- package/dist/lib/browser/chunk-N4SSCQ7P.mjs +1602 -0
- package/dist/lib/browser/chunk-N4SSCQ7P.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +52 -45
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/intent-resolver-5YVZJFS3.mjs +29 -0
- package/dist/lib/browser/intent-resolver-5YVZJFS3.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-IGMBLSV7.mjs → react-surface-RRTZFTKR.mjs} +24 -23
- package/dist/lib/browser/react-surface-RRTZFTKR.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +10 -4
- package/dist/lib/node/AutomationPanel-BCEY3YXO.cjs +26 -0
- package/dist/lib/node/AutomationPanel-BCEY3YXO.cjs.map +7 -0
- package/dist/lib/node/ChatContainer-QUWFEBTI.cjs +33 -0
- package/dist/lib/node/ChatContainer-QUWFEBTI.cjs.map +7 -0
- package/dist/lib/node/{ai-client-A3RRU55B.cjs → ai-client-AOB6TLNW.cjs} +8 -8
- package/dist/lib/node/{ai-client-A3RRU55B.cjs.map → ai-client-AOB6TLNW.cjs.map} +3 -3
- package/dist/lib/node/{app-graph-builder-MF5M4QRS.cjs → app-graph-builder-CDEQJEHY.cjs} +43 -12
- package/dist/lib/node/{app-graph-builder-MF5M4QRS.cjs.map → app-graph-builder-CDEQJEHY.cjs.map} +3 -3
- package/dist/lib/node/{chunk-ZS5RZ7RM.cjs → chunk-AWZVJZ2I.cjs} +6 -6
- package/dist/lib/node/chunk-DKGNORZK.cjs +1586 -0
- package/dist/lib/node/chunk-DKGNORZK.cjs.map +7 -0
- package/dist/lib/node/{chunk-BUQOZA4N.cjs → chunk-H3RSMGJG.cjs} +87 -11
- package/dist/lib/node/chunk-H3RSMGJG.cjs.map +7 -0
- package/dist/lib/node/{AutomationPanel-RXJDVLCF.cjs → chunk-IPCNJYQL.cjs} +123 -9
- package/dist/lib/node/chunk-IPCNJYQL.cjs.map +7 -0
- package/dist/lib/node/{chunk-VEGLN4YN.cjs → chunk-LC6KNDPQ.cjs} +78 -26
- package/dist/lib/node/chunk-LC6KNDPQ.cjs.map +7 -0
- package/dist/lib/node/{chunk-5VF5JKUN.cjs → chunk-TQEDPRY5.cjs} +5 -5
- package/dist/lib/node/{chunk-5VF5JKUN.cjs.map → chunk-TQEDPRY5.cjs.map} +2 -2
- package/dist/lib/node/index.cjs +96 -88
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/{intent-resolver-TBHYXBDI.cjs → intent-resolver-MJFZT5IU.cjs} +20 -15
- package/dist/lib/node/intent-resolver-MJFZT5IU.cjs.map +7 -0
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-surface-BVUZMKYS.cjs → react-surface-BVZ63QP4.cjs} +25 -24
- package/dist/lib/node/react-surface-BVZ63QP4.cjs.map +7 -0
- package/dist/lib/node/types/index.cjs +15 -9
- package/dist/lib/node/types/index.cjs.map +2 -2
- package/dist/lib/node-esm/AutomationPanel-YTIZ74RI.mjs +9 -0
- package/dist/lib/node-esm/AutomationPanel-YTIZ74RI.mjs.map +7 -0
- package/dist/lib/node-esm/ChatContainer-QSMDZRDU.mjs +13 -0
- package/dist/lib/node-esm/ChatContainer-QSMDZRDU.mjs.map +7 -0
- package/dist/lib/node-esm/{ai-client-2GBZRHBA.mjs → ai-client-RUCCJ7JZ.mjs} +4 -4
- package/dist/lib/node-esm/{ai-client-2GBZRHBA.mjs.map → ai-client-RUCCJ7JZ.mjs.map} +3 -3
- package/dist/lib/node-esm/{app-graph-builder-5N7OK23B.mjs → app-graph-builder-GR3URVNX.mjs} +33 -2
- package/dist/lib/node-esm/{app-graph-builder-5N7OK23B.mjs.map → app-graph-builder-GR3URVNX.mjs.map} +3 -3
- package/dist/lib/node-esm/chunk-7JO77AAS.mjs +151 -0
- package/dist/lib/node-esm/chunk-7JO77AAS.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-5QUXIXNB.mjs → chunk-CQPQXIJP.mjs} +66 -8
- package/dist/lib/node-esm/{chunk-5QUXIXNB.mjs.map → chunk-CQPQXIJP.mjs.map} +4 -4
- package/dist/lib/node-esm/chunk-CZXU4CFK.mjs +244 -0
- package/dist/lib/node-esm/chunk-CZXU4CFK.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-D7RARVTS.mjs +1603 -0
- package/dist/lib/node-esm/chunk-D7RARVTS.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-X3LPRWIL.mjs → chunk-JFHI22MF.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-X3LPRWIL.mjs.map → chunk-JFHI22MF.mjs.map} +2 -2
- package/dist/lib/node-esm/{chunk-ISYLEDVU.mjs → chunk-LSSWQIQD.mjs} +2 -2
- package/dist/lib/node-esm/index.mjs +52 -45
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/intent-resolver-FCKNRTKQ.mjs +30 -0
- package/dist/lib/node-esm/intent-resolver-FCKNRTKQ.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-77S6XJOM.mjs → react-surface-Y5LQHUQN.mjs} +24 -23
- package/dist/lib/node-esm/react-surface-Y5LQHUQN.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +10 -4
- package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
- package/dist/types/src/artifacts.stories.d.ts +10 -24
- package/dist/types/src/artifacts.stories.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +22 -22
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +27 -27
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/Box/StatusLine.d.ts +11 -0
- package/dist/types/src/components/Box/StatusLine.d.ts.map +1 -0
- package/dist/types/src/components/Box/StatusLine.stories.d.ts +9 -0
- package/dist/types/src/components/Box/StatusLine.stories.d.ts.map +1 -0
- package/dist/types/src/components/Box/Tabbed.d.ts +15 -0
- package/dist/types/src/components/Box/Tabbed.d.ts.map +1 -0
- package/dist/types/src/components/Box/Tabbed.stories.d.ts +8 -0
- package/dist/types/src/components/Box/Tabbed.stories.d.ts.map +1 -0
- package/dist/types/src/components/Box/ToggleContainer.d.ts +13 -0
- package/dist/types/src/components/Box/ToggleContainer.d.ts.map +1 -0
- package/dist/types/src/components/Box/ToggleContainer.stories.d.ts +9 -0
- package/dist/types/src/components/Box/ToggleContainer.stories.d.ts.map +1 -0
- package/dist/types/src/components/Box/index.d.ts +4 -0
- package/dist/types/src/components/Box/index.d.ts.map +1 -0
- package/dist/types/src/components/ChatContainer/ChatContainer.d.ts +7 -0
- package/dist/types/src/components/ChatContainer/ChatContainer.d.ts.map +1 -0
- package/dist/types/src/components/ChatContainer/index.d.ts +4 -0
- package/dist/types/src/components/ChatContainer/index.d.ts.map +1 -0
- package/dist/types/src/components/MarkdownViewer/MarkdownViewer.d.ts +14 -0
- package/dist/types/src/components/MarkdownViewer/MarkdownViewer.d.ts.map +1 -0
- package/dist/types/src/components/MarkdownViewer/MarkdownViewer.stories.d.ts +8 -0
- package/dist/types/src/components/MarkdownViewer/MarkdownViewer.stories.d.ts.map +1 -0
- package/dist/types/src/components/MarkdownViewer/index.d.ts +2 -0
- package/dist/types/src/components/MarkdownViewer/index.d.ts.map +1 -0
- package/dist/types/src/components/Prompt/Prompt.d.ts +7 -0
- package/dist/types/src/components/Prompt/Prompt.d.ts.map +1 -0
- package/dist/types/src/components/Prompt/Prompt.stories.d.ts +8 -0
- package/dist/types/src/components/Prompt/Prompt.stories.d.ts.map +1 -0
- package/dist/types/src/components/Prompt/index.d.ts +2 -0
- package/dist/types/src/components/Prompt/index.d.ts.map +1 -0
- package/dist/types/src/components/Prompt/prompt-autocomplete.d.ts +20 -0
- package/dist/types/src/components/Prompt/prompt-autocomplete.d.ts.map +1 -0
- package/dist/types/src/components/ServiceRegistry/ServiceRegistry.d.ts +6 -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/Thread/Thread.d.ts +6 -9
- package/dist/types/src/components/Thread/Thread.d.ts.map +1 -1
- package/dist/types/src/components/Thread/Thread.stories.d.ts +3 -4
- package/dist/types/src/components/Thread/Thread.stories.d.ts.map +1 -1
- package/dist/types/src/components/Thread/ThreadMessage.d.ts +12 -0
- package/dist/types/src/components/Thread/ThreadMessage.d.ts.map +1 -0
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +5 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +3 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/processor.d.ts +39 -15
- package/dist/types/src/hooks/processor.d.ts.map +1 -1
- package/dist/types/src/hooks/useChatProcessor.d.ts +7 -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/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} +1 -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 +12 -6
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/index.d.ts +1 -0
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/registry.d.ts +10 -0
- package/dist/types/src/types/registry.d.ts.map +1 -0
- package/dist/types/src/types/schema.d.ts +156 -7
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +2 -2
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +56 -49
- package/src/AutomationPlugin.tsx +18 -26
- package/src/artifacts.stories.tsx +126 -65
- package/src/capabilities/ai-client.ts +1 -1
- package/src/capabilities/app-graph-builder.ts +31 -2
- package/src/capabilities/intent-resolver.ts +14 -9
- package/src/capabilities/react-surface.tsx +14 -12
- package/src/components/Box/StatusLine.stories.tsx +52 -0
- package/src/components/Box/StatusLine.tsx +76 -0
- package/src/components/Box/Tabbed.stories.tsx +51 -0
- package/src/components/Box/Tabbed.tsx +89 -0
- package/src/components/Box/ToggleContainer.stories.tsx +110 -0
- package/src/components/Box/ToggleContainer.tsx +108 -0
- package/src/components/Box/index.ts +7 -0
- package/src/components/ChatContainer/ChatContainer.tsx +52 -0
- package/src/components/ChatContainer/index.ts +8 -0
- package/src/components/MarkdownViewer/MarkdownViewer.stories.tsx +56 -0
- package/src/components/MarkdownViewer/MarkdownViewer.tsx +79 -0
- package/src/components/MarkdownViewer/index.ts +5 -0
- package/src/components/Prompt/Prompt.stories.tsx +50 -0
- package/src/components/Prompt/Prompt.tsx +36 -0
- package/src/components/Prompt/index.ts +5 -0
- package/src/components/Prompt/prompt-autocomplete.ts +200 -0
- package/src/components/PromptEditor/PromptEditor.stories.tsx +3 -3
- package/src/components/ServiceRegistry/ServiceRegistry.stories.tsx +49 -0
- package/src/components/ServiceRegistry/ServiceRegistry.tsx +75 -0
- package/src/components/ServiceRegistry/index.ts +5 -0
- package/src/components/Thread/Thread.stories.tsx +152 -97
- package/src/components/Thread/Thread.tsx +115 -108
- package/src/components/Thread/ThreadMessage.tsx +225 -0
- package/src/components/TriggerEditor/TriggerEditor.tsx +8 -5
- package/src/components/index.ts +4 -1
- package/src/hooks/index.ts +4 -0
- package/src/hooks/processor.ts +114 -65
- package/src/hooks/useChatProcessor.tsx +86 -0
- package/src/hooks/useMessageQueue.ts +23 -0
- package/src/hooks/useServices.ts +28 -0
- package/src/meta.ts +2 -1
- package/src/testing/index.ts +2 -1
- 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 +227 -0
- package/src/tools/openapi.ts +331 -0
- package/src/translations.ts +9 -6
- package/src/types/index.ts +1 -0
- package/src/types/registry.ts +26 -0
- package/src/types/schema.ts +90 -3
- package/src/types/types.ts +2 -2
- package/dist/lib/browser/AssistantPanel-KO6DZBTU.mjs +0 -340
- package/dist/lib/browser/AssistantPanel-KO6DZBTU.mjs.map +0 -7
- package/dist/lib/browser/AutomationPanel-BMLM533Z.mjs +0 -131
- package/dist/lib/browser/AutomationPanel-BMLM533Z.mjs.map +0 -7
- package/dist/lib/browser/ChatContainer-SIAJFRFF.mjs +0 -300
- package/dist/lib/browser/ChatContainer-SIAJFRFF.mjs.map +0 -7
- package/dist/lib/browser/chunk-C3VRGDR6.mjs +0 -75
- package/dist/lib/browser/chunk-C3VRGDR6.mjs.map +0 -7
- package/dist/lib/browser/chunk-JSNPW6JF.mjs +0 -14
- package/dist/lib/browser/chunk-JSNPW6JF.mjs.map +0 -7
- package/dist/lib/browser/chunk-KPSDH6XZ.mjs +0 -118
- package/dist/lib/browser/chunk-KPSDH6XZ.mjs.map +0 -7
- package/dist/lib/browser/chunk-YZF3SDZL.mjs +0 -139
- package/dist/lib/browser/chunk-YZF3SDZL.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-AHDQ3KQP.mjs +0 -24
- package/dist/lib/browser/intent-resolver-AHDQ3KQP.mjs.map +0 -7
- package/dist/lib/browser/react-surface-IGMBLSV7.mjs.map +0 -7
- package/dist/lib/node/AssistantPanel-PPFS2HKK.cjs +0 -360
- package/dist/lib/node/AssistantPanel-PPFS2HKK.cjs.map +0 -7
- package/dist/lib/node/AutomationPanel-RXJDVLCF.cjs.map +0 -7
- package/dist/lib/node/ChatContainer-GS2SC5OG.cjs +0 -318
- package/dist/lib/node/ChatContainer-GS2SC5OG.cjs.map +0 -7
- package/dist/lib/node/chunk-BUQOZA4N.cjs.map +0 -7
- package/dist/lib/node/chunk-DNLBVFR7.cjs +0 -147
- package/dist/lib/node/chunk-DNLBVFR7.cjs.map +0 -7
- package/dist/lib/node/chunk-TWDGP26W.cjs +0 -172
- package/dist/lib/node/chunk-TWDGP26W.cjs.map +0 -7
- package/dist/lib/node/chunk-VEGLN4YN.cjs.map +0 -7
- package/dist/lib/node/chunk-Z2YFE5SJ.cjs +0 -49
- package/dist/lib/node/chunk-Z2YFE5SJ.cjs.map +0 -7
- package/dist/lib/node/intent-resolver-TBHYXBDI.cjs.map +0 -7
- package/dist/lib/node/react-surface-BVUZMKYS.cjs.map +0 -7
- package/dist/lib/node-esm/AssistantPanel-XSSKKCJY.mjs +0 -341
- package/dist/lib/node-esm/AssistantPanel-XSSKKCJY.mjs.map +0 -7
- package/dist/lib/node-esm/AutomationPanel-GQZZ4UBI.mjs +0 -132
- package/dist/lib/node-esm/AutomationPanel-GQZZ4UBI.mjs.map +0 -7
- package/dist/lib/node-esm/ChatContainer-57ILGC3R.mjs +0 -301
- package/dist/lib/node-esm/ChatContainer-57ILGC3R.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-ICHNUP5M.mjs +0 -119
- package/dist/lib/node-esm/chunk-ICHNUP5M.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JCYVS5GG.mjs +0 -76
- package/dist/lib/node-esm/chunk-JCYVS5GG.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-L2B6VGMG.mjs +0 -16
- package/dist/lib/node-esm/chunk-L2B6VGMG.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-U7HXYMPZ.mjs +0 -141
- package/dist/lib/node-esm/chunk-U7HXYMPZ.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-DPJJHFGK.mjs +0 -25
- package/dist/lib/node-esm/intent-resolver-DPJJHFGK.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-77S6XJOM.mjs.map +0 -7
- 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/ChatContainer.d.ts +0 -8
- package/dist/types/src/components/ChatContainer.d.ts.map +0 -1
- package/dist/types/src/testing/testing.d.ts.map +0 -1
- package/src/components/AssistantPanel/AssistantPanel.tsx +0 -232
- package/src/components/AssistantPanel/index.ts +0 -7
- package/src/components/AssistantPanel/system-instructions.ts +0 -166
- package/src/components/ChatContainer.tsx +0 -80
- /package/dist/lib/browser/{chunk-HZ4TA7HY.mjs.map → chunk-BQHXJZ4K.mjs.map} +0 -0
- /package/dist/lib/node/{chunk-ZS5RZ7RM.cjs.map → chunk-AWZVJZ2I.cjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-ISYLEDVU.mjs.map → chunk-LSSWQIQD.mjs.map} +0 -0
- /package/src/testing/{testing.ts → test-functions.ts} +0 -0
package/src/hooks/processor.ts
CHANGED
|
@@ -2,27 +2,23 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type
|
|
5
|
+
import { type Signal, batch, computed, signal } from '@preact/signals-core';
|
|
6
6
|
|
|
7
7
|
import { type PromiseIntentDispatcher } from '@dxos/app-framework';
|
|
8
|
-
import { type Tool, Message } from '@dxos/artifact';
|
|
8
|
+
import { type Tool, Message, type MessageContentBlock } from '@dxos/artifact';
|
|
9
9
|
import {
|
|
10
|
+
isToolUse,
|
|
11
|
+
runTools,
|
|
10
12
|
type AIServiceClientImpl,
|
|
11
13
|
type GenerateRequest,
|
|
12
14
|
type GenerationStream,
|
|
13
|
-
|
|
14
|
-
runTools,
|
|
15
|
+
MixedStreamParser,
|
|
15
16
|
} from '@dxos/assistant';
|
|
16
17
|
import { createStatic } from '@dxos/echo-schema';
|
|
17
18
|
import { invariant } from '@dxos/invariant';
|
|
18
19
|
import { log } from '@dxos/log';
|
|
19
20
|
import { type Space } from '@dxos/react-client/echo';
|
|
20
21
|
|
|
21
|
-
const defaultOptions: Pick<GenerateRequest, 'model' | 'systemPrompt'> = {
|
|
22
|
-
model: '@anthropic/claude-3-5-sonnet-20241022',
|
|
23
|
-
systemPrompt: '',
|
|
24
|
-
};
|
|
25
|
-
|
|
26
22
|
// TODO(burdon): Factor out.
|
|
27
23
|
declare global {
|
|
28
24
|
interface ToolContextExtensions {
|
|
@@ -31,56 +27,109 @@ declare global {
|
|
|
31
27
|
}
|
|
32
28
|
}
|
|
33
29
|
|
|
30
|
+
type RequestOptions = {
|
|
31
|
+
history?: Message[];
|
|
32
|
+
onComplete?: (messages: Message[]) => void;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type ChatProcessorOptions = Pick<GenerateRequest, 'model' | 'systemPrompt'>;
|
|
36
|
+
|
|
37
|
+
const defaultOptions: ChatProcessorOptions = {
|
|
38
|
+
model: '@anthropic/claude-3-5-sonnet-20241022',
|
|
39
|
+
systemPrompt: 'you are a helpful assistant',
|
|
40
|
+
};
|
|
41
|
+
|
|
34
42
|
/**
|
|
35
|
-
* Handles interactions with
|
|
36
|
-
* Manages message history, and executes tools based on AI responses.
|
|
43
|
+
* Handles interactions with the AI service.
|
|
37
44
|
* Maintains a queue of messages and handles streaming responses from the AI service.
|
|
45
|
+
* Executes tools based on AI responses.
|
|
38
46
|
* Supports cancellation of in-progress requests.
|
|
39
47
|
*/
|
|
40
|
-
// TODO(burdon): Tests.
|
|
41
48
|
export class ChatProcessor {
|
|
49
|
+
/** SSE stream parser. */
|
|
50
|
+
private readonly _parser = new MixedStreamParser();
|
|
51
|
+
|
|
52
|
+
/** Current streaming response (iterator). */
|
|
53
|
+
private _stream: GenerationStream | undefined;
|
|
54
|
+
|
|
55
|
+
/** Pending messages (incl. the user request). */
|
|
56
|
+
private readonly _pending: Signal<Message[]> = signal([]);
|
|
57
|
+
|
|
58
|
+
/** Current streaming block (from the AI service). */
|
|
59
|
+
private readonly _block: Signal<MessageContentBlock | undefined> = signal(undefined);
|
|
60
|
+
|
|
42
61
|
/** Prior history from queue. */
|
|
43
62
|
private _history: Message[] = [];
|
|
44
63
|
|
|
45
|
-
/**
|
|
46
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Streaming state.
|
|
66
|
+
* @reactive
|
|
67
|
+
*/
|
|
68
|
+
public readonly streaming: Signal<boolean> = computed(() => this._block.value !== undefined);
|
|
47
69
|
|
|
48
|
-
/**
|
|
49
|
-
|
|
70
|
+
/**
|
|
71
|
+
* Array of Messages (incl. the current message being streamed).
|
|
72
|
+
* @reactive
|
|
73
|
+
*/
|
|
74
|
+
public readonly messages: Signal<Message[]> = computed(() => {
|
|
75
|
+
const messages = [...this._pending.value];
|
|
76
|
+
if (this._block.value) {
|
|
77
|
+
const current = messages.pop();
|
|
78
|
+
invariant(current);
|
|
79
|
+
const { content, ...rest } = current;
|
|
80
|
+
const message = { ...rest, content: [...content, this._block.value] };
|
|
81
|
+
messages.push(message);
|
|
82
|
+
}
|
|
50
83
|
|
|
51
|
-
|
|
52
|
-
|
|
84
|
+
return messages;
|
|
85
|
+
});
|
|
53
86
|
|
|
54
87
|
constructor(
|
|
55
88
|
private readonly _client: AIServiceClientImpl,
|
|
56
|
-
private
|
|
89
|
+
private _tools?: Tool[],
|
|
57
90
|
private readonly _extensions?: ToolContextExtensions,
|
|
58
|
-
private readonly _options:
|
|
59
|
-
) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
91
|
+
private readonly _options: ChatProcessorOptions = defaultOptions,
|
|
92
|
+
) {
|
|
93
|
+
// Message complete.
|
|
94
|
+
this._parser.message.on((message) => {
|
|
95
|
+
batch(() => {
|
|
96
|
+
this._pending.value = [...this._pending.value, message];
|
|
97
|
+
this._block.value = undefined;
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
// Streaming update (happens before message complete).
|
|
102
|
+
this._parser.update.on((block) => {
|
|
103
|
+
batch(() => {
|
|
104
|
+
this._block.value = block;
|
|
105
|
+
});
|
|
106
|
+
});
|
|
63
107
|
}
|
|
64
108
|
|
|
65
|
-
|
|
66
|
-
|
|
109
|
+
/**
|
|
110
|
+
* Update tools.
|
|
111
|
+
*/
|
|
112
|
+
setTools(tools: Tool[]) {
|
|
113
|
+
this._tools = tools;
|
|
67
114
|
}
|
|
68
115
|
|
|
69
116
|
/**
|
|
70
117
|
* Make GPT request.
|
|
71
118
|
*/
|
|
72
|
-
async request(message: string,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
119
|
+
async request(message: string, options: RequestOptions = {}): Promise<Message[]> {
|
|
120
|
+
batch(() => {
|
|
121
|
+
this._history = options.history ?? [];
|
|
122
|
+
this._pending.value = [
|
|
123
|
+
createStatic(Message, {
|
|
124
|
+
role: 'user',
|
|
125
|
+
content: [{ type: 'text', text: message }],
|
|
126
|
+
}),
|
|
127
|
+
];
|
|
128
|
+
this._block.value = undefined;
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
await this._generate();
|
|
132
|
+
options.onComplete?.(this._pending.value);
|
|
84
133
|
return this._reset();
|
|
85
134
|
}
|
|
86
135
|
|
|
@@ -90,51 +139,52 @@ export class ChatProcessor {
|
|
|
90
139
|
*/
|
|
91
140
|
async cancel(): Promise<Message[]> {
|
|
92
141
|
log.info('cancelling...');
|
|
93
|
-
this.
|
|
142
|
+
this._stream?.abort();
|
|
94
143
|
return this._reset();
|
|
95
144
|
}
|
|
96
145
|
|
|
97
146
|
private async _reset(): Promise<Message[]> {
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
147
|
+
const messages = this._pending.value;
|
|
148
|
+
batch(() => {
|
|
149
|
+
this._history = [];
|
|
150
|
+
this._pending.value = [];
|
|
151
|
+
this._block.value = undefined;
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
return messages;
|
|
103
155
|
}
|
|
104
156
|
|
|
105
|
-
|
|
157
|
+
/**
|
|
158
|
+
* Generate a response from the AI service.
|
|
159
|
+
* Iterates over tool requests.
|
|
160
|
+
*/
|
|
161
|
+
private async _generate() {
|
|
106
162
|
try {
|
|
107
163
|
let more = false;
|
|
108
164
|
do {
|
|
109
|
-
log.info('requesting...', { history: this._history.length,
|
|
110
|
-
this.
|
|
165
|
+
log.info('requesting...', { history: this._history.length, messages: this._pending.value.length });
|
|
166
|
+
this._stream = await this._client.generate({
|
|
111
167
|
...this._options,
|
|
112
168
|
// TODO(burdon): Rename messages or separate history/message.
|
|
113
169
|
history: [...this._history, ...this._pending.value],
|
|
114
170
|
tools: this._tools,
|
|
115
171
|
});
|
|
116
172
|
|
|
117
|
-
//
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
for await (const event of this._response) {
|
|
121
|
-
log.info('event', { event: event.type });
|
|
122
|
-
this._streaming.value = this._response.accumulatedMessages.map((message) => createStatic(Message, message));
|
|
123
|
-
}
|
|
124
|
-
});
|
|
173
|
+
// Wait until complete.
|
|
174
|
+
await this._parser.parse(this._stream);
|
|
175
|
+
await this._stream.complete();
|
|
125
176
|
|
|
126
|
-
//
|
|
127
|
-
|
|
128
|
-
log.info('response', { messages: messages.length });
|
|
129
|
-
this._pending.value.push(...messages.map((message) => createStatic(Message, message)));
|
|
130
|
-
this._streaming.value = [];
|
|
177
|
+
// Add messages.
|
|
178
|
+
log.info('response', { messages: this._pending.value });
|
|
131
179
|
|
|
132
180
|
// Resolve tool use locally.
|
|
133
181
|
more = false;
|
|
134
|
-
|
|
182
|
+
const message = this._pending.value.at(-1);
|
|
183
|
+
invariant(message);
|
|
184
|
+
if (isToolUse(message)) {
|
|
135
185
|
log.info('tool request...');
|
|
136
186
|
const response = await runTools({
|
|
137
|
-
message:
|
|
187
|
+
message: this._pending.value.at(-1)!,
|
|
138
188
|
tools: this._tools ?? [],
|
|
139
189
|
extensions: this._extensions,
|
|
140
190
|
});
|
|
@@ -142,7 +192,7 @@ export class ChatProcessor {
|
|
|
142
192
|
log.info('tool response', { response });
|
|
143
193
|
switch (response.type) {
|
|
144
194
|
case 'continue': {
|
|
145
|
-
this._pending.value.
|
|
195
|
+
this._pending.value = [...this._pending.value, response.message];
|
|
146
196
|
more = true;
|
|
147
197
|
break;
|
|
148
198
|
}
|
|
@@ -154,8 +204,7 @@ export class ChatProcessor {
|
|
|
154
204
|
log.catch('request failed', { err });
|
|
155
205
|
} finally {
|
|
156
206
|
log.info('done');
|
|
157
|
-
this.
|
|
158
|
-
this._streaming.value = [];
|
|
207
|
+
this._stream = undefined;
|
|
159
208
|
}
|
|
160
209
|
}
|
|
161
210
|
}
|
|
@@ -0,0 +1,86 @@
|
|
|
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 { FunctionType } from '@dxos/functions';
|
|
10
|
+
import { useConfig } from '@dxos/react-client';
|
|
11
|
+
import { Filter, getSpace, useQuery } from '@dxos/react-client/echo';
|
|
12
|
+
import { isNotNullOrUndefined } from '@dxos/util';
|
|
13
|
+
|
|
14
|
+
import { AutomationCapabilities } from '../capabilities';
|
|
15
|
+
import { ChatProcessor } from '../hooks';
|
|
16
|
+
import { covertFunctionToTool, createToolsFromService } from '../tools';
|
|
17
|
+
import { ServiceType, type AIChatType } from '../types';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Creates a processor for the chat.
|
|
21
|
+
*/
|
|
22
|
+
export const useChatProcessor = (chat: AIChatType) => {
|
|
23
|
+
const aiClient = useCapability(AutomationCapabilities.AiClient);
|
|
24
|
+
const globalTools = useCapabilities(Capabilities.Tools);
|
|
25
|
+
const artifactDefinitions = useCapabilities(Capabilities.ArtifactDefinition);
|
|
26
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
27
|
+
const space = getSpace(chat);
|
|
28
|
+
|
|
29
|
+
// Services.
|
|
30
|
+
const services = useQuery(space, Filter.schema(ServiceType));
|
|
31
|
+
const [serviceTools, setServiceTools] = useState<Tool[]>([]);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
queueMicrotask(async () => {
|
|
34
|
+
const tools = await Promise.all(services.map((service) => createToolsFromService(service)));
|
|
35
|
+
setServiceTools(tools.flat());
|
|
36
|
+
});
|
|
37
|
+
}, [services]);
|
|
38
|
+
|
|
39
|
+
// Tools.
|
|
40
|
+
const config = useConfig();
|
|
41
|
+
const functions = useQuery(space, Filter.schema(FunctionType));
|
|
42
|
+
const tools = useMemo(
|
|
43
|
+
() => [
|
|
44
|
+
...globalTools.flat(),
|
|
45
|
+
...artifactDefinitions.flatMap((definition) => definition.tools),
|
|
46
|
+
...serviceTools,
|
|
47
|
+
...functions
|
|
48
|
+
.map((fn) => covertFunctionToTool(fn, config.values.runtime?.services?.edge?.url ?? '', space?.id))
|
|
49
|
+
.filter(isNotNullOrUndefined),
|
|
50
|
+
],
|
|
51
|
+
[globalTools, artifactDefinitions, serviceTools, functions, space?.id],
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
// Prompt.
|
|
55
|
+
const systemPrompt = useMemo(
|
|
56
|
+
() => createSystemPrompt({ artifacts: artifactDefinitions.map((definition) => definition.instructions) }),
|
|
57
|
+
[artifactDefinitions],
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
// Create processor.
|
|
61
|
+
const processor = useMemo(
|
|
62
|
+
() =>
|
|
63
|
+
new ChatProcessor(
|
|
64
|
+
aiClient,
|
|
65
|
+
tools,
|
|
66
|
+
{
|
|
67
|
+
space,
|
|
68
|
+
dispatch,
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
model: '@anthropic/claude-3-5-sonnet-20241022',
|
|
72
|
+
systemPrompt,
|
|
73
|
+
},
|
|
74
|
+
),
|
|
75
|
+
[aiClient, tools, space, dispatch, systemPrompt],
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
// Update processor.
|
|
79
|
+
// useEffect(() => {
|
|
80
|
+
// if (processor) {
|
|
81
|
+
// processor.setTools(tools.flat());
|
|
82
|
+
// }
|
|
83
|
+
// }, [processor, tools]);
|
|
84
|
+
|
|
85
|
+
return processor;
|
|
86
|
+
};
|
|
@@ -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 edgeClient = useEdgeClient();
|
|
16
|
+
const space = getSpace(chat);
|
|
17
|
+
const queueDxn = useMemo(
|
|
18
|
+
() => new DXN(DXN.kind.QUEUE, [QueueSubspaceTags.DATA, space!.id, chat.queue.dxn.parts.at(-1)!]),
|
|
19
|
+
[chat.queue.dxn],
|
|
20
|
+
);
|
|
21
|
+
|
|
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
|
+
};
|
package/src/meta.ts
CHANGED
|
@@ -9,7 +9,8 @@ export const AUTOMATION_PLUGIN = 'dxos.org/plugin/automation';
|
|
|
9
9
|
export const meta = {
|
|
10
10
|
id: AUTOMATION_PLUGIN,
|
|
11
11
|
name: 'Automation',
|
|
12
|
-
description:
|
|
12
|
+
description:
|
|
13
|
+
'The Automation tab allows you to trigger pre-defined workflows related to the element you are interacting with inside of Composer.',
|
|
13
14
|
icon: 'ph--magic-wand--regular',
|
|
14
15
|
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/experimental/plugin-automation',
|
|
15
16
|
tags: ['experimental'],
|
package/src/testing/index.ts
CHANGED
|
@@ -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
|
+
};
|