@dxos/react-ui-canvas-compute 0.8.4-main.70d3990 → 0.8.4-main.74a063c4e0
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 +884 -1048
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +884 -1048
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/compute.stories.d.ts +22 -1
- package/dist/types/src/compute.stories.d.ts.map +1 -1
- package/dist/types/src/graph/controller.d.ts +8 -4
- package/dist/types/src/graph/controller.d.ts.map +1 -1
- 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/shapes/Audio.d.ts.map +1 -1
- package/dist/types/src/shapes/Beacon.d.ts.map +1 -1
- package/dist/types/src/shapes/Chat.d.ts.map +1 -1
- package/dist/types/src/shapes/Constant.d.ts.map +1 -1
- package/dist/types/src/shapes/{Queue.d.ts → Feed.d.ts} +8 -8
- package/dist/types/src/shapes/Feed.d.ts.map +1 -0
- package/dist/types/src/shapes/Function.d.ts.map +1 -1
- package/dist/types/src/shapes/Gpt.d.ts.map +1 -1
- package/dist/types/src/shapes/Json.d.ts.map +1 -1
- package/dist/types/src/shapes/RNG.d.ts.map +1 -1
- package/dist/types/src/shapes/Scope.d.ts.map +1 -1
- package/dist/types/src/shapes/Surface.d.ts.map +1 -1
- package/dist/types/src/shapes/Switch.d.ts.map +1 -1
- package/dist/types/src/shapes/Template.d.ts.map +1 -1
- package/dist/types/src/shapes/Text.d.ts.map +1 -1
- package/dist/types/src/shapes/Thread.d.ts.map +1 -1
- package/dist/types/src/shapes/Trigger.d.ts +4 -2
- 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 +2 -2
- package/dist/types/src/shapes/common/FunctionBody.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 -56
- package/src/README.md +0 -3
- package/src/compute.stories.tsx +80 -116
- package/src/graph/controller.ts +101 -68
- package/src/graph/node-defs.ts +28 -28
- package/src/hooks/useComputeNodeState.ts +0 -1
- package/src/hooks/useGraphMonitor.ts +9 -8
- package/src/json.test.ts +3 -3
- package/src/registry.ts +2 -2
- package/src/schema.test.ts +6 -6
- 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 +0 -1
- package/src/shapes/Constant.tsx +0 -1
- package/src/shapes/{Queue.tsx → Feed.tsx} +26 -21
- package/src/shapes/Function.tsx +10 -8
- package/src/shapes/Gpt.tsx +6 -2
- package/src/shapes/GptRealtime.tsx +1 -1
- package/src/shapes/Json.tsx +7 -3
- package/src/shapes/RNG.tsx +0 -1
- package/src/shapes/Scope.tsx +1 -2
- package/src/shapes/Surface.tsx +4 -3
- package/src/shapes/Switch.tsx +1 -2
- package/src/shapes/Template.tsx +0 -1
- package/src/shapes/Text.tsx +0 -1
- package/src/shapes/Thread.tsx +15 -9
- package/src/shapes/Trigger.tsx +12 -6
- package/src/shapes/common/Box.tsx +8 -11
- package/src/shapes/common/FunctionBody.tsx +4 -4
- package/src/shapes/common/TypeSelect.tsx +1 -1
- package/src/shapes/index.ts +2 -2
- package/src/testing/circuits.ts +6 -14
- package/dist/types/src/shapes/Queue.d.ts.map +0 -1
|
@@ -4,10 +4,13 @@ import "@dxos/node-std/globals";
|
|
|
4
4
|
import * as Effect from "effect/Effect";
|
|
5
5
|
import * as Either from "effect/Either";
|
|
6
6
|
import * as Exit from "effect/Exit";
|
|
7
|
+
import * as Layer from "effect/Layer";
|
|
7
8
|
import * as Scope from "effect/Scope";
|
|
8
9
|
import { Event, synchronized } from "@dxos/async";
|
|
9
10
|
import { GraphExecutor, ValueBag, isNotExecuted } from "@dxos/conductor";
|
|
10
11
|
import { Resource } from "@dxos/context";
|
|
12
|
+
import { unwrapExit } from "@dxos/effect";
|
|
13
|
+
import { ComputeEventLogger, Trace, TracingService } from "@dxos/functions";
|
|
11
14
|
import { log } from "@dxos/log";
|
|
12
15
|
|
|
13
16
|
// src/hooks/compute-context.ts
|
|
@@ -77,7 +80,7 @@ var useComputeNodeState = (shape) => {
|
|
|
77
80
|
const { controller } = useComputeContext();
|
|
78
81
|
invariant(controller, void 0, {
|
|
79
82
|
F: __dxlog_file,
|
|
80
|
-
L:
|
|
83
|
+
L: 33,
|
|
81
84
|
S: void 0,
|
|
82
85
|
A: [
|
|
83
86
|
"controller",
|
|
@@ -90,7 +93,7 @@ var useComputeNodeState = (shape) => {
|
|
|
90
93
|
queueMicrotask(async () => {
|
|
91
94
|
invariant(shape.node, "Node not specified", {
|
|
92
95
|
F: __dxlog_file,
|
|
93
|
-
L:
|
|
96
|
+
L: 39,
|
|
94
97
|
S: void 0,
|
|
95
98
|
A: [
|
|
96
99
|
"shape.node",
|
|
@@ -147,7 +150,6 @@ import { useMemo } from "react";
|
|
|
147
150
|
import { ComputeGraphModel, DEFAULT_INPUT, DEFAULT_OUTPUT } from "@dxos/conductor";
|
|
148
151
|
import { Obj, Ref } from "@dxos/echo";
|
|
149
152
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
150
|
-
import { getSpace } from "@dxos/react-client/echo";
|
|
151
153
|
import { isNonNullable } from "@dxos/util";
|
|
152
154
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/hooks/useGraphMonitor.ts";
|
|
153
155
|
var mapEdge = (graph, { source, target, output = DEFAULT_OUTPUT, input = DEFAULT_INPUT }) => {
|
|
@@ -155,7 +157,7 @@ var mapEdge = (graph, { source, target, output = DEFAULT_OUTPUT, input = DEFAULT
|
|
|
155
157
|
const targetNode = graph.findNode(target);
|
|
156
158
|
invariant2(sourceNode?.node, void 0, {
|
|
157
159
|
F: __dxlog_file2,
|
|
158
|
-
L:
|
|
160
|
+
L: 25,
|
|
159
161
|
S: void 0,
|
|
160
162
|
A: [
|
|
161
163
|
"sourceNode?.node",
|
|
@@ -164,7 +166,7 @@ var mapEdge = (graph, { source, target, output = DEFAULT_OUTPUT, input = DEFAULT
|
|
|
164
166
|
});
|
|
165
167
|
invariant2(targetNode?.node, void 0, {
|
|
166
168
|
F: __dxlog_file2,
|
|
167
|
-
L:
|
|
169
|
+
L: 26,
|
|
168
170
|
S: void 0,
|
|
169
171
|
A: [
|
|
170
172
|
"targetNode?.node",
|
|
@@ -188,7 +190,7 @@ var useGraphMonitor = (model) => {
|
|
|
188
190
|
}
|
|
189
191
|
invariant2(node.type, void 0, {
|
|
190
192
|
F: __dxlog_file2,
|
|
191
|
-
L:
|
|
193
|
+
L: 51,
|
|
192
194
|
S: void 0,
|
|
193
195
|
A: [
|
|
194
196
|
"node.type",
|
|
@@ -246,25 +248,27 @@ var linkTriggerToCompute = (graph, computeNode, triggerData) => {
|
|
|
246
248
|
const functionTrigger = triggerData.functionTrigger?.target;
|
|
247
249
|
invariant2(functionTrigger, void 0, {
|
|
248
250
|
F: __dxlog_file2,
|
|
249
|
-
L:
|
|
251
|
+
L: 114,
|
|
250
252
|
S: void 0,
|
|
251
253
|
A: [
|
|
252
254
|
"functionTrigger",
|
|
253
255
|
""
|
|
254
256
|
]
|
|
255
257
|
});
|
|
256
|
-
functionTrigger
|
|
257
|
-
|
|
258
|
+
Obj.change(functionTrigger, (obj) => {
|
|
259
|
+
obj.function = Ref.make(graph.root);
|
|
260
|
+
obj.inputNodeId = computeNode.id;
|
|
261
|
+
});
|
|
258
262
|
};
|
|
259
263
|
var deleteTriggerObjects = (computeGraph, deleted) => {
|
|
260
|
-
const
|
|
261
|
-
if (!
|
|
264
|
+
const db = Obj.getDatabase(computeGraph.root);
|
|
265
|
+
if (!db) {
|
|
262
266
|
return;
|
|
263
267
|
}
|
|
264
268
|
for (const node of deleted.nodes) {
|
|
265
269
|
if (node.type === "trigger") {
|
|
266
270
|
const trigger = node;
|
|
267
|
-
|
|
271
|
+
db.remove(trigger.functionTrigger.target);
|
|
268
272
|
}
|
|
269
273
|
}
|
|
270
274
|
};
|
|
@@ -301,33 +305,33 @@ var nodeFactory = {
|
|
|
301
305
|
[NODE_INPUT]: () => createNode(NODE_INPUT),
|
|
302
306
|
[NODE_OUTPUT]: () => createNode(NODE_OUTPUT),
|
|
303
307
|
// Extensions.
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
308
|
+
"text-to-image": () => createNode("text-to-image"),
|
|
309
|
+
and: () => createNode("and"),
|
|
310
|
+
append: () => createNode("append"),
|
|
311
|
+
audio: () => createNode("audio"),
|
|
312
|
+
beacon: () => createNode("beacon"),
|
|
313
|
+
chat: () => createNode("chat"),
|
|
314
|
+
constant: (shape) => createNode("constant", {
|
|
311
315
|
value: shape.value
|
|
312
316
|
}),
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
317
|
+
"make-queue": () => createNode("make-queue"),
|
|
318
|
+
database: () => createNode("database"),
|
|
319
|
+
gpt: () => createNode("gpt"),
|
|
320
|
+
"gpt-realtime": () => createNode("gpt-realtime"),
|
|
321
|
+
if: () => createNode("if"),
|
|
322
|
+
"if-else": () => createNode("if-else"),
|
|
323
|
+
function: () => createNode("function"),
|
|
324
|
+
json: () => createNode("json"),
|
|
325
|
+
"json-transform": () => createNode("json-transform"),
|
|
326
|
+
not: () => createNode("not"),
|
|
327
|
+
or: () => createNode("or"),
|
|
328
|
+
queue: () => createNode("queue"),
|
|
329
|
+
rng: () => createNode("rng"),
|
|
330
|
+
reducer: () => createNode("reducer"),
|
|
331
|
+
scope: () => createNode("scope"),
|
|
332
|
+
surface: () => createNode("surface"),
|
|
333
|
+
switch: () => createNode("switch"),
|
|
334
|
+
template: (shape) => {
|
|
331
335
|
const node = createNode("template", {
|
|
332
336
|
valueType: shape.valueType,
|
|
333
337
|
value: shape.text
|
|
@@ -335,9 +339,9 @@ var nodeFactory = {
|
|
|
335
339
|
node.inputSchema = JsonSchema.toJsonSchema(getTemplateInputSchema(node));
|
|
336
340
|
return node;
|
|
337
341
|
},
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
342
|
+
text: () => createNode("text"),
|
|
343
|
+
thread: () => createNode("thread"),
|
|
344
|
+
trigger: () => createNode(NODE_INPUT)
|
|
341
345
|
};
|
|
342
346
|
var createNode = (type, props) => ({
|
|
343
347
|
id: Obj2.ID.random(),
|
|
@@ -359,16 +363,16 @@ var AUTO_TRIGGER_NODES = [
|
|
|
359
363
|
"switch",
|
|
360
364
|
"constant"
|
|
361
365
|
];
|
|
362
|
-
var createComputeGraphController = (graph,
|
|
366
|
+
var createComputeGraphController = (graph, computeRuntime) => {
|
|
363
367
|
const computeGraph = createComputeGraph(graph);
|
|
364
|
-
const controller = new ComputeGraphController(
|
|
368
|
+
const controller = new ComputeGraphController(computeRuntime, computeGraph);
|
|
365
369
|
return {
|
|
366
370
|
controller,
|
|
367
371
|
graph
|
|
368
372
|
};
|
|
369
373
|
};
|
|
370
374
|
var ComputeGraphController = class extends Resource {
|
|
371
|
-
|
|
375
|
+
_computeRuntime;
|
|
372
376
|
_graph;
|
|
373
377
|
_executor = new GraphExecutor({
|
|
374
378
|
computeNodeResolver: (node) => resolveComputeNode(node)
|
|
@@ -388,8 +392,8 @@ var ComputeGraphController = class extends Resource {
|
|
|
388
392
|
/** Computed result. */
|
|
389
393
|
output = new Event();
|
|
390
394
|
events = new Event();
|
|
391
|
-
constructor(
|
|
392
|
-
super(), this.
|
|
395
|
+
constructor(_computeRuntime, _graph) {
|
|
396
|
+
super(), this._computeRuntime = _computeRuntime, this._graph = _graph;
|
|
393
397
|
}
|
|
394
398
|
toJSON() {
|
|
395
399
|
return {
|
|
@@ -459,7 +463,7 @@ var ComputeGraphController = class extends Resource {
|
|
|
459
463
|
} catch (err) {
|
|
460
464
|
log.catch(err, void 0, {
|
|
461
465
|
F: __dxlog_file4,
|
|
462
|
-
L:
|
|
466
|
+
L: 230,
|
|
463
467
|
S: this,
|
|
464
468
|
C: (f, a) => f(...a)
|
|
465
469
|
});
|
|
@@ -481,12 +485,11 @@ var ComputeGraphController = class extends Resource {
|
|
|
481
485
|
for (const [nodeId2, outputs] of Object.entries(this._forcedOutputs)) {
|
|
482
486
|
executor.setOutputs(nodeId2, Effect.succeed(ValueBag.make(outputs)));
|
|
483
487
|
}
|
|
484
|
-
|
|
485
|
-
await Effect.runPromise(Effect.gen(this, function* () {
|
|
488
|
+
unwrapExit(await this._computeRuntime.runPromiseExit(Effect.gen(this, function* () {
|
|
486
489
|
const scope = yield* Scope.make();
|
|
487
490
|
const executable = yield* Effect.promise(() => resolveComputeNode(this._graph.getNode(nodeId)));
|
|
488
491
|
const computingOutputs = executable.exec != null;
|
|
489
|
-
const effect = (computingOutputs ? executor.computeOutputs(nodeId) : executor.computeInputs(nodeId)).pipe(Effect.withSpan("runGraph"), Scope.extend(scope), Effect.
|
|
492
|
+
const effect = (computingOutputs ? executor.computeOutputs(nodeId) : executor.computeInputs(nodeId)).pipe(Effect.withSpan("runGraph"), Scope.extend(scope), Effect.provide(ComputeEventLogger.layerFromTracing.pipe(Layer.provideMerge(TracingService.layerNoop), Layer.provideMerge(Trace.writerLayerNoop))), Effect.flatMap(computeValueBag), Effect.withSpan("test"), Effect.tap((values) => {
|
|
490
493
|
for (const [key, value] of Object.entries(values)) {
|
|
491
494
|
if (computingOutputs) {
|
|
492
495
|
this._onOutputComputed(nodeId, key, value);
|
|
@@ -497,7 +500,7 @@ var ComputeGraphController = class extends Resource {
|
|
|
497
500
|
}));
|
|
498
501
|
yield* effect;
|
|
499
502
|
yield* Scope.close(scope, Exit.void);
|
|
500
|
-
}));
|
|
503
|
+
})));
|
|
501
504
|
this.update.emit();
|
|
502
505
|
}
|
|
503
506
|
/**
|
|
@@ -518,13 +521,13 @@ var ComputeGraphController = class extends Resource {
|
|
|
518
521
|
const allAffectedNodes = [
|
|
519
522
|
...new Set(triggerNodes.flatMap((node) => executor.getAllDependantNodes(node.id)))
|
|
520
523
|
];
|
|
521
|
-
await
|
|
524
|
+
unwrapExit(await this._computeRuntime.runPromiseExit(Effect.gen(this, function* () {
|
|
522
525
|
const scope = yield* Scope.make();
|
|
523
526
|
const tasks = [];
|
|
524
527
|
for (const node of allAffectedNodes) {
|
|
525
528
|
const executable = yield* Effect.promise(() => resolveComputeNode(this._graph.getNode(node)));
|
|
526
529
|
const computingOutputs = executable.exec != null;
|
|
527
|
-
const effect = (computingOutputs ? executor.computeOutputs(node) : executor.computeInputs(node)).pipe(Effect.withSpan("runGraph"), Scope.extend(scope), Effect.flatMap(computeValueBag), Effect.provide(
|
|
530
|
+
const effect = (computingOutputs ? executor.computeOutputs(node) : executor.computeInputs(node)).pipe(Effect.withSpan("runGraph"), Scope.extend(scope), Effect.flatMap(computeValueBag), Effect.provide(ComputeEventLogger.layerFromTracing.pipe(Layer.provideMerge(TracingService.layerNoop), Layer.provideMerge(Trace.writerLayerNoop))), Effect.withSpan("test"), Effect.tap((values) => {
|
|
528
531
|
for (const [key, value] of Object.entries(values)) {
|
|
529
532
|
if (computingOutputs) {
|
|
530
533
|
this._onOutputComputed(node, key, value);
|
|
@@ -537,7 +540,7 @@ var ComputeGraphController = class extends Resource {
|
|
|
537
540
|
}
|
|
538
541
|
yield* Effect.all(tasks);
|
|
539
542
|
yield* Scope.close(scope, Exit.void);
|
|
540
|
-
}));
|
|
543
|
+
})));
|
|
541
544
|
this.update.emit();
|
|
542
545
|
}
|
|
543
546
|
_createLogger() {
|
|
@@ -553,7 +556,7 @@ var ComputeGraphController = class extends Resource {
|
|
|
553
556
|
event
|
|
554
557
|
}, {
|
|
555
558
|
F: __dxlog_file4,
|
|
556
|
-
L:
|
|
559
|
+
L: 379,
|
|
557
560
|
S: this,
|
|
558
561
|
C: (f, a) => f(...a)
|
|
559
562
|
});
|
|
@@ -630,78 +633,69 @@ var computeValueBag = (bag) => {
|
|
|
630
633
|
import { noteShape } from "@dxos/react-ui-canvas-editor";
|
|
631
634
|
|
|
632
635
|
// src/shapes/common/Box.tsx
|
|
633
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
634
636
|
import React, { forwardRef } from "react";
|
|
635
637
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
636
638
|
import { Icon, IconButton } from "@dxos/react-ui";
|
|
637
639
|
import { useEditorContext, useShapeDef } from "@dxos/react-ui-canvas-editor";
|
|
638
|
-
import { mx } from "@dxos/
|
|
640
|
+
import { mx } from "@dxos/ui-theme";
|
|
639
641
|
var __dxlog_file5 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/common/Box.tsx";
|
|
640
642
|
var headerHeight = 32;
|
|
641
643
|
var footerHeight = 32;
|
|
642
644
|
var Box = /* @__PURE__ */ forwardRef(({ children, classNames, shape, title, status, open, onAction }, forwardedRef) => {
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
ev.stopPropagation();
|
|
695
|
-
onAction?.(open ? "close" : "open");
|
|
696
|
-
}
|
|
697
|
-
})));
|
|
698
|
-
} finally {
|
|
699
|
-
_effect.f();
|
|
700
|
-
}
|
|
645
|
+
invariant4(shape.type, void 0, {
|
|
646
|
+
F: __dxlog_file5,
|
|
647
|
+
L: 29,
|
|
648
|
+
S: void 0,
|
|
649
|
+
A: [
|
|
650
|
+
"shape.type",
|
|
651
|
+
""
|
|
652
|
+
]
|
|
653
|
+
});
|
|
654
|
+
const { icon, name, openable } = useShapeDef(shape.type) ?? {
|
|
655
|
+
icon: "ph--placeholder--regular"
|
|
656
|
+
};
|
|
657
|
+
const { debug } = useEditorContext();
|
|
658
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
659
|
+
ref: forwardedRef,
|
|
660
|
+
className: "flex flex-col h-full w-full justify-between"
|
|
661
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
662
|
+
className: "flex shrink-0 w-full justify-between items-center h-[32px] bg-input-surface"
|
|
663
|
+
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
664
|
+
icon,
|
|
665
|
+
classNames: "mx-2"
|
|
666
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
667
|
+
className: "grow text-sm truncate"
|
|
668
|
+
}, debug ? shape.type : name ?? shape.text ?? title), /* @__PURE__ */ React.createElement(IconButton, {
|
|
669
|
+
classNames: "p-1 text-green-500",
|
|
670
|
+
variant: "ghost",
|
|
671
|
+
icon: "ph--play--regular",
|
|
672
|
+
label: "run",
|
|
673
|
+
iconOnly: true,
|
|
674
|
+
onDoubleClick: (ev) => ev.stopPropagation(),
|
|
675
|
+
onClick: (ev) => {
|
|
676
|
+
ev.stopPropagation();
|
|
677
|
+
onAction?.("run");
|
|
678
|
+
}
|
|
679
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
680
|
+
className: mx("flex flex-col h-full grow overflow-hidden", classNames)
|
|
681
|
+
}, children), /* @__PURE__ */ React.createElement("div", {
|
|
682
|
+
className: "flex shrink-0 w-full justify-between items-center h-[32px] bg-input-surface"
|
|
683
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
684
|
+
className: "grow px-2 text-sm truncate"
|
|
685
|
+
}, debug ? shape.id : status), openable && /* @__PURE__ */ React.createElement(IconButton, {
|
|
686
|
+
classNames: "p-1",
|
|
687
|
+
variant: "ghost",
|
|
688
|
+
icon: open ? "ph--caret-up--regular" : "ph--caret-down--regular",
|
|
689
|
+
label: open ? "close" : "open",
|
|
690
|
+
iconOnly: true,
|
|
691
|
+
onClick: (ev) => {
|
|
692
|
+
ev.stopPropagation();
|
|
693
|
+
onAction?.(open ? "close" : "open");
|
|
694
|
+
}
|
|
695
|
+
})));
|
|
701
696
|
});
|
|
702
697
|
|
|
703
698
|
// src/shapes/common/FunctionBody.tsx
|
|
704
|
-
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
705
699
|
import * as SchemaAST2 from "effect/SchemaAST";
|
|
706
700
|
import React2, { useRef, useState as useState3 } from "react";
|
|
707
701
|
import { VoidInput, VoidOutput } from "@dxos/conductor";
|
|
@@ -745,70 +739,65 @@ var createShape = ({ id, ...rest }) => {
|
|
|
745
739
|
var bodyPadding = 8;
|
|
746
740
|
var expandedHeight = 200;
|
|
747
741
|
var FunctionBody = ({ shape, name, content, inputSchema = VoidInput, outputSchema = VoidOutput, ...props }) => {
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
setOpen(true);
|
|
763
|
-
break;
|
|
764
|
-
}
|
|
765
|
-
case "close": {
|
|
766
|
-
const el = getParentShapeElement(rootRef.current, shape.id);
|
|
767
|
-
el.style.height = "";
|
|
768
|
-
setOpen(false);
|
|
769
|
-
break;
|
|
770
|
-
}
|
|
771
|
-
}
|
|
772
|
-
};
|
|
773
|
-
const inputs = getProperties(inputSchema.ast);
|
|
774
|
-
const outputs = getProperties(outputSchema.ast);
|
|
775
|
-
const columnCount = inputs.length && outputs.length ? 2 : 1;
|
|
776
|
-
return /* @__PURE__ */ React2.createElement(Box, {
|
|
777
|
-
ref: rootRef,
|
|
778
|
-
shape,
|
|
779
|
-
title: name,
|
|
780
|
-
classNames: "divide-y divide-separator",
|
|
781
|
-
open,
|
|
782
|
-
onAction: handleAction,
|
|
783
|
-
...props
|
|
784
|
-
}, /* @__PURE__ */ React2.createElement("div", {
|
|
785
|
-
className: `grid grid-cols-${columnCount} items-center`,
|
|
786
|
-
style: {
|
|
787
|
-
paddingTop: bodyPadding,
|
|
788
|
-
paddingBottom: bodyPadding
|
|
789
|
-
}
|
|
790
|
-
}, (inputs?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement("div", {
|
|
791
|
-
className: "flex flex-col"
|
|
792
|
-
}, inputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
|
|
793
|
-
key: name2,
|
|
794
|
-
className: "pli-2 truncate text-sm font-mono items-center",
|
|
795
|
-
style: {
|
|
796
|
-
height: rowHeight
|
|
742
|
+
const { scale } = useCanvasContext();
|
|
743
|
+
const rootRef = useRef(null);
|
|
744
|
+
const [open, setOpen] = useState3(false);
|
|
745
|
+
const handleAction = (action) => {
|
|
746
|
+
if (!rootRef.current) {
|
|
747
|
+
return;
|
|
748
|
+
}
|
|
749
|
+
switch (action) {
|
|
750
|
+
case "open": {
|
|
751
|
+
const el = getParentShapeElement(rootRef.current, shape.id);
|
|
752
|
+
const { height } = el.getBoundingClientRect();
|
|
753
|
+
el.style.height = `${height / scale + expandedHeight}px`;
|
|
754
|
+
setOpen(true);
|
|
755
|
+
break;
|
|
797
756
|
}
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
style: {
|
|
804
|
-
height: rowHeight
|
|
757
|
+
case "close": {
|
|
758
|
+
const el = getParentShapeElement(rootRef.current, shape.id);
|
|
759
|
+
el.style.height = "";
|
|
760
|
+
setOpen(false);
|
|
761
|
+
break;
|
|
805
762
|
}
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
763
|
+
}
|
|
764
|
+
};
|
|
765
|
+
const inputs = getProperties(inputSchema.ast);
|
|
766
|
+
const outputs = getProperties(outputSchema.ast);
|
|
767
|
+
const columnCount = inputs.length && outputs.length ? 2 : 1;
|
|
768
|
+
return /* @__PURE__ */ React2.createElement(Box, {
|
|
769
|
+
ref: rootRef,
|
|
770
|
+
shape,
|
|
771
|
+
title: name,
|
|
772
|
+
classNames: "divide-y divide-separator",
|
|
773
|
+
open,
|
|
774
|
+
onAction: handleAction,
|
|
775
|
+
...props
|
|
776
|
+
}, /* @__PURE__ */ React2.createElement("div", {
|
|
777
|
+
className: `grid grid-cols-${columnCount} items-center`,
|
|
778
|
+
style: {
|
|
779
|
+
paddingTop: bodyPadding,
|
|
780
|
+
paddingBottom: bodyPadding
|
|
781
|
+
}
|
|
782
|
+
}, (inputs?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement("div", {
|
|
783
|
+
className: "flex flex-col"
|
|
784
|
+
}, inputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
|
|
785
|
+
key: name2,
|
|
786
|
+
className: "px-2 truncate text-sm font-mono items-center",
|
|
787
|
+
style: {
|
|
788
|
+
height: rowHeight
|
|
789
|
+
}
|
|
790
|
+
}, name2))), (outputs?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement("div", {
|
|
791
|
+
className: "flex flex-col"
|
|
792
|
+
}, outputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
|
|
793
|
+
key: name2,
|
|
794
|
+
className: "px-2 truncate text-sm font-mono items-center text-right",
|
|
795
|
+
style: {
|
|
796
|
+
height: rowHeight
|
|
797
|
+
}
|
|
798
|
+
}, name2)))), open && /* @__PURE__ */ React2.createElement("div", {
|
|
799
|
+
className: "flex flex-col grow overflow-hidden"
|
|
800
|
+
}, content));
|
|
812
801
|
};
|
|
813
802
|
var getHeight = (input) => {
|
|
814
803
|
const properties = SchemaAST2.getPropertySignatures(input.ast);
|
|
@@ -829,30 +818,23 @@ var createFunctionAnchors = (shape, input = VoidInput, output = VoidOutput) => {
|
|
|
829
818
|
};
|
|
830
819
|
|
|
831
820
|
// src/shapes/common/TypeSelect.tsx
|
|
832
|
-
import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
|
|
833
821
|
import React3 from "react";
|
|
834
822
|
import { ComputeValueType } from "@dxos/conductor";
|
|
835
823
|
import { Select } from "@dxos/react-ui";
|
|
836
824
|
var TypeSelect = ({ value, onValueChange }) => {
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
value: type
|
|
848
|
-
}, type))), /* @__PURE__ */ React3.createElement(Select.ScrollDownButton, null), /* @__PURE__ */ React3.createElement(Select.Arrow, null))));
|
|
849
|
-
} finally {
|
|
850
|
-
_effect.f();
|
|
851
|
-
}
|
|
825
|
+
return /* @__PURE__ */ React3.createElement(Select.Root, {
|
|
826
|
+
value,
|
|
827
|
+
onValueChange
|
|
828
|
+
}, /* @__PURE__ */ React3.createElement(Select.TriggerButton, {
|
|
829
|
+
variant: "ghost",
|
|
830
|
+
classNames: "w-full px-0!"
|
|
831
|
+
}), /* @__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, {
|
|
832
|
+
key: type,
|
|
833
|
+
value: type
|
|
834
|
+
}, type))), /* @__PURE__ */ React3.createElement(Select.ScrollDownButton, null), /* @__PURE__ */ React3.createElement(Select.Arrow, null))));
|
|
852
835
|
};
|
|
853
836
|
|
|
854
837
|
// src/shapes/Array.tsx
|
|
855
|
-
import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
|
|
856
838
|
import * as Schema3 from "effect/Schema";
|
|
857
839
|
import React4 from "react";
|
|
858
840
|
import { ReducerInput, ReducerOutput } from "@dxos/conductor";
|
|
@@ -860,16 +842,11 @@ var ReducerShape = Schema3.extend(ComputeShape, Schema3.Struct({
|
|
|
860
842
|
type: Schema3.Literal("reducer")
|
|
861
843
|
}));
|
|
862
844
|
var ReducerComponent = ({ shape }) => {
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
outputSchema: ReducerOutput
|
|
869
|
-
});
|
|
870
|
-
} finally {
|
|
871
|
-
_effect.f();
|
|
872
|
-
}
|
|
845
|
+
return /* @__PURE__ */ React4.createElement(FunctionBody, {
|
|
846
|
+
shape,
|
|
847
|
+
inputSchema: ReducerInput,
|
|
848
|
+
outputSchema: ReducerOutput
|
|
849
|
+
});
|
|
873
850
|
};
|
|
874
851
|
var createReducer = ({ id, size = {
|
|
875
852
|
width: 192,
|
|
@@ -889,7 +866,6 @@ var reducerShape = {
|
|
|
889
866
|
};
|
|
890
867
|
|
|
891
868
|
// src/shapes/Append.tsx
|
|
892
|
-
import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
|
|
893
869
|
import * as Schema4 from "effect/Schema";
|
|
894
870
|
import React5 from "react";
|
|
895
871
|
import { AppendInput } from "@dxos/conductor";
|
|
@@ -905,15 +881,10 @@ var createAppend = (props) => createShape({
|
|
|
905
881
|
...props
|
|
906
882
|
});
|
|
907
883
|
var AppendComponent = ({ shape }) => {
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
inputSchema: AppendInput
|
|
913
|
-
});
|
|
914
|
-
} finally {
|
|
915
|
-
_effect.f();
|
|
916
|
-
}
|
|
884
|
+
return /* @__PURE__ */ React5.createElement(FunctionBody, {
|
|
885
|
+
shape,
|
|
886
|
+
inputSchema: AppendInput
|
|
887
|
+
});
|
|
917
888
|
};
|
|
918
889
|
var appendShape = {
|
|
919
890
|
type: "append",
|
|
@@ -925,7 +896,6 @@ var appendShape = {
|
|
|
925
896
|
};
|
|
926
897
|
|
|
927
898
|
// src/shapes/Audio.tsx
|
|
928
|
-
import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
|
|
929
899
|
import * as Schema5 from "effect/Schema";
|
|
930
900
|
import React6, { useEffect as useEffect3, useState as useState4 } from "react";
|
|
931
901
|
import { Icon as Icon2 } from "@dxos/react-ui";
|
|
@@ -942,29 +912,24 @@ var createAudio = (props) => createShape({
|
|
|
942
912
|
...props
|
|
943
913
|
});
|
|
944
914
|
var AudioComponent = ({ shape }) => {
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
onClick: () => setActive(!active)
|
|
964
|
-
}));
|
|
965
|
-
} finally {
|
|
966
|
-
_effect.f();
|
|
967
|
-
}
|
|
915
|
+
const { node } = useComputeNodeState(shape);
|
|
916
|
+
const [active, setActive] = useState4(false);
|
|
917
|
+
useEffect3(() => {
|
|
918
|
+
node.value = active;
|
|
919
|
+
}, [
|
|
920
|
+
active
|
|
921
|
+
]);
|
|
922
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
923
|
+
className: "flex w-full justify-center items-center"
|
|
924
|
+
}, /* @__PURE__ */ React6.createElement(Icon2, {
|
|
925
|
+
icon: active ? "ph--microphone--regular" : "ph--microphone-slash--regular",
|
|
926
|
+
classNames: [
|
|
927
|
+
"transition opacity-20 duration-1000",
|
|
928
|
+
active && "opacity-100 text-error-text"
|
|
929
|
+
],
|
|
930
|
+
size: 8,
|
|
931
|
+
onClick: () => setActive(!active)
|
|
932
|
+
}));
|
|
968
933
|
};
|
|
969
934
|
var audioShape = {
|
|
970
935
|
type: "audio",
|
|
@@ -981,7 +946,6 @@ var audioShape = {
|
|
|
981
946
|
};
|
|
982
947
|
|
|
983
948
|
// src/shapes/Beacon.tsx
|
|
984
|
-
import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
|
|
985
949
|
import * as Schema6 from "effect/Schema";
|
|
986
950
|
import React7 from "react";
|
|
987
951
|
import { DEFAULT_INPUT as DEFAULT_INPUT3, isTruthy } from "@dxos/conductor";
|
|
@@ -999,24 +963,19 @@ var createBeacon = (props) => createShape({
|
|
|
999
963
|
...props
|
|
1000
964
|
});
|
|
1001
965
|
var BeaconComponent = ({ shape }) => {
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
size: 8
|
|
1016
|
-
}));
|
|
1017
|
-
} finally {
|
|
1018
|
-
_effect.f();
|
|
1019
|
-
}
|
|
966
|
+
const { runtime } = useComputeNodeState(shape);
|
|
967
|
+
const input = runtime.inputs[DEFAULT_INPUT3];
|
|
968
|
+
const value = input?.type === "executed" ? input.value : false;
|
|
969
|
+
return /* @__PURE__ */ React7.createElement("div", {
|
|
970
|
+
className: "flex w-full justify-center items-center"
|
|
971
|
+
}, /* @__PURE__ */ React7.createElement(Icon3, {
|
|
972
|
+
icon: "ph--sun--regular",
|
|
973
|
+
classNames: [
|
|
974
|
+
"transition opacity-20 duration-1000",
|
|
975
|
+
isTruthy(value) && "opacity-100 text-yellow-500"
|
|
976
|
+
],
|
|
977
|
+
size: 8
|
|
978
|
+
}));
|
|
1020
979
|
};
|
|
1021
980
|
var beaconShape = {
|
|
1022
981
|
type: "beacon",
|
|
@@ -1057,7 +1016,7 @@ var defineShape = ({ type, name, icon, symbol: Symbol, createShape: createShape2
|
|
|
1057
1016
|
// Be careful not to name component factories with a capital letter.
|
|
1058
1017
|
component: () => {
|
|
1059
1018
|
return /* @__PURE__ */ React8.createElement("div", {
|
|
1060
|
-
className: "flex
|
|
1019
|
+
className: "flex w-full justify-center items-center"
|
|
1061
1020
|
}, /* @__PURE__ */ React8.createElement(Symbol, null));
|
|
1062
1021
|
},
|
|
1063
1022
|
createShape: createShape2,
|
|
@@ -1084,7 +1043,7 @@ var createSymbol = (pathConstructor, inputs) => ({
|
|
|
1084
1043
|
});
|
|
1085
1044
|
return /* @__PURE__ */ React8.createElement("svg", {
|
|
1086
1045
|
viewBox: `0 0 ${width} ${height}`,
|
|
1087
|
-
className: "
|
|
1046
|
+
className: "h-full w-full"
|
|
1088
1047
|
}, getAnchorPoints({
|
|
1089
1048
|
x: 0,
|
|
1090
1049
|
y: centerY
|
|
@@ -1206,7 +1165,6 @@ var notShape = defineShape({
|
|
|
1206
1165
|
});
|
|
1207
1166
|
|
|
1208
1167
|
// src/shapes/Chat.tsx
|
|
1209
|
-
import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
|
|
1210
1168
|
import * as Schema8 from "effect/Schema";
|
|
1211
1169
|
import React9, { useRef as useRef2 } from "react";
|
|
1212
1170
|
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT3 } from "@dxos/conductor";
|
|
@@ -1216,28 +1174,23 @@ var ChatShape = Schema8.extend(ComputeShape, Schema8.Struct({
|
|
|
1216
1174
|
type: Schema8.Literal("chat")
|
|
1217
1175
|
}));
|
|
1218
1176
|
var TextInputComponent = ({ shape, title, ...props }) => {
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
const
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
...props
|
|
1237
|
-
}));
|
|
1238
|
-
} finally {
|
|
1239
|
-
_effect.f();
|
|
1240
|
-
}
|
|
1177
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1178
|
+
const inputRef = useRef2(null);
|
|
1179
|
+
const handleEnter = (text) => {
|
|
1180
|
+
const value = text.trim();
|
|
1181
|
+
if (value.length) {
|
|
1182
|
+
runtime.setOutput(DEFAULT_OUTPUT3, value);
|
|
1183
|
+
inputRef.current?.setText("");
|
|
1184
|
+
}
|
|
1185
|
+
};
|
|
1186
|
+
return /* @__PURE__ */ React9.createElement(Box, {
|
|
1187
|
+
shape,
|
|
1188
|
+
title
|
|
1189
|
+
}, /* @__PURE__ */ React9.createElement(TextBox, {
|
|
1190
|
+
ref: inputRef,
|
|
1191
|
+
onEnter: handleEnter,
|
|
1192
|
+
...props
|
|
1193
|
+
}));
|
|
1241
1194
|
};
|
|
1242
1195
|
var createChat = (props) => createShape({
|
|
1243
1196
|
type: "chat",
|
|
@@ -1267,7 +1220,6 @@ var chatShape = {
|
|
|
1267
1220
|
};
|
|
1268
1221
|
|
|
1269
1222
|
// src/shapes/Constant.tsx
|
|
1270
|
-
import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
|
|
1271
1223
|
import * as Schema9 from "effect/Schema";
|
|
1272
1224
|
import React10, { useCallback as useCallback2, useRef as useRef3, useState as useState5 } from "react";
|
|
1273
1225
|
import { ComputeValueType as ComputeValueType2 } from "@dxos/conductor";
|
|
@@ -1291,57 +1243,52 @@ var inferType = (value) => {
|
|
|
1291
1243
|
}
|
|
1292
1244
|
};
|
|
1293
1245
|
var ConstantComponent = ({ shape, title, chat, ...props }) => {
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
const
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
if (
|
|
1303
|
-
|
|
1304
|
-
if (!isNaN(floatValue)) {
|
|
1305
|
-
node.value = floatValue;
|
|
1306
|
-
}
|
|
1307
|
-
} else if (type === "object") {
|
|
1308
|
-
node.value = safeParseJson(value, {});
|
|
1309
|
-
} else {
|
|
1310
|
-
node.value = value;
|
|
1246
|
+
const { node } = useComputeNodeState(shape);
|
|
1247
|
+
const [type, setType] = useState5(inferType(node.value) ?? ComputeValueType2.literals[0]);
|
|
1248
|
+
const inputRef = useRef3(null);
|
|
1249
|
+
const handleEnter = useCallback2((text) => {
|
|
1250
|
+
const value = text.trim();
|
|
1251
|
+
if (value.length) {
|
|
1252
|
+
if (type === "number") {
|
|
1253
|
+
const floatValue = parseFloat(value);
|
|
1254
|
+
if (!isNaN(floatValue)) {
|
|
1255
|
+
node.value = floatValue;
|
|
1311
1256
|
}
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
type
|
|
1316
|
-
]);
|
|
1317
|
-
return /* @__PURE__ */ React10.createElement(Box, {
|
|
1318
|
-
shape,
|
|
1319
|
-
title,
|
|
1320
|
-
status: /* @__PURE__ */ React10.createElement(TypeSelect, {
|
|
1321
|
-
value: type,
|
|
1322
|
-
onValueChange: setType
|
|
1323
|
-
})
|
|
1324
|
-
}, (type === "string" || type === "number") && /* @__PURE__ */ React10.createElement(TextBox2, {
|
|
1325
|
-
...props,
|
|
1326
|
-
ref: inputRef,
|
|
1327
|
-
value: node.value,
|
|
1328
|
-
onEnter: handleEnter
|
|
1329
|
-
}), type === "object" && /* @__PURE__ */ React10.createElement(TextBox2, {
|
|
1330
|
-
...props,
|
|
1331
|
-
ref: inputRef,
|
|
1332
|
-
value: JSON.stringify(node.value, null, 2),
|
|
1333
|
-
language: "json"
|
|
1334
|
-
}), type === "boolean" && /* @__PURE__ */ React10.createElement("div", {
|
|
1335
|
-
className: "flex grow justify-center items-center"
|
|
1336
|
-
}, /* @__PURE__ */ React10.createElement(Input.Root, null, /* @__PURE__ */ React10.createElement(Input.Switch, {
|
|
1337
|
-
checked: node.value,
|
|
1338
|
-
onCheckedChange: (value) => {
|
|
1257
|
+
} else if (type === "object") {
|
|
1258
|
+
node.value = safeParseJson(value, {});
|
|
1259
|
+
} else {
|
|
1339
1260
|
node.value = value;
|
|
1340
1261
|
}
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1262
|
+
inputRef.current?.focus();
|
|
1263
|
+
}
|
|
1264
|
+
}, [
|
|
1265
|
+
type
|
|
1266
|
+
]);
|
|
1267
|
+
return /* @__PURE__ */ React10.createElement(Box, {
|
|
1268
|
+
shape,
|
|
1269
|
+
title,
|
|
1270
|
+
status: /* @__PURE__ */ React10.createElement(TypeSelect, {
|
|
1271
|
+
value: type,
|
|
1272
|
+
onValueChange: setType
|
|
1273
|
+
})
|
|
1274
|
+
}, (type === "string" || type === "number") && /* @__PURE__ */ React10.createElement(TextBox2, {
|
|
1275
|
+
...props,
|
|
1276
|
+
ref: inputRef,
|
|
1277
|
+
value: node.value,
|
|
1278
|
+
onEnter: handleEnter
|
|
1279
|
+
}), type === "object" && /* @__PURE__ */ React10.createElement(TextBox2, {
|
|
1280
|
+
...props,
|
|
1281
|
+
ref: inputRef,
|
|
1282
|
+
value: JSON.stringify(node.value, null, 2),
|
|
1283
|
+
language: "json"
|
|
1284
|
+
}), type === "boolean" && /* @__PURE__ */ React10.createElement("div", {
|
|
1285
|
+
className: "flex grow justify-center items-center"
|
|
1286
|
+
}, /* @__PURE__ */ React10.createElement(Input.Root, null, /* @__PURE__ */ React10.createElement(Input.Switch, {
|
|
1287
|
+
checked: node.value,
|
|
1288
|
+
onCheckedChange: (value) => {
|
|
1289
|
+
node.value = value;
|
|
1290
|
+
}
|
|
1291
|
+
}))));
|
|
1345
1292
|
};
|
|
1346
1293
|
var createConstant = (props) => createShape({
|
|
1347
1294
|
type: "constant",
|
|
@@ -1370,7 +1317,6 @@ var constantShape = {
|
|
|
1370
1317
|
};
|
|
1371
1318
|
|
|
1372
1319
|
// src/shapes/Database.tsx
|
|
1373
|
-
import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
|
|
1374
1320
|
import * as Schema10 from "effect/Schema";
|
|
1375
1321
|
import React11 from "react";
|
|
1376
1322
|
import { createAnchorMap as createAnchorMap5 } from "@dxos/react-ui-canvas-editor";
|
|
@@ -1386,14 +1332,9 @@ var createDatabase = (props) => createShape({
|
|
|
1386
1332
|
...props
|
|
1387
1333
|
});
|
|
1388
1334
|
var DatabaseComponent = ({ shape }) => {
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
shape
|
|
1393
|
-
});
|
|
1394
|
-
} finally {
|
|
1395
|
-
_effect.f();
|
|
1396
|
-
}
|
|
1335
|
+
return /* @__PURE__ */ React11.createElement(Box, {
|
|
1336
|
+
shape
|
|
1337
|
+
});
|
|
1397
1338
|
};
|
|
1398
1339
|
var databaseShape = {
|
|
1399
1340
|
type: "database",
|
|
@@ -1409,18 +1350,83 @@ var databaseShape = {
|
|
|
1409
1350
|
})
|
|
1410
1351
|
};
|
|
1411
1352
|
|
|
1412
|
-
// src/shapes/
|
|
1413
|
-
import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
|
|
1353
|
+
// src/shapes/Feed.tsx
|
|
1414
1354
|
import * as Schema11 from "effect/Schema";
|
|
1415
|
-
import React12, {
|
|
1355
|
+
import React12, { Fragment } from "react";
|
|
1356
|
+
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT4, QueueInput, QueueOutput } from "@dxos/conductor";
|
|
1357
|
+
import { ScrollArea } from "@dxos/react-ui";
|
|
1358
|
+
import { mx as mx2 } from "@dxos/ui-theme";
|
|
1359
|
+
var FeedShape = Schema11.extend(ComputeShape, Schema11.Struct({
|
|
1360
|
+
type: Schema11.Literal("queue")
|
|
1361
|
+
}));
|
|
1362
|
+
var createFeed = (props) => createShape({
|
|
1363
|
+
type: "queue",
|
|
1364
|
+
size: {
|
|
1365
|
+
width: 256,
|
|
1366
|
+
height: 512
|
|
1367
|
+
},
|
|
1368
|
+
...props
|
|
1369
|
+
});
|
|
1370
|
+
var FeedComponent = ({ shape }) => {
|
|
1371
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1372
|
+
const items = runtime.outputs[DEFAULT_OUTPUT4]?.type === "executed" ? runtime.outputs[DEFAULT_OUTPUT4].value : [];
|
|
1373
|
+
const handleAction = (action) => {
|
|
1374
|
+
if (action === "run") {
|
|
1375
|
+
runtime.evalNode();
|
|
1376
|
+
}
|
|
1377
|
+
};
|
|
1378
|
+
return /* @__PURE__ */ React12.createElement(Box, {
|
|
1379
|
+
shape,
|
|
1380
|
+
status: `${items.length} items`,
|
|
1381
|
+
onAction: handleAction
|
|
1382
|
+
}, /* @__PURE__ */ React12.createElement(ScrollArea.Root, {
|
|
1383
|
+
orientation: "vertical"
|
|
1384
|
+
}, /* @__PURE__ */ React12.createElement(ScrollArea.Viewport, {
|
|
1385
|
+
classNames: "divide-y divide-separator"
|
|
1386
|
+
}, [
|
|
1387
|
+
...items
|
|
1388
|
+
].map((item, i) => /* @__PURE__ */ React12.createElement(FeedItem, {
|
|
1389
|
+
key: i,
|
|
1390
|
+
classNames: "p-1 px-2",
|
|
1391
|
+
item
|
|
1392
|
+
})))));
|
|
1393
|
+
};
|
|
1394
|
+
var FeedItem = ({ classNames, item }) => {
|
|
1395
|
+
if (typeof item !== "object") {
|
|
1396
|
+
return /* @__PURE__ */ React12.createElement("div", {
|
|
1397
|
+
className: mx2(classNames, "whitespace-pre-wrap")
|
|
1398
|
+
}, item);
|
|
1399
|
+
}
|
|
1400
|
+
return /* @__PURE__ */ React12.createElement("div", {
|
|
1401
|
+
className: mx2("grid grid-cols-[80px_1fr]", classNames)
|
|
1402
|
+
}, Object.entries(item).map(([key, value]) => /* @__PURE__ */ React12.createElement(Fragment, {
|
|
1403
|
+
key
|
|
1404
|
+
}, /* @__PURE__ */ React12.createElement("div", {
|
|
1405
|
+
className: "p-1 text-xs text-subdued"
|
|
1406
|
+
}, key), /* @__PURE__ */ React12.createElement("div", null, typeof value === "string" ? value : JSON.stringify(value)))));
|
|
1407
|
+
};
|
|
1408
|
+
var feedShape = {
|
|
1409
|
+
type: "feed",
|
|
1410
|
+
name: "Feed",
|
|
1411
|
+
icon: "ph--queue--regular",
|
|
1412
|
+
component: FeedComponent,
|
|
1413
|
+
createShape: createFeed,
|
|
1414
|
+
getAnchors: (shape) => createFunctionAnchors(shape, QueueInput, QueueOutput),
|
|
1415
|
+
resizable: true
|
|
1416
|
+
};
|
|
1417
|
+
|
|
1418
|
+
// src/shapes/Function.tsx
|
|
1419
|
+
import * as Schema12 from "effect/Schema";
|
|
1420
|
+
import React13, { useCallback as useCallback3, useRef as useRef4 } from "react";
|
|
1416
1421
|
import { AnyOutput, FunctionInput } from "@dxos/conductor";
|
|
1417
1422
|
import { Ref as Ref2, getSnapshot, isInstanceOf } from "@dxos/echo/internal";
|
|
1418
|
-
import {
|
|
1423
|
+
import { Script } from "@dxos/functions";
|
|
1424
|
+
import { Operation } from "@dxos/operation";
|
|
1419
1425
|
import { useClient } from "@dxos/react-client";
|
|
1420
1426
|
import { Filter, parseId } from "@dxos/react-client/echo";
|
|
1421
1427
|
import { TextBox as TextBox3 } from "@dxos/react-ui-canvas-editor";
|
|
1422
|
-
var FunctionShape =
|
|
1423
|
-
type:
|
|
1428
|
+
var FunctionShape = Schema12.extend(ComputeShape, Schema12.Struct({
|
|
1429
|
+
type: Schema12.Literal("function")
|
|
1424
1430
|
}));
|
|
1425
1431
|
var createFunction = (props) => createShape({
|
|
1426
1432
|
type: "function",
|
|
@@ -1431,59 +1437,54 @@ var createFunction = (props) => createShape({
|
|
|
1431
1437
|
...props
|
|
1432
1438
|
});
|
|
1433
1439
|
var TextInputComponent2 = ({ shape, title, ...props }) => {
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
const
|
|
1439
|
-
const
|
|
1440
|
-
|
|
1441
|
-
|
|
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
|
-
onEnter: handleEnter
|
|
1483
|
-
}));
|
|
1484
|
-
} finally {
|
|
1485
|
-
_effect.f();
|
|
1486
|
-
}
|
|
1440
|
+
const client = useClient();
|
|
1441
|
+
const { node, runtime } = useComputeNodeState(shape);
|
|
1442
|
+
const inputRef = useRef4(null);
|
|
1443
|
+
const handleEnter = useCallback3(async (text) => {
|
|
1444
|
+
const value = text.trim();
|
|
1445
|
+
const { spaceId, objectId } = parseId(value);
|
|
1446
|
+
if (!spaceId || !objectId) {
|
|
1447
|
+
return;
|
|
1448
|
+
}
|
|
1449
|
+
const space = client.spaces.get(spaceId);
|
|
1450
|
+
const object = space?.db.getObjectById(objectId);
|
|
1451
|
+
if (!space || !isInstanceOf(Script.Script, object)) {
|
|
1452
|
+
return;
|
|
1453
|
+
}
|
|
1454
|
+
const [fn] = await space.db.query(Filter.type(Operation.PersistentOperation, {
|
|
1455
|
+
source: Ref2.make(object)
|
|
1456
|
+
})).run();
|
|
1457
|
+
if (!fn) {
|
|
1458
|
+
return;
|
|
1459
|
+
}
|
|
1460
|
+
node.value = value;
|
|
1461
|
+
node.function = Ref2.make(fn);
|
|
1462
|
+
node.inputSchema = fn.inputSchema ? getSnapshot(fn.inputSchema) : void 0;
|
|
1463
|
+
node.outputSchema = fn.outputSchema ? getSnapshot(fn.outputSchema) : void 0;
|
|
1464
|
+
}, [
|
|
1465
|
+
client,
|
|
1466
|
+
node
|
|
1467
|
+
]);
|
|
1468
|
+
const handleAction = useCallback3((action) => {
|
|
1469
|
+
if (action !== "run") {
|
|
1470
|
+
return;
|
|
1471
|
+
}
|
|
1472
|
+
runtime.evalNode();
|
|
1473
|
+
}, [
|
|
1474
|
+
runtime
|
|
1475
|
+
]);
|
|
1476
|
+
return /* @__PURE__ */ React13.createElement(Box, {
|
|
1477
|
+
shape,
|
|
1478
|
+
title: "Function",
|
|
1479
|
+
onAction: handleAction
|
|
1480
|
+
}, /* @__PURE__ */ React13.createElement(TextBox3, {
|
|
1481
|
+
...props,
|
|
1482
|
+
ref: inputRef,
|
|
1483
|
+
value: node.value,
|
|
1484
|
+
language: node.valueType === "object" ? "json" : void 0,
|
|
1485
|
+
onBlur: handleEnter,
|
|
1486
|
+
onEnter: handleEnter
|
|
1487
|
+
}));
|
|
1487
1488
|
};
|
|
1488
1489
|
var functionShape = {
|
|
1489
1490
|
type: "function",
|
|
@@ -1495,12 +1496,12 @@ var functionShape = {
|
|
|
1495
1496
|
};
|
|
1496
1497
|
|
|
1497
1498
|
// src/shapes/Gpt.tsx
|
|
1498
|
-
import
|
|
1499
|
-
import
|
|
1500
|
-
import React13, { useEffect as useEffect4, useState as useState6 } from "react";
|
|
1499
|
+
import * as Schema13 from "effect/Schema";
|
|
1500
|
+
import React14, { useEffect as useEffect4, useState as useState6 } from "react";
|
|
1501
1501
|
import { GptInput, GptOutput } from "@dxos/conductor";
|
|
1502
|
-
|
|
1503
|
-
|
|
1502
|
+
import { ScrollArea as ScrollArea2 } from "@dxos/react-ui";
|
|
1503
|
+
var GptShape = Schema13.extend(ComputeShape, Schema13.Struct({
|
|
1504
|
+
type: Schema13.Literal("gpt")
|
|
1504
1505
|
}));
|
|
1505
1506
|
var createGpt = (props) => createShape({
|
|
1506
1507
|
type: "gpt",
|
|
@@ -1511,54 +1512,50 @@ var createGpt = (props) => createShape({
|
|
|
1511
1512
|
...props
|
|
1512
1513
|
});
|
|
1513
1514
|
var GptComponent = ({ shape }) => {
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
const
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
});
|
|
1538
|
-
break;
|
|
1539
|
-
}
|
|
1515
|
+
const { meta, runtime } = useComputeNodeState(shape);
|
|
1516
|
+
const [text, setText] = useState6("");
|
|
1517
|
+
const [tokens, setTokens] = useState6(0);
|
|
1518
|
+
useEffect4(() => {
|
|
1519
|
+
return runtime.subscribeToEventLog((ev) => {
|
|
1520
|
+
switch (ev.type) {
|
|
1521
|
+
case "begin-compute": {
|
|
1522
|
+
setText("");
|
|
1523
|
+
break;
|
|
1524
|
+
}
|
|
1525
|
+
case "custom": {
|
|
1526
|
+
const token = ev.event;
|
|
1527
|
+
switch (token.type) {
|
|
1528
|
+
case "content_block_delta":
|
|
1529
|
+
switch (token.delta.type) {
|
|
1530
|
+
case "text_delta": {
|
|
1531
|
+
const delta = token.delta.text;
|
|
1532
|
+
setText((prev) => {
|
|
1533
|
+
const text2 = prev + delta;
|
|
1534
|
+
setTokens(text2.split(" ").length);
|
|
1535
|
+
return text2;
|
|
1536
|
+
});
|
|
1537
|
+
break;
|
|
1540
1538
|
}
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
break;
|
|
1539
|
+
}
|
|
1540
|
+
break;
|
|
1544
1541
|
}
|
|
1542
|
+
break;
|
|
1545
1543
|
}
|
|
1546
|
-
}
|
|
1547
|
-
}, [
|
|
1548
|
-
runtime?.subscribeToEventLog
|
|
1549
|
-
]);
|
|
1550
|
-
return /* @__PURE__ */ React13.createElement(FunctionBody, {
|
|
1551
|
-
shape,
|
|
1552
|
-
content: /* @__PURE__ */ React13.createElement("div", {
|
|
1553
|
-
className: "pli-2 plb-1 overflow-y-auto"
|
|
1554
|
-
}, text),
|
|
1555
|
-
status: `${tokens} tokens`,
|
|
1556
|
-
inputSchema: meta.input,
|
|
1557
|
-
outputSchema: meta.output
|
|
1544
|
+
}
|
|
1558
1545
|
});
|
|
1559
|
-
}
|
|
1560
|
-
|
|
1561
|
-
|
|
1546
|
+
}, [
|
|
1547
|
+
runtime?.subscribeToEventLog
|
|
1548
|
+
]);
|
|
1549
|
+
return /* @__PURE__ */ React14.createElement(FunctionBody, {
|
|
1550
|
+
shape,
|
|
1551
|
+
content: /* @__PURE__ */ React14.createElement(ScrollArea2.Root, {
|
|
1552
|
+
orientation: "vertical",
|
|
1553
|
+
thin: true
|
|
1554
|
+
}, /* @__PURE__ */ React14.createElement(ScrollArea2.Viewport, null, text)),
|
|
1555
|
+
status: `${tokens} tokens`,
|
|
1556
|
+
inputSchema: meta.input,
|
|
1557
|
+
outputSchema: meta.output
|
|
1558
|
+
});
|
|
1562
1559
|
};
|
|
1563
1560
|
var gptShape = {
|
|
1564
1561
|
type: "gpt",
|
|
@@ -1570,44 +1567,162 @@ var gptShape = {
|
|
|
1570
1567
|
openable: true
|
|
1571
1568
|
};
|
|
1572
1569
|
|
|
1570
|
+
// src/shapes/GptRealtime.tsx
|
|
1571
|
+
import * as Schema14 from "effect/Schema";
|
|
1572
|
+
import React15, { useState as useState7 } from "react";
|
|
1573
|
+
import { log as log2 } from "@dxos/log";
|
|
1574
|
+
import { useConfig } from "@dxos/react-client";
|
|
1575
|
+
import { Icon as Icon4 } from "@dxos/react-ui";
|
|
1576
|
+
var __dxlog_file6 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/GptRealtime.tsx";
|
|
1577
|
+
var GptRealtimeShape = Schema14.extend(ComputeShape, Schema14.Struct({
|
|
1578
|
+
type: Schema14.Literal("gpt-realtime")
|
|
1579
|
+
}));
|
|
1580
|
+
var createGptRealtime = (props) => createShape({
|
|
1581
|
+
type: "gpt-realtime",
|
|
1582
|
+
size: {
|
|
1583
|
+
width: 256,
|
|
1584
|
+
height: 256
|
|
1585
|
+
},
|
|
1586
|
+
...props
|
|
1587
|
+
});
|
|
1588
|
+
var GptRealtimeComponent = ({ shape }) => {
|
|
1589
|
+
const [isLive, setIsLive] = useState7(false);
|
|
1590
|
+
const [isReady, setIsReady] = useState7(false);
|
|
1591
|
+
const config = useConfig();
|
|
1592
|
+
const start = async () => {
|
|
1593
|
+
setIsLive(true);
|
|
1594
|
+
try {
|
|
1595
|
+
const peerConnection = new RTCPeerConnection();
|
|
1596
|
+
peerConnection.ontrack = (event) => {
|
|
1597
|
+
const audioElement = document.createElement("audio");
|
|
1598
|
+
audioElement.srcObject = event.streams[0];
|
|
1599
|
+
audioElement.autoplay = true;
|
|
1600
|
+
audioElement.controls = false;
|
|
1601
|
+
audioElement.style.display = "none";
|
|
1602
|
+
document.body.appendChild(audioElement);
|
|
1603
|
+
setIsReady(true);
|
|
1604
|
+
};
|
|
1605
|
+
const stream = await navigator.mediaDevices.getUserMedia({
|
|
1606
|
+
audio: true
|
|
1607
|
+
});
|
|
1608
|
+
stream.getTracks().forEach((track) => peerConnection.addTransceiver(track, {
|
|
1609
|
+
direction: "sendrecv"
|
|
1610
|
+
}));
|
|
1611
|
+
const offer = await peerConnection.createOffer();
|
|
1612
|
+
await peerConnection.setLocalDescription(offer);
|
|
1613
|
+
const AiServiceUrl = new URL("/rtc-connect", config.values.runtime?.services?.ai?.server ?? DEFAULT_AI_SERVICE_URL);
|
|
1614
|
+
const response = await fetch(AiServiceUrl, {
|
|
1615
|
+
method: "POST",
|
|
1616
|
+
body: offer.sdp,
|
|
1617
|
+
headers: {
|
|
1618
|
+
"Content-Type": "application/sdp"
|
|
1619
|
+
}
|
|
1620
|
+
});
|
|
1621
|
+
const answer = await response.text();
|
|
1622
|
+
await peerConnection.setRemoteDescription({
|
|
1623
|
+
sdp: answer,
|
|
1624
|
+
type: "answer"
|
|
1625
|
+
});
|
|
1626
|
+
const dataChannel = peerConnection.createDataChannel("response");
|
|
1627
|
+
const configureData = () => {
|
|
1628
|
+
log2.info("Configuring data channel", void 0, {
|
|
1629
|
+
F: __dxlog_file6,
|
|
1630
|
+
L: 87,
|
|
1631
|
+
S: void 0,
|
|
1632
|
+
C: (f, a) => f(...a)
|
|
1633
|
+
});
|
|
1634
|
+
const event = {
|
|
1635
|
+
type: "session.update",
|
|
1636
|
+
session: {
|
|
1637
|
+
modalities: [
|
|
1638
|
+
"text",
|
|
1639
|
+
"audio"
|
|
1640
|
+
],
|
|
1641
|
+
// Provide the tools. Note they match the keys in the `fns` object above
|
|
1642
|
+
tools: []
|
|
1643
|
+
}
|
|
1644
|
+
};
|
|
1645
|
+
dataChannel.send(JSON.stringify(event));
|
|
1646
|
+
};
|
|
1647
|
+
dataChannel.addEventListener("open", (ev) => {
|
|
1648
|
+
log2.info("Opening data channel", {
|
|
1649
|
+
ev
|
|
1650
|
+
}, {
|
|
1651
|
+
F: __dxlog_file6,
|
|
1652
|
+
L: 100,
|
|
1653
|
+
S: void 0,
|
|
1654
|
+
C: (f, a) => f(...a)
|
|
1655
|
+
});
|
|
1656
|
+
configureData();
|
|
1657
|
+
});
|
|
1658
|
+
dataChannel.addEventListener("message", async (ev) => {
|
|
1659
|
+
const msg = JSON.parse(ev.data);
|
|
1660
|
+
if (msg.type === "response.function_call_arguments.done") {
|
|
1661
|
+
}
|
|
1662
|
+
});
|
|
1663
|
+
} catch (error) {
|
|
1664
|
+
log2.error("Error in realtime session:", {
|
|
1665
|
+
error
|
|
1666
|
+
}, {
|
|
1667
|
+
F: __dxlog_file6,
|
|
1668
|
+
L: 140,
|
|
1669
|
+
S: void 0,
|
|
1670
|
+
C: (f, a) => f(...a)
|
|
1671
|
+
});
|
|
1672
|
+
throw error;
|
|
1673
|
+
}
|
|
1674
|
+
};
|
|
1675
|
+
return /* @__PURE__ */ React15.createElement("div", {
|
|
1676
|
+
className: "flex w-full justify-center items-center"
|
|
1677
|
+
}, /* @__PURE__ */ React15.createElement(Icon4, {
|
|
1678
|
+
icon: isReady ? "ph--waveform--regular" : isLive ? "ph--pulse--regular" : "ph--play--regular",
|
|
1679
|
+
size: 16,
|
|
1680
|
+
classNames: !isLive && "cursor-pointer",
|
|
1681
|
+
onClick: start
|
|
1682
|
+
}));
|
|
1683
|
+
};
|
|
1684
|
+
var gptRealtimeShape = {
|
|
1685
|
+
type: "gpt-realtime",
|
|
1686
|
+
name: "GPT Realtime",
|
|
1687
|
+
icon: "ph--pulse--regular",
|
|
1688
|
+
component: GptRealtimeComponent,
|
|
1689
|
+
createShape: createGptRealtime,
|
|
1690
|
+
// TODO(dmaretskyi): Can we fetch the schema dynamically?
|
|
1691
|
+
getAnchors: (shape) => createFunctionAnchors(shape, Schema14.Struct({
|
|
1692
|
+
audio: Schema14.Any
|
|
1693
|
+
}), Schema14.Struct({})),
|
|
1694
|
+
resizable: true
|
|
1695
|
+
};
|
|
1696
|
+
var DEFAULT_AI_SERVICE_URL = "http://localhost:8788";
|
|
1697
|
+
|
|
1573
1698
|
// src/shapes/Json.tsx
|
|
1574
|
-
import
|
|
1575
|
-
import
|
|
1576
|
-
import React14 from "react";
|
|
1699
|
+
import * as Schema15 from "effect/Schema";
|
|
1700
|
+
import React16 from "react";
|
|
1577
1701
|
import { DEFAULT_INPUT as DEFAULT_INPUT4, DefaultOutput, JsonTransformInput } from "@dxos/conductor";
|
|
1578
1702
|
import { createAnchorMap as createAnchorMap6 } from "@dxos/react-ui-canvas-editor";
|
|
1579
|
-
import {
|
|
1580
|
-
var JsonShape =
|
|
1581
|
-
type:
|
|
1703
|
+
import { Json } from "@dxos/react-ui-syntax-highlighter";
|
|
1704
|
+
var JsonShape = Schema15.extend(ComputeShape, Schema15.Struct({
|
|
1705
|
+
type: Schema15.Literal("json")
|
|
1582
1706
|
}));
|
|
1583
|
-
var JsonTransformShape =
|
|
1584
|
-
type:
|
|
1707
|
+
var JsonTransformShape = Schema15.extend(ComputeShape, Schema15.Struct({
|
|
1708
|
+
type: Schema15.Literal("json-transform")
|
|
1585
1709
|
}));
|
|
1586
1710
|
var JsonComponent = ({ shape, ...props }) => {
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
}));
|
|
1598
|
-
} finally {
|
|
1599
|
-
_effect.f();
|
|
1600
|
-
}
|
|
1711
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1712
|
+
const input = runtime.inputs[DEFAULT_INPUT4];
|
|
1713
|
+
const value = input?.type === "executed" ? input.value : void 0;
|
|
1714
|
+
return /* @__PURE__ */ React16.createElement(Box, {
|
|
1715
|
+
shape
|
|
1716
|
+
}, /* @__PURE__ */ React16.createElement(Json.Root, {
|
|
1717
|
+
data: value
|
|
1718
|
+
}, /* @__PURE__ */ React16.createElement(Json.Content, null, /* @__PURE__ */ React16.createElement(Json.Filter, null), /* @__PURE__ */ React16.createElement(Json.Data, {
|
|
1719
|
+
classNames: "text-xs"
|
|
1720
|
+
}))));
|
|
1601
1721
|
};
|
|
1602
1722
|
var JsonTransformComponent = ({ shape, ...props }) => {
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
shape
|
|
1607
|
-
});
|
|
1608
|
-
} finally {
|
|
1609
|
-
_effect.f();
|
|
1610
|
-
}
|
|
1723
|
+
return /* @__PURE__ */ React16.createElement(Box, {
|
|
1724
|
+
shape
|
|
1725
|
+
});
|
|
1611
1726
|
};
|
|
1612
1727
|
var createJson = (props) => createShape({
|
|
1613
1728
|
type: "json",
|
|
@@ -1621,7 +1736,7 @@ var jsonShape = {
|
|
|
1621
1736
|
type: "json",
|
|
1622
1737
|
name: "JSON",
|
|
1623
1738
|
icon: "ph--code--regular",
|
|
1624
|
-
component: (props) => /* @__PURE__ */
|
|
1739
|
+
component: (props) => /* @__PURE__ */ React16.createElement(JsonComponent, props),
|
|
1625
1740
|
createShape: createJson,
|
|
1626
1741
|
getAnchors: (shape) => createAnchorMap6(shape, {
|
|
1627
1742
|
[createAnchorId("input")]: {
|
|
@@ -1647,46 +1762,35 @@ var jsonTransformShape = {
|
|
|
1647
1762
|
type: "json-transform",
|
|
1648
1763
|
name: "Transform",
|
|
1649
1764
|
icon: "ph--shuffle-simple--regular",
|
|
1650
|
-
component: (props) => /* @__PURE__ */
|
|
1765
|
+
component: (props) => /* @__PURE__ */ React16.createElement(JsonTransformComponent, props),
|
|
1651
1766
|
createShape: createJsonTransform,
|
|
1652
1767
|
getAnchors: (shape) => createFunctionAnchors(shape, JsonTransformInput, DefaultOutput),
|
|
1653
1768
|
resizable: true
|
|
1654
1769
|
};
|
|
1655
1770
|
|
|
1656
1771
|
// src/shapes/Logic.tsx
|
|
1657
|
-
import
|
|
1658
|
-
import
|
|
1659
|
-
import React15 from "react";
|
|
1772
|
+
import * as Schema16 from "effect/Schema";
|
|
1773
|
+
import React17 from "react";
|
|
1660
1774
|
import { IfElseInput, IfElseOutput, IfInput, IfOutput } from "@dxos/conductor";
|
|
1661
|
-
var IfShape =
|
|
1662
|
-
type:
|
|
1775
|
+
var IfShape = Schema16.extend(ComputeShape, Schema16.Struct({
|
|
1776
|
+
type: Schema16.Literal("if")
|
|
1663
1777
|
}));
|
|
1664
|
-
var IfElseShape =
|
|
1665
|
-
type:
|
|
1778
|
+
var IfElseShape = Schema16.extend(ComputeShape, Schema16.Struct({
|
|
1779
|
+
type: Schema16.Literal("if-else")
|
|
1666
1780
|
}));
|
|
1667
1781
|
var IfComponent = ({ shape, ...props }) => {
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
outputSchema: IfOutput
|
|
1674
|
-
});
|
|
1675
|
-
} finally {
|
|
1676
|
-
_effect.f();
|
|
1677
|
-
}
|
|
1782
|
+
return /* @__PURE__ */ React17.createElement(FunctionBody, {
|
|
1783
|
+
shape,
|
|
1784
|
+
inputSchema: IfInput,
|
|
1785
|
+
outputSchema: IfOutput
|
|
1786
|
+
});
|
|
1678
1787
|
};
|
|
1679
1788
|
var IfElseComponent = ({ shape, ...props }) => {
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
outputSchema: IfElseOutput
|
|
1686
|
-
});
|
|
1687
|
-
} finally {
|
|
1688
|
-
_effect.f();
|
|
1689
|
-
}
|
|
1789
|
+
return /* @__PURE__ */ React17.createElement(FunctionBody, {
|
|
1790
|
+
shape,
|
|
1791
|
+
inputSchema: IfElseInput,
|
|
1792
|
+
outputSchema: IfElseOutput
|
|
1793
|
+
});
|
|
1690
1794
|
};
|
|
1691
1795
|
var createIf = (props) => createShape({
|
|
1692
1796
|
type: "if",
|
|
@@ -1700,7 +1804,7 @@ var ifShape = {
|
|
|
1700
1804
|
type: "if",
|
|
1701
1805
|
name: "IF",
|
|
1702
1806
|
icon: "ph--arrows-split--regular",
|
|
1703
|
-
component: (props) => /* @__PURE__ */
|
|
1807
|
+
component: (props) => /* @__PURE__ */ React17.createElement(IfComponent, props),
|
|
1704
1808
|
createShape: createIf,
|
|
1705
1809
|
getAnchors: (shape) => createFunctionAnchors(shape, IfInput, IfOutput)
|
|
1706
1810
|
};
|
|
@@ -1716,95 +1820,21 @@ var ifElseShape = {
|
|
|
1716
1820
|
type: "if-else",
|
|
1717
1821
|
name: "IF/ELSE",
|
|
1718
1822
|
icon: "ph--arrows-merge--regular",
|
|
1719
|
-
component: (props) => /* @__PURE__ */
|
|
1823
|
+
component: (props) => /* @__PURE__ */ React17.createElement(IfElseComponent, props),
|
|
1720
1824
|
createShape: createIfElse,
|
|
1721
1825
|
getAnchors: (shape) => createFunctionAnchors(shape, IfElseInput, IfElseOutput)
|
|
1722
1826
|
};
|
|
1723
1827
|
|
|
1724
|
-
// src/shapes/Queue.tsx
|
|
1725
|
-
import { useSignals as _useSignals15 } from "@preact-signals/safe-react/tracking";
|
|
1726
|
-
import * as Schema15 from "effect/Schema";
|
|
1727
|
-
import React16, { Fragment } from "react";
|
|
1728
|
-
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT4, QueueInput, QueueOutput } from "@dxos/conductor";
|
|
1729
|
-
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
1730
|
-
var QueueShape = Schema15.extend(ComputeShape, Schema15.Struct({
|
|
1731
|
-
type: Schema15.Literal("queue")
|
|
1732
|
-
}));
|
|
1733
|
-
var createQueue = (props) => createShape({
|
|
1734
|
-
type: "queue",
|
|
1735
|
-
size: {
|
|
1736
|
-
width: 256,
|
|
1737
|
-
height: 512
|
|
1738
|
-
},
|
|
1739
|
-
...props
|
|
1740
|
-
});
|
|
1741
|
-
var QueueComponent = ({ shape }) => {
|
|
1742
|
-
var _effect = _useSignals15();
|
|
1743
|
-
try {
|
|
1744
|
-
const { runtime } = useComputeNodeState(shape);
|
|
1745
|
-
const items = runtime.outputs[DEFAULT_OUTPUT4]?.type === "executed" ? runtime.outputs[DEFAULT_OUTPUT4].value : [];
|
|
1746
|
-
const handleAction = (action) => {
|
|
1747
|
-
if (action === "run") {
|
|
1748
|
-
runtime.evalNode();
|
|
1749
|
-
}
|
|
1750
|
-
};
|
|
1751
|
-
return /* @__PURE__ */ React16.createElement(Box, {
|
|
1752
|
-
shape,
|
|
1753
|
-
status: `${items.length} items`,
|
|
1754
|
-
onAction: handleAction
|
|
1755
|
-
}, /* @__PURE__ */ React16.createElement("div", {
|
|
1756
|
-
className: "flex flex-col is-full overflow-y-auto divide-y divide-separator"
|
|
1757
|
-
}, [
|
|
1758
|
-
...items
|
|
1759
|
-
].map((item, i) => /* @__PURE__ */ React16.createElement(QueueItem, {
|
|
1760
|
-
key: i,
|
|
1761
|
-
classNames: "p-1 pli-2",
|
|
1762
|
-
item
|
|
1763
|
-
}))));
|
|
1764
|
-
} finally {
|
|
1765
|
-
_effect.f();
|
|
1766
|
-
}
|
|
1767
|
-
};
|
|
1768
|
-
var QueueItem = ({ classNames, item }) => {
|
|
1769
|
-
var _effect = _useSignals15();
|
|
1770
|
-
try {
|
|
1771
|
-
if (typeof item !== "object") {
|
|
1772
|
-
return /* @__PURE__ */ React16.createElement("div", {
|
|
1773
|
-
className: mx2(classNames, "whitespace-pre-wrap")
|
|
1774
|
-
}, item);
|
|
1775
|
-
}
|
|
1776
|
-
return /* @__PURE__ */ React16.createElement("div", {
|
|
1777
|
-
className: mx2("grid grid-cols-[80px,1fr]", classNames)
|
|
1778
|
-
}, Object.entries(item).map(([key, value]) => /* @__PURE__ */ React16.createElement(Fragment, {
|
|
1779
|
-
key
|
|
1780
|
-
}, /* @__PURE__ */ React16.createElement("div", {
|
|
1781
|
-
className: "p-1 text-xs text-subdued"
|
|
1782
|
-
}, key), /* @__PURE__ */ React16.createElement("div", null, typeof value === "string" ? value : JSON.stringify(value)))));
|
|
1783
|
-
} finally {
|
|
1784
|
-
_effect.f();
|
|
1785
|
-
}
|
|
1786
|
-
};
|
|
1787
|
-
var queueShape = {
|
|
1788
|
-
type: "queue",
|
|
1789
|
-
name: "Queue",
|
|
1790
|
-
icon: "ph--queue--regular",
|
|
1791
|
-
component: QueueComponent,
|
|
1792
|
-
createShape: createQueue,
|
|
1793
|
-
getAnchors: (shape) => createFunctionAnchors(shape, QueueInput, QueueOutput),
|
|
1794
|
-
resizable: true
|
|
1795
|
-
};
|
|
1796
|
-
|
|
1797
1828
|
// src/shapes/RNG.tsx
|
|
1798
|
-
import
|
|
1799
|
-
import
|
|
1800
|
-
import React17, { useEffect as useEffect5, useState as useState7 } from "react";
|
|
1829
|
+
import * as Schema17 from "effect/Schema";
|
|
1830
|
+
import React18, { useEffect as useEffect5, useState as useState8 } from "react";
|
|
1801
1831
|
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT5 } from "@dxos/conductor";
|
|
1802
|
-
import { Icon as
|
|
1832
|
+
import { Icon as Icon5 } from "@dxos/react-ui";
|
|
1803
1833
|
import { createAnchorMap as createAnchorMap7 } from "@dxos/react-ui-canvas-editor";
|
|
1804
|
-
var RandomShape =
|
|
1805
|
-
type:
|
|
1806
|
-
min:
|
|
1807
|
-
max:
|
|
1834
|
+
var RandomShape = Schema17.extend(ComputeShape, Schema17.Struct({
|
|
1835
|
+
type: Schema17.Literal("rng"),
|
|
1836
|
+
min: Schema17.optional(Schema17.Number),
|
|
1837
|
+
max: Schema17.optional(Schema17.Number)
|
|
1808
1838
|
}));
|
|
1809
1839
|
var createRandom = (props) => createShape({
|
|
1810
1840
|
type: "rng",
|
|
@@ -1824,42 +1854,37 @@ var icons = [
|
|
|
1824
1854
|
];
|
|
1825
1855
|
var pickIcon = () => icons[Math.floor(Math.random() * icons.length)];
|
|
1826
1856
|
var RandomComponent = ({ shape }) => {
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
clearTimeout(t1);
|
|
1842
|
-
clearTimeout(t2);
|
|
1843
|
-
};
|
|
1844
|
-
}, [
|
|
1845
|
-
spin
|
|
1846
|
-
]);
|
|
1847
|
-
const handleClick = (ev) => {
|
|
1848
|
-
ev.stopPropagation();
|
|
1849
|
-
runtime.setOutput(DEFAULT_OUTPUT5, Math.random());
|
|
1850
|
-
setSpin(true);
|
|
1857
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1858
|
+
const [spin, setSpin] = useState8(false);
|
|
1859
|
+
const [icon, setIcon] = useState8(pickIcon());
|
|
1860
|
+
useEffect5(() => {
|
|
1861
|
+
if (!spin) {
|
|
1862
|
+
return;
|
|
1863
|
+
}
|
|
1864
|
+
const i = setInterval(() => setIcon(pickIcon()), 250);
|
|
1865
|
+
const t1 = setTimeout(() => clearInterval(i), 900);
|
|
1866
|
+
const t2 = setTimeout(() => setSpin(false), 1100);
|
|
1867
|
+
return () => {
|
|
1868
|
+
clearInterval(i);
|
|
1869
|
+
clearTimeout(t1);
|
|
1870
|
+
clearTimeout(t2);
|
|
1851
1871
|
};
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
}
|
|
1872
|
+
}, [
|
|
1873
|
+
spin
|
|
1874
|
+
]);
|
|
1875
|
+
const handleClick = (ev) => {
|
|
1876
|
+
ev.stopPropagation();
|
|
1877
|
+
runtime.setOutput(DEFAULT_OUTPUT5, Math.random());
|
|
1878
|
+
setSpin(true);
|
|
1879
|
+
};
|
|
1880
|
+
return /* @__PURE__ */ React18.createElement("div", {
|
|
1881
|
+
className: "flex grow items-center justify-center"
|
|
1882
|
+
}, /* @__PURE__ */ React18.createElement(Icon5, {
|
|
1883
|
+
icon,
|
|
1884
|
+
classNames: spin && "animate-[spin_1s]",
|
|
1885
|
+
size: 10,
|
|
1886
|
+
onClick: handleClick
|
|
1887
|
+
}));
|
|
1863
1888
|
};
|
|
1864
1889
|
var randomShape = {
|
|
1865
1890
|
type: "rng",
|
|
@@ -1876,14 +1901,13 @@ var randomShape = {
|
|
|
1876
1901
|
};
|
|
1877
1902
|
|
|
1878
1903
|
// src/shapes/Scope.tsx
|
|
1879
|
-
import
|
|
1880
|
-
import
|
|
1881
|
-
import React18 from "react";
|
|
1904
|
+
import * as Schema18 from "effect/Schema";
|
|
1905
|
+
import React19 from "react";
|
|
1882
1906
|
import { DEFAULT_INPUT as DEFAULT_INPUT5 } from "@dxos/conductor";
|
|
1883
1907
|
import { createAnchorMap as createAnchorMap8 } from "@dxos/react-ui-canvas-editor";
|
|
1884
1908
|
import { Chaos, shaderPresets, useAudioStream } from "@dxos/react-ui-sfx";
|
|
1885
|
-
var ScopeShape =
|
|
1886
|
-
type:
|
|
1909
|
+
var ScopeShape = Schema18.extend(ComputeShape, Schema18.Struct({
|
|
1910
|
+
type: Schema18.Literal("scope")
|
|
1887
1911
|
}));
|
|
1888
1912
|
var createScope = (props) => createShape({
|
|
1889
1913
|
type: "scope",
|
|
@@ -1895,25 +1919,20 @@ var createScope = (props) => createShape({
|
|
|
1895
1919
|
...props
|
|
1896
1920
|
});
|
|
1897
1921
|
var ScopeComponent = ({ shape }) => {
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
}
|
|
1913
|
-
}));
|
|
1914
|
-
} finally {
|
|
1915
|
-
_effect.f();
|
|
1916
|
-
}
|
|
1922
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1923
|
+
const input = runtime.inputs[DEFAULT_INPUT5];
|
|
1924
|
+
const active = input?.type === "executed" ? input.value : false;
|
|
1925
|
+
const { getAverage } = useAudioStream(active);
|
|
1926
|
+
return /* @__PURE__ */ React19.createElement("div", {
|
|
1927
|
+
className: "flex w-full justify-center items-center bg-black"
|
|
1928
|
+
}, /* @__PURE__ */ React19.createElement(Chaos, {
|
|
1929
|
+
active,
|
|
1930
|
+
getValue: getAverage,
|
|
1931
|
+
options: {
|
|
1932
|
+
...shaderPresets.heptapod,
|
|
1933
|
+
zoom: 1.2
|
|
1934
|
+
}
|
|
1935
|
+
}));
|
|
1917
1936
|
};
|
|
1918
1937
|
var scopeShape = {
|
|
1919
1938
|
type: "scope",
|
|
@@ -1930,14 +1949,14 @@ var scopeShape = {
|
|
|
1930
1949
|
};
|
|
1931
1950
|
|
|
1932
1951
|
// src/shapes/Surface.tsx
|
|
1933
|
-
import
|
|
1934
|
-
import
|
|
1935
|
-
import
|
|
1936
|
-
import { Surface } from "@dxos/app-framework/react";
|
|
1952
|
+
import * as Schema19 from "effect/Schema";
|
|
1953
|
+
import React20 from "react";
|
|
1954
|
+
import { Surface } from "@dxos/app-framework/ui";
|
|
1937
1955
|
import { DEFAULT_INPUT as DEFAULT_INPUT6 } from "@dxos/conductor";
|
|
1956
|
+
import { Card } from "@dxos/react-ui";
|
|
1938
1957
|
import { createAnchorMap as createAnchorMap9 } from "@dxos/react-ui-canvas-editor";
|
|
1939
|
-
var SurfaceShape =
|
|
1940
|
-
type:
|
|
1958
|
+
var SurfaceShape = Schema19.extend(ComputeShape, Schema19.Struct({
|
|
1959
|
+
type: Schema19.Literal("surface")
|
|
1941
1960
|
}));
|
|
1942
1961
|
var createSurface = (props) => createShape({
|
|
1943
1962
|
type: "surface",
|
|
@@ -1948,29 +1967,24 @@ var createSurface = (props) => createShape({
|
|
|
1948
1967
|
...props
|
|
1949
1968
|
});
|
|
1950
1969
|
var SurfaceComponent = ({ shape }) => {
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
limit: 1
|
|
1970
|
-
}));
|
|
1971
|
-
} finally {
|
|
1972
|
-
_effect.f();
|
|
1973
|
-
}
|
|
1970
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1971
|
+
const input = runtime.inputs[DEFAULT_INPUT6];
|
|
1972
|
+
const value = input?.type === "executed" ? input.value : null;
|
|
1973
|
+
const handleAction = (action) => {
|
|
1974
|
+
if (action === "run") {
|
|
1975
|
+
runtime.evalNode();
|
|
1976
|
+
}
|
|
1977
|
+
};
|
|
1978
|
+
return /* @__PURE__ */ React20.createElement(Box, {
|
|
1979
|
+
shape,
|
|
1980
|
+
onAction: handleAction
|
|
1981
|
+
}, /* @__PURE__ */ React20.createElement(Card.Root, null, value !== null && /* @__PURE__ */ React20.createElement(Surface.Surface, {
|
|
1982
|
+
role: "card--content",
|
|
1983
|
+
data: {
|
|
1984
|
+
value
|
|
1985
|
+
},
|
|
1986
|
+
limit: 1
|
|
1987
|
+
})));
|
|
1974
1988
|
};
|
|
1975
1989
|
var surfaceShape = {
|
|
1976
1990
|
type: "surface",
|
|
@@ -1988,14 +2002,13 @@ var surfaceShape = {
|
|
|
1988
2002
|
};
|
|
1989
2003
|
|
|
1990
2004
|
// src/shapes/Switch.tsx
|
|
1991
|
-
import
|
|
1992
|
-
import
|
|
1993
|
-
import React20, { useEffect as useEffect6, useState as useState8 } from "react";
|
|
2005
|
+
import * as Schema20 from "effect/Schema";
|
|
2006
|
+
import React21, { useEffect as useEffect6, useState as useState9 } from "react";
|
|
1994
2007
|
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT6 } from "@dxos/conductor";
|
|
1995
2008
|
import { Input as Input2 } from "@dxos/react-ui";
|
|
1996
2009
|
import { createAnchorMap as createAnchorMap10 } from "@dxos/react-ui-canvas-editor";
|
|
1997
|
-
var SwitchShape =
|
|
1998
|
-
type:
|
|
2010
|
+
var SwitchShape = Schema20.extend(ComputeShape, Schema20.Struct({
|
|
2011
|
+
type: Schema20.Literal("switch")
|
|
1999
2012
|
}));
|
|
2000
2013
|
var createSwitch = (props) => createShape({
|
|
2001
2014
|
type: "switch",
|
|
@@ -2006,25 +2019,20 @@ var createSwitch = (props) => createShape({
|
|
|
2006
2019
|
...props
|
|
2007
2020
|
});
|
|
2008
2021
|
var SwitchComponent = ({ shape }) => {
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
onCheckedChange: (value2) => setValue(value2)
|
|
2024
|
-
})));
|
|
2025
|
-
} finally {
|
|
2026
|
-
_effect.f();
|
|
2027
|
-
}
|
|
2022
|
+
const { runtime } = useComputeNodeState(shape);
|
|
2023
|
+
const [value, setValue] = useState9(false);
|
|
2024
|
+
useEffect6(() => {
|
|
2025
|
+
runtime.setOutput(DEFAULT_OUTPUT6, value);
|
|
2026
|
+
}, [
|
|
2027
|
+
value
|
|
2028
|
+
]);
|
|
2029
|
+
return /* @__PURE__ */ React21.createElement("div", {
|
|
2030
|
+
className: "flex w-full justify-center items-center",
|
|
2031
|
+
onClick: (ev) => ev.stopPropagation()
|
|
2032
|
+
}, /* @__PURE__ */ React21.createElement(Input2.Root, null, /* @__PURE__ */ React21.createElement(Input2.Switch, {
|
|
2033
|
+
checked: value,
|
|
2034
|
+
onCheckedChange: (value2) => setValue(value2)
|
|
2035
|
+
})));
|
|
2028
2036
|
};
|
|
2029
2037
|
var switchShape = {
|
|
2030
2038
|
type: "switch",
|
|
@@ -2041,15 +2049,14 @@ var switchShape = {
|
|
|
2041
2049
|
};
|
|
2042
2050
|
|
|
2043
2051
|
// src/shapes/Table.tsx
|
|
2044
|
-
import
|
|
2045
|
-
import
|
|
2046
|
-
import React21 from "react";
|
|
2052
|
+
import * as Schema21 from "effect/Schema";
|
|
2053
|
+
import React22 from "react";
|
|
2047
2054
|
import { createInputSchema, createOutputSchema } from "@dxos/conductor";
|
|
2048
2055
|
import { Message } from "@dxos/types";
|
|
2049
2056
|
var InputSchema = createInputSchema(Message.Message);
|
|
2050
|
-
var OutputSchema = createOutputSchema(
|
|
2051
|
-
var TableShape =
|
|
2052
|
-
type:
|
|
2057
|
+
var OutputSchema = createOutputSchema(Schema21.mutable(Schema21.Array(Message.Message)));
|
|
2058
|
+
var TableShape = Schema21.extend(ComputeShape, Schema21.Struct({
|
|
2059
|
+
type: Schema21.Literal("table")
|
|
2053
2060
|
}));
|
|
2054
2061
|
var createTable = (props) => createShape({
|
|
2055
2062
|
type: "table",
|
|
@@ -2060,14 +2067,9 @@ var createTable = (props) => createShape({
|
|
|
2060
2067
|
...props
|
|
2061
2068
|
});
|
|
2062
2069
|
var TableComponent = ({ shape }) => {
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
shape
|
|
2067
|
-
});
|
|
2068
|
-
} finally {
|
|
2069
|
-
_effect.f();
|
|
2070
|
-
}
|
|
2070
|
+
return /* @__PURE__ */ React22.createElement(Box, {
|
|
2071
|
+
shape
|
|
2072
|
+
});
|
|
2071
2073
|
};
|
|
2072
2074
|
var tableShape = {
|
|
2073
2075
|
type: "table",
|
|
@@ -2080,62 +2082,56 @@ var tableShape = {
|
|
|
2080
2082
|
};
|
|
2081
2083
|
|
|
2082
2084
|
// src/shapes/Template.tsx
|
|
2083
|
-
import
|
|
2084
|
-
import
|
|
2085
|
-
import React22, { useRef as useRef5 } from "react";
|
|
2085
|
+
import * as Schema22 from "effect/Schema";
|
|
2086
|
+
import React23, { useRef as useRef5 } from "react";
|
|
2086
2087
|
import { ComputeValueType as ComputeValueType3, TemplateOutput, VoidInput as VoidInput2, getTemplateInputSchema as getTemplateInputSchema2 } from "@dxos/conductor";
|
|
2087
2088
|
import { toJsonSchema } from "@dxos/echo/internal";
|
|
2088
2089
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
2089
2090
|
import { TextBox as TextBox4 } from "@dxos/react-ui-canvas-editor";
|
|
2090
|
-
var
|
|
2091
|
-
var TemplateShape =
|
|
2092
|
-
type:
|
|
2093
|
-
valueType:
|
|
2091
|
+
var __dxlog_file7 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/Template.tsx";
|
|
2092
|
+
var TemplateShape = Schema22.extend(ComputeShape, Schema22.Struct({
|
|
2093
|
+
type: Schema22.Literal("template"),
|
|
2094
|
+
valueType: Schema22.optional(ComputeValueType3)
|
|
2094
2095
|
}));
|
|
2095
2096
|
var TextInputComponent3 = ({ shape, title, ...props }) => {
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
const
|
|
2100
|
-
|
|
2101
|
-
const
|
|
2102
|
-
|
|
2103
|
-
|
|
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
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
onEnter: handleEnter
|
|
2135
|
-
}));
|
|
2136
|
-
} finally {
|
|
2137
|
-
_effect.f();
|
|
2138
|
-
}
|
|
2097
|
+
const { node } = useComputeNodeState(shape);
|
|
2098
|
+
const inputRef = useRef5(null);
|
|
2099
|
+
const handleEnter = (text) => {
|
|
2100
|
+
const value = text.trim();
|
|
2101
|
+
if (value.length) {
|
|
2102
|
+
const schema = getTemplateInputSchema2(node);
|
|
2103
|
+
node.value = value;
|
|
2104
|
+
node.inputSchema = toJsonSchema(schema);
|
|
2105
|
+
}
|
|
2106
|
+
};
|
|
2107
|
+
const handleTypeChange = (newType) => {
|
|
2108
|
+
invariant5(Schema22.is(ComputeValueType3)(newType), "Invalid type", {
|
|
2109
|
+
F: __dxlog_file7,
|
|
2110
|
+
L: 58,
|
|
2111
|
+
S: void 0,
|
|
2112
|
+
A: [
|
|
2113
|
+
"Schema.is(ComputeValueType)(newType)",
|
|
2114
|
+
"'Invalid type'"
|
|
2115
|
+
]
|
|
2116
|
+
});
|
|
2117
|
+
node.valueType = newType;
|
|
2118
|
+
node.inputSchema = toJsonSchema(getTemplateInputSchema2(node));
|
|
2119
|
+
};
|
|
2120
|
+
return /* @__PURE__ */ React23.createElement(Box, {
|
|
2121
|
+
shape,
|
|
2122
|
+
title: "Template",
|
|
2123
|
+
status: /* @__PURE__ */ React23.createElement(TypeSelect, {
|
|
2124
|
+
value: node.valueType ?? "string",
|
|
2125
|
+
onValueChange: handleTypeChange
|
|
2126
|
+
})
|
|
2127
|
+
}, /* @__PURE__ */ React23.createElement(TextBox4, {
|
|
2128
|
+
...props,
|
|
2129
|
+
ref: inputRef,
|
|
2130
|
+
value: node.value,
|
|
2131
|
+
language: node.valueType === "object" ? "json" : void 0,
|
|
2132
|
+
onBlur: handleEnter,
|
|
2133
|
+
onEnter: handleEnter
|
|
2134
|
+
}));
|
|
2139
2135
|
};
|
|
2140
2136
|
var createTemplate = (props) => createShape({
|
|
2141
2137
|
type: "template",
|
|
@@ -2149,7 +2145,7 @@ var templateShape = {
|
|
|
2149
2145
|
type: "template",
|
|
2150
2146
|
name: "Template",
|
|
2151
2147
|
icon: "ph--article--regular",
|
|
2152
|
-
component: (props) => /* @__PURE__ */
|
|
2148
|
+
component: (props) => /* @__PURE__ */ React23.createElement(TextInputComponent3, {
|
|
2153
2149
|
...props,
|
|
2154
2150
|
placeholder: "Prompt"
|
|
2155
2151
|
}),
|
|
@@ -2159,14 +2155,13 @@ var templateShape = {
|
|
|
2159
2155
|
};
|
|
2160
2156
|
|
|
2161
2157
|
// src/shapes/Text.tsx
|
|
2162
|
-
import
|
|
2163
|
-
import
|
|
2164
|
-
import React23 from "react";
|
|
2158
|
+
import * as Schema23 from "effect/Schema";
|
|
2159
|
+
import React24 from "react";
|
|
2165
2160
|
import { DEFAULT_INPUT as DEFAULT_INPUT7 } from "@dxos/conductor";
|
|
2166
2161
|
import { TextBox as TextBox5 } from "@dxos/react-ui-canvas-editor";
|
|
2167
2162
|
import { createAnchorMap as createAnchorMap11 } from "@dxos/react-ui-canvas-editor";
|
|
2168
|
-
var TextShape =
|
|
2169
|
-
type:
|
|
2163
|
+
var TextShape = Schema23.extend(ComputeShape, Schema23.Struct({
|
|
2164
|
+
type: Schema23.Literal("text")
|
|
2170
2165
|
}));
|
|
2171
2166
|
var createText = (props) => createShape({
|
|
2172
2167
|
type: "text",
|
|
@@ -2177,25 +2172,20 @@ var createText = (props) => createShape({
|
|
|
2177
2172
|
...props
|
|
2178
2173
|
});
|
|
2179
2174
|
var TextComponent = ({ shape }) => {
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
value
|
|
2195
|
-
}));
|
|
2196
|
-
} finally {
|
|
2197
|
-
_effect.f();
|
|
2198
|
-
}
|
|
2175
|
+
const { runtime } = useComputeNodeState(shape);
|
|
2176
|
+
const input = runtime.inputs[DEFAULT_INPUT7];
|
|
2177
|
+
const value = input?.type === "executed" ? input.value : 0;
|
|
2178
|
+
const handleAction = (action) => {
|
|
2179
|
+
if (action === "run") {
|
|
2180
|
+
runtime.evalNode();
|
|
2181
|
+
}
|
|
2182
|
+
};
|
|
2183
|
+
return /* @__PURE__ */ React24.createElement(Box, {
|
|
2184
|
+
shape,
|
|
2185
|
+
onAction: handleAction
|
|
2186
|
+
}, /* @__PURE__ */ React24.createElement(TextBox5, {
|
|
2187
|
+
value
|
|
2188
|
+
}));
|
|
2199
2189
|
};
|
|
2200
2190
|
var textShape = {
|
|
2201
2191
|
type: "text",
|
|
@@ -2213,16 +2203,16 @@ var textShape = {
|
|
|
2213
2203
|
};
|
|
2214
2204
|
|
|
2215
2205
|
// src/shapes/Thread.tsx
|
|
2216
|
-
import
|
|
2217
|
-
import
|
|
2218
|
-
import React24, { useEffect as useEffect7, useRef as useRef6 } from "react";
|
|
2206
|
+
import * as Schema24 from "effect/Schema";
|
|
2207
|
+
import React25, { useEffect as useEffect7, useRef as useRef6 } from "react";
|
|
2219
2208
|
import { createInputSchema as createInputSchema2, createOutputSchema as createOutputSchema2 } from "@dxos/conductor";
|
|
2220
|
-
import {
|
|
2209
|
+
import { ScrollArea as ScrollArea3 } from "@dxos/react-ui";
|
|
2221
2210
|
import { Message as Message2 } from "@dxos/types";
|
|
2211
|
+
import { mx as mx3 } from "@dxos/ui-theme";
|
|
2222
2212
|
var InputSchema2 = createInputSchema2(Message2.Message);
|
|
2223
|
-
var OutputSchema2 = createOutputSchema2(
|
|
2224
|
-
var ThreadShape =
|
|
2225
|
-
type:
|
|
2213
|
+
var OutputSchema2 = createOutputSchema2(Schema24.mutable(Schema24.Array(Message2.Message)));
|
|
2214
|
+
var ThreadShape = Schema24.extend(ComputeShape, Schema24.Struct({
|
|
2215
|
+
type: Schema24.Literal("thread")
|
|
2226
2216
|
}));
|
|
2227
2217
|
var createThread = (props) => createShape({
|
|
2228
2218
|
type: "thread",
|
|
@@ -2233,49 +2223,42 @@ var createThread = (props) => createShape({
|
|
|
2233
2223
|
...props
|
|
2234
2224
|
});
|
|
2235
2225
|
var ThreadComponent = ({ shape }) => {
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
} finally {
|
|
2259
|
-
_effect.f();
|
|
2260
|
-
}
|
|
2226
|
+
const items = [];
|
|
2227
|
+
const scrollRef = useRef6(null);
|
|
2228
|
+
useEffect7(() => {
|
|
2229
|
+
if (scrollRef.current) {
|
|
2230
|
+
scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
|
|
2231
|
+
}
|
|
2232
|
+
}, [
|
|
2233
|
+
items
|
|
2234
|
+
]);
|
|
2235
|
+
return /* @__PURE__ */ React25.createElement(Box, {
|
|
2236
|
+
shape
|
|
2237
|
+
}, /* @__PURE__ */ React25.createElement(ScrollArea3.Root, {
|
|
2238
|
+
orientation: "vertical"
|
|
2239
|
+
}, /* @__PURE__ */ React25.createElement(ScrollArea3.Viewport, {
|
|
2240
|
+
classNames: "gap-2 p-2",
|
|
2241
|
+
ref: scrollRef
|
|
2242
|
+
}, [
|
|
2243
|
+
...items
|
|
2244
|
+
].map((item, i) => /* @__PURE__ */ React25.createElement(ThreadItem, {
|
|
2245
|
+
key: i,
|
|
2246
|
+
item
|
|
2247
|
+
})))));
|
|
2261
2248
|
};
|
|
2262
2249
|
var ThreadItem = ({ classNames, item }) => {
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
}, item);
|
|
2269
|
-
}
|
|
2270
|
-
const { role, message } = item;
|
|
2271
|
-
return /* @__PURE__ */ React24.createElement("div", {
|
|
2272
|
-
className: mx3("flex", classNames, role === "user" && "justify-end")
|
|
2273
|
-
}, /* @__PURE__ */ React24.createElement("div", {
|
|
2274
|
-
className: mx3("block rounded-md p-1 pli-2 text-sm", role === "user" ? "bg-blue-100 dark:bg-blue-800" : role === "system" ? "bg-red-100, dark:bg-red-800" : "whitespace-pre-wrap bg-neutral-50 dark:bg-neutral-800")
|
|
2275
|
-
}, message));
|
|
2276
|
-
} finally {
|
|
2277
|
-
_effect.f();
|
|
2250
|
+
if (typeof item !== "object") {
|
|
2251
|
+
return /* @__PURE__ */ React25.createElement("div", {
|
|
2252
|
+
role: "none",
|
|
2253
|
+
className: mx3(classNames)
|
|
2254
|
+
}, item);
|
|
2278
2255
|
}
|
|
2256
|
+
const { role, message } = item;
|
|
2257
|
+
return /* @__PURE__ */ React25.createElement("div", {
|
|
2258
|
+
className: mx3("flex", classNames, role === "user" && "justify-end")
|
|
2259
|
+
}, /* @__PURE__ */ React25.createElement("div", {
|
|
2260
|
+
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")
|
|
2261
|
+
}, message));
|
|
2279
2262
|
};
|
|
2280
2263
|
var threadShape = {
|
|
2281
2264
|
type: "thread",
|
|
@@ -2288,12 +2271,11 @@ var threadShape = {
|
|
|
2288
2271
|
};
|
|
2289
2272
|
|
|
2290
2273
|
// src/shapes/TextToImage.tsx
|
|
2291
|
-
import
|
|
2292
|
-
import
|
|
2293
|
-
import React25 from "react";
|
|
2274
|
+
import * as Schema25 from "effect/Schema";
|
|
2275
|
+
import React26 from "react";
|
|
2294
2276
|
import { createAnchorMap as createAnchorMap12 } from "@dxos/react-ui-canvas-editor";
|
|
2295
|
-
var TextToImageShape =
|
|
2296
|
-
type:
|
|
2277
|
+
var TextToImageShape = Schema25.extend(ComputeShape, Schema25.Struct({
|
|
2278
|
+
type: Schema25.Literal("text-to-image")
|
|
2297
2279
|
}));
|
|
2298
2280
|
var createTextToImage = (props) => createShape({
|
|
2299
2281
|
type: "text-to-image",
|
|
@@ -2304,14 +2286,9 @@ var createTextToImage = (props) => createShape({
|
|
|
2304
2286
|
...props
|
|
2305
2287
|
});
|
|
2306
2288
|
var TextToImageComponent = ({ shape }) => {
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
shape
|
|
2311
|
-
});
|
|
2312
|
-
} finally {
|
|
2313
|
-
_effect.f();
|
|
2314
|
-
}
|
|
2289
|
+
return /* @__PURE__ */ React26.createElement(Box, {
|
|
2290
|
+
shape
|
|
2291
|
+
});
|
|
2315
2292
|
};
|
|
2316
2293
|
var textToImageShape = {
|
|
2317
2294
|
type: "text-to-image",
|
|
@@ -2328,18 +2305,17 @@ var textToImageShape = {
|
|
|
2328
2305
|
};
|
|
2329
2306
|
|
|
2330
2307
|
// src/shapes/Trigger.tsx
|
|
2331
|
-
import
|
|
2332
|
-
import
|
|
2333
|
-
import React26, { useEffect as useEffect8 } from "react";
|
|
2308
|
+
import * as Schema26 from "effect/Schema";
|
|
2309
|
+
import React27, { useEffect as useEffect8 } from "react";
|
|
2334
2310
|
import { VoidInput as VoidInput3 } from "@dxos/conductor";
|
|
2335
|
-
import { Filter as Filter2, Obj as Obj4, Query, Ref as Ref3
|
|
2311
|
+
import { Filter as Filter2, Obj as Obj4, Query, Ref as Ref3 } from "@dxos/echo";
|
|
2336
2312
|
import { Trigger, TriggerEvent } from "@dxos/functions";
|
|
2337
2313
|
import { DXN, SpaceId } from "@dxos/keys";
|
|
2338
2314
|
import { useSpace } from "@dxos/react-client/echo";
|
|
2339
2315
|
import { Select as Select2 } from "@dxos/react-ui";
|
|
2340
|
-
var TriggerShape =
|
|
2341
|
-
type:
|
|
2342
|
-
functionTrigger:
|
|
2316
|
+
var TriggerShape = Schema26.extend(ComputeShape, Schema26.Struct({
|
|
2317
|
+
type: Schema26.Literal("trigger"),
|
|
2318
|
+
functionTrigger: Schema26.optional(Ref3.Ref(Trigger.Trigger))
|
|
2343
2319
|
}));
|
|
2344
2320
|
var createTrigger = (props) => {
|
|
2345
2321
|
const functionTrigger = Trigger.make({
|
|
@@ -2357,66 +2333,60 @@ var createTrigger = (props) => {
|
|
|
2357
2333
|
});
|
|
2358
2334
|
};
|
|
2359
2335
|
var TriggerComponent = ({ shape }) => {
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
functionTrigger.spec = createTriggerSpec({
|
|
2336
|
+
const space = useSpace();
|
|
2337
|
+
const functionTrigger = shape.functionTrigger?.target;
|
|
2338
|
+
useEffect8(() => {
|
|
2339
|
+
if (functionTrigger && !functionTrigger.spec) {
|
|
2340
|
+
Obj4.change(functionTrigger, (obj) => {
|
|
2341
|
+
obj.spec = createTriggerSpec({
|
|
2367
2342
|
triggerKind: "email",
|
|
2368
2343
|
spaceId: space?.id
|
|
2369
2344
|
});
|
|
2370
|
-
}
|
|
2371
|
-
}
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2345
|
+
});
|
|
2346
|
+
}
|
|
2347
|
+
}, [
|
|
2348
|
+
functionTrigger,
|
|
2349
|
+
functionTrigger?.spec
|
|
2350
|
+
]);
|
|
2351
|
+
useEffect8(() => {
|
|
2352
|
+
shape.size.height = getHeight(getOutputSchema(functionTrigger?.spec?.kind ?? "email"));
|
|
2353
|
+
}, [
|
|
2354
|
+
functionTrigger?.spec?.kind
|
|
2355
|
+
]);
|
|
2356
|
+
const setKind = (kind) => {
|
|
2357
|
+
if (functionTrigger?.spec?.kind !== kind) {
|
|
2358
|
+
Obj4.change(functionTrigger, (obj) => {
|
|
2359
|
+
obj.spec = createTriggerSpec({
|
|
2383
2360
|
triggerKind: kind,
|
|
2384
2361
|
spaceId: space?.id
|
|
2385
2362
|
});
|
|
2386
|
-
}
|
|
2387
|
-
};
|
|
2388
|
-
if (!functionTrigger?.spec) {
|
|
2389
|
-
return;
|
|
2363
|
+
});
|
|
2390
2364
|
}
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
value: functionTrigger.spec?.kind,
|
|
2395
|
-
onValueChange: (kind) => setKind(kind)
|
|
2396
|
-
}),
|
|
2397
|
-
inputSchema: VoidInput3,
|
|
2398
|
-
outputSchema: getOutputSchema(functionTrigger.spec.kind)
|
|
2399
|
-
});
|
|
2400
|
-
} finally {
|
|
2401
|
-
_effect.f();
|
|
2365
|
+
};
|
|
2366
|
+
if (!functionTrigger?.spec) {
|
|
2367
|
+
return;
|
|
2402
2368
|
}
|
|
2369
|
+
return /* @__PURE__ */ React27.createElement(FunctionBody, {
|
|
2370
|
+
shape,
|
|
2371
|
+
status: /* @__PURE__ */ React27.createElement(TriggerKindSelect, {
|
|
2372
|
+
value: functionTrigger.spec?.kind,
|
|
2373
|
+
onValueChange: (kind) => setKind(kind)
|
|
2374
|
+
}),
|
|
2375
|
+
inputSchema: VoidInput3,
|
|
2376
|
+
outputSchema: getOutputSchema(functionTrigger.spec.kind)
|
|
2377
|
+
});
|
|
2403
2378
|
};
|
|
2404
2379
|
var TriggerKindSelect = ({ value, onValueChange }) => {
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
value: kind
|
|
2416
|
-
}, kind))), /* @__PURE__ */ React26.createElement(Select2.ScrollDownButton, null), /* @__PURE__ */ React26.createElement(Select2.Arrow, null))));
|
|
2417
|
-
} finally {
|
|
2418
|
-
_effect.f();
|
|
2419
|
-
}
|
|
2380
|
+
return /* @__PURE__ */ React27.createElement(Select2.Root, {
|
|
2381
|
+
value,
|
|
2382
|
+
onValueChange
|
|
2383
|
+
}, /* @__PURE__ */ React27.createElement(Select2.TriggerButton, {
|
|
2384
|
+
variant: "ghost",
|
|
2385
|
+
classNames: "w-full px-0!"
|
|
2386
|
+
}), /* @__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, {
|
|
2387
|
+
key: kind,
|
|
2388
|
+
value: kind
|
|
2389
|
+
}, kind))), /* @__PURE__ */ React27.createElement(Select2.ScrollDownButton, null), /* @__PURE__ */ React27.createElement(Select2.Arrow, null))));
|
|
2420
2390
|
};
|
|
2421
2391
|
var createTriggerSpec = (props) => {
|
|
2422
2392
|
const kind = props.triggerKind ?? "email";
|
|
@@ -2474,140 +2444,6 @@ var triggerShape = {
|
|
|
2474
2444
|
getAnchors: (shape) => createFunctionAnchors(shape, VoidInput3, getOutputSchema(shape.functionTrigger?.target?.spec?.kind ?? "email"))
|
|
2475
2445
|
};
|
|
2476
2446
|
|
|
2477
|
-
// src/shapes/GptRealtime.tsx
|
|
2478
|
-
import { useSignals as _useSignals26 } from "@preact-signals/safe-react/tracking";
|
|
2479
|
-
import * as Schema26 from "effect/Schema";
|
|
2480
|
-
import React27, { useState as useState9 } from "react";
|
|
2481
|
-
import { log as log2 } from "@dxos/log";
|
|
2482
|
-
import { useConfig } from "@dxos/react-client";
|
|
2483
|
-
import { Icon as Icon5 } from "@dxos/react-ui";
|
|
2484
|
-
var __dxlog_file7 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/GptRealtime.tsx";
|
|
2485
|
-
var GptRealtimeShape = Schema26.extend(ComputeShape, Schema26.Struct({
|
|
2486
|
-
type: Schema26.Literal("gpt-realtime")
|
|
2487
|
-
}));
|
|
2488
|
-
var createGptRealtime = (props) => createShape({
|
|
2489
|
-
type: "gpt-realtime",
|
|
2490
|
-
size: {
|
|
2491
|
-
width: 256,
|
|
2492
|
-
height: 256
|
|
2493
|
-
},
|
|
2494
|
-
...props
|
|
2495
|
-
});
|
|
2496
|
-
var GptRealtimeComponent = ({ shape }) => {
|
|
2497
|
-
var _effect = _useSignals26();
|
|
2498
|
-
try {
|
|
2499
|
-
const [isLive, setIsLive] = useState9(false);
|
|
2500
|
-
const [isReady, setIsReady] = useState9(false);
|
|
2501
|
-
const config = useConfig();
|
|
2502
|
-
const start = async () => {
|
|
2503
|
-
setIsLive(true);
|
|
2504
|
-
try {
|
|
2505
|
-
const peerConnection = new RTCPeerConnection();
|
|
2506
|
-
peerConnection.ontrack = (event) => {
|
|
2507
|
-
const audioElement = document.createElement("audio");
|
|
2508
|
-
audioElement.srcObject = event.streams[0];
|
|
2509
|
-
audioElement.autoplay = true;
|
|
2510
|
-
audioElement.controls = false;
|
|
2511
|
-
audioElement.style.display = "none";
|
|
2512
|
-
document.body.appendChild(audioElement);
|
|
2513
|
-
setIsReady(true);
|
|
2514
|
-
};
|
|
2515
|
-
const stream = await navigator.mediaDevices.getUserMedia({
|
|
2516
|
-
audio: true
|
|
2517
|
-
});
|
|
2518
|
-
stream.getTracks().forEach((track) => peerConnection.addTransceiver(track, {
|
|
2519
|
-
direction: "sendrecv"
|
|
2520
|
-
}));
|
|
2521
|
-
const offer = await peerConnection.createOffer();
|
|
2522
|
-
await peerConnection.setLocalDescription(offer);
|
|
2523
|
-
const AiServiceUrl = new URL("/rtc-connect", config.values.runtime?.services?.ai?.server ?? DEFAULT_AI_SERVICE_URL);
|
|
2524
|
-
const response = await fetch(AiServiceUrl, {
|
|
2525
|
-
method: "POST",
|
|
2526
|
-
body: offer.sdp,
|
|
2527
|
-
headers: {
|
|
2528
|
-
"Content-Type": "application/sdp"
|
|
2529
|
-
}
|
|
2530
|
-
});
|
|
2531
|
-
const answer = await response.text();
|
|
2532
|
-
await peerConnection.setRemoteDescription({
|
|
2533
|
-
sdp: answer,
|
|
2534
|
-
type: "answer"
|
|
2535
|
-
});
|
|
2536
|
-
const dataChannel = peerConnection.createDataChannel("response");
|
|
2537
|
-
const configureData = () => {
|
|
2538
|
-
log2.info("Configuring data channel", void 0, {
|
|
2539
|
-
F: __dxlog_file7,
|
|
2540
|
-
L: 87,
|
|
2541
|
-
S: void 0,
|
|
2542
|
-
C: (f, a) => f(...a)
|
|
2543
|
-
});
|
|
2544
|
-
const event = {
|
|
2545
|
-
type: "session.update",
|
|
2546
|
-
session: {
|
|
2547
|
-
modalities: [
|
|
2548
|
-
"text",
|
|
2549
|
-
"audio"
|
|
2550
|
-
],
|
|
2551
|
-
// Provide the tools. Note they match the keys in the `fns` object above
|
|
2552
|
-
tools: []
|
|
2553
|
-
}
|
|
2554
|
-
};
|
|
2555
|
-
dataChannel.send(JSON.stringify(event));
|
|
2556
|
-
};
|
|
2557
|
-
dataChannel.addEventListener("open", (ev) => {
|
|
2558
|
-
log2.info("Opening data channel", {
|
|
2559
|
-
ev
|
|
2560
|
-
}, {
|
|
2561
|
-
F: __dxlog_file7,
|
|
2562
|
-
L: 100,
|
|
2563
|
-
S: void 0,
|
|
2564
|
-
C: (f, a) => f(...a)
|
|
2565
|
-
});
|
|
2566
|
-
configureData();
|
|
2567
|
-
});
|
|
2568
|
-
dataChannel.addEventListener("message", async (ev) => {
|
|
2569
|
-
const msg = JSON.parse(ev.data);
|
|
2570
|
-
if (msg.type === "response.function_call_arguments.done") {
|
|
2571
|
-
}
|
|
2572
|
-
});
|
|
2573
|
-
} catch (error) {
|
|
2574
|
-
log2.error("Error in realtime session:", {
|
|
2575
|
-
error
|
|
2576
|
-
}, {
|
|
2577
|
-
F: __dxlog_file7,
|
|
2578
|
-
L: 140,
|
|
2579
|
-
S: void 0,
|
|
2580
|
-
C: (f, a) => f(...a)
|
|
2581
|
-
});
|
|
2582
|
-
throw error;
|
|
2583
|
-
}
|
|
2584
|
-
};
|
|
2585
|
-
return /* @__PURE__ */ React27.createElement("div", {
|
|
2586
|
-
className: "flex is-full justify-center items-center"
|
|
2587
|
-
}, /* @__PURE__ */ React27.createElement(Icon5, {
|
|
2588
|
-
icon: isReady ? "ph--waveform--regular" : isLive ? "ph--pulse--regular" : "ph--play--regular",
|
|
2589
|
-
size: 16,
|
|
2590
|
-
classNames: !isLive && "cursor-pointer",
|
|
2591
|
-
onClick: start
|
|
2592
|
-
}));
|
|
2593
|
-
} finally {
|
|
2594
|
-
_effect.f();
|
|
2595
|
-
}
|
|
2596
|
-
};
|
|
2597
|
-
var gptRealtimeShape = {
|
|
2598
|
-
type: "gpt-realtime",
|
|
2599
|
-
name: "GPT Realtime",
|
|
2600
|
-
icon: "ph--pulse--regular",
|
|
2601
|
-
component: GptRealtimeComponent,
|
|
2602
|
-
createShape: createGptRealtime,
|
|
2603
|
-
// TODO(dmaretskyi): Can we fetch the schema dynamically?
|
|
2604
|
-
getAnchors: (shape) => createFunctionAnchors(shape, Schema26.Struct({
|
|
2605
|
-
audio: Schema26.Any
|
|
2606
|
-
}), Schema26.Struct({})),
|
|
2607
|
-
resizable: true
|
|
2608
|
-
};
|
|
2609
|
-
var DEFAULT_AI_SERVICE_URL = "http://localhost:8788";
|
|
2610
|
-
|
|
2611
2447
|
// src/registry.ts
|
|
2612
2448
|
var computeShapes = [
|
|
2613
2449
|
{
|
|
@@ -2653,7 +2489,7 @@ var computeShapes = [
|
|
|
2653
2489
|
shapes: [
|
|
2654
2490
|
//
|
|
2655
2491
|
jsonShape,
|
|
2656
|
-
|
|
2492
|
+
feedShape,
|
|
2657
2493
|
threadShape,
|
|
2658
2494
|
textShape,
|
|
2659
2495
|
surfaceShape,
|
|
@@ -2712,6 +2548,9 @@ export {
|
|
|
2712
2548
|
ConstantShape,
|
|
2713
2549
|
DatabaseComponent,
|
|
2714
2550
|
DatabaseShape,
|
|
2551
|
+
FeedComponent,
|
|
2552
|
+
FeedItem,
|
|
2553
|
+
FeedShape,
|
|
2715
2554
|
FunctionBody,
|
|
2716
2555
|
FunctionShape,
|
|
2717
2556
|
GptComponent,
|
|
@@ -2729,9 +2568,6 @@ export {
|
|
|
2729
2568
|
JsonTransformShape,
|
|
2730
2569
|
NotShape,
|
|
2731
2570
|
OrShape,
|
|
2732
|
-
QueueComponent,
|
|
2733
|
-
QueueItem,
|
|
2734
|
-
QueueShape,
|
|
2735
2571
|
RandomComponent,
|
|
2736
2572
|
RandomShape,
|
|
2737
2573
|
ReducerComponent,
|
|
@@ -2774,6 +2610,7 @@ export {
|
|
|
2774
2610
|
createComputeNode,
|
|
2775
2611
|
createConstant,
|
|
2776
2612
|
createDatabase,
|
|
2613
|
+
createFeed,
|
|
2777
2614
|
createFunction,
|
|
2778
2615
|
createFunctionAnchors,
|
|
2779
2616
|
createGpt,
|
|
@@ -2784,7 +2621,6 @@ export {
|
|
|
2784
2621
|
createJsonTransform,
|
|
2785
2622
|
createNot,
|
|
2786
2623
|
createOr,
|
|
2787
|
-
createQueue,
|
|
2788
2624
|
createRandom,
|
|
2789
2625
|
createReducer,
|
|
2790
2626
|
createScope,
|
|
@@ -2798,6 +2634,7 @@ export {
|
|
|
2798
2634
|
createThread,
|
|
2799
2635
|
createTrigger,
|
|
2800
2636
|
databaseShape,
|
|
2637
|
+
feedShape,
|
|
2801
2638
|
footerHeight,
|
|
2802
2639
|
functionShape,
|
|
2803
2640
|
getHeight,
|
|
@@ -2814,7 +2651,6 @@ export {
|
|
|
2814
2651
|
notShape,
|
|
2815
2652
|
orShape,
|
|
2816
2653
|
parseAnchorId,
|
|
2817
|
-
queueShape,
|
|
2818
2654
|
randomShape,
|
|
2819
2655
|
reducerShape,
|
|
2820
2656
|
resolveComputeNode,
|