@dxos/react-ui-canvas-compute 0.8.4-main.3eb6e50203 → 0.8.4-main.3fbcb4aa9b

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 (107) hide show
  1. package/dist/lib/browser/index.mjs +427 -504
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +427 -504
  5. package/dist/lib/node-esm/index.mjs.map +4 -4
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/types/src/components/DiagnosticOverlay.d.ts.map +1 -1
  8. package/dist/types/src/compute-layout.d.ts.map +1 -1
  9. package/dist/types/src/compute.stories.d.ts +1 -1
  10. package/dist/types/src/compute.stories.d.ts.map +1 -1
  11. package/dist/types/src/graph/controller.d.ts +33 -28
  12. package/dist/types/src/graph/controller.d.ts.map +1 -1
  13. package/dist/types/src/graph/node-defs.d.ts.map +1 -1
  14. package/dist/types/src/hooks/useComputeGraphController.d.ts.map +1 -1
  15. package/dist/types/src/hooks/useComputeNodeState.d.ts +2 -3
  16. package/dist/types/src/hooks/useComputeNodeState.d.ts.map +1 -1
  17. package/dist/types/src/hooks/useGraphMonitor.d.ts.map +1 -1
  18. package/dist/types/src/shapes/Append.d.ts +1 -1
  19. package/dist/types/src/shapes/Append.d.ts.map +1 -1
  20. package/dist/types/src/shapes/Array.d.ts +1 -1
  21. package/dist/types/src/shapes/Array.d.ts.map +1 -1
  22. package/dist/types/src/shapes/Audio.d.ts +1 -1
  23. package/dist/types/src/shapes/Audio.d.ts.map +1 -1
  24. package/dist/types/src/shapes/Beacon.d.ts +1 -1
  25. package/dist/types/src/shapes/Beacon.d.ts.map +1 -1
  26. package/dist/types/src/shapes/Boolean.d.ts +7 -7
  27. package/dist/types/src/shapes/Boolean.d.ts.map +1 -1
  28. package/dist/types/src/shapes/Chat.d.ts +1 -1
  29. package/dist/types/src/shapes/Chat.d.ts.map +1 -1
  30. package/dist/types/src/shapes/Constant.d.ts +1 -1
  31. package/dist/types/src/shapes/Constant.d.ts.map +1 -1
  32. package/dist/types/src/shapes/Database.d.ts +1 -1
  33. package/dist/types/src/shapes/Database.d.ts.map +1 -1
  34. package/dist/types/src/shapes/{Queue.d.ts → Feed.d.ts} +9 -9
  35. package/dist/types/src/shapes/Feed.d.ts.map +1 -0
  36. package/dist/types/src/shapes/Function.d.ts +1 -1
  37. package/dist/types/src/shapes/Function.d.ts.map +1 -1
  38. package/dist/types/src/shapes/Gpt.d.ts +1 -1
  39. package/dist/types/src/shapes/Gpt.d.ts.map +1 -1
  40. package/dist/types/src/shapes/GptRealtime.d.ts +1 -1
  41. package/dist/types/src/shapes/GptRealtime.d.ts.map +1 -1
  42. package/dist/types/src/shapes/Json.d.ts +2 -2
  43. package/dist/types/src/shapes/Json.d.ts.map +1 -1
  44. package/dist/types/src/shapes/Logic.d.ts +2 -2
  45. package/dist/types/src/shapes/Logic.d.ts.map +1 -1
  46. package/dist/types/src/shapes/RNG.d.ts +2 -2
  47. package/dist/types/src/shapes/RNG.d.ts.map +1 -1
  48. package/dist/types/src/shapes/Scope.d.ts +1 -1
  49. package/dist/types/src/shapes/Scope.d.ts.map +1 -1
  50. package/dist/types/src/shapes/Surface.d.ts +1 -1
  51. package/dist/types/src/shapes/Surface.d.ts.map +1 -1
  52. package/dist/types/src/shapes/Switch.d.ts +1 -1
  53. package/dist/types/src/shapes/Switch.d.ts.map +1 -1
  54. package/dist/types/src/shapes/Table.d.ts +1 -1
  55. package/dist/types/src/shapes/Table.d.ts.map +1 -1
  56. package/dist/types/src/shapes/Template.d.ts +2 -2
  57. package/dist/types/src/shapes/Template.d.ts.map +1 -1
  58. package/dist/types/src/shapes/Text.d.ts +1 -1
  59. package/dist/types/src/shapes/Text.d.ts.map +1 -1
  60. package/dist/types/src/shapes/TextToImage.d.ts +1 -1
  61. package/dist/types/src/shapes/TextToImage.d.ts.map +1 -1
  62. package/dist/types/src/shapes/Thread.d.ts +1 -1
  63. package/dist/types/src/shapes/Thread.d.ts.map +1 -1
  64. package/dist/types/src/shapes/Trigger.d.ts +4 -3
  65. package/dist/types/src/shapes/Trigger.d.ts.map +1 -1
  66. package/dist/types/src/shapes/common/Box.d.ts.map +1 -1
  67. package/dist/types/src/shapes/common/FunctionBody.d.ts.map +1 -1
  68. package/dist/types/src/shapes/common/TypeSelect.d.ts +1 -1
  69. package/dist/types/src/shapes/common/TypeSelect.d.ts.map +1 -1
  70. package/dist/types/src/shapes/defs.d.ts +1 -1
  71. package/dist/types/src/shapes/defs.d.ts.map +1 -1
  72. package/dist/types/src/shapes/index.d.ts +2 -2
  73. package/dist/types/src/shapes/index.d.ts.map +1 -1
  74. package/dist/types/src/testing/circuits.d.ts.map +1 -1
  75. package/dist/types/tsconfig.tsbuildinfo +1 -1
  76. package/package.json +47 -48
  77. package/src/README.md +0 -3
  78. package/src/compute.stories.tsx +32 -13
  79. package/src/graph/controller.ts +54 -23
  80. package/src/graph/node-defs.ts +28 -28
  81. package/src/hooks/useComputeNodeState.ts +3 -5
  82. package/src/hooks/useGraphMonitor.ts +3 -3
  83. package/src/registry.ts +2 -2
  84. package/src/shapes/Audio.tsx +2 -3
  85. package/src/shapes/Beacon.tsx +1 -2
  86. package/src/shapes/Boolean.tsx +2 -2
  87. package/src/shapes/Chat.tsx +0 -1
  88. package/src/shapes/Constant.tsx +0 -1
  89. package/src/shapes/{Queue.tsx → Feed.tsx} +14 -15
  90. package/src/shapes/Function.tsx +3 -3
  91. package/src/shapes/Gpt.tsx +0 -1
  92. package/src/shapes/GptRealtime.tsx +1 -1
  93. package/src/shapes/Json.tsx +9 -3
  94. package/src/shapes/RNG.tsx +0 -1
  95. package/src/shapes/Scope.tsx +1 -2
  96. package/src/shapes/Surface.tsx +6 -2
  97. package/src/shapes/Switch.tsx +1 -2
  98. package/src/shapes/Template.tsx +0 -1
  99. package/src/shapes/Text.tsx +0 -1
  100. package/src/shapes/Thread.tsx +2 -6
  101. package/src/shapes/Trigger.tsx +15 -20
  102. package/src/shapes/common/Box.tsx +5 -7
  103. package/src/shapes/common/FunctionBody.tsx +2 -2
  104. package/src/shapes/common/TypeSelect.tsx +1 -1
  105. package/src/shapes/index.ts +2 -2
  106. package/src/testing/circuits.ts +2 -2
  107. package/dist/types/src/shapes/Queue.d.ts.map +0 -1
@@ -7,10 +7,10 @@ import * as Exit from "effect/Exit";
7
7
  import * as Layer from "effect/Layer";
8
8
  import * as Scope from "effect/Scope";
9
9
  import { Event, synchronized } from "@dxos/async";
10
- 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";
11
12
  import { Resource } from "@dxos/context";
12
13
  import { unwrapExit } from "@dxos/effect";
13
- import { ComputeEventLogger, TracingService } from "@dxos/functions";
14
14
  import { log } from "@dxos/log";
15
15
 
16
16
  // src/hooks/compute-context.ts
@@ -78,28 +78,12 @@ import { invariant } from "@dxos/invariant";
78
78
  var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/hooks/useComputeNodeState.ts";
79
79
  var useComputeNodeState = (shape) => {
80
80
  const { controller } = useComputeContext();
81
- invariant(controller, void 0, {
82
- F: __dxlog_file,
83
- L: 34,
84
- S: void 0,
85
- A: [
86
- "controller",
87
- ""
88
- ]
89
- });
81
+ invariant(controller, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 12, S: void 0, A: ["controller", ""] });
90
82
  const [meta, setMeta] = useState2();
