@dxos/plugin-automation 0.8.4-main.406dc2a → 0.8.4-main.548089c
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-W6K45EP4.mjs +11 -0
- package/dist/lib/browser/{AutomationSettings-3EYSPFKB.mjs → AutomationSettings-YGXYZZEU.mjs} +6 -7
- package/dist/lib/{node-esm/AutomationSettings-WKSMWITV.mjs.map → browser/AutomationSettings-YGXYZZEU.mjs.map} +1 -1
- package/dist/lib/browser/FunctionsContainer-JIFRD7DW.mjs +151 -0
- package/dist/lib/browser/FunctionsContainer-JIFRD7DW.mjs.map +7 -0
- package/dist/lib/browser/{FunctionsPanel-NRIKAPQV.mjs → FunctionsPanel-CRW6SJUN.mjs} +3 -3
- package/dist/lib/browser/{app-graph-builder-DV5HMFX4.mjs → app-graph-builder-W7LLC6XW.mjs} +7 -7
- package/dist/lib/browser/app-graph-builder-W7LLC6XW.mjs.map +7 -0
- package/dist/lib/browser/{chunk-VL3KSDVL.mjs → chunk-DLZNSNOV.mjs} +18 -17
- package/dist/lib/browser/chunk-DLZNSNOV.mjs.map +7 -0
- package/dist/lib/browser/{chunk-DK7BLEKU.mjs → chunk-HUHVG4BU.mjs} +5 -5
- package/dist/lib/browser/{chunk-SUKAEYF3.mjs → chunk-JW7XSPYW.mjs} +8 -8
- package/dist/lib/browser/chunk-JW7XSPYW.mjs.map +7 -0
- package/dist/lib/browser/chunk-LZQFZO3B.mjs +17 -0
- package/dist/lib/browser/chunk-LZQFZO3B.mjs.map +7 -0
- package/dist/lib/browser/{chunk-MVPRI3DB.mjs → chunk-RYEK6OMM.mjs} +20 -6
- package/dist/lib/browser/chunk-RYEK6OMM.mjs.map +7 -0
- package/dist/lib/browser/{chunk-DLLE4FKP.mjs → chunk-TWWFNOIR.mjs} +27 -12
- package/dist/lib/browser/chunk-TWWFNOIR.mjs.map +7 -0
- package/dist/lib/browser/{chunk-5ARH77PV.mjs → chunk-XAKZ4ANY.mjs} +2 -2
- package/dist/lib/browser/chunk-XAKZ4ANY.mjs.map +7 -0
- package/dist/lib/browser/{chunk-VGBZKM3O.mjs → chunk-YBPJCY3F.mjs} +2 -2
- package/dist/lib/browser/compute-runtime-EIQTHJFZ.mjs +113 -0
- package/dist/lib/browser/compute-runtime-EIQTHJFZ.mjs.map +7 -0
- package/dist/lib/browser/hooks/index.mjs +3 -4
- package/dist/lib/browser/index.mjs +17 -10
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-D2OHKQRR.mjs → intent-resolver-5HR7M7T6.mjs} +8 -8
- package/dist/lib/browser/intent-resolver-5HR7M7T6.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-G7CG7BML.mjs → react-surface-LXPASRXE.mjs} +6 -5
- package/dist/lib/browser/react-surface-LXPASRXE.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +2 -2
- package/dist/lib/node-esm/{AutomationPanel-EETYIR35.mjs → AutomationPanel-NI6EHUWH.mjs} +4 -4
- package/dist/lib/node-esm/{AutomationSettings-WKSMWITV.mjs → AutomationSettings-3BAIEDRA.mjs} +6 -7
- package/dist/lib/node-esm/FunctionsContainer-MK76KBEW.mjs +152 -0
- package/dist/lib/node-esm/FunctionsContainer-MK76KBEW.mjs.map +7 -0
- package/dist/lib/node-esm/{FunctionsPanel-SAMRTELO.mjs → FunctionsPanel-RVVCS6VH.mjs} +3 -3
- package/dist/lib/node-esm/{app-graph-builder-TR2WXPX2.mjs → app-graph-builder-SLQOO7GH.mjs} +7 -7
- package/dist/lib/node-esm/app-graph-builder-SLQOO7GH.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-5MQJPJR2.mjs → chunk-CEVIVRTY.mjs} +6 -2
- package/dist/lib/node-esm/chunk-CEVIVRTY.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-B7N3H45O.mjs → chunk-CPJ33QGN.mjs} +5 -5
- package/dist/lib/node-esm/{chunk-CJUI6AKX.mjs → chunk-ECJKIUBO.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-WHCSOUNN.mjs → chunk-KB7NFEYY.mjs} +2 -2
- package/dist/lib/node-esm/chunk-KB7NFEYY.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-QCA543ZR.mjs → chunk-LMTQG3PX.mjs} +20 -6
- package/dist/lib/node-esm/chunk-LMTQG3PX.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-AKHETVIQ.mjs → chunk-O4KCL7XS.mjs} +18 -17
- package/dist/lib/node-esm/chunk-O4KCL7XS.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-YQXW3JXD.mjs → chunk-RVK52XGK.mjs} +27 -12
- package/dist/lib/node-esm/chunk-RVK52XGK.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-J3XEBEIE.mjs → chunk-W76WUTZY.mjs} +8 -8
- package/dist/lib/node-esm/chunk-W76WUTZY.mjs.map +7 -0
- package/dist/lib/node-esm/compute-runtime-URROOC34.mjs +114 -0
- package/dist/lib/node-esm/compute-runtime-URROOC34.mjs.map +7 -0
- package/dist/lib/node-esm/hooks/index.mjs +3 -4
- package/dist/lib/node-esm/index.mjs +17 -10
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/{intent-resolver-2LGBVXT5.mjs → intent-resolver-KDRYB5BC.mjs} +8 -8
- package/dist/lib/node-esm/intent-resolver-KDRYB5BC.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{react-surface-OMZSBDHS.mjs → react-surface-AFCHOTCJ.mjs} +6 -5
- package/dist/lib/node-esm/react-surface-AFCHOTCJ.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +2 -2
- package/dist/types/src/capabilities/capabilities.d.ts +2 -1
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
- package/dist/types/src/capabilities/compute-runtime.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +2 -2
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts +3 -0
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsContainer.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsPanel/FunctionsPanel.d.ts.map +1 -1
- package/dist/types/src/components/FunctionsRegistry/FunctionsRegistry.d.ts +8 -0
- package/dist/types/src/components/FunctionsRegistry/FunctionsRegistry.d.ts.map +1 -0
- package/dist/types/src/components/FunctionsRegistry/index.d.ts +2 -0
- package/dist/types/src/components/FunctionsRegistry/index.d.ts.map +1 -0
- package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts +2 -2
- package/dist/types/src/components/TriggerEditor/FunctionInputEditor.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +3 -3
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts +3 -1
- package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeRuntimeCallback.d.ts.map +1 -1
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts +2 -2
- package/dist/types/src/hooks/useTriggerRuntimeControls.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +3 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +36 -34
- package/src/AutomationPlugin.tsx +2 -2
- package/src/capabilities/app-graph-builder.ts +6 -6
- package/src/capabilities/capabilities.ts +2 -9
- package/src/capabilities/compute-runtime.ts +22 -33
- package/src/capabilities/intent-resolver.ts +5 -5
- package/src/capabilities/react-surface.tsx +2 -1
- package/src/components/AutomationPanel/AutomationPanel.stories.tsx +3 -4
- package/src/components/AutomationPanel/AutomationPanel.tsx +31 -30
- package/src/components/FunctionsContainer.tsx +7 -0
- package/src/components/FunctionsPanel/FunctionsPanel.tsx +32 -13
- package/src/components/FunctionsRegistry/FunctionsRegistry.tsx +135 -0
- package/src/components/FunctionsRegistry/index.ts +5 -0
- package/src/components/TriggerEditor/FunctionInputEditor.tsx +2 -2
- package/src/components/TriggerEditor/SpecSelector.tsx +4 -4
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +14 -13
- package/src/components/TriggerEditor/TriggerEditor.tsx +10 -10
- package/src/hooks/useComputeRuntimeCallback.ts +3 -1
- package/src/hooks/useTriggerRuntimeControls.ts +4 -3
- package/src/index.ts +1 -0
- package/src/meta.ts +5 -2
- package/src/translations.ts +3 -0
- package/dist/lib/browser/AutomationPanel-3PHA5FTJ.mjs +0 -11
- package/dist/lib/browser/FunctionsContainer-HHBMPUOD.mjs +0 -36
- package/dist/lib/browser/FunctionsContainer-HHBMPUOD.mjs.map +0 -7
- package/dist/lib/browser/app-graph-builder-DV5HMFX4.mjs.map +0 -7
- package/dist/lib/browser/chunk-5ARH77PV.mjs.map +0 -7
- package/dist/lib/browser/chunk-6TUZQIEN.mjs +0 -14
- package/dist/lib/browser/chunk-6TUZQIEN.mjs.map +0 -7
- package/dist/lib/browser/chunk-DLLE4FKP.mjs.map +0 -7
- package/dist/lib/browser/chunk-MVPRI3DB.mjs.map +0 -7
- package/dist/lib/browser/chunk-SUKAEYF3.mjs.map +0 -7
- package/dist/lib/browser/chunk-VL3KSDVL.mjs.map +0 -7
- package/dist/lib/browser/chunk-WWURMV25.mjs +0 -13
- package/dist/lib/browser/chunk-WWURMV25.mjs.map +0 -7
- package/dist/lib/browser/compute-runtime-YJREH6WP.mjs +0 -160
- package/dist/lib/browser/compute-runtime-YJREH6WP.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-D2OHKQRR.mjs.map +0 -7
- package/dist/lib/browser/react-surface-G7CG7BML.mjs.map +0 -7
- package/dist/lib/node-esm/FunctionsContainer-ZKVOBUHV.mjs +0 -37
- package/dist/lib/node-esm/FunctionsContainer-ZKVOBUHV.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-TR2WXPX2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-2EWXIFEK.mjs +0 -16
- package/dist/lib/node-esm/chunk-2EWXIFEK.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-5MQJPJR2.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-AKHETVIQ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-J3XEBEIE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-QCA543ZR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WHCSOUNN.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YQXW3JXD.mjs.map +0 -7
- package/dist/lib/node-esm/compute-runtime-CMEPAYND.mjs +0 -161
- package/dist/lib/node-esm/compute-runtime-CMEPAYND.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-2LGBVXT5.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-OMZSBDHS.mjs.map +0 -7
- /package/dist/lib/browser/{AutomationPanel-3PHA5FTJ.mjs.map → AutomationPanel-W6K45EP4.mjs.map} +0 -0
- /package/dist/lib/browser/{FunctionsPanel-NRIKAPQV.mjs.map → FunctionsPanel-CRW6SJUN.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-DK7BLEKU.mjs.map → chunk-HUHVG4BU.mjs.map} +0 -0
- /package/dist/lib/browser/{chunk-VGBZKM3O.mjs.map → chunk-YBPJCY3F.mjs.map} +0 -0
- /package/dist/lib/node-esm/{AutomationPanel-EETYIR35.mjs.map → AutomationPanel-NI6EHUWH.mjs.map} +0 -0
- /package/dist/lib/{browser/AutomationSettings-3EYSPFKB.mjs.map → node-esm/AutomationSettings-3BAIEDRA.mjs.map} +0 -0
- /package/dist/lib/node-esm/{FunctionsPanel-SAMRTELO.mjs.map → FunctionsPanel-RVVCS6VH.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-B7N3H45O.mjs.map → chunk-CPJ33QGN.mjs.map} +0 -0
- /package/dist/lib/node-esm/{chunk-CJUI6AKX.mjs.map → chunk-ECJKIUBO.mjs.map} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-automation",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.548089c",
|
|
4
4
|
"description": "Prompt chain plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -49,53 +49,55 @@
|
|
|
49
49
|
"@effect/platform-browser": "0.72.0",
|
|
50
50
|
"@preact-signals/safe-react": "^0.9.0",
|
|
51
51
|
"@preact/signals-core": "^1.12.1",
|
|
52
|
-
"@dxos/ai": "0.8.4-main.
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/assistant": "0.8.4-main.
|
|
55
|
-
"@dxos/conductor": "0.8.4-main.
|
|
56
|
-
"@dxos/context": "0.8.4-main.
|
|
57
|
-
"@dxos/functions": "0.8.4-main.
|
|
58
|
-
"@dxos/
|
|
59
|
-
"@dxos/
|
|
60
|
-
"@dxos/echo": "0.8.4-main.
|
|
61
|
-
"@dxos/live-object": "0.8.4-main.
|
|
62
|
-
"@dxos/log": "0.8.4-main.
|
|
63
|
-
"@dxos/
|
|
64
|
-
"@dxos/
|
|
65
|
-
"@dxos/plugin-
|
|
66
|
-
"@dxos/
|
|
67
|
-
"@dxos/
|
|
68
|
-
"@dxos/
|
|
69
|
-
"@dxos/react-ui-components": "0.8.4-main.
|
|
70
|
-
"@dxos/
|
|
71
|
-
"@dxos/react-ui-
|
|
72
|
-
"@dxos/react-ui-
|
|
73
|
-
"@dxos/
|
|
74
|
-
"@dxos/
|
|
75
|
-
"@dxos/
|
|
76
|
-
"@dxos/
|
|
52
|
+
"@dxos/ai": "0.8.4-main.548089c",
|
|
53
|
+
"@dxos/app-framework": "0.8.4-main.548089c",
|
|
54
|
+
"@dxos/assistant": "0.8.4-main.548089c",
|
|
55
|
+
"@dxos/conductor": "0.8.4-main.548089c",
|
|
56
|
+
"@dxos/context": "0.8.4-main.548089c",
|
|
57
|
+
"@dxos/functions": "0.8.4-main.548089c",
|
|
58
|
+
"@dxos/functions-runtime": "0.8.4-main.548089c",
|
|
59
|
+
"@dxos/async": "0.8.4-main.548089c",
|
|
60
|
+
"@dxos/echo": "0.8.4-main.548089c",
|
|
61
|
+
"@dxos/live-object": "0.8.4-main.548089c",
|
|
62
|
+
"@dxos/log": "0.8.4-main.548089c",
|
|
63
|
+
"@dxos/plugin-client": "0.8.4-main.548089c",
|
|
64
|
+
"@dxos/invariant": "0.8.4-main.548089c",
|
|
65
|
+
"@dxos/plugin-deck": "0.8.4-main.548089c",
|
|
66
|
+
"@dxos/plugin-graph": "0.8.4-main.548089c",
|
|
67
|
+
"@dxos/random": "0.8.4-main.548089c",
|
|
68
|
+
"@dxos/react-client": "0.8.4-main.548089c",
|
|
69
|
+
"@dxos/react-ui-components": "0.8.4-main.548089c",
|
|
70
|
+
"@dxos/plugin-space": "0.8.4-main.548089c",
|
|
71
|
+
"@dxos/react-ui-editor": "0.8.4-main.548089c",
|
|
72
|
+
"@dxos/react-ui-form": "0.8.4-main.548089c",
|
|
73
|
+
"@dxos/keys": "0.8.4-main.548089c",
|
|
74
|
+
"@dxos/react-ui-list": "0.8.4-main.548089c",
|
|
75
|
+
"@dxos/react-ui-stack": "0.8.4-main.548089c",
|
|
76
|
+
"@dxos/schema": "0.8.4-main.548089c",
|
|
77
|
+
"@dxos/util": "0.8.4-main.548089c",
|
|
78
|
+
"@dxos/types": "0.8.4-main.548089c"
|
|
77
79
|
},
|
|
78
80
|
"devDependencies": {
|
|
79
|
-
"@effect-
|
|
81
|
+
"@effect-atom/atom-react": "^0.3.4",
|
|
80
82
|
"@effect/platform": "0.92.1",
|
|
81
83
|
"@types/react": "~19.2.2",
|
|
82
|
-
"@types/react-dom": "~19.2.
|
|
84
|
+
"@types/react-dom": "~19.2.2",
|
|
83
85
|
"effect": "3.18.3",
|
|
84
86
|
"react": "~19.2.0",
|
|
85
87
|
"react-dom": "~19.2.0",
|
|
86
88
|
"vite": "7.1.9",
|
|
87
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
88
|
-
"@dxos/react-ui-theme": "0.8.4-main.
|
|
89
|
-
"@dxos/storybook-utils": "0.8.4-main.
|
|
89
|
+
"@dxos/react-ui": "0.8.4-main.548089c",
|
|
90
|
+
"@dxos/react-ui-theme": "0.8.4-main.548089c",
|
|
91
|
+
"@dxos/storybook-utils": "0.8.4-main.548089c"
|
|
90
92
|
},
|
|
91
93
|
"peerDependencies": {
|
|
92
|
-
"@effect-
|
|
94
|
+
"@effect-atom/atom-react": "^0.3.4",
|
|
93
95
|
"@effect/platform": "^0.80.12",
|
|
94
96
|
"effect": "^3.13.3",
|
|
95
97
|
"react": "^19.0.0",
|
|
96
98
|
"react-dom": "^19.0.0",
|
|
97
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
98
|
-
"@dxos/react-ui-theme": "0.8.4-main.
|
|
99
|
+
"@dxos/react-ui": "0.8.4-main.548089c",
|
|
100
|
+
"@dxos/react-ui-theme": "0.8.4-main.548089c"
|
|
99
101
|
},
|
|
100
102
|
"publishConfig": {
|
|
101
103
|
"access": "public"
|
package/src/AutomationPlugin.tsx
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Capabilities, Events, contributes, defineModule, definePlugin } from '@dxos/app-framework';
|
|
6
|
-
import {
|
|
6
|
+
import { Function, Trigger } from '@dxos/functions';
|
|
7
7
|
import { ClientCapabilities, ClientEvents } from '@dxos/plugin-client';
|
|
8
8
|
|
|
9
9
|
import { AppGraphBuilder, ComputeRuntime, IntentResolver, ReactSurface } from './capabilities';
|
|
@@ -20,7 +20,7 @@ export const AutomationPlugin = definePlugin(meta, () => [
|
|
|
20
20
|
defineModule({
|
|
21
21
|
id: `${meta.id}/module/schema`,
|
|
22
22
|
activatesOn: ClientEvents.SetupSchema,
|
|
23
|
-
activate: () => contributes(ClientCapabilities.Schema, [
|
|
23
|
+
activate: () => contributes(ClientCapabilities.Schema, [Function.Function, Trigger.Trigger]),
|
|
24
24
|
}),
|
|
25
25
|
defineModule({
|
|
26
26
|
id: `${meta.id}/module/app-graph-builder`,
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Atom } from '@effect-atom/atom-react';
|
|
6
6
|
import * as Function from 'effect/Function';
|
|
7
7
|
import * as Option from 'effect/Option';
|
|
8
8
|
|
|
9
9
|
import { Capabilities, type PluginContext, contributes } from '@dxos/app-framework';
|
|
10
10
|
import { Obj } from '@dxos/echo';
|
|
11
|
-
import {
|
|
11
|
+
import { Script } from '@dxos/functions';
|
|
12
12
|
import { ATTENDABLE_PATH_SEPARATOR, PLANK_COMPANION_TYPE } from '@dxos/plugin-deck/types';
|
|
13
13
|
import { createExtension } from '@dxos/plugin-graph';
|
|
14
14
|
import { meta as spaceMeta } from '@dxos/plugin-space';
|
|
@@ -20,7 +20,7 @@ export default (context: PluginContext) =>
|
|
|
20
20
|
createExtension({
|
|
21
21
|
id: `${meta.id}/space-settings-automation`,
|
|
22
22
|
connector: (node) =>
|
|
23
|
-
|
|
23
|
+
Atom.make((get) =>
|
|
24
24
|
Function.pipe(
|
|
25
25
|
get(node),
|
|
26
26
|
Option.flatMap((node) => (node.type === `${spaceMeta.id}/settings` ? Option.some(node) : Option.none())),
|
|
@@ -42,7 +42,7 @@ export default (context: PluginContext) =>
|
|
|
42
42
|
createExtension({
|
|
43
43
|
id: `${meta.id}/space-settings-functions`,
|
|
44
44
|
connector: (node) =>
|
|
45
|
-
|
|
45
|
+
Atom.make((get) =>
|
|
46
46
|
Function.pipe(
|
|
47
47
|
get(node),
|
|
48
48
|
Option.flatMap((node) => (node.type === `${spaceMeta.id}/settings` ? Option.some(node) : Option.none())),
|
|
@@ -64,10 +64,10 @@ export default (context: PluginContext) =>
|
|
|
64
64
|
createExtension({
|
|
65
65
|
id: `${meta.id}/script-companion`,
|
|
66
66
|
connector: (node) =>
|
|
67
|
-
|
|
67
|
+
Atom.make((get) =>
|
|
68
68
|
Function.pipe(
|
|
69
69
|
get(node),
|
|
70
|
-
Option.flatMap((node) => (Obj.instanceOf(
|
|
70
|
+
Option.flatMap((node) => (Obj.instanceOf(Script.Script, node.data) ? Option.some(node) : Option.none())),
|
|
71
71
|
Option.map((node) => [
|
|
72
72
|
{
|
|
73
73
|
id: [node.id, 'automation'].join(ATTENDABLE_PATH_SEPARATOR),
|
|
@@ -6,15 +6,8 @@ import type * as ManagedRuntime from 'effect/ManagedRuntime';
|
|
|
6
6
|
|
|
7
7
|
import { type AiService, type ToolExecutionService, type ToolResolverService } from '@dxos/ai';
|
|
8
8
|
import { defineCapability } from '@dxos/app-framework';
|
|
9
|
-
import type {
|
|
10
|
-
|
|
11
|
-
DatabaseService,
|
|
12
|
-
FunctionInvocationService,
|
|
13
|
-
InvocationTracer,
|
|
14
|
-
QueueService,
|
|
15
|
-
TriggerDispatcher,
|
|
16
|
-
TriggerStateStore,
|
|
17
|
-
} from '@dxos/functions';
|
|
9
|
+
import type { CredentialsService, DatabaseService, FunctionInvocationService, QueueService } from '@dxos/functions';
|
|
10
|
+
import type { InvocationTracer, TriggerDispatcher, TriggerStateStore } from '@dxos/functions-runtime';
|
|
18
11
|
import type { SpaceId } from '@dxos/keys';
|
|
19
12
|
|
|
20
13
|
import { meta } from '../meta';
|
|
@@ -2,28 +2,24 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import * as Toolkit from '@effect/ai/Toolkit';
|
|
6
5
|
import * as BrowserKeyValueStore from '@effect/platform-browser/BrowserKeyValueStore';
|
|
7
6
|
import * as Effect from 'effect/Effect';
|
|
8
7
|
import * as Layer from 'effect/Layer';
|
|
9
8
|
import * as ManagedRuntime from 'effect/ManagedRuntime';
|
|
10
9
|
|
|
11
10
|
import { Capabilities, type PluginContext, contributes } from '@dxos/app-framework';
|
|
12
|
-
import { makeToolExecutionServiceFromFunctions, makeToolResolverFromFunctions } from '@dxos/assistant';
|
|
11
|
+
import { GenericToolkit, makeToolExecutionServiceFromFunctions, makeToolResolverFromFunctions } from '@dxos/assistant';
|
|
13
12
|
import { Resource } from '@dxos/context';
|
|
14
13
|
import { Query, Ref } from '@dxos/echo';
|
|
14
|
+
import { CredentialsService, DatabaseService, QueueService } from '@dxos/functions';
|
|
15
15
|
import {
|
|
16
|
-
CredentialsService,
|
|
17
|
-
DatabaseService,
|
|
18
16
|
FunctionImplementationResolver,
|
|
19
|
-
|
|
17
|
+
FunctionInvocationServiceLayerWithLocalLoopbackExecutor,
|
|
20
18
|
InvocationTracer,
|
|
21
|
-
LocalFunctionExecutionService,
|
|
22
|
-
QueueService,
|
|
23
19
|
RemoteFunctionExecutionService,
|
|
24
20
|
TriggerDispatcher,
|
|
25
|
-
} from '@dxos/functions';
|
|
26
|
-
import { TriggerStateStore } from '@dxos/functions';
|
|
21
|
+
} from '@dxos/functions-runtime';
|
|
22
|
+
import { TriggerStateStore } from '@dxos/functions-runtime';
|
|
27
23
|
import { invariant } from '@dxos/invariant';
|
|
28
24
|
import { type SpaceId } from '@dxos/keys';
|
|
29
25
|
import { ClientCapabilities } from '@dxos/plugin-client';
|
|
@@ -65,15 +61,12 @@ class ComputeRuntimeProviderImpl extends Resource implements AutomationCapabilit
|
|
|
65
61
|
const serviceLayer =
|
|
66
62
|
this.#context.getCapability(Capabilities.AiServiceLayer) ?? Layer.die('AiService not found');
|
|
67
63
|
|
|
68
|
-
// TODO(dmaretskyi): Make
|
|
69
|
-
const functions = this.#context.getCapabilities(Capabilities.Functions);
|
|
64
|
+
// TODO(dmaretskyi): Make these reactive.
|
|
65
|
+
const functions = this.#context.getCapabilities(Capabilities.Functions).flat();
|
|
70
66
|
const toolkits = this.#context.getCapabilities(Capabilities.Toolkit);
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
const
|
|
74
|
-
// TODO(wittjosiah): Don't cast.
|
|
75
|
-
const toolkit = Toolkit.merge(...toolkits) as Toolkit.Toolkit<any>;
|
|
76
|
-
const handlersLayer = Layer.mergeAll(Layer.empty, ...handlers);
|
|
67
|
+
const mergedToolkit = GenericToolkit.merge(...toolkits);
|
|
68
|
+
const toolkit = mergedToolkit.toolkit;
|
|
69
|
+
const toolkitLayer = mergedToolkit.layer;
|
|
77
70
|
|
|
78
71
|
const space = client.spaces.get(spaceId);
|
|
79
72
|
invariant(space);
|
|
@@ -84,29 +77,25 @@ class ComputeRuntimeProviderImpl extends Resource implements AutomationCapabilit
|
|
|
84
77
|
Layer.mergeAll(
|
|
85
78
|
InvocationTracerLive,
|
|
86
79
|
TriggerStateStore.layerKv.pipe(Layer.provide(BrowserKeyValueStore.layerLocalStorage)),
|
|
87
|
-
makeToolResolverFromFunctions(
|
|
88
|
-
makeToolExecutionServiceFromFunctions(toolkit,
|
|
80
|
+
makeToolResolverFromFunctions(functions, toolkit),
|
|
81
|
+
makeToolExecutionServiceFromFunctions(toolkit, toolkitLayer),
|
|
89
82
|
),
|
|
90
83
|
),
|
|
91
84
|
Layer.provideMerge(
|
|
92
85
|
Layer.mergeAll(
|
|
93
|
-
|
|
86
|
+
FunctionInvocationServiceLayerWithLocalLoopbackExecutor.pipe(
|
|
87
|
+
Layer.provideMerge(FunctionImplementationResolver.layerTest({ functions })),
|
|
94
88
|
Layer.provideMerge(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
client.edge.baseUrl,
|
|
100
|
-
// If agent is not enabled do not provide spaceId because space context will be unavailable on EDGE.
|
|
101
|
-
client.config.get('runtime.client.edgeFeatures.agents') ? spaceId : undefined,
|
|
102
|
-
),
|
|
103
|
-
),
|
|
104
|
-
Layer.provideMerge(serviceLayer),
|
|
105
|
-
Layer.provideMerge(CredentialsService.layerFromDatabase()),
|
|
106
|
-
Layer.provideMerge(space ? DatabaseService.layer(space.db) : DatabaseService.notAvailable),
|
|
107
|
-
Layer.provideMerge(space ? QueueService.layer(space.queues) : QueueService.notAvailable),
|
|
89
|
+
RemoteFunctionExecutionService.fromClient(
|
|
90
|
+
client,
|
|
91
|
+
// If agent is not enabled do not provide spaceId because space context will be unavailable on EDGE.
|
|
92
|
+
client.config.get('runtime.client.edgeFeatures.agents') ? spaceId : undefined,
|
|
108
93
|
),
|
|
109
94
|
),
|
|
95
|
+
Layer.provideMerge(serviceLayer),
|
|
96
|
+
Layer.provideMerge(CredentialsService.layerFromDatabase()),
|
|
97
|
+
Layer.provideMerge(space ? DatabaseService.layer(space.db) : DatabaseService.notAvailable),
|
|
98
|
+
Layer.provideMerge(space ? QueueService.layer(space.queues) : QueueService.notAvailable),
|
|
110
99
|
),
|
|
111
100
|
),
|
|
112
101
|
),
|
|
@@ -10,8 +10,8 @@ import {
|
|
|
10
10
|
createIntent,
|
|
11
11
|
createResolver,
|
|
12
12
|
} from '@dxos/app-framework';
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
13
|
+
import { Ref } from '@dxos/echo';
|
|
14
|
+
import { Function, Script, Trigger } from '@dxos/functions';
|
|
15
15
|
import { type DXN } from '@dxos/keys';
|
|
16
16
|
import { ATTENDABLE_PATH_SEPARATOR } from '@dxos/plugin-deck/types';
|
|
17
17
|
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
@@ -24,17 +24,17 @@ export default (context: PluginContext) =>
|
|
|
24
24
|
createResolver({
|
|
25
25
|
intent: AutomationAction.CreateTriggerFromTemplate,
|
|
26
26
|
resolve: async ({ space, template, enabled = false, scriptName, input }) => {
|
|
27
|
-
const trigger =
|
|
27
|
+
const trigger = Trigger.make({ enabled, input });
|
|
28
28
|
|
|
29
29
|
// TODO(wittjosiah): Factor out function lookup by script name?
|
|
30
30
|
if (scriptName) {
|
|
31
31
|
const {
|
|
32
32
|
objects: [script],
|
|
33
|
-
} = await space.db.query(Filter.type(
|
|
33
|
+
} = await space.db.query(Filter.type(Script.Script, { name: scriptName })).run();
|
|
34
34
|
if (script) {
|
|
35
35
|
const {
|
|
36
36
|
objects: [fn],
|
|
37
|
-
} = await space.db.query(Filter.type(
|
|
37
|
+
} = await space.db.query(Filter.type(Function.Function, { source: Ref.make(script) })).run();
|
|
38
38
|
if (fn) {
|
|
39
39
|
trigger.function = Ref.make(fn);
|
|
40
40
|
}
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import { Capabilities, contributes, createSurface
|
|
7
|
+
import { Capabilities, contributes, createSurface } from '@dxos/app-framework';
|
|
8
|
+
import { useLayout } from '@dxos/app-framework/react';
|
|
8
9
|
import { Obj } from '@dxos/echo';
|
|
9
10
|
import { getSpace, parseId, useSpace } from '@dxos/react-client/echo';
|
|
10
11
|
|
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import { FunctionTrigger, FunctionType } from '@dxos/functions';
|
|
8
|
+
import { Function, Trigger } from '@dxos/functions';
|
|
10
9
|
import { useSpaces } from '@dxos/react-client/echo';
|
|
11
10
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
12
11
|
import { withTheme } from '@dxos/react-ui/testing';
|
|
@@ -36,10 +35,10 @@ const meta = {
|
|
|
36
35
|
withClientProvider({
|
|
37
36
|
createIdentity: true,
|
|
38
37
|
createSpace: true,
|
|
39
|
-
types: [
|
|
38
|
+
types: [Function.Function, Trigger.Trigger],
|
|
40
39
|
onCreateSpace: ({ space }) => {
|
|
41
40
|
for (const fn of functions) {
|
|
42
|
-
space.db.add(
|
|
41
|
+
space.db.add(Function.make(fn));
|
|
43
42
|
}
|
|
44
43
|
},
|
|
45
44
|
}),
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import * as Array from 'effect/Array';
|
|
6
|
-
import * as
|
|
6
|
+
import * as EFn from 'effect/Function';
|
|
7
7
|
import * as Match from 'effect/Match';
|
|
8
8
|
import * as Schema from 'effect/Schema';
|
|
9
9
|
import React, { useMemo, useState } from 'react';
|
|
10
10
|
|
|
11
11
|
import { Filter, Obj, Tag } from '@dxos/echo';
|
|
12
|
-
import {
|
|
12
|
+
import { Function, Script, Trigger } from '@dxos/functions';
|
|
13
13
|
import { useTypeOptions } from '@dxos/plugin-space';
|
|
14
14
|
import { type Client, useClient } from '@dxos/react-client';
|
|
15
15
|
import { type Space, getSpace, useQuery } from '@dxos/react-client/echo';
|
|
@@ -17,7 +17,8 @@ import { Clipboard, IconButton, Input, Separator, type ThemedClassName, useTrans
|
|
|
17
17
|
import { ControlItem, controlItemClasses } from '@dxos/react-ui-form';
|
|
18
18
|
import { List } from '@dxos/react-ui-list';
|
|
19
19
|
import { ghostHover, mx } from '@dxos/react-ui-theme';
|
|
20
|
-
import {
|
|
20
|
+
import { View } from '@dxos/schema';
|
|
21
|
+
import { Project } from '@dxos/types';
|
|
21
22
|
|
|
22
23
|
import { meta } from '../../meta';
|
|
23
24
|
import { TriggerEditor, type TriggerEditorProps } from '../TriggerEditor';
|
|
@@ -27,7 +28,7 @@ const grid = 'grid grid-cols-[40px_1fr_32px] min-bs-[2.5rem]';
|
|
|
27
28
|
export type AutomationPanelProps = ThemedClassName<{
|
|
28
29
|
space: Space;
|
|
29
30
|
object?: Obj.Any;
|
|
30
|
-
initialTrigger?:
|
|
31
|
+
initialTrigger?: Trigger.Trigger;
|
|
31
32
|
onDone?: () => void;
|
|
32
33
|
}>;
|
|
33
34
|
|
|
@@ -35,28 +36,28 @@ export type AutomationPanelProps = ThemedClassName<{
|
|
|
35
36
|
export const AutomationPanel = ({ classNames, space, object, initialTrigger, onDone }: AutomationPanelProps) => {
|
|
36
37
|
const { t } = useTranslation(meta.id);
|
|
37
38
|
const client = useClient();
|
|
38
|
-
const functions = useQuery(space, Filter.type(
|
|
39
|
-
const triggers = useQuery(space, Filter.type(
|
|
39
|
+
const functions = useQuery(space, Filter.type(Function.Function));
|
|
40
|
+
const triggers = useQuery(space, Filter.type(Trigger.Trigger));
|
|
40
41
|
const filteredTriggers = useMemo(() => {
|
|
41
42
|
return object ? triggers.filter(triggerMatch(object)) : triggers;
|
|
42
43
|
}, [object, triggers]);
|
|
43
44
|
const tags = useQuery(space, Filter.type(Tag.Tag));
|
|
44
45
|
const types = useTypeOptions({ space, annotation: ['dynamic', 'limited-static', 'object-form'] });
|
|
45
46
|
|
|
46
|
-
const [trigger, setTrigger] = useState<
|
|
47
|
-
const [selected, setSelected] = useState<
|
|
47
|
+
const [trigger, setTrigger] = useState<Trigger.Trigger | undefined>(initialTrigger);
|
|
48
|
+
const [selected, setSelected] = useState<Trigger.Trigger>();
|
|
48
49
|
|
|
49
|
-
const handleSelect = (trigger:
|
|
50
|
+
const handleSelect = (trigger: Trigger.Trigger) => {
|
|
50
51
|
setTrigger(trigger);
|
|
51
52
|
setSelected(trigger);
|
|
52
53
|
};
|
|
53
54
|
|
|
54
55
|
const handleAdd = () => {
|
|
55
|
-
setTrigger(
|
|
56
|
+
setTrigger(Trigger.make({}));
|
|
56
57
|
setSelected(undefined);
|
|
57
58
|
};
|
|
58
59
|
|
|
59
|
-
const handleDelete = (trigger:
|
|
60
|
+
const handleDelete = (trigger: Trigger.Trigger) => {
|
|
60
61
|
space.db.remove(trigger);
|
|
61
62
|
setTrigger(undefined);
|
|
62
63
|
setSelected(undefined);
|
|
@@ -66,7 +67,7 @@ export const AutomationPanel = ({ classNames, space, object, initialTrigger, onD
|
|
|
66
67
|
if (selected) {
|
|
67
68
|
Object.assign(selected, trigger);
|
|
68
69
|
} else {
|
|
69
|
-
space.db.add(
|
|
70
|
+
space.db.add(Trigger.make(trigger));
|
|
70
71
|
}
|
|
71
72
|
|
|
72
73
|
setTrigger(undefined);
|
|
@@ -98,20 +99,20 @@ export const AutomationPanel = ({ classNames, space, object, initialTrigger, onD
|
|
|
98
99
|
return (
|
|
99
100
|
<div className={mx(controlItemClasses, classNames)}>
|
|
100
101
|
{filteredTriggers.length > 0 && (
|
|
101
|
-
<List.Root<
|
|
102
|
+
<List.Root<Trigger.Trigger>
|
|
102
103
|
items={filteredTriggers}
|
|
103
|
-
isItem={Schema.is(
|
|
104
|
+
isItem={Schema.is(Trigger.Trigger)}
|
|
104
105
|
getId={(field) => field.id}
|
|
105
106
|
>
|
|
106
107
|
{({ items: filteredTriggers }) => (
|
|
107
|
-
<div role='list' className='flex flex-col
|
|
108
|
+
<div role='list' className='flex flex-col is-full'>
|
|
108
109
|
{filteredTriggers?.map((trigger) => {
|
|
109
110
|
const copyAction = getCopyAction(client, trigger);
|
|
110
111
|
return (
|
|
111
|
-
<List.Item<
|
|
112
|
+
<List.Item<Trigger.Trigger>
|
|
112
113
|
key={trigger.id}
|
|
113
114
|
item={trigger}
|
|
114
|
-
classNames={mx(grid, ghostHover, 'items-center', '
|
|
115
|
+
classNames={mx(grid, ghostHover, 'items-center', 'pli-2')}
|
|
115
116
|
>
|
|
116
117
|
<Input.Root>
|
|
117
118
|
<Input.Switch
|
|
@@ -122,7 +123,7 @@ export const AutomationPanel = ({ classNames, space, object, initialTrigger, onD
|
|
|
122
123
|
|
|
123
124
|
<div className={'flex'}>
|
|
124
125
|
<List.ItemTitle
|
|
125
|
-
classNames='
|
|
126
|
+
classNames='pli-1 cursor-pointer w-0 shrink truncate'
|
|
126
127
|
onClick={() => handleSelect(trigger)}
|
|
127
128
|
>
|
|
128
129
|
{getFunctionName(functions, trigger) ?? '∅'}
|
|
@@ -151,7 +152,7 @@ export const AutomationPanel = ({ classNames, space, object, initialTrigger, onD
|
|
|
151
152
|
);
|
|
152
153
|
};
|
|
153
154
|
|
|
154
|
-
const getCopyAction = (client: Client, trigger:
|
|
155
|
+
const getCopyAction = (client: Client, trigger: Trigger.Trigger | undefined) => {
|
|
155
156
|
if (trigger?.spec?.kind === 'email') {
|
|
156
157
|
return { translationKey: 'trigger copy email', contentProvider: () => `${getSpace(trigger)!.id}@dxos.network` };
|
|
157
158
|
}
|
|
@@ -163,7 +164,7 @@ const getCopyAction = (client: Client, trigger: FunctionTrigger | undefined) =>
|
|
|
163
164
|
return undefined;
|
|
164
165
|
};
|
|
165
166
|
|
|
166
|
-
const getWebhookUrl = (client: Client, trigger:
|
|
167
|
+
const getWebhookUrl = (client: Client, trigger: Trigger.Trigger) => {
|
|
167
168
|
const spaceId = getSpace(trigger)!.id;
|
|
168
169
|
const edgeUrl = new URL(client.config.values.runtime!.services!.edge!.url!);
|
|
169
170
|
const isSecure = edgeUrl.protocol.startsWith('https') || edgeUrl.protocol.startsWith('wss');
|
|
@@ -171,7 +172,7 @@ const getWebhookUrl = (client: Client, trigger: FunctionTrigger) => {
|
|
|
171
172
|
return new URL(`/webhook/${spaceId}:${trigger.id}`, edgeUrl).toString();
|
|
172
173
|
};
|
|
173
174
|
|
|
174
|
-
const getFunctionName = (functions:
|
|
175
|
+
const getFunctionName = (functions: Function.Function[], trigger: Trigger.Trigger) => {
|
|
175
176
|
// TODO(wittjosiah): Truncation should be done in the UI.
|
|
176
177
|
// Warning that the List component is currently a can of worms.
|
|
177
178
|
const shortId = trigger.function && `${trigger.function.dxn.toString().slice(0, 16)}…`;
|
|
@@ -179,25 +180,25 @@ const getFunctionName = (functions: FunctionType[], trigger: FunctionTrigger) =>
|
|
|
179
180
|
return functionObject?.name ?? shortId;
|
|
180
181
|
};
|
|
181
182
|
|
|
182
|
-
const scriptMatch = (script:
|
|
183
|
+
const scriptMatch = (script: Script.Script) => (trigger: Trigger.Trigger) => {
|
|
183
184
|
const fn = trigger.function?.target;
|
|
184
|
-
if (!Obj.instanceOf(
|
|
185
|
+
if (!Obj.instanceOf(Function.Function, fn)) {
|
|
185
186
|
return false;
|
|
186
187
|
}
|
|
187
188
|
|
|
188
189
|
return fn.source?.target === script;
|
|
189
190
|
};
|
|
190
191
|
|
|
191
|
-
const projectMatch = (project:
|
|
192
|
-
const viewQueries =
|
|
192
|
+
const projectMatch = (project: Project.Project) => {
|
|
193
|
+
const viewQueries = EFn.pipe(
|
|
193
194
|
project.collections,
|
|
194
195
|
Array.map((collection) => collection.target),
|
|
195
|
-
Array.filter(Schema.is(
|
|
196
|
+
Array.filter(Schema.is(View.View)),
|
|
196
197
|
Array.map((view) => Obj.getSnapshot(view).query.ast),
|
|
197
198
|
Array.map((ast) => JSON.stringify(ast)),
|
|
198
199
|
);
|
|
199
200
|
|
|
200
|
-
return (trigger:
|
|
201
|
+
return (trigger: Trigger.Trigger) => {
|
|
201
202
|
const spec = Obj.getSnapshot(trigger).spec;
|
|
202
203
|
if (spec?.kind !== 'subscription') {
|
|
203
204
|
return false;
|
|
@@ -209,13 +210,13 @@ const projectMatch = (project: DataType.Project) => {
|
|
|
209
210
|
};
|
|
210
211
|
|
|
211
212
|
const triggerMatch = Match.type<Obj.Any>().pipe(
|
|
212
|
-
Match.withReturnType<(trigger:
|
|
213
|
+
Match.withReturnType<(trigger: Trigger.Trigger) => boolean>(),
|
|
213
214
|
Match.when(
|
|
214
|
-
(obj) => Obj.instanceOf(
|
|
215
|
+
(obj) => Obj.instanceOf(Script.Script, obj),
|
|
215
216
|
(obj) => scriptMatch(obj),
|
|
216
217
|
),
|
|
217
218
|
Match.when(
|
|
218
|
-
(obj) => Obj.instanceOf(
|
|
219
|
+
(obj) => Obj.instanceOf(Project.Project, obj),
|
|
219
220
|
(obj) => projectMatch(obj),
|
|
220
221
|
),
|
|
221
222
|
Match.orElse((_obj) => () => true),
|
|
@@ -11,6 +11,7 @@ import { ControlPage, ControlSection } from '@dxos/react-ui-form';
|
|
|
11
11
|
import { meta } from '../meta';
|
|
12
12
|
|
|
13
13
|
import { FunctionsPanel } from './FunctionsPanel';
|
|
14
|
+
import { FunctionsRegistry } from './FunctionsRegistry';
|
|
14
15
|
|
|
15
16
|
export const FunctionsContainer = ({ space }: { space: Space }) => {
|
|
16
17
|
const { t } = useTranslation(meta.id);
|
|
@@ -22,6 +23,12 @@ export const FunctionsContainer = ({ space }: { space: Space }) => {
|
|
|
22
23
|
>
|
|
23
24
|
<FunctionsPanel space={space} />
|
|
24
25
|
</ControlSection>
|
|
26
|
+
<ControlSection
|
|
27
|
+
title={t('functions registry verbose label', { ns: meta.id })}
|
|
28
|
+
description={t('functions registry description', { ns: meta.id })}
|
|
29
|
+
>
|
|
30
|
+
<FunctionsRegistry space={space} />
|
|
31
|
+
</ControlSection>
|
|
25
32
|
</ControlPage>
|
|
26
33
|
);
|
|
27
34
|
};
|
|
@@ -5,10 +5,13 @@
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React, { useCallback, useMemo } from 'react';
|
|
7
7
|
|
|
8
|
-
import { LayoutAction, createIntent
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
8
|
+
import { LayoutAction, createIntent } from '@dxos/app-framework';
|
|
9
|
+
import { useIntentDispatcher } from '@dxos/app-framework/react';
|
|
10
|
+
import { Obj } from '@dxos/echo';
|
|
11
|
+
import { Function, Script } from '@dxos/functions';
|
|
12
|
+
import { SpaceAction } from '@dxos/plugin-space/types';
|
|
13
|
+
import { Filter, type Space, useQuery } from '@dxos/react-client/echo';
|
|
14
|
+
import { Button, IconButton, useTranslation } from '@dxos/react-ui';
|
|
12
15
|
import { controlItemClasses } from '@dxos/react-ui-form';
|
|
13
16
|
import { List } from '@dxos/react-ui-list';
|
|
14
17
|
import { ghostHover, mx } from '@dxos/react-ui-theme';
|
|
@@ -23,8 +26,8 @@ export type FunctionsPanelProps = {
|
|
|
23
26
|
|
|
24
27
|
export const FunctionsPanel = ({ space }: FunctionsPanelProps) => {
|
|
25
28
|
const { t } = useTranslation(meta.id);
|
|
26
|
-
const functions = useQuery(space, Filter.type(
|
|
27
|
-
const scripts = useQuery(space, Filter.type(
|
|
29
|
+
const functions = useQuery(space, Filter.type(Function.Function));
|
|
30
|
+
const scripts = useQuery(space, Filter.type(Script.Script));
|
|
28
31
|
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
29
32
|
|
|
30
33
|
const functionToScriptMap = useMemo(
|
|
@@ -40,13 +43,13 @@ export const FunctionsPanel = ({ space }: FunctionsPanelProps) => {
|
|
|
40
43
|
}
|
|
41
44
|
return map;
|
|
42
45
|
},
|
|
43
|
-
{} as Record<string,
|
|
46
|
+
{} as Record<string, Script.Script>,
|
|
44
47
|
),
|
|
45
48
|
[functions, scripts],
|
|
46
49
|
);
|
|
47
50
|
|
|
48
51
|
const getScriptName = useCallback(
|
|
49
|
-
(func:
|
|
52
|
+
(func: Function.Function) => {
|
|
50
53
|
const script = functionToScriptMap[func.id];
|
|
51
54
|
return script?.name;
|
|
52
55
|
},
|
|
@@ -54,23 +57,33 @@ export const FunctionsPanel = ({ space }: FunctionsPanelProps) => {
|
|
|
54
57
|
);
|
|
55
58
|
|
|
56
59
|
const handleGoToScript = useCallback(
|
|
57
|
-
(func:
|
|
60
|
+
(func: Function.Function) => {
|
|
58
61
|
const script = functionToScriptMap[func.id];
|
|
59
62
|
if (script) {
|
|
60
|
-
void dispatch(
|
|
63
|
+
void dispatch(
|
|
64
|
+
createIntent(LayoutAction.Open, {
|
|
65
|
+
part: 'main',
|
|
66
|
+
subject: [Obj.getDXN(script).toString()],
|
|
67
|
+
}),
|
|
68
|
+
);
|
|
61
69
|
}
|
|
62
70
|
},
|
|
63
71
|
[functionToScriptMap, dispatch],
|
|
64
72
|
);
|
|
65
73
|
|
|
74
|
+
const handleDelete = useCallback(
|
|
75
|
+
(func: Function.Function) => dispatch(createIntent(SpaceAction.RemoveObjects, { objects: [func] })),
|
|
76
|
+
[dispatch],
|
|
77
|
+
);
|
|
78
|
+
|
|
66
79
|
return (
|
|
67
80
|
<div role='none' className={mx(controlItemClasses)}>
|
|
68
81
|
{functions.length > 0 && (
|
|
69
|
-
<List.Root<
|
|
82
|
+
<List.Root<Function.Function> items={functions} isItem={Schema.is(Function.Function)} getId={(func) => func.id}>
|
|
70
83
|
{({ items }) => (
|
|
71
|
-
<div role='list' className='flex flex-col
|
|
84
|
+
<div role='list' className='flex flex-col is-full'>
|
|
72
85
|
{items?.map((func) => (
|
|
73
|
-
<List.Item<
|
|
86
|
+
<List.Item<Function.Function>
|
|
74
87
|
key={func.id}
|
|
75
88
|
item={func}
|
|
76
89
|
classNames={mx(grid, ghostHover, 'items-center', 'pli-2', 'min-bs-[3rem]')}
|
|
@@ -84,6 +97,12 @@ export const FunctionsPanel = ({ space }: FunctionsPanelProps) => {
|
|
|
84
97
|
{functionToScriptMap[func.id] && (
|
|
85
98
|
<Button onClick={() => handleGoToScript(func)}>{t('go to function source button label')}</Button>
|
|
86
99
|
)}
|
|
100
|
+
<IconButton
|
|
101
|
+
iconOnly
|
|
102
|
+
icon='ph--trash--regular'
|
|
103
|
+
label={t('delete function button label')}
|
|
104
|
+
onClick={() => handleDelete(func)}
|
|
105
|
+
/>
|
|
87
106
|
</List.Item>
|
|
88
107
|
))}
|
|
89
108
|
</div>
|