@dxos/react-ui-canvas-compute 0.8.4-main.fd6878d → 0.8.4-staging.60fe92afc8

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 (126) hide show
  1. package/LICENSE +102 -5
  2. package/dist/lib/browser/index.mjs +963 -1198
  3. package/dist/lib/browser/index.mjs.map +4 -4
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/node-esm/index.mjs +963 -1198
  6. package/dist/lib/node-esm/index.mjs.map +4 -4
  7. package/dist/lib/node-esm/meta.json +1 -1
  8. package/dist/types/src/components/DiagnosticOverlay.d.ts.map +1 -1
  9. package/dist/types/src/compute-layout.d.ts.map +1 -1
  10. package/dist/types/src/compute.stories.d.ts +33 -5
  11. package/dist/types/src/compute.stories.d.ts.map +1 -1
  12. package/dist/types/src/graph/controller.d.ts +54 -53
  13. package/dist/types/src/graph/controller.d.ts.map +1 -1
  14. package/dist/types/src/graph/node-defs.d.ts.map +1 -1
  15. package/dist/types/src/hooks/useComputeGraphController.d.ts +1 -1
  16. package/dist/types/src/hooks/useComputeGraphController.d.ts.map +1 -1
  17. package/dist/types/src/hooks/useComputeNodeState.d.ts +4 -5
  18. package/dist/types/src/hooks/useComputeNodeState.d.ts.map +1 -1
  19. package/dist/types/src/hooks/useGraphMonitor.d.ts +2 -2
  20. package/dist/types/src/hooks/useGraphMonitor.d.ts.map +1 -1
  21. package/dist/types/src/json.test.d.ts +1 -1
  22. package/dist/types/src/json.test.d.ts.map +1 -1
  23. package/dist/types/src/shapes/Append.d.ts +2 -2
  24. package/dist/types/src/shapes/Append.d.ts.map +1 -1
  25. package/dist/types/src/shapes/Array.d.ts +2 -2
  26. package/dist/types/src/shapes/Array.d.ts.map +1 -1
  27. package/dist/types/src/shapes/Audio.d.ts +2 -2
  28. package/dist/types/src/shapes/Audio.d.ts.map +1 -1
  29. package/dist/types/src/shapes/Beacon.d.ts +2 -2
  30. package/dist/types/src/shapes/Beacon.d.ts.map +1 -1
  31. package/dist/types/src/shapes/Boolean.d.ts +8 -8
  32. package/dist/types/src/shapes/Boolean.d.ts.map +1 -1
  33. package/dist/types/src/shapes/Chat.d.ts +2 -2
  34. package/dist/types/src/shapes/Chat.d.ts.map +1 -1
  35. package/dist/types/src/shapes/Constant.d.ts +3 -3
  36. package/dist/types/src/shapes/Constant.d.ts.map +1 -1
  37. package/dist/types/src/shapes/Database.d.ts +2 -2
  38. package/dist/types/src/shapes/Database.d.ts.map +1 -1
  39. package/dist/types/src/shapes/{Queue.d.ts → Feed.d.ts} +10 -10
  40. package/dist/types/src/shapes/Feed.d.ts.map +1 -0
  41. package/dist/types/src/shapes/Function.d.ts +2 -2
  42. package/dist/types/src/shapes/Function.d.ts.map +1 -1
  43. package/dist/types/src/shapes/Gpt.d.ts +2 -2
  44. package/dist/types/src/shapes/Gpt.d.ts.map +1 -1
  45. package/dist/types/src/shapes/GptRealtime.d.ts +2 -2
  46. package/dist/types/src/shapes/GptRealtime.d.ts.map +1 -1
  47. package/dist/types/src/shapes/Json.d.ts +3 -3
  48. package/dist/types/src/shapes/Json.d.ts.map +1 -1
  49. package/dist/types/src/shapes/Logic.d.ts +3 -3
  50. package/dist/types/src/shapes/Logic.d.ts.map +1 -1
  51. package/dist/types/src/shapes/RNG.d.ts +3 -3
  52. package/dist/types/src/shapes/RNG.d.ts.map +1 -1
  53. package/dist/types/src/shapes/Scope.d.ts +2 -2
  54. package/dist/types/src/shapes/Scope.d.ts.map +1 -1
  55. package/dist/types/src/shapes/Surface.d.ts +2 -2
  56. package/dist/types/src/shapes/Surface.d.ts.map +1 -1
  57. package/dist/types/src/shapes/Switch.d.ts +2 -2
  58. package/dist/types/src/shapes/Switch.d.ts.map +1 -1
  59. package/dist/types/src/shapes/Table.d.ts +2 -2
  60. package/dist/types/src/shapes/Table.d.ts.map +1 -1
  61. package/dist/types/src/shapes/Template.d.ts +3 -3
  62. package/dist/types/src/shapes/Template.d.ts.map +1 -1
  63. package/dist/types/src/shapes/Text.d.ts +2 -2
  64. package/dist/types/src/shapes/Text.d.ts.map +1 -1
  65. package/dist/types/src/shapes/TextToImage.d.ts +2 -2
  66. package/dist/types/src/shapes/TextToImage.d.ts.map +1 -1
  67. package/dist/types/src/shapes/Thread.d.ts +2 -2
  68. package/dist/types/src/shapes/Thread.d.ts.map +1 -1
  69. package/dist/types/src/shapes/Trigger.d.ts +11 -61
  70. package/dist/types/src/shapes/Trigger.d.ts.map +1 -1
  71. package/dist/types/src/shapes/common/Box.d.ts +4 -4
  72. package/dist/types/src/shapes/common/Box.d.ts.map +1 -1
  73. package/dist/types/src/shapes/common/FunctionBody.d.ts +3 -3
  74. package/dist/types/src/shapes/common/FunctionBody.d.ts.map +1 -1
  75. package/dist/types/src/shapes/common/TypeSelect.d.ts +1 -1
  76. package/dist/types/src/shapes/common/TypeSelect.d.ts.map +1 -1
  77. package/dist/types/src/shapes/defs.d.ts +3 -2
  78. package/dist/types/src/shapes/defs.d.ts.map +1 -1
  79. package/dist/types/src/shapes/index.d.ts +2 -2
  80. package/dist/types/src/shapes/index.d.ts.map +1 -1
  81. package/dist/types/src/testing/circuits.d.ts +18 -24
  82. package/dist/types/src/testing/circuits.d.ts.map +1 -1
  83. package/dist/types/tsconfig.tsbuildinfo +1 -1
  84. package/package.json +63 -57
  85. package/src/README.md +0 -3
  86. package/src/compute-layout.ts +1 -1
  87. package/src/compute.stories.tsx +100 -123
  88. package/src/graph/controller.ts +158 -79
  89. package/src/graph/node-defs.ts +31 -31
  90. package/src/hooks/useComputeGraphController.ts +1 -1
  91. package/src/hooks/useComputeNodeState.ts +8 -9
  92. package/src/hooks/useGraphMonitor.ts +11 -10
  93. package/src/json.test.ts +4 -4
  94. package/src/registry.ts +2 -2
  95. package/src/schema.test.ts +12 -12
  96. package/src/shapes/Append.tsx +1 -1
  97. package/src/shapes/Array.tsx +1 -1
  98. package/src/shapes/Audio.tsx +2 -3
  99. package/src/shapes/Beacon.tsx +1 -2
  100. package/src/shapes/Boolean.tsx +2 -2
  101. package/src/shapes/Chat.tsx +1 -2
  102. package/src/shapes/Constant.tsx +1 -2
  103. package/src/shapes/Database.tsx +1 -1
  104. package/src/shapes/{Queue.tsx → Feed.tsx} +27 -22
  105. package/src/shapes/Function.tsx +16 -13
  106. package/src/shapes/Gpt.tsx +7 -3
  107. package/src/shapes/GptRealtime.tsx +1 -1
  108. package/src/shapes/Json.tsx +10 -4
  109. package/src/shapes/Logic.tsx +1 -1
  110. package/src/shapes/RNG.tsx +6 -3
  111. package/src/shapes/Scope.tsx +3 -3
  112. package/src/shapes/Surface.tsx +13 -5
  113. package/src/shapes/Switch.tsx +1 -2
  114. package/src/shapes/Table.tsx +5 -4
  115. package/src/shapes/Template.tsx +2 -3
  116. package/src/shapes/Text.tsx +1 -2
  117. package/src/shapes/TextToImage.tsx +1 -1
  118. package/src/shapes/Thread.tsx +14 -11
  119. package/src/shapes/Trigger.tsx +51 -58
  120. package/src/shapes/common/Box.tsx +6 -9
  121. package/src/shapes/common/FunctionBody.tsx +4 -3
  122. package/src/shapes/common/TypeSelect.tsx +1 -1
  123. package/src/shapes/defs.ts +5 -4
  124. package/src/shapes/index.ts +2 -2
  125. package/src/testing/circuits.ts +9 -18
  126. package/dist/types/src/shapes/Queue.d.ts.map +0 -1
@@ -1,10 +1,16 @@
1
1
  import "@dxos/node-std/globals";
2
2
 
3
3
  // src/graph/controller.ts
4
- import { Effect, Either, Exit, Scope } from "effect";
4
+ import * as Effect from "effect/Effect";
5
+ import * as Either from "effect/Either";
6
+ import * as Exit from "effect/Exit";
7
+ import * as Layer from "effect/Layer";
8
+ import * as Scope from "effect/Scope";
5
9
  import { Event, synchronized } from "@dxos/async";
6
- import { GraphExecutor, ValueBag, isNotExecuted } from "@dxos/conductor";
10
+ import { Trace } from "@dxos/compute";
11
+ import { ComputeBeginEvent, ComputeCustomEvent, ComputeEndEvent, ComputeInputEvent, ComputeNodeContext, ComputeOutputEvent, GraphExecutor, ValueBag, isNotExecuted } from "@dxos/conductor";
7
12
  import { Resource } from "@dxos/context";
13
+ import { EffectEx } from "@dxos/effect";
8
14
  import { log } from "@dxos/log";
9
15
 
10
16
  // src/hooks/compute-context.ts
@@ -66,34 +72,18 @@ var useComputeGraphController = ({ controller, graph, editorRef }) => {
66
72
  };
67
73
 
68
74
  // src/hooks/useComputeNodeState.ts
69
- import { Schema } from "effect";
75
+ import * as Schema from "effect/Schema";
70
76
  import { useCallback, useEffect as useEffect2, useState as useState2 } from "react";
71
77
  import { invariant } from "@dxos/invariant";
72
78
  var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/hooks/useComputeNodeState.ts";
73
79
  var useComputeNodeState = (shape) => {
74
80
  const { controller } = useComputeContext();
75
- invariant(controller, void 0, {
76
- F: __dxlog_file,
77
- L: 34,
78
- S: void 0,
79
- A: [
80
- "controller",
81
- ""
82
- ]
83
- });
81
+ invariant(controller, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 12, S: void 0, A: ["controller", ""] });
84
82
  const [meta, setMeta] = useState2();
