@dxos/react-ui-canvas-compute 0.8.3 → 0.8.4-main.1068cf700f
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 +938 -1074
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +938 -1074
- 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 +33 -5
- package/dist/types/src/compute.stories.d.ts.map +1 -1
- package/dist/types/src/graph/controller.d.ts +40 -27
- 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 +2 -2
- 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 +6 -34
- package/dist/types/src/shapes/Trigger.d.ts.map +1 -1
- package/dist/types/src/shapes/common/Box.d.ts +4 -4
- package/dist/types/src/shapes/common/Box.d.ts.map +1 -1
- package/dist/types/src/shapes/common/FunctionBody.d.ts +3 -3
- 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 +18 -24
- package/dist/types/src/testing/circuits.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +60 -52
- package/src/compute-layout.ts +1 -1
- package/src/compute.stories.tsx +84 -139
- package/src/graph/controller.ts +121 -80
- package/src/graph/node-defs.ts +7 -6
- package/src/hooks/useComputeGraphController.ts +2 -2
- package/src/hooks/useComputeNodeState.ts +10 -7
- package/src/hooks/useGraphMonitor.ts +11 -10
- package/src/json.test.ts +4 -4
- package/src/registry.ts +2 -2
- package/src/schema.test.ts +13 -13
- 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 +19 -16
- package/src/shapes/Gpt.tsx +13 -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 +18 -11
- 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 +7 -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 +22 -15
- package/src/shapes/Trigger.tsx +51 -58
- package/src/shapes/common/Box.tsx +10 -11
- package/src/shapes/common/FunctionBody.tsx +7 -6
- package/src/shapes/common/TypeSelect.tsx +1 -1
- package/src/shapes/defs.ts +5 -4
- package/src/testing/circuits.ts +8 -17
- package/dist/lib/node/index.cjs +0 -2896
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
|
@@ -1,96 +1,27 @@
|
|
|
1
1
|
import "@dxos/node-std/globals";
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
import
|
|
3
|
+
// src/graph/controller.ts
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Either from "effect/Either";
|
|
6
|
+
import * as Exit from "effect/Exit";
|
|
7
|
+
import * as Layer from "effect/Layer";
|
|
8
|
+
import * as Scope from "effect/Scope";
|
|
5
9
|
import { Event, synchronized } from "@dxos/async";
|
|
6
|
-
import { GraphExecutor,
|
|
10
|
+
import { GraphExecutor, ValueBag, isNotExecuted } from "@dxos/conductor";
|
|
7
11
|
import { Resource } from "@dxos/context";
|
|
12
|
+
import { unwrapExit } from "@dxos/effect";
|
|
13
|
+
import { ComputeEventLogger, TracingService } from "@dxos/functions";
|
|
8
14
|
import { log } from "@dxos/log";
|
|
9
15
|
|
|
10
|
-
//
|
|
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 = "/home/runner/work/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
|
-
["database"]: () => createNode("database"),
|
|
52
|
-
["gpt"]: () => createNode("gpt"),
|
|
53
|
-
["gpt-realtime"]: () => createNode("gpt-realtime"),
|
|
54
|
-
["if"]: () => createNode("if"),
|
|
55
|
-
["if-else"]: () => createNode("if-else"),
|
|
56
|
-
["function"]: () => createNode("function"),
|
|
57
|
-
["json"]: () => createNode("json"),
|
|
58
|
-
["json-transform"]: () => createNode("json-transform"),
|
|
59
|
-
["not"]: () => createNode("not"),
|
|
60
|
-
["or"]: () => createNode("or"),
|
|
61
|
-
["queue"]: () => createNode("queue"),
|
|
62
|
-
["rng"]: () => createNode("rng"),
|
|
63
|
-
["reducer"]: () => createNode("reducer"),
|
|
64
|
-
["scope"]: () => createNode("scope"),
|
|
65
|
-
["surface"]: () => createNode("surface"),
|
|
66
|
-
["switch"]: () => createNode("switch"),
|
|
67
|
-
["template"]: (shape) => {
|
|
68
|
-
const node = createNode("template", {
|
|
69
|
-
valueType: shape.valueType,
|
|
70
|
-
value: shape.text
|
|
71
|
-
});
|
|
72
|
-
node.inputSchema = toJsonSchema(getTemplateInputSchema(node));
|
|
73
|
-
return node;
|
|
74
|
-
},
|
|
75
|
-
["text"]: () => createNode("text"),
|
|
76
|
-
["thread"]: () => createNode("thread"),
|
|
77
|
-
["trigger"]: () => createNode(NODE_INPUT)
|
|
78
|
-
};
|
|
79
|
-
var createNode = (type, props) => ({
|
|
80
|
-
id: ObjectId.random(),
|
|
81
|
-
type,
|
|
82
|
-
...props
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
// packages/ui/react-ui-canvas-compute/src/hooks/compute-context.ts
|
|
16
|
+
// src/hooks/compute-context.ts
|
|
86
17
|
import { createContext, useContext } from "react";
|
|
87
|
-
import { raise
|
|
18
|
+
import { raise } from "@dxos/debug";
|
|
88
19
|
var ComputeContext = createContext(null);
|
|
89
20
|
var useComputeContext = () => {
|
|
90
|
-
return useContext(ComputeContext) ??
|
|
21
|
+
return useContext(ComputeContext) ?? raise(new Error("Missing ComputeContext"));
|
|
91
22
|
};
|
|
92
23
|
|
|
93
|
-
//
|
|
24
|
+
// src/hooks/useComputeGraphController.ts
|
|
94
25
|
import { useEffect, useState } from "react";
|
|
95
26
|
var combine = (...cbs) => {
|
|
96
27
|
return () => {
|
|
@@ -140,16 +71,16 @@ var useComputeGraphController = ({ controller, graph, editorRef }) => {
|
|
|
140
71
|
]);
|
|
141
72
|
};
|
|
142
73
|
|
|
143
|
-
//
|
|
144
|
-
import
|
|
74
|
+
// src/hooks/useComputeNodeState.ts
|
|
75
|
+
import * as Schema from "effect/Schema";
|
|
145
76
|
import { useCallback, useEffect as useEffect2, useState as useState2 } from "react";
|
|
146
|
-
import { invariant
|
|
147
|
-
var
|
|
77
|
+
import { invariant } from "@dxos/invariant";
|
|
78
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/hooks/useComputeNodeState.ts";
|
|
148
79
|
var useComputeNodeState = (shape) => {
|
|
149
80
|
const { controller } = useComputeContext();
|
|
150
|
-
|
|
151
|
-
F:
|
|
152
|
-
L:
|
|
81
|
+
invariant(controller, void 0, {
|
|
82
|
+
F: __dxlog_file,
|
|
83
|
+
L: 34,
|
|
153
84
|
S: void 0,
|
|
154
85
|
A: [
|
|
155
86
|
"controller",
|
|
@@ -160,9 +91,9 @@ var useComputeNodeState = (shape) => {
|
|
|
160
91
|
useEffect2(() => {
|
|
161
92
|
let disposed = false;
|
|
162
93
|
queueMicrotask(async () => {
|
|
163
|
-
|
|
164
|
-
F:
|
|
165
|
-
L:
|
|
94
|
+
invariant(shape.node, "Node not specified", {
|
|
95
|
+
F: __dxlog_file,
|
|
96
|
+
L: 40,
|
|
166
97
|
S: void 0,
|
|
167
98
|
A: [
|
|
168
99
|
"shape.node",
|
|
@@ -214,29 +145,28 @@ var useComputeNodeState = (shape) => {
|
|
|
214
145
|
};
|
|
215
146
|
};
|
|
216
147
|
|
|
217
|
-
//
|
|
148
|
+
// src/hooks/useGraphMonitor.ts
|
|
218
149
|
import { useMemo } from "react";
|
|
219
150
|
import { ComputeGraphModel, DEFAULT_INPUT, DEFAULT_OUTPUT } from "@dxos/conductor";
|
|
220
|
-
import {
|
|
221
|
-
import { invariant as
|
|
222
|
-
import { getSpace } from "@dxos/react-client/echo";
|
|
151
|
+
import { Obj, Ref } from "@dxos/echo";
|
|
152
|
+
import { invariant as invariant2 } from "@dxos/invariant";
|
|
223
153
|
import { isNonNullable } from "@dxos/util";
|
|
224
|
-
var
|
|
154
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/hooks/useGraphMonitor.ts";
|
|
225
155
|
var mapEdge = (graph, { source, target, output = DEFAULT_OUTPUT, input = DEFAULT_INPUT }) => {
|
|
226
156
|
const sourceNode = graph.findNode(source);
|
|
227
157
|
const targetNode = graph.findNode(target);
|
|
228
|
-
|
|
229
|
-
F:
|
|
230
|
-
L:
|
|
158
|
+
invariant2(sourceNode?.node, void 0, {
|
|
159
|
+
F: __dxlog_file2,
|
|
160
|
+
L: 25,
|
|
231
161
|
S: void 0,
|
|
232
162
|
A: [
|
|
233
163
|
"sourceNode?.node",
|
|
234
164
|
""
|
|
235
165
|
]
|
|
236
166
|
});
|
|
237
|
-
|
|
238
|
-
F:
|
|
239
|
-
L:
|
|
167
|
+
invariant2(targetNode?.node, void 0, {
|
|
168
|
+
F: __dxlog_file2,
|
|
169
|
+
L: 26,
|
|
240
170
|
S: void 0,
|
|
241
171
|
A: [
|
|
242
172
|
"targetNode?.node",
|
|
@@ -244,7 +174,7 @@ var mapEdge = (graph, { source, target, output = DEFAULT_OUTPUT, input = DEFAULT
|
|
|
244
174
|
]
|
|
245
175
|
});
|
|
246
176
|
return {
|
|
247
|
-
id:
|
|
177
|
+
id: Obj.ID.random(),
|
|
248
178
|
source: sourceNode.node,
|
|
249
179
|
target: targetNode.node,
|
|
250
180
|
output,
|
|
@@ -258,9 +188,9 @@ var useGraphMonitor = (model) => {
|
|
|
258
188
|
if (!model) {
|
|
259
189
|
return;
|
|
260
190
|
}
|
|
261
|
-
|
|
262
|
-
F:
|
|
263
|
-
L:
|
|
191
|
+
invariant2(node.type, void 0, {
|
|
192
|
+
F: __dxlog_file2,
|
|
193
|
+
L: 51,
|
|
264
194
|
S: void 0,
|
|
265
195
|
A: [
|
|
266
196
|
"node.type",
|
|
@@ -316,58 +246,154 @@ var createComputeGraph = (graph) => {
|
|
|
316
246
|
};
|
|
317
247
|
var linkTriggerToCompute = (graph, computeNode, triggerData) => {
|
|
318
248
|
const functionTrigger = triggerData.functionTrigger?.target;
|
|
319
|
-
|
|
320
|
-
F:
|
|
321
|
-
L:
|
|
249
|
+
invariant2(functionTrigger, void 0, {
|
|
250
|
+
F: __dxlog_file2,
|
|
251
|
+
L: 114,
|
|
322
252
|
S: void 0,
|
|
323
253
|
A: [
|
|
324
254
|
"functionTrigger",
|
|
325
255
|
""
|
|
326
256
|
]
|
|
327
257
|
});
|
|
328
|
-
functionTrigger
|
|
329
|
-
|
|
258
|
+
Obj.change(functionTrigger, (t) => {
|
|
259
|
+
t.function = Ref.make(graph.root);
|
|
260
|
+
t.inputNodeId = computeNode.id;
|
|
261
|
+
});
|
|
330
262
|
};
|
|
331
263
|
var deleteTriggerObjects = (computeGraph, deleted) => {
|
|
332
|
-
const
|
|
333
|
-
if (!
|
|
264
|
+
const db = Obj.getDatabase(computeGraph.root);
|
|
265
|
+
if (!db) {
|
|
334
266
|
return;
|
|
335
267
|
}
|
|
336
268
|
for (const node of deleted.nodes) {
|
|
337
269
|
if (node.type === "trigger") {
|
|
338
270
|
const trigger = node;
|
|
339
|
-
|
|
271
|
+
db.remove(trigger.functionTrigger.target);
|
|
340
272
|
}
|
|
341
273
|
}
|
|
342
274
|
};
|
|
343
275
|
|
|
344
|
-
//
|
|
276
|
+
// src/graph/node-defs.ts
|
|
277
|
+
import { NODE_INPUT, NODE_OUTPUT, getTemplateInputSchema, registry } from "@dxos/conductor";
|
|
278
|
+
import { raise as raise2 } from "@dxos/debug";
|
|
279
|
+
import { JsonSchema, Obj as Obj2 } from "@dxos/echo";
|
|
280
|
+
import { invariant as invariant3 } from "@dxos/invariant";
|
|
281
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/graph/node-defs.ts";
|
|
282
|
+
var resolveComputeNode = async (node) => {
|
|
283
|
+
const impl = registry[node.type];
|
|
284
|
+
invariant3(impl, `Unknown node type: ${node.type}`, {
|
|
285
|
+
F: __dxlog_file3,
|
|
286
|
+
L: 22,
|
|
287
|
+
S: void 0,
|
|
288
|
+
A: [
|
|
289
|
+
"impl",
|
|
290
|
+
"`Unknown node type: ${node.type}`"
|
|
291
|
+
]
|
|
292
|
+
});
|
|
293
|
+
return impl;
|
|
294
|
+
};
|
|
295
|
+
var isValidComputeNode = (type) => {
|
|
296
|
+
return nodeFactory[type] !== void 0;
|
|
297
|
+
};
|
|
298
|
+
var createComputeNode = (shape) => {
|
|
299
|
+
const type = shape.type ?? raise2(new Error("Type not specified"));
|
|
300
|
+
const factory = nodeFactory[type] ?? raise2(new Error(`Unknown shape type: ${type}`));
|
|
301
|
+
return factory(shape);
|
|
302
|
+
};
|
|
303
|
+
var nodeFactory = {
|
|
304
|
+
// System.
|
|
305
|
+
[NODE_INPUT]: () => createNode(NODE_INPUT),
|
|
306
|
+
[NODE_OUTPUT]: () => createNode(NODE_OUTPUT),
|
|
307
|
+
// Extensions.
|
|
308
|
+
["text-to-image"]: () => createNode("text-to-image"),
|
|
309
|
+
["and"]: () => createNode("and"),
|
|
310
|
+
["append"]: () => createNode("append"),
|
|
311
|
+
["audio"]: () => createNode("audio"),
|
|
312
|
+
["beacon"]: () => createNode("beacon"),
|
|
313
|
+
["chat"]: () => createNode("chat"),
|
|
314
|
+
["constant"]: (shape) => createNode("constant", {
|
|
315
|
+
value: shape.value
|
|
316
|
+
}),
|
|
317
|
+
["make-queue"]: () => createNode("make-queue"),
|
|
318
|
+
["database"]: () => createNode("database"),
|
|
319
|
+
["gpt"]: () => createNode("gpt"),
|
|
320
|
+
["gpt-realtime"]: () => createNode("gpt-realtime"),
|
|
321
|
+
["if"]: () => createNode("if"),
|
|
322
|
+
["if-else"]: () => createNode("if-else"),
|
|
323
|
+
["function"]: () => createNode("function"),
|
|
324
|
+
["json"]: () => createNode("json"),
|
|
325
|
+
["json-transform"]: () => createNode("json-transform"),
|
|
326
|
+
["not"]: () => createNode("not"),
|
|
327
|
+
["or"]: () => createNode("or"),
|
|
328
|
+
["queue"]: () => createNode("queue"),
|
|
329
|
+
["rng"]: () => createNode("rng"),
|
|
330
|
+
["reducer"]: () => createNode("reducer"),
|
|
331
|
+
["scope"]: () => createNode("scope"),
|
|
332
|
+
["surface"]: () => createNode("surface"),
|
|
333
|
+
["switch"]: () => createNode("switch"),
|
|
334
|
+
["template"]: (shape) => {
|
|
335
|
+
const node = createNode("template", {
|
|
336
|
+
valueType: shape.valueType,
|
|
337
|
+
value: shape.text
|
|
338
|
+
});
|
|
339
|
+
node.inputSchema = JsonSchema.toJsonSchema(getTemplateInputSchema(node));
|
|
340
|
+
return node;
|
|
341
|
+
},
|
|
342
|
+
["text"]: () => createNode("text"),
|
|
343
|
+
["thread"]: () => createNode("thread"),
|
|
344
|
+
["trigger"]: () => createNode(NODE_INPUT)
|
|
345
|
+
};
|
|
346
|
+
var createNode = (type, props) => ({
|
|
347
|
+
id: Obj2.ID.random(),
|
|
348
|
+
type,
|
|
349
|
+
...props
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
// src/graph/controller.ts
|
|
345
353
|
function _ts_decorate(decorators, target, key, desc) {
|
|
346
354
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
347
355
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
348
356
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
349
357
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
350
358
|
}
|
|
351
|
-
var __dxlog_file4 = "/
|
|
359
|
+
var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/graph/controller.ts";
|
|
352
360
|
var InvalidStateError = Error;
|
|
353
361
|
var AUTO_TRIGGER_NODES = [
|
|
354
362
|
"chat",
|
|
355
363
|
"switch",
|
|
356
364
|
"constant"
|
|
357
365
|
];
|
|
358
|
-
var createComputeGraphController = (graph,
|
|
366
|
+
var createComputeGraphController = (graph, computeRuntime) => {
|
|
359
367
|
const computeGraph = createComputeGraph(graph);
|
|
360
|
-
const controller = new ComputeGraphController(
|
|
368
|
+
const controller = new ComputeGraphController(computeRuntime, computeGraph);
|
|
361
369
|
return {
|
|
362
370
|
controller,
|
|
363
371
|
graph
|
|
364
372
|
};
|
|
365
373
|
};
|
|
366
374
|
var ComputeGraphController = class extends Resource {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
375
|
+
_computeRuntime;
|
|
376
|
+
_graph;
|
|
377
|
+
_executor = new GraphExecutor({
|
|
378
|
+
computeNodeResolver: (node) => resolveComputeNode(node)
|
|
379
|
+
});
|
|
380
|
+
_diagnostics = [];
|
|
381
|
+
/**
|
|
382
|
+
* Canvas force-sets outputs of those nodes.
|
|
383
|
+
*/
|
|
384
|
+
_forcedOutputs = {};
|
|
385
|
+
/**
|
|
386
|
+
* Runtime state of the execution graph.
|
|
387
|
+
*/
|
|
388
|
+
_runtimeStateInputs = {};
|
|
389
|
+
_runtimeStateOutputs = {};
|
|
390
|
+
// TODO(burdon): Remove? Make state reactive?
|
|
391
|
+
update = new Event();
|
|
392
|
+
/** Computed result. */
|
|
393
|
+
output = new Event();
|
|
394
|
+
events = new Event();
|
|
395
|
+
constructor(_computeRuntime, _graph) {
|
|
396
|
+
super(), this._computeRuntime = _computeRuntime, this._graph = _graph;
|
|
371
397
|
}
|
|
372
398
|
toJSON() {
|
|
373
399
|
return {
|
|
@@ -437,7 +463,7 @@ var ComputeGraphController = class extends Resource {
|
|
|
437
463
|
} catch (err) {
|
|
438
464
|
log.catch(err, void 0, {
|
|
439
465
|
F: __dxlog_file4,
|
|
440
|
-
L:
|
|
466
|
+
L: 229,
|
|
441
467
|
S: this,
|
|
442
468
|
C: (f, a) => f(...a)
|
|
443
469
|
});
|
|
@@ -459,12 +485,11 @@ var ComputeGraphController = class extends Resource {
|
|
|
459
485
|
for (const [nodeId2, outputs] of Object.entries(this._forcedOutputs)) {
|
|
460
486
|
executor.setOutputs(nodeId2, Effect.succeed(ValueBag.make(outputs)));
|
|
461
487
|
}
|
|
462
|
-
|
|
463
|
-
await Effect.runPromise(Effect.gen(this, function* () {
|
|
488
|
+
unwrapExit(await this._computeRuntime.runPromiseExit(Effect.gen(this, function* () {
|
|
464
489
|
const scope = yield* Scope.make();
|
|
465
490
|
const executable = yield* Effect.promise(() => resolveComputeNode(this._graph.getNode(nodeId)));
|
|
466
491
|
const computingOutputs = executable.exec != null;
|
|
467
|
-
const effect = (computingOutputs ? executor.computeOutputs(nodeId) : executor.computeInputs(nodeId)).pipe(Effect.withSpan("runGraph"), Scope.extend(scope), Effect.
|
|
492
|
+
const effect = (computingOutputs ? executor.computeOutputs(nodeId) : executor.computeInputs(nodeId)).pipe(Effect.withSpan("runGraph"), Scope.extend(scope), Effect.provide(ComputeEventLogger.layerFromTracing.pipe(Layer.provideMerge(TracingService.layerNoop))), Effect.flatMap(computeValueBag), Effect.withSpan("test"), Effect.tap((values) => {
|
|
468
493
|
for (const [key, value] of Object.entries(values)) {
|
|
469
494
|
if (computingOutputs) {
|
|
470
495
|
this._onOutputComputed(nodeId, key, value);
|
|
@@ -475,7 +500,7 @@ var ComputeGraphController = class extends Resource {
|
|
|
475
500
|
}));
|
|
476
501
|
yield* effect;
|
|
477
502
|
yield* Scope.close(scope, Exit.void);
|
|
478
|
-
}));
|
|
503
|
+
})));
|
|
479
504
|
this.update.emit();
|
|
480
505
|
}
|
|
481
506
|
/**
|
|
@@ -496,13 +521,13 @@ var ComputeGraphController = class extends Resource {
|
|
|
496
521
|
const allAffectedNodes = [
|
|
497
522
|
...new Set(triggerNodes.flatMap((node) => executor.getAllDependantNodes(node.id)))
|
|
498
523
|
];
|
|
499
|
-
await
|
|
524
|
+
unwrapExit(await this._computeRuntime.runPromiseExit(Effect.gen(this, function* () {
|
|
500
525
|
const scope = yield* Scope.make();
|
|
501
526
|
const tasks = [];
|
|
502
527
|
for (const node of allAffectedNodes) {
|
|
503
528
|
const executable = yield* Effect.promise(() => resolveComputeNode(this._graph.getNode(node)));
|
|
504
529
|
const computingOutputs = executable.exec != null;
|
|
505
|
-
const effect = (computingOutputs ? executor.computeOutputs(node) : executor.computeInputs(node)).pipe(Effect.withSpan("runGraph"), Scope.extend(scope), Effect.flatMap(computeValueBag), Effect.provide(
|
|
530
|
+
const effect = (computingOutputs ? executor.computeOutputs(node) : executor.computeInputs(node)).pipe(Effect.withSpan("runGraph"), Scope.extend(scope), Effect.flatMap(computeValueBag), Effect.provide(ComputeEventLogger.layerFromTracing.pipe(Layer.provideMerge(TracingService.layerNoop))), Effect.withSpan("test"), Effect.tap((values) => {
|
|
506
531
|
for (const [key, value] of Object.entries(values)) {
|
|
507
532
|
if (computingOutputs) {
|
|
508
533
|
this._onOutputComputed(node, key, value);
|
|
@@ -515,7 +540,7 @@ var ComputeGraphController = class extends Resource {
|
|
|
515
540
|
}
|
|
516
541
|
yield* Effect.all(tasks);
|
|
517
542
|
yield* Scope.close(scope, Exit.void);
|
|
518
|
-
}));
|
|
543
|
+
})));
|
|
519
544
|
this.update.emit();
|
|
520
545
|
}
|
|
521
546
|
_createLogger() {
|
|
@@ -531,7 +556,7 @@ var ComputeGraphController = class extends Resource {
|
|
|
531
556
|
event
|
|
532
557
|
}, {
|
|
533
558
|
F: __dxlog_file4,
|
|
534
|
-
L:
|
|
559
|
+
L: 376,
|
|
535
560
|
S: this,
|
|
536
561
|
C: (f, a) => f(...a)
|
|
537
562
|
});
|
|
@@ -604,92 +629,86 @@ var computeValueBag = (bag) => {
|
|
|
604
629
|
})))).pipe(Effect.map((entries) => Object.fromEntries(entries)));
|
|
605
630
|
};
|
|
606
631
|
|
|
607
|
-
//
|
|
632
|
+
// src/registry.ts
|
|
608
633
|
import { noteShape } from "@dxos/react-ui-canvas-editor";
|
|
609
634
|
|
|
610
|
-
//
|
|
611
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
635
|
+
// src/shapes/common/Box.tsx
|
|
612
636
|
import React, { forwardRef } from "react";
|
|
613
637
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
614
638
|
import { Icon, IconButton } from "@dxos/react-ui";
|
|
615
639
|
import { useEditorContext, useShapeDef } from "@dxos/react-ui-canvas-editor";
|
|
616
|
-
import { mx } from "@dxos/
|
|
617
|
-
var __dxlog_file5 = "/
|
|
640
|
+
import { mx } from "@dxos/ui-theme";
|
|
641
|
+
var __dxlog_file5 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/common/Box.tsx";
|
|
618
642
|
var headerHeight = 32;
|
|
619
643
|
var footerHeight = 32;
|
|
620
644
|
var Box = /* @__PURE__ */ forwardRef(({ children, classNames, shape, title, status, open, onAction }, forwardedRef) => {
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
}
|
|
675
|
-
})));
|
|
676
|
-
} finally {
|
|
677
|
-
_effect.f();
|
|
678
|
-
}
|
|
645
|
+
invariant4(shape.type, void 0, {
|
|
646
|
+
F: __dxlog_file5,
|
|
647
|
+
L: 29,
|
|
648
|
+
S: void 0,
|
|
649
|
+
A: [
|
|
650
|
+
"shape.type",
|
|
651
|
+
""
|
|
652
|
+
]
|
|
653
|
+
});
|
|
654
|
+
const { icon, name, openable } = useShapeDef(shape.type) ?? {
|
|
655
|
+
icon: "ph--placeholder--regular"
|
|
656
|
+
};
|
|
657
|
+
const { debug } = useEditorContext();
|
|
658
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
659
|
+
ref: forwardedRef,
|
|
660
|
+
className: "flex flex-col bs-full is-full justify-between"
|
|
661
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
662
|
+
className: "flex shrink-0 is-full justify-between items-center bs-[32px] bg-hoverSurface"
|
|
663
|
+
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
664
|
+
icon,
|
|
665
|
+
classNames: "mx-2"
|
|
666
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
667
|
+
className: "grow text-sm truncate"
|
|
668
|
+
}, debug ? shape.type : name ?? shape.text ?? title), /* @__PURE__ */ React.createElement(IconButton, {
|
|
669
|
+
classNames: "p-1 text-green-500",
|
|
670
|
+
variant: "ghost",
|
|
671
|
+
icon: "ph--play--regular",
|
|
672
|
+
size: 4,
|
|
673
|
+
label: "run",
|
|
674
|
+
iconOnly: true,
|
|
675
|
+
onDoubleClick: (ev) => ev.stopPropagation(),
|
|
676
|
+
onClick: (ev) => {
|
|
677
|
+
ev.stopPropagation();
|
|
678
|
+
onAction?.("run");
|
|
679
|
+
}
|
|
680
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
681
|
+
className: mx("flex flex-col bs-full grow overflow-hidden", classNames)
|
|
682
|
+
}, children), /* @__PURE__ */ React.createElement("div", {
|
|
683
|
+
className: "flex shrink-0 is-full justify-between items-center bs-[32px] bg-hoverSurface"
|
|
684
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
685
|
+
className: "grow pli-2 text-sm truncate"
|
|
686
|
+
}, debug ? shape.id : status), openable && /* @__PURE__ */ React.createElement(IconButton, {
|
|
687
|
+
classNames: "p-1",
|
|
688
|
+
variant: "ghost",
|
|
689
|
+
icon: open ? "ph--caret-up--regular" : "ph--caret-down--regular",
|
|
690
|
+
size: 4,
|
|
691
|
+
label: open ? "close" : "open",
|
|
692
|
+
iconOnly: true,
|
|
693
|
+
onClick: (ev) => {
|
|
694
|
+
ev.stopPropagation();
|
|
695
|
+
onAction?.(open ? "close" : "open");
|
|
696
|
+
}
|
|
697
|
+
})));
|
|
679
698
|
});
|
|
680
699
|
|
|
681
|
-
//
|
|
682
|
-
import
|
|
683
|
-
import { SchemaAST as SchemaAST2 } from "effect";
|
|
700
|
+
// src/shapes/common/FunctionBody.tsx
|
|
701
|
+
import * as SchemaAST2 from "effect/SchemaAST";
|
|
684
702
|
import React2, { useRef, useState as useState3 } from "react";
|
|
685
703
|
import { VoidInput, VoidOutput } from "@dxos/conductor";
|
|
686
704
|
import { useCanvasContext } from "@dxos/react-ui-canvas";
|
|
687
|
-
import {
|
|
705
|
+
import { createAnchors, getParentShapeElement, rowHeight } from "@dxos/react-ui-canvas-editor";
|
|
688
706
|
|
|
689
|
-
//
|
|
690
|
-
import
|
|
707
|
+
// src/shapes/defs.ts
|
|
708
|
+
import * as Schema2 from "effect/Schema";
|
|
709
|
+
import * as SchemaAST from "effect/SchemaAST";
|
|
691
710
|
import { DEFAULT_INPUT as DEFAULT_INPUT2, DEFAULT_OUTPUT as DEFAULT_OUTPUT2 } from "@dxos/conductor";
|
|
692
|
-
import {
|
|
711
|
+
import { Obj as Obj3 } from "@dxos/echo";
|
|
693
712
|
import { Polygon } from "@dxos/react-ui-canvas-editor";
|
|
694
713
|
var getProperties = (ast) => SchemaAST.getPropertySignatures(ast).map(({ name }) => ({
|
|
695
714
|
name: name.toString()
|
|
@@ -707,85 +726,80 @@ var parseAnchorId = (id) => {
|
|
|
707
726
|
};
|
|
708
727
|
var ComputeShape = Schema2.extend(Polygon, Schema2.Struct({
|
|
709
728
|
// TODO(burdon): Rename computeNode?
|
|
710
|
-
node: Schema2.optional(
|
|
729
|
+
node: Schema2.optional(Obj3.ID.annotations({
|
|
711
730
|
description: "Compute node id"
|
|
712
731
|
}))
|
|
713
732
|
}).pipe(Schema2.mutable));
|
|
714
733
|
var createShape = ({ id, ...rest }) => {
|
|
715
734
|
return {
|
|
716
|
-
id: id ??
|
|
735
|
+
id: id ?? Obj3.ID.random(),
|
|
717
736
|
...rest
|
|
718
737
|
};
|
|
719
738
|
};
|
|
720
739
|
|
|
721
|
-
//
|
|
740
|
+
// src/shapes/common/FunctionBody.tsx
|
|
722
741
|
var bodyPadding = 8;
|
|
723
742
|
var expandedHeight = 200;
|
|
724
743
|
var FunctionBody = ({ shape, name, content, inputSchema = VoidInput, outputSchema = VoidOutput, ...props }) => {
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
setOpen(true);
|
|
740
|
-
break;
|
|
741
|
-
}
|
|
742
|
-
case "close": {
|
|
743
|
-
const el = getParentShapeElement(rootRef.current, shape.id);
|
|
744
|
-
el.style.height = "";
|
|
745
|
-
setOpen(false);
|
|
746
|
-
break;
|
|
747
|
-
}
|
|
748
|
-
}
|
|
749
|
-
};
|
|
750
|
-
const inputs = getProperties(inputSchema.ast);
|
|
751
|
-
const outputs = getProperties(outputSchema.ast);
|
|
752
|
-
const columnCount = inputs.length && outputs.length ? 2 : 1;
|
|
753
|
-
return /* @__PURE__ */ React2.createElement(Box, {
|
|
754
|
-
ref: rootRef,
|
|
755
|
-
shape,
|
|
756
|
-
title: name,
|
|
757
|
-
classNames: "divide-y divide-separator",
|
|
758
|
-
open,
|
|
759
|
-
onAction: handleAction,
|
|
760
|
-
...props
|
|
761
|
-
}, /* @__PURE__ */ React2.createElement("div", {
|
|
762
|
-
className: `grid grid-cols-${columnCount} items-center`,
|
|
763
|
-
style: {
|
|
764
|
-
paddingTop: bodyPadding,
|
|
765
|
-
paddingBottom: bodyPadding
|
|
766
|
-
}
|
|
767
|
-
}, (inputs?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement("div", {
|
|
768
|
-
className: "flex flex-col"
|
|
769
|
-
}, inputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
|
|
770
|
-
key: name2,
|
|
771
|
-
className: "px-2 truncate text-sm font-mono items-center",
|
|
772
|
-
style: {
|
|
773
|
-
height: rowHeight
|
|
744
|
+
const { scale } = useCanvasContext();
|
|
745
|
+
const rootRef = useRef(null);
|
|
746
|
+
const [open, setOpen] = useState3(false);
|
|
747
|
+
const handleAction = (action) => {
|
|
748
|
+
if (!rootRef.current) {
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
switch (action) {
|
|
752
|
+
case "open": {
|
|
753
|
+
const el = getParentShapeElement(rootRef.current, shape.id);
|
|
754
|
+
const { height } = el.getBoundingClientRect();
|
|
755
|
+
el.style.height = `${height / scale + expandedHeight}px`;
|
|
756
|
+
setOpen(true);
|
|
757
|
+
break;
|
|
774
758
|
}
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
style: {
|
|
781
|
-
height: rowHeight
|
|
759
|
+
case "close": {
|
|
760
|
+
const el = getParentShapeElement(rootRef.current, shape.id);
|
|
761
|
+
el.style.height = "";
|
|
762
|
+
setOpen(false);
|
|
763
|
+
break;
|
|
782
764
|
}
|
|
783
|
-
}
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
765
|
+
}
|
|
766
|
+
};
|
|
767
|
+
const inputs = getProperties(inputSchema.ast);
|
|
768
|
+
const outputs = getProperties(outputSchema.ast);
|
|
769
|
+
const columnCount = inputs.length && outputs.length ? 2 : 1;
|
|
770
|
+
return /* @__PURE__ */ React2.createElement(Box, {
|
|
771
|
+
ref: rootRef,
|
|
772
|
+
shape,
|
|
773
|
+
title: name,
|
|
774
|
+
classNames: "divide-y divide-separator",
|
|
775
|
+
open,
|
|
776
|
+
onAction: handleAction,
|
|
777
|
+
...props
|
|
778
|
+
}, /* @__PURE__ */ React2.createElement("div", {
|
|
779
|
+
className: `grid grid-cols-${columnCount} items-center`,
|
|
780
|
+
style: {
|
|
781
|
+
paddingTop: bodyPadding,
|
|
782
|
+
paddingBottom: bodyPadding
|
|
783
|
+
}
|
|
784
|
+
}, (inputs?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement("div", {
|
|
785
|
+
className: "flex flex-col"
|
|
786
|
+
}, inputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
|
|
787
|
+
key: name2,
|
|
788
|
+
className: "pli-2 truncate text-sm font-mono items-center",
|
|
789
|
+
style: {
|
|
790
|
+
height: rowHeight
|
|
791
|
+
}
|
|
792
|
+
}, name2))), (outputs?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement("div", {
|
|
793
|
+
className: "flex flex-col"
|
|
794
|
+
}, outputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
|
|
795
|
+
key: name2,
|
|
796
|
+
className: "pli-2 truncate text-sm font-mono items-center text-right",
|
|
797
|
+
style: {
|
|
798
|
+
height: rowHeight
|
|
799
|
+
}
|
|
800
|
+
}, name2)))), open && /* @__PURE__ */ React2.createElement("div", {
|
|
801
|
+
className: "flex flex-col grow overflow-hidden"
|
|
802
|
+
}, content));
|
|
789
803
|
};
|
|
790
804
|
var getHeight = (input) => {
|
|
791
805
|
const properties = SchemaAST2.getPropertySignatures(input.ast);
|
|
@@ -805,48 +819,36 @@ var createFunctionAnchors = (shape, input = VoidInput, output = VoidOutput) => {
|
|
|
805
819
|
});
|
|
806
820
|
};
|
|
807
821
|
|
|
808
|
-
//
|
|
809
|
-
import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
|
|
822
|
+
// src/shapes/common/TypeSelect.tsx
|
|
810
823
|
import React3 from "react";
|
|
811
824
|
import { ComputeValueType } from "@dxos/conductor";
|
|
812
825
|
import { Select } from "@dxos/react-ui";
|
|
813
826
|
var TypeSelect = ({ value, onValueChange }) => {
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
value: type
|
|
825
|
-
}, type))), /* @__PURE__ */ React3.createElement(Select.ScrollDownButton, null), /* @__PURE__ */ React3.createElement(Select.Arrow, null))));
|
|
826
|
-
} finally {
|
|
827
|
-
_effect.f();
|
|
828
|
-
}
|
|
827
|
+
return /* @__PURE__ */ React3.createElement(Select.Root, {
|
|
828
|
+
value,
|
|
829
|
+
onValueChange
|
|
830
|
+
}, /* @__PURE__ */ React3.createElement(Select.TriggerButton, {
|
|
831
|
+
variant: "ghost",
|
|
832
|
+
classNames: "is-full !pli-0"
|
|
833
|
+
}), /* @__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, {
|
|
834
|
+
key: type,
|
|
835
|
+
value: type
|
|
836
|
+
}, type))), /* @__PURE__ */ React3.createElement(Select.ScrollDownButton, null), /* @__PURE__ */ React3.createElement(Select.Arrow, null))));
|
|
829
837
|
};
|
|
830
838
|
|
|
831
|
-
//
|
|
832
|
-
import
|
|
833
|
-
import { Schema as Schema3 } from "effect";
|
|
839
|
+
// src/shapes/Array.tsx
|
|
840
|
+
import * as Schema3 from "effect/Schema";
|
|
834
841
|
import React4 from "react";
|
|
835
842
|
import { ReducerInput, ReducerOutput } from "@dxos/conductor";
|
|
836
843
|
var ReducerShape = Schema3.extend(ComputeShape, Schema3.Struct({
|
|
837
844
|
type: Schema3.Literal("reducer")
|
|
838
845
|
}));
|
|
839
846
|
var ReducerComponent = ({ shape }) => {
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
outputSchema: ReducerOutput
|
|
846
|
-
});
|
|
847
|
-
} finally {
|
|
848
|
-
_effect.f();
|
|
849
|
-
}
|
|
847
|
+
return /* @__PURE__ */ React4.createElement(FunctionBody, {
|
|
848
|
+
shape,
|
|
849
|
+
inputSchema: ReducerInput,
|
|
850
|
+
outputSchema: ReducerOutput
|
|
851
|
+
});
|
|
850
852
|
};
|
|
851
853
|
var createReducer = ({ id, size = {
|
|
852
854
|
width: 192,
|
|
@@ -865,9 +867,8 @@ var reducerShape = {
|
|
|
865
867
|
getAnchors: (shape) => createFunctionAnchors(shape, ReducerInput, ReducerOutput)
|
|
866
868
|
};
|
|
867
869
|
|
|
868
|
-
//
|
|
869
|
-
import
|
|
870
|
-
import { Schema as Schema4 } from "effect";
|
|
870
|
+
// src/shapes/Append.tsx
|
|
871
|
+
import * as Schema4 from "effect/Schema";
|
|
871
872
|
import React5 from "react";
|
|
872
873
|
import { AppendInput } from "@dxos/conductor";
|
|
873
874
|
var AppendShape = Schema4.extend(ComputeShape, Schema4.Struct({
|
|
@@ -882,15 +883,10 @@ var createAppend = (props) => createShape({
|
|
|
882
883
|
...props
|
|
883
884
|
});
|
|
884
885
|
var AppendComponent = ({ shape }) => {
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
inputSchema: AppendInput
|
|
890
|
-
});
|
|
891
|
-
} finally {
|
|
892
|
-
_effect.f();
|
|
893
|
-
}
|
|
886
|
+
return /* @__PURE__ */ React5.createElement(FunctionBody, {
|
|
887
|
+
shape,
|
|
888
|
+
inputSchema: AppendInput
|
|
889
|
+
});
|
|
894
890
|
};
|
|
895
891
|
var appendShape = {
|
|
896
892
|
type: "append",
|
|
@@ -901,9 +897,8 @@ var appendShape = {
|
|
|
901
897
|
getAnchors: (shape) => createFunctionAnchors(shape, AppendInput)
|
|
902
898
|
};
|
|
903
899
|
|
|
904
|
-
//
|
|
905
|
-
import
|
|
906
|
-
import { Schema as Schema5 } from "effect";
|
|
900
|
+
// src/shapes/Audio.tsx
|
|
901
|
+
import * as Schema5 from "effect/Schema";
|
|
907
902
|
import React6, { useEffect as useEffect3, useState as useState4 } from "react";
|
|
908
903
|
import { Icon as Icon2 } from "@dxos/react-ui";
|
|
909
904
|
import { createAnchorMap } from "@dxos/react-ui-canvas-editor";
|
|
@@ -919,29 +914,24 @@ var createAudio = (props) => createShape({
|
|
|
919
914
|
...props
|
|
920
915
|
});
|
|
921
916
|
var AudioComponent = ({ shape }) => {
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
onClick: () => setActive(!active)
|
|
941
|
-
}));
|
|
942
|
-
} finally {
|
|
943
|
-
_effect.f();
|
|
944
|
-
}
|
|
917
|
+
const { node } = useComputeNodeState(shape);
|
|
918
|
+
const [active, setActive] = useState4(false);
|
|
919
|
+
useEffect3(() => {
|
|
920
|
+
node.value = active;
|
|
921
|
+
}, [
|
|
922
|
+
active
|
|
923
|
+
]);
|
|
924
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
925
|
+
className: "flex is-full justify-center items-center"
|
|
926
|
+
}, /* @__PURE__ */ React6.createElement(Icon2, {
|
|
927
|
+
icon: active ? "ph--microphone--regular" : "ph--microphone-slash--regular",
|
|
928
|
+
classNames: [
|
|
929
|
+
"transition opacity-20 duration-1000",
|
|
930
|
+
active && "opacity-100 text-red-500"
|
|
931
|
+
],
|
|
932
|
+
size: 8,
|
|
933
|
+
onClick: () => setActive(!active)
|
|
934
|
+
}));
|
|
945
935
|
};
|
|
946
936
|
var audioShape = {
|
|
947
937
|
type: "audio",
|
|
@@ -957,14 +947,12 @@ var audioShape = {
|
|
|
957
947
|
})
|
|
958
948
|
};
|
|
959
949
|
|
|
960
|
-
//
|
|
961
|
-
import
|
|
962
|
-
import { Schema as Schema6 } from "effect";
|
|
950
|
+
// src/shapes/Beacon.tsx
|
|
951
|
+
import * as Schema6 from "effect/Schema";
|
|
963
952
|
import React7 from "react";
|
|
964
953
|
import { DEFAULT_INPUT as DEFAULT_INPUT3, isTruthy } from "@dxos/conductor";
|
|
965
954
|
import { Icon as Icon3 } from "@dxos/react-ui";
|
|
966
955
|
import { createAnchorMap as createAnchorMap2 } from "@dxos/react-ui-canvas-editor";
|
|
967
|
-
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
968
956
|
var BeaconShape = Schema6.extend(ComputeShape, Schema6.Struct({
|
|
969
957
|
type: Schema6.Literal("beacon")
|
|
970
958
|
}));
|
|
@@ -977,21 +965,19 @@ var createBeacon = (props) => createShape({
|
|
|
977
965
|
...props
|
|
978
966
|
});
|
|
979
967
|
var BeaconComponent = ({ shape }) => {
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
}
|
|
993
|
-
_effect.f();
|
|
994
|
-
}
|
|
968
|
+
const { runtime } = useComputeNodeState(shape);
|
|
969
|
+
const input = runtime.inputs[DEFAULT_INPUT3];
|
|
970
|
+
const value = input?.type === "executed" ? input.value : false;
|
|
971
|
+
return /* @__PURE__ */ React7.createElement("div", {
|
|
972
|
+
className: "flex is-full justify-center items-center"
|
|
973
|
+
}, /* @__PURE__ */ React7.createElement(Icon3, {
|
|
974
|
+
icon: "ph--sun--regular",
|
|
975
|
+
classNames: [
|
|
976
|
+
"transition opacity-20 duration-1000",
|
|
977
|
+
isTruthy(value) && "opacity-100 text-yellow-500"
|
|
978
|
+
],
|
|
979
|
+
size: 8
|
|
980
|
+
}));
|
|
995
981
|
};
|
|
996
982
|
var beaconShape = {
|
|
997
983
|
type: "beacon",
|
|
@@ -1007,8 +993,8 @@ var beaconShape = {
|
|
|
1007
993
|
})
|
|
1008
994
|
};
|
|
1009
995
|
|
|
1010
|
-
//
|
|
1011
|
-
import
|
|
996
|
+
// src/shapes/Boolean.tsx
|
|
997
|
+
import * as Schema7 from "effect/Schema";
|
|
1012
998
|
import React8 from "react";
|
|
1013
999
|
import { getAnchorPoints } from "@dxos/react-ui-canvas-editor";
|
|
1014
1000
|
import { createAnchors as createAnchors2 } from "@dxos/react-ui-canvas-editor";
|
|
@@ -1032,7 +1018,7 @@ var defineShape = ({ type, name, icon, symbol: Symbol, createShape: createShape2
|
|
|
1032
1018
|
// Be careful not to name component factories with a capital letter.
|
|
1033
1019
|
component: () => {
|
|
1034
1020
|
return /* @__PURE__ */ React8.createElement("div", {
|
|
1035
|
-
className: "flex
|
|
1021
|
+
className: "flex is-full justify-center items-center"
|
|
1036
1022
|
}, /* @__PURE__ */ React8.createElement(Symbol, null));
|
|
1037
1023
|
},
|
|
1038
1024
|
createShape: createShape2,
|
|
@@ -1059,7 +1045,7 @@ var createSymbol = (pathConstructor, inputs) => ({
|
|
|
1059
1045
|
});
|
|
1060
1046
|
return /* @__PURE__ */ React8.createElement("svg", {
|
|
1061
1047
|
viewBox: `0 0 ${width} ${height}`,
|
|
1062
|
-
className: "
|
|
1048
|
+
className: "is-full bs-full"
|
|
1063
1049
|
}, getAnchorPoints({
|
|
1064
1050
|
x: 0,
|
|
1065
1051
|
y: centerY
|
|
@@ -1180,9 +1166,8 @@ var notShape = defineShape({
|
|
|
1180
1166
|
]
|
|
1181
1167
|
});
|
|
1182
1168
|
|
|
1183
|
-
//
|
|
1184
|
-
import
|
|
1185
|
-
import { Schema as Schema8 } from "effect";
|
|
1169
|
+
// src/shapes/Chat.tsx
|
|
1170
|
+
import * as Schema8 from "effect/Schema";
|
|
1186
1171
|
import React9, { useRef as useRef2 } from "react";
|
|
1187
1172
|
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT3 } from "@dxos/conductor";
|
|
1188
1173
|
import { TextBox } from "@dxos/react-ui-canvas-editor";
|
|
@@ -1191,28 +1176,23 @@ var ChatShape = Schema8.extend(ComputeShape, Schema8.Struct({
|
|
|
1191
1176
|
type: Schema8.Literal("chat")
|
|
1192
1177
|
}));
|
|
1193
1178
|
var TextInputComponent = ({ shape, title, ...props }) => {
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
const
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
...props
|
|
1212
|
-
}));
|
|
1213
|
-
} finally {
|
|
1214
|
-
_effect.f();
|
|
1215
|
-
}
|
|
1179
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1180
|
+
const inputRef = useRef2(null);
|
|
1181
|
+
const handleEnter = (text) => {
|
|
1182
|
+
const value = text.trim();
|
|
1183
|
+
if (value.length) {
|
|
1184
|
+
runtime.setOutput(DEFAULT_OUTPUT3, value);
|
|
1185
|
+
inputRef.current?.setText("");
|
|
1186
|
+
}
|
|
1187
|
+
};
|
|
1188
|
+
return /* @__PURE__ */ React9.createElement(Box, {
|
|
1189
|
+
shape,
|
|
1190
|
+
title
|
|
1191
|
+
}, /* @__PURE__ */ React9.createElement(TextBox, {
|
|
1192
|
+
ref: inputRef,
|
|
1193
|
+
onEnter: handleEnter,
|
|
1194
|
+
...props
|
|
1195
|
+
}));
|
|
1216
1196
|
};
|
|
1217
1197
|
var createChat = (props) => createShape({
|
|
1218
1198
|
type: "chat",
|
|
@@ -1241,9 +1221,8 @@ var chatShape = {
|
|
|
1241
1221
|
resizable: true
|
|
1242
1222
|
};
|
|
1243
1223
|
|
|
1244
|
-
//
|
|
1245
|
-
import
|
|
1246
|
-
import { Schema as Schema9 } from "effect";
|
|
1224
|
+
// src/shapes/Constant.tsx
|
|
1225
|
+
import * as Schema9 from "effect/Schema";
|
|
1247
1226
|
import React10, { useCallback as useCallback2, useRef as useRef3, useState as useState5 } from "react";
|
|
1248
1227
|
import { ComputeValueType as ComputeValueType2 } from "@dxos/conductor";
|
|
1249
1228
|
import { Input } from "@dxos/react-ui";
|
|
@@ -1266,57 +1245,52 @@ var inferType = (value) => {
|
|
|
1266
1245
|
}
|
|
1267
1246
|
};
|
|
1268
1247
|
var ConstantComponent = ({ shape, title, chat, ...props }) => {
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
const
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
if (
|
|
1278
|
-
|
|
1279
|
-
if (!isNaN(floatValue)) {
|
|
1280
|
-
node.value = floatValue;
|
|
1281
|
-
}
|
|
1282
|
-
} else if (type === "object") {
|
|
1283
|
-
node.value = safeParseJson(value, {});
|
|
1284
|
-
} else {
|
|
1285
|
-
node.value = value;
|
|
1248
|
+
const { node } = useComputeNodeState(shape);
|
|
1249
|
+
const [type, setType] = useState5(inferType(node.value) ?? ComputeValueType2.literals[0]);
|
|
1250
|
+
const inputRef = useRef3(null);
|
|
1251
|
+
const handleEnter = useCallback2((text) => {
|
|
1252
|
+
const value = text.trim();
|
|
1253
|
+
if (value.length) {
|
|
1254
|
+
if (type === "number") {
|
|
1255
|
+
const floatValue = parseFloat(value);
|
|
1256
|
+
if (!isNaN(floatValue)) {
|
|
1257
|
+
node.value = floatValue;
|
|
1286
1258
|
}
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
type
|
|
1291
|
-
]);
|
|
1292
|
-
return /* @__PURE__ */ React10.createElement(Box, {
|
|
1293
|
-
shape,
|
|
1294
|
-
title,
|
|
1295
|
-
status: /* @__PURE__ */ React10.createElement(TypeSelect, {
|
|
1296
|
-
value: type,
|
|
1297
|
-
onValueChange: setType
|
|
1298
|
-
})
|
|
1299
|
-
}, (type === "string" || type === "number") && /* @__PURE__ */ React10.createElement(TextBox2, {
|
|
1300
|
-
...props,
|
|
1301
|
-
ref: inputRef,
|
|
1302
|
-
value: node.value,
|
|
1303
|
-
onEnter: handleEnter
|
|
1304
|
-
}), type === "object" && /* @__PURE__ */ React10.createElement(TextBox2, {
|
|
1305
|
-
...props,
|
|
1306
|
-
ref: inputRef,
|
|
1307
|
-
value: JSON.stringify(node.value, null, 2),
|
|
1308
|
-
language: "json"
|
|
1309
|
-
}), type === "boolean" && /* @__PURE__ */ React10.createElement("div", {
|
|
1310
|
-
className: "flex grow justify-center items-center"
|
|
1311
|
-
}, /* @__PURE__ */ React10.createElement(Input.Root, null, /* @__PURE__ */ React10.createElement(Input.Switch, {
|
|
1312
|
-
checked: node.value,
|
|
1313
|
-
onCheckedChange: (value) => {
|
|
1259
|
+
} else if (type === "object") {
|
|
1260
|
+
node.value = safeParseJson(value, {});
|
|
1261
|
+
} else {
|
|
1314
1262
|
node.value = value;
|
|
1315
1263
|
}
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1264
|
+
inputRef.current?.focus();
|
|
1265
|
+
}
|
|
1266
|
+
}, [
|
|
1267
|
+
type
|
|
1268
|
+
]);
|
|
1269
|
+
return /* @__PURE__ */ React10.createElement(Box, {
|
|
1270
|
+
shape,
|
|
1271
|
+
title,
|
|
1272
|
+
status: /* @__PURE__ */ React10.createElement(TypeSelect, {
|
|
1273
|
+
value: type,
|
|
1274
|
+
onValueChange: setType
|
|
1275
|
+
})
|
|
1276
|
+
}, (type === "string" || type === "number") && /* @__PURE__ */ React10.createElement(TextBox2, {
|
|
1277
|
+
...props,
|
|
1278
|
+
ref: inputRef,
|
|
1279
|
+
value: node.value,
|
|
1280
|
+
onEnter: handleEnter
|
|
1281
|
+
}), type === "object" && /* @__PURE__ */ React10.createElement(TextBox2, {
|
|
1282
|
+
...props,
|
|
1283
|
+
ref: inputRef,
|
|
1284
|
+
value: JSON.stringify(node.value, null, 2),
|
|
1285
|
+
language: "json"
|
|
1286
|
+
}), type === "boolean" && /* @__PURE__ */ React10.createElement("div", {
|
|
1287
|
+
className: "flex grow justify-center items-center"
|
|
1288
|
+
}, /* @__PURE__ */ React10.createElement(Input.Root, null, /* @__PURE__ */ React10.createElement(Input.Switch, {
|
|
1289
|
+
checked: node.value,
|
|
1290
|
+
onCheckedChange: (value) => {
|
|
1291
|
+
node.value = value;
|
|
1292
|
+
}
|
|
1293
|
+
}))));
|
|
1320
1294
|
};
|
|
1321
1295
|
var createConstant = (props) => createShape({
|
|
1322
1296
|
type: "constant",
|
|
@@ -1344,9 +1318,8 @@ var constantShape = {
|
|
|
1344
1318
|
resizable: true
|
|
1345
1319
|
};
|
|
1346
1320
|
|
|
1347
|
-
//
|
|
1348
|
-
import
|
|
1349
|
-
import { Schema as Schema10 } from "effect";
|
|
1321
|
+
// src/shapes/Database.tsx
|
|
1322
|
+
import * as Schema10 from "effect/Schema";
|
|
1350
1323
|
import React11 from "react";
|
|
1351
1324
|
import { createAnchorMap as createAnchorMap5 } from "@dxos/react-ui-canvas-editor";
|
|
1352
1325
|
var DatabaseShape = Schema10.extend(ComputeShape, Schema10.Struct({
|
|
@@ -1361,14 +1334,9 @@ var createDatabase = (props) => createShape({
|
|
|
1361
1334
|
...props
|
|
1362
1335
|
});
|
|
1363
1336
|
var DatabaseComponent = ({ shape }) => {
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
shape
|
|
1368
|
-
});
|
|
1369
|
-
} finally {
|
|
1370
|
-
_effect.f();
|
|
1371
|
-
}
|
|
1337
|
+
return /* @__PURE__ */ React11.createElement(Box, {
|
|
1338
|
+
shape
|
|
1339
|
+
});
|
|
1372
1340
|
};
|
|
1373
1341
|
var databaseShape = {
|
|
1374
1342
|
type: "database",
|
|
@@ -1384,15 +1352,14 @@ var databaseShape = {
|
|
|
1384
1352
|
})
|
|
1385
1353
|
};
|
|
1386
1354
|
|
|
1387
|
-
//
|
|
1388
|
-
import
|
|
1389
|
-
import { Schema as Schema11 } from "effect";
|
|
1355
|
+
// src/shapes/Function.tsx
|
|
1356
|
+
import * as Schema11 from "effect/Schema";
|
|
1390
1357
|
import React12, { useCallback as useCallback3, useRef as useRef4 } from "react";
|
|
1391
1358
|
import { AnyOutput, FunctionInput } from "@dxos/conductor";
|
|
1392
|
-
import {
|
|
1393
|
-
import {
|
|
1359
|
+
import { Ref as Ref2, getSnapshot, isInstanceOf } from "@dxos/echo/internal";
|
|
1360
|
+
import { Function, Script } from "@dxos/functions";
|
|
1394
1361
|
import { useClient } from "@dxos/react-client";
|
|
1395
|
-
import { Filter,
|
|
1362
|
+
import { Filter, parseId } from "@dxos/react-client/echo";
|
|
1396
1363
|
import { TextBox as TextBox3 } from "@dxos/react-ui-canvas-editor";
|
|
1397
1364
|
var FunctionShape = Schema11.extend(ComputeShape, Schema11.Struct({
|
|
1398
1365
|
type: Schema11.Literal("function")
|
|
@@ -1406,59 +1373,54 @@ var createFunction = (props) => createShape({
|
|
|
1406
1373
|
...props
|
|
1407
1374
|
});
|
|
1408
1375
|
var TextInputComponent2 = ({ shape, title, ...props }) => {
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
const
|
|
1414
|
-
const
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
onEnter: handleEnter
|
|
1458
|
-
}));
|
|
1459
|
-
} finally {
|
|
1460
|
-
_effect.f();
|
|
1461
|
-
}
|
|
1376
|
+
const client = useClient();
|
|
1377
|
+
const { node, runtime } = useComputeNodeState(shape);
|
|
1378
|
+
const inputRef = useRef4(null);
|
|
1379
|
+
const handleEnter = useCallback3(async (text) => {
|
|
1380
|
+
const value = text.trim();
|
|
1381
|
+
const { spaceId, objectId } = parseId(value);
|
|
1382
|
+
if (!spaceId || !objectId) {
|
|
1383
|
+
return;
|
|
1384
|
+
}
|
|
1385
|
+
const space = client.spaces.get(spaceId);
|
|
1386
|
+
const object = space?.db.getObjectById(objectId);
|
|
1387
|
+
if (!space || !isInstanceOf(Script.Script, object)) {
|
|
1388
|
+
return;
|
|
1389
|
+
}
|
|
1390
|
+
const [fn] = await space.db.query(Filter.type(Function.Function, {
|
|
1391
|
+
source: Ref2.make(object)
|
|
1392
|
+
})).run();
|
|
1393
|
+
if (!fn) {
|
|
1394
|
+
return;
|
|
1395
|
+
}
|
|
1396
|
+
node.value = value;
|
|
1397
|
+
node.function = Ref2.make(fn);
|
|
1398
|
+
node.inputSchema = fn.inputSchema ? getSnapshot(fn.inputSchema) : void 0;
|
|
1399
|
+
node.outputSchema = fn.outputSchema ? getSnapshot(fn.outputSchema) : void 0;
|
|
1400
|
+
}, [
|
|
1401
|
+
client,
|
|
1402
|
+
node
|
|
1403
|
+
]);
|
|
1404
|
+
const handleAction = useCallback3((action) => {
|
|
1405
|
+
if (action !== "run") {
|
|
1406
|
+
return;
|
|
1407
|
+
}
|
|
1408
|
+
runtime.evalNode();
|
|
1409
|
+
}, [
|
|
1410
|
+
runtime
|
|
1411
|
+
]);
|
|
1412
|
+
return /* @__PURE__ */ React12.createElement(Box, {
|
|
1413
|
+
shape,
|
|
1414
|
+
title: "Function",
|
|
1415
|
+
onAction: handleAction
|
|
1416
|
+
}, /* @__PURE__ */ React12.createElement(TextBox3, {
|
|
1417
|
+
...props,
|
|
1418
|
+
ref: inputRef,
|
|
1419
|
+
value: node.value,
|
|
1420
|
+
language: node.valueType === "object" ? "json" : void 0,
|
|
1421
|
+
onBlur: handleEnter,
|
|
1422
|
+
onEnter: handleEnter
|
|
1423
|
+
}));
|
|
1462
1424
|
};
|
|
1463
1425
|
var functionShape = {
|
|
1464
1426
|
type: "function",
|
|
@@ -1469,11 +1431,11 @@ var functionShape = {
|
|
|
1469
1431
|
getAnchors: (shape) => createFunctionAnchors(shape, FunctionInput, AnyOutput)
|
|
1470
1432
|
};
|
|
1471
1433
|
|
|
1472
|
-
//
|
|
1473
|
-
import
|
|
1474
|
-
import { Schema as Schema12 } from "effect";
|
|
1434
|
+
// src/shapes/Gpt.tsx
|
|
1435
|
+
import * as Schema12 from "effect/Schema";
|
|
1475
1436
|
import React13, { useEffect as useEffect4, useState as useState6 } from "react";
|
|
1476
1437
|
import { GptInput, GptOutput } from "@dxos/conductor";
|
|
1438
|
+
import { ScrollArea } from "@dxos/react-ui";
|
|
1477
1439
|
var GptShape = Schema12.extend(ComputeShape, Schema12.Struct({
|
|
1478
1440
|
type: Schema12.Literal("gpt")
|
|
1479
1441
|
}));
|
|
@@ -1486,54 +1448,50 @@ var createGpt = (props) => createShape({
|
|
|
1486
1448
|
...props
|
|
1487
1449
|
});
|
|
1488
1450
|
var GptComponent = ({ shape }) => {
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
const
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
});
|
|
1513
|
-
break;
|
|
1514
|
-
}
|
|
1451
|
+
const { meta, runtime } = useComputeNodeState(shape);
|
|
1452
|
+
const [text, setText] = useState6("");
|
|
1453
|
+
const [tokens, setTokens] = useState6(0);
|
|
1454
|
+
useEffect4(() => {
|
|
1455
|
+
return runtime.subscribeToEventLog((ev) => {
|
|
1456
|
+
switch (ev.type) {
|
|
1457
|
+
case "begin-compute": {
|
|
1458
|
+
setText("");
|
|
1459
|
+
break;
|
|
1460
|
+
}
|
|
1461
|
+
case "custom": {
|
|
1462
|
+
const token = ev.event;
|
|
1463
|
+
switch (token.type) {
|
|
1464
|
+
case "content_block_delta":
|
|
1465
|
+
switch (token.delta.type) {
|
|
1466
|
+
case "text_delta": {
|
|
1467
|
+
const delta = token.delta.text;
|
|
1468
|
+
setText((prev) => {
|
|
1469
|
+
const text2 = prev + delta;
|
|
1470
|
+
setTokens(text2.split(" ").length);
|
|
1471
|
+
return text2;
|
|
1472
|
+
});
|
|
1473
|
+
break;
|
|
1515
1474
|
}
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
break;
|
|
1475
|
+
}
|
|
1476
|
+
break;
|
|
1519
1477
|
}
|
|
1478
|
+
break;
|
|
1520
1479
|
}
|
|
1521
|
-
}
|
|
1522
|
-
}, [
|
|
1523
|
-
runtime?.subscribeToEventLog
|
|
1524
|
-
]);
|
|
1525
|
-
return /* @__PURE__ */ React13.createElement(FunctionBody, {
|
|
1526
|
-
shape,
|
|
1527
|
-
content: /* @__PURE__ */ React13.createElement("div", {
|
|
1528
|
-
className: "px-2 py-1 overflow-y-scroll"
|
|
1529
|
-
}, text),
|
|
1530
|
-
status: `${tokens} tokens`,
|
|
1531
|
-
inputSchema: meta.input,
|
|
1532
|
-
outputSchema: meta.output
|
|
1480
|
+
}
|
|
1533
1481
|
});
|
|
1534
|
-
}
|
|
1535
|
-
|
|
1536
|
-
|
|
1482
|
+
}, [
|
|
1483
|
+
runtime?.subscribeToEventLog
|
|
1484
|
+
]);
|
|
1485
|
+
return /* @__PURE__ */ React13.createElement(FunctionBody, {
|
|
1486
|
+
shape,
|
|
1487
|
+
content: /* @__PURE__ */ React13.createElement(ScrollArea.Root, {
|
|
1488
|
+
orientation: "vertical",
|
|
1489
|
+
thin: true
|
|
1490
|
+
}, /* @__PURE__ */ React13.createElement(ScrollArea.Viewport, null, text)),
|
|
1491
|
+
status: `${tokens} tokens`,
|
|
1492
|
+
inputSchema: meta.input,
|
|
1493
|
+
outputSchema: meta.output
|
|
1494
|
+
});
|
|
1537
1495
|
};
|
|
1538
1496
|
var gptShape = {
|
|
1539
1497
|
type: "gpt",
|
|
@@ -1545,9 +1503,8 @@ var gptShape = {
|
|
|
1545
1503
|
openable: true
|
|
1546
1504
|
};
|
|
1547
1505
|
|
|
1548
|
-
//
|
|
1549
|
-
import
|
|
1550
|
-
import { Schema as Schema13 } from "effect";
|
|
1506
|
+
// src/shapes/Json.tsx
|
|
1507
|
+
import * as Schema13 from "effect/Schema";
|
|
1551
1508
|
import React14 from "react";
|
|
1552
1509
|
import { DEFAULT_INPUT as DEFAULT_INPUT4, DefaultOutput, JsonTransformInput } from "@dxos/conductor";
|
|
1553
1510
|
import { createAnchorMap as createAnchorMap6 } from "@dxos/react-ui-canvas-editor";
|
|
@@ -1559,30 +1516,20 @@ var JsonTransformShape = Schema13.extend(ComputeShape, Schema13.Struct({
|
|
|
1559
1516
|
type: Schema13.Literal("json-transform")
|
|
1560
1517
|
}));
|
|
1561
1518
|
var JsonComponent = ({ shape, ...props }) => {
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
classNames: "text-xs"
|
|
1572
|
-
}));
|
|
1573
|
-
} finally {
|
|
1574
|
-
_effect.f();
|
|
1575
|
-
}
|
|
1519
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1520
|
+
const input = runtime.inputs[DEFAULT_INPUT4];
|
|
1521
|
+
const value = input?.type === "executed" ? input.value : void 0;
|
|
1522
|
+
return /* @__PURE__ */ React14.createElement(Box, {
|
|
1523
|
+
shape
|
|
1524
|
+
}, /* @__PURE__ */ React14.createElement(JsonFilter, {
|
|
1525
|
+
data: value,
|
|
1526
|
+
classNames: "text-xs"
|
|
1527
|
+
}));
|
|
1576
1528
|
};
|
|
1577
1529
|
var JsonTransformComponent = ({ shape, ...props }) => {
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
shape
|
|
1582
|
-
});
|
|
1583
|
-
} finally {
|
|
1584
|
-
_effect.f();
|
|
1585
|
-
}
|
|
1530
|
+
return /* @__PURE__ */ React14.createElement(Box, {
|
|
1531
|
+
shape
|
|
1532
|
+
});
|
|
1586
1533
|
};
|
|
1587
1534
|
var createJson = (props) => createShape({
|
|
1588
1535
|
type: "json",
|
|
@@ -1628,9 +1575,8 @@ var jsonTransformShape = {
|
|
|
1628
1575
|
resizable: true
|
|
1629
1576
|
};
|
|
1630
1577
|
|
|
1631
|
-
//
|
|
1632
|
-
import
|
|
1633
|
-
import { Schema as Schema14 } from "effect";
|
|
1578
|
+
// src/shapes/Logic.tsx
|
|
1579
|
+
import * as Schema14 from "effect/Schema";
|
|
1634
1580
|
import React15 from "react";
|
|
1635
1581
|
import { IfElseInput, IfElseOutput, IfInput, IfOutput } from "@dxos/conductor";
|
|
1636
1582
|
var IfShape = Schema14.extend(ComputeShape, Schema14.Struct({
|
|
@@ -1640,28 +1586,18 @@ var IfElseShape = Schema14.extend(ComputeShape, Schema14.Struct({
|
|
|
1640
1586
|
type: Schema14.Literal("if-else")
|
|
1641
1587
|
}));
|
|
1642
1588
|
var IfComponent = ({ shape, ...props }) => {
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
outputSchema: IfOutput
|
|
1649
|
-
});
|
|
1650
|
-
} finally {
|
|
1651
|
-
_effect.f();
|
|
1652
|
-
}
|
|
1589
|
+
return /* @__PURE__ */ React15.createElement(FunctionBody, {
|
|
1590
|
+
shape,
|
|
1591
|
+
inputSchema: IfInput,
|
|
1592
|
+
outputSchema: IfOutput
|
|
1593
|
+
});
|
|
1653
1594
|
};
|
|
1654
1595
|
var IfElseComponent = ({ shape, ...props }) => {
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
outputSchema: IfElseOutput
|
|
1661
|
-
});
|
|
1662
|
-
} finally {
|
|
1663
|
-
_effect.f();
|
|
1664
|
-
}
|
|
1596
|
+
return /* @__PURE__ */ React15.createElement(FunctionBody, {
|
|
1597
|
+
shape,
|
|
1598
|
+
inputSchema: IfElseInput,
|
|
1599
|
+
outputSchema: IfElseOutput
|
|
1600
|
+
});
|
|
1665
1601
|
};
|
|
1666
1602
|
var createIf = (props) => createShape({
|
|
1667
1603
|
type: "if",
|
|
@@ -1696,12 +1632,12 @@ var ifElseShape = {
|
|
|
1696
1632
|
getAnchors: (shape) => createFunctionAnchors(shape, IfElseInput, IfElseOutput)
|
|
1697
1633
|
};
|
|
1698
1634
|
|
|
1699
|
-
//
|
|
1700
|
-
import
|
|
1701
|
-
import { Schema as Schema15 } from "effect";
|
|
1635
|
+
// src/shapes/Queue.tsx
|
|
1636
|
+
import * as Schema15 from "effect/Schema";
|
|
1702
1637
|
import React16, { Fragment } from "react";
|
|
1703
1638
|
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT4, QueueInput, QueueOutput } from "@dxos/conductor";
|
|
1704
|
-
import {
|
|
1639
|
+
import { ScrollArea as ScrollArea2 } from "@dxos/react-ui";
|
|
1640
|
+
import { mx as mx2 } from "@dxos/ui-theme";
|
|
1705
1641
|
var QueueShape = Schema15.extend(ComputeShape, Schema15.Struct({
|
|
1706
1642
|
type: Schema15.Literal("queue")
|
|
1707
1643
|
}));
|
|
@@ -1714,50 +1650,42 @@ var createQueue = (props) => createShape({
|
|
|
1714
1650
|
...props
|
|
1715
1651
|
});
|
|
1716
1652
|
var QueueComponent = ({ shape }) => {
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
} finally {
|
|
1740
|
-
_effect.f();
|
|
1741
|
-
}
|
|
1653
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1654
|
+
const items = runtime.outputs[DEFAULT_OUTPUT4]?.type === "executed" ? runtime.outputs[DEFAULT_OUTPUT4].value : [];
|
|
1655
|
+
const handleAction = (action) => {
|
|
1656
|
+
if (action === "run") {
|
|
1657
|
+
runtime.evalNode();
|
|
1658
|
+
}
|
|
1659
|
+
};
|
|
1660
|
+
return /* @__PURE__ */ React16.createElement(Box, {
|
|
1661
|
+
shape,
|
|
1662
|
+
status: `${items.length} items`,
|
|
1663
|
+
onAction: handleAction
|
|
1664
|
+
}, /* @__PURE__ */ React16.createElement(ScrollArea2.Root, {
|
|
1665
|
+
orientation: "vertical"
|
|
1666
|
+
}, /* @__PURE__ */ React16.createElement(ScrollArea2.Viewport, {
|
|
1667
|
+
classNames: "divide-y divide-separator"
|
|
1668
|
+
}, [
|
|
1669
|
+
...items
|
|
1670
|
+
].map((item, i) => /* @__PURE__ */ React16.createElement(QueueItem, {
|
|
1671
|
+
key: i,
|
|
1672
|
+
classNames: "p-1 pli-2",
|
|
1673
|
+
item
|
|
1674
|
+
})))));
|
|
1742
1675
|
};
|
|
1743
1676
|
var QueueItem = ({ classNames, item }) => {
|
|
1744
|
-
|
|
1745
|
-
try {
|
|
1746
|
-
if (typeof item !== "object") {
|
|
1747
|
-
return /* @__PURE__ */ React16.createElement("div", {
|
|
1748
|
-
className: mx3(classNames, "whitespace-pre-wrap")
|
|
1749
|
-
}, item);
|
|
1750
|
-
}
|
|
1677
|
+
if (typeof item !== "object") {
|
|
1751
1678
|
return /* @__PURE__ */ React16.createElement("div", {
|
|
1752
|
-
className:
|
|
1753
|
-
},
|
|
1754
|
-
key
|
|
1755
|
-
}, /* @__PURE__ */ React16.createElement("div", {
|
|
1756
|
-
className: "p-1 text-xs text-subdued"
|
|
1757
|
-
}, key), /* @__PURE__ */ React16.createElement("div", null, typeof value === "string" ? value : JSON.stringify(value)))));
|
|
1758
|
-
} finally {
|
|
1759
|
-
_effect.f();
|
|
1679
|
+
className: mx2(classNames, "whitespace-pre-wrap")
|
|
1680
|
+
}, item);
|
|
1760
1681
|
}
|
|
1682
|
+
return /* @__PURE__ */ React16.createElement("div", {
|
|
1683
|
+
className: mx2("grid grid-cols-[80px,1fr]", classNames)
|
|
1684
|
+
}, Object.entries(item).map(([key, value]) => /* @__PURE__ */ React16.createElement(Fragment, {
|
|
1685
|
+
key
|
|
1686
|
+
}, /* @__PURE__ */ React16.createElement("div", {
|
|
1687
|
+
className: "p-1 text-xs text-subdued"
|
|
1688
|
+
}, key), /* @__PURE__ */ React16.createElement("div", null, typeof value === "string" ? value : JSON.stringify(value)))));
|
|
1761
1689
|
};
|
|
1762
1690
|
var queueShape = {
|
|
1763
1691
|
type: "queue",
|
|
@@ -1769,14 +1697,12 @@ var queueShape = {
|
|
|
1769
1697
|
resizable: true
|
|
1770
1698
|
};
|
|
1771
1699
|
|
|
1772
|
-
//
|
|
1773
|
-
import
|
|
1774
|
-
import { Schema as Schema16 } from "effect";
|
|
1700
|
+
// src/shapes/RNG.tsx
|
|
1701
|
+
import * as Schema16 from "effect/Schema";
|
|
1775
1702
|
import React17, { useEffect as useEffect5, useState as useState7 } from "react";
|
|
1776
1703
|
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT5 } from "@dxos/conductor";
|
|
1777
1704
|
import { Icon as Icon4 } from "@dxos/react-ui";
|
|
1778
1705
|
import { createAnchorMap as createAnchorMap7 } from "@dxos/react-ui-canvas-editor";
|
|
1779
|
-
import { mx as mx4 } from "@dxos/react-ui-theme";
|
|
1780
1706
|
var RandomShape = Schema16.extend(ComputeShape, Schema16.Struct({
|
|
1781
1707
|
type: Schema16.Literal("rng"),
|
|
1782
1708
|
min: Schema16.optional(Schema16.Number),
|
|
@@ -1800,42 +1726,37 @@ var icons = [
|
|
|
1800
1726
|
];
|
|
1801
1727
|
var pickIcon = () => icons[Math.floor(Math.random() * icons.length)];
|
|
1802
1728
|
var RandomComponent = ({ shape }) => {
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
clearTimeout(t1);
|
|
1818
|
-
clearTimeout(t2);
|
|
1819
|
-
};
|
|
1820
|
-
}, [
|
|
1821
|
-
spin
|
|
1822
|
-
]);
|
|
1823
|
-
const handleClick = (ev) => {
|
|
1824
|
-
ev.stopPropagation();
|
|
1825
|
-
runtime.setOutput(DEFAULT_OUTPUT5, Math.random());
|
|
1826
|
-
setSpin(true);
|
|
1729
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1730
|
+
const [spin, setSpin] = useState7(false);
|
|
1731
|
+
const [icon, setIcon] = useState7(pickIcon());
|
|
1732
|
+
useEffect5(() => {
|
|
1733
|
+
if (!spin) {
|
|
1734
|
+
return;
|
|
1735
|
+
}
|
|
1736
|
+
const i = setInterval(() => setIcon(pickIcon()), 250);
|
|
1737
|
+
const t1 = setTimeout(() => clearInterval(i), 900);
|
|
1738
|
+
const t2 = setTimeout(() => setSpin(false), 1100);
|
|
1739
|
+
return () => {
|
|
1740
|
+
clearInterval(i);
|
|
1741
|
+
clearTimeout(t1);
|
|
1742
|
+
clearTimeout(t2);
|
|
1827
1743
|
};
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
}
|
|
1744
|
+
}, [
|
|
1745
|
+
spin
|
|
1746
|
+
]);
|
|
1747
|
+
const handleClick = (ev) => {
|
|
1748
|
+
ev.stopPropagation();
|
|
1749
|
+
runtime.setOutput(DEFAULT_OUTPUT5, Math.random());
|
|
1750
|
+
setSpin(true);
|
|
1751
|
+
};
|
|
1752
|
+
return /* @__PURE__ */ React17.createElement("div", {
|
|
1753
|
+
className: "flex grow items-center justify-center"
|
|
1754
|
+
}, /* @__PURE__ */ React17.createElement(Icon4, {
|
|
1755
|
+
icon,
|
|
1756
|
+
classNames: spin && "animate-[spin_1s]",
|
|
1757
|
+
size: 10,
|
|
1758
|
+
onClick: handleClick
|
|
1759
|
+
}));
|
|
1839
1760
|
};
|
|
1840
1761
|
var randomShape = {
|
|
1841
1762
|
type: "rng",
|
|
@@ -1851,13 +1772,12 @@ var randomShape = {
|
|
|
1851
1772
|
})
|
|
1852
1773
|
};
|
|
1853
1774
|
|
|
1854
|
-
//
|
|
1855
|
-
import
|
|
1856
|
-
import { Schema as Schema17 } from "effect";
|
|
1775
|
+
// src/shapes/Scope.tsx
|
|
1776
|
+
import * as Schema17 from "effect/Schema";
|
|
1857
1777
|
import React18 from "react";
|
|
1858
1778
|
import { DEFAULT_INPUT as DEFAULT_INPUT5 } from "@dxos/conductor";
|
|
1859
1779
|
import { createAnchorMap as createAnchorMap8 } from "@dxos/react-ui-canvas-editor";
|
|
1860
|
-
import {
|
|
1780
|
+
import { Chaos, shaderPresets, useAudioStream } from "@dxos/react-ui-sfx";
|
|
1861
1781
|
var ScopeShape = Schema17.extend(ComputeShape, Schema17.Struct({
|
|
1862
1782
|
type: Schema17.Literal("scope")
|
|
1863
1783
|
}));
|
|
@@ -1871,25 +1791,20 @@ var createScope = (props) => createShape({
|
|
|
1871
1791
|
...props
|
|
1872
1792
|
});
|
|
1873
1793
|
var ScopeComponent = ({ shape }) => {
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
}
|
|
1889
|
-
}));
|
|
1890
|
-
} finally {
|
|
1891
|
-
_effect.f();
|
|
1892
|
-
}
|
|
1794
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1795
|
+
const input = runtime.inputs[DEFAULT_INPUT5];
|
|
1796
|
+
const active = input?.type === "executed" ? input.value : false;
|
|
1797
|
+
const { getAverage } = useAudioStream(active);
|
|
1798
|
+
return /* @__PURE__ */ React18.createElement("div", {
|
|
1799
|
+
className: "flex is-full justify-center items-center bg-black"
|
|
1800
|
+
}, /* @__PURE__ */ React18.createElement(Chaos, {
|
|
1801
|
+
active,
|
|
1802
|
+
getValue: getAverage,
|
|
1803
|
+
options: {
|
|
1804
|
+
...shaderPresets.heptapod,
|
|
1805
|
+
zoom: 1.2
|
|
1806
|
+
}
|
|
1807
|
+
}));
|
|
1893
1808
|
};
|
|
1894
1809
|
var scopeShape = {
|
|
1895
1810
|
type: "scope",
|
|
@@ -1905,11 +1820,10 @@ var scopeShape = {
|
|
|
1905
1820
|
})
|
|
1906
1821
|
};
|
|
1907
1822
|
|
|
1908
|
-
//
|
|
1909
|
-
import
|
|
1910
|
-
import { Schema as Schema18 } from "effect";
|
|
1823
|
+
// src/shapes/Surface.tsx
|
|
1824
|
+
import * as Schema18 from "effect/Schema";
|
|
1911
1825
|
import React19 from "react";
|
|
1912
|
-
import { Surface } from "@dxos/app-framework";
|
|
1826
|
+
import { Surface } from "@dxos/app-framework/ui";
|
|
1913
1827
|
import { DEFAULT_INPUT as DEFAULT_INPUT6 } from "@dxos/conductor";
|
|
1914
1828
|
import { createAnchorMap as createAnchorMap9 } from "@dxos/react-ui-canvas-editor";
|
|
1915
1829
|
var SurfaceShape = Schema18.extend(ComputeShape, Schema18.Struct({
|
|
@@ -1924,29 +1838,24 @@ var createSurface = (props) => createShape({
|
|
|
1924
1838
|
...props
|
|
1925
1839
|
});
|
|
1926
1840
|
var SurfaceComponent = ({ shape }) => {
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
limit: 1
|
|
1946
|
-
}));
|
|
1947
|
-
} finally {
|
|
1948
|
-
_effect.f();
|
|
1949
|
-
}
|
|
1841
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1842
|
+
const input = runtime.inputs[DEFAULT_INPUT6];
|
|
1843
|
+
const value = input?.type === "executed" ? input.value : null;
|
|
1844
|
+
const handleAction = (action) => {
|
|
1845
|
+
if (action === "run") {
|
|
1846
|
+
runtime.evalNode();
|
|
1847
|
+
}
|
|
1848
|
+
};
|
|
1849
|
+
return /* @__PURE__ */ React19.createElement(Box, {
|
|
1850
|
+
shape,
|
|
1851
|
+
onAction: handleAction
|
|
1852
|
+
}, value !== null && /* @__PURE__ */ React19.createElement(Surface.Surface, {
|
|
1853
|
+
role: "card--extrinsic",
|
|
1854
|
+
data: {
|
|
1855
|
+
value
|
|
1856
|
+
},
|
|
1857
|
+
limit: 1
|
|
1858
|
+
}));
|
|
1950
1859
|
};
|
|
1951
1860
|
var surfaceShape = {
|
|
1952
1861
|
type: "surface",
|
|
@@ -1963,9 +1872,8 @@ var surfaceShape = {
|
|
|
1963
1872
|
resizable: true
|
|
1964
1873
|
};
|
|
1965
1874
|
|
|
1966
|
-
//
|
|
1967
|
-
import
|
|
1968
|
-
import { Schema as Schema19 } from "effect";
|
|
1875
|
+
// src/shapes/Switch.tsx
|
|
1876
|
+
import * as Schema19 from "effect/Schema";
|
|
1969
1877
|
import React20, { useEffect as useEffect6, useState as useState8 } from "react";
|
|
1970
1878
|
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT6 } from "@dxos/conductor";
|
|
1971
1879
|
import { Input as Input2 } from "@dxos/react-ui";
|
|
@@ -1982,25 +1890,20 @@ var createSwitch = (props) => createShape({
|
|
|
1982
1890
|
...props
|
|
1983
1891
|
});
|
|
1984
1892
|
var SwitchComponent = ({ shape }) => {
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
onCheckedChange: (value2) => setValue(value2)
|
|
2000
|
-
})));
|
|
2001
|
-
} finally {
|
|
2002
|
-
_effect.f();
|
|
2003
|
-
}
|
|
1893
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1894
|
+
const [value, setValue] = useState8(false);
|
|
1895
|
+
useEffect6(() => {
|
|
1896
|
+
runtime.setOutput(DEFAULT_OUTPUT6, value);
|
|
1897
|
+
}, [
|
|
1898
|
+
value
|
|
1899
|
+
]);
|
|
1900
|
+
return /* @__PURE__ */ React20.createElement("div", {
|
|
1901
|
+
className: "flex is-full justify-center items-center",
|
|
1902
|
+
onClick: (ev) => ev.stopPropagation()
|
|
1903
|
+
}, /* @__PURE__ */ React20.createElement(Input2.Root, null, /* @__PURE__ */ React20.createElement(Input2.Switch, {
|
|
1904
|
+
checked: value,
|
|
1905
|
+
onCheckedChange: (value2) => setValue(value2)
|
|
1906
|
+
})));
|
|
2004
1907
|
};
|
|
2005
1908
|
var switchShape = {
|
|
2006
1909
|
type: "switch",
|
|
@@ -2016,13 +1919,13 @@ var switchShape = {
|
|
|
2016
1919
|
})
|
|
2017
1920
|
};
|
|
2018
1921
|
|
|
2019
|
-
//
|
|
2020
|
-
import
|
|
2021
|
-
import { Schema as Schema20 } from "effect";
|
|
1922
|
+
// src/shapes/Table.tsx
|
|
1923
|
+
import * as Schema20 from "effect/Schema";
|
|
2022
1924
|
import React21 from "react";
|
|
2023
|
-
import { createInputSchema, createOutputSchema
|
|
2024
|
-
|
|
2025
|
-
var
|
|
1925
|
+
import { createInputSchema, createOutputSchema } from "@dxos/conductor";
|
|
1926
|
+
import { Message } from "@dxos/types";
|
|
1927
|
+
var InputSchema = createInputSchema(Message.Message);
|
|
1928
|
+
var OutputSchema = createOutputSchema(Schema20.mutable(Schema20.Array(Message.Message)));
|
|
2026
1929
|
var TableShape = Schema20.extend(ComputeShape, Schema20.Struct({
|
|
2027
1930
|
type: Schema20.Literal("table")
|
|
2028
1931
|
}));
|
|
@@ -2035,14 +1938,9 @@ var createTable = (props) => createShape({
|
|
|
2035
1938
|
...props
|
|
2036
1939
|
});
|
|
2037
1940
|
var TableComponent = ({ shape }) => {
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
shape
|
|
2042
|
-
});
|
|
2043
|
-
} finally {
|
|
2044
|
-
_effect.f();
|
|
2045
|
-
}
|
|
1941
|
+
return /* @__PURE__ */ React21.createElement(Box, {
|
|
1942
|
+
shape
|
|
1943
|
+
});
|
|
2046
1944
|
};
|
|
2047
1945
|
var tableShape = {
|
|
2048
1946
|
type: "table",
|
|
@@ -2054,63 +1952,57 @@ var tableShape = {
|
|
|
2054
1952
|
resizable: true
|
|
2055
1953
|
};
|
|
2056
1954
|
|
|
2057
|
-
//
|
|
2058
|
-
import
|
|
2059
|
-
import { Schema as Schema21 } from "effect";
|
|
1955
|
+
// src/shapes/Template.tsx
|
|
1956
|
+
import * as Schema21 from "effect/Schema";
|
|
2060
1957
|
import React22, { useRef as useRef5 } from "react";
|
|
2061
|
-
import { ComputeValueType as ComputeValueType3,
|
|
2062
|
-
import { toJsonSchema
|
|
1958
|
+
import { ComputeValueType as ComputeValueType3, TemplateOutput, VoidInput as VoidInput2, getTemplateInputSchema as getTemplateInputSchema2 } from "@dxos/conductor";
|
|
1959
|
+
import { toJsonSchema } from "@dxos/echo/internal";
|
|
2063
1960
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
2064
1961
|
import { TextBox as TextBox4 } from "@dxos/react-ui-canvas-editor";
|
|
2065
|
-
var __dxlog_file6 = "/
|
|
1962
|
+
var __dxlog_file6 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/Template.tsx";
|
|
2066
1963
|
var TemplateShape = Schema21.extend(ComputeShape, Schema21.Struct({
|
|
2067
1964
|
type: Schema21.Literal("template"),
|
|
2068
1965
|
valueType: Schema21.optional(ComputeValueType3)
|
|
2069
1966
|
}));
|
|
2070
1967
|
var TextInputComponent3 = ({ shape, title, ...props }) => {
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
const
|
|
2075
|
-
|
|
2076
|
-
const
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
onEnter: handleEnter
|
|
2110
|
-
}));
|
|
2111
|
-
} finally {
|
|
2112
|
-
_effect.f();
|
|
2113
|
-
}
|
|
1968
|
+
const { node } = useComputeNodeState(shape);
|
|
1969
|
+
const inputRef = useRef5(null);
|
|
1970
|
+
const handleEnter = (text) => {
|
|
1971
|
+
const value = text.trim();
|
|
1972
|
+
if (value.length) {
|
|
1973
|
+
const schema = getTemplateInputSchema2(node);
|
|
1974
|
+
node.value = value;
|
|
1975
|
+
node.inputSchema = toJsonSchema(schema);
|
|
1976
|
+
}
|
|
1977
|
+
};
|
|
1978
|
+
const handleTypeChange = (newType) => {
|
|
1979
|
+
invariant5(Schema21.is(ComputeValueType3)(newType), "Invalid type", {
|
|
1980
|
+
F: __dxlog_file6,
|
|
1981
|
+
L: 59,
|
|
1982
|
+
S: void 0,
|
|
1983
|
+
A: [
|
|
1984
|
+
"Schema.is(ComputeValueType)(newType)",
|
|
1985
|
+
"'Invalid type'"
|
|
1986
|
+
]
|
|
1987
|
+
});
|
|
1988
|
+
node.valueType = newType;
|
|
1989
|
+
node.inputSchema = toJsonSchema(getTemplateInputSchema2(node));
|
|
1990
|
+
};
|
|
1991
|
+
return /* @__PURE__ */ React22.createElement(Box, {
|
|
1992
|
+
shape,
|
|
1993
|
+
title: "Template",
|
|
1994
|
+
status: /* @__PURE__ */ React22.createElement(TypeSelect, {
|
|
1995
|
+
value: node.valueType ?? "string",
|
|
1996
|
+
onValueChange: handleTypeChange
|
|
1997
|
+
})
|
|
1998
|
+
}, /* @__PURE__ */ React22.createElement(TextBox4, {
|
|
1999
|
+
...props,
|
|
2000
|
+
ref: inputRef,
|
|
2001
|
+
value: node.value,
|
|
2002
|
+
language: node.valueType === "object" ? "json" : void 0,
|
|
2003
|
+
onBlur: handleEnter,
|
|
2004
|
+
onEnter: handleEnter
|
|
2005
|
+
}));
|
|
2114
2006
|
};
|
|
2115
2007
|
var createTemplate = (props) => createShape({
|
|
2116
2008
|
type: "template",
|
|
@@ -2133,9 +2025,8 @@ var templateShape = {
|
|
|
2133
2025
|
resizable: true
|
|
2134
2026
|
};
|
|
2135
2027
|
|
|
2136
|
-
//
|
|
2137
|
-
import
|
|
2138
|
-
import { Schema as Schema22 } from "effect";
|
|
2028
|
+
// src/shapes/Text.tsx
|
|
2029
|
+
import * as Schema22 from "effect/Schema";
|
|
2139
2030
|
import React23 from "react";
|
|
2140
2031
|
import { DEFAULT_INPUT as DEFAULT_INPUT7 } from "@dxos/conductor";
|
|
2141
2032
|
import { TextBox as TextBox5 } from "@dxos/react-ui-canvas-editor";
|
|
@@ -2152,25 +2043,20 @@ var createText = (props) => createShape({
|
|
|
2152
2043
|
...props
|
|
2153
2044
|
});
|
|
2154
2045
|
var TextComponent = ({ shape }) => {
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
value
|
|
2170
|
-
}));
|
|
2171
|
-
} finally {
|
|
2172
|
-
_effect.f();
|
|
2173
|
-
}
|
|
2046
|
+
const { runtime } = useComputeNodeState(shape);
|
|
2047
|
+
const input = runtime.inputs[DEFAULT_INPUT7];
|
|
2048
|
+
const value = input?.type === "executed" ? input.value : 0;
|
|
2049
|
+
const handleAction = (action) => {
|
|
2050
|
+
if (action === "run") {
|
|
2051
|
+
runtime.evalNode();
|
|
2052
|
+
}
|
|
2053
|
+
};
|
|
2054
|
+
return /* @__PURE__ */ React23.createElement(Box, {
|
|
2055
|
+
shape,
|
|
2056
|
+
onAction: handleAction
|
|
2057
|
+
}, /* @__PURE__ */ React23.createElement(TextBox5, {
|
|
2058
|
+
value
|
|
2059
|
+
}));
|
|
2174
2060
|
};
|
|
2175
2061
|
var textShape = {
|
|
2176
2062
|
type: "text",
|
|
@@ -2187,14 +2073,15 @@ var textShape = {
|
|
|
2187
2073
|
resizable: true
|
|
2188
2074
|
};
|
|
2189
2075
|
|
|
2190
|
-
//
|
|
2191
|
-
import
|
|
2192
|
-
import { Schema as Schema23 } from "effect";
|
|
2076
|
+
// src/shapes/Thread.tsx
|
|
2077
|
+
import * as Schema23 from "effect/Schema";
|
|
2193
2078
|
import React24, { useEffect as useEffect7, useRef as useRef6 } from "react";
|
|
2194
|
-
import { createInputSchema as createInputSchema2, createOutputSchema as createOutputSchema2
|
|
2195
|
-
import {
|
|
2196
|
-
|
|
2197
|
-
|
|
2079
|
+
import { createInputSchema as createInputSchema2, createOutputSchema as createOutputSchema2 } from "@dxos/conductor";
|
|
2080
|
+
import { ScrollArea as ScrollArea3 } from "@dxos/react-ui";
|
|
2081
|
+
import { Message as Message2 } from "@dxos/types";
|
|
2082
|
+
import { mx as mx3 } from "@dxos/ui-theme";
|
|
2083
|
+
var InputSchema2 = createInputSchema2(Message2.Message);
|
|
2084
|
+
var OutputSchema2 = createOutputSchema2(Schema23.mutable(Schema23.Array(Message2.Message)));
|
|
2198
2085
|
var ThreadShape = Schema23.extend(ComputeShape, Schema23.Struct({
|
|
2199
2086
|
type: Schema23.Literal("thread")
|
|
2200
2087
|
}));
|
|
@@ -2207,49 +2094,42 @@ var createThread = (props) => createShape({
|
|
|
2207
2094
|
...props
|
|
2208
2095
|
});
|
|
2209
2096
|
var ThreadComponent = ({ shape }) => {
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
} finally {
|
|
2233
|
-
_effect.f();
|
|
2234
|
-
}
|
|
2097
|
+
const items = [];
|
|
2098
|
+
const scrollRef = useRef6(null);
|
|
2099
|
+
useEffect7(() => {
|
|
2100
|
+
if (scrollRef.current) {
|
|
2101
|
+
scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
|
|
2102
|
+
}
|
|
2103
|
+
}, [
|
|
2104
|
+
items
|
|
2105
|
+
]);
|
|
2106
|
+
return /* @__PURE__ */ React24.createElement(Box, {
|
|
2107
|
+
shape
|
|
2108
|
+
}, /* @__PURE__ */ React24.createElement(ScrollArea3.Root, {
|
|
2109
|
+
orientation: "vertical"
|
|
2110
|
+
}, /* @__PURE__ */ React24.createElement(ScrollArea3.Viewport, {
|
|
2111
|
+
classNames: "gap-2 p-2",
|
|
2112
|
+
ref: scrollRef
|
|
2113
|
+
}, [
|
|
2114
|
+
...items
|
|
2115
|
+
].map((item, i) => /* @__PURE__ */ React24.createElement(ThreadItem, {
|
|
2116
|
+
key: i,
|
|
2117
|
+
item
|
|
2118
|
+
})))));
|
|
2235
2119
|
};
|
|
2236
2120
|
var ThreadItem = ({ classNames, item }) => {
|
|
2237
|
-
|
|
2238
|
-
try {
|
|
2239
|
-
if (typeof item !== "object") {
|
|
2240
|
-
return /* @__PURE__ */ React24.createElement("div", {
|
|
2241
|
-
className: mx5(classNames)
|
|
2242
|
-
}, item);
|
|
2243
|
-
}
|
|
2244
|
-
const { role, message } = item;
|
|
2121
|
+
if (typeof item !== "object") {
|
|
2245
2122
|
return /* @__PURE__ */ React24.createElement("div", {
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
}, message));
|
|
2250
|
-
} finally {
|
|
2251
|
-
_effect.f();
|
|
2123
|
+
role: "none",
|
|
2124
|
+
className: mx3(classNames)
|
|
2125
|
+
}, item);
|
|
2252
2126
|
}
|
|
2127
|
+
const { role, message } = item;
|
|
2128
|
+
return /* @__PURE__ */ React24.createElement("div", {
|
|
2129
|
+
className: mx3("flex", classNames, role === "user" && "justify-end")
|
|
2130
|
+
}, /* @__PURE__ */ React24.createElement("div", {
|
|
2131
|
+
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")
|
|
2132
|
+
}, message));
|
|
2253
2133
|
};
|
|
2254
2134
|
var threadShape = {
|
|
2255
2135
|
type: "thread",
|
|
@@ -2261,9 +2141,8 @@ var threadShape = {
|
|
|
2261
2141
|
resizable: true
|
|
2262
2142
|
};
|
|
2263
2143
|
|
|
2264
|
-
//
|
|
2265
|
-
import
|
|
2266
|
-
import { Schema as Schema24 } from "effect";
|
|
2144
|
+
// src/shapes/TextToImage.tsx
|
|
2145
|
+
import * as Schema24 from "effect/Schema";
|
|
2267
2146
|
import React25 from "react";
|
|
2268
2147
|
import { createAnchorMap as createAnchorMap12 } from "@dxos/react-ui-canvas-editor";
|
|
2269
2148
|
var TextToImageShape = Schema24.extend(ComputeShape, Schema24.Struct({
|
|
@@ -2278,14 +2157,9 @@ var createTextToImage = (props) => createShape({
|
|
|
2278
2157
|
...props
|
|
2279
2158
|
});
|
|
2280
2159
|
var TextToImageComponent = ({ shape }) => {
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
shape
|
|
2285
|
-
});
|
|
2286
|
-
} finally {
|
|
2287
|
-
_effect.f();
|
|
2288
|
-
}
|
|
2160
|
+
return /* @__PURE__ */ React25.createElement(Box, {
|
|
2161
|
+
shape
|
|
2162
|
+
});
|
|
2289
2163
|
};
|
|
2290
2164
|
var textToImageShape = {
|
|
2291
2165
|
type: "text-to-image",
|
|
@@ -2301,127 +2175,122 @@ var textToImageShape = {
|
|
|
2301
2175
|
})
|
|
2302
2176
|
};
|
|
2303
2177
|
|
|
2304
|
-
//
|
|
2305
|
-
import
|
|
2306
|
-
import { Schema as Schema25 } from "effect";
|
|
2178
|
+
// src/shapes/Trigger.tsx
|
|
2179
|
+
import * as Schema25 from "effect/Schema";
|
|
2307
2180
|
import React26, { useEffect as useEffect8 } from "react";
|
|
2308
2181
|
import { VoidInput as VoidInput3 } from "@dxos/conductor";
|
|
2309
|
-
import {
|
|
2310
|
-
import {
|
|
2182
|
+
import { Filter as Filter2, Obj as Obj4, Query, Ref as Ref3, Type } from "@dxos/echo";
|
|
2183
|
+
import { Trigger, TriggerEvent } from "@dxos/functions";
|
|
2311
2184
|
import { DXN, SpaceId } from "@dxos/keys";
|
|
2312
|
-
import {
|
|
2185
|
+
import { useSpace } from "@dxos/react-client/echo";
|
|
2313
2186
|
import { Select as Select2 } from "@dxos/react-ui";
|
|
2314
2187
|
var TriggerShape = Schema25.extend(ComputeShape, Schema25.Struct({
|
|
2315
2188
|
type: Schema25.Literal("trigger"),
|
|
2316
|
-
functionTrigger: Schema25.optional(
|
|
2189
|
+
functionTrigger: Schema25.optional(Type.Ref(Trigger.Trigger))
|
|
2317
2190
|
}));
|
|
2318
2191
|
var createTrigger = (props) => {
|
|
2319
|
-
const functionTrigger =
|
|
2192
|
+
const functionTrigger = Trigger.make({
|
|
2320
2193
|
enabled: true,
|
|
2321
2194
|
spec: createTriggerSpec(props)
|
|
2322
2195
|
});
|
|
2323
2196
|
return createShape({
|
|
2324
2197
|
type: "trigger",
|
|
2325
|
-
functionTrigger:
|
|
2198
|
+
functionTrigger: Ref3.make(functionTrigger),
|
|
2326
2199
|
size: {
|
|
2327
2200
|
width: 192,
|
|
2328
|
-
height: getHeight(
|
|
2201
|
+
height: getHeight(TriggerEvent.EmailEvent)
|
|
2329
2202
|
},
|
|
2330
2203
|
...props
|
|
2331
2204
|
});
|
|
2332
2205
|
};
|
|
2333
2206
|
var TriggerComponent = ({ shape }) => {
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
triggerKind: TriggerKind.Email,
|
|
2207
|
+
const space = useSpace();
|
|
2208
|
+
const functionTrigger = shape.functionTrigger?.target;
|
|
2209
|
+
useEffect8(() => {
|
|
2210
|
+
if (functionTrigger && !functionTrigger.spec) {
|
|
2211
|
+
Obj4.change(functionTrigger, (t) => {
|
|
2212
|
+
t.spec = createTriggerSpec({
|
|
2213
|
+
triggerKind: "email",
|
|
2342
2214
|
spaceId: space?.id
|
|
2343
2215
|
});
|
|
2344
|
-
}
|
|
2345
|
-
}
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2216
|
+
});
|
|
2217
|
+
}
|
|
2218
|
+
}, [
|
|
2219
|
+
functionTrigger,
|
|
2220
|
+
functionTrigger?.spec
|
|
2221
|
+
]);
|
|
2222
|
+
useEffect8(() => {
|
|
2223
|
+
shape.size.height = getHeight(getOutputSchema(functionTrigger?.spec?.kind ?? "email"));
|
|
2224
|
+
}, [
|
|
2225
|
+
functionTrigger?.spec?.kind
|
|
2226
|
+
]);
|
|
2227
|
+
const setKind = (kind) => {
|
|
2228
|
+
if (functionTrigger?.spec?.kind !== kind) {
|
|
2229
|
+
Obj4.change(functionTrigger, (t) => {
|
|
2230
|
+
t.spec = createTriggerSpec({
|
|
2357
2231
|
triggerKind: kind,
|
|
2358
2232
|
spaceId: space?.id
|
|
2359
2233
|
});
|
|
2360
|
-
}
|
|
2361
|
-
};
|
|
2362
|
-
if (!functionTrigger?.spec) {
|
|
2363
|
-
return;
|
|
2234
|
+
});
|
|
2364
2235
|
}
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
value: functionTrigger.spec?.kind,
|
|
2369
|
-
onValueChange: (kind) => setKind(kind)
|
|
2370
|
-
}),
|
|
2371
|
-
inputSchema: VoidInput3,
|
|
2372
|
-
outputSchema: getOutputSchema(functionTrigger.spec.kind)
|
|
2373
|
-
});
|
|
2374
|
-
} finally {
|
|
2375
|
-
_effect.f();
|
|
2236
|
+
};
|
|
2237
|
+
if (!functionTrigger?.spec) {
|
|
2238
|
+
return;
|
|
2376
2239
|
}
|
|
2240
|
+
return /* @__PURE__ */ React26.createElement(FunctionBody, {
|
|
2241
|
+
shape,
|
|
2242
|
+
status: /* @__PURE__ */ React26.createElement(TriggerKindSelect, {
|
|
2243
|
+
value: functionTrigger.spec?.kind,
|
|
2244
|
+
onValueChange: (kind) => setKind(kind)
|
|
2245
|
+
}),
|
|
2246
|
+
inputSchema: VoidInput3,
|
|
2247
|
+
outputSchema: getOutputSchema(functionTrigger.spec.kind)
|
|
2248
|
+
});
|
|
2377
2249
|
};
|
|
2378
2250
|
var TriggerKindSelect = ({ value, onValueChange }) => {
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
value: kind
|
|
2390
|
-
}, kind))), /* @__PURE__ */ React26.createElement(Select2.ScrollDownButton, null), /* @__PURE__ */ React26.createElement(Select2.Arrow, null))));
|
|
2391
|
-
} finally {
|
|
2392
|
-
_effect.f();
|
|
2393
|
-
}
|
|
2251
|
+
return /* @__PURE__ */ React26.createElement(Select2.Root, {
|
|
2252
|
+
value,
|
|
2253
|
+
onValueChange
|
|
2254
|
+
}, /* @__PURE__ */ React26.createElement(Select2.TriggerButton, {
|
|
2255
|
+
variant: "ghost",
|
|
2256
|
+
classNames: "is-full !pli-0"
|
|
2257
|
+
}), /* @__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, {
|
|
2258
|
+
key: kind,
|
|
2259
|
+
value: kind
|
|
2260
|
+
}, kind))), /* @__PURE__ */ React26.createElement(Select2.ScrollDownButton, null), /* @__PURE__ */ React26.createElement(Select2.Arrow, null))));
|
|
2394
2261
|
};
|
|
2395
2262
|
var createTriggerSpec = (props) => {
|
|
2396
|
-
const kind = props.triggerKind ??
|
|
2263
|
+
const kind = props.triggerKind ?? "email";
|
|
2397
2264
|
switch (kind) {
|
|
2398
|
-
case
|
|
2265
|
+
case "timer":
|
|
2399
2266
|
return {
|
|
2400
|
-
kind:
|
|
2267
|
+
kind: "timer",
|
|
2401
2268
|
cron: "*/10 * * * * *"
|
|
2402
2269
|
};
|
|
2403
|
-
case
|
|
2270
|
+
case "webhook":
|
|
2404
2271
|
return {
|
|
2405
|
-
kind:
|
|
2272
|
+
kind: "webhook",
|
|
2406
2273
|
method: "POST"
|
|
2407
2274
|
};
|
|
2408
|
-
case
|
|
2275
|
+
case "subscription":
|
|
2409
2276
|
return {
|
|
2410
|
-
kind:
|
|
2411
|
-
|
|
2277
|
+
kind: "subscription",
|
|
2278
|
+
query: {
|
|
2279
|
+
ast: Query.select(Filter2.nothing()).ast
|
|
2280
|
+
}
|
|
2412
2281
|
};
|
|
2413
|
-
case
|
|
2282
|
+
case "email":
|
|
2414
2283
|
return {
|
|
2415
|
-
kind:
|
|
2284
|
+
kind: "email"
|
|
2416
2285
|
};
|
|
2417
|
-
case
|
|
2286
|
+
case "queue": {
|
|
2418
2287
|
const dxn = new DXN(DXN.kind.QUEUE, [
|
|
2419
2288
|
"data",
|
|
2420
2289
|
props.spaceId ?? SpaceId.random(),
|
|
2421
|
-
|
|
2290
|
+
Obj4.ID.random()
|
|
2422
2291
|
]).toString();
|
|
2423
2292
|
return {
|
|
2424
|
-
kind:
|
|
2293
|
+
kind: "queue",
|
|
2425
2294
|
queue: dxn
|
|
2426
2295
|
};
|
|
2427
2296
|
}
|
|
@@ -2429,11 +2298,11 @@ var createTriggerSpec = (props) => {
|
|
|
2429
2298
|
};
|
|
2430
2299
|
var getOutputSchema = (kind) => {
|
|
2431
2300
|
const kindToSchema = {
|
|
2432
|
-
[
|
|
2433
|
-
[
|
|
2434
|
-
[
|
|
2435
|
-
[
|
|
2436
|
-
[
|
|
2301
|
+
["email"]: TriggerEvent.EmailEvent,
|
|
2302
|
+
["subscription"]: TriggerEvent.SubscriptionEvent,
|
|
2303
|
+
["timer"]: TriggerEvent.TimerEvent,
|
|
2304
|
+
["webhook"]: TriggerEvent.WebhookEvent,
|
|
2305
|
+
["queue"]: TriggerEvent.QueueEvent
|
|
2437
2306
|
};
|
|
2438
2307
|
return kindToSchema[kind];
|
|
2439
2308
|
};
|
|
@@ -2443,17 +2312,16 @@ var triggerShape = {
|
|
|
2443
2312
|
icon: "ph--lightning--regular",
|
|
2444
2313
|
component: TriggerComponent,
|
|
2445
2314
|
createShape: createTrigger,
|
|
2446
|
-
getAnchors: (shape) => createFunctionAnchors(shape, VoidInput3, getOutputSchema(shape.functionTrigger?.target?.spec?.kind ??
|
|
2315
|
+
getAnchors: (shape) => createFunctionAnchors(shape, VoidInput3, getOutputSchema(shape.functionTrigger?.target?.spec?.kind ?? "email"))
|
|
2447
2316
|
};
|
|
2448
2317
|
|
|
2449
|
-
//
|
|
2450
|
-
import
|
|
2451
|
-
import { Schema as Schema26 } from "effect";
|
|
2318
|
+
// src/shapes/GptRealtime.tsx
|
|
2319
|
+
import * as Schema26 from "effect/Schema";
|
|
2452
2320
|
import React27, { useState as useState9 } from "react";
|
|
2453
2321
|
import { log as log2 } from "@dxos/log";
|
|
2454
2322
|
import { useConfig } from "@dxos/react-client";
|
|
2455
2323
|
import { Icon as Icon5 } from "@dxos/react-ui";
|
|
2456
|
-
var __dxlog_file7 = "/
|
|
2324
|
+
var __dxlog_file7 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/GptRealtime.tsx";
|
|
2457
2325
|
var GptRealtimeShape = Schema26.extend(ComputeShape, Schema26.Struct({
|
|
2458
2326
|
type: Schema26.Literal("gpt-realtime")
|
|
2459
2327
|
}));
|
|
@@ -2466,105 +2334,100 @@ var createGptRealtime = (props) => createShape({
|
|
|
2466
2334
|
...props
|
|
2467
2335
|
});
|
|
2468
2336
|
var GptRealtimeComponent = ({ shape }) => {
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
const
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2337
|
+
const [isLive, setIsLive] = useState9(false);
|
|
2338
|
+
const [isReady, setIsReady] = useState9(false);
|
|
2339
|
+
const config = useConfig();
|
|
2340
|
+
const start = async () => {
|
|
2341
|
+
setIsLive(true);
|
|
2342
|
+
try {
|
|
2343
|
+
const peerConnection = new RTCPeerConnection();
|
|
2344
|
+
peerConnection.ontrack = (event) => {
|
|
2345
|
+
const audioElement = document.createElement("audio");
|
|
2346
|
+
audioElement.srcObject = event.streams[0];
|
|
2347
|
+
audioElement.autoplay = true;
|
|
2348
|
+
audioElement.controls = false;
|
|
2349
|
+
audioElement.style.display = "none";
|
|
2350
|
+
document.body.appendChild(audioElement);
|
|
2351
|
+
setIsReady(true);
|
|
2352
|
+
};
|
|
2353
|
+
const stream = await navigator.mediaDevices.getUserMedia({
|
|
2354
|
+
audio: true
|
|
2355
|
+
});
|
|
2356
|
+
stream.getTracks().forEach((track) => peerConnection.addTransceiver(track, {
|
|
2357
|
+
direction: "sendrecv"
|
|
2358
|
+
}));
|
|
2359
|
+
const offer = await peerConnection.createOffer();
|
|
2360
|
+
await peerConnection.setLocalDescription(offer);
|
|
2361
|
+
const AiServiceUrl = new URL("/rtc-connect", config.values.runtime?.services?.ai?.server ?? DEFAULT_AI_SERVICE_URL);
|
|
2362
|
+
const response = await fetch(AiServiceUrl, {
|
|
2363
|
+
method: "POST",
|
|
2364
|
+
body: offer.sdp,
|
|
2365
|
+
headers: {
|
|
2366
|
+
"Content-Type": "application/sdp"
|
|
2367
|
+
}
|
|
2368
|
+
});
|
|
2369
|
+
const answer = await response.text();
|
|
2370
|
+
await peerConnection.setRemoteDescription({
|
|
2371
|
+
sdp: answer,
|
|
2372
|
+
type: "answer"
|
|
2373
|
+
});
|
|
2374
|
+
const dataChannel = peerConnection.createDataChannel("response");
|
|
2375
|
+
const configureData = () => {
|
|
2376
|
+
log2.info("Configuring data channel", void 0, {
|
|
2377
|
+
F: __dxlog_file7,
|
|
2378
|
+
L: 87,
|
|
2379
|
+
S: void 0,
|
|
2380
|
+
C: (f, a) => f(...a)
|
|
2489
2381
|
});
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
headers: {
|
|
2500
|
-
"Content-Type": "application/sdp"
|
|
2382
|
+
const event = {
|
|
2383
|
+
type: "session.update",
|
|
2384
|
+
session: {
|
|
2385
|
+
modalities: [
|
|
2386
|
+
"text",
|
|
2387
|
+
"audio"
|
|
2388
|
+
],
|
|
2389
|
+
// Provide the tools. Note they match the keys in the `fns` object above
|
|
2390
|
+
tools: []
|
|
2501
2391
|
}
|
|
2502
|
-
});
|
|
2503
|
-
const answer = await response.text();
|
|
2504
|
-
await peerConnection.setRemoteDescription({
|
|
2505
|
-
sdp: answer,
|
|
2506
|
-
type: "answer"
|
|
2507
|
-
});
|
|
2508
|
-
const dataChannel = peerConnection.createDataChannel("response");
|
|
2509
|
-
const configureData = () => {
|
|
2510
|
-
log2.info("Configuring data channel", void 0, {
|
|
2511
|
-
F: __dxlog_file7,
|
|
2512
|
-
L: 87,
|
|
2513
|
-
S: void 0,
|
|
2514
|
-
C: (f, a) => f(...a)
|
|
2515
|
-
});
|
|
2516
|
-
const event = {
|
|
2517
|
-
type: "session.update",
|
|
2518
|
-
session: {
|
|
2519
|
-
modalities: [
|
|
2520
|
-
"text",
|
|
2521
|
-
"audio"
|
|
2522
|
-
],
|
|
2523
|
-
// Provide the tools. Note they match the keys in the `fns` object above
|
|
2524
|
-
tools: []
|
|
2525
|
-
}
|
|
2526
|
-
};
|
|
2527
|
-
dataChannel.send(JSON.stringify(event));
|
|
2528
2392
|
};
|
|
2529
|
-
dataChannel.
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
L: 100,
|
|
2535
|
-
S: void 0,
|
|
2536
|
-
C: (f, a) => f(...a)
|
|
2537
|
-
});
|
|
2538
|
-
configureData();
|
|
2539
|
-
});
|
|
2540
|
-
dataChannel.addEventListener("message", async (ev) => {
|
|
2541
|
-
const msg = JSON.parse(ev.data);
|
|
2542
|
-
if (msg.type === "response.function_call_arguments.done") {
|
|
2543
|
-
}
|
|
2544
|
-
});
|
|
2545
|
-
} catch (error) {
|
|
2546
|
-
log2.error("Error in realtime session:", {
|
|
2547
|
-
error
|
|
2393
|
+
dataChannel.send(JSON.stringify(event));
|
|
2394
|
+
};
|
|
2395
|
+
dataChannel.addEventListener("open", (ev) => {
|
|
2396
|
+
log2.info("Opening data channel", {
|
|
2397
|
+
ev
|
|
2548
2398
|
}, {
|
|
2549
2399
|
F: __dxlog_file7,
|
|
2550
|
-
L:
|
|
2400
|
+
L: 100,
|
|
2551
2401
|
S: void 0,
|
|
2552
2402
|
C: (f, a) => f(...a)
|
|
2553
2403
|
});
|
|
2554
|
-
|
|
2555
|
-
}
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2404
|
+
configureData();
|
|
2405
|
+
});
|
|
2406
|
+
dataChannel.addEventListener("message", async (ev) => {
|
|
2407
|
+
const msg = JSON.parse(ev.data);
|
|
2408
|
+
if (msg.type === "response.function_call_arguments.done") {
|
|
2409
|
+
}
|
|
2410
|
+
});
|
|
2411
|
+
} catch (error) {
|
|
2412
|
+
log2.error("Error in realtime session:", {
|
|
2413
|
+
error
|
|
2414
|
+
}, {
|
|
2415
|
+
F: __dxlog_file7,
|
|
2416
|
+
L: 140,
|
|
2417
|
+
S: void 0,
|
|
2418
|
+
C: (f, a) => f(...a)
|
|
2419
|
+
});
|
|
2420
|
+
throw error;
|
|
2421
|
+
}
|
|
2422
|
+
};
|
|
2423
|
+
return /* @__PURE__ */ React27.createElement("div", {
|
|
2424
|
+
className: "flex is-full justify-center items-center"
|
|
2425
|
+
}, /* @__PURE__ */ React27.createElement(Icon5, {
|
|
2426
|
+
icon: isReady ? "ph--waveform--regular" : isLive ? "ph--pulse--regular" : "ph--play--regular",
|
|
2427
|
+
size: 16,
|
|
2428
|
+
classNames: !isLive && "cursor-pointer",
|
|
2429
|
+
onClick: start
|
|
2430
|
+
}));
|
|
2568
2431
|
};
|
|
2569
2432
|
var gptRealtimeShape = {
|
|
2570
2433
|
type: "gpt-realtime",
|
|
@@ -2580,7 +2443,7 @@ var gptRealtimeShape = {
|
|
|
2580
2443
|
};
|
|
2581
2444
|
var DEFAULT_AI_SERVICE_URL = "http://localhost:8788";
|
|
2582
2445
|
|
|
2583
|
-
//
|
|
2446
|
+
// src/registry.ts
|
|
2584
2447
|
var computeShapes = [
|
|
2585
2448
|
{
|
|
2586
2449
|
title: "Inputs",
|
|
@@ -2642,11 +2505,12 @@ var computeShapes = [
|
|
|
2642
2505
|
}
|
|
2643
2506
|
];
|
|
2644
2507
|
|
|
2645
|
-
//
|
|
2508
|
+
// src/compute-layout.ts
|
|
2646
2509
|
import { DefaultInput, DefaultOutput as DefaultOutput2 } from "@dxos/conductor";
|
|
2647
|
-
import { toEffectSchema } from "@dxos/echo
|
|
2510
|
+
import { toEffectSchema } from "@dxos/echo/internal";
|
|
2648
2511
|
import { ShapeLayout } from "@dxos/react-ui-canvas-editor";
|
|
2649
2512
|
var ComputeShapeLayout = class extends ShapeLayout {
|
|
2513
|
+
_controller;
|
|
2650
2514
|
constructor(_controller, registry2) {
|
|
2651
2515
|
super(registry2), this._controller = _controller;
|
|
2652
2516
|
}
|