@dxos/react-ui-canvas-compute 0.8.4-main.c4373fc → 0.8.4-main.c85a9c8dae

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 +778 -962
  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 +778 -962
  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 +18 -31
  10. package/dist/types/src/graph/controller.d.ts.map +1 -1
  11. package/dist/types/src/hooks/useComputeNodeState.d.ts +2 -2
  12. package/dist/types/src/hooks/useComputeNodeState.d.ts.map +1 -1
  13. package/dist/types/src/hooks/useGraphMonitor.d.ts +2 -2
  14. package/dist/types/src/hooks/useGraphMonitor.d.ts.map +1 -1
  15. package/dist/types/src/shapes/Function.d.ts.map +1 -1
  16. package/dist/types/src/shapes/Gpt.d.ts.map +1 -1
  17. package/dist/types/src/shapes/Queue.d.ts.map +1 -1
  18. package/dist/types/src/shapes/RNG.d.ts.map +1 -1
  19. package/dist/types/src/shapes/Surface.d.ts.map +1 -1
  20. package/dist/types/src/shapes/Thread.d.ts.map +1 -1
  21. package/dist/types/src/shapes/Trigger.d.ts +6 -4
  22. package/dist/types/src/shapes/Trigger.d.ts.map +1 -1
  23. package/dist/types/src/shapes/common/Box.d.ts +4 -4
  24. package/dist/types/src/shapes/common/Box.d.ts.map +1 -1
  25. package/dist/types/src/shapes/common/FunctionBody.d.ts +2 -2
  26. package/dist/types/src/shapes/common/FunctionBody.d.ts.map +1 -1
  27. package/dist/types/src/testing/circuits.d.ts +18 -24
  28. package/dist/types/src/testing/circuits.d.ts.map +1 -1
  29. package/dist/types/tsconfig.tsbuildinfo +1 -1
  30. package/package.json +59 -54
  31. package/src/README.md +0 -3
  32. package/src/compute.stories.tsx +72 -113
  33. package/src/graph/controller.ts +109 -71
  34. package/src/graph/node-defs.ts +31 -31
  35. package/src/hooks/useComputeNodeState.ts +4 -3
  36. package/src/hooks/useGraphMonitor.ts +11 -10
  37. package/src/json.test.ts +3 -3
  38. package/src/schema.test.ts +11 -11
  39. package/src/shapes/Function.tsx +10 -8
  40. package/src/shapes/Gpt.tsx +6 -1
  41. package/src/shapes/Queue.tsx +15 -9
  42. package/src/shapes/RNG.tsx +5 -1
  43. package/src/shapes/Surface.tsx +9 -3
  44. package/src/shapes/Table.tsx +3 -3
  45. package/src/shapes/Thread.tsx +17 -11
  46. package/src/shapes/Trigger.tsx +33 -44
  47. package/src/shapes/common/Box.tsx +5 -6
  48. package/src/shapes/common/FunctionBody.tsx +2 -2
  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, (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
  };
@@ -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,64 +305,51 @@ 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
  });
347
351
 
348
352
  // src/graph/controller.ts
