@dxos/plugin-automation 0.7.2 → 0.7.3-staging.971cd8d
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/AssistantPanel-622FK3DP.mjs +341 -0
- package/dist/lib/browser/AssistantPanel-622FK3DP.mjs.map +7 -0
- package/dist/lib/browser/AutomationPanel-AQMN2CQR.mjs +153 -0
- package/dist/lib/browser/AutomationPanel-AQMN2CQR.mjs.map +7 -0
- package/dist/lib/browser/{chunk-B3Z4NQC2.mjs → chunk-7KB4UMXO.mjs} +2 -8
- package/dist/lib/browser/{chunk-B3Z4NQC2.mjs.map → chunk-7KB4UMXO.mjs.map} +3 -3
- package/dist/lib/browser/{chunk-PQLGYMNY.mjs → chunk-X5KMOH3I.mjs} +2 -2
- package/dist/lib/browser/{chunk-PQLGYMNY.mjs.map → chunk-X5KMOH3I.mjs.map} +1 -1
- package/dist/lib/browser/index.mjs +111 -288
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/meta.mjs +1 -1
- package/dist/lib/browser/types/index.mjs +1 -2
- package/dist/lib/node/AssistantPanel-HRJRVOZD.cjs +361 -0
- package/dist/lib/node/AssistantPanel-HRJRVOZD.cjs.map +7 -0
- package/dist/lib/node/AutomationPanel-HZS5WKI5.cjs +173 -0
- package/dist/lib/node/AutomationPanel-HZS5WKI5.cjs.map +7 -0
- package/dist/lib/node/{chunk-SUMUWFZA.cjs → chunk-CUCUWUAF.cjs} +5 -8
- package/dist/lib/node/{chunk-SUMUWFZA.cjs.map → chunk-CUCUWUAF.cjs.map} +3 -3
- package/dist/lib/node/{chunk-JSZ6PAYL.cjs → chunk-DTJ7XVO2.cjs} +5 -5
- package/dist/lib/node/{chunk-JSZ6PAYL.cjs.map → chunk-DTJ7XVO2.cjs.map} +1 -1
- package/dist/lib/node/index.cjs +145 -315
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.cjs +3 -3
- package/dist/lib/node/meta.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types/index.cjs +6 -7
- package/dist/lib/node/types/index.cjs.map +2 -2
- package/dist/lib/node-esm/AssistantPanel-QIIX7S4V.mjs +342 -0
- package/dist/lib/node-esm/AssistantPanel-QIIX7S4V.mjs.map +7 -0
- package/dist/lib/node-esm/AutomationPanel-JUHOWQWW.mjs +154 -0
- package/dist/lib/node-esm/AutomationPanel-JUHOWQWW.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-PYT2WY4B.mjs → chunk-23LY7DYS.mjs} +2 -7
- package/dist/lib/node-esm/{chunk-PYT2WY4B.mjs.map → chunk-23LY7DYS.mjs.map} +3 -3
- package/dist/lib/node-esm/{chunk-B35UD3D7.mjs → chunk-HNOBZHWK.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-B35UD3D7.mjs.map → chunk-HNOBZHWK.mjs.map} +1 -1
- package/dist/lib/node-esm/index.mjs +111 -288
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/meta.mjs +1 -1
- package/dist/lib/node-esm/types/index.mjs +1 -2
- package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
- package/dist/types/src/components/AssistantPanel/AssistantPanel.d.ts +8 -0
- package/dist/types/src/components/AssistantPanel/AssistantPanel.d.ts.map +1 -0
- package/dist/types/src/components/AssistantPanel/index.d.ts +3 -0
- package/dist/types/src/components/AssistantPanel/index.d.ts.map +1 -0
- package/dist/types/src/components/AssistantPanel/system-instructions.d.ts +6 -0
- package/dist/types/src/components/AssistantPanel/system-instructions.d.ts.map +1 -0
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +8 -0
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -0
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts +6 -0
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts.map +1 -0
- package/dist/types/src/components/AutomationPanel/index.d.ts +3 -0
- package/dist/types/src/components/AutomationPanel/index.d.ts.map +1 -0
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +6 -3
- 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 +2 -3
- 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/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/testing.d.ts +12 -0
- package/dist/types/src/testing/testing.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +2 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +3 -3
- package/dist/types/src/types/types.d.ts +1 -2
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/package.json +38 -34
- package/src/AutomationPlugin.tsx +89 -36
- package/src/components/AssistantPanel/AssistantPanel.tsx +230 -0
- package/src/components/AssistantPanel/index.ts +7 -0
- package/src/components/AssistantPanel/system-instructions.ts +166 -0
- package/src/components/AutomationPanel/AutomationPanel.stories.tsx +57 -0
- package/src/components/AutomationPanel/AutomationPanel.tsx +135 -0
- package/src/components/AutomationPanel/index.ts +7 -0
- package/src/components/PromptEditor/PromptEditor.stories.tsx +1 -1
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +2 -32
- package/src/components/TriggerEditor/TriggerEditor.tsx +19 -47
- package/src/components/index.ts +4 -3
- package/src/hooks/email.ts +2 -2
- package/src/meta.ts +1 -1
- package/src/presets.ts +1 -1
- package/src/testing/index.ts +5 -0
- package/src/testing/testing.ts +34 -0
- package/src/translations.ts +3 -0
- package/src/types/types.ts +4 -6
- package/dist/types/src/components/AutomationPanel.d.ts +0 -3
- package/dist/types/src/components/AutomationPanel.d.ts.map +0 -1
- package/src/components/AutomationPanel.tsx +0 -23
|
@@ -4,7 +4,7 @@ var meta_default = {
|
|
|
4
4
|
id: AUTOMATION_PLUGIN,
|
|
5
5
|
name: "Automation",
|
|
6
6
|
description: "Automation workflows.",
|
|
7
|
-
icon: "ph--
|
|
7
|
+
icon: "ph--magic-wand--regular",
|
|
8
8
|
source: "https://github.com/dxos/dxos/tree/main/packages/plugins/experimental/plugin-automation",
|
|
9
9
|
tags: [
|
|
10
10
|
"experimental"
|
|
@@ -15,4 +15,4 @@ export {
|
|
|
15
15
|
AUTOMATION_PLUGIN,
|
|
16
16
|
meta_default
|
|
17
17
|
};
|
|
18
|
-
//# sourceMappingURL=chunk-
|
|
18
|
+
//# sourceMappingURL=chunk-X5KMOH3I.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/meta.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const AUTOMATION_PLUGIN = 'dxos.org/plugin/automation';\n\nexport default {\n id: AUTOMATION_PLUGIN,\n name: 'Automation',\n description: 'Automation workflows.',\n icon: 'ph--
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const AUTOMATION_PLUGIN = 'dxos.org/plugin/automation';\n\nexport default {\n id: AUTOMATION_PLUGIN,\n name: 'Automation',\n description: 'Automation workflows.',\n icon: 'ph--magic-wand--regular',\n source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/experimental/plugin-automation',\n tags: ['experimental'],\n} satisfies PluginMeta;\n"],
|
|
5
5
|
"mappings": ";AAMO,IAAMA,oBAAoB;AAEjC,IAAA,eAAe;EACbC,IAAID;EACJE,MAAM;EACNC,aAAa;EACbC,MAAM;EACNC,QAAQ;EACRC,MAAM;IAAC;;AACT;",
|
|
6
6
|
"names": ["AUTOMATION_PLUGIN", "id", "name", "description", "icon", "source", "tags"]
|
|
7
7
|
}
|
|
@@ -4,276 +4,27 @@ import {
|
|
|
4
4
|
ChainInputType,
|
|
5
5
|
ChainPromptType,
|
|
6
6
|
ChainType
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-7KB4UMXO.mjs";
|
|
8
8
|
import {
|
|
9
9
|
AUTOMATION_PLUGIN,
|
|
10
10
|
meta_default
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-X5KMOH3I.mjs";
|
|
12
12
|
|
|
13
13
|
// packages/plugins/experimental/plugin-automation/src/AutomationPlugin.tsx
|
|
14
|
-
import
|
|
14
|
+
import React from "react";
|
|
15
15
|
import { parseMetadataResolverPlugin, resolvePlugin } from "@dxos/app-framework";
|
|
16
16
|
import { FunctionTrigger } from "@dxos/functions";
|
|
17
17
|
import { invariant } from "@dxos/invariant";
|
|
18
18
|
import { parseClientPlugin } from "@dxos/plugin-client";
|
|
19
19
|
import { createExtension, toSignal } from "@dxos/plugin-graph";
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
import React from "react";
|
|
24
|
-
import { Button, Icon, Toolbar } from "@dxos/react-ui";
|
|
25
|
-
var AutomationPanel = () => {
|
|
26
|
-
const handleCreate = () => {
|
|
27
|
-
};
|
|
28
|
-
return /* @__PURE__ */ React.createElement("div", {
|
|
29
|
-
className: "flex flex-col"
|
|
30
|
-
}, /* @__PURE__ */ React.createElement(Toolbar.Root, {
|
|
31
|
-
classNames: "p-2"
|
|
32
|
-
}, /* @__PURE__ */ React.createElement(Button, {
|
|
33
|
-
onClick: handleCreate
|
|
34
|
-
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
35
|
-
icon: "ph--plus--regular"
|
|
36
|
-
}))));
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
// packages/plugins/experimental/plugin-automation/src/components/PromptEditor/PromptEditor.tsx
|
|
40
|
-
import React2, { useEffect } from "react";
|
|
41
|
-
import { createDocAccessor } from "@dxos/react-client/echo";
|
|
42
|
-
import { Input, Select, useThemeContext, useTranslation } from "@dxos/react-ui";
|
|
43
|
-
import { createBasicExtensions, createDataExtensions, createThemeExtensions, useTextEditor } from "@dxos/react-ui-editor";
|
|
44
|
-
import { attentionSurface, groupBorder, mx as mx2 } from "@dxos/react-ui-theme";
|
|
45
|
-
import { nonNullable } from "@dxos/util";
|
|
46
|
-
|
|
47
|
-
// packages/plugins/experimental/plugin-automation/src/components/PromptEditor/prompt-extension.ts
|
|
48
|
-
import { HighlightStyle, StreamLanguage, syntaxHighlighting } from "@codemirror/language";
|
|
49
|
-
import { tags } from "@dxos/react-ui-editor";
|
|
50
|
-
import { mx } from "@dxos/react-ui-theme";
|
|
51
|
-
var nameRegex = /\{([\w-]+)}/;
|
|
52
|
-
var parser = StreamLanguage.define({
|
|
53
|
-
token: (stream) => {
|
|
54
|
-
if (stream.eatSpace()) {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
if (stream.match(/^#.*/)) {
|
|
58
|
-
return "lineComment";
|
|
59
|
-
}
|
|
60
|
-
if (stream.match(/^-+$/)) {
|
|
61
|
-
return "lineComment";
|
|
62
|
-
}
|
|
63
|
-
if (stream.match(nameRegex)) {
|
|
64
|
-
return "variableName";
|
|
65
|
-
}
|
|
66
|
-
stream.next();
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
var highlightStyles = HighlightStyle.define([
|
|
71
|
-
{
|
|
72
|
-
tag: tags.variableName,
|
|
73
|
-
class: mx("rounded border border-yellow-500 bg-yellow-100 text-black font-mono text-sm")
|
|
74
|
-
}
|
|
75
|
-
]);
|
|
76
|
-
var promptExtension = [
|
|
77
|
-
parser,
|
|
78
|
-
syntaxHighlighting(highlightStyles)
|
|
79
|
-
];
|
|
80
|
-
|
|
81
|
-
// packages/plugins/experimental/plugin-automation/src/components/PromptEditor/PromptEditor.tsx
|
|
82
|
-
var inputTypes = [
|
|
83
|
-
{
|
|
84
|
-
value: ChainInputType.VALUE,
|
|
85
|
-
label: "Value"
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
value: ChainInputType.PASS_THROUGH,
|
|
89
|
-
label: "Pass through"
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
value: ChainInputType.RETRIEVER,
|
|
93
|
-
label: "Retriever"
|
|
94
|
-
},
|
|
95
|
-
// {
|
|
96
|
-
// value: ChainInputType.FUNCTION,
|
|
97
|
-
// label: 'Function',
|
|
98
|
-
// },
|
|
99
|
-
// {
|
|
100
|
-
// value: ChainInputType.QUERY,
|
|
101
|
-
// label: 'Query',
|
|
102
|
-
// },
|
|
103
|
-
{
|
|
104
|
-
value: ChainInputType.RESOLVER,
|
|
105
|
-
label: "Resolver"
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
value: ChainInputType.CONTEXT,
|
|
109
|
-
label: "Context"
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
value: ChainInputType.SCHEMA,
|
|
113
|
-
label: "Schema"
|
|
114
|
-
}
|
|
115
|
-
];
|
|
116
|
-
var getInputType = (type) => inputTypes.find(({ value }) => String(value) === type)?.value;
|
|
117
|
-
var usePromptInputs = (prompt) => {
|
|
118
|
-
useEffect(() => {
|
|
119
|
-
const text = prompt.template ?? "";
|
|
120
|
-
if (!prompt.inputs) {
|
|
121
|
-
prompt.inputs = [];
|
|
122
|
-
}
|
|
123
|
-
const regex = new RegExp(nameRegex, "g");
|
|
124
|
-
const variables = new Set([
|
|
125
|
-
...text.matchAll(regex)
|
|
126
|
-
].map((m) => m[1]));
|
|
127
|
-
const unclaimed = new Map(prompt.inputs?.filter(nonNullable).map((input) => [
|
|
128
|
-
input.name,
|
|
129
|
-
input
|
|
130
|
-
]));
|
|
131
|
-
const missing = [];
|
|
132
|
-
Array.from(variables.values()).forEach((name) => {
|
|
133
|
-
if (unclaimed.has(name)) {
|
|
134
|
-
unclaimed.delete(name);
|
|
135
|
-
} else {
|
|
136
|
-
missing.push(name);
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
const values = unclaimed.values();
|
|
140
|
-
missing.forEach((name) => {
|
|
141
|
-
const next = values.next().value;
|
|
142
|
-
if (next) {
|
|
143
|
-
next.name = name;
|
|
144
|
-
} else {
|
|
145
|
-
prompt.inputs?.push({
|
|
146
|
-
name
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
for (const input of values) {
|
|
151
|
-
prompt.inputs.splice(prompt.inputs.indexOf(input), 1);
|
|
152
|
-
}
|
|
153
|
-
}, [
|
|
154
|
-
prompt.template
|
|
155
|
-
]);
|
|
156
|
-
};
|
|
157
|
-
var PromptEditor = ({ prompt, commandEditable = true }) => {
|
|
158
|
-
const { t } = useTranslation(AUTOMATION_PLUGIN);
|
|
159
|
-
const { themeMode } = useThemeContext();
|
|
160
|
-
const { parentRef } = useTextEditor(() => ({
|
|
161
|
-
initialValue: prompt.template,
|
|
162
|
-
extensions: [
|
|
163
|
-
createDataExtensions({
|
|
164
|
-
id: prompt.id,
|
|
165
|
-
text: prompt.template !== void 0 ? createDocAccessor(prompt, [
|
|
166
|
-
"template"
|
|
167
|
-
]) : void 0
|
|
168
|
-
}),
|
|
169
|
-
createBasicExtensions({
|
|
170
|
-
bracketMatching: false,
|
|
171
|
-
lineWrapping: true,
|
|
172
|
-
placeholder: t("template placeholder")
|
|
173
|
-
}),
|
|
174
|
-
createThemeExtensions({
|
|
175
|
-
themeMode,
|
|
176
|
-
slots: {
|
|
177
|
-
content: {
|
|
178
|
-
className: "!p-3"
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}),
|
|
182
|
-
promptExtension
|
|
183
|
-
]
|
|
184
|
-
}), [
|
|
185
|
-
themeMode,
|
|
186
|
-
prompt
|
|
187
|
-
]);
|
|
188
|
-
usePromptInputs(prompt);
|
|
189
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
190
|
-
className: mx2("flex flex-col w-full overflow-hidden gap-4", groupBorder)
|
|
191
|
-
}, commandEditable && /* @__PURE__ */ React2.createElement("div", {
|
|
192
|
-
className: "flex items-center pl-4"
|
|
193
|
-
}, /* @__PURE__ */ React2.createElement("span", {
|
|
194
|
-
className: "text-neutral-500"
|
|
195
|
-
}, "/"), /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
196
|
-
placeholder: t("command placeholder"),
|
|
197
|
-
classNames: mx2("is-full bg-transparent m-2"),
|
|
198
|
-
value: prompt.command ?? "",
|
|
199
|
-
onChange: (event) => {
|
|
200
|
-
prompt.command = event.target.value.replace(/\w/g, "");
|
|
201
|
-
}
|
|
202
|
-
}))), /* @__PURE__ */ React2.createElement("div", {
|
|
203
|
-
ref: parentRef,
|
|
204
|
-
className: mx2(attentionSurface, "rounded", "min-h-[120px]")
|
|
205
|
-
}), (prompt.inputs?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement("div", {
|
|
206
|
-
className: "flex flex-col"
|
|
207
|
-
}, /* @__PURE__ */ React2.createElement("table", {
|
|
208
|
-
className: "w-full table-fixed border-collapse my-2"
|
|
209
|
-
}, /* @__PURE__ */ React2.createElement("tbody", null, prompt.inputs?.filter(nonNullable).map((input) => /* @__PURE__ */ React2.createElement("tr", {
|
|
210
|
-
key: input.name
|
|
211
|
-
}, /* @__PURE__ */ React2.createElement("td", {
|
|
212
|
-
className: "w-[160px] p-1 font-mono text-sm whitespace-nowrap truncate"
|
|
213
|
-
}, /* @__PURE__ */ React2.createElement("code", {
|
|
214
|
-
className: "px-2"
|
|
215
|
-
}, input.name)), /* @__PURE__ */ React2.createElement("td", {
|
|
216
|
-
className: "w-[120px] p-1"
|
|
217
|
-
}, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Select.Root, {
|
|
218
|
-
value: String(input.type),
|
|
219
|
-
onValueChange: (type) => {
|
|
220
|
-
input.type = getInputType(type) ?? ChainInputType.VALUE;
|
|
221
|
-
}
|
|
222
|
-
}, /* @__PURE__ */ React2.createElement(Select.TriggerButton, {
|
|
223
|
-
placeholder: "Type",
|
|
224
|
-
classNames: "is-full"
|
|
225
|
-
}), /* @__PURE__ */ React2.createElement(Select.Portal, null, /* @__PURE__ */ React2.createElement(Select.Content, null, /* @__PURE__ */ React2.createElement(Select.Viewport, null, inputTypes.map(({ value, label }) => /* @__PURE__ */ React2.createElement(Select.Option, {
|
|
226
|
-
key: value,
|
|
227
|
-
value: String(value)
|
|
228
|
-
}, label)))))))), /* @__PURE__ */ React2.createElement("td", {
|
|
229
|
-
className: "p-1 pr-2"
|
|
230
|
-
}, input.type !== void 0 && [
|
|
231
|
-
ChainInputType.VALUE,
|
|
232
|
-
ChainInputType.CONTEXT,
|
|
233
|
-
ChainInputType.RESOLVER,
|
|
234
|
-
ChainInputType.SCHEMA
|
|
235
|
-
].includes(input.type) && /* @__PURE__ */ React2.createElement("div", null, /* @__PURE__ */ React2.createElement(Input.Root, null, /* @__PURE__ */ React2.createElement(Input.TextInput, {
|
|
236
|
-
placeholder: t("command placeholder"),
|
|
237
|
-
classNames: mx2("is-full bg-transparent"),
|
|
238
|
-
value: input.value ?? "",
|
|
239
|
-
onChange: (event) => {
|
|
240
|
-
input.value = event.target.value;
|
|
241
|
-
}
|
|
242
|
-
}))))))))));
|
|
243
|
-
};
|
|
20
|
+
import { memoizeQuery } from "@dxos/plugin-space";
|
|
21
|
+
import { getSpace, getTypename, isEchoObject, loadObjectReferences, parseId, SpaceState } from "@dxos/react-client/echo";
|
|
22
|
+
import { translations as formTranslations } from "@dxos/react-ui-form";
|
|
244
23
|
|
|
245
|
-
// packages/plugins/experimental/plugin-automation/src/components/
|
|
246
|
-
import
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
import { Filter, useQuery } from "@dxos/react-client/echo";
|
|
250
|
-
import { useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
251
|
-
import { Form, SelectInput } from "@dxos/react-ui-form";
|
|
252
|
-
var TriggerEditor = ({ space, trigger }) => {
|
|
253
|
-
const { t } = useTranslation2(AUTOMATION_PLUGIN);
|
|
254
|
-
const functions = useQuery(space, Filter.schema(FunctionType));
|
|
255
|
-
return /* @__PURE__ */ React3.createElement(Form, {
|
|
256
|
-
schema: FunctionTriggerSchema,
|
|
257
|
-
values: trigger,
|
|
258
|
-
filter: (props) => props.filter((p) => p.name !== "meta"),
|
|
259
|
-
Custom: {
|
|
260
|
-
["function"]: (props) => /* @__PURE__ */ React3.createElement(SelectInput, {
|
|
261
|
-
...props,
|
|
262
|
-
options: functions.map(({ name }) => ({
|
|
263
|
-
value: name,
|
|
264
|
-
label: name
|
|
265
|
-
}))
|
|
266
|
-
}),
|
|
267
|
-
["spec.type"]: (props) => /* @__PURE__ */ React3.createElement(SelectInput, {
|
|
268
|
-
...props,
|
|
269
|
-
options: Object.values(TriggerKind).map((kind) => ({
|
|
270
|
-
value: kind,
|
|
271
|
-
label: t(`trigger type ${kind}`)
|
|
272
|
-
}))
|
|
273
|
-
})
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
};
|
|
24
|
+
// packages/plugins/experimental/plugin-automation/src/components/index.ts
|
|
25
|
+
import { lazy } from "react";
|
|
26
|
+
var AssistantPanel = lazy(() => import("./AssistantPanel-622FK3DP.mjs"));
|
|
27
|
+
var AutomationPanel = lazy(() => import("./AutomationPanel-AQMN2CQR.mjs"));
|
|
277
28
|
|
|
278
29
|
// packages/plugins/experimental/plugin-automation/src/translations.ts
|
|
279
30
|
var translations_default = [
|
|
@@ -302,7 +53,9 @@ var translations_default = [
|
|
|
302
53
|
"trigger filter": "Filter",
|
|
303
54
|
"trigger cron": "Cron",
|
|
304
55
|
"trigger method": "Method",
|
|
305
|
-
"trigger endpoint": "Endpoint"
|
|
56
|
+
"trigger endpoint": "Endpoint",
|
|
57
|
+
"open assistant panel label": "Show Assistant",
|
|
58
|
+
"assistant panel label": "Assistant"
|
|
306
59
|
}
|
|
307
60
|
}
|
|
308
61
|
}
|
|
@@ -329,9 +82,12 @@ var AutomationPlugin = () => {
|
|
|
329
82
|
}
|
|
330
83
|
}
|
|
331
84
|
},
|
|
332
|
-
translations:
|
|
85
|
+
translations: [
|
|
86
|
+
...translations_default,
|
|
87
|
+
...formTranslations
|
|
88
|
+
],
|
|
333
89
|
echo: {
|
|
334
|
-
|
|
90
|
+
system: [
|
|
335
91
|
ChainType,
|
|
336
92
|
ChainPromptType,
|
|
337
93
|
FunctionTrigger
|
|
@@ -347,7 +103,17 @@ var AutomationPlugin = () => {
|
|
|
347
103
|
ns: AUTOMATION_PLUGIN
|
|
348
104
|
}
|
|
349
105
|
],
|
|
350
|
-
icon: "ph--
|
|
106
|
+
icon: "ph--magic-wand--regular"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
id: "assistant",
|
|
110
|
+
label: [
|
|
111
|
+
"open assistant panel label",
|
|
112
|
+
{
|
|
113
|
+
ns: AUTOMATION_PLUGIN
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
icon: "ph--atom--regular"
|
|
351
117
|
}
|
|
352
118
|
]
|
|
353
119
|
},
|
|
@@ -359,7 +125,7 @@ var AutomationPlugin = () => {
|
|
|
359
125
|
const client = clientPlugin?.provides.client;
|
|
360
126
|
invariant(resolve, void 0, {
|
|
361
127
|
F: __dxlog_file,
|
|
362
|
-
L:
|
|
128
|
+
L: 66,
|
|
363
129
|
S: void 0,
|
|
364
130
|
A: [
|
|
365
131
|
"resolve",
|
|
@@ -368,7 +134,7 @@ var AutomationPlugin = () => {
|
|
|
368
134
|
});
|
|
369
135
|
invariant(client, void 0, {
|
|
370
136
|
F: __dxlog_file,
|
|
371
|
-
L:
|
|
137
|
+
L: 67,
|
|
372
138
|
S: void 0,
|
|
373
139
|
A: [
|
|
374
140
|
"client",
|
|
@@ -384,10 +150,11 @@ var AutomationPlugin = () => {
|
|
|
384
150
|
return;
|
|
385
151
|
}
|
|
386
152
|
const type = "orphan-settings-for-subject";
|
|
387
|
-
const icon = "ph--
|
|
153
|
+
const icon = "ph--magic-wand--regular";
|
|
388
154
|
const [subjectId] = id.split("~");
|
|
389
155
|
const { spaceId, objectId } = parseId(subjectId);
|
|
390
|
-
const
|
|
156
|
+
const spaces = toSignal((onChange) => client.spaces.subscribe(() => onChange()).unsubscribe, () => client.spaces.get());
|
|
157
|
+
const space = spaces?.find((space2) => space2.id === spaceId && space2.state.get() === SpaceState.SPACE_READY);
|
|
391
158
|
if (!objectId) {
|
|
392
159
|
const label2 = space ? space.properties.name || [
|
|
393
160
|
"unnamed space label",
|
|
@@ -413,15 +180,9 @@ var AutomationPlugin = () => {
|
|
|
413
180
|
}
|
|
414
181
|
};
|
|
415
182
|
}
|
|
416
|
-
const object =
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
id: objectId
|
|
420
|
-
}).first();
|
|
421
|
-
onChange();
|
|
422
|
-
});
|
|
423
|
-
return () => clearTimeout(timeout);
|
|
424
|
-
}, () => space?.db.getObjectById(objectId), subjectId);
|
|
183
|
+
const [object] = memoizeQuery(space, {
|
|
184
|
+
id: objectId
|
|
185
|
+
});
|
|
425
186
|
if (!object || !subjectId) {
|
|
426
187
|
return;
|
|
427
188
|
}
|
|
@@ -443,6 +204,54 @@ var AutomationPlugin = () => {
|
|
|
443
204
|
}
|
|
444
205
|
};
|
|
445
206
|
}
|
|
207
|
+
}),
|
|
208
|
+
createExtension({
|
|
209
|
+
id: `${AUTOMATION_PLUGIN}/assistant-for-subject`,
|
|
210
|
+
resolver: ({ id }) => {
|
|
211
|
+
if (!id.endsWith("~assistant")) {
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
const [subjectId] = id.split("~");
|
|
215
|
+
const { spaceId, objectId } = parseId(subjectId);
|
|
216
|
+
const spaces = toSignal((onChange) => client.spaces.subscribe(() => onChange()).unsubscribe, () => client.spaces.get());
|
|
217
|
+
const space = spaces?.find((space2) => space2.id === spaceId && space2.state.get() === SpaceState.SPACE_READY);
|
|
218
|
+
if (!objectId) {
|
|
219
|
+
return {
|
|
220
|
+
id,
|
|
221
|
+
type: "orphan-automation-for-subject",
|
|
222
|
+
data: null,
|
|
223
|
+
properties: {
|
|
224
|
+
icon: "ph--atom--regular",
|
|
225
|
+
label: [
|
|
226
|
+
"assistant panel label",
|
|
227
|
+
{
|
|
228
|
+
ns: AUTOMATION_PLUGIN
|
|
229
|
+
}
|
|
230
|
+
],
|
|
231
|
+
object: null,
|
|
232
|
+
space
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
const [object] = memoizeQuery(space, {
|
|
237
|
+
id: objectId
|
|
238
|
+
});
|
|
239
|
+
return {
|
|
240
|
+
id,
|
|
241
|
+
type: "orphan-automation-for-subject",
|
|
242
|
+
data: null,
|
|
243
|
+
properties: {
|
|
244
|
+
icon: "ph--atom--regular",
|
|
245
|
+
label: [
|
|
246
|
+
"assistant panel label",
|
|
247
|
+
{
|
|
248
|
+
ns: AUTOMATION_PLUGIN
|
|
249
|
+
}
|
|
250
|
+
],
|
|
251
|
+
object
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
}
|
|
446
255
|
})
|
|
447
256
|
];
|
|
448
257
|
}
|
|
@@ -450,21 +259,36 @@ var AutomationPlugin = () => {
|
|
|
450
259
|
surface: {
|
|
451
260
|
component: ({ data, role }) => {
|
|
452
261
|
switch (role) {
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
262
|
+
case "complementary--assistant":
|
|
263
|
+
return /* @__PURE__ */ React.createElement(AssistantPanel, {
|
|
264
|
+
subject: data.subject
|
|
265
|
+
});
|
|
266
|
+
case "complementary--automation": {
|
|
267
|
+
const object = data.subject;
|
|
268
|
+
const space = isEchoObject(object) ? getSpace(object) : void 0;
|
|
269
|
+
if (space) {
|
|
270
|
+
invariant(isEchoObject(object), void 0, {
|
|
271
|
+
F: __dxlog_file,
|
|
272
|
+
L: 193,
|
|
273
|
+
S: void 0,
|
|
274
|
+
A: [
|
|
275
|
+
"isEchoObject(object)",
|
|
276
|
+
""
|
|
277
|
+
]
|
|
278
|
+
});
|
|
279
|
+
return /* @__PURE__ */ React.createElement(AutomationPanel, {
|
|
280
|
+
space,
|
|
281
|
+
object
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
break;
|
|
285
|
+
}
|
|
457
286
|
}
|
|
458
287
|
return null;
|
|
459
288
|
}
|
|
460
289
|
},
|
|
461
290
|
intent: {
|
|
462
291
|
resolver: (intent) => {
|
|
463
|
-
switch (intent.action) {
|
|
464
|
-
case AutomationAction.CREATE: {
|
|
465
|
-
return {};
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
292
|
}
|
|
469
293
|
}
|
|
470
294
|
}
|
|
@@ -472,7 +296,7 @@ var AutomationPlugin = () => {
|
|
|
472
296
|
};
|
|
473
297
|
|
|
474
298
|
// packages/plugins/experimental/plugin-automation/src/presets.ts
|
|
475
|
-
import { create } from "@dxos/
|
|
299
|
+
import { create } from "@dxos/live-object";
|
|
476
300
|
var str = (...text) => text.filter((value) => value !== void 0 && value !== false).flat().join("\n");
|
|
477
301
|
var chainPresets = [
|
|
478
302
|
{
|
|
@@ -692,6 +516,7 @@ var chainPresets = [
|
|
|
692
516
|
// packages/plugins/experimental/plugin-automation/src/index.ts
|
|
693
517
|
var src_default = AutomationPlugin;
|
|
694
518
|
export {
|
|
519
|
+
AssistantPanel,
|
|
695
520
|
AutomationAction,
|
|
696
521
|
AutomationPanel,
|
|
697
522
|
AutomationPlugin,
|
|
@@ -699,8 +524,6 @@ export {
|
|
|
699
524
|
ChainInputType,
|
|
700
525
|
ChainPromptType,
|
|
701
526
|
ChainType,
|
|
702
|
-
PromptEditor,
|
|
703
|
-
TriggerEditor,
|
|
704
527
|
chainPresets,
|
|
705
528
|
src_default as default,
|
|
706
529
|
str
|