@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
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AUTOMATION_PLUGIN
|
|
3
|
+
} from "./chunk-PQLGYMNY.mjs";
|
|
4
|
+
|
|
1
5
|
// packages/plugins/experimental/plugin-automation/src/types/schema.ts
|
|
2
6
|
import { ref, S, TypedObject } from "@dxos/echo-schema";
|
|
3
7
|
var ChainInputType;
|
|
@@ -35,8 +39,10 @@ var ChainType = class extends TypedObject({
|
|
|
35
39
|
};
|
|
36
40
|
|
|
37
41
|
// packages/plugins/experimental/plugin-automation/src/types/types.ts
|
|
42
|
+
var AUTOMATION_ACTION = `${AUTOMATION_PLUGIN}/action`;
|
|
38
43
|
var AutomationAction;
|
|
39
|
-
|
|
44
|
+
(function(AutomationAction2) {
|
|
45
|
+
AutomationAction2[AutomationAction2["CREATE"] = `${AUTOMATION_ACTION}/create`] = "CREATE";
|
|
40
46
|
})(AutomationAction || (AutomationAction = {}));
|
|
41
47
|
|
|
42
48
|
export {
|
|
@@ -46,4 +52,4 @@ export {
|
|
|
46
52
|
ChainType,
|
|
47
53
|
AutomationAction
|
|
48
54
|
};
|
|
49
|
-
//# sourceMappingURL=chunk-
|
|
55
|
+
//# sourceMappingURL=chunk-B3Z4NQC2.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/types/schema.ts", "../../../src/types/types.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { ref, S, TypedObject } from '@dxos/echo-schema';\n\n// TODO(burdon): Change to S.Literal (and discriminated union).\nexport enum ChainInputType {\n VALUE = 0,\n PASS_THROUGH = 1,\n RETRIEVER = 2,\n FUNCTION = 3,\n QUERY = 4,\n RESOLVER = 5,\n CONTEXT = 6,\n SCHEMA = 7,\n}\n\nexport const ChainInputSchema = S.mutable(\n S.Struct({\n name: S.String,\n type: S.optional(S.Enums(ChainInputType)),\n value: S.optional(S.String),\n }),\n);\n\nexport type ChainInput = S.Schema.Type<typeof ChainInputSchema>;\n\nexport class ChainPromptType extends TypedObject({ typename: 'dxos.org/type/ChainPrompt', version: '0.1.0' })({\n command: S.optional(S.String),\n template: S.String,\n inputs: S.optional(S.mutable(S.Array(ChainInputSchema))),\n}) {}\n\nexport class ChainType extends TypedObject({ typename: 'dxos.org/type/Chain', version: '0.1.0' })({\n name: S.optional(S.String),\n prompts: S.optional(S.mutable(S.Array(ref(ChainPromptType)))),\n}) {}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport type {\n GraphBuilderProvides,\n IntentResolverProvides,\n MetadataRecordsProvides,\n SurfaceProvides,\n TranslationsProvides,\n} from '@dxos/app-framework';\nimport { type SchemaProvides } from '@dxos/plugin-client';\nimport { type PanelProvides } from '@dxos/plugin-deck/types';\n\
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["ref", "S", "TypedObject", "ChainInputType", "ChainInputSchema", "S", "mutable", "Struct", "name", "String", "type", "optional", "Enums", "value", "ChainPromptType", "TypedObject", "typename", "version", "command", "template", "inputs", "Array", "ChainType", "prompts", "ref", "AutomationAction"]
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { ref, S, TypedObject } from '@dxos/echo-schema';\n\n// TODO(burdon): Change to S.Literal (and discriminated union).\nexport enum ChainInputType {\n VALUE = 0,\n PASS_THROUGH = 1,\n RETRIEVER = 2,\n FUNCTION = 3,\n QUERY = 4,\n RESOLVER = 5,\n CONTEXT = 6,\n SCHEMA = 7,\n}\n\nexport const ChainInputSchema = S.mutable(\n S.Struct({\n name: S.String,\n type: S.optional(S.Enums(ChainInputType)),\n value: S.optional(S.String),\n }),\n);\n\nexport type ChainInput = S.Schema.Type<typeof ChainInputSchema>;\n\nexport class ChainPromptType extends TypedObject({ typename: 'dxos.org/type/ChainPrompt', version: '0.1.0' })({\n command: S.optional(S.String),\n template: S.String,\n inputs: S.optional(S.mutable(S.Array(ChainInputSchema))),\n}) {}\n\nexport class ChainType extends TypedObject({ typename: 'dxos.org/type/Chain', version: '0.1.0' })({\n name: S.optional(S.String),\n prompts: S.optional(S.mutable(S.Array(ref(ChainPromptType)))),\n}) {}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport type {\n GraphBuilderProvides,\n IntentResolverProvides,\n MetadataRecordsProvides,\n SurfaceProvides,\n TranslationsProvides,\n} from '@dxos/app-framework';\nimport { type SchemaProvides } from '@dxos/plugin-client';\nimport { type PanelProvides } from '@dxos/plugin-deck/types';\n\nimport { AUTOMATION_PLUGIN } from '../meta';\n\nconst AUTOMATION_ACTION = `${AUTOMATION_PLUGIN}/action`;\n\nexport enum AutomationAction {\n CREATE = `${AUTOMATION_ACTION}/create`,\n}\n\nexport type AutomationPluginProvides = SurfaceProvides &\n IntentResolverProvides &\n MetadataRecordsProvides &\n TranslationsProvides &\n GraphBuilderProvides &\n SchemaProvides &\n PanelProvides;\n"],
|
|
5
|
+
"mappings": ";;;;;AAIA,SAASA,KAAKC,GAAGC,mBAAmB;;UAGxBC,iBAAAA;;;;;;;;;GAAAA,mBAAAA,iBAAAA,CAAAA,EAAAA;AAWL,IAAMC,mBAAmBC,EAAEC,QAChCD,EAAEE,OAAO;EACPC,MAAMH,EAAEI;EACRC,MAAML,EAAEM,SAASN,EAAEO,MAAMT,cAAAA,CAAAA;EACzBU,OAAOR,EAAEM,SAASN,EAAEI,MAAM;AAC5B,CAAA,CAAA;AAKK,IAAMK,kBAAN,cAA8BC,YAAY;EAAEC,UAAU;EAA6BC,SAAS;AAAQ,CAAA,EAAG;EAC5GC,SAASb,EAAEM,SAASN,EAAEI,MAAM;EAC5BU,UAAUd,EAAEI;EACZW,QAAQf,EAAEM,SAASN,EAAEC,QAAQD,EAAEgB,MAAMjB,gBAAAA,CAAAA,CAAAA;AACvC,CAAA,EAAA;AAAI;AAEG,IAAMkB,YAAN,cAAwBP,YAAY;EAAEC,UAAU;EAAuBC,SAAS;AAAQ,CAAA,EAAG;EAChGT,MAAMH,EAAEM,SAASN,EAAEI,MAAM;EACzBc,SAASlB,EAAEM,SAASN,EAAEC,QAAQD,EAAEgB,MAAMG,IAAIV,eAAAA,CAAAA,CAAAA,CAAAA;AAC5C,CAAA,EAAA;AAAI;;;ACrBJ,IAAMW,oBAAoB,GAAGC,iBAAAA;;UAEjBC,mBAAAA;kDACD,GAAGF,iBAAAA,SAA0B,IAAA;GAD5BE,qBAAAA,mBAAAA,CAAAA,EAAAA;",
|
|
6
|
+
"names": ["ref", "S", "TypedObject", "ChainInputType", "ChainInputSchema", "S", "mutable", "Struct", "name", "String", "type", "optional", "Enums", "value", "ChainPromptType", "TypedObject", "typename", "version", "command", "template", "inputs", "Array", "ChainType", "prompts", "ref", "AUTOMATION_ACTION", "AUTOMATION_PLUGIN", "AutomationAction"]
|
|
7
7
|
}
|
|
@@ -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--flow-arrow--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-PQLGYMNY.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--flow-arrow--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,27 +4,276 @@ import {
|
|
|
4
4
|
ChainInputType,
|
|
5
5
|
ChainPromptType,
|
|
6
6
|
ChainType
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-B3Z4NQC2.mjs";
|
|
8
8
|
import {
|
|
9
9
|
AUTOMATION_PLUGIN,
|
|
10
10
|
meta_default
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-PQLGYMNY.mjs";
|
|
12
12
|
|
|
13
13
|
// packages/plugins/experimental/plugin-automation/src/AutomationPlugin.tsx
|
|
14
|
-
import
|
|
14
|
+
import React4 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
|
-
|
|
20
|
+
import { getTypename, loadObjectReferences, parseId } from "@dxos/react-client/echo";
|
|
21
|
+
|
|
22
|
+
// packages/plugins/experimental/plugin-automation/src/components/AutomationPanel.tsx
|
|
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
|
+
};
|
|
23
244
|
|
|
24
|
-
// packages/plugins/experimental/plugin-automation/src/components/
|
|
25
|
-
import
|
|
26
|
-
|
|
27
|
-
|
|
245
|
+
// packages/plugins/experimental/plugin-automation/src/components/TriggerEditor/TriggerEditor.tsx
|
|
246
|
+
import React3 from "react";
|
|
247
|
+
import { FunctionTriggerSchema, TriggerKind } from "@dxos/functions";
|
|
248
|
+
import { FunctionType } from "@dxos/plugin-script/types";
|
|
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
|
+
};
|
|
28
277
|
|
|
29
278
|
// packages/plugins/experimental/plugin-automation/src/translations.ts
|
|
30
279
|
var translations_default = [
|
|
@@ -53,9 +302,7 @@ var translations_default = [
|
|
|
53
302
|
"trigger filter": "Filter",
|
|
54
303
|
"trigger cron": "Cron",
|
|
55
304
|
"trigger method": "Method",
|
|
56
|
-
"trigger endpoint": "Endpoint"
|
|
57
|
-
"open assistant panel label": "Show Assistant",
|
|
58
|
-
"assistant panel label": "Assistant"
|
|
305
|
+
"trigger endpoint": "Endpoint"
|
|
59
306
|
}
|
|
60
307
|
}
|
|
61
308
|
}
|
|
@@ -82,10 +329,7 @@ var AutomationPlugin = () => {
|
|
|
82
329
|
}
|
|
83
330
|
}
|
|
84
331
|
},
|
|
85
|
-
translations:
|
|
86
|
-
...translations_default,
|
|
87
|
-
...formTranslations
|
|
88
|
-
],
|
|
332
|
+
translations: translations_default,
|
|
89
333
|
echo: {
|
|
90
334
|
schema: [
|
|
91
335
|
ChainType,
|
|
@@ -103,17 +347,7 @@ var AutomationPlugin = () => {
|
|
|
103
347
|
ns: AUTOMATION_PLUGIN
|
|
104
348
|
}
|
|
105
349
|
],
|
|
106
|
-
icon: "ph--
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
id: "assistant",
|
|
110
|
-
label: [
|
|
111
|
-
"open assistant panel label",
|
|
112
|
-
{
|
|
113
|
-
ns: AUTOMATION_PLUGIN
|
|
114
|
-
}
|
|
115
|
-
],
|
|
116
|
-
icon: "ph--atom--regular"
|
|
350
|
+
icon: "ph--flow-arrow--regular"
|
|
117
351
|
}
|
|
118
352
|
]
|
|
119
353
|
},
|
|
@@ -125,7 +359,7 @@ var AutomationPlugin = () => {
|
|
|
125
359
|
const client = clientPlugin?.provides.client;
|
|
126
360
|
invariant(resolve, void 0, {
|
|
127
361
|
F: __dxlog_file,
|
|
128
|
-
L:
|
|
362
|
+
L: 52,
|
|
129
363
|
S: void 0,
|
|
130
364
|
A: [
|
|
131
365
|
"resolve",
|
|
@@ -134,7 +368,7 @@ var AutomationPlugin = () => {
|
|
|
134
368
|
});
|
|
135
369
|
invariant(client, void 0, {
|
|
136
370
|
F: __dxlog_file,
|
|
137
|
-
L:
|
|
371
|
+
L: 53,
|
|
138
372
|
S: void 0,
|
|
139
373
|
A: [
|
|
140
374
|
"client",
|
|
@@ -150,11 +384,10 @@ var AutomationPlugin = () => {
|
|
|
150
384
|
return;
|
|
151
385
|
}
|
|
152
386
|
const type = "orphan-settings-for-subject";
|
|
153
|
-
const icon = "ph--
|
|
387
|
+
const icon = "ph--flow-arrow--regular";
|
|
154
388
|
const [subjectId] = id.split("~");
|
|
155
389
|
const { spaceId, objectId } = parseId(subjectId);
|
|
156
|
-
const
|
|
157
|
-
const space = spaces?.find((space2) => space2.id === spaceId && space2.state.get() === SpaceState.SPACE_READY);
|
|
390
|
+
const space = client.spaces.get().find((space2) => space2.id === spaceId);
|
|
158
391
|
if (!objectId) {
|
|
159
392
|
const label2 = space ? space.properties.name || [
|
|
160
393
|
"unnamed space label",
|
|
@@ -180,9 +413,15 @@ var AutomationPlugin = () => {
|
|
|
180
413
|
}
|
|
181
414
|
};
|
|
182
415
|
}
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
416
|
+
const object = toSignal((onChange) => {
|
|
417
|
+
const timeout = setTimeout(async () => {
|
|
418
|
+
await space?.db.query({
|
|
419
|
+
id: objectId
|
|
420
|
+
}).first();
|
|
421
|
+
onChange();
|
|
422
|
+
});
|
|
423
|
+
return () => clearTimeout(timeout);
|
|
424
|
+
}, () => space?.db.getObjectById(objectId), subjectId);
|
|
186
425
|
if (!object || !subjectId) {
|
|
187
426
|
return;
|
|
188
427
|
}
|
|
@@ -204,54 +443,6 @@ var AutomationPlugin = () => {
|
|
|
204
443
|
}
|
|
205
444
|
};
|
|
206
445
|
}
|
|
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
|
-
}
|
|
255
446
|
})
|
|
256
447
|
];
|
|
257
448
|
}
|
|
@@ -259,36 +450,21 @@ var AutomationPlugin = () => {
|
|
|
259
450
|
surface: {
|
|
260
451
|
component: ({ data, role }) => {
|
|
261
452
|
switch (role) {
|
|
262
|
-
case
|
|
263
|
-
|
|
264
|
-
|
|
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
|
-
}
|
|
453
|
+
// case 'article':
|
|
454
|
+
// return data.object instanceof ChainType ? <ChainArticle chain={data.object} /> : null;
|
|
455
|
+
case "complementary--automation":
|
|
456
|
+
return /* @__PURE__ */ React4.createElement(AutomationPanel, null);
|
|
286
457
|
}
|
|
287
458
|
return null;
|
|
288
459
|
}
|
|
289
460
|
},
|
|
290
461
|
intent: {
|
|
291
462
|
resolver: (intent) => {
|
|
463
|
+
switch (intent.action) {
|
|
464
|
+
case AutomationAction.CREATE: {
|
|
465
|
+
return {};
|
|
466
|
+
}
|
|
467
|
+
}
|
|
292
468
|
}
|
|
293
469
|
}
|
|
294
470
|
}
|
|
@@ -516,7 +692,6 @@ var chainPresets = [
|
|
|
516
692
|
// packages/plugins/experimental/plugin-automation/src/index.ts
|
|
517
693
|
var src_default = AutomationPlugin;
|
|
518
694
|
export {
|
|
519
|
-
AssistantPanel,
|
|
520
695
|
AutomationAction,
|
|
521
696
|
AutomationPanel,
|
|
522
697
|
AutomationPlugin,
|
|
@@ -524,6 +699,8 @@ export {
|
|
|
524
699
|
ChainInputType,
|
|
525
700
|
ChainPromptType,
|
|
526
701
|
ChainType,
|
|
702
|
+
PromptEditor,
|
|
703
|
+
TriggerEditor,
|
|
527
704
|
chainPresets,
|
|
528
705
|
src_default as default,
|
|
529
706
|
str
|