@dxos/plugin-automation 0.6.14-main.1366248

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 (120) hide show
  1. package/LICENSE +8 -0
  2. package/README.md +15 -0
  3. package/dist/lib/browser/PromptContainer-3GUENQHE.mjs +19 -0
  4. package/dist/lib/browser/PromptContainer-3GUENQHE.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-2FOJUVYG.mjs +217 -0
  6. package/dist/lib/browser/chunk-2FOJUVYG.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-J4SYTP4Y.mjs +55 -0
  8. package/dist/lib/browser/chunk-J4SYTP4Y.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-PQLGYMNY.mjs +18 -0
  10. package/dist/lib/browser/chunk-PQLGYMNY.mjs.map +7 -0
  11. package/dist/lib/browser/index.mjs +1150 -0
  12. package/dist/lib/browser/index.mjs.map +7 -0
  13. package/dist/lib/browser/meta.json +1 -0
  14. package/dist/lib/browser/meta.mjs +9 -0
  15. package/dist/lib/browser/meta.mjs.map +7 -0
  16. package/dist/lib/browser/types/index.mjs +16 -0
  17. package/dist/lib/browser/types/index.mjs.map +7 -0
  18. package/dist/lib/node/PromptContainer-74ZRO4HK.cjs +45 -0
  19. package/dist/lib/node/PromptContainer-74ZRO4HK.cjs.map +7 -0
  20. package/dist/lib/node/chunk-4TMTUB4X.cjs +240 -0
  21. package/dist/lib/node/chunk-4TMTUB4X.cjs.map +7 -0
  22. package/dist/lib/node/chunk-JSZ6PAYL.cjs +41 -0
  23. package/dist/lib/node/chunk-JSZ6PAYL.cjs.map +7 -0
  24. package/dist/lib/node/chunk-XS53UP75.cjs +76 -0
  25. package/dist/lib/node/chunk-XS53UP75.cjs.map +7 -0
  26. package/dist/lib/node/index.cjs +1152 -0
  27. package/dist/lib/node/index.cjs.map +7 -0
  28. package/dist/lib/node/meta.cjs +30 -0
  29. package/dist/lib/node/meta.cjs.map +7 -0
  30. package/dist/lib/node/meta.json +1 -0
  31. package/dist/lib/node/types/index.cjs +38 -0
  32. package/dist/lib/node/types/index.cjs.map +7 -0
  33. package/dist/lib/node-esm/PromptContainer-5OK4GWIR.mjs +20 -0
  34. package/dist/lib/node-esm/PromptContainer-5OK4GWIR.mjs.map +7 -0
  35. package/dist/lib/node-esm/chunk-AAUSG7OA.mjs +56 -0
  36. package/dist/lib/node-esm/chunk-AAUSG7OA.mjs.map +7 -0
  37. package/dist/lib/node-esm/chunk-B35UD3D7.mjs +20 -0
  38. package/dist/lib/node-esm/chunk-B35UD3D7.mjs.map +7 -0
  39. package/dist/lib/node-esm/chunk-FN6DOJZP.mjs +218 -0
  40. package/dist/lib/node-esm/chunk-FN6DOJZP.mjs.map +7 -0
  41. package/dist/lib/node-esm/index.mjs +1151 -0
  42. package/dist/lib/node-esm/index.mjs.map +7 -0
  43. package/dist/lib/node-esm/meta.json +1 -0
  44. package/dist/lib/node-esm/meta.mjs +10 -0
  45. package/dist/lib/node-esm/meta.mjs.map +7 -0
  46. package/dist/lib/node-esm/types/index.mjs +17 -0
  47. package/dist/lib/node-esm/types/index.mjs.map +7 -0
  48. package/dist/types/src/AutomationPlugin.d.ts +4 -0
  49. package/dist/types/src/AutomationPlugin.d.ts.map +1 -0
  50. package/dist/types/src/components/AutomationPanel.d.ts +3 -0
  51. package/dist/types/src/components/AutomationPanel.d.ts.map +1 -0
  52. package/dist/types/src/components/Chain.d.ts +12 -0
  53. package/dist/types/src/components/Chain.d.ts.map +1 -0
  54. package/dist/types/src/components/PromptContainer.d.ts +6 -0
  55. package/dist/types/src/components/PromptContainer.d.ts.map +1 -0
  56. package/dist/types/src/components/PromptEditor/PromptEditor.d.ts +10 -0
  57. package/dist/types/src/components/PromptEditor/PromptEditor.d.ts.map +1 -0
  58. package/dist/types/src/components/PromptEditor/PromptEditor.stories.d.ts +6 -0
  59. package/dist/types/src/components/PromptEditor/PromptEditor.stories.d.ts.map +1 -0
  60. package/dist/types/src/components/PromptEditor/index.d.ts +2 -0
  61. package/dist/types/src/components/PromptEditor/index.d.ts.map +1 -0
  62. package/dist/types/src/components/PromptEditor/prompt-extension.d.ts +4 -0
  63. package/dist/types/src/components/PromptEditor/prompt-extension.d.ts.map +1 -0
  64. package/dist/types/src/components/PromptEditor/types.d.ts +18 -0
  65. package/dist/types/src/components/PromptEditor/types.d.ts.map +1 -0
  66. package/dist/types/src/components/TriggerEditor/Form.d.ts +5 -0
  67. package/dist/types/src/components/TriggerEditor/Form.d.ts.map +1 -0
  68. package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts +8 -0
  69. package/dist/types/src/components/TriggerEditor/TriggerEditor.d.ts.map +1 -0
  70. package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts +5 -0
  71. package/dist/types/src/components/TriggerEditor/TriggerEditor.stories.d.ts.map +1 -0
  72. package/dist/types/src/components/TriggerEditor/email.d.ts +4 -0
  73. package/dist/types/src/components/TriggerEditor/email.d.ts.map +1 -0
  74. package/dist/types/src/components/TriggerEditor/index.d.ts +2 -0
  75. package/dist/types/src/components/TriggerEditor/index.d.ts.map +1 -0
  76. package/dist/types/src/components/TriggerEditor/invokation-handler.d.ts +5 -0
  77. package/dist/types/src/components/TriggerEditor/invokation-handler.d.ts.map +1 -0
  78. package/dist/types/src/components/TriggerEditor/meta.d.ts +25 -0
  79. package/dist/types/src/components/TriggerEditor/meta.d.ts.map +1 -0
  80. package/dist/types/src/components/index.d.ts +6 -0
  81. package/dist/types/src/components/index.d.ts.map +1 -0
  82. package/dist/types/src/index.d.ts +7 -0
  83. package/dist/types/src/index.d.ts.map +1 -0
  84. package/dist/types/src/meta.d.ts +11 -0
  85. package/dist/types/src/meta.d.ts.map +1 -0
  86. package/dist/types/src/presets.d.ts +9 -0
  87. package/dist/types/src/presets.d.ts.map +1 -0
  88. package/dist/types/src/translations.d.ts +18 -0
  89. package/dist/types/src/translations.d.ts.map +1 -0
  90. package/dist/types/src/types/chain.d.ts +71 -0
  91. package/dist/types/src/types/chain.d.ts.map +1 -0
  92. package/dist/types/src/types/index.d.ts +3 -0
  93. package/dist/types/src/types/index.d.ts.map +1 -0
  94. package/dist/types/src/types/types.d.ts +8 -0
  95. package/dist/types/src/types/types.d.ts.map +1 -0
  96. package/package.json +99 -0
  97. package/src/AutomationPlugin.tsx +158 -0
  98. package/src/components/AutomationPanel.tsx +21 -0
  99. package/src/components/Chain.tsx +66 -0
  100. package/src/components/PromptContainer.tsx +19 -0
  101. package/src/components/PromptEditor/PromptEditor.stories.tsx +64 -0
  102. package/src/components/PromptEditor/PromptEditor.tsx +222 -0
  103. package/src/components/PromptEditor/index.ts +5 -0
  104. package/src/components/PromptEditor/prompt-extension.ts +43 -0
  105. package/src/components/PromptEditor/types.tsx +28 -0
  106. package/src/components/TriggerEditor/Form.tsx +18 -0
  107. package/src/components/TriggerEditor/TriggerEditor.stories.tsx +82 -0
  108. package/src/components/TriggerEditor/TriggerEditor.tsx +346 -0
  109. package/src/components/TriggerEditor/email.ts +49 -0
  110. package/src/components/TriggerEditor/index.ts +5 -0
  111. package/src/components/TriggerEditor/invokation-handler.ts +110 -0
  112. package/src/components/TriggerEditor/meta.tsx +225 -0
  113. package/src/components/index.ts +12 -0
  114. package/src/index.ts +12 -0
  115. package/src/meta.ts +16 -0
  116. package/src/presets.ts +248 -0
  117. package/src/translations.ts +31 -0
  118. package/src/types/chain.ts +38 -0
  119. package/src/types/index.ts +6 -0
  120. package/src/types/types.ts +29 -0
@@ -0,0 +1,225 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import React, { type FC } from 'react';
6
+
7
+ import { create, getMeta as getEchoMeta } from '@dxos/echo-schema';
8
+ import { type FunctionTrigger } from '@dxos/functions/types';
9
+ import { GameType } from '@dxos/plugin-chess/types';
10
+ import { FileType } from '@dxos/plugin-ipfs/types';
11
+ import { DocumentType } from '@dxos/plugin-markdown';
12
+ import { type ScriptType } from '@dxos/plugin-script';
13
+ import { DiagramType } from '@dxos/plugin-sketch/types';
14
+ import { CollectionType, MessageType } from '@dxos/plugin-space';
15
+ import { Input } from '@dxos/react-ui';
16
+ import { safeParseInt } from '@dxos/util';
17
+
18
+ import { InputRow } from './Form';
19
+ import { chainPresets } from '../../presets';
20
+ import { type ChainPromptType } from '../../types';
21
+ import { ChainPresets } from '../Chain';
22
+ import { PromptEditor } from '../PromptEditor';
23
+
24
+ // TODO(burdon): Factor out deps (remove from package.json). Provide via plugins.
25
+
26
+ type TriggerId = string;
27
+
28
+ const stateInitialValues = {
29
+ schemas: [
30
+ // TODO(burdon): Get all schema from API.
31
+ DocumentType,
32
+ FileType,
33
+ GameType,
34
+ MessageType,
35
+ DiagramType,
36
+ CollectionType,
37
+ ] as any[],
38
+ selectedSchema: {} as Record<TriggerId, any>,
39
+ };
40
+
41
+ // TODO(burdon): What is this for?
42
+ export const state = create<typeof stateInitialValues>(stateInitialValues);
43
+
44
+ //
45
+ // Trigger meta.
46
+ // TODO(burdon): Custom/generated UX to provide values to functions from types/other metadata.
47
+ //
48
+
49
+ type MetaProps<T> = { meta: T } & { triggerId?: string };
50
+
51
+ type MetaExtension<T> = {
52
+ initialValue?: () => T;
53
+ component: FC<MetaProps<T>>;
54
+ };
55
+
56
+ const USERFUNCTIONS_PRESET_META_KEY = 'dxos.org/service/function-preset';
57
+
58
+ /**
59
+ * Create meta type from function.
60
+ * @param trigger - function trigger.
61
+ * @param script - function script.
62
+ */
63
+ export const getFunctionMetaExtension = (
64
+ trigger: FunctionTrigger,
65
+ script?: ScriptType,
66
+ ): MetaExtension<any> | undefined => {
67
+ if (script) {
68
+ const meta = getEchoMeta(script).keys.find((key) => key.source === USERFUNCTIONS_PRESET_META_KEY);
69
+ const extension = meta && metaExtensions[meta.id];
70
+ if (extension) {
71
+ return extension;
72
+ }
73
+ }
74
+ // TODO: try to infer by spec type?
75
+ return trigger?.function ? metaExtensions[trigger.function] : metaExtensions['dxos.org/function/gpt'];
76
+ };
77
+
78
+ //
79
+ // Default (generic).
80
+ // TODO(burdon): Create property editor.
81
+ //
82
+
83
+ type DefaultMeta = {};
84
+
85
+ const DefaultMetaProps = ({ meta }: MetaProps<DefaultMeta>) => {
86
+ return <></>;
87
+ };
88
+
89
+ //
90
+ // Chess
91
+ //
92
+
93
+ type ChessMeta = { level?: number };
94
+
95
+ const ChessMetaProps = ({ meta }: MetaProps<ChessMeta>) => {
96
+ if (!meta) {
97
+ return null;
98
+ }
99
+
100
+ return (
101
+ <>
102
+ <InputRow label='Level'>
103
+ <Input.TextInput
104
+ type='number'
105
+ value={meta.level ?? 1}
106
+ onChange={(event) => (meta.level = safeParseInt(event.target.value))}
107
+ placeholder='Engine strength.'
108
+ />
109
+ </InputRow>
110
+ </>
111
+ );
112
+ };
113
+
114
+ //
115
+ // Email
116
+ //
117
+
118
+ type EmailWorkerMeta = { account?: string };
119
+
120
+ const EmailWorkerMetaProps = ({ meta }: MetaProps<EmailWorkerMeta>) => {
121
+ if (!meta) {
122
+ return null;
123
+ }
124
+
125
+ return (
126
+ <>
127
+ <InputRow label='Account'>
128
+ <Input.TextInput
129
+ value={meta.account ?? ''}
130
+ onChange={(event) => (meta.account = event.target.value)}
131
+ placeholder='https://'
132
+ />
133
+ </InputRow>
134
+ </>
135
+ );
136
+ };
137
+
138
+ //
139
+ // Chain
140
+ //
141
+
142
+ type ChainPromptMeta = { model?: string; prompt?: ChainPromptType };
143
+
144
+ const ChainPromptMetaProps = ({ meta, triggerId }: MetaProps<ChainPromptMeta>) => {
145
+ const schema = triggerId ? state.selectedSchema[triggerId] : undefined;
146
+ if (!meta) {
147
+ return null;
148
+ }
149
+
150
+ return (
151
+ <>
152
+ <InputRow label='Model'>
153
+ <Input.TextInput
154
+ value={meta.model ?? ''}
155
+ onChange={(event) => (meta.model = event.target.value)}
156
+ placeholder='llama2'
157
+ />
158
+ </InputRow>
159
+ <InputRow label='Presets'>
160
+ <ChainPresets
161
+ presets={chainPresets}
162
+ onSelect={(preset) => {
163
+ meta.prompt = preset.createPrompt();
164
+ }}
165
+ />
166
+ </InputRow>
167
+ {meta.prompt && (
168
+ <InputRow label='Prompt'>
169
+ <PromptEditor prompt={meta.prompt} schema={schema} />
170
+ </InputRow>
171
+ )}
172
+ </>
173
+ );
174
+ };
175
+
176
+ //
177
+ // Embedding
178
+ //
179
+
180
+ type EmbeddingMeta = { model?: string; prompt?: ChainPromptType };
181
+
182
+ const EmbeddingMetaProps = ({ meta }: MetaProps<EmbeddingMeta>) => {
183
+ if (!meta) {
184
+ return null;
185
+ }
186
+
187
+ return (
188
+ <>
189
+ <InputRow label='Model'>
190
+ <Input.TextInput
191
+ value={meta.model ?? ''}
192
+ onChange={(event) => (meta.model = event.target.value)}
193
+ placeholder='llama2'
194
+ />
195
+ </InputRow>
196
+ </>
197
+ );
198
+ };
199
+
200
+ const metaExtensions: Record<string, MetaExtension<any>> = {
201
+ __DEFAULT__: {
202
+ initialValue: () => ({}),
203
+ component: DefaultMetaProps,
204
+ } satisfies MetaExtension<DefaultMeta>,
205
+
206
+ 'dxos.org/function/chess': {
207
+ initialValue: () => ({ level: 2 }),
208
+ component: ChessMetaProps,
209
+ } satisfies MetaExtension<ChessMeta>,
210
+
211
+ 'dxos.org/function/email-worker': {
212
+ initialValue: () => ({ account: 'hello@dxos.network' }),
213
+ component: EmailWorkerMetaProps,
214
+ } satisfies MetaExtension<EmailWorkerMeta>,
215
+
216
+ 'dxos.org/function/gpt': {
217
+ initialValue: () => ({ model: 'llama2' }),
218
+ component: ChainPromptMetaProps,
219
+ } satisfies MetaExtension<ChainPromptMeta>,
220
+
221
+ 'dxos.org/function/embedding': {
222
+ initialValue: () => ({ model: 'llama2' }),
223
+ component: EmbeddingMetaProps,
224
+ } satisfies MetaExtension<EmbeddingMeta>,
225
+ };
@@ -0,0 +1,12 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { lazy } from 'react';
6
+
7
+ export const PromptContainer = lazy(() => import('./PromptContainer'));
8
+
9
+ export * from './AutomationPanel';
10
+ export * from './Chain';
11
+ export * from './PromptEditor';
12
+ export * from './TriggerEditor';
package/src/index.ts ADDED
@@ -0,0 +1,12 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { AutomationPlugin } from './AutomationPlugin';
6
+
7
+ export default AutomationPlugin;
8
+
9
+ export * from './AutomationPlugin';
10
+ export * from './components';
11
+ export * from './presets';
12
+ export * from './types';
package/src/meta.ts ADDED
@@ -0,0 +1,16 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type PluginMeta } from '@dxos/app-framework';
6
+
7
+ export const AUTOMATION_PLUGIN = 'dxos.org/plugin/automation';
8
+
9
+ export default {
10
+ id: AUTOMATION_PLUGIN,
11
+ name: 'Automation',
12
+ description: 'Automation workflows.',
13
+ icon: 'ph--flow-arrow--regular',
14
+ source: 'https://github.com/dxos/dxos/tree/main/packages/plugins/experimental/plugin-automation',
15
+ tags: ['experimental'],
16
+ } satisfies PluginMeta;
package/src/presets.ts ADDED
@@ -0,0 +1,248 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { create } from '@dxos/echo-schema';
6
+
7
+ import { ChainInputType, ChainPromptType } from './types';
8
+
9
+ export const str = (...text: (string | undefined | boolean)[]): string =>
10
+ text
11
+ .filter((value) => value !== undefined && value !== false)
12
+ .flat()
13
+ .join('\n');
14
+
15
+ export type Preset = {
16
+ id: string;
17
+ title: string;
18
+ createPrompt: () => ChainPromptType;
19
+ };
20
+
21
+ export const chainPresets: Preset[] = [
22
+ {
23
+ id: 'dxos.org/prompt/translate',
24
+ title: 'Translate',
25
+ createPrompt: () =>
26
+ create(ChainPromptType, {
27
+ command: 'say',
28
+ template: str(
29
+ // prettier-ignore
30
+ 'Translate the following into {language}:',
31
+ '',
32
+ '---',
33
+ '',
34
+ '{input}',
35
+ ),
36
+ inputs: [
37
+ {
38
+ type: ChainInputType.VALUE,
39
+ name: 'language',
40
+ value: 'japanese',
41
+ },
42
+ {
43
+ type: ChainInputType.PASS_THROUGH,
44
+ name: 'input',
45
+ },
46
+ // TODO(burdon): Message.
47
+ // {
48
+ // type: ChainInputType.CONTEXT,
49
+ // name: 'input',
50
+ // value: 'object.text',
51
+ // },
52
+ ],
53
+ }),
54
+ },
55
+ {
56
+ id: 'dxos.org/prompt/chess',
57
+ title: 'Chess',
58
+ createPrompt: () =>
59
+ create(ChainPromptType, {
60
+ command: 'hint',
61
+ template: str(
62
+ // prettier-ignore
63
+ 'You are a machine that is an expert chess player.',
64
+ '',
65
+ 'The move history of the current game is: {history}',
66
+ '',
67
+ 'Suggest the next move and very briefly explain your strategy in a couple of sentences.',
68
+ ),
69
+ inputs: [
70
+ {
71
+ type: ChainInputType.CONTEXT,
72
+ name: 'history',
73
+ value: 'object.pgn',
74
+ },
75
+ ],
76
+ }),
77
+ },
78
+ {
79
+ id: 'dxos.org/prompt/mermaid',
80
+ title: 'Mermaid',
81
+ createPrompt: () =>
82
+ create(ChainPromptType, {
83
+ command: 'draw',
84
+ template: str(
85
+ // prettier-ignore
86
+ 'Create a simplified mermaid graph representing the text below.',
87
+ 'Do not explain anything.',
88
+ '',
89
+ '---',
90
+ '',
91
+ '{input}',
92
+ ),
93
+ inputs: [
94
+ {
95
+ type: ChainInputType.PASS_THROUGH,
96
+ name: 'input',
97
+ },
98
+ ],
99
+ }),
100
+ },
101
+ {
102
+ id: 'dxos.org/prompt/list',
103
+ title: 'List',
104
+ createPrompt: () =>
105
+ create(ChainPromptType, {
106
+ command: 'list',
107
+ template: str(
108
+ // prettier-ignore
109
+ 'You are a machine that only replies with valid, iterable RFC8259 compliant JSON in your responses.',
110
+ 'Your entire response should be a single array of JSON objects.',
111
+ '',
112
+ 'Your entire response should be a map where the key is the type and the value is a single array of JSON objects conforming to the following types:',
113
+ '',
114
+ '{schema}',
115
+ '',
116
+ '---',
117
+ '',
118
+ '{question}',
119
+ ),
120
+ inputs: [
121
+ {
122
+ type: ChainInputType.SCHEMA,
123
+ name: 'schema',
124
+ value: 'example.com/type/project',
125
+ },
126
+ {
127
+ type: ChainInputType.PASS_THROUGH,
128
+ name: 'question',
129
+ },
130
+ ],
131
+ }),
132
+ },
133
+ {
134
+ id: 'dxos.org/prompt/base',
135
+ title: 'RAG',
136
+ createPrompt: () =>
137
+ create(ChainPromptType, {
138
+ command: 'rag',
139
+ template: str(
140
+ // prettier-ignore
141
+ "Very briefly answer the question based only on the following context and say if you don't know the answer.",
142
+ // 'answer the question using the following context as well as your training data:',
143
+ '',
144
+ '{context}',
145
+ '',
146
+ '---',
147
+ '',
148
+ 'question: {question}',
149
+ ),
150
+ inputs: [
151
+ {
152
+ type: ChainInputType.RETRIEVER,
153
+ name: 'context',
154
+ },
155
+ {
156
+ type: ChainInputType.CONTEXT,
157
+ name: 'question',
158
+ value: 'object.text',
159
+ },
160
+ ],
161
+ }),
162
+ },
163
+ {
164
+ id: 'dxos.org/prompt/lookup',
165
+ title: 'Lookup',
166
+ createPrompt: () =>
167
+ create(ChainPromptType, {
168
+ command: 'lookup',
169
+ template: str(
170
+ // prettier-ignore
171
+ 'Lookup and very briefly summarize the following topic in one or two sentences:',
172
+ '',
173
+ '---',
174
+ '',
175
+ '{input}',
176
+ ),
177
+ inputs: [
178
+ {
179
+ type: ChainInputType.CONTEXT,
180
+ name: 'input',
181
+ value: 'text',
182
+ },
183
+ ],
184
+ }),
185
+ },
186
+ {
187
+ id: 'dxos.org/prompt/extract',
188
+ title: 'Extract',
189
+ createPrompt: () =>
190
+ create(ChainPromptType, {
191
+ command: 'extract',
192
+ template: str(
193
+ // prettier-ignore
194
+ 'List all people and companies mentioned in the text below.',
195
+ '',
196
+ 'You are a machine that only replies with valid, iterable RFC8259 compliant JSON in your responses.',
197
+ 'Your entire response should be a map where the key is the type and the value is a single array of JSON objects conforming to the following types:',
198
+ '',
199
+ '{contact}',
200
+ '{company}',
201
+ '',
202
+ '---',
203
+ '',
204
+ '{input}',
205
+ ),
206
+ inputs: [
207
+ {
208
+ type: ChainInputType.SCHEMA,
209
+ name: 'contact',
210
+ value: 'example.com/type/contact',
211
+ },
212
+ {
213
+ type: ChainInputType.SCHEMA,
214
+ name: 'company',
215
+ value: 'example.com/type/organization',
216
+ },
217
+ {
218
+ type: ChainInputType.CONTEXT,
219
+ name: 'input',
220
+ value: 'text',
221
+ },
222
+ ],
223
+ }),
224
+ },
225
+ {
226
+ id: 'dxos.org/prompt/discord',
227
+ title: 'Summarize',
228
+ createPrompt: () =>
229
+ create(ChainPromptType, {
230
+ command: 'summarize',
231
+ template: str(
232
+ // prettier-ignore
233
+ 'Summarize what the team is working on and format it as a markdown table without any explanation.',
234
+ '',
235
+ '---',
236
+ '',
237
+ '{context}',
238
+ ),
239
+ inputs: [
240
+ {
241
+ type: ChainInputType.RESOLVER,
242
+ name: 'context',
243
+ value: 'discord.messages.recent',
244
+ },
245
+ ],
246
+ }),
247
+ },
248
+ ];
@@ -0,0 +1,31 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { AUTOMATION_PLUGIN } from './meta';
6
+
7
+ export default [
8
+ {
9
+ 'en-US': {
10
+ [AUTOMATION_PLUGIN]: {
11
+ 'plugin name': 'Automation',
12
+ 'object placeholder': 'New prompt',
13
+ 'create object label': 'Create prompt',
14
+ 'create trigger label': 'Create trigger',
15
+ 'create stack section label': 'Create prompt',
16
+ 'command placeholder': 'Enter slash command...',
17
+ 'template placeholder': 'Enter template...',
18
+ 'value placeholder': 'Enter value...',
19
+ 'select preset template placeholder': 'Select preset',
20
+ 'open automation panel label': 'Show Automations',
21
+
22
+ // 'create object label': 'Create rule',
23
+ // 'create stack section label': 'Create rule',
24
+ // 'command placeholder': 'Enter command...',
25
+ // 'template placeholder': 'Enter template...',
26
+ // 'value placeholder': 'Enter value...',
27
+ // 'select preset template placeholder': 'Select preset',
28
+ },
29
+ },
30
+ },
31
+ ];
@@ -0,0 +1,38 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { ref, S, TypedObject } from '@dxos/echo-schema';
6
+
7
+ // TODO(burdon): Change to S.Literal (and discriminated union).
8
+ export enum ChainInputType {
9
+ VALUE = 0,
10
+ PASS_THROUGH = 1,
11
+ RETRIEVER = 2,
12
+ FUNCTION = 3,
13
+ QUERY = 4,
14
+ RESOLVER = 5,
15
+ CONTEXT = 6,
16
+ SCHEMA = 7,
17
+ }
18
+
19
+ export const ChainInputSchema = S.mutable(
20
+ S.Struct({
21
+ name: S.String,
22
+ type: S.optional(S.Enums(ChainInputType)),
23
+ value: S.optional(S.String),
24
+ }),
25
+ );
26
+
27
+ export type ChainInput = S.Schema.Type<typeof ChainInputSchema>;
28
+
29
+ export class ChainPromptType extends TypedObject({ typename: 'dxos.org/type/ChainPrompt', version: '0.1.0' })({
30
+ command: S.optional(S.String),
31
+ template: S.String,
32
+ inputs: S.optional(S.mutable(S.Array(ChainInputSchema))),
33
+ }) {}
34
+
35
+ export class ChainType extends TypedObject({ typename: 'dxos.org/type/Chain', version: '0.1.0' })({
36
+ name: S.optional(S.String),
37
+ prompts: S.optional(S.mutable(S.Array(ref(ChainPromptType)))),
38
+ }) {}
@@ -0,0 +1,6 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ export * from './chain';
6
+ export * from './types';
@@ -0,0 +1,29 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import type {
6
+ GraphBuilderProvides,
7
+ IntentResolverProvides,
8
+ MetadataRecordsProvides,
9
+ SurfaceProvides,
10
+ TranslationsProvides,
11
+ } from '@dxos/app-framework';
12
+ import { type SchemaProvides } from '@dxos/plugin-client';
13
+ import { type PanelProvides } from '@dxos/plugin-deck/types';
14
+
15
+ import { AUTOMATION_PLUGIN } from '../meta';
16
+
17
+ const AUTOMATION_ACTION = `${AUTOMATION_PLUGIN}/action`;
18
+
19
+ export enum AutomationAction {
20
+ CREATE = `${AUTOMATION_ACTION}/create`,
21
+ }
22
+
23
+ export type AutomationPluginProvides = SurfaceProvides &
24
+ IntentResolverProvides &
25
+ MetadataRecordsProvides &
26
+ TranslationsProvides &
27
+ GraphBuilderProvides &
28
+ SchemaProvides &
29
+ PanelProvides;