91
83
  useEffect2(() => {
92
84
  let disposed = false;
93
85
  queueMicrotask(async () => {
94
- invariant(shape.node, "Node not specified", {
95
- F: __dxlog_file,
96
- L: 40,
97
- S: void 0,
98
- A: [
99
- "shape.node",
100
- "'Node not specified'"
101
- ]
102
- });
86
+ invariant(shape.node, "Node not specified", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 17, S: void 0, A: ["shape.node", "'Node not specified'"] });
103
87
  const node = controller.getComputeNode(shape.node);
104
88
  const meta2 = await controller.getMeta(node);
105
89
  if (disposed) {
@@ -155,24 +139,8 @@ var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/hook
155
139
  var mapEdge = (graph, { source, target, output = DEFAULT_OUTPUT, input = DEFAULT_INPUT }) => {
156
140
  const sourceNode = graph.findNode(source);
157
141
  const targetNode = graph.findNode(target);
158
- invariant2(sourceNode?.node, void 0, {
159
- F: __dxlog_file2,
160
- L: 25,
161
- S: void 0,
162
- A: [
163
- "sourceNode?.node",
164
- ""
165
- ]
166
- });
167
- invariant2(targetNode?.node, void 0, {
168
- F: __dxlog_file2,
169
- L: 26,
170
- S: void 0,
171
- A: [
172
- "targetNode?.node",
173
- ""
174
- ]
175
- });
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", ""] });
176
144
  return {
177
145
  id: Obj.ID.random(),
178
146
  source: sourceNode.node,
@@ -188,15 +156,7 @@ var useGraphMonitor = (model) => {
188
156
  if (!model) {
189
157
  return;
190
158
  }
191
- invariant2(node.type, void 0, {
192
- F: __dxlog_file2,
193
- L: 51,
194
- S: void 0,
195
- A: [
196
- "node.type",
197
- ""
198
- ]
199
- });
159
+ invariant2(node.type, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 37, S: void 0, A: ["node.type", ""] });
200
160
  if (!isValidComputeNode(node.type)) {
201
161
  return;
202
162
  }
@@ -246,18 +206,10 @@ var createComputeGraph = (graph) => {
246
206
  };
247
207
  var linkTriggerToCompute = (graph, computeNode, triggerData) => {
248
208
  const functionTrigger = triggerData.functionTrigger?.target;
249
- invariant2(functionTrigger, void 0, {
250
- F: __dxlog_file2,
251
- L: 114,
252
- S: void 0,
253
- A: [
254
- "functionTrigger",
255
- ""
256
- ]
257
- });
258
- Obj.change(functionTrigger, (t) => {
259
- t.function = Ref.make(graph.root);
260
- t.inputNodeId = computeNode.id;
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;
261
213
  });
262
214
  };
263
215
  var deleteTriggerObjects = (computeGraph, deleted) => {
@@ -281,15 +233,7 @@ import { invariant as invariant3 } from "@dxos/invariant";
281
233
  var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/graph/node-defs.ts";
282
234
  var resolveComputeNode = async (node) => {
283
235
  const impl = registry[node.type];
284
- invariant3(impl, `Unknown node type: ${node.type}`, {
285
- F: __dxlog_file3,
286
- L: 22,
287
- S: void 0,
288
- A: [
289
- "impl",
290
- "`Unknown node type: ${node.type}`"
291
- ]
292
- });
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}`"] });
293
237
  return impl;
294
238
  };
295
239
  var isValidComputeNode = (type) => {
@@ -305,33 +249,33 @@ var nodeFactory = {
305
249
  [NODE_INPUT]: () => createNode(NODE_INPUT),
306
250
  [NODE_OUTPUT]: () => createNode(NODE_OUTPUT),
307
251
  // Extensions.
308
- ["text-to-image"]: () => createNode("text-to-image"),
309
- ["and"]: () => createNode("and"),
310
- ["append"]: () => createNode("append"),
311
- ["audio"]: () => createNode("audio"),
312
- ["beacon"]: () => createNode("beacon"),
313
- ["chat"]: () => createNode("chat"),
314
- ["constant"]: (shape) => createNode("constant", {
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", {
315
259
  value: shape.value
316
260
  }),
317
- ["make-queue"]: () => createNode("make-queue"),
318
- ["database"]: () => createNode("database"),
319
- ["gpt"]: () => createNode("gpt"),
320
- ["gpt-realtime"]: () => createNode("gpt-realtime"),
321
- ["if"]: () => createNode("if"),
322
- ["if-else"]: () => createNode("if-else"),
323
- ["function"]: () => createNode("function"),
324
- ["json"]: () => createNode("json"),
325
- ["json-transform"]: () => createNode("json-transform"),
326
- ["not"]: () => createNode("not"),
327
- ["or"]: () => createNode("or"),
328
- ["queue"]: () => createNode("queue"),
329
- ["rng"]: () => createNode("rng"),
330
- ["reducer"]: () => createNode("reducer"),
331
- ["scope"]: () => createNode("scope"),
332
- ["surface"]: () => createNode("surface"),
333
- ["switch"]: () => createNode("switch"),
334
- ["template"]: (shape) => {
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) => {
335
279
  const node = createNode("template", {
336
280
  valueType: shape.valueType,
337
281
  value: shape.text
@@ -339,9 +283,9 @@ var nodeFactory = {
339
283
  node.inputSchema = JsonSchema.toJsonSchema(getTemplateInputSchema(node));
340
284
  return node;
341
285
  },
342
- ["text"]: () => createNode("text"),
343
- ["thread"]: () => createNode("thread"),
344
- ["trigger"]: () => createNode(NODE_INPUT)
286
+ text: () => createNode("text"),
287
+ thread: () => createNode("thread"),
288
+ trigger: () => createNode(NODE_INPUT)
345
289
  };
346
290
  var createNode = (type, props) => ({
347
291
  id: Obj2.ID.random(),
@@ -350,13 +294,13 @@ var createNode = (type, props) => ({
350
294
  });
351
295
 
352
296
  // src/graph/controller.ts
297
+ var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/graph/controller.ts";
353
298
  function _ts_decorate(decorators, target, key, desc) {
354
299
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
355
300
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
356
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;
357
302
  return c > 3 && r && Object.defineProperty(target, key, r), r;
358
303
  }
359
- var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/graph/controller.ts";
360
304
  var InvalidStateError = Error;
361
305
  var AUTO_TRIGGER_NODES = [
362
306
  "chat",
@@ -461,12 +405,7 @@ var ComputeGraphController = class extends Resource {
461
405
  try {
462
406
  await this.exec(nodeId);
463
407
  } catch (err) {
464
- log.catch(err, void 0, {
465
- F: __dxlog_file4,
466
- L: 229,
467
- S: this,
468
- C: (f, a) => f(...a)
469
- });
408
+ log.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 128, S: this });
470
409
  }
471
410
  });
472
411
  }
@@ -489,7 +428,7 @@ var ComputeGraphController = class extends Resource {
489
428
  const scope = yield* Scope.make();
490
429
  const executable = yield* Effect.promise(() => resolveComputeNode(this._graph.getNode(nodeId)));
491
430
  const computingOutputs = executable.exec != null;
492
- const effect = (computingOutputs ? executor.computeOutputs(nodeId) : executor.computeInputs(nodeId)).pipe(Effect.withSpan("runGraph"), Scope.extend(scope), Effect.provide(ComputeEventLogger.layerFromTracing.pipe(Layer.provideMerge(TracingService.layerNoop))), Effect.flatMap(computeValueBag), Effect.withSpan("test"), Effect.tap((values) => {
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) => {
493
432
  for (const [key, value] of Object.entries(values)) {
494
433
  if (computingOutputs) {
495
434
  this._onOutputComputed(nodeId, key, value);
@@ -527,7 +466,7 @@ var ComputeGraphController = class extends Resource {
527
466
  for (const node of allAffectedNodes) {
528
467
  const executable = yield* Effect.promise(() => resolveComputeNode(this._graph.getNode(node)));
529
468
  const computingOutputs = executable.exec != null;
530
- const effect = (computingOutputs ? executor.computeOutputs(node) : executor.computeInputs(node)).pipe(Effect.withSpan("runGraph"), Scope.extend(scope), Effect.flatMap(computeValueBag), Effect.provide(ComputeEventLogger.layerFromTracing.pipe(Layer.provideMerge(TracingService.layerNoop))), Effect.withSpan("test"), Effect.tap((values) => {
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) => {
531
470
  for (const [key, value] of Object.entries(values)) {
532
471
  if (computingOutputs) {
533
472
  this._onOutputComputed(node, key, value);
@@ -543,23 +482,20 @@ var ComputeGraphController = class extends Resource {
543
482
  })));
544
483
  this.update.emit();
545
484
  }
546
- _createLogger() {
485
+ _createTraceWriter() {
547
486
  return {
548
- log: (event) => {
549
- this._handleEvent(event);
550
- },
551
- nodeId: void 0
487
+ write: (eventType, payload) => {
488
+ const event = traceEventToComputeEvent(eventType.key, payload);
489
+ if (event) {
490
+ this._handleEvent(event);
491
+ }
492
+ }
552
493
  };
553
494
  }
554
495
  _handleEvent(event) {
555
496
  log("handleEvent", {
556
497
  event
557
- }, {
558
- F: __dxlog_file4,
559
- L: 376,
560
- S: this,
561
- C: (f, a) => f(...a)
562
- });
498
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 223, S: this });
563
499
  switch (event.type) {
564
500
  case "compute-input": {
565
501
  this._onInputComputed(event.nodeId, event.property, {
@@ -598,6 +534,37 @@ _ts_decorate([
598
534
  _ts_decorate([
599
535
  synchronized
600
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
+ };
601
568
  var computeValueBag = (bag) => {
602
569
  return Effect.all(Object.entries(bag.values).map(([key, eff]) => Effect.either(eff).pipe(Effect.map((value) => {
603
570
  if (Either.isLeft(value)) {
@@ -642,24 +609,16 @@ var __dxlog_file5 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shap
642
609
  var headerHeight = 32;
643
610
  var footerHeight = 32;
644
611
  var Box = /* @__PURE__ */ forwardRef(({ children, classNames, shape, title, status, open, onAction }, forwardedRef) => {
645
- invariant4(shape.type, void 0, {
646
- F: __dxlog_file5,
647
- L: 29,
648
- S: void 0,
649
- A: [
650
- "shape.type",
651
- ""
652
- ]
653
- });
612
+ invariant4(shape.type, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 12, S: void 0, A: ["shape.type", ""] });
654
613
  const { icon, name, openable } = useShapeDef(shape.type) ?? {
655
614
  icon: "ph--placeholder--regular"
656
615
  };
657
616
  const { debug } = useEditorContext();
658
617
  return /* @__PURE__ */ React.createElement("div", {
659
618
  ref: forwardedRef,
660
- className: "flex flex-col bs-full is-full justify-between"
619
+ className: "flex flex-col h-full w-full justify-between"
661
620
  }, /* @__PURE__ */ React.createElement("div", {
662
- className: "flex shrink-0 is-full justify-between items-center bs-[32px] bg-hoverSurface"
621
+ className: "flex shrink-0 w-full justify-between items-center h-[32px] bg-input-surface"
663
622
  }, /* @__PURE__ */ React.createElement(Icon, {
664
623
  icon,
665
624
  classNames: "mx-2"
@@ -669,7 +628,6 @@ var Box = /* @__PURE__ */ forwardRef(({ children, classNames, shape, title, stat
669
628
  classNames: "p-1 text-green-500",
670
629
  variant: "ghost",
671
630
  icon: "ph--play--regular",
672
- size: 4,
673
631
  label: "run",
674
632
  iconOnly: true,
675
633
  onDoubleClick: (ev) => ev.stopPropagation(),
@@ -678,16 +636,15 @@ var Box = /* @__PURE__ */ forwardRef(({ children, classNames, shape, title, stat
678
636
  onAction?.("run");
679
637
  }
680
638
  })), /* @__PURE__ */ React.createElement("div", {
681
- className: mx("flex flex-col bs-full grow overflow-hidden", classNames)
639
+ className: mx("flex flex-col h-full grow overflow-hidden", classNames)
682
640
  }, children), /* @__PURE__ */ React.createElement("div", {
683
- className: "flex shrink-0 is-full justify-between items-center bs-[32px] bg-hoverSurface"
641
+ className: "flex shrink-0 w-full justify-between items-center h-[32px] bg-input-surface"
684
642
  }, /* @__PURE__ */ React.createElement("div", {
685
- className: "grow pli-2 text-sm truncate"
643
+ className: "grow px-2 text-sm truncate"
686
644
  }, debug ? shape.id : status), openable && /* @__PURE__ */ React.createElement(IconButton, {
687
645
  classNames: "p-1",
688
646
  variant: "ghost",
689
647
  icon: open ? "ph--caret-up--regular" : "ph--caret-down--regular",
690
- size: 4,
691
648
  label: open ? "close" : "open",
692
649
  iconOnly: true,
693
650
  onClick: (ev) => {
@@ -785,7 +742,7 @@ var FunctionBody = ({ shape, name, content, inputSchema = VoidInput, outputSchem
785
742
  className: "flex flex-col"
786
743
  }, inputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
787
744
  key: name2,
788
- className: "pli-2 truncate text-sm font-mono items-center",
745
+ className: "px-2 truncate text-sm font-mono items-center",
789
746
  style: {
790
747
  height: rowHeight
791
748
  }
@@ -793,7 +750,7 @@ var FunctionBody = ({ shape, name, content, inputSchema = VoidInput, outputSchem
793
750
  className: "flex flex-col"
794
751
  }, outputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
795
752
  key: name2,
796
- className: "pli-2 truncate text-sm font-mono items-center text-right",
753
+ className: "px-2 truncate text-sm font-mono items-center text-right",
797
754
  style: {
798
755
  height: rowHeight
799
756
  }
@@ -829,7 +786,7 @@ var TypeSelect = ({ value, onValueChange }) => {
829
786
  onValueChange
830
787
  }, /* @__PURE__ */ React3.createElement(Select.TriggerButton, {
831
788
  variant: "ghost",
832
- classNames: "is-full !pli-0"
789
+ classNames: "w-full px-0!"
833
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, {
834
791
  key: type,
835
792
  value: type
@@ -922,12 +879,12 @@ var AudioComponent = ({ shape }) => {
922
879
  active
923
880
  ]);
924
881
  return /* @__PURE__ */ React6.createElement("div", {
925
- className: "flex is-full justify-center items-center"
882
+ className: "flex w-full justify-center items-center"
926
883
  }, /* @__PURE__ */ React6.createElement(Icon2, {
927
884
  icon: active ? "ph--microphone--regular" : "ph--microphone-slash--regular",
928
885
  classNames: [
929
886
  "transition opacity-20 duration-1000",
930
- active && "opacity-100 text-red-500"
887
+ active && "opacity-100 text-error-text"
931
888
  ],
932
889
  size: 8,
933
890
  onClick: () => setActive(!active)
@@ -969,7 +926,7 @@ var BeaconComponent = ({ shape }) => {
969
926
  const input = runtime.inputs[DEFAULT_INPUT3];
970
927
  const value = input?.type === "executed" ? input.value : false;
971
928
  return /* @__PURE__ */ React7.createElement("div", {
972
- className: "flex is-full justify-center items-center"
929
+ className: "flex w-full justify-center items-center"
973
930
  }, /* @__PURE__ */ React7.createElement(Icon3, {
974
931
  icon: "ph--sun--regular",
975
932
  classNames: [
@@ -1018,7 +975,7 @@ var defineShape = ({ type, name, icon, symbol: Symbol, createShape: createShape2
1018
975
  // Be careful not to name component factories with a capital letter.
1019
976
  component: () => {
1020
977
  return /* @__PURE__ */ React8.createElement("div", {
1021
- className: "flex is-full justify-center items-center"
978
+ className: "flex w-full justify-center items-center"
1022
979
  }, /* @__PURE__ */ React8.createElement(Symbol, null));
1023
980
  },
1024
981
  createShape: createShape2,
@@ -1045,7 +1002,7 @@ var createSymbol = (pathConstructor, inputs) => ({
1045
1002
  });
1046
1003
  return /* @__PURE__ */ React8.createElement("svg", {
1047
1004
  viewBox: `0 0 ${width} ${height}`,
1048
- className: "is-full bs-full"
1005
+ className: "h-full w-full"
1049
1006
  }, getAnchorPoints({
1050
1007
  x: 0,
1051
1008
  y: centerY
@@ -1352,17 +1309,83 @@ var databaseShape = {
1352
1309
  })
1353
1310
  };
1354
1311
 
1355
- // src/shapes/Function.tsx
1312
+ // src/shapes/Feed.tsx
1356
1313
  import * as Schema11 from "effect/Schema";
1357
- import React12, { useCallback as useCallback3, useRef as useRef4 } from "react";
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
+
1377
+ // src/shapes/Function.tsx
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";
1358
1382
  import { AnyOutput, FunctionInput } from "@dxos/conductor";
1359
1383
  import { Ref as Ref2, getSnapshot, isInstanceOf } from "@dxos/echo/internal";
1360
- import { Function, Script } from "@dxos/functions";
1361
1384
  import { useClient } from "@dxos/react-client";
1362
1385
  import { Filter, parseId } from "@dxos/react-client/echo";
1363
1386
  import { TextBox as TextBox3 } from "@dxos/react-ui-canvas-editor";
1364
- var FunctionShape = Schema11.extend(ComputeShape, Schema11.Struct({
1365
- type: Schema11.Literal("function")
1387
+ var FunctionShape = Schema12.extend(ComputeShape, Schema12.Struct({
1388
+ type: Schema12.Literal("function")
1366
1389
  }));
1367
1390
  var createFunction = (props) => createShape({
1368
1391
  type: "function",
@@ -1387,7 +1410,7 @@ var TextInputComponent2 = ({ shape, title, ...props }) => {
1387
1410
  if (!space || !isInstanceOf(Script.Script, object)) {
1388
1411
  return;
1389
1412
  }
1390
- const [fn] = await space.db.query(Filter.type(Function.Function, {
1413
+ const [fn] = await space.db.query(Filter.type(Operation.PersistentOperation, {
1391
1414
  source: Ref2.make(object)
1392
1415
  })).run();
1393
1416
  if (!fn) {
@@ -1409,11 +1432,11 @@ var TextInputComponent2 = ({ shape, title, ...props }) => {
1409
1432
  }, [
1410
1433
  runtime
1411
1434
  ]);
1412
- return /* @__PURE__ */ React12.createElement(Box, {
1435
+ return /* @__PURE__ */ React13.createElement(Box, {
1413
1436
  shape,
1414
1437
  title: "Function",
1415
1438
  onAction: handleAction
1416
- }, /* @__PURE__ */ React12.createElement(TextBox3, {
1439
+ }, /* @__PURE__ */ React13.createElement(TextBox3, {
1417
1440
  ...props,
1418
1441
  ref: inputRef,
1419
1442
  value: node.value,
@@ -1432,12 +1455,12 @@ var functionShape = {
1432
1455
  };
1433
1456
 
1434
1457
  // src/shapes/Gpt.tsx
1435
- import * as Schema12 from "effect/Schema";
1436
- import React13, { useEffect as useEffect4, useState as useState6 } from "react";
1458
+ import * as Schema13 from "effect/Schema";
1459
+ import React14, { useEffect as useEffect4, useState as useState6 } from "react";
1437
1460
  import { GptInput, GptOutput } from "@dxos/conductor";
1438
- import { ScrollArea } from "@dxos/react-ui";
1439
- var GptShape = Schema12.extend(ComputeShape, Schema12.Struct({
1440
- type: Schema12.Literal("gpt")
1461
+ import { ScrollArea as ScrollArea2 } from "@dxos/react-ui";
1462
+ var GptShape = Schema13.extend(ComputeShape, Schema13.Struct({
1463
+ type: Schema13.Literal("gpt")
1441
1464
  }));
1442
1465
  var createGpt = (props) => createShape({
1443
1466
  type: "gpt",
@@ -1482,12 +1505,12 @@ var GptComponent = ({ shape }) => {
1482
1505
  }, [
1483
1506
  runtime?.subscribeToEventLog
1484
1507
  ]);
1485
- return /* @__PURE__ */ React13.createElement(FunctionBody, {
1508
+ return /* @__PURE__ */ React14.createElement(FunctionBody, {
1486
1509
  shape,
1487
- content: /* @__PURE__ */ React13.createElement(ScrollArea.Root, {
1510
+ content: /* @__PURE__ */ React14.createElement(ScrollArea2.Root, {
1488
1511
  orientation: "vertical",
1489
1512
  thin: true
1490
- }, /* @__PURE__ */ React13.createElement(ScrollArea.Viewport, null, text)),
1513
+ }, /* @__PURE__ */ React14.createElement(ScrollArea2.Viewport, null, text)),
1491
1514
  status: `${tokens} tokens`,
1492
1515
  inputSchema: meta.input,
1493
1516
  outputSchema: meta.output
@@ -1503,31 +1526,145 @@ var gptShape = {
1503
1526
  openable: true
1504
1527
  };
1505
1528
 
1529
+ // src/shapes/GptRealtime.tsx
1530
+ import * as Schema14 from "effect/Schema";
1531
+ import React15, { useState as useState7 } from "react";
1532
+ import { log as log2 } from "@dxos/log";
1533
+ import { useConfig } from "@dxos/react-client";
1534
+ import { Icon as Icon4 } from "@dxos/react-ui";
1535
+ var __dxlog_file6 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/GptRealtime.tsx";
1536
+ var GptRealtimeShape = Schema14.extend(ComputeShape, Schema14.Struct({
1537
+ type: Schema14.Literal("gpt-realtime")
1538
+ }));
1539
+ var createGptRealtime = (props) => createShape({
1540
+ type: "gpt-realtime",
1541
+ size: {
1542
+ width: 256,
1543
+ height: 256
1544
+ },
1545
+ ...props
1546
+ });
1547
+ var GptRealtimeComponent = ({ shape }) => {
1548
+ const [isLive, setIsLive] = useState7(false);
1549
+ const [isReady, setIsReady] = useState7(false);
1550
+ const config = useConfig();
1551
+ const start = async () => {
1552
+ setIsLive(true);
1553
+ try {
1554
+ const peerConnection = new RTCPeerConnection();
1555
+ peerConnection.ontrack = (event) => {
1556
+ const audioElement = document.createElement("audio");
1557
+ audioElement.srcObject = event.streams[0];
1558
+ audioElement.autoplay = true;
1559
+ audioElement.controls = false;
1560
+ audioElement.style.display = "none";
1561
+ document.body.appendChild(audioElement);
1562
+ setIsReady(true);
1563
+ };
1564
+ const stream = await navigator.mediaDevices.getUserMedia({
1565
+ audio: true
1566
+ });
1567
+ stream.getTracks().forEach((track) => peerConnection.addTransceiver(track, {
1568
+ direction: "sendrecv"
1569
+ }));
1570
+ const offer = await peerConnection.createOffer();
1571
+ await peerConnection.setLocalDescription(offer);
1572
+ const AiServiceUrl = new URL("/rtc-connect", config.values.runtime?.services?.ai?.server ?? DEFAULT_AI_SERVICE_URL);
1573
+ const response = await fetch(AiServiceUrl, {
1574
+ method: "POST",
1575
+ body: offer.sdp,
1576
+ headers: {
1577
+ "Content-Type": "application/sdp"
1578
+ }
1579
+ });
1580
+ const answer = await response.text();
1581
+ await peerConnection.setRemoteDescription({
1582
+ sdp: answer,
1583
+ type: "answer"
1584
+ });
1585
+ const dataChannel = peerConnection.createDataChannel("response");
1586
+ const configureData = () => {
1587
+ log2.info("Configuring data channel", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 69, S: void 0 });
1588
+ const event = {
1589
+ type: "session.update",
1590
+ session: {
1591
+ modalities: [
1592
+ "text",
1593
+ "audio"
1594
+ ],
1595
+ // Provide the tools. Note they match the keys in the `fns` object above
1596
+ tools: []
1597
+ }
1598
+ };
1599
+ dataChannel.send(JSON.stringify(event));
1600
+ };
1601
+ dataChannel.addEventListener("open", (ev) => {
1602
+ log2.info("Opening data channel", {
1603
+ ev
1604
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 84, S: void 0 });
1605
+ configureData();
1606
+ });
1607
+ dataChannel.addEventListener("message", async (ev) => {
1608
+ const msg = JSON.parse(ev.data);
1609
+ if (msg.type === "response.function_call_arguments.done") {
1610
+ }
1611
+ });
1612
+ } catch (error) {
1613
+ log2.error("Error in realtime session:", {
1614
+ error
1615
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 124, S: void 0 });
1616
+ throw error;
1617
+ }
1618
+ };
1619
+ return /* @__PURE__ */ React15.createElement("div", {
1620
+ className: "flex w-full justify-center items-center"
1621
+ }, /* @__PURE__ */ React15.createElement(Icon4, {
1622
+ icon: isReady ? "ph--waveform--regular" : isLive ? "ph--pulse--regular" : "ph--play--regular",
1623
+ size: 16,
1624
+ classNames: !isLive && "cursor-pointer",
1625
+ onClick: start
1626
+ }));
1627
+ };
1628
+ var gptRealtimeShape = {
1629
+ type: "gpt-realtime",
1630
+ name: "GPT Realtime",
1631
+ icon: "ph--pulse--regular",
1632
+ component: GptRealtimeComponent,
1633
+ createShape: createGptRealtime,
1634
+ // TODO(dmaretskyi): Can we fetch the schema dynamically?
1635
+ getAnchors: (shape) => createFunctionAnchors(shape, Schema14.Struct({
1636
+ audio: Schema14.Any
1637
+ }), Schema14.Struct({})),
1638
+ resizable: true
1639
+ };
1640
+ var DEFAULT_AI_SERVICE_URL = "http://localhost:8788";
1641
+
1506
1642
  // src/shapes/Json.tsx
1507
- import * as Schema13 from "effect/Schema";
1508
- import React14 from "react";
1643
+ import * as Schema15 from "effect/Schema";
1644
+ import React16 from "react";
1509
1645
  import { DEFAULT_INPUT as DEFAULT_INPUT4, DefaultOutput, JsonTransformInput } from "@dxos/conductor";
1510
1646
  import { createAnchorMap as createAnchorMap6 } from "@dxos/react-ui-canvas-editor";
1511
- import { JsonFilter } from "@dxos/react-ui-syntax-highlighter";
1512
- var JsonShape = Schema13.extend(ComputeShape, Schema13.Struct({
1513
- type: Schema13.Literal("json")
1647
+ import { Syntax } from "@dxos/react-ui-syntax-highlighter";
1648
+ var JsonShape = Schema15.extend(ComputeShape, Schema15.Struct({
1649
+ type: Schema15.Literal("json")
1514
1650
  }));
1515
- var JsonTransformShape = Schema13.extend(ComputeShape, Schema13.Struct({
1516
- type: Schema13.Literal("json-transform")
1651
+ var JsonTransformShape = Schema15.extend(ComputeShape, Schema15.Struct({
1652
+ type: Schema15.Literal("json-transform")
1517
1653
  }));
1518
1654
  var JsonComponent = ({ shape, ...props }) => {
1519
1655
  const { runtime } = useComputeNodeState(shape);
1520
1656
  const input = runtime.inputs[DEFAULT_INPUT4];
1521
1657
  const value = input?.type === "executed" ? input.value : void 0;
1522
- return /* @__PURE__ */ React14.createElement(Box, {
1658
+ return /* @__PURE__ */ React16.createElement(Box, {
1523
1659
  shape
1524
- }, /* @__PURE__ */ React14.createElement(JsonFilter, {
1525
- data: value,
1660
+ }, /* @__PURE__ */ React16.createElement(Syntax.Root, {
1661
+ data: value
1662
+ }, /* @__PURE__ */ React16.createElement(Syntax.Content, null, /* @__PURE__ */ React16.createElement(Syntax.Filter, null), /* @__PURE__ */ React16.createElement(Syntax.Viewport, null, /* @__PURE__ */ React16.createElement(Syntax.Code, {
1526
1663
  classNames: "text-xs"
1527
- }));
1664
+ })))));
1528
1665
  };
1529
1666
  var JsonTransformComponent = ({ shape, ...props }) => {
1530
- return /* @__PURE__ */ React14.createElement(Box, {
1667
+ return /* @__PURE__ */ React16.createElement(Box, {
1531
1668
  shape
1532
1669
  });
1533
1670
  };
@@ -1543,7 +1680,7 @@ var jsonShape = {
1543
1680
  type: "json",
1544
1681
  name: "JSON",
1545
1682
  icon: "ph--code--regular",
1546
- component: (props) => /* @__PURE__ */ React14.createElement(JsonComponent, props),
1683
+ component: (props) => /* @__PURE__ */ React16.createElement(JsonComponent, props),
1547
1684
  createShape: createJson,
1548
1685
  getAnchors: (shape) => createAnchorMap6(shape, {
1549
1686
  [createAnchorId("input")]: {
@@ -1569,31 +1706,31 @@ var jsonTransformShape = {
1569
1706
  type: "json-transform",
1570
1707
  name: "Transform",
1571
1708
  icon: "ph--shuffle-simple--regular",
1572
- component: (props) => /* @__PURE__ */ React14.createElement(JsonTransformComponent, props),
1709
+ component: (props) => /* @__PURE__ */ React16.createElement(JsonTransformComponent, props),
1573
1710
  createShape: createJsonTransform,
1574
1711
  getAnchors: (shape) => createFunctionAnchors(shape, JsonTransformInput, DefaultOutput),
1575
1712
  resizable: true
1576
1713
  };
1577
1714
 
1578
1715
  // src/shapes/Logic.tsx
1579
- import * as Schema14 from "effect/Schema";
1580
- import React15 from "react";
1716
+ import * as Schema16 from "effect/Schema";
1717
+ import React17 from "react";
1581
1718
  import { IfElseInput, IfElseOutput, IfInput, IfOutput } from "@dxos/conductor";
1582
- var IfShape = Schema14.extend(ComputeShape, Schema14.Struct({
1583
- type: Schema14.Literal("if")
1719
+ var IfShape = Schema16.extend(ComputeShape, Schema16.Struct({
1720
+ type: Schema16.Literal("if")
1584
1721
  }));
1585
- var IfElseShape = Schema14.extend(ComputeShape, Schema14.Struct({
1586
- type: Schema14.Literal("if-else")
1722
+ var IfElseShape = Schema16.extend(ComputeShape, Schema16.Struct({
1723
+ type: Schema16.Literal("if-else")
1587
1724
  }));
1588
1725
  var IfComponent = ({ shape, ...props }) => {
1589
- return /* @__PURE__ */ React15.createElement(FunctionBody, {
1726
+ return /* @__PURE__ */ React17.createElement(FunctionBody, {
1590
1727
  shape,
1591
1728
  inputSchema: IfInput,
1592
1729
  outputSchema: IfOutput
1593
1730
  });
1594
1731
  };
1595
1732
  var IfElseComponent = ({ shape, ...props }) => {
1596
- return /* @__PURE__ */ React15.createElement(FunctionBody, {
1733
+ return /* @__PURE__ */ React17.createElement(FunctionBody, {
1597
1734
  shape,
1598
1735
  inputSchema: IfElseInput,
1599
1736
  outputSchema: IfElseOutput
@@ -1611,7 +1748,7 @@ var ifShape = {
1611
1748
  type: "if",
1612
1749
  name: "IF",
1613
1750
  icon: "ph--arrows-split--regular",
1614
- component: (props) => /* @__PURE__ */ React15.createElement(IfComponent, props),
1751
+ component: (props) => /* @__PURE__ */ React17.createElement(IfComponent, props),
1615
1752
  createShape: createIf,
1616
1753
  getAnchors: (shape) => createFunctionAnchors(shape, IfInput, IfOutput)
1617
1754
  };
@@ -1627,86 +1764,21 @@ var ifElseShape = {
1627
1764
  type: "if-else",
1628
1765
  name: "IF/ELSE",
1629
1766
  icon: "ph--arrows-merge--regular",
1630
- component: (props) => /* @__PURE__ */ React15.createElement(IfElseComponent, props),
1767
+ component: (props) => /* @__PURE__ */ React17.createElement(IfElseComponent, props),
1631
1768
  createShape: createIfElse,
1632
1769
  getAnchors: (shape) => createFunctionAnchors(shape, IfElseInput, IfElseOutput)
1633
1770
  };
1634
1771
 
1635
- // src/shapes/Queue.tsx
1636
- import * as Schema15 from "effect/Schema";
1637
- import React16, { Fragment } from "react";
1638
- import { DEFAULT_OUTPUT as DEFAULT_OUTPUT4, QueueInput, QueueOutput } from "@dxos/conductor";
1639
- import { ScrollArea as ScrollArea2 } from "@dxos/react-ui";
1640
- import { mx as mx2 } from "@dxos/ui-theme";
1641
- var QueueShape = Schema15.extend(ComputeShape, Schema15.Struct({
1642
- type: Schema15.Literal("queue")
1643
- }));
1644
- var createQueue = (props) => createShape({
1645
- type: "queue",
1646
- size: {
1647
- width: 256,
1648
- height: 512
1649
- },
1650
- ...props
1651
- });
1652
- var QueueComponent = ({ shape }) => {
1653
- const { runtime } = useComputeNodeState(shape);
1654
- const items = runtime.outputs[DEFAULT_OUTPUT4]?.type === "executed" ? runtime.outputs[DEFAULT_OUTPUT4].value : [];
1655
- const handleAction = (action) => {
1656
- if (action === "run") {
1657
- runtime.evalNode();
1658
- }
1659
- };
1660
- return /* @__PURE__ */ React16.createElement(Box, {
1661
- shape,
1662
- status: `${items.length} items`,
1663
- onAction: handleAction
1664
- }, /* @__PURE__ */ React16.createElement(ScrollArea2.Root, {
1665
- orientation: "vertical"
1666
- }, /* @__PURE__ */ React16.createElement(ScrollArea2.Viewport, {
1667
- classNames: "divide-y divide-separator"
1668
- }, [
1669
- ...items
1670
- ].map((item, i) => /* @__PURE__ */ React16.createElement(QueueItem, {
1671
- key: i,
1672
- classNames: "p-1 pli-2",
1673
- item
1674
- })))));
1675
- };
1676
- var QueueItem = ({ classNames, item }) => {
1677
- if (typeof item !== "object") {
1678
- return /* @__PURE__ */ React16.createElement("div", {
1679
- className: mx2(classNames, "whitespace-pre-wrap")
1680
- }, item);
1681
- }
1682
- return /* @__PURE__ */ React16.createElement("div", {
1683
- className: mx2("grid grid-cols-[80px,1fr]", classNames)
1684
- }, Object.entries(item).map(([key, value]) => /* @__PURE__ */ React16.createElement(Fragment, {
1685
- key
1686
- }, /* @__PURE__ */ React16.createElement("div", {
1687
- className: "p-1 text-xs text-subdued"
1688
- }, key), /* @__PURE__ */ React16.createElement("div", null, typeof value === "string" ? value : JSON.stringify(value)))));
1689
- };
1690
- var queueShape = {
1691
- type: "queue",
1692
- name: "Queue",
1693
- icon: "ph--queue--regular",
1694
- component: QueueComponent,
1695
- createShape: createQueue,
1696
- getAnchors: (shape) => createFunctionAnchors(shape, QueueInput, QueueOutput),
1697
- resizable: true
1698
- };
1699
-
1700
1772
  // src/shapes/RNG.tsx
1701
- import * as Schema16 from "effect/Schema";
1702
- import React17, { useEffect as useEffect5, useState as useState7 } from "react";
1773
+ import * as Schema17 from "effect/Schema";
1774
+ import React18, { useEffect as useEffect5, useState as useState8 } from "react";
1703
1775
  import { DEFAULT_OUTPUT as DEFAULT_OUTPUT5 } from "@dxos/conductor";
1704
- import { Icon as Icon4 } from "@dxos/react-ui";
1776
+ import { Icon as Icon5 } from "@dxos/react-ui";
1705
1777
  import { createAnchorMap as createAnchorMap7 } from "@dxos/react-ui-canvas-editor";
1706
- var RandomShape = Schema16.extend(ComputeShape, Schema16.Struct({
1707
- type: Schema16.Literal("rng"),
1708
- min: Schema16.optional(Schema16.Number),
1709
- max: Schema16.optional(Schema16.Number)
1778
+ var RandomShape = Schema17.extend(ComputeShape, Schema17.Struct({
1779
+ type: Schema17.Literal("rng"),
1780
+ min: Schema17.optional(Schema17.Number),
1781
+ max: Schema17.optional(Schema17.Number)
1710
1782
  }));
1711
1783
  var createRandom = (props) => createShape({
1712
1784
  type: "rng",
@@ -1727,8 +1799,8 @@ var icons = [
1727
1799
  var pickIcon = () => icons[Math.floor(Math.random() * icons.length)];
1728
1800
  var RandomComponent = ({ shape }) => {
1729
1801
  const { runtime } = useComputeNodeState(shape);
1730
- const [spin, setSpin] = useState7(false);
1731
- const [icon, setIcon] = useState7(pickIcon());
1802
+ const [spin, setSpin] = useState8(false);
1803
+ const [icon, setIcon] = useState8(pickIcon());
1732
1804
  useEffect5(() => {
1733
1805
  if (!spin) {
1734
1806
  return;
@@ -1749,9 +1821,9 @@ var RandomComponent = ({ shape }) => {
1749
1821
  runtime.setOutput(DEFAULT_OUTPUT5, Math.random());
1750
1822
  setSpin(true);
1751
1823
  };
1752
- return /* @__PURE__ */ React17.createElement("div", {
1824
+ return /* @__PURE__ */ React18.createElement("div", {
1753
1825
  className: "flex grow items-center justify-center"
1754
- }, /* @__PURE__ */ React17.createElement(Icon4, {
1826
+ }, /* @__PURE__ */ React18.createElement(Icon5, {
1755
1827
  icon,
1756
1828
  classNames: spin && "animate-[spin_1s]",
1757
1829
  size: 10,
@@ -1773,13 +1845,13 @@ var randomShape = {
1773
1845
  };
1774
1846
 
1775
1847
  // src/shapes/Scope.tsx
1776
- import * as Schema17 from "effect/Schema";
1777
- import React18 from "react";
1848
+ import * as Schema18 from "effect/Schema";
1849
+ import React19 from "react";
1778
1850
  import { DEFAULT_INPUT as DEFAULT_INPUT5 } from "@dxos/conductor";
1779
1851
  import { createAnchorMap as createAnchorMap8 } from "@dxos/react-ui-canvas-editor";
1780
1852
  import { Chaos, shaderPresets, useAudioStream } from "@dxos/react-ui-sfx";
1781
- var ScopeShape = Schema17.extend(ComputeShape, Schema17.Struct({
1782
- type: Schema17.Literal("scope")
1853
+ var ScopeShape = Schema18.extend(ComputeShape, Schema18.Struct({
1854
+ type: Schema18.Literal("scope")
1783
1855
  }));
1784
1856
  var createScope = (props) => createShape({
1785
1857
  type: "scope",
@@ -1795,9 +1867,9 @@ var ScopeComponent = ({ shape }) => {
1795
1867
  const input = runtime.inputs[DEFAULT_INPUT5];
1796
1868
  const active = input?.type === "executed" ? input.value : false;
1797
1869
  const { getAverage } = useAudioStream(active);
1798
- return /* @__PURE__ */ React18.createElement("div", {
1799
- className: "flex is-full justify-center items-center bg-black"
1800
- }, /* @__PURE__ */ React18.createElement(Chaos, {
1870
+ return /* @__PURE__ */ React19.createElement("div", {
1871
+ className: "flex w-full justify-center items-center bg-black"
1872
+ }, /* @__PURE__ */ React19.createElement(Chaos, {
1801
1873
  active,
1802
1874
  getValue: getAverage,
1803
1875
  options: {
@@ -1821,13 +1893,15 @@ var scopeShape = {
1821
1893
  };
1822
1894
 
1823
1895
  // src/shapes/Surface.tsx
1824
- import * as Schema18 from "effect/Schema";
1825
- import React19 from "react";
1896
+ import * as Schema19 from "effect/Schema";
1897
+ import React20 from "react";
1826
1898
  import { Surface } from "@dxos/app-framework/ui";
1899
+ import { AppSurface } from "@dxos/app-toolkit/ui";
1827
1900
  import { DEFAULT_INPUT as DEFAULT_INPUT6 } from "@dxos/conductor";
1901
+ import { Card } from "@dxos/react-ui";
1828
1902
  import { createAnchorMap as createAnchorMap9 } from "@dxos/react-ui-canvas-editor";
1829
- var SurfaceShape = Schema18.extend(ComputeShape, Schema18.Struct({
1830
- type: Schema18.Literal("surface")
1903
+ var SurfaceShape = Schema19.extend(ComputeShape, Schema19.Struct({
1904
+ type: Schema19.Literal("surface")
1831
1905
  }));
1832
1906
  var createSurface = (props) => createShape({
1833
1907
  type: "surface",
@@ -1846,16 +1920,16 @@ var SurfaceComponent = ({ shape }) => {
1846
1920
  runtime.evalNode();
1847
1921
  }
1848
1922
  };
1849
- return /* @__PURE__ */ React19.createElement(Box, {
1923
+ return /* @__PURE__ */ React20.createElement(Box, {
1850
1924
  shape,
1851
1925
  onAction: handleAction
1852
- }, value !== null && /* @__PURE__ */ React19.createElement(Surface.Surface, {
1853
- role: "card--extrinsic",
1926
+ }, /* @__PURE__ */ React20.createElement(Card.Root, null, value !== null && /* @__PURE__ */ React20.createElement(Surface.Surface, {
1927
+ type: AppSurface.Card,
1854
1928
  data: {
1855
- value
1929
+ subject: value
1856
1930
  },
1857
1931
  limit: 1
1858
- }));
1932
+ })));
1859
1933
  };
1860
1934
  var surfaceShape = {
1861
1935
  type: "surface",
@@ -1873,13 +1947,13 @@ var surfaceShape = {
1873
1947
  };
1874
1948
 
1875
1949
  // src/shapes/Switch.tsx
1876
- import * as Schema19 from "effect/Schema";
1877
- import React20, { useEffect as useEffect6, useState as useState8 } from "react";
1950
+ import * as Schema20 from "effect/Schema";
1951
+ import React21, { useEffect as useEffect6, useState as useState9 } from "react";
1878
1952
  import { DEFAULT_OUTPUT as DEFAULT_OUTPUT6 } from "@dxos/conductor";
1879
1953
  import { Input as Input2 } from "@dxos/react-ui";
1880
1954
  import { createAnchorMap as createAnchorMap10 } from "@dxos/react-ui-canvas-editor";
1881
- var SwitchShape = Schema19.extend(ComputeShape, Schema19.Struct({
1882
- type: Schema19.Literal("switch")
1955
+ var SwitchShape = Schema20.extend(ComputeShape, Schema20.Struct({
1956
+ type: Schema20.Literal("switch")
1883
1957
  }));
1884
1958
  var createSwitch = (props) => createShape({
1885
1959
  type: "switch",
@@ -1891,16 +1965,16 @@ var createSwitch = (props) => createShape({
1891
1965
  });
1892
1966
  var SwitchComponent = ({ shape }) => {
1893
1967
  const { runtime } = useComputeNodeState(shape);
1894
- const [value, setValue] = useState8(false);
1968
+ const [value, setValue] = useState9(false);
1895
1969
  useEffect6(() => {
1896
1970
  runtime.setOutput(DEFAULT_OUTPUT6, value);
1897
1971
  }, [
1898
1972
  value
1899
1973
  ]);
1900
- return /* @__PURE__ */ React20.createElement("div", {
1901
- className: "flex is-full justify-center items-center",
1974
+ return /* @__PURE__ */ React21.createElement("div", {
1975
+ className: "flex w-full justify-center items-center",
1902
1976
  onClick: (ev) => ev.stopPropagation()
1903
- }, /* @__PURE__ */ React20.createElement(Input2.Root, null, /* @__PURE__ */ React20.createElement(Input2.Switch, {
1977
+ }, /* @__PURE__ */ React21.createElement(Input2.Root, null, /* @__PURE__ */ React21.createElement(Input2.Switch, {
1904
1978
  checked: value,
1905
1979
  onCheckedChange: (value2) => setValue(value2)
1906
1980
  })));
@@ -1920,14 +1994,14 @@ var switchShape = {
1920
1994
  };
1921
1995
 
1922
1996
  // src/shapes/Table.tsx
1923
- import * as Schema20 from "effect/Schema";
1924
- import React21 from "react";
1997
+ import * as Schema21 from "effect/Schema";
1998
+ import React22 from "react";
1925
1999
  import { createInputSchema, createOutputSchema } from "@dxos/conductor";
1926
2000
  import { Message } from "@dxos/types";
1927
2001
  var InputSchema = createInputSchema(Message.Message);
1928
- var OutputSchema = createOutputSchema(Schema20.mutable(Schema20.Array(Message.Message)));
1929
- var TableShape = Schema20.extend(ComputeShape, Schema20.Struct({
1930
- type: Schema20.Literal("table")
2002
+ var OutputSchema = createOutputSchema(Schema21.mutable(Schema21.Array(Message.Message)));
2003
+ var TableShape = Schema21.extend(ComputeShape, Schema21.Struct({
2004
+ type: Schema21.Literal("table")
1931
2005
  }));
1932
2006
  var createTable = (props) => createShape({
1933
2007
  type: "table",
@@ -1938,7 +2012,7 @@ var createTable = (props) => createShape({
1938
2012
  ...props
1939
2013
  });
1940
2014
  var TableComponent = ({ shape }) => {
1941
- return /* @__PURE__ */ React21.createElement(Box, {
2015
+ return /* @__PURE__ */ React22.createElement(Box, {
1942
2016
  shape
1943
2017
  });
1944
2018
  };
@@ -1953,16 +2027,16 @@ var tableShape = {
1953
2027
  };
1954
2028
 
1955
2029
  // src/shapes/Template.tsx
1956
- import * as Schema21 from "effect/Schema";
1957
- import React22, { useRef as useRef5 } from "react";
2030
+ import * as Schema22 from "effect/Schema";
2031
+ import React23, { useRef as useRef5 } from "react";
1958
2032
  import { ComputeValueType as ComputeValueType3, TemplateOutput, VoidInput as VoidInput2, getTemplateInputSchema as getTemplateInputSchema2 } from "@dxos/conductor";
1959
2033
  import { toJsonSchema } from "@dxos/echo/internal";
1960
2034
  import { invariant as invariant5 } from "@dxos/invariant";
1961
2035
  import { TextBox as TextBox4 } from "@dxos/react-ui-canvas-editor";
1962
- var __dxlog_file6 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/Template.tsx";
1963
- var TemplateShape = Schema21.extend(ComputeShape, Schema21.Struct({
1964
- type: Schema21.Literal("template"),
1965
- valueType: Schema21.optional(ComputeValueType3)
2036
+ var __dxlog_file7 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/Template.tsx";
2037
+ var TemplateShape = Schema22.extend(ComputeShape, Schema22.Struct({
2038
+ type: Schema22.Literal("template"),
2039
+ valueType: Schema22.optional(ComputeValueType3)
1966
2040
  }));
1967
2041
  var TextInputComponent3 = ({ shape, title, ...props }) => {
1968
2042
  const { node } = useComputeNodeState(shape);
@@ -1976,26 +2050,18 @@ var TextInputComponent3 = ({ shape, title, ...props }) => {
1976
2050
  }
1977
2051
  };
1978
2052
  const handleTypeChange = (newType) => {
1979
- invariant5(Schema21.is(ComputeValueType3)(newType), "Invalid type", {
1980
- F: __dxlog_file6,
1981
- L: 59,
1982
- S: void 0,
1983
- A: [
1984
- "Schema.is(ComputeValueType)(newType)",
1985
- "'Invalid type'"
1986
- ]
1987
- });
2053
+ invariant5(Schema22.is(ComputeValueType3)(newType), "Invalid type", { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 32, S: void 0, A: ["Schema.is(ComputeValueType)(newType)", "'Invalid type'"] });
1988
2054
  node.valueType = newType;
1989
2055
  node.inputSchema = toJsonSchema(getTemplateInputSchema2(node));
1990
2056
  };
1991
- return /* @__PURE__ */ React22.createElement(Box, {
2057
+ return /* @__PURE__ */ React23.createElement(Box, {
1992
2058
  shape,
1993
2059
  title: "Template",
1994
- status: /* @__PURE__ */ React22.createElement(TypeSelect, {
2060
+ status: /* @__PURE__ */ React23.createElement(TypeSelect, {
1995
2061
  value: node.valueType ?? "string",
1996
2062
  onValueChange: handleTypeChange
1997
2063
  })
1998
- }, /* @__PURE__ */ React22.createElement(TextBox4, {
2064
+ }, /* @__PURE__ */ React23.createElement(TextBox4, {
1999
2065
  ...props,
2000
2066
  ref: inputRef,
2001
2067
  value: node.value,
@@ -2016,7 +2082,7 @@ var templateShape = {
2016
2082
  type: "template",
2017
2083
  name: "Template",
2018
2084
  icon: "ph--article--regular",
2019
- component: (props) => /* @__PURE__ */ React22.createElement(TextInputComponent3, {
2085
+ component: (props) => /* @__PURE__ */ React23.createElement(TextInputComponent3, {
2020
2086
  ...props,
2021
2087
  placeholder: "Prompt"
2022
2088
  }),
@@ -2026,13 +2092,13 @@ var templateShape = {
2026
2092
  };
2027
2093
 
2028
2094
  // src/shapes/Text.tsx
2029
- import * as Schema22 from "effect/Schema";
2030
- import React23 from "react";
2095
+ import * as Schema23 from "effect/Schema";
2096
+ import React24 from "react";
2031
2097
  import { DEFAULT_INPUT as DEFAULT_INPUT7 } from "@dxos/conductor";
2032
2098
  import { TextBox as TextBox5 } from "@dxos/react-ui-canvas-editor";
2033
2099
  import { createAnchorMap as createAnchorMap11 } from "@dxos/react-ui-canvas-editor";
2034
- var TextShape = Schema22.extend(ComputeShape, Schema22.Struct({
2035
- type: Schema22.Literal("text")
2100
+ var TextShape = Schema23.extend(ComputeShape, Schema23.Struct({
2101
+ type: Schema23.Literal("text")
2036
2102
  }));
2037
2103
  var createText = (props) => createShape({
2038
2104
  type: "text",
@@ -2051,10 +2117,10 @@ var TextComponent = ({ shape }) => {
2051
2117
  runtime.evalNode();
2052
2118
  }
2053
2119
  };
2054
- return /* @__PURE__ */ React23.createElement(Box, {
2120
+ return /* @__PURE__ */ React24.createElement(Box, {
2055
2121
  shape,
2056
2122
  onAction: handleAction
2057
- }, /* @__PURE__ */ React23.createElement(TextBox5, {
2123
+ }, /* @__PURE__ */ React24.createElement(TextBox5, {
2058
2124
  value
2059
2125
  }));
2060
2126
  };
@@ -2074,16 +2140,16 @@ var textShape = {
2074
2140
  };
2075
2141
 
2076
2142
  // src/shapes/Thread.tsx
2077
- import * as Schema23 from "effect/Schema";
2078
- import React24, { useEffect as useEffect7, useRef as useRef6 } from "react";
2143
+ import * as Schema24 from "effect/Schema";
2144
+ import React25, { useEffect as useEffect7, useRef as useRef6 } from "react";
2079
2145
  import { createInputSchema as createInputSchema2, createOutputSchema as createOutputSchema2 } from "@dxos/conductor";
2080
2146
  import { ScrollArea as ScrollArea3 } from "@dxos/react-ui";
2081
2147
  import { Message as Message2 } from "@dxos/types";
2082
2148
  import { mx as mx3 } from "@dxos/ui-theme";
2083
2149
  var InputSchema2 = createInputSchema2(Message2.Message);
2084
- var OutputSchema2 = createOutputSchema2(Schema23.mutable(Schema23.Array(Message2.Message)));
2085
- var ThreadShape = Schema23.extend(ComputeShape, Schema23.Struct({
2086
- type: Schema23.Literal("thread")
2150
+ var OutputSchema2 = createOutputSchema2(Schema24.mutable(Schema24.Array(Message2.Message)));
2151
+ var ThreadShape = Schema24.extend(ComputeShape, Schema24.Struct({
2152
+ type: Schema24.Literal("thread")
2087
2153
  }));
2088
2154
  var createThread = (props) => createShape({
2089
2155
  type: "thread",
@@ -2103,32 +2169,31 @@ var ThreadComponent = ({ shape }) => {
2103
2169
  }, [
2104
2170
  items
2105
2171
  ]);
2106
- return /* @__PURE__ */ React24.createElement(Box, {
2172
+ return /* @__PURE__ */ React25.createElement(Box, {
2107
2173
  shape
2108
- }, /* @__PURE__ */ React24.createElement(ScrollArea3.Root, {
2174
+ }, /* @__PURE__ */ React25.createElement(ScrollArea3.Root, {
2109
2175
  orientation: "vertical"
2110
- }, /* @__PURE__ */ React24.createElement(ScrollArea3.Viewport, {
2176
+ }, /* @__PURE__ */ React25.createElement(ScrollArea3.Viewport, {
2111
2177
  classNames: "gap-2 p-2",
2112
2178
  ref: scrollRef
2113
2179
  }, [
2114
2180
  ...items
2115
- ].map((item, i) => /* @__PURE__ */ React24.createElement(ThreadItem, {
2181
+ ].map((item, i) => /* @__PURE__ */ React25.createElement(ThreadItem, {
2116
2182
  key: i,
2117
2183
  item
2118
2184
  })))));
2119
2185
  };
2120
2186
  var ThreadItem = ({ classNames, item }) => {
2121
2187
  if (typeof item !== "object") {
2122
- return /* @__PURE__ */ React24.createElement("div", {
2123
- role: "none",
2188
+ return /* @__PURE__ */ React25.createElement("div", {
2124
2189
  className: mx3(classNames)
2125
2190
  }, item);
2126
2191
  }
2127
2192
  const { role, message } = item;
2128
- return /* @__PURE__ */ React24.createElement("div", {
2193
+ return /* @__PURE__ */ React25.createElement("div", {
2129
2194
  className: mx3("flex", classNames, role === "user" && "justify-end")
2130
- }, /* @__PURE__ */ React24.createElement("div", {
2131
- className: mx3("block rounded-md p-1 pli-2 text-sm", role === "user" ? "bg-blue-100 dark:bg-blue-800" : role === "system" ? "bg-red-100, dark:bg-red-800" : "whitespace-pre-wrap bg-neutral-50 dark:bg-neutral-800")
2195
+ }, /* @__PURE__ */ React25.createElement("div", {
2196
+ className: mx3("block rounded-md p-1 px-2 text-sm", role === "user" ? "bg-blue-100 dark:bg-blue-800" : role === "system" ? "bg-red-100, dark:bg-red-800" : "whitespace-pre-wrap bg-neutral-50 dark:bg-neutral-800")
2132
2197
  }, message));
2133
2198
  };
2134
2199
  var threadShape = {
@@ -2142,11 +2207,11 @@ var threadShape = {
2142
2207
  };
2143
2208
 
2144
2209
  // src/shapes/TextToImage.tsx
2145
- import * as Schema24 from "effect/Schema";
2146
- import React25 from "react";
2210
+ import * as Schema25 from "effect/Schema";
2211
+ import React26 from "react";
2147
2212
  import { createAnchorMap as createAnchorMap12 } from "@dxos/react-ui-canvas-editor";
2148
- var TextToImageShape = Schema24.extend(ComputeShape, Schema24.Struct({
2149
- type: Schema24.Literal("text-to-image")
2213
+ var TextToImageShape = Schema25.extend(ComputeShape, Schema25.Struct({
2214
+ type: Schema25.Literal("text-to-image")
2150
2215
  }));
2151
2216
  var createTextToImage = (props) => createShape({
2152
2217
  type: "text-to-image",
@@ -2157,7 +2222,7 @@ var createTextToImage = (props) => createShape({
2157
2222
  ...props
2158
2223
  });
2159
2224
  var TextToImageComponent = ({ shape }) => {
2160
- return /* @__PURE__ */ React25.createElement(Box, {
2225
+ return /* @__PURE__ */ React26.createElement(Box, {
2161
2226
  shape
2162
2227
  });
2163
2228
  };
@@ -2176,17 +2241,17 @@ var textToImageShape = {
2176
2241
  };
2177
2242
 
2178
2243
  // src/shapes/Trigger.tsx
2179
- import * as Schema25 from "effect/Schema";
2180
- import React26, { useEffect as useEffect8 } from "react";
2244
+ import * as Schema26 from "effect/Schema";
2245
+ import React27, { useEffect as useEffect8 } from "react";
2246
+ import { Trigger, TriggerEvent } from "@dxos/compute";
2181
2247
  import { VoidInput as VoidInput3 } from "@dxos/conductor";
2182
- import { Filter as Filter2, Obj as Obj4, Query, Ref as Ref3, Type } from "@dxos/echo";
2183
- import { Trigger, TriggerEvent } from "@dxos/functions";
2248
+ import { Filter as Filter2, Obj as Obj4, Query, Ref as Ref3 } from "@dxos/echo";
2184
2249
  import { DXN, SpaceId } from "@dxos/keys";
2185
- import { useSpace } from "@dxos/react-client/echo";
2250
+ import { useSpaces } from "@dxos/react-client/echo";
2186
2251
  import { Select as Select2 } from "@dxos/react-ui";
2187
- var TriggerShape = Schema25.extend(ComputeShape, Schema25.Struct({
2188
- type: Schema25.Literal("trigger"),
2189
- functionTrigger: Schema25.optional(Type.Ref(Trigger.Trigger))
2252
+ var TriggerShape = Schema26.extend(ComputeShape, Schema26.Struct({
2253
+ type: Schema26.Literal("trigger"),
2254
+ functionTrigger: Schema26.optional(Ref3.Ref(Trigger.Trigger))
2190
2255
  }));
2191
2256
  var createTrigger = (props) => {
2192
2257
  const functionTrigger = Trigger.make({
@@ -2204,12 +2269,12 @@ var createTrigger = (props) => {
2204
2269
  });
2205
2270
  };
2206
2271
  var TriggerComponent = ({ shape }) => {
2207
- const space = useSpace();
2272
+ const [space] = useSpaces();
2208
2273
  const functionTrigger = shape.functionTrigger?.target;
2209
2274
  useEffect8(() => {
2210
2275
  if (functionTrigger && !functionTrigger.spec) {
2211
- Obj4.change(functionTrigger, (t) => {
2212
- t.spec = createTriggerSpec({
2276
+ Obj4.update(functionTrigger, (functionTrigger2) => {
2277
+ functionTrigger2.spec = createTriggerSpec({
2213
2278
  triggerKind: "email",
2214
2279
  spaceId: space?.id
2215
2280
  });
@@ -2226,8 +2291,8 @@ var TriggerComponent = ({ shape }) => {
2226
2291
  ]);
2227
2292
  const setKind = (kind) => {
2228
2293
  if (functionTrigger?.spec?.kind !== kind) {
2229
- Obj4.change(functionTrigger, (t) => {
2230
- t.spec = createTriggerSpec({
2294
+ Obj4.update(functionTrigger, (obj) => {
2295
+ obj.spec = createTriggerSpec({
2231
2296
  triggerKind: kind,
2232
2297
  spaceId: space?.id
2233
2298
  });
@@ -2237,9 +2302,9 @@ var TriggerComponent = ({ shape }) => {
2237
2302
  if (!functionTrigger?.spec) {
2238
2303
  return;
2239
2304
  }
2240
- return /* @__PURE__ */ React26.createElement(FunctionBody, {
2305
+ return /* @__PURE__ */ React27.createElement(FunctionBody, {
2241
2306
  shape,
2242
- status: /* @__PURE__ */ React26.createElement(TriggerKindSelect, {
2307
+ status: /* @__PURE__ */ React27.createElement(TriggerKindSelect, {
2243
2308
  value: functionTrigger.spec?.kind,
2244
2309
  onValueChange: (kind) => setKind(kind)
2245
2310
  }),
@@ -2248,51 +2313,37 @@ var TriggerComponent = ({ shape }) => {
2248
2313
  });
2249
2314
  };
2250
2315
  var TriggerKindSelect = ({ value, onValueChange }) => {
2251
- return /* @__PURE__ */ React26.createElement(Select2.Root, {
2316
+ return /* @__PURE__ */ React27.createElement(Select2.Root, {
2252
2317
  value,
2253
2318
  onValueChange
2254
- }, /* @__PURE__ */ React26.createElement(Select2.TriggerButton, {
2319
+ }, /* @__PURE__ */ React27.createElement(Select2.TriggerButton, {
2255
2320
  variant: "ghost",
2256
- classNames: "is-full !pli-0"
2257
- }), /* @__PURE__ */ React26.createElement(Select2.Portal, null, /* @__PURE__ */ React26.createElement(Select2.Content, null, /* @__PURE__ */ React26.createElement(Select2.ScrollUpButton, null), /* @__PURE__ */ React26.createElement(Select2.Viewport, null, Trigger.Kinds.map((kind) => /* @__PURE__ */ React26.createElement(Select2.Option, {
2321
+ classNames: "w-full px-0!"
2322
+ }), /* @__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, {
2258
2323
  key: kind,
2259
2324
  value: kind
2260
- }, kind))), /* @__PURE__ */ React26.createElement(Select2.ScrollDownButton, null), /* @__PURE__ */ React26.createElement(Select2.Arrow, null))));
2325
+ }, kind))), /* @__PURE__ */ React27.createElement(Select2.ScrollDownButton, null), /* @__PURE__ */ React27.createElement(Select2.Arrow, null))));
2261
2326
  };
2262
2327
  var createTriggerSpec = (props) => {
2263
2328
  const kind = props.triggerKind ?? "email";
2264
2329
  switch (kind) {
2265
2330
  case "timer":
2266
- return {
2267
- kind: "timer",
2268
- cron: "*/10 * * * * *"
2269
- };
2331
+ return Trigger.specTimer("*/10 * * * * *");
2270
2332
  case "webhook":
2271
- return {
2272
- kind: "webhook",
2333
+ return Trigger.specWebhook({
2273
2334
  method: "POST"
2274
- };
2335
+ });
2275
2336
  case "subscription":
2276
- return {
2277
- kind: "subscription",
2278
- query: {
2279
- ast: Query.select(Filter2.nothing()).ast
2280
- }
2281
- };
2337
+ return Trigger.specSubscription(Query.select(Filter2.nothing()));
2282
2338
  case "email":
2283
- return {
2284
- kind: "email"
2285
- };
2339
+ return Trigger.specEmail();
2286
2340
  case "queue": {
2287
2341
  const dxn = new DXN(DXN.kind.QUEUE, [
2288
2342
  "data",
2289
2343
  props.spaceId ?? SpaceId.random(),
2290
2344
  Obj4.ID.random()
2291
2345
  ]).toString();
2292
- return {
2293
- kind: "queue",
2294
- queue: dxn
2295
- };
2346
+ return Trigger.specQueue(dxn);
2296
2347
  }
2297
2348
  }
2298
2349
  };
@@ -2315,134 +2366,6 @@ var triggerShape = {
2315
2366
  getAnchors: (shape) => createFunctionAnchors(shape, VoidInput3, getOutputSchema(shape.functionTrigger?.target?.spec?.kind ?? "email"))
2316
2367
  };
2317
2368
 
2318
- // src/shapes/GptRealtime.tsx
2319
- import * as Schema26 from "effect/Schema";
2320
- import React27, { useState as useState9 } from "react";
2321
- import { log as log2 } from "@dxos/log";
2322
- import { useConfig } from "@dxos/react-client";
2323
- import { Icon as Icon5 } from "@dxos/react-ui";
2324
- var __dxlog_file7 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/GptRealtime.tsx";
2325
- var GptRealtimeShape = Schema26.extend(ComputeShape, Schema26.Struct({
2326
- type: Schema26.Literal("gpt-realtime")
2327
- }));
2328
- var createGptRealtime = (props) => createShape({
2329
- type: "gpt-realtime",
2330
- size: {
2331
- width: 256,
2332
- height: 256
2333
- },
2334
- ...props
2335
- });
2336
- var GptRealtimeComponent = ({ shape }) => {
2337
- const [isLive, setIsLive] = useState9(false);
2338
- const [isReady, setIsReady] = useState9(false);
2339
- const config = useConfig();
2340
- const start = async () => {
2341
- setIsLive(true);
2342
- try {
2343
- const peerConnection = new RTCPeerConnection();
2344
- peerConnection.ontrack = (event) => {
2345
- const audioElement = document.createElement("audio");
2346
- audioElement.srcObject = event.streams[0];
2347
- audioElement.autoplay = true;
2348
- audioElement.controls = false;
2349
- audioElement.style.display = "none";
2350
- document.body.appendChild(audioElement);
2351
- setIsReady(true);
2352
- };
2353
- const stream = await navigator.mediaDevices.getUserMedia({
2354
- audio: true
2355
- });
2356
- stream.getTracks().forEach((track) => peerConnection.addTransceiver(track, {
2357
- direction: "sendrecv"
2358
- }));
2359
- const offer = await peerConnection.createOffer();
2360
- await peerConnection.setLocalDescription(offer);
2361
- const AiServiceUrl = new URL("/rtc-connect", config.values.runtime?.services?.ai?.server ?? DEFAULT_AI_SERVICE_URL);
2362
- const response = await fetch(AiServiceUrl, {
2363
- method: "POST",
2364
- body: offer.sdp,
2365
- headers: {
2366
- "Content-Type": "application/sdp"
2367
- }
2368
- });
2369
- const answer = await response.text();
2370
- await peerConnection.setRemoteDescription({
2371
- sdp: answer,
2372
- type: "answer"
2373
- });
2374
- const dataChannel = peerConnection.createDataChannel("response");
2375
- const configureData = () => {
2376
- log2.info("Configuring data channel", void 0, {
2377
- F: __dxlog_file7,
2378
- L: 87,
2379
- S: void 0,
2380
- C: (f, a) => f(...a)
2381
- });
2382
- const event = {
2383
- type: "session.update",
2384
- session: {
2385
- modalities: [
2386
- "text",
2387
- "audio"
2388
- ],
2389
- // Provide the tools. Note they match the keys in the `fns` object above
2390
- tools: []
2391
- }
2392
- };
2393
- dataChannel.send(JSON.stringify(event));
2394
- };
2395
- dataChannel.addEventListener("open", (ev) => {
2396
- log2.info("Opening data channel", {
2397
- ev
2398
- }, {
2399
- F: __dxlog_file7,
2400
- L: 100,
2401
- S: void 0,
2402
- C: (f, a) => f(...a)
2403
- });
2404
- configureData();
2405
- });
2406
- dataChannel.addEventListener("message", async (ev) => {
2407
- const msg = JSON.parse(ev.data);
2408
- if (msg.type === "response.function_call_arguments.done") {
2409
- }
2410
- });
2411
- } catch (error) {
2412
- log2.error("Error in realtime session:", {
2413
- error
2414
- }, {
2415
- F: __dxlog_file7,
2416
- L: 140,
2417
- S: void 0,
2418
- C: (f, a) => f(...a)
2419
- });
2420
- throw error;
2421
- }
2422
- };
2423
- return /* @__PURE__ */ React27.createElement("div", {
2424
- className: "flex is-full justify-center items-center"
2425
- }, /* @__PURE__ */ React27.createElement(Icon5, {
2426
- icon: isReady ? "ph--waveform--regular" : isLive ? "ph--pulse--regular" : "ph--play--regular",
2427
- size: 16,
2428
- classNames: !isLive && "cursor-pointer",
2429
- onClick: start
2430
- }));
2431
- };
2432
- var gptRealtimeShape = {
2433
- type: "gpt-realtime",
2434
- name: "GPT Realtime",
2435
- icon: "ph--pulse--regular",
2436
- component: GptRealtimeComponent,
2437
- createShape: createGptRealtime,
2438
- // TODO(dmaretskyi): Can we fetch the schema dynamically?
2439
- getAnchors: (shape) => createFunctionAnchors(shape, Schema26.Struct({
2440
- audio: Schema26.Any
2441
- }), Schema26.Struct({})),
2442
- resizable: true
2443
- };
2444
- var DEFAULT_AI_SERVICE_URL = "http://localhost:8788";
2445
-
2446
2369
  // src/registry.ts
2447
2370
  var computeShapes = [
2448
2371
  {
@@ -2488,7 +2411,7 @@ var computeShapes = [
2488
2411
  shapes: [
2489
2412
  //
2490
2413
  jsonShape,
2491
- queueShape,
2414
+ feedShape,
2492
2415
  threadShape,
2493
2416
  textShape,
2494
2417
  surfaceShape,
@@ -2547,6 +2470,9 @@ export {
2547
2470
  ConstantShape,
2548
2471
  DatabaseComponent,
2549
2472
  DatabaseShape,
2473
+ FeedComponent,
2474
+ FeedItem,
2475
+ FeedShape,
2550
2476
  FunctionBody,
2551
2477
  FunctionShape,
2552
2478
  GptComponent,
@@ -2564,9 +2490,6 @@ export {
2564
2490
  JsonTransformShape,
2565
2491
  NotShape,
2566
2492
  OrShape,
2567
- QueueComponent,
2568
- QueueItem,
2569
- QueueShape,
2570
2493
  RandomComponent,
2571
2494
  RandomShape,
2572
2495
  ReducerComponent,
@@ -2609,6 +2532,7 @@ export {
2609
2532
  createComputeNode,
2610
2533
  createConstant,
2611
2534
  createDatabase,
2535
+ createFeed,
2612
2536
  createFunction,
2613
2537
  createFunctionAnchors,
2614
2538
  createGpt,
@@ -2619,7 +2543,6 @@ export {
2619
2543
  createJsonTransform,
2620
2544
  createNot,
2621
2545
  createOr,
2622
- createQueue,
2623
2546
  createRandom,
2624
2547
  createReducer,
2625
2548
  createScope,
@@ -2633,6 +2556,7 @@ export {
2633
2556
  createThread,
2634
2557
  createTrigger,
2635
2558
  databaseShape,
2559
+ feedShape,
2636
2560
  footerHeight,
2637
2561
  functionShape,
2638
2562
  getHeight,
@@ -2649,7 +2573,6 @@ export {
2649
2573
  notShape,
2650
2574
  orShape,
2651
2575
  parseAnchorId,
2652
- queueShape,
2653
2576
  randomShape,
2654
2577
  reducerShape,
2655
2578
  resolveComputeNode,