@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
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Array from 'effect/Array';
|
|
6
|
+
import * as EffectFunction from 'effect/Function';
|
|
7
|
+
import * as Order from 'effect/Order';
|
|
8
|
+
import * as Schema from 'effect/Schema';
|
|
9
|
+
import { useState } from 'react';
|
|
10
|
+
import React, { useCallback } from 'react';
|
|
11
|
+
|
|
12
|
+
import { Obj } from '@dxos/echo';
|
|
13
|
+
import { Function } from '@dxos/functions';
|
|
14
|
+
import { getDeployedFunctions } from '@dxos/functions-runtime/edge';
|
|
15
|
+
import { useClient } from '@dxos/react-client';
|
|
16
|
+
import { Filter, Query, type Space, useQuery } from '@dxos/react-client/echo';
|
|
17
|
+
import { useAsyncEffect } from '@dxos/react-ui';
|
|
18
|
+
import { IconButton, useTranslation } from '@dxos/react-ui';
|
|
19
|
+
import { controlItemClasses } from '@dxos/react-ui-form';
|
|
20
|
+
import { List } from '@dxos/react-ui-list';
|
|
21
|
+
import { ghostHover, mx } from '@dxos/react-ui-theme';
|
|
22
|
+
|
|
23
|
+
import { meta } from '../../meta';
|
|
24
|
+
|
|
25
|
+
const grid = 'grid grid-cols-[1fr_1fr_auto] min-bs-[2.5rem]';
|
|
26
|
+
|
|
27
|
+
type FunctionsRegistryProps = {
|
|
28
|
+
space: Space;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const FunctionsRegistry = ({ space }: FunctionsRegistryProps) => {
|
|
32
|
+
const client = useClient();
|
|
33
|
+
const [loading, setLoading] = useState(true);
|
|
34
|
+
const [functions, setFunctions] = useState<Function.Function[]>([]);
|
|
35
|
+
const { t } = useTranslation(meta.id);
|
|
36
|
+
|
|
37
|
+
const dbFunctions = useQuery(space, Filter.type(Function.Function));
|
|
38
|
+
|
|
39
|
+
const state = (func: Function.Function) => {
|
|
40
|
+
const dbFunction = dbFunctions.find((f) => f.key === func.key);
|
|
41
|
+
if (!dbFunction) {
|
|
42
|
+
return 'import';
|
|
43
|
+
}
|
|
44
|
+
if (dbFunction.version === func.version && dbFunction.updated === func.updated) {
|
|
45
|
+
return 'none';
|
|
46
|
+
}
|
|
47
|
+
return 'update';
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
useAsyncEffect(async () => {
|
|
51
|
+
setLoading(true);
|
|
52
|
+
const functions = await getDeployedFunctions(client);
|
|
53
|
+
setFunctions(functions);
|
|
54
|
+
setLoading(false);
|
|
55
|
+
}, []);
|
|
56
|
+
|
|
57
|
+
const dedupedFunctions = EffectFunction.pipe(
|
|
58
|
+
functions,
|
|
59
|
+
Array.filter((_) => _.key !== undefined),
|
|
60
|
+
Array.sort(Order.reverse(Order.mapInput(Order.string, (_: Function.Function) => _.updated ?? ''))),
|
|
61
|
+
Array.dedupeWith((self, that) => self.key === that.key),
|
|
62
|
+
Array.sort(Order.mapInput(Order.string, (_: Function.Function) => _.key ?? '')),
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const hanleImportOrUpdate = useCallback(
|
|
66
|
+
async (func: Function.Function) => {
|
|
67
|
+
const {
|
|
68
|
+
objects: [existingFunc],
|
|
69
|
+
} = await space.db.query(Query.type(Function.Function, { key: func.key })).run();
|
|
70
|
+
if (!existingFunc) {
|
|
71
|
+
space.db.add(func);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
existingFunc.version = func.version;
|
|
75
|
+
existingFunc.updated = func.updated;
|
|
76
|
+
existingFunc.name = func.name;
|
|
77
|
+
existingFunc.description = func.description;
|
|
78
|
+
// TODO(dmaretskyi): A workaround for an ECHO bug.
|
|
79
|
+
existingFunc.inputSchema = JSON.parse(JSON.stringify(func.inputSchema));
|
|
80
|
+
existingFunc.outputSchema = JSON.parse(JSON.stringify(func.outputSchema));
|
|
81
|
+
Obj.getMeta(existingFunc).keys = JSON.parse(JSON.stringify(Obj.getMeta(func).keys));
|
|
82
|
+
},
|
|
83
|
+
[space],
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<div role='none' className={mx(controlItemClasses)}>
|
|
88
|
+
{dedupedFunctions.length > 0 && (
|
|
89
|
+
<List.Root<Function.Function>
|
|
90
|
+
items={dedupedFunctions}
|
|
91
|
+
isItem={Schema.is(Function.Function)}
|
|
92
|
+
getId={(func) => func.id}
|
|
93
|
+
>
|
|
94
|
+
{({ items }) => (
|
|
95
|
+
<div role='list' className='flex flex-col w-full'>
|
|
96
|
+
{items?.map((func) => (
|
|
97
|
+
<List.Item<Function.Function>
|
|
98
|
+
key={func.id}
|
|
99
|
+
item={func}
|
|
100
|
+
classNames={mx(grid, ghostHover, 'items-center', 'pli-2', 'min-bs-[3rem]')}
|
|
101
|
+
>
|
|
102
|
+
<div className='flex flex-col truncate'>
|
|
103
|
+
<List.ItemTitle classNames='truncate'>{func.name}</List.ItemTitle>
|
|
104
|
+
<div className='text-xs text-description truncate'>{func.key}</div>
|
|
105
|
+
</div>
|
|
106
|
+
<div className='flex flex-col truncate'>
|
|
107
|
+
<div className='text-xs text-description truncate'>{func.version}</div>
|
|
108
|
+
<div className='text-xs text-description truncate'>
|
|
109
|
+
{func.updated ? `Uploaded ${new Date(func.updated).toLocaleString()}` : ''}
|
|
110
|
+
</div>
|
|
111
|
+
</div>
|
|
112
|
+
|
|
113
|
+
<IconButton
|
|
114
|
+
iconOnly
|
|
115
|
+
icon={state(func) === 'update' ? 'ph--arrows-clockwise--regular' : 'ph--download--regular'}
|
|
116
|
+
label={
|
|
117
|
+
state(func) === 'update' ? t('update function button label') : t('import function button label')
|
|
118
|
+
}
|
|
119
|
+
disabled={state(func) === 'none'}
|
|
120
|
+
onClick={() => hanleImportOrUpdate(func)}
|
|
121
|
+
/>
|
|
122
|
+
</List.Item>
|
|
123
|
+
))}
|
|
124
|
+
</div>
|
|
125
|
+
)}
|
|
126
|
+
</List.Root>
|
|
127
|
+
)}
|
|
128
|
+
|
|
129
|
+
{dedupedFunctions.length === 0 && !loading && (
|
|
130
|
+
<div className='text-center plb-4 text-gray-500'>{t('no functions found')}</div>
|
|
131
|
+
)}
|
|
132
|
+
{loading && <div className='text-center plb-4 text-gray-500'>{t('loading functions')}</div>}
|
|
133
|
+
</div>
|
|
134
|
+
);
|
|
135
|
+
};
|
|
@@ -6,12 +6,12 @@ import React, { useCallback, useMemo } from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { Ref, Type } from '@dxos/echo';
|
|
8
8
|
import { type JsonPath } from '@dxos/echo/internal';
|
|
9
|
-
import { type
|
|
9
|
+
import { type Function } from '@dxos/functions';
|
|
10
10
|
import { useOnTransition } from '@dxos/react-ui';
|
|
11
11
|
import { Form, type FormInputStateProps, type QueryRefOptions, useFormValues } from '@dxos/react-ui-form';
|
|
12
12
|
|
|
13
13
|
export type FunctionInputEditorProps = {
|
|
14
|
-
functions:
|
|
14
|
+
functions: Function.Function[];
|
|
15
15
|
onQueryRefOptions: QueryRefOptions;
|
|
16
16
|
} & FormInputStateProps;
|
|
17
17
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import React, { useCallback, useMemo } from 'react';
|
|
6
6
|
|
|
7
7
|
import { Filter, Query } from '@dxos/echo';
|
|
8
|
-
import {
|
|
8
|
+
import { Trigger } from '@dxos/functions';
|
|
9
9
|
import { useTranslation } from '@dxos/react-ui';
|
|
10
10
|
import { type InputProps, SelectInput, useInputProps } from '@dxos/react-ui-form';
|
|
11
11
|
|
|
@@ -15,10 +15,10 @@ export type SpecSelectorProps = InputProps;
|
|
|
15
15
|
|
|
16
16
|
export const SpecSelector = (props: SpecSelectorProps) => {
|
|
17
17
|
const { t } = useTranslation(meta.id);
|
|
18
|
-
const specProps = useInputProps(['spec' satisfies keyof
|
|
18
|
+
const specProps = useInputProps(['spec' satisfies keyof Trigger.Trigger]);
|
|
19
19
|
|
|
20
20
|
const handleTypeChange = useCallback(
|
|
21
|
-
(_type: any, value: string):
|
|
21
|
+
(_type: any, value: string): Trigger.Spec | undefined => {
|
|
22
22
|
const getDefaultTriggerSpec = (kind: string) => {
|
|
23
23
|
switch (kind) {
|
|
24
24
|
case 'timer':
|
|
@@ -54,7 +54,7 @@ export const SpecSelector = (props: SpecSelectorProps) => {
|
|
|
54
54
|
|
|
55
55
|
const options = useMemo(
|
|
56
56
|
() =>
|
|
57
|
-
|
|
57
|
+
Trigger.Kinds.map((kind) => ({
|
|
58
58
|
value: kind,
|
|
59
59
|
label: t(`trigger type ${kind}`),
|
|
60
60
|
})),
|
|
@@ -6,14 +6,15 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
|
6
6
|
import React, { useState } from 'react';
|
|
7
7
|
|
|
8
8
|
import { Filter, Obj, Ref, Tag, Type } from '@dxos/echo';
|
|
9
|
-
import {
|
|
9
|
+
import { Function } from '@dxos/functions';
|
|
10
|
+
import { Trigger } from '@dxos/functions';
|
|
10
11
|
import { invariant } from '@dxos/invariant';
|
|
11
12
|
import { faker } from '@dxos/random';
|
|
12
13
|
import { useQuery } from '@dxos/react-client/echo';
|
|
13
14
|
import { ContactType, useClientProvider, withClientProvider } from '@dxos/react-client/testing';
|
|
14
15
|
import { useAsyncEffect } from '@dxos/react-ui';
|
|
15
|
-
import { withTheme } from '@dxos/react-ui/testing';
|
|
16
|
-
import {
|
|
16
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
17
|
+
import { Employer, Organization, Person, Project } from '@dxos/types';
|
|
17
18
|
|
|
18
19
|
import { functions } from '../../testing';
|
|
19
20
|
import { translations } from '../../translations';
|
|
@@ -22,15 +23,15 @@ import { TriggerEditor, type TriggerEditorProps } from './TriggerEditor';
|
|
|
22
23
|
|
|
23
24
|
const types = [
|
|
24
25
|
// TODO(burdon): Get label from annotation.
|
|
25
|
-
{ value:
|
|
26
|
-
{ value:
|
|
27
|
-
{ value: Type.getTypename(
|
|
28
|
-
{ value:
|
|
26
|
+
{ value: Organization.Organization.typename, label: 'Organization' },
|
|
27
|
+
{ value: Person.Person.typename, label: 'Person' },
|
|
28
|
+
{ value: Type.getTypename(Project.Project), label: 'Project' },
|
|
29
|
+
{ value: Employer.Employer.typename, label: 'Employer' },
|
|
29
30
|
];
|
|
30
31
|
|
|
31
32
|
const DefaultStory = (props: Partial<TriggerEditorProps>) => {
|
|
32
33
|
const { space } = useClientProvider();
|
|
33
|
-
const [trigger, setTrigger] = useState<
|
|
34
|
+
const [trigger, setTrigger] = useState<Trigger.Trigger>();
|
|
34
35
|
const tags = useQuery(space, Filter.type(Tag.Tag));
|
|
35
36
|
|
|
36
37
|
useAsyncEffect(async () => {
|
|
@@ -38,11 +39,11 @@ const DefaultStory = (props: Partial<TriggerEditorProps>) => {
|
|
|
38
39
|
return;
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
const result = await space.db.query(Filter.type(
|
|
42
|
+
const result = await space.db.query(Filter.type(Function.Function)).run();
|
|
42
43
|
const fn = result.objects.find((fn) => fn.name === 'example.com/function/forex');
|
|
43
44
|
invariant(fn);
|
|
44
45
|
const trigger = space.db.add(
|
|
45
|
-
|
|
46
|
+
Trigger.make({
|
|
46
47
|
function: Ref.make(fn),
|
|
47
48
|
spec: { kind: 'webhook' },
|
|
48
49
|
input: {
|
|
@@ -78,17 +79,18 @@ const meta = {
|
|
|
78
79
|
render: DefaultStory,
|
|
79
80
|
decorators: [
|
|
80
81
|
withTheme,
|
|
82
|
+
withLayout({ container: 'column' }),
|
|
81
83
|
withClientProvider({
|
|
82
84
|
createIdentity: true,
|
|
83
85
|
createSpace: true,
|
|
84
|
-
types: [Tag.Tag,
|
|
86
|
+
types: [Tag.Tag, Function.Function, Trigger.Trigger, ContactType],
|
|
85
87
|
onCreateSpace: ({ space }) => {
|
|
86
88
|
space.db.add(Tag.make({ label: 'Important' }));
|
|
87
89
|
space.db.add(Tag.make({ label: 'Investor' }));
|
|
88
90
|
space.db.add(Tag.make({ label: 'New' }));
|
|
89
91
|
|
|
90
92
|
for (const fn of functions) {
|
|
91
|
-
space.db.add(
|
|
93
|
+
space.db.add(Function.make(fn));
|
|
92
94
|
}
|
|
93
95
|
Array.from({ length: 10 }).map(() => {
|
|
94
96
|
return space.db.add(
|
|
@@ -102,7 +104,6 @@ const meta = {
|
|
|
102
104
|
}),
|
|
103
105
|
],
|
|
104
106
|
parameters: {
|
|
105
|
-
layout: 'column',
|
|
106
107
|
translations,
|
|
107
108
|
},
|
|
108
109
|
} satisfies Meta<typeof DefaultStory>;
|
|
@@ -6,7 +6,7 @@ import React, { useCallback, useMemo } from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { ComputeGraph } from '@dxos/conductor';
|
|
8
8
|
import { type Query, Type } from '@dxos/echo';
|
|
9
|
-
import {
|
|
9
|
+
import { Function, Script, Trigger } from '@dxos/functions';
|
|
10
10
|
import { Filter, Ref, type Space, useQuery } from '@dxos/react-client/echo';
|
|
11
11
|
import { Input } from '@dxos/react-ui';
|
|
12
12
|
import { QueryForm, type QueryFormProps } from '@dxos/react-ui-components';
|
|
@@ -17,15 +17,15 @@ import { SpecSelector } from './SpecSelector';
|
|
|
17
17
|
|
|
18
18
|
export type TriggerEditorProps = {
|
|
19
19
|
space: Space;
|
|
20
|
-
trigger:
|
|
20
|
+
trigger: Trigger.Trigger;
|
|
21
21
|
// TODO(wittjosiah): This needs to apply to whole spec but currently only applies to spec.kind & spec.query.
|
|
22
22
|
readonlySpec?: boolean;
|
|
23
|
-
onSave?: (trigger: Omit<
|
|
23
|
+
onSave?: (trigger: Omit<Trigger.Trigger, 'id'>) => void;
|
|
24
24
|
onCancel?: () => void;
|
|
25
25
|
} & Pick<QueryFormProps, 'types' | 'tags'>;
|
|
26
26
|
|
|
27
27
|
export const TriggerEditor = ({ space, trigger, readonlySpec, types, tags, onSave, onCancel }: TriggerEditorProps) => {
|
|
28
|
-
const handleSave = ({ id: _, ...values }:
|
|
28
|
+
const handleSave = ({ id: _, ...values }: Trigger.Trigger) => {
|
|
29
29
|
onSave?.(values);
|
|
30
30
|
};
|
|
31
31
|
|
|
@@ -36,7 +36,7 @@ export const TriggerEditor = ({ space, trigger, readonlySpec, types, tags, onSav
|
|
|
36
36
|
<Form
|
|
37
37
|
outerSpacing={false}
|
|
38
38
|
Custom={Custom}
|
|
39
|
-
schema={
|
|
39
|
+
schema={Trigger.Trigger}
|
|
40
40
|
values={trigger}
|
|
41
41
|
onSave={handleSave}
|
|
42
42
|
onCancel={onCancel}
|
|
@@ -52,14 +52,14 @@ type UseCustomInputsProps = {
|
|
|
52
52
|
} & Pick<QueryFormProps, 'types' | 'tags'>;
|
|
53
53
|
|
|
54
54
|
const useCustomInputs = ({ space, readonlySpec, types, tags, onQueryRefOptions }: UseCustomInputsProps) => {
|
|
55
|
-
const functions = useQuery(space, Filter.type(
|
|
55
|
+
const functions = useQuery(space, Filter.type(Function.Function));
|
|
56
56
|
const workflows = useQuery(space, Filter.type(ComputeGraph));
|
|
57
|
-
const scripts = useQuery(space, Filter.type(
|
|
57
|
+
const scripts = useQuery(space, Filter.type(Script.Script));
|
|
58
58
|
|
|
59
59
|
return useMemo(
|
|
60
60
|
(): CustomInputMap => ({
|
|
61
61
|
// Function selector.
|
|
62
|
-
['function' satisfies keyof
|
|
62
|
+
['function' satisfies keyof Trigger.Trigger]: (props) => {
|
|
63
63
|
const getValue = useCallback(() => {
|
|
64
64
|
const formValue = props.getValue();
|
|
65
65
|
if (Ref.isRef(formValue)) {
|
|
@@ -121,7 +121,7 @@ const getWorkflowOptions = (graphs: ComputeGraph[]) => {
|
|
|
121
121
|
return graphs.map((graph) => ({ label: `compute-${graph.id}`, value: `dxn:echo:@:${graph.id}` }));
|
|
122
122
|
};
|
|
123
123
|
|
|
124
|
-
const getFunctionOptions = (scripts:
|
|
125
|
-
const getLabel = (fn:
|
|
124
|
+
const getFunctionOptions = (scripts: Script.Script[], functions: Function.Function[]) => {
|
|
125
|
+
const getLabel = (fn: Function.Function) => scripts.find((s) => fn.source?.target?.id === s.id)?.name ?? fn.name;
|
|
126
126
|
return functions.map((fn) => ({ label: getLabel(fn), value: `dxn:echo:@:${fn.id}` }));
|
|
127
127
|
};
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import type * as Effect from 'effect/Effect';
|
|
6
6
|
import { useCallback } from 'react';
|
|
7
7
|
|
|
8
|
-
import { useCapability } from '@dxos/app-framework';
|
|
8
|
+
import { useCapability } from '@dxos/app-framework/react';
|
|
9
9
|
import type { Space } from '@dxos/react-client/echo';
|
|
10
10
|
|
|
11
11
|
import { AutomationCapabilities } from '../capabilities';
|
|
@@ -13,6 +13,7 @@ import { AutomationCapabilities } from '../capabilities';
|
|
|
13
13
|
/**
|
|
14
14
|
* Create an effectful function that has access to compute services
|
|
15
15
|
*/
|
|
16
|
+
// TODO(burdon): Factor out (figure out cross-plugin capabilities dependencies).
|
|
16
17
|
export const useComputeRuntimeCallback = <T>(
|
|
17
18
|
space: Space | undefined,
|
|
18
19
|
fn: () => Effect.Effect<T, any, AutomationCapabilities.ComputeServices>,
|
|
@@ -25,6 +26,7 @@ export const useComputeRuntimeCallback = <T>(
|
|
|
25
26
|
if (!runtime) {
|
|
26
27
|
throw new TypeError('Space not provided to useComputeRuntimeCallback');
|
|
27
28
|
}
|
|
29
|
+
|
|
28
30
|
return runtime.runPromise(fn());
|
|
29
31
|
}, [runtime, ...(deps ?? [])]);
|
|
30
32
|
};
|
|
@@ -5,21 +5,22 @@
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
6
|
|
|
7
7
|
import { Filter } from '@dxos/echo';
|
|
8
|
-
import {
|
|
8
|
+
import { Trigger } from '@dxos/functions';
|
|
9
|
+
import { TriggerDispatcher } from '@dxos/functions-runtime';
|
|
9
10
|
import { type Space, useQuery } from '@dxos/react-client/echo';
|
|
10
11
|
import { useAsyncState } from '@dxos/react-ui';
|
|
11
12
|
|
|
12
13
|
import { useComputeRuntimeCallback } from './useComputeRuntimeCallback';
|
|
13
14
|
|
|
14
15
|
interface TriggerRuntimeControls {
|
|
15
|
-
triggers:
|
|
16
|
+
triggers: Trigger.Trigger[];
|
|
16
17
|
isRunning: boolean;
|
|
17
18
|
start: () => void;
|
|
18
19
|
stop: () => void;
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
export const useTriggerRuntimeControls = (space: Space | undefined): TriggerRuntimeControls => {
|
|
22
|
-
const triggers = useQuery(space, Filter.type(
|
|
23
|
+
const triggers = useQuery(space, Filter.type(Trigger.Trigger));
|
|
23
24
|
|
|
24
25
|
const [isRunningState, setIsRunningState] = useAsyncState(
|
|
25
26
|
useComputeRuntimeCallback(space, () => TriggerDispatcher.pipe(Effect.map((t) => t.running))),
|
package/src/index.ts
CHANGED
package/src/meta.ts
CHANGED
|
@@ -3,12 +3,15 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type PluginMeta } from '@dxos/app-framework';
|
|
6
|
+
import { trim } from '@dxos/util';
|
|
6
7
|
|
|
7
8
|
export const meta: PluginMeta = {
|
|
8
9
|
id: 'dxos.org/plugin/automation',
|
|
9
10
|
name: 'Automation',
|
|
10
|
-
description:
|
|
11
|
-
|
|
11
|
+
description: trim`
|
|
12
|
+
Workflow automation engine that triggers custom actions based on object events and conditions.
|
|
13
|
+
Create automated pipelines that respond to changes and streamline repetitive tasks.
|
|
14
|
+
`,
|
|
12
15
|
icon: 'ph--robot--regular',
|
|
13
16
|
source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/plugin-automation',
|
|
14
17
|
};
|
package/src/translations.ts
CHANGED
|
@@ -22,10 +22,13 @@ export const translations = [
|
|
|
22
22
|
|
|
23
23
|
'functions panel label': 'Functions',
|
|
24
24
|
'functions verbose label': 'Manage deployed functions',
|
|
25
|
+
'functions registry verbose label': 'Functions registry',
|
|
26
|
+
'functions registry description': 'Import functions from the registry',
|
|
25
27
|
'functions description': 'You can manage all the functions deployed from your space on EDGE here.',
|
|
26
28
|
'function copy id': 'Copy Function ID',
|
|
27
29
|
'no functions found': 'No functions found',
|
|
28
30
|
'go to function source button label': 'Show function source',
|
|
31
|
+
'delete function button label': 'Delete function',
|
|
29
32
|
|
|
30
33
|
'trigger editor title': 'Configure Trigger',
|
|
31
34
|
'new trigger label': 'Add Trigger',
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AutomationPanel,
|
|
3
|
-
AutomationPanel_default
|
|
4
|
-
} from "./chunk-VL3KSDVL.mjs";
|
|
5
|
-
import "./chunk-SUKAEYF3.mjs";
|
|
6
|
-
import "./chunk-WWURMV25.mjs";
|
|
7
|
-
export {
|
|
8
|
-
AutomationPanel,
|
|
9
|
-
AutomationPanel_default as default
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=AutomationPanel-3PHA5FTJ.mjs.map
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
FunctionsPanel
|
|
3
|
-
} from "./chunk-DLLE4FKP.mjs";
|
|
4
|
-
import {
|
|
5
|
-
meta
|
|
6
|
-
} from "./chunk-WWURMV25.mjs";
|
|
7
|
-
|
|
8
|
-
// src/components/FunctionsContainer.tsx
|
|
9
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
10
|
-
import React from "react";
|
|
11
|
-
import { useTranslation } from "@dxos/react-ui";
|
|
12
|
-
import { ControlPage, ControlSection } from "@dxos/react-ui-form";
|
|
13
|
-
var FunctionsContainer = ({ space }) => {
|
|
14
|
-
var _effect = _useSignals();
|
|
15
|
-
try {
|
|
16
|
-
const { t } = useTranslation(meta.id);
|
|
17
|
-
return /* @__PURE__ */ React.createElement(ControlPage, null, /* @__PURE__ */ React.createElement(ControlSection, {
|
|
18
|
-
title: t("functions verbose label", {
|
|
19
|
-
ns: meta.id
|
|
20
|
-
}),
|
|
21
|
-
description: t("functions description", {
|
|
22
|
-
ns: meta.id
|
|
23
|
-
})
|
|
24
|
-
}, /* @__PURE__ */ React.createElement(FunctionsPanel, {
|
|
25
|
-
space
|
|
26
|
-
})));
|
|
27
|
-
} finally {
|
|
28
|
-
_effect.f();
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
var FunctionsContainer_default = FunctionsContainer;
|
|
32
|
-
export {
|
|
33
|
-
FunctionsContainer,
|
|
34
|
-
FunctionsContainer_default as default
|
|
35
|
-
};
|
|
36
|
-
//# sourceMappingURL=FunctionsContainer-HHBMPUOD.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/FunctionsContainer.tsx"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport React from 'react';\n\nimport { type Space } from '@dxos/react-client/echo';\nimport { useTranslation } from '@dxos/react-ui';\nimport { ControlPage, ControlSection } from '@dxos/react-ui-form';\n\nimport { meta } from '../meta';\n\nimport { FunctionsPanel } from './FunctionsPanel';\n\nexport const FunctionsContainer = ({ space }: { space: Space }) => {\n const { t } = useTranslation(meta.id);\n return (\n <ControlPage>\n <ControlSection\n title={t('functions verbose label', { ns: meta.id })}\n description={t('functions description', { ns: meta.id })}\n >\n <FunctionsPanel space={space} />\n </ControlSection>\n </ControlPage>\n );\n};\n\nexport default FunctionsContainer;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;AAIA,OAAOA,WAAW;AAGlB,SAASC,sBAAsB;AAC/B,SAASC,aAAaC,sBAAsB;AAMrC,IAAMC,qBAAqB,CAAC,EAAEC,MAAK,MAAoB;;;AAC5D,UAAM,EAAEC,EAAC,IAAKC,eAAeC,KAAKC,EAAE;AACpC,WACE,sBAAA,cAACC,aAAAA,MACC,sBAAA,cAACC,gBAAAA;MACCC,OAAON,EAAE,2BAA2B;QAAEO,IAAIL,KAAKC;MAAG,CAAA;MAClDK,aAAaR,EAAE,yBAAyB;QAAEO,IAAIL,KAAKC;MAAG,CAAA;OAEtD,sBAAA,cAACM,gBAAAA;MAAeV;;;;;AAIxB;AAEA,IAAA,6BAAeD;",
|
|
6
|
-
"names": ["React", "useTranslation", "ControlPage", "ControlSection", "FunctionsContainer", "space", "t", "useTranslation", "meta", "id", "ControlPage", "ControlSection", "title", "ns", "description", "FunctionsPanel"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/app-graph-builder.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Rx } from '@effect-rx/rx-react';\nimport * as Function from 'effect/Function';\nimport * as Option from 'effect/Option';\n\nimport { Capabilities, type PluginContext, contributes } from '@dxos/app-framework';\nimport { Obj } from '@dxos/echo';\nimport { ScriptType } from '@dxos/functions';\nimport { ATTENDABLE_PATH_SEPARATOR, PLANK_COMPANION_TYPE } from '@dxos/plugin-deck/types';\nimport { createExtension } from '@dxos/plugin-graph';\nimport { meta as spaceMeta } from '@dxos/plugin-space';\n\nimport { meta } from '../meta';\n\nexport default (context: PluginContext) =>\n contributes(Capabilities.AppGraphBuilder, [\n createExtension({\n id: `${meta.id}/space-settings-automation`,\n connector: (node) =>\n Rx.make((get) =>\n Function.pipe(\n get(node),\n Option.flatMap((node) => (node.type === `${spaceMeta.id}/settings` ? Option.some(node) : Option.none())),\n Option.map((node) => [\n {\n id: `automation-${node.id}`,\n type: `${meta.id}/space-settings-automation`,\n data: `${meta.id}/space-settings-automation`,\n properties: {\n label: ['automation panel label', { ns: meta.id }],\n icon: 'ph--lightning--regular',\n },\n },\n ]),\n Option.getOrElse(() => []),\n ),\n ),\n }),\n createExtension({\n id: `${meta.id}/space-settings-functions`,\n connector: (node) =>\n Rx.make((get) =>\n Function.pipe(\n get(node),\n Option.flatMap((node) => (node.type === `${spaceMeta.id}/settings` ? Option.some(node) : Option.none())),\n Option.map((node) => [\n {\n id: `functions-${node.id}`,\n type: `${meta.id}/space-settings-functions`,\n data: `${meta.id}/space-settings-functions`,\n properties: {\n label: ['functions panel label', { ns: meta.id }],\n icon: 'ph--function--regular',\n },\n },\n ]),\n Option.getOrElse(() => []),\n ),\n ),\n }),\n createExtension({\n id: `${meta.id}/script-companion`,\n connector: (node) =>\n Rx.make((get) =>\n Function.pipe(\n get(node),\n Option.flatMap((node) => (Obj.instanceOf(ScriptType, node.data) ? Option.some(node) : Option.none())),\n Option.map((node) => [\n {\n id: [node.id, 'automation'].join(ATTENDABLE_PATH_SEPARATOR),\n type: PLANK_COMPANION_TYPE,\n data: 'automation',\n properties: {\n label: ['script automation label', { ns: meta.id }],\n icon: 'ph--lightning--regular',\n disposition: 'hidden',\n },\n },\n ]),\n Option.getOrElse(() => []),\n ),\n ),\n }),\n ]);\n"],
|
|
5
|
-
"mappings": ";;;;;AAIA,SAASA,UAAU;AACnB,YAAYC,cAAc;AAC1B,YAAYC,YAAY;AAExB,SAASC,cAAkCC,mBAAmB;AAC9D,SAASC,WAAW;AACpB,SAASC,kBAAkB;AAC3B,SAASC,2BAA2BC,4BAA4B;AAChE,SAASC,uBAAuB;AAChC,SAASC,QAAQC,iBAAiB;AAIlC,IAAA,6BAAe,CAACC,YACdC,YAAYC,aAAaC,iBAAiB;EACxCC,gBAAgB;IACdC,IAAI,GAAGC,KAAKD,EAAE;IACdE,WAAW,CAACC,SACVC,GAAGC,KAAK,CAACC,QACEC,cACPD,IAAIH,IAAAA,GACGK,eAAQ,CAACL,UAAUA,MAAKM,SAAS,GAAGC,UAAUV,EAAE,cAAqBW,YAAKR,KAAAA,IAAeS,YAAI,CAAA,GAC7FC,WAAI,CAACV,UAAS;MACnB;QACEH,IAAI,cAAcG,MAAKH,EAAE;QACzBS,MAAM,GAAGR,KAAKD,EAAE;QAChBc,MAAM,GAAGb,KAAKD,EAAE;QAChBe,YAAY;UACVC,OAAO;YAAC;YAA0B;cAAEC,IAAIhB,KAAKD;YAAG;;UAChDkB,MAAM;QACR;MACF;KACD,GACMC,iBAAU,MAAM,CAAA,CAAE,CAAA,CAAA;EAGjC,CAAA;EACApB,gBAAgB;IACdC,IAAI,GAAGC,KAAKD,EAAE;IACdE,WAAW,CAACC,SACVC,GAAGC,KAAK,CAACC,QACEC,cACPD,IAAIH,IAAAA,GACGK,eAAQ,CAACL,UAAUA,MAAKM,SAAS,GAAGC,UAAUV,EAAE,cAAqBW,YAAKR,KAAAA,IAAeS,YAAI,CAAA,GAC7FC,WAAI,CAACV,UAAS;MACnB;QACEH,IAAI,aAAaG,MAAKH,EAAE;QACxBS,MAAM,GAAGR,KAAKD,EAAE;QAChBc,MAAM,GAAGb,KAAKD,EAAE;QAChBe,YAAY;UACVC,OAAO;YAAC;YAAyB;cAAEC,IAAIhB,KAAKD;YAAG;;UAC/CkB,MAAM;QACR;MACF;KACD,GACMC,iBAAU,MAAM,CAAA,CAAE,CAAA,CAAA;EAGjC,CAAA;EACApB,gBAAgB;IACdC,IAAI,GAAGC,KAAKD,EAAE;IACdE,WAAW,CAACC,SACVC,GAAGC,KAAK,CAACC,QACEC,cACPD,IAAIH,IAAAA,GACGK,eAAQ,CAACL,UAAUiB,IAAIC,WAAWC,YAAYnB,MAAKW,IAAI,IAAWH,YAAKR,KAAAA,IAAeS,YAAI,CAAA,GAC1FC,WAAI,CAACV,UAAS;MACnB;QACEH,IAAI;UAACG,MAAKH;UAAI;UAAcuB,KAAKC,yBAAAA;QACjCf,MAAMgB;QACNX,MAAM;QACNC,YAAY;UACVC,OAAO;YAAC;YAA2B;cAAEC,IAAIhB,KAAKD;YAAG;;UACjDkB,MAAM;UACNQ,aAAa;QACf;MACF;KACD,GACMP,iBAAU,MAAM,CAAA,CAAE,CAAA,CAAA;EAGjC,CAAA;CACD;",
|
|
6
|
-
"names": ["Rx", "Function", "Option", "Capabilities", "contributes", "Obj", "ScriptType", "ATTENDABLE_PATH_SEPARATOR", "PLANK_COMPANION_TYPE", "createExtension", "meta", "spaceMeta", "context", "contributes", "Capabilities", "AppGraphBuilder", "createExtension", "id", "meta", "connector", "node", "Rx", "make", "get", "pipe", "flatMap", "type", "spaceMeta", "some", "none", "map", "data", "properties", "label", "ns", "icon", "getOrElse", "Obj", "instanceOf", "ScriptType", "join", "ATTENDABLE_PATH_SEPARATOR", "PLANK_COMPANION_TYPE", "disposition"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/capabilities.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as ManagedRuntime from 'effect/ManagedRuntime';\n\nimport { type AiService, type ToolExecutionService, type ToolResolverService } from '@dxos/ai';\nimport { defineCapability } from '@dxos/app-framework';\nimport type {\n CredentialsService,\n DatabaseService,\n FunctionInvocationService,\n InvocationTracer,\n QueueService,\n TriggerDispatcher,\n TriggerStateStore,\n} from '@dxos/functions';\nimport type { SpaceId } from '@dxos/keys';\n\nimport { meta } from '../meta';\n\nexport namespace AutomationCapabilities {\n /**\n * Service stack for executing agents, functions, and triggers.\n */\n export type ComputeServices =\n | TriggerDispatcher\n | AiService.AiService\n | DatabaseService\n | QueueService\n | CredentialsService\n | FunctionInvocationService\n | InvocationTracer\n | TriggerStateStore\n // TODO(dmaretskyi): Those should be provided at AI-chat call site.\n | ToolResolverService\n | ToolExecutionService;\n\n export type ComputeRuntime = ManagedRuntime.ManagedRuntime<AutomationCapabilities.ComputeServices, never>;\n export interface ComputeRuntimeProvider {\n getRuntime(spaceId: SpaceId): ComputeRuntime;\n }\n\n /**\n * Runtime for executing agents, functions, and triggers.\n */\n export const ComputeRuntime = defineCapability<ComputeRuntimeProvider>(`${meta.id}/capability/compute-runtime`);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;AAOA,SAASA,wBAAwB;UAchBC,yBAAAA;0BAyBFC,iBAAiBC,iBAAyC,GAAGC,KAAKC,EAAE,6BAA6B;AAChH,GA1BiBJ,2BAAAA,yBAAAA,CAAAA,EAAAA;;",
|
|
6
|
-
"names": ["defineCapability", "AutomationCapabilities", "ComputeRuntime", "defineCapability", "meta", "id"]
|
|
7
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// src/capabilities/index.ts
|
|
2
|
-
import { lazy } from "@dxos/app-framework";
|
|
3
|
-
var AppGraphBuilder = lazy(() => import("./app-graph-builder-DV5HMFX4.mjs"));
|
|
4
|
-
var ComputeRuntime = lazy(() => import("./compute-runtime-YJREH6WP.mjs"));
|
|
5
|
-
var IntentResolver = lazy(() => import("./intent-resolver-D2OHKQRR.mjs"));
|
|
6
|
-
var ReactSurface = lazy(() => import("./react-surface-G7CG7BML.mjs"));
|
|
7
|
-
|
|
8
|
-
export {
|
|
9
|
-
AppGraphBuilder,
|
|
10
|
-
ComputeRuntime,
|
|
11
|
-
IntentResolver,
|
|
12
|
-
ReactSurface
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=chunk-6TUZQIEN.mjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/capabilities/index.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { lazy } from '@dxos/app-framework';\n\nexport const AppGraphBuilder = lazy(() => import('./app-graph-builder'));\nexport const ComputeRuntime = lazy(() => import('./compute-runtime'));\nexport const IntentResolver = lazy(() => import('./intent-resolver'));\nexport const ReactSurface = lazy(() => import('./react-surface'));\n\nexport * from './capabilities';\n"],
|
|
5
|
-
"mappings": ";AAIA,SAASA,YAAY;AAEd,IAAMC,kBAAkBC,KAAK,MAAM,OAAO,kCAAA,CAAA;AAC1C,IAAMC,iBAAiBD,KAAK,MAAM,OAAO,gCAAA,CAAA;AACzC,IAAME,iBAAiBF,KAAK,MAAM,OAAO,gCAAA,CAAA;AACzC,IAAMG,eAAeH,KAAK,MAAM,OAAO,8BAAA,CAAA;",
|
|
6
|
-
"names": ["lazy", "AppGraphBuilder", "lazy", "ComputeRuntime", "IntentResolver", "ReactSurface"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/FunctionsPanel/FunctionsPanel.tsx", "../../../src/components/FunctionsPanel/index.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\nimport React, { useCallback, useMemo } from 'react';\n\nimport { LayoutAction, createIntent, useIntentDispatcher } from '@dxos/app-framework';\nimport { FunctionType, ScriptType } from '@dxos/functions';\nimport { Filter, type Space, fullyQualifiedId, useQuery } from '@dxos/react-client/echo';\nimport { Button, useTranslation } from '@dxos/react-ui';\nimport { controlItemClasses } from '@dxos/react-ui-form';\nimport { List } from '@dxos/react-ui-list';\nimport { ghostHover, mx } from '@dxos/react-ui-theme';\n\nimport { meta } from '../../meta';\n\nconst grid = 'grid grid-cols-[1fr_auto] min-bs-[2.5rem]';\n\nexport type FunctionsPanelProps = {\n space: Space;\n};\n\nexport const FunctionsPanel = ({ space }: FunctionsPanelProps) => {\n const { t } = useTranslation(meta.id);\n const functions = useQuery(space, Filter.type(FunctionType));\n const scripts = useQuery(space, Filter.type(ScriptType));\n const { dispatchPromise: dispatch } = useIntentDispatcher();\n\n const functionToScriptMap = useMemo(\n () =>\n functions.reduce(\n (map, func) => {\n const scriptId = func.source?.target?.id;\n if (scriptId) {\n const script = scripts.find((s) => s.id === scriptId);\n if (script) {\n map[func.id] = script;\n }\n }\n return map;\n },\n {} as Record<string, ScriptType>,\n ),\n [functions, scripts],\n );\n\n const getScriptName = useCallback(\n (func: FunctionType) => {\n const script = functionToScriptMap[func.id];\n return script?.name;\n },\n [functionToScriptMap],\n );\n\n const handleGoToScript = useCallback(\n (func: FunctionType) => {\n const script = functionToScriptMap[func.id];\n if (script) {\n void dispatch(createIntent(LayoutAction.Open, { part: 'main', subject: [fullyQualifiedId(script)] }));\n }\n },\n [functionToScriptMap, dispatch],\n );\n\n return (\n <div role='none' className={mx(controlItemClasses)}>\n {functions.length > 0 && (\n <List.Root<FunctionType> items={functions} isItem={Schema.is(FunctionType)} getId={(func) => func.id}>\n {({ items }) => (\n <div role='list' className='flex flex-col w-full'>\n {items?.map((func) => (\n <List.Item<FunctionType>\n key={func.id}\n item={func}\n classNames={mx(grid, ghostHover, 'items-center', 'pli-2', 'min-bs-[3rem]')}\n >\n <div className='flex flex-col truncate'>\n <List.ItemTitle classNames='truncate'>{func.name}</List.ItemTitle>\n {getScriptName(func) && (\n <div className='text-xs text-description truncate'>{getScriptName(func)}</div>\n )}\n </div>\n {functionToScriptMap[func.id] && (\n <Button onClick={() => handleGoToScript(func)}>{t('go to function source button label')}</Button>\n )}\n </List.Item>\n ))}\n </div>\n )}\n </List.Root>\n )}\n\n {functions.length === 0 && <div className='text-center plb-4 text-gray-500'>{t('no functions found')}</div>}\n </div>\n );\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { FunctionsPanel } from './FunctionsPanel';\n\nexport * from './FunctionsPanel';\nexport default FunctionsPanel;\n"],
|
|
5
|
-
"mappings": ";;;;;;AAIA,YAAYA,YAAY;AACxB,OAAOC,SAASC,aAAaC,eAAe;AAE5C,SAASC,cAAcC,cAAcC,2BAA2B;AAChE,SAASC,cAAcC,kBAAkB;AACzC,SAASC,QAAoBC,kBAAkBC,gBAAgB;AAC/D,SAASC,QAAQC,sBAAsB;AACvC,SAASC,0BAA0B;AACnC,SAASC,YAAY;AACrB,SAASC,YAAYC,UAAU;AAI/B,IAAMC,OAAO;AAMN,IAAMC,iBAAiB,CAAC,EAAEC,MAAK,MAAuB;;;AAC3D,UAAM,EAAEC,EAAC,IAAKC,eAAeC,KAAKC,EAAE;AACpC,UAAMC,YAAYC,SAASN,OAAOO,OAAOC,KAAKC,YAAAA,CAAAA;AAC9C,UAAMC,UAAUJ,SAASN,OAAOO,OAAOC,KAAKG,UAAAA,CAAAA;AAC5C,UAAM,EAAEC,iBAAiBC,SAAQ,IAAKC,oBAAAA;AAEtC,UAAMC,sBAAsBC,QAC1B,MACEX,UAAUY,OACR,CAACC,KAAKC,SAAAA;AACJ,YAAMC,WAAWD,KAAKE,QAAQC,QAAQlB;AACtC,UAAIgB,UAAU;AACZ,cAAMG,SAASb,QAAQc,KAAK,CAACC,MAAMA,EAAErB,OAAOgB,QAAAA;AAC5C,YAAIG,QAAQ;AACVL,cAAIC,KAAKf,EAAE,IAAImB;QACjB;MACF;AACA,aAAOL;IACT,GACA,CAAC,CAAA,GAEL;MAACb;MAAWK;KAAQ;AAGtB,UAAMgB,gBAAgBC,YACpB,CAACR,SAAAA;AACC,YAAMI,SAASR,oBAAoBI,KAAKf,EAAE;AAC1C,aAAOmB,QAAQK;IACjB,GACA;MAACb;KAAoB;AAGvB,UAAMc,mBAAmBF,YACvB,CAACR,SAAAA;AACC,YAAMI,SAASR,oBAAoBI,KAAKf,EAAE;AAC1C,UAAImB,QAAQ;AACV,aAAKV,SAASiB,aAAaC,aAAaC,MAAM;UAAEC,MAAM;UAAQC,SAAS;YAACC,iBAAiBZ,MAAAA;;QAAS,CAAA,CAAA;MACpG;IACF,GACA;MAACR;MAAqBF;KAAS;AAGjC,WACE,sBAAA,cAACuB,OAAAA;MAAIC,MAAK;MAAOC,WAAWC,GAAGC,kBAAAA;OAC5BnC,UAAUoC,SAAS,KAClB,sBAAA,cAACC,KAAKC,MAAI;MAAeC,OAAOvC;MAAWwC,QAAeC,UAAGrC,YAAAA;MAAesC,OAAO,CAAC5B,SAASA,KAAKf;OAC/F,CAAC,EAAEwC,MAAK,MACP,sBAAA,cAACR,OAAAA;MAAIC,MAAK;MAAOC,WAAU;OACxBM,OAAO1B,IAAI,CAACC,SACX,sBAAA,cAACuB,KAAKM,MAAI;MACRC,KAAK9B,KAAKf;MACV8C,MAAM/B;MACNgC,YAAYZ,GAAGzC,MAAMsD,YAAY,gBAAgB,SAAS,eAAA;OAE1D,sBAAA,cAAChB,OAAAA;MAAIE,WAAU;OACb,sBAAA,cAACI,KAAKW,WAAS;MAACF,YAAW;OAAYhC,KAAKS,IAAI,GAC/CF,cAAcP,IAAAA,KACb,sBAAA,cAACiB,OAAAA;MAAIE,WAAU;OAAqCZ,cAAcP,IAAAA,CAAAA,CAAAA,GAGrEJ,oBAAoBI,KAAKf,EAAE,KAC1B,sBAAA,cAACkD,QAAAA;MAAOC,SAAS,MAAM1B,iBAAiBV,IAAAA;OAAQlB,EAAE,oCAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAS/DI,UAAUoC,WAAW,KAAK,sBAAA,cAACL,OAAAA;MAAIE,WAAU;OAAmCrC,EAAE,oBAAA,CAAA,CAAA;;;;AAGrF;;;ACzFA,IAAA,yBAAeuD;",
|
|
6
|
-
"names": ["Schema", "React", "useCallback", "useMemo", "LayoutAction", "createIntent", "useIntentDispatcher", "FunctionType", "ScriptType", "Filter", "fullyQualifiedId", "useQuery", "Button", "useTranslation", "controlItemClasses", "List", "ghostHover", "mx", "grid", "FunctionsPanel", "space", "t", "useTranslation", "meta", "id", "functions", "useQuery", "Filter", "type", "FunctionType", "scripts", "ScriptType", "dispatchPromise", "dispatch", "useIntentDispatcher", "functionToScriptMap", "useMemo", "reduce", "map", "func", "scriptId", "source", "target", "script", "find", "s", "getScriptName", "useCallback", "name", "handleGoToScript", "createIntent", "LayoutAction", "Open", "part", "subject", "fullyQualifiedId", "div", "role", "className", "mx", "controlItemClasses", "length", "List", "Root", "items", "isItem", "is", "getId", "Item", "key", "item", "classNames", "ghostHover", "ItemTitle", "Button", "onClick", "FunctionsPanel"]
|
|
7
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/hooks/useComputeRuntimeCallback.ts", "../../../src/hooks/useTriggerRuntimeControls.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Effect from 'effect/Effect';\nimport { useCallback } from 'react';\n\nimport { useCapability } from '@dxos/app-framework';\nimport type { Space } from '@dxos/react-client/echo';\n\nimport { AutomationCapabilities } from '../capabilities';\n\n/**\n * Create an effectful function that has access to compute services\n */\nexport const useComputeRuntimeCallback = <T>(\n space: Space | undefined,\n fn: () => Effect.Effect<T, any, AutomationCapabilities.ComputeServices>,\n deps?: React.DependencyList,\n): (() => Promise<T>) => {\n const computeRuntime = useCapability(AutomationCapabilities.ComputeRuntime);\n const runtime = space !== undefined ? computeRuntime.getRuntime(space.id) : undefined;\n\n return useCallback(() => {\n if (!runtime) {\n throw new TypeError('Space not provided to useComputeRuntimeCallback');\n }\n return runtime.runPromise(fn());\n }, [runtime, ...(deps ?? [])]);\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Filter } from '@dxos/echo';\nimport { FunctionTrigger, TriggerDispatcher } from '@dxos/functions';\nimport { type Space, useQuery } from '@dxos/react-client/echo';\nimport { useAsyncState } from '@dxos/react-ui';\n\nimport { useComputeRuntimeCallback } from './useComputeRuntimeCallback';\n\ninterface TriggerRuntimeControls {\n triggers: FunctionTrigger[];\n isRunning: boolean;\n start: () => void;\n stop: () => void;\n}\n\nexport const useTriggerRuntimeControls = (space: Space | undefined): TriggerRuntimeControls => {\n const triggers = useQuery(space, Filter.type(FunctionTrigger));\n\n const [isRunningState, setIsRunningState] = useAsyncState(\n useComputeRuntimeCallback(space, () => TriggerDispatcher.pipe(Effect.map((t) => t.running))),\n );\n\n const start = useComputeRuntimeCallback(\n space,\n Effect.fnUntraced(function* () {\n const dispatcher = yield* TriggerDispatcher;\n yield* dispatcher.start();\n setIsRunningState(true);\n }),\n );\n\n const stop = useComputeRuntimeCallback(\n space,\n Effect.fnUntraced(function* () {\n const dispatcher = yield* TriggerDispatcher;\n yield* dispatcher.stop();\n setIsRunningState(false);\n }),\n );\n\n return {\n triggers,\n isRunning: isRunningState ?? false,\n start: () => void start(),\n stop: () => void stop(),\n };\n};\n"],
|
|
5
|
-
"mappings": ";;;;;AAKA,SAASA,mBAAmB;AAE5B,SAASC,qBAAqB;AAQvB,IAAMC,4BAA4B,CACvCC,OACAC,IACAC,SAAAA;AAEA,QAAMC,iBAAiBC,cAAcC,uBAAuBC,cAAc;AAC1E,QAAMC,UAAUP,UAAUQ,SAAYL,eAAeM,WAAWT,MAAMU,EAAE,IAAIF;AAE5E,SAAOG,YAAY,MAAA;AACjB,QAAI,CAACJ,SAAS;AACZ,YAAM,IAAIK,UAAU,iDAAA;IACtB;AACA,WAAOL,QAAQM,WAAWZ,GAAAA,CAAAA;EAC5B,GAAG;IAACM;OAAaL,QAAQ,CAAA;GAAI;AAC/B;;;ACzBA,YAAYY,YAAY;AAExB,SAASC,cAAc;AACvB,SAASC,iBAAiBC,yBAAyB;AACnD,SAAqBC,gBAAgB;AACrC,SAASC,qBAAqB;AAWvB,IAAMC,4BAA4B,CAACC,UAAAA;AACxC,QAAMC,WAAWC,SAASF,OAAOG,OAAOC,KAAKC,eAAAA,CAAAA;AAE7C,QAAM,CAACC,gBAAgBC,iBAAAA,IAAqBC,cAC1CC,0BAA0BT,OAAO,MAAMU,kBAAkBC,KAAYC,WAAI,CAACC,MAAMA,EAAEC,OAAO,CAAA,CAAA,CAAA;AAG3F,QAAMC,QAAQN,0BACZT,OACOgB,kBAAW,aAAA;AAChB,UAAMC,aAAa,OAAOP;AAC1B,WAAOO,WAAWF,MAAK;AACvBR,sBAAkB,IAAA;EACpB,CAAA,CAAA;AAGF,QAAMW,OAAOT,0BACXT,OACOgB,kBAAW,aAAA;AAChB,UAAMC,aAAa,OAAOP;AAC1B,WAAOO,WAAWC,KAAI;AACtBX,sBAAkB,KAAA;EACpB,CAAA,CAAA;AAGF,SAAO;IACLN;IACAkB,WAAWb,kBAAkB;IAC7BS,OAAO,MAAM,KAAKA,MAAAA;IAClBG,MAAM,MAAM,KAAKA,KAAAA;EACnB;AACF;",
|
|
6
|
-
"names": ["useCallback", "useCapability", "useComputeRuntimeCallback", "space", "fn", "deps", "computeRuntime", "useCapability", "AutomationCapabilities", "ComputeRuntime", "runtime", "undefined", "getRuntime", "id", "useCallback", "TypeError", "runPromise", "Effect", "Filter", "FunctionTrigger", "TriggerDispatcher", "useQuery", "useAsyncState", "useTriggerRuntimeControls", "space", "triggers", "useQuery", "Filter", "type", "FunctionTrigger", "isRunningState", "setIsRunningState", "useAsyncState", "useComputeRuntimeCallback", "TriggerDispatcher", "pipe", "map", "t", "running", "start", "fnUntraced", "dispatcher", "stop", "isRunning"]
|
|
7
|
-
}
|