85
83
  useEffect2(() => {
86
84
  let disposed = false;
87
85
  queueMicrotask(async () => {
88
- invariant(shape.node, "Node not specified", {
89
- F: __dxlog_file,
90
- L: 40,
91
- S: void 0,
92
- A: [
93
- "shape.node",
94
- "'Node not specified'"
95
- ]
96
- });
86
+ invariant(shape.node, "Node not specified", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 17, S: void 0, A: ["shape.node", "'Node not specified'"] });
97
87
  const node = controller.getComputeNode(shape.node);
98
88
  const meta2 = await controller.getMeta(node);
99
89
  if (disposed) {
@@ -142,34 +132,17 @@ var useComputeNodeState = (shape) => {
142
132
  // src/hooks/useGraphMonitor.ts
143
133
  import { useMemo } from "react";
144
134
  import { ComputeGraphModel, DEFAULT_INPUT, DEFAULT_OUTPUT } from "@dxos/conductor";
145
- import { ObjectId, Ref } from "@dxos/echo-schema";
135
+ import { Obj, Ref } from "@dxos/echo";
146
136
  import { invariant as invariant2 } from "@dxos/invariant";
147
- import { getSpace } from "@dxos/react-client/echo";
148
137
  import { isNonNullable } from "@dxos/util";
149
138
  var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/hooks/useGraphMonitor.ts";
150
139
  var mapEdge = (graph, { source, target, output = DEFAULT_OUTPUT, input = DEFAULT_INPUT }) => {
151
140
  const sourceNode = graph.findNode(source);
152
141
  const targetNode = graph.findNode(target);
153
- invariant2(sourceNode?.node, void 0, {
154
- F: __dxlog_file2,
155
- L: 26,
156
- S: void 0,
157
- A: [
158
- "sourceNode?.node",
159
- ""
160
- ]
161
- });
162
- invariant2(targetNode?.node, void 0, {
163
- F: __dxlog_file2,
164
- L: 27,
165
- S: void 0,
166
- A: [
167
- "targetNode?.node",
168
- ""
169
- ]
170
- });
142
+ invariant2(sourceNode?.node, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 15, S: void 0, A: ["sourceNode?.node", ""] });
143
+ invariant2(targetNode?.node, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 16, S: void 0, A: ["targetNode?.node", ""] });
171
144
  return {
172
- id: ObjectId.random(),
145
+ id: Obj.ID.random(),
173
146
  source: sourceNode.node,
174
147
  target: targetNode.node,
175
148
  output,
@@ -183,15 +156,7 @@ var useGraphMonitor = (model) => {
183
156
  if (!model) {
184
157
  return;
185
158
  }
186
- invariant2(node.type, void 0, {
187
- F: __dxlog_file2,
188
- L: 52,
189
- S: void 0,
190
- A: [
191
- "node.type",
192
- ""
193
- ]
194
- });
159
+ invariant2(node.type, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 37, S: void 0, A: ["node.type", ""] });
195
160
  if (!isValidComputeNode(node.type)) {
196
161
  return;
197
162
  }
@@ -241,27 +206,21 @@ var createComputeGraph = (graph) => {
241
206
  };
242
207
  var linkTriggerToCompute = (graph, computeNode, triggerData) => {
243
208
  const functionTrigger = triggerData.functionTrigger?.target;
244
- invariant2(functionTrigger, void 0, {
245
- F: __dxlog_file2,
246
- L: 115,
247
- S: void 0,
248
- A: [
249
- "functionTrigger",
250
- ""
251
- ]
209
+ invariant2(functionTrigger, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 88, S: void 0, A: ["functionTrigger", ""] });
210
+ Obj.update(functionTrigger, (functionTrigger2) => {
211
+ functionTrigger2.function = Ref.make(graph.root);
212
+ functionTrigger2.inputNodeId = computeNode.id;
252
213
  });
253
- functionTrigger.function = Ref.make(graph.root);
254
- functionTrigger.inputNodeId = computeNode.id;
255
214
  };
256
215
  var deleteTriggerObjects = (computeGraph, deleted) => {
257
- const space = getSpace(computeGraph.root);
258
- if (!space) {
216
+ const db = Obj.getDatabase(computeGraph.root);
217
+ if (!db) {
259
218
  return;
260
219
  }
261
220
  for (const node of deleted.nodes) {
262
221
  if (node.type === "trigger") {
263
222
  const trigger = node;
264
- space.db.remove(trigger.functionTrigger.target);
223
+ db.remove(trigger.functionTrigger.target);
265
224
  }
266
225
  }
267
226
  };
@@ -269,20 +228,12 @@ var deleteTriggerObjects = (computeGraph, deleted) => {
269
228
  // src/graph/node-defs.ts
270
229
  import { NODE_INPUT, NODE_OUTPUT, getTemplateInputSchema, registry } from "@dxos/conductor";
271
230
  import { raise as raise2 } from "@dxos/debug";
272
- import { ObjectId as ObjectId2, toJsonSchema } from "@dxos/echo-schema";
231
+ import { JsonSchema, Obj as Obj2 } from "@dxos/echo";
273
232
  import { invariant as invariant3 } from "@dxos/invariant";
274
233
  var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/graph/node-defs.ts";
275
234
  var resolveComputeNode = async (node) => {
276
235
  const impl = registry[node.type];
277
- invariant3(impl, `Unknown node type: ${node.type}`, {
278
- F: __dxlog_file3,
279
- L: 22,
280
- S: void 0,
281
- A: [
282
- "impl",
283
- "`Unknown node type: ${node.type}`"
284
- ]
285
- });
236
+ invariant3(impl, `Unknown node type: ${node.type}`, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 10, S: void 0, A: ["impl", "`Unknown node type: ${node.type}`"] });
286
237
  return impl;
287
238
  };
288
239
  var isValidComputeNode = (type) => {
@@ -298,95 +249,95 @@ var nodeFactory = {
298
249
  [NODE_INPUT]: () => createNode(NODE_INPUT),
299
250
  [NODE_OUTPUT]: () => createNode(NODE_OUTPUT),
300
251
  // Extensions.
301
- ["text-to-image"]: () => createNode("text-to-image"),
302
- ["and"]: () => createNode("and"),
303
- ["append"]: () => createNode("append"),
304
- ["audio"]: () => createNode("audio"),
305
- ["beacon"]: () => createNode("beacon"),
306
- ["chat"]: () => createNode("chat"),
307
- ["constant"]: (shape) => createNode("constant", {
252
+ "text-to-image": () => createNode("text-to-image"),
253
+ and: () => createNode("and"),
254
+ append: () => createNode("append"),
255
+ audio: () => createNode("audio"),
256
+ beacon: () => createNode("beacon"),
257
+ chat: () => createNode("chat"),
258
+ constant: (shape) => createNode("constant", {
308
259
  value: shape.value
309
260
  }),
310
- ["make-queue"]: () => createNode("make-queue"),
311
- ["database"]: () => createNode("database"),
312
- ["gpt"]: () => createNode("gpt"),
313
- ["gpt-realtime"]: () => createNode("gpt-realtime"),
314
- ["if"]: () => createNode("if"),
315
- ["if-else"]: () => createNode("if-else"),
316
- ["function"]: () => createNode("function"),
317
- ["json"]: () => createNode("json"),
318
- ["json-transform"]: () => createNode("json-transform"),
319
- ["not"]: () => createNode("not"),
320
- ["or"]: () => createNode("or"),
321
- ["queue"]: () => createNode("queue"),
322
- ["rng"]: () => createNode("rng"),
323
- ["reducer"]: () => createNode("reducer"),
324
- ["scope"]: () => createNode("scope"),
325
- ["surface"]: () => createNode("surface"),
326
- ["switch"]: () => createNode("switch"),
327
- ["template"]: (shape) => {
261
+ "make-queue": () => createNode("make-queue"),
262
+ database: () => createNode("database"),
263
+ gpt: () => createNode("gpt"),
264
+ "gpt-realtime": () => createNode("gpt-realtime"),
265
+ if: () => createNode("if"),
266
+ "if-else": () => createNode("if-else"),
267
+ function: () => createNode("function"),
268
+ json: () => createNode("json"),
269
+ "json-transform": () => createNode("json-transform"),
270
+ not: () => createNode("not"),
271
+ or: () => createNode("or"),
272
+ queue: () => createNode("queue"),
273
+ rng: () => createNode("rng"),
274
+ reducer: () => createNode("reducer"),
275
+ scope: () => createNode("scope"),
276
+ surface: () => createNode("surface"),
277
+ switch: () => createNode("switch"),
278
+ template: (shape) => {
328
279
  const node = createNode("template", {
329
280
  valueType: shape.valueType,
330
281
  value: shape.text
331
282
  });
332
- node.inputSchema = toJsonSchema(getTemplateInputSchema(node));
283
+ node.inputSchema = JsonSchema.toJsonSchema(getTemplateInputSchema(node));
333
284
  return node;
334
285
  },
335
- ["text"]: () => createNode("text"),
336
- ["thread"]: () => createNode("thread"),
337
- ["trigger"]: () => createNode(NODE_INPUT)
286
+ text: () => createNode("text"),
287
+ thread: () => createNode("thread"),
288
+ trigger: () => createNode(NODE_INPUT)
338
289
  };
339
290
  var createNode = (type, props) => ({
340
- id: ObjectId2.random(),
291
+ id: Obj2.ID.random(),
341
292
  type,
342
293
  ...props
343
294
  });
344
295
 
345
296
  // src/graph/controller.ts
297
+ var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/graph/controller.ts";
346
298
  function _ts_decorate(decorators, target, key, desc) {
347
299
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
348
300
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
349
301
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
350
302
  return c > 3 && r && Object.defineProperty(target, key, r), r;
351
303
  }
352
- var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/graph/controller.ts";
353
304
  var InvalidStateError = Error;
354
305
  var AUTO_TRIGGER_NODES = [
355
306
  "chat",
356
307
  "switch",
357
308
  "constant"
358
309
  ];
359
- var createComputeGraphController = (graph, serviceContainer) => {
310
+ var createComputeGraphController = (graph, computeRuntime) => {
360
311
  const computeGraph = createComputeGraph(graph);
361
- const controller = new ComputeGraphController(serviceContainer, computeGraph);
312
+ const controller = new ComputeGraphController(computeRuntime, computeGraph);
362
313
  return {
363
314
  controller,
364
315
  graph
365
316
  };
366
317
  };
367
318
  var ComputeGraphController = class extends Resource {
368
- _serviceContainer;
319
+ _computeRuntime;
369
320
  _graph;
370
- _executor;
371
- _diagnostics;
321
+ _executor = new GraphExecutor({
322
+ computeNodeResolver: (node) => resolveComputeNode(node)
323
+ });
324
+ _diagnostics = [];
372
325
  /**
373
326
  * Canvas force-sets outputs of those nodes.
374
327
  */
375
- _forcedOutputs;
328
+ _forcedOutputs = {};
376
329
  /**
377
330
  * Runtime state of the execution graph.
378
331
  */
379
- _runtimeStateInputs;
380
- _runtimeStateOutputs;
332
+ _runtimeStateInputs = {};
333
+ _runtimeStateOutputs = {};
381
334
  // TODO(burdon): Remove? Make state reactive?
382
- update;
335
+ update = new Event();
383
336
  /** Computed result. */
384
- output;
385
- events;
386
- constructor(_serviceContainer, _graph) {
387
- super(), this._serviceContainer = _serviceContainer, this._graph = _graph, this._executor = new GraphExecutor({
388
- computeNodeResolver: (node) => resolveComputeNode(node)
389
- }), this._diagnostics = [], this._forcedOutputs = {}, this._runtimeStateInputs = {}, this._runtimeStateOutputs = {}, this.update = new Event(), this.output = new Event(), this.events = new Event();
337
+ output = new Event();
338
+ events = new Event();
339
+ constructor(_computeRuntime, _graph) {
340
+ super(), this._computeRuntime = _computeRuntime, this._graph = _graph;
390
341
  }
391
342
  toJSON() {
392
343
  return {
@@ -454,12 +405,7 @@ var ComputeGraphController = class extends Resource {
454
405
  try {
455
406
  await this.exec(nodeId);
456
407
  } catch (err) {
457
- log.catch(err, void 0, {
458
- F: __dxlog_file4,
459
- L: 199,
460
- S: this,
461
- C: (f, a) => f(...a)
462
- });
408
+ log.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 128, S: this });
463
409
  }
464
410
  });
465
411
  }
@@ -478,12 +424,11 @@ var ComputeGraphController = class extends Resource {
478
424
  for (const [nodeId2, outputs] of Object.entries(this._forcedOutputs)) {
479
425
  executor.setOutputs(nodeId2, Effect.succeed(ValueBag.make(outputs)));
480
426
  }
481
- const serviceLayer = this._serviceContainer.createLayer();
482
- await Effect.runPromise(Effect.gen(this, function* () {
427
+ EffectEx.unwrapExit(await this._computeRuntime.runPromiseExit(Effect.gen(this, function* () {
483
428
  const scope = yield* Scope.make();
484
429
  const executable = yield* Effect.promise(() => resolveComputeNode(this._graph.getNode(nodeId)));
485
430
  const computingOutputs = executable.exec != null;
486
- 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) => {
431
+ const effect = (computingOutputs ? executor.computeOutputs(nodeId) : executor.computeInputs(nodeId)).pipe(Effect.withSpan("runGraph"), Scope.extend(scope), Effect.provide(Layer.mergeAll(Layer.succeed(Trace.TraceService, this._createTraceWriter()), ComputeNodeContext.layerNoop)), Effect.flatMap(computeValueBag), Effect.withSpan("test"), Effect.tap((values) => {
487
432
  for (const [key, value] of Object.entries(values)) {
488
433
  if (computingOutputs) {
489
434
  this._onOutputComputed(nodeId, key, value);
@@ -494,7 +439,7 @@ var ComputeGraphController = class extends Resource {
494
439
  }));
495
440
  yield* effect;
496
441
  yield* Scope.close(scope, Exit.void);
497
- }));
442
+ })));
498
443
  this.update.emit();
499
444
  }
500
445
  /**
@@ -515,13 +460,13 @@ var ComputeGraphController = class extends Resource {
515
460
  const allAffectedNodes = [
516
461
  ...new Set(triggerNodes.flatMap((node) => executor.getAllDependantNodes(node.id)))
517
462
  ];
518
- await Effect.runPromise(Effect.gen(this, function* () {
463
+ EffectEx.unwrapExit(await this._computeRuntime.runPromiseExit(Effect.gen(this, function* () {
519
464
  const scope = yield* Scope.make();
520
465
  const tasks = [];
521
466
  for (const node of allAffectedNodes) {
522
467
  const executable = yield* Effect.promise(() => resolveComputeNode(this._graph.getNode(node)));
523
468
  const computingOutputs = executable.exec != null;
524
- 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) => {
469
+ const effect = (computingOutputs ? executor.computeOutputs(node) : executor.computeInputs(node)).pipe(Effect.withSpan("runGraph"), Scope.extend(scope), Effect.flatMap(computeValueBag), Effect.provide(Layer.mergeAll(Layer.succeed(Trace.TraceService, this._createTraceWriter()), ComputeNodeContext.layerNoop)), Effect.withSpan("test"), Effect.tap((values) => {
525
470
  for (const [key, value] of Object.entries(values)) {
526
471
  if (computingOutputs) {
527
472
  this._onOutputComputed(node, key, value);
@@ -534,26 +479,23 @@ var ComputeGraphController = class extends Resource {
534
479
  }
535
480
  yield* Effect.all(tasks);
536
481
  yield* Scope.close(scope, Exit.void);
537
- }));
482
+ })));
538
483
  this.update.emit();
539
484
  }
540
- _createLogger() {
485
+ _createTraceWriter() {
541
486
  return {
542
- log: (event) => {
543
- this._handleEvent(event);
544
- },
545
- nodeId: void 0
487
+ write: (eventType, payload) => {
488
+ const event = traceEventToComputeEvent(eventType.key, payload);
489
+ if (event) {
490
+ this._handleEvent(event);
491
+ }
492
+ }
546
493
  };
547
494
  }
548
495
  _handleEvent(event) {
549
496
  log("handleEvent", {
550
497
  event
551
- }, {
552
- F: __dxlog_file4,
553
- L: 335,
554
- S: this,
555
- C: (f, a) => f(...a)
556
- });
498
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 223, S: this });
557
499
  switch (event.type) {
558
500
  case "compute-input": {
559
501
  this._onInputComputed(event.nodeId, event.property, {
@@ -592,6 +534,37 @@ _ts_decorate([
592
534
  _ts_decorate([
593
535
  synchronized
594
536
  ], ComputeGraphController.prototype, "exec", null);
537
+ var traceEventToComputeEvent = (key, payload) => {
538
+ switch (key) {
539
+ case ComputeBeginEvent.key:
540
+ return {
541
+ type: "begin-compute",
542
+ ...payload
543
+ };
544
+ case ComputeEndEvent.key:
545
+ return {
546
+ type: "end-compute",
547
+ ...payload
548
+ };
549
+ case ComputeInputEvent.key:
550
+ return {
551
+ type: "compute-input",
552
+ ...payload
553
+ };
554
+ case ComputeOutputEvent.key:
555
+ return {
556
+ type: "compute-output",
557
+ ...payload
558
+ };
559
+ case ComputeCustomEvent.key:
560
+ return {
561
+ type: "custom",
562
+ ...payload
563
+ };
564
+ default:
565
+ return void 0;
566
+ }
567
+ };
595
568
  var computeValueBag = (bag) => {
596
569
  return Effect.all(Object.entries(bag.values).map(([key, eff]) => Effect.either(eff).pipe(Effect.map((value) => {
597
570
  if (Either.isLeft(value)) {
@@ -627,88 +600,72 @@ var computeValueBag = (bag) => {
627
600
  import { noteShape } from "@dxos/react-ui-canvas-editor";
628
601
 
629
602
  // src/shapes/common/Box.tsx
630
- import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
631
603
  import React, { forwardRef } from "react";
632
604
  import { invariant as invariant4 } from "@dxos/invariant";
633
605
  import { Icon, IconButton } from "@dxos/react-ui";
634
606
  import { useEditorContext, useShapeDef } from "@dxos/react-ui-canvas-editor";
635
- import { mx } from "@dxos/react-ui-theme";
607
+ import { mx } from "@dxos/ui-theme";
636
608
  var __dxlog_file5 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/common/Box.tsx";
637
609
  var headerHeight = 32;
638
610
  var footerHeight = 32;
639
611
  var Box = /* @__PURE__ */ forwardRef(({ children, classNames, shape, title, status, open, onAction }, forwardedRef) => {
640
- var _effect = _useSignals();
641
- try {
642
- invariant4(shape.type, void 0, {
643
- F: __dxlog_file5,
644
- L: 30,
645
- S: void 0,
646
- A: [
647
- "shape.type",
648
- ""
649
- ]
650
- });
651
- const { icon, name, openable } = useShapeDef(shape.type) ?? {
652
- icon: "ph--placeholder--regular"
653
- };
654
- const { debug } = useEditorContext();
655
- return /* @__PURE__ */ React.createElement("div", {
656
- ref: forwardedRef,
657
- className: "flex flex-col h-full w-full justify-between"
658
- }, /* @__PURE__ */ React.createElement("div", {
659
- className: "flex shrink-0 w-full justify-between items-center h-[32px] bg-hoverSurface"
660
- }, /* @__PURE__ */ React.createElement(Icon, {
661
- icon,
662
- classNames: "mx-2"
663
- }), /* @__PURE__ */ React.createElement("div", {
664
- className: "grow text-sm truncate"
665
- }, debug ? shape.type : name ?? shape.text ?? title), /* @__PURE__ */ React.createElement(IconButton, {
666
- classNames: "p-1 text-green-500",
667
- variant: "ghost",
668
- icon: "ph--play--regular",
669
- size: 4,
670
- label: "run",
671
- iconOnly: true,
672
- onDoubleClick: (ev) => ev.stopPropagation(),
673
- onClick: (ev) => {
674
- ev.stopPropagation();
675
- onAction?.("run");
676
- }
677
- })), /* @__PURE__ */ React.createElement("div", {
678
- className: mx("flex flex-col h-full grow overflow-hidden", classNames)
679
- }, children), /* @__PURE__ */ React.createElement("div", {
680
- className: "flex shrink-0 w-full justify-between items-center h-[32px] bg-hoverSurface"
681
- }, /* @__PURE__ */ React.createElement("div", {
682
- className: "grow px-2 text-sm truncate"
683
- }, debug ? shape.id : status), openable && /* @__PURE__ */ React.createElement(IconButton, {
684
- classNames: "p-1",
685
- variant: "ghost",
686
- icon: open ? "ph--caret-up--regular" : "ph--caret-down--regular",
687
- size: 4,
688
- label: open ? "close" : "open",
689
- iconOnly: true,
690
- onClick: (ev) => {
691
- ev.stopPropagation();
692
- onAction?.(open ? "close" : "open");
693
- }
694
- })));
695
- } finally {
696
- _effect.f();
697
- }
612
+ invariant4(shape.type, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 12, S: void 0, A: ["shape.type", ""] });
613
+ const { icon, name, openable } = useShapeDef(shape.type) ?? {
614
+ icon: "ph--circle-dashed--regular"
615
+ };
616
+ const { debug } = useEditorContext();
617
+ return /* @__PURE__ */ React.createElement("div", {
618
+ ref: forwardedRef,
619
+ className: "flex flex-col h-full w-full justify-between"
620
+ }, /* @__PURE__ */ React.createElement("div", {
621
+ className: "flex shrink-0 w-full justify-between items-center h-[32px] bg-input-surface"
622
+ }, /* @__PURE__ */ React.createElement(Icon, {
623
+ icon,
624
+ classNames: "mx-2"
625
+ }), /* @__PURE__ */ React.createElement("div", {
626
+ className: "grow text-sm truncate"
627
+ }, debug ? shape.type : name ?? shape.text ?? title), /* @__PURE__ */ React.createElement(IconButton, {
628
+ classNames: "p-1 text-green-500",
629
+ variant: "ghost",
630
+ icon: "ph--play--regular",
631
+ label: "run",
632
+ iconOnly: true,
633
+ onDoubleClick: (ev) => ev.stopPropagation(),
634
+ onClick: (ev) => {
635
+ ev.stopPropagation();
636
+ onAction?.("run");
637
+ }
638
+ })), /* @__PURE__ */ React.createElement("div", {
639
+ className: mx("flex flex-col h-full grow overflow-hidden", classNames)
640
+ }, children), /* @__PURE__ */ React.createElement("div", {
641
+ className: "flex shrink-0 w-full justify-between items-center h-[32px] bg-input-surface"
642
+ }, /* @__PURE__ */ React.createElement("div", {
643
+ className: "grow px-2 text-sm truncate"
644
+ }, debug ? shape.id : status), openable && /* @__PURE__ */ React.createElement(IconButton, {
645
+ classNames: "p-1",
646
+ variant: "ghost",
647
+ icon: open ? "ph--caret-up--regular" : "ph--caret-down--regular",
648
+ label: open ? "close" : "open",
649
+ iconOnly: true,
650
+ onClick: (ev) => {
651
+ ev.stopPropagation();
652
+ onAction?.(open ? "close" : "open");
653
+ }
654
+ })));
698
655
  });
699
656
 
700
657
  // src/shapes/common/FunctionBody.tsx
701
- import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
702
- import { SchemaAST as SchemaAST2 } from "effect";
658
+ import * as SchemaAST2 from "effect/SchemaAST";
703
659
  import React2, { useRef, useState as useState3 } from "react";
704
660
  import { VoidInput, VoidOutput } from "@dxos/conductor";
705
661
  import { useCanvasContext } from "@dxos/react-ui-canvas";
706
662
  import { createAnchors, getParentShapeElement, rowHeight } from "@dxos/react-ui-canvas-editor";
707
663
 
708
664
  // src/shapes/defs.ts
709
- import { Schema as Schema2, SchemaAST } from "effect";
665
+ import * as Schema2 from "effect/Schema";
666
+ import * as SchemaAST from "effect/SchemaAST";
710
667
  import { DEFAULT_INPUT as DEFAULT_INPUT2, DEFAULT_OUTPUT as DEFAULT_OUTPUT2 } from "@dxos/conductor";
711
- import { ObjectId as ObjectId3 } from "@dxos/echo-schema";
668
+ import { Obj as Obj3 } from "@dxos/echo";
712
669
  import { Polygon } from "@dxos/react-ui-canvas-editor";
713
670
  var getProperties = (ast) => SchemaAST.getPropertySignatures(ast).map(({ name }) => ({
714
671
  name: name.toString()
@@ -726,13 +683,13 @@ var parseAnchorId = (id) => {
726
683
  };
727
684
  var ComputeShape = Schema2.extend(Polygon, Schema2.Struct({
728
685
  // TODO(burdon): Rename computeNode?
729
- node: Schema2.optional(ObjectId3.annotations({
686
+ node: Schema2.optional(Obj3.ID.annotations({
730
687
  description: "Compute node id"
731
688
  }))
732
689
  }).pipe(Schema2.mutable));
733
690
  var createShape = ({ id, ...rest }) => {
734
691
  return {
735
- id: id ?? ObjectId3.random(),
692
+ id: id ?? Obj3.ID.random(),
736
693
  ...rest
737
694
  };
738
695
  };
@@ -741,70 +698,65 @@ var createShape = ({ id, ...rest }) => {
741
698
  var bodyPadding = 8;
742
699
  var expandedHeight = 200;
743
700
  var FunctionBody = ({ shape, name, content, inputSchema = VoidInput, outputSchema = VoidOutput, ...props }) => {
744
- var _effect = _useSignals2();
745
- try {
746
- const { scale } = useCanvasContext();
747
- const rootRef = useRef(null);
748
- const [open, setOpen] = useState3(false);
749
- const handleAction = (action) => {
750
- if (!rootRef.current) {
751
- return;
752
- }
753
- switch (action) {
754
- case "open": {
755
- const el = getParentShapeElement(rootRef.current, shape.id);
756
- const { height } = el.getBoundingClientRect();
757
- el.style.height = `${height / scale + expandedHeight}px`;
758
- setOpen(true);
759
- break;
760
- }
761
- case "close": {
762
- const el = getParentShapeElement(rootRef.current, shape.id);
763
- el.style.height = "";
764
- setOpen(false);
765
- break;
766
- }
767
- }
768
- };
769
- const inputs = getProperties(inputSchema.ast);
770
- const outputs = getProperties(outputSchema.ast);
771
- const columnCount = inputs.length && outputs.length ? 2 : 1;
772
- return /* @__PURE__ */ React2.createElement(Box, {
773
- ref: rootRef,
774
- shape,
775
- title: name,
776
- classNames: "divide-y divide-separator",
777
- open,
778
- onAction: handleAction,
779
- ...props
780
- }, /* @__PURE__ */ React2.createElement("div", {
781
- className: `grid grid-cols-${columnCount} items-center`,
782
- style: {
783
- paddingTop: bodyPadding,
784
- paddingBottom: bodyPadding
785
- }
786
- }, (inputs?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement("div", {
787
- className: "flex flex-col"
788
- }, inputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
789
- key: name2,
790
- className: "px-2 truncate text-sm font-mono items-center",
791
- style: {
792
- height: rowHeight
701
+ const { scale } = useCanvasContext();
702
+ const rootRef = useRef(null);
703
+ const [open, setOpen] = useState3(false);
704
+ const handleAction = (action) => {
705
+ if (!rootRef.current) {
706
+ return;
707
+ }
708
+ switch (action) {
709
+ case "open": {
710
+ const el = getParentShapeElement(rootRef.current, shape.id);
711
+ const { height } = el.getBoundingClientRect();
712
+ el.style.height = `${height / scale + expandedHeight}px`;
713
+ setOpen(true);
714
+ break;
793
715
  }
794
- }, name2))), (outputs?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement("div", {
795
- className: "flex flex-col"
796
- }, outputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
797
- key: name2,
798
- className: "px-2 truncate text-sm font-mono items-center text-right",
799
- style: {
800
- height: rowHeight
716
+ case "close": {
717
+ const el = getParentShapeElement(rootRef.current, shape.id);
718
+ el.style.height = "";
719
+ setOpen(false);
720
+ break;
801
721
  }
802
- }, name2)))), open && /* @__PURE__ */ React2.createElement("div", {
803
- className: "flex flex-col grow overflow-hidden"
804
- }, content));
805
- } finally {
806
- _effect.f();
807
- }
722
+ }
723
+ };
724
+ const inputs = getProperties(inputSchema.ast);
725
+ const outputs = getProperties(outputSchema.ast);
726
+ const columnCount = inputs.length && outputs.length ? 2 : 1;
727
+ return /* @__PURE__ */ React2.createElement(Box, {
728
+ ref: rootRef,
729
+ shape,
730
+ title: name,
731
+ classNames: "divide-y divide-separator",
732
+ open,
733
+ onAction: handleAction,
734
+ ...props
735
+ }, /* @__PURE__ */ React2.createElement("div", {
736
+ className: `grid grid-cols-${columnCount} items-center`,
737
+ style: {
738
+ paddingTop: bodyPadding,
739
+ paddingBottom: bodyPadding
740
+ }
741
+ }, (inputs?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement("div", {
742
+ className: "flex flex-col"
743
+ }, inputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
744
+ key: name2,
745
+ className: "px-2 truncate text-sm font-mono items-center",
746
+ style: {
747
+ height: rowHeight
748
+ }
749
+ }, name2))), (outputs?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement("div", {
750
+ className: "flex flex-col"
751
+ }, outputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
752
+ key: name2,
753
+ className: "px-2 truncate text-sm font-mono items-center text-right",
754
+ style: {
755
+ height: rowHeight
756
+ }
757
+ }, name2)))), open && /* @__PURE__ */ React2.createElement("div", {
758
+ className: "flex flex-col grow overflow-hidden"
759
+ }, content));
808
760
  };
809
761
  var getHeight = (input) => {
810
762
  const properties = SchemaAST2.getPropertySignatures(input.ast);
@@ -825,47 +777,35 @@ var createFunctionAnchors = (shape, input = VoidInput, output = VoidOutput) => {
825
777
  };
826
778
 
827
779
  // src/shapes/common/TypeSelect.tsx
828
- import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
829
780
  import React3 from "react";
830
781
  import { ComputeValueType } from "@dxos/conductor";
831
782
  import { Select } from "@dxos/react-ui";
832
783
  var TypeSelect = ({ value, onValueChange }) => {
833
- var _effect = _useSignals3();
834
- try {
835
- return /* @__PURE__ */ React3.createElement(Select.Root, {
836
- value,
837
- onValueChange
838
- }, /* @__PURE__ */ React3.createElement(Select.TriggerButton, {
839
- variant: "ghost",
840
- classNames: "w-full !px-0"
841
- }), /* @__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, {
842
- key: type,
843
- value: type
844
- }, type))), /* @__PURE__ */ React3.createElement(Select.ScrollDownButton, null), /* @__PURE__ */ React3.createElement(Select.Arrow, null))));
845
- } finally {
846
- _effect.f();
847
- }
784
+ return /* @__PURE__ */ React3.createElement(Select.Root, {
785
+ value,
786
+ onValueChange
787
+ }, /* @__PURE__ */ React3.createElement(Select.TriggerButton, {
788
+ variant: "ghost",
789
+ classNames: "w-full px-0!"
790
+ }), /* @__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, {
791
+ key: type,
792
+ value: type
793
+ }, type))), /* @__PURE__ */ React3.createElement(Select.ScrollDownButton, null), /* @__PURE__ */ React3.createElement(Select.Arrow, null))));
848
794
  };
849
795
 
850
796
  // src/shapes/Array.tsx
851
- import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
852
- import { Schema as Schema3 } from "effect";
797
+ import * as Schema3 from "effect/Schema";
853
798
  import React4 from "react";
854
799
  import { ReducerInput, ReducerOutput } from "@dxos/conductor";
855
800
  var ReducerShape = Schema3.extend(ComputeShape, Schema3.Struct({
856
801
  type: Schema3.Literal("reducer")
857
802
  }));
858
803
  var ReducerComponent = ({ shape }) => {
859
- var _effect = _useSignals4();
860
- try {
861
- return /* @__PURE__ */ React4.createElement(FunctionBody, {
862
- shape,
863
- inputSchema: ReducerInput,
864
- outputSchema: ReducerOutput
865
- });
866
- } finally {
867
- _effect.f();
868
- }
804
+ return /* @__PURE__ */ React4.createElement(FunctionBody, {
805
+ shape,
806
+ inputSchema: ReducerInput,
807
+ outputSchema: ReducerOutput
808
+ });
869
809
  };
870
810
  var createReducer = ({ id, size = {
871
811
  width: 192,
@@ -885,8 +825,7 @@ var reducerShape = {
885
825
  };
886
826
 
887
827
  // src/shapes/Append.tsx
888
- import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
889
- import { Schema as Schema4 } from "effect";
828
+ import * as Schema4 from "effect/Schema";
890
829
  import React5 from "react";
891
830
  import { AppendInput } from "@dxos/conductor";
892
831
  var AppendShape = Schema4.extend(ComputeShape, Schema4.Struct({
@@ -901,15 +840,10 @@ var createAppend = (props) => createShape({
901
840
  ...props
902
841
  });
903
842
  var AppendComponent = ({ shape }) => {
904
- var _effect = _useSignals5();
905
- try {
906
- return /* @__PURE__ */ React5.createElement(FunctionBody, {
907
- shape,
908
- inputSchema: AppendInput
909
- });
910
- } finally {
911
- _effect.f();
912
- }
843
+ return /* @__PURE__ */ React5.createElement(FunctionBody, {
844
+ shape,
845
+ inputSchema: AppendInput
846
+ });
913
847
  };
914
848
  var appendShape = {
915
849
  type: "append",
@@ -921,8 +855,7 @@ var appendShape = {
921
855
  };
922
856
 
923
857
  // src/shapes/Audio.tsx
924
- import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
925
- import { Schema as Schema5 } from "effect";
858
+ import * as Schema5 from "effect/Schema";
926
859
  import React6, { useEffect as useEffect3, useState as useState4 } from "react";
927
860
  import { Icon as Icon2 } from "@dxos/react-ui";
928
861
  import { createAnchorMap } from "@dxos/react-ui-canvas-editor";
@@ -938,29 +871,24 @@ var createAudio = (props) => createShape({
938
871
  ...props
939
872
  });
940
873
  var AudioComponent = ({ shape }) => {
941
- var _effect = _useSignals6();
942
- try {
943
- const { node } = useComputeNodeState(shape);
944
- const [active, setActive] = useState4(false);
945
- useEffect3(() => {
946
- node.value = active;
947
- }, [
948
- active
949
- ]);
950
- return /* @__PURE__ */ React6.createElement("div", {
951
- className: "flex w-full justify-center items-center"
952
- }, /* @__PURE__ */ React6.createElement(Icon2, {
953
- icon: active ? "ph--microphone--regular" : "ph--microphone-slash--regular",
954
- classNames: [
955
- "transition opacity-20 duration-1000",
956
- active && "opacity-100 text-red-500"
957
- ],
958
- size: 8,
959
- onClick: () => setActive(!active)
960
- }));
961
- } finally {
962
- _effect.f();
963
- }
874
+ const { node } = useComputeNodeState(shape);
875
+ const [active, setActive] = useState4(false);
876
+ useEffect3(() => {
877
+ node.value = active;
878
+ }, [
879
+ active
880
+ ]);
881
+ return /* @__PURE__ */ React6.createElement("div", {
882
+ className: "flex w-full justify-center items-center"
883
+ }, /* @__PURE__ */ React6.createElement(Icon2, {
884
+ icon: active ? "ph--microphone--regular" : "ph--microphone-slash--regular",
885
+ classNames: [
886
+ "transition opacity-20 duration-1000",
887
+ active && "opacity-100 text-error-text"
888
+ ],
889
+ size: 8,
890
+ onClick: () => setActive(!active)
891
+ }));
964
892
  };
965
893
  var audioShape = {
966
894
  type: "audio",
@@ -977,8 +905,7 @@ var audioShape = {
977
905
  };
978
906
 
979
907
  // src/shapes/Beacon.tsx
980
- import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
981
- import { Schema as Schema6 } from "effect";
908
+ import * as Schema6 from "effect/Schema";
982
909
  import React7 from "react";
983
910
  import { DEFAULT_INPUT as DEFAULT_INPUT3, isTruthy } from "@dxos/conductor";
984
911
  import { Icon as Icon3 } from "@dxos/react-ui";
@@ -995,24 +922,19 @@ var createBeacon = (props) => createShape({
995
922
  ...props
996
923
  });
997
924
  var BeaconComponent = ({ shape }) => {
998
- var _effect = _useSignals7();
999
- try {
1000
- const { runtime } = useComputeNodeState(shape);
1001
- const input = runtime.inputs[DEFAULT_INPUT3];
1002
- const value = input?.type === "executed" ? input.value : false;
1003
- return /* @__PURE__ */ React7.createElement("div", {
1004
- className: "flex w-full justify-center items-center"
1005
- }, /* @__PURE__ */ React7.createElement(Icon3, {
1006
- icon: "ph--sun--regular",
1007
- classNames: [
1008
- "transition opacity-20 duration-1000",
1009
- isTruthy(value) && "opacity-100 text-yellow-500"
1010
- ],
1011
- size: 8
1012
- }));
1013
- } finally {
1014
- _effect.f();
1015
- }
925
+ const { runtime } = useComputeNodeState(shape);
926
+ const input = runtime.inputs[DEFAULT_INPUT3];
927
+ const value = input?.type === "executed" ? input.value : false;
928
+ return /* @__PURE__ */ React7.createElement("div", {
929
+ className: "flex w-full justify-center items-center"
930
+ }, /* @__PURE__ */ React7.createElement(Icon3, {
931
+ icon: "ph--sun--regular",
932
+ classNames: [
933
+ "transition opacity-20 duration-1000",
934
+ isTruthy(value) && "opacity-100 text-yellow-500"
935
+ ],
936
+ size: 8
937
+ }));
1016
938
  };
1017
939
  var beaconShape = {
1018
940
  type: "beacon",
@@ -1029,7 +951,7 @@ var beaconShape = {
1029
951
  };
1030
952
 
1031
953
  // src/shapes/Boolean.tsx
1032
- import { Schema as Schema7 } from "effect";
954
+ import * as Schema7 from "effect/Schema";
1033
955
  import React8 from "react";
1034
956
  import { getAnchorPoints } from "@dxos/react-ui-canvas-editor";
1035
957
  import { createAnchors as createAnchors2 } from "@dxos/react-ui-canvas-editor";
@@ -1080,7 +1002,7 @@ var createSymbol = (pathConstructor, inputs) => ({
1080
1002
  });
1081
1003
  return /* @__PURE__ */ React8.createElement("svg", {
1082
1004
  viewBox: `0 0 ${width} ${height}`,
1083
- className: "w-full h-full"
1005
+ className: "h-full w-full"
1084
1006
  }, getAnchorPoints({
1085
1007
  x: 0,
1086
1008
  y: centerY
@@ -1202,8 +1124,7 @@ var notShape = defineShape({
1202
1124
  });
1203
1125
 
1204
1126
  // src/shapes/Chat.tsx
1205
- import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
1206
- import { Schema as Schema8 } from "effect";
1127
+ import * as Schema8 from "effect/Schema";
1207
1128
  import React9, { useRef as useRef2 } from "react";
1208
1129
  import { DEFAULT_OUTPUT as DEFAULT_OUTPUT3 } from "@dxos/conductor";
1209
1130
  import { TextBox } from "@dxos/react-ui-canvas-editor";
@@ -1212,28 +1133,23 @@ var ChatShape = Schema8.extend(ComputeShape, Schema8.Struct({
1212
1133
  type: Schema8.Literal("chat")
1213
1134
  }));
1214
1135
  var TextInputComponent = ({ shape, title, ...props }) => {
1215
- var _effect = _useSignals8();
1216
- try {
1217
- const { runtime } = useComputeNodeState(shape);
1218
- const inputRef = useRef2(null);
1219
- const handleEnter = (text) => {
1220
- const value = text.trim();
1221
- if (value.length) {
1222
- runtime.setOutput(DEFAULT_OUTPUT3, value);
1223
- inputRef.current?.setText("");
1224
- }
1225
- };
1226
- return /* @__PURE__ */ React9.createElement(Box, {
1227
- shape,
1228
- title
1229
- }, /* @__PURE__ */ React9.createElement(TextBox, {
1230
- ref: inputRef,
1231
- onEnter: handleEnter,
1232
- ...props
1233
- }));
1234
- } finally {
1235
- _effect.f();
1236
- }
1136
+ const { runtime } = useComputeNodeState(shape);
1137
+ const inputRef = useRef2(null);
1138
+ const handleEnter = (text) => {
1139
+ const value = text.trim();
1140
+ if (value.length) {
1141
+ runtime.setOutput(DEFAULT_OUTPUT3, value);
1142
+ inputRef.current?.setText("");
1143
+ }
1144
+ };
1145
+ return /* @__PURE__ */ React9.createElement(Box, {
1146
+ shape,
1147
+ title
1148
+ }, /* @__PURE__ */ React9.createElement(TextBox, {
1149
+ ref: inputRef,
1150
+ onEnter: handleEnter,
1151
+ ...props
1152
+ }));
1237
1153
  };
1238
1154
  var createChat = (props) => createShape({
1239
1155
  type: "chat",
@@ -1263,8 +1179,7 @@ var chatShape = {
1263
1179
  };
1264
1180
 
1265
1181
  // src/shapes/Constant.tsx
1266
- import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
1267
- import { Schema as Schema9 } from "effect";
1182
+ import * as Schema9 from "effect/Schema";
1268
1183
  import React10, { useCallback as useCallback2, useRef as useRef3, useState as useState5 } from "react";
1269
1184
  import { ComputeValueType as ComputeValueType2 } from "@dxos/conductor";
1270
1185
  import { Input } from "@dxos/react-ui";
@@ -1287,57 +1202,52 @@ var inferType = (value) => {
1287
1202
  }
1288
1203
  };
1289
1204
  var ConstantComponent = ({ shape, title, chat, ...props }) => {
1290
- var _effect = _useSignals9();
1291
- try {
1292
- const { node } = useComputeNodeState(shape);
1293
- const [type, setType] = useState5(inferType(node.value) ?? ComputeValueType2.literals[0]);
1294
- const inputRef = useRef3(null);
1295
- const handleEnter = useCallback2((text) => {
1296
- const value = text.trim();
1297
- if (value.length) {
1298
- if (type === "number") {
1299
- const floatValue = parseFloat(value);
1300
- if (!isNaN(floatValue)) {
1301
- node.value = floatValue;
1302
- }
1303
- } else if (type === "object") {
1304
- node.value = safeParseJson(value, {});
1305
- } else {
1306
- node.value = value;
1205
+ const { node } = useComputeNodeState(shape);
1206
+ const [type, setType] = useState5(inferType(node.value) ?? ComputeValueType2.literals[0]);
1207
+ const inputRef = useRef3(null);
1208
+ const handleEnter = useCallback2((text) => {
1209
+ const value = text.trim();
1210
+ if (value.length) {
1211
+ if (type === "number") {
1212
+ const floatValue = parseFloat(value);
1213
+ if (!isNaN(floatValue)) {
1214
+ node.value = floatValue;
1307
1215
  }
1308
- inputRef.current?.focus();
1309
- }
1310
- }, [
1311
- type
1312
- ]);
1313
- return /* @__PURE__ */ React10.createElement(Box, {
1314
- shape,
1315
- title,
1316
- status: /* @__PURE__ */ React10.createElement(TypeSelect, {
1317
- value: type,
1318
- onValueChange: setType
1319
- })
1320
- }, (type === "string" || type === "number") && /* @__PURE__ */ React10.createElement(TextBox2, {
1321
- ...props,
1322
- ref: inputRef,
1323
- value: node.value,
1324
- onEnter: handleEnter
1325
- }), type === "object" && /* @__PURE__ */ React10.createElement(TextBox2, {
1326
- ...props,
1327
- ref: inputRef,
1328
- value: JSON.stringify(node.value, null, 2),
1329
- language: "json"
1330
- }), type === "boolean" && /* @__PURE__ */ React10.createElement("div", {
1331
- className: "flex grow justify-center items-center"
1332
- }, /* @__PURE__ */ React10.createElement(Input.Root, null, /* @__PURE__ */ React10.createElement(Input.Switch, {
1333
- checked: node.value,
1334
- onCheckedChange: (value) => {
1216
+ } else if (type === "object") {
1217
+ node.value = safeParseJson(value, {});
1218
+ } else {
1335
1219
  node.value = value;
1336
1220
  }
1337
- }))));
1338
- } finally {
1339
- _effect.f();
1340
- }
1221
+ inputRef.current?.focus();
1222
+ }
1223
+ }, [
1224
+ type
1225
+ ]);
1226
+ return /* @__PURE__ */ React10.createElement(Box, {
1227
+ shape,
1228
+ title,
1229
+ status: /* @__PURE__ */ React10.createElement(TypeSelect, {
1230
+ value: type,
1231
+ onValueChange: setType
1232
+ })
1233
+ }, (type === "string" || type === "number") && /* @__PURE__ */ React10.createElement(TextBox2, {
1234
+ ...props,
1235
+ ref: inputRef,
1236
+ value: node.value,
1237
+ onEnter: handleEnter
1238
+ }), type === "object" && /* @__PURE__ */ React10.createElement(TextBox2, {
1239
+ ...props,
1240
+ ref: inputRef,
1241
+ value: JSON.stringify(node.value, null, 2),
1242
+ language: "json"
1243
+ }), type === "boolean" && /* @__PURE__ */ React10.createElement("div", {
1244
+ className: "flex grow justify-center items-center"
1245
+ }, /* @__PURE__ */ React10.createElement(Input.Root, null, /* @__PURE__ */ React10.createElement(Input.Switch, {
1246
+ checked: node.value,
1247
+ onCheckedChange: (value) => {
1248
+ node.value = value;
1249
+ }
1250
+ }))));
1341
1251
  };
1342
1252
  var createConstant = (props) => createShape({
1343
1253
  type: "constant",
@@ -1366,8 +1276,7 @@ var constantShape = {
1366
1276
  };
1367
1277
 
1368
1278
  // src/shapes/Database.tsx
1369
- import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
1370
- import { Schema as Schema10 } from "effect";
1279
+ import * as Schema10 from "effect/Schema";
1371
1280
  import React11 from "react";
1372
1281
  import { createAnchorMap as createAnchorMap5 } from "@dxos/react-ui-canvas-editor";
1373
1282
  var DatabaseShape = Schema10.extend(ComputeShape, Schema10.Struct({
@@ -1382,14 +1291,9 @@ var createDatabase = (props) => createShape({
1382
1291
  ...props
1383
1292
  });
1384
1293
  var DatabaseComponent = ({ shape }) => {
1385
- var _effect = _useSignals10();
1386
- try {
1387
- return /* @__PURE__ */ React11.createElement(Box, {
1388
- shape
1389
- });
1390
- } finally {
1391
- _effect.f();
1392
- }
1294
+ return /* @__PURE__ */ React11.createElement(Box, {
1295
+ shape
1296
+ });
1393
1297
  };
1394
1298
  var databaseShape = {
1395
1299
  type: "database",
@@ -1405,18 +1309,84 @@ var databaseShape = {
1405
1309
  })
1406
1310
  };
1407
1311
 
1312
+ // src/shapes/Feed.tsx
1313
+ import * as Schema11 from "effect/Schema";
1314
+ import React12, { Fragment } from "react";
1315
+ import { DEFAULT_OUTPUT as DEFAULT_OUTPUT4, QueueInput, QueueOutput } from "@dxos/conductor";
1316
+ import { ScrollArea } from "@dxos/react-ui";
1317
+ import { mx as mx2 } from "@dxos/ui-theme";
1318
+ var FeedShape = Schema11.extend(ComputeShape, Schema11.Struct({
1319
+ type: Schema11.Literal("queue")
1320
+ }));
1321
+ var createFeed = (props) => createShape({
1322
+ type: "queue",
1323
+ size: {
1324
+ width: 256,
1325
+ height: 512
1326
+ },
1327
+ ...props
1328
+ });
1329
+ var FeedComponent = ({ shape }) => {
1330
+ const { runtime } = useComputeNodeState(shape);
1331
+ const items = runtime.outputs[DEFAULT_OUTPUT4]?.type === "executed" ? runtime.outputs[DEFAULT_OUTPUT4].value : [];
1332
+ const handleAction = (action) => {
1333
+ if (action === "run") {
1334
+ runtime.evalNode();
1335
+ }
1336
+ };
1337
+ return /* @__PURE__ */ React12.createElement(Box, {
1338
+ shape,
1339
+ status: `${items.length} items`,
1340
+ onAction: handleAction
1341
+ }, /* @__PURE__ */ React12.createElement(ScrollArea.Root, {
1342
+ orientation: "vertical"
1343
+ }, /* @__PURE__ */ React12.createElement(ScrollArea.Viewport, {
1344
+ classNames: "divide-y divide-separator"
1345
+ }, [
1346
+ ...items
1347
+ ].map((item, i) => /* @__PURE__ */ React12.createElement(FeedItem, {
1348
+ key: i,
1349
+ classNames: "p-1 px-2",
1350
+ item
1351
+ })))));
1352
+ };
1353
+ var FeedItem = ({ classNames, item }) => {
1354
+ if (typeof item !== "object") {
1355
+ return /* @__PURE__ */ React12.createElement("div", {
1356
+ className: mx2(classNames, "whitespace-pre-wrap")
1357
+ }, item);
1358
+ }
1359
+ return /* @__PURE__ */ React12.createElement("div", {
1360
+ className: mx2("grid grid-cols-[80px_1fr]", classNames)
1361
+ }, Object.entries(item).map(([key, value]) => /* @__PURE__ */ React12.createElement(Fragment, {
1362
+ key
1363
+ }, /* @__PURE__ */ React12.createElement("div", {
1364
+ className: "p-1 text-xs text-subdued"
1365
+ }, key), /* @__PURE__ */ React12.createElement("div", null, typeof value === "string" ? value : JSON.stringify(value)))));
1366
+ };
1367
+ var feedShape = {
1368
+ type: "feed",
1369
+ name: "Feed",
1370
+ icon: "ph--queue--regular",
1371
+ component: FeedComponent,
1372
+ createShape: createFeed,
1373
+ getAnchors: (shape) => createFunctionAnchors(shape, QueueInput, QueueOutput),
1374
+ resizable: true
1375
+ };
1376
+
1408
1377
  // src/shapes/Function.tsx
1409
- import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
1410
- import { Schema as Schema11 } from "effect";
1411
- import React12, { useCallback as useCallback3, useRef as useRef4 } from "react";
1378
+ import * as Schema12 from "effect/Schema";
1379
+ import React13, { useCallback as useCallback3, useRef as useRef4 } from "react";
1380
+ import { Script } from "@dxos/compute";
1381
+ import { Operation } from "@dxos/compute";
1412
1382
  import { AnyOutput, FunctionInput } from "@dxos/conductor";
1413
- import { Ref as Ref2, getSnapshot, isInstanceOf } from "@dxos/echo-schema";
1414
- import { FunctionType, ScriptType } from "@dxos/functions";
1383
+ import { Filter, Ref as Ref2 } from "@dxos/echo";
1384
+ import { instanceOf as isInstanceOf } from "@dxos/echo/Obj";
1385
+ import { parseId } from "@dxos/keys";
1415
1386
  import { useClient } from "@dxos/react-client";
1416
- import { Filter, parseId } from "@dxos/react-client/echo";
1417
1387
  import { TextBox as TextBox3 } from "@dxos/react-ui-canvas-editor";
1418
- var FunctionShape = Schema11.extend(ComputeShape, Schema11.Struct({
1419
- type: Schema11.Literal("function")
1388
+ var FunctionShape = Schema12.extend(ComputeShape, Schema12.Struct({
1389
+ type: Schema12.Literal("function")
1420
1390
  }));
1421
1391
  var createFunction = (props) => createShape({
1422
1392
  type: "function",
@@ -1427,59 +1397,54 @@ var createFunction = (props) => createShape({
1427
1397
  ...props
1428
1398
  });
1429
1399
  var TextInputComponent2 = ({ shape, title, ...props }) => {
1430
- var _effect = _useSignals11();
1431
- try {
1432
- const client = useClient();
1433
- const { node, runtime } = useComputeNodeState(shape);
1434
- const inputRef = useRef4(null);
1435
- const handleEnter = useCallback3(async (text) => {
1436
- const value = text.trim();
1437
- const { spaceId, objectId } = parseId(value);
1438
- if (!spaceId || !objectId) {
1439
- return;
1440
- }
1441
- const space = client.spaces.get(spaceId);
1442
- const object = space?.db.getObjectById(objectId);
1443
- if (!space || !isInstanceOf(ScriptType, object)) {
1444
- return;
1445
- }
1446
- const { objects: [fn] } = await space.db.query(Filter.type(FunctionType, {
1447
- source: Ref2.make(object)
1448
- })).run();
1449
- if (!fn) {
1450
- return;
1451
- }
1452
- node.value = value;
1453
- node.function = Ref2.make(fn);
1454
- node.inputSchema = getSnapshot(fn.inputSchema);
1455
- node.outputSchema = getSnapshot(fn.outputSchema);
1456
- }, [
1457
- client,
1458
- node
1459
- ]);
1460
- const handleAction = useCallback3((action) => {
1461
- if (action !== "run") {
1462
- return;
1463
- }
1464
- runtime.evalNode();
1465
- }, [
1466
- runtime
1467
- ]);
1468
- return /* @__PURE__ */ React12.createElement(Box, {
1469
- shape,
1470
- title: "Function",
1471
- onAction: handleAction
1472
- }, /* @__PURE__ */ React12.createElement(TextBox3, {
1473
- ...props,
1474
- ref: inputRef,
1475
- value: node.value,
1476
- language: node.valueType === "object" ? "json" : void 0,
1477
- onBlur: handleEnter,
1478
- onEnter: handleEnter
1479
- }));
1480
- } finally {
1481
- _effect.f();
1482
- }
1400
+ const client = useClient();
1401
+ const { node, runtime } = useComputeNodeState(shape);
1402
+ const inputRef = useRef4(null);
1403
+ const handleEnter = useCallback3(async (text) => {
1404
+ const value = text.trim();
1405
+ const { spaceId, objectId } = parseId(value);
1406
+ if (!spaceId || !objectId) {
1407
+ return;
1408
+ }
1409
+ const space = client.spaces.get(spaceId);
1410
+ const object = space?.db.query(Filter.id(objectId)).runSync()[0];
1411
+ if (!space || !isInstanceOf(Script.Script, object)) {
1412
+ return;
1413
+ }
1414
+ const [fn] = await space.db.query(Filter.type(Operation.PersistentOperation, {
1415
+ source: Ref2.make(object)
1416
+ })).run();
1417
+ if (!fn) {
1418
+ return;
1419
+ }
1420
+ node.value = value;
1421
+ node.function = Ref2.make(fn);
1422
+ node.inputSchema = fn.inputSchema;
1423
+ node.outputSchema = fn.outputSchema;
1424
+ }, [
1425
+ client,
1426
+ node
1427
+ ]);
1428
+ const handleAction = useCallback3((action) => {
1429
+ if (action !== "run") {
1430
+ return;
1431
+ }
1432
+ runtime.evalNode();
1433
+ }, [
1434
+ runtime
1435
+ ]);
1436
+ return /* @__PURE__ */ React13.createElement(Box, {
1437
+ shape,
1438
+ title: "Function",
1439
+ onAction: handleAction
1440
+ }, /* @__PURE__ */ React13.createElement(TextBox3, {
1441
+ ...props,
1442
+ ref: inputRef,
1443
+ value: node.value,
1444
+ language: node.valueType === "object" ? "json" : void 0,
1445
+ onBlur: handleEnter,
1446
+ onEnter: handleEnter
1447
+ }));
1483
1448
  };
1484
1449
  var functionShape = {
1485
1450
  type: "function",
@@ -1491,12 +1456,12 @@ var functionShape = {
1491
1456
  };
1492
1457
 
1493
1458
  // src/shapes/Gpt.tsx
1494
- import { useSignals as _useSignals12 } from "@preact-signals/safe-react/tracking";
1495
- import { Schema as Schema12 } from "effect";
1496
- import React13, { useEffect as useEffect4, useState as useState6 } from "react";
1459
+ import * as Schema13 from "effect/Schema";
1460
+ import React14, { useEffect as useEffect4, useState as useState6 } from "react";
1497
1461
  import { GptInput, GptOutput } from "@dxos/conductor";
1498
- var GptShape = Schema12.extend(ComputeShape, Schema12.Struct({
1499
- type: Schema12.Literal("gpt")
1462
+ import { ScrollArea as ScrollArea2 } from "@dxos/react-ui";
1463
+ var GptShape = Schema13.extend(ComputeShape, Schema13.Struct({
1464
+ type: Schema13.Literal("gpt")
1500
1465
  }));
1501
1466
  var createGpt = (props) => createShape({
1502
1467
  type: "gpt",
@@ -1507,54 +1472,50 @@ var createGpt = (props) => createShape({
1507
1472
  ...props
1508
1473
  });
1509
1474
  var GptComponent = ({ shape }) => {
1510
- var _effect = _useSignals12();
1511
- try {
1512
- const { meta, runtime } = useComputeNodeState(shape);
1513
- const [text, setText] = useState6("");
1514
- const [tokens, setTokens] = useState6(0);
1515
- useEffect4(() => {
1516
- return runtime.subscribeToEventLog((ev) => {
1517
- switch (ev.type) {
1518
- case "begin-compute": {
1519
- setText("");
1520
- break;
1521
- }
1522
- case "custom": {
1523
- const token = ev.event;
1524
- switch (token.type) {
1525
- case "content_block_delta":
1526
- switch (token.delta.type) {
1527
- case "text_delta": {
1528
- const delta = token.delta.text;
1529
- setText((prev) => {
1530
- const text2 = prev + delta;
1531
- setTokens(text2.split(" ").length);
1532
- return text2;
1533
- });
1534
- break;
1535
- }
1475
+ const { meta, runtime } = useComputeNodeState(shape);
1476
+ const [text, setText] = useState6("");
1477
+ const [tokens, setTokens] = useState6(0);
1478
+ useEffect4(() => {
1479
+ return runtime.subscribeToEventLog((ev) => {
1480
+ switch (ev.type) {
1481
+ case "begin-compute": {
1482
+ setText("");
1483
+ break;
1484
+ }
1485
+ case "custom": {
1486
+ const token = ev.event;
1487
+ switch (token.type) {
1488
+ case "content_block_delta":
1489
+ switch (token.delta.type) {
1490
+ case "text_delta": {
1491
+ const delta = token.delta.text;
1492
+ setText((prev) => {
1493
+ const text2 = prev + delta;
1494
+ setTokens(text2.split(" ").length);
1495
+ return text2;
1496
+ });
1497
+ break;
1536
1498
  }
1537
- break;
1538
- }
1539
- break;
1499
+ }
1500
+ break;
1540
1501
  }
1502
+ break;
1541
1503
  }
1542
- });
1543
- }, [
1544
- runtime?.subscribeToEventLog
1545
- ]);
1546
- return /* @__PURE__ */ React13.createElement(FunctionBody, {
1547
- shape,
1548
- content: /* @__PURE__ */ React13.createElement("div", {
1549
- className: "px-2 py-1 overflow-y-scroll"
1550
- }, text),
1551
- status: `${tokens} tokens`,
1552
- inputSchema: meta.input,
1553
- outputSchema: meta.output
1504
+ }
1554
1505
  });
1555
- } finally {
1556
- _effect.f();
1557
- }
1506
+ }, [
1507
+ runtime?.subscribeToEventLog
1508
+ ]);
1509
+ return /* @__PURE__ */ React14.createElement(FunctionBody, {
1510
+ shape,
1511
+ content: /* @__PURE__ */ React14.createElement(ScrollArea2.Root, {
1512
+ orientation: "vertical",
1513
+ thin: true
1514
+ }, /* @__PURE__ */ React14.createElement(ScrollArea2.Viewport, null, text)),
1515
+ status: `${tokens} tokens`,
1516
+ inputSchema: meta.input,
1517
+ outputSchema: meta.output
1518
+ });
1558
1519
  };
1559
1520
  var gptShape = {
1560
1521
  type: "gpt",
@@ -1566,44 +1527,147 @@ var gptShape = {
1566
1527
  openable: true
1567
1528
  };
1568
1529
 
1530
+ // src/shapes/GptRealtime.tsx
1531
+ import * as Schema14 from "effect/Schema";
1532
+ import React15, { useState as useState7 } from "react";
1533
+ import { log as log2 } from "@dxos/log";
1534
+ import { useConfig } from "@dxos/react-client";
1535
+ import { Icon as Icon4 } from "@dxos/react-ui";
1536
+ var __dxlog_file6 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/GptRealtime.tsx";
1537
+ var GptRealtimeShape = Schema14.extend(ComputeShape, Schema14.Struct({
1538
+ type: Schema14.Literal("gpt-realtime")
1539
+ }));
1540
+ var createGptRealtime = (props) => createShape({
1541
+ type: "gpt-realtime",
1542
+ size: {
1543
+ width: 256,
1544
+ height: 256
1545
+ },
1546
+ ...props
1547
+ });
1548
+ var GptRealtimeComponent = ({ shape }) => {
1549
+ const [isLive, setIsLive] = useState7(false);
1550
+ const [isReady, setIsReady] = useState7(false);
1551
+ const config = useConfig();
1552
+ const start = async () => {
1553
+ setIsLive(true);
1554
+ try {
1555
+ const peerConnection = new RTCPeerConnection();
1556
+ peerConnection.ontrack = (event) => {
1557
+ const audioElement = document.createElement("audio");
1558
+ audioElement.srcObject = event.streams[0];
1559
+ audioElement.autoplay = true;
1560
+ audioElement.controls = false;
1561
+ audioElement.style.display = "none";
1562
+ document.body.appendChild(audioElement);
1563
+ setIsReady(true);
1564
+ };
1565
+ const stream = await navigator.mediaDevices.getUserMedia({
1566
+ audio: true
1567
+ });
1568
+ stream.getTracks().forEach((track) => peerConnection.addTransceiver(track, {
1569
+ direction: "sendrecv"
1570
+ }));
1571
+ const offer = await peerConnection.createOffer();
1572
+ await peerConnection.setLocalDescription(offer);
1573
+ const AiServiceUrl = new URL("/rtc-connect", config.values.runtime?.services?.ai?.server ?? DEFAULT_AI_SERVICE_URL);
1574
+ const response = await fetch(AiServiceUrl, {
1575
+ method: "POST",
1576
+ body: offer.sdp,
1577
+ headers: {
1578
+ "Content-Type": "application/sdp"
1579
+ }
1580
+ });
1581
+ const answer = await response.text();
1582
+ await peerConnection.setRemoteDescription({
1583
+ sdp: answer,
1584
+ type: "answer"
1585
+ });
1586
+ const dataChannel = peerConnection.createDataChannel("response");
1587
+ const configureData = () => {
1588
+ log2.info("Configuring data channel", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 69, S: void 0 });
1589
+ const event = {
1590
+ type: "session.update",
1591
+ session: {
1592
+ modalities: [
1593
+ "text",
1594
+ "audio"
1595
+ ],
1596
+ // Provide the tools. Note they match the keys in the `fns` object above
1597
+ tools: []
1598
+ }
1599
+ };
1600
+ dataChannel.send(JSON.stringify(event));
1601
+ };
1602
+ dataChannel.addEventListener("open", (ev) => {
1603
+ log2.info("Opening data channel", {
1604
+ ev
1605
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 84, S: void 0 });
1606
+ configureData();
1607
+ });
1608
+ dataChannel.addEventListener("message", async (ev) => {
1609
+ const msg = JSON.parse(ev.data);
1610
+ if (msg.type === "response.function_call_arguments.done") {
1611
+ }
1612
+ });
1613
+ } catch (error) {
1614
+ log2.error("Error in realtime session:", {
1615
+ error
1616
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 124, S: void 0 });
1617
+ throw error;
1618
+ }
1619
+ };
1620
+ return /* @__PURE__ */ React15.createElement("div", {
1621
+ className: "flex w-full justify-center items-center"
1622
+ }, /* @__PURE__ */ React15.createElement(Icon4, {
1623
+ icon: isReady ? "ph--waveform--regular" : isLive ? "ph--pulse--regular" : "ph--play--regular",
1624
+ size: 16,
1625
+ classNames: !isLive && "cursor-pointer",
1626
+ onClick: start
1627
+ }));
1628
+ };
1629
+ var gptRealtimeShape = {
1630
+ type: "gpt-realtime",
1631
+ name: "GPT Realtime",
1632
+ icon: "ph--pulse--regular",
1633
+ component: GptRealtimeComponent,
1634
+ createShape: createGptRealtime,
1635
+ // TODO(dmaretskyi): Can we fetch the schema dynamically?
1636
+ getAnchors: (shape) => createFunctionAnchors(shape, Schema14.Struct({
1637
+ audio: Schema14.Any
1638
+ }), Schema14.Struct({})),
1639
+ resizable: true
1640
+ };
1641
+ var DEFAULT_AI_SERVICE_URL = "http://localhost:8788";
1642
+
1569
1643
  // src/shapes/Json.tsx
1570
- import { useSignals as _useSignals13 } from "@preact-signals/safe-react/tracking";
1571
- import { Schema as Schema13 } from "effect";
1572
- import React14 from "react";
1644
+ import * as Schema15 from "effect/Schema";
1645
+ import React16 from "react";
1573
1646
  import { DEFAULT_INPUT as DEFAULT_INPUT4, DefaultOutput, JsonTransformInput } from "@dxos/conductor";
1574
1647
  import { createAnchorMap as createAnchorMap6 } from "@dxos/react-ui-canvas-editor";
1575
- import { JsonFilter } from "@dxos/react-ui-syntax-highlighter";
1576
- var JsonShape = Schema13.extend(ComputeShape, Schema13.Struct({
1577
- type: Schema13.Literal("json")
1648
+ import { Syntax } from "@dxos/react-ui-syntax-highlighter";
1649
+ var JsonShape = Schema15.extend(ComputeShape, Schema15.Struct({
1650
+ type: Schema15.Literal("json")
1578
1651
  }));
1579
- var JsonTransformShape = Schema13.extend(ComputeShape, Schema13.Struct({
1580
- type: Schema13.Literal("json-transform")
1652
+ var JsonTransformShape = Schema15.extend(ComputeShape, Schema15.Struct({
1653
+ type: Schema15.Literal("json-transform")
1581
1654
  }));
1582
1655
  var JsonComponent = ({ shape, ...props }) => {
1583
- var _effect = _useSignals13();
1584
- try {
1585
- const { runtime } = useComputeNodeState(shape);
1586
- const input = runtime.inputs[DEFAULT_INPUT4];
1587
- const value = input?.type === "executed" ? input.value : void 0;
1588
- return /* @__PURE__ */ React14.createElement(Box, {
1589
- shape
1590
- }, /* @__PURE__ */ React14.createElement(JsonFilter, {
1591
- data: value,
1592
- classNames: "text-xs"
1593
- }));
1594
- } finally {
1595
- _effect.f();
1596
- }
1656
+ const { runtime } = useComputeNodeState(shape);
1657
+ const input = runtime.inputs[DEFAULT_INPUT4];
1658
+ const value = input?.type === "executed" ? input.value : void 0;
1659
+ return /* @__PURE__ */ React16.createElement(Box, {
1660
+ shape
1661
+ }, /* @__PURE__ */ React16.createElement(Syntax.Root, {
1662
+ data: value
1663
+ }, /* @__PURE__ */ React16.createElement(Syntax.Content, null, /* @__PURE__ */ React16.createElement(Syntax.Filter, null), /* @__PURE__ */ React16.createElement(Syntax.Viewport, null, /* @__PURE__ */ React16.createElement(Syntax.Code, {
1664
+ classNames: "text-xs"
1665
+ })))));
1597
1666
  };
1598
1667
  var JsonTransformComponent = ({ shape, ...props }) => {
1599
- var _effect = _useSignals13();
1600
- try {
1601
- return /* @__PURE__ */ React14.createElement(Box, {
1602
- shape
1603
- });
1604
- } finally {
1605
- _effect.f();
1606
- }
1668
+ return /* @__PURE__ */ React16.createElement(Box, {
1669
+ shape
1670
+ });
1607
1671
  };
1608
1672
  var createJson = (props) => createShape({
1609
1673
  type: "json",
@@ -1617,7 +1681,7 @@ var jsonShape = {
1617
1681
  type: "json",
1618
1682
  name: "JSON",
1619
1683
  icon: "ph--code--regular",
1620
- component: (props) => /* @__PURE__ */ React14.createElement(JsonComponent, props),
1684
+ component: (props) => /* @__PURE__ */ React16.createElement(JsonComponent, props),
1621
1685
  createShape: createJson,
1622
1686
  getAnchors: (shape) => createAnchorMap6(shape, {
1623
1687
  [createAnchorId("input")]: {
@@ -1643,46 +1707,35 @@ var jsonTransformShape = {
1643
1707
  type: "json-transform",
1644
1708
  name: "Transform",
1645
1709
  icon: "ph--shuffle-simple--regular",
1646
- component: (props) => /* @__PURE__ */ React14.createElement(JsonTransformComponent, props),
1710
+ component: (props) => /* @__PURE__ */ React16.createElement(JsonTransformComponent, props),
1647
1711
  createShape: createJsonTransform,
1648
1712
  getAnchors: (shape) => createFunctionAnchors(shape, JsonTransformInput, DefaultOutput),
1649
1713
  resizable: true
1650
1714
  };
1651
1715
 
1652
1716
  // src/shapes/Logic.tsx
1653
- import { useSignals as _useSignals14 } from "@preact-signals/safe-react/tracking";
1654
- import { Schema as Schema14 } from "effect";
1655
- import React15 from "react";
1717
+ import * as Schema16 from "effect/Schema";
1718
+ import React17 from "react";
1656
1719
  import { IfElseInput, IfElseOutput, IfInput, IfOutput } from "@dxos/conductor";
1657
- var IfShape = Schema14.extend(ComputeShape, Schema14.Struct({
1658
- type: Schema14.Literal("if")
1720
+ var IfShape = Schema16.extend(ComputeShape, Schema16.Struct({
1721
+ type: Schema16.Literal("if")
1659
1722
  }));
1660
- var IfElseShape = Schema14.extend(ComputeShape, Schema14.Struct({
1661
- type: Schema14.Literal("if-else")
1723
+ var IfElseShape = Schema16.extend(ComputeShape, Schema16.Struct({
1724
+ type: Schema16.Literal("if-else")
1662
1725
  }));
1663
1726
  var IfComponent = ({ shape, ...props }) => {
1664
- var _effect = _useSignals14();
1665
- try {
1666
- return /* @__PURE__ */ React15.createElement(FunctionBody, {
1667
- shape,
1668
- inputSchema: IfInput,
1669
- outputSchema: IfOutput
1670
- });
1671
- } finally {
1672
- _effect.f();
1673
- }
1727
+ return /* @__PURE__ */ React17.createElement(FunctionBody, {
1728
+ shape,
1729
+ inputSchema: IfInput,
1730
+ outputSchema: IfOutput
1731
+ });
1674
1732
  };
1675
1733
  var IfElseComponent = ({ shape, ...props }) => {
1676
- var _effect = _useSignals14();
1677
- try {
1678
- return /* @__PURE__ */ React15.createElement(FunctionBody, {
1679
- shape,
1680
- inputSchema: IfElseInput,
1681
- outputSchema: IfElseOutput
1682
- });
1683
- } finally {
1684
- _effect.f();
1685
- }
1734
+ return /* @__PURE__ */ React17.createElement(FunctionBody, {
1735
+ shape,
1736
+ inputSchema: IfElseInput,
1737
+ outputSchema: IfElseOutput
1738
+ });
1686
1739
  };
1687
1740
  var createIf = (props) => createShape({
1688
1741
  type: "if",
@@ -1696,7 +1749,7 @@ var ifShape = {
1696
1749
  type: "if",
1697
1750
  name: "IF",
1698
1751
  icon: "ph--arrows-split--regular",
1699
- component: (props) => /* @__PURE__ */ React15.createElement(IfComponent, props),
1752
+ component: (props) => /* @__PURE__ */ React17.createElement(IfComponent, props),
1700
1753
  createShape: createIf,
1701
1754
  getAnchors: (shape) => createFunctionAnchors(shape, IfInput, IfOutput)
1702
1755
  };
@@ -1712,95 +1765,21 @@ var ifElseShape = {
1712
1765
  type: "if-else",
1713
1766
  name: "IF/ELSE",
1714
1767
  icon: "ph--arrows-merge--regular",
1715
- component: (props) => /* @__PURE__ */ React15.createElement(IfElseComponent, props),
1768
+ component: (props) => /* @__PURE__ */ React17.createElement(IfElseComponent, props),
1716
1769
  createShape: createIfElse,
1717
1770
  getAnchors: (shape) => createFunctionAnchors(shape, IfElseInput, IfElseOutput)
1718
1771
  };
1719
1772
 
1720
- // src/shapes/Queue.tsx
1721
- import { useSignals as _useSignals15 } from "@preact-signals/safe-react/tracking";
1722
- import { Schema as Schema15 } from "effect";
1723
- import React16, { Fragment } from "react";
1724
- import { DEFAULT_OUTPUT as DEFAULT_OUTPUT4, QueueInput, QueueOutput } from "@dxos/conductor";
1725
- import { mx as mx2 } from "@dxos/react-ui-theme";
1726
- var QueueShape = Schema15.extend(ComputeShape, Schema15.Struct({
1727
- type: Schema15.Literal("queue")
1728
- }));
1729
- var createQueue = (props) => createShape({
1730
- type: "queue",
1731
- size: {
1732
- width: 256,
1733
- height: 512
1734
- },
1735
- ...props
1736
- });
1737
- var QueueComponent = ({ shape }) => {
1738
- var _effect = _useSignals15();
1739
- try {
1740
- const { runtime } = useComputeNodeState(shape);
1741
- const items = runtime.outputs[DEFAULT_OUTPUT4]?.type === "executed" ? runtime.outputs[DEFAULT_OUTPUT4].value : [];
1742
- const handleAction = (action) => {
1743
- if (action === "run") {
1744
- runtime.evalNode();
1745
- }
1746
- };
1747
- return /* @__PURE__ */ React16.createElement(Box, {
1748
- shape,
1749
- status: `${items.length} items`,
1750
- onAction: handleAction
1751
- }, /* @__PURE__ */ React16.createElement("div", {
1752
- className: "flex flex-col w-full overflow-y-scroll divide-y divide-separator"
1753
- }, [
1754
- ...items
1755
- ].map((item, i) => /* @__PURE__ */ React16.createElement(QueueItem, {
1756
- key: i,
1757
- classNames: "p-1 px-2",
1758
- item
1759
- }))));
1760
- } finally {
1761
- _effect.f();
1762
- }
1763
- };
1764
- var QueueItem = ({ classNames, item }) => {
1765
- var _effect = _useSignals15();
1766
- try {
1767
- if (typeof item !== "object") {
1768
- return /* @__PURE__ */ React16.createElement("div", {
1769
- className: mx2(classNames, "whitespace-pre-wrap")
1770
- }, item);
1771
- }
1772
- return /* @__PURE__ */ React16.createElement("div", {
1773
- className: mx2("grid grid-cols-[80px,1fr]", classNames)
1774
- }, Object.entries(item).map(([key, value]) => /* @__PURE__ */ React16.createElement(Fragment, {
1775
- key
1776
- }, /* @__PURE__ */ React16.createElement("div", {
1777
- className: "p-1 text-xs text-subdued"
1778
- }, key), /* @__PURE__ */ React16.createElement("div", null, typeof value === "string" ? value : JSON.stringify(value)))));
1779
- } finally {
1780
- _effect.f();
1781
- }
1782
- };
1783
- var queueShape = {
1784
- type: "queue",
1785
- name: "Queue",
1786
- icon: "ph--queue--regular",
1787
- component: QueueComponent,
1788
- createShape: createQueue,
1789
- getAnchors: (shape) => createFunctionAnchors(shape, QueueInput, QueueOutput),
1790
- resizable: true
1791
- };
1792
-
1793
1773
  // src/shapes/RNG.tsx
1794
- import { useSignals as _useSignals16 } from "@preact-signals/safe-react/tracking";
1795
- import { Schema as Schema16 } from "effect";
1796
- import React17, { useEffect as useEffect5, useState as useState7 } from "react";
1774
+ import * as Schema17 from "effect/Schema";
1775
+ import React18, { useEffect as useEffect5, useState as useState8 } from "react";
1797
1776
  import { DEFAULT_OUTPUT as DEFAULT_OUTPUT5 } from "@dxos/conductor";
1798
- import { Icon as Icon4 } from "@dxos/react-ui";
1777
+ import { Icon as Icon5 } from "@dxos/react-ui";
1799
1778
  import { createAnchorMap as createAnchorMap7 } from "@dxos/react-ui-canvas-editor";
1800
- var RandomShape = Schema16.extend(ComputeShape, Schema16.Struct({
1801
- type: Schema16.Literal("rng"),
1802
- min: Schema16.optional(Schema16.Number),
1803
- max: Schema16.optional(Schema16.Number)
1779
+ var RandomShape = Schema17.extend(ComputeShape, Schema17.Struct({
1780
+ type: Schema17.Literal("rng"),
1781
+ min: Schema17.optional(Schema17.Number),
1782
+ max: Schema17.optional(Schema17.Number)
1804
1783
  }));
1805
1784
  var createRandom = (props) => createShape({
1806
1785
  type: "rng",
@@ -1820,42 +1799,37 @@ var icons = [
1820
1799
  ];
1821
1800
  var pickIcon = () => icons[Math.floor(Math.random() * icons.length)];
1822
1801
  var RandomComponent = ({ shape }) => {
1823
- var _effect = _useSignals16();
1824
- try {
1825
- const { runtime } = useComputeNodeState(shape);
1826
- const [spin, setSpin] = useState7(false);
1827
- const [icon, setIcon] = useState7(pickIcon());
1828
- useEffect5(() => {
1829
- if (!spin) {
1830
- return;
1831
- }
1832
- const i = setInterval(() => setIcon(pickIcon()), 250);
1833
- const t1 = setTimeout(() => clearInterval(i), 900);
1834
- const t2 = setTimeout(() => setSpin(false), 1100);
1835
- return () => {
1836
- clearInterval(i);
1837
- clearTimeout(t1);
1838
- clearTimeout(t2);
1839
- };
1840
- }, [
1841
- spin
1842
- ]);
1843
- const handleClick = (ev) => {
1844
- ev.stopPropagation();
1845
- runtime.setOutput(DEFAULT_OUTPUT5, Math.random());
1846
- setSpin(true);
1802
+ const { runtime } = useComputeNodeState(shape);
1803
+ const [spin, setSpin] = useState8(false);
1804
+ const [icon, setIcon] = useState8(pickIcon());
1805
+ useEffect5(() => {
1806
+ if (!spin) {
1807
+ return;
1808
+ }
1809
+ const i = setInterval(() => setIcon(pickIcon()), 250);
1810
+ const t1 = setTimeout(() => clearInterval(i), 900);
1811
+ const t2 = setTimeout(() => setSpin(false), 1100);
1812
+ return () => {
1813
+ clearInterval(i);
1814
+ clearTimeout(t1);
1815
+ clearTimeout(t2);
1847
1816
  };
1848
- return /* @__PURE__ */ React17.createElement("div", {
1849
- className: "flex grow items-center justify-center"
1850
- }, /* @__PURE__ */ React17.createElement(Icon4, {
1851
- icon,
1852
- classNames: spin && "animate-[spin_1s]",
1853
- size: 10,
1854
- onClick: handleClick
1855
- }));
1856
- } finally {
1857
- _effect.f();
1858
- }
1817
+ }, [
1818
+ spin
1819
+ ]);
1820
+ const handleClick = (ev) => {
1821
+ ev.stopPropagation();
1822
+ runtime.setOutput(DEFAULT_OUTPUT5, Math.random());
1823
+ setSpin(true);
1824
+ };
1825
+ return /* @__PURE__ */ React18.createElement("div", {
1826
+ className: "flex grow items-center justify-center"
1827
+ }, /* @__PURE__ */ React18.createElement(Icon5, {
1828
+ icon,
1829
+ classNames: spin && "animate-[spin_1s]",
1830
+ size: 10,
1831
+ onClick: handleClick
1832
+ }));
1859
1833
  };
1860
1834
  var randomShape = {
1861
1835
  type: "rng",
@@ -1872,14 +1846,14 @@ var randomShape = {
1872
1846
  };
1873
1847
 
1874
1848
  // src/shapes/Scope.tsx
1875
- import { useSignals as _useSignals17 } from "@preact-signals/safe-react/tracking";
1876
- import { Schema as Schema17 } from "effect";
1877
- import React18 from "react";
1849
+ import * as Schema18 from "effect/Schema";
1850
+ import React19 from "react";
1878
1851
  import { DEFAULT_INPUT as DEFAULT_INPUT5 } from "@dxos/conductor";
1852
+ import { useAudioStream } from "@dxos/react-ui-audio";
1879
1853
  import { createAnchorMap as createAnchorMap8 } from "@dxos/react-ui-canvas-editor";
1880
- import { Chaos, shaderPresets, useAudioStream } from "@dxos/react-ui-sfx";
1881
- var ScopeShape = Schema17.extend(ComputeShape, Schema17.Struct({
1882
- type: Schema17.Literal("scope")
1854
+ import { Chaos, shaderPresets } from "@dxos/react-ui-experimental";
1855
+ var ScopeShape = Schema18.extend(ComputeShape, Schema18.Struct({
1856
+ type: Schema18.Literal("scope")
1883
1857
  }));
1884
1858
  var createScope = (props) => createShape({
1885
1859
  type: "scope",
@@ -1891,25 +1865,20 @@ var createScope = (props) => createShape({
1891
1865
  ...props
1892
1866
  });
1893
1867
  var ScopeComponent = ({ shape }) => {
1894
- var _effect = _useSignals17();
1895
- try {
1896
- const { runtime } = useComputeNodeState(shape);
1897
- const input = runtime.inputs[DEFAULT_INPUT5];
1898
- const active = input?.type === "executed" ? input.value : false;
1899
- const { getAverage } = useAudioStream(active);
1900
- return /* @__PURE__ */ React18.createElement("div", {
1901
- className: "flex w-full justify-center items-center bg-black"
1902
- }, /* @__PURE__ */ React18.createElement(Chaos, {
1903
- active,
1904
- getValue: getAverage,
1905
- options: {
1906
- ...shaderPresets.heptapod,
1907
- zoom: 1.2
1908
- }
1909
- }));
1910
- } finally {
1911
- _effect.f();
1912
- }
1868
+ const { runtime } = useComputeNodeState(shape);
1869
+ const input = runtime.inputs[DEFAULT_INPUT5];
1870
+ const active = input?.type === "executed" ? input.value : false;
1871
+ const { getAverage } = useAudioStream(active);
1872
+ return /* @__PURE__ */ React19.createElement("div", {
1873
+ className: "flex w-full justify-center items-center bg-black"
1874
+ }, /* @__PURE__ */ React19.createElement(Chaos, {
1875
+ active,
1876
+ getValue: getAverage,
1877
+ options: {
1878
+ ...shaderPresets.heptapod,
1879
+ zoom: 1.2
1880
+ }
1881
+ }));
1913
1882
  };
1914
1883
  var scopeShape = {
1915
1884
  type: "scope",
@@ -1926,14 +1895,15 @@ var scopeShape = {
1926
1895
  };
1927
1896
 
1928
1897
  // src/shapes/Surface.tsx
1929
- import { useSignals as _useSignals18 } from "@preact-signals/safe-react/tracking";
1930
- import { Schema as Schema18 } from "effect";
1931
- import React19 from "react";
1932
- import { Surface } from "@dxos/app-framework";
1898
+ import * as Schema19 from "effect/Schema";
1899
+ import React20 from "react";
1900
+ import { Surface } from "@dxos/app-framework/ui";
1901
+ import { AppSurface } from "@dxos/app-toolkit/ui";
1933
1902
  import { DEFAULT_INPUT as DEFAULT_INPUT6 } from "@dxos/conductor";
1903
+ import { Card } from "@dxos/react-ui";
1934
1904
  import { createAnchorMap as createAnchorMap9 } from "@dxos/react-ui-canvas-editor";
1935
- var SurfaceShape = Schema18.extend(ComputeShape, Schema18.Struct({
1936
- type: Schema18.Literal("surface")
1905
+ var SurfaceShape = Schema19.extend(ComputeShape, Schema19.Struct({
1906
+ type: Schema19.Literal("surface")
1937
1907
  }));
1938
1908
  var createSurface = (props) => createShape({
1939
1909
  type: "surface",
@@ -1944,29 +1914,24 @@ var createSurface = (props) => createShape({
1944
1914
  ...props
1945
1915
  });
1946
1916
  var SurfaceComponent = ({ shape }) => {
1947
- var _effect = _useSignals18();
1948
- try {
1949
- const { runtime } = useComputeNodeState(shape);
1950
- const input = runtime.inputs[DEFAULT_INPUT6];
1951
- const value = input?.type === "executed" ? input.value : null;
1952
- const handleAction = (action) => {
1953
- if (action === "run") {
1954
- runtime.evalNode();
1955
- }
1956
- };
1957
- return /* @__PURE__ */ React19.createElement(Box, {
1958
- shape,
1959
- onAction: handleAction
1960
- }, value !== null && /* @__PURE__ */ React19.createElement(Surface, {
1961
- role: "card--extrinsic",
1962
- data: {
1963
- value
1964
- },
1965
- limit: 1
1966
- }));
1967
- } finally {
1968
- _effect.f();
1969
- }
1917
+ const { runtime } = useComputeNodeState(shape);
1918
+ const input = runtime.inputs[DEFAULT_INPUT6];
1919
+ const value = input?.type === "executed" ? input.value : null;
1920
+ const handleAction = (action) => {
1921
+ if (action === "run") {
1922
+ runtime.evalNode();
1923
+ }
1924
+ };
1925
+ return /* @__PURE__ */ React20.createElement(Box, {
1926
+ shape,
1927
+ onAction: handleAction
1928
+ }, /* @__PURE__ */ React20.createElement(Card.Root, null, value !== null && /* @__PURE__ */ React20.createElement(Surface.Surface, {
1929
+ type: AppSurface.Card,
1930
+ data: {
1931
+ subject: value
1932
+ },
1933
+ limit: 1
1934
+ })));
1970
1935
  };
1971
1936
  var surfaceShape = {
1972
1937
  type: "surface",
@@ -1984,14 +1949,13 @@ var surfaceShape = {
1984
1949
  };
1985
1950
 
1986
1951
  // src/shapes/Switch.tsx
1987
- import { useSignals as _useSignals19 } from "@preact-signals/safe-react/tracking";
1988
- import { Schema as Schema19 } from "effect";
1989
- import React20, { useEffect as useEffect6, useState as useState8 } from "react";
1952
+ import * as Schema20 from "effect/Schema";
1953
+ import React21, { useEffect as useEffect6, useState as useState9 } from "react";
1990
1954
  import { DEFAULT_OUTPUT as DEFAULT_OUTPUT6 } from "@dxos/conductor";
1991
1955
  import { Input as Input2 } from "@dxos/react-ui";
1992
1956
  import { createAnchorMap as createAnchorMap10 } from "@dxos/react-ui-canvas-editor";
1993
- var SwitchShape = Schema19.extend(ComputeShape, Schema19.Struct({
1994
- type: Schema19.Literal("switch")
1957
+ var SwitchShape = Schema20.extend(ComputeShape, Schema20.Struct({
1958
+ type: Schema20.Literal("switch")
1995
1959
  }));
1996
1960
  var createSwitch = (props) => createShape({
1997
1961
  type: "switch",
@@ -2002,25 +1966,20 @@ var createSwitch = (props) => createShape({
2002
1966
  ...props
2003
1967
  });
2004
1968
  var SwitchComponent = ({ shape }) => {
2005
- var _effect = _useSignals19();
2006
- try {
2007
- const { runtime } = useComputeNodeState(shape);
2008
- const [value, setValue] = useState8(false);
2009
- useEffect6(() => {
2010
- runtime.setOutput(DEFAULT_OUTPUT6, value);
2011
- }, [
2012
- value
2013
- ]);
2014
- return /* @__PURE__ */ React20.createElement("div", {
2015
- className: "flex w-full justify-center items-center",
2016
- onClick: (ev) => ev.stopPropagation()
2017
- }, /* @__PURE__ */ React20.createElement(Input2.Root, null, /* @__PURE__ */ React20.createElement(Input2.Switch, {
2018
- checked: value,
2019
- onCheckedChange: (value2) => setValue(value2)
2020
- })));
2021
- } finally {
2022
- _effect.f();
2023
- }
1969
+ const { runtime } = useComputeNodeState(shape);
1970
+ const [value, setValue] = useState9(false);
1971
+ useEffect6(() => {
1972
+ runtime.setOutput(DEFAULT_OUTPUT6, value);
1973
+ }, [
1974
+ value
1975
+ ]);
1976
+ return /* @__PURE__ */ React21.createElement("div", {
1977
+ className: "flex w-full justify-center items-center",
1978
+ onClick: (ev) => ev.stopPropagation()
1979
+ }, /* @__PURE__ */ React21.createElement(Input2.Root, null, /* @__PURE__ */ React21.createElement(Input2.Switch, {
1980
+ checked: value,
1981
+ onCheckedChange: (value2) => setValue(value2)
1982
+ })));
2024
1983
  };
2025
1984
  var switchShape = {
2026
1985
  type: "switch",
@@ -2037,15 +1996,15 @@ var switchShape = {
2037
1996
  };
2038
1997
 
2039
1998
  // src/shapes/Table.tsx
2040
- import { useSignals as _useSignals20 } from "@preact-signals/safe-react/tracking";
2041
- import { Schema as Schema20 } from "effect";
2042
- import React21 from "react";
1999
+ import * as Schema21 from "effect/Schema";
2000
+ import React22 from "react";
2043
2001
  import { createInputSchema, createOutputSchema } from "@dxos/conductor";
2044
- import { DataType } from "@dxos/schema";
2045
- var InputSchema = createInputSchema(DataType.Message);
2046
- var OutputSchema = createOutputSchema(Schema20.mutable(Schema20.Array(DataType.Message)));
2047
- var TableShape = Schema20.extend(ComputeShape, Schema20.Struct({
2048
- type: Schema20.Literal("table")
2002
+ import { Type } from "@dxos/echo";
2003
+ import { Message } from "@dxos/types";
2004
+ var InputSchema = createInputSchema(Type.getSchema(Message.Message));
2005
+ var OutputSchema = createOutputSchema(Schema21.mutable(Schema21.Array(Type.getSchema(Message.Message))));
2006
+ var TableShape = Schema21.extend(ComputeShape, Schema21.Struct({
2007
+ type: Schema21.Literal("table")
2049
2008
  }));
2050
2009
  var createTable = (props) => createShape({
2051
2010
  type: "table",
@@ -2056,14 +2015,9 @@ var createTable = (props) => createShape({
2056
2015
  ...props
2057
2016
  });
2058
2017
  var TableComponent = ({ shape }) => {
2059
- var _effect = _useSignals20();
2060
- try {
2061
- return /* @__PURE__ */ React21.createElement(Box, {
2062
- shape
2063
- });
2064
- } finally {
2065
- _effect.f();
2066
- }
2018
+ return /* @__PURE__ */ React22.createElement(Box, {
2019
+ shape
2020
+ });
2067
2021
  };
2068
2022
  var tableShape = {
2069
2023
  type: "table",
@@ -2076,62 +2030,48 @@ var tableShape = {
2076
2030
  };
2077
2031
 
2078
2032
  // src/shapes/Template.tsx
2079
- import { useSignals as _useSignals21 } from "@preact-signals/safe-react/tracking";
2080
- import { Schema as Schema21 } from "effect";
2081
- import React22, { useRef as useRef5 } from "react";
2033
+ import * as Schema22 from "effect/Schema";
2034
+ import React23, { useRef as useRef5 } from "react";
2082
2035
  import { ComputeValueType as ComputeValueType3, TemplateOutput, VoidInput as VoidInput2, getTemplateInputSchema as getTemplateInputSchema2 } from "@dxos/conductor";
2083
- import { toJsonSchema as toJsonSchema2 } from "@dxos/echo-schema";
2036
+ import { toJsonSchema } from "@dxos/echo/JsonSchema";
2084
2037
  import { invariant as invariant5 } from "@dxos/invariant";
2085
2038
  import { TextBox as TextBox4 } from "@dxos/react-ui-canvas-editor";
2086
- var __dxlog_file6 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/Template.tsx";
2087
- var TemplateShape = Schema21.extend(ComputeShape, Schema21.Struct({
2088
- type: Schema21.Literal("template"),
2089
- valueType: Schema21.optional(ComputeValueType3)
2039
+ var __dxlog_file7 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/Template.tsx";
2040
+ var TemplateShape = Schema22.extend(ComputeShape, Schema22.Struct({
2041
+ type: Schema22.Literal("template"),
2042
+ valueType: Schema22.optional(ComputeValueType3)
2090
2043
  }));
2091
2044
  var TextInputComponent3 = ({ shape, title, ...props }) => {
2092
- var _effect = _useSignals21();
2093
- try {
2094
- const { node } = useComputeNodeState(shape);
2095
- const inputRef = useRef5(null);
2096
- const handleEnter = (text) => {
2097
- const value = text.trim();
2098
- if (value.length) {
2099
- const schema = getTemplateInputSchema2(node);
2100
- node.value = value;
2101
- node.inputSchema = toJsonSchema2(schema);
2102
- }
2103
- };
2104
- const handleTypeChange = (newType) => {
2105
- invariant5(Schema21.is(ComputeValueType3)(newType), "Invalid type", {
2106
- F: __dxlog_file6,
2107
- L: 59,
2108
- S: void 0,
2109
- A: [
2110
- "Schema.is(ComputeValueType)(newType)",
2111
- "'Invalid type'"
2112
- ]
2113
- });
2114
- node.valueType = newType;
2115
- node.inputSchema = toJsonSchema2(getTemplateInputSchema2(node));
2116
- };
2117
- return /* @__PURE__ */ React22.createElement(Box, {
2118
- shape,
2119
- title: "Template",
2120
- status: /* @__PURE__ */ React22.createElement(TypeSelect, {
2121
- value: node.valueType ?? "string",
2122
- onValueChange: handleTypeChange
2123
- })
2124
- }, /* @__PURE__ */ React22.createElement(TextBox4, {
2125
- ...props,
2126
- ref: inputRef,
2127
- value: node.value,
2128
- language: node.valueType === "object" ? "json" : void 0,
2129
- onBlur: handleEnter,
2130
- onEnter: handleEnter
2131
- }));
2132
- } finally {
2133
- _effect.f();
2134
- }
2045
+ const { node } = useComputeNodeState(shape);
2046
+ const inputRef = useRef5(null);
2047
+ const handleEnter = (text) => {
2048
+ const value = text.trim();
2049
+ if (value.length) {
2050
+ const schema = getTemplateInputSchema2(node);
2051
+ node.value = value;
2052
+ node.inputSchema = toJsonSchema(schema);
2053
+ }
2054
+ };
2055
+ const handleTypeChange = (newType) => {
2056
+ invariant5(Schema22.is(ComputeValueType3)(newType), "Invalid type", { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 32, S: void 0, A: ["Schema.is(ComputeValueType)(newType)", "'Invalid type'"] });
2057
+ node.valueType = newType;
2058
+ node.inputSchema = toJsonSchema(getTemplateInputSchema2(node));
2059
+ };
2060
+ return /* @__PURE__ */ React23.createElement(Box, {
2061
+ shape,
2062
+ title: "Template",
2063
+ status: /* @__PURE__ */ React23.createElement(TypeSelect, {
2064
+ value: node.valueType ?? "string",
2065
+ onValueChange: handleTypeChange
2066
+ })
2067
+ }, /* @__PURE__ */ React23.createElement(TextBox4, {
2068
+ ...props,
2069
+ ref: inputRef,
2070
+ value: node.value,
2071
+ language: node.valueType === "object" ? "json" : void 0,
2072
+ onBlur: handleEnter,
2073
+ onEnter: handleEnter
2074
+ }));
2135
2075
  };
2136
2076
  var createTemplate = (props) => createShape({
2137
2077
  type: "template",
@@ -2145,7 +2085,7 @@ var templateShape = {
2145
2085
  type: "template",
2146
2086
  name: "Template",
2147
2087
  icon: "ph--article--regular",
2148
- component: (props) => /* @__PURE__ */ React22.createElement(TextInputComponent3, {
2088
+ component: (props) => /* @__PURE__ */ React23.createElement(TextInputComponent3, {
2149
2089
  ...props,
2150
2090
  placeholder: "Prompt"
2151
2091
  }),
@@ -2155,14 +2095,13 @@ var templateShape = {
2155
2095
  };
2156
2096
 
2157
2097
  // src/shapes/Text.tsx
2158
- import { useSignals as _useSignals22 } from "@preact-signals/safe-react/tracking";
2159
- import { Schema as Schema22 } from "effect";
2160
- import React23 from "react";
2098
+ import * as Schema23 from "effect/Schema";
2099
+ import React24 from "react";
2161
2100
  import { DEFAULT_INPUT as DEFAULT_INPUT7 } from "@dxos/conductor";
2162
2101
  import { TextBox as TextBox5 } from "@dxos/react-ui-canvas-editor";
2163
2102
  import { createAnchorMap as createAnchorMap11 } from "@dxos/react-ui-canvas-editor";
2164
- var TextShape = Schema22.extend(ComputeShape, Schema22.Struct({
2165
- type: Schema22.Literal("text")
2103
+ var TextShape = Schema23.extend(ComputeShape, Schema23.Struct({
2104
+ type: Schema23.Literal("text")
2166
2105
  }));
2167
2106
  var createText = (props) => createShape({
2168
2107
  type: "text",
@@ -2173,25 +2112,20 @@ var createText = (props) => createShape({
2173
2112
  ...props
2174
2113
  });
2175
2114
  var TextComponent = ({ shape }) => {
2176
- var _effect = _useSignals22();
2177
- try {
2178
- const { runtime } = useComputeNodeState(shape);
2179
- const input = runtime.inputs[DEFAULT_INPUT7];
2180
- const value = input?.type === "executed" ? input.value : 0;
2181
- const handleAction = (action) => {
2182
- if (action === "run") {
2183
- runtime.evalNode();
2184
- }
2185
- };
2186
- return /* @__PURE__ */ React23.createElement(Box, {
2187
- shape,
2188
- onAction: handleAction
2189
- }, /* @__PURE__ */ React23.createElement(TextBox5, {
2190
- value
2191
- }));
2192
- } finally {
2193
- _effect.f();
2194
- }
2115
+ const { runtime } = useComputeNodeState(shape);
2116
+ const input = runtime.inputs[DEFAULT_INPUT7];
2117
+ const value = input?.type === "executed" ? input.value : 0;
2118
+ const handleAction = (action) => {
2119
+ if (action === "run") {
2120
+ runtime.evalNode();
2121
+ }
2122
+ };
2123
+ return /* @__PURE__ */ React24.createElement(Box, {
2124
+ shape,
2125
+ onAction: handleAction
2126
+ }, /* @__PURE__ */ React24.createElement(TextBox5, {
2127
+ value
2128
+ }));
2195
2129
  };
2196
2130
  var textShape = {
2197
2131
  type: "text",
@@ -2209,16 +2143,17 @@ var textShape = {
2209
2143
  };
2210
2144
 
2211
2145
  // src/shapes/Thread.tsx
2212
- import { useSignals as _useSignals23 } from "@preact-signals/safe-react/tracking";
2213
- import { Schema as Schema23 } from "effect";
2214
- import React24, { useEffect as useEffect7, useRef as useRef6 } from "react";
2146
+ import * as Schema24 from "effect/Schema";
2147
+ import React25, { useEffect as useEffect7, useRef as useRef6 } from "react";
2215
2148
  import { createInputSchema as createInputSchema2, createOutputSchema as createOutputSchema2 } from "@dxos/conductor";
2216
- import { mx as mx3 } from "@dxos/react-ui-theme";
2217
- import { DataType as DataType2 } from "@dxos/schema";
2218
- var InputSchema2 = createInputSchema2(DataType2.Message);
2219
- var OutputSchema2 = createOutputSchema2(Schema23.mutable(Schema23.Array(DataType2.Message)));
2220
- var ThreadShape = Schema23.extend(ComputeShape, Schema23.Struct({
2221
- type: Schema23.Literal("thread")
2149
+ import { Type as Type2 } from "@dxos/echo";
2150
+ import { ScrollArea as ScrollArea3 } from "@dxos/react-ui";
2151
+ import { Message as Message2 } from "@dxos/types";
2152
+ import { mx as mx3 } from "@dxos/ui-theme";
2153
+ var InputSchema2 = createInputSchema2(Type2.getSchema(Message2.Message));
2154
+ var OutputSchema2 = createOutputSchema2(Schema24.mutable(Schema24.Array(Type2.getSchema(Message2.Message))));
2155
+ var ThreadShape = Schema24.extend(ComputeShape, Schema24.Struct({
2156
+ type: Schema24.Literal("thread")
2222
2157
  }));
2223
2158
  var createThread = (props) => createShape({
2224
2159
  type: "thread",
@@ -2229,49 +2164,41 @@ var createThread = (props) => createShape({
2229
2164
  ...props
2230
2165
  });
2231
2166
  var ThreadComponent = ({ shape }) => {
2232
- var _effect = _useSignals23();
2233
- try {
2234
- const items = [];
2235
- const scrollRef = useRef6(null);
2236
- useEffect7(() => {
2237
- if (scrollRef.current) {
2238
- scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
2239
- }
2240
- }, [
2241
- items
2242
- ]);
2243
- return /* @__PURE__ */ React24.createElement(Box, {
2244
- shape
2245
- }, /* @__PURE__ */ React24.createElement("div", {
2246
- ref: scrollRef,
2247
- className: "flex flex-col w-full overflow-y-scroll gap-2 p-2"
2248
- }, [
2249
- ...items
2250
- ].map((item, i) => /* @__PURE__ */ React24.createElement(ThreadItem, {
2251
- key: i,
2252
- item
2253
- }))));
2254
- } finally {
2255
- _effect.f();
2256
- }
2167
+ const items = [];
2168
+ const scrollRef = useRef6(null);
2169
+ useEffect7(() => {
2170
+ if (scrollRef.current) {
2171
+ scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
2172
+ }
2173
+ }, [
2174
+ items
2175
+ ]);
2176
+ return /* @__PURE__ */ React25.createElement(Box, {
2177
+ shape
2178
+ }, /* @__PURE__ */ React25.createElement(ScrollArea3.Root, {
2179
+ orientation: "vertical"
2180
+ }, /* @__PURE__ */ React25.createElement(ScrollArea3.Viewport, {
2181
+ classNames: "gap-2 p-2",
2182
+ ref: scrollRef
2183
+ }, [
2184
+ ...items
2185
+ ].map((item, i) => /* @__PURE__ */ React25.createElement(ThreadItem, {
2186
+ key: i,
2187
+ item
2188
+ })))));
2257
2189
  };
2258
2190
  var ThreadItem = ({ classNames, item }) => {
2259
- var _effect = _useSignals23();
2260
- try {
2261
- if (typeof item !== "object") {
2262
- return /* @__PURE__ */ React24.createElement("div", {
2263
- className: mx3(classNames)
2264
- }, item);
2265
- }
2266
- const { role, message } = item;
2267
- return /* @__PURE__ */ React24.createElement("div", {
2268
- className: mx3("flex", classNames, role === "user" && "justify-end")
2269
- }, /* @__PURE__ */ React24.createElement("div", {
2270
- 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")
2271
- }, message));
2272
- } finally {
2273
- _effect.f();
2191
+ if (typeof item !== "object") {
2192
+ return /* @__PURE__ */ React25.createElement("div", {
2193
+ className: mx3(classNames)
2194
+ }, item);
2274
2195
  }
2196
+ const { role, message } = item;
2197
+ return /* @__PURE__ */ React25.createElement("div", {
2198
+ className: mx3("flex", classNames, role === "user" && "justify-end")
2199
+ }, /* @__PURE__ */ React25.createElement("div", {
2200
+ 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")
2201
+ }, message));
2275
2202
  };
2276
2203
  var threadShape = {
2277
2204
  type: "thread",
@@ -2284,12 +2211,11 @@ var threadShape = {
2284
2211
  };
2285
2212
 
2286
2213
  // src/shapes/TextToImage.tsx
2287
- import { useSignals as _useSignals24 } from "@preact-signals/safe-react/tracking";
2288
- import { Schema as Schema24 } from "effect";
2289
- import React25 from "react";
2214
+ import * as Schema25 from "effect/Schema";
2215
+ import React26 from "react";
2290
2216
  import { createAnchorMap as createAnchorMap12 } from "@dxos/react-ui-canvas-editor";
2291
- var TextToImageShape = Schema24.extend(ComputeShape, Schema24.Struct({
2292
- type: Schema24.Literal("text-to-image")
2217
+ var TextToImageShape = Schema25.extend(ComputeShape, Schema25.Struct({
2218
+ type: Schema25.Literal("text-to-image")
2293
2219
  }));
2294
2220
  var createTextToImage = (props) => createShape({
2295
2221
  type: "text-to-image",
@@ -2300,14 +2226,9 @@ var createTextToImage = (props) => createShape({
2300
2226
  ...props
2301
2227
  });
2302
2228
  var TextToImageComponent = ({ shape }) => {
2303
- var _effect = _useSignals24();
2304
- try {
2305
- return /* @__PURE__ */ React25.createElement(Box, {
2306
- shape
2307
- });
2308
- } finally {
2309
- _effect.f();
2310
- }
2229
+ return /* @__PURE__ */ React26.createElement(Box, {
2230
+ shape
2231
+ });
2311
2232
  };
2312
2233
  var textToImageShape = {
2313
2234
  type: "text-to-image",
@@ -2324,21 +2245,20 @@ var textToImageShape = {
2324
2245
  };
2325
2246
 
2326
2247
  // src/shapes/Trigger.tsx
2327
- import { useSignals as _useSignals25 } from "@preact-signals/safe-react/tracking";
2328
- import { Schema as Schema25 } from "effect";
2329
- import React26, { useEffect as useEffect8 } from "react";
2248
+ import * as Schema26 from "effect/Schema";
2249
+ import React27, { useEffect as useEffect8 } from "react";
2250
+ import { Trigger, TriggerEvent } from "@dxos/compute";
2330
2251
  import { VoidInput as VoidInput3 } from "@dxos/conductor";
2331
- import { ObjectId as ObjectId4, Ref as Ref3 } from "@dxos/echo-schema";
2332
- import { EmailTriggerOutput, FunctionTrigger, QueueTriggerOutput, SubscriptionTriggerOutput, TimerTriggerOutput, TriggerKind, WebhookTriggerOutput } from "@dxos/functions";
2333
- import { DXN, SpaceId } from "@dxos/keys";
2334
- import { live, useSpace } from "@dxos/react-client/echo";
2252
+ import { Filter as Filter2, Obj as Obj4, Query, Ref as Ref3 } from "@dxos/echo";
2253
+ import { useSpaces } from "@dxos/react-client/echo";
2335
2254
  import { Select as Select2 } from "@dxos/react-ui";
2336
- var TriggerShape = Schema25.extend(ComputeShape, Schema25.Struct({
2337
- type: Schema25.Literal("trigger"),
2338
- functionTrigger: Schema25.optional(Ref3(FunctionTrigger))
2255
+ var TriggerShapeSchema = Schema26.extend(ComputeShape, Schema26.Struct({
2256
+ type: Schema26.Literal("trigger"),
2257
+ functionTrigger: Schema26.optional(Ref3.Ref(Trigger.Trigger))
2339
2258
  }));
2259
+ var TriggerShape = TriggerShapeSchema;
2340
2260
  var createTrigger = (props) => {
2341
- const functionTrigger = live(FunctionTrigger, {
2261
+ const functionTrigger = Trigger.make({
2342
2262
  enabled: true,
2343
2263
  spec: createTriggerSpec(props)
2344
2264
  });
@@ -2347,115 +2267,94 @@ var createTrigger = (props) => {
2347
2267
  functionTrigger: Ref3.make(functionTrigger),
2348
2268
  size: {
2349
2269
  width: 192,
2350
- height: getHeight(EmailTriggerOutput)
2270
+ height: getHeight(TriggerEvent.EmailEvent)
2351
2271
  },
2352
2272
  ...props
2353
2273
  });
2354
2274
  };
2355
2275
  var TriggerComponent = ({ shape }) => {
2356
- var _effect = _useSignals25();
2357
- try {
2358
- const space = useSpace();
2359
- const functionTrigger = shape.functionTrigger?.target;
2360
- useEffect8(() => {
2361
- if (functionTrigger && !functionTrigger.spec) {
2362
- functionTrigger.spec = createTriggerSpec({
2363
- triggerKind: TriggerKind.Email,
2276
+ const [space] = useSpaces();
2277
+ const functionTrigger = shape.functionTrigger?.target;
2278
+ useEffect8(() => {
2279
+ if (functionTrigger && !functionTrigger.spec) {
2280
+ Obj4.update(functionTrigger, (functionTrigger2) => {
2281
+ functionTrigger2.spec = createTriggerSpec({
2282
+ triggerKind: "email",
2364
2283
  spaceId: space?.id
2365
2284
  });
2366
- }
2367
- }, [
2368
- functionTrigger,
2369
- functionTrigger?.spec
2370
- ]);
2371
- useEffect8(() => {
2372
- shape.size.height = getHeight(getOutputSchema(functionTrigger?.spec?.kind ?? TriggerKind.Email));
2373
- }, [
2374
- functionTrigger?.spec?.kind
2375
- ]);
2376
- const setKind = (kind) => {
2377
- if (functionTrigger?.spec?.kind !== kind) {
2378
- functionTrigger.spec = createTriggerSpec({
2285
+ });
2286
+ }
2287
+ }, [
2288
+ functionTrigger,
2289
+ functionTrigger?.spec
2290
+ ]);
2291
+ useEffect8(() => {
2292
+ shape.size.height = getHeight(getOutputSchema(functionTrigger?.spec?.kind ?? "email"));
2293
+ }, [
2294
+ functionTrigger?.spec?.kind
2295
+ ]);
2296
+ const setKind = (kind) => {
2297
+ if (functionTrigger?.spec?.kind !== kind) {
2298
+ Obj4.update(functionTrigger, (obj) => {
2299
+ obj.spec = createTriggerSpec({
2379
2300
  triggerKind: kind,
2380
2301
  spaceId: space?.id
2381
2302
  });
2382
- }
2383
- };
2384
- if (!functionTrigger?.spec) {
2385
- return;
2303
+ });
2386
2304
  }
2387
- return /* @__PURE__ */ React26.createElement(FunctionBody, {
2388
- shape,
2389
- status: /* @__PURE__ */ React26.createElement(TriggerKindSelect, {
2390
- value: functionTrigger.spec?.kind,
2391
- onValueChange: (kind) => setKind(kind)
2392
- }),
2393
- inputSchema: VoidInput3,
2394
- outputSchema: getOutputSchema(functionTrigger.spec.kind)
2395
- });
2396
- } finally {
2397
- _effect.f();
2305
+ };
2306
+ if (!functionTrigger?.spec) {
2307
+ return;
2398
2308
  }
2309
+ return /* @__PURE__ */ React27.createElement(FunctionBody, {
2310
+ shape,
2311
+ status: /* @__PURE__ */ React27.createElement(TriggerKindSelect, {
2312
+ value: functionTrigger.spec?.kind,
2313
+ onValueChange: (kind) => setKind(kind)
2314
+ }),
2315
+ inputSchema: VoidInput3,
2316
+ outputSchema: getOutputSchema(functionTrigger.spec.kind)
2317
+ });
2399
2318
  };
2400
2319
  var TriggerKindSelect = ({ value, onValueChange }) => {
2401
- var _effect = _useSignals25();
2402
- try {
2403
- return /* @__PURE__ */ React26.createElement(Select2.Root, {
2404
- value,
2405
- onValueChange
2406
- }, /* @__PURE__ */ React26.createElement(Select2.TriggerButton, {
2407
- variant: "ghost",
2408
- classNames: "w-full !px-0"
2409
- }), /* @__PURE__ */ React26.createElement(Select2.Portal, null, /* @__PURE__ */ React26.createElement(Select2.Content, null, /* @__PURE__ */ React26.createElement(Select2.ScrollUpButton, null), /* @__PURE__ */ React26.createElement(Select2.Viewport, null, Object.values(TriggerKind).map((kind) => /* @__PURE__ */ React26.createElement(Select2.Option, {
2410
- key: kind,
2411
- value: kind
2412
- }, kind))), /* @__PURE__ */ React26.createElement(Select2.ScrollDownButton, null), /* @__PURE__ */ React26.createElement(Select2.Arrow, null))));
2413
- } finally {
2414
- _effect.f();
2415
- }
2320
+ return /* @__PURE__ */ React27.createElement(Select2.Root, {
2321
+ value,
2322
+ onValueChange
2323
+ }, /* @__PURE__ */ React27.createElement(Select2.TriggerButton, {
2324
+ variant: "ghost",
2325
+ classNames: "w-full px-0!"
2326
+ }), /* @__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, {
2327
+ key: kind,
2328
+ value: kind
2329
+ }, kind))), /* @__PURE__ */ React27.createElement(Select2.ScrollDownButton, null), /* @__PURE__ */ React27.createElement(Select2.Arrow, null))));
2416
2330
  };
2417
2331
  var createTriggerSpec = (props) => {
2418
- const kind = props.triggerKind ?? TriggerKind.Email;
2332
+ const kind = props.triggerKind ?? "email";
2419
2333
  switch (kind) {
2420
- case TriggerKind.Timer:
2421
- return {
2422
- kind: TriggerKind.Timer,
2423
- cron: "*/10 * * * * *"
2424
- };
2425
- case TriggerKind.Webhook:
2426
- return {
2427
- kind: TriggerKind.Webhook,
2334
+ case "timer":
2335
+ return Trigger.specTimer("*/10 * * * * *");
2336
+ case "webhook":
2337
+ return Trigger.specWebhook({
2428
2338
  method: "POST"
2429
- };
2430
- case TriggerKind.Subscription:
2431
- return {
2432
- kind: TriggerKind.Subscription,
2433
- filter: {}
2434
- };
2435
- case TriggerKind.Email:
2436
- return {
2437
- kind: TriggerKind.Email
2438
- };
2439
- case TriggerKind.Queue: {
2440
- const dxn = new DXN(DXN.kind.QUEUE, [
2441
- "data",
2442
- props.spaceId ?? SpaceId.random(),
2443
- ObjectId4.random()
2444
- ]).toString();
2339
+ });
2340
+ case "subscription":
2341
+ return Trigger.specSubscription(Query.select(Filter2.nothing()));
2342
+ case "email":
2343
+ return Trigger.specEmail();
2344
+ case "feed": {
2445
2345
  return {
2446
- kind: TriggerKind.Queue,
2447
- queue: dxn
2346
+ kind: "feed"
2448
2347
  };
2449
2348
  }
2450
2349
  }
2451
2350
  };
2452
2351
  var getOutputSchema = (kind) => {
2453
2352
  const kindToSchema = {
2454
- [TriggerKind.Email]: EmailTriggerOutput,
2455
- [TriggerKind.Subscription]: SubscriptionTriggerOutput,
2456
- [TriggerKind.Timer]: TimerTriggerOutput,
2457
- [TriggerKind.Webhook]: WebhookTriggerOutput,
2458
- [TriggerKind.Queue]: QueueTriggerOutput
2353
+ ["email"]: TriggerEvent.EmailEvent,
2354
+ ["subscription"]: TriggerEvent.SubscriptionEvent,
2355
+ ["timer"]: TriggerEvent.TimerEvent,
2356
+ ["webhook"]: TriggerEvent.WebhookEvent,
2357
+ ["feed"]: TriggerEvent.FeedEvent
2459
2358
  };
2460
2359
  return kindToSchema[kind];
2461
2360
  };
@@ -2465,143 +2364,9 @@ var triggerShape = {
2465
2364
  icon: "ph--lightning--regular",
2466
2365
  component: TriggerComponent,
2467
2366
  createShape: createTrigger,
2468
- getAnchors: (shape) => createFunctionAnchors(shape, VoidInput3, getOutputSchema(shape.functionTrigger?.target?.spec?.kind ?? TriggerKind.Email))
2367
+ getAnchors: (shape) => createFunctionAnchors(shape, VoidInput3, getOutputSchema(shape.functionTrigger?.target?.spec?.kind ?? "email"))
2469
2368
  };
2470
2369
 
2471
- // src/shapes/GptRealtime.tsx
2472
- import { useSignals as _useSignals26 } from "@preact-signals/safe-react/tracking";
2473
- import { Schema as Schema26 } from "effect";
2474
- import React27, { useState as useState9 } from "react";
2475
- import { log as log2 } from "@dxos/log";
2476
- import { useConfig } from "@dxos/react-client";
2477
- import { Icon as Icon5 } from "@dxos/react-ui";
2478
- var __dxlog_file7 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/GptRealtime.tsx";
2479
- var GptRealtimeShape = Schema26.extend(ComputeShape, Schema26.Struct({
2480
- type: Schema26.Literal("gpt-realtime")
2481
- }));
2482
- var createGptRealtime = (props) => createShape({
2483
- type: "gpt-realtime",
2484
- size: {
2485
- width: 256,
2486
- height: 256
2487
- },
2488
- ...props
2489
- });
2490
- var GptRealtimeComponent = ({ shape }) => {
2491
- var _effect = _useSignals26();
2492
- try {
2493
- const [isLive, setIsLive] = useState9(false);
2494
- const [isReady, setIsReady] = useState9(false);
2495
- const config = useConfig();
2496
- const start = async () => {
2497
- setIsLive(true);
2498
- try {
2499
- const peerConnection = new RTCPeerConnection();
2500
- peerConnection.ontrack = (event) => {
2501
- const audioElement = document.createElement("audio");
2502
- audioElement.srcObject = event.streams[0];
2503
- audioElement.autoplay = true;
2504
- audioElement.controls = false;
2505
- audioElement.style.display = "none";
2506
- document.body.appendChild(audioElement);
2507
- setIsReady(true);
2508
- };
2509
- const stream = await navigator.mediaDevices.getUserMedia({
2510
- audio: true
2511
- });
2512
- stream.getTracks().forEach((track) => peerConnection.addTransceiver(track, {
2513
- direction: "sendrecv"
2514
- }));
2515
- const offer = await peerConnection.createOffer();
2516
- await peerConnection.setLocalDescription(offer);
2517
- const AiServiceUrl = new URL("/rtc-connect", config.values.runtime?.services?.ai?.server ?? DEFAULT_AI_SERVICE_URL);
2518
- const response = await fetch(AiServiceUrl, {
2519
- method: "POST",
2520
- body: offer.sdp,
2521
- headers: {
2522
- "Content-Type": "application/sdp"
2523
- }
2524
- });
2525
- const answer = await response.text();
2526
- await peerConnection.setRemoteDescription({
2527
- sdp: answer,
2528
- type: "answer"
2529
- });
2530
- const dataChannel = peerConnection.createDataChannel("response");
2531
- const configureData = () => {
2532
- log2.info("Configuring data channel", void 0, {
2533
- F: __dxlog_file7,
2534
- L: 87,
2535
- S: void 0,
2536
- C: (f, a) => f(...a)
2537
- });
2538
- const event = {
2539
- type: "session.update",
2540
- session: {
2541
- modalities: [
2542
- "text",
2543
- "audio"
2544
- ],
2545
- // Provide the tools. Note they match the keys in the `fns` object above
2546
- tools: []
2547
- }
2548
- };
2549
- dataChannel.send(JSON.stringify(event));
2550
- };
2551
- dataChannel.addEventListener("open", (ev) => {
2552
- log2.info("Opening data channel", {
2553
- ev
2554
- }, {
2555
- F: __dxlog_file7,
2556
- L: 100,
2557
- S: void 0,
2558
- C: (f, a) => f(...a)
2559
- });
2560
- configureData();
2561
- });
2562
- dataChannel.addEventListener("message", async (ev) => {
2563
- const msg = JSON.parse(ev.data);
2564
- if (msg.type === "response.function_call_arguments.done") {
2565
- }
2566
- });
2567
- } catch (error) {
2568
- log2.error("Error in realtime session:", {
2569
- error
2570
- }, {
2571
- F: __dxlog_file7,
2572
- L: 140,
2573
- S: void 0,
2574
- C: (f, a) => f(...a)
2575
- });
2576
- throw error;
2577
- }
2578
- };
2579
- return /* @__PURE__ */ React27.createElement("div", {
2580
- className: "flex w-full justify-center items-center"
2581
- }, /* @__PURE__ */ React27.createElement(Icon5, {
2582
- icon: isReady ? "ph--waveform--regular" : isLive ? "ph--pulse--regular" : "ph--play--regular",
2583
- size: 16,
2584
- classNames: !isLive && "cursor-pointer",
2585
- onClick: start
2586
- }));
2587
- } finally {
2588
- _effect.f();
2589
- }
2590
- };
2591
- var gptRealtimeShape = {
2592
- type: "gpt-realtime",
2593
- name: "GPT Realtime",
2594
- icon: "ph--pulse--regular",
2595
- component: GptRealtimeComponent,
2596
- createShape: createGptRealtime,
2597
- // TODO(dmaretskyi): Can we fetch the schema dynamically?
2598
- getAnchors: (shape) => createFunctionAnchors(shape, Schema26.Struct({
2599
- audio: Schema26.Any
2600
- }), Schema26.Struct({})),
2601
- resizable: true
2602
- };
2603
- var DEFAULT_AI_SERVICE_URL = "http://localhost:8788";
2604
-
2605
2370
  // src/registry.ts
2606
2371
  var computeShapes = [
2607
2372
  {
@@ -2647,7 +2412,7 @@ var computeShapes = [
2647
2412
  shapes: [
2648
2413
  //
2649
2414
  jsonShape,
2650
- queueShape,
2415
+ feedShape,
2651
2416
  threadShape,
2652
2417
  textShape,
2653
2418
  surfaceShape,
@@ -2666,7 +2431,7 @@ var computeShapes = [
2666
2431
 
2667
2432
  // src/compute-layout.ts
2668
2433
  import { DefaultInput, DefaultOutput as DefaultOutput2 } from "@dxos/conductor";
2669
- import { toEffectSchema } from "@dxos/echo-schema";
2434
+ import { toEffectSchema } from "@dxos/echo/JsonSchema";
2670
2435
  import { ShapeLayout } from "@dxos/react-ui-canvas-editor";
2671
2436
  var ComputeShapeLayout = class extends ShapeLayout {
2672
2437
  _controller;
@@ -2706,6 +2471,9 @@ export {
2706
2471
  ConstantShape,
2707
2472
  DatabaseComponent,
2708
2473
  DatabaseShape,
2474
+ FeedComponent,
2475
+ FeedItem,
2476
+ FeedShape,
2709
2477
  FunctionBody,
2710
2478
  FunctionShape,
2711
2479
  GptComponent,
@@ -2723,9 +2491,6 @@ export {
2723
2491
  JsonTransformShape,
2724
2492
  NotShape,
2725
2493
  OrShape,
2726
- QueueComponent,
2727
- QueueItem,
2728
- QueueShape,
2729
2494
  RandomComponent,
2730
2495
  RandomShape,
2731
2496
  ReducerComponent,
@@ -2768,6 +2533,7 @@ export {
2768
2533
  createComputeNode,
2769
2534
  createConstant,
2770
2535
  createDatabase,
2536
+ createFeed,
2771
2537
  createFunction,
2772
2538
  createFunctionAnchors,
2773
2539
  createGpt,
@@ -2778,7 +2544,6 @@ export {
2778
2544
  createJsonTransform,
2779
2545
  createNot,
2780
2546
  createOr,
2781
- createQueue,
2782
2547
  createRandom,
2783
2548
  createReducer,
2784
2549
  createScope,
@@ -2792,6 +2557,7 @@ export {
2792
2557
  createThread,
2793
2558
  createTrigger,
2794
2559
  databaseShape,
2560
+ feedShape,
2795
2561
  footerHeight,
2796
2562
  functionShape,
2797
2563
  getHeight,
@@ -2808,7 +2574,6 @@ export {
2808
2574
  notShape,
2809
2575
  orShape,
2810
2576
  parseAnchorId,
2811
- queueShape,
2812
2577
  randomShape,
2813
2578
  reducerShape,
2814
2579
  resolveComputeNode,