@dxos/react-ui-canvas-compute 0.8.4-main.406dc2a → 0.8.4-main.422d1c7879

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 (76) hide show
  1. package/dist/lib/browser/index.mjs +940 -1136
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +940 -1136
  5. package/dist/lib/node-esm/index.mjs.map +4 -4
  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 +19 -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/Audio.d.ts.map +1 -1
  16. package/dist/types/src/shapes/Beacon.d.ts.map +1 -1
  17. package/dist/types/src/shapes/Chat.d.ts.map +1 -1
  18. package/dist/types/src/shapes/Constant.d.ts.map +1 -1
  19. package/dist/types/src/shapes/{Queue.d.ts → Feed.d.ts} +8 -8
  20. package/dist/types/src/shapes/Feed.d.ts.map +1 -0
  21. package/dist/types/src/shapes/Function.d.ts.map +1 -1
  22. package/dist/types/src/shapes/Gpt.d.ts.map +1 -1
  23. package/dist/types/src/shapes/Json.d.ts.map +1 -1
  24. package/dist/types/src/shapes/RNG.d.ts.map +1 -1
  25. package/dist/types/src/shapes/Scope.d.ts.map +1 -1
  26. package/dist/types/src/shapes/Surface.d.ts.map +1 -1
  27. package/dist/types/src/shapes/Switch.d.ts.map +1 -1
  28. package/dist/types/src/shapes/Template.d.ts.map +1 -1
  29. package/dist/types/src/shapes/Text.d.ts.map +1 -1
  30. package/dist/types/src/shapes/Thread.d.ts.map +1 -1
  31. package/dist/types/src/shapes/Trigger.d.ts +6 -4
  32. package/dist/types/src/shapes/Trigger.d.ts.map +1 -1
  33. package/dist/types/src/shapes/common/Box.d.ts +4 -4
  34. package/dist/types/src/shapes/common/Box.d.ts.map +1 -1
  35. package/dist/types/src/shapes/common/FunctionBody.d.ts +2 -2
  36. package/dist/types/src/shapes/common/FunctionBody.d.ts.map +1 -1
  37. package/dist/types/src/shapes/index.d.ts +2 -2
  38. package/dist/types/src/shapes/index.d.ts.map +1 -1
  39. package/dist/types/src/testing/circuits.d.ts +18 -24
  40. package/dist/types/src/testing/circuits.d.ts.map +1 -1
  41. package/dist/types/tsconfig.tsbuildinfo +1 -1
  42. package/package.json +61 -57
  43. package/src/README.md +0 -3
  44. package/src/compute.stories.tsx +90 -115
  45. package/src/graph/controller.ts +102 -72
  46. package/src/graph/node-defs.ts +31 -31
  47. package/src/hooks/useComputeNodeState.ts +4 -4
  48. package/src/hooks/useGraphMonitor.ts +11 -10
  49. package/src/json.test.ts +3 -3
  50. package/src/registry.ts +2 -2
  51. package/src/schema.test.ts +11 -11
  52. package/src/shapes/Audio.tsx +1 -2
  53. package/src/shapes/Beacon.tsx +0 -1
  54. package/src/shapes/Boolean.tsx +1 -1
  55. package/src/shapes/Chat.tsx +0 -1
  56. package/src/shapes/Constant.tsx +0 -1
  57. package/src/shapes/{Queue.tsx → Feed.tsx} +26 -21
  58. package/src/shapes/Function.tsx +11 -9
  59. package/src/shapes/Gpt.tsx +6 -2
  60. package/src/shapes/Json.tsx +9 -3
  61. package/src/shapes/RNG.tsx +5 -2
  62. package/src/shapes/Scope.tsx +0 -1
  63. package/src/shapes/Surface.tsx +12 -4
  64. package/src/shapes/Switch.tsx +0 -1
  65. package/src/shapes/Table.tsx +3 -3
  66. package/src/shapes/Template.tsx +0 -1
  67. package/src/shapes/Text.tsx +0 -1
  68. package/src/shapes/Thread.tsx +17 -11
  69. package/src/shapes/Trigger.tsx +35 -50
  70. package/src/shapes/common/Box.tsx +5 -8
  71. package/src/shapes/common/FunctionBody.tsx +2 -2
  72. package/src/shapes/common/TypeSelect.tsx +1 -1
  73. package/src/shapes/defs.ts +3 -3
  74. package/src/shapes/index.ts +2 -2
  75. package/src/testing/circuits.ts +7 -16
  76. package/dist/types/src/shapes/Queue.d.ts.map +0 -1
@@ -4,10 +4,13 @@ import "@dxos/node-std/globals";
4
4
  import * as Effect from "effect/Effect";
5
5
  import * as Either from "effect/Either";
6
6
  import * as Exit from "effect/Exit";
7
+ import * as Layer from "effect/Layer";
7
8
  import * as Scope from "effect/Scope";
8
9
  import { Event, synchronized } from "@dxos/async";
9
10
  import { GraphExecutor, ValueBag, isNotExecuted } from "@dxos/conductor";
10
11
  import { Resource } from "@dxos/context";
12
+ import { unwrapExit } from "@dxos/effect";
13
+ import { ComputeEventLogger, Trace } from "@dxos/functions";
11
14
  import { log } from "@dxos/log";
12
15
 
13
16
  // src/hooks/compute-context.ts
@@ -77,7 +80,7 @@ var useComputeNodeState = (shape) => {
77
80
  const { controller } = useComputeContext();
78
81
  invariant(controller, void 0, {
79
82
  F: __dxlog_file,
80
- L: 34,
83
+ L: 33,
81
84
  S: void 0,
82
85
  A: [
83
86
  "controller",
@@ -90,7 +93,7 @@ var useComputeNodeState = (shape) => {
90
93
  queueMicrotask(async () => {
91
94
  invariant(shape.node, "Node not specified", {
92
95
  F: __dxlog_file,
93
- L: 40,
96
+ L: 39,
94
97
  S: void 0,
95
98
  A: [
96
99
  "shape.node",
@@ -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, (functionTrigger2) => {
259
+ functionTrigger2.function = Ref.make(graph.root);
260
+ functionTrigger2.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(Layer.mergeAll(ComputeEventLogger.layerNoop, Trace.writerLayerNoop)), 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(Layer.mergeAll(ComputeEventLogger.layerNoop, Trace.writerLayerNoop)), 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: 369,
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,69 @@ 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
+ label: "run",
673
+ iconOnly: true,
674
+ onDoubleClick: (ev) => ev.stopPropagation(),
675
+ onClick: (ev) => {
676
+ ev.stopPropagation();
677
+ onAction?.("run");
678
+ }
679
+ })), /* @__PURE__ */ React.createElement("div", {
680
+ className: mx("flex flex-col h-full grow overflow-hidden", classNames)
681
+ }, children), /* @__PURE__ */ React.createElement("div", {
682
+ className: "flex shrink-0 w-full justify-between items-center h-[32px] bg-input-surface"
683
+ }, /* @__PURE__ */ React.createElement("div", {
684
+ className: "grow px-2 text-sm truncate"
685
+ }, debug ? shape.id : status), openable && /* @__PURE__ */ React.createElement(IconButton, {
686
+ classNames: "p-1",
687
+ variant: "ghost",
688
+ icon: open ? "ph--caret-up--regular" : "ph--caret-down--regular",
689
+ label: open ? "close" : "open",
690
+ iconOnly: true,
691
+ onClick: (ev) => {
692
+ ev.stopPropagation();
693
+ onAction?.(open ? "close" : "open");
694
+ }
695
+ })));
707
696
  });
708
697
 
709
698
  // src/shapes/common/FunctionBody.tsx
710
- import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
711
699
  import * as SchemaAST2 from "effect/SchemaAST";
712
700
  import React2, { useRef, useState as useState3 } from "react";
713
701
  import { VoidInput, VoidOutput } from "@dxos/conductor";
@@ -718,7 +706,7 @@ import { createAnchors, getParentShapeElement, rowHeight } from "@dxos/react-ui-
718
706
  import * as Schema2 from "effect/Schema";
719
707
  import * as SchemaAST from "effect/SchemaAST";
720
708
  import { DEFAULT_INPUT as DEFAULT_INPUT2, DEFAULT_OUTPUT as DEFAULT_OUTPUT2 } from "@dxos/conductor";
721
- import { ObjectId as ObjectId3 } from "@dxos/echo/internal";
709
+ import { Obj as Obj3 } from "@dxos/echo";
722
710
  import { Polygon } from "@dxos/react-ui-canvas-editor";
723
711
  var getProperties = (ast) => SchemaAST.getPropertySignatures(ast).map(({ name }) => ({
724
712
  name: name.toString()
@@ -736,13 +724,13 @@ var parseAnchorId = (id) => {
736
724
  };
737
725
  var ComputeShape = Schema2.extend(Polygon, Schema2.Struct({
738
726
  // TODO(burdon): Rename computeNode?
739
- node: Schema2.optional(ObjectId3.annotations({
727
+ node: Schema2.optional(Obj3.ID.annotations({
740
728
  description: "Compute node id"
741
729
  }))
742
730
  }).pipe(Schema2.mutable));
743
731
  var createShape = ({ id, ...rest }) => {
744
732
  return {
745
- id: id ?? ObjectId3.random(),
733
+ id: id ?? Obj3.ID.random(),
746
734
  ...rest
747
735
  };
748
736
  };
@@ -751,70 +739,65 @@ var createShape = ({ id, ...rest }) => {
751
739
  var bodyPadding = 8;
752
740
  var expandedHeight = 200;
753
741
  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
742
+ const { scale } = useCanvasContext();
743
+ const rootRef = useRef(null);
744
+ const [open, setOpen] = useState3(false);
745
+ const handleAction = (action) => {
746
+ if (!rootRef.current) {
747
+ return;
748
+ }
749
+ switch (action) {
750
+ case "open": {
751
+ const el = getParentShapeElement(rootRef.current, shape.id);
752
+ const { height } = el.getBoundingClientRect();
753
+ el.style.height = `${height / scale + expandedHeight}px`;
754
+ setOpen(true);
755
+ break;
803
756
  }
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
757
+ case "close": {
758
+ const el = getParentShapeElement(rootRef.current, shape.id);
759
+ el.style.height = "";
760
+ setOpen(false);
761
+ break;
811
762
  }
812
- }, name2)))), open && /* @__PURE__ */ React2.createElement("div", {
813
- className: "flex flex-col grow overflow-hidden"
814
- }, content));
815
- } finally {
816
- _effect.f();
817
- }
763
+ }
764
+ };
765
+ const inputs = getProperties(inputSchema.ast);
766
+ const outputs = getProperties(outputSchema.ast);
767
+ const columnCount = inputs.length && outputs.length ? 2 : 1;
768
+ return /* @__PURE__ */ React2.createElement(Box, {
769
+ ref: rootRef,
770
+ shape,
771
+ title: name,
772
+ classNames: "divide-y divide-separator",
773
+ open,
774
+ onAction: handleAction,
775
+ ...props
776
+ }, /* @__PURE__ */ React2.createElement("div", {
777
+ className: `grid grid-cols-${columnCount} items-center`,
778
+ style: {
779
+ paddingTop: bodyPadding,
780
+ paddingBottom: bodyPadding
781
+ }
782
+ }, (inputs?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement("div", {
783
+ className: "flex flex-col"
784
+ }, inputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
785
+ key: name2,
786
+ className: "px-2 truncate text-sm font-mono items-center",
787
+ style: {
788
+ height: rowHeight
789
+ }
790
+ }, name2))), (outputs?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement("div", {
791
+ className: "flex flex-col"
792
+ }, outputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
793
+ key: name2,
794
+ className: "px-2 truncate text-sm font-mono items-center text-right",
795
+ style: {
796
+ height: rowHeight
797
+ }
798
+ }, name2)))), open && /* @__PURE__ */ React2.createElement("div", {
799
+ className: "flex flex-col grow overflow-hidden"
800
+ }, content));
818
801
  };
