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