@dxos/react-ui-canvas-compute 0.8.4-main.7ace549 → 0.8.4-main.9735255

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.
@@ -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
@@ -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: 26,
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: 27,
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: 52,
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: 115,
251
+ L: 114,
250
252
  S: void 0,
251
253
  A: [
252
254
  "functionTrigger",
253
255
  ""
254
256
  ]
255
257
  });
256
- functionTrigger.function = Ref.make(graph.root);
257
- functionTrigger.inputNodeId = computeNode.id;
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 space = getSpace(computeGraph.root);
261
- if (!space) {
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
- space.db.remove(trigger.functionTrigger.target);
271
+ db.remove(trigger.functionTrigger.target);
268
272
  }
269
273
  }
270
274
  };
@@ -359,16 +363,16 @@ var AUTO_TRIGGER_NODES = [
359
363
  "switch",
360
364
  "constant"
361
365
  ];
362
- var createComputeGraphController = (graph, serviceContainer) => {
366
+ var createComputeGraphController = (graph, computeRuntime) => {
363
367
  const computeGraph = createComputeGraph(graph);
364
- const controller = new ComputeGraphController(serviceContainer, computeGraph);
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
- _serviceContainer;
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(_serviceContainer, _graph) {
392
- super(), this._serviceContainer = _serviceContainer, this._graph = _graph;
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: 210,
466
+ L: 229,
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
- const serviceLayer = this._serviceContainer.createLayer();
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.flatMap(computeValueBag), Effect.provide(serviceLayer), Effect.withSpan("test"), Effect.tap((values) => {
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 Effect.runPromise(Effect.gen(this, function* () {
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(this._serviceContainer.createLayer()), Effect.withSpan("test"), Effect.tap((values) => {
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: 346,
559
+ L: 376,
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/react-ui-theme";
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
- var _effect = _useSignals();
644
- try {
645
- invariant4(shape.type, void 0, {
646
- F: __dxlog_file5,
647
- L: 30,
648
- S: void 0,
649
- A: [
650
- "shape.type",
651
- ""
652
- ]
653
- });
654
- const { icon, name, openable } = useShapeDef(shape.type) ?? {
655
- icon: "ph--placeholder--regular"
656
- };
657
- const { debug } = useEditorContext();
658
- return /* @__PURE__ */ React.createElement("div", {
659
- ref: forwardedRef,
660
- className: "flex flex-col bs-full is-full justify-between"
661
- }, /* @__PURE__ */ React.createElement("div", {
662
- className: "flex shrink-0 is-full justify-between items-center bs-[32px] bg-hoverSurface"
663
- }, /* @__PURE__ */ React.createElement(Icon, {
664
- icon,
665
- classNames: "mx-2"
666
- }), /* @__PURE__ */ React.createElement("div", {
667
- className: "grow text-sm truncate"
668
- }, debug ? shape.type : name ?? shape.text ?? title), /* @__PURE__ */ React.createElement(IconButton, {
669
- classNames: "p-1 text-green-500",
670
- variant: "ghost",
671
- icon: "ph--play--regular",
672
- size: 4,
673
- label: "run",
674
- iconOnly: true,
675
- onDoubleClick: (ev) => ev.stopPropagation(),
676
- onClick: (ev) => {
677
- ev.stopPropagation();
678
- onAction?.("run");
679
- }
680
- })), /* @__PURE__ */ React.createElement("div", {
681
- className: mx("flex flex-col bs-full grow overflow-hidden", classNames)
682
- }, children), /* @__PURE__ */ React.createElement("div", {
683
- className: "flex shrink-0 is-full justify-between items-center bs-[32px] bg-hoverSurface"
684
- }, /* @__PURE__ */ React.createElement("div", {
685
- className: "grow pli-2 text-sm truncate"
686
- }, debug ? shape.id : status), openable && /* @__PURE__ */ React.createElement(IconButton, {
687
- classNames: "p-1",
688
- variant: "ghost",
689
- icon: open ? "ph--caret-up--regular" : "ph--caret-down--regular",
690
- size: 4,
691
- label: open ? "close" : "open",
692
- iconOnly: true,
693
- onClick: (ev) => {
694
- ev.stopPropagation();
695
- onAction?.(open ? "close" : "open");
696
- }
697
- })));
698
- } finally {
699
- _effect.f();
700
- }
645
+ invariant4(shape.type, void 0, {
646
+ F: __dxlog_file5,
647
+ L: 30,
648
+ S: void 0,
649
+ A: [
650
+ "shape.type",
651
+ ""
652
+ ]
653
+ });
654
+ const { icon, name, openable } = useShapeDef(shape.type) ?? {
655
+ icon: "ph--placeholder--regular"
656
+ };
657
+ const { debug } = useEditorContext();
658
+ return /* @__PURE__ */ React.createElement("div", {
659
+ ref: forwardedRef,
660
+ className: "flex flex-col bs-full is-full justify-between"
661
+ }, /* @__PURE__ */ React.createElement("div", {
662
+ className: "flex shrink-0 is-full justify-between items-center bs-[32px] bg-hoverSurface"
663
+ }, /* @__PURE__ */ React.createElement(Icon, {
664
+ icon,
665
+ classNames: "mx-2"
666
+ }), /* @__PURE__ */ React.createElement("div", {
667
+ className: "grow text-sm truncate"
668
+ }, debug ? shape.type : name ?? shape.text ?? title), /* @__PURE__ */ React.createElement(IconButton, {
669
+ classNames: "p-1 text-green-500",
670
+ variant: "ghost",
671
+ icon: "ph--play--regular",
672
+ size: 4,
673
+ label: "run",
674
+ iconOnly: true,
675
+ onDoubleClick: (ev) => ev.stopPropagation(),
676
+ onClick: (ev) => {
677
+ ev.stopPropagation();
678
+ onAction?.("run");
679
+ }
680
+ })), /* @__PURE__ */ React.createElement("div", {
681
+ className: mx("flex flex-col bs-full grow overflow-hidden", classNames)
682
+ }, children), /* @__PURE__ */ React.createElement("div", {
683
+ className: "flex shrink-0 is-full justify-between items-center bs-[32px] bg-hoverSurface"
684
+ }, /* @__PURE__ */ React.createElement("div", {
685
+ className: "grow pli-2 text-sm truncate"
686
+ }, debug ? shape.id : status), openable && /* @__PURE__ */ React.createElement(IconButton, {
687
+ classNames: "p-1",
688
+ variant: "ghost",
689
+ icon: open ? "ph--caret-up--regular" : "ph--caret-down--regular",
690
+ size: 4,
691
+ label: open ? "close" : "open",
692
+ iconOnly: true,
693
+ onClick: (ev) => {
694
+ ev.stopPropagation();
695
+ onAction?.(open ? "close" : "open");
696
+ }
697
+ })));
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";
@@ -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
- var _effect = _useSignals2();
749
- try {
750
- const { scale } = useCanvasContext();
751
- const rootRef = useRef(null);
752
- const [open, setOpen] = useState3(false);
753
- const handleAction = (action) => {
754
- if (!rootRef.current) {
755
- return;
756
- }
757
- switch (action) {
758
- case "open": {
759
- const el = getParentShapeElement(rootRef.current, shape.id);
760
- const { height } = el.getBoundingClientRect();
761
- el.style.height = `${height / scale + expandedHeight}px`;
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
- }, name2))), (outputs?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement("div", {
799
- className: "flex flex-col"
800
- }, outputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
801
- key: name2,
802
- className: "pli-2 truncate text-sm font-mono items-center text-right",
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
- }, name2)))), open && /* @__PURE__ */ React2.createElement("div", {
807
- className: "flex flex-col grow overflow-hidden"
808
- }, content));
809
- } finally {
810
- _effect.f();
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: "pli-2 truncate text-sm font-mono items-center",
789
+ style: {
790
+ height: rowHeight
791
+ }
792
+ }, name2))), (outputs?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement("div", {
793
+ className: "flex flex-col"
794
+ }, outputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
795
+ key: name2,
796
+ className: "pli-2 truncate text-sm font-mono items-center text-right",
797
+ style: {
798
+ height: rowHeight
799
+ }
800
+ }, name2)))), open && /* @__PURE__ */ React2.createElement("div", {
801
+ className: "flex flex-col grow overflow-hidden"
802
+ }, content));
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
- var _effect = _useSignals3();
838
- try {
839
- return /* @__PURE__ */ React3.createElement(Select.Root, {
840
- value,
841
- onValueChange
842
- }, /* @__PURE__ */ React3.createElement(Select.TriggerButton, {
843
- variant: "ghost",
844
- classNames: "is-full !pli-0"
845
- }), /* @__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, {
846
- key: type,
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: "is-full !pli-0"
833
+ }), /* @__PURE__ */ React3.createElement(Select.Portal, null, /* @__PURE__ */ React3.createElement(Select.Content, null, /* @__PURE__ */ React3.createElement(Select.ScrollUpButton, null), /* @__PURE__ */ React3.createElement(Select.Viewport, null, ComputeValueType.literals.map((type) => /* @__PURE__ */ React3.createElement(Select.Option, {
834
+ key: type,
835
+ value: type
836
+ }, type))), /* @__PURE__ */ React3.createElement(Select.ScrollDownButton, null), /* @__PURE__ */ React3.createElement(Select.Arrow, null))));
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
- var _effect = _useSignals4();
864
- try {
865
- return /* @__PURE__ */ React4.createElement(FunctionBody, {
866
- shape,
867
- inputSchema: ReducerInput,
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
- var _effect = _useSignals5();
909
- try {
910
- return /* @__PURE__ */ React5.createElement(FunctionBody, {
911
- shape,
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
- var _effect = _useSignals6();
946
- try {
947
- const { node } = useComputeNodeState(shape);
948
- const [active, setActive] = useState4(false);
949
- useEffect3(() => {
950
- node.value = active;
951
- }, [
952
- active
953
- ]);
954
- return /* @__PURE__ */ React6.createElement("div", {
955
- className: "flex is-full justify-center items-center"
956
- }, /* @__PURE__ */ React6.createElement(Icon2, {
957
- icon: active ? "ph--microphone--regular" : "ph--microphone-slash--regular",
958
- classNames: [
959
- "transition opacity-20 duration-1000",
960
- active && "opacity-100 text-red-500"
961
- ],
962
- size: 8,
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 is-full justify-center items-center"
926
+ }, /* @__PURE__ */ React6.createElement(Icon2, {
927
+ icon: active ? "ph--microphone--regular" : "ph--microphone-slash--regular",
928
+ classNames: [
929
+ "transition opacity-20 duration-1000",
930
+ active && "opacity-100 text-red-500"
931
+ ],
932
+ size: 8,
933
+ onClick: () => setActive(!active)
934
+ }));
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
- var _effect = _useSignals7();
1003
- try {
1004
- const { runtime } = useComputeNodeState(shape);
1005
- const input = runtime.inputs[DEFAULT_INPUT3];
1006
- const value = input?.type === "executed" ? input.value : false;
1007
- return /* @__PURE__ */ React7.createElement("div", {
1008
- className: "flex is-full justify-center items-center"
1009
- }, /* @__PURE__ */ React7.createElement(Icon3, {
1010
- icon: "ph--sun--regular",
1011
- classNames: [
1012
- "transition opacity-20 duration-1000",
1013
- isTruthy(value) && "opacity-100 text-yellow-500"
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 is-full justify-center items-center"
973
+ }, /* @__PURE__ */ React7.createElement(Icon3, {
974
+ icon: "ph--sun--regular",
975
+ classNames: [
976
+ "transition opacity-20 duration-1000",
977
+ isTruthy(value) && "opacity-100 text-yellow-500"
978
+ ],
979
+ size: 8
980
+ }));
1020
981
  };
1021
982
  var beaconShape = {
1022
983
  type: "beacon",
@@ -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
- var _effect = _useSignals8();
1220
- try {
1221
- const { runtime } = useComputeNodeState(shape);
1222
- const inputRef = useRef2(null);
1223
- const handleEnter = (text) => {
1224
- const value = text.trim();
1225
- if (value.length) {
1226
- runtime.setOutput(DEFAULT_OUTPUT3, value);
1227
- inputRef.current?.setText("");
1228
- }
1229
- };
1230
- return /* @__PURE__ */ React9.createElement(Box, {
1231
- shape,
1232
- title
1233
- }, /* @__PURE__ */ React9.createElement(TextBox, {
1234
- ref: inputRef,
1235
- onEnter: handleEnter,
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
- var _effect = _useSignals9();
1295
- try {
1296
- const { node } = useComputeNodeState(shape);
1297
- const [type, setType] = useState5(inferType(node.value) ?? ComputeValueType2.literals[0]);
1298
- const inputRef = useRef3(null);
1299
- const handleEnter = useCallback2((text) => {
1300
- const value = text.trim();
1301
- if (value.length) {
1302
- if (type === "number") {
1303
- const floatValue = parseFloat(value);
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
- inputRef.current?.focus();
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
- } finally {
1343
- _effect.f();
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
- var _effect = _useSignals10();
1390
- try {
1391
- return /* @__PURE__ */ React11.createElement(Box, {
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
- var _effect = _useSignals11();
1435
- try {
1436
- const client = useClient();
1437
- const { node, runtime } = useComputeNodeState(shape);
1438
- const inputRef = useRef4(null);
1439
- const handleEnter = useCallback3(async (text) => {
1440
- const value = text.trim();
1441
- const { spaceId, objectId } = parseId(value);
1442
- if (!spaceId || !objectId) {
1443
- return;
1444
- }
1445
- const space = client.spaces.get(spaceId);
1446
- const object = space?.db.getObjectById(objectId);
1447
- if (!space || !isInstanceOf(Script.Script, object)) {
1448
- return;
1449
- }
1450
- const { objects: [fn] } = await space.db.query(Filter.type(Function.Function, {
1451
- source: Ref2.make(object)
1452
- })).run();
1453
- if (!fn) {
1454
- return;
1455
- }
1456
- node.value = value;
1457
- node.function = Ref2.make(fn);
1458
- node.inputSchema = getSnapshot(fn.inputSchema);
1459
- node.outputSchema = getSnapshot(fn.outputSchema);
1460
- }, [
1461
- client,
1462
- node
1463
- ]);
1464
- const handleAction = useCallback3((action) => {
1465
- if (action !== "run") {
1466
- return;
1467
- }
1468
- runtime.evalNode();
1469
- }, [
1470
- runtime
1471
- ]);
1472
- return /* @__PURE__ */ React12.createElement(Box, {
1473
- shape,
1474
- title: "Function",
1475
- onAction: handleAction
1476
- }, /* @__PURE__ */ React12.createElement(TextBox3, {
1477
- ...props,
1478
- ref: inputRef,
1479
- value: node.value,
1480
- language: node.valueType === "object" ? "json" : void 0,
1481
- onBlur: handleEnter,
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,7 +1432,6 @@ 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";
@@ -1511,54 +1447,49 @@ var createGpt = (props) => createShape({
1511
1447
  ...props
1512
1448
  });
1513
1449
  var GptComponent = ({ shape }) => {
1514
- var _effect = _useSignals12();
1515
- try {
1516
- const { meta, runtime } = useComputeNodeState(shape);
1517
- const [text, setText] = useState6("");
1518
- const [tokens, setTokens] = useState6(0);
1519
- useEffect4(() => {
1520
- return runtime.subscribeToEventLog((ev) => {
1521
- switch (ev.type) {
1522
- case "begin-compute": {
1523
- setText("");
1524
- break;
1525
- }
1526
- case "custom": {
1527
- const token = ev.event;
1528
- switch (token.type) {
1529
- case "content_block_delta":
1530
- switch (token.delta.type) {
1531
- case "text_delta": {
1532
- const delta = token.delta.text;
1533
- setText((prev) => {
1534
- const text2 = prev + delta;
1535
- setTokens(text2.split(" ").length);
1536
- return text2;
1537
- });
1538
- break;
1539
- }
1450
+ const { meta, runtime } = useComputeNodeState(shape);
1451
+ const [text, setText] = useState6("");
1452
+ const [tokens, setTokens] = useState6(0);
1453
+ useEffect4(() => {
1454
+ return runtime.subscribeToEventLog((ev) => {
1455
+ switch (ev.type) {
1456
+ case "begin-compute": {
1457
+ setText("");
1458
+ break;
1459
+ }
1460
+ case "custom": {
1461
+ const token = ev.event;
1462
+ switch (token.type) {
1463
+ case "content_block_delta":
1464
+ switch (token.delta.type) {
1465
+ case "text_delta": {
1466
+ const delta = token.delta.text;
1467
+ setText((prev) => {
1468
+ const text2 = prev + delta;
1469
+ setTokens(text2.split(" ").length);
1470
+ return text2;
1471
+ });
1472
+ break;
1540
1473
  }
1541
- break;
1542
- }
1543
- break;
1474
+ }
1475
+ break;
1544
1476
  }
1477
+ break;
1545
1478
  }
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
1479
+ }
1558
1480
  });
1559
- } finally {
1560
- _effect.f();
1561
- }
1481
+ }, [
1482
+ runtime?.subscribeToEventLog
1483
+ ]);
1484
+ return /* @__PURE__ */ React13.createElement(FunctionBody, {
1485
+ shape,
1486
+ content: /* @__PURE__ */ React13.createElement("div", {
1487
+ className: "pli-2 plb-1 overflow-y-auto"
1488
+ }, text),
1489
+ status: `${tokens} tokens`,
1490
+ inputSchema: meta.input,
1491
+ outputSchema: meta.output
1492
+ });
1562
1493
  };
1563
1494
  var gptShape = {
1564
1495
  type: "gpt",
@@ -1571,7 +1502,6 @@ var gptShape = {
1571
1502
  };
1572
1503
 
1573
1504
  // src/shapes/Json.tsx
1574
- import { useSignals as _useSignals13 } from "@preact-signals/safe-react/tracking";
1575
1505
  import * as Schema13 from "effect/Schema";
1576
1506
  import React14 from "react";
1577
1507
  import { DEFAULT_INPUT as DEFAULT_INPUT4, DefaultOutput, JsonTransformInput } from "@dxos/conductor";
@@ -1584,30 +1514,20 @@ var JsonTransformShape = Schema13.extend(ComputeShape, Schema13.Struct({
1584
1514
  type: Schema13.Literal("json-transform")
1585
1515
  }));
1586
1516
  var JsonComponent = ({ shape, ...props }) => {
1587
- var _effect = _useSignals13();
1588
- try {
1589
- const { runtime } = useComputeNodeState(shape);
1590
- const input = runtime.inputs[DEFAULT_INPUT4];
1591
- const value = input?.type === "executed" ? input.value : void 0;
1592
- return /* @__PURE__ */ React14.createElement(Box, {
1593
- shape
1594
- }, /* @__PURE__ */ React14.createElement(JsonFilter, {
1595
- data: value,
1596
- classNames: "text-xs"
1597
- }));
1598
- } finally {
1599
- _effect.f();
1600
- }
1517
+ const { runtime } = useComputeNodeState(shape);
1518
+ const input = runtime.inputs[DEFAULT_INPUT4];
1519
+ const value = input?.type === "executed" ? input.value : void 0;
1520
+ return /* @__PURE__ */ React14.createElement(Box, {
1521
+ shape
1522
+ }, /* @__PURE__ */ React14.createElement(JsonFilter, {
1523
+ data: value,
1524
+ classNames: "text-xs"
1525
+ }));
1601
1526
  };
1602
1527
  var JsonTransformComponent = ({ shape, ...props }) => {
1603
- var _effect = _useSignals13();
1604
- try {
1605
- return /* @__PURE__ */ React14.createElement(Box, {
1606
- shape
1607
- });
1608
- } finally {
1609
- _effect.f();
1610
- }
1528
+ return /* @__PURE__ */ React14.createElement(Box, {
1529
+ shape
1530
+ });
1611
1531
  };
1612
1532
  var createJson = (props) => createShape({
1613
1533
  type: "json",
@@ -1654,7 +1574,6 @@ var jsonTransformShape = {
1654
1574
  };
1655
1575
 
1656
1576
  // src/shapes/Logic.tsx
1657
- import { useSignals as _useSignals14 } from "@preact-signals/safe-react/tracking";
1658
1577
  import * as Schema14 from "effect/Schema";
1659
1578
  import React15 from "react";
1660
1579
  import { IfElseInput, IfElseOutput, IfInput, IfOutput } from "@dxos/conductor";
@@ -1665,28 +1584,18 @@ var IfElseShape = Schema14.extend(ComputeShape, Schema14.Struct({
1665
1584
  type: Schema14.Literal("if-else")
1666
1585
  }));
1667
1586
  var IfComponent = ({ shape, ...props }) => {
1668
- var _effect = _useSignals14();
1669
- try {
1670
- return /* @__PURE__ */ React15.createElement(FunctionBody, {
1671
- shape,
1672
- inputSchema: IfInput,
1673
- outputSchema: IfOutput
1674
- });
1675
- } finally {
1676
- _effect.f();
1677
- }
1587
+ return /* @__PURE__ */ React15.createElement(FunctionBody, {
1588
+ shape,
1589
+ inputSchema: IfInput,
1590
+ outputSchema: IfOutput
1591
+ });
1678
1592
  };
1679
1593
  var IfElseComponent = ({ shape, ...props }) => {
1680
- var _effect = _useSignals14();
1681
- try {
1682
- return /* @__PURE__ */ React15.createElement(FunctionBody, {
1683
- shape,
1684
- inputSchema: IfElseInput,
1685
- outputSchema: IfElseOutput
1686
- });
1687
- } finally {
1688
- _effect.f();
1689
- }
1594
+ return /* @__PURE__ */ React15.createElement(FunctionBody, {
1595
+ shape,
1596
+ inputSchema: IfElseInput,
1597
+ outputSchema: IfElseOutput
1598
+ });
1690
1599
  };
1691
1600
  var createIf = (props) => createShape({
1692
1601
  type: "if",
@@ -1722,11 +1631,10 @@ var ifElseShape = {
1722
1631
  };
1723
1632
 
1724
1633
  // src/shapes/Queue.tsx
1725
- import { useSignals as _useSignals15 } from "@preact-signals/safe-react/tracking";
1726
1634
  import * as Schema15 from "effect/Schema";
1727
1635
  import React16, { Fragment } from "react";
1728
1636
  import { DEFAULT_OUTPUT as DEFAULT_OUTPUT4, QueueInput, QueueOutput } from "@dxos/conductor";
1729
- import { mx as mx2 } from "@dxos/react-ui-theme";
1637
+ import { mx as mx2 } from "@dxos/ui-theme";
1730
1638
  var QueueShape = Schema15.extend(ComputeShape, Schema15.Struct({
1731
1639
  type: Schema15.Literal("queue")
1732
1640
  }));
@@ -1739,50 +1647,40 @@ var createQueue = (props) => createShape({
1739
1647
  ...props
1740
1648
  });
1741
1649
  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
- }
1650
+ const { runtime } = useComputeNodeState(shape);
1651
+ const items = runtime.outputs[DEFAULT_OUTPUT4]?.type === "executed" ? runtime.outputs[DEFAULT_OUTPUT4].value : [];
1652
+ const handleAction = (action) => {
1653
+ if (action === "run") {
1654
+ runtime.evalNode();
1655
+ }
1656
+ };
1657
+ return /* @__PURE__ */ React16.createElement(Box, {
1658
+ shape,
1659
+ status: `${items.length} items`,
1660
+ onAction: handleAction
1661
+ }, /* @__PURE__ */ React16.createElement("div", {
1662
+ className: "flex flex-col is-full overflow-y-auto divide-y divide-separator"
1663
+ }, [
1664
+ ...items
1665
+ ].map((item, i) => /* @__PURE__ */ React16.createElement(QueueItem, {
1666
+ key: i,
1667
+ classNames: "p-1 pli-2",
1668
+ item
1669
+ }))));
1767
1670
  };
1768
1671
  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
- }
1672
+ if (typeof item !== "object") {
1776
1673
  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();
1674
+ className: mx2(classNames, "whitespace-pre-wrap")
1675
+ }, item);
1785
1676
  }
1677
+ return /* @__PURE__ */ React16.createElement("div", {
1678
+ className: mx2("grid grid-cols-[80px,1fr]", classNames)
1679
+ }, Object.entries(item).map(([key, value]) => /* @__PURE__ */ React16.createElement(Fragment, {
1680
+ key
1681
+ }, /* @__PURE__ */ React16.createElement("div", {
1682
+ className: "p-1 text-xs text-subdued"
1683
+ }, key), /* @__PURE__ */ React16.createElement("div", null, typeof value === "string" ? value : JSON.stringify(value)))));
1786
1684
  };
1787
1685
  var queueShape = {
1788
1686
  type: "queue",
@@ -1795,7 +1693,6 @@ var queueShape = {
1795
1693
  };
1796
1694
 
1797
1695
  // src/shapes/RNG.tsx
1798
- import { useSignals as _useSignals16 } from "@preact-signals/safe-react/tracking";
1799
1696
  import * as Schema16 from "effect/Schema";
1800
1697
  import React17, { useEffect as useEffect5, useState as useState7 } from "react";
1801
1698
  import { DEFAULT_OUTPUT as DEFAULT_OUTPUT5 } from "@dxos/conductor";
@@ -1824,42 +1721,37 @@ var icons = [
1824
1721
  ];
1825
1722
  var pickIcon = () => icons[Math.floor(Math.random() * icons.length)];
1826
1723
  var RandomComponent = ({ shape }) => {
1827
- var _effect = _useSignals16();
1828
- try {
1829
- const { runtime } = useComputeNodeState(shape);
1830
- const [spin, setSpin] = useState7(false);
1831
- const [icon, setIcon] = useState7(pickIcon());
1832
- useEffect5(() => {
1833
- if (!spin) {
1834
- return;
1835
- }
1836
- const i = setInterval(() => setIcon(pickIcon()), 250);
1837
- const t1 = setTimeout(() => clearInterval(i), 900);
1838
- const t2 = setTimeout(() => setSpin(false), 1100);
1839
- return () => {
1840
- clearInterval(i);
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);
1724
+ const { runtime } = useComputeNodeState(shape);
1725
+ const [spin, setSpin] = useState7(false);
1726
+ const [icon, setIcon] = useState7(pickIcon());
1727
+ useEffect5(() => {
1728
+ if (!spin) {
1729
+ return;
1730
+ }
1731
+ const i = setInterval(() => setIcon(pickIcon()), 250);
1732
+ const t1 = setTimeout(() => clearInterval(i), 900);
1733
+ const t2 = setTimeout(() => setSpin(false), 1100);
1734
+ return () => {
1735
+ clearInterval(i);
1736
+ clearTimeout(t1);
1737
+ clearTimeout(t2);
1851
1738
  };
1852
- return /* @__PURE__ */ React17.createElement("div", {
1853
- className: "flex grow items-center justify-center"
1854
- }, /* @__PURE__ */ React17.createElement(Icon4, {
1855
- icon,
1856
- classNames: spin && "animate-[spin_1s]",
1857
- size: 10,
1858
- onClick: handleClick
1859
- }));
1860
- } finally {
1861
- _effect.f();
1862
- }
1739
+ }, [
1740
+ spin
1741
+ ]);
1742
+ const handleClick = (ev) => {
1743
+ ev.stopPropagation();
1744
+ runtime.setOutput(DEFAULT_OUTPUT5, Math.random());
1745
+ setSpin(true);
1746
+ };
1747
+ return /* @__PURE__ */ React17.createElement("div", {
1748
+ className: "flex grow items-center justify-center"
1749
+ }, /* @__PURE__ */ React17.createElement(Icon4, {
1750
+ icon,
1751
+ classNames: spin && "animate-[spin_1s]",
1752
+ size: 10,
1753
+ onClick: handleClick
1754
+ }));
1863
1755
  };
1864
1756
  var randomShape = {
1865
1757
  type: "rng",
@@ -1876,7 +1768,6 @@ var randomShape = {
1876
1768
  };
1877
1769
 
1878
1770
  // src/shapes/Scope.tsx
1879
- import { useSignals as _useSignals17 } from "@preact-signals/safe-react/tracking";
1880
1771
  import * as Schema17 from "effect/Schema";
1881
1772
  import React18 from "react";
1882
1773
  import { DEFAULT_INPUT as DEFAULT_INPUT5 } from "@dxos/conductor";
@@ -1895,25 +1786,20 @@ var createScope = (props) => createShape({
1895
1786
  ...props
1896
1787
  });
1897
1788
  var ScopeComponent = ({ shape }) => {
1898
- var _effect = _useSignals17();
1899
- try {
1900
- const { runtime } = useComputeNodeState(shape);
1901
- const input = runtime.inputs[DEFAULT_INPUT5];
1902
- const active = input?.type === "executed" ? input.value : false;
1903
- const { getAverage } = useAudioStream(active);
1904
- return /* @__PURE__ */ React18.createElement("div", {
1905
- className: "flex is-full justify-center items-center bg-black"
1906
- }, /* @__PURE__ */ React18.createElement(Chaos, {
1907
- active,
1908
- getValue: getAverage,
1909
- options: {
1910
- ...shaderPresets.heptapod,
1911
- zoom: 1.2
1912
- }
1913
- }));
1914
- } finally {
1915
- _effect.f();
1916
- }
1789
+ const { runtime } = useComputeNodeState(shape);
1790
+ const input = runtime.inputs[DEFAULT_INPUT5];
1791
+ const active = input?.type === "executed" ? input.value : false;
1792
+ const { getAverage } = useAudioStream(active);
1793
+ return /* @__PURE__ */ React18.createElement("div", {
1794
+ className: "flex is-full justify-center items-center bg-black"
1795
+ }, /* @__PURE__ */ React18.createElement(Chaos, {
1796
+ active,
1797
+ getValue: getAverage,
1798
+ options: {
1799
+ ...shaderPresets.heptapod,
1800
+ zoom: 1.2
1801
+ }
1802
+ }));
1917
1803
  };
1918
1804
  var scopeShape = {
1919
1805
  type: "scope",
@@ -1930,7 +1816,6 @@ var scopeShape = {
1930
1816
  };
1931
1817
 
1932
1818
  // src/shapes/Surface.tsx
1933
- import { useSignals as _useSignals18 } from "@preact-signals/safe-react/tracking";
1934
1819
  import * as Schema18 from "effect/Schema";
1935
1820
  import React19 from "react";
1936
1821
  import { Surface } from "@dxos/app-framework/react";
@@ -1948,29 +1833,24 @@ var createSurface = (props) => createShape({
1948
1833
  ...props
1949
1834
  });
1950
1835
  var SurfaceComponent = ({ shape }) => {
1951
- var _effect = _useSignals18();
1952
- try {
1953
- const { runtime } = useComputeNodeState(shape);
1954
- const input = runtime.inputs[DEFAULT_INPUT6];
1955
- const value = input?.type === "executed" ? input.value : null;
1956
- const handleAction = (action) => {
1957
- if (action === "run") {
1958
- runtime.evalNode();
1959
- }
1960
- };
1961
- return /* @__PURE__ */ React19.createElement(Box, {
1962
- shape,
1963
- onAction: handleAction
1964
- }, value !== null && /* @__PURE__ */ React19.createElement(Surface, {
1965
- role: "card--extrinsic",
1966
- data: {
1967
- value
1968
- },
1969
- limit: 1
1970
- }));
1971
- } finally {
1972
- _effect.f();
1973
- }
1836
+ const { runtime } = useComputeNodeState(shape);
1837
+ const input = runtime.inputs[DEFAULT_INPUT6];
1838
+ const value = input?.type === "executed" ? input.value : null;
1839
+ const handleAction = (action) => {
1840
+ if (action === "run") {
1841
+ runtime.evalNode();
1842
+ }
1843
+ };
1844
+ return /* @__PURE__ */ React19.createElement(Box, {
1845
+ shape,
1846
+ onAction: handleAction
1847
+ }, value !== null && /* @__PURE__ */ React19.createElement(Surface, {
1848
+ role: "card--extrinsic",
1849
+ data: {
1850
+ value
1851
+ },
1852
+ limit: 1
1853
+ }));
1974
1854
  };
1975
1855
  var surfaceShape = {
1976
1856
  type: "surface",
@@ -1988,7 +1868,6 @@ var surfaceShape = {
1988
1868
  };
1989
1869
 
1990
1870
  // src/shapes/Switch.tsx
1991
- import { useSignals as _useSignals19 } from "@preact-signals/safe-react/tracking";
1992
1871
  import * as Schema19 from "effect/Schema";
1993
1872
  import React20, { useEffect as useEffect6, useState as useState8 } from "react";
1994
1873
  import { DEFAULT_OUTPUT as DEFAULT_OUTPUT6 } from "@dxos/conductor";
@@ -2006,25 +1885,20 @@ var createSwitch = (props) => createShape({
2006
1885
  ...props
2007
1886
  });
2008
1887
  var SwitchComponent = ({ shape }) => {
2009
- var _effect = _useSignals19();
2010
- try {
2011
- const { runtime } = useComputeNodeState(shape);
2012
- const [value, setValue] = useState8(false);
2013
- useEffect6(() => {
2014
- runtime.setOutput(DEFAULT_OUTPUT6, value);
2015
- }, [
2016
- value
2017
- ]);
2018
- return /* @__PURE__ */ React20.createElement("div", {
2019
- className: "flex is-full justify-center items-center",
2020
- onClick: (ev) => ev.stopPropagation()
2021
- }, /* @__PURE__ */ React20.createElement(Input2.Root, null, /* @__PURE__ */ React20.createElement(Input2.Switch, {
2022
- checked: value,
2023
- onCheckedChange: (value2) => setValue(value2)
2024
- })));
2025
- } finally {
2026
- _effect.f();
2027
- }
1888
+ const { runtime } = useComputeNodeState(shape);
1889
+ const [value, setValue] = useState8(false);
1890
+ useEffect6(() => {
1891
+ runtime.setOutput(DEFAULT_OUTPUT6, value);
1892
+ }, [
1893
+ value
1894
+ ]);
1895
+ return /* @__PURE__ */ React20.createElement("div", {
1896
+ className: "flex is-full justify-center items-center",
1897
+ onClick: (ev) => ev.stopPropagation()
1898
+ }, /* @__PURE__ */ React20.createElement(Input2.Root, null, /* @__PURE__ */ React20.createElement(Input2.Switch, {
1899
+ checked: value,
1900
+ onCheckedChange: (value2) => setValue(value2)
1901
+ })));
2028
1902
  };
2029
1903
  var switchShape = {
2030
1904
  type: "switch",
@@ -2041,7 +1915,6 @@ var switchShape = {
2041
1915
  };
2042
1916
 
2043
1917
  // src/shapes/Table.tsx
2044
- import { useSignals as _useSignals20 } from "@preact-signals/safe-react/tracking";
2045
1918
  import * as Schema20 from "effect/Schema";
2046
1919
  import React21 from "react";
2047
1920
  import { createInputSchema, createOutputSchema } from "@dxos/conductor";
@@ -2060,14 +1933,9 @@ var createTable = (props) => createShape({
2060
1933
  ...props
2061
1934
  });
2062
1935
  var TableComponent = ({ shape }) => {
2063
- var _effect = _useSignals20();
2064
- try {
2065
- return /* @__PURE__ */ React21.createElement(Box, {
2066
- shape
2067
- });
2068
- } finally {
2069
- _effect.f();
2070
- }
1936
+ return /* @__PURE__ */ React21.createElement(Box, {
1937
+ shape
1938
+ });
2071
1939
  };
2072
1940
  var tableShape = {
2073
1941
  type: "table",
@@ -2080,7 +1948,6 @@ var tableShape = {
2080
1948
  };
2081
1949
 
2082
1950
  // src/shapes/Template.tsx
2083
- import { useSignals as _useSignals21 } from "@preact-signals/safe-react/tracking";
2084
1951
  import * as Schema21 from "effect/Schema";
2085
1952
  import React22, { useRef as useRef5 } from "react";
2086
1953
  import { ComputeValueType as ComputeValueType3, TemplateOutput, VoidInput as VoidInput2, getTemplateInputSchema as getTemplateInputSchema2 } from "@dxos/conductor";
@@ -2093,49 +1960,44 @@ var TemplateShape = Schema21.extend(ComputeShape, Schema21.Struct({
2093
1960
  valueType: Schema21.optional(ComputeValueType3)
2094
1961
  }));
2095
1962
  var TextInputComponent3 = ({ shape, title, ...props }) => {
2096
- var _effect = _useSignals21();
2097
- try {
2098
- const { node } = useComputeNodeState(shape);
2099
- const inputRef = useRef5(null);
2100
- const handleEnter = (text) => {
2101
- const value = text.trim();
2102
- if (value.length) {
2103
- const schema = getTemplateInputSchema2(node);
2104
- node.value = value;
2105
- node.inputSchema = toJsonSchema(schema);
2106
- }
2107
- };
2108
- const handleTypeChange = (newType) => {
2109
- invariant5(Schema21.is(ComputeValueType3)(newType), "Invalid type", {
2110
- F: __dxlog_file6,
2111
- L: 59,
2112
- S: void 0,
2113
- A: [
2114
- "Schema.is(ComputeValueType)(newType)",
2115
- "'Invalid type'"
2116
- ]
2117
- });
2118
- node.valueType = newType;
2119
- node.inputSchema = toJsonSchema(getTemplateInputSchema2(node));
2120
- };
2121
- return /* @__PURE__ */ React22.createElement(Box, {
2122
- shape,
2123
- title: "Template",
2124
- status: /* @__PURE__ */ React22.createElement(TypeSelect, {
2125
- value: node.valueType ?? "string",
2126
- onValueChange: handleTypeChange
2127
- })
2128
- }, /* @__PURE__ */ React22.createElement(TextBox4, {
2129
- ...props,
2130
- ref: inputRef,
2131
- value: node.value,
2132
- language: node.valueType === "object" ? "json" : void 0,
2133
- onBlur: handleEnter,
2134
- onEnter: handleEnter
2135
- }));
2136
- } finally {
2137
- _effect.f();
2138
- }
1963
+ const { node } = useComputeNodeState(shape);
1964
+ const inputRef = useRef5(null);
1965
+ const handleEnter = (text) => {
1966
+ const value = text.trim();
1967
+ if (value.length) {
1968
+ const schema = getTemplateInputSchema2(node);
1969
+ node.value = value;
1970
+ node.inputSchema = toJsonSchema(schema);
1971
+ }
1972
+ };
1973
+ const handleTypeChange = (newType) => {
1974
+ invariant5(Schema21.is(ComputeValueType3)(newType), "Invalid type", {
1975
+ F: __dxlog_file6,
1976
+ L: 59,
1977
+ S: void 0,
1978
+ A: [
1979
+ "Schema.is(ComputeValueType)(newType)",
1980
+ "'Invalid type'"
1981
+ ]
1982
+ });
1983
+ node.valueType = newType;
1984
+ node.inputSchema = toJsonSchema(getTemplateInputSchema2(node));
1985
+ };
1986
+ return /* @__PURE__ */ React22.createElement(Box, {
1987
+ shape,
1988
+ title: "Template",
1989
+ status: /* @__PURE__ */ React22.createElement(TypeSelect, {
1990
+ value: node.valueType ?? "string",
1991
+ onValueChange: handleTypeChange
1992
+ })
1993
+ }, /* @__PURE__ */ React22.createElement(TextBox4, {
1994
+ ...props,
1995
+ ref: inputRef,
1996
+ value: node.value,
1997
+ language: node.valueType === "object" ? "json" : void 0,
1998
+ onBlur: handleEnter,
1999
+ onEnter: handleEnter
2000
+ }));
2139
2001
  };
2140
2002
  var createTemplate = (props) => createShape({
2141
2003
  type: "template",
@@ -2159,7 +2021,6 @@ var templateShape = {
2159
2021
  };
2160
2022
 
2161
2023
  // src/shapes/Text.tsx
2162
- import { useSignals as _useSignals22 } from "@preact-signals/safe-react/tracking";
2163
2024
  import * as Schema22 from "effect/Schema";
2164
2025
  import React23 from "react";
2165
2026
  import { DEFAULT_INPUT as DEFAULT_INPUT7 } from "@dxos/conductor";
@@ -2177,25 +2038,20 @@ var createText = (props) => createShape({
2177
2038
  ...props
2178
2039
  });
2179
2040
  var TextComponent = ({ shape }) => {
2180
- var _effect = _useSignals22();
2181
- try {
2182
- const { runtime } = useComputeNodeState(shape);
2183
- const input = runtime.inputs[DEFAULT_INPUT7];
2184
- const value = input?.type === "executed" ? input.value : 0;
2185
- const handleAction = (action) => {
2186
- if (action === "run") {
2187
- runtime.evalNode();
2188
- }
2189
- };
2190
- return /* @__PURE__ */ React23.createElement(Box, {
2191
- shape,
2192
- onAction: handleAction
2193
- }, /* @__PURE__ */ React23.createElement(TextBox5, {
2194
- value
2195
- }));
2196
- } finally {
2197
- _effect.f();
2198
- }
2041
+ const { runtime } = useComputeNodeState(shape);
2042
+ const input = runtime.inputs[DEFAULT_INPUT7];
2043
+ const value = input?.type === "executed" ? input.value : 0;
2044
+ const handleAction = (action) => {
2045
+ if (action === "run") {
2046
+ runtime.evalNode();
2047
+ }
2048
+ };
2049
+ return /* @__PURE__ */ React23.createElement(Box, {
2050
+ shape,
2051
+ onAction: handleAction
2052
+ }, /* @__PURE__ */ React23.createElement(TextBox5, {
2053
+ value
2054
+ }));
2199
2055
  };
2200
2056
  var textShape = {
2201
2057
  type: "text",
@@ -2213,12 +2069,11 @@ var textShape = {
2213
2069
  };
2214
2070
 
2215
2071
  // src/shapes/Thread.tsx
2216
- import { useSignals as _useSignals23 } from "@preact-signals/safe-react/tracking";
2217
2072
  import * as Schema23 from "effect/Schema";
2218
2073
  import React24, { useEffect as useEffect7, useRef as useRef6 } from "react";
2219
2074
  import { createInputSchema as createInputSchema2, createOutputSchema as createOutputSchema2 } from "@dxos/conductor";
2220
- import { mx as mx3 } from "@dxos/react-ui-theme";
2221
2075
  import { Message as Message2 } from "@dxos/types";
2076
+ import { mx as mx3 } from "@dxos/ui-theme";
2222
2077
  var InputSchema2 = createInputSchema2(Message2.Message);
2223
2078
  var OutputSchema2 = createOutputSchema2(Schema23.mutable(Schema23.Array(Message2.Message)));
2224
2079
  var ThreadShape = Schema23.extend(ComputeShape, Schema23.Struct({
@@ -2233,49 +2088,39 @@ var createThread = (props) => createShape({
2233
2088
  ...props
2234
2089
  });
2235
2090
  var ThreadComponent = ({ shape }) => {
2236
- var _effect = _useSignals23();
2237
- try {
2238
- const items = [];
2239
- const scrollRef = useRef6(null);
2240
- useEffect7(() => {
2241
- if (scrollRef.current) {
2242
- scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
2243
- }
2244
- }, [
2245
- items
2246
- ]);
2247
- return /* @__PURE__ */ React24.createElement(Box, {
2248
- shape
2249
- }, /* @__PURE__ */ React24.createElement("div", {
2250
- ref: scrollRef,
2251
- className: "flex flex-col is-full overflow-y-auto gap-2 p-2"
2252
- }, [
2253
- ...items
2254
- ].map((item, i) => /* @__PURE__ */ React24.createElement(ThreadItem, {
2255
- key: i,
2256
- item
2257
- }))));
2258
- } finally {
2259
- _effect.f();
2260
- }
2091
+ const items = [];
2092
+ const scrollRef = useRef6(null);
2093
+ useEffect7(() => {
2094
+ if (scrollRef.current) {
2095
+ scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
2096
+ }
2097
+ }, [
2098
+ items
2099
+ ]);
2100
+ return /* @__PURE__ */ React24.createElement(Box, {
2101
+ shape
2102
+ }, /* @__PURE__ */ React24.createElement("div", {
2103
+ ref: scrollRef,
2104
+ className: "flex flex-col is-full overflow-y-auto gap-2 p-2"
2105
+ }, [
2106
+ ...items
2107
+ ].map((item, i) => /* @__PURE__ */ React24.createElement(ThreadItem, {
2108
+ key: i,
2109
+ item
2110
+ }))));
2261
2111
  };
2262
2112
  var ThreadItem = ({ classNames, item }) => {
2263
- var _effect = _useSignals23();
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;
2113
+ if (typeof item !== "object") {
2271
2114
  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();
2115
+ className: mx3(classNames)
2116
+ }, item);
2278
2117
  }
2118
+ const { role, message } = item;
2119
+ return /* @__PURE__ */ React24.createElement("div", {
2120
+ className: mx3("flex", classNames, role === "user" && "justify-end")
2121
+ }, /* @__PURE__ */ React24.createElement("div", {
2122
+ 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")
2123
+ }, message));
2279
2124
  };
2280
2125
  var threadShape = {
2281
2126
  type: "thread",
@@ -2288,7 +2133,6 @@ var threadShape = {
2288
2133
  };
2289
2134
 
2290
2135
  // src/shapes/TextToImage.tsx
2291
- import { useSignals as _useSignals24 } from "@preact-signals/safe-react/tracking";
2292
2136
  import * as Schema24 from "effect/Schema";
2293
2137
  import React25 from "react";
2294
2138
  import { createAnchorMap as createAnchorMap12 } from "@dxos/react-ui-canvas-editor";
@@ -2304,14 +2148,9 @@ var createTextToImage = (props) => createShape({
2304
2148
  ...props
2305
2149
  });
2306
2150
  var TextToImageComponent = ({ shape }) => {
2307
- var _effect = _useSignals24();
2308
- try {
2309
- return /* @__PURE__ */ React25.createElement(Box, {
2310
- shape
2311
- });
2312
- } finally {
2313
- _effect.f();
2314
- }
2151
+ return /* @__PURE__ */ React25.createElement(Box, {
2152
+ shape
2153
+ });
2315
2154
  };
2316
2155
  var textToImageShape = {
2317
2156
  type: "text-to-image",
@@ -2328,7 +2167,6 @@ var textToImageShape = {
2328
2167
  };
2329
2168
 
2330
2169
  // src/shapes/Trigger.tsx
2331
- import { useSignals as _useSignals25 } from "@preact-signals/safe-react/tracking";
2332
2170
  import * as Schema25 from "effect/Schema";
2333
2171
  import React26, { useEffect as useEffect8 } from "react";
2334
2172
  import { VoidInput as VoidInput3 } from "@dxos/conductor";
@@ -2357,66 +2195,60 @@ var createTrigger = (props) => {
2357
2195
  });
2358
2196
  };
2359
2197
  var TriggerComponent = ({ shape }) => {
2360
- var _effect = _useSignals25();
2361
- try {
2362
- const space = useSpace();
2363
- const functionTrigger = shape.functionTrigger?.target;
2364
- useEffect8(() => {
2365
- if (functionTrigger && !functionTrigger.spec) {
2366
- functionTrigger.spec = createTriggerSpec({
2198
+ const space = useSpace();
2199
+ const functionTrigger = shape.functionTrigger?.target;
2200
+ useEffect8(() => {
2201
+ if (functionTrigger && !functionTrigger.spec) {
2202
+ Obj4.change(functionTrigger, (t) => {
2203
+ t.spec = createTriggerSpec({
2367
2204
  triggerKind: "email",
2368
2205
  spaceId: space?.id
2369
2206
  });
2370
- }
2371
- }, [
2372
- functionTrigger,
2373
- functionTrigger?.spec
2374
- ]);
2375
- useEffect8(() => {
2376
- shape.size.height = getHeight(getOutputSchema(functionTrigger?.spec?.kind ?? "email"));
2377
- }, [
2378
- functionTrigger?.spec?.kind
2379
- ]);
2380
- const setKind = (kind) => {
2381
- if (functionTrigger?.spec?.kind !== kind) {
2382
- functionTrigger.spec = createTriggerSpec({
2207
+ });
2208
+ }
2209
+ }, [
2210
+ functionTrigger,
2211
+ functionTrigger?.spec
2212
+ ]);
2213
+ useEffect8(() => {
2214
+ shape.size.height = getHeight(getOutputSchema(functionTrigger?.spec?.kind ?? "email"));
2215
+ }, [
2216
+ functionTrigger?.spec?.kind
2217
+ ]);
2218
+ const setKind = (kind) => {
2219
+ if (functionTrigger?.spec?.kind !== kind) {
2220
+ Obj4.change(functionTrigger, (t) => {
2221
+ t.spec = createTriggerSpec({
2383
2222
  triggerKind: kind,
2384
2223
  spaceId: space?.id
2385
2224
  });
2386
- }
2387
- };
2388
- if (!functionTrigger?.spec) {
2389
- return;
2225
+ });
2390
2226
  }
2391
- return /* @__PURE__ */ React26.createElement(FunctionBody, {
2392
- shape,
2393
- status: /* @__PURE__ */ React26.createElement(TriggerKindSelect, {
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();
2227
+ };
2228
+ if (!functionTrigger?.spec) {
2229
+ return;
2402
2230
  }
2231
+ return /* @__PURE__ */ React26.createElement(FunctionBody, {
2232
+ shape,
2233
+ status: /* @__PURE__ */ React26.createElement(TriggerKindSelect, {
2234
+ value: functionTrigger.spec?.kind,
2235
+ onValueChange: (kind) => setKind(kind)
2236
+ }),
2237
+ inputSchema: VoidInput3,
2238
+ outputSchema: getOutputSchema(functionTrigger.spec.kind)
2239
+ });
2403
2240
  };
2404
2241
  var TriggerKindSelect = ({ value, onValueChange }) => {
2405
- var _effect = _useSignals25();
2406
- try {
2407
- return /* @__PURE__ */ React26.createElement(Select2.Root, {
2408
- value,
2409
- onValueChange
2410
- }, /* @__PURE__ */ React26.createElement(Select2.TriggerButton, {
2411
- variant: "ghost",
2412
- classNames: "is-full !pli-0"
2413
- }), /* @__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, {
2414
- key: kind,
2415
- value: kind
2416
- }, kind))), /* @__PURE__ */ React26.createElement(Select2.ScrollDownButton, null), /* @__PURE__ */ React26.createElement(Select2.Arrow, null))));
2417
- } finally {
2418
- _effect.f();
2419
- }
2242
+ return /* @__PURE__ */ React26.createElement(Select2.Root, {
2243
+ value,
2244
+ onValueChange
2245
+ }, /* @__PURE__ */ React26.createElement(Select2.TriggerButton, {
2246
+ variant: "ghost",
2247
+ classNames: "is-full !pli-0"
2248
+ }), /* @__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, {
2249
+ key: kind,
2250
+ value: kind
2251
+ }, kind))), /* @__PURE__ */ React26.createElement(Select2.ScrollDownButton, null), /* @__PURE__ */ React26.createElement(Select2.Arrow, null))));
2420
2252
  };
2421
2253
  var createTriggerSpec = (props) => {
2422
2254
  const kind = props.triggerKind ?? "email";
@@ -2475,7 +2307,6 @@ var triggerShape = {
2475
2307
  };
2476
2308
 
2477
2309
  // src/shapes/GptRealtime.tsx
2478
- import { useSignals as _useSignals26 } from "@preact-signals/safe-react/tracking";
2479
2310
  import * as Schema26 from "effect/Schema";
2480
2311
  import React27, { useState as useState9 } from "react";
2481
2312
  import { log as log2 } from "@dxos/log";
@@ -2494,105 +2325,100 @@ var createGptRealtime = (props) => createShape({
2494
2325
  ...props
2495
2326
  });
2496
2327
  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
2328
+ const [isLive, setIsLive] = useState9(false);
2329
+ const [isReady, setIsReady] = useState9(false);
2330
+ const config = useConfig();
2331
+ const start = async () => {
2332
+ setIsLive(true);
2333
+ try {
2334
+ const peerConnection = new RTCPeerConnection();
2335
+ peerConnection.ontrack = (event) => {
2336
+ const audioElement = document.createElement("audio");
2337
+ audioElement.srcObject = event.streams[0];
2338
+ audioElement.autoplay = true;
2339
+ audioElement.controls = false;
2340
+ audioElement.style.display = "none";
2341
+ document.body.appendChild(audioElement);
2342
+ setIsReady(true);
2343
+ };
2344
+ const stream = await navigator.mediaDevices.getUserMedia({
2345
+ audio: true
2346
+ });
2347
+ stream.getTracks().forEach((track) => peerConnection.addTransceiver(track, {
2348
+ direction: "sendrecv"
2349
+ }));
2350
+ const offer = await peerConnection.createOffer();
2351
+ await peerConnection.setLocalDescription(offer);
2352
+ const AiServiceUrl = new URL("/rtc-connect", config.values.runtime?.services?.ai?.server ?? DEFAULT_AI_SERVICE_URL);
2353
+ const response = await fetch(AiServiceUrl, {
2354
+ method: "POST",
2355
+ body: offer.sdp,
2356
+ headers: {
2357
+ "Content-Type": "application/sdp"
2358
+ }
2359
+ });
2360
+ const answer = await response.text();
2361
+ await peerConnection.setRemoteDescription({
2362
+ sdp: answer,
2363
+ type: "answer"
2364
+ });
2365
+ const dataChannel = peerConnection.createDataChannel("response");
2366
+ const configureData = () => {
2367
+ log2.info("Configuring data channel", void 0, {
2368
+ F: __dxlog_file7,
2369
+ L: 87,
2370
+ S: void 0,
2371
+ C: (f, a) => f(...a)
2517
2372
  });
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"
2373
+ const event = {
2374
+ type: "session.update",
2375
+ session: {
2376
+ modalities: [
2377
+ "text",
2378
+ "audio"
2379
+ ],
2380
+ // Provide the tools. Note they match the keys in the `fns` object above
2381
+ tools: []
2529
2382
  }
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
2383
  };
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
2384
+ dataChannel.send(JSON.stringify(event));
2385
+ };
2386
+ dataChannel.addEventListener("open", (ev) => {
2387
+ log2.info("Opening data channel", {
2388
+ ev
2576
2389
  }, {
2577
2390
  F: __dxlog_file7,
2578
- L: 140,
2391
+ L: 100,
2579
2392
  S: void 0,
2580
2393
  C: (f, a) => f(...a)
2581
2394
  });
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
- }
2395
+ configureData();
2396
+ });
2397
+ dataChannel.addEventListener("message", async (ev) => {
2398
+ const msg = JSON.parse(ev.data);
2399
+ if (msg.type === "response.function_call_arguments.done") {
2400
+ }
2401
+ });
2402
+ } catch (error) {
2403
+ log2.error("Error in realtime session:", {
2404
+ error
2405
+ }, {
2406
+ F: __dxlog_file7,
2407
+ L: 140,
2408
+ S: void 0,
2409
+ C: (f, a) => f(...a)
2410
+ });
2411
+ throw error;
2412
+ }
2413
+ };
2414
+ return /* @__PURE__ */ React27.createElement("div", {
2415
+ className: "flex is-full justify-center items-center"
2416
+ }, /* @__PURE__ */ React27.createElement(Icon5, {
2417
+ icon: isReady ? "ph--waveform--regular" : isLive ? "ph--pulse--regular" : "ph--play--regular",
2418
+ size: 16,
2419
+ classNames: !isLive && "cursor-pointer",
2420
+ onClick: start
2421
+ }));
2596
2422
  };
2597
2423
  var gptRealtimeShape = {
2598
2424
  type: "gpt-realtime",