@dxos/react-ui-canvas-compute 0.8.4-main.4a85c3132b → 0.8.4-main.51f1e5ca51
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.
- package/dist/lib/browser/index.mjs +381 -458
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +381 -458
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/DiagnosticOverlay.d.ts.map +1 -1
- package/dist/types/src/compute-layout.d.ts.map +1 -1
- package/dist/types/src/compute.stories.d.ts +1 -1
- package/dist/types/src/compute.stories.d.ts.map +1 -1
- package/dist/types/src/graph/controller.d.ts +32 -27
- package/dist/types/src/graph/controller.d.ts.map +1 -1
- package/dist/types/src/graph/node-defs.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeGraphController.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeNodeState.d.ts +2 -3
- package/dist/types/src/hooks/useComputeNodeState.d.ts.map +1 -1
- package/dist/types/src/hooks/useGraphMonitor.d.ts.map +1 -1
- package/dist/types/src/shapes/Append.d.ts +1 -1
- package/dist/types/src/shapes/Append.d.ts.map +1 -1
- package/dist/types/src/shapes/Array.d.ts +1 -1
- package/dist/types/src/shapes/Array.d.ts.map +1 -1
- package/dist/types/src/shapes/Audio.d.ts +1 -1
- package/dist/types/src/shapes/Audio.d.ts.map +1 -1
- package/dist/types/src/shapes/Beacon.d.ts +1 -1
- package/dist/types/src/shapes/Beacon.d.ts.map +1 -1
- package/dist/types/src/shapes/Boolean.d.ts +7 -7
- package/dist/types/src/shapes/Boolean.d.ts.map +1 -1
- package/dist/types/src/shapes/Chat.d.ts +1 -1
- package/dist/types/src/shapes/Chat.d.ts.map +1 -1
- package/dist/types/src/shapes/Constant.d.ts +1 -1
- package/dist/types/src/shapes/Constant.d.ts.map +1 -1
- package/dist/types/src/shapes/Database.d.ts +1 -1
- package/dist/types/src/shapes/Database.d.ts.map +1 -1
- package/dist/types/src/shapes/{Queue.d.ts → Feed.d.ts} +9 -9
- package/dist/types/src/shapes/Feed.d.ts.map +1 -0
- package/dist/types/src/shapes/Function.d.ts +1 -1
- package/dist/types/src/shapes/Function.d.ts.map +1 -1
- package/dist/types/src/shapes/Gpt.d.ts +1 -1
- package/dist/types/src/shapes/Gpt.d.ts.map +1 -1
- package/dist/types/src/shapes/GptRealtime.d.ts +1 -1
- package/dist/types/src/shapes/GptRealtime.d.ts.map +1 -1
- package/dist/types/src/shapes/Json.d.ts +2 -2
- package/dist/types/src/shapes/Json.d.ts.map +1 -1
- package/dist/types/src/shapes/Logic.d.ts +2 -2
- package/dist/types/src/shapes/Logic.d.ts.map +1 -1
- package/dist/types/src/shapes/RNG.d.ts +2 -2
- package/dist/types/src/shapes/RNG.d.ts.map +1 -1
- package/dist/types/src/shapes/Scope.d.ts +1 -1
- package/dist/types/src/shapes/Scope.d.ts.map +1 -1
- package/dist/types/src/shapes/Surface.d.ts +1 -1
- package/dist/types/src/shapes/Surface.d.ts.map +1 -1
- package/dist/types/src/shapes/Switch.d.ts +1 -1
- package/dist/types/src/shapes/Switch.d.ts.map +1 -1
- package/dist/types/src/shapes/Table.d.ts +1 -1
- package/dist/types/src/shapes/Table.d.ts.map +1 -1
- package/dist/types/src/shapes/Template.d.ts +2 -2
- package/dist/types/src/shapes/Template.d.ts.map +1 -1
- package/dist/types/src/shapes/Text.d.ts +1 -1
- package/dist/types/src/shapes/Text.d.ts.map +1 -1
- package/dist/types/src/shapes/TextToImage.d.ts +1 -1
- package/dist/types/src/shapes/TextToImage.d.ts.map +1 -1
- package/dist/types/src/shapes/Thread.d.ts +1 -1
- package/dist/types/src/shapes/Thread.d.ts.map +1 -1
- package/dist/types/src/shapes/Trigger.d.ts +2 -2
- package/dist/types/src/shapes/Trigger.d.ts.map +1 -1
- package/dist/types/src/shapes/common/Box.d.ts.map +1 -1
- package/dist/types/src/shapes/common/FunctionBody.d.ts.map +1 -1
- package/dist/types/src/shapes/common/TypeSelect.d.ts +1 -1
- package/dist/types/src/shapes/common/TypeSelect.d.ts.map +1 -1
- package/dist/types/src/shapes/defs.d.ts +1 -1
- package/dist/types/src/shapes/defs.d.ts.map +1 -1
- package/dist/types/src/shapes/index.d.ts +2 -2
- package/dist/types/src/shapes/index.d.ts.map +1 -1
- package/dist/types/src/testing/circuits.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +44 -47
- package/src/compute.stories.tsx +25 -9
- package/src/graph/controller.ts +52 -22
- package/src/hooks/useComputeNodeState.ts +3 -5
- package/src/hooks/useGraphMonitor.ts +3 -3
- package/src/registry.ts +2 -2
- package/src/shapes/Audio.tsx +1 -2
- package/src/shapes/Beacon.tsx +0 -1
- package/src/shapes/Boolean.tsx +1 -1
- package/src/shapes/Chat.tsx +0 -1
- package/src/shapes/Constant.tsx +0 -1
- package/src/shapes/{Queue.tsx → Feed.tsx} +13 -14
- package/src/shapes/Function.tsx +3 -3
- package/src/shapes/Gpt.tsx +0 -1
- package/src/shapes/Json.tsx +9 -3
- package/src/shapes/RNG.tsx +0 -1
- package/src/shapes/Scope.tsx +0 -1
- package/src/shapes/Surface.tsx +4 -2
- package/src/shapes/Switch.tsx +0 -1
- package/src/shapes/Template.tsx +0 -1
- package/src/shapes/Text.tsx +0 -1
- package/src/shapes/Trigger.tsx +12 -17
- package/src/shapes/common/Box.tsx +0 -2
- package/src/shapes/index.ts +2 -2
- package/src/testing/circuits.ts +2 -2
- 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 {
|
|
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
|
-
|
|
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
|
-
|
|
251
|
-
|
|
252
|
-
|
|
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) => {
|
|
@@ -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: 230,
|
|
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(
|
|
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(
|
|
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
|
-
|
|
485
|
+
_createTraceWriter() {
|
|
547
486
|
return {
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
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: 377,
|
|
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,15 +609,7 @@ 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
|
};
|
|
@@ -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(),
|
|
@@ -687,7 +645,6 @@ var Box = /* @__PURE__ */ forwardRef(({ children, classNames, shape, title, stat
|
|
|
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) => {
|
|
@@ -927,7 +884,7 @@ var AudioComponent = ({ shape }) => {
|
|
|
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-
|
|
887
|
+
active && "opacity-100 text-error-text"
|
|
931
888
|
],
|
|
932
889
|
size: 8,
|
|
933
890
|
onClick: () => setActive(!active)
|
|
@@ -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: "
|
|
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/
|
|
1312
|
+
// src/shapes/Feed.tsx
|
|
1356
1313
|
import * as Schema11 from "effect/Schema";
|
|
1357
|
-
import React12, {
|
|
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 =
|
|
1365
|
-
type:
|
|
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(
|
|
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__ */
|
|
1435
|
+
return /* @__PURE__ */ React13.createElement(Box, {
|
|
1413
1436
|
shape,
|
|
1414
1437
|
title: "Function",
|
|
1415
1438
|
onAction: handleAction
|
|
1416
|
-
}, /* @__PURE__ */
|
|
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
|
|
1436
|
-
import
|
|
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 =
|
|
1440
|
-
type:
|
|
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__ */
|
|
1508
|
+
return /* @__PURE__ */ React14.createElement(FunctionBody, {
|
|
1486
1509
|
shape,
|
|
1487
|
-
content: /* @__PURE__ */
|
|
1510
|
+
content: /* @__PURE__ */ React14.createElement(ScrollArea2.Root, {
|
|
1488
1511
|
orientation: "vertical",
|
|
1489
1512
|
thin: true
|
|
1490
|
-
}, /* @__PURE__ */
|
|
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
|
|
1508
|
-
import
|
|
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 {
|
|
1512
|
-
var JsonShape =
|
|
1513
|
-
type:
|
|
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 =
|
|
1516
|
-
type:
|
|
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__ */
|
|
1658
|
+
return /* @__PURE__ */ React16.createElement(Box, {
|
|
1523
1659
|
shape
|
|
1524
|
-
}, /* @__PURE__ */
|
|
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__ */
|
|
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__ */
|
|
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__ */
|
|
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
|
|
1580
|
-
import
|
|
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 =
|
|
1583
|
-
type:
|
|
1719
|
+
var IfShape = Schema16.extend(ComputeShape, Schema16.Struct({
|
|
1720
|
+
type: Schema16.Literal("if")
|
|
1584
1721
|
}));
|
|
1585
|
-
var IfElseShape =
|
|
1586
|
-
type:
|
|
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__ */
|
|
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__ */
|
|
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__ */
|
|
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__ */
|
|
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 px-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
|
|
1702
|
-
import
|
|
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
|
|
1776
|
+
import { Icon as Icon5 } from "@dxos/react-ui";
|
|
1705
1777
|
import { createAnchorMap as createAnchorMap7 } from "@dxos/react-ui-canvas-editor";
|
|
1706
|
-
var RandomShape =
|
|
1707
|
-
type:
|
|
1708
|
-
min:
|
|
1709
|
-
max:
|
|
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] =
|
|
1731
|
-
const [icon, setIcon] =
|
|
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__ */
|
|
1824
|
+
return /* @__PURE__ */ React18.createElement("div", {
|
|
1753
1825
|
className: "flex grow items-center justify-center"
|
|
1754
|
-
}, /* @__PURE__ */
|
|
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
|
|
1777
|
-
import
|
|
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 =
|
|
1782
|
-
type:
|
|
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__ */
|
|
1870
|
+
return /* @__PURE__ */ React19.createElement("div", {
|
|
1799
1871
|
className: "flex w-full justify-center items-center bg-black"
|
|
1800
|
-
}, /* @__PURE__ */
|
|
1872
|
+
}, /* @__PURE__ */ React19.createElement(Chaos, {
|
|
1801
1873
|
active,
|
|
1802
1874
|
getValue: getAverage,
|
|
1803
1875
|
options: {
|
|
@@ -1821,14 +1893,15 @@ var scopeShape = {
|
|
|
1821
1893
|
};
|
|
1822
1894
|
|
|
1823
1895
|
// src/shapes/Surface.tsx
|
|
1824
|
-
import * as
|
|
1825
|
-
import
|
|
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";
|
|
1828
1901
|
import { Card } from "@dxos/react-ui";
|
|
1829
1902
|
import { createAnchorMap as createAnchorMap9 } from "@dxos/react-ui-canvas-editor";
|
|
1830
|
-
var SurfaceShape =
|
|
1831
|
-
type:
|
|
1903
|
+
var SurfaceShape = Schema19.extend(ComputeShape, Schema19.Struct({
|
|
1904
|
+
type: Schema19.Literal("surface")
|
|
1832
1905
|
}));
|
|
1833
1906
|
var createSurface = (props) => createShape({
|
|
1834
1907
|
type: "surface",
|
|
@@ -1847,13 +1920,13 @@ var SurfaceComponent = ({ shape }) => {
|
|
|
1847
1920
|
runtime.evalNode();
|
|
1848
1921
|
}
|
|
1849
1922
|
};
|
|
1850
|
-
return /* @__PURE__ */
|
|
1923
|
+
return /* @__PURE__ */ React20.createElement(Box, {
|
|
1851
1924
|
shape,
|
|
1852
1925
|
onAction: handleAction
|
|
1853
|
-
}, /* @__PURE__ */
|
|
1854
|
-
|
|
1926
|
+
}, /* @__PURE__ */ React20.createElement(Card.Root, null, value !== null && /* @__PURE__ */ React20.createElement(Surface.Surface, {
|
|
1927
|
+
type: AppSurface.Card,
|
|
1855
1928
|
data: {
|
|
1856
|
-
value
|
|
1929
|
+
subject: value
|
|
1857
1930
|
},
|
|
1858
1931
|
limit: 1
|
|
1859
1932
|
})));
|
|
@@ -1874,13 +1947,13 @@ var surfaceShape = {
|
|
|
1874
1947
|
};
|
|
1875
1948
|
|
|
1876
1949
|
// src/shapes/Switch.tsx
|
|
1877
|
-
import * as
|
|
1878
|
-
import
|
|
1950
|
+
import * as Schema20 from "effect/Schema";
|
|
1951
|
+
import React21, { useEffect as useEffect6, useState as useState9 } from "react";
|
|
1879
1952
|
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT6 } from "@dxos/conductor";
|
|
1880
1953
|
import { Input as Input2 } from "@dxos/react-ui";
|
|
1881
1954
|
import { createAnchorMap as createAnchorMap10 } from "@dxos/react-ui-canvas-editor";
|
|
1882
|
-
var SwitchShape =
|
|
1883
|
-
type:
|
|
1955
|
+
var SwitchShape = Schema20.extend(ComputeShape, Schema20.Struct({
|
|
1956
|
+
type: Schema20.Literal("switch")
|
|
1884
1957
|
}));
|
|
1885
1958
|
var createSwitch = (props) => createShape({
|
|
1886
1959
|
type: "switch",
|
|
@@ -1892,16 +1965,16 @@ var createSwitch = (props) => createShape({
|
|
|
1892
1965
|
});
|
|
1893
1966
|
var SwitchComponent = ({ shape }) => {
|
|
1894
1967
|
const { runtime } = useComputeNodeState(shape);
|
|
1895
|
-
const [value, setValue] =
|
|
1968
|
+
const [value, setValue] = useState9(false);
|
|
1896
1969
|
useEffect6(() => {
|
|
1897
1970
|
runtime.setOutput(DEFAULT_OUTPUT6, value);
|
|
1898
1971
|
}, [
|
|
1899
1972
|
value
|
|
1900
1973
|
]);
|
|
1901
|
-
return /* @__PURE__ */
|
|
1974
|
+
return /* @__PURE__ */ React21.createElement("div", {
|
|
1902
1975
|
className: "flex w-full justify-center items-center",
|
|
1903
1976
|
onClick: (ev) => ev.stopPropagation()
|
|
1904
|
-
}, /* @__PURE__ */
|
|
1977
|
+
}, /* @__PURE__ */ React21.createElement(Input2.Root, null, /* @__PURE__ */ React21.createElement(Input2.Switch, {
|
|
1905
1978
|
checked: value,
|
|
1906
1979
|
onCheckedChange: (value2) => setValue(value2)
|
|
1907
1980
|
})));
|
|
@@ -1921,14 +1994,14 @@ var switchShape = {
|
|
|
1921
1994
|
};
|
|
1922
1995
|
|
|
1923
1996
|
// src/shapes/Table.tsx
|
|
1924
|
-
import * as
|
|
1925
|
-
import
|
|
1997
|
+
import * as Schema21 from "effect/Schema";
|
|
1998
|
+
import React22 from "react";
|
|
1926
1999
|
import { createInputSchema, createOutputSchema } from "@dxos/conductor";
|
|
1927
2000
|
import { Message } from "@dxos/types";
|
|
1928
2001
|
var InputSchema = createInputSchema(Message.Message);
|
|
1929
|
-
var OutputSchema = createOutputSchema(
|
|
1930
|
-
var TableShape =
|
|
1931
|
-
type:
|
|
2002
|
+
var OutputSchema = createOutputSchema(Schema21.mutable(Schema21.Array(Message.Message)));
|
|
2003
|
+
var TableShape = Schema21.extend(ComputeShape, Schema21.Struct({
|
|
2004
|
+
type: Schema21.Literal("table")
|
|
1932
2005
|
}));
|
|
1933
2006
|
var createTable = (props) => createShape({
|
|
1934
2007
|
type: "table",
|
|
@@ -1939,7 +2012,7 @@ var createTable = (props) => createShape({
|
|
|
1939
2012
|
...props
|
|
1940
2013
|
});
|
|
1941
2014
|
var TableComponent = ({ shape }) => {
|
|
1942
|
-
return /* @__PURE__ */
|
|
2015
|
+
return /* @__PURE__ */ React22.createElement(Box, {
|
|
1943
2016
|
shape
|
|
1944
2017
|
});
|
|
1945
2018
|
};
|
|
@@ -1954,16 +2027,16 @@ var tableShape = {
|
|
|
1954
2027
|
};
|
|
1955
2028
|
|
|
1956
2029
|
// src/shapes/Template.tsx
|
|
1957
|
-
import * as
|
|
1958
|
-
import
|
|
2030
|
+
import * as Schema22 from "effect/Schema";
|
|
2031
|
+
import React23, { useRef as useRef5 } from "react";
|
|
1959
2032
|
import { ComputeValueType as ComputeValueType3, TemplateOutput, VoidInput as VoidInput2, getTemplateInputSchema as getTemplateInputSchema2 } from "@dxos/conductor";
|
|
1960
2033
|
import { toJsonSchema } from "@dxos/echo/internal";
|
|
1961
2034
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
1962
2035
|
import { TextBox as TextBox4 } from "@dxos/react-ui-canvas-editor";
|
|
1963
|
-
var
|
|
1964
|
-
var TemplateShape =
|
|
1965
|
-
type:
|
|
1966
|
-
valueType:
|
|
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)
|
|
1967
2040
|
}));
|
|
1968
2041
|
var TextInputComponent3 = ({ shape, title, ...props }) => {
|
|
1969
2042
|
const { node } = useComputeNodeState(shape);
|
|
@@ -1977,26 +2050,18 @@ var TextInputComponent3 = ({ shape, title, ...props }) => {
|
|
|
1977
2050
|
}
|
|
1978
2051
|
};
|
|
1979
2052
|
const handleTypeChange = (newType) => {
|
|
1980
|
-
invariant5(
|
|
1981
|
-
F: __dxlog_file6,
|
|
1982
|
-
L: 59,
|
|
1983
|
-
S: void 0,
|
|
1984
|
-
A: [
|
|
1985
|
-
"Schema.is(ComputeValueType)(newType)",
|
|
1986
|
-
"'Invalid type'"
|
|
1987
|
-
]
|
|
1988
|
-
});
|
|
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'"] });
|
|
1989
2054
|
node.valueType = newType;
|
|
1990
2055
|
node.inputSchema = toJsonSchema(getTemplateInputSchema2(node));
|
|
1991
2056
|
};
|
|
1992
|
-
return /* @__PURE__ */
|
|
2057
|
+
return /* @__PURE__ */ React23.createElement(Box, {
|
|
1993
2058
|
shape,
|
|
1994
2059
|
title: "Template",
|
|
1995
|
-
status: /* @__PURE__ */
|
|
2060
|
+
status: /* @__PURE__ */ React23.createElement(TypeSelect, {
|
|
1996
2061
|
value: node.valueType ?? "string",
|
|
1997
2062
|
onValueChange: handleTypeChange
|
|
1998
2063
|
})
|
|
1999
|
-
}, /* @__PURE__ */
|
|
2064
|
+
}, /* @__PURE__ */ React23.createElement(TextBox4, {
|
|
2000
2065
|
...props,
|
|
2001
2066
|
ref: inputRef,
|
|
2002
2067
|
value: node.value,
|
|
@@ -2017,7 +2082,7 @@ var templateShape = {
|
|
|
2017
2082
|
type: "template",
|
|
2018
2083
|
name: "Template",
|
|
2019
2084
|
icon: "ph--article--regular",
|
|
2020
|
-
component: (props) => /* @__PURE__ */
|
|
2085
|
+
component: (props) => /* @__PURE__ */ React23.createElement(TextInputComponent3, {
|
|
2021
2086
|
...props,
|
|
2022
2087
|
placeholder: "Prompt"
|
|
2023
2088
|
}),
|
|
@@ -2027,13 +2092,13 @@ var templateShape = {
|
|
|
2027
2092
|
};
|
|
2028
2093
|
|
|
2029
2094
|
// src/shapes/Text.tsx
|
|
2030
|
-
import * as
|
|
2031
|
-
import
|
|
2095
|
+
import * as Schema23 from "effect/Schema";
|
|
2096
|
+
import React24 from "react";
|
|
2032
2097
|
import { DEFAULT_INPUT as DEFAULT_INPUT7 } from "@dxos/conductor";
|
|
2033
2098
|
import { TextBox as TextBox5 } from "@dxos/react-ui-canvas-editor";
|
|
2034
2099
|
import { createAnchorMap as createAnchorMap11 } from "@dxos/react-ui-canvas-editor";
|
|
2035
|
-
var TextShape =
|
|
2036
|
-
type:
|
|
2100
|
+
var TextShape = Schema23.extend(ComputeShape, Schema23.Struct({
|
|
2101
|
+
type: Schema23.Literal("text")
|
|
2037
2102
|
}));
|
|
2038
2103
|
var createText = (props) => createShape({
|
|
2039
2104
|
type: "text",
|
|
@@ -2052,10 +2117,10 @@ var TextComponent = ({ shape }) => {
|
|
|
2052
2117
|
runtime.evalNode();
|
|
2053
2118
|
}
|
|
2054
2119
|
};
|
|
2055
|
-
return /* @__PURE__ */
|
|
2120
|
+
return /* @__PURE__ */ React24.createElement(Box, {
|
|
2056
2121
|
shape,
|
|
2057
2122
|
onAction: handleAction
|
|
2058
|
-
}, /* @__PURE__ */
|
|
2123
|
+
}, /* @__PURE__ */ React24.createElement(TextBox5, {
|
|
2059
2124
|
value
|
|
2060
2125
|
}));
|
|
2061
2126
|
};
|
|
@@ -2075,16 +2140,16 @@ var textShape = {
|
|
|
2075
2140
|
};
|
|
2076
2141
|
|
|
2077
2142
|
// src/shapes/Thread.tsx
|
|
2078
|
-
import * as
|
|
2079
|
-
import
|
|
2143
|
+
import * as Schema24 from "effect/Schema";
|
|
2144
|
+
import React25, { useEffect as useEffect7, useRef as useRef6 } from "react";
|
|
2080
2145
|
import { createInputSchema as createInputSchema2, createOutputSchema as createOutputSchema2 } from "@dxos/conductor";
|
|
2081
2146
|
import { ScrollArea as ScrollArea3 } from "@dxos/react-ui";
|
|
2082
2147
|
import { Message as Message2 } from "@dxos/types";
|
|
2083
2148
|
import { mx as mx3 } from "@dxos/ui-theme";
|
|
2084
2149
|
var InputSchema2 = createInputSchema2(Message2.Message);
|
|
2085
|
-
var OutputSchema2 = createOutputSchema2(
|
|
2086
|
-
var ThreadShape =
|
|
2087
|
-
type:
|
|
2150
|
+
var OutputSchema2 = createOutputSchema2(Schema24.mutable(Schema24.Array(Message2.Message)));
|
|
2151
|
+
var ThreadShape = Schema24.extend(ComputeShape, Schema24.Struct({
|
|
2152
|
+
type: Schema24.Literal("thread")
|
|
2088
2153
|
}));
|
|
2089
2154
|
var createThread = (props) => createShape({
|
|
2090
2155
|
type: "thread",
|
|
@@ -2104,31 +2169,31 @@ var ThreadComponent = ({ shape }) => {
|
|
|
2104
2169
|
}, [
|
|
2105
2170
|
items
|
|
2106
2171
|
]);
|
|
2107
|
-
return /* @__PURE__ */
|
|
2172
|
+
return /* @__PURE__ */ React25.createElement(Box, {
|
|
2108
2173
|
shape
|
|
2109
|
-
}, /* @__PURE__ */
|
|
2174
|
+
}, /* @__PURE__ */ React25.createElement(ScrollArea3.Root, {
|
|
2110
2175
|
orientation: "vertical"
|
|
2111
|
-
}, /* @__PURE__ */
|
|
2176
|
+
}, /* @__PURE__ */ React25.createElement(ScrollArea3.Viewport, {
|
|
2112
2177
|
classNames: "gap-2 p-2",
|
|
2113
2178
|
ref: scrollRef
|
|
2114
2179
|
}, [
|
|
2115
2180
|
...items
|
|
2116
|
-
].map((item, i) => /* @__PURE__ */
|
|
2181
|
+
].map((item, i) => /* @__PURE__ */ React25.createElement(ThreadItem, {
|
|
2117
2182
|
key: i,
|
|
2118
2183
|
item
|
|
2119
2184
|
})))));
|
|
2120
2185
|
};
|
|
2121
2186
|
var ThreadItem = ({ classNames, item }) => {
|
|
2122
2187
|
if (typeof item !== "object") {
|
|
2123
|
-
return /* @__PURE__ */
|
|
2188
|
+
return /* @__PURE__ */ React25.createElement("div", {
|
|
2124
2189
|
role: "none",
|
|
2125
2190
|
className: mx3(classNames)
|
|
2126
2191
|
}, item);
|
|
2127
2192
|
}
|
|
2128
2193
|
const { role, message } = item;
|
|
2129
|
-
return /* @__PURE__ */
|
|
2194
|
+
return /* @__PURE__ */ React25.createElement("div", {
|
|
2130
2195
|
className: mx3("flex", classNames, role === "user" && "justify-end")
|
|
2131
|
-
}, /* @__PURE__ */
|
|
2196
|
+
}, /* @__PURE__ */ React25.createElement("div", {
|
|
2132
2197
|
className: mx3("block rounded-md p-1 px-2 text-sm", role === "user" ? "bg-blue-100 dark:bg-blue-800" : role === "system" ? "bg-red-100, dark:bg-red-800" : "whitespace-pre-wrap bg-neutral-50 dark:bg-neutral-800")
|
|
2133
2198
|
}, message));
|
|
2134
2199
|
};
|
|
@@ -2143,11 +2208,11 @@ var threadShape = {
|
|
|
2143
2208
|
};
|
|
2144
2209
|
|
|
2145
2210
|
// src/shapes/TextToImage.tsx
|
|
2146
|
-
import * as
|
|
2147
|
-
import
|
|
2211
|
+
import * as Schema25 from "effect/Schema";
|
|
2212
|
+
import React26 from "react";
|
|
2148
2213
|
import { createAnchorMap as createAnchorMap12 } from "@dxos/react-ui-canvas-editor";
|
|
2149
|
-
var TextToImageShape =
|
|
2150
|
-
type:
|
|
2214
|
+
var TextToImageShape = Schema25.extend(ComputeShape, Schema25.Struct({
|
|
2215
|
+
type: Schema25.Literal("text-to-image")
|
|
2151
2216
|
}));
|
|
2152
2217
|
var createTextToImage = (props) => createShape({
|
|
2153
2218
|
type: "text-to-image",
|
|
@@ -2158,7 +2223,7 @@ var createTextToImage = (props) => createShape({
|
|
|
2158
2223
|
...props
|
|
2159
2224
|
});
|
|
2160
2225
|
var TextToImageComponent = ({ shape }) => {
|
|
2161
|
-
return /* @__PURE__ */
|
|
2226
|
+
return /* @__PURE__ */ React26.createElement(Box, {
|
|
2162
2227
|
shape
|
|
2163
2228
|
});
|
|
2164
2229
|
};
|
|
@@ -2177,17 +2242,17 @@ var textToImageShape = {
|
|
|
2177
2242
|
};
|
|
2178
2243
|
|
|
2179
2244
|
// src/shapes/Trigger.tsx
|
|
2180
|
-
import * as
|
|
2181
|
-
import
|
|
2245
|
+
import * as Schema26 from "effect/Schema";
|
|
2246
|
+
import React27, { useEffect as useEffect8 } from "react";
|
|
2247
|
+
import { Trigger, TriggerEvent } from "@dxos/compute";
|
|
2182
2248
|
import { VoidInput as VoidInput3 } from "@dxos/conductor";
|
|
2183
2249
|
import { Filter as Filter2, Obj as Obj4, Query, Ref as Ref3 } from "@dxos/echo";
|
|
2184
|
-
import { Trigger, TriggerEvent } from "@dxos/functions";
|
|
2185
2250
|
import { DXN, SpaceId } from "@dxos/keys";
|
|
2186
|
-
import {
|
|
2251
|
+
import { useSpaces } from "@dxos/react-client/echo";
|
|
2187
2252
|
import { Select as Select2 } from "@dxos/react-ui";
|
|
2188
|
-
var TriggerShape =
|
|
2189
|
-
type:
|
|
2190
|
-
functionTrigger:
|
|
2253
|
+
var TriggerShape = Schema26.extend(ComputeShape, Schema26.Struct({
|
|
2254
|
+
type: Schema26.Literal("trigger"),
|
|
2255
|
+
functionTrigger: Schema26.optional(Ref3.Ref(Trigger.Trigger))
|
|
2191
2256
|
}));
|
|
2192
2257
|
var createTrigger = (props) => {
|
|
2193
2258
|
const functionTrigger = Trigger.make({
|
|
@@ -2205,12 +2270,12 @@ var createTrigger = (props) => {
|
|
|
2205
2270
|
});
|
|
2206
2271
|
};
|
|
2207
2272
|
var TriggerComponent = ({ shape }) => {
|
|
2208
|
-
const space =
|
|
2273
|
+
const [space] = useSpaces();
|
|
2209
2274
|
const functionTrigger = shape.functionTrigger?.target;
|
|
2210
2275
|
useEffect8(() => {
|
|
2211
2276
|
if (functionTrigger && !functionTrigger.spec) {
|
|
2212
|
-
Obj4.
|
|
2213
|
-
|
|
2277
|
+
Obj4.update(functionTrigger, (functionTrigger2) => {
|
|
2278
|
+
functionTrigger2.spec = createTriggerSpec({
|
|
2214
2279
|
triggerKind: "email",
|
|
2215
2280
|
spaceId: space?.id
|
|
2216
2281
|
});
|
|
@@ -2227,8 +2292,8 @@ var TriggerComponent = ({ shape }) => {
|
|
|
2227
2292
|
]);
|
|
2228
2293
|
const setKind = (kind) => {
|
|
2229
2294
|
if (functionTrigger?.spec?.kind !== kind) {
|
|
2230
|
-
Obj4.
|
|
2231
|
-
|
|
2295
|
+
Obj4.update(functionTrigger, (obj) => {
|
|
2296
|
+
obj.spec = createTriggerSpec({
|
|
2232
2297
|
triggerKind: kind,
|
|
2233
2298
|
spaceId: space?.id
|
|
2234
2299
|
});
|
|
@@ -2238,9 +2303,9 @@ var TriggerComponent = ({ shape }) => {
|
|
|
2238
2303
|
if (!functionTrigger?.spec) {
|
|
2239
2304
|
return;
|
|
2240
2305
|
}
|
|
2241
|
-
return /* @__PURE__ */
|
|
2306
|
+
return /* @__PURE__ */ React27.createElement(FunctionBody, {
|
|
2242
2307
|
shape,
|
|
2243
|
-
status: /* @__PURE__ */
|
|
2308
|
+
status: /* @__PURE__ */ React27.createElement(TriggerKindSelect, {
|
|
2244
2309
|
value: functionTrigger.spec?.kind,
|
|
2245
2310
|
onValueChange: (kind) => setKind(kind)
|
|
2246
2311
|
}),
|
|
@@ -2249,51 +2314,37 @@ var TriggerComponent = ({ shape }) => {
|
|
|
2249
2314
|
});
|
|
2250
2315
|
};
|
|
2251
2316
|
var TriggerKindSelect = ({ value, onValueChange }) => {
|
|
2252
|
-
return /* @__PURE__ */
|
|
2317
|
+
return /* @__PURE__ */ React27.createElement(Select2.Root, {
|
|
2253
2318
|
value,
|
|
2254
2319
|
onValueChange
|
|
2255
|
-
}, /* @__PURE__ */
|
|
2320
|
+
}, /* @__PURE__ */ React27.createElement(Select2.TriggerButton, {
|
|
2256
2321
|
variant: "ghost",
|
|
2257
2322
|
classNames: "w-full px-0!"
|
|
2258
|
-
}), /* @__PURE__ */
|
|
2323
|
+
}), /* @__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, {
|
|
2259
2324
|
key: kind,
|
|
2260
2325
|
value: kind
|
|
2261
|
-
}, kind))), /* @__PURE__ */
|
|
2326
|
+
}, kind))), /* @__PURE__ */ React27.createElement(Select2.ScrollDownButton, null), /* @__PURE__ */ React27.createElement(Select2.Arrow, null))));
|
|
2262
2327
|
};
|
|
2263
2328
|
var createTriggerSpec = (props) => {
|
|
2264
2329
|
const kind = props.triggerKind ?? "email";
|
|
2265
2330
|
switch (kind) {
|
|
2266
2331
|
case "timer":
|
|
2267
|
-
return
|
|
2268
|
-
kind: "timer",
|
|
2269
|
-
cron: "*/10 * * * * *"
|
|
2270
|
-
};
|
|
2332
|
+
return Trigger.specTimer("*/10 * * * * *");
|
|
2271
2333
|
case "webhook":
|
|
2272
|
-
return {
|
|
2273
|
-
kind: "webhook",
|
|
2334
|
+
return Trigger.specWebhook({
|
|
2274
2335
|
method: "POST"
|
|
2275
|
-
};
|
|
2336
|
+
});
|
|
2276
2337
|
case "subscription":
|
|
2277
|
-
return
|
|
2278
|
-
kind: "subscription",
|
|
2279
|
-
query: {
|
|
2280
|
-
ast: Query.select(Filter2.nothing()).ast
|
|
2281
|
-
}
|
|
2282
|
-
};
|
|
2338
|
+
return Trigger.specSubscription(Query.select(Filter2.nothing()));
|
|
2283
2339
|
case "email":
|
|
2284
|
-
return
|
|
2285
|
-
kind: "email"
|
|
2286
|
-
};
|
|
2340
|
+
return Trigger.specEmail();
|
|
2287
2341
|
case "queue": {
|
|
2288
2342
|
const dxn = new DXN(DXN.kind.QUEUE, [
|
|
2289
2343
|
"data",
|
|
2290
2344
|
props.spaceId ?? SpaceId.random(),
|
|
2291
2345
|
Obj4.ID.random()
|
|
2292
2346
|
]).toString();
|
|
2293
|
-
return
|
|
2294
|
-
kind: "queue",
|
|
2295
|
-
queue: dxn
|
|
2296
|
-
};
|
|
2347
|
+
return Trigger.specQueue(dxn);
|
|
2297
2348
|
}
|
|
2298
2349
|
}
|
|
2299
2350
|
};
|
|
@@ -2316,134 +2367,6 @@ var triggerShape = {
|
|
|
2316
2367
|
getAnchors: (shape) => createFunctionAnchors(shape, VoidInput3, getOutputSchema(shape.functionTrigger?.target?.spec?.kind ?? "email"))
|
|
2317
2368
|
};
|
|
2318
2369
|
|
|
2319
|
-
// src/shapes/GptRealtime.tsx
|
|
2320
|
-
import * as Schema26 from "effect/Schema";
|
|
2321
|
-
import React27, { useState as useState9 } from "react";
|
|
2322
|
-
import { log as log2 } from "@dxos/log";
|
|
2323
|
-
import { useConfig } from "@dxos/react-client";
|
|
2324
|
-
import { Icon as Icon5 } from "@dxos/react-ui";
|
|
2325
|
-
var __dxlog_file7 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/GptRealtime.tsx";
|
|
2326
|
-
var GptRealtimeShape = Schema26.extend(ComputeShape, Schema26.Struct({
|
|
2327
|
-
type: Schema26.Literal("gpt-realtime")
|
|
2328
|
-
}));
|
|
2329
|
-
var createGptRealtime = (props) => createShape({
|
|
2330
|
-
type: "gpt-realtime",
|
|
2331
|
-
size: {
|
|
2332
|
-
width: 256,
|
|
2333
|
-
height: 256
|
|
2334
|
-
},
|
|
2335
|
-
...props
|
|
2336
|
-
});
|
|
2337
|
-
var GptRealtimeComponent = ({ shape }) => {
|
|
2338
|
-
const [isLive, setIsLive] = useState9(false);
|
|
2339
|
-
const [isReady, setIsReady] = useState9(false);
|
|
2340
|
-
const config = useConfig();
|
|
2341
|
-
const start = async () => {
|
|
2342
|
-
setIsLive(true);
|
|
2343
|
-
try {
|
|
2344
|
-
const peerConnection = new RTCPeerConnection();
|
|
2345
|
-
peerConnection.ontrack = (event) => {
|
|
2346
|
-
const audioElement = document.createElement("audio");
|
|
2347
|
-
audioElement.srcObject = event.streams[0];
|
|
2348
|
-
audioElement.autoplay = true;
|
|
2349
|
-
audioElement.controls = false;
|
|
2350
|
-
audioElement.style.display = "none";
|
|
2351
|
-
document.body.appendChild(audioElement);
|
|
2352
|
-
setIsReady(true);
|
|
2353
|
-
};
|
|
2354
|
-
const stream = await navigator.mediaDevices.getUserMedia({
|
|
2355
|
-
audio: true
|
|
2356
|
-
});
|
|
2357
|
-
stream.getTracks().forEach((track) => peerConnection.addTransceiver(track, {
|
|
2358
|
-
direction: "sendrecv"
|
|
2359
|
-
}));
|
|
2360
|
-
const offer = await peerConnection.createOffer();
|
|
2361
|
-
await peerConnection.setLocalDescription(offer);
|
|
2362
|
-
const AiServiceUrl = new URL("/rtc-connect", config.values.runtime?.services?.ai?.server ?? DEFAULT_AI_SERVICE_URL);
|
|
2363
|
-
const response = await fetch(AiServiceUrl, {
|
|
2364
|
-
method: "POST",
|
|
2365
|
-
body: offer.sdp,
|
|
2366
|
-
headers: {
|
|
2367
|
-
"Content-Type": "application/sdp"
|
|
2368
|
-
}
|
|
2369
|
-
});
|
|
2370
|
-
const answer = await response.text();
|
|
2371
|
-
await peerConnection.setRemoteDescription({
|
|
2372
|
-
sdp: answer,
|
|
2373
|
-
type: "answer"
|
|
2374
|
-
});
|
|
2375
|
-
const dataChannel = peerConnection.createDataChannel("response");
|
|
2376
|
-
const configureData = () => {
|
|
2377
|
-
log2.info("Configuring data channel", void 0, {
|
|
2378
|
-
F: __dxlog_file7,
|
|
2379
|
-
L: 87,
|
|
2380
|
-
S: void 0,
|
|
2381
|
-
C: (f, a) => f(...a)
|
|
2382
|
-
});
|
|
2383
|
-
const event = {
|
|
2384
|
-
type: "session.update",
|
|
2385
|
-
session: {
|
|
2386
|
-
modalities: [
|
|
2387
|
-
"text",
|
|
2388
|
-
"audio"
|
|
2389
|
-
],
|
|
2390
|
-
// Provide the tools. Note they match the keys in the `fns` object above
|
|
2391
|
-
tools: []
|
|
2392
|
-
}
|
|
2393
|
-
};
|
|
2394
|
-
dataChannel.send(JSON.stringify(event));
|
|
2395
|
-
};
|
|
2396
|
-
dataChannel.addEventListener("open", (ev) => {
|
|
2397
|
-
log2.info("Opening data channel", {
|
|
2398
|
-
ev
|
|
2399
|
-
}, {
|
|
2400
|
-
F: __dxlog_file7,
|
|
2401
|
-
L: 100,
|
|
2402
|
-
S: void 0,
|
|
2403
|
-
C: (f, a) => f(...a)
|
|
2404
|
-
});
|
|
2405
|
-
configureData();
|
|
2406
|
-
});
|
|
2407
|
-
dataChannel.addEventListener("message", async (ev) => {
|
|
2408
|
-
const msg = JSON.parse(ev.data);
|
|
2409
|
-
if (msg.type === "response.function_call_arguments.done") {
|
|
2410
|
-
}
|
|
2411
|
-
});
|
|
2412
|
-
} catch (error) {
|
|
2413
|
-
log2.error("Error in realtime session:", {
|
|
2414
|
-
error
|
|
2415
|
-
}, {
|
|
2416
|
-
F: __dxlog_file7,
|
|
2417
|
-
L: 140,
|
|
2418
|
-
S: void 0,
|
|
2419
|
-
C: (f, a) => f(...a)
|
|
2420
|
-
});
|
|
2421
|
-
throw error;
|
|
2422
|
-
}
|
|
2423
|
-
};
|
|
2424
|
-
return /* @__PURE__ */ React27.createElement("div", {
|
|
2425
|
-
className: "flex w-full justify-center items-center"
|
|
2426
|
-
}, /* @__PURE__ */ React27.createElement(Icon5, {
|
|
2427
|
-
icon: isReady ? "ph--waveform--regular" : isLive ? "ph--pulse--regular" : "ph--play--regular",
|
|
2428
|
-
size: 16,
|
|
2429
|
-
classNames: !isLive && "cursor-pointer",
|
|
2430
|
-
onClick: start
|
|
2431
|
-
}));
|
|
2432
|
-
};
|
|
2433
|
-
var gptRealtimeShape = {
|
|
2434
|
-
type: "gpt-realtime",
|
|
2435
|
-
name: "GPT Realtime",
|
|
2436
|
-
icon: "ph--pulse--regular",
|
|
2437
|
-
component: GptRealtimeComponent,
|
|
2438
|
-
createShape: createGptRealtime,
|
|
2439
|
-
// TODO(dmaretskyi): Can we fetch the schema dynamically?
|
|
2440
|
-
getAnchors: (shape) => createFunctionAnchors(shape, Schema26.Struct({
|
|
2441
|
-
audio: Schema26.Any
|
|
2442
|
-
}), Schema26.Struct({})),
|
|
2443
|
-
resizable: true
|
|
2444
|
-
};
|
|
2445
|
-
var DEFAULT_AI_SERVICE_URL = "http://localhost:8788";
|
|
2446
|
-
|
|
2447
2370
|
// src/registry.ts
|
|
2448
2371
|
var computeShapes = [
|
|
2449
2372
|
{
|
|
@@ -2489,7 +2412,7 @@ var computeShapes = [
|
|
|
2489
2412
|
shapes: [
|
|
2490
2413
|
//
|
|
2491
2414
|
jsonShape,
|
|
2492
|
-
|
|
2415
|
+
feedShape,
|
|
2493
2416
|
threadShape,
|
|
2494
2417
|
textShape,
|
|
2495
2418
|
surfaceShape,
|
|
@@ -2548,6 +2471,9 @@ export {
|
|
|
2548
2471
|
ConstantShape,
|
|
2549
2472
|
DatabaseComponent,
|
|
2550
2473
|
DatabaseShape,
|
|
2474
|
+
FeedComponent,
|
|
2475
|
+
FeedItem,
|
|
2476
|
+
FeedShape,
|
|
2551
2477
|
FunctionBody,
|
|
2552
2478
|
FunctionShape,
|
|
2553
2479
|
GptComponent,
|
|
@@ -2565,9 +2491,6 @@ export {
|
|
|
2565
2491
|
JsonTransformShape,
|
|
2566
2492
|
NotShape,
|
|
2567
2493
|
OrShape,
|
|
2568
|
-
QueueComponent,
|
|
2569
|
-
QueueItem,
|
|
2570
|
-
QueueShape,
|
|
2571
2494
|
RandomComponent,
|
|
2572
2495
|
RandomShape,
|
|
2573
2496
|
ReducerComponent,
|
|
@@ -2610,6 +2533,7 @@ export {
|
|
|
2610
2533
|
createComputeNode,
|
|
2611
2534
|
createConstant,
|
|
2612
2535
|
createDatabase,
|
|
2536
|
+
createFeed,
|
|
2613
2537
|
createFunction,
|
|
2614
2538
|
createFunctionAnchors,
|
|
2615
2539
|
createGpt,
|
|
@@ -2620,7 +2544,6 @@ export {
|
|
|
2620
2544
|
createJsonTransform,
|
|
2621
2545
|
createNot,
|
|
2622
2546
|
createOr,
|
|
2623
|
-
createQueue,
|
|
2624
2547
|
createRandom,
|
|
2625
2548
|
createReducer,
|
|
2626
2549
|
createScope,
|
|
@@ -2634,6 +2557,7 @@ export {
|
|
|
2634
2557
|
createThread,
|
|
2635
2558
|
createTrigger,
|
|
2636
2559
|
databaseShape,
|
|
2560
|
+
feedShape,
|
|
2637
2561
|
footerHeight,
|
|
2638
2562
|
functionShape,
|
|
2639
2563
|
getHeight,
|
|
@@ -2650,7 +2574,6 @@ export {
|
|
|
2650
2574
|
notShape,
|
|
2651
2575
|
orShape,
|
|
2652
2576
|
parseAnchorId,
|
|
2653
|
-
queueShape,
|
|
2654
2577
|
randomShape,
|
|
2655
2578
|
reducerShape,
|
|
2656
2579
|
resolveComputeNode,
|