@dxos/plugin-automation 0.7.1 → 0.7.2-main.f1adc9f

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.
Files changed (116) hide show
  1. package/dist/lib/browser/AssistantPanel-622FK3DP.mjs +341 -0
  2. package/dist/lib/browser/AssistantPanel-622FK3DP.mjs.map +7 -0
  3. package/dist/lib/browser/AutomationPanel-PVI2EJNE.mjs +125 -0
  4. package/dist/lib/browser/AutomationPanel-PVI2EJNE.mjs.map +7 -0
  5. package/dist/lib/browser/{chunk-B3Z4NQC2.mjs → chunk-R6GS7UA7.mjs} +2 -8
  6. package/dist/lib/browser/{chunk-B3Z4NQC2.mjs.map → chunk-R6GS7UA7.mjs.map} +3 -3
  7. package/dist/lib/browser/{chunk-PQLGYMNY.mjs → chunk-X5KMOH3I.mjs} +2 -2
  8. package/dist/lib/browser/{chunk-PQLGYMNY.mjs.map → chunk-X5KMOH3I.mjs.map} +1 -1
  9. package/dist/lib/browser/index.mjs +277 -1011
  10. package/dist/lib/browser/index.mjs.map +4 -4
  11. package/dist/lib/browser/meta.json +1 -1
  12. package/dist/lib/browser/meta.mjs +1 -1
  13. package/dist/lib/browser/types/index.mjs +1 -2
  14. package/dist/lib/node/AssistantPanel-HRJRVOZD.cjs +361 -0
  15. package/dist/lib/node/AssistantPanel-HRJRVOZD.cjs.map +7 -0
  16. package/dist/lib/node/AutomationPanel-Z2XW24BN.cjs +145 -0
  17. package/dist/lib/node/AutomationPanel-Z2XW24BN.cjs.map +7 -0
  18. package/dist/lib/node/{chunk-JSZ6PAYL.cjs → chunk-DTJ7XVO2.cjs} +5 -5
  19. package/dist/lib/node/{chunk-JSZ6PAYL.cjs.map → chunk-DTJ7XVO2.cjs.map} +1 -1
  20. package/dist/lib/node/{chunk-SUMUWFZA.cjs → chunk-JHKEVE65.cjs} +5 -8
  21. package/dist/lib/node/{chunk-SUMUWFZA.cjs.map → chunk-JHKEVE65.cjs.map} +3 -3
  22. package/dist/lib/node/index.cjs +298 -1008
  23. package/dist/lib/node/index.cjs.map +4 -4
  24. package/dist/lib/node/meta.cjs +3 -3
  25. package/dist/lib/node/meta.cjs.map +1 -1
  26. package/dist/lib/node/meta.json +1 -1
  27. package/dist/lib/node/types/index.cjs +6 -7
  28. package/dist/lib/node/types/index.cjs.map +2 -2
  29. package/dist/lib/node-esm/AssistantPanel-QIIX7S4V.mjs +342 -0
  30. package/dist/lib/node-esm/AssistantPanel-QIIX7S4V.mjs.map +7 -0
  31. package/dist/lib/node-esm/AutomationPanel-5L5NFVKU.mjs +126 -0
  32. package/dist/lib/node-esm/AutomationPanel-5L5NFVKU.mjs.map +7 -0
  33. package/dist/lib/node-esm/{chunk-B35UD3D7.mjs → chunk-HNOBZHWK.mjs} +2 -2
  34. package/dist/lib/node-esm/{chunk-B35UD3D7.mjs.map → chunk-HNOBZHWK.mjs.map} +1 -1
  35. package/dist/lib/node-esm/{chunk-PYT2WY4B.mjs → chunk-ISJZVA2J.mjs} +2 -7
  36. package/dist/lib/node-esm/{chunk-PYT2WY4B.mjs.map → chunk-ISJZVA2J.mjs.map} +3 -3
  37. package/dist/lib/node-esm/index.mjs +277 -1011
  38. package/dist/lib/node-esm/index.mjs.map +4 -4
  39. package/dist/lib/node-esm/meta.json +1 -1
  40. package/dist/lib/node-esm/meta.mjs +1 -1
  41. package/dist/lib/node-esm/types/index.mjs +1 -2
  42. package/dist/types/src/AutomationPlugin.d.ts.map +1 -1
  43. package/dist/types/src/components/AssistantPanel/AssistantPanel.d.ts +8 -0
  44. package/dist/types/src/components/AssistantPanel/AssistantPanel.d.ts.map +1 -0
  45. package/dist/types/src/components/AssistantPanel/index.d.ts +3 -0
  46. package/dist/types/src/components/AssistantPanel/index.d.ts.map +1 -0
  47. package/dist/types/src/components/AssistantPanel/system-instructions.d.ts +6 -0
  48. package/dist/types/src/components/AssistantPanel/system-instructions.d.ts.map +1 -0
  49. package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts +9 -0
  50. package/dist/types/src/components/AutomationPanel/AutomationPanel.d.ts.map +1 -0
  51. package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts +6 -0
  52. package/dist/types/src/components/AutomationPanel/AutomationPanel.stories.d.ts.map +1 -0
  53. package/dist/types/src/components/AutomationPanel/index.d.ts +3 -0
  54. package/dist/types/src/components/AutomationPanel/index.d.ts.map +1 -0
  55. package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +5 -3
  56. package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -1
  57. package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts +1 -1
  58. package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -1
  59. package/dist/types/src/components/index.d.ts +2 -5
  60. package/dist/types/src/components/index.d.ts.map +1 -1
  61. package/dist/types/src/hooks/invocation-handler.d.ts.map +1 -1
  62. package/dist/types/src/hooks/useLocalTriggerManager.d.ts.map +1 -1
  63. package/dist/types/src/testing/index.d.ts +2 -0
  64. package/dist/types/src/testing/index.d.ts.map +1 -0
  65. package/dist/types/src/testing/testing.d.ts +12 -0
  66. package/dist/types/src/testing/testing.d.ts.map +1 -0
  67. package/dist/types/src/translations.d.ts +3 -1
  68. package/dist/types/src/translations.d.ts.map +1 -1
  69. package/dist/types/src/types/schema.d.ts +3 -3
  70. package/dist/types/src/types/types.d.ts +0 -1
  71. package/dist/types/src/types/types.d.ts.map +1 -1
  72. package/package.json +37 -34
  73. package/src/AutomationPlugin.tsx +90 -37
  74. package/src/components/AssistantPanel/AssistantPanel.tsx +230 -0
  75. package/src/components/AssistantPanel/index.ts +7 -0
  76. package/src/components/AssistantPanel/system-instructions.ts +166 -0
  77. package/src/components/AutomationPanel/AutomationPanel.stories.tsx +57 -0
  78. package/src/components/AutomationPanel/AutomationPanel.tsx +96 -0
  79. package/src/components/AutomationPanel/index.ts +7 -0
  80. package/src/components/TriggerEditor/TriggerEditor.stories.tsx +15 -27
  81. package/src/components/TriggerEditor/TriggerEditor.tsx +39 -324
  82. package/src/components/index.ts +2 -6
  83. package/src/hooks/invocation-handler.ts +6 -9
  84. package/src/hooks/useLocalTriggerManager.ts +2 -4
  85. package/src/meta.ts +1 -1
  86. package/src/testing/index.ts +5 -0
  87. package/src/testing/testing.ts +34 -0
  88. package/src/translations.ts +4 -1
  89. package/src/types/types.ts +3 -5
  90. package/dist/lib/browser/PromptContainer-6CBNCUKQ.mjs +0 -19
  91. package/dist/lib/browser/PromptContainer-6CBNCUKQ.mjs.map +0 -7
  92. package/dist/lib/browser/chunk-CJMV64XO.mjs +0 -217
  93. package/dist/lib/browser/chunk-CJMV64XO.mjs.map +0 -7
  94. package/dist/lib/node/PromptContainer-7RCGCU3K.cjs +0 -45
  95. package/dist/lib/node/PromptContainer-7RCGCU3K.cjs.map +0 -7
  96. package/dist/lib/node/chunk-YGRHTCOX.cjs +0 -240
  97. package/dist/lib/node/chunk-YGRHTCOX.cjs.map +0 -7
  98. package/dist/lib/node-esm/PromptContainer-4SCHQV5C.mjs +0 -20
  99. package/dist/lib/node-esm/PromptContainer-4SCHQV5C.mjs.map +0 -7
  100. package/dist/lib/node-esm/chunk-62AB5HXX.mjs +0 -218
  101. package/dist/lib/node-esm/chunk-62AB5HXX.mjs.map +0 -7
  102. package/dist/types/src/components/AutomationPanel.d.ts +0 -3
  103. package/dist/types/src/components/AutomationPanel.d.ts.map +0 -1
  104. package/dist/types/src/components/Chain.d.ts +0 -12
  105. package/dist/types/src/components/Chain.d.ts.map +0 -1
  106. package/dist/types/src/components/PromptContainer.d.ts +0 -6
  107. package/dist/types/src/components/PromptContainer.d.ts.map +0 -1
  108. package/dist/types/src/components/TriggerEditor/Form.d.ts +0 -5
  109. package/dist/types/src/components/TriggerEditor/Form.d.ts.map +0 -1
  110. package/dist/types/src/components/TriggerEditor/meta.d.ts +0 -25
  111. package/dist/types/src/components/TriggerEditor/meta.d.ts.map +0 -1
  112. package/src/components/AutomationPanel.tsx +0 -23
  113. package/src/components/Chain.tsx +0 -66
  114. package/src/components/PromptContainer.tsx +0 -19
  115. package/src/components/TriggerEditor/Form.tsx +0 -18
  116. package/src/components/TriggerEditor/meta.tsx +0 -226
