@dxos/react-ui-canvas-compute 0.8.4-main.72ec0f3 → 0.8.4-main.7996785055

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