@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
|
@@ -2,27 +2,35 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React from 'react';
|
|
5
|
+
import React, { useEffect, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { ComputeGraph } from '@dxos/conductor';
|
|
8
|
+
import {
|
|
9
|
+
FunctionType,
|
|
10
|
+
FunctionTriggerSchema,
|
|
11
|
+
type FunctionTriggerType,
|
|
12
|
+
type FunctionTrigger,
|
|
13
|
+
ScriptType,
|
|
14
|
+
TriggerKind,
|
|
15
|
+
} from '@dxos/functions';
|
|
9
16
|
import { Filter, useQuery, type Space } from '@dxos/react-client/echo';
|
|
10
|
-
import { useTranslation } from '@dxos/react-ui';
|
|
11
|
-
import { Form, SelectInput } from '@dxos/react-ui-form';
|
|
17
|
+
import { IconButton, Input, useTranslation } from '@dxos/react-ui';
|
|
18
|
+
import { Form, SelectInput, TextInput } from '@dxos/react-ui-form';
|
|
12
19
|
|
|
13
20
|
import { AUTOMATION_PLUGIN } from '../../meta';
|
|
14
21
|
|
|
15
22
|
export type TriggerEditorProps = {
|
|
16
23
|
space: Space;
|
|
17
24
|
trigger: FunctionTriggerType;
|
|
18
|
-
storedTrigger?: FunctionTrigger;
|
|
19
25
|
onSave?: (trigger: Omit<FunctionTrigger, 'id'>) => void;
|
|
20
26
|
onCancel?: () => void;
|
|
21
27
|
};
|
|
22
28
|
|
|
23
|
-
export const TriggerEditor = ({ space, trigger, onSave, onCancel
|
|
29
|
+
export const TriggerEditor = ({ space, trigger, onSave, onCancel }: TriggerEditorProps) => {
|
|
24
30
|
const { t } = useTranslation(AUTOMATION_PLUGIN);
|
|
31
|
+
|
|
25
32
|
const functions = useQuery(space, Filter.schema(FunctionType));
|
|
33
|
+
const workflows = useQuery(space, Filter.schema(ComputeGraph));
|
|
26
34
|
const scripts = useQuery(space, Filter.schema(ScriptType));
|
|
27
35
|
|
|
28
36
|
const handleSave = (values: FunctionTriggerType) => {
|
|
@@ -33,21 +41,17 @@ export const TriggerEditor = ({ space, trigger, onSave, onCancel, storedTrigger
|
|
|
33
41
|
<Form<FunctionTriggerType>
|
|
34
42
|
schema={FunctionTriggerSchema}
|
|
35
43
|
values={trigger}
|
|
36
|
-
filter={(props) => props.filter((p) => p.name !== 'meta')}
|
|
37
44
|
onSave={handleSave}
|
|
38
45
|
onCancel={onCancel}
|
|
39
46
|
Custom={{
|
|
40
47
|
['function' satisfies keyof FunctionTriggerType]: (props) => (
|
|
41
|
-
<SelectInput
|
|
48
|
+
<SelectInput
|
|
42
49
|
{...props}
|
|
43
|
-
options={
|
|
44
|
-
value: fn.name,
|
|
45
|
-
label: getFunctionName(scripts, fn),
|
|
46
|
-
}))}
|
|
50
|
+
options={getWorkflowOptions(workflows).concat(getFunctionOptions(scripts, functions))}
|
|
47
51
|
/>
|
|
48
52
|
),
|
|
49
53
|
['spec.type' as const]: (props) => (
|
|
50
|
-
<SelectInput
|
|
54
|
+
<SelectInput
|
|
51
55
|
{...props}
|
|
52
56
|
options={Object.values(TriggerKind).map((kind) => ({
|
|
53
57
|
value: kind,
|
|
@@ -55,11 +59,72 @@ export const TriggerEditor = ({ space, trigger, onSave, onCancel, storedTrigger
|
|
|
55
59
|
}))}
|
|
56
60
|
/>
|
|
57
61
|
),
|
|
62
|
+
['meta' as const]: (props) => {
|
|
63
|
+
const meta = props.getValue()!;
|
|
64
|
+
useEffect(() => props.onValueChange('object', { ...meta }), []);
|
|
65
|
+
const [newMetaFieldName, setNewMetaFieldName] = useState('');
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<>
|
|
69
|
+
<div>{props.label}</div>
|
|
70
|
+
{[...Object.keys(meta)].map((key) => {
|
|
71
|
+
const compositeKey: any = `meta.${key}`;
|
|
72
|
+
return (
|
|
73
|
+
<div key={compositeKey} role='none' className='flex items-center mt-2 gap-1'>
|
|
74
|
+
<div role='none' className='flex-1'>
|
|
75
|
+
<TextInput {...props} type={'string'} label={key} />
|
|
76
|
+
</div>
|
|
77
|
+
<IconButton
|
|
78
|
+
icon='ph--trash--regular'
|
|
79
|
+
iconOnly
|
|
80
|
+
classNames={'mt-6'}
|
|
81
|
+
label={t('trigger meta remove')}
|
|
82
|
+
onClick={() => {
|
|
83
|
+
const newValues: any = { ...props.getValue() };
|
|
84
|
+
delete newValues[key];
|
|
85
|
+
props.onValueChange('object', newValues);
|
|
86
|
+
}}
|
|
87
|
+
/>
|
|
88
|
+
</div>
|
|
89
|
+
);
|
|
90
|
+
})}
|
|
91
|
+
<div role='none' className='flex items-center mt-2 gap-1 plb-1'>
|
|
92
|
+
<div role='none' className='flex-1'>
|
|
93
|
+
<Input.Root>
|
|
94
|
+
<Input.TextInput
|
|
95
|
+
placeholder={t('trigger meta prop name placeholder')}
|
|
96
|
+
value={newMetaFieldName}
|
|
97
|
+
onChange={(event) => setNewMetaFieldName(event.target.value)}
|
|
98
|
+
/>
|
|
99
|
+
</Input.Root>
|
|
100
|
+
</div>
|
|
101
|
+
<IconButton
|
|
102
|
+
icon='ph--plus--regular'
|
|
103
|
+
iconOnly
|
|
104
|
+
label={t('trigger meta add')}
|
|
105
|
+
onClick={() => {
|
|
106
|
+
if (newMetaFieldName.length) {
|
|
107
|
+
const meta = props.getValue() ?? {};
|
|
108
|
+
const metaWithNewProp = { ...meta, [newMetaFieldName]: '' };
|
|
109
|
+
setNewMetaFieldName('');
|
|
110
|
+
props.onValueChange('object', metaWithNewProp);
|
|
111
|
+
}
|
|
112
|
+
}}
|
|
113
|
+
/>
|
|
114
|
+
</div>
|
|
115
|
+
</>
|
|
116
|
+
);
|
|
117
|
+
},
|
|
58
118
|
}}
|
|
59
119
|
/>
|
|
60
120
|
);
|
|
61
121
|
};
|
|
62
122
|
|
|
63
|
-
const
|
|
64
|
-
return
|
|
123
|
+
const getWorkflowOptions = (graphs: ComputeGraph[]) => {
|
|
124
|
+
return graphs.map((graph) => ({ label: `compute-${graph.id}`, value: `dxn:echo:@:${graph.id}` }));
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const getFunctionOptions = (scripts: ScriptType[], functions: FunctionType[]) => {
|
|
128
|
+
const getLabel = (fn: FunctionType) => scripts.find((s) => fn.source?.target?.id === s.id)?.name ?? fn.name;
|
|
129
|
+
return functions.map((fn) => ({ label: getLabel(fn), value: `dxn:worker:${fn.name}` }));
|
|
65
130
|
};
|
package/src/components/index.ts
CHANGED
|
@@ -4,5 +4,13 @@
|
|
|
4
4
|
|
|
5
5
|
import { lazy } from 'react';
|
|
6
6
|
|
|
7
|
-
export
|
|
7
|
+
export * from './AutomationPanel';
|
|
8
|
+
export * from './ChatContainer';
|
|
9
|
+
export * from './MarkdownViewer';
|
|
10
|
+
export * from './PromptEditor';
|
|
11
|
+
export * from './ServiceRegistry';
|
|
12
|
+
export * from './Thread';
|
|
13
|
+
export * from './TriggerEditor';
|
|
14
|
+
|
|
8
15
|
export const AutomationPanel = lazy(() => import('./AutomationPanel'));
|
|
16
|
+
export const ChatContainer = lazy(() => import('./ChatContainer'));
|
package/src/hooks/email.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { foreignKey } from '@dxos/echo-schema';
|
|
|
7
7
|
import { log } from '@dxos/log';
|
|
8
8
|
import { MailboxType } from '@dxos/plugin-inbox/types';
|
|
9
9
|
import { MessageType } from '@dxos/plugin-space/types';
|
|
10
|
-
import { type Space, Filter, create } from '@dxos/react-client/echo';
|
|
10
|
+
import { type Space, Filter, create, makeRef } from '@dxos/react-client/echo';
|
|
11
11
|
|
|
12
12
|
export const SOURCE_ID = 'hub.dxos.network/api/mailbox';
|
|
13
13
|
|
|
@@ -41,7 +41,7 @@ export const handleEmail = async (space: Space, data: any) => {
|
|
|
41
41
|
},
|
|
42
42
|
),
|
|
43
43
|
);
|
|
44
|
-
mailbox.messages?.push(object);
|
|
44
|
+
mailbox.messages?.push(makeRef(object));
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
package/src/hooks/index.ts
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
import { sleep } from '@dxos/async';
|
|
6
6
|
import { getObjectCore, ResultFormat } from '@dxos/echo-db';
|
|
7
|
-
import type
|
|
7
|
+
import { type AnyObjectData } from '@dxos/echo-schema';
|
|
8
|
+
import { FunctionType } from '@dxos/functions';
|
|
8
9
|
import { type FunctionTrigger } from '@dxos/functions';
|
|
9
10
|
import { invariant } from '@dxos/invariant';
|
|
10
11
|
import { DXN, LOCAL_SPACE_TAG } from '@dxos/keys';
|
|
11
12
|
import { log } from '@dxos/log';
|
|
12
|
-
import { FunctionType } from '@dxos/plugin-script';
|
|
13
13
|
import { type Client, type Config } from '@dxos/react-client';
|
|
14
14
|
import { type Space } from '@dxos/react-client/echo';
|
|
15
15
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { describe, it } from 'vitest';
|
|
6
|
+
|
|
7
|
+
import { ChatProcessor } from './processor';
|
|
8
|
+
|
|
9
|
+
describe('ChatProcessor', () => {
|
|
10
|
+
it('should be instantiable', ({ expect }) => {
|
|
11
|
+
const client = {} as any; // TODO(burdon): Create mock.
|
|
12
|
+
const processor = new ChatProcessor(client);
|
|
13
|
+
expect(processor).toBeDefined();
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Signal, batch, computed, signal } from '@preact/signals-core';
|
|
6
|
+
|
|
7
|
+
import { type PromiseIntentDispatcher } from '@dxos/app-framework';
|
|
8
|
+
import { type Tool, Message, type MessageContentBlock } from '@dxos/artifact';
|
|
9
|
+
import {
|
|
10
|
+
isToolUse,
|
|
11
|
+
runTools,
|
|
12
|
+
type AIServiceClientImpl,
|
|
13
|
+
type GenerateRequest,
|
|
14
|
+
type GenerationStream,
|
|
15
|
+
MixedStreamParser,
|
|
16
|
+
} from '@dxos/assistant';
|
|
17
|
+
import { createStatic } from '@dxos/echo-schema';
|
|
18
|
+
import { invariant } from '@dxos/invariant';
|
|
19
|
+
import { log } from '@dxos/log';
|
|
20
|
+
import { type Space } from '@dxos/react-client/echo';
|
|
21
|
+
|
|
22
|
+
// TODO(burdon): Factor out.
|
|
23
|
+
declare global {
|
|
24
|
+
interface ToolContextExtensions {
|
|
25
|
+
space?: Space;
|
|
26
|
+
dispatch?: PromiseIntentDispatcher;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
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
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Handles interactions with the AI service.
|
|
44
|
+
* Maintains a queue of messages and handles streaming responses from the AI service.
|
|
45
|
+
* Executes tools based on AI responses.
|
|
46
|
+
* Supports cancellation of in-progress requests.
|
|
47
|
+
*/
|
|
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
|
+
|
|
61
|
+
/** Prior history from queue. */
|
|
62
|
+
private _history: Message[] = [];
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Streaming state.
|
|
66
|
+
* @reactive
|
|
67
|
+
*/
|
|
68
|
+
public readonly streaming: Signal<boolean> = computed(() => this._block.value !== undefined);
|
|
69
|
+
|
|
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
|
+
}
|
|
83
|
+
|
|
84
|
+
return messages;
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
constructor(
|
|
88
|
+
private readonly _client: AIServiceClientImpl,
|
|
89
|
+
private _tools?: Tool[],
|
|
90
|
+
private readonly _extensions?: ToolContextExtensions,
|
|
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
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Update tools.
|
|
111
|
+
*/
|
|
112
|
+
setTools(tools: Tool[]) {
|
|
113
|
+
this._tools = tools;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Make GPT request.
|
|
118
|
+
*/
|
|
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);
|
|
133
|
+
return this._reset();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Cancel pending requests.
|
|
138
|
+
* @returns Pending requests (incl. the request message).
|
|
139
|
+
*/
|
|
140
|
+
async cancel(): Promise<Message[]> {
|
|
141
|
+
log.info('cancelling...');
|
|
142
|
+
this._stream?.abort();
|
|
143
|
+
return this._reset();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
private async _reset(): Promise<Message[]> {
|
|
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;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Generate a response from the AI service.
|
|
159
|
+
* Iterates over tool requests.
|
|
160
|
+
*/
|
|
161
|
+
private async _generate() {
|
|
162
|
+
try {
|
|
163
|
+
let more = false;
|
|
164
|
+
do {
|
|
165
|
+
log.info('requesting...', { history: this._history.length, messages: this._pending.value.length });
|
|
166
|
+
this._stream = await this._client.generate({
|
|
167
|
+
...this._options,
|
|
168
|
+
// TODO(burdon): Rename messages or separate history/message.
|
|
169
|
+
history: [...this._history, ...this._pending.value],
|
|
170
|
+
tools: this._tools,
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
// Wait until complete.
|
|
174
|
+
await this._parser.parse(this._stream);
|
|
175
|
+
await this._stream.complete();
|
|
176
|
+
|
|
177
|
+
// Add messages.
|
|
178
|
+
log.info('response', { messages: this._pending.value });
|
|
179
|
+
|
|
180
|
+
// Resolve tool use locally.
|
|
181
|
+
more = false;
|
|
182
|
+
const message = this._pending.value.at(-1);
|
|
183
|
+
invariant(message);
|
|
184
|
+
if (isToolUse(message)) {
|
|
185
|
+
log.info('tool request...');
|
|
186
|
+
const response = await runTools({
|
|
187
|
+
message: this._pending.value.at(-1)!,
|
|
188
|
+
tools: this._tools ?? [],
|
|
189
|
+
extensions: this._extensions,
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
log.info('tool response', { response });
|
|
193
|
+
switch (response.type) {
|
|
194
|
+
case 'continue': {
|
|
195
|
+
this._pending.value = [...this._pending.value, response.message];
|
|
196
|
+
more = true;
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
} while (more);
|
|
202
|
+
} catch (err) {
|
|
203
|
+
// TODO(burdon): Handle error.
|
|
204
|
+
log.catch('request failed', { err });
|
|
205
|
+
} finally {
|
|
206
|
+
log.info('done');
|
|
207
|
+
this._stream = undefined;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
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/index.ts
CHANGED
|
@@ -2,11 +2,8 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { AutomationPlugin } from './AutomationPlugin';
|
|
6
|
-
|
|
7
|
-
export default AutomationPlugin;
|
|
8
|
-
|
|
9
5
|
export * from './AutomationPlugin';
|
|
10
6
|
export * from './components';
|
|
7
|
+
export * from './meta';
|
|
11
8
|
export * from './presets';
|
|
12
9
|
export * from './types';
|
package/src/meta.ts
CHANGED
|
@@ -6,10 +6,11 @@ import { type PluginMeta } from '@dxos/app-framework';
|
|
|
6
6
|
|
|
7
7
|
export const AUTOMATION_PLUGIN = 'dxos.org/plugin/automation';
|
|
8
8
|
|
|
9
|
-
export
|
|
9
|
+
export const 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
|
@@ -2,12 +2,19 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { createSystemPrompt } from '@dxos/artifact';
|
|
6
|
+
import { type GenerateRequest } from '@dxos/assistant';
|
|
5
7
|
import { AST, S, toJsonSchema } from '@dxos/echo-schema';
|
|
6
8
|
|
|
9
|
+
export const createProcessorOptions = (artifacts: string[]): Pick<GenerateRequest, 'model' | 'systemPrompt'> => ({
|
|
10
|
+
model: '@anthropic/claude-3-5-sonnet-20241022',
|
|
11
|
+
systemPrompt: createSystemPrompt({ artifacts }),
|
|
12
|
+
});
|
|
13
|
+
|
|
7
14
|
export const functions = [
|
|
8
15
|
{
|
|
9
16
|
name: 'example.com/function/chess',
|
|
10
|
-
version: '0.0
|
|
17
|
+
version: '0.1.0',
|
|
11
18
|
inputSchema: toJsonSchema(
|
|
12
19
|
S.Struct({
|
|
13
20
|
level: S.Number.annotations({
|
|
@@ -18,7 +25,7 @@ export const functions = [
|
|
|
18
25
|
},
|
|
19
26
|
{
|
|
20
27
|
name: 'example.com/function/forex',
|
|
21
|
-
version: '0.0
|
|
28
|
+
version: '0.1.0',
|
|
22
29
|
binding: 'FOREX',
|
|
23
30
|
inputSchema: toJsonSchema(
|
|
24
31
|
S.Struct({
|