@@ -1,218 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
- import {
3
- ChainInputType
4
- } from "./chunk-PYT2WY4B.mjs";
5
- import {
6
- AUTOMATION_PLUGIN
7
- } from "./chunk-B35UD3D7.mjs";
8
-
9
- // packages/plugins/experimental/plugin-automation/src/components/PromptEditor/PromptEditor.tsx
10
- import React, { useEffect } from "react";
11
- import { createDocAccessor } from "@dxos/react-client/echo";
12
- import { Input, Select, useThemeContext, useTranslation } from "@dxos/react-ui";
13
- import { createBasicExtensions, createDataExtensions, createThemeExtensions, useTextEditor } from "@dxos/react-ui-editor";
14
- import { attentionSurface, groupBorder, mx as mx2 } from "@dxos/react-ui-theme";
15
- import { nonNullable } from "@dxos/util";
16
-
17
- // packages/plugins/experimental/plugin-automation/src/components/PromptEditor/prompt-extension.ts
18
- import { HighlightStyle, StreamLanguage, syntaxHighlighting } from "@codemirror/language";
19
- import { tags } from "@dxos/react-ui-editor";
20
- import { mx } from "@dxos/react-ui-theme";
21
- var nameRegex = /\{([\w-]+)}/;
22
- var parser = StreamLanguage.define({
23
- token: (stream) => {
24
- if (stream.eatSpace()) {
25
- return null;
26
- }
27
- if (stream.match(/^#.*/)) {
28
- return "lineComment";
29
- }
30
- if (stream.match(/^-+$/)) {
31
- return "lineComment";
32
- }
33
- if (stream.match(nameRegex)) {
34
- return "variableName";
35
- }
36
- stream.next();
37
- return null;
38
- }
39
- });
40
- var highlightStyles = HighlightStyle.define([
41
- {
42
- tag: tags.variableName,
43
- class: mx("rounded border border-yellow-500 bg-yellow-100 text-black font-mono text-sm")
44
- }
45
- ]);
46
- var promptExtension = [
47
- parser,
48
- syntaxHighlighting(highlightStyles)
49
- ];
50
-
51
- // packages/plugins/experimental/plugin-automation/src/components/PromptEditor/PromptEditor.tsx
52
- var inputTypes = [
53
- {
54
- value: ChainInputType.VALUE,
55
- label: "Value"
56
- },
57
- {
58
- value: ChainInputType.PASS_THROUGH,
59
- label: "Pass through"
60
- },
61
- {
62
- value: ChainInputType.RETRIEVER,
63
- label: "Retriever"
64
- },
65
- // {
66
- // value: ChainInputType.FUNCTION,
67
- // label: 'Function',
68
- // },
69
- // {
70
- // value: ChainInputType.QUERY,
71
- // label: 'Query',
72
- // },
73
- {
74
- value: ChainInputType.RESOLVER,
75
- label: "Resolver"
76
- },
77
- {
78
- value: ChainInputType.CONTEXT,
79
- label: "Context"
80
- },
81
- {
82
- value: ChainInputType.SCHEMA,
83
- label: "Schema"
84
- }
85
- ];
86
- var getInputType = (type) => inputTypes.find(({ value }) => String(value) === type)?.value;
87
- var usePromptInputs = (prompt) => {
88
- useEffect(() => {
89
- const text = prompt.template ?? "";
90
- if (!prompt.inputs) {
91
- prompt.inputs = [];
92
- }
93
- const regex = new RegExp(nameRegex, "g");
94
- const variables = new Set([
95
- ...text.matchAll(regex)
96
- ].map((m) => m[1]));
97
- const unclaimed = new Map(prompt.inputs?.filter(nonNullable).map((input) => [
98
- input.name,
99
- input
100
- ]));
101
- const missing = [];
102
- Array.from(variables.values()).forEach((name) => {
103
- if (unclaimed.has(name)) {
104
- unclaimed.delete(name);
105
- } else {
106
- missing.push(name);
107
- }
108
- });
109
- const values = unclaimed.values();
110
- missing.forEach((name) => {
111
- const next = values.next().value;
112
- if (next) {
113
- next.name = name;
114
- } else {
115
- prompt.inputs?.push({
116
- name
117
- });
118
- }
119
- });
120
- for (const input of values) {
121
- prompt.inputs.splice(prompt.inputs.indexOf(input), 1);
122
- }
123
- }, [
124
- prompt.template
125
- ]);
126
- };
127
- var PromptEditor = ({ prompt, commandEditable = true }) => {
128
- const { t } = useTranslation(AUTOMATION_PLUGIN);
129
- const { themeMode } = useThemeContext();
130
- const { parentRef } = useTextEditor(() => ({
131
- initialValue: prompt.template,
132
- extensions: [
133
- createDataExtensions({
134
- id: prompt.id,
135
- text: prompt.template !== void 0 ? createDocAccessor(prompt, [
136
- "template"
137
- ]) : void 0
138
- }),
139
- createBasicExtensions({
140
- bracketMatching: false,
141
- lineWrapping: true,
142
- placeholder: t("template placeholder")
143
- }),
144
- createThemeExtensions({
145
- themeMode,
146
- slots: {
147
- content: {
148
- className: "!p-3"
149
- }
150
- }
151
- }),
152
- promptExtension
153
- ]
154
- }), [
155
- themeMode,
156
- prompt
157
- ]);
158
- usePromptInputs(prompt);
159
- return /* @__PURE__ */ React.createElement("div", {
160
- className: mx2("flex flex-col w-full overflow-hidden gap-4", groupBorder)
161
- }, commandEditable && /* @__PURE__ */ React.createElement("div", {
162
- className: "flex items-center pl-4"
163
- }, /* @__PURE__ */ React.createElement("span", {
164
- className: "text-neutral-500"
165
- }, "/"), /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement(Input.TextInput, {
166
- placeholder: t("command placeholder"),
167
- classNames: mx2("is-full bg-transparent m-2"),
168
- value: prompt.command ?? "",
169
- onChange: (event) => {
170
- prompt.command = event.target.value.replace(/\w/g, "");
171
- }
172
- }))), /* @__PURE__ */ React.createElement("div", {
173
- ref: parentRef,
174
- className: mx2(attentionSurface, "rounded", "min-h-[120px]")
175
- }), (prompt.inputs?.length ?? 0) > 0 && /* @__PURE__ */ React.createElement("div", {
176
- className: "flex flex-col"
177
- }, /* @__PURE__ */ React.createElement("table", {
178
- className: "w-full table-fixed border-collapse my-2"
179
- }, /* @__PURE__ */ React.createElement("tbody", null, prompt.inputs?.filter(nonNullable).map((input) => /* @__PURE__ */ React.createElement("tr", {
180
- key: input.name
181
- }, /* @__PURE__ */ React.createElement("td", {
182
- className: "w-[160px] p-1 font-mono text-sm whitespace-nowrap truncate"
183
- }, /* @__PURE__ */ React.createElement("code", {
184
- className: "px-2"
185
- }, input.name)), /* @__PURE__ */ React.createElement("td", {
186
- className: "w-[120px] p-1"
187
- }, /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement(Select.Root, {
188
- value: String(input.type),
189
- onValueChange: (type) => {
190
- input.type = getInputType(type) ?? ChainInputType.VALUE;
191
- }
192
- }, /* @__PURE__ */ React.createElement(Select.TriggerButton, {
193
- placeholder: "Type",
194
- classNames: "is-full"
195
- }), /* @__PURE__ */ React.createElement(Select.Portal, null, /* @__PURE__ */ React.createElement(Select.Content, null, /* @__PURE__ */ React.createElement(Select.Viewport, null, inputTypes.map(({ value, label }) => /* @__PURE__ */ React.createElement(Select.Option, {
196
- key: value,
197
- value: String(value)
198
- }, label)))))))), /* @__PURE__ */ React.createElement("td", {
199
- className: "p-1 pr-2"
200
- }, input.type !== void 0 && [
201
- ChainInputType.VALUE,
202
- ChainInputType.CONTEXT,
203
- ChainInputType.RESOLVER,
204
- ChainInputType.SCHEMA
205
- ].includes(input.type) && /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(Input.Root, null, /* @__PURE__ */ React.createElement(Input.TextInput, {
206
- placeholder: t("command placeholder"),
207
- classNames: mx2("is-full bg-transparent"),
208
- value: input.value ?? "",
209
- onChange: (event) => {
210
- input.value = event.target.value;
211
- }
212
- }))))))))));
213
- };
214
-
215
- export {
216
- PromptEditor
217
- };
218
- //# sourceMappingURL=chunk-62AB5HXX.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/components/PromptEditor/PromptEditor.tsx", "../../../src/components/PromptEditor/prompt-extension.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Schema as S } from '@effect/schema';\nimport React, { useEffect } from 'react';\n\nimport { createDocAccessor } from '@dxos/react-client/echo';\nimport { Input, Select, useThemeContext, useTranslation } from '@dxos/react-ui';\nimport {\n createBasicExtensions,\n createDataExtensions,\n createThemeExtensions,\n useTextEditor,\n} from '@dxos/react-ui-editor';\nimport { attentionSurface, groupBorder, mx } from '@dxos/react-ui-theme';\nimport { nonNullable } from '@dxos/util';\n\nimport { nameRegex, promptExtension } from './prompt-extension';\nimport { AUTOMATION_PLUGIN } from '../../meta';\nimport { type ChainInput, ChainInputType, type ChainPromptType } from '../../types';\n\nconst inputTypes = [\n {\n value: ChainInputType.VALUE,\n label: 'Value',\n },\n {\n value: ChainInputType.PASS_THROUGH,\n label: 'Pass through',\n },\n {\n value: ChainInputType.RETRIEVER,\n label: 'Retriever',\n },\n // {\n // value: ChainInputType.FUNCTION,\n // label: 'Function',\n // },\n // {\n // value: ChainInputType.QUERY,\n // label: 'Query',\n // },\n {\n value: ChainInputType.RESOLVER,\n label: 'Resolver',\n },\n {\n value: ChainInputType.CONTEXT,\n label: 'Context',\n },\n {\n value: ChainInputType.SCHEMA,\n label: 'Schema',\n },\n];\n\nconst getInputType = (type: string) => inputTypes.find(({ value }) => String(value) === type)?.value;\n\nconst usePromptInputs = (prompt: ChainPromptType) => {\n useEffect(() => {\n const text = prompt.template ?? '';\n if (!prompt.inputs) {\n prompt.inputs = []; // TODO(burdon): Required?\n }\n\n const regex = new RegExp(nameRegex, 'g');\n const variables = new Set<string>([...text.matchAll(regex)].map((m) => m[1]));\n\n // Create map of unclaimed inputs.\n const unclaimed = new Map<string, ChainInput>(\n prompt.inputs?.filter(nonNullable).map((input) => [input.name, input]),\n );\n const missing: string[] = [];\n Array.from(variables.values()).forEach((name) => {\n if (unclaimed.has(name)) {\n unclaimed.delete(name);\n } else {\n missing.push(name);\n }\n });\n\n // Match or create new inputs.\n const values = unclaimed.values();\n missing.forEach((name) => {\n const next = values.next().value;\n if (next) {\n next.name = name;\n } else {\n prompt.inputs?.push({ name });\n }\n });\n\n // Remove unclaimed (deleted) inputs.\n // TODO(burdon): If user types incorrect name value, it will be deleted. Garbage collect?\n for (const input of values) {\n prompt.inputs.splice(prompt.inputs.indexOf(input), 1);\n }\n }, [prompt.template]);\n};\n\nexport type PromptEditorProps = {\n prompt: ChainPromptType;\n commandEditable?: boolean;\n schema?: S.Schema<any, any, any>;\n};\n\nexport const PromptEditor = ({ prompt, commandEditable = true }: PromptEditorProps) => {\n const { t } = useTranslation(AUTOMATION_PLUGIN);\n const { themeMode } = useThemeContext();\n\n const { parentRef } = useTextEditor(\n () => ({\n initialValue: prompt.template,\n extensions: [\n createDataExtensions({\n id: prompt.id,\n text: prompt.template !== undefined ? createDocAccessor(prompt, ['template']) : undefined,\n }),\n createBasicExtensions({\n bracketMatching: false,\n lineWrapping: true,\n placeholder: t('template placeholder'),\n }),\n createThemeExtensions({\n themeMode,\n slots: {\n content: { className: '!p-3' },\n },\n }),\n promptExtension,\n ],\n }),\n [themeMode, prompt],\n );\n\n usePromptInputs(prompt);\n\n return (\n <div className={mx('flex flex-col w-full overflow-hidden gap-4', groupBorder)}>\n {commandEditable && (\n <div className='flex items-center pl-4'>\n <span className='text-neutral-500'>/</span>\n <Input.Root>\n <Input.TextInput\n placeholder={t('command placeholder')}\n classNames={mx('is-full bg-transparent m-2')}\n value={prompt.command ?? ''}\n onChange={(event) => {\n prompt.command = event.target.value.replace(/\\w/g, '');\n }}\n />\n </Input.Root>\n </div>\n )}\n\n <div ref={parentRef} className={mx(attentionSurface, 'rounded', 'min-h-[120px]')} />\n\n {(prompt.inputs?.length ?? 0) > 0 && (\n <div className='flex flex-col'>\n {/* TODO(zan): Improve layout with grid */}\n <table className='w-full table-fixed border-collapse my-2'>\n <tbody>\n {prompt.inputs?.filter(nonNullable).map((input) => (\n <tr key={input.name}>\n <td className='w-[160px] p-1 font-mono text-sm whitespace-nowrap truncate'>\n <code className='px-2'>{input.name}</code>\n </td>\n <td className='w-[120px] p-1'>\n <Input.Root>\n <Select.Root\n value={String(input.type)}\n onValueChange={(type) => {\n input.type = getInputType(type) ?? ChainInputType.VALUE;\n }}\n >\n <Select.TriggerButton placeholder='Type' classNames='is-full' />\n <Select.Portal>\n <Select.Content>\n <Select.Viewport>\n {inputTypes.map(({ value, label }) => (\n <Select.Option key={value} value={String(value)}>\n {label}\n </Select.Option>\n ))}\n </Select.Viewport>\n </Select.Content>\n </Select.Portal>\n </Select.Root>\n </Input.Root>\n </td>\n <td className='p-1 pr-2'>\n {input.type !== undefined &&\n [\n ChainInputType.VALUE,\n ChainInputType.CONTEXT,\n ChainInputType.RESOLVER,\n ChainInputType.SCHEMA,\n ].includes(input.type) && (\n <div>\n <Input.Root>\n <Input.TextInput\n placeholder={t('command placeholder')}\n classNames={mx('is-full bg-transparent')}\n value={input.value ?? ''}\n onChange={(event) => {\n input.value = event.target.value;\n }}\n />\n </Input.Root>\n </div>\n )}\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n )}\n </div>\n );\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { HighlightStyle, StreamLanguage, syntaxHighlighting } from '@codemirror/language';\nimport { type Extension } from '@codemirror/state';\n\nimport { tags } from '@dxos/react-ui-editor';\nimport { mx } from '@dxos/react-ui-theme';\n\nexport const nameRegex = /\\{([\\w-]+)}/;\n\nconst parser = StreamLanguage.define({\n token: (stream) => {\n if (stream.eatSpace()) {\n return null;\n }\n if (stream.match(/^#.*/)) {\n return 'lineComment';\n }\n if (stream.match(/^-+$/)) {\n return 'lineComment';\n }\n if (stream.match(nameRegex)) {\n return 'variableName';\n }\n stream.next();\n return null;\n },\n});\n\n/**\n * https://codemirror.net/examples/styling\n * https://lezer.codemirror.net/docs/ref/#highlight\n */\nconst highlightStyles = HighlightStyle.define([\n {\n tag: tags.variableName,\n class: mx('rounded border border-yellow-500 bg-yellow-100 text-black font-mono text-sm'),\n },\n]);\n\nexport const promptExtension: Extension = [parser, syntaxHighlighting(highlightStyles)];\n"],
5
- "mappings": ";;;;;;;;;AAKA,OAAOA,SAASC,iBAAiB;AAEjC,SAASC,yBAAyB;AAClC,SAASC,OAAOC,QAAQC,iBAAiBC,sBAAsB;AAC/D,SACEC,uBACAC,sBACAC,uBACAC,qBACK;AACP,SAASC,kBAAkBC,aAAaC,MAAAA,WAAU;AAClD,SAASC,mBAAmB;;;ACZ5B,SAASC,gBAAgBC,gBAAgBC,0BAA0B;AAGnE,SAASC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9B,aAAY;IAAOa,YAAW;MACpD,sBAAA,cAACe,OAAOG,QAAM,MACZ,sBAAA,cAACH,OAAOI,SAAO,MACb,sBAAA,cAACJ,OAAOK,UAAQ,MACbhG,WAAW0B,IAAI,CAAC,EAAEzB,OAAOG,MAAK,MAC7B,sBAAA,cAACuF,OAAOM,QAAM;IAACT,KAAKvF;IAAOA,OAAOY,OAAOZ,KAAAA;KACtCG,KAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,GASjB,sBAAA,cAACqF,MAAAA;IAAGtB,WAAU;KACXnC,MAAMrB,SAAS+C,UACd;IACExD,eAAeC;IACfD,eAAeM;IACfN,eAAeK;IACfL,eAAeO;IACfyF,SAASlE,MAAMrB,IAAI,KACnB,sBAAA,cAAC0D,OAAAA,MACC,sBAAA,cAACI,MAAMC,MAAI,MACT,sBAAA,cAACD,MAAME,WAAS;IACdZ,aAAahB,EAAE,qBAAA;IACf6B,YAAYN,IAAG,wBAAA;IACfrE,OAAO+B,MAAM/B,SAAS;IACtB6E,UAAU,CAACC,UAAAA;AACT/C,YAAM/B,QAAQ8E,MAAMC,OAAO/E;IAC7B;;AAc9B;",
6
- "names": ["React", "useEffect", "createDocAccessor", "Input", "Select", "useThemeContext", "useTranslation", "createBasicExtensions", "createDataExtensions", "createThemeExtensions", "useTextEditor", "attentionSurface", "groupBorder", "mx", "nonNullable", "HighlightStyle", "StreamLanguage", "syntaxHighlighting", "tags", "mx", "nameRegex", "parser", "StreamLanguage", "define", "token", "stream", "eatSpace", "match", "next", "highlightStyles", "HighlightStyle", "tag", "tags", "variableName", "class", "mx", "promptExtension", "syntaxHighlighting", "inputTypes", "value", "ChainInputType", "VALUE", "label", "PASS_THROUGH", "RETRIEVER", "RESOLVER", "CONTEXT", "SCHEMA", "getInputType", "type", "find", "String", "usePromptInputs", "prompt", "useEffect", "text", "template", "inputs", "regex", "RegExp", "nameRegex", "variables", "Set", "matchAll", "map", "m", "unclaimed", "Map", "filter", "nonNullable", "input", "name", "missing", "Array", "from", "values", "forEach", "has", "delete", "push", "next", "splice", "indexOf", "PromptEditor", "commandEditable", "t", "useTranslation", "AUTOMATION_PLUGIN", "themeMode", "useThemeContext", "parentRef", "useTextEditor", "initialValue", "extensions", "createDataExtensions", "id", "undefined", "createDocAccessor", "createBasicExtensions", "bracketMatching", "lineWrapping", "placeholder", "createThemeExtensions", "slots", "content", "className", "promptExtension", "div", "mx", "groupBorder", "span", "Input", "Root", "TextInput", "classNames", "command", "onChange", "event", "target", "replace", "ref", "attentionSurface", "length", "table", "tbody", "tr", "key", "td", "code", "Select", "onValueChange", "TriggerButton", "Portal", "Content", "Viewport", "Option", "includes"]
7
- }
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- export declare const AutomationPanel: () => React.JSX.Element;
3
- //# sourceMappingURL=AutomationPanel.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AutomationPanel.d.ts","sourceRoot":"","sources":["../../../../src/components/AutomationPanel.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,eAAO,MAAM,eAAe,yBAY3B,CAAC"}
@@ -1,12 +0,0 @@
1
- import React, { type FC } from 'react';
2
- import { type Preset } from '../presets';
3
- import { type ChainType } from '../types';
4
- export type ChainProps = {
5
- chain: ChainType;
6
- };
7
- export declare const Chain: ({ chain }: ChainProps) => React.JSX.Element | null;
8
- export declare const ChainPresets: FC<{
9
- presets: Preset[];
10
- onSelect: (preset: Preset) => void;
11
- }>;
12
- //# sourceMappingURL=Chain.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Chain.d.ts","sourceRoot":"","sources":["../../../../src/components/Chain.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAQvC,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE,SAAS,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,KAAK,cAAe,UAAU,6BAqB1C,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,CAuBtF,CAAC"}
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- import { type PromptEditorProps } from './PromptEditor';
3
- type PromptContainerProps = PromptEditorProps;
4
- declare const PromptContainer: (props: PromptContainerProps) => React.JSX.Element;
5
- export default PromptContainer;
6
- //# sourceMappingURL=PromptContainer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PromptContainer.d.ts","sourceRoot":"","sources":["../../../../src/components/PromptContainer.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAgB,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEtE,KAAK,oBAAoB,GAAG,iBAAiB,CAAC;AAE9C,QAAA,MAAM,eAAe,UAAW,oBAAoB,sBAMnD,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -1,5 +0,0 @@
1
- import React, { type PropsWithChildren } from 'react';
2
- export declare const InputRow: ({ label, children }: PropsWithChildren<{
3
- label?: string;
4
- }>) => React.JSX.Element;
5
- //# sourceMappingURL=Form.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../../../src/components/TriggerEditor/Form.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAItD,eAAO,MAAM,QAAQ,wBAAyB,iBAAiB,CAAC;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,sBASlF,CAAC"}
@@ -1,25 +0,0 @@
1
- import { type FC } from 'react';
2
- import { type FunctionTrigger } from '@dxos/functions/types';
3
- import { type ScriptType } from '@dxos/plugin-script';
4
- type TriggerId = string;
5
- export declare const state: import("@dxos/echo-schema").ReactiveObject<{
6
- schemas: any[];
7
- selectedSchema: Record<TriggerId, any>;
8
- }>;
9
- type MetaProps<T> = {
10
- meta: T;
11
- } & {
12
- triggerId?: string;
13
- };
14
- type MetaExtension<T> = {
15
- initialValue?: () => T;
16
- component: FC<MetaProps<T>>;
17
- };
18
- /**
19
- * Create meta type from function.
20
- * @param trigger - function trigger.
21
- * @param script - function script.
22
- */
23
- export declare const getFunctionMetaExtension: (trigger: FunctionTrigger, script?: ScriptType) => MetaExtension<any> | undefined;
24
- export {};
25
- //# sourceMappingURL=meta.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../../../src/components/TriggerEditor/meta.tsx"],"names":[],"mappings":"AAIA,OAAc,EAAE,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAI7D,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,qBAAqB,CAAC;AActD,KAAK,SAAS,GAAG,MAAM,CAAC;AAgBxB,eAAO,MAAM,KAAK;aALX,GAAG,EAAE;oBACY,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC;EAI4B,CAAC;AAO3E,KAAK,SAAS,CAAC,CAAC,IAAI;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzD,KAAK,aAAa,CAAC,CAAC,IAAI;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC,CAAC;IACvB,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;CAC7B,CAAC;AAIF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,YAC1B,eAAe,WACf,UAAU,KAClB,aAAa,CAAC,GAAG,CAAC,GAAG,SAWvB,CAAC"}
@@ -1,23 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import React from 'react';
6
-
7
- import { Button, Icon, Toolbar } from '@dxos/react-ui';
8
-
9
- // TODO(burdon): Form components.
10
-
11
- export const AutomationPanel = () => {
12
- const handleCreate = () => {};
13
-
14
- return (
15
- <div className='flex flex-col'>
16
- <Toolbar.Root classNames='p-2'>
17
- <Button onClick={handleCreate}>
18
- <Icon icon='ph--plus--regular' />
19
- </Button>
20
- </Toolbar.Root>
21
- </div>
22
- );
23
- };
@@ -1,66 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import React, { type FC } from 'react';
6
-
7
- import { getSpace } from '@dxos/react-client/echo';
8
- import { Select, useTranslation } from '@dxos/react-ui';
9
- import { nonNullable } from '@dxos/util';
10
-
11
- import { PromptEditor } from './PromptEditor';
12
- import { AUTOMATION_PLUGIN } from '../meta';
13
- import { chainPresets, type Preset } from '../presets';
14
- import { type ChainType } from '../types';
15
-
16
- export type ChainProps = {
17
- chain: ChainType;
18
- };
19
-
20
- export const Chain = ({ chain }: ChainProps) => {
21
- const space = getSpace(chain);
22
- if (!space) {
23
- return null;
24
- }
25
-
26
- const handleSelectPreset = (preset: Preset) => {
27
- chain.name = preset.title;
28
- // TODO(burdon): API issue.
29
- chain.prompts?.filter(nonNullable).forEach((prompt) => space.db.remove(prompt));
30
- chain.prompts = [preset.createPrompt()];
31
- };
32
-
33
- return (
34
- <div className='flex flex-col my-2 gap-4'>
35
- {chain.prompts?.filter(nonNullable).map((prompt, i) => <PromptEditor key={i} prompt={prompt} />)}
36
- <div className='p-2'>
37
- <ChainPresets presets={chainPresets} onSelect={handleSelectPreset} />
38
- </div>
39
- </div>
40
- );
41
- };
42
-
43
- export const ChainPresets: FC<{ presets: Preset[]; onSelect: (preset: Preset) => void }> = ({ presets, onSelect }) => {
44
- const { t } = useTranslation(AUTOMATION_PLUGIN);
45
-
46
- return (
47
- <Select.Root
48
- onValueChange={(value) => {
49
- onSelect(presets.find(({ id }) => id === value)!);
50
- }}
51
- >
52
- <Select.TriggerButton classNames='w-full' placeholder={t('select preset template placeholder')} />
53
- <Select.Portal>
54
- <Select.Content>
55
- <Select.Viewport>
56
- {presets.map(({ id, title }) => (
57
- <Select.Option key={id} value={id}>
58
- {title}
59
- </Select.Option>
60
- ))}
61
- </Select.Viewport>
62
- </Select.Content>
63
- </Select.Portal>
64
- </Select.Root>
65
- );
66
- };
@@ -1,19 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import React from 'react';
6
-
7
- import { PromptEditor, type PromptEditorProps } from './PromptEditor';
8
-
9
- type PromptContainerProps = PromptEditorProps;
10
-
11
- const PromptContainer = (props: PromptContainerProps) => {
12
- return (
13
- <div role='none' className='row-span-2 pli-2'>
14
- <PromptEditor {...props} />
15
- </div>
16
- );
17
- };
18
-
19
- export default PromptContainer;
@@ -1,18 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import React, { type PropsWithChildren } from 'react';
6
-
7
- import { Input } from '@dxos/react-ui';
8
-
9
- export const InputRow = ({ label, children }: PropsWithChildren<{ label?: string }>) => (
10
- <Input.Root>
11
- <tr>
12
- <td className='w-[80px] px-2 text-right align-top pt-3 overflow-hidden'>
13
- <Input.Label classNames='truncate text-xs'>{label}</Input.Label>
14
- </td>
15
- <td className='p-1 pr-2'>{children}</td>
16
- </tr>
17
- </Input.Root>
18
- );