819
802
  var getHeight = (input) => {
820
803
  const properties = SchemaAST2.getPropertySignatures(input.ast);
@@ -835,30 +818,23 @@ var createFunctionAnchors = (shape, input = VoidInput, output = VoidOutput) => {
835
818
  };
836
819
 
837
820
  // src/shapes/common/TypeSelect.tsx
838
- import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
839
821
  import React3 from "react";
840
822
  import { ComputeValueType } from "@dxos/conductor";
841
823
  import { Select } from "@dxos/react-ui";
842
824
  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
- }
825
+ return /* @__PURE__ */ React3.createElement(Select.Root, {
826
+ value,
827
+ onValueChange
828
+ }, /* @__PURE__ */ React3.createElement(Select.TriggerButton, {
829
+ variant: "ghost",
830
+ classNames: "w-full px-0!"
831
+ }), /* @__PURE__ */ React3.createElement(Select.Portal, null, /* @__PURE__ */ React3.createElement(Select.Content, null, /* @__PURE__ */ React3.createElement(Select.ScrollUpButton, null), /* @__PURE__ */ React3.createElement(Select.Viewport, null, ComputeValueType.literals.map((type) => /* @__PURE__ */ React3.createElement(Select.Option, {
832
+ key: type,
833
+ value: type
834
+ }, type))), /* @__PURE__ */ React3.createElement(Select.ScrollDownButton, null), /* @__PURE__ */ React3.createElement(Select.Arrow, null))));
858
835
  };
859
836
 
860
837
  // src/shapes/Array.tsx
861
- import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
862
838
  import * as Schema3 from "effect/Schema";
863
839
  import React4 from "react";
864
840
  import { ReducerInput, ReducerOutput } from "@dxos/conductor";
@@ -866,16 +842,11 @@ var ReducerShape = Schema3.extend(ComputeShape, Schema3.Struct({
866
842
  type: Schema3.Literal("reducer")
867
843
  }));
868
844
  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
- }
845
+ return /* @__PURE__ */ React4.createElement(FunctionBody, {
846
+ shape,
847
+ inputSchema: ReducerInput,
848
+ outputSchema: ReducerOutput
849
+ });
879
850
  };
880
851
  var createReducer = ({ id, size = {
881
852
  width: 192,
@@ -895,7 +866,6 @@ var reducerShape = {
895
866
  };
896
867
 
897
868
  // src/shapes/Append.tsx
898
- import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
899
869
  import * as Schema4 from "effect/Schema";
900
870
  import React5 from "react";
901
871
  import { AppendInput } from "@dxos/conductor";
@@ -911,15 +881,10 @@ var createAppend = (props) => createShape({
911
881
  ...props
912
882
  });
913
883
  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
- }
884
+ return /* @__PURE__ */ React5.createElement(FunctionBody, {
885
+ shape,
886
+ inputSchema: AppendInput
887
+ });
923
888
  };
924
889
  var appendShape = {
925
890
  type: "append",
@@ -931,7 +896,6 @@ var appendShape = {
931
896
  };
932
897
 
933
898
  // src/shapes/Audio.tsx
934
- import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
935
899
  import * as Schema5 from "effect/Schema";
936
900
  import React6, { useEffect as useEffect3, useState as useState4 } from "react";
937
901
  import { Icon as Icon2 } from "@dxos/react-ui";
@@ -948,29 +912,24 @@ var createAudio = (props) => createShape({
948
912
  ...props
949
913
  });
950
914
  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
- }
915
+ const { node } = useComputeNodeState(shape);
916
+ const [active, setActive] = useState4(false);
917
+ useEffect3(() => {
918
+ node.value = active;
919
+ }, [
920
+ active
921
+ ]);
922
+ return /* @__PURE__ */ React6.createElement("div", {
923
+ className: "flex w-full justify-center items-center"
924
+ }, /* @__PURE__ */ React6.createElement(Icon2, {
925
+ icon: active ? "ph--microphone--regular" : "ph--microphone-slash--regular",
926
+ classNames: [
927
+ "transition opacity-20 duration-1000",
928
+ active && "opacity-100 text-error-text"
929
+ ],
930
+ size: 8,
931
+ onClick: () => setActive(!active)
932
+ }));
974
933
  };
975
934
  var audioShape = {
976
935
  type: "audio",
@@ -987,7 +946,6 @@ var audioShape = {
987
946
  };
988
947
 
989
948
  // src/shapes/Beacon.tsx
990
- import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
991
949
  import * as Schema6 from "effect/Schema";
992
950
  import React7 from "react";
993
951
  import { DEFAULT_INPUT as DEFAULT_INPUT3, isTruthy } from "@dxos/conductor";
@@ -1005,24 +963,19 @@ var createBeacon = (props) => createShape({
1005
963
  ...props
1006
964
  });
1007
965
  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
- }
966
+ const { runtime } = useComputeNodeState(shape);
967
+ const input = runtime.inputs[DEFAULT_INPUT3];
968
+ const value = input?.type === "executed" ? input.value : false;
969
+ return /* @__PURE__ */ React7.createElement("div", {
970
+ className: "flex w-full justify-center items-center"
971
+ }, /* @__PURE__ */ React7.createElement(Icon3, {
972
+ icon: "ph--sun--regular",
973
+ classNames: [
974
+ "transition opacity-20 duration-1000",
975
+ isTruthy(value) && "opacity-100 text-yellow-500"
976
+ ],
977
+ size: 8
978
+ }));
1026
979
  };
1027
980
  var beaconShape = {
1028
981
  type: "beacon",
@@ -1090,7 +1043,7 @@ var createSymbol = (pathConstructor, inputs) => ({
1090
1043
  });
1091
1044
  return /* @__PURE__ */ React8.createElement("svg", {
1092
1045
  viewBox: `0 0 ${width} ${height}`,
1093
- className: "w-full h-full"
1046
+ className: "h-full w-full"
1094
1047
  }, getAnchorPoints({
1095
1048
  x: 0,
1096
1049
  y: centerY
@@ -1212,7 +1165,6 @@ var notShape = defineShape({
1212
1165
  });
1213
1166
 
1214
1167
  // src/shapes/Chat.tsx
1215
- import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
1216
1168
  import * as Schema8 from "effect/Schema";
1217
1169
  import React9, { useRef as useRef2 } from "react";
1218
1170
  import { DEFAULT_OUTPUT as DEFAULT_OUTPUT3 } from "@dxos/conductor";
@@ -1222,28 +1174,23 @@ var ChatShape = Schema8.extend(ComputeShape, Schema8.Struct({
1222
1174
  type: Schema8.Literal("chat")
1223
1175
  }));
1224
1176
  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
- }
1177
+ const { runtime } = useComputeNodeState(shape);
1178
+ const inputRef = useRef2(null);
1179
+ const handleEnter = (text) => {
1180
+ const value = text.trim();
1181
+ if (value.length) {
1182
+ runtime.setOutput(DEFAULT_OUTPUT3, value);
1183
+ inputRef.current?.setText("");
1184
+ }
1185
+ };
1186
+ return /* @__PURE__ */ React9.createElement(Box, {
1187
+ shape,
1188
+ title
1189
+ }, /* @__PURE__ */ React9.createElement(TextBox, {
1190
+ ref: inputRef,
1191
+ onEnter: handleEnter,
1192
+ ...props
1193
+ }));
1247
1194
  };
1248
1195
  var createChat = (props) => createShape({
1249
1196
  type: "chat",
@@ -1273,7 +1220,6 @@ var chatShape = {
1273
1220
  };
1274
1221
 
1275
1222
  // src/shapes/Constant.tsx
1276
- import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
1277
1223
  import * as Schema9 from "effect/Schema";
1278
1224
  import React10, { useCallback as useCallback2, useRef as useRef3, useState as useState5 } from "react";
1279
1225
  import { ComputeValueType as ComputeValueType2 } from "@dxos/conductor";
@@ -1297,57 +1243,52 @@ var inferType = (value) => {
1297
1243
  }
1298
1244
  };
1299
1245
  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;
1246
+ const { node } = useComputeNodeState(shape);
1247
+ const [type, setType] = useState5(inferType(node.value) ?? ComputeValueType2.literals[0]);
1248
+ const inputRef = useRef3(null);
1249
+ const handleEnter = useCallback2((text) => {
1250
+ const value = text.trim();
1251
+ if (value.length) {
1252
+ if (type === "number") {
1253
+ const floatValue = parseFloat(value);
1254
+ if (!isNaN(floatValue)) {
1255
+ node.value = floatValue;
1317
1256
  }
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) => {
1257
+ } else if (type === "object") {
1258
+ node.value = safeParseJson(value, {});
1259
+ } else {
1345
1260
  node.value = value;
1346
1261
  }
1347
- }))));
1348
- } finally {
1349
- _effect.f();
1350
- }
1262
+ inputRef.current?.focus();
1263
+ }
1264
+ }, [
1265
+ type
1266
+ ]);
1267
+ return /* @__PURE__ */ React10.createElement(Box, {
1268
+ shape,
1269
+ title,
1270
+ status: /* @__PURE__ */ React10.createElement(TypeSelect, {
1271
+ value: type,
1272
+ onValueChange: setType
1273
+ })
1274
+ }, (type === "string" || type === "number") && /* @__PURE__ */ React10.createElement(TextBox2, {
1275
+ ...props,
1276
+ ref: inputRef,
1277
+ value: node.value,
1278
+ onEnter: handleEnter
1279
+ }), type === "object" && /* @__PURE__ */ React10.createElement(TextBox2, {
1280
+ ...props,
1281
+ ref: inputRef,
1282
+ value: JSON.stringify(node.value, null, 2),
1283
+ language: "json"
1284
+ }), type === "boolean" && /* @__PURE__ */ React10.createElement("div", {
1285
+ className: "flex grow justify-center items-center"
1286
+ }, /* @__PURE__ */ React10.createElement(Input.Root, null, /* @__PURE__ */ React10.createElement(Input.Switch, {
1287
+ checked: node.value,
1288
+ onCheckedChange: (value) => {
1289
+ node.value = value;
1290
+ }
1291
+ }))));
1351
1292
  };