349
- function _define_property(obj, key, value) {
350
- if (key in obj) {
351
- Object.defineProperty(obj, key, {
352
- value,
353
- enumerable: true,
354
- configurable: true,
355
- writable: true
356
- });
357
- } else {
358
- obj[key] = value;
359
- }
360
- return obj;
361
- }
362
353
  function _ts_decorate(decorators, target, key, desc) {
363
354
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
364
355
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -372,15 +363,38 @@ var AUTO_TRIGGER_NODES = [
372
363
  "switch",
373
364
  "constant"
374
365
  ];
375
- var createComputeGraphController = (graph, serviceContainer) => {
366
+ var createComputeGraphController = (graph, computeRuntime) => {
376
367
  const computeGraph = createComputeGraph(graph);
377
- const controller = new ComputeGraphController(serviceContainer, computeGraph);
368
+ const controller = new ComputeGraphController(computeRuntime, computeGraph);
378
369
  return {
379
370
  controller,
380
371
  graph
381
372
  };
382
373
  };
383
374
  var ComputeGraphController = class extends Resource {
375
+ _computeRuntime;
376
+ _graph;
377
+ _executor = new GraphExecutor({
378
+ computeNodeResolver: (node) => resolveComputeNode(node)
379
+ });
380
+ _diagnostics = [];
381
+ /**
382
+ * Canvas force-sets outputs of those nodes.
383
+ */
384
+ _forcedOutputs = {};
385
+ /**
386
+ * Runtime state of the execution graph.
387
+ */
388
+ _runtimeStateInputs = {};
389
+ _runtimeStateOutputs = {};
390
+ // TODO(burdon): Remove? Make state reactive?
391
+ update = new Event();
392
+ /** Computed result. */
393
+ output = new Event();
394
+ events = new Event();
395
+ constructor(_computeRuntime, _graph) {
396
+ super(), this._computeRuntime = _computeRuntime, this._graph = _graph;
397
+ }
384
398
  toJSON() {
385
399
  return {
386
400
  graph: this._graph,
@@ -441,8 +455,7 @@ var ComputeGraphController = class extends Resource {
441
455
  return this._runtimeStateOutputs[nodeId] ?? {};
442
456
  }
443
457
  setOutput(nodeId, property, value) {
444
- var _this__forcedOutputs, _nodeId;
445
- (_this__forcedOutputs = this._forcedOutputs)[_nodeId = nodeId] ?? (_this__forcedOutputs[_nodeId] = {});
458
+ this._forcedOutputs[nodeId] ??= {};
446
459
  this._forcedOutputs[nodeId][property] = value;
447
460
  queueMicrotask(async () => {
448
461
  try {
@@ -450,7 +463,7 @@ var ComputeGraphController = class extends Resource {
450
463
  } catch (err) {
451
464
  log.catch(err, void 0, {
452
465
  F: __dxlog_file4,
453
- L: 203,
466
+ L: 230,
454
467
  S: this,
455
468
  C: (f, a) => f(...a)
456
469
  });
@@ -472,12 +485,11 @@ var ComputeGraphController = class extends Resource {
472
485
  for (const [nodeId2, outputs] of Object.entries(this._forcedOutputs)) {
473
486
  executor.setOutputs(nodeId2, Effect.succeed(ValueBag.make(outputs)));
474
487
  }
475
- const serviceLayer = this._serviceContainer.createLayer();
476
- await Effect.runPromise(Effect.gen(this, function* () {
488
+ unwrapExit(await this._computeRuntime.runPromiseExit(Effect.gen(this, function* () {
477
489
  const scope = yield* Scope.make();
478
490
  const executable = yield* Effect.promise(() => resolveComputeNode(this._graph.getNode(nodeId)));
479
491
  const computingOutputs = executable.exec != null;
480
- 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) => {
481
493
  for (const [key, value] of Object.entries(values)) {
482
494
  if (computingOutputs) {
483
495
  this._onOutputComputed(nodeId, key, value);
@@ -488,7 +500,7 @@ var ComputeGraphController = class extends Resource {
488
500
  }));
489
501
  yield* effect;
490
502
  yield* Scope.close(scope, Exit.void);
491
- }));
503
+ })));
492
504
  this.update.emit();
493
505
  }
494
506
  /**
@@ -509,13 +521,13 @@ var ComputeGraphController = class extends Resource {
509
521
  const allAffectedNodes = [
510
522
  ...new Set(triggerNodes.flatMap((node) => executor.getAllDependantNodes(node.id)))
511
523
  ];
512
- await Effect.runPromise(Effect.gen(this, function* () {
524
+ unwrapExit(await this._computeRuntime.runPromiseExit(Effect.gen(this, function* () {
513
525
  const scope = yield* Scope.make();
514
526
  const tasks = [];
515
527
  for (const node of allAffectedNodes) {
516
528
  const executable = yield* Effect.promise(() => resolveComputeNode(this._graph.getNode(node)));
517
529
  const computingOutputs = executable.exec != null;
518
- 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) => {
519
531
  for (const [key, value] of Object.entries(values)) {
520
532
  if (computingOutputs) {
521
533
  this._onOutputComputed(node, key, value);
@@ -528,7 +540,7 @@ var ComputeGraphController = class extends Resource {
528
540
  }
529
541
  yield* Effect.all(tasks);
530
542
  yield* Scope.close(scope, Exit.void);
531
- }));
543
+ })));
532
544
  this.update.emit();
533
545
  }
534
546
  _createLogger() {
@@ -544,7 +556,7 @@ var ComputeGraphController = class extends Resource {
544
556
  event
545
557
  }, {
546
558
  F: __dxlog_file4,
547
- L: 339,
559
+ L: 377,
548
560
  S: this,
549
561
  C: (f, a) => f(...a)
550
562
  });
@@ -567,13 +579,11 @@ var ComputeGraphController = class extends Resource {
567
579
  this.events.emit(event);
568
580
  }
569
581
  _onInputComputed(nodeId, property, value) {
570
- var _this__runtimeStateInputs, _nodeId;
571
- (_this__runtimeStateInputs = this._runtimeStateInputs)[_nodeId = nodeId] ?? (_this__runtimeStateInputs[_nodeId] = {});
582
+ this._runtimeStateInputs[nodeId] ??= {};
572
583
  this._runtimeStateInputs[nodeId][property] = value;
573
584
  }
574
585
  _onOutputComputed(nodeId, property, value) {
575
- var _this__runtimeStateOutputs, _nodeId;
576
- (_this__runtimeStateOutputs = this._runtimeStateOutputs)[_nodeId = nodeId] ?? (_this__runtimeStateOutputs[_nodeId] = {});
586
+ this._runtimeStateOutputs[nodeId] ??= {};
577
587
  this._runtimeStateOutputs[nodeId][property] = value;
578
588
  this.output.emit({
579
589
  nodeId,
@@ -581,19 +591,6 @@ var ComputeGraphController = class extends Resource {
581
591
  value
582
592
  });
583
593
  }
584
- constructor(_serviceContainer, _graph) {
585
- super(), _define_property(this, "_serviceContainer", void 0), _define_property(this, "_graph", void 0), _define_property(this, "_executor", void 0), _define_property(this, "_diagnostics", void 0), /**
586
- * Canvas force-sets outputs of those nodes.
587
- */
588
- _define_property(this, "_forcedOutputs", void 0), /**
589
- * Runtime state of the execution graph.
590
- */
591
- _define_property(this, "_runtimeStateInputs", void 0), _define_property(this, "_runtimeStateOutputs", void 0), // TODO(burdon): Remove? Make state reactive?
592
- _define_property(this, "update", void 0), /** Computed result. */
593
- _define_property(this, "output", void 0), _define_property(this, "events", void 0), this._serviceContainer = _serviceContainer, this._graph = _graph, this._executor = new GraphExecutor({
594
- computeNodeResolver: (node) => resolveComputeNode(node)
595
- }), this._diagnostics = [], this._forcedOutputs = {}, this._runtimeStateInputs = {}, this._runtimeStateOutputs = {}, this.update = new Event(), this.output = new Event(), this.events = new Event();
596
- }
597
594
  };
598
595
  _ts_decorate([
599
596
  synchronized
@@ -636,78 +633,71 @@ var computeValueBag = (bag) => {
636
633
  import { noteShape } from "@dxos/react-ui-canvas-editor";
637
634
 
638
635
  // src/shapes/common/Box.tsx
639
- import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
640
636
  import React, { forwardRef } from "react";
641
637
  import { invariant as invariant4 } from "@dxos/invariant";
642
638
  import { Icon, IconButton } from "@dxos/react-ui";
643
639
  import { useEditorContext, useShapeDef } from "@dxos/react-ui-canvas-editor";
644
- import { mx } from "@dxos/react-ui-theme";
640
+ import { mx } from "@dxos/ui-theme";
645
641
  var __dxlog_file5 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/common/Box.tsx";
646
642
  var headerHeight = 32;
647
643
  var footerHeight = 32;
648
644
  var Box = /* @__PURE__ */ forwardRef(({ children, classNames, shape, title, status, open, onAction }, forwardedRef) => {
649
- var _effect = _useSignals();
650
- try {
651
- invariant4(shape.type, void 0, {
652
- F: __dxlog_file5,
653
- L: 30,
654
- S: void 0,
655
- A: [
656
- "shape.type",
657
- ""
658
- ]
659
- });
660
- const { icon, name, openable } = useShapeDef(shape.type) ?? {
661
- icon: "ph--placeholder--regular"
662
- };
663
- const { debug } = useEditorContext();
664
- return /* @__PURE__ */ React.createElement("div", {
665
- ref: forwardedRef,
666
- className: "flex flex-col h-full w-full justify-between"
667
- }, /* @__PURE__ */ React.createElement("div", {
668
- className: "flex shrink-0 w-full justify-between items-center h-[32px] bg-hoverSurface"
669
- }, /* @__PURE__ */ React.createElement(Icon, {
670
- icon,
671
- classNames: "mx-2"
672
- }), /* @__PURE__ */ React.createElement("div", {
673
- className: "grow text-sm truncate"
674
- }, debug ? shape.type : name ?? shape.text ?? title), /* @__PURE__ */ React.createElement(IconButton, {
675
- classNames: "p-1 text-green-500",
676
- variant: "ghost",
677
- icon: "ph--play--regular",
678
- size: 4,
679
- label: "run",
680
- iconOnly: true,
681
- onDoubleClick: (ev) => ev.stopPropagation(),
682
- onClick: (ev) => {
683
- ev.stopPropagation();
684
- onAction?.("run");
685
- }
686
- })), /* @__PURE__ */ React.createElement("div", {
687
- className: mx("flex flex-col h-full grow overflow-hidden", classNames)
688
- }, children), /* @__PURE__ */ React.createElement("div", {
689
- className: "flex shrink-0 w-full justify-between items-center h-[32px] bg-hoverSurface"
690
- }, /* @__PURE__ */ React.createElement("div", {
691
- className: "grow px-2 text-sm truncate"
692
- }, debug ? shape.id : status), openable && /* @__PURE__ */ React.createElement(IconButton, {
693
- classNames: "p-1",
694
- variant: "ghost",
695
- icon: open ? "ph--caret-up--regular" : "ph--caret-down--regular",
696
- size: 4,
697
- label: open ? "close" : "open",
698
- iconOnly: true,
699
- onClick: (ev) => {
700
- ev.stopPropagation();
701
- onAction?.(open ? "close" : "open");
702
- }
703
- })));
704
- } finally {
705
- _effect.f();
706
- }
645
+ invariant4(shape.type, void 0, {
646
+ F: __dxlog_file5,
647
+ L: 29,
648
+ S: void 0,
649
+ A: [
650
+ "shape.type",
651
+ ""
652
+ ]
653
+ });
654
+ const { icon, name, openable } = useShapeDef(shape.type) ?? {
655
+ icon: "ph--placeholder--regular"
656
+ };
657
+ const { debug } = useEditorContext();
658
+ return /* @__PURE__ */ React.createElement("div", {
659
+ ref: forwardedRef,
660
+ className: "flex flex-col h-full w-full justify-between"
661
+ }, /* @__PURE__ */ React.createElement("div", {
662
+ className: "flex shrink-0 w-full justify-between items-center h-[32px] bg-input-surface"
663
+ }, /* @__PURE__ */ React.createElement(Icon, {
664
+ icon,
665
+ classNames: "mx-2"
666
+ }), /* @__PURE__ */ React.createElement("div", {
667
+ className: "grow text-sm truncate"
668
+ }, debug ? shape.type : name ?? shape.text ?? title), /* @__PURE__ */ React.createElement(IconButton, {
669
+ classNames: "p-1 text-green-500",
670
+ variant: "ghost",
671
+ icon: "ph--play--regular",
672
+ size: 4,
673
+ label: "run",
674
+ iconOnly: true,
675
+ onDoubleClick: (ev) => ev.stopPropagation(),
676
+ onClick: (ev) => {
677
+ ev.stopPropagation();
678
+ onAction?.("run");
679
+ }
680
+ })), /* @__PURE__ */ React.createElement("div", {
681
+ className: mx("flex flex-col h-full grow overflow-hidden", classNames)
682
+ }, children), /* @__PURE__ */ React.createElement("div", {
683
+ className: "flex shrink-0 w-full justify-between items-center h-[32px] bg-input-surface"
684
+ }, /* @__PURE__ */ React.createElement("div", {
685
+ className: "grow px-2 text-sm truncate"
686
+ }, debug ? shape.id : status), openable && /* @__PURE__ */ React.createElement(IconButton, {
687
+ classNames: "p-1",
688
+ variant: "ghost",
689
+ icon: open ? "ph--caret-up--regular" : "ph--caret-down--regular",
690
+ size: 4,
691
+ label: open ? "close" : "open",
692
+ iconOnly: true,
693
+ onClick: (ev) => {
694
+ ev.stopPropagation();
695
+ onAction?.(open ? "close" : "open");
696
+ }
697
+ })));
707
698
  });
708
699
 
709
700
  // src/shapes/common/FunctionBody.tsx
710
- import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
711
701
  import * as SchemaAST2 from "effect/SchemaAST";
712
702
  import React2, { useRef, useState as useState3 } from "react";
713
703
  import { VoidInput, VoidOutput } from "@dxos/conductor";
@@ -718,7 +708,7 @@ import { createAnchors, getParentShapeElement, rowHeight } from "@dxos/react-ui-
718
708
  import * as Schema2 from "effect/Schema";
719
709
  import * as SchemaAST from "effect/SchemaAST";
720
710
  import { DEFAULT_INPUT as DEFAULT_INPUT2, DEFAULT_OUTPUT as DEFAULT_OUTPUT2 } from "@dxos/conductor";
721
- import { ObjectId as ObjectId3 } from "@dxos/echo/internal";
711
+ import { Obj as Obj3 } from "@dxos/echo";
722
712
  import { Polygon } from "@dxos/react-ui-canvas-editor";
723
713
  var getProperties = (ast) => SchemaAST.getPropertySignatures(ast).map(({ name }) => ({
724
714
  name: name.toString()
@@ -736,13 +726,13 @@ var parseAnchorId = (id) => {
736
726
  };
737
727
  var ComputeShape = Schema2.extend(Polygon, Schema2.Struct({
738
728
  // TODO(burdon): Rename computeNode?
739
- node: Schema2.optional(ObjectId3.annotations({
729
+ node: Schema2.optional(Obj3.ID.annotations({
740
730
  description: "Compute node id"
741
731
  }))
742
732
  }).pipe(Schema2.mutable));
743
733
  var createShape = ({ id, ...rest }) => {
744
734
  return {
745
- id: id ?? ObjectId3.random(),
735
+ id: id ?? Obj3.ID.random(),
746
736
  ...rest
747
737
  };
748
738
  };
@@ -751,70 +741,65 @@ var createShape = ({ id, ...rest }) => {
751
741
  var bodyPadding = 8;
752
742
  var expandedHeight = 200;
753
743
  var FunctionBody = ({ shape, name, content, inputSchema = VoidInput, outputSchema = VoidOutput, ...props }) => {
754
- var _effect = _useSignals2();
755
- try {
756
- const { scale } = useCanvasContext();
757
- const rootRef = useRef(null);
758
- const [open, setOpen] = useState3(false);
759
- const handleAction = (action) => {
760
- if (!rootRef.current) {
761
- return;
762
- }
763
- switch (action) {
764
- case "open": {
765
- const el = getParentShapeElement(rootRef.current, shape.id);
766
- const { height } = el.getBoundingClientRect();
767
- el.style.height = `${height / scale + expandedHeight}px`;
768
- setOpen(true);
769
- break;
770
- }
771
- case "close": {
772
- const el = getParentShapeElement(rootRef.current, shape.id);
773
- el.style.height = "";
774
- setOpen(false);
775
- break;
776
- }
777
- }
778
- };
779
- const inputs = getProperties(inputSchema.ast);
780
- const outputs = getProperties(outputSchema.ast);
781
- const columnCount = inputs.length && outputs.length ? 2 : 1;
782
- return /* @__PURE__ */ React2.createElement(Box, {
783
- ref: rootRef,
784
- shape,
785
- title: name,
786
- classNames: "divide-y divide-separator",
787
- open,
788
- onAction: handleAction,
789
- ...props
790
- }, /* @__PURE__ */ React2.createElement("div", {
791
- className: `grid grid-cols-${columnCount} items-center`,
792
- style: {
793
- paddingTop: bodyPadding,
794
- paddingBottom: bodyPadding
795
- }
796
- }, (inputs?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement("div", {
797
- className: "flex flex-col"
798
- }, inputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
799
- key: name2,
800
- className: "px-2 truncate text-sm font-mono items-center",
801
- style: {
802
- 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;
803
758
  }
804
- }, name2))), (outputs?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement("div", {
805
- className: "flex flex-col"
806
- }, outputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
807
- key: name2,
808
- className: "px-2 truncate text-sm font-mono items-center text-right",
809
- style: {
810
- height: rowHeight
759
+ case "close": {
760
+ const el = getParentShapeElement(rootRef.current, shape.id);
761
+ el.style.height = "";
762
+ setOpen(false);
763
+ break;
811
764
  }
812
- }, name2)))), open && /* @__PURE__ */ React2.createElement("div", {
813
- className: "flex flex-col grow overflow-hidden"
814
- }, content));
815
- } finally {
816
- _effect.f();
817
- }
765
+ }
766
+ };
767
+ const inputs = getProperties(inputSchema.ast);
768
+ const outputs = getProperties(outputSchema.ast);
769
+ const columnCount = inputs.length && outputs.length ? 2 : 1;
770
+ return /* @__PURE__ */ React2.createElement(Box, {
771
+ ref: rootRef,
772
+ shape,
773
+ title: name,
774
+ classNames: "divide-y divide-separator",
775
+ open,
776
+ onAction: handleAction,
777
+ ...props
778
+ }, /* @__PURE__ */ React2.createElement("div", {
779
+ className: `grid grid-cols-${columnCount} items-center`,
780
+ style: {
781
+ paddingTop: bodyPadding,
782
+ paddingBottom: bodyPadding
783
+ }
784
+ }, (inputs?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement("div", {
785
+ className: "flex flex-col"
786
+ }, inputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
787
+ key: name2,
788
+ className: "px-2 truncate text-sm font-mono items-center",
789
+ style: {
790
+ height: rowHeight
791
+ }
792
+ }, name2))), (outputs?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement("div", {
793
+ className: "flex flex-col"
794
+ }, outputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
795
+ key: name2,
796
+ className: "px-2 truncate text-sm font-mono items-center text-right",
797
+ style: {
798
+ height: rowHeight
799
+ }
800
+ }, name2)))), open && /* @__PURE__ */ React2.createElement("div", {
801
+ className: "flex flex-col grow overflow-hidden"
802
+ }, content));
818
803
  };
819
804
  var getHeight = (input) => {
820
805
  const properties = SchemaAST2.getPropertySignatures(input.ast);
@@ -835,30 +820,23 @@ var createFunctionAnchors = (shape, input = VoidInput, output = VoidOutput) => {
835
820
  };
836
821
 
837
822
  // src/shapes/common/TypeSelect.tsx
838
- import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
839
823
  import React3 from "react";
840
824
  import { ComputeValueType } from "@dxos/conductor";
841
825
  import { Select } from "@dxos/react-ui";
842
826
  var TypeSelect = ({ value, onValueChange }) => {
843
- var _effect = _useSignals3();
844
- try {
845
- return /* @__PURE__ */ React3.createElement(Select.Root, {
846
- value,
847
- onValueChange
848
- }, /* @__PURE__ */ React3.createElement(Select.TriggerButton, {
849
- variant: "ghost",
850
- classNames: "w-full !px-0"
851
- }), /* @__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, {
852
- key: type,
853
- value: type
854
- }, type))), /* @__PURE__ */ React3.createElement(Select.ScrollDownButton, null), /* @__PURE__ */ React3.createElement(Select.Arrow, null))));
855
- } finally {
856
- _effect.f();
857
- }
827
+ return /* @__PURE__ */ React3.createElement(Select.Root, {
828
+ value,
829
+ onValueChange
830
+ }, /* @__PURE__ */ React3.createElement(Select.TriggerButton, {
831
+ variant: "ghost",
832
+ classNames: "w-full px-0!"
833
+ }), /* @__PURE__ */ React3.createElement(Select.Portal, null, /* @__PURE__ */ React3.createElement(Select.Content, null, /* @__PURE__ */ React3.createElement(Select.ScrollUpButton, null), /* @__PURE__ */ React3.createElement(Select.Viewport, null, ComputeValueType.literals.map((type) => /* @__PURE__ */ React3.createElement(Select.Option, {
834
+ key: type,
835
+ value: type
836
+ }, type))), /* @__PURE__ */ React3.createElement(Select.ScrollDownButton, null), /* @__PURE__ */ React3.createElement(Select.Arrow, null))));
858
837
  };
859
838
 
860
839
  // src/shapes/Array.tsx
861
- import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
862
840
  import * as Schema3 from "effect/Schema";
863
841
  import React4 from "react";
864
842
  import { ReducerInput, ReducerOutput } from "@dxos/conductor";
@@ -866,16 +844,11 @@ var ReducerShape = Schema3.extend(ComputeShape, Schema3.Struct({
866
844
  type: Schema3.Literal("reducer")
867
845
  }));
868
846
  var ReducerComponent = ({ shape }) => {
869
- var _effect = _useSignals4();
870
- try {
871
- return /* @__PURE__ */ React4.createElement(FunctionBody, {
872
- shape,
873
- inputSchema: ReducerInput,
874
- outputSchema: ReducerOutput
875
- });
876
- } finally {
877
- _effect.f();
878
- }
847
+ return /* @__PURE__ */ React4.createElement(FunctionBody, {
848
+ shape,
849
+ inputSchema: ReducerInput,
850
+ outputSchema: ReducerOutput
851
+ });
879
852
  };
880
853
  var createReducer = ({ id, size = {
881
854
  width: 192,
@@ -895,7 +868,6 @@ var reducerShape = {
895
868
  };
896
869
 
897
870
  // src/shapes/Append.tsx
898
- import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
899
871
  import * as Schema4 from "effect/Schema";
900
872
  import React5 from "react";
901
873
  import { AppendInput } from "@dxos/conductor";
@@ -911,15 +883,10 @@ var createAppend = (props) => createShape({
911
883
  ...props
912
884
  });
913
885
  var AppendComponent = ({ shape }) => {
914
- var _effect = _useSignals5();
915
- try {
916
- return /* @__PURE__ */ React5.createElement(FunctionBody, {
917
- shape,
918
- inputSchema: AppendInput
919
- });
920
- } finally {
921
- _effect.f();
922
- }
886
+ return /* @__PURE__ */ React5.createElement(FunctionBody, {
887
+ shape,
888
+ inputSchema: AppendInput
889
+ });
923
890
  };
924
891
  var appendShape = {
925
892
  type: "append",
@@ -931,7 +898,6 @@ var appendShape = {
931
898
  };
932
899
 
933
900
  // src/shapes/Audio.tsx
934
- import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
935
901
  import * as Schema5 from "effect/Schema";
936
902
  import React6, { useEffect as useEffect3, useState as useState4 } from "react";
937
903
  import { Icon as Icon2 } from "@dxos/react-ui";
@@ -948,29 +914,24 @@ var createAudio = (props) => createShape({
948
914
  ...props
949
915
  });
950
916
  var AudioComponent = ({ shape }) => {
951
- var _effect = _useSignals6();
952
- try {
953
- const { node } = useComputeNodeState(shape);
954
- const [active, setActive] = useState4(false);
955
- useEffect3(() => {
956
- node.value = active;
957
- }, [
958
- active
959
- ]);
960
- return /* @__PURE__ */ React6.createElement("div", {
961
- className: "flex w-full justify-center items-center"
962
- }, /* @__PURE__ */ React6.createElement(Icon2, {
963
- icon: active ? "ph--microphone--regular" : "ph--microphone-slash--regular",
964
- classNames: [
965
- "transition opacity-20 duration-1000",
966
- active && "opacity-100 text-red-500"
967
- ],
968
- size: 8,
969
- onClick: () => setActive(!active)
970
- }));
971
- } finally {
972
- _effect.f();
973
- }
917
+ const { node } = useComputeNodeState(shape);
918
+ const [active, setActive] = useState4(false);
919
+ useEffect3(() => {
920
+ node.value = active;
921
+ }, [
922
+ active
923
+ ]);
924
+ return /* @__PURE__ */ React6.createElement("div", {
925
+ className: "flex w-full justify-center items-center"
926
+ }, /* @__PURE__ */ React6.createElement(Icon2, {
927
+ icon: active ? "ph--microphone--regular" : "ph--microphone-slash--regular",
928
+ classNames: [
929
+ "transition opacity-20 duration-1000",
930
+ active && "opacity-100 text-red-500"
931
+ ],
932
+ size: 8,
933
+ onClick: () => setActive(!active)
934
+ }));
974
935
  };
975
936
  var audioShape = {
976
937
  type: "audio",
@@ -987,7 +948,6 @@ var audioShape = {
987
948
  };
988
949
 
989
950
  // src/shapes/Beacon.tsx
990
- import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
991
951
  import * as Schema6 from "effect/Schema";
992
952
  import React7 from "react";
993
953
  import { DEFAULT_INPUT as DEFAULT_INPUT3, isTruthy } from "@dxos/conductor";
@@ -1005,24 +965,19 @@ var createBeacon = (props) => createShape({
1005
965
  ...props
1006
966
  });
1007
967
  var BeaconComponent = ({ shape }) => {
1008
- var _effect = _useSignals7();
1009
- try {
1010
- const { runtime } = useComputeNodeState(shape);
1011
- const input = runtime.inputs[DEFAULT_INPUT3];
1012
- const value = input?.type === "executed" ? input.value : false;
1013
- return /* @__PURE__ */ React7.createElement("div", {
1014
- className: "flex w-full justify-center items-center"
1015
- }, /* @__PURE__ */ React7.createElement(Icon3, {
1016
- icon: "ph--sun--regular",
1017
- classNames: [
1018
- "transition opacity-20 duration-1000",
1019
- isTruthy(value) && "opacity-100 text-yellow-500"
1020
- ],
1021
- size: 8
1022
- }));
1023
- } finally {
1024
- _effect.f();
1025
- }
968
+ const { runtime } = useComputeNodeState(shape);
969
+ const input = runtime.inputs[DEFAULT_INPUT3];
970
+ const value = input?.type === "executed" ? input.value : false;
971
+ return /* @__PURE__ */ React7.createElement("div", {
972
+ className: "flex w-full justify-center items-center"
973
+ }, /* @__PURE__ */ React7.createElement(Icon3, {
974
+ icon: "ph--sun--regular",
975
+ classNames: [
976
+ "transition opacity-20 duration-1000",
977
+ isTruthy(value) && "opacity-100 text-yellow-500"
978
+ ],
979
+ size: 8
980
+ }));
1026
981
  };
1027
982
  var beaconShape = {
1028
983
  type: "beacon",
@@ -1212,7 +1167,6 @@ var notShape = defineShape({
1212
1167
  });
1213
1168
 
1214
1169
  // src/shapes/Chat.tsx
1215
- import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
1216
1170
  import * as Schema8 from "effect/Schema";
1217
1171
  import React9, { useRef as useRef2 } from "react";
1218
1172
  import { DEFAULT_OUTPUT as DEFAULT_OUTPUT3 } from "@dxos/conductor";
@@ -1222,28 +1176,23 @@ var ChatShape = Schema8.extend(ComputeShape, Schema8.Struct({
1222
1176
  type: Schema8.Literal("chat")
1223
1177
  }));
1224
1178
  var TextInputComponent = ({ shape, title, ...props }) => {
1225
- var _effect = _useSignals8();
1226
- try {
1227
- const { runtime } = useComputeNodeState(shape);
1228
- const inputRef = useRef2(null);
1229
- const handleEnter = (text) => {
1230
- const value = text.trim();
1231
- if (value.length) {
1232
- runtime.setOutput(DEFAULT_OUTPUT3, value);
1233
- inputRef.current?.setText("");
1234
- }
1235
- };
1236
- return /* @__PURE__ */ React9.createElement(Box, {
1237
- shape,
1238
- title
1239
- }, /* @__PURE__ */ React9.createElement(TextBox, {
1240
- ref: inputRef,
1241
- onEnter: handleEnter,
1242
- ...props
1243
- }));
1244
- } finally {
1245
- _effect.f();
1246
- }
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
+ }));
1247
1196
  };
1248
1197
  var createChat = (props) => createShape({
1249
1198
  type: "chat",
@@ -1273,7 +1222,6 @@ var chatShape = {
1273
1222
  };
1274
1223
 
1275
1224
  // src/shapes/Constant.tsx
1276
- import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
1277
1225
  import * as Schema9 from "effect/Schema";
1278
1226
  import React10, { useCallback as useCallback2, useRef as useRef3, useState as useState5 } from "react";
1279
1227
  import { ComputeValueType as ComputeValueType2 } from "@dxos/conductor";
@@ -1297,57 +1245,52 @@ var inferType = (value) => {
1297
1245
  }
1298
1246
  };
1299
1247
  var ConstantComponent = ({ shape, title, chat, ...props }) => {
1300
- var _effect = _useSignals9();
1301
- try {
1302
- const { node } = useComputeNodeState(shape);
1303
- const [type, setType] = useState5(inferType(node.value) ?? ComputeValueType2.literals[0]);
1304
- const inputRef = useRef3(null);
1305
- const handleEnter = useCallback2((text) => {
1306
- const value = text.trim();
1307
- if (value.length) {
1308
- if (type === "number") {
1309
- const floatValue = parseFloat(value);
1310
- if (!isNaN(floatValue)) {
1311
- node.value = floatValue;
1312
- }
1313
- } else if (type === "object") {
1314
- node.value = safeParseJson(value, {});
1315
- } else {
1316
- 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;
1317
1258
  }
1318
- inputRef.current?.focus();
1319
- }
1320
- }, [
1321
- type
1322
- ]);
1323
- return /* @__PURE__ */ React10.createElement(Box, {
1324
- shape,
1325
- title,
1326
- status: /* @__PURE__ */ React10.createElement(TypeSelect, {
1327
- value: type,
1328
- onValueChange: setType
1329
- })
1330
- }, (type === "string" || type === "number") && /* @__PURE__ */ React10.createElement(TextBox2, {
1331
- ...props,
1332
- ref: inputRef,
1333
- value: node.value,
1334
- onEnter: handleEnter
1335
- }), type === "object" && /* @__PURE__ */ React10.createElement(TextBox2, {
1336
- ...props,
1337
- ref: inputRef,
1338
- value: JSON.stringify(node.value, null, 2),
1339
- language: "json"
1340
- }), type === "boolean" && /* @__PURE__ */ React10.createElement("div", {
1341
- className: "flex grow justify-center items-center"
1342
- }, /* @__PURE__ */ React10.createElement(Input.Root, null, /* @__PURE__ */ React10.createElement(Input.Switch, {
1343
- checked: node.value,
1344
- onCheckedChange: (value) => {
1259
+ } else if (type === "object") {
1260
+ node.value = safeParseJson(value, {});
1261
+ } else {
1345
1262
  node.value = value;
1346
1263
  }
1347
- }))));
1348
- } finally {
1349
- _effect.f();
1350
- }
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
+ }))));
1351
1294
  };
1352
1295
  var createConstant = (props) => createShape({
1353
1296
  type: "constant",
@@ -1376,7 +1319,6 @@ var constantShape = {
1376
1319
  };
1377
1320
 
1378
1321
  // src/shapes/Database.tsx
1379
- import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
1380
1322
  import * as Schema10 from "effect/Schema";
1381
1323
  import React11 from "react";
1382
1324
  import { createAnchorMap as createAnchorMap5 } from "@dxos/react-ui-canvas-editor";
@@ -1392,14 +1334,9 @@ var createDatabase = (props) => createShape({
1392
1334
  ...props
1393
1335
  });
1394
1336
  var DatabaseComponent = ({ shape }) => {
1395
- var _effect = _useSignals10();
1396
- try {
1397
- return /* @__PURE__ */ React11.createElement(Box, {
1398
- shape
1399
- });
1400
- } finally {
1401
- _effect.f();
1402
- }
1337
+ return /* @__PURE__ */ React11.createElement(Box, {
1338
+ shape
1339
+ });
1403
1340
  };
1404
1341
  var databaseShape = {
1405
1342
  type: "database",
@@ -1416,12 +1353,11 @@ var databaseShape = {
1416
1353
  };
1417
1354
 
1418
1355
  // src/shapes/Function.tsx
1419
- import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
1420
1356
  import * as Schema11 from "effect/Schema";
1421
1357
  import React12, { useCallback as useCallback3, useRef as useRef4 } from "react";
1422
1358
  import { AnyOutput, FunctionInput } from "@dxos/conductor";
1423
1359
  import { Ref as Ref2, getSnapshot, isInstanceOf } from "@dxos/echo/internal";
1424
- import { FunctionType, ScriptType } from "@dxos/functions";
1360
+ import { Function, Script } from "@dxos/functions";
1425
1361
  import { useClient } from "@dxos/react-client";
1426
1362
  import { Filter, parseId } from "@dxos/react-client/echo";
1427
1363
  import { TextBox as TextBox3 } from "@dxos/react-ui-canvas-editor";
@@ -1437,59 +1373,54 @@ var createFunction = (props) => createShape({
1437
1373
  ...props
1438
1374
  });
1439
1375
  var TextInputComponent2 = ({ shape, title, ...props }) => {
1440
- var _effect = _useSignals11();
1441
- try {
1442
- const client = useClient();
1443
- const { node, runtime } = useComputeNodeState(shape);
1444
- const inputRef = useRef4(null);
1445
- const handleEnter = useCallback3(async (text) => {
1446
- const value = text.trim();
1447
- const { spaceId, objectId } = parseId(value);
1448
- if (!spaceId || !objectId) {
1449
- return;
1450
- }
1451
- const space = client.spaces.get(spaceId);
1452
- const object = space?.db.getObjectById(objectId);
1453
- if (!space || !isInstanceOf(ScriptType, object)) {
1454
- return;
1455
- }
1456
- const { objects: [fn] } = await space.db.query(Filter.type(FunctionType, {
1457
- source: Ref2.make(object)
1458
- })).run();
1459
- if (!fn) {
1460
- return;
1461
- }
1462
- node.value = value;
1463
- node.function = Ref2.make(fn);
1464
- node.inputSchema = getSnapshot(fn.inputSchema);
1465
- node.outputSchema = getSnapshot(fn.outputSchema);
1466
- }, [
1467
- client,
1468
- node
1469
- ]);
1470
- const handleAction = useCallback3((action) => {
1471
- if (action !== "run") {
1472
- return;
1473
- }
1474
- runtime.evalNode();
1475
- }, [
1476
- runtime
1477
- ]);
1478
- return /* @__PURE__ */ React12.createElement(Box, {
1479
- shape,
1480
- title: "Function",
1481
- onAction: handleAction
1482
- }, /* @__PURE__ */ React12.createElement(TextBox3, {
1483
- ...props,
1484
- ref: inputRef,
1485
- value: node.value,
1486
- language: node.valueType === "object" ? "json" : void 0,
1487
- onBlur: handleEnter,
1488
- onEnter: handleEnter
1489
- }));
1490
- } finally {
1491
- _effect.f();
1492
- }
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
+ }));
1493
1424
  };
1494
1425
  var functionShape = {
1495
1426
  type: "function",
@@ -1501,10 +1432,10 @@ var functionShape = {
1501
1432
  };
1502
1433
 
1503
1434
  // src/shapes/Gpt.tsx
1504
- import { useSignals as _useSignals12 } from "@preact-signals/safe-react/tracking";
1505
1435
  import * as Schema12 from "effect/Schema";
1506
1436
  import React13, { useEffect as useEffect4, useState as useState6 } from "react";
1507
1437
  import { GptInput, GptOutput } from "@dxos/conductor";
1438
+ import { ScrollArea } from "@dxos/react-ui";
1508
1439
  var GptShape = Schema12.extend(ComputeShape, Schema12.Struct({
1509
1440
  type: Schema12.Literal("gpt")
1510
1441
  }));
@@ -1517,54 +1448,50 @@ var createGpt = (props) => createShape({
1517
1448
  ...props
1518
1449
  });
1519
1450
  var GptComponent = ({ shape }) => {
1520
- var _effect = _useSignals12();
1521
- try {
1522
- const { meta, runtime } = useComputeNodeState(shape);
1523
- const [text, setText] = useState6("");
1524
- const [tokens, setTokens] = useState6(0);
1525
- useEffect4(() => {
1526
- return runtime.subscribeToEventLog((ev) => {
1527
- switch (ev.type) {
1528
- case "begin-compute": {
1529
- setText("");
1530
- break;
1531
- }
1532
- case "custom": {
1533
- const token = ev.event;
1534
- switch (token.type) {
1535
- case "content_block_delta":
1536
- switch (token.delta.type) {
1537
- case "text_delta": {
1538
- const delta = token.delta.text;
1539
- setText((prev) => {
1540
- const text2 = prev + delta;
1541
- setTokens(text2.split(" ").length);
1542
- return text2;
1543
- });
1544
- break;
1545
- }
1451
+ const { meta, runtime } = useComputeNodeState(shape);
1452
+ const [text, setText] = useState6("");
1453
+ const [tokens, setTokens] = useState6(0);
1454
+ useEffect4(() => {
1455
+ return runtime.subscribeToEventLog((ev) => {
1456
+ switch (ev.type) {
1457
+ case "begin-compute": {
1458
+ setText("");
1459
+ break;
1460
+ }
1461
+ case "custom": {
1462
+ const token = ev.event;
1463
+ switch (token.type) {
1464
+ case "content_block_delta":
1465
+ switch (token.delta.type) {
1466
+ case "text_delta": {
1467
+ const delta = token.delta.text;
1468
+ setText((prev) => {
1469
+ const text2 = prev + delta;
1470
+ setTokens(text2.split(" ").length);
1471
+ return text2;
1472
+ });
1473
+ break;
1546
1474
  }
1547
- break;
1548
- }
1549
- break;
1475
+ }
1476
+ break;
1550
1477
  }
1478
+ break;
1551
1479
  }
1552
- });
1553
- }, [
1554
- runtime?.subscribeToEventLog
1555
- ]);
1556
- return /* @__PURE__ */ React13.createElement(FunctionBody, {
1557
- shape,
1558
- content: /* @__PURE__ */ React13.createElement("div", {
1559
- className: "px-2 py-1 overflow-y-scroll"
1560
- }, text),
1561
- status: `${tokens} tokens`,
1562
- inputSchema: meta.input,
1563
- outputSchema: meta.output
1480
+ }
1564
1481
  });
1565
- } finally {
1566
- _effect.f();
1567
- }
1482
+ }, [
1483
+ runtime?.subscribeToEventLog
1484
+ ]);
1485
+ return /* @__PURE__ */ React13.createElement(FunctionBody, {
1486
+ shape,
1487
+ content: /* @__PURE__ */ React13.createElement(ScrollArea.Root, {
1488
+ orientation: "vertical",
1489
+ thin: true
1490
+ }, /* @__PURE__ */ React13.createElement(ScrollArea.Viewport, null, text)),
1491
+ status: `${tokens} tokens`,
1492
+ inputSchema: meta.input,
1493
+ outputSchema: meta.output
1494
+ });
1568
1495
  };
1569
1496
  var gptShape = {
1570
1497
  type: "gpt",
@@ -1577,7 +1504,6 @@ var gptShape = {
1577
1504
  };
1578
1505
 
1579
1506
  // src/shapes/Json.tsx
1580
- import { useSignals as _useSignals13 } from "@preact-signals/safe-react/tracking";
1581
1507
  import * as Schema13 from "effect/Schema";
1582
1508
  import React14 from "react";
1583
1509
  import { DEFAULT_INPUT as DEFAULT_INPUT4, DefaultOutput, JsonTransformInput } from "@dxos/conductor";
@@ -1590,30 +1516,20 @@ var JsonTransformShape = Schema13.extend(ComputeShape, Schema13.Struct({
1590
1516
  type: Schema13.Literal("json-transform")
1591
1517
  }));
1592
1518
  var JsonComponent = ({ shape, ...props }) => {
1593
- var _effect = _useSignals13();
1594
- try {
1595
- const { runtime } = useComputeNodeState(shape);
1596
- const input = runtime.inputs[DEFAULT_INPUT4];
1597
- const value = input?.type === "executed" ? input.value : void 0;
1598
- return /* @__PURE__ */ React14.createElement(Box, {
1599
- shape
1600
- }, /* @__PURE__ */ React14.createElement(JsonFilter, {
1601
- data: value,
1602
- classNames: "text-xs"
1603
- }));
1604
- } finally {
1605
- _effect.f();
1606
- }
1519
+ const { runtime } = useComputeNodeState(shape);
1520
+ const input = runtime.inputs[DEFAULT_INPUT4];
1521
+ const value = input?.type === "executed" ? input.value : void 0;
1522
+ return /* @__PURE__ */ React14.createElement(Box, {
1523
+ shape
1524
+ }, /* @__PURE__ */ React14.createElement(JsonFilter, {
1525
+ data: value,
1526
+ classNames: "text-xs"
1527
+ }));
1607
1528
  };
1608
1529
  var JsonTransformComponent = ({ shape, ...props }) => {
1609
- var _effect = _useSignals13();
1610
- try {
1611
- return /* @__PURE__ */ React14.createElement(Box, {
1612
- shape
1613
- });
1614
- } finally {
1615
- _effect.f();
1616
- }
1530
+ return /* @__PURE__ */ React14.createElement(Box, {
1531
+ shape
1532
+ });
1617
1533
  };
1618
1534
  var createJson = (props) => createShape({
1619
1535
  type: "json",
@@ -1660,7 +1576,6 @@ var jsonTransformShape = {
1660
1576
  };
1661
1577
 
1662
1578
  // src/shapes/Logic.tsx
1663
- import { useSignals as _useSignals14 } from "@preact-signals/safe-react/tracking";
1664
1579
  import * as Schema14 from "effect/Schema";
1665
1580
  import React15 from "react";
1666
1581
  import { IfElseInput, IfElseOutput, IfInput, IfOutput } from "@dxos/conductor";
@@ -1671,28 +1586,18 @@ var IfElseShape = Schema14.extend(ComputeShape, Schema14.Struct({
1671
1586
  type: Schema14.Literal("if-else")
1672
1587
  }));
1673
1588
  var IfComponent = ({ shape, ...props }) => {
1674
- var _effect = _useSignals14();
1675
- try {
1676
- return /* @__PURE__ */ React15.createElement(FunctionBody, {
1677
- shape,
1678
- inputSchema: IfInput,
1679
- outputSchema: IfOutput
1680
- });
1681
- } finally {
1682
- _effect.f();
1683
- }
1589
+ return /* @__PURE__ */ React15.createElement(FunctionBody, {
1590
+ shape,
1591
+ inputSchema: IfInput,
1592
+ outputSchema: IfOutput
1593
+ });
1684
1594
  };
1685
1595
  var IfElseComponent = ({ shape, ...props }) => {
1686
- var _effect = _useSignals14();
1687
- try {
1688
- return /* @__PURE__ */ React15.createElement(FunctionBody, {
1689
- shape,
1690
- inputSchema: IfElseInput,
1691
- outputSchema: IfElseOutput
1692
- });
1693
- } finally {
1694
- _effect.f();
1695
- }
1596
+ return /* @__PURE__ */ React15.createElement(FunctionBody, {
1597
+ shape,
1598
+ inputSchema: IfElseInput,
1599
+ outputSchema: IfElseOutput
1600
+ });
1696
1601
  };
1697
1602
  var createIf = (props) => createShape({
1698
1603
  type: "if",
@@ -1728,11 +1633,11 @@ var ifElseShape = {
1728
1633
  };
1729
1634
 
1730
1635
  // src/shapes/Queue.tsx
1731
- import { useSignals as _useSignals15 } from "@preact-signals/safe-react/tracking";
1732
1636
  import * as Schema15 from "effect/Schema";
1733
1637
  import React16, { Fragment } from "react";
1734
1638
  import { DEFAULT_OUTPUT as DEFAULT_OUTPUT4, QueueInput, QueueOutput } from "@dxos/conductor";
1735
- import { mx as mx2 } from "@dxos/react-ui-theme";
1639
+ import { ScrollArea as ScrollArea2 } from "@dxos/react-ui";
1640
+ import { mx as mx2 } from "@dxos/ui-theme";
1736
1641
  var QueueShape = Schema15.extend(ComputeShape, Schema15.Struct({
1737
1642
  type: Schema15.Literal("queue")
1738
1643
  }));
@@ -1745,50 +1650,42 @@ var createQueue = (props) => createShape({
1745
1650
  ...props
1746
1651
  });
1747
1652
  var QueueComponent = ({ shape }) => {
1748
- var _effect = _useSignals15();
1749
- try {
1750
- const { runtime } = useComputeNodeState(shape);
1751
- const items = runtime.outputs[DEFAULT_OUTPUT4]?.type === "executed" ? runtime.outputs[DEFAULT_OUTPUT4].value : [];
1752
- const handleAction = (action) => {
1753
- if (action === "run") {
1754
- runtime.evalNode();
1755
- }
1756
- };
1757
- return /* @__PURE__ */ React16.createElement(Box, {
1758
- shape,
1759
- status: `${items.length} items`,
1760
- onAction: handleAction
1761
- }, /* @__PURE__ */ React16.createElement("div", {
1762
- className: "flex flex-col w-full overflow-y-scroll divide-y divide-separator"
1763
- }, [
1764
- ...items
1765
- ].map((item, i) => /* @__PURE__ */ React16.createElement(QueueItem, {
1766
- key: i,
1767
- classNames: "p-1 px-2",
1768
- item
1769
- }))));
1770
- } finally {
1771
- _effect.f();
1772
- }
1653
+ const { runtime } = useComputeNodeState(shape);
1654
+ const items = runtime.outputs[DEFAULT_OUTPUT4]?.type === "executed" ? runtime.outputs[DEFAULT_OUTPUT4].value : [];
1655
+ const handleAction = (action) => {
1656
+ if (action === "run") {
1657
+ runtime.evalNode();
1658
+ }
1659
+ };
1660
+ return /* @__PURE__ */ React16.createElement(Box, {
1661
+ shape,
1662
+ status: `${items.length} items`,
1663
+ onAction: handleAction
1664
+ }, /* @__PURE__ */ React16.createElement(ScrollArea2.Root, {
1665
+ orientation: "vertical"
1666
+ }, /* @__PURE__ */ React16.createElement(ScrollArea2.Viewport, {
1667
+ classNames: "divide-y divide-separator"
1668
+ }, [
1669
+ ...items
1670
+ ].map((item, i) => /* @__PURE__ */ React16.createElement(QueueItem, {
1671
+ key: i,
1672
+ classNames: "p-1 px-2",
1673
+ item
1674
+ })))));
1773
1675
  };
1774
1676
  var QueueItem = ({ classNames, item }) => {
1775
- var _effect = _useSignals15();
1776
- try {
1777
- if (typeof item !== "object") {
1778
- return /* @__PURE__ */ React16.createElement("div", {
1779
- className: mx2(classNames, "whitespace-pre-wrap")
1780
- }, item);
1781
- }
1677
+ if (typeof item !== "object") {
1782
1678
  return /* @__PURE__ */ React16.createElement("div", {
1783
- className: mx2("grid grid-cols-[80px,1fr]", classNames)
1784
- }, Object.entries(item).map(([key, value]) => /* @__PURE__ */ React16.createElement(Fragment, {
1785
- key
1786
- }, /* @__PURE__ */ React16.createElement("div", {
1787
- className: "p-1 text-xs text-subdued"
1788
- }, key), /* @__PURE__ */ React16.createElement("div", null, typeof value === "string" ? value : JSON.stringify(value)))));
1789
- } finally {
1790
- _effect.f();
1679
+ className: mx2(classNames, "whitespace-pre-wrap")
1680
+ }, item);
1791
1681
  }
1682
+ return /* @__PURE__ */ React16.createElement("div", {
1683
+ className: mx2("grid grid-cols-[80px_1fr]", classNames)
1684
+ }, Object.entries(item).map(([key, value]) => /* @__PURE__ */ React16.createElement(Fragment, {
1685
+ key
1686
+ }, /* @__PURE__ */ React16.createElement("div", {
1687
+ className: "p-1 text-xs text-subdued"
1688
+ }, key), /* @__PURE__ */ React16.createElement("div", null, typeof value === "string" ? value : JSON.stringify(value)))));
1792
1689
  };
1793
1690
  var queueShape = {
1794
1691
  type: "queue",
@@ -1801,7 +1698,6 @@ var queueShape = {
1801
1698
  };
1802
1699
 
1803
1700
  // src/shapes/RNG.tsx
1804
- import { useSignals as _useSignals16 } from "@preact-signals/safe-react/tracking";
1805
1701
  import * as Schema16 from "effect/Schema";
1806
1702
  import React17, { useEffect as useEffect5, useState as useState7 } from "react";
1807
1703
  import { DEFAULT_OUTPUT as DEFAULT_OUTPUT5 } from "@dxos/conductor";
@@ -1830,42 +1726,37 @@ var icons = [
1830
1726
  ];
1831
1727
  var pickIcon = () => icons[Math.floor(Math.random() * icons.length)];
1832
1728
  var RandomComponent = ({ shape }) => {
1833
- var _effect = _useSignals16();
1834
- try {
1835
- const { runtime } = useComputeNodeState(shape);
1836
- const [spin, setSpin] = useState7(false);
1837
- const [icon, setIcon] = useState7(pickIcon());
1838
- useEffect5(() => {
1839
- if (!spin) {
1840
- return;
1841
- }
1842
- const i = setInterval(() => setIcon(pickIcon()), 250);
1843
- const t1 = setTimeout(() => clearInterval(i), 900);
1844
- const t2 = setTimeout(() => setSpin(false), 1100);
1845
- return () => {
1846
- clearInterval(i);
1847
- clearTimeout(t1);
1848
- clearTimeout(t2);
1849
- };
1850
- }, [
1851
- spin
1852
- ]);
1853
- const handleClick = (ev) => {
1854
- ev.stopPropagation();
1855
- runtime.setOutput(DEFAULT_OUTPUT5, Math.random());
1856
- setSpin(true);
1729
+ const { runtime } = useComputeNodeState(shape);
1730
+ const [spin, setSpin] = useState7(false);
1731
+ const [icon, setIcon] = useState7(pickIcon());
1732
+ useEffect5(() => {
1733
+ if (!spin) {
1734
+ return;
1735
+ }
1736
+ const i = setInterval(() => setIcon(pickIcon()), 250);
1737
+ const t1 = setTimeout(() => clearInterval(i), 900);
1738
+ const t2 = setTimeout(() => setSpin(false), 1100);
1739
+ return () => {
1740
+ clearInterval(i);
1741
+ clearTimeout(t1);
1742
+ clearTimeout(t2);
1857
1743
  };
1858
- return /* @__PURE__ */ React17.createElement("div", {
1859
- className: "flex grow items-center justify-center"
1860
- }, /* @__PURE__ */ React17.createElement(Icon4, {
1861
- icon,
1862
- classNames: spin && "animate-[spin_1s]",
1863
- size: 10,
1864
- onClick: handleClick
1865
- }));
1866
- } finally {
1867
- _effect.f();
1868
- }
1744
+ }, [
1745
+ spin
1746
+ ]);
1747
+ const handleClick = (ev) => {
1748
+ ev.stopPropagation();
1749
+ runtime.setOutput(DEFAULT_OUTPUT5, Math.random());
1750
+ setSpin(true);
1751
+ };
1752
+ return /* @__PURE__ */ React17.createElement("div", {
1753
+ className: "flex grow items-center justify-center"
1754
+ }, /* @__PURE__ */ React17.createElement(Icon4, {
1755
+ icon,
1756
+ classNames: spin && "animate-[spin_1s]",
1757
+ size: 10,
1758
+ onClick: handleClick
1759
+ }));
1869
1760
  };
1870
1761
  var randomShape = {
1871
1762
  type: "rng",
@@ -1882,7 +1773,6 @@ var randomShape = {
1882
1773
  };
1883
1774
 
1884
1775
  // src/shapes/Scope.tsx
1885
- import { useSignals as _useSignals17 } from "@preact-signals/safe-react/tracking";
1886
1776
  import * as Schema17 from "effect/Schema";
1887
1777
  import React18 from "react";
1888
1778
  import { DEFAULT_INPUT as DEFAULT_INPUT5 } from "@dxos/conductor";
@@ -1901,25 +1791,20 @@ var createScope = (props) => createShape({
1901
1791
  ...props
1902
1792
  });
1903
1793
  var ScopeComponent = ({ shape }) => {
1904
- var _effect = _useSignals17();
1905
- try {
1906
- const { runtime } = useComputeNodeState(shape);
1907
- const input = runtime.inputs[DEFAULT_INPUT5];
1908
- const active = input?.type === "executed" ? input.value : false;
1909
- const { getAverage } = useAudioStream(active);
1910
- return /* @__PURE__ */ React18.createElement("div", {
1911
- className: "flex w-full justify-center items-center bg-black"
1912
- }, /* @__PURE__ */ React18.createElement(Chaos, {
1913
- active,
1914
- getValue: getAverage,
1915
- options: {
1916
- ...shaderPresets.heptapod,
1917
- zoom: 1.2
1918
- }
1919
- }));
1920
- } finally {
1921
- _effect.f();
1922
- }
1794
+ const { runtime } = useComputeNodeState(shape);
1795
+ const input = runtime.inputs[DEFAULT_INPUT5];
1796
+ const active = input?.type === "executed" ? input.value : false;
1797
+ const { getAverage } = useAudioStream(active);
1798
+ return /* @__PURE__ */ React18.createElement("div", {
1799
+ className: "flex w-full justify-center items-center bg-black"
1800
+ }, /* @__PURE__ */ React18.createElement(Chaos, {
1801
+ active,
1802
+ getValue: getAverage,
1803
+ options: {
1804
+ ...shaderPresets.heptapod,
1805
+ zoom: 1.2
1806
+ }
1807
+ }));
1923
1808
  };
1924
1809
  var scopeShape = {
1925
1810
  type: "scope",
@@ -1936,11 +1821,11 @@ var scopeShape = {
1936
1821
  };
1937
1822
 
1938
1823
  // src/shapes/Surface.tsx
1939
- import { useSignals as _useSignals18 } from "@preact-signals/safe-react/tracking";
1940
1824
  import * as Schema18 from "effect/Schema";
1941
1825
  import React19 from "react";
1942
- import { Surface } from "@dxos/app-framework";
1826
+ import { Surface } from "@dxos/app-framework/ui";
1943
1827
  import { DEFAULT_INPUT as DEFAULT_INPUT6 } from "@dxos/conductor";
1828
+ import { Card } from "@dxos/react-ui";
1944
1829
  import { createAnchorMap as createAnchorMap9 } from "@dxos/react-ui-canvas-editor";
1945
1830
  var SurfaceShape = Schema18.extend(ComputeShape, Schema18.Struct({
1946
1831
  type: Schema18.Literal("surface")
@@ -1954,29 +1839,24 @@ var createSurface = (props) => createShape({
1954
1839
  ...props
1955
1840
  });
1956
1841
  var SurfaceComponent = ({ shape }) => {
1957
- var _effect = _useSignals18();
1958
- try {
1959
- const { runtime } = useComputeNodeState(shape);
1960
- const input = runtime.inputs[DEFAULT_INPUT6];
1961
- const value = input?.type === "executed" ? input.value : null;
1962
- const handleAction = (action) => {
1963
- if (action === "run") {
1964
- runtime.evalNode();
1965
- }
1966
- };
1967
- return /* @__PURE__ */ React19.createElement(Box, {
1968
- shape,
1969
- onAction: handleAction
1970
- }, value !== null && /* @__PURE__ */ React19.createElement(Surface, {
1971
- role: "card--extrinsic",
1972
- data: {
1973
- value
1974
- },
1975
- limit: 1
1976
- }));
1977
- } finally {
1978
- _effect.f();
1979
- }
1842
+ const { runtime } = useComputeNodeState(shape);
1843
+ const input = runtime.inputs[DEFAULT_INPUT6];
1844
+ const value = input?.type === "executed" ? input.value : null;
1845
+ const handleAction = (action) => {
1846
+ if (action === "run") {
1847
+ runtime.evalNode();
1848
+ }
1849
+ };
1850
+ return /* @__PURE__ */ React19.createElement(Box, {
1851
+ shape,
1852
+ onAction: handleAction
1853
+ }, /* @__PURE__ */ React19.createElement(Card.Root, null, value !== null && /* @__PURE__ */ React19.createElement(Surface.Surface, {
1854
+ role: "card--content",
1855
+ data: {
1856
+ value
1857
+ },
1858
+ limit: 1
1859
+ })));
1980
1860
  };
1981
1861
  var surfaceShape = {
1982
1862
  type: "surface",
@@ -1994,7 +1874,6 @@ var surfaceShape = {
1994
1874
  };
1995
1875
 
1996
1876
  // src/shapes/Switch.tsx
1997
- import { useSignals as _useSignals19 } from "@preact-signals/safe-react/tracking";
1998
1877
  import * as Schema19 from "effect/Schema";
1999
1878
  import React20, { useEffect as useEffect6, useState as useState8 } from "react";
2000
1879
  import { DEFAULT_OUTPUT as DEFAULT_OUTPUT6 } from "@dxos/conductor";
@@ -2012,25 +1891,20 @@ var createSwitch = (props) => createShape({
2012
1891
  ...props
2013
1892
  });
2014
1893
  var SwitchComponent = ({ shape }) => {
2015
- var _effect = _useSignals19();
2016
- try {
2017
- const { runtime } = useComputeNodeState(shape);
2018
- const [value, setValue] = useState8(false);
2019
- useEffect6(() => {
2020
- runtime.setOutput(DEFAULT_OUTPUT6, value);
2021
- }, [
2022
- value
2023
- ]);
2024
- return /* @__PURE__ */ React20.createElement("div", {
2025
- className: "flex w-full justify-center items-center",
2026
- onClick: (ev) => ev.stopPropagation()
2027
- }, /* @__PURE__ */ React20.createElement(Input2.Root, null, /* @__PURE__ */ React20.createElement(Input2.Switch, {
2028
- checked: value,
2029
- onCheckedChange: (value2) => setValue(value2)
2030
- })));
2031
- } finally {
2032
- _effect.f();
2033
- }
1894
+ const { runtime } = useComputeNodeState(shape);
1895
+ const [value, setValue] = useState8(false);
1896
+ useEffect6(() => {
1897
+ runtime.setOutput(DEFAULT_OUTPUT6, value);
1898
+ }, [
1899
+ value
1900
+ ]);
1901
+ return /* @__PURE__ */ React20.createElement("div", {
1902
+ className: "flex w-full justify-center items-center",
1903
+ onClick: (ev) => ev.stopPropagation()
1904
+ }, /* @__PURE__ */ React20.createElement(Input2.Root, null, /* @__PURE__ */ React20.createElement(Input2.Switch, {
1905
+ checked: value,
1906
+ onCheckedChange: (value2) => setValue(value2)
1907
+ })));
2034
1908
  };
2035
1909
  var switchShape = {
2036
1910
  type: "switch",
@@ -2047,13 +1921,12 @@ var switchShape = {
2047
1921
  };
2048
1922
 
2049
1923
  // src/shapes/Table.tsx
2050
- import { useSignals as _useSignals20 } from "@preact-signals/safe-react/tracking";
2051
1924
  import * as Schema20 from "effect/Schema";
2052
1925
  import React21 from "react";
2053
1926
  import { createInputSchema, createOutputSchema } from "@dxos/conductor";
2054
- import { DataType } from "@dxos/schema";
2055
- var InputSchema = createInputSchema(DataType.Message);
2056
- var OutputSchema = createOutputSchema(Schema20.mutable(Schema20.Array(DataType.Message)));
1927
+ import { Message } from "@dxos/types";
1928
+ var InputSchema = createInputSchema(Message.Message);
1929
+ var OutputSchema = createOutputSchema(Schema20.mutable(Schema20.Array(Message.Message)));
2057
1930
  var TableShape = Schema20.extend(ComputeShape, Schema20.Struct({
2058
1931
  type: Schema20.Literal("table")
2059
1932
  }));
@@ -2066,14 +1939,9 @@ var createTable = (props) => createShape({
2066
1939
  ...props
2067
1940
  });
2068
1941
  var TableComponent = ({ shape }) => {
2069
- var _effect = _useSignals20();
2070
- try {
2071
- return /* @__PURE__ */ React21.createElement(Box, {
2072
- shape
2073
- });
2074
- } finally {
2075
- _effect.f();
2076
- }
1942
+ return /* @__PURE__ */ React21.createElement(Box, {
1943
+ shape
1944
+ });
2077
1945
  };
2078
1946
  var tableShape = {
2079
1947
  type: "table",
@@ -2086,11 +1954,10 @@ var tableShape = {
2086
1954
  };
2087
1955
 
2088
1956
  // src/shapes/Template.tsx
2089
- import { useSignals as _useSignals21 } from "@preact-signals/safe-react/tracking";
2090
1957
  import * as Schema21 from "effect/Schema";
2091
1958
  import React22, { useRef as useRef5 } from "react";
2092
1959
  import { ComputeValueType as ComputeValueType3, TemplateOutput, VoidInput as VoidInput2, getTemplateInputSchema as getTemplateInputSchema2 } from "@dxos/conductor";
2093
- import { toJsonSchema as toJsonSchema2 } from "@dxos/echo/internal";
1960
+ import { toJsonSchema } from "@dxos/echo/internal";
2094
1961
  import { invariant as invariant5 } from "@dxos/invariant";
2095
1962
  import { TextBox as TextBox4 } from "@dxos/react-ui-canvas-editor";
2096
1963
  var __dxlog_file6 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/Template.tsx";
@@ -2099,49 +1966,44 @@ var TemplateShape = Schema21.extend(ComputeShape, Schema21.Struct({
2099
1966
  valueType: Schema21.optional(ComputeValueType3)
2100
1967
  }));
2101
1968
  var TextInputComponent3 = ({ shape, title, ...props }) => {
2102
- var _effect = _useSignals21();
2103
- try {
2104
- const { node } = useComputeNodeState(shape);
2105
- const inputRef = useRef5(null);
2106
- const handleEnter = (text) => {
2107
- const value = text.trim();
2108
- if (value.length) {
2109
- const schema = getTemplateInputSchema2(node);
2110
- node.value = value;
2111
- node.inputSchema = toJsonSchema2(schema);
2112
- }
2113
- };
2114
- const handleTypeChange = (newType) => {
2115
- invariant5(Schema21.is(ComputeValueType3)(newType), "Invalid type", {
2116
- F: __dxlog_file6,
2117
- L: 59,
2118
- S: void 0,
2119
- A: [
2120
- "Schema.is(ComputeValueType)(newType)",
2121
- "'Invalid type'"
2122
- ]
2123
- });
2124
- node.valueType = newType;
2125
- node.inputSchema = toJsonSchema2(getTemplateInputSchema2(node));
2126
- };
2127
- return /* @__PURE__ */ React22.createElement(Box, {
2128
- shape,
2129
- title: "Template",
2130
- status: /* @__PURE__ */ React22.createElement(TypeSelect, {
2131
- value: node.valueType ?? "string",
2132
- onValueChange: handleTypeChange
2133
- })
2134
- }, /* @__PURE__ */ React22.createElement(TextBox4, {
2135
- ...props,
2136
- ref: inputRef,
2137
- value: node.value,
2138
- language: node.valueType === "object" ? "json" : void 0,
2139
- onBlur: handleEnter,
2140
- onEnter: handleEnter
2141
- }));
2142
- } finally {
2143
- _effect.f();
2144
- }
1969
+ const { node } = useComputeNodeState(shape);
1970
+ const inputRef = useRef5(null);
1971
+ const handleEnter = (text) => {
1972
+ const value = text.trim();
1973
+ if (value.length) {
1974
+ const schema = getTemplateInputSchema2(node);
1975
+ node.value = value;
1976
+ node.inputSchema = toJsonSchema(schema);
1977
+ }
1978
+ };
1979
+ const handleTypeChange = (newType) => {
1980
+ invariant5(Schema21.is(ComputeValueType3)(newType), "Invalid type", {
1981
+ F: __dxlog_file6,
1982
+ L: 59,
1983
+ S: void 0,
1984
+ A: [
1985
+ "Schema.is(ComputeValueType)(newType)",
1986
+ "'Invalid type'"
1987
+ ]
1988
+ });
1989
+ node.valueType = newType;
1990
+ node.inputSchema = toJsonSchema(getTemplateInputSchema2(node));
1991
+ };
1992
+ return /* @__PURE__ */ React22.createElement(Box, {
1993
+ shape,
1994
+ title: "Template",
1995
+ status: /* @__PURE__ */ React22.createElement(TypeSelect, {
1996
+ value: node.valueType ?? "string",
1997
+ onValueChange: handleTypeChange
1998
+ })
1999
+ }, /* @__PURE__ */ React22.createElement(TextBox4, {
2000
+ ...props,
2001
+ ref: inputRef,
2002
+ value: node.value,
2003
+ language: node.valueType === "object" ? "json" : void 0,
2004
+ onBlur: handleEnter,
2005
+ onEnter: handleEnter
2006
+ }));
2145
2007
  };
2146
2008
  var createTemplate = (props) => createShape({
2147
2009
  type: "template",
@@ -2165,7 +2027,6 @@ var templateShape = {
2165
2027
  };
2166
2028
 
2167
2029
  // src/shapes/Text.tsx
2168
- import { useSignals as _useSignals22 } from "@preact-signals/safe-react/tracking";
2169
2030
  import * as Schema22 from "effect/Schema";
2170
2031
  import React23 from "react";
2171
2032
  import { DEFAULT_INPUT as DEFAULT_INPUT7 } from "@dxos/conductor";
@@ -2183,25 +2044,20 @@ var createText = (props) => createShape({
2183
2044
  ...props
2184
2045
  });
2185
2046
  var TextComponent = ({ shape }) => {
2186
- var _effect = _useSignals22();
2187
- try {
2188
- const { runtime } = useComputeNodeState(shape);
2189
- const input = runtime.inputs[DEFAULT_INPUT7];
2190
- const value = input?.type === "executed" ? input.value : 0;
2191
- const handleAction = (action) => {
2192
- if (action === "run") {
2193
- runtime.evalNode();
2194
- }
2195
- };
2196
- return /* @__PURE__ */ React23.createElement(Box, {
2197
- shape,
2198
- onAction: handleAction
2199
- }, /* @__PURE__ */ React23.createElement(TextBox5, {
2200
- value
2201
- }));
2202
- } finally {
2203
- _effect.f();
2204
- }
2047
+ const { runtime } = useComputeNodeState(shape);
2048
+ const input = runtime.inputs[DEFAULT_INPUT7];
2049
+ const value = input?.type === "executed" ? input.value : 0;
2050
+ const handleAction = (action) => {
2051
+ if (action === "run") {
2052
+ runtime.evalNode();
2053
+ }
2054
+ };
2055
+ return /* @__PURE__ */ React23.createElement(Box, {
2056
+ shape,
2057
+ onAction: handleAction
2058
+ }, /* @__PURE__ */ React23.createElement(TextBox5, {
2059
+ value
2060
+ }));
2205
2061
  };
2206
2062
  var textShape = {
2207
2063
  type: "text",
@@ -2219,14 +2075,14 @@ var textShape = {
2219
2075
  };
2220
2076
 
2221
2077
  // src/shapes/Thread.tsx
2222
- import { useSignals as _useSignals23 } from "@preact-signals/safe-react/tracking";
2223
2078
  import * as Schema23 from "effect/Schema";
2224
2079
  import React24, { useEffect as useEffect7, useRef as useRef6 } from "react";
2225
2080
  import { createInputSchema as createInputSchema2, createOutputSchema as createOutputSchema2 } from "@dxos/conductor";
2226
- import { mx as mx3 } from "@dxos/react-ui-theme";
2227
- import { DataType as DataType2 } from "@dxos/schema";
2228
- var InputSchema2 = createInputSchema2(DataType2.Message);
2229
- var OutputSchema2 = createOutputSchema2(Schema23.mutable(Schema23.Array(DataType2.Message)));
2081
+ import { ScrollArea as ScrollArea3 } from "@dxos/react-ui";
2082
+ import { Message as Message2 } from "@dxos/types";
2083
+ import { mx as mx3 } from "@dxos/ui-theme";
2084
+ var InputSchema2 = createInputSchema2(Message2.Message);
2085
+ var OutputSchema2 = createOutputSchema2(Schema23.mutable(Schema23.Array(Message2.Message)));
2230
2086
  var ThreadShape = Schema23.extend(ComputeShape, Schema23.Struct({
2231
2087
  type: Schema23.Literal("thread")
2232
2088
  }));
@@ -2239,49 +2095,42 @@ var createThread = (props) => createShape({
2239
2095
  ...props
2240
2096
  });
2241
2097
  var ThreadComponent = ({ shape }) => {
2242
- var _effect = _useSignals23();
2243
- try {
2244
- const items = [];
2245
- const scrollRef = useRef6(null);
2246
- useEffect7(() => {
2247
- if (scrollRef.current) {
2248
- scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
2249
- }
2250
- }, [
2251
- items
2252
- ]);
2253
- return /* @__PURE__ */ React24.createElement(Box, {
2254
- shape
2255
- }, /* @__PURE__ */ React24.createElement("div", {
2256
- ref: scrollRef,
2257
- className: "flex flex-col w-full overflow-y-scroll gap-2 p-2"
2258
- }, [
2259
- ...items
2260
- ].map((item, i) => /* @__PURE__ */ React24.createElement(ThreadItem, {
2261
- key: i,
2262
- item
2263
- }))));
2264
- } finally {
2265
- _effect.f();
2266
- }
2098
+ const items = [];
2099
+ const scrollRef = useRef6(null);
2100
+ useEffect7(() => {
2101
+ if (scrollRef.current) {
2102
+ scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
2103
+ }
2104
+ }, [
2105
+ items
2106
+ ]);
2107
+ return /* @__PURE__ */ React24.createElement(Box, {
2108
+ shape
2109
+ }, /* @__PURE__ */ React24.createElement(ScrollArea3.Root, {
2110
+ orientation: "vertical"
2111
+ }, /* @__PURE__ */ React24.createElement(ScrollArea3.Viewport, {
2112
+ classNames: "gap-2 p-2",
2113
+ ref: scrollRef
2114
+ }, [
2115
+ ...items
2116
+ ].map((item, i) => /* @__PURE__ */ React24.createElement(ThreadItem, {
2117
+ key: i,
2118
+ item
2119
+ })))));
2267
2120
  };
2268
2121
  var ThreadItem = ({ classNames, item }) => {
2269
- var _effect = _useSignals23();
2270
- try {
2271
- if (typeof item !== "object") {
2272
- return /* @__PURE__ */ React24.createElement("div", {
2273
- className: mx3(classNames)
2274
- }, item);
2275
- }
2276
- const { role, message } = item;
2122
+ if (typeof item !== "object") {
2277
2123
  return /* @__PURE__ */ React24.createElement("div", {
2278
- className: mx3("flex", classNames, role === "user" && "justify-end")
2279
- }, /* @__PURE__ */ React24.createElement("div", {
2280
- 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")
2281
- }, message));
2282
- } finally {
2283
- _effect.f();
2124
+ role: "none",
2125
+ className: mx3(classNames)
2126
+ }, item);
2284
2127
  }
2128
+ const { role, message } = item;
2129
+ return /* @__PURE__ */ React24.createElement("div", {
2130
+ className: mx3("flex", classNames, role === "user" && "justify-end")
2131
+ }, /* @__PURE__ */ React24.createElement("div", {
2132
+ className: mx3("block rounded-md p-1 px-2 text-sm", role === "user" ? "bg-blue-100 dark:bg-blue-800" : role === "system" ? "bg-red-100, dark:bg-red-800" : "whitespace-pre-wrap bg-neutral-50 dark:bg-neutral-800")
2133
+ }, message));
2285
2134
  };
2286
2135
  var threadShape = {
2287
2136
  type: "thread",
@@ -2294,7 +2143,6 @@ var threadShape = {
2294
2143
  };
2295
2144
 
2296
2145
  // src/shapes/TextToImage.tsx
2297
- import { useSignals as _useSignals24 } from "@preact-signals/safe-react/tracking";
2298
2146
  import * as Schema24 from "effect/Schema";
2299
2147
  import React25 from "react";
2300
2148
  import { createAnchorMap as createAnchorMap12 } from "@dxos/react-ui-canvas-editor";
@@ -2310,14 +2158,9 @@ var createTextToImage = (props) => createShape({
2310
2158
  ...props
2311
2159
  });
2312
2160
  var TextToImageComponent = ({ shape }) => {
2313
- var _effect = _useSignals24();
2314
- try {
2315
- return /* @__PURE__ */ React25.createElement(Box, {
2316
- shape
2317
- });
2318
- } finally {
2319
- _effect.f();
2320
- }
2161
+ return /* @__PURE__ */ React25.createElement(Box, {
2162
+ shape
2163
+ });
2321
2164
  };
2322
2165
  var textToImageShape = {
2323
2166
  type: "text-to-image",
@@ -2334,22 +2177,20 @@ var textToImageShape = {
2334
2177
  };
2335
2178
 
2336
2179
  // src/shapes/Trigger.tsx
2337
- import { useSignals as _useSignals25 } from "@preact-signals/safe-react/tracking";
2338
2180
  import * as Schema25 from "effect/Schema";
2339
2181
  import React26, { useEffect as useEffect8 } from "react";
2340
2182
  import { VoidInput as VoidInput3 } from "@dxos/conductor";
2341
- import { Filter as Filter2, Obj, Query } from "@dxos/echo";
2342
- import { ObjectId as ObjectId4, Ref as Ref3 } from "@dxos/echo/internal";
2343
- import { EmailTriggerOutput, FunctionTrigger, QueueTriggerOutput, SubscriptionTriggerOutput, TimerTriggerOutput, TriggerKinds, WebhookTriggerOutput } from "@dxos/functions";
2183
+ import { Filter as Filter2, Obj as Obj4, Query, Ref as Ref3 } from "@dxos/echo";
2184
+ import { Trigger, TriggerEvent } from "@dxos/functions";
2344
2185
  import { DXN, SpaceId } from "@dxos/keys";
2345
2186
  import { useSpace } from "@dxos/react-client/echo";
2346
2187
  import { Select as Select2 } from "@dxos/react-ui";
2347
2188
  var TriggerShape = Schema25.extend(ComputeShape, Schema25.Struct({
2348
2189
  type: Schema25.Literal("trigger"),
2349
- functionTrigger: Schema25.optional(Ref3(FunctionTrigger))
2190
+ functionTrigger: Schema25.optional(Ref3.Ref(Trigger.Trigger))
2350
2191
  }));
2351
2192
  var createTrigger = (props) => {
2352
- const functionTrigger = Obj.make(FunctionTrigger, {
2193
+ const functionTrigger = Trigger.make({
2353
2194
  enabled: true,
2354
2195
  spec: createTriggerSpec(props)
2355
2196
  });
@@ -2358,72 +2199,66 @@ var createTrigger = (props) => {
2358
2199
  functionTrigger: Ref3.make(functionTrigger),
2359
2200
  size: {
2360
2201
  width: 192,
2361
- height: getHeight(EmailTriggerOutput)
2202
+ height: getHeight(TriggerEvent.EmailEvent)
2362
2203
  },
2363
2204
  ...props
2364
2205
  });
2365
2206
  };
2366
2207
  var TriggerComponent = ({ shape }) => {
2367
- var _effect = _useSignals25();
2368
- try {
2369
- const space = useSpace();
2370
- const functionTrigger = shape.functionTrigger?.target;
2371
- useEffect8(() => {
2372
- if (functionTrigger && !functionTrigger.spec) {
2373
- functionTrigger.spec = createTriggerSpec({
2208
+ const space = useSpace();
2209
+ const functionTrigger = shape.functionTrigger?.target;
2210
+ useEffect8(() => {
2211
+ if (functionTrigger && !functionTrigger.spec) {
2212
+ Obj4.change(functionTrigger, (t) => {
2213
+ t.spec = createTriggerSpec({
2374
2214
  triggerKind: "email",
2375
2215
  spaceId: space?.id
2376
2216
  });
2377
- }
2378
- }, [
2379
- functionTrigger,
2380
- functionTrigger?.spec
2381
- ]);
2382
- useEffect8(() => {
2383
- shape.size.height = getHeight(getOutputSchema(functionTrigger?.spec?.kind ?? "email"));
2384
- }, [
2385
- functionTrigger?.spec?.kind
2386
- ]);
2387
- const setKind = (kind) => {
2388
- if (functionTrigger?.spec?.kind !== kind) {
2389
- functionTrigger.spec = createTriggerSpec({
2217
+ });
2218
+ }
2219
+ }, [
2220
+ functionTrigger,
2221
+ functionTrigger?.spec
2222
+ ]);
2223
+ useEffect8(() => {
2224
+ shape.size.height = getHeight(getOutputSchema(functionTrigger?.spec?.kind ?? "email"));
2225
+ }, [
2226
+ functionTrigger?.spec?.kind
2227
+ ]);
2228
+ const setKind = (kind) => {
2229
+ if (functionTrigger?.spec?.kind !== kind) {
2230
+ Obj4.change(functionTrigger, (t) => {
2231
+ t.spec = createTriggerSpec({
2390
2232
  triggerKind: kind,
2391
2233
  spaceId: space?.id
2392
2234
  });
2393
- }
2394
- };
2395
- if (!functionTrigger?.spec) {
2396
- return;
2235
+ });
2397
2236
  }
2398
- return /* @__PURE__ */ React26.createElement(FunctionBody, {
2399
- shape,
2400
- status: /* @__PURE__ */ React26.createElement(TriggerKindSelect, {
2401
- value: functionTrigger.spec?.kind,
2402
- onValueChange: (kind) => setKind(kind)
2403
- }),
2404
- inputSchema: VoidInput3,
2405
- outputSchema: getOutputSchema(functionTrigger.spec.kind)
2406
- });
2407
- } finally {
2408
- _effect.f();
2237
+ };
2238
+ if (!functionTrigger?.spec) {
2239
+ return;
2409
2240
  }
2241
+ return /* @__PURE__ */ React26.createElement(FunctionBody, {
2242
+ shape,
2243
+ status: /* @__PURE__ */ React26.createElement(TriggerKindSelect, {
2244
+ value: functionTrigger.spec?.kind,
2245
+ onValueChange: (kind) => setKind(kind)
2246
+ }),
2247
+ inputSchema: VoidInput3,
2248
+ outputSchema: getOutputSchema(functionTrigger.spec.kind)
2249
+ });
2410
2250
  };
2411
2251
  var TriggerKindSelect = ({ value, onValueChange }) => {
2412
- var _effect = _useSignals25();
2413
- try {
2414
- return /* @__PURE__ */ React26.createElement(Select2.Root, {
2415
- value,
2416
- onValueChange
2417
- }, /* @__PURE__ */ React26.createElement(Select2.TriggerButton, {
2418
- variant: "ghost",
2419
- classNames: "w-full !px-0"
2420
- }), /* @__PURE__ */ React26.createElement(Select2.Portal, null, /* @__PURE__ */ React26.createElement(Select2.Content, null, /* @__PURE__ */ React26.createElement(Select2.ScrollUpButton, null), /* @__PURE__ */ React26.createElement(Select2.Viewport, null, TriggerKinds.map((kind) => /* @__PURE__ */ React26.createElement(Select2.Option, {
2421
- key: kind,
2422
- value: kind
2423
- }, kind))), /* @__PURE__ */ React26.createElement(Select2.ScrollDownButton, null), /* @__PURE__ */ React26.createElement(Select2.Arrow, null))));
2424
- } finally {
2425
- _effect.f();
2426
- }
2252
+ return /* @__PURE__ */ React26.createElement(Select2.Root, {
2253
+ value,
2254
+ onValueChange
2255
+ }, /* @__PURE__ */ React26.createElement(Select2.TriggerButton, {
2256
+ variant: "ghost",
2257
+ classNames: "w-full px-0!"
2258
+ }), /* @__PURE__ */ React26.createElement(Select2.Portal, null, /* @__PURE__ */ React26.createElement(Select2.Content, null, /* @__PURE__ */ React26.createElement(Select2.ScrollUpButton, null), /* @__PURE__ */ React26.createElement(Select2.Viewport, null, Trigger.Kinds.map((kind) => /* @__PURE__ */ React26.createElement(Select2.Option, {
2259
+ key: kind,
2260
+ value: kind
2261
+ }, kind))), /* @__PURE__ */ React26.createElement(Select2.ScrollDownButton, null), /* @__PURE__ */ React26.createElement(Select2.Arrow, null))));
2427
2262
  };
2428
2263
  var createTriggerSpec = (props) => {
2429
2264
  const kind = props.triggerKind ?? "email";
@@ -2442,7 +2277,6 @@ var createTriggerSpec = (props) => {
2442
2277
  return {
2443
2278
  kind: "subscription",
2444
2279
  query: {
2445
- string: "Query.select(Filter.nothing())",
2446
2280
  ast: Query.select(Filter2.nothing()).ast
2447
2281
  }
2448
2282
  };
@@ -2454,7 +2288,7 @@ var createTriggerSpec = (props) => {
2454
2288
  const dxn = new DXN(DXN.kind.QUEUE, [
2455
2289
  "data",
2456
2290
  props.spaceId ?? SpaceId.random(),
2457
- ObjectId4.random()
2291
+ Obj4.ID.random()
2458
2292
  ]).toString();
2459
2293
  return {
2460
2294
  kind: "queue",
@@ -2465,11 +2299,11 @@ var createTriggerSpec = (props) => {
2465
2299
  };
2466
2300
  var getOutputSchema = (kind) => {
2467
2301
  const kindToSchema = {
2468
- ["email"]: EmailTriggerOutput,
2469
- ["subscription"]: SubscriptionTriggerOutput,
2470
- ["timer"]: TimerTriggerOutput,
2471
- ["webhook"]: WebhookTriggerOutput,
2472
- ["queue"]: QueueTriggerOutput
2302
+ ["email"]: TriggerEvent.EmailEvent,
2303
+ ["subscription"]: TriggerEvent.SubscriptionEvent,
2304
+ ["timer"]: TriggerEvent.TimerEvent,
2305
+ ["webhook"]: TriggerEvent.WebhookEvent,
2306
+ ["queue"]: TriggerEvent.QueueEvent
2473
2307
  };
2474
2308
  return kindToSchema[kind];
2475
2309
  };
@@ -2483,7 +2317,6 @@ var triggerShape = {
2483
2317
  };
2484
2318
 
2485
2319
  // src/shapes/GptRealtime.tsx
2486
- import { useSignals as _useSignals26 } from "@preact-signals/safe-react/tracking";
2487
2320
  import * as Schema26 from "effect/Schema";
2488
2321
  import React27, { useState as useState9 } from "react";
2489
2322
  import { log as log2 } from "@dxos/log";
@@ -2502,105 +2335,100 @@ var createGptRealtime = (props) => createShape({
2502
2335
  ...props
2503
2336
  });
2504
2337
  var GptRealtimeComponent = ({ shape }) => {
2505
- var _effect = _useSignals26();
2506
- try {
2507
- const [isLive, setIsLive] = useState9(false);
2508
- const [isReady, setIsReady] = useState9(false);
2509
- const config = useConfig();
2510
- const start = async () => {
2511
- setIsLive(true);
2512
- try {
2513
- const peerConnection = new RTCPeerConnection();
2514
- peerConnection.ontrack = (event) => {
2515
- const audioElement = document.createElement("audio");
2516
- audioElement.srcObject = event.streams[0];
2517
- audioElement.autoplay = true;
2518
- audioElement.controls = false;
2519
- audioElement.style.display = "none";
2520
- document.body.appendChild(audioElement);
2521
- setIsReady(true);
2522
- };
2523
- const stream = await navigator.mediaDevices.getUserMedia({
2524
- audio: true
2338
+ const [isLive, setIsLive] = useState9(false);
2339
+ const [isReady, setIsReady] = useState9(false);
2340
+ const config = useConfig();
2341
+ const start = async () => {
2342
+ setIsLive(true);
2343
+ try {
2344
+ const peerConnection = new RTCPeerConnection();
2345
+ peerConnection.ontrack = (event) => {
2346
+ const audioElement = document.createElement("audio");
2347
+ audioElement.srcObject = event.streams[0];
2348
+ audioElement.autoplay = true;
2349
+ audioElement.controls = false;
2350
+ audioElement.style.display = "none";
2351
+ document.body.appendChild(audioElement);
2352
+ setIsReady(true);
2353
+ };
2354
+ const stream = await navigator.mediaDevices.getUserMedia({
2355
+ audio: true
2356
+ });
2357
+ stream.getTracks().forEach((track) => peerConnection.addTransceiver(track, {
2358
+ direction: "sendrecv"
2359
+ }));
2360
+ const offer = await peerConnection.createOffer();
2361
+ await peerConnection.setLocalDescription(offer);
2362
+ const AiServiceUrl = new URL("/rtc-connect", config.values.runtime?.services?.ai?.server ?? DEFAULT_AI_SERVICE_URL);
2363
+ const response = await fetch(AiServiceUrl, {
2364
+ method: "POST",
2365
+ body: offer.sdp,
2366
+ headers: {
2367
+ "Content-Type": "application/sdp"
2368
+ }
2369
+ });
2370
+ const answer = await response.text();
2371
+ await peerConnection.setRemoteDescription({
2372
+ sdp: answer,
2373
+ type: "answer"
2374
+ });
2375
+ const dataChannel = peerConnection.createDataChannel("response");
2376
+ const configureData = () => {
2377
+ log2.info("Configuring data channel", void 0, {
2378
+ F: __dxlog_file7,
2379
+ L: 87,
2380
+ S: void 0,
2381
+ C: (f, a) => f(...a)
2525
2382
  });
2526
- stream.getTracks().forEach((track) => peerConnection.addTransceiver(track, {
2527
- direction: "sendrecv"
2528
- }));
2529
- const offer = await peerConnection.createOffer();
2530
- await peerConnection.setLocalDescription(offer);
2531
- const AiServiceUrl = new URL("/rtc-connect", config.values.runtime?.services?.ai?.server ?? DEFAULT_AI_SERVICE_URL);
2532
- const response = await fetch(AiServiceUrl, {
2533
- method: "POST",
2534
- body: offer.sdp,
2535
- headers: {
2536
- "Content-Type": "application/sdp"
2383
+ const event = {
2384
+ type: "session.update",
2385
+ session: {
2386
+ modalities: [
2387
+ "text",
2388
+ "audio"
2389
+ ],
2390
+ // Provide the tools. Note they match the keys in the `fns` object above
2391
+ tools: []
2537
2392
  }
2538
- });
2539
- const answer = await response.text();
2540
- await peerConnection.setRemoteDescription({
2541
- sdp: answer,
2542
- type: "answer"
2543
- });
2544
- const dataChannel = peerConnection.createDataChannel("response");
2545
- const configureData = () => {
2546
- log2.info("Configuring data channel", void 0, {
2547
- F: __dxlog_file7,
2548
- L: 87,
2549
- S: void 0,
2550
- C: (f, a) => f(...a)
2551
- });
2552
- const event = {
2553
- type: "session.update",
2554
- session: {
2555
- modalities: [
2556
- "text",
2557
- "audio"
2558
- ],
2559
- // Provide the tools. Note they match the keys in the `fns` object above
2560
- tools: []
2561
- }
2562
- };
2563
- dataChannel.send(JSON.stringify(event));
2564
2393
  };
2565
- dataChannel.addEventListener("open", (ev) => {
2566
- log2.info("Opening data channel", {
2567
- ev
2568
- }, {
2569
- F: __dxlog_file7,
2570
- L: 100,
2571
- S: void 0,
2572
- C: (f, a) => f(...a)
2573
- });
2574
- configureData();
2575
- });
2576
- dataChannel.addEventListener("message", async (ev) => {
2577
- const msg = JSON.parse(ev.data);
2578
- if (msg.type === "response.function_call_arguments.done") {
2579
- }
2580
- });
2581
- } catch (error) {
2582
- log2.error("Error in realtime session:", {
2583
- error
2394
+ dataChannel.send(JSON.stringify(event));
2395
+ };
2396
+ dataChannel.addEventListener("open", (ev) => {
2397
+ log2.info("Opening data channel", {
2398
+ ev
2584
2399
  }, {
2585
2400
  F: __dxlog_file7,
2586
- L: 140,
2401
+ L: 100,
2587
2402
  S: void 0,
2588
2403
  C: (f, a) => f(...a)
2589
2404
  });
2590
- throw error;
2591
- }
2592
- };
2593
- return /* @__PURE__ */ React27.createElement("div", {
2594
- className: "flex w-full justify-center items-center"
2595
- }, /* @__PURE__ */ React27.createElement(Icon5, {
2596
- icon: isReady ? "ph--waveform--regular" : isLive ? "ph--pulse--regular" : "ph--play--regular",
2597
- size: 16,
2598
- classNames: !isLive && "cursor-pointer",
2599
- onClick: start
2600
- }));
2601
- } finally {
2602
- _effect.f();
2603
- }
2405
+ configureData();
2406
+ });
2407
+ dataChannel.addEventListener("message", async (ev) => {
2408
+ const msg = JSON.parse(ev.data);
2409
+ if (msg.type === "response.function_call_arguments.done") {
2410
+ }
2411
+ });
2412
+ } catch (error) {
2413
+ log2.error("Error in realtime session:", {
2414
+ error
2415
+ }, {
2416
+ F: __dxlog_file7,
2417
+ L: 140,
2418
+ S: void 0,
2419
+ C: (f, a) => f(...a)
2420
+ });
2421
+ throw error;
2422
+ }
2423
+ };
2424
+ return /* @__PURE__ */ React27.createElement("div", {
2425
+ className: "flex w-full justify-center items-center"
2426
+ }, /* @__PURE__ */ React27.createElement(Icon5, {
2427
+ icon: isReady ? "ph--waveform--regular" : isLive ? "ph--pulse--regular" : "ph--play--regular",
2428
+ size: 16,
2429
+ classNames: !isLive && "cursor-pointer",
2430
+ onClick: start
2431
+ }));
2604
2432
  };
2605
2433
  var gptRealtimeShape = {
2606
2434
  type: "gpt-realtime",
@@ -2682,20 +2510,11 @@ var computeShapes = [
2682
2510
  import { DefaultInput, DefaultOutput as DefaultOutput2 } from "@dxos/conductor";
2683
2511
  import { toEffectSchema } from "@dxos/echo/internal";
2684
2512
  import { ShapeLayout } from "@dxos/react-ui-canvas-editor";
2685
- function _define_property2(obj, key, value) {
2686
- if (key in obj) {
2687
- Object.defineProperty(obj, key, {
2688
- value,
2689
- enumerable: true,
2690
- configurable: true,
2691
- writable: true
2692
- });
2693
- } else {
2694
- obj[key] = value;
2695
- }
2696
- return obj;
2697
- }
2698
2513
  var ComputeShapeLayout = class extends ShapeLayout {
2514
+ _controller;
2515
+ constructor(_controller, registry2) {
2516
+ super(registry2), this._controller = _controller;
2517
+ }
2699
2518
  // TODO(burdon): Doesn't update.
2700
2519
  getAnchors(shape) {
2701
2520
  const shapeDef = this._registry.getShapeDef(shape.type);
@@ -2710,9 +2529,6 @@ var ComputeShapeLayout = class extends ShapeLayout {
2710
2529
  }
2711
2530
  return anchors;
2712
2531
  }
2713
- constructor(_controller, registry2) {
2714
- super(registry2), _define_property2(this, "_controller", void 0), this._controller = _controller;
2715
- }
2716
2532
  };
2717
2533
  export {
2718
2534
  AndShape,