@dxos/plugin-automation 0.7.4-staging.f7e8224 → 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
package/src/AutomationPlugin.tsx
CHANGED
|
@@ -2,207 +2,90 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
import { parseMetadataResolverPlugin, type PluginDefinition, resolvePlugin } from '@dxos/app-framework';
|
|
5
|
+
import { Capabilities, contributes, createIntent, defineModule, definePlugin, Events } from '@dxos/app-framework';
|
|
8
6
|
import { FunctionTrigger } from '@dxos/functions';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { memoizeQuery } from '@dxos/plugin-space';
|
|
13
|
-
import {
|
|
14
|
-
getSpace,
|
|
15
|
-
getTypename,
|
|
16
|
-
isEchoObject,
|
|
17
|
-
loadObjectReferences,
|
|
18
|
-
parseId,
|
|
19
|
-
SpaceState,
|
|
20
|
-
} from '@dxos/react-client/echo';
|
|
21
|
-
import { translations as formTranslations } from '@dxos/react-ui-form';
|
|
7
|
+
import { ClientCapabilities, ClientEvents } from '@dxos/plugin-client';
|
|
8
|
+
import { DeckCapabilities } from '@dxos/plugin-deck';
|
|
9
|
+
import { RefArray } from '@dxos/react-client/echo';
|
|
22
10
|
|
|
23
|
-
import {
|
|
24
|
-
import
|
|
11
|
+
import { AiClient, AppGraphBuilder, IntentResolver, ReactSurface } from './capabilities';
|
|
12
|
+
import { AUTOMATION_PLUGIN, meta } from './meta';
|
|
25
13
|
import translations from './translations';
|
|
26
|
-
import {
|
|
14
|
+
import { AutomationAction, ChainPromptType, ChainType, AIChatType, ServiceType } from './types';
|
|
27
15
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
16
|
+
// TODO(wittjosiah): Rename to AssistantPlugin?
|
|
17
|
+
export const AutomationPlugin = () =>
|
|
18
|
+
definePlugin(meta, [
|
|
19
|
+
defineModule({
|
|
20
|
+
id: `${meta.id}/module/ai-client`,
|
|
21
|
+
activatesOn: ClientEvents.ClientReady,
|
|
22
|
+
activate: AiClient,
|
|
23
|
+
}),
|
|
24
|
+
defineModule({
|
|
25
|
+
id: `${meta.id}/module/translations`,
|
|
26
|
+
activatesOn: Events.SetupTranslations,
|
|
27
|
+
activate: () => contributes(Capabilities.Translations, translations),
|
|
28
|
+
}),
|
|
29
|
+
defineModule({
|
|
30
|
+
id: `${meta.id}/module/metadata`,
|
|
31
|
+
activatesOn: Events.SetupMetadata,
|
|
32
|
+
activate: () => [
|
|
33
|
+
contributes(Capabilities.Metadata, {
|
|
34
|
+
id: ChainType.typename,
|
|
35
|
+
metadata: {
|
|
35
36
|
placeholder: ['object placeholder', { ns: AUTOMATION_PLUGIN }],
|
|
36
37
|
icon: 'ph--magic-wand--regular',
|
|
37
38
|
// TODO(wittjosiah): Move out of metadata.
|
|
38
|
-
loadReferences: (chain: ChainType) =>
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
translations: [...translations, ...formTranslations],
|
|
43
|
-
echo: {
|
|
44
|
-
system: [ChainType, ChainPromptType, FunctionTrigger],
|
|
45
|
-
},
|
|
46
|
-
complementary: {
|
|
47
|
-
panels: [
|
|
48
|
-
{
|
|
49
|
-
id: 'automation',
|
|
50
|
-
label: ['open automation panel label', { ns: AUTOMATION_PLUGIN }],
|
|
51
|
-
icon: 'ph--magic-wand--regular',
|
|
39
|
+
loadReferences: async (chain: ChainType) => await RefArray.loadAll(chain.prompts ?? []),
|
|
52
40
|
},
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
41
|
+
}),
|
|
42
|
+
contributes(Capabilities.Metadata, {
|
|
43
|
+
id: AIChatType.typename,
|
|
44
|
+
metadata: {
|
|
45
|
+
createObject: (props: { name?: string }) => createIntent(AutomationAction.Create, props),
|
|
46
|
+
placeholder: ['object placeholder', { ns: AUTOMATION_PLUGIN }],
|
|
56
47
|
icon: 'ph--atom--regular',
|
|
57
48
|
},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
data: null,
|
|
102
|
-
properties: {
|
|
103
|
-
icon,
|
|
104
|
-
label,
|
|
105
|
-
showResolvedThreads: false,
|
|
106
|
-
object: null,
|
|
107
|
-
space,
|
|
108
|
-
},
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const [object] = memoizeQuery(space, { id: objectId });
|
|
113
|
-
if (!object || !subjectId) {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const meta = resolve(getTypename(object) ?? '');
|
|
118
|
-
const label = meta.label?.(object) ||
|
|
119
|
-
object.name ||
|
|
120
|
-
meta.placeholder || ['unnamed object settings label', { ns: AUTOMATION_PLUGIN }];
|
|
121
|
-
|
|
122
|
-
return {
|
|
123
|
-
id,
|
|
124
|
-
type,
|
|
125
|
-
data: null,
|
|
126
|
-
properties: {
|
|
127
|
-
icon,
|
|
128
|
-
label,
|
|
129
|
-
object,
|
|
130
|
-
},
|
|
131
|
-
};
|
|
132
|
-
},
|
|
133
|
-
}),
|
|
134
|
-
createExtension({
|
|
135
|
-
id: `${AUTOMATION_PLUGIN}/assistant-for-subject`,
|
|
136
|
-
resolver: ({ id }) => {
|
|
137
|
-
// TODO(Zan): Find util (or make one). Effect schema!!
|
|
138
|
-
if (!id.endsWith('~assistant')) {
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const [subjectId] = id.split('~');
|
|
143
|
-
const { spaceId, objectId } = parseId(subjectId);
|
|
144
|
-
const spaces = toSignal(
|
|
145
|
-
(onChange) => client.spaces.subscribe(() => onChange()).unsubscribe,
|
|
146
|
-
() => client.spaces.get(),
|
|
147
|
-
);
|
|
148
|
-
const space = spaces?.find(
|
|
149
|
-
(space) => space.id === spaceId && space.state.get() === SpaceState.SPACE_READY,
|
|
150
|
-
);
|
|
151
|
-
if (!objectId) {
|
|
152
|
-
// TODO(wittjosiah): Support assistant for arbitrary subjects.
|
|
153
|
-
// This is to ensure that the assistant panel is not stuck on an old object.
|
|
154
|
-
return {
|
|
155
|
-
id,
|
|
156
|
-
type: 'orphan-automation-for-subject',
|
|
157
|
-
data: null,
|
|
158
|
-
properties: {
|
|
159
|
-
icon: 'ph--atom--regular',
|
|
160
|
-
label: ['assistant panel label', { ns: AUTOMATION_PLUGIN }],
|
|
161
|
-
object: null,
|
|
162
|
-
space,
|
|
163
|
-
},
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
const [object] = memoizeQuery(space, { id: objectId });
|
|
168
|
-
|
|
169
|
-
return {
|
|
170
|
-
id,
|
|
171
|
-
type: 'orphan-automation-for-subject',
|
|
172
|
-
data: null,
|
|
173
|
-
properties: {
|
|
174
|
-
icon: 'ph--atom--regular',
|
|
175
|
-
label: ['assistant panel label', { ns: AUTOMATION_PLUGIN }],
|
|
176
|
-
object,
|
|
177
|
-
},
|
|
178
|
-
};
|
|
179
|
-
},
|
|
180
|
-
}),
|
|
181
|
-
];
|
|
182
|
-
},
|
|
183
|
-
},
|
|
184
|
-
surface: {
|
|
185
|
-
component: ({ data, role }) => {
|
|
186
|
-
switch (role) {
|
|
187
|
-
case 'complementary--assistant':
|
|
188
|
-
return <AssistantPanel subject={data.subject as any} />;
|
|
189
|
-
case 'complementary--automation': {
|
|
190
|
-
const object = data.subject;
|
|
191
|
-
const space = isEchoObject(object) ? getSpace(object) : undefined;
|
|
192
|
-
if (space) {
|
|
193
|
-
invariant(isEchoObject(object));
|
|
194
|
-
return <AutomationPanel space={space} object={object} />;
|
|
195
|
-
}
|
|
196
|
-
break;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return null;
|
|
201
|
-
},
|
|
202
|
-
},
|
|
203
|
-
intent: {
|
|
204
|
-
resolver: (intent) => {},
|
|
205
|
-
},
|
|
206
|
-
},
|
|
207
|
-
};
|
|
208
|
-
};
|
|
49
|
+
}),
|
|
50
|
+
],
|
|
51
|
+
}),
|
|
52
|
+
defineModule({
|
|
53
|
+
id: `${meta.id}/module/schema`,
|
|
54
|
+
activatesOn: ClientEvents.SetupSchema,
|
|
55
|
+
activate: () => [
|
|
56
|
+
contributes(ClientCapabilities.SystemSchema, [ChainType, ChainPromptType, FunctionTrigger, ServiceType]),
|
|
57
|
+
contributes(ClientCapabilities.Schema, [AIChatType]),
|
|
58
|
+
],
|
|
59
|
+
}),
|
|
60
|
+
defineModule({
|
|
61
|
+
id: `${meta.id}/module/complementary-panels`,
|
|
62
|
+
activatesOn: Events.Startup,
|
|
63
|
+
activate: () => [
|
|
64
|
+
contributes(DeckCapabilities.ComplementaryPanel, {
|
|
65
|
+
id: 'service-registry',
|
|
66
|
+
label: ['service registry label', { ns: AUTOMATION_PLUGIN }],
|
|
67
|
+
icon: 'ph--plugs--regular',
|
|
68
|
+
}),
|
|
69
|
+
contributes(DeckCapabilities.ComplementaryPanel, {
|
|
70
|
+
id: 'automation',
|
|
71
|
+
label: ['automation panel label', { ns: AUTOMATION_PLUGIN }],
|
|
72
|
+
icon: 'ph--magic-wand--regular',
|
|
73
|
+
}),
|
|
74
|
+
],
|
|
75
|
+
}),
|
|
76
|
+
defineModule({
|
|
77
|
+
id: `${meta.id}/module/react-surface`,
|
|
78
|
+
activatesOn: Events.SetupSurfaces,
|
|
79
|
+
activate: ReactSurface,
|
|
80
|
+
}),
|
|
81
|
+
defineModule({
|
|
82
|
+
id: `${meta.id}/module/app-graph-builder`,
|
|
83
|
+
activatesOn: Events.SetupAppGraph,
|
|
84
|
+
activate: AppGraphBuilder,
|
|
85
|
+
}),
|
|
86
|
+
defineModule({
|
|
87
|
+
id: `${meta.id}/module/intent-resolver`,
|
|
88
|
+
activatesOn: Events.SetupIntents,
|
|
89
|
+
activate: IntentResolver,
|
|
90
|
+
}),
|
|
91
|
+
]);
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import '@dxos-theme';
|
|
6
|
+
|
|
7
|
+
import { type StoryObj, type Meta } from '@storybook/react';
|
|
8
|
+
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
9
|
+
|
|
10
|
+
import { Capabilities, IntentPlugin, Surface, useCapabilities, useIntentDispatcher } from '@dxos/app-framework';
|
|
11
|
+
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
12
|
+
import { Message, type Tool } from '@dxos/artifact';
|
|
13
|
+
import { capabilities, genericTools, localServiceEndpoints, type IsObject } from '@dxos/artifact-testing';
|
|
14
|
+
import { AIServiceClientImpl } from '@dxos/assistant';
|
|
15
|
+
import { createStatic, ObjectId } from '@dxos/echo-schema';
|
|
16
|
+
import { EdgeHttpClient } from '@dxos/edge-client';
|
|
17
|
+
import { invariant } from '@dxos/invariant';
|
|
18
|
+
import { DXN, QueueSubspaceTags, SpaceId } from '@dxos/keys';
|
|
19
|
+
import { ChessPlugin } from '@dxos/plugin-chess';
|
|
20
|
+
import { ChessType } from '@dxos/plugin-chess/types';
|
|
21
|
+
import { ClientPlugin } from '@dxos/plugin-client';
|
|
22
|
+
import { MapPlugin } from '@dxos/plugin-map';
|
|
23
|
+
import { SpacePlugin } from '@dxos/plugin-space';
|
|
24
|
+
import { TablePlugin } from '@dxos/plugin-table';
|
|
25
|
+
import { useSpace } from '@dxos/react-client/echo';
|
|
26
|
+
import { useQueue } from '@dxos/react-edge-client';
|
|
27
|
+
import { IconButton, Input, Toolbar } from '@dxos/react-ui';
|
|
28
|
+
import { mx } from '@dxos/react-ui-theme';
|
|
29
|
+
import { withLayout, withSignals, withTheme } from '@dxos/storybook-utils';
|
|
30
|
+
|
|
31
|
+
import { Thread, type ThreadProps } from './components';
|
|
32
|
+
import { ChatProcessor } from './hooks';
|
|
33
|
+
import { createProcessorOptions } from './testing';
|
|
34
|
+
import translations from './translations';
|
|
35
|
+
|
|
36
|
+
const endpoints = localServiceEndpoints;
|
|
37
|
+
|
|
38
|
+
type RenderProps = {
|
|
39
|
+
items?: IsObject[];
|
|
40
|
+
prompts?: string[];
|
|
41
|
+
} & Pick<ThreadProps, 'debug'>;
|
|
42
|
+
|
|
43
|
+
// TODO(burdon): Use ChatContainer.
|
|
44
|
+
const Render = ({ items: _items, prompts = [], ...props }: RenderProps) => {
|
|
45
|
+
const space = useSpace();
|
|
46
|
+
const artifactDefinitions = useCapabilities(Capabilities.ArtifactDefinition);
|
|
47
|
+
const tools = useMemo<Tool[]>(
|
|
48
|
+
() => [...genericTools, ...artifactDefinitions.flatMap((definition) => definition.tools)],
|
|
49
|
+
[genericTools, artifactDefinitions],
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const [aiClient] = useState(() => new AIServiceClientImpl({ endpoint: endpoints.ai }));
|
|
53
|
+
const [edgeClient] = useState(() => new EdgeHttpClient(endpoints.edge));
|
|
54
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
55
|
+
const processor = useMemo<ChatProcessor | undefined>(() => {
|
|
56
|
+
if (!space) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return new ChatProcessor(
|
|
61
|
+
aiClient,
|
|
62
|
+
tools,
|
|
63
|
+
{
|
|
64
|
+
space,
|
|
65
|
+
dispatch,
|
|
66
|
+
},
|
|
67
|
+
createProcessorOptions(artifactDefinitions.map((definition) => definition.instructions)),
|
|
68
|
+
);
|
|
69
|
+
}, [aiClient, tools, space, dispatch, artifactDefinitions]);
|
|
70
|
+
|
|
71
|
+
// Queue.
|
|
72
|
+
const [queueDxn, setQueueDxn] = useState(() => randomQueueDxn());
|
|
73
|
+
const queue = useQueue<Message>(edgeClient, DXN.tryParse(queueDxn));
|
|
74
|
+
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
if (queue?.items.length === 0 && !queue.isLoading && prompts.length > 0) {
|
|
77
|
+
queue.append([
|
|
78
|
+
createStatic(Message, {
|
|
79
|
+
role: 'assistant',
|
|
80
|
+
content: prompts.map(
|
|
81
|
+
(prompt) =>
|
|
82
|
+
({
|
|
83
|
+
type: 'json',
|
|
84
|
+
disposition: 'suggest',
|
|
85
|
+
json: JSON.stringify({ text: prompt }),
|
|
86
|
+
}) as const,
|
|
87
|
+
),
|
|
88
|
+
}),
|
|
89
|
+
]);
|
|
90
|
+
}
|
|
91
|
+
}, [queueDxn, prompts, queue?.items.length, queue?.isLoading]);
|
|
92
|
+
|
|
93
|
+
// State.
|
|
94
|
+
const artifactItems: any[] = []; // TODO(burdon): Query from space.
|
|
95
|
+
const messages = [...(queue?.items ?? []), ...(processor?.messages.value ?? [])];
|
|
96
|
+
|
|
97
|
+
const handleSubmit = processor
|
|
98
|
+
? async (message: string) => {
|
|
99
|
+
invariant(processor);
|
|
100
|
+
if (processor.streaming.value) {
|
|
101
|
+
await processor.cancel();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
invariant(queue);
|
|
105
|
+
await processor.request(message, {
|
|
106
|
+
history: queue.items,
|
|
107
|
+
onComplete: (messages) => {
|
|
108
|
+
queue.append(messages);
|
|
109
|
+
},
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
: undefined;
|
|
113
|
+
|
|
114
|
+
const handleSuggest = useCallback(
|
|
115
|
+
(text: string) => {
|
|
116
|
+
void handleSubmit?.(text);
|
|
117
|
+
},
|
|
118
|
+
[handleSubmit],
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
const handleDelete = useCallback(
|
|
122
|
+
(id: string) => {
|
|
123
|
+
invariant(ObjectId.isValid(id), 'Invalid message id');
|
|
124
|
+
void queue?.delete([id]);
|
|
125
|
+
},
|
|
126
|
+
[queue],
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
return (
|
|
130
|
+
<div className='grid grid-cols-2 w-full h-full divide-x divide-separator overflow-hidden'>
|
|
131
|
+
{/* Thread */}
|
|
132
|
+
<div className='flex flex-col gap-4 overflow-hidden'>
|
|
133
|
+
<Toolbar.Root classNames='p-2'>
|
|
134
|
+
<Input.Root>
|
|
135
|
+
<Input.TextInput
|
|
136
|
+
spellCheck={false}
|
|
137
|
+
placeholder='Queue DXN'
|
|
138
|
+
value={queueDxn}
|
|
139
|
+
// onClick={() => setQueueDxn('')} Why?????
|
|
140
|
+
onChange={(ev) => setQueueDxn(ev.target.value)}
|
|
141
|
+
/>
|
|
142
|
+
<IconButton
|
|
143
|
+
iconOnly
|
|
144
|
+
label='Copy DXN'
|
|
145
|
+
icon='ph--copy--regular'
|
|
146
|
+
onClick={() => navigator.clipboard.writeText(queueDxn)}
|
|
147
|
+
/>
|
|
148
|
+
<IconButton
|
|
149
|
+
iconOnly
|
|
150
|
+
label='Clear history'
|
|
151
|
+
icon='ph--trash--regular'
|
|
152
|
+
onClick={() => setQueueDxn(randomQueueDxn())}
|
|
153
|
+
/>
|
|
154
|
+
<IconButton iconOnly label='Stop' icon='ph--stop--regular' onClick={() => processor?.cancel()} />
|
|
155
|
+
</Input.Root>
|
|
156
|
+
</Toolbar.Root>
|
|
157
|
+
|
|
158
|
+
<Thread
|
|
159
|
+
messages={messages}
|
|
160
|
+
streaming={processor?.streaming.value}
|
|
161
|
+
onSubmit={processor ? handleSubmit : undefined}
|
|
162
|
+
onSuggest={processor ? handleSuggest : undefined}
|
|
163
|
+
onDelete={processor ? handleDelete : undefined}
|
|
164
|
+
{...props}
|
|
165
|
+
/>
|
|
166
|
+
</div>
|
|
167
|
+
|
|
168
|
+
{/* Artifacts Deck/Mosaic */}
|
|
169
|
+
<div className='overflow-hidden grid grid-rows-[2fr_1fr] divide-y divide-separator'>
|
|
170
|
+
{artifactItems.length > 0 && (
|
|
171
|
+
<div className={mx('flex grow overflow-hidden', artifactItems.length === 1 && 'row-span-2')}>
|
|
172
|
+
<Surface role='canvas-node' limit={1} data={artifactItems[0]} />
|
|
173
|
+
</div>
|
|
174
|
+
)}
|
|
175
|
+
|
|
176
|
+
{artifactItems.length > 1 && (
|
|
177
|
+
<div className='flex shrink-0 overflow-hidden divide-x divide-separator'>
|
|
178
|
+
<div className='flex flex-1 h-full'>
|
|
179
|
+
{artifactItems.slice(1, 3).map((item, idx) => (
|
|
180
|
+
<Surface key={idx} role='canvas-node' limit={1} data={item} />
|
|
181
|
+
))}
|
|
182
|
+
</div>
|
|
183
|
+
</div>
|
|
184
|
+
)}
|
|
185
|
+
</div>
|
|
186
|
+
</div>
|
|
187
|
+
);
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
const randomQueueDxn = () =>
|
|
191
|
+
new DXN(DXN.kind.QUEUE, [QueueSubspaceTags.DATA, SpaceId.random(), ObjectId.random()]).toString();
|
|
192
|
+
|
|
193
|
+
const meta: Meta<typeof Render> = {
|
|
194
|
+
title: 'plugins/plugin-automation/artifacts',
|
|
195
|
+
render: Render,
|
|
196
|
+
decorators: [
|
|
197
|
+
withSignals,
|
|
198
|
+
withPluginManager({
|
|
199
|
+
plugins: [
|
|
200
|
+
ClientPlugin({
|
|
201
|
+
onClientInitialized: async (_, client) => {
|
|
202
|
+
await client.halo.createIdentity();
|
|
203
|
+
},
|
|
204
|
+
}),
|
|
205
|
+
SpacePlugin({ observability: false }),
|
|
206
|
+
IntentPlugin(),
|
|
207
|
+
ChessPlugin(),
|
|
208
|
+
MapPlugin(),
|
|
209
|
+
TablePlugin(),
|
|
210
|
+
],
|
|
211
|
+
capabilities,
|
|
212
|
+
}),
|
|
213
|
+
withTheme,
|
|
214
|
+
withLayout({ fullscreen: true, tooltips: true }),
|
|
215
|
+
],
|
|
216
|
+
parameters: {
|
|
217
|
+
translations,
|
|
218
|
+
},
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
export default meta;
|
|
222
|
+
|
|
223
|
+
type Story = StoryObj<typeof Render>;
|
|
224
|
+
|
|
225
|
+
export const Default: Story = {
|
|
226
|
+
args: {
|
|
227
|
+
debug: true,
|
|
228
|
+
prompts: ['Ask me a question', 'Show me a chess puzzle'],
|
|
229
|
+
},
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
export const WithInitialItems: Story = {
|
|
233
|
+
args: {
|
|
234
|
+
debug: true,
|
|
235
|
+
items: [
|
|
236
|
+
createStatic(ChessType, {
|
|
237
|
+
fen: 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1',
|
|
238
|
+
}),
|
|
239
|
+
],
|
|
240
|
+
},
|
|
241
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { contributes, type PluginsContext } from '@dxos/app-framework';
|
|
6
|
+
import { AIServiceClientImpl } from '@dxos/assistant';
|
|
7
|
+
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
8
|
+
|
|
9
|
+
import { AutomationCapabilities } from './capabilities';
|
|
10
|
+
|
|
11
|
+
// TODO(wittjosiah): Factor out.
|
|
12
|
+
const DEFAULT_AI_SERVICE_URL = 'http://localhost:8788';
|
|
13
|
+
|
|
14
|
+
export default (context: PluginsContext) => {
|
|
15
|
+
const client = context.requestCapability(ClientCapabilities.Client);
|
|
16
|
+
const endpoint = client.config.values.runtime?.services?.ai?.server ?? DEFAULT_AI_SERVICE_URL;
|
|
17
|
+
const aiClient = new AIServiceClientImpl({ endpoint });
|
|
18
|
+
return contributes(AutomationCapabilities.AiClient, aiClient);
|
|
19
|
+
};
|