@dxos/plugin-automation 0.7.4 → 0.7.5-labs.071a3e2
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-YPD3AGQN.mjs +8 -0
- package/dist/lib/browser/ChatContainer-ODZECATM.mjs +12 -0
- package/dist/lib/browser/ai-client-UJLNYP7B.mjs +22 -0
- package/dist/lib/browser/ai-client-UJLNYP7B.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-3H5TCRG4.mjs +162 -0
- package/dist/lib/browser/app-graph-builder-3H5TCRG4.mjs.map +7 -0
- package/dist/lib/browser/chunk-43WRHV2L.mjs +150 -0
- package/dist/lib/browser/chunk-43WRHV2L.mjs.map +7 -0
- package/dist/lib/browser/chunk-BQHXJZ4K.mjs +15 -0
- package/dist/lib/browser/chunk-BQHXJZ4K.mjs.map +7 -0
- package/dist/lib/browser/chunk-DL7XA62G.mjs +1531 -0
- package/dist/lib/browser/chunk-DL7XA62G.mjs.map +7 -0
- package/dist/lib/browser/{chunk-X5KMOH3I.mjs → chunk-DQ7ZSYJJ.mjs} +4 -4
- package/dist/lib/browser/chunk-DQ7ZSYJJ.mjs.map +7 -0
- package/dist/lib/browser/chunk-PQGFC2ZO.mjs +284 -0
- package/dist/lib/browser/chunk-PQGFC2ZO.mjs.map +7 -0
- package/dist/lib/browser/chunk-Z54KIF6H.mjs +242 -0
- package/dist/lib/browser/chunk-Z54KIF6H.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +152 -252
- package/dist/lib/browser/index.mjs.map +4 -4
- 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-WRHRCEV5.mjs +50 -0
- package/dist/lib/browser/react-surface-WRHRCEV5.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +12 -3
- package/dist/lib/node/{meta.cjs → AutomationPanel-CO26O75P.cjs} +7 -11
- package/dist/lib/node/AutomationPanel-CO26O75P.cjs.map +7 -0
- package/dist/lib/node/ChatContainer-5URBEXQD.cjs +33 -0
- package/dist/lib/node/ChatContainer-5URBEXQD.cjs.map +7 -0
- package/dist/lib/node/ai-client-AOB6TLNW.cjs +38 -0
- package/dist/lib/node/ai-client-AOB6TLNW.cjs.map +7 -0
- package/dist/lib/node/app-graph-builder-CDEQJEHY.cjs +178 -0
- package/dist/lib/node/app-graph-builder-CDEQJEHY.cjs.map +7 -0
- package/dist/lib/node/chunk-AWZVJZ2I.cjs +34 -0
- package/dist/lib/node/chunk-AWZVJZ2I.cjs.map +7 -0
- package/dist/lib/node/chunk-D2QQXWOY.cjs +302 -0
- package/dist/lib/node/chunk-D2QQXWOY.cjs.map +7 -0
- package/dist/lib/node/chunk-H3RSMGJG.cjs +173 -0
- package/dist/lib/node/chunk-H3RSMGJG.cjs.map +7 -0
- package/dist/lib/node/chunk-NH7STAX6.cjs +1515 -0
- package/dist/lib/node/chunk-NH7STAX6.cjs.map +7 -0
- package/dist/lib/node/chunk-OCW5GAVZ.cjs +266 -0
- package/dist/lib/node/chunk-OCW5GAVZ.cjs.map +7 -0
- package/dist/lib/node/{chunk-DTJ7XVO2.cjs → chunk-TQEDPRY5.cjs} +8 -8
- package/dist/lib/node/chunk-TQEDPRY5.cjs.map +7 -0
- package/dist/lib/node/index.cjs +169 -282
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/intent-resolver-MJFZT5IU.cjs +44 -0
- 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-HDAVE6NU.cjs +70 -0
- package/dist/lib/node/react-surface-HDAVE6NU.cjs.map +7 -0
- package/dist/lib/node/types/index.cjs +16 -7
- package/dist/lib/node/types/index.cjs.map +2 -2
- package/dist/lib/node-esm/AutomationPanel-VQZUKPK2.mjs +9 -0
- package/dist/lib/node-esm/AutomationPanel-VQZUKPK2.mjs.map +7 -0
- package/dist/lib/node-esm/ChatContainer-23QIVDG5.mjs +13 -0
- package/dist/lib/node-esm/ChatContainer-23QIVDG5.mjs.map +7 -0
- package/dist/lib/node-esm/ai-client-RUCCJ7JZ.mjs +23 -0
- package/dist/lib/node-esm/ai-client-RUCCJ7JZ.mjs.map +7 -0
- package/dist/lib/node-esm/app-graph-builder-GR3URVNX.mjs +163 -0
- package/dist/lib/node-esm/app-graph-builder-GR3URVNX.mjs.map +7 -0
- 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-HNOBZHWK.mjs → chunk-JFHI22MF.mjs} +4 -4
- package/dist/lib/node-esm/chunk-JFHI22MF.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-JJFWFS6P.mjs +1532 -0
- package/dist/lib/node-esm/chunk-JJFWFS6P.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-LSSWQIQD.mjs +16 -0
- package/dist/lib/node-esm/chunk-LSSWQIQD.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-NSVQZ3EH.mjs +243 -0
- package/dist/lib/node-esm/chunk-NSVQZ3EH.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-VN2AFV25.mjs +285 -0
- package/dist/lib/node-esm/chunk-VN2AFV25.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +152 -252
- package/dist/lib/node-esm/index.mjs.map +4 -4
- 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-FZ5OFRDE.mjs +51 -0
- package/dist/lib/node-esm/react-surface-FZ5OFRDE.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +12 -3
- package/dist/types/src/AutomationPlugin.d.ts +1 -3
- package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
- package/dist/types/src/artifacts.stories.d.ts +16 -0
- package/dist/types/src/artifacts.stories.d.ts.map +1 -0
- 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 +180 -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 +182 -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/components/AutomationPanel/AutomationPanel.d.ts +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts.map +1 -1
- package/dist/types/src/components/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/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/ScrollContainer.d.ts +15 -0
- package/dist/types/src/components/Thread/ScrollContainer.d.ts.map +1 -0
- package/dist/types/src/components/Thread/StatusLine.d.ts +11 -0
- package/dist/types/src/components/Thread/StatusLine.d.ts.map +1 -0
- package/dist/types/src/components/Thread/StatusLine.stories.d.ts +9 -0
- package/dist/types/src/components/Thread/StatusLine.stories.d.ts.map +1 -0
- package/dist/types/src/components/Thread/Tabbed.d.ts +9 -0
- package/dist/types/src/components/Thread/Tabbed.d.ts.map +1 -0
- package/dist/types/src/components/Thread/Tabbed.stories.d.ts +8 -0
- package/dist/types/src/components/Thread/Tabbed.stories.d.ts.map +1 -0
- package/dist/types/src/components/Thread/Thread.d.ts +11 -0
- package/dist/types/src/components/Thread/Thread.d.ts.map +1 -0
- package/dist/types/src/components/Thread/Thread.stories.d.ts +10 -0
- package/dist/types/src/components/Thread/Thread.stories.d.ts.map +1 -0
- 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/Thread/ToggleContainer.d.ts +13 -0
- package/dist/types/src/components/Thread/ToggleContainer.d.ts.map +1 -0
- package/dist/types/src/components/Thread/ToggleContainer.stories.d.ts +9 -0
- package/dist/types/src/components/Thread/ToggleContainer.stories.d.ts.map +1 -0
- package/dist/types/src/components/Thread/index.d.ts +2 -0
- package/dist/types/src/components/Thread/index.d.ts.map +1 -0
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +1 -2
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +12 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/email.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +4 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/invocation-handler.d.ts.map +1 -1
- package/dist/types/src/hooks/processor.d.ts +70 -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 +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/index.d.ts +1 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +1 -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 +81 -2
- 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 +189 -39
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +16 -5
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +54 -48
- package/src/AutomationPlugin.tsx +77 -194
- package/src/artifacts.stories.tsx +241 -0
- package/src/capabilities/ai-client.ts +19 -0
- package/src/capabilities/app-graph-builder.ts +156 -0
- package/src/capabilities/capabilities.ts +12 -0
- package/src/capabilities/index.ts +12 -0
- package/src/capabilities/intent-resolver.ts +27 -0
- package/src/capabilities/react-surface.tsx +36 -0
- package/src/components/AutomationPanel/AutomationPanel.stories.tsx +1 -2
- package/src/components/AutomationPanel/AutomationPanel.tsx +61 -39
- 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/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/ScrollContainer.tsx +92 -0
- package/src/components/Thread/StatusLine.stories.tsx +52 -0
- package/src/components/Thread/StatusLine.tsx +76 -0
- package/src/components/Thread/Tabbed.stories.tsx +52 -0
- package/src/components/Thread/Tabbed.tsx +72 -0
- package/src/components/Thread/Thread.stories.tsx +190 -0
- package/src/components/Thread/Thread.tsx +156 -0
- package/src/components/Thread/ThreadMessage.tsx +203 -0
- package/src/components/Thread/ToggleContainer.stories.tsx +111 -0
- package/src/components/Thread/ToggleContainer.tsx +103 -0
- package/src/components/Thread/index.ts +5 -0
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +1 -2
- package/src/components/TriggerEditor/TriggerEditor.tsx +81 -16
- package/src/components/index.ts +9 -1
- package/src/hooks/email.ts +2 -2
- package/src/hooks/index.ts +5 -0
- package/src/hooks/invocation-handler.ts +2 -2
- package/src/hooks/processor.test.ts +15 -0
- package/src/hooks/processor.ts +210 -0
- package/src/hooks/useChatProcessor.tsx +86 -0
- package/src/hooks/useMessageQueue.ts +23 -0
- package/src/hooks/useServices.ts +28 -0
- package/src/index.ts +1 -4
- package/src/meta.ts +3 -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 +227 -0
- package/src/tools/openapi.ts +331 -0
- package/src/translations.ts +17 -2
- package/src/types/index.ts +1 -0
- package/src/types/registry.ts +26 -0
- package/src/types/schema.ts +96 -2
- package/src/types/types.ts +15 -21
- package/dist/lib/browser/AssistantPanel-N3QSALKY.mjs +0 -341
- package/dist/lib/browser/AssistantPanel-N3QSALKY.mjs.map +0 -7
- package/dist/lib/browser/AutomationPanel-AQMN2CQR.mjs +0 -153
- package/dist/lib/browser/AutomationPanel-AQMN2CQR.mjs.map +0 -7
- package/dist/lib/browser/chunk-7KB4UMXO.mjs +0 -49
- package/dist/lib/browser/chunk-7KB4UMXO.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-RIA4TI3B.cjs +0 -361
- package/dist/lib/node/AssistantPanel-RIA4TI3B.cjs.map +0 -7
- package/dist/lib/node/AutomationPanel-HZS5WKI5.cjs +0 -173
- package/dist/lib/node/AutomationPanel-HZS5WKI5.cjs.map +0 -7
- package/dist/lib/node/chunk-CUCUWUAF.cjs +0 -73
- package/dist/lib/node/chunk-CUCUWUAF.cjs.map +0 -7
- package/dist/lib/node/chunk-DTJ7XVO2.cjs.map +0 -7
- package/dist/lib/node/meta.cjs.map +0 -7
- package/dist/lib/node-esm/AssistantPanel-72YH43CH.mjs +0 -342
- package/dist/lib/node-esm/AssistantPanel-72YH43CH.mjs.map +0 -7
- package/dist/lib/node-esm/AutomationPanel-JUHOWQWW.mjs +0 -154
- package/dist/lib/node-esm/AutomationPanel-JUHOWQWW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-23LY7DYS.mjs +0 -51
- package/dist/lib/node-esm/chunk-23LY7DYS.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/testing/testing.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/dist/lib/browser/{meta.mjs.map → AutomationPanel-YPD3AGQN.mjs.map} +0 -0
- /package/dist/lib/{node-esm/meta.mjs.map → browser/ChatContainer-ODZECATM.mjs.map} +0 -0
|
@@ -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,227 @@
|
|
|
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('openapi', () => {
|
|
16
|
+
describe('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
|
+
|
|
30
|
+
log.info('tools', { tools });
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('amadeus hotel name autocomplete', async () => {
|
|
34
|
+
const tools = await createToolsFromApi(HOTEL_NAME_AUTOCOMPLETE_API);
|
|
35
|
+
|
|
36
|
+
log.info('tools', { tools });
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test.only('weather', async () => {
|
|
40
|
+
const tools = await createToolsFromApi(WEATHER_API, { authorization: VISUAL_CROSSING_CREDENTIALS });
|
|
41
|
+
|
|
42
|
+
log.info('tools', { tools });
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
describe.skip('invoke tools', () => {
|
|
47
|
+
test('amadeus hotel name autocomplete', async () => {
|
|
48
|
+
const tools = await createToolsFromApi(HOTEL_NAME_AUTOCOMPLETE_API, { authorization: AMADEUS_AUTH });
|
|
49
|
+
|
|
50
|
+
const result = await tools[0].execute!({
|
|
51
|
+
keyword: 'William Vale Brooklyn',
|
|
52
|
+
subType: ['HOTEL_LEISURE', 'HOTEL_GDS'],
|
|
53
|
+
countryCode: 'US',
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
log.info('result', { result });
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('weather API', async () => {
|
|
60
|
+
const tools = await createToolsFromApi(WEATHER_API, { authorization: VISUAL_CROSSING_CREDENTIALS });
|
|
61
|
+
const forecastTool = tools.find((t) => t.name.includes('forecast'));
|
|
62
|
+
|
|
63
|
+
const result = await forecastTool?.execute!({
|
|
64
|
+
locations: 'Brooklyn, NY',
|
|
65
|
+
aggregateHours: '24',
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
log.info('result', { result });
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
describe.skip('AI uses tools', () => {
|
|
73
|
+
test('amadeus flight availabilities', { timeout: 60_000 }, async () => {
|
|
74
|
+
const tools = await createToolsFromApi(FLIGHT_SEARCH_API, {
|
|
75
|
+
authorization: AMADEUS_AUTH,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
const client = new AIServiceClientImpl({
|
|
79
|
+
endpoint: AI_SERVICE_ENDPOINT.LOCAL,
|
|
80
|
+
});
|
|
81
|
+
const processor = new ChatProcessor(client, tools);
|
|
82
|
+
const reply = await processor.request(
|
|
83
|
+
`What is the cheapest flight from New York to Paris? going on ${new Date().toISOString()} and returning after a week. 1 adult traveler`,
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
log.info('reply', { reply });
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// TODO(dmaretskyi): Doesn't work.
|
|
90
|
+
test('amadeus hotel name autocomplete', { timeout: 60_000 }, async () => {
|
|
91
|
+
const tools = await createToolsFromApi(HOTEL_NAME_AUTOCOMPLETE_API, { authorization: AMADEUS_AUTH });
|
|
92
|
+
|
|
93
|
+
const client = new AIServiceClientImpl({
|
|
94
|
+
endpoint: AI_SERVICE_ENDPOINT.LOCAL,
|
|
95
|
+
});
|
|
96
|
+
const processor = new ChatProcessor(client, tools);
|
|
97
|
+
const reply = await processor.request('Find me the William Wale in Brooklyn New York');
|
|
98
|
+
|
|
99
|
+
log.info('reply', { reply });
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
test.only('weather forecast', { timeout: 60_000 }, async () => {
|
|
103
|
+
const tools = await createToolsFromApi(WEATHER_API, {
|
|
104
|
+
authorization: VISUAL_CROSSING_CREDENTIALS,
|
|
105
|
+
instructions: WEATHER_INSTRUCTIONS,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const client = new AIServiceClientImpl({
|
|
109
|
+
endpoint: AI_SERVICE_ENDPOINT.LOCAL,
|
|
110
|
+
});
|
|
111
|
+
const processor = new ChatProcessor(client, tools);
|
|
112
|
+
const reply = await processor.request(
|
|
113
|
+
`Today's date is ${new Date().toISOString().split('T')[0]}. Give me weather forecast for Warsaw for next 5 days.`,
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
log.info('reply', { reply });
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
describe.skip('invoke api directly', { timeout: 10_000 }, () => {
|
|
121
|
+
test('amadeus flight availabilities', async () => {
|
|
122
|
+
const response = await fetch('https://test.api.amadeus.com/v1/shopping/availability/flight-availabilities', {
|
|
123
|
+
method: 'POST',
|
|
124
|
+
headers: {
|
|
125
|
+
accept: 'application/vnd.amadeus+json',
|
|
126
|
+
'X-HTTP-Method-Override': 'GET',
|
|
127
|
+
'Content-Type': 'application/vnd.amadeus+json',
|
|
128
|
+
Authorization: await resolveAuthorization(AMADEUS_AUTH),
|
|
129
|
+
},
|
|
130
|
+
body: JSON.stringify({
|
|
131
|
+
originDestinations: [
|
|
132
|
+
{
|
|
133
|
+
departureDateTime: {
|
|
134
|
+
date: new Date().toISOString().split('T')[0],
|
|
135
|
+
time: new Date().toTimeString().split(' ')[0],
|
|
136
|
+
},
|
|
137
|
+
destinationLocationCode: 'MAD',
|
|
138
|
+
id: '1',
|
|
139
|
+
originLocationCode: 'BOS',
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
sources: ['GDS'],
|
|
143
|
+
travelers: [
|
|
144
|
+
{
|
|
145
|
+
id: '1',
|
|
146
|
+
travelerType: 'ADULT',
|
|
147
|
+
},
|
|
148
|
+
],
|
|
149
|
+
}),
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
log.info('response', { status: response.status, body: await response.json() });
|
|
153
|
+
expect(response.status).toBe(200);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
test.only('amadeus hotel name autocomplete', async () => {
|
|
157
|
+
const response = await fetch(
|
|
158
|
+
'https://test.api.amadeus.com/v1/reference-data/locations/hotel?keyword=PARI&subtype=HOTEL_LEISURE,HOTEL_GDS',
|
|
159
|
+
{
|
|
160
|
+
method: 'GET',
|
|
161
|
+
headers: {
|
|
162
|
+
// accept: 'application/vnd.amadeus+json',
|
|
163
|
+
// 'X-HTTP-Method-Override': 'GET',
|
|
164
|
+
Authorization: await resolveAuthorization(AMADEUS_AUTH),
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
log.info('response', { status: response.status, body: await response.json() });
|
|
170
|
+
expect(response.status).toBe(200);
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
describe.skip('rapidapi', () => {
|
|
175
|
+
test('amadeus flight availabilities', async () => {
|
|
176
|
+
const departureDate = new Date().toISOString().split('T')[0];
|
|
177
|
+
const arrivalDate = new Date(new Date().getTime() + 7 * 24 * 60 * 60 * 1000).toISOString().split('T')[0];
|
|
178
|
+
|
|
179
|
+
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`;
|
|
180
|
+
const options = {
|
|
181
|
+
method: 'GET',
|
|
182
|
+
headers: {
|
|
183
|
+
'x-rapidapi-key': RAPID_API_CREDENTIALS.key,
|
|
184
|
+
'x-rapidapi-host': 'amadeus-api2.p.rapidapi.com',
|
|
185
|
+
},
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
const response = await fetch(url, options);
|
|
189
|
+
log.info('response', { status: response.status, body: await response.json() });
|
|
190
|
+
expect(response.status).toBe(200);
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
const FLIGHT_SEARCH_API =
|
|
196
|
+
'https://api.apis.guru/v2/specs/amadeus.com/amadeus-flight-availabilities-search/1.0.2/swagger.json';
|
|
197
|
+
const HOTEL_SEARCH_API = 'https://api.apis.guru/v2/specs/amadeus.com/amadeus-hotel-search/3.0.8/swagger.json';
|
|
198
|
+
const HOTEL_NAME_AUTOCOMPLETE_API =
|
|
199
|
+
'https://api.apis.guru/v2/specs/amadeus.com/amadeus-hotel-name-autocomplete/1.0.3/swagger.json';
|
|
200
|
+
const WEATHER_API = 'https://api.apis.guru/v2/specs/visualcrossing.com/weather/4.6/openapi.json';
|
|
201
|
+
|
|
202
|
+
const WEATHER_INSTRUCTIONS = `
|
|
203
|
+
If the user doesn't provide a date, use today's date.
|
|
204
|
+
Make sure to provide the start and end dates when possible to reduce the amount of data returned.
|
|
205
|
+
Use the tool that accepts the date parameters.
|
|
206
|
+
`;
|
|
207
|
+
|
|
208
|
+
const AMADEUS_AUTH: ApiAuthorization = {
|
|
209
|
+
type: 'oauth',
|
|
210
|
+
clientId: 'BOEnpLd1sMyKjAPGKYeAPFFy60u53QEG',
|
|
211
|
+
clientSecret: 'n4qldSN7usvD57gm',
|
|
212
|
+
tokenUrl: 'https://test.api.amadeus.com/v1/security/oauth2/token',
|
|
213
|
+
grantType: 'client_credentials',
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
const VISUAL_CROSSING_CREDENTIALS: ApiAuthorization = {
|
|
217
|
+
type: 'api-key',
|
|
218
|
+
key: 'FDPRVS953KB4GQQLD25GRT975',
|
|
219
|
+
placement: {
|
|
220
|
+
type: 'query',
|
|
221
|
+
name: 'key',
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
const RAPID_API_CREDENTIALS = {
|
|
226
|
+
key: '92271b6740msh32fd821d70f050dp16665bjsna69195c9e838',
|
|
227
|
+
};
|