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