@dxos/plugin-automation 0.7.5-labs.e27f9b9 → 0.7.5-labs.ea4b4c2
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-VW2XIUPU.mjs +8 -0
- package/dist/lib/browser/ChatContainer-5TAVTN3T.mjs +12 -0
- package/dist/lib/browser/{ai-client-AARXEMMJ.mjs → ai-client-5CNY6JBF.mjs} +3 -3
- package/dist/lib/browser/{app-graph-builder-B4U34VSR.mjs → app-graph-builder-FZGK55G7.mjs} +39 -4
- package/dist/lib/browser/app-graph-builder-FZGK55G7.mjs.map +7 -0
- package/dist/lib/browser/{chunk-HZ4TA7HY.mjs → chunk-2H2EUYXL.mjs} +2 -2
- package/dist/lib/browser/{chunk-5SLV6AUA.mjs → chunk-DVE33EZL.mjs} +525 -290
- package/dist/lib/browser/chunk-DVE33EZL.mjs.map +7 -0
- package/dist/lib/browser/{chunk-IYSMXX6Q.mjs → chunk-MJK7GL5P.mjs} +68 -44
- package/dist/lib/browser/chunk-MJK7GL5P.mjs.map +7 -0
- package/dist/lib/browser/{chunk-RAVNWHNE.mjs → chunk-NQFZ6XRX.mjs} +6 -5
- package/dist/lib/browser/chunk-NQFZ6XRX.mjs.map +7 -0
- package/dist/lib/browser/{chunk-7XADMUOW.mjs → chunk-Q4IMHYGH.mjs} +21 -76
- package/dist/lib/browser/chunk-Q4IMHYGH.mjs.map +7 -0
- package/dist/lib/browser/{chunk-HKX3D3ZP.mjs → chunk-R4JH4TLE.mjs} +4 -2
- package/dist/lib/browser/chunk-R4JH4TLE.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +21 -15
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-754MPV7H.mjs → intent-resolver-BWAXKT27.mjs} +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-4QZ6AKBF.mjs → react-surface-ILBDBZCN.mjs} +17 -9
- package/dist/lib/browser/react-surface-ILBDBZCN.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +6 -6
- package/dist/lib/node/{AutomationPanel-LRDEDGXI.cjs → AutomationPanel-G6EDDYWW.cjs} +7 -7
- package/dist/lib/node/{AutomationPanel-LRDEDGXI.cjs.map → AutomationPanel-G6EDDYWW.cjs.map} +2 -2
- package/dist/lib/node/{ChatContainer-6LZX4K2Z.cjs → ChatContainer-EN24W3K4.cjs} +10 -10
- package/dist/lib/node/ChatContainer-EN24W3K4.cjs.map +7 -0
- package/dist/lib/node/{ai-client-SA35GN5Q.cjs → ai-client-FKLPDELV.cjs} +7 -7
- package/dist/lib/node/{app-graph-builder-ENVDOPS4.cjs → app-graph-builder-T76NYV42.cjs} +48 -14
- package/dist/lib/node/app-graph-builder-T76NYV42.cjs.map +7 -0
- package/dist/lib/node/{chunk-6VMSH4P6.cjs → chunk-CJGJXNY3.cjs} +549 -327
- package/dist/lib/node/chunk-CJGJXNY3.cjs.map +7 -0
- package/dist/lib/node/{chunk-5VF5JKUN.cjs → chunk-EQYHOTGG.cjs} +8 -5
- package/dist/lib/node/chunk-EQYHOTGG.cjs.map +7 -0
- package/dist/lib/node/chunk-GB7245FH.cjs +173 -0
- package/dist/lib/node/chunk-GB7245FH.cjs.map +7 -0
- package/dist/lib/node/{chunk-HEYQONXC.cjs → chunk-HMBKP6VG.cjs} +82 -60
- package/dist/lib/node/chunk-HMBKP6VG.cjs.map +7 -0
- package/dist/lib/node/{chunk-WWU5FVAO.cjs → chunk-QXIHYOMF.cjs} +10 -9
- package/dist/lib/node/chunk-QXIHYOMF.cjs.map +7 -0
- package/dist/lib/node/{chunk-ZS5RZ7RM.cjs → chunk-U5Z7LFWB.cjs} +6 -6
- package/dist/lib/node/index.cjs +81 -75
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/{intent-resolver-CNVBSG4E.cjs → intent-resolver-C6OKFVEW.cjs} +8 -8
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/{react-surface-5HYLBDC3.cjs → react-surface-LWDY7SQG.cjs} +24 -18
- package/dist/lib/node/react-surface-LWDY7SQG.cjs.map +7 -0
- package/dist/lib/node/types/index.cjs +13 -13
- package/dist/lib/node/types/index.cjs.map +1 -1
- package/dist/lib/node-esm/{AutomationPanel-ZV7VEEPP.mjs → AutomationPanel-V3IWQAMO.mjs} +3 -3
- package/dist/lib/node-esm/{ChatContainer-PPVMC2FC.mjs → ChatContainer-CNTY3C2D.mjs} +5 -5
- package/dist/lib/node-esm/{ai-client-2ZA4TYFZ.mjs → ai-client-XGNA6SJ5.mjs} +3 -3
- package/dist/lib/node-esm/{app-graph-builder-IYOUCQZT.mjs → app-graph-builder-IJQEN7WT.mjs} +39 -4
- package/dist/lib/node-esm/app-graph-builder-IJQEN7WT.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-MS7OIGVR.mjs → chunk-6HLBYDUI.mjs} +6 -5
- package/dist/lib/node-esm/chunk-6HLBYDUI.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-EVTLHDM2.mjs → chunk-DNCXRGAF.mjs} +21 -76
- package/dist/lib/node-esm/chunk-DNCXRGAF.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-X3LPRWIL.mjs → chunk-EMVA6QUT.mjs} +4 -2
- package/dist/lib/node-esm/chunk-EMVA6QUT.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-ISYLEDVU.mjs → chunk-IJRTDSKN.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-WISKXX7U.mjs → chunk-QP47VJT6.mjs} +525 -290
- package/dist/lib/node-esm/chunk-QP47VJT6.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-3KB5HRXA.mjs → chunk-ZLIAMW45.mjs} +68 -44
- package/dist/lib/node-esm/chunk-ZLIAMW45.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +21 -15
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-RQBXW442.mjs → intent-resolver-DCP4ZDBA.mjs} +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-SS5WCRJ2.mjs → react-surface-SBDXFVIN.mjs} +17 -9
- package/dist/lib/node-esm/react-surface-SBDXFVIN.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +6 -6
- package/dist/types/src/capabilities/app-graph-builder.d.ts +23 -22
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/AmbientChatDialog/AmbientChatDialog.d.ts +3 -0
- package/dist/types/src/components/AmbientChatDialog/AmbientChatDialog.d.ts.map +1 -0
- package/dist/types/src/components/AmbientChatDialog/index.d.ts +2 -0
- package/dist/types/src/components/AmbientChatDialog/index.d.ts.map +1 -0
- package/dist/types/src/components/Box/StatusLine.d.ts.map +1 -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.map +1 -0
- package/dist/types/src/components/{Thread → Box}/ToggleContainer.d.ts +3 -3
- package/dist/types/src/components/Box/ToggleContainer.d.ts.map +1 -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 +0 -1
- package/dist/types/src/components/ChatContainer/ChatContainer.d.ts.map +1 -1
- 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.stories.d.ts.map +1 -1
- package/dist/types/src/components/Thread/Thread.stories.d.ts +1 -0
- package/dist/types/src/components/Thread/Thread.stories.d.ts.map +1 -1
- package/dist/types/src/components/Thread/ThreadMessage.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +3 -1
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/processor.d.ts +7 -2
- 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 +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/translations.d.ts +3 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/registry.d.ts +7 -6
- package/dist/types/src/types/registry.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +94 -69
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/package.json +52 -50
- package/src/AutomationPlugin.tsx +7 -7
- package/src/capabilities/app-graph-builder.ts +34 -3
- package/src/capabilities/react-surface.tsx +12 -4
- package/src/components/AmbientChatDialog/AmbientChatDialog.tsx +26 -0
- package/src/components/AmbientChatDialog/index.ts +5 -0
- package/src/components/{Thread → Box}/StatusLine.tsx +1 -1
- package/src/components/{Thread → Box}/Tabbed.stories.tsx +2 -3
- package/src/components/Box/Tabbed.tsx +89 -0
- package/src/components/{Thread → Box}/ToggleContainer.stories.tsx +1 -2
- package/src/components/{Thread → Box}/ToggleContainer.tsx +28 -23
- package/src/components/Box/index.ts +7 -0
- package/src/components/ChatContainer/ChatContainer.tsx +15 -80
- 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 +2 -1
- package/src/components/ServiceRegistry/ServiceRegistry.tsx +7 -7
- package/src/components/Thread/Thread.stories.tsx +8 -1
- package/src/components/Thread/Thread.tsx +2 -2
- package/src/components/Thread/ThreadMessage.tsx +58 -28
- package/src/components/TriggerEditor/TriggerEditor.tsx +8 -5
- package/src/components/index.ts +1 -0
- package/src/hooks/index.ts +3 -1
- package/src/hooks/processor.ts +16 -7
- package/src/hooks/useChatProcessor.tsx +86 -0
- package/src/hooks/useMessageQueue.ts +23 -0
- package/src/hooks/{useServiceRegistry.ts → useServices.ts} +8 -2
- package/src/meta.ts +4 -1
- package/src/testing/index.ts +2 -1
- package/src/testing/test-services.ts +131 -0
- package/src/translations.ts +1 -0
- package/src/types/registry.ts +17 -80
- package/src/types/schema.ts +20 -8
- package/dist/lib/browser/AutomationPanel-WFJZAW4F.mjs +0 -8
- package/dist/lib/browser/ChatContainer-OFCOZ5T2.mjs +0 -12
- package/dist/lib/browser/app-graph-builder-B4U34VSR.mjs.map +0 -7
- package/dist/lib/browser/chunk-5SLV6AUA.mjs.map +0 -7
- package/dist/lib/browser/chunk-7XADMUOW.mjs.map +0 -7
- package/dist/lib/browser/chunk-HKX3D3ZP.mjs.map +0 -7
- package/dist/lib/browser/chunk-IYSMXX6Q.mjs.map +0 -7
- package/dist/lib/browser/chunk-RAVNWHNE.mjs.map +0 -7
- package/dist/lib/browser/react-surface-4QZ6AKBF.mjs.map +0 -7
- package/dist/lib/node/ChatContainer-6LZX4K2Z.cjs.map +0 -7
- package/dist/lib/node/app-graph-builder-ENVDOPS4.cjs.map +0 -7
- package/dist/lib/node/chunk-5VF5JKUN.cjs.map +0 -7
- package/dist/lib/node/chunk-6VMSH4P6.cjs.map +0 -7
- package/dist/lib/node/chunk-HEYQONXC.cjs.map +0 -7
- package/dist/lib/node/chunk-LU4HQWJD.cjs +0 -226
- package/dist/lib/node/chunk-LU4HQWJD.cjs.map +0 -7
- package/dist/lib/node/chunk-WWU5FVAO.cjs.map +0 -7
- package/dist/lib/node/react-surface-5HYLBDC3.cjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-IYOUCQZT.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-3KB5HRXA.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-EVTLHDM2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MS7OIGVR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WISKXX7U.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-X3LPRWIL.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-SS5WCRJ2.mjs.map +0 -7
- package/dist/types/src/components/Thread/ScrollContainer.d.ts +0 -15
- package/dist/types/src/components/Thread/ScrollContainer.d.ts.map +0 -1
- package/dist/types/src/components/Thread/StatusLine.d.ts.map +0 -1
- package/dist/types/src/components/Thread/StatusLine.stories.d.ts.map +0 -1
- package/dist/types/src/components/Thread/Tabbed.d.ts +0 -9
- package/dist/types/src/components/Thread/Tabbed.d.ts.map +0 -1
- package/dist/types/src/components/Thread/Tabbed.stories.d.ts.map +0 -1
- package/dist/types/src/components/Thread/ToggleContainer.d.ts.map +0 -1
- package/dist/types/src/components/Thread/ToggleContainer.stories.d.ts.map +0 -1
- package/dist/types/src/hooks/useServiceRegistry.d.ts +0 -3
- package/dist/types/src/hooks/useServiceRegistry.d.ts.map +0 -1
- package/dist/types/src/testing/testing.d.ts.map +0 -1
- package/src/components/Thread/ScrollContainer.tsx +0 -92
- package/src/components/Thread/Tabbed.tsx +0 -72
- /package/dist/lib/browser/{AutomationPanel-WFJZAW4F.mjs.map → AutomationPanel-VW2XIUPU.mjs.map} +0 -0
- /package/dist/lib/browser/{ChatContainer-OFCOZ5T2.mjs.map → ChatContainer-5TAVTN3T.mjs.map} +0 -0
- /package/dist/lib/browser/{ai-client-AARXEMMJ.mjs.map → ai-client-5CNY6JBF.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-HZ4TA7HY.mjs.map → chunk-2H2EUYXL.mjs.map} +0 -0
- /package/dist/lib/browser/{intent-resolver-754MPV7H.mjs.map → intent-resolver-BWAXKT27.mjs.map} +0 -0
- /package/dist/lib/node/{ai-client-SA35GN5Q.cjs.map → ai-client-FKLPDELV.cjs.map} +0 -0
- /package/dist/lib/node/{chunk-ZS5RZ7RM.cjs.map → chunk-U5Z7LFWB.cjs.map} +0 -0
- /package/dist/lib/node/{intent-resolver-CNVBSG4E.cjs.map → intent-resolver-C6OKFVEW.cjs.map} +0 -0
- /package/dist/lib/node-esm/{AutomationPanel-ZV7VEEPP.mjs.map → AutomationPanel-V3IWQAMO.mjs.map} +0 -0
- /package/dist/lib/node-esm/{ChatContainer-PPVMC2FC.mjs.map → ChatContainer-CNTY3C2D.mjs.map} +0 -0
- /package/dist/lib/node-esm/{ai-client-2ZA4TYFZ.mjs.map → ai-client-XGNA6SJ5.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-ISYLEDVU.mjs.map → chunk-IJRTDSKN.mjs.map} +0 -0
- /package/dist/lib/node-esm/{intent-resolver-RQBXW442.mjs.map → intent-resolver-DCP4ZDBA.mjs.map} +0 -0
- /package/dist/types/src/components/{Thread → Box}/StatusLine.d.ts +0 -0
- /package/dist/types/src/components/{Thread → Box}/StatusLine.stories.d.ts +0 -0
- /package/dist/types/src/components/{Thread → Box}/Tabbed.stories.d.ts +0 -0
- /package/dist/types/src/components/{Thread → Box}/ToggleContainer.stories.d.ts +0 -0
- /package/src/components/{Thread → Box}/StatusLine.stories.tsx +0 -0
- /package/src/testing/{testing.ts → test-functions.ts} +0 -0
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, { type FC } from 'react';
|
|
5
|
+
import React, { useEffect, useRef, useState, type FC } from 'react';
|
|
6
6
|
|
|
7
7
|
import { type MessageContentBlock, type Message } from '@dxos/artifact';
|
|
8
8
|
import { invariant } from '@dxos/invariant';
|
|
9
|
+
import { log } from '@dxos/log';
|
|
9
10
|
import { Button, ButtonGroup, Icon, type ThemedClassName } from '@dxos/react-ui';
|
|
10
11
|
import { Json } from '@dxos/react-ui-syntax-highlighter';
|
|
11
12
|
import { mx } from '@dxos/react-ui-theme';
|
|
12
13
|
import { safeParseJson } from '@dxos/util';
|
|
13
14
|
|
|
14
|
-
import { StatusLine } from '
|
|
15
|
-
import { ToggleContainer } from './ToggleContainer';
|
|
15
|
+
import { ToggleContainer, StatusLine, Tabs } from '../Box';
|
|
16
16
|
import { MarkdownViewer } from '../MarkdownViewer';
|
|
17
17
|
|
|
18
18
|
export type ThreadMessageProps = ThemedClassName<{
|
|
@@ -38,34 +38,37 @@ export const ThreadMessage: FC<ThreadMessageProps> = ({
|
|
|
38
38
|
const { role, content = [] } = message;
|
|
39
39
|
|
|
40
40
|
// TODO(burdon): Factor out tool blocks.
|
|
41
|
-
const
|
|
42
|
-
if (collapse &&
|
|
43
|
-
let request: MessageContentBlock & { type: 'tool_use' };
|
|
44
|
-
const
|
|
45
|
-
switch (
|
|
41
|
+
const toolBlocks = content.filter((block) => block.type === 'tool_use' || block.type === 'tool_result');
|
|
42
|
+
if (collapse && toolBlocks.length > 0) {
|
|
43
|
+
let request: (MessageContentBlock & { type: 'tool_use' }) | undefined;
|
|
44
|
+
const items = toolBlocks.map((block) => {
|
|
45
|
+
switch (block.type) {
|
|
46
46
|
case 'tool_use': {
|
|
47
|
-
request =
|
|
47
|
+
request = block;
|
|
48
48
|
// TODO(burdon): Get plugin name.
|
|
49
|
-
return `Calling ${
|
|
49
|
+
return { title: `Calling ${block.name}...`, block };
|
|
50
50
|
}
|
|
51
|
+
|
|
51
52
|
case 'tool_result': {
|
|
52
53
|
if (!request) {
|
|
53
|
-
|
|
54
|
+
log.warn('unexpected message', { block });
|
|
55
|
+
return { title: 'Error', block };
|
|
54
56
|
}
|
|
55
57
|
|
|
56
|
-
return `Processed ${request.name}
|
|
58
|
+
return { title: `Processed ${request.name}`, block };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
default: {
|
|
62
|
+
request = undefined;
|
|
63
|
+
return { title: 'Error', block };
|
|
57
64
|
}
|
|
58
|
-
default:
|
|
59
|
-
return 'Error';
|
|
60
65
|
}
|
|
61
66
|
});
|
|
62
67
|
|
|
63
68
|
return (
|
|
64
69
|
<div className={mx('flex', classNames)}>
|
|
65
|
-
<div className='w-full p-1 px-2 overflow-hidden rounded-md bg-
|
|
66
|
-
<
|
|
67
|
-
<Json data={content[content.length - 1]} classNames='!p-1 text-xs' />
|
|
68
|
-
</ToggleContainer>
|
|
70
|
+
<div className='w-full p-1 px-2 overflow-hidden rounded-md bg-baseSurface'>
|
|
71
|
+
<TabbedContainer items={items} />
|
|
69
72
|
</div>
|
|
70
73
|
</div>
|
|
71
74
|
);
|
|
@@ -102,8 +105,8 @@ const Block = ({
|
|
|
102
105
|
<div
|
|
103
106
|
className={mx(
|
|
104
107
|
'p-1 px-2 overflow-hidden rounded-md',
|
|
105
|
-
(block.type !== 'text' || block.disposition) && 'w-full bg-
|
|
106
|
-
block.type === 'text' && role === 'user' && 'bg-
|
|
108
|
+
(block.type !== 'text' || block.disposition) && 'w-full bg-baseSurface',
|
|
109
|
+
block.type === 'text' && role === 'user' && 'bg-primary-200 dark:bg-primary-500',
|
|
107
110
|
)}
|
|
108
111
|
>
|
|
109
112
|
<Component block={block} onSuggest={onSuggest} />
|
|
@@ -113,12 +116,9 @@ const Block = ({
|
|
|
113
116
|
|
|
114
117
|
const titles: Record<string, string> = {
|
|
115
118
|
['cot' as const]: 'Chain of thought',
|
|
116
|
-
|
|
117
|
-
// TODO(burdon): Only show if debugging.
|
|
119
|
+
['artifact' as const]: 'Artifact',
|
|
118
120
|
['tool_use' as const]: 'Tool request',
|
|
119
121
|
['tool_result' as const]: 'Tool result',
|
|
120
|
-
|
|
121
|
-
['artifact' as const]: 'Artifact',
|
|
122
122
|
};
|
|
123
123
|
|
|
124
124
|
type BlockComponent = FC<{ block: MessageContentBlock; onSuggest: (text: string) => void }>;
|
|
@@ -141,8 +141,7 @@ const componentMap: Record<string, BlockComponent> = {
|
|
|
141
141
|
<Icon icon={'ph--circle-notch--regular'} classNames='text-subdued ml-2 animate-spin' size={4} />
|
|
142
142
|
) : undefined
|
|
143
143
|
}
|
|
144
|
-
|
|
145
|
-
toggle
|
|
144
|
+
open={block.disposition === 'cot'}
|
|
146
145
|
>
|
|
147
146
|
<MarkdownViewer content={block.text} classNames={[block.disposition === 'cot' && 'text-sm text-subdued']} />
|
|
148
147
|
</ToggleContainer>
|
|
@@ -157,6 +156,7 @@ const componentMap: Record<string, BlockComponent> = {
|
|
|
157
156
|
const { text = '' }: { text: string } = safeParseJson(block.json ?? '{}') ?? ({} as any);
|
|
158
157
|
return <Button onClick={() => onSuggest(text)}>{text}</Button>;
|
|
159
158
|
}
|
|
159
|
+
|
|
160
160
|
case 'select': {
|
|
161
161
|
const { options = [] }: { options: string[] } = safeParseJson(block.json ?? '{}') ?? ({} as any);
|
|
162
162
|
return (
|
|
@@ -169,10 +169,11 @@ const componentMap: Record<string, BlockComponent> = {
|
|
|
169
169
|
</ButtonGroup>
|
|
170
170
|
);
|
|
171
171
|
}
|
|
172
|
+
|
|
172
173
|
default: {
|
|
173
174
|
const title = block.disposition ? titles[block.disposition] : undefined;
|
|
174
175
|
return (
|
|
175
|
-
<ToggleContainer title={title ?? 'JSON'}
|
|
176
|
+
<ToggleContainer title={title ?? 'JSON'}>
|
|
176
177
|
<Json data={safeParseJson(block.json ?? block)} classNames='!p-1 text-xs' />
|
|
177
178
|
</ToggleContainer>
|
|
178
179
|
);
|
|
@@ -187,9 +188,38 @@ const componentMap: Record<string, BlockComponent> = {
|
|
|
187
188
|
}
|
|
188
189
|
|
|
189
190
|
return (
|
|
190
|
-
<ToggleContainer title={title ?? 'JSON'}
|
|
191
|
+
<ToggleContainer title={title ?? 'JSON'}>
|
|
191
192
|
<Json data={block} classNames='!p-1 text-xs' />
|
|
192
193
|
</ToggleContainer>
|
|
193
194
|
);
|
|
194
195
|
},
|
|
195
196
|
};
|
|
197
|
+
|
|
198
|
+
const TabbedContainer = ({ items }: { items: { title: string; block: any }[] }) => {
|
|
199
|
+
const lines = items.map((item) => item.title);
|
|
200
|
+
const tabsRef = useRef<HTMLDivElement>(null);
|
|
201
|
+
const [selected, setSelected] = useState(0);
|
|
202
|
+
const [open, setOpen] = useState(false);
|
|
203
|
+
useEffect(() => {
|
|
204
|
+
if (open) {
|
|
205
|
+
tabsRef.current?.focus();
|
|
206
|
+
}
|
|
207
|
+
}, [open]);
|
|
208
|
+
|
|
209
|
+
const handleSelect = (index: number) => {
|
|
210
|
+
if (index === selected) {
|
|
211
|
+
setOpen(false);
|
|
212
|
+
} else {
|
|
213
|
+
setSelected(index);
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
return (
|
|
218
|
+
<ToggleContainer title={<StatusLine lines={lines} autoAdvance />} open={open} onChangeOpen={setOpen}>
|
|
219
|
+
<div className='flex gap-2 w-full'>
|
|
220
|
+
<Tabs ref={tabsRef} length={items.length} selected={selected} onSelect={handleSelect} />
|
|
221
|
+
<Json data={items[selected].block} classNames='!p-1 text-xs' />
|
|
222
|
+
</div>
|
|
223
|
+
</ToggleContainer>
|
|
224
|
+
);
|
|
225
|
+
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, { useState } from 'react';
|
|
5
|
+
import React, { useEffect, useState } from 'react';
|
|
6
6
|
|
|
7
7
|
import { ComputeGraph } from '@dxos/conductor';
|
|
8
8
|
import {
|
|
@@ -61,11 +61,9 @@ export const TriggerEditor = ({ space, trigger, onSave, onCancel }: TriggerEdito
|
|
|
61
61
|
),
|
|
62
62
|
['meta' as const]: (props) => {
|
|
63
63
|
const meta = props.getValue()!;
|
|
64
|
-
|
|
64
|
+
useEffect(() => props.onValueChange('object', { ...meta }), []);
|
|
65
65
|
const [newMetaFieldName, setNewMetaFieldName] = useState('');
|
|
66
66
|
|
|
67
|
-
React.useEffect(() => props.onValueChange('object', { ...meta }), []);
|
|
68
|
-
|
|
69
67
|
return (
|
|
70
68
|
<>
|
|
71
69
|
<div>{props.label}</div>
|
|
@@ -74,7 +72,12 @@ export const TriggerEditor = ({ space, trigger, onSave, onCancel }: TriggerEdito
|
|
|
74
72
|
return (
|
|
75
73
|
<div key={compositeKey} role='none' className='flex items-center mt-2 gap-1'>
|
|
76
74
|
<div role='none' className='flex-1'>
|
|
77
|
-
<TextInput
|
|
75
|
+
<TextInput
|
|
76
|
+
{...props}
|
|
77
|
+
getValue={() => (props.getValue() as any)[key]}
|
|
78
|
+
type={'string'}
|
|
79
|
+
label={key}
|
|
80
|
+
/>
|
|
78
81
|
</div>
|
|
79
82
|
<IconButton
|
|
80
83
|
icon='ph--trash--regular'
|
package/src/components/index.ts
CHANGED
package/src/hooks/index.ts
CHANGED
package/src/hooks/processor.ts
CHANGED
|
@@ -19,11 +19,6 @@ import { invariant } from '@dxos/invariant';
|
|
|
19
19
|
import { log } from '@dxos/log';
|
|
20
20
|
import { type Space } from '@dxos/react-client/echo';
|
|
21
21
|
|
|
22
|
-
const defaultOptions: Pick<GenerateRequest, 'model' | 'systemPrompt'> = {
|
|
23
|
-
model: '@anthropic/claude-3-5-sonnet-20241022',
|
|
24
|
-
systemPrompt: '',
|
|
25
|
-
};
|
|
26
|
-
|
|
27
22
|
// TODO(burdon): Factor out.
|
|
28
23
|
declare global {
|
|
29
24
|
interface ToolContextExtensions {
|
|
@@ -37,6 +32,13 @@ type RequestOptions = {
|
|
|
37
32
|
onComplete?: (messages: Message[]) => void;
|
|
38
33
|
};
|
|
39
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
|
+
|
|
40
42
|
/**
|
|
41
43
|
* Handles interactions with the AI service.
|
|
42
44
|
* Maintains a queue of messages and handles streaming responses from the AI service.
|
|
@@ -84,9 +86,9 @@ export class ChatProcessor {
|
|
|
84
86
|
|
|
85
87
|
constructor(
|
|
86
88
|
private readonly _client: AIServiceClientImpl,
|
|
87
|
-
private
|
|
89
|
+
private _tools?: Tool[],
|
|
88
90
|
private readonly _extensions?: ToolContextExtensions,
|
|
89
|
-
private readonly _options:
|
|
91
|
+
private readonly _options: ChatProcessorOptions = defaultOptions,
|
|
90
92
|
) {
|
|
91
93
|
// Message complete.
|
|
92
94
|
this._parser.message.on((message) => {
|
|
@@ -104,6 +106,13 @@ export class ChatProcessor {
|
|
|
104
106
|
});
|
|
105
107
|
}
|
|
106
108
|
|
|
109
|
+
/**
|
|
110
|
+
* Update tools.
|
|
111
|
+
*/
|
|
112
|
+
setTools(tools: Tool[]) {
|
|
113
|
+
this._tools = tools;
|
|
114
|
+
}
|
|
115
|
+
|
|
107
116
|
/**
|
|
108
117
|
* Make GPT request.
|
|
109
118
|
*/
|
|
@@ -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
|
+
};
|
|
@@ -4,9 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
import { useEffect, useMemo, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
7
|
+
import { type Space } from '@dxos/client/echo';
|
|
8
8
|
|
|
9
|
-
|
|
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[] => {
|
|
10
16
|
const registry = useMemo(() => new MockServiceRegistry(), []);
|
|
11
17
|
const [services, setServices] = useState<ServiceType[]>([]);
|
|
12
18
|
useEffect(() => {
|
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 const AMBIENT_CHAT_DIALOG = `${AUTOMATION_PLUGIN}/ambient-chat/dialog`;
|
|
10
|
+
|
|
9
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
|
@@ -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;
|
package/src/translations.ts
CHANGED
package/src/types/registry.ts
CHANGED
|
@@ -2,88 +2,25 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { type ServiceType } from './schema';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export type ServiceQuery = {
|
|
8
|
+
name?: string;
|
|
9
|
+
category?: string;
|
|
10
|
+
};
|
|
10
11
|
|
|
11
12
|
export interface BaseServiceRegistry {
|
|
12
|
-
queryServices(query
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export class MockServiceRegistry implements BaseServiceRegistry {
|
|
16
|
-
async queryServices(query: ServiceQuery): Promise<ServiceType[]> {
|
|
17
|
-
return TEST_SERVICES;
|
|
18
|
-
}
|
|
13
|
+
queryServices(query?: ServiceQuery): Promise<ServiceType[]>;
|
|
19
14
|
}
|
|
20
15
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
type: 'api-key',
|
|
33
|
-
key: 'FDPRVS953KB4GQQLD25GRT975',
|
|
34
|
-
placement: {
|
|
35
|
-
type: 'query',
|
|
36
|
-
name: 'key',
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const TEST_SERVICES: ServiceType[] = [
|
|
41
|
-
/**
|
|
42
|
-
* dxn:service:example.com/service/FlightSearch
|
|
43
|
-
*/
|
|
44
|
-
createStatic(ServiceType, {
|
|
45
|
-
serviceId: 'example.com/service/FlightSearch',
|
|
46
|
-
name: 'Amadeus Flight Search',
|
|
47
|
-
description: 'Search for local and international flights.',
|
|
48
|
-
interfaces: [
|
|
49
|
-
{
|
|
50
|
-
kind: 'api',
|
|
51
|
-
schemaUrl: 'https://api.apis.guru/v2/specs/amadeus.com/amadeus-flight-availabilities-search/1.0.2/swagger.json',
|
|
52
|
-
authorization: AMADEUS_AUTH,
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
}),
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* dxn:service:example.com/service/HotelSearch
|
|
59
|
-
*/
|
|
60
|
-
// TODO(burdon): Not working.
|
|
61
|
-
createStatic(ServiceType, {
|
|
62
|
-
serviceId: 'example.com/service/HotelSearch',
|
|
63
|
-
name: 'Amadeus Hotel Search',
|
|
64
|
-
description: 'Search for local and international hotels.',
|
|
65
|
-
interfaces: [
|
|
66
|
-
{
|
|
67
|
-
kind: 'api',
|
|
68
|
-
schemaUrl: 'https://api.apis.guru/v2/specs/amadeus.com/amadeus-hotel-search/3.0.8/swagger.json',
|
|
69
|
-
authorization: AMADEUS_AUTH,
|
|
70
|
-
},
|
|
71
|
-
],
|
|
72
|
-
}),
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* dxn:service:example.com/service/Weather
|
|
76
|
-
*/
|
|
77
|
-
createStatic(ServiceType, {
|
|
78
|
-
serviceId: 'example.com/service/Weather',
|
|
79
|
-
name: 'Visual Crossing Weather',
|
|
80
|
-
description: 'Search for global weather forecasts.',
|
|
81
|
-
interfaces: [
|
|
82
|
-
{
|
|
83
|
-
kind: 'api',
|
|
84
|
-
schemaUrl: 'https://api.apis.guru/v2/specs/visualcrossing.com/weather/4.6/openapi.json',
|
|
85
|
-
authorization: VISUAL_CROSSING_CREDENTIALS,
|
|
86
|
-
},
|
|
87
|
-
],
|
|
88
|
-
}),
|
|
89
|
-
] as const;
|
|
16
|
+
export const categoryIcons: Record<string, string> = {
|
|
17
|
+
finance: 'ph--bank--regular',
|
|
18
|
+
health: 'ph--heart--regular',
|
|
19
|
+
geolocation: 'ph--globe-simple--regular',
|
|
20
|
+
education: 'ph--books--regular',
|
|
21
|
+
entertainment: 'ph--music-notes--regular',
|
|
22
|
+
shopping: 'ph--shopping-cart--regular',
|
|
23
|
+
travel: 'ph--airplane-takeoff--regular',
|
|
24
|
+
utilities: 'ph--lightning--regular',
|
|
25
|
+
weather: 'ph--cloud-rain--regular',
|
|
26
|
+
} as const;
|