@dxos/react-ui-canvas-compute 0.8.4-main.72ec0f3 → 0.8.4-main.8360d9e660
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 +738 -903
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +738 -903
- package/dist/lib/node-esm/index.mjs.map +3 -3
- 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/useGraphMonitor.d.ts +2 -2
- package/dist/types/src/hooks/useGraphMonitor.d.ts.map +1 -1
- 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/Queue.d.ts.map +1 -1
- package/dist/types/src/shapes/Surface.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/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 +59 -56
- package/src/README.md +0 -3
- package/src/compute.stories.tsx +73 -114
- package/src/graph/controller.ts +98 -67
- package/src/graph/node-defs.ts +31 -31
- package/src/hooks/useGraphMonitor.ts +11 -10
- package/src/json.test.ts +3 -3
- package/src/schema.test.ts +11 -11
- package/src/shapes/Audio.tsx +2 -2
- package/src/shapes/Beacon.tsx +1 -1
- package/src/shapes/Boolean.tsx +2 -2
- package/src/shapes/Function.tsx +8 -6
- package/src/shapes/Gpt.tsx +6 -1
- package/src/shapes/GptRealtime.tsx +1 -1
- package/src/shapes/Queue.tsx +15 -9
- package/src/shapes/Scope.tsx +1 -1
- package/src/shapes/Surface.tsx +4 -2
- package/src/shapes/Switch.tsx +1 -1
- package/src/shapes/Thread.tsx +15 -9
- package/src/shapes/Trigger.tsx +13 -8
- package/src/shapes/common/Box.tsx +8 -9
- package/src/shapes/common/FunctionBody.tsx +4 -4
- package/src/shapes/common/TypeSelect.tsx +1 -1
- package/src/shapes/defs.ts +3 -3
- package/src/testing/circuits.ts +5 -14
|
@@ -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, TracingService } from "@dxos/functions";
|
|
11
14
|
import { log } from "@dxos/log";
|
|
12
15
|
|
|
13
16
|
// src/hooks/compute-context.ts
|
|
@@ -145,9 +148,8 @@ var useComputeNodeState = (shape) => {
|
|
|
145
148
|
// src/hooks/useGraphMonitor.ts
|
|
146
149
|
import { useMemo } from "react";
|
|
147
150
|
import { ComputeGraphModel, DEFAULT_INPUT, DEFAULT_OUTPUT } from "@dxos/conductor";
|
|
148
|
-
import {
|
|
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",
|
|
@@ -172,7 +174,7 @@ var mapEdge = (graph, { source, target, output = DEFAULT_OUTPUT, input = DEFAULT
|
|
|
172
174
|
]
|
|
173
175
|
});
|
|
174
176
|
return {
|
|
175
|
-
id:
|
|
177
|
+
id: Obj.ID.random(),
|
|
176
178
|
source: sourceNode.node,
|
|
177
179
|
target: targetNode.node,
|
|
178
180
|
output,
|
|
@@ -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, (t) => {
|
|
259
|
+
t.function = Ref.make(graph.root);
|
|
260
|
+
t.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
|
};
|
|
@@ -272,7 +276,7 @@ var deleteTriggerObjects = (computeGraph, deleted) => {
|
|
|
272
276
|
// src/graph/node-defs.ts
|
|
273
277
|
import { NODE_INPUT, NODE_OUTPUT, getTemplateInputSchema, registry } from "@dxos/conductor";
|
|
274
278
|
import { raise as raise2 } from "@dxos/debug";
|
|
275
|
-
import {
|
|
279
|
+
import { JsonSchema, Obj as Obj2 } from "@dxos/echo";
|
|
276
280
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
277
281
|
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/graph/node-defs.ts";
|
|
278
282
|
var resolveComputeNode = async (node) => {
|
|
@@ -301,46 +305,46 @@ 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
|
|
334
338
|
});
|
|
335
|
-
node.inputSchema = toJsonSchema(getTemplateInputSchema(node));
|
|
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
|
-
id:
|
|
347
|
+
id: Obj2.ID.random(),
|
|
344
348
|
type,
|
|
345
349
|
...props
|
|
346
350
|
});
|
|
@@ -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))), 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))), 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: 377,
|
|
557
560
|
S: this,
|
|
558
561
|
C: (f, a) => f(...a)
|
|
559
562
|
});
|
|
@@ -630,78 +633,71 @@ 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
|
-
|
|
695
|
-
|
|
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
|
+
size: 4,
|
|
673
|
+
label: "run",
|
|
674
|
+
iconOnly: true,
|
|
675
|
+
onDoubleClick: (ev) => ev.stopPropagation(),
|
|
676
|
+
onClick: (ev) => {
|
|
677
|
+
ev.stopPropagation();
|
|
678
|
+
onAction?.("run");
|
|
679
|
+
}
|
|
680
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
681
|
+
className: mx("flex flex-col h-full grow overflow-hidden", classNames)
|
|
682
|
+
}, children), /* @__PURE__ */ React.createElement("div", {
|
|
683
|
+
className: "flex shrink-0 w-full justify-between items-center h-[32px] bg-input-surface"
|
|
684
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
685
|
+
className: "grow px-2 text-sm truncate"
|
|
686
|
+
}, debug ? shape.id : status), openable && /* @__PURE__ */ React.createElement(IconButton, {
|
|
687
|
+
classNames: "p-1",
|
|
688
|
+
variant: "ghost",
|
|
689
|
+
icon: open ? "ph--caret-up--regular" : "ph--caret-down--regular",
|
|
690
|
+
size: 4,
|
|
691
|
+
label: open ? "close" : "open",
|
|
692
|
+
iconOnly: true,
|
|
693
|
+
onClick: (ev) => {
|
|
694
|
+
ev.stopPropagation();
|
|
695
|
+
onAction?.(open ? "close" : "open");
|
|
696
|
+
}
|
|
697
|
+
})));
|
|
701
698
|
});
|
|
702
699
|
|
|
703
700
|
// src/shapes/common/FunctionBody.tsx
|
|
704
|
-
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
705
701
|
import * as SchemaAST2 from "effect/SchemaAST";
|
|
706
702
|
import React2, { useRef, useState as useState3 } from "react";
|
|
707
703
|
import { VoidInput, VoidOutput } from "@dxos/conductor";
|
|
@@ -712,7 +708,7 @@ import { createAnchors, getParentShapeElement, rowHeight } from "@dxos/react-ui-
|
|
|
712
708
|
import * as Schema2 from "effect/Schema";
|
|
713
709
|
import * as SchemaAST from "effect/SchemaAST";
|
|
714
710
|
import { DEFAULT_INPUT as DEFAULT_INPUT2, DEFAULT_OUTPUT as DEFAULT_OUTPUT2 } from "@dxos/conductor";
|
|
715
|
-
import {
|
|
711
|
+
import { Obj as Obj3 } from "@dxos/echo";
|
|
716
712
|
import { Polygon } from "@dxos/react-ui-canvas-editor";
|
|
717
713
|
var getProperties = (ast) => SchemaAST.getPropertySignatures(ast).map(({ name }) => ({
|
|
718
714
|
name: name.toString()
|
|
@@ -730,13 +726,13 @@ var parseAnchorId = (id) => {
|
|
|
730
726
|
};
|
|
731
727
|
var ComputeShape = Schema2.extend(Polygon, Schema2.Struct({
|
|
732
728
|
// TODO(burdon): Rename computeNode?
|
|
733
|
-
node: Schema2.optional(
|
|
729
|
+
node: Schema2.optional(Obj3.ID.annotations({
|
|
734
730
|
description: "Compute node id"
|
|
735
731
|
}))
|
|
736
732
|
}).pipe(Schema2.mutable));
|
|
737
733
|
var createShape = ({ id, ...rest }) => {
|
|
738
734
|
return {
|
|
739
|
-
id: id ??
|
|
735
|
+
id: id ?? Obj3.ID.random(),
|
|
740
736
|
...rest
|
|
741
737
|
};
|
|
742
738
|
};
|
|
@@ -745,70 +741,65 @@ var createShape = ({ id, ...rest }) => {
|
|
|
745
741
|
var bodyPadding = 8;
|
|
746
742
|
var expandedHeight = 200;
|
|
747
743
|
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
|
|
744
|
+
const { scale } = useCanvasContext();
|
|
745
|
+
const rootRef = useRef(null);
|
|
746
|
+
const [open, setOpen] = useState3(false);
|
|
747
|
+
const handleAction = (action) => {
|
|
748
|
+
if (!rootRef.current) {
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
switch (action) {
|
|
752
|
+
case "open": {
|
|
753
|
+
const el = getParentShapeElement(rootRef.current, shape.id);
|
|
754
|
+
const { height } = el.getBoundingClientRect();
|
|
755
|
+
el.style.height = `${height / scale + expandedHeight}px`;
|
|
756
|
+
setOpen(true);
|
|
757
|
+
break;
|
|
797
758
|
}
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
style: {
|
|
804
|
-
height: rowHeight
|
|
759
|
+
case "close": {
|
|
760
|
+
const el = getParentShapeElement(rootRef.current, shape.id);
|
|
761
|
+
el.style.height = "";
|
|
762
|
+
setOpen(false);
|
|
763
|
+
break;
|
|
805
764
|
}
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
765
|
+
}
|
|
766
|
+
};
|
|
767
|
+
const inputs = getProperties(inputSchema.ast);
|
|
768
|
+
const outputs = getProperties(outputSchema.ast);
|
|
769
|
+
const columnCount = inputs.length && outputs.length ? 2 : 1;
|
|
770
|
+
return /* @__PURE__ */ React2.createElement(Box, {
|
|
771
|
+
ref: rootRef,
|
|
772
|
+
shape,
|
|
773
|
+
title: name,
|
|
774
|
+
classNames: "divide-y divide-separator",
|
|
775
|
+
open,
|
|
776
|
+
onAction: handleAction,
|
|
777
|
+
...props
|
|
778
|
+
}, /* @__PURE__ */ React2.createElement("div", {
|
|
779
|
+
className: `grid grid-cols-${columnCount} items-center`,
|
|
780
|
+
style: {
|
|
781
|
+
paddingTop: bodyPadding,
|
|
782
|
+
paddingBottom: bodyPadding
|
|
783
|
+
}
|
|
784
|
+
}, (inputs?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement("div", {
|
|
785
|
+
className: "flex flex-col"
|
|
786
|
+
}, inputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
|
|
787
|
+
key: name2,
|
|
788
|
+
className: "px-2 truncate text-sm font-mono items-center",
|
|
789
|
+
style: {
|
|
790
|
+
height: rowHeight
|
|
791
|
+
}
|
|
792
|
+
}, name2))), (outputs?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement("div", {
|
|
793
|
+
className: "flex flex-col"
|
|
794
|
+
}, outputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
|
|
795
|
+
key: name2,
|
|
796
|
+
className: "px-2 truncate text-sm font-mono items-center text-right",
|
|
797
|
+
style: {
|
|
798
|
+
height: rowHeight
|
|
799
|
+
}
|
|
800
|
+
}, name2)))), open && /* @__PURE__ */ React2.createElement("div", {
|
|
801
|
+
className: "flex flex-col grow overflow-hidden"
|
|
802
|
+
}, content));
|
|
812
803
|
};
|
|
813
804
|
var getHeight = (input) => {
|
|
814
805
|
const properties = SchemaAST2.getPropertySignatures(input.ast);
|
|
@@ -829,30 +820,23 @@ var createFunctionAnchors = (shape, input = VoidInput, output = VoidOutput) => {
|
|
|
829
820
|
};
|
|
830
821
|
|
|
831
822
|
// src/shapes/common/TypeSelect.tsx
|
|
832
|
-
import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
|
|
833
823
|
import React3 from "react";
|
|
834
824
|
import { ComputeValueType } from "@dxos/conductor";
|
|
835
825
|
import { Select } from "@dxos/react-ui";
|
|
836
826
|
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
|
-
}
|
|
827
|
+
return /* @__PURE__ */ React3.createElement(Select.Root, {
|
|
828
|
+
value,
|
|
829
|
+
onValueChange
|
|
830
|
+
}, /* @__PURE__ */ React3.createElement(Select.TriggerButton, {
|
|
831
|
+
variant: "ghost",
|
|
832
|
+
classNames: "w-full px-0!"
|
|
833
|
+
}), /* @__PURE__ */ React3.createElement(Select.Portal, null, /* @__PURE__ */ React3.createElement(Select.Content, null, /* @__PURE__ */ React3.createElement(Select.ScrollUpButton, null), /* @__PURE__ */ React3.createElement(Select.Viewport, null, ComputeValueType.literals.map((type) => /* @__PURE__ */ React3.createElement(Select.Option, {
|
|
834
|
+
key: type,
|
|
835
|
+
value: type
|
|
836
|
+
}, type))), /* @__PURE__ */ React3.createElement(Select.ScrollDownButton, null), /* @__PURE__ */ React3.createElement(Select.Arrow, null))));
|
|
852
837
|
};
|
|
853
838
|
|
|
854
839
|
// src/shapes/Array.tsx
|
|
855
|
-
import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
|
|
856
840
|
import * as Schema3 from "effect/Schema";
|
|
857
841
|
import React4 from "react";
|
|
858
842
|
import { ReducerInput, ReducerOutput } from "@dxos/conductor";
|
|
@@ -860,16 +844,11 @@ var ReducerShape = Schema3.extend(ComputeShape, Schema3.Struct({
|
|
|
860
844
|
type: Schema3.Literal("reducer")
|
|
861
845
|
}));
|
|
862
846
|
var ReducerComponent = ({ shape }) => {
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
outputSchema: ReducerOutput
|
|
869
|
-
});
|
|
870
|
-
} finally {
|
|
871
|
-
_effect.f();
|
|
872
|
-
}
|
|
847
|
+
return /* @__PURE__ */ React4.createElement(FunctionBody, {
|
|
848
|
+
shape,
|
|
849
|
+
inputSchema: ReducerInput,
|
|
850
|
+
outputSchema: ReducerOutput
|
|
851
|
+
});
|
|
873
852
|
};
|
|
874
853
|
var createReducer = ({ id, size = {
|
|
875
854
|
width: 192,
|
|
@@ -889,7 +868,6 @@ var reducerShape = {
|
|
|
889
868
|
};
|
|
890
869
|
|
|
891
870
|
// src/shapes/Append.tsx
|
|
892
|
-
import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
|
|
893
871
|
import * as Schema4 from "effect/Schema";
|
|
894
872
|
import React5 from "react";
|
|
895
873
|
import { AppendInput } from "@dxos/conductor";
|
|
@@ -905,15 +883,10 @@ var createAppend = (props) => createShape({
|
|
|
905
883
|
...props
|
|
906
884
|
});
|
|
907
885
|
var AppendComponent = ({ shape }) => {
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
inputSchema: AppendInput
|
|
913
|
-
});
|
|
914
|
-
} finally {
|
|
915
|
-
_effect.f();
|
|
916
|
-
}
|
|
886
|
+
return /* @__PURE__ */ React5.createElement(FunctionBody, {
|
|
887
|
+
shape,
|
|
888
|
+
inputSchema: AppendInput
|
|
889
|
+
});
|
|
917
890
|
};
|
|
918
891
|
var appendShape = {
|
|
919
892
|
type: "append",
|
|
@@ -925,7 +898,6 @@ var appendShape = {
|
|
|
925
898
|
};
|
|
926
899
|
|
|
927
900
|
// src/shapes/Audio.tsx
|
|
928
|
-
import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
|
|
929
901
|
import * as Schema5 from "effect/Schema";
|
|
930
902
|
import React6, { useEffect as useEffect3, useState as useState4 } from "react";
|
|
931
903
|
import { Icon as Icon2 } from "@dxos/react-ui";
|
|
@@ -942,29 +914,24 @@ var createAudio = (props) => createShape({
|
|
|
942
914
|
...props
|
|
943
915
|
});
|
|
944
916
|
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
|
-
}
|
|
917
|
+
const { node } = useComputeNodeState(shape);
|
|
918
|
+
const [active, setActive] = useState4(false);
|
|
919
|
+
useEffect3(() => {
|
|
920
|
+
node.value = active;
|
|
921
|
+
}, [
|
|
922
|
+
active
|
|
923
|
+
]);
|
|
924
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
925
|
+
className: "flex w-full justify-center items-center"
|
|
926
|
+
}, /* @__PURE__ */ React6.createElement(Icon2, {
|
|
927
|
+
icon: active ? "ph--microphone--regular" : "ph--microphone-slash--regular",
|
|
928
|
+
classNames: [
|
|
929
|
+
"transition opacity-20 duration-1000",
|
|
930
|
+
active && "opacity-100 text-error-text"
|
|
931
|
+
],
|
|
932
|
+
size: 8,
|
|
933
|
+
onClick: () => setActive(!active)
|
|
934
|
+
}));
|
|
968
935
|
};
|
|
969
936
|
var audioShape = {
|
|
970
937
|
type: "audio",
|
|
@@ -981,7 +948,6 @@ var audioShape = {
|
|
|
981
948
|
};
|
|
982
949
|
|
|
983
950
|
// src/shapes/Beacon.tsx
|
|
984
|
-
import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
|
|
985
951
|
import * as Schema6 from "effect/Schema";
|
|
986
952
|
import React7 from "react";
|
|
987
953
|
import { DEFAULT_INPUT as DEFAULT_INPUT3, isTruthy } from "@dxos/conductor";
|
|
@@ -999,24 +965,19 @@ var createBeacon = (props) => createShape({
|
|
|
999
965
|
...props
|
|
1000
966
|
});
|
|
1001
967
|
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
|
-
}
|
|
968
|
+
const { runtime } = useComputeNodeState(shape);
|
|
969
|
+
const input = runtime.inputs[DEFAULT_INPUT3];
|
|
970
|
+
const value = input?.type === "executed" ? input.value : false;
|
|
971
|
+
return /* @__PURE__ */ React7.createElement("div", {
|
|
972
|
+
className: "flex w-full justify-center items-center"
|
|
973
|
+
}, /* @__PURE__ */ React7.createElement(Icon3, {
|
|
974
|
+
icon: "ph--sun--regular",
|
|
975
|
+
classNames: [
|
|
976
|
+
"transition opacity-20 duration-1000",
|
|
977
|
+
isTruthy(value) && "opacity-100 text-yellow-500"
|
|
978
|
+
],
|
|
979
|
+
size: 8
|
|
980
|
+
}));
|
|
1020
981
|
};
|
|
1021
982
|
var beaconShape = {
|
|
1022
983
|
type: "beacon",
|
|
@@ -1057,7 +1018,7 @@ var defineShape = ({ type, name, icon, symbol: Symbol, createShape: createShape2
|
|
|
1057
1018
|
// Be careful not to name component factories with a capital letter.
|
|
1058
1019
|
component: () => {
|
|
1059
1020
|
return /* @__PURE__ */ React8.createElement("div", {
|
|
1060
|
-
className: "flex
|
|
1021
|
+
className: "flex w-full justify-center items-center"
|
|
1061
1022
|
}, /* @__PURE__ */ React8.createElement(Symbol, null));
|
|
1062
1023
|
},
|
|
1063
1024
|
createShape: createShape2,
|
|
@@ -1084,7 +1045,7 @@ var createSymbol = (pathConstructor, inputs) => ({
|
|
|
1084
1045
|
});
|
|
1085
1046
|
return /* @__PURE__ */ React8.createElement("svg", {
|
|
1086
1047
|
viewBox: `0 0 ${width} ${height}`,
|
|
1087
|
-
className: "
|
|
1048
|
+
className: "w-full h-full"
|
|
1088
1049
|
}, getAnchorPoints({
|
|
1089
1050
|
x: 0,
|
|
1090
1051
|
y: centerY
|
|
@@ -1206,7 +1167,6 @@ var notShape = defineShape({
|
|
|
1206
1167
|
});
|
|
1207
1168
|
|
|
1208
1169
|
// src/shapes/Chat.tsx
|
|
1209
|
-
import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
|
|
1210
1170
|
import * as Schema8 from "effect/Schema";
|
|
1211
1171
|
import React9, { useRef as useRef2 } from "react";
|
|
1212
1172
|
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT3 } from "@dxos/conductor";
|
|
@@ -1216,28 +1176,23 @@ var ChatShape = Schema8.extend(ComputeShape, Schema8.Struct({
|
|
|
1216
1176
|
type: Schema8.Literal("chat")
|
|
1217
1177
|
}));
|
|
1218
1178
|
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
|
-
}
|
|
1179
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1180
|
+
const inputRef = useRef2(null);
|
|
1181
|
+
const handleEnter = (text) => {
|
|
1182
|
+
const value = text.trim();
|
|
1183
|
+
if (value.length) {
|
|
1184
|
+
runtime.setOutput(DEFAULT_OUTPUT3, value);
|
|
1185
|
+
inputRef.current?.setText("");
|
|
1186
|
+
}
|
|
1187
|
+
};
|
|
1188
|
+
return /* @__PURE__ */ React9.createElement(Box, {
|
|
1189
|
+
shape,
|
|
1190
|
+
title
|
|
1191
|
+
}, /* @__PURE__ */ React9.createElement(TextBox, {
|
|
1192
|
+
ref: inputRef,
|
|
1193
|
+
onEnter: handleEnter,
|
|
1194
|
+
...props
|
|
1195
|
+
}));
|
|
1241
1196
|
};
|
|
1242
1197
|
var createChat = (props) => createShape({
|
|
1243
1198
|
type: "chat",
|
|
@@ -1267,7 +1222,6 @@ var chatShape = {
|
|
|
1267
1222
|
};
|
|
1268
1223
|
|
|
1269
1224
|
// src/shapes/Constant.tsx
|
|
1270
|
-
import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
|
|
1271
1225
|
import * as Schema9 from "effect/Schema";
|
|
1272
1226
|
import React10, { useCallback as useCallback2, useRef as useRef3, useState as useState5 } from "react";
|
|
1273
1227
|
import { ComputeValueType as ComputeValueType2 } from "@dxos/conductor";
|
|
@@ -1291,57 +1245,52 @@ var inferType = (value) => {
|
|
|
1291
1245
|
}
|
|
1292
1246
|
};
|
|
1293
1247
|
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;
|
|
1248
|
+
const { node } = useComputeNodeState(shape);
|
|
1249
|
+
const [type, setType] = useState5(inferType(node.value) ?? ComputeValueType2.literals[0]);
|
|
1250
|
+
const inputRef = useRef3(null);
|
|
1251
|
+
const handleEnter = useCallback2((text) => {
|
|
1252
|
+
const value = text.trim();
|
|
1253
|
+
if (value.length) {
|
|
1254
|
+
if (type === "number") {
|
|
1255
|
+
const floatValue = parseFloat(value);
|
|
1256
|
+
if (!isNaN(floatValue)) {
|
|
1257
|
+
node.value = floatValue;
|
|
1311
1258
|
}
|
|
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) => {
|
|
1259
|
+
} else if (type === "object") {
|
|
1260
|
+
node.value = safeParseJson(value, {});
|
|
1261
|
+
} else {
|
|
1339
1262
|
node.value = value;
|
|
1340
1263
|
}
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1264
|
+
inputRef.current?.focus();
|
|
1265
|
+
}
|
|
1266
|
+
}, [
|
|
1267
|
+
type
|
|
1268
|
+
]);
|
|
1269
|
+
return /* @__PURE__ */ React10.createElement(Box, {
|
|
1270
|
+
shape,
|
|
1271
|
+
title,
|
|
1272
|
+
status: /* @__PURE__ */ React10.createElement(TypeSelect, {
|
|
1273
|
+
value: type,
|
|
1274
|
+
onValueChange: setType
|
|
1275
|
+
})
|
|
1276
|
+
}, (type === "string" || type === "number") && /* @__PURE__ */ React10.createElement(TextBox2, {
|
|
1277
|
+
...props,
|
|
1278
|
+
ref: inputRef,
|
|
1279
|
+
value: node.value,
|
|
1280
|
+
onEnter: handleEnter
|
|
1281
|
+
}), type === "object" && /* @__PURE__ */ React10.createElement(TextBox2, {
|
|
1282
|
+
...props,
|
|
1283
|
+
ref: inputRef,
|
|
1284
|
+
value: JSON.stringify(node.value, null, 2),
|
|
1285
|
+
language: "json"
|
|
1286
|
+
}), type === "boolean" && /* @__PURE__ */ React10.createElement("div", {
|
|
1287
|
+
className: "flex grow justify-center items-center"
|
|
1288
|
+
}, /* @__PURE__ */ React10.createElement(Input.Root, null, /* @__PURE__ */ React10.createElement(Input.Switch, {
|
|
1289
|
+
checked: node.value,
|
|
1290
|
+
onCheckedChange: (value) => {
|
|
1291
|
+
node.value = value;
|
|
1292
|
+
}
|
|
1293
|
+
}))));
|
|
1345
1294
|
};
|
|
1346
1295
|
var createConstant = (props) => createShape({
|
|
1347
1296
|
type: "constant",
|
|
@@ -1370,7 +1319,6 @@ var constantShape = {
|
|
|
1370
1319
|
};
|
|
1371
1320
|
|
|
1372
1321
|
// src/shapes/Database.tsx
|
|
1373
|
-
import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
|
|
1374
1322
|
import * as Schema10 from "effect/Schema";
|
|
1375
1323
|
import React11 from "react";
|
|
1376
1324
|
import { createAnchorMap as createAnchorMap5 } from "@dxos/react-ui-canvas-editor";
|
|
@@ -1386,14 +1334,9 @@ var createDatabase = (props) => createShape({
|
|
|
1386
1334
|
...props
|
|
1387
1335
|
});
|
|
1388
1336
|
var DatabaseComponent = ({ shape }) => {
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
shape
|
|
1393
|
-
});
|
|
1394
|
-
} finally {
|
|
1395
|
-
_effect.f();
|
|
1396
|
-
}
|
|
1337
|
+
return /* @__PURE__ */ React11.createElement(Box, {
|
|
1338
|
+
shape
|
|
1339
|
+
});
|
|
1397
1340
|
};
|
|
1398
1341
|
var databaseShape = {
|
|
1399
1342
|
type: "database",
|
|
@@ -1410,7 +1353,6 @@ var databaseShape = {
|
|
|
1410
1353
|
};
|
|
1411
1354
|
|
|
1412
1355
|
// src/shapes/Function.tsx
|
|
1413
|
-
import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
|
|
1414
1356
|
import * as Schema11 from "effect/Schema";
|
|
1415
1357
|
import React12, { useCallback as useCallback3, useRef as useRef4 } from "react";
|
|
1416
1358
|
import { AnyOutput, FunctionInput } from "@dxos/conductor";
|
|
@@ -1431,59 +1373,54 @@ var createFunction = (props) => createShape({
|
|
|
1431
1373
|
...props
|
|
1432
1374
|
});
|
|
1433
1375
|
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
|
-
}
|
|
1376
|
+
const client = useClient();
|
|
1377
|
+
const { node, runtime } = useComputeNodeState(shape);
|
|
1378
|
+
const inputRef = useRef4(null);
|
|
1379
|
+
const handleEnter = useCallback3(async (text) => {
|
|
1380
|
+
const value = text.trim();
|
|
1381
|
+
const { spaceId, objectId } = parseId(value);
|
|
1382
|
+
if (!spaceId || !objectId) {
|
|
1383
|
+
return;
|
|
1384
|
+
}
|
|
1385
|
+
const space = client.spaces.get(spaceId);
|
|
1386
|
+
const object = space?.db.getObjectById(objectId);
|
|
1387
|
+
if (!space || !isInstanceOf(Script.Script, object)) {
|
|
1388
|
+
return;
|
|
1389
|
+
}
|
|
1390
|
+
const [fn] = await space.db.query(Filter.type(Function.Function, {
|
|
1391
|
+
source: Ref2.make(object)
|
|
1392
|
+
})).run();
|
|
1393
|
+
if (!fn) {
|
|
1394
|
+
return;
|
|
1395
|
+
}
|
|
1396
|
+
node.value = value;
|
|
1397
|
+
node.function = Ref2.make(fn);
|
|
1398
|
+
node.inputSchema = fn.inputSchema ? getSnapshot(fn.inputSchema) : void 0;
|
|
1399
|
+
node.outputSchema = fn.outputSchema ? getSnapshot(fn.outputSchema) : void 0;
|
|
1400
|
+
}, [
|
|
1401
|
+
client,
|
|
1402
|
+
node
|
|
1403
|
+
]);
|
|
1404
|
+
const handleAction = useCallback3((action) => {
|
|
1405
|
+
if (action !== "run") {
|
|
1406
|
+
return;
|
|
1407
|
+
}
|
|
1408
|
+
runtime.evalNode();
|
|
1409
|
+
}, [
|
|
1410
|
+
runtime
|
|
1411
|
+
]);
|
|
1412
|
+
return /* @__PURE__ */ React12.createElement(Box, {
|
|
1413
|
+
shape,
|
|
1414
|
+
title: "Function",
|
|
1415
|
+
onAction: handleAction
|
|
1416
|
+
}, /* @__PURE__ */ React12.createElement(TextBox3, {
|
|
1417
|
+
...props,
|
|
1418
|
+
ref: inputRef,
|
|
1419
|
+
value: node.value,
|
|
1420
|
+
language: node.valueType === "object" ? "json" : void 0,
|
|
1421
|
+
onBlur: handleEnter,
|
|
1422
|
+
onEnter: handleEnter
|
|
1423
|
+
}));
|
|
1487
1424
|
};
|
|
1488
1425
|
var functionShape = {
|
|
1489
1426
|
type: "function",
|
|
@@ -1495,10 +1432,10 @@ var functionShape = {
|
|
|
1495
1432
|
};
|
|
1496
1433
|
|
|
1497
1434
|
// src/shapes/Gpt.tsx
|
|
1498
|
-
import { useSignals as _useSignals12 } from "@preact-signals/safe-react/tracking";
|
|
1499
1435
|
import * as Schema12 from "effect/Schema";
|
|
1500
1436
|
import React13, { useEffect as useEffect4, useState as useState6 } from "react";
|
|
1501
1437
|
import { GptInput, GptOutput } from "@dxos/conductor";
|
|
1438
|
+
import { ScrollArea } from "@dxos/react-ui";
|
|
1502
1439
|
var GptShape = Schema12.extend(ComputeShape, Schema12.Struct({
|
|
1503
1440
|
type: Schema12.Literal("gpt")
|
|
1504
1441
|
}));
|
|
@@ -1511,54 +1448,50 @@ var createGpt = (props) => createShape({
|
|
|
1511
1448
|
...props
|
|
1512
1449
|
});
|
|
1513
1450
|
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
|
-
}
|
|
1451
|
+
const { meta, runtime } = useComputeNodeState(shape);
|
|
1452
|
+
const [text, setText] = useState6("");
|
|
1453
|
+
const [tokens, setTokens] = useState6(0);
|
|
1454
|
+
useEffect4(() => {
|
|
1455
|
+
return runtime.subscribeToEventLog((ev) => {
|
|
1456
|
+
switch (ev.type) {
|
|
1457
|
+
case "begin-compute": {
|
|
1458
|
+
setText("");
|
|
1459
|
+
break;
|
|
1460
|
+
}
|
|
1461
|
+
case "custom": {
|
|
1462
|
+
const token = ev.event;
|
|
1463
|
+
switch (token.type) {
|
|
1464
|
+
case "content_block_delta":
|
|
1465
|
+
switch (token.delta.type) {
|
|
1466
|
+
case "text_delta": {
|
|
1467
|
+
const delta = token.delta.text;
|
|
1468
|
+
setText((prev) => {
|
|
1469
|
+
const text2 = prev + delta;
|
|
1470
|
+
setTokens(text2.split(" ").length);
|
|
1471
|
+
return text2;
|
|
1472
|
+
});
|
|
1473
|
+
break;
|
|
1540
1474
|
}
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
break;
|
|
1475
|
+
}
|
|
1476
|
+
break;
|
|
1544
1477
|
}
|
|
1478
|
+
break;
|
|
1545
1479
|
}
|
|
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
|
|
1480
|
+
}
|
|
1558
1481
|
});
|
|
1559
|
-
}
|
|
1560
|
-
|
|
1561
|
-
|
|
1482
|
+
}, [
|
|
1483
|
+
runtime?.subscribeToEventLog
|
|
1484
|
+
]);
|
|
1485
|
+
return /* @__PURE__ */ React13.createElement(FunctionBody, {
|
|
1486
|
+
shape,
|
|
1487
|
+
content: /* @__PURE__ */ React13.createElement(ScrollArea.Root, {
|
|
1488
|
+
orientation: "vertical",
|
|
1489
|
+
thin: true
|
|
1490
|
+
}, /* @__PURE__ */ React13.createElement(ScrollArea.Viewport, null, text)),
|
|
1491
|
+
status: `${tokens} tokens`,
|
|
1492
|
+
inputSchema: meta.input,
|
|
1493
|
+
outputSchema: meta.output
|
|
1494
|
+
});
|
|
1562
1495
|
};
|
|
1563
1496
|
var gptShape = {
|
|
1564
1497
|
type: "gpt",
|
|
@@ -1571,7 +1504,6 @@ var gptShape = {
|
|
|
1571
1504
|
};
|
|
1572
1505
|
|
|
1573
1506
|
// src/shapes/Json.tsx
|
|
1574
|
-
import { useSignals as _useSignals13 } from "@preact-signals/safe-react/tracking";
|
|
1575
1507
|
import * as Schema13 from "effect/Schema";
|
|
1576
1508
|
import React14 from "react";
|
|
1577
1509
|
import { DEFAULT_INPUT as DEFAULT_INPUT4, DefaultOutput, JsonTransformInput } from "@dxos/conductor";
|
|
@@ -1584,30 +1516,20 @@ var JsonTransformShape = Schema13.extend(ComputeShape, Schema13.Struct({
|
|
|
1584
1516
|
type: Schema13.Literal("json-transform")
|
|
1585
1517
|
}));
|
|
1586
1518
|
var JsonComponent = ({ shape, ...props }) => {
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
classNames: "text-xs"
|
|
1597
|
-
}));
|
|
1598
|
-
} finally {
|
|
1599
|
-
_effect.f();
|
|
1600
|
-
}
|
|
1519
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1520
|
+
const input = runtime.inputs[DEFAULT_INPUT4];
|
|
1521
|
+
const value = input?.type === "executed" ? input.value : void 0;
|
|
1522
|
+
return /* @__PURE__ */ React14.createElement(Box, {
|
|
1523
|
+
shape
|
|
1524
|
+
}, /* @__PURE__ */ React14.createElement(JsonFilter, {
|
|
1525
|
+
data: value,
|
|
1526
|
+
classNames: "text-xs"
|
|
1527
|
+
}));
|
|
1601
1528
|
};
|
|
1602
1529
|
var JsonTransformComponent = ({ shape, ...props }) => {
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
shape
|
|
1607
|
-
});
|
|
1608
|
-
} finally {
|
|
1609
|
-
_effect.f();
|
|
1610
|
-
}
|
|
1530
|
+
return /* @__PURE__ */ React14.createElement(Box, {
|
|
1531
|
+
shape
|
|
1532
|
+
});
|
|
1611
1533
|
};
|
|
1612
1534
|
var createJson = (props) => createShape({
|
|
1613
1535
|
type: "json",
|
|
@@ -1654,7 +1576,6 @@ var jsonTransformShape = {
|
|
|
1654
1576
|
};
|
|
1655
1577
|
|
|
1656
1578
|
// src/shapes/Logic.tsx
|
|
1657
|
-
import { useSignals as _useSignals14 } from "@preact-signals/safe-react/tracking";
|
|
1658
1579
|
import * as Schema14 from "effect/Schema";
|
|
1659
1580
|
import React15 from "react";
|
|
1660
1581
|
import { IfElseInput, IfElseOutput, IfInput, IfOutput } from "@dxos/conductor";
|
|
@@ -1665,28 +1586,18 @@ var IfElseShape = Schema14.extend(ComputeShape, Schema14.Struct({
|
|
|
1665
1586
|
type: Schema14.Literal("if-else")
|
|
1666
1587
|
}));
|
|
1667
1588
|
var IfComponent = ({ shape, ...props }) => {
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
outputSchema: IfOutput
|
|
1674
|
-
});
|
|
1675
|
-
} finally {
|
|
1676
|
-
_effect.f();
|
|
1677
|
-
}
|
|
1589
|
+
return /* @__PURE__ */ React15.createElement(FunctionBody, {
|
|
1590
|
+
shape,
|
|
1591
|
+
inputSchema: IfInput,
|
|
1592
|
+
outputSchema: IfOutput
|
|
1593
|
+
});
|
|
1678
1594
|
};
|
|
1679
1595
|
var IfElseComponent = ({ shape, ...props }) => {
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
outputSchema: IfElseOutput
|
|
1686
|
-
});
|
|
1687
|
-
} finally {
|
|
1688
|
-
_effect.f();
|
|
1689
|
-
}
|
|
1596
|
+
return /* @__PURE__ */ React15.createElement(FunctionBody, {
|
|
1597
|
+
shape,
|
|
1598
|
+
inputSchema: IfElseInput,
|
|
1599
|
+
outputSchema: IfElseOutput
|
|
1600
|
+
});
|
|
1690
1601
|
};
|
|
1691
1602
|
var createIf = (props) => createShape({
|
|
1692
1603
|
type: "if",
|
|
@@ -1722,11 +1633,11 @@ var ifElseShape = {
|
|
|
1722
1633
|
};
|
|
1723
1634
|
|
|
1724
1635
|
// src/shapes/Queue.tsx
|
|
1725
|
-
import { useSignals as _useSignals15 } from "@preact-signals/safe-react/tracking";
|
|
1726
1636
|
import * as Schema15 from "effect/Schema";
|
|
1727
1637
|
import React16, { Fragment } from "react";
|
|
1728
1638
|
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT4, QueueInput, QueueOutput } from "@dxos/conductor";
|
|
1729
|
-
import {
|
|
1639
|
+
import { ScrollArea as ScrollArea2 } from "@dxos/react-ui";
|
|
1640
|
+
import { mx as mx2 } from "@dxos/ui-theme";
|
|
1730
1641
|
var QueueShape = Schema15.extend(ComputeShape, Schema15.Struct({
|
|
1731
1642
|
type: Schema15.Literal("queue")
|
|
1732
1643
|
}));
|
|
@@ -1739,50 +1650,42 @@ var createQueue = (props) => createShape({
|
|
|
1739
1650
|
...props
|
|
1740
1651
|
});
|
|
1741
1652
|
var QueueComponent = ({ shape }) => {
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
} finally {
|
|
1765
|
-
_effect.f();
|
|
1766
|
-
}
|
|
1653
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1654
|
+
const items = runtime.outputs[DEFAULT_OUTPUT4]?.type === "executed" ? runtime.outputs[DEFAULT_OUTPUT4].value : [];
|
|
1655
|
+
const handleAction = (action) => {
|
|
1656
|
+
if (action === "run") {
|
|
1657
|
+
runtime.evalNode();
|
|
1658
|
+
}
|
|
1659
|
+
};
|
|
1660
|
+
return /* @__PURE__ */ React16.createElement(Box, {
|
|
1661
|
+
shape,
|
|
1662
|
+
status: `${items.length} items`,
|
|
1663
|
+
onAction: handleAction
|
|
1664
|
+
}, /* @__PURE__ */ React16.createElement(ScrollArea2.Root, {
|
|
1665
|
+
orientation: "vertical"
|
|
1666
|
+
}, /* @__PURE__ */ React16.createElement(ScrollArea2.Viewport, {
|
|
1667
|
+
classNames: "divide-y divide-separator"
|
|
1668
|
+
}, [
|
|
1669
|
+
...items
|
|
1670
|
+
].map((item, i) => /* @__PURE__ */ React16.createElement(QueueItem, {
|
|
1671
|
+
key: i,
|
|
1672
|
+
classNames: "p-1 px-2",
|
|
1673
|
+
item
|
|
1674
|
+
})))));
|
|
1767
1675
|
};
|
|
1768
1676
|
var QueueItem = ({ classNames, item }) => {
|
|
1769
|
-
|
|
1770
|
-
try {
|
|
1771
|
-
if (typeof item !== "object") {
|
|
1772
|
-
return /* @__PURE__ */ React16.createElement("div", {
|
|
1773
|
-
className: mx2(classNames, "whitespace-pre-wrap")
|
|
1774
|
-
}, item);
|
|
1775
|
-
}
|
|
1677
|
+
if (typeof item !== "object") {
|
|
1776
1678
|
return /* @__PURE__ */ React16.createElement("div", {
|
|
1777
|
-
className: mx2("
|
|
1778
|
-
},
|
|
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();
|
|
1679
|
+
className: mx2(classNames, "whitespace-pre-wrap")
|
|
1680
|
+
}, item);
|
|
1785
1681
|
}
|
|
1682
|
+
return /* @__PURE__ */ React16.createElement("div", {
|
|
1683
|
+
className: mx2("grid grid-cols-[80px_1fr]", classNames)
|
|
1684
|
+
}, Object.entries(item).map(([key, value]) => /* @__PURE__ */ React16.createElement(Fragment, {
|
|
1685
|
+
key
|
|
1686
|
+
}, /* @__PURE__ */ React16.createElement("div", {
|
|
1687
|
+
className: "p-1 text-xs text-subdued"
|
|
1688
|
+
}, key), /* @__PURE__ */ React16.createElement("div", null, typeof value === "string" ? value : JSON.stringify(value)))));
|
|
1786
1689
|
};
|
|
1787
1690
|
var queueShape = {
|
|
1788
1691
|
type: "queue",
|
|
@@ -1795,7 +1698,6 @@ var queueShape = {
|
|
|
1795
1698
|
};
|
|
1796
1699
|
|
|
1797
1700
|
// src/shapes/RNG.tsx
|
|
1798
|
-
import { useSignals as _useSignals16 } from "@preact-signals/safe-react/tracking";
|
|
1799
1701
|
import * as Schema16 from "effect/Schema";
|
|
1800
1702
|
import React17, { useEffect as useEffect5, useState as useState7 } from "react";
|
|
1801
1703
|
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT5 } from "@dxos/conductor";
|
|
@@ -1824,42 +1726,37 @@ var icons = [
|
|
|
1824
1726
|
];
|
|
1825
1727
|
var pickIcon = () => icons[Math.floor(Math.random() * icons.length)];
|
|
1826
1728
|
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);
|
|
1729
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1730
|
+
const [spin, setSpin] = useState7(false);
|
|
1731
|
+
const [icon, setIcon] = useState7(pickIcon());
|
|
1732
|
+
useEffect5(() => {
|
|
1733
|
+
if (!spin) {
|
|
1734
|
+
return;
|
|
1735
|
+
}
|
|
1736
|
+
const i = setInterval(() => setIcon(pickIcon()), 250);
|
|
1737
|
+
const t1 = setTimeout(() => clearInterval(i), 900);
|
|
1738
|
+
const t2 = setTimeout(() => setSpin(false), 1100);
|
|
1739
|
+
return () => {
|
|
1740
|
+
clearInterval(i);
|
|
1741
|
+
clearTimeout(t1);
|
|
1742
|
+
clearTimeout(t2);
|
|
1851
1743
|
};
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
}
|
|
1744
|
+
}, [
|
|
1745
|
+
spin
|
|
1746
|
+
]);
|
|
1747
|
+
const handleClick = (ev) => {
|
|
1748
|
+
ev.stopPropagation();
|
|
1749
|
+
runtime.setOutput(DEFAULT_OUTPUT5, Math.random());
|
|
1750
|
+
setSpin(true);
|
|
1751
|
+
};
|
|
1752
|
+
return /* @__PURE__ */ React17.createElement("div", {
|
|
1753
|
+
className: "flex grow items-center justify-center"
|
|
1754
|
+
}, /* @__PURE__ */ React17.createElement(Icon4, {
|
|
1755
|
+
icon,
|
|
1756
|
+
classNames: spin && "animate-[spin_1s]",
|
|
1757
|
+
size: 10,
|
|
1758
|
+
onClick: handleClick
|
|
1759
|
+
}));
|
|
1863
1760
|
};
|
|
1864
1761
|
var randomShape = {
|
|
1865
1762
|
type: "rng",
|
|
@@ -1876,7 +1773,6 @@ var randomShape = {
|
|
|
1876
1773
|
};
|
|
1877
1774
|
|
|
1878
1775
|
// src/shapes/Scope.tsx
|
|
1879
|
-
import { useSignals as _useSignals17 } from "@preact-signals/safe-react/tracking";
|
|
1880
1776
|
import * as Schema17 from "effect/Schema";
|
|
1881
1777
|
import React18 from "react";
|
|
1882
1778
|
import { DEFAULT_INPUT as DEFAULT_INPUT5 } from "@dxos/conductor";
|
|
@@ -1895,25 +1791,20 @@ var createScope = (props) => createShape({
|
|
|
1895
1791
|
...props
|
|
1896
1792
|
});
|
|
1897
1793
|
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
|
-
}
|
|
1794
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1795
|
+
const input = runtime.inputs[DEFAULT_INPUT5];
|
|
1796
|
+
const active = input?.type === "executed" ? input.value : false;
|
|
1797
|
+
const { getAverage } = useAudioStream(active);
|
|
1798
|
+
return /* @__PURE__ */ React18.createElement("div", {
|
|
1799
|
+
className: "flex w-full justify-center items-center bg-black"
|
|
1800
|
+
}, /* @__PURE__ */ React18.createElement(Chaos, {
|
|
1801
|
+
active,
|
|
1802
|
+
getValue: getAverage,
|
|
1803
|
+
options: {
|
|
1804
|
+
...shaderPresets.heptapod,
|
|
1805
|
+
zoom: 1.2
|
|
1806
|
+
}
|
|
1807
|
+
}));
|
|
1917
1808
|
};
|
|
1918
1809
|
var scopeShape = {
|
|
1919
1810
|
type: "scope",
|
|
@@ -1930,11 +1821,11 @@ var scopeShape = {
|
|
|
1930
1821
|
};
|
|
1931
1822
|
|
|
1932
1823
|
// src/shapes/Surface.tsx
|
|
1933
|
-
import { useSignals as _useSignals18 } from "@preact-signals/safe-react/tracking";
|
|
1934
1824
|
import * as Schema18 from "effect/Schema";
|
|
1935
1825
|
import React19 from "react";
|
|
1936
|
-
import { Surface } from "@dxos/app-framework/
|
|
1826
|
+
import { Surface } from "@dxos/app-framework/ui";
|
|
1937
1827
|
import { DEFAULT_INPUT as DEFAULT_INPUT6 } from "@dxos/conductor";
|
|
1828
|
+
import { Card } from "@dxos/react-ui";
|
|
1938
1829
|
import { createAnchorMap as createAnchorMap9 } from "@dxos/react-ui-canvas-editor";
|
|
1939
1830
|
var SurfaceShape = Schema18.extend(ComputeShape, Schema18.Struct({
|
|
1940
1831
|
type: Schema18.Literal("surface")
|
|
@@ -1948,29 +1839,24 @@ var createSurface = (props) => createShape({
|
|
|
1948
1839
|
...props
|
|
1949
1840
|
});
|
|
1950
1841
|
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
|
-
}
|
|
1842
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1843
|
+
const input = runtime.inputs[DEFAULT_INPUT6];
|
|
1844
|
+
const value = input?.type === "executed" ? input.value : null;
|
|
1845
|
+
const handleAction = (action) => {
|
|
1846
|
+
if (action === "run") {
|
|
1847
|
+
runtime.evalNode();
|
|
1848
|
+
}
|
|
1849
|
+
};
|
|
1850
|
+
return /* @__PURE__ */ React19.createElement(Box, {
|
|
1851
|
+
shape,
|
|
1852
|
+
onAction: handleAction
|
|
1853
|
+
}, /* @__PURE__ */ React19.createElement(Card.Root, null, value !== null && /* @__PURE__ */ React19.createElement(Surface.Surface, {
|
|
1854
|
+
role: "card--content",
|
|
1855
|
+
data: {
|
|
1856
|
+
value
|
|
1857
|
+
},
|
|
1858
|
+
limit: 1
|
|
1859
|
+
})));
|
|
1974
1860
|
};
|
|
1975
1861
|
var surfaceShape = {
|
|
1976
1862
|
type: "surface",
|
|
@@ -1988,7 +1874,6 @@ var surfaceShape = {
|
|
|
1988
1874
|
};
|
|
1989
1875
|
|
|
1990
1876
|
// src/shapes/Switch.tsx
|
|
1991
|
-
import { useSignals as _useSignals19 } from "@preact-signals/safe-react/tracking";
|
|
1992
1877
|
import * as Schema19 from "effect/Schema";
|
|
1993
1878
|
import React20, { useEffect as useEffect6, useState as useState8 } from "react";
|
|
1994
1879
|
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT6 } from "@dxos/conductor";
|
|
@@ -2006,25 +1891,20 @@ var createSwitch = (props) => createShape({
|
|
|
2006
1891
|
...props
|
|
2007
1892
|
});
|
|
2008
1893
|
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
|
-
}
|
|
1894
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1895
|
+
const [value, setValue] = useState8(false);
|
|
1896
|
+
useEffect6(() => {
|
|
1897
|
+
runtime.setOutput(DEFAULT_OUTPUT6, value);
|
|
1898
|
+
}, [
|
|
1899
|
+
value
|
|
1900
|
+
]);
|
|
1901
|
+
return /* @__PURE__ */ React20.createElement("div", {
|
|
1902
|
+
className: "flex w-full justify-center items-center",
|
|
1903
|
+
onClick: (ev) => ev.stopPropagation()
|
|
1904
|
+
}, /* @__PURE__ */ React20.createElement(Input2.Root, null, /* @__PURE__ */ React20.createElement(Input2.Switch, {
|
|
1905
|
+
checked: value,
|
|
1906
|
+
onCheckedChange: (value2) => setValue(value2)
|
|
1907
|
+
})));
|
|
2028
1908
|
};
|
|
2029
1909
|
var switchShape = {
|
|
2030
1910
|
type: "switch",
|
|
@@ -2041,7 +1921,6 @@ var switchShape = {
|
|
|
2041
1921
|
};
|
|
2042
1922
|
|
|
2043
1923
|
// src/shapes/Table.tsx
|
|
2044
|
-
import { useSignals as _useSignals20 } from "@preact-signals/safe-react/tracking";
|
|
2045
1924
|
import * as Schema20 from "effect/Schema";
|
|
2046
1925
|
import React21 from "react";
|
|
2047
1926
|
import { createInputSchema, createOutputSchema } from "@dxos/conductor";
|
|
@@ -2060,14 +1939,9 @@ var createTable = (props) => createShape({
|
|
|
2060
1939
|
...props
|
|
2061
1940
|
});
|
|
2062
1941
|
var TableComponent = ({ shape }) => {
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
shape
|
|
2067
|
-
});
|
|
2068
|
-
} finally {
|
|
2069
|
-
_effect.f();
|
|
2070
|
-
}
|
|
1942
|
+
return /* @__PURE__ */ React21.createElement(Box, {
|
|
1943
|
+
shape
|
|
1944
|
+
});
|
|
2071
1945
|
};
|
|
2072
1946
|
var tableShape = {
|
|
2073
1947
|
type: "table",
|
|
@@ -2080,11 +1954,10 @@ var tableShape = {
|
|
|
2080
1954
|
};
|
|
2081
1955
|
|
|
2082
1956
|
// src/shapes/Template.tsx
|
|
2083
|
-
import { useSignals as _useSignals21 } from "@preact-signals/safe-react/tracking";
|
|
2084
1957
|
import * as Schema21 from "effect/Schema";
|
|
2085
1958
|
import React22, { useRef as useRef5 } from "react";
|
|
2086
1959
|
import { ComputeValueType as ComputeValueType3, TemplateOutput, VoidInput as VoidInput2, getTemplateInputSchema as getTemplateInputSchema2 } from "@dxos/conductor";
|
|
2087
|
-
import { toJsonSchema
|
|
1960
|
+
import { toJsonSchema } from "@dxos/echo/internal";
|
|
2088
1961
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
2089
1962
|
import { TextBox as TextBox4 } from "@dxos/react-ui-canvas-editor";
|
|
2090
1963
|
var __dxlog_file6 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/Template.tsx";
|
|
@@ -2093,49 +1966,44 @@ var TemplateShape = Schema21.extend(ComputeShape, Schema21.Struct({
|
|
|
2093
1966
|
valueType: Schema21.optional(ComputeValueType3)
|
|
2094
1967
|
}));
|
|
2095
1968
|
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
|
-
}
|
|
1969
|
+
const { node } = useComputeNodeState(shape);
|
|
1970
|
+
const inputRef = useRef5(null);
|
|
1971
|
+
const handleEnter = (text) => {
|
|
1972
|
+
const value = text.trim();
|
|
1973
|
+
if (value.length) {
|
|
1974
|
+
const schema = getTemplateInputSchema2(node);
|
|
1975
|
+
node.value = value;
|
|
1976
|
+
node.inputSchema = toJsonSchema(schema);
|
|
1977
|
+
}
|
|
1978
|
+
};
|
|
1979
|
+
const handleTypeChange = (newType) => {
|
|
1980
|
+
invariant5(Schema21.is(ComputeValueType3)(newType), "Invalid type", {
|
|
1981
|
+
F: __dxlog_file6,
|
|
1982
|
+
L: 59,
|
|
1983
|
+
S: void 0,
|
|
1984
|
+
A: [
|
|
1985
|
+
"Schema.is(ComputeValueType)(newType)",
|
|
1986
|
+
"'Invalid type'"
|
|
1987
|
+
]
|
|
1988
|
+
});
|
|
1989
|
+
node.valueType = newType;
|
|
1990
|
+
node.inputSchema = toJsonSchema(getTemplateInputSchema2(node));
|
|
1991
|
+
};
|
|
1992
|
+
return /* @__PURE__ */ React22.createElement(Box, {
|
|
1993
|
+
shape,
|
|
1994
|
+
title: "Template",
|
|
1995
|
+
status: /* @__PURE__ */ React22.createElement(TypeSelect, {
|
|
1996
|
+
value: node.valueType ?? "string",
|
|
1997
|
+
onValueChange: handleTypeChange
|
|
1998
|
+
})
|
|
1999
|
+
}, /* @__PURE__ */ React22.createElement(TextBox4, {
|
|
2000
|
+
...props,
|
|
2001
|
+
ref: inputRef,
|
|
2002
|
+
value: node.value,
|
|
2003
|
+
language: node.valueType === "object" ? "json" : void 0,
|
|
2004
|
+
onBlur: handleEnter,
|
|
2005
|
+
onEnter: handleEnter
|
|
2006
|
+
}));
|
|
2139
2007
|
};
|
|
2140
2008
|
var createTemplate = (props) => createShape({
|
|
2141
2009
|
type: "template",
|
|
@@ -2159,7 +2027,6 @@ var templateShape = {
|
|
|
2159
2027
|
};
|
|
2160
2028
|
|
|
2161
2029
|
// src/shapes/Text.tsx
|
|
2162
|
-
import { useSignals as _useSignals22 } from "@preact-signals/safe-react/tracking";
|
|
2163
2030
|
import * as Schema22 from "effect/Schema";
|
|
2164
2031
|
import React23 from "react";
|
|
2165
2032
|
import { DEFAULT_INPUT as DEFAULT_INPUT7 } from "@dxos/conductor";
|
|
@@ -2177,25 +2044,20 @@ var createText = (props) => createShape({
|
|
|
2177
2044
|
...props
|
|
2178
2045
|
});
|
|
2179
2046
|
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
|
-
}
|
|
2047
|
+
const { runtime } = useComputeNodeState(shape);
|
|
2048
|
+
const input = runtime.inputs[DEFAULT_INPUT7];
|
|
2049
|
+
const value = input?.type === "executed" ? input.value : 0;
|
|
2050
|
+
const handleAction = (action) => {
|
|
2051
|
+
if (action === "run") {
|
|
2052
|
+
runtime.evalNode();
|
|
2053
|
+
}
|
|
2054
|
+
};
|
|
2055
|
+
return /* @__PURE__ */ React23.createElement(Box, {
|
|
2056
|
+
shape,
|
|
2057
|
+
onAction: handleAction
|
|
2058
|
+
}, /* @__PURE__ */ React23.createElement(TextBox5, {
|
|
2059
|
+
value
|
|
2060
|
+
}));
|
|
2199
2061
|
};
|
|
2200
2062
|
var textShape = {
|
|
2201
2063
|
type: "text",
|
|
@@ -2213,12 +2075,12 @@ var textShape = {
|
|
|
2213
2075
|
};
|
|
2214
2076
|
|
|
2215
2077
|
// src/shapes/Thread.tsx
|
|
2216
|
-
import { useSignals as _useSignals23 } from "@preact-signals/safe-react/tracking";
|
|
2217
2078
|
import * as Schema23 from "effect/Schema";
|
|
2218
2079
|
import React24, { useEffect as useEffect7, useRef as useRef6 } from "react";
|
|
2219
2080
|
import { createInputSchema as createInputSchema2, createOutputSchema as createOutputSchema2 } from "@dxos/conductor";
|
|
2220
|
-
import {
|
|
2081
|
+
import { ScrollArea as ScrollArea3 } from "@dxos/react-ui";
|
|
2221
2082
|
import { Message as Message2 } from "@dxos/types";
|
|
2083
|
+
import { mx as mx3 } from "@dxos/ui-theme";
|
|
2222
2084
|
var InputSchema2 = createInputSchema2(Message2.Message);
|
|
2223
2085
|
var OutputSchema2 = createOutputSchema2(Schema23.mutable(Schema23.Array(Message2.Message)));
|
|
2224
2086
|
var ThreadShape = Schema23.extend(ComputeShape, Schema23.Struct({
|
|
@@ -2233,49 +2095,42 @@ var createThread = (props) => createShape({
|
|
|
2233
2095
|
...props
|
|
2234
2096
|
});
|
|
2235
2097
|
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
|
-
}
|
|
2098
|
+
const items = [];
|
|
2099
|
+
const scrollRef = useRef6(null);
|
|
2100
|
+
useEffect7(() => {
|
|
2101
|
+
if (scrollRef.current) {
|
|
2102
|
+
scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
|
|
2103
|
+
}
|
|
2104
|
+
}, [
|
|
2105
|
+
items
|
|
2106
|
+
]);
|
|
2107
|
+
return /* @__PURE__ */ React24.createElement(Box, {
|
|
2108
|
+
shape
|
|
2109
|
+
}, /* @__PURE__ */ React24.createElement(ScrollArea3.Root, {
|
|
2110
|
+
orientation: "vertical"
|
|
2111
|
+
}, /* @__PURE__ */ React24.createElement(ScrollArea3.Viewport, {
|
|
2112
|
+
classNames: "gap-2 p-2",
|
|
2113
|
+
ref: scrollRef
|
|
2114
|
+
}, [
|
|
2115
|
+
...items
|
|
2116
|
+
].map((item, i) => /* @__PURE__ */ React24.createElement(ThreadItem, {
|
|
2117
|
+
key: i,
|
|
2118
|
+
item
|
|
2119
|
+
})))));
|
|
2261
2120
|
};
|
|
2262
2121
|
var ThreadItem = ({ classNames, item }) => {
|
|
2263
|
-
|
|
2264
|
-
try {
|
|
2265
|
-
if (typeof item !== "object") {
|
|
2266
|
-
return /* @__PURE__ */ React24.createElement("div", {
|
|
2267
|
-
className: mx3(classNames)
|
|
2268
|
-
}, item);
|
|
2269
|
-
}
|
|
2270
|
-
const { role, message } = item;
|
|
2122
|
+
if (typeof item !== "object") {
|
|
2271
2123
|
return /* @__PURE__ */ React24.createElement("div", {
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
}, message));
|
|
2276
|
-
} finally {
|
|
2277
|
-
_effect.f();
|
|
2124
|
+
role: "none",
|
|
2125
|
+
className: mx3(classNames)
|
|
2126
|
+
}, item);
|
|
2278
2127
|
}
|
|
2128
|
+
const { role, message } = item;
|
|
2129
|
+
return /* @__PURE__ */ React24.createElement("div", {
|
|
2130
|
+
className: mx3("flex", classNames, role === "user" && "justify-end")
|
|
2131
|
+
}, /* @__PURE__ */ React24.createElement("div", {
|
|
2132
|
+
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")
|
|
2133
|
+
}, message));
|
|
2279
2134
|
};
|
|
2280
2135
|
var threadShape = {
|
|
2281
2136
|
type: "thread",
|
|
@@ -2288,7 +2143,6 @@ var threadShape = {
|
|
|
2288
2143
|
};
|
|
2289
2144
|
|
|
2290
2145
|
// src/shapes/TextToImage.tsx
|
|
2291
|
-
import { useSignals as _useSignals24 } from "@preact-signals/safe-react/tracking";
|
|
2292
2146
|
import * as Schema24 from "effect/Schema";
|
|
2293
2147
|
import React25 from "react";
|
|
2294
2148
|
import { createAnchorMap as createAnchorMap12 } from "@dxos/react-ui-canvas-editor";
|
|
@@ -2304,14 +2158,9 @@ var createTextToImage = (props) => createShape({
|
|
|
2304
2158
|
...props
|
|
2305
2159
|
});
|
|
2306
2160
|
var TextToImageComponent = ({ shape }) => {
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
shape
|
|
2311
|
-
});
|
|
2312
|
-
} finally {
|
|
2313
|
-
_effect.f();
|
|
2314
|
-
}
|
|
2161
|
+
return /* @__PURE__ */ React25.createElement(Box, {
|
|
2162
|
+
shape
|
|
2163
|
+
});
|
|
2315
2164
|
};
|
|
2316
2165
|
var textToImageShape = {
|
|
2317
2166
|
type: "text-to-image",
|
|
@@ -2328,19 +2177,17 @@ var textToImageShape = {
|
|
|
2328
2177
|
};
|
|
2329
2178
|
|
|
2330
2179
|
// src/shapes/Trigger.tsx
|
|
2331
|
-
import { useSignals as _useSignals25 } from "@preact-signals/safe-react/tracking";
|
|
2332
2180
|
import * as Schema25 from "effect/Schema";
|
|
2333
2181
|
import React26, { useEffect as useEffect8 } from "react";
|
|
2334
2182
|
import { VoidInput as VoidInput3 } from "@dxos/conductor";
|
|
2335
|
-
import { Filter as Filter2, Query } from "@dxos/echo";
|
|
2336
|
-
import { ObjectId as ObjectId4, Ref as Ref3 } from "@dxos/echo/internal";
|
|
2183
|
+
import { Filter as Filter2, Obj as Obj4, Query, Ref as Ref3 } from "@dxos/echo";
|
|
2337
2184
|
import { Trigger, TriggerEvent } from "@dxos/functions";
|
|
2338
2185
|
import { DXN, SpaceId } from "@dxos/keys";
|
|
2339
2186
|
import { useSpace } from "@dxos/react-client/echo";
|
|
2340
2187
|
import { Select as Select2 } from "@dxos/react-ui";
|
|
2341
2188
|
var TriggerShape = Schema25.extend(ComputeShape, Schema25.Struct({
|
|
2342
2189
|
type: Schema25.Literal("trigger"),
|
|
2343
|
-
functionTrigger: Schema25.optional(Ref3(Trigger.Trigger))
|
|
2190
|
+
functionTrigger: Schema25.optional(Ref3.Ref(Trigger.Trigger))
|
|
2344
2191
|
}));
|
|
2345
2192
|
var createTrigger = (props) => {
|
|
2346
2193
|
const functionTrigger = Trigger.make({
|
|
@@ -2358,66 +2205,60 @@ var createTrigger = (props) => {
|
|
|
2358
2205
|
});
|
|
2359
2206
|
};
|
|
2360
2207
|
var TriggerComponent = ({ shape }) => {
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
functionTrigger.spec = createTriggerSpec({
|
|
2208
|
+
const space = useSpace();
|
|
2209
|
+
const functionTrigger = shape.functionTrigger?.target;
|
|
2210
|
+
useEffect8(() => {
|
|
2211
|
+
if (functionTrigger && !functionTrigger.spec) {
|
|
2212
|
+
Obj4.change(functionTrigger, (t) => {
|
|
2213
|
+
t.spec = createTriggerSpec({
|
|
2368
2214
|
triggerKind: "email",
|
|
2369
2215
|
spaceId: space?.id
|
|
2370
2216
|
});
|
|
2371
|
-
}
|
|
2372
|
-
}
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2217
|
+
});
|
|
2218
|
+
}
|
|
2219
|
+
}, [
|
|
2220
|
+
functionTrigger,
|
|
2221
|
+
functionTrigger?.spec
|
|
2222
|
+
]);
|
|
2223
|
+
useEffect8(() => {
|
|
2224
|
+
shape.size.height = getHeight(getOutputSchema(functionTrigger?.spec?.kind ?? "email"));
|
|
2225
|
+
}, [
|
|
2226
|
+
functionTrigger?.spec?.kind
|
|
2227
|
+
]);
|
|
2228
|
+
const setKind = (kind) => {
|
|
2229
|
+
if (functionTrigger?.spec?.kind !== kind) {
|
|
2230
|
+
Obj4.change(functionTrigger, (t) => {
|
|
2231
|
+
t.spec = createTriggerSpec({
|
|
2384
2232
|
triggerKind: kind,
|
|
2385
2233
|
spaceId: space?.id
|
|
2386
2234
|
});
|
|
2387
|
-
}
|
|
2388
|
-
};
|
|
2389
|
-
if (!functionTrigger?.spec) {
|
|
2390
|
-
return;
|
|
2235
|
+
});
|
|
2391
2236
|
}
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
value: functionTrigger.spec?.kind,
|
|
2396
|
-
onValueChange: (kind) => setKind(kind)
|
|
2397
|
-
}),
|
|
2398
|
-
inputSchema: VoidInput3,
|
|
2399
|
-
outputSchema: getOutputSchema(functionTrigger.spec.kind)
|
|
2400
|
-
});
|
|
2401
|
-
} finally {
|
|
2402
|
-
_effect.f();
|
|
2237
|
+
};
|
|
2238
|
+
if (!functionTrigger?.spec) {
|
|
2239
|
+
return;
|
|
2403
2240
|
}
|
|
2241
|
+
return /* @__PURE__ */ React26.createElement(FunctionBody, {
|
|
2242
|
+
shape,
|
|
2243
|
+
status: /* @__PURE__ */ React26.createElement(TriggerKindSelect, {
|
|
2244
|
+
value: functionTrigger.spec?.kind,
|
|
2245
|
+
onValueChange: (kind) => setKind(kind)
|
|
2246
|
+
}),
|
|
2247
|
+
inputSchema: VoidInput3,
|
|
2248
|
+
outputSchema: getOutputSchema(functionTrigger.spec.kind)
|
|
2249
|
+
});
|
|
2404
2250
|
};
|
|
2405
2251
|
var TriggerKindSelect = ({ value, onValueChange }) => {
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
value: kind
|
|
2417
|
-
}, kind))), /* @__PURE__ */ React26.createElement(Select2.ScrollDownButton, null), /* @__PURE__ */ React26.createElement(Select2.Arrow, null))));
|
|
2418
|
-
} finally {
|
|
2419
|
-
_effect.f();
|
|
2420
|
-
}
|
|
2252
|
+
return /* @__PURE__ */ React26.createElement(Select2.Root, {
|
|
2253
|
+
value,
|
|
2254
|
+
onValueChange
|
|
2255
|
+
}, /* @__PURE__ */ React26.createElement(Select2.TriggerButton, {
|
|
2256
|
+
variant: "ghost",
|
|
2257
|
+
classNames: "w-full px-0!"
|
|
2258
|
+
}), /* @__PURE__ */ React26.createElement(Select2.Portal, null, /* @__PURE__ */ React26.createElement(Select2.Content, null, /* @__PURE__ */ React26.createElement(Select2.ScrollUpButton, null), /* @__PURE__ */ React26.createElement(Select2.Viewport, null, Trigger.Kinds.map((kind) => /* @__PURE__ */ React26.createElement(Select2.Option, {
|
|
2259
|
+
key: kind,
|
|
2260
|
+
value: kind
|
|
2261
|
+
}, kind))), /* @__PURE__ */ React26.createElement(Select2.ScrollDownButton, null), /* @__PURE__ */ React26.createElement(Select2.Arrow, null))));
|
|
2421
2262
|
};
|
|
2422
2263
|
var createTriggerSpec = (props) => {
|
|
2423
2264
|
const kind = props.triggerKind ?? "email";
|
|
@@ -2447,7 +2288,7 @@ var createTriggerSpec = (props) => {
|
|
|
2447
2288
|
const dxn = new DXN(DXN.kind.QUEUE, [
|
|
2448
2289
|
"data",
|
|
2449
2290
|
props.spaceId ?? SpaceId.random(),
|
|
2450
|
-
|
|
2291
|
+
Obj4.ID.random()
|
|
2451
2292
|
]).toString();
|
|
2452
2293
|
return {
|
|
2453
2294
|
kind: "queue",
|
|
@@ -2476,7 +2317,6 @@ var triggerShape = {
|
|
|
2476
2317
|
};
|
|
2477
2318
|
|
|
2478
2319
|
// src/shapes/GptRealtime.tsx
|
|
2479
|
-
import { useSignals as _useSignals26 } from "@preact-signals/safe-react/tracking";
|
|
2480
2320
|
import * as Schema26 from "effect/Schema";
|
|
2481
2321
|
import React27, { useState as useState9 } from "react";
|
|
2482
2322
|
import { log as log2 } from "@dxos/log";
|
|
@@ -2495,105 +2335,100 @@ var createGptRealtime = (props) => createShape({
|
|
|
2495
2335
|
...props
|
|
2496
2336
|
});
|
|
2497
2337
|
var GptRealtimeComponent = ({ shape }) => {
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
const
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2338
|
+
const [isLive, setIsLive] = useState9(false);
|
|
2339
|
+
const [isReady, setIsReady] = useState9(false);
|
|
2340
|
+
const config = useConfig();
|
|
2341
|
+
const start = async () => {
|
|
2342
|
+
setIsLive(true);
|
|
2343
|
+
try {
|
|
2344
|
+
const peerConnection = new RTCPeerConnection();
|
|
2345
|
+
peerConnection.ontrack = (event) => {
|
|
2346
|
+
const audioElement = document.createElement("audio");
|
|
2347
|
+
audioElement.srcObject = event.streams[0];
|
|
2348
|
+
audioElement.autoplay = true;
|
|
2349
|
+
audioElement.controls = false;
|
|
2350
|
+
audioElement.style.display = "none";
|
|
2351
|
+
document.body.appendChild(audioElement);
|
|
2352
|
+
setIsReady(true);
|
|
2353
|
+
};
|
|
2354
|
+
const stream = await navigator.mediaDevices.getUserMedia({
|
|
2355
|
+
audio: true
|
|
2356
|
+
});
|
|
2357
|
+
stream.getTracks().forEach((track) => peerConnection.addTransceiver(track, {
|
|
2358
|
+
direction: "sendrecv"
|
|
2359
|
+
}));
|
|
2360
|
+
const offer = await peerConnection.createOffer();
|
|
2361
|
+
await peerConnection.setLocalDescription(offer);
|
|
2362
|
+
const AiServiceUrl = new URL("/rtc-connect", config.values.runtime?.services?.ai?.server ?? DEFAULT_AI_SERVICE_URL);
|
|
2363
|
+
const response = await fetch(AiServiceUrl, {
|
|
2364
|
+
method: "POST",
|
|
2365
|
+
body: offer.sdp,
|
|
2366
|
+
headers: {
|
|
2367
|
+
"Content-Type": "application/sdp"
|
|
2368
|
+
}
|
|
2369
|
+
});
|
|
2370
|
+
const answer = await response.text();
|
|
2371
|
+
await peerConnection.setRemoteDescription({
|
|
2372
|
+
sdp: answer,
|
|
2373
|
+
type: "answer"
|
|
2374
|
+
});
|
|
2375
|
+
const dataChannel = peerConnection.createDataChannel("response");
|
|
2376
|
+
const configureData = () => {
|
|
2377
|
+
log2.info("Configuring data channel", void 0, {
|
|
2378
|
+
F: __dxlog_file7,
|
|
2379
|
+
L: 87,
|
|
2380
|
+
S: void 0,
|
|
2381
|
+
C: (f, a) => f(...a)
|
|
2518
2382
|
});
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
headers: {
|
|
2529
|
-
"Content-Type": "application/sdp"
|
|
2383
|
+
const event = {
|
|
2384
|
+
type: "session.update",
|
|
2385
|
+
session: {
|
|
2386
|
+
modalities: [
|
|
2387
|
+
"text",
|
|
2388
|
+
"audio"
|
|
2389
|
+
],
|
|
2390
|
+
// Provide the tools. Note they match the keys in the `fns` object above
|
|
2391
|
+
tools: []
|
|
2530
2392
|
}
|
|
2531
|
-
});
|
|
2532
|
-
const answer = await response.text();
|
|
2533
|
-
await peerConnection.setRemoteDescription({
|
|
2534
|
-
sdp: answer,
|
|
2535
|
-
type: "answer"
|
|
2536
|
-
});
|
|
2537
|
-
const dataChannel = peerConnection.createDataChannel("response");
|
|
2538
|
-
const configureData = () => {
|
|
2539
|
-
log2.info("Configuring data channel", void 0, {
|
|
2540
|
-
F: __dxlog_file7,
|
|
2541
|
-
L: 87,
|
|
2542
|
-
S: void 0,
|
|
2543
|
-
C: (f, a) => f(...a)
|
|
2544
|
-
});
|
|
2545
|
-
const event = {
|
|
2546
|
-
type: "session.update",
|
|
2547
|
-
session: {
|
|
2548
|
-
modalities: [
|
|
2549
|
-
"text",
|
|
2550
|
-
"audio"
|
|
2551
|
-
],
|
|
2552
|
-
// Provide the tools. Note they match the keys in the `fns` object above
|
|
2553
|
-
tools: []
|
|
2554
|
-
}
|
|
2555
|
-
};
|
|
2556
|
-
dataChannel.send(JSON.stringify(event));
|
|
2557
2393
|
};
|
|
2558
|
-
dataChannel.
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
L: 100,
|
|
2564
|
-
S: void 0,
|
|
2565
|
-
C: (f, a) => f(...a)
|
|
2566
|
-
});
|
|
2567
|
-
configureData();
|
|
2568
|
-
});
|
|
2569
|
-
dataChannel.addEventListener("message", async (ev) => {
|
|
2570
|
-
const msg = JSON.parse(ev.data);
|
|
2571
|
-
if (msg.type === "response.function_call_arguments.done") {
|
|
2572
|
-
}
|
|
2573
|
-
});
|
|
2574
|
-
} catch (error) {
|
|
2575
|
-
log2.error("Error in realtime session:", {
|
|
2576
|
-
error
|
|
2394
|
+
dataChannel.send(JSON.stringify(event));
|
|
2395
|
+
};
|
|
2396
|
+
dataChannel.addEventListener("open", (ev) => {
|
|
2397
|
+
log2.info("Opening data channel", {
|
|
2398
|
+
ev
|
|
2577
2399
|
}, {
|
|
2578
2400
|
F: __dxlog_file7,
|
|
2579
|
-
L:
|
|
2401
|
+
L: 100,
|
|
2580
2402
|
S: void 0,
|
|
2581
2403
|
C: (f, a) => f(...a)
|
|
2582
2404
|
});
|
|
2583
|
-
|
|
2584
|
-
}
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2405
|
+
configureData();
|
|
2406
|
+
});
|
|
2407
|
+
dataChannel.addEventListener("message", async (ev) => {
|
|
2408
|
+
const msg = JSON.parse(ev.data);
|
|
2409
|
+
if (msg.type === "response.function_call_arguments.done") {
|
|
2410
|
+
}
|
|
2411
|
+
});
|
|
2412
|
+
} catch (error) {
|
|
2413
|
+
log2.error("Error in realtime session:", {
|
|
2414
|
+
error
|
|
2415
|
+
}, {
|
|
2416
|
+
F: __dxlog_file7,
|
|
2417
|
+
L: 140,
|
|
2418
|
+
S: void 0,
|
|
2419
|
+
C: (f, a) => f(...a)
|
|
2420
|
+
});
|
|
2421
|
+
throw error;
|
|
2422
|
+
}
|
|
2423
|
+
};
|
|
2424
|
+
return /* @__PURE__ */ React27.createElement("div", {
|
|
2425
|
+
className: "flex w-full justify-center items-center"
|
|
2426
|
+
}, /* @__PURE__ */ React27.createElement(Icon5, {
|
|
2427
|
+
icon: isReady ? "ph--waveform--regular" : isLive ? "ph--pulse--regular" : "ph--play--regular",
|
|
2428
|
+
size: 16,
|
|
2429
|
+
classNames: !isLive && "cursor-pointer",
|
|
2430
|
+
onClick: start
|
|
2431
|
+
}));
|
|
2597
2432
|
};
|
|
2598
2433
|
var gptRealtimeShape = {
|
|
2599
2434
|
type: "gpt-realtime",
|