@dxos/plugin-automation 0.7.2-main.f1adc9f → 0.7.2
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/{chunk-R6GS7UA7.mjs → chunk-B3Z4NQC2.mjs} +8 -2
- package/dist/lib/browser/{chunk-R6GS7UA7.mjs.map → chunk-B3Z4NQC2.mjs.map} +3 -3
- package/dist/lib/browser/{chunk-X5KMOH3I.mjs → chunk-PQLGYMNY.mjs} +2 -2
- package/dist/lib/browser/{chunk-X5KMOH3I.mjs.map → chunk-PQLGYMNY.mjs.map} +1 -1
- package/dist/lib/browser/index.mjs +286 -109
- 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 +2 -1
- package/dist/lib/node/{chunk-DTJ7XVO2.cjs → chunk-JSZ6PAYL.cjs} +5 -5
- package/dist/lib/node/{chunk-DTJ7XVO2.cjs.map → chunk-JSZ6PAYL.cjs.map} +1 -1
- package/dist/lib/node/{chunk-JHKEVE65.cjs → chunk-SUMUWFZA.cjs} +8 -5
- package/dist/lib/node/{chunk-JHKEVE65.cjs.map → chunk-SUMUWFZA.cjs.map} +3 -3
- package/dist/lib/node/index.cjs +313 -143
- 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 +7 -6
- package/dist/lib/node/types/index.cjs.map +2 -2
- package/dist/lib/node-esm/{chunk-HNOBZHWK.mjs → chunk-B35UD3D7.mjs} +2 -2
- package/dist/lib/node-esm/{chunk-HNOBZHWK.mjs.map → chunk-B35UD3D7.mjs.map} +1 -1
- package/dist/lib/node-esm/{chunk-ISJZVA2J.mjs → chunk-PYT2WY4B.mjs} +7 -2
- package/dist/lib/node-esm/{chunk-ISJZVA2J.mjs.map → chunk-PYT2WY4B.mjs.map} +3 -3
- package/dist/lib/node-esm/index.mjs +286 -109
- 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 +2 -1
- package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
- package/dist/types/src/components/AutomationPanel.d.ts +3 -0
- package/dist/types/src/components/AutomationPanel.d.ts.map +1 -0
- package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +2 -4
- 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 +3 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +0 -2
- 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 -0
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/package.json +34 -37
- package/src/AutomationPlugin.tsx +35 -88
- package/src/components/AutomationPanel.tsx +23 -0
- package/src/components/TriggerEditor/TriggerEditor.stories.tsx +32 -2
- package/src/components/TriggerEditor/TriggerEditor.tsx +43 -9
- package/src/components/index.ts +3 -4
- package/src/meta.ts +1 -1
- package/src/translations.ts +0 -3
- package/src/types/types.ts +5 -3
- package/dist/lib/browser/AssistantPanel-622FK3DP.mjs +0 -341
- package/dist/lib/browser/AssistantPanel-622FK3DP.mjs.map +0 -7
- package/dist/lib/browser/AutomationPanel-PVI2EJNE.mjs +0 -125
- package/dist/lib/browser/AutomationPanel-PVI2EJNE.mjs.map +0 -7
- package/dist/lib/node/AssistantPanel-HRJRVOZD.cjs +0 -361
- package/dist/lib/node/AssistantPanel-HRJRVOZD.cjs.map +0 -7
- package/dist/lib/node/AutomationPanel-Z2XW24BN.cjs +0 -145
- package/dist/lib/node/AutomationPanel-Z2XW24BN.cjs.map +0 -7
- package/dist/lib/node-esm/AssistantPanel-QIIX7S4V.mjs +0 -342
- package/dist/lib/node-esm/AssistantPanel-QIIX7S4V.mjs.map +0 -7
- package/dist/lib/node-esm/AutomationPanel-5L5NFVKU.mjs +0 -126
- package/dist/lib/node-esm/AutomationPanel-5L5NFVKU.mjs.map +0 -7
- package/dist/types/src/components/AssistantPanel/AssistantPanel.d.ts +0 -8
- package/dist/types/src/components/AssistantPanel/AssistantPanel.d.ts.map +0 -1
- package/dist/types/src/components/AssistantPanel/index.d.ts +0 -3
- package/dist/types/src/components/AssistantPanel/index.d.ts.map +0 -1
- package/dist/types/src/components/AssistantPanel/system-instructions.d.ts +0 -6
- package/dist/types/src/components/AssistantPanel/system-instructions.d.ts.map +0 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +0 -9
- package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +0 -1
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts +0 -6
- package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts.map +0 -1
- package/dist/types/src/components/AutomationPanel/index.d.ts +0 -3
- package/dist/types/src/components/AutomationPanel/index.d.ts.map +0 -1
- package/dist/types/src/testing/index.d.ts +0 -2
- package/dist/types/src/testing/index.d.ts.map +0 -1
- package/dist/types/src/testing/testing.d.ts +0 -12
- package/dist/types/src/testing/testing.d.ts.map +0 -1
- package/src/components/AssistantPanel/AssistantPanel.tsx +0 -230
- package/src/components/AssistantPanel/index.ts +0 -7
- package/src/components/AssistantPanel/system-instructions.ts +0 -166
- package/src/components/AutomationPanel/AutomationPanel.stories.tsx +0 -57
- package/src/components/AutomationPanel/AutomationPanel.tsx +0 -96
- package/src/components/AutomationPanel/index.ts +0 -7
- package/src/testing/index.ts +0 -5
- package/src/testing/testing.ts +0 -34
|
@@ -5,27 +5,276 @@ import {
|
|
|
5
5
|
ChainInputType,
|
|
6
6
|
ChainPromptType,
|
|
7
7
|
ChainType
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-PYT2WY4B.mjs";
|
|
9
9
|
import {
|
|
10
10
|
AUTOMATION_PLUGIN,
|
|
11
11
|
meta_default
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-B35UD3D7.mjs";
|
|
13
13
|
|
|
14
14
|
// packages/plugins/experimental/plugin-automation/src/AutomationPlugin.tsx
|
|
15
|
-
import
|
|
15
|
+
import React4 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
|
-
|
|
21
|
+
import { getTypename, loadObjectReferences, parseId } from "@dxos/react-client/echo";
|
|
22
|
+
|
|
23
|
+
// packages/plugins/experimental/plugin-automation/src/components/AutomationPanel.tsx
|
|
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
|
+
};
|
|
24
245
|
|
|
25
|
-
// packages/plugins/experimental/plugin-automation/src/components/
|
|
26
|
-
import
|
|
27
|
-
|
|
28
|
-
|
|
246
|
+
// packages/plugins/experimental/plugin-automation/src/components/TriggerEditor/TriggerEditor.tsx
|
|
247
|
+
import React3 from "react";
|
|
248
|
+
import { FunctionTriggerSchema, TriggerKind } from "@dxos/functions";
|
|
249
|
+
import { FunctionType } from "@dxos/plugin-script/types";
|
|
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
|
+
};
|
|
29
278
|
|
|
30
279
|
// packages/plugins/experimental/plugin-automation/src/translations.ts
|
|
31
280
|
var translations_default = [
|
|
@@ -54,9 +303,7 @@ var translations_default = [
|
|
|
54
303
|
"trigger filter": "Filter",
|
|
55
304
|
"trigger cron": "Cron",
|
|
56
305
|
"trigger method": "Method",
|
|
57
|
-
"trigger endpoint": "Endpoint"
|
|
58
|
-
"open assistant panel label": "Show Assistant",
|
|
59
|
-
"assistant panel label": "Assistant"
|
|
306
|
+
"trigger endpoint": "Endpoint"
|
|
60
307
|
}
|
|
61
308
|
}
|
|
62
309
|
}
|
|
@@ -83,10 +330,7 @@ var AutomationPlugin = () => {
|
|
|
83
330
|
}
|
|
84
331
|
}
|
|
85
332
|
},
|
|
86
|
-
translations:
|
|
87
|
-
...translations_default,
|
|
88
|
-
...formTranslations
|
|
89
|
-
],
|
|
333
|
+
translations: translations_default,
|
|
90
334
|
echo: {
|
|
91
335
|
schema: [
|
|
92
336
|
ChainType,
|
|
@@ -104,17 +348,7 @@ var AutomationPlugin = () => {
|
|
|
104
348
|
ns: AUTOMATION_PLUGIN
|
|
105
349
|
}
|
|
106
350
|
],
|
|
107
|
-
icon: "ph--
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
id: "assistant",
|
|
111
|
-
label: [
|
|
112
|
-
"open assistant panel label",
|
|
113
|
-
{
|
|
114
|
-
ns: AUTOMATION_PLUGIN
|
|
115
|
-
}
|
|
116
|
-
],
|
|
117
|
-
icon: "ph--atom--regular"
|
|
351
|
+
icon: "ph--flow-arrow--regular"
|
|
118
352
|
}
|
|
119
353
|
]
|
|
120
354
|
},
|
|
@@ -126,7 +360,7 @@ var AutomationPlugin = () => {
|
|
|
126
360
|
const client = clientPlugin?.provides.client;
|
|
127
361
|
invariant(resolve, void 0, {
|
|
128
362
|
F: __dxlog_file,
|
|
129
|
-
L:
|
|
363
|
+
L: 52,
|
|
130
364
|
S: void 0,
|
|
131
365
|
A: [
|
|
132
366
|
"resolve",
|
|
@@ -135,7 +369,7 @@ var AutomationPlugin = () => {
|
|
|
135
369
|
});
|
|
136
370
|
invariant(client, void 0, {
|
|
137
371
|
F: __dxlog_file,
|
|
138
|
-
L:
|
|
372
|
+
L: 53,
|
|
139
373
|
S: void 0,
|
|
140
374
|
A: [
|
|
141
375
|
"client",
|
|
@@ -151,11 +385,10 @@ var AutomationPlugin = () => {
|
|
|
151
385
|
return;
|
|
152
386
|
}
|
|
153
387
|
const type = "orphan-settings-for-subject";
|
|
154
|
-
const icon = "ph--
|
|
388
|
+
const icon = "ph--flow-arrow--regular";
|
|
155
389
|
const [subjectId] = id.split("~");
|
|
156
390
|
const { spaceId, objectId } = parseId(subjectId);
|
|
157
|
-
const
|
|
158
|
-
const space = spaces?.find((space2) => space2.id === spaceId && space2.state.get() === SpaceState.SPACE_READY);
|
|
391
|
+
const space = client.spaces.get().find((space2) => space2.id === spaceId);
|
|
159
392
|
if (!objectId) {
|
|
160
393
|
const label2 = space ? space.properties.name || [
|
|
161
394
|
"unnamed space label",
|
|
@@ -181,9 +414,15 @@ var AutomationPlugin = () => {
|
|
|
181
414
|
}
|
|
182
415
|
};
|
|
183
416
|
}
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
417
|
+
const object = toSignal((onChange) => {
|
|
418
|
+
const timeout = setTimeout(async () => {
|
|
419
|
+
await space?.db.query({
|
|
420
|
+
id: objectId
|
|
421
|
+
}).first();
|
|
422
|
+
onChange();
|
|
423
|
+
});
|
|
424
|
+
return () => clearTimeout(timeout);
|
|
425
|
+
}, () => space?.db.getObjectById(objectId), subjectId);
|
|
187
426
|
if (!object || !subjectId) {
|
|
188
427
|
return;
|
|
189
428
|
}
|
|
@@ -205,54 +444,6 @@ var AutomationPlugin = () => {
|
|
|
205
444
|
}
|
|
206
445
|
};
|
|
207
446
|
}
|
|
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
|
-
}
|
|
256
447
|
})
|
|
257
448
|
];
|
|
258
449
|
}
|
|
@@ -260,36 +451,21 @@ var AutomationPlugin = () => {
|
|
|
260
451
|
surface: {
|
|
261
452
|
component: ({ data, role }) => {
|
|
262
453
|
switch (role) {
|
|
263
|
-
case
|
|
264
|
-
|
|
265
|
-
|
|
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
|
-
}
|
|
454
|
+
// case 'article':
|
|
455
|
+
// return data.object instanceof ChainType ? <ChainArticle chain={data.object} /> : null;
|
|
456
|
+
case "complementary--automation":
|
|
457
|
+
return /* @__PURE__ */ React4.createElement(AutomationPanel, null);
|
|
287
458
|
}
|
|
288
459
|
return null;
|
|
289
460
|
}
|
|
290
461
|
},
|
|
291
462
|
intent: {
|
|
292
463
|
resolver: (intent) => {
|
|
464
|
+
switch (intent.action) {
|
|
465
|
+
case AutomationAction.CREATE: {
|
|
466
|
+
return {};
|
|
467
|
+
}
|
|
468
|
+
}
|
|
293
469
|
}
|
|
294
470
|
}
|
|
295
471
|
}
|
|
@@ -517,7 +693,6 @@ var chainPresets = [
|
|
|
517
693
|
// packages/plugins/experimental/plugin-automation/src/index.ts
|
|
518
694
|
var src_default = AutomationPlugin;
|
|
519
695
|
export {
|
|
520
|
-
AssistantPanel,
|
|
521
696
|
AutomationAction,
|
|
522
697
|
AutomationPanel,
|
|
523
698
|
AutomationPlugin,
|
|
@@ -525,6 +700,8 @@ export {
|
|
|
525
700
|
ChainInputType,
|
|
526
701
|
ChainPromptType,
|
|
527
702
|
ChainType,
|
|
703
|
+
PromptEditor,
|
|
704
|
+
TriggerEditor,
|
|
528
705
|
chainPresets,
|
|
529
706
|
src_default as default,
|
|
530
707
|
str
|