1352
1293
  var createConstant = (props) => createShape({
1353
1294
  type: "constant",
@@ -1376,7 +1317,6 @@ var constantShape = {
1376
1317
  };
1377
1318
 
1378
1319
  // src/shapes/Database.tsx
1379
- import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
1380
1320
  import * as Schema10 from "effect/Schema";
1381
1321
  import React11 from "react";
1382
1322
  import { createAnchorMap as createAnchorMap5 } from "@dxos/react-ui-canvas-editor";
@@ -1392,14 +1332,9 @@ var createDatabase = (props) => createShape({
1392
1332
  ...props
1393
1333
  });
1394
1334
  var DatabaseComponent = ({ shape }) => {
1395
- var _effect = _useSignals10();
1396
- try {
1397
- return /* @__PURE__ */ React11.createElement(Box, {
1398
- shape
1399
- });
1400
- } finally {
1401
- _effect.f();
1402
- }
1335
+ return /* @__PURE__ */ React11.createElement(Box, {
1336
+ shape
1337
+ });
1403
1338
  };
1404
1339
  var databaseShape = {
1405
1340
  type: "database",
@@ -1415,18 +1350,83 @@ var databaseShape = {
1415
1350
  })
1416
1351
  };
1417
1352
 
1418
- // src/shapes/Function.tsx
1419
- import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
1353
+ // src/shapes/Feed.tsx
1420
1354
  import * as Schema11 from "effect/Schema";
1421
- import React12, { useCallback as useCallback3, useRef as useRef4 } from "react";
1355
+ import React12, { Fragment } from "react";
1356
+ import { DEFAULT_OUTPUT as DEFAULT_OUTPUT4, QueueInput, QueueOutput } from "@dxos/conductor";
1357
+ import { ScrollArea } from "@dxos/react-ui";
1358
+ import { mx as mx2 } from "@dxos/ui-theme";
1359
+ var FeedShape = Schema11.extend(ComputeShape, Schema11.Struct({
1360
+ type: Schema11.Literal("queue")
1361
+ }));
1362
+ var createFeed = (props) => createShape({
1363
+ type: "queue",
1364
+ size: {
1365
+ width: 256,
1366
+ height: 512
1367
+ },
1368
+ ...props
1369
+ });
1370
+ var FeedComponent = ({ shape }) => {
1371
+ const { runtime } = useComputeNodeState(shape);
1372
+ const items = runtime.outputs[DEFAULT_OUTPUT4]?.type === "executed" ? runtime.outputs[DEFAULT_OUTPUT4].value : [];
1373
+ const handleAction = (action) => {
1374
+ if (action === "run") {
1375
+ runtime.evalNode();
1376
+ }
1377
+ };
1378
+ return /* @__PURE__ */ React12.createElement(Box, {
1379
+ shape,
1380
+ status: `${items.length} items`,
1381
+ onAction: handleAction
1382
+ }, /* @__PURE__ */ React12.createElement(ScrollArea.Root, {
1383
+ orientation: "vertical"
1384
+ }, /* @__PURE__ */ React12.createElement(ScrollArea.Viewport, {
1385
+ classNames: "divide-y divide-separator"
1386
+ }, [
1387
+ ...items
1388
+ ].map((item, i) => /* @__PURE__ */ React12.createElement(FeedItem, {
1389
+ key: i,
1390
+ classNames: "p-1 px-2",
1391
+ item
1392
+ })))));
1393
+ };
1394
+ var FeedItem = ({ classNames, item }) => {
1395
+ if (typeof item !== "object") {
1396
+ return /* @__PURE__ */ React12.createElement("div", {
1397
+ className: mx2(classNames, "whitespace-pre-wrap")
1398
+ }, item);
1399
+ }
1400
+ return /* @__PURE__ */ React12.createElement("div", {
1401
+ className: mx2("grid grid-cols-[80px_1fr]", classNames)
1402
+ }, Object.entries(item).map(([key, value]) => /* @__PURE__ */ React12.createElement(Fragment, {
1403
+ key
1404
+ }, /* @__PURE__ */ React12.createElement("div", {
1405
+ className: "p-1 text-xs text-subdued"
1406
+ }, key), /* @__PURE__ */ React12.createElement("div", null, typeof value === "string" ? value : JSON.stringify(value)))));
1407
+ };
1408
+ var feedShape = {
1409
+ type: "feed",
1410
+ name: "Feed",
1411
+ icon: "ph--queue--regular",
1412
+ component: FeedComponent,
1413
+ createShape: createFeed,
1414
+ getAnchors: (shape) => createFunctionAnchors(shape, QueueInput, QueueOutput),
1415
+ resizable: true
1416
+ };
1417
+
1418
+ // src/shapes/Function.tsx
1419
+ import * as Schema12 from "effect/Schema";
1420
+ import React13, { useCallback as useCallback3, useRef as useRef4 } from "react";
1422
1421
  import { AnyOutput, FunctionInput } from "@dxos/conductor";
1423
1422
  import { Ref as Ref2, getSnapshot, isInstanceOf } from "@dxos/echo/internal";
1424
- import { FunctionType, ScriptType } from "@dxos/functions";
1423
+ import { Script } from "@dxos/functions";
1424
+ import { Operation } from "@dxos/operation";
1425
1425
  import { useClient } from "@dxos/react-client";
1426
1426
  import { Filter, parseId } from "@dxos/react-client/echo";
1427
1427
  import { TextBox as TextBox3 } from "@dxos/react-ui-canvas-editor";
1428
- var FunctionShape = Schema11.extend(ComputeShape, Schema11.Struct({
1429
- type: Schema11.Literal("function")
1428
+ var FunctionShape = Schema12.extend(ComputeShape, Schema12.Struct({
1429
+ type: Schema12.Literal("function")
1430
1430
  }));
1431
1431
  var createFunction = (props) => createShape({
1432
1432
  type: "function",
@@ -1437,59 +1437,54 @@ var createFunction = (props) => createShape({
1437
1437
  ...props
1438
1438
  });
1439
1439
  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
- }
1440
+ const client = useClient();
1441
+ const { node, runtime } = useComputeNodeState(shape);
1442
+ const inputRef = useRef4(null);
1443
+ const handleEnter = useCallback3(async (text) => {
1444
+ const value = text.trim();
1445
+ const { spaceId, objectId } = parseId(value);
1446
+ if (!spaceId || !objectId) {
1447
+ return;
1448
+ }
1449
+ const space = client.spaces.get(spaceId);
1450
+ const object = space?.db.getObjectById(objectId);
1451
+ if (!space || !isInstanceOf(Script.Script, object)) {
1452
+ return;
1453
+ }
1454
+ const [fn] = await space.db.query(Filter.type(Operation.PersistentOperation, {
1455
+ source: Ref2.make(object)
1456
+ })).run();
1457
+ if (!fn) {
1458
+ return;
1459
+ }
1460
+ node.value = value;
1461
+ node.function = Ref2.make(fn);
1462
+ node.inputSchema = fn.inputSchema ? getSnapshot(fn.inputSchema) : void 0;
1463
+ node.outputSchema = fn.outputSchema ? getSnapshot(fn.outputSchema) : void 0;
1464
+ }, [
1465
+ client,
1466
+ node
1467
+ ]);
1468
+ const handleAction = useCallback3((action) => {
1469
+ if (action !== "run") {
1470
+ return;
1471
+ }
1472
+ runtime.evalNode();
1473
+ }, [
1474
+ runtime
1475
+ ]);
1476
+ return /* @__PURE__ */ React13.createElement(Box, {
1477
+ shape,
1478
+ title: "Function",
1479
+ onAction: handleAction
1480
+ }, /* @__PURE__ */ React13.createElement(TextBox3, {
1481
+ ...props,
1482
+ ref: inputRef,
1483
+ value: node.value,
1484
+ language: node.valueType === "object" ? "json" : void 0,
1485
+ onBlur: handleEnter,
1486
+ onEnter: handleEnter
1487
+ }));
1493
1488
  };
1494
1489
  var functionShape = {
1495
1490
  type: "function",
@@ -1501,12 +1496,12 @@ var functionShape = {
1501
1496
  };
1502
1497
 
1503
1498
  // src/shapes/Gpt.tsx
1504
- import { useSignals as _useSignals12 } from "@preact-signals/safe-react/tracking";
1505
- import * as Schema12 from "effect/Schema";
1506
- import React13, { useEffect as useEffect4, useState as useState6 } from "react";
1499
+ import * as Schema13 from "effect/Schema";
1500
+ import React14, { useEffect as useEffect4, useState as useState6 } from "react";
1507
1501
  import { GptInput, GptOutput } from "@dxos/conductor";
1508
- var GptShape = Schema12.extend(ComputeShape, Schema12.Struct({
1509
- type: Schema12.Literal("gpt")
1502
+ import { ScrollArea as ScrollArea2 } from "@dxos/react-ui";
1503
+ var GptShape = Schema13.extend(ComputeShape, Schema13.Struct({
1504
+ type: Schema13.Literal("gpt")
1510
1505
  }));
1511
1506
  var createGpt = (props) => createShape({
1512
1507
  type: "gpt",
@@ -1517,54 +1512,50 @@ var createGpt = (props) => createShape({
1517
1512
  ...props
1518
1513
  });
1519
1514
  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
- }
1515
+ const { meta, runtime } = useComputeNodeState(shape);
1516
+ const [text, setText] = useState6("");
1517
+ const [tokens, setTokens] = useState6(0);
1518
+ useEffect4(() => {
1519
+ return runtime.subscribeToEventLog((ev) => {
1520
+ switch (ev.type) {
1521
+ case "begin-compute": {
1522
+ setText("");
1523
+ break;
1524
+ }
1525
+ case "custom": {
1526
+ const token = ev.event;
1527
+ switch (token.type) {
1528
+ case "content_block_delta":
1529
+ switch (token.delta.type) {
1530
+ case "text_delta": {
1531
+ const delta = token.delta.text;
1532
+ setText((prev) => {
1533
+ const text2 = prev + delta;
1534
+ setTokens(text2.split(" ").length);
1535
+ return text2;
1536
+ });
1537
+ break;
1546
1538
  }
1547
- break;
1548
- }
1549
- break;
1539
+ }
1540
+ break;
1550
1541
  }
1542
+ break;
1551
1543
  }
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
1544
+ }
1564
1545
  });
1565
- } finally {
1566
- _effect.f();
1567
- }
1546
+ }, [
1547
+ runtime?.subscribeToEventLog
1548
+ ]);
1549
+ return /* @__PURE__ */ React14.createElement(FunctionBody, {
1550
+ shape,
1551
+ content: /* @__PURE__ */ React14.createElement(ScrollArea2.Root, {
1552
+ orientation: "vertical",
1553
+ thin: true
1554
+ }, /* @__PURE__ */ React14.createElement(ScrollArea2.Viewport, null, text)),
1555
+ status: `${tokens} tokens`,
1556
+ inputSchema: meta.input,
1557
+ outputSchema: meta.output
1558
+ });
1568
1559
  };
1569
1560
  var gptShape = {
1570
1561
  type: "gpt",
@@ -1576,44 +1567,162 @@ var gptShape = {
1576
1567
  openable: true
1577
1568
  };
1578
1569
 
1570
+ // src/shapes/GptRealtime.tsx
1571
+ import * as Schema14 from "effect/Schema";
1572
+ import React15, { useState as useState7 } from "react";
1573
+ import { log as log2 } from "@dxos/log";
1574
+ import { useConfig } from "@dxos/react-client";
1575
+ import { Icon as Icon4 } from "@dxos/react-ui";
1576
+ var __dxlog_file6 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/GptRealtime.tsx";
1577
+ var GptRealtimeShape = Schema14.extend(ComputeShape, Schema14.Struct({
1578
+ type: Schema14.Literal("gpt-realtime")
1579
+ }));
1580
+ var createGptRealtime = (props) => createShape({
1581
+ type: "gpt-realtime",
1582
+ size: {
1583
+ width: 256,
1584
+ height: 256
1585
+ },
1586
+ ...props
1587
+ });
1588
+ var GptRealtimeComponent = ({ shape }) => {
1589
+ const [isLive, setIsLive] = useState7(false);
1590
+ const [isReady, setIsReady] = useState7(false);
1591
+ const config = useConfig();
1592
+ const start = async () => {
1593
+ setIsLive(true);
1594
+ try {
1595
+ const peerConnection = new RTCPeerConnection();
1596
+ peerConnection.ontrack = (event) => {
1597
+ const audioElement = document.createElement("audio");
1598
+ audioElement.srcObject = event.streams[0];
1599
+ audioElement.autoplay = true;
1600
+ audioElement.controls = false;
1601
+ audioElement.style.display = "none";
1602
+ document.body.appendChild(audioElement);
1603
+ setIsReady(true);
1604
+ };
1605
+ const stream = await navigator.mediaDevices.getUserMedia({
1606
+ audio: true
1607
+ });
1608
+ stream.getTracks().forEach((track) => peerConnection.addTransceiver(track, {
1609
+ direction: "sendrecv"
1610
+ }));
1611
+ const offer = await peerConnection.createOffer();
1612
+ await peerConnection.setLocalDescription(offer);
1613
+ const AiServiceUrl = new URL("/rtc-connect", config.values.runtime?.services?.ai?.server ?? DEFAULT_AI_SERVICE_URL);
1614
+ const response = await fetch(AiServiceUrl, {
1615
+ method: "POST",
1616
+ body: offer.sdp,
1617
+ headers: {
1618
+ "Content-Type": "application/sdp"
1619
+ }
1620
+ });
1621
+ const answer = await response.text();
1622
+ await peerConnection.setRemoteDescription({
1623
+ sdp: answer,
1624
+ type: "answer"
1625
+ });
1626
+ const dataChannel = peerConnection.createDataChannel("response");
1627
+ const configureData = () => {
1628
+ log2.info("Configuring data channel", void 0, {
1629
+ F: __dxlog_file6,
1630
+ L: 87,
1631
+ S: void 0,
1632
+ C: (f, a) => f(...a)
1633
+ });
1634
+ const event = {
1635
+ type: "session.update",
1636
+ session: {
1637
+ modalities: [
1638
+ "text",
1639
+ "audio"
1640
+ ],
1641
+ // Provide the tools. Note they match the keys in the `fns` object above
1642
+ tools: []
1643
+ }
1644
+ };
1645
+ dataChannel.send(JSON.stringify(event));
1646
+ };
1647
+ dataChannel.addEventListener("open", (ev) => {
1648
+ log2.info("Opening data channel", {
1649
+ ev
1650
+ }, {
1651
+ F: __dxlog_file6,
1652
+ L: 100,
1653
+ S: void 0,
1654
+ C: (f, a) => f(...a)
1655
+ });
1656
+ configureData();
1657
+ });
1658
+ dataChannel.addEventListener("message", async (ev) => {
1659
+ const msg = JSON.parse(ev.data);
1660
+ if (msg.type === "response.function_call_arguments.done") {
1661
+ }
1662
+ });
1663
+ } catch (error) {
1664
+ log2.error("Error in realtime session:", {
1665
+ error
1666
+ }, {
1667
+ F: __dxlog_file6,
1668
+ L: 140,
1669
+ S: void 0,
1670
+ C: (f, a) => f(...a)
1671
+ });
1672
+ throw error;
1673
+ }
1674
+ };
1675
+ return /* @__PURE__ */ React15.createElement("div", {
1676
+ className: "flex w-full justify-center items-center"
1677
+ }, /* @__PURE__ */ React15.createElement(Icon4, {
1678
+ icon: isReady ? "ph--waveform--regular" : isLive ? "ph--pulse--regular" : "ph--play--regular",
1679
+ size: 16,
1680
+ classNames: !isLive && "cursor-pointer",
1681
+ onClick: start
1682
+ }));
1683
+ };
1684
+ var gptRealtimeShape = {
1685
+ type: "gpt-realtime",
1686
+ name: "GPT Realtime",
1687
+ icon: "ph--pulse--regular",
1688
+ component: GptRealtimeComponent,
1689
+ createShape: createGptRealtime,
1690
+ // TODO(dmaretskyi): Can we fetch the schema dynamically?
1691
+ getAnchors: (shape) => createFunctionAnchors(shape, Schema14.Struct({
1692
+ audio: Schema14.Any
1693
+ }), Schema14.Struct({})),
1694
+ resizable: true
1695
+ };
1696
+ var DEFAULT_AI_SERVICE_URL = "http://localhost:8788";
1697
+
1579
1698
  // src/shapes/Json.tsx
1580
- import { useSignals as _useSignals13 } from "@preact-signals/safe-react/tracking";
1581
- import * as Schema13 from "effect/Schema";
1582
- import React14 from "react";
1699
+ import * as Schema15 from "effect/Schema";
1700
+ import React16 from "react";
1583
1701
  import { DEFAULT_INPUT as DEFAULT_INPUT4, DefaultOutput, JsonTransformInput } from "@dxos/conductor";
1584
1702
  import { createAnchorMap as createAnchorMap6 } from "@dxos/react-ui-canvas-editor";
1585
- import { JsonFilter } from "@dxos/react-ui-syntax-highlighter";
1586
- var JsonShape = Schema13.extend(ComputeShape, Schema13.Struct({
1587
- type: Schema13.Literal("json")
1703
+ import { Syntax } from "@dxos/react-ui-syntax-highlighter";
1704
+ var JsonShape = Schema15.extend(ComputeShape, Schema15.Struct({
1705
+ type: Schema15.Literal("json")
1588
1706
  }));
1589
- var JsonTransformShape = Schema13.extend(ComputeShape, Schema13.Struct({
1590
- type: Schema13.Literal("json-transform")
1707
+ var JsonTransformShape = Schema15.extend(ComputeShape, Schema15.Struct({
1708
+ type: Schema15.Literal("json-transform")
1591
1709
  }));
1592
1710
  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
- }
1711
+ const { runtime } = useComputeNodeState(shape);
1712
+ const input = runtime.inputs[DEFAULT_INPUT4];
1713
+ const value = input?.type === "executed" ? input.value : void 0;
1714
+ return /* @__PURE__ */ React16.createElement(Box, {
1715
+ shape
1716
+ }, /* @__PURE__ */ React16.createElement(Syntax.Root, {
1717
+ data: value
1718
+ }, /* @__PURE__ */ React16.createElement(Syntax.Content, null, /* @__PURE__ */ React16.createElement(Syntax.Filter, null), /* @__PURE__ */ React16.createElement(Syntax.Viewport, null, /* @__PURE__ */ React16.createElement(Syntax.Code, {
1719
+ classNames: "text-xs"
1720
+ })))));
1607
1721
  };
1608
1722
  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
- }
1723
+ return /* @__PURE__ */ React16.createElement(Box, {
1724
+ shape
1725
+ });
1617
1726
  };
1618
1727
  var createJson = (props) => createShape({
1619
1728
  type: "json",
@@ -1627,7 +1736,7 @@ var jsonShape = {
1627
1736
  type: "json",
1628
1737
  name: "JSON",
1629
1738
  icon: "ph--code--regular",
1630
- component: (props) => /* @__PURE__ */ React14.createElement(JsonComponent, props),
1739
+ component: (props) => /* @__PURE__ */ React16.createElement(JsonComponent, props),
1631
1740
  createShape: createJson,
1632
1741
  getAnchors: (shape) => createAnchorMap6(shape, {
1633
1742
  [createAnchorId("input")]: {
@@ -1653,46 +1762,35 @@ var jsonTransformShape = {
1653
1762
  type: "json-transform",
1654
1763
  name: "Transform",
1655
1764
  icon: "ph--shuffle-simple--regular",
1656
- component: (props) => /* @__PURE__ */ React14.createElement(JsonTransformComponent, props),
1765
+ component: (props) => /* @__PURE__ */ React16.createElement(JsonTransformComponent, props),
1657
1766
  createShape: createJsonTransform,
1658
1767
  getAnchors: (shape) => createFunctionAnchors(shape, JsonTransformInput, DefaultOutput),
1659
1768
  resizable: true
1660
1769
  };
1661
1770
 
1662
1771
  // src/shapes/Logic.tsx
1663
- import { useSignals as _useSignals14 } from "@preact-signals/safe-react/tracking";
1664
- import * as Schema14 from "effect/Schema";
1665
- import React15 from "react";
1772
+ import * as Schema16 from "effect/Schema";
1773
+ import React17 from "react";
1666
1774
  import { IfElseInput, IfElseOutput, IfInput, IfOutput } from "@dxos/conductor";
1667
- var IfShape = Schema14.extend(ComputeShape, Schema14.Struct({
1668
- type: Schema14.Literal("if")
1775
+ var IfShape = Schema16.extend(ComputeShape, Schema16.Struct({
1776
+ type: Schema16.Literal("if")
1669
1777
  }));
1670
- var IfElseShape = Schema14.extend(ComputeShape, Schema14.Struct({
1671
- type: Schema14.Literal("if-else")
1778
+ var IfElseShape = Schema16.extend(ComputeShape, Schema16.Struct({
1779
+ type: Schema16.Literal("if-else")
1672
1780
  }));
1673
1781
  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
- }
1782
+ return /* @__PURE__ */ React17.createElement(FunctionBody, {
1783
+ shape,
1784
+ inputSchema: IfInput,
1785
+ outputSchema: IfOutput
1786
+ });
1684
1787
  };
1685
1788
  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
- }
1789
+ return /* @__PURE__ */ React17.createElement(FunctionBody, {
1790
+ shape,
1791
+ inputSchema: IfElseInput,
1792
+ outputSchema: IfElseOutput
1793
+ });
1696
1794
  };
1697
1795
  var createIf = (props) => createShape({
1698
1796
  type: "if",
@@ -1706,7 +1804,7 @@ var ifShape = {
1706
1804
  type: "if",
1707
1805
  name: "IF",
1708
1806
  icon: "ph--arrows-split--regular",
1709
- component: (props) => /* @__PURE__ */ React15.createElement(IfComponent, props),
1807
+ component: (props) => /* @__PURE__ */ React17.createElement(IfComponent, props),
1710
1808
  createShape: createIf,
1711
1809
  getAnchors: (shape) => createFunctionAnchors(shape, IfInput, IfOutput)
1712
1810
  };
@@ -1722,95 +1820,21 @@ var ifElseShape = {
1722
1820
  type: "if-else",
1723
1821
  name: "IF/ELSE",
1724
1822
  icon: "ph--arrows-merge--regular",
1725
- component: (props) => /* @__PURE__ */ React15.createElement(IfElseComponent, props),
1823
+ component: (props) => /* @__PURE__ */ React17.createElement(IfElseComponent, props),
1726
1824
  createShape: createIfElse,
1727
1825
  getAnchors: (shape) => createFunctionAnchors(shape, IfElseInput, IfElseOutput)
1728
1826
  };
1729
1827
 
1730
- // src/shapes/Queue.tsx
1731
- import { useSignals as _useSignals15 } from "@preact-signals/safe-react/tracking";
1732
- import * as Schema15 from "effect/Schema";
1733
- import React16, { Fragment } from "react";
1734
- import { DEFAULT_OUTPUT as DEFAULT_OUTPUT4, QueueInput, QueueOutput } from "@dxos/conductor";
1735
- import { mx as mx2 } from "@dxos/react-ui-theme";
1736
- var QueueShape = Schema15.extend(ComputeShape, Schema15.Struct({
1737
- type: Schema15.Literal("queue")
1738
- }));
1739
- var createQueue = (props) => createShape({
1740
- type: "queue",
1741
- size: {
1742
- width: 256,
1743
- height: 512
1744
- },
1745
- ...props
1746
- });
1747
- 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
- }
1773
- };
1774
- 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
- }
1782
- 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();
1791
- }
1792
- };
1793
- var queueShape = {
1794
- type: "queue",
1795
- name: "Queue",
1796
- icon: "ph--queue--regular",
1797
- component: QueueComponent,
1798
- createShape: createQueue,
1799
- getAnchors: (shape) => createFunctionAnchors(shape, QueueInput, QueueOutput),
1800
- resizable: true
1801
- };
1802
-
1803
1828
  // src/shapes/RNG.tsx
1804
- import { useSignals as _useSignals16 } from "@preact-signals/safe-react/tracking";
1805
- import * as Schema16 from "effect/Schema";
1806
- import React17, { useEffect as useEffect5, useState as useState7 } from "react";
1829
+ import * as Schema17 from "effect/Schema";
1830
+ import React18, { useEffect as useEffect5, useState as useState8 } from "react";
1807
1831
  import { DEFAULT_OUTPUT as DEFAULT_OUTPUT5 } from "@dxos/conductor";
1808
- import { Icon as Icon4 } from "@dxos/react-ui";
1832
+ import { Icon as Icon5 } from "@dxos/react-ui";
1809
1833
  import { createAnchorMap as createAnchorMap7 } from "@dxos/react-ui-canvas-editor";
1810
- var RandomShape = Schema16.extend(ComputeShape, Schema16.Struct({
1811
- type: Schema16.Literal("rng"),
1812
- min: Schema16.optional(Schema16.Number),
1813
- max: Schema16.optional(Schema16.Number)
1834
+ var RandomShape = Schema17.extend(ComputeShape, Schema17.Struct({
1835
+ type: Schema17.Literal("rng"),
1836
+ min: Schema17.optional(Schema17.Number),
1837
+ max: Schema17.optional(Schema17.Number)
1814
1838
  }));
1815
1839
  var createRandom = (props) => createShape({
1816
1840
  type: "rng",
@@ -1830,42 +1854,37 @@ var icons = [
1830
1854
  ];
1831
1855
  var pickIcon = () => icons[Math.floor(Math.random() * icons.length)];
1832
1856
  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);
1857
+ const { runtime } = useComputeNodeState(shape);
1858
+ const [spin, setSpin] = useState8(false);
1859
+ const [icon, setIcon] = useState8(pickIcon());
1860
+ useEffect5(() => {
1861
+ if (!spin) {
1862
+ return;
1863
+ }
1864
+ const i = setInterval(() => setIcon(pickIcon()), 250);
1865
+ const t1 = setTimeout(() => clearInterval(i), 900);
1866
+ const t2 = setTimeout(() => setSpin(false), 1100);
1867
+ return () => {
1868
+ clearInterval(i);
1869
+ clearTimeout(t1);
1870
+ clearTimeout(t2);
1857
1871
  };
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
- }
1872
+ }, [
1873
+ spin
1874
+ ]);
1875
+ const handleClick = (ev) => {
1876
+ ev.stopPropagation();
1877
+ runtime.setOutput(DEFAULT_OUTPUT5, Math.random());
1878
+ setSpin(true);
1879
+ };
1880
+ return /* @__PURE__ */ React18.createElement("div", {
1881
+ className: "flex grow items-center justify-center"
1882
+ }, /* @__PURE__ */ React18.createElement(Icon5, {
1883
+ icon,
1884
+ classNames: spin && "animate-[spin_1s]",
1885
+ size: 10,
1886
+ onClick: handleClick
1887
+ }));
1869
1888
  };
1870
1889
  var randomShape = {
1871
1890
  type: "rng",
@@ -1882,14 +1901,13 @@ var randomShape = {
1882
1901
  };
1883
1902
 
1884
1903
  // src/shapes/Scope.tsx
1885
- import { useSignals as _useSignals17 } from "@preact-signals/safe-react/tracking";
1886
- import * as Schema17 from "effect/Schema";
1887
- import React18 from "react";
1904
+ import * as Schema18 from "effect/Schema";
1905
+ import React19 from "react";
1888
1906
  import { DEFAULT_INPUT as DEFAULT_INPUT5 } from "@dxos/conductor";
1889
1907
  import { createAnchorMap as createAnchorMap8 } from "@dxos/react-ui-canvas-editor";
1890
1908
  import { Chaos, shaderPresets, useAudioStream } from "@dxos/react-ui-sfx";
1891
- var ScopeShape = Schema17.extend(ComputeShape, Schema17.Struct({
1892
- type: Schema17.Literal("scope")
1909
+ var ScopeShape = Schema18.extend(ComputeShape, Schema18.Struct({
1910
+ type: Schema18.Literal("scope")
1893
1911
  }));
1894
1912
  var createScope = (props) => createShape({
1895
1913
  type: "scope",
@@ -1901,25 +1919,20 @@ var createScope = (props) => createShape({
1901
1919
  ...props
1902
1920
  });
1903
1921
  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
- }
1922
+ const { runtime } = useComputeNodeState(shape);
1923
+ const input = runtime.inputs[DEFAULT_INPUT5];
1924
+ const active = input?.type === "executed" ? input.value : false;
1925
+ const { getAverage } = useAudioStream(active);
1926
+ return /* @__PURE__ */ React19.createElement("div", {
1927
+ className: "flex w-full justify-center items-center bg-black"
1928
+ }, /* @__PURE__ */ React19.createElement(Chaos, {
1929
+ active,
1930
+ getValue: getAverage,
1931
+ options: {
1932
+ ...shaderPresets.heptapod,
1933
+ zoom: 1.2
1934
+ }
1935
+ }));
1923
1936
  };
1924
1937
  var scopeShape = {
1925
1938
  type: "scope",
@@ -1936,14 +1949,15 @@ var scopeShape = {
1936
1949
  };
1937
1950
 
1938
1951
  // src/shapes/Surface.tsx
1939
- import { useSignals as _useSignals18 } from "@preact-signals/safe-react/tracking";
1940
- import * as Schema18 from "effect/Schema";
1941
- import React19 from "react";
1942
- import { Surface } from "@dxos/app-framework";
1952
+ import * as Schema19 from "effect/Schema";
1953
+ import React20 from "react";
1954
+ import { Surface } from "@dxos/app-framework/ui";
1955
+ import { AppSurface } from "@dxos/app-toolkit/ui";
1943
1956
  import { DEFAULT_INPUT as DEFAULT_INPUT6 } from "@dxos/conductor";
1957
+ import { Card } from "@dxos/react-ui";
1944
1958
  import { createAnchorMap as createAnchorMap9 } from "@dxos/react-ui-canvas-editor";
1945
- var SurfaceShape = Schema18.extend(ComputeShape, Schema18.Struct({
1946
- type: Schema18.Literal("surface")
1959
+ var SurfaceShape = Schema19.extend(ComputeShape, Schema19.Struct({
1960
+ type: Schema19.Literal("surface")
1947
1961
  }));
1948
1962
  var createSurface = (props) => createShape({
1949
1963
  type: "surface",
@@ -1954,29 +1968,24 @@ var createSurface = (props) => createShape({
1954
1968
  ...props
1955
1969
  });
1956
1970
  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
- }
1971
+ const { runtime } = useComputeNodeState(shape);
1972
+ const input = runtime.inputs[DEFAULT_INPUT6];
1973
+ const value = input?.type === "executed" ? input.value : null;
1974
+ const handleAction = (action) => {
1975
+ if (action === "run") {
1976
+ runtime.evalNode();
1977
+ }
1978
+ };
1979
+ return /* @__PURE__ */ React20.createElement(Box, {
1980
+ shape,
1981
+ onAction: handleAction
1982
+ }, /* @__PURE__ */ React20.createElement(Card.Root, null, value !== null && /* @__PURE__ */ React20.createElement(Surface.Surface, {
1983
+ type: AppSurface.Card,
1984
+ data: {
1985
+ subject: value
1986
+ },
1987
+ limit: 1
1988
+ })));
1980
1989
  };
1981
1990
  var surfaceShape = {
1982
1991
  type: "surface",
@@ -1994,14 +2003,13 @@ var surfaceShape = {
1994
2003
  };
1995
2004
 
1996
2005
  // src/shapes/Switch.tsx
1997
- import { useSignals as _useSignals19 } from "@preact-signals/safe-react/tracking";
1998
- import * as Schema19 from "effect/Schema";
1999
- import React20, { useEffect as useEffect6, useState as useState8 } from "react";
2006
+ import * as Schema20 from "effect/Schema";
2007
+ import React21, { useEffect as useEffect6, useState as useState9 } from "react";
2000
2008
  import { DEFAULT_OUTPUT as DEFAULT_OUTPUT6 } from "@dxos/conductor";
2001
2009
  import { Input as Input2 } from "@dxos/react-ui";
2002
2010
  import { createAnchorMap as createAnchorMap10 } from "@dxos/react-ui-canvas-editor";
2003
- var SwitchShape = Schema19.extend(ComputeShape, Schema19.Struct({
2004
- type: Schema19.Literal("switch")
2011
+ var SwitchShape = Schema20.extend(ComputeShape, Schema20.Struct({
2012
+ type: Schema20.Literal("switch")
2005
2013
  }));
2006
2014
  var createSwitch = (props) => createShape({
2007
2015
  type: "switch",
@@ -2012,25 +2020,20 @@ var createSwitch = (props) => createShape({
2012
2020
  ...props
2013
2021
  });
2014
2022
  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
- }
2023
+ const { runtime } = useComputeNodeState(shape);
2024
+ const [value, setValue] = useState9(false);
2025
+ useEffect6(() => {
2026
+ runtime.setOutput(DEFAULT_OUTPUT6, value);
2027
+ }, [
2028
+ value
2029
+ ]);
2030
+ return /* @__PURE__ */ React21.createElement("div", {
2031
+ className: "flex w-full justify-center items-center",
2032
+ onClick: (ev) => ev.stopPropagation()
2033
+ }, /* @__PURE__ */ React21.createElement(Input2.Root, null, /* @__PURE__ */ React21.createElement(Input2.Switch, {
2034
+ checked: value,
2035
+ onCheckedChange: (value2) => setValue(value2)
2036
+ })));
2034
2037
  };
2035
2038
  var switchShape = {
2036
2039
  type: "switch",
@@ -2047,15 +2050,14 @@ var switchShape = {
2047
2050
  };
2048
2051
 
2049
2052
  // src/shapes/Table.tsx
2050
- import { useSignals as _useSignals20 } from "@preact-signals/safe-react/tracking";
2051
- import * as Schema20 from "effect/Schema";
2052
- import React21 from "react";
2053
+ import * as Schema21 from "effect/Schema";
2054
+ import React22 from "react";
2053
2055
  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)));
2057
- var TableShape = Schema20.extend(ComputeShape, Schema20.Struct({
2058
- type: Schema20.Literal("table")
2056
+ import { Message } from "@dxos/types";
2057
+ var InputSchema = createInputSchema(Message.Message);
2058
+ var OutputSchema = createOutputSchema(Schema21.mutable(Schema21.Array(Message.Message)));
2059
+ var TableShape = Schema21.extend(ComputeShape, Schema21.Struct({
2060
+ type: Schema21.Literal("table")
2059
2061
  }));
2060
2062
  var createTable = (props) => createShape({
2061
2063
  type: "table",
@@ -2066,14 +2068,9 @@ var createTable = (props) => createShape({
2066
2068
  ...props
2067
2069
  });
2068
2070
  var TableComponent = ({ shape }) => {
2069
- var _effect = _useSignals20();
2070
- try {
2071
- return /* @__PURE__ */ React21.createElement(Box, {
2072
- shape
2073
- });
2074
- } finally {
2075
- _effect.f();
2076
- }
2071
+ return /* @__PURE__ */ React22.createElement(Box, {
2072
+ shape
2073
+ });
2077
2074
  };
2078
2075
  var tableShape = {
2079
2076
  type: "table",
@@ -2086,62 +2083,56 @@ var tableShape = {
2086
2083
  };
2087
2084
 
2088
2085
  // src/shapes/Template.tsx
2089
- import { useSignals as _useSignals21 } from "@preact-signals/safe-react/tracking";
2090
- import * as Schema21 from "effect/Schema";
2091
- import React22, { useRef as useRef5 } from "react";
2086
+ import * as Schema22 from "effect/Schema";
2087
+ import React23, { useRef as useRef5 } from "react";
2092
2088
  import { ComputeValueType as ComputeValueType3, TemplateOutput, VoidInput as VoidInput2, getTemplateInputSchema as getTemplateInputSchema2 } from "@dxos/conductor";
2093
- import { toJsonSchema as toJsonSchema2 } from "@dxos/echo/internal";
2089
+ import { toJsonSchema } from "@dxos/echo/internal";
2094
2090
  import { invariant as invariant5 } from "@dxos/invariant";
2095
2091
  import { TextBox as TextBox4 } from "@dxos/react-ui-canvas-editor";
2096
- var __dxlog_file6 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/Template.tsx";
2097
- var TemplateShape = Schema21.extend(ComputeShape, Schema21.Struct({
2098
- type: Schema21.Literal("template"),
2099
- valueType: Schema21.optional(ComputeValueType3)
2092
+ var __dxlog_file7 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/Template.tsx";
2093
+ var TemplateShape = Schema22.extend(ComputeShape, Schema22.Struct({
2094
+ type: Schema22.Literal("template"),
2095
+ valueType: Schema22.optional(ComputeValueType3)
2100
2096
  }));
2101
2097
  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
- }
2098
+ const { node } = useComputeNodeState(shape);
2099
+ const inputRef = useRef5(null);
2100
+ const handleEnter = (text) => {
2101
+ const value = text.trim();
2102
+ if (value.length) {
2103
+ const schema = getTemplateInputSchema2(node);
2104
+ node.value = value;
2105
+ node.inputSchema = toJsonSchema(schema);
2106
+ }
2107
+ };
2108
+ const handleTypeChange = (newType) => {
2109
+ invariant5(Schema22.is(ComputeValueType3)(newType), "Invalid type", {
2110
+ F: __dxlog_file7,
2111
+ L: 58,
2112
+ S: void 0,
2113
+ A: [
2114
+ "Schema.is(ComputeValueType)(newType)",
2115
+ "'Invalid type'"
2116
+ ]
2117
+ });
2118
+ node.valueType = newType;
2119
+ node.inputSchema = toJsonSchema(getTemplateInputSchema2(node));
2120
+ };
2121
+ return /* @__PURE__ */ React23.createElement(Box, {
2122
+ shape,
2123
+ title: "Template",
2124
+ status: /* @__PURE__ */ React23.createElement(TypeSelect, {
2125
+ value: node.valueType ?? "string",
2126
+ onValueChange: handleTypeChange
2127
+ })
2128
+ }, /* @__PURE__ */ React23.createElement(TextBox4, {
2129
+ ...props,
2130
+ ref: inputRef,
2131
+ value: node.value,
2132
+ language: node.valueType === "object" ? "json" : void 0,
2133
+ onBlur: handleEnter,
2134
+ onEnter: handleEnter
2135
+ }));
2145
2136
  };
2146
2137
  var createTemplate = (props) => createShape({
2147
2138
  type: "template",
@@ -2155,7 +2146,7 @@ var templateShape = {
2155
2146
  type: "template",
2156
2147
  name: "Template",
2157
2148
  icon: "ph--article--regular",
2158
- component: (props) => /* @__PURE__ */ React22.createElement(TextInputComponent3, {
2149
+ component: (props) => /* @__PURE__ */ React23.createElement(TextInputComponent3, {
2159
2150
  ...props,
2160
2151
  placeholder: "Prompt"
2161
2152
  }),
@@ -2165,14 +2156,13 @@ var templateShape = {
2165
2156
  };
2166
2157
 
2167
2158
  // src/shapes/Text.tsx
2168
- import { useSignals as _useSignals22 } from "@preact-signals/safe-react/tracking";
2169
- import * as Schema22 from "effect/Schema";
2170
- import React23 from "react";
2159
+ import * as Schema23 from "effect/Schema";
2160
+ import React24 from "react";
2171
2161
  import { DEFAULT_INPUT as DEFAULT_INPUT7 } from "@dxos/conductor";
2172
2162
  import { TextBox as TextBox5 } from "@dxos/react-ui-canvas-editor";
2173
2163
  import { createAnchorMap as createAnchorMap11 } from "@dxos/react-ui-canvas-editor";
2174
- var TextShape = Schema22.extend(ComputeShape, Schema22.Struct({
2175
- type: Schema22.Literal("text")
2164
+ var TextShape = Schema23.extend(ComputeShape, Schema23.Struct({
2165
+ type: Schema23.Literal("text")
2176
2166
  }));
2177
2167
  var createText = (props) => createShape({
2178
2168
  type: "text",
@@ -2183,25 +2173,20 @@ var createText = (props) => createShape({
2183
2173
  ...props
2184
2174
  });
2185
2175
  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
- }
2176
+ const { runtime } = useComputeNodeState(shape);
2177
+ const input = runtime.inputs[DEFAULT_INPUT7];
2178
+ const value = input?.type === "executed" ? input.value : 0;
2179
+ const handleAction = (action) => {
2180
+ if (action === "run") {
2181
+ runtime.evalNode();
2182
+ }
2183
+ };
2184
+ return /* @__PURE__ */ React24.createElement(Box, {
2185
+ shape,
2186
+ onAction: handleAction
2187
+ }, /* @__PURE__ */ React24.createElement(TextBox5, {
2188
+ value
2189
+ }));
2205
2190
  };
2206
2191
  var textShape = {
2207
2192
  type: "text",
@@ -2219,16 +2204,16 @@ var textShape = {
2219
2204
  };
2220
2205
 
2221
2206
  // src/shapes/Thread.tsx
2222
- import { useSignals as _useSignals23 } from "@preact-signals/safe-react/tracking";
2223
- import * as Schema23 from "effect/Schema";
2224
- import React24, { useEffect as useEffect7, useRef as useRef6 } from "react";
2207
+ import * as Schema24 from "effect/Schema";
2208
+ import React25, { useEffect as useEffect7, useRef as useRef6 } from "react";
2225
2209
  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)));
2230
- var ThreadShape = Schema23.extend(ComputeShape, Schema23.Struct({
2231
- type: Schema23.Literal("thread")
2210
+ import { ScrollArea as ScrollArea3 } from "@dxos/react-ui";
2211
+ import { Message as Message2 } from "@dxos/types";
2212
+ import { mx as mx3 } from "@dxos/ui-theme";
2213
+ var InputSchema2 = createInputSchema2(Message2.Message);
2214
+ var OutputSchema2 = createOutputSchema2(Schema24.mutable(Schema24.Array(Message2.Message)));
2215
+ var ThreadShape = Schema24.extend(ComputeShape, Schema24.Struct({
2216
+ type: Schema24.Literal("thread")
2232
2217
  }));
2233
2218
  var createThread = (props) => createShape({
2234
2219
  type: "thread",
@@ -2239,49 +2224,42 @@ var createThread = (props) => createShape({
2239
2224
  ...props
2240
2225
  });
2241
2226
  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
- }
2227
+ const items = [];
2228
+ const scrollRef = useRef6(null);
2229
+ useEffect7(() => {
2230
+ if (scrollRef.current) {
2231
+ scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
2232
+ }
2233
+ }, [
2234
+ items
2235
+ ]);
2236
+ return /* @__PURE__ */ React25.createElement(Box, {
2237
+ shape
2238
+ }, /* @__PURE__ */ React25.createElement(ScrollArea3.Root, {
2239
+ orientation: "vertical"
2240
+ }, /* @__PURE__ */ React25.createElement(ScrollArea3.Viewport, {
2241
+ classNames: "gap-2 p-2",
2242
+ ref: scrollRef
2243
+ }, [
2244
+ ...items
2245
+ ].map((item, i) => /* @__PURE__ */ React25.createElement(ThreadItem, {
2246
+ key: i,
2247
+ item
2248
+ })))));
2267
2249
  };
2268
2250
  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;
2277
- 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();
2251
+ if (typeof item !== "object") {
2252
+ return /* @__PURE__ */ React25.createElement("div", {
2253
+ role: "none",
2254
+ className: mx3(classNames)
2255
+ }, item);
2284
2256
  }
2257
+ const { role, message } = item;
2258
+ return /* @__PURE__ */ React25.createElement("div", {
2259
+ className: mx3("flex", classNames, role === "user" && "justify-end")
2260
+ }, /* @__PURE__ */ React25.createElement("div", {
2261
+ 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")
2262
+ }, message));
2285
2263
  };
2286
2264
  var threadShape = {
2287
2265
  type: "thread",
@@ -2294,12 +2272,11 @@ var threadShape = {
2294
2272
  };
2295
2273
 
2296
2274
  // src/shapes/TextToImage.tsx
2297
- import { useSignals as _useSignals24 } from "@preact-signals/safe-react/tracking";
2298
- import * as Schema24 from "effect/Schema";
2299
- import React25 from "react";
2275
+ import * as Schema25 from "effect/Schema";
2276
+ import React26 from "react";
2300
2277
  import { createAnchorMap as createAnchorMap12 } from "@dxos/react-ui-canvas-editor";
2301
- var TextToImageShape = Schema24.extend(ComputeShape, Schema24.Struct({
2302
- type: Schema24.Literal("text-to-image")
2278
+ var TextToImageShape = Schema25.extend(ComputeShape, Schema25.Struct({
2279
+ type: Schema25.Literal("text-to-image")
2303
2280
  }));
2304
2281
  var createTextToImage = (props) => createShape({
2305
2282
  type: "text-to-image",
@@ -2310,14 +2287,9 @@ var createTextToImage = (props) => createShape({
2310
2287
  ...props
2311
2288
  });
2312
2289
  var TextToImageComponent = ({ shape }) => {
2313
- var _effect = _useSignals24();
2314
- try {
2315
- return /* @__PURE__ */ React25.createElement(Box, {
2316
- shape
2317
- });
2318
- } finally {
2319
- _effect.f();
2320
- }
2290
+ return /* @__PURE__ */ React26.createElement(Box, {
2291
+ shape
2292
+ });
2321
2293
  };
2322
2294
  var textToImageShape = {
2323
2295
  type: "text-to-image",
@@ -2334,22 +2306,20 @@ var textToImageShape = {
2334
2306
  };
2335
2307
 
2336
2308
  // src/shapes/Trigger.tsx
2337
- import { useSignals as _useSignals25 } from "@preact-signals/safe-react/tracking";
2338
- import * as Schema25 from "effect/Schema";
2339
- import React26, { useEffect as useEffect8 } from "react";
2309
+ import * as Schema26 from "effect/Schema";
2310
+ import React27, { useEffect as useEffect8 } from "react";
2340
2311
  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";
2312
+ import { Filter as Filter2, Obj as Obj4, Query, Ref as Ref3 } from "@dxos/echo";
2313
+ import { Trigger, TriggerEvent } from "@dxos/functions";
2344
2314
  import { DXN, SpaceId } from "@dxos/keys";
2345
- import { useSpace } from "@dxos/react-client/echo";
2315
+ import { useSpaces } from "@dxos/react-client/echo";
2346
2316
  import { Select as Select2 } from "@dxos/react-ui";
2347
- var TriggerShape = Schema25.extend(ComputeShape, Schema25.Struct({
2348
- type: Schema25.Literal("trigger"),
2349
- functionTrigger: Schema25.optional(Ref3(FunctionTrigger))
2317
+ var TriggerShape = Schema26.extend(ComputeShape, Schema26.Struct({
2318
+ type: Schema26.Literal("trigger"),
2319
+ functionTrigger: Schema26.optional(Ref3.Ref(Trigger.Trigger))
2350
2320
  }));
2351
2321
  var createTrigger = (props) => {
2352
- const functionTrigger = Obj.make(FunctionTrigger, {
2322
+ const functionTrigger = Trigger.make({
2353
2323
  enabled: true,
2354
2324
  spec: createTriggerSpec(props)
2355
2325
  });
@@ -2358,117 +2328,97 @@ var createTrigger = (props) => {
2358
2328
  functionTrigger: Ref3.make(functionTrigger),
2359
2329
  size: {
2360
2330
  width: 192,
2361
- height: getHeight(EmailTriggerOutput)
2331
+ height: getHeight(TriggerEvent.EmailEvent)
2362
2332
  },
2363
2333
  ...props
2364
2334
  });
2365
2335
  };
2366
2336
  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({
2337
+ const [space] = useSpaces();
2338
+ const functionTrigger = shape.functionTrigger?.target;
2339
+ useEffect8(() => {
2340
+ if (functionTrigger && !functionTrigger.spec) {
2341
+ Obj4.change(functionTrigger, (functionTrigger2) => {
2342
+ functionTrigger2.spec = createTriggerSpec({
2374
2343
  triggerKind: "email",
2375
2344
  spaceId: space?.id
2376
2345
  });
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({
2346
+ });
2347
+ }
2348
+ }, [
2349
+ functionTrigger,
2350
+ functionTrigger?.spec
2351
+ ]);
2352
+ useEffect8(() => {
2353
+ shape.size.height = getHeight(getOutputSchema(functionTrigger?.spec?.kind ?? "email"));
2354
+ }, [
2355
+ functionTrigger?.spec?.kind
2356
+ ]);
2357
+ const setKind = (kind) => {
2358
+ if (functionTrigger?.spec?.kind !== kind) {
2359
+ Obj4.change(functionTrigger, (obj) => {
2360
+ obj.spec = createTriggerSpec({
2390
2361
  triggerKind: kind,
2391
2362
  spaceId: space?.id
2392
2363
  });
2393
- }
2394
- };
2395
- if (!functionTrigger?.spec) {
2396
- return;
2364
+ });
2397
2365
  }
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();
2366
+ };
2367
+ if (!functionTrigger?.spec) {
2368
+ return;
2409
2369
  }
2370
+ return /* @__PURE__ */ React27.createElement(FunctionBody, {
2371
+ shape,
2372
+ status: /* @__PURE__ */ React27.createElement(TriggerKindSelect, {
2373
+ value: functionTrigger.spec?.kind,
2374
+ onValueChange: (kind) => setKind(kind)
2375
+ }),
2376
+ inputSchema: VoidInput3,
2377
+ outputSchema: getOutputSchema(functionTrigger.spec.kind)
2378
+ });
2410
2379
  };
2411
2380
  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
- }
2381
+ return /* @__PURE__ */ React27.createElement(Select2.Root, {
2382
+ value,
2383
+ onValueChange
2384
+ }, /* @__PURE__ */ React27.createElement(Select2.TriggerButton, {
2385
+ variant: "ghost",
2386
+ classNames: "w-full px-0!"
2387
+ }), /* @__PURE__ */ React27.createElement(Select2.Portal, null, /* @__PURE__ */ React27.createElement(Select2.Content, null, /* @__PURE__ */ React27.createElement(Select2.ScrollUpButton, null), /* @__PURE__ */ React27.createElement(Select2.Viewport, null, Trigger.Kinds.map((kind) => /* @__PURE__ */ React27.createElement(Select2.Option, {
2388
+ key: kind,
2389
+ value: kind
2390
+ }, kind))), /* @__PURE__ */ React27.createElement(Select2.ScrollDownButton, null), /* @__PURE__ */ React27.createElement(Select2.Arrow, null))));
2427
2391
  };
2428
2392
  var createTriggerSpec = (props) => {
2429
2393
  const kind = props.triggerKind ?? "email";
2430
2394
  switch (kind) {
2431
2395
  case "timer":
2432
- return {
2433
- kind: "timer",
2434
- cron: "*/10 * * * * *"
2435
- };
2396
+ return Trigger.specTimer("*/10 * * * * *");
2436
2397
  case "webhook":
2437
- return {
2438
- kind: "webhook",
2398
+ return Trigger.specWebhook({
2439
2399
  method: "POST"
2440
- };
2400
+ });
2441
2401
  case "subscription":
2442
- return {
2443
- kind: "subscription",
2444
- query: {
2445
- ast: Query.select(Filter2.nothing()).ast
2446
- }
2447
- };
2402
+ return Trigger.specSubscription(Query.select(Filter2.nothing()));
2448
2403
  case "email":
2449
- return {
2450
- kind: "email"
2451
- };
2404
+ return Trigger.specEmail();
2452
2405
  case "queue": {
2453
2406
  const dxn = new DXN(DXN.kind.QUEUE, [
2454
2407
  "data",
2455
2408
  props.spaceId ?? SpaceId.random(),
2456
- ObjectId4.random()
2409
+ Obj4.ID.random()
2457
2410
  ]).toString();
2458
- return {
2459
- kind: "queue",
2460
- queue: dxn
2461
- };
2411
+ return Trigger.specQueue(dxn);
2462
2412
  }
2463
2413
  }
2464
2414
  };
2465
2415
  var getOutputSchema = (kind) => {
2466
2416
  const kindToSchema = {
2467
- ["email"]: EmailTriggerOutput,
2468
- ["subscription"]: SubscriptionTriggerOutput,
2469
- ["timer"]: TimerTriggerOutput,
2470
- ["webhook"]: WebhookTriggerOutput,
2471
- ["queue"]: QueueTriggerOutput
2417
+ ["email"]: TriggerEvent.EmailEvent,
2418
+ ["subscription"]: TriggerEvent.SubscriptionEvent,
2419
+ ["timer"]: TriggerEvent.TimerEvent,
2420
+ ["webhook"]: TriggerEvent.WebhookEvent,
2421
+ ["queue"]: TriggerEvent.QueueEvent
2472
2422
  };
2473
2423
  return kindToSchema[kind];
2474
2424
  };
@@ -2481,140 +2431,6 @@ var triggerShape = {
2481
2431
  getAnchors: (shape) => createFunctionAnchors(shape, VoidInput3, getOutputSchema(shape.functionTrigger?.target?.spec?.kind ?? "email"))
2482
2432
  };
2483
2433
 
2484
- // src/shapes/GptRealtime.tsx
2485
- import { useSignals as _useSignals26 } from "@preact-signals/safe-react/tracking";
2486
- import * as Schema26 from "effect/Schema";
2487
- import React27, { useState as useState9 } from "react";
2488
- import { log as log2 } from "@dxos/log";
2489
- import { useConfig } from "@dxos/react-client";
2490
- import { Icon as Icon5 } from "@dxos/react-ui";
2491
- var __dxlog_file7 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/GptRealtime.tsx";
2492
- var GptRealtimeShape = Schema26.extend(ComputeShape, Schema26.Struct({
2493
- type: Schema26.Literal("gpt-realtime")
2494
- }));
2495
- var createGptRealtime = (props) => createShape({
2496
- type: "gpt-realtime",
2497
- size: {
2498
- width: 256,
2499
- height: 256
2500
- },
2501
- ...props
2502
- });
2503
- var GptRealtimeComponent = ({ shape }) => {
2504
- var _effect = _useSignals26();
2505
- try {
2506
- const [isLive, setIsLive] = useState9(false);
2507
- const [isReady, setIsReady] = useState9(false);
2508
- const config = useConfig();
2509
- const start = async () => {
2510
- setIsLive(true);
2511
- try {
2512
- const peerConnection = new RTCPeerConnection();
2513
- peerConnection.ontrack = (event) => {
2514
- const audioElement = document.createElement("audio");
2515
- audioElement.srcObject = event.streams[0];
2516
- audioElement.autoplay = true;
2517
- audioElement.controls = false;
2518
- audioElement.style.display = "none";
2519
- document.body.appendChild(audioElement);
2520
- setIsReady(true);
2521
- };
2522
- const stream = await navigator.mediaDevices.getUserMedia({
2523
- audio: true
2524
- });
2525
- stream.getTracks().forEach((track) => peerConnection.addTransceiver(track, {
2526
- direction: "sendrecv"
2527
- }));
2528
- const offer = await peerConnection.createOffer();
2529
- await peerConnection.setLocalDescription(offer);
2530
- const AiServiceUrl = new URL("/rtc-connect", config.values.runtime?.services?.ai?.server ?? DEFAULT_AI_SERVICE_URL);
2531
- const response = await fetch(AiServiceUrl, {
2532
- method: "POST",
2533
- body: offer.sdp,
2534
- headers: {
2535
- "Content-Type": "application/sdp"
2536
- }
2537
- });
2538
- const answer = await response.text();
2539
- await peerConnection.setRemoteDescription({
2540
- sdp: answer,
2541
- type: "answer"
2542
- });
2543
- const dataChannel = peerConnection.createDataChannel("response");
2544
- const configureData = () => {
2545
- log2.info("Configuring data channel", void 0, {
2546
- F: __dxlog_file7,
2547
- L: 87,
2548
- S: void 0,
2549
- C: (f, a) => f(...a)
2550
- });
2551
- const event = {
2552
- type: "session.update",
2553
- session: {
2554
- modalities: [
2555
- "text",
2556
- "audio"
2557
- ],
2558
- // Provide the tools. Note they match the keys in the `fns` object above
2559
- tools: []
2560
- }
2561
- };
2562
- dataChannel.send(JSON.stringify(event));
2563
- };
2564
- dataChannel.addEventListener("open", (ev) => {
2565
- log2.info("Opening data channel", {
2566
- ev
2567
- }, {
2568
- F: __dxlog_file7,
2569
- L: 100,
2570
- S: void 0,
2571
- C: (f, a) => f(...a)
2572
- });
2573
- configureData();
2574
- });
2575
- dataChannel.addEventListener("message", async (ev) => {
2576
- const msg = JSON.parse(ev.data);
2577
- if (msg.type === "response.function_call_arguments.done") {
2578
- }
2579
- });
2580
- } catch (error) {
2581
- log2.error("Error in realtime session:", {
2582
- error
2583
- }, {
2584
- F: __dxlog_file7,
2585
- L: 140,
2586
- S: void 0,
2587
- C: (f, a) => f(...a)
2588
- });
2589
- throw error;
2590
- }
2591
- };
2592
- return /* @__PURE__ */ React27.createElement("div", {
2593
- className: "flex w-full justify-center items-center"
2594
- }, /* @__PURE__ */ React27.createElement(Icon5, {
2595
- icon: isReady ? "ph--waveform--regular" : isLive ? "ph--pulse--regular" : "ph--play--regular",
2596
- size: 16,
2597
- classNames: !isLive && "cursor-pointer",
2598
- onClick: start
2599
- }));
2600
- } finally {
2601
- _effect.f();
2602
- }
2603
- };
2604
- var gptRealtimeShape = {
2605
- type: "gpt-realtime",
2606
- name: "GPT Realtime",
2607
- icon: "ph--pulse--regular",
2608
- component: GptRealtimeComponent,
2609
- createShape: createGptRealtime,
2610
- // TODO(dmaretskyi): Can we fetch the schema dynamically?
2611
- getAnchors: (shape) => createFunctionAnchors(shape, Schema26.Struct({
2612
- audio: Schema26.Any
2613
- }), Schema26.Struct({})),
2614
- resizable: true
2615
- };
2616
- var DEFAULT_AI_SERVICE_URL = "http://localhost:8788";
2617
-
2618
2434
  // src/registry.ts
2619
2435
  var computeShapes = [
2620
2436
  {
@@ -2660,7 +2476,7 @@ var computeShapes = [
2660
2476
  shapes: [
2661
2477
  //
2662
2478
  jsonShape,
2663
- queueShape,
2479
+ feedShape,
2664
2480
  threadShape,
2665
2481
  textShape,
2666
2482
  surfaceShape,
@@ -2681,20 +2497,11 @@ var computeShapes = [
2681
2497
  import { DefaultInput, DefaultOutput as DefaultOutput2 } from "@dxos/conductor";
2682
2498
  import { toEffectSchema } from "@dxos/echo/internal";
2683
2499
  import { ShapeLayout } from "@dxos/react-ui-canvas-editor";
2684
- function _define_property2(obj, key, value) {
2685
- if (key in obj) {
2686
- Object.defineProperty(obj, key, {
2687
- value,
2688
- enumerable: true,
2689
- configurable: true,
2690
- writable: true
2691
- });
2692
- } else {
2693
- obj[key] = value;
2694
- }
2695
- return obj;
2696
- }
2697
2500
  var ComputeShapeLayout = class extends ShapeLayout {
2501
+ _controller;
2502
+ constructor(_controller, registry2) {
2503
+ super(registry2), this._controller = _controller;
2504
+ }
2698
2505
  // TODO(burdon): Doesn't update.
2699
2506
  getAnchors(shape) {
2700
2507
  const shapeDef = this._registry.getShapeDef(shape.type);
@@ -2709,9 +2516,6 @@ var ComputeShapeLayout = class extends ShapeLayout {
2709
2516
  }
2710
2517
  return anchors;
2711
2518
  }
2712
- constructor(_controller, registry2) {
2713
- super(registry2), _define_property2(this, "_controller", void 0), this._controller = _controller;
2714
- }
2715
2519
  };
2716
2520
  export {
2717
2521
  AndShape,
@@ -2731,6 +2535,9 @@ export {
2731
2535
  ConstantShape,
2732
2536
  DatabaseComponent,
2733
2537
  DatabaseShape,
2538
+ FeedComponent,
2539
+ FeedItem,
2540
+ FeedShape,
2734
2541
  FunctionBody,
2735
2542
  FunctionShape,
2736
2543
  GptComponent,
@@ -2748,9 +2555,6 @@ export {
2748
2555
  JsonTransformShape,
2749
2556
  NotShape,
2750
2557
  OrShape,
2751
- QueueComponent,
2752
- QueueItem,
2753
- QueueShape,
2754
2558
  RandomComponent,
2755
2559
  RandomShape,
2756
2560
  ReducerComponent,
@@ -2793,6 +2597,7 @@ export {
2793
2597
  createComputeNode,
2794
2598
  createConstant,
2795
2599
  createDatabase,
2600
+ createFeed,
2796
2601
  createFunction,
2797
2602
  createFunctionAnchors,
2798
2603
  createGpt,
@@ -2803,7 +2608,6 @@ export {
2803
2608
  createJsonTransform,
2804
2609
  createNot,
2805
2610
  createOr,
2806
- createQueue,
2807
2611
  createRandom,
2808
2612
  createReducer,
2809
2613
  createScope,
@@ -2817,6 +2621,7 @@ export {
2817
2621
  createThread,
2818
2622
  createTrigger,
2819
2623
  databaseShape,
2624
+ feedShape,
2820
2625
  footerHeight,
2821
2626
  functionShape,
2822
2627
  getHeight,
@@ -2833,7 +2638,6 @@ export {
2833
2638
  notShape,
2834
2639
  orShape,
2835
2640
  parseAnchorId,
2836
- queueShape,
2837
2641
  randomShape,
2838
2642
  reducerShape,
2839
2643
  resolveComputeNode,