@dxos/react-ui-canvas-compute 0.8.4-main.f9ba587 → 0.8.4-main.fffef41
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/index.mjs +236 -209
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +236 -209
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/compute.stories.d.ts +12 -5
- package/dist/types/src/compute.stories.d.ts.map +1 -1
- package/dist/types/src/graph/controller.d.ts +33 -24
- package/dist/types/src/graph/controller.d.ts.map +1 -1
- package/dist/types/src/graph/node-defs.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeGraphController.d.ts +2 -2
- package/dist/types/src/hooks/useComputeGraphController.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeNodeState.d.ts +4 -3
- package/dist/types/src/hooks/useComputeNodeState.d.ts.map +1 -1
- package/dist/types/src/hooks/useGraphMonitor.d.ts +1 -1
- package/dist/types/src/hooks/useGraphMonitor.d.ts.map +1 -1
- package/dist/types/src/json.test.d.ts +1 -1
- package/dist/types/src/json.test.d.ts.map +1 -1
- package/dist/types/src/shapes/Append.d.ts +1 -1
- package/dist/types/src/shapes/Append.d.ts.map +1 -1
- package/dist/types/src/shapes/Array.d.ts +1 -1
- package/dist/types/src/shapes/Array.d.ts.map +1 -1
- package/dist/types/src/shapes/Audio.d.ts +1 -1
- package/dist/types/src/shapes/Audio.d.ts.map +1 -1
- package/dist/types/src/shapes/Beacon.d.ts +1 -1
- package/dist/types/src/shapes/Beacon.d.ts.map +1 -1
- package/dist/types/src/shapes/Boolean.d.ts +1 -1
- package/dist/types/src/shapes/Boolean.d.ts.map +1 -1
- package/dist/types/src/shapes/Chat.d.ts +1 -1
- package/dist/types/src/shapes/Chat.d.ts.map +1 -1
- package/dist/types/src/shapes/Constant.d.ts +1 -1
- package/dist/types/src/shapes/Constant.d.ts.map +1 -1
- package/dist/types/src/shapes/Database.d.ts +1 -1
- package/dist/types/src/shapes/Database.d.ts.map +1 -1
- package/dist/types/src/shapes/Function.d.ts +1 -1
- package/dist/types/src/shapes/Function.d.ts.map +1 -1
- package/dist/types/src/shapes/Gpt.d.ts +1 -1
- package/dist/types/src/shapes/Gpt.d.ts.map +1 -1
- package/dist/types/src/shapes/GptRealtime.d.ts +1 -1
- package/dist/types/src/shapes/GptRealtime.d.ts.map +1 -1
- package/dist/types/src/shapes/Json.d.ts +1 -1
- package/dist/types/src/shapes/Json.d.ts.map +1 -1
- package/dist/types/src/shapes/Logic.d.ts +1 -1
- package/dist/types/src/shapes/Logic.d.ts.map +1 -1
- package/dist/types/src/shapes/Queue.d.ts +1 -1
- package/dist/types/src/shapes/Queue.d.ts.map +1 -1
- package/dist/types/src/shapes/RNG.d.ts +1 -1
- package/dist/types/src/shapes/RNG.d.ts.map +1 -1
- package/dist/types/src/shapes/Scope.d.ts +1 -1
- package/dist/types/src/shapes/Scope.d.ts.map +1 -1
- package/dist/types/src/shapes/Surface.d.ts +1 -1
- package/dist/types/src/shapes/Surface.d.ts.map +1 -1
- package/dist/types/src/shapes/Switch.d.ts +1 -1
- package/dist/types/src/shapes/Switch.d.ts.map +1 -1
- package/dist/types/src/shapes/Table.d.ts +1 -1
- package/dist/types/src/shapes/Table.d.ts.map +1 -1
- package/dist/types/src/shapes/Template.d.ts +1 -1
- package/dist/types/src/shapes/Template.d.ts.map +1 -1
- package/dist/types/src/shapes/Text.d.ts +1 -1
- package/dist/types/src/shapes/Text.d.ts.map +1 -1
- package/dist/types/src/shapes/TextToImage.d.ts +1 -1
- package/dist/types/src/shapes/TextToImage.d.ts.map +1 -1
- package/dist/types/src/shapes/Thread.d.ts +1 -1
- package/dist/types/src/shapes/Thread.d.ts.map +1 -1
- package/dist/types/src/shapes/Trigger.d.ts +4 -33
- package/dist/types/src/shapes/Trigger.d.ts.map +1 -1
- package/dist/types/src/shapes/common/Box.d.ts.map +1 -1
- package/dist/types/src/shapes/common/FunctionBody.d.ts +1 -1
- package/dist/types/src/shapes/common/FunctionBody.d.ts.map +1 -1
- package/dist/types/src/shapes/defs.d.ts +2 -1
- package/dist/types/src/shapes/defs.d.ts.map +1 -1
- package/dist/types/src/testing/circuits.d.ts +1 -1
- package/dist/types/src/testing/circuits.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +53 -49
- package/src/compute-layout.ts +1 -1
- package/src/compute.stories.tsx +29 -40
- package/src/graph/controller.ts +25 -14
- package/src/graph/node-defs.ts +4 -4
- package/src/hooks/useComputeGraphController.ts +2 -2
- package/src/hooks/useComputeNodeState.ts +10 -7
- package/src/hooks/useGraphMonitor.ts +2 -2
- package/src/json.test.ts +1 -1
- package/src/registry.ts +2 -2
- package/src/schema.test.ts +4 -4
- package/src/shapes/Append.tsx +3 -3
- package/src/shapes/Array.tsx +3 -3
- package/src/shapes/Audio.tsx +5 -4
- package/src/shapes/Beacon.tsx +6 -6
- package/src/shapes/Boolean.tsx +5 -5
- package/src/shapes/Chat.tsx +4 -3
- package/src/shapes/Constant.tsx +4 -3
- package/src/shapes/Database.tsx +2 -2
- package/src/shapes/Function.tsx +10 -9
- package/src/shapes/Gpt.tsx +8 -6
- package/src/shapes/GptRealtime.tsx +3 -3
- package/src/shapes/Json.tsx +4 -3
- package/src/shapes/Logic.tsx +3 -3
- package/src/shapes/Queue.tsx +6 -5
- package/src/shapes/RNG.tsx +10 -6
- package/src/shapes/Scope.tsx +6 -5
- package/src/shapes/Surface.tsx +11 -6
- package/src/shapes/Switch.tsx +5 -4
- package/src/shapes/Table.tsx +6 -6
- package/src/shapes/Template.tsx +6 -5
- package/src/shapes/Text.tsx +5 -4
- package/src/shapes/TextToImage.tsx +2 -2
- package/src/shapes/Thread.tsx +8 -8
- package/src/shapes/Trigger.tsx +42 -54
- package/src/shapes/common/Box.tsx +7 -7
- package/src/shapes/common/FunctionBody.tsx +5 -4
- package/src/shapes/common/TypeSelect.tsx +1 -1
- package/src/shapes/defs.ts +3 -2
- package/src/testing/circuits.ts +5 -5
|
@@ -1,94 +1,21 @@
|
|
|
1
1
|
import "@dxos/node-std/globals";
|
|
2
2
|
|
|
3
3
|
// src/graph/controller.ts
|
|
4
|
-
import
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Either from "effect/Either";
|
|
6
|
+
import * as Exit from "effect/Exit";
|
|
7
|
+
import * as Scope from "effect/Scope";
|
|
5
8
|
import { Event, synchronized } from "@dxos/async";
|
|
6
|
-
import { GraphExecutor,
|
|
9
|
+
import { GraphExecutor, ValueBag, isNotExecuted } from "@dxos/conductor";
|
|
7
10
|
import { Resource } from "@dxos/context";
|
|
8
11
|
import { log } from "@dxos/log";
|
|
9
12
|
|
|
10
|
-
// src/graph/node-defs.ts
|
|
11
|
-
import { NODE_INPUT, NODE_OUTPUT, registry, getTemplateInputSchema } from "@dxos/conductor";
|
|
12
|
-
import { raise } from "@dxos/debug";
|
|
13
|
-
import { ObjectId, toJsonSchema } from "@dxos/echo-schema";
|
|
14
|
-
import { invariant } from "@dxos/invariant";
|
|
15
|
-
var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/graph/node-defs.ts";
|
|
16
|
-
var resolveComputeNode = async (node) => {
|
|
17
|
-
const impl = registry[node.type];
|
|
18
|
-
invariant(impl, `Unknown node type: ${node.type}`, {
|
|
19
|
-
F: __dxlog_file,
|
|
20
|
-
L: 22,
|
|
21
|
-
S: void 0,
|
|
22
|
-
A: [
|
|
23
|
-
"impl",
|
|
24
|
-
"`Unknown node type: ${node.type}`"
|
|
25
|
-
]
|
|
26
|
-
});
|
|
27
|
-
return impl;
|
|
28
|
-
};
|
|
29
|
-
var isValidComputeNode = (type) => {
|
|
30
|
-
return nodeFactory[type] !== void 0;
|
|
31
|
-
};
|
|
32
|
-
var createComputeNode = (shape) => {
|
|
33
|
-
const type = shape.type ?? raise(new Error("Type not specified"));
|
|
34
|
-
const factory = nodeFactory[type] ?? raise(new Error(`Unknown shape type: ${type}`));
|
|
35
|
-
return factory(shape);
|
|
36
|
-
};
|
|
37
|
-
var nodeFactory = {
|
|
38
|
-
// System.
|
|
39
|
-
[NODE_INPUT]: () => createNode(NODE_INPUT),
|
|
40
|
-
[NODE_OUTPUT]: () => createNode(NODE_OUTPUT),
|
|
41
|
-
// Extensions.
|
|
42
|
-
["text-to-image"]: () => createNode("text-to-image"),
|
|
43
|
-
["and"]: () => createNode("and"),
|
|
44
|
-
["append"]: () => createNode("append"),
|
|
45
|
-
["audio"]: () => createNode("audio"),
|
|
46
|
-
["beacon"]: () => createNode("beacon"),
|
|
47
|
-
["chat"]: () => createNode("chat"),
|
|
48
|
-
["constant"]: (shape) => createNode("constant", {
|
|
49
|
-
value: shape.value
|
|
50
|
-
}),
|
|
51
|
-
["make-queue"]: () => createNode("make-queue"),
|
|
52
|
-
["database"]: () => createNode("database"),
|
|
53
|
-
["gpt"]: () => createNode("gpt"),
|
|
54
|
-
["gpt-realtime"]: () => createNode("gpt-realtime"),
|
|
55
|
-
["if"]: () => createNode("if"),
|
|
56
|
-
["if-else"]: () => createNode("if-else"),
|
|
57
|
-
["function"]: () => createNode("function"),
|
|
58
|
-
["json"]: () => createNode("json"),
|
|
59
|
-
["json-transform"]: () => createNode("json-transform"),
|
|
60
|
-
["not"]: () => createNode("not"),
|
|
61
|
-
["or"]: () => createNode("or"),
|
|
62
|
-
["queue"]: () => createNode("queue"),
|
|
63
|
-
["rng"]: () => createNode("rng"),
|
|
64
|
-
["reducer"]: () => createNode("reducer"),
|
|
65
|
-
["scope"]: () => createNode("scope"),
|
|
66
|
-
["surface"]: () => createNode("surface"),
|
|
67
|
-
["switch"]: () => createNode("switch"),
|
|
68
|
-
["template"]: (shape) => {
|
|
69
|
-
const node = createNode("template", {
|
|
70
|
-
valueType: shape.valueType,
|
|
71
|
-
value: shape.text
|
|
72
|
-
});
|
|
73
|
-
node.inputSchema = toJsonSchema(getTemplateInputSchema(node));
|
|
74
|
-
return node;
|
|
75
|
-
},
|
|
76
|
-
["text"]: () => createNode("text"),
|
|
77
|
-
["thread"]: () => createNode("thread"),
|
|
78
|
-
["trigger"]: () => createNode(NODE_INPUT)
|
|
79
|
-
};
|
|
80
|
-
var createNode = (type, props) => ({
|
|
81
|
-
id: ObjectId.random(),
|
|
82
|
-
type,
|
|
83
|
-
...props
|
|
84
|
-
});
|
|
85
|
-
|
|
86
13
|
// src/hooks/compute-context.ts
|
|
87
14
|
import { createContext, useContext } from "react";
|
|
88
|
-
import { raise
|
|
15
|
+
import { raise } from "@dxos/debug";
|
|
89
16
|
var ComputeContext = createContext(null);
|
|
90
17
|
var useComputeContext = () => {
|
|
91
|
-
return useContext(ComputeContext) ??
|
|
18
|
+
return useContext(ComputeContext) ?? raise(new Error("Missing ComputeContext"));
|
|
92
19
|
};
|
|
93
20
|
|
|
94
21
|
// src/hooks/useComputeGraphController.ts
|
|
@@ -142,15 +69,15 @@ var useComputeGraphController = ({ controller, graph, editorRef }) => {
|
|
|
142
69
|
};
|
|
143
70
|
|
|
144
71
|
// src/hooks/useComputeNodeState.ts
|
|
145
|
-
import
|
|
72
|
+
import * as Schema from "effect/Schema";
|
|
146
73
|
import { useCallback, useEffect as useEffect2, useState as useState2 } from "react";
|
|
147
|
-
import { invariant
|
|
148
|
-
var
|
|
74
|
+
import { invariant } from "@dxos/invariant";
|
|
75
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/hooks/useComputeNodeState.ts";
|
|
149
76
|
var useComputeNodeState = (shape) => {
|
|
150
77
|
const { controller } = useComputeContext();
|
|
151
|
-
|
|
152
|
-
F:
|
|
153
|
-
L:
|
|
78
|
+
invariant(controller, void 0, {
|
|
79
|
+
F: __dxlog_file,
|
|
80
|
+
L: 34,
|
|
154
81
|
S: void 0,
|
|
155
82
|
A: [
|
|
156
83
|
"controller",
|
|
@@ -161,9 +88,9 @@ var useComputeNodeState = (shape) => {
|
|
|
161
88
|
useEffect2(() => {
|
|
162
89
|
let disposed = false;
|
|
163
90
|
queueMicrotask(async () => {
|
|
164
|
-
|
|
165
|
-
F:
|
|
166
|
-
L:
|
|
91
|
+
invariant(shape.node, "Node not specified", {
|
|
92
|
+
F: __dxlog_file,
|
|
93
|
+
L: 40,
|
|
167
94
|
S: void 0,
|
|
168
95
|
A: [
|
|
169
96
|
"shape.node",
|
|
@@ -218,16 +145,16 @@ var useComputeNodeState = (shape) => {
|
|
|
218
145
|
// src/hooks/useGraphMonitor.ts
|
|
219
146
|
import { useMemo } from "react";
|
|
220
147
|
import { ComputeGraphModel, DEFAULT_INPUT, DEFAULT_OUTPUT } from "@dxos/conductor";
|
|
221
|
-
import { ObjectId
|
|
222
|
-
import { invariant as
|
|
148
|
+
import { ObjectId, Ref } from "@dxos/echo/internal";
|
|
149
|
+
import { invariant as invariant2 } from "@dxos/invariant";
|
|
223
150
|
import { getSpace } from "@dxos/react-client/echo";
|
|
224
151
|
import { isNonNullable } from "@dxos/util";
|
|
225
|
-
var
|
|
152
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/hooks/useGraphMonitor.ts";
|
|
226
153
|
var mapEdge = (graph, { source, target, output = DEFAULT_OUTPUT, input = DEFAULT_INPUT }) => {
|
|
227
154
|
const sourceNode = graph.findNode(source);
|
|
228
155
|
const targetNode = graph.findNode(target);
|
|
229
|
-
|
|
230
|
-
F:
|
|
156
|
+
invariant2(sourceNode?.node, void 0, {
|
|
157
|
+
F: __dxlog_file2,
|
|
231
158
|
L: 26,
|
|
232
159
|
S: void 0,
|
|
233
160
|
A: [
|
|
@@ -235,8 +162,8 @@ var mapEdge = (graph, { source, target, output = DEFAULT_OUTPUT, input = DEFAULT
|
|
|
235
162
|
""
|
|
236
163
|
]
|
|
237
164
|
});
|
|
238
|
-
|
|
239
|
-
F:
|
|
165
|
+
invariant2(targetNode?.node, void 0, {
|
|
166
|
+
F: __dxlog_file2,
|
|
240
167
|
L: 27,
|
|
241
168
|
S: void 0,
|
|
242
169
|
A: [
|
|
@@ -245,7 +172,7 @@ var mapEdge = (graph, { source, target, output = DEFAULT_OUTPUT, input = DEFAULT
|
|
|
245
172
|
]
|
|
246
173
|
});
|
|
247
174
|
return {
|
|
248
|
-
id:
|
|
175
|
+
id: ObjectId.random(),
|
|
249
176
|
source: sourceNode.node,
|
|
250
177
|
target: targetNode.node,
|
|
251
178
|
output,
|
|
@@ -259,8 +186,8 @@ var useGraphMonitor = (model) => {
|
|
|
259
186
|
if (!model) {
|
|
260
187
|
return;
|
|
261
188
|
}
|
|
262
|
-
|
|
263
|
-
F:
|
|
189
|
+
invariant2(node.type, void 0, {
|
|
190
|
+
F: __dxlog_file2,
|
|
264
191
|
L: 52,
|
|
265
192
|
S: void 0,
|
|
266
193
|
A: [
|
|
@@ -317,8 +244,8 @@ var createComputeGraph = (graph) => {
|
|
|
317
244
|
};
|
|
318
245
|
var linkTriggerToCompute = (graph, computeNode, triggerData) => {
|
|
319
246
|
const functionTrigger = triggerData.functionTrigger?.target;
|
|
320
|
-
|
|
321
|
-
F:
|
|
247
|
+
invariant2(functionTrigger, void 0, {
|
|
248
|
+
F: __dxlog_file2,
|
|
322
249
|
L: 115,
|
|
323
250
|
S: void 0,
|
|
324
251
|
A: [
|
|
@@ -342,6 +269,82 @@ var deleteTriggerObjects = (computeGraph, deleted) => {
|
|
|
342
269
|
}
|
|
343
270
|
};
|
|
344
271
|
|
|
272
|
+
// src/graph/node-defs.ts
|
|
273
|
+
import { NODE_INPUT, NODE_OUTPUT, getTemplateInputSchema, registry } from "@dxos/conductor";
|
|
274
|
+
import { raise as raise2 } from "@dxos/debug";
|
|
275
|
+
import { ObjectId as ObjectId2, toJsonSchema } from "@dxos/echo/internal";
|
|
276
|
+
import { invariant as invariant3 } from "@dxos/invariant";
|
|
277
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/graph/node-defs.ts";
|
|
278
|
+
var resolveComputeNode = async (node) => {
|
|
279
|
+
const impl = registry[node.type];
|
|
280
|
+
invariant3(impl, `Unknown node type: ${node.type}`, {
|
|
281
|
+
F: __dxlog_file3,
|
|
282
|
+
L: 22,
|
|
283
|
+
S: void 0,
|
|
284
|
+
A: [
|
|
285
|
+
"impl",
|
|
286
|
+
"`Unknown node type: ${node.type}`"
|
|
287
|
+
]
|
|
288
|
+
});
|
|
289
|
+
return impl;
|
|
290
|
+
};
|
|
291
|
+
var isValidComputeNode = (type) => {
|
|
292
|
+
return nodeFactory[type] !== void 0;
|
|
293
|
+
};
|
|
294
|
+
var createComputeNode = (shape) => {
|
|
295
|
+
const type = shape.type ?? raise2(new Error("Type not specified"));
|
|
296
|
+
const factory = nodeFactory[type] ?? raise2(new Error(`Unknown shape type: ${type}`));
|
|
297
|
+
return factory(shape);
|
|
298
|
+
};
|
|
299
|
+
var nodeFactory = {
|
|
300
|
+
// System.
|
|
301
|
+
[NODE_INPUT]: () => createNode(NODE_INPUT),
|
|
302
|
+
[NODE_OUTPUT]: () => createNode(NODE_OUTPUT),
|
|
303
|
+
// Extensions.
|
|
304
|
+
["text-to-image"]: () => createNode("text-to-image"),
|
|
305
|
+
["and"]: () => createNode("and"),
|
|
306
|
+
["append"]: () => createNode("append"),
|
|
307
|
+
["audio"]: () => createNode("audio"),
|
|
308
|
+
["beacon"]: () => createNode("beacon"),
|
|
309
|
+
["chat"]: () => createNode("chat"),
|
|
310
|
+
["constant"]: (shape) => createNode("constant", {
|
|
311
|
+
value: shape.value
|
|
312
|
+
}),
|
|
313
|
+
["make-queue"]: () => createNode("make-queue"),
|
|
314
|
+
["database"]: () => createNode("database"),
|
|
315
|
+
["gpt"]: () => createNode("gpt"),
|
|
316
|
+
["gpt-realtime"]: () => createNode("gpt-realtime"),
|
|
317
|
+
["if"]: () => createNode("if"),
|
|
318
|
+
["if-else"]: () => createNode("if-else"),
|
|
319
|
+
["function"]: () => createNode("function"),
|
|
320
|
+
["json"]: () => createNode("json"),
|
|
321
|
+
["json-transform"]: () => createNode("json-transform"),
|
|
322
|
+
["not"]: () => createNode("not"),
|
|
323
|
+
["or"]: () => createNode("or"),
|
|
324
|
+
["queue"]: () => createNode("queue"),
|
|
325
|
+
["rng"]: () => createNode("rng"),
|
|
326
|
+
["reducer"]: () => createNode("reducer"),
|
|
327
|
+
["scope"]: () => createNode("scope"),
|
|
328
|
+
["surface"]: () => createNode("surface"),
|
|
329
|
+
["switch"]: () => createNode("switch"),
|
|
330
|
+
["template"]: (shape) => {
|
|
331
|
+
const node = createNode("template", {
|
|
332
|
+
valueType: shape.valueType,
|
|
333
|
+
value: shape.text
|
|
334
|
+
});
|
|
335
|
+
node.inputSchema = toJsonSchema(getTemplateInputSchema(node));
|
|
336
|
+
return node;
|
|
337
|
+
},
|
|
338
|
+
["text"]: () => createNode("text"),
|
|
339
|
+
["thread"]: () => createNode("thread"),
|
|
340
|
+
["trigger"]: () => createNode(NODE_INPUT)
|
|
341
|
+
};
|
|
342
|
+
var createNode = (type, props) => ({
|
|
343
|
+
id: ObjectId2.random(),
|
|
344
|
+
type,
|
|
345
|
+
...props
|
|
346
|
+
});
|
|
347
|
+
|
|
345
348
|
// src/graph/controller.ts
|
|
346
349
|
function _ts_decorate(decorators, target, key, desc) {
|
|
347
350
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -365,10 +368,28 @@ var createComputeGraphController = (graph, serviceContainer) => {
|
|
|
365
368
|
};
|
|
366
369
|
};
|
|
367
370
|
var ComputeGraphController = class extends Resource {
|
|
371
|
+
_serviceContainer;
|
|
372
|
+
_graph;
|
|
373
|
+
_executor = new GraphExecutor({
|
|
374
|
+
computeNodeResolver: (node) => resolveComputeNode(node)
|
|
375
|
+
});
|
|
376
|
+
_diagnostics = [];
|
|
377
|
+
/**
|
|
378
|
+
* Canvas force-sets outputs of those nodes.
|
|
379
|
+
*/
|
|
380
|
+
_forcedOutputs = {};
|
|
381
|
+
/**
|
|
382
|
+
* Runtime state of the execution graph.
|
|
383
|
+
*/
|
|
384
|
+
_runtimeStateInputs = {};
|
|
385
|
+
_runtimeStateOutputs = {};
|
|
386
|
+
// TODO(burdon): Remove? Make state reactive?
|
|
387
|
+
update = new Event();
|
|
388
|
+
/** Computed result. */
|
|
389
|
+
output = new Event();
|
|
390
|
+
events = new Event();
|
|
368
391
|
constructor(_serviceContainer, _graph) {
|
|
369
|
-
super(), this._serviceContainer = _serviceContainer, this._graph = _graph
|
|
370
|
-
computeNodeResolver: (node) => resolveComputeNode(node)
|
|
371
|
-
}), this._diagnostics = [], this._forcedOutputs = {}, this._runtimeStateInputs = {}, this._runtimeStateOutputs = {}, this.update = new Event(), this.output = new Event(), this.events = new Event();
|
|
392
|
+
super(), this._serviceContainer = _serviceContainer, this._graph = _graph;
|
|
372
393
|
}
|
|
373
394
|
toJSON() {
|
|
374
395
|
return {
|
|
@@ -438,7 +459,7 @@ var ComputeGraphController = class extends Resource {
|
|
|
438
459
|
} catch (err) {
|
|
439
460
|
log.catch(err, void 0, {
|
|
440
461
|
F: __dxlog_file4,
|
|
441
|
-
L:
|
|
462
|
+
L: 210,
|
|
442
463
|
S: this,
|
|
443
464
|
C: (f, a) => f(...a)
|
|
444
465
|
});
|
|
@@ -532,7 +553,7 @@ var ComputeGraphController = class extends Resource {
|
|
|
532
553
|
event
|
|
533
554
|
}, {
|
|
534
555
|
F: __dxlog_file4,
|
|
535
|
-
L:
|
|
556
|
+
L: 346,
|
|
536
557
|
S: this,
|
|
537
558
|
C: (f, a) => f(...a)
|
|
538
559
|
});
|
|
@@ -636,9 +657,9 @@ var Box = /* @__PURE__ */ forwardRef(({ children, classNames, shape, title, stat
|
|
|
636
657
|
const { debug } = useEditorContext();
|
|
637
658
|
return /* @__PURE__ */ React.createElement("div", {
|
|
638
659
|
ref: forwardedRef,
|
|
639
|
-
className: "flex flex-col
|
|
660
|
+
className: "flex flex-col bs-full is-full justify-between"
|
|
640
661
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
641
|
-
className: "flex shrink-0
|
|
662
|
+
className: "flex shrink-0 is-full justify-between items-center bs-[32px] bg-hoverSurface"
|
|
642
663
|
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
643
664
|
icon,
|
|
644
665
|
classNames: "mx-2"
|
|
@@ -657,11 +678,11 @@ var Box = /* @__PURE__ */ forwardRef(({ children, classNames, shape, title, stat
|
|
|
657
678
|
onAction?.("run");
|
|
658
679
|
}
|
|
659
680
|
})), /* @__PURE__ */ React.createElement("div", {
|
|
660
|
-
className: mx("flex flex-col
|
|
681
|
+
className: mx("flex flex-col bs-full grow overflow-hidden", classNames)
|
|
661
682
|
}, children), /* @__PURE__ */ React.createElement("div", {
|
|
662
|
-
className: "flex shrink-0
|
|
683
|
+
className: "flex shrink-0 is-full justify-between items-center bs-[32px] bg-hoverSurface"
|
|
663
684
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
664
|
-
className: "grow
|
|
685
|
+
className: "grow pli-2 text-sm truncate"
|
|
665
686
|
}, debug ? shape.id : status), openable && /* @__PURE__ */ React.createElement(IconButton, {
|
|
666
687
|
classNames: "p-1",
|
|
667
688
|
variant: "ghost",
|
|
@@ -681,16 +702,17 @@ var Box = /* @__PURE__ */ forwardRef(({ children, classNames, shape, title, stat
|
|
|
681
702
|
|
|
682
703
|
// src/shapes/common/FunctionBody.tsx
|
|
683
704
|
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
684
|
-
import
|
|
705
|
+
import * as SchemaAST2 from "effect/SchemaAST";
|
|
685
706
|
import React2, { useRef, useState as useState3 } from "react";
|
|
686
707
|
import { VoidInput, VoidOutput } from "@dxos/conductor";
|
|
687
708
|
import { useCanvasContext } from "@dxos/react-ui-canvas";
|
|
688
|
-
import {
|
|
709
|
+
import { createAnchors, getParentShapeElement, rowHeight } from "@dxos/react-ui-canvas-editor";
|
|
689
710
|
|
|
690
711
|
// src/shapes/defs.ts
|
|
691
|
-
import
|
|
712
|
+
import * as Schema2 from "effect/Schema";
|
|
713
|
+
import * as SchemaAST from "effect/SchemaAST";
|
|
692
714
|
import { DEFAULT_INPUT as DEFAULT_INPUT2, DEFAULT_OUTPUT as DEFAULT_OUTPUT2 } from "@dxos/conductor";
|
|
693
|
-
import { ObjectId as ObjectId3 } from "@dxos/echo
|
|
715
|
+
import { ObjectId as ObjectId3 } from "@dxos/echo/internal";
|
|
694
716
|
import { Polygon } from "@dxos/react-ui-canvas-editor";
|
|
695
717
|
var getProperties = (ast) => SchemaAST.getPropertySignatures(ast).map(({ name }) => ({
|
|
696
718
|
name: name.toString()
|
|
@@ -769,7 +791,7 @@ var FunctionBody = ({ shape, name, content, inputSchema = VoidInput, outputSchem
|
|
|
769
791
|
className: "flex flex-col"
|
|
770
792
|
}, inputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
|
|
771
793
|
key: name2,
|
|
772
|
-
className: "
|
|
794
|
+
className: "pli-2 truncate text-sm font-mono items-center",
|
|
773
795
|
style: {
|
|
774
796
|
height: rowHeight
|
|
775
797
|
}
|
|
@@ -777,7 +799,7 @@ var FunctionBody = ({ shape, name, content, inputSchema = VoidInput, outputSchem
|
|
|
777
799
|
className: "flex flex-col"
|
|
778
800
|
}, outputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
|
|
779
801
|
key: name2,
|
|
780
|
-
className: "
|
|
802
|
+
className: "pli-2 truncate text-sm font-mono items-center text-right",
|
|
781
803
|
style: {
|
|
782
804
|
height: rowHeight
|
|
783
805
|
}
|
|
@@ -819,7 +841,7 @@ var TypeSelect = ({ value, onValueChange }) => {
|
|
|
819
841
|
onValueChange
|
|
820
842
|
}, /* @__PURE__ */ React3.createElement(Select.TriggerButton, {
|
|
821
843
|
variant: "ghost",
|
|
822
|
-
classNames: "
|
|
844
|
+
classNames: "is-full !pli-0"
|
|
823
845
|
}), /* @__PURE__ */ React3.createElement(Select.Portal, null, /* @__PURE__ */ React3.createElement(Select.Content, null, /* @__PURE__ */ React3.createElement(Select.ScrollUpButton, null), /* @__PURE__ */ React3.createElement(Select.Viewport, null, ComputeValueType.literals.map((type) => /* @__PURE__ */ React3.createElement(Select.Option, {
|
|
824
846
|
key: type,
|
|
825
847
|
value: type
|
|
@@ -831,7 +853,7 @@ var TypeSelect = ({ value, onValueChange }) => {
|
|
|
831
853
|
|
|
832
854
|
// src/shapes/Array.tsx
|
|
833
855
|
import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
|
|
834
|
-
import
|
|
856
|
+
import * as Schema3 from "effect/Schema";
|
|
835
857
|
import React4 from "react";
|
|
836
858
|
import { ReducerInput, ReducerOutput } from "@dxos/conductor";
|
|
837
859
|
var ReducerShape = Schema3.extend(ComputeShape, Schema3.Struct({
|
|
@@ -868,7 +890,7 @@ var reducerShape = {
|
|
|
868
890
|
|
|
869
891
|
// src/shapes/Append.tsx
|
|
870
892
|
import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
|
|
871
|
-
import
|
|
893
|
+
import * as Schema4 from "effect/Schema";
|
|
872
894
|
import React5 from "react";
|
|
873
895
|
import { AppendInput } from "@dxos/conductor";
|
|
874
896
|
var AppendShape = Schema4.extend(ComputeShape, Schema4.Struct({
|
|
@@ -904,7 +926,7 @@ var appendShape = {
|
|
|
904
926
|
|
|
905
927
|
// src/shapes/Audio.tsx
|
|
906
928
|
import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
|
|
907
|
-
import
|
|
929
|
+
import * as Schema5 from "effect/Schema";
|
|
908
930
|
import React6, { useEffect as useEffect3, useState as useState4 } from "react";
|
|
909
931
|
import { Icon as Icon2 } from "@dxos/react-ui";
|
|
910
932
|
import { createAnchorMap } from "@dxos/react-ui-canvas-editor";
|
|
@@ -930,7 +952,7 @@ var AudioComponent = ({ shape }) => {
|
|
|
930
952
|
active
|
|
931
953
|
]);
|
|
932
954
|
return /* @__PURE__ */ React6.createElement("div", {
|
|
933
|
-
className: "flex
|
|
955
|
+
className: "flex is-full justify-center items-center"
|
|
934
956
|
}, /* @__PURE__ */ React6.createElement(Icon2, {
|
|
935
957
|
icon: active ? "ph--microphone--regular" : "ph--microphone-slash--regular",
|
|
936
958
|
classNames: [
|
|
@@ -960,12 +982,11 @@ var audioShape = {
|
|
|
960
982
|
|
|
961
983
|
// src/shapes/Beacon.tsx
|
|
962
984
|
import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
|
|
963
|
-
import
|
|
985
|
+
import * as Schema6 from "effect/Schema";
|
|
964
986
|
import React7 from "react";
|
|
965
987
|
import { DEFAULT_INPUT as DEFAULT_INPUT3, isTruthy } from "@dxos/conductor";
|
|
966
988
|
import { Icon as Icon3 } from "@dxos/react-ui";
|
|
967
989
|
import { createAnchorMap as createAnchorMap2 } from "@dxos/react-ui-canvas-editor";
|
|
968
|
-
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
969
990
|
var BeaconShape = Schema6.extend(ComputeShape, Schema6.Struct({
|
|
970
991
|
type: Schema6.Literal("beacon")
|
|
971
992
|
}));
|
|
@@ -984,10 +1005,13 @@ var BeaconComponent = ({ shape }) => {
|
|
|
984
1005
|
const input = runtime.inputs[DEFAULT_INPUT3];
|
|
985
1006
|
const value = input?.type === "executed" ? input.value : false;
|
|
986
1007
|
return /* @__PURE__ */ React7.createElement("div", {
|
|
987
|
-
className: "flex
|
|
1008
|
+
className: "flex is-full justify-center items-center"
|
|
988
1009
|
}, /* @__PURE__ */ React7.createElement(Icon3, {
|
|
989
1010
|
icon: "ph--sun--regular",
|
|
990
|
-
classNames:
|
|
1011
|
+
classNames: [
|
|
1012
|
+
"transition opacity-20 duration-1000",
|
|
1013
|
+
isTruthy(value) && "opacity-100 text-yellow-500"
|
|
1014
|
+
],
|
|
991
1015
|
size: 8
|
|
992
1016
|
}));
|
|
993
1017
|
} finally {
|
|
@@ -1009,7 +1033,7 @@ var beaconShape = {
|
|
|
1009
1033
|
};
|
|
1010
1034
|
|
|
1011
1035
|
// src/shapes/Boolean.tsx
|
|
1012
|
-
import
|
|
1036
|
+
import * as Schema7 from "effect/Schema";
|
|
1013
1037
|
import React8 from "react";
|
|
1014
1038
|
import { getAnchorPoints } from "@dxos/react-ui-canvas-editor";
|
|
1015
1039
|
import { createAnchors as createAnchors2 } from "@dxos/react-ui-canvas-editor";
|
|
@@ -1033,7 +1057,7 @@ var defineShape = ({ type, name, icon, symbol: Symbol, createShape: createShape2
|
|
|
1033
1057
|
// Be careful not to name component factories with a capital letter.
|
|
1034
1058
|
component: () => {
|
|
1035
1059
|
return /* @__PURE__ */ React8.createElement("div", {
|
|
1036
|
-
className: "flex
|
|
1060
|
+
className: "flex is-full justify-center items-center"
|
|
1037
1061
|
}, /* @__PURE__ */ React8.createElement(Symbol, null));
|
|
1038
1062
|
},
|
|
1039
1063
|
createShape: createShape2,
|
|
@@ -1060,7 +1084,7 @@ var createSymbol = (pathConstructor, inputs) => ({
|
|
|
1060
1084
|
});
|
|
1061
1085
|
return /* @__PURE__ */ React8.createElement("svg", {
|
|
1062
1086
|
viewBox: `0 0 ${width} ${height}`,
|
|
1063
|
-
className: "
|
|
1087
|
+
className: "is-full bs-full"
|
|
1064
1088
|
}, getAnchorPoints({
|
|
1065
1089
|
x: 0,
|
|
1066
1090
|
y: centerY
|
|
@@ -1183,7 +1207,7 @@ var notShape = defineShape({
|
|
|
1183
1207
|
|
|
1184
1208
|
// src/shapes/Chat.tsx
|
|
1185
1209
|
import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
|
|
1186
|
-
import
|
|
1210
|
+
import * as Schema8 from "effect/Schema";
|
|
1187
1211
|
import React9, { useRef as useRef2 } from "react";
|
|
1188
1212
|
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT3 } from "@dxos/conductor";
|
|
1189
1213
|
import { TextBox } from "@dxos/react-ui-canvas-editor";
|
|
@@ -1244,7 +1268,7 @@ var chatShape = {
|
|
|
1244
1268
|
|
|
1245
1269
|
// src/shapes/Constant.tsx
|
|
1246
1270
|
import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
|
|
1247
|
-
import
|
|
1271
|
+
import * as Schema9 from "effect/Schema";
|
|
1248
1272
|
import React10, { useCallback as useCallback2, useRef as useRef3, useState as useState5 } from "react";
|
|
1249
1273
|
import { ComputeValueType as ComputeValueType2 } from "@dxos/conductor";
|
|
1250
1274
|
import { Input } from "@dxos/react-ui";
|
|
@@ -1347,7 +1371,7 @@ var constantShape = {
|
|
|
1347
1371
|
|
|
1348
1372
|
// src/shapes/Database.tsx
|
|
1349
1373
|
import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
|
|
1350
|
-
import
|
|
1374
|
+
import * as Schema10 from "effect/Schema";
|
|
1351
1375
|
import React11 from "react";
|
|
1352
1376
|
import { createAnchorMap as createAnchorMap5 } from "@dxos/react-ui-canvas-editor";
|
|
1353
1377
|
var DatabaseShape = Schema10.extend(ComputeShape, Schema10.Struct({
|
|
@@ -1387,11 +1411,11 @@ var databaseShape = {
|
|
|
1387
1411
|
|
|
1388
1412
|
// src/shapes/Function.tsx
|
|
1389
1413
|
import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
|
|
1390
|
-
import
|
|
1414
|
+
import * as Schema11 from "effect/Schema";
|
|
1391
1415
|
import React12, { useCallback as useCallback3, useRef as useRef4 } from "react";
|
|
1392
1416
|
import { AnyOutput, FunctionInput } from "@dxos/conductor";
|
|
1393
|
-
import {
|
|
1394
|
-
import {
|
|
1417
|
+
import { Ref as Ref2, getSnapshot, isInstanceOf } from "@dxos/echo/internal";
|
|
1418
|
+
import { Function, Script } from "@dxos/functions";
|
|
1395
1419
|
import { useClient } from "@dxos/react-client";
|
|
1396
1420
|
import { Filter, parseId } from "@dxos/react-client/echo";
|
|
1397
1421
|
import { TextBox as TextBox3 } from "@dxos/react-ui-canvas-editor";
|
|
@@ -1420,10 +1444,10 @@ var TextInputComponent2 = ({ shape, title, ...props }) => {
|
|
|
1420
1444
|
}
|
|
1421
1445
|
const space = client.spaces.get(spaceId);
|
|
1422
1446
|
const object = space?.db.getObjectById(objectId);
|
|
1423
|
-
if (!space || !isInstanceOf(
|
|
1447
|
+
if (!space || !isInstanceOf(Script.Script, object)) {
|
|
1424
1448
|
return;
|
|
1425
1449
|
}
|
|
1426
|
-
const { objects: [fn] } = await space.db.query(Filter.type(
|
|
1450
|
+
const { objects: [fn] } = await space.db.query(Filter.type(Function.Function, {
|
|
1427
1451
|
source: Ref2.make(object)
|
|
1428
1452
|
})).run();
|
|
1429
1453
|
if (!fn) {
|
|
@@ -1472,7 +1496,7 @@ var functionShape = {
|
|
|
1472
1496
|
|
|
1473
1497
|
// src/shapes/Gpt.tsx
|
|
1474
1498
|
import { useSignals as _useSignals12 } from "@preact-signals/safe-react/tracking";
|
|
1475
|
-
import
|
|
1499
|
+
import * as Schema12 from "effect/Schema";
|
|
1476
1500
|
import React13, { useEffect as useEffect4, useState as useState6 } from "react";
|
|
1477
1501
|
import { GptInput, GptOutput } from "@dxos/conductor";
|
|
1478
1502
|
var GptShape = Schema12.extend(ComputeShape, Schema12.Struct({
|
|
@@ -1526,7 +1550,7 @@ var GptComponent = ({ shape }) => {
|
|
|
1526
1550
|
return /* @__PURE__ */ React13.createElement(FunctionBody, {
|
|
1527
1551
|
shape,
|
|
1528
1552
|
content: /* @__PURE__ */ React13.createElement("div", {
|
|
1529
|
-
className: "
|
|
1553
|
+
className: "pli-2 plb-1 overflow-y-auto"
|
|
1530
1554
|
}, text),
|
|
1531
1555
|
status: `${tokens} tokens`,
|
|
1532
1556
|
inputSchema: meta.input,
|
|
@@ -1548,7 +1572,7 @@ var gptShape = {
|
|
|
1548
1572
|
|
|
1549
1573
|
// src/shapes/Json.tsx
|
|
1550
1574
|
import { useSignals as _useSignals13 } from "@preact-signals/safe-react/tracking";
|
|
1551
|
-
import
|
|
1575
|
+
import * as Schema13 from "effect/Schema";
|
|
1552
1576
|
import React14 from "react";
|
|
1553
1577
|
import { DEFAULT_INPUT as DEFAULT_INPUT4, DefaultOutput, JsonTransformInput } from "@dxos/conductor";
|
|
1554
1578
|
import { createAnchorMap as createAnchorMap6 } from "@dxos/react-ui-canvas-editor";
|
|
@@ -1631,7 +1655,7 @@ var jsonTransformShape = {
|
|
|
1631
1655
|
|
|
1632
1656
|
// src/shapes/Logic.tsx
|
|
1633
1657
|
import { useSignals as _useSignals14 } from "@preact-signals/safe-react/tracking";
|
|
1634
|
-
import
|
|
1658
|
+
import * as Schema14 from "effect/Schema";
|
|
1635
1659
|
import React15 from "react";
|
|
1636
1660
|
import { IfElseInput, IfElseOutput, IfInput, IfOutput } from "@dxos/conductor";
|
|
1637
1661
|
var IfShape = Schema14.extend(ComputeShape, Schema14.Struct({
|
|
@@ -1699,10 +1723,10 @@ var ifElseShape = {
|
|
|
1699
1723
|
|
|
1700
1724
|
// src/shapes/Queue.tsx
|
|
1701
1725
|
import { useSignals as _useSignals15 } from "@preact-signals/safe-react/tracking";
|
|
1702
|
-
import
|
|
1726
|
+
import * as Schema15 from "effect/Schema";
|
|
1703
1727
|
import React16, { Fragment } from "react";
|
|
1704
1728
|
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT4, QueueInput, QueueOutput } from "@dxos/conductor";
|
|
1705
|
-
import { mx as
|
|
1729
|
+
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
1706
1730
|
var QueueShape = Schema15.extend(ComputeShape, Schema15.Struct({
|
|
1707
1731
|
type: Schema15.Literal("queue")
|
|
1708
1732
|
}));
|
|
@@ -1729,12 +1753,12 @@ var QueueComponent = ({ shape }) => {
|
|
|
1729
1753
|
status: `${items.length} items`,
|
|
1730
1754
|
onAction: handleAction
|
|
1731
1755
|
}, /* @__PURE__ */ React16.createElement("div", {
|
|
1732
|
-
className: "flex flex-col
|
|
1756
|
+
className: "flex flex-col is-full overflow-y-auto divide-y divide-separator"
|
|
1733
1757
|
}, [
|
|
1734
1758
|
...items
|
|
1735
1759
|
].map((item, i) => /* @__PURE__ */ React16.createElement(QueueItem, {
|
|
1736
1760
|
key: i,
|
|
1737
|
-
classNames: "p-1
|
|
1761
|
+
classNames: "p-1 pli-2",
|
|
1738
1762
|
item
|
|
1739
1763
|
}))));
|
|
1740
1764
|
} finally {
|
|
@@ -1746,11 +1770,11 @@ var QueueItem = ({ classNames, item }) => {
|
|
|
1746
1770
|
try {
|
|
1747
1771
|
if (typeof item !== "object") {
|
|
1748
1772
|
return /* @__PURE__ */ React16.createElement("div", {
|
|
1749
|
-
className:
|
|
1773
|
+
className: mx2(classNames, "whitespace-pre-wrap")
|
|
1750
1774
|
}, item);
|
|
1751
1775
|
}
|
|
1752
1776
|
return /* @__PURE__ */ React16.createElement("div", {
|
|
1753
|
-
className:
|
|
1777
|
+
className: mx2("grid grid-cols-[80px,1fr]", classNames)
|
|
1754
1778
|
}, Object.entries(item).map(([key, value]) => /* @__PURE__ */ React16.createElement(Fragment, {
|
|
1755
1779
|
key
|
|
1756
1780
|
}, /* @__PURE__ */ React16.createElement("div", {
|
|
@@ -1772,12 +1796,11 @@ var queueShape = {
|
|
|
1772
1796
|
|
|
1773
1797
|
// src/shapes/RNG.tsx
|
|
1774
1798
|
import { useSignals as _useSignals16 } from "@preact-signals/safe-react/tracking";
|
|
1775
|
-
import
|
|
1799
|
+
import * as Schema16 from "effect/Schema";
|
|
1776
1800
|
import React17, { useEffect as useEffect5, useState as useState7 } from "react";
|
|
1777
1801
|
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT5 } from "@dxos/conductor";
|
|
1778
1802
|
import { Icon as Icon4 } from "@dxos/react-ui";
|
|
1779
1803
|
import { createAnchorMap as createAnchorMap7 } from "@dxos/react-ui-canvas-editor";
|
|
1780
|
-
import { mx as mx4 } from "@dxos/react-ui-theme";
|
|
1781
1804
|
var RandomShape = Schema16.extend(ComputeShape, Schema16.Struct({
|
|
1782
1805
|
type: Schema16.Literal("rng"),
|
|
1783
1806
|
min: Schema16.optional(Schema16.Number),
|
|
@@ -1830,7 +1853,7 @@ var RandomComponent = ({ shape }) => {
|
|
|
1830
1853
|
className: "flex grow items-center justify-center"
|
|
1831
1854
|
}, /* @__PURE__ */ React17.createElement(Icon4, {
|
|
1832
1855
|
icon,
|
|
1833
|
-
classNames:
|
|
1856
|
+
classNames: spin && "animate-[spin_1s]",
|
|
1834
1857
|
size: 10,
|
|
1835
1858
|
onClick: handleClick
|
|
1836
1859
|
}));
|
|
@@ -1854,11 +1877,11 @@ var randomShape = {
|
|
|
1854
1877
|
|
|
1855
1878
|
// src/shapes/Scope.tsx
|
|
1856
1879
|
import { useSignals as _useSignals17 } from "@preact-signals/safe-react/tracking";
|
|
1857
|
-
import
|
|
1880
|
+
import * as Schema17 from "effect/Schema";
|
|
1858
1881
|
import React18 from "react";
|
|
1859
1882
|
import { DEFAULT_INPUT as DEFAULT_INPUT5 } from "@dxos/conductor";
|
|
1860
1883
|
import { createAnchorMap as createAnchorMap8 } from "@dxos/react-ui-canvas-editor";
|
|
1861
|
-
import {
|
|
1884
|
+
import { Chaos, shaderPresets, useAudioStream } from "@dxos/react-ui-sfx";
|
|
1862
1885
|
var ScopeShape = Schema17.extend(ComputeShape, Schema17.Struct({
|
|
1863
1886
|
type: Schema17.Literal("scope")
|
|
1864
1887
|
}));
|
|
@@ -1879,7 +1902,7 @@ var ScopeComponent = ({ shape }) => {
|
|
|
1879
1902
|
const active = input?.type === "executed" ? input.value : false;
|
|
1880
1903
|
const { getAverage } = useAudioStream(active);
|
|
1881
1904
|
return /* @__PURE__ */ React18.createElement("div", {
|
|
1882
|
-
className: "flex
|
|
1905
|
+
className: "flex is-full justify-center items-center bg-black"
|
|
1883
1906
|
}, /* @__PURE__ */ React18.createElement(Chaos, {
|
|
1884
1907
|
active,
|
|
1885
1908
|
getValue: getAverage,
|
|
@@ -1908,9 +1931,9 @@ var scopeShape = {
|
|
|
1908
1931
|
|
|
1909
1932
|
// src/shapes/Surface.tsx
|
|
1910
1933
|
import { useSignals as _useSignals18 } from "@preact-signals/safe-react/tracking";
|
|
1911
|
-
import
|
|
1934
|
+
import * as Schema18 from "effect/Schema";
|
|
1912
1935
|
import React19 from "react";
|
|
1913
|
-
import { Surface } from "@dxos/app-framework";
|
|
1936
|
+
import { Surface } from "@dxos/app-framework/react";
|
|
1914
1937
|
import { DEFAULT_INPUT as DEFAULT_INPUT6 } from "@dxos/conductor";
|
|
1915
1938
|
import { createAnchorMap as createAnchorMap9 } from "@dxos/react-ui-canvas-editor";
|
|
1916
1939
|
var SurfaceShape = Schema18.extend(ComputeShape, Schema18.Struct({
|
|
@@ -1939,7 +1962,7 @@ var SurfaceComponent = ({ shape }) => {
|
|
|
1939
1962
|
shape,
|
|
1940
1963
|
onAction: handleAction
|
|
1941
1964
|
}, value !== null && /* @__PURE__ */ React19.createElement(Surface, {
|
|
1942
|
-
role: "
|
|
1965
|
+
role: "card--extrinsic",
|
|
1943
1966
|
data: {
|
|
1944
1967
|
value
|
|
1945
1968
|
},
|
|
@@ -1966,7 +1989,7 @@ var surfaceShape = {
|
|
|
1966
1989
|
|
|
1967
1990
|
// src/shapes/Switch.tsx
|
|
1968
1991
|
import { useSignals as _useSignals19 } from "@preact-signals/safe-react/tracking";
|
|
1969
|
-
import
|
|
1992
|
+
import * as Schema19 from "effect/Schema";
|
|
1970
1993
|
import React20, { useEffect as useEffect6, useState as useState8 } from "react";
|
|
1971
1994
|
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT6 } from "@dxos/conductor";
|
|
1972
1995
|
import { Input as Input2 } from "@dxos/react-ui";
|
|
@@ -1993,7 +2016,7 @@ var SwitchComponent = ({ shape }) => {
|
|
|
1993
2016
|
value
|
|
1994
2017
|
]);
|
|
1995
2018
|
return /* @__PURE__ */ React20.createElement("div", {
|
|
1996
|
-
className: "flex
|
|
2019
|
+
className: "flex is-full justify-center items-center",
|
|
1997
2020
|
onClick: (ev) => ev.stopPropagation()
|
|
1998
2021
|
}, /* @__PURE__ */ React20.createElement(Input2.Root, null, /* @__PURE__ */ React20.createElement(Input2.Switch, {
|
|
1999
2022
|
checked: value,
|
|
@@ -2019,12 +2042,12 @@ var switchShape = {
|
|
|
2019
2042
|
|
|
2020
2043
|
// src/shapes/Table.tsx
|
|
2021
2044
|
import { useSignals as _useSignals20 } from "@preact-signals/safe-react/tracking";
|
|
2022
|
-
import
|
|
2045
|
+
import * as Schema20 from "effect/Schema";
|
|
2023
2046
|
import React21 from "react";
|
|
2024
|
-
import { Message } from "@dxos/ai";
|
|
2025
2047
|
import { createInputSchema, createOutputSchema } from "@dxos/conductor";
|
|
2026
|
-
|
|
2027
|
-
var
|
|
2048
|
+
import { Message } from "@dxos/types";
|
|
2049
|
+
var InputSchema = createInputSchema(Message.Message);
|
|
2050
|
+
var OutputSchema = createOutputSchema(Schema20.mutable(Schema20.Array(Message.Message)));
|
|
2028
2051
|
var TableShape = Schema20.extend(ComputeShape, Schema20.Struct({
|
|
2029
2052
|
type: Schema20.Literal("table")
|
|
2030
2053
|
}));
|
|
@@ -2058,10 +2081,10 @@ var tableShape = {
|
|
|
2058
2081
|
|
|
2059
2082
|
// src/shapes/Template.tsx
|
|
2060
2083
|
import { useSignals as _useSignals21 } from "@preact-signals/safe-react/tracking";
|
|
2061
|
-
import
|
|
2084
|
+
import * as Schema21 from "effect/Schema";
|
|
2062
2085
|
import React22, { useRef as useRef5 } from "react";
|
|
2063
|
-
import { ComputeValueType as ComputeValueType3,
|
|
2064
|
-
import { toJsonSchema as toJsonSchema2 } from "@dxos/echo
|
|
2086
|
+
import { ComputeValueType as ComputeValueType3, TemplateOutput, VoidInput as VoidInput2, getTemplateInputSchema as getTemplateInputSchema2 } from "@dxos/conductor";
|
|
2087
|
+
import { toJsonSchema as toJsonSchema2 } from "@dxos/echo/internal";
|
|
2065
2088
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
2066
2089
|
import { TextBox as TextBox4 } from "@dxos/react-ui-canvas-editor";
|
|
2067
2090
|
var __dxlog_file6 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/Template.tsx";
|
|
@@ -2085,7 +2108,7 @@ var TextInputComponent3 = ({ shape, title, ...props }) => {
|
|
|
2085
2108
|
const handleTypeChange = (newType) => {
|
|
2086
2109
|
invariant5(Schema21.is(ComputeValueType3)(newType), "Invalid type", {
|
|
2087
2110
|
F: __dxlog_file6,
|
|
2088
|
-
L:
|
|
2111
|
+
L: 59,
|
|
2089
2112
|
S: void 0,
|
|
2090
2113
|
A: [
|
|
2091
2114
|
"Schema.is(ComputeValueType)(newType)",
|
|
@@ -2137,7 +2160,7 @@ var templateShape = {
|
|
|
2137
2160
|
|
|
2138
2161
|
// src/shapes/Text.tsx
|
|
2139
2162
|
import { useSignals as _useSignals22 } from "@preact-signals/safe-react/tracking";
|
|
2140
|
-
import
|
|
2163
|
+
import * as Schema22 from "effect/Schema";
|
|
2141
2164
|
import React23 from "react";
|
|
2142
2165
|
import { DEFAULT_INPUT as DEFAULT_INPUT7 } from "@dxos/conductor";
|
|
2143
2166
|
import { TextBox as TextBox5 } from "@dxos/react-ui-canvas-editor";
|
|
@@ -2191,13 +2214,13 @@ var textShape = {
|
|
|
2191
2214
|
|
|
2192
2215
|
// src/shapes/Thread.tsx
|
|
2193
2216
|
import { useSignals as _useSignals23 } from "@preact-signals/safe-react/tracking";
|
|
2194
|
-
import
|
|
2217
|
+
import * as Schema23 from "effect/Schema";
|
|
2195
2218
|
import React24, { useEffect as useEffect7, useRef as useRef6 } from "react";
|
|
2196
|
-
import { Message as Message2 } from "@dxos/ai";
|
|
2197
2219
|
import { createInputSchema as createInputSchema2, createOutputSchema as createOutputSchema2 } from "@dxos/conductor";
|
|
2198
|
-
import { mx as
|
|
2199
|
-
|
|
2200
|
-
var
|
|
2220
|
+
import { mx as mx3 } from "@dxos/react-ui-theme";
|
|
2221
|
+
import { Message as Message2 } from "@dxos/types";
|
|
2222
|
+
var InputSchema2 = createInputSchema2(Message2.Message);
|
|
2223
|
+
var OutputSchema2 = createOutputSchema2(Schema23.mutable(Schema23.Array(Message2.Message)));
|
|
2201
2224
|
var ThreadShape = Schema23.extend(ComputeShape, Schema23.Struct({
|
|
2202
2225
|
type: Schema23.Literal("thread")
|
|
2203
2226
|
}));
|
|
@@ -2225,7 +2248,7 @@ var ThreadComponent = ({ shape }) => {
|
|
|
2225
2248
|
shape
|
|
2226
2249
|
}, /* @__PURE__ */ React24.createElement("div", {
|
|
2227
2250
|
ref: scrollRef,
|
|
2228
|
-
className: "flex flex-col
|
|
2251
|
+
className: "flex flex-col is-full overflow-y-auto gap-2 p-2"
|
|
2229
2252
|
}, [
|
|
2230
2253
|
...items
|
|
2231
2254
|
].map((item, i) => /* @__PURE__ */ React24.createElement(ThreadItem, {
|
|
@@ -2241,14 +2264,14 @@ var ThreadItem = ({ classNames, item }) => {
|
|
|
2241
2264
|
try {
|
|
2242
2265
|
if (typeof item !== "object") {
|
|
2243
2266
|
return /* @__PURE__ */ React24.createElement("div", {
|
|
2244
|
-
className:
|
|
2267
|
+
className: mx3(classNames)
|
|
2245
2268
|
}, item);
|
|
2246
2269
|
}
|
|
2247
2270
|
const { role, message } = item;
|
|
2248
2271
|
return /* @__PURE__ */ React24.createElement("div", {
|
|
2249
|
-
className:
|
|
2272
|
+
className: mx3("flex", classNames, role === "user" && "justify-end")
|
|
2250
2273
|
}, /* @__PURE__ */ React24.createElement("div", {
|
|
2251
|
-
className:
|
|
2274
|
+
className: mx3("block rounded-md p-1 pli-2 text-sm", role === "user" ? "bg-blue-100 dark:bg-blue-800" : role === "system" ? "bg-red-100, dark:bg-red-800" : "whitespace-pre-wrap bg-neutral-50 dark:bg-neutral-800")
|
|
2252
2275
|
}, message));
|
|
2253
2276
|
} finally {
|
|
2254
2277
|
_effect.f();
|
|
@@ -2266,7 +2289,7 @@ var threadShape = {
|
|
|
2266
2289
|
|
|
2267
2290
|
// src/shapes/TextToImage.tsx
|
|
2268
2291
|
import { useSignals as _useSignals24 } from "@preact-signals/safe-react/tracking";
|
|
2269
|
-
import
|
|
2292
|
+
import * as Schema24 from "effect/Schema";
|
|
2270
2293
|
import React25 from "react";
|
|
2271
2294
|
import { createAnchorMap as createAnchorMap12 } from "@dxos/react-ui-canvas-editor";
|
|
2272
2295
|
var TextToImageShape = Schema24.extend(ComputeShape, Schema24.Struct({
|
|
@@ -2306,20 +2329,21 @@ var textToImageShape = {
|
|
|
2306
2329
|
|
|
2307
2330
|
// src/shapes/Trigger.tsx
|
|
2308
2331
|
import { useSignals as _useSignals25 } from "@preact-signals/safe-react/tracking";
|
|
2309
|
-
import
|
|
2332
|
+
import * as Schema25 from "effect/Schema";
|
|
2310
2333
|
import React26, { useEffect as useEffect8 } from "react";
|
|
2311
2334
|
import { VoidInput as VoidInput3 } from "@dxos/conductor";
|
|
2312
|
-
import {
|
|
2313
|
-
import {
|
|
2335
|
+
import { Filter as Filter2, Query } from "@dxos/echo";
|
|
2336
|
+
import { ObjectId as ObjectId4, Ref as Ref3 } from "@dxos/echo/internal";
|
|
2337
|
+
import { Trigger, TriggerEvent } from "@dxos/functions";
|
|
2314
2338
|
import { DXN, SpaceId } from "@dxos/keys";
|
|
2315
|
-
import {
|
|
2339
|
+
import { useSpace } from "@dxos/react-client/echo";
|
|
2316
2340
|
import { Select as Select2 } from "@dxos/react-ui";
|
|
2317
2341
|
var TriggerShape = Schema25.extend(ComputeShape, Schema25.Struct({
|
|
2318
2342
|
type: Schema25.Literal("trigger"),
|
|
2319
|
-
functionTrigger: Schema25.optional(Ref3(
|
|
2343
|
+
functionTrigger: Schema25.optional(Ref3(Trigger.Trigger))
|
|
2320
2344
|
}));
|
|
2321
2345
|
var createTrigger = (props) => {
|
|
2322
|
-
const functionTrigger =
|
|
2346
|
+
const functionTrigger = Trigger.make({
|
|
2323
2347
|
enabled: true,
|
|
2324
2348
|
spec: createTriggerSpec(props)
|
|
2325
2349
|
});
|
|
@@ -2328,7 +2352,7 @@ var createTrigger = (props) => {
|
|
|
2328
2352
|
functionTrigger: Ref3.make(functionTrigger),
|
|
2329
2353
|
size: {
|
|
2330
2354
|
width: 192,
|
|
2331
|
-
height: getHeight(
|
|
2355
|
+
height: getHeight(TriggerEvent.EmailEvent)
|
|
2332
2356
|
},
|
|
2333
2357
|
...props
|
|
2334
2358
|
});
|
|
@@ -2341,7 +2365,7 @@ var TriggerComponent = ({ shape }) => {
|
|
|
2341
2365
|
useEffect8(() => {
|
|
2342
2366
|
if (functionTrigger && !functionTrigger.spec) {
|
|
2343
2367
|
functionTrigger.spec = createTriggerSpec({
|
|
2344
|
-
triggerKind:
|
|
2368
|
+
triggerKind: "email",
|
|
2345
2369
|
spaceId: space?.id
|
|
2346
2370
|
});
|
|
2347
2371
|
}
|
|
@@ -2350,7 +2374,7 @@ var TriggerComponent = ({ shape }) => {
|
|
|
2350
2374
|
functionTrigger?.spec
|
|
2351
2375
|
]);
|
|
2352
2376
|
useEffect8(() => {
|
|
2353
|
-
shape.size.height = getHeight(getOutputSchema(functionTrigger?.spec?.kind ??
|
|
2377
|
+
shape.size.height = getHeight(getOutputSchema(functionTrigger?.spec?.kind ?? "email"));
|
|
2354
2378
|
}, [
|
|
2355
2379
|
functionTrigger?.spec?.kind
|
|
2356
2380
|
]);
|
|
@@ -2386,8 +2410,8 @@ var TriggerKindSelect = ({ value, onValueChange }) => {
|
|
|
2386
2410
|
onValueChange
|
|
2387
2411
|
}, /* @__PURE__ */ React26.createElement(Select2.TriggerButton, {
|
|
2388
2412
|
variant: "ghost",
|
|
2389
|
-
classNames: "
|
|
2390
|
-
}), /* @__PURE__ */ React26.createElement(Select2.Portal, null, /* @__PURE__ */ React26.createElement(Select2.Content, null, /* @__PURE__ */ React26.createElement(Select2.ScrollUpButton, null), /* @__PURE__ */ React26.createElement(Select2.Viewport, null,
|
|
2413
|
+
classNames: "is-full !pli-0"
|
|
2414
|
+
}), /* @__PURE__ */ React26.createElement(Select2.Portal, null, /* @__PURE__ */ React26.createElement(Select2.Content, null, /* @__PURE__ */ React26.createElement(Select2.ScrollUpButton, null), /* @__PURE__ */ React26.createElement(Select2.Viewport, null, Trigger.Kinds.map((kind) => /* @__PURE__ */ React26.createElement(Select2.Option, {
|
|
2391
2415
|
key: kind,
|
|
2392
2416
|
value: kind
|
|
2393
2417
|
}, kind))), /* @__PURE__ */ React26.createElement(Select2.ScrollDownButton, null), /* @__PURE__ */ React26.createElement(Select2.Arrow, null))));
|
|
@@ -2396,35 +2420,37 @@ var TriggerKindSelect = ({ value, onValueChange }) => {
|
|
|
2396
2420
|
}
|
|
2397
2421
|
};
|
|
2398
2422
|
var createTriggerSpec = (props) => {
|
|
2399
|
-
const kind = props.triggerKind ??
|
|
2423
|
+
const kind = props.triggerKind ?? "email";
|
|
2400
2424
|
switch (kind) {
|
|
2401
|
-
case
|
|
2425
|
+
case "timer":
|
|
2402
2426
|
return {
|
|
2403
|
-
kind:
|
|
2427
|
+
kind: "timer",
|
|
2404
2428
|
cron: "*/10 * * * * *"
|
|
2405
2429
|
};
|
|
2406
|
-
case
|
|
2430
|
+
case "webhook":
|
|
2407
2431
|
return {
|
|
2408
|
-
kind:
|
|
2432
|
+
kind: "webhook",
|
|
2409
2433
|
method: "POST"
|
|
2410
2434
|
};
|
|
2411
|
-
case
|
|
2435
|
+
case "subscription":
|
|
2412
2436
|
return {
|
|
2413
|
-
kind:
|
|
2414
|
-
|
|
2437
|
+
kind: "subscription",
|
|
2438
|
+
query: {
|
|
2439
|
+
ast: Query.select(Filter2.nothing()).ast
|
|
2440
|
+
}
|
|
2415
2441
|
};
|
|
2416
|
-
case
|
|
2442
|
+
case "email":
|
|
2417
2443
|
return {
|
|
2418
|
-
kind:
|
|
2444
|
+
kind: "email"
|
|
2419
2445
|
};
|
|
2420
|
-
case
|
|
2446
|
+
case "queue": {
|
|
2421
2447
|
const dxn = new DXN(DXN.kind.QUEUE, [
|
|
2422
2448
|
"data",
|
|
2423
2449
|
props.spaceId ?? SpaceId.random(),
|
|
2424
2450
|
ObjectId4.random()
|
|
2425
2451
|
]).toString();
|
|
2426
2452
|
return {
|
|
2427
|
-
kind:
|
|
2453
|
+
kind: "queue",
|
|
2428
2454
|
queue: dxn
|
|
2429
2455
|
};
|
|
2430
2456
|
}
|
|
@@ -2432,11 +2458,11 @@ var createTriggerSpec = (props) => {
|
|
|
2432
2458
|
};
|
|
2433
2459
|
var getOutputSchema = (kind) => {
|
|
2434
2460
|
const kindToSchema = {
|
|
2435
|
-
[
|
|
2436
|
-
[
|
|
2437
|
-
[
|
|
2438
|
-
[
|
|
2439
|
-
[
|
|
2461
|
+
["email"]: TriggerEvent.EmailEvent,
|
|
2462
|
+
["subscription"]: TriggerEvent.SubscriptionEvent,
|
|
2463
|
+
["timer"]: TriggerEvent.TimerEvent,
|
|
2464
|
+
["webhook"]: TriggerEvent.WebhookEvent,
|
|
2465
|
+
["queue"]: TriggerEvent.QueueEvent
|
|
2440
2466
|
};
|
|
2441
2467
|
return kindToSchema[kind];
|
|
2442
2468
|
};
|
|
@@ -2446,12 +2472,12 @@ var triggerShape = {
|
|
|
2446
2472
|
icon: "ph--lightning--regular",
|
|
2447
2473
|
component: TriggerComponent,
|
|
2448
2474
|
createShape: createTrigger,
|
|
2449
|
-
getAnchors: (shape) => createFunctionAnchors(shape, VoidInput3, getOutputSchema(shape.functionTrigger?.target?.spec?.kind ??
|
|
2475
|
+
getAnchors: (shape) => createFunctionAnchors(shape, VoidInput3, getOutputSchema(shape.functionTrigger?.target?.spec?.kind ?? "email"))
|
|
2450
2476
|
};
|
|
2451
2477
|
|
|
2452
2478
|
// src/shapes/GptRealtime.tsx
|
|
2453
2479
|
import { useSignals as _useSignals26 } from "@preact-signals/safe-react/tracking";
|
|
2454
|
-
import
|
|
2480
|
+
import * as Schema26 from "effect/Schema";
|
|
2455
2481
|
import React27, { useState as useState9 } from "react";
|
|
2456
2482
|
import { log as log2 } from "@dxos/log";
|
|
2457
2483
|
import { useConfig } from "@dxos/react-client";
|
|
@@ -2558,7 +2584,7 @@ var GptRealtimeComponent = ({ shape }) => {
|
|
|
2558
2584
|
}
|
|
2559
2585
|
};
|
|
2560
2586
|
return /* @__PURE__ */ React27.createElement("div", {
|
|
2561
|
-
className: "flex
|
|
2587
|
+
className: "flex is-full justify-center items-center"
|
|
2562
2588
|
}, /* @__PURE__ */ React27.createElement(Icon5, {
|
|
2563
2589
|
icon: isReady ? "ph--waveform--regular" : isLive ? "ph--pulse--regular" : "ph--play--regular",
|
|
2564
2590
|
size: 16,
|
|
@@ -2647,9 +2673,10 @@ var computeShapes = [
|
|
|
2647
2673
|
|
|
2648
2674
|
// src/compute-layout.ts
|
|
2649
2675
|
import { DefaultInput, DefaultOutput as DefaultOutput2 } from "@dxos/conductor";
|
|
2650
|
-
import { toEffectSchema } from "@dxos/echo
|
|
2676
|
+
import { toEffectSchema } from "@dxos/echo/internal";
|
|
2651
2677
|
import { ShapeLayout } from "@dxos/react-ui-canvas-editor";
|
|
2652
2678
|
var ComputeShapeLayout = class extends ShapeLayout {
|
|
2679
|
+
_controller;
|
|
2653
2680
|
constructor(_controller, registry2) {
|
|
2654
2681
|
super(registry2), this._controller = _controller;
|
|
2655
2682
|
}
|