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