@dxos/react-ui-canvas-compute 0.8.4-main.4a85c3132b → 0.8.4-main.4f23b4e393
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 +383 -460
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +383 -460
- 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 +45 -47
- package/src/compute.stories.tsx +26 -10
- package/src/graph/controller.ts +53 -23
- 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 +5 -4
- 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/Thread.tsx +1 -5
- 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,84 @@ 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";
|
|
1383
|
+
import { Filter } from "@dxos/echo";
|
|
1359
1384
|
import { Ref as Ref2, getSnapshot, isInstanceOf } from "@dxos/echo/internal";
|
|
1360
|
-
import {
|
|
1385
|
+
import { parseId } from "@dxos/keys";
|
|
1361
1386
|
import { useClient } from "@dxos/react-client";
|
|
1362
|
-
import { Filter, parseId } from "@dxos/react-client/echo";
|
|
1363
1387
|
import { TextBox as TextBox3 } from "@dxos/react-ui-canvas-editor";
|
|
1364
|
-
var FunctionShape =
|
|
1365
|
-
type:
|
|
1388
|
+
var FunctionShape = Schema12.extend(ComputeShape, Schema12.Struct({
|
|
1389
|
+
type: Schema12.Literal("function")
|
|
1366
1390
|
}));
|
|
1367
1391
|
var createFunction = (props) => createShape({
|
|
1368
1392
|
type: "function",
|
|
@@ -1387,7 +1411,7 @@ var TextInputComponent2 = ({ shape, title, ...props }) => {
|
|
|
1387
1411
|
if (!space || !isInstanceOf(Script.Script, object)) {
|
|
1388
1412
|
return;
|
|
1389
1413
|
}
|
|
1390
|
-
const [fn] = await space.db.query(Filter.type(
|
|
1414
|
+
const [fn] = await space.db.query(Filter.type(Operation.PersistentOperation, {
|
|
1391
1415
|
source: Ref2.make(object)
|
|
1392
1416
|
})).run();
|
|
1393
1417
|
if (!fn) {
|
|
@@ -1409,11 +1433,11 @@ var TextInputComponent2 = ({ shape, title, ...props }) => {
|
|
|
1409
1433
|
}, [
|
|
1410
1434
|
runtime
|
|
1411
1435
|
]);
|
|
1412
|
-
return /* @__PURE__ */
|
|
1436
|
+
return /* @__PURE__ */ React13.createElement(Box, {
|
|
1413
1437
|
shape,
|
|
1414
1438
|
title: "Function",
|
|
1415
1439
|
onAction: handleAction
|
|
1416
|
-
}, /* @__PURE__ */
|
|
1440
|
+
}, /* @__PURE__ */ React13.createElement(TextBox3, {
|
|
1417
1441
|
...props,
|
|
1418
1442
|
ref: inputRef,
|
|
1419
1443
|
value: node.value,
|
|
@@ -1432,12 +1456,12 @@ var functionShape = {
|
|
|
1432
1456
|
};
|
|
1433
1457
|
|
|
1434
1458
|
// src/shapes/Gpt.tsx
|
|
1435
|
-
import * as
|
|
1436
|
-
import
|
|
1459
|
+
import * as Schema13 from "effect/Schema";
|
|
1460
|
+
import React14, { useEffect as useEffect4, useState as useState6 } from "react";
|
|
1437
1461
|
import { GptInput, GptOutput } from "@dxos/conductor";
|
|
1438
|
-
import { ScrollArea } from "@dxos/react-ui";
|
|
1439
|
-
var GptShape =
|
|
1440
|
-
type:
|
|
1462
|
+
import { ScrollArea as ScrollArea2 } from "@dxos/react-ui";
|
|
1463
|
+
var GptShape = Schema13.extend(ComputeShape, Schema13.Struct({
|
|
1464
|
+
type: Schema13.Literal("gpt")
|
|
1441
1465
|
}));
|
|
1442
1466
|
var createGpt = (props) => createShape({
|
|
1443
1467
|
type: "gpt",
|
|
@@ -1482,12 +1506,12 @@ var GptComponent = ({ shape }) => {
|
|
|
1482
1506
|
}, [
|
|
1483
1507
|
runtime?.subscribeToEventLog
|
|
1484
1508
|
]);
|
|
1485
|
-
return /* @__PURE__ */
|
|
1509
|
+
return /* @__PURE__ */ React14.createElement(FunctionBody, {
|
|
1486
1510
|
shape,
|
|
1487
|
-
content: /* @__PURE__ */
|
|
1511
|
+
content: /* @__PURE__ */ React14.createElement(ScrollArea2.Root, {
|
|
1488
1512
|
orientation: "vertical",
|
|
1489
1513
|
thin: true
|
|
1490
|
-
}, /* @__PURE__ */
|
|
1514
|
+
}, /* @__PURE__ */ React14.createElement(ScrollArea2.Viewport, null, text)),
|
|
1491
1515
|
status: `${tokens} tokens`,
|
|
1492
1516
|
inputSchema: meta.input,
|
|
1493
1517
|
outputSchema: meta.output
|
|
@@ -1503,31 +1527,145 @@ var gptShape = {
|
|
|
1503
1527
|
openable: true
|
|
1504
1528
|
};
|
|
1505
1529
|
|
|
1530
|
+
// src/shapes/GptRealtime.tsx
|
|
1531
|
+
import * as Schema14 from "effect/Schema";
|
|
1532
|
+
import React15, { useState as useState7 } from "react";
|
|
1533
|
+
import { log as log2 } from "@dxos/log";
|
|
1534
|
+
import { useConfig } from "@dxos/react-client";
|
|
1535
|
+
import { Icon as Icon4 } from "@dxos/react-ui";
|
|
1536
|
+
var __dxlog_file6 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/GptRealtime.tsx";
|
|
1537
|
+
var GptRealtimeShape = Schema14.extend(ComputeShape, Schema14.Struct({
|
|
1538
|
+
type: Schema14.Literal("gpt-realtime")
|
|
1539
|
+
}));
|
|
1540
|
+
var createGptRealtime = (props) => createShape({
|
|
1541
|
+
type: "gpt-realtime",
|
|
1542
|
+
size: {
|
|
1543
|
+
width: 256,
|
|
1544
|
+
height: 256
|
|
1545
|
+
},
|
|
1546
|
+
...props
|
|
1547
|
+
});
|
|
1548
|
+
var GptRealtimeComponent = ({ shape }) => {
|
|
1549
|
+
const [isLive, setIsLive] = useState7(false);
|
|
1550
|
+
const [isReady, setIsReady] = useState7(false);
|
|
1551
|
+
const config = useConfig();
|
|
1552
|
+
const start = async () => {
|
|
1553
|
+
setIsLive(true);
|
|
1554
|
+
try {
|
|
1555
|
+
const peerConnection = new RTCPeerConnection();
|
|
1556
|
+
peerConnection.ontrack = (event) => {
|
|
1557
|
+
const audioElement = document.createElement("audio");
|
|
1558
|
+
audioElement.srcObject = event.streams[0];
|
|
1559
|
+
audioElement.autoplay = true;
|
|
1560
|
+
audioElement.controls = false;
|
|
1561
|
+
audioElement.style.display = "none";
|
|
1562
|
+
document.body.appendChild(audioElement);
|
|
1563
|
+
setIsReady(true);
|
|
1564
|
+
};
|
|
1565
|
+
const stream = await navigator.mediaDevices.getUserMedia({
|
|
1566
|
+
audio: true
|
|
1567
|
+
});
|
|
1568
|
+
stream.getTracks().forEach((track) => peerConnection.addTransceiver(track, {
|
|
1569
|
+
direction: "sendrecv"
|
|
1570
|
+
}));
|
|
1571
|
+
const offer = await peerConnection.createOffer();
|
|
1572
|
+
await peerConnection.setLocalDescription(offer);
|
|
1573
|
+
const AiServiceUrl = new URL("/rtc-connect", config.values.runtime?.services?.ai?.server ?? DEFAULT_AI_SERVICE_URL);
|
|
1574
|
+
const response = await fetch(AiServiceUrl, {
|
|
1575
|
+
method: "POST",
|
|
1576
|
+
body: offer.sdp,
|
|
1577
|
+
headers: {
|
|
1578
|
+
"Content-Type": "application/sdp"
|
|
1579
|
+
}
|
|
1580
|
+
});
|
|
1581
|
+
const answer = await response.text();
|
|
1582
|
+
await peerConnection.setRemoteDescription({
|
|
1583
|
+
sdp: answer,
|
|
1584
|
+
type: "answer"
|
|
1585
|
+
});
|
|
1586
|
+
const dataChannel = peerConnection.createDataChannel("response");
|
|
1587
|
+
const configureData = () => {
|
|
1588
|
+
log2.info("Configuring data channel", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 69, S: void 0 });
|
|
1589
|
+
const event = {
|
|
1590
|
+
type: "session.update",
|
|
1591
|
+
session: {
|
|
1592
|
+
modalities: [
|
|
1593
|
+
"text",
|
|
1594
|
+
"audio"
|
|
1595
|
+
],
|
|
1596
|
+
// Provide the tools. Note they match the keys in the `fns` object above
|
|
1597
|
+
tools: []
|
|
1598
|
+
}
|
|
1599
|
+
};
|
|
1600
|
+
dataChannel.send(JSON.stringify(event));
|
|
1601
|
+
};
|
|
1602
|
+
dataChannel.addEventListener("open", (ev) => {
|
|
1603
|
+
log2.info("Opening data channel", {
|
|
1604
|
+
ev
|
|
1605
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 84, S: void 0 });
|
|
1606
|
+
configureData();
|
|
1607
|
+
});
|
|
1608
|
+
dataChannel.addEventListener("message", async (ev) => {
|
|
1609
|
+
const msg = JSON.parse(ev.data);
|
|
1610
|
+
if (msg.type === "response.function_call_arguments.done") {
|
|
1611
|
+
}
|
|
1612
|
+
});
|
|
1613
|
+
} catch (error) {
|
|
1614
|
+
log2.error("Error in realtime session:", {
|
|
1615
|
+
error
|
|
1616
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 124, S: void 0 });
|
|
1617
|
+
throw error;
|
|
1618
|
+
}
|
|
1619
|
+
};
|
|
1620
|
+
return /* @__PURE__ */ React15.createElement("div", {
|
|
1621
|
+
className: "flex w-full justify-center items-center"
|
|
1622
|
+
}, /* @__PURE__ */ React15.createElement(Icon4, {
|
|
1623
|
+
icon: isReady ? "ph--waveform--regular" : isLive ? "ph--pulse--regular" : "ph--play--regular",
|
|
1624
|
+
size: 16,
|
|
1625
|
+
classNames: !isLive && "cursor-pointer",
|
|
1626
|
+
onClick: start
|
|
1627
|
+
}));
|
|
1628
|
+
};
|
|
1629
|
+
var gptRealtimeShape = {
|
|
1630
|
+
type: "gpt-realtime",
|
|
1631
|
+
name: "GPT Realtime",
|
|
1632
|
+
icon: "ph--pulse--regular",
|
|
1633
|
+
component: GptRealtimeComponent,
|
|
1634
|
+
createShape: createGptRealtime,
|
|
1635
|
+
// TODO(dmaretskyi): Can we fetch the schema dynamically?
|
|
1636
|
+
getAnchors: (shape) => createFunctionAnchors(shape, Schema14.Struct({
|
|
1637
|
+
audio: Schema14.Any
|
|
1638
|
+
}), Schema14.Struct({})),
|
|
1639
|
+
resizable: true
|
|
1640
|
+
};
|
|
1641
|
+
var DEFAULT_AI_SERVICE_URL = "http://localhost:8788";
|
|
1642
|
+
|
|
1506
1643
|
// src/shapes/Json.tsx
|
|
1507
|
-
import * as
|
|
1508
|
-
import
|
|
1644
|
+
import * as Schema15 from "effect/Schema";
|
|
1645
|
+
import React16 from "react";
|
|
1509
1646
|
import { DEFAULT_INPUT as DEFAULT_INPUT4, DefaultOutput, JsonTransformInput } from "@dxos/conductor";
|
|
1510
1647
|
import { createAnchorMap as createAnchorMap6 } from "@dxos/react-ui-canvas-editor";
|
|
1511
|
-
import {
|
|
1512
|
-
var JsonShape =
|
|
1513
|
-
type:
|
|
1648
|
+
import { Syntax } from "@dxos/react-ui-syntax-highlighter";
|
|
1649
|
+
var JsonShape = Schema15.extend(ComputeShape, Schema15.Struct({
|
|
1650
|
+
type: Schema15.Literal("json")
|
|
1514
1651
|
}));
|
|
1515
|
-
var JsonTransformShape =
|
|
1516
|
-
type:
|
|
1652
|
+
var JsonTransformShape = Schema15.extend(ComputeShape, Schema15.Struct({
|
|
1653
|
+
type: Schema15.Literal("json-transform")
|
|
1517
1654
|
}));
|
|
1518
1655
|
var JsonComponent = ({ shape, ...props }) => {
|
|
1519
1656
|
const { runtime } = useComputeNodeState(shape);
|
|
1520
1657
|
const input = runtime.inputs[DEFAULT_INPUT4];
|
|
1521
1658
|
const value = input?.type === "executed" ? input.value : void 0;
|
|
1522
|
-
return /* @__PURE__ */
|
|
1659
|
+
return /* @__PURE__ */ React16.createElement(Box, {
|
|
1523
1660
|
shape
|
|
1524
|
-
}, /* @__PURE__ */
|
|
1525
|
-
data: value
|
|
1661
|
+
}, /* @__PURE__ */ React16.createElement(Syntax.Root, {
|
|
1662
|
+
data: value
|
|
1663
|
+
}, /* @__PURE__ */ React16.createElement(Syntax.Content, null, /* @__PURE__ */ React16.createElement(Syntax.Filter, null), /* @__PURE__ */ React16.createElement(Syntax.Viewport, null, /* @__PURE__ */ React16.createElement(Syntax.Code, {
|
|
1526
1664
|
classNames: "text-xs"
|
|
1527
|
-
}));
|
|
1665
|
+
})))));
|
|
1528
1666
|
};
|
|
1529
1667
|
var JsonTransformComponent = ({ shape, ...props }) => {
|
|
1530
|
-
return /* @__PURE__ */
|
|
1668
|
+
return /* @__PURE__ */ React16.createElement(Box, {
|
|
1531
1669
|
shape
|
|
1532
1670
|
});
|
|
1533
1671
|
};
|
|
@@ -1543,7 +1681,7 @@ var jsonShape = {
|
|
|
1543
1681
|
type: "json",
|
|
1544
1682
|
name: "JSON",
|
|
1545
1683
|
icon: "ph--code--regular",
|
|
1546
|
-
component: (props) => /* @__PURE__ */
|
|
1684
|
+
component: (props) => /* @__PURE__ */ React16.createElement(JsonComponent, props),
|
|
1547
1685
|
createShape: createJson,
|
|
1548
1686
|
getAnchors: (shape) => createAnchorMap6(shape, {
|
|
1549
1687
|
[createAnchorId("input")]: {
|
|
@@ -1569,31 +1707,31 @@ var jsonTransformShape = {
|
|
|
1569
1707
|
type: "json-transform",
|
|
1570
1708
|
name: "Transform",
|
|
1571
1709
|
icon: "ph--shuffle-simple--regular",
|
|
1572
|
-
component: (props) => /* @__PURE__ */
|
|
1710
|
+
component: (props) => /* @__PURE__ */ React16.createElement(JsonTransformComponent, props),
|
|
1573
1711
|
createShape: createJsonTransform,
|
|
1574
1712
|
getAnchors: (shape) => createFunctionAnchors(shape, JsonTransformInput, DefaultOutput),
|
|
1575
1713
|
resizable: true
|
|
1576
1714
|
};
|
|
1577
1715
|
|
|
1578
1716
|
// src/shapes/Logic.tsx
|
|
1579
|
-
import * as
|
|
1580
|
-
import
|
|
1717
|
+
import * as Schema16 from "effect/Schema";
|
|
1718
|
+
import React17 from "react";
|
|
1581
1719
|
import { IfElseInput, IfElseOutput, IfInput, IfOutput } from "@dxos/conductor";
|
|
1582
|
-
var IfShape =
|
|
1583
|
-
type:
|
|
1720
|
+
var IfShape = Schema16.extend(ComputeShape, Schema16.Struct({
|
|
1721
|
+
type: Schema16.Literal("if")
|
|
1584
1722
|
}));
|
|
1585
|
-
var IfElseShape =
|
|
1586
|
-
type:
|
|
1723
|
+
var IfElseShape = Schema16.extend(ComputeShape, Schema16.Struct({
|
|
1724
|
+
type: Schema16.Literal("if-else")
|
|
1587
1725
|
}));
|
|
1588
1726
|
var IfComponent = ({ shape, ...props }) => {
|
|
1589
|
-
return /* @__PURE__ */
|
|
1727
|
+
return /* @__PURE__ */ React17.createElement(FunctionBody, {
|
|
1590
1728
|
shape,
|
|
1591
1729
|
inputSchema: IfInput,
|
|
1592
1730
|
outputSchema: IfOutput
|
|
1593
1731
|
});
|
|
1594
1732
|
};
|
|
1595
1733
|
var IfElseComponent = ({ shape, ...props }) => {
|
|
1596
|
-
return /* @__PURE__ */
|
|
1734
|
+
return /* @__PURE__ */ React17.createElement(FunctionBody, {
|
|
1597
1735
|
shape,
|
|
1598
1736
|
inputSchema: IfElseInput,
|
|
1599
1737
|
outputSchema: IfElseOutput
|
|
@@ -1611,7 +1749,7 @@ var ifShape = {
|
|
|
1611
1749
|
type: "if",
|
|
1612
1750
|
name: "IF",
|
|
1613
1751
|
icon: "ph--arrows-split--regular",
|
|
1614
|
-
component: (props) => /* @__PURE__ */
|
|
1752
|
+
component: (props) => /* @__PURE__ */ React17.createElement(IfComponent, props),
|
|
1615
1753
|
createShape: createIf,
|
|
1616
1754
|
getAnchors: (shape) => createFunctionAnchors(shape, IfInput, IfOutput)
|
|
1617
1755
|
};
|
|
@@ -1627,86 +1765,21 @@ var ifElseShape = {
|
|
|
1627
1765
|
type: "if-else",
|
|
1628
1766
|
name: "IF/ELSE",
|
|
1629
1767
|
icon: "ph--arrows-merge--regular",
|
|
1630
|
-
component: (props) => /* @__PURE__ */
|
|
1768
|
+
component: (props) => /* @__PURE__ */ React17.createElement(IfElseComponent, props),
|
|
1631
1769
|
createShape: createIfElse,
|
|
1632
1770
|
getAnchors: (shape) => createFunctionAnchors(shape, IfElseInput, IfElseOutput)
|
|
1633
1771
|
};
|
|
1634
1772
|
|
|
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
1773
|
// src/shapes/RNG.tsx
|
|
1701
|
-
import * as
|
|
1702
|
-
import
|
|
1774
|
+
import * as Schema17 from "effect/Schema";
|
|
1775
|
+
import React18, { useEffect as useEffect5, useState as useState8 } from "react";
|
|
1703
1776
|
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT5 } from "@dxos/conductor";
|
|
1704
|
-
import { Icon as
|
|
1777
|
+
import { Icon as Icon5 } from "@dxos/react-ui";
|
|
1705
1778
|
import { createAnchorMap as createAnchorMap7 } from "@dxos/react-ui-canvas-editor";
|
|
1706
|
-
var RandomShape =
|
|
1707
|
-
type:
|
|
1708
|
-
min:
|
|
1709
|
-
max:
|
|
1779
|
+
var RandomShape = Schema17.extend(ComputeShape, Schema17.Struct({
|
|
1780
|
+
type: Schema17.Literal("rng"),
|
|
1781
|
+
min: Schema17.optional(Schema17.Number),
|
|
1782
|
+
max: Schema17.optional(Schema17.Number)
|
|
1710
1783
|
}));
|
|
1711
1784
|
var createRandom = (props) => createShape({
|
|
1712
1785
|
type: "rng",
|
|
@@ -1727,8 +1800,8 @@ var icons = [
|
|
|
1727
1800
|
var pickIcon = () => icons[Math.floor(Math.random() * icons.length)];
|
|
1728
1801
|
var RandomComponent = ({ shape }) => {
|
|
1729
1802
|
const { runtime } = useComputeNodeState(shape);
|
|
1730
|
-
const [spin, setSpin] =
|
|
1731
|
-
const [icon, setIcon] =
|
|
1803
|
+
const [spin, setSpin] = useState8(false);
|
|
1804
|
+
const [icon, setIcon] = useState8(pickIcon());
|
|
1732
1805
|
useEffect5(() => {
|
|
1733
1806
|
if (!spin) {
|
|
1734
1807
|
return;
|
|
@@ -1749,9 +1822,9 @@ var RandomComponent = ({ shape }) => {
|
|
|
1749
1822
|
runtime.setOutput(DEFAULT_OUTPUT5, Math.random());
|
|
1750
1823
|
setSpin(true);
|
|
1751
1824
|
};
|
|
1752
|
-
return /* @__PURE__ */
|
|
1825
|
+
return /* @__PURE__ */ React18.createElement("div", {
|
|
1753
1826
|
className: "flex grow items-center justify-center"
|
|
1754
|
-
}, /* @__PURE__ */
|
|
1827
|
+
}, /* @__PURE__ */ React18.createElement(Icon5, {
|
|
1755
1828
|
icon,
|
|
1756
1829
|
classNames: spin && "animate-[spin_1s]",
|
|
1757
1830
|
size: 10,
|
|
@@ -1773,13 +1846,13 @@ var randomShape = {
|
|
|
1773
1846
|
};
|
|
1774
1847
|
|
|
1775
1848
|
// src/shapes/Scope.tsx
|
|
1776
|
-
import * as
|
|
1777
|
-
import
|
|
1849
|
+
import * as Schema18 from "effect/Schema";
|
|
1850
|
+
import React19 from "react";
|
|
1778
1851
|
import { DEFAULT_INPUT as DEFAULT_INPUT5 } from "@dxos/conductor";
|
|
1779
1852
|
import { createAnchorMap as createAnchorMap8 } from "@dxos/react-ui-canvas-editor";
|
|
1780
1853
|
import { Chaos, shaderPresets, useAudioStream } from "@dxos/react-ui-sfx";
|
|
1781
|
-
var ScopeShape =
|
|
1782
|
-
type:
|
|
1854
|
+
var ScopeShape = Schema18.extend(ComputeShape, Schema18.Struct({
|
|
1855
|
+
type: Schema18.Literal("scope")
|
|
1783
1856
|
}));
|
|
1784
1857
|
var createScope = (props) => createShape({
|
|
1785
1858
|
type: "scope",
|
|
@@ -1795,9 +1868,9 @@ var ScopeComponent = ({ shape }) => {
|
|
|
1795
1868
|
const input = runtime.inputs[DEFAULT_INPUT5];
|
|
1796
1869
|
const active = input?.type === "executed" ? input.value : false;
|
|
1797
1870
|
const { getAverage } = useAudioStream(active);
|
|
1798
|
-
return /* @__PURE__ */
|
|
1871
|
+
return /* @__PURE__ */ React19.createElement("div", {
|
|
1799
1872
|
className: "flex w-full justify-center items-center bg-black"
|
|
1800
|
-
}, /* @__PURE__ */
|
|
1873
|
+
}, /* @__PURE__ */ React19.createElement(Chaos, {
|
|
1801
1874
|
active,
|
|
1802
1875
|
getValue: getAverage,
|
|
1803
1876
|
options: {
|
|
@@ -1821,14 +1894,15 @@ var scopeShape = {
|
|
|
1821
1894
|
};
|
|
1822
1895
|
|
|
1823
1896
|
// src/shapes/Surface.tsx
|
|
1824
|
-
import * as
|
|
1825
|
-
import
|
|
1897
|
+
import * as Schema19 from "effect/Schema";
|
|
1898
|
+
import React20 from "react";
|
|
1826
1899
|
import { Surface } from "@dxos/app-framework/ui";
|
|
1900
|
+
import { AppSurface } from "@dxos/app-toolkit/ui";
|
|
1827
1901
|
import { DEFAULT_INPUT as DEFAULT_INPUT6 } from "@dxos/conductor";
|
|
1828
1902
|
import { Card } from "@dxos/react-ui";
|
|
1829
1903
|
import { createAnchorMap as createAnchorMap9 } from "@dxos/react-ui-canvas-editor";
|
|
1830
|
-
var SurfaceShape =
|
|
1831
|
-
type:
|
|
1904
|
+
var SurfaceShape = Schema19.extend(ComputeShape, Schema19.Struct({
|
|
1905
|
+
type: Schema19.Literal("surface")
|
|
1832
1906
|
}));
|
|
1833
1907
|
var createSurface = (props) => createShape({
|
|
1834
1908
|
type: "surface",
|
|
@@ -1847,13 +1921,13 @@ var SurfaceComponent = ({ shape }) => {
|
|
|
1847
1921
|
runtime.evalNode();
|
|
1848
1922
|
}
|
|
1849
1923
|
};
|
|
1850
|
-
return /* @__PURE__ */
|
|
1924
|
+
return /* @__PURE__ */ React20.createElement(Box, {
|
|
1851
1925
|
shape,
|
|
1852
1926
|
onAction: handleAction
|
|
1853
|
-
}, /* @__PURE__ */
|
|
1854
|
-
|
|
1927
|
+
}, /* @__PURE__ */ React20.createElement(Card.Root, null, value !== null && /* @__PURE__ */ React20.createElement(Surface.Surface, {
|
|
1928
|
+
type: AppSurface.Card,
|
|
1855
1929
|
data: {
|
|
1856
|
-
value
|
|
1930
|
+
subject: value
|
|
1857
1931
|
},
|
|
1858
1932
|
limit: 1
|
|
1859
1933
|
})));
|
|
@@ -1874,13 +1948,13 @@ var surfaceShape = {
|
|
|
1874
1948
|
};
|
|
1875
1949
|
|
|
1876
1950
|
// src/shapes/Switch.tsx
|
|
1877
|
-
import * as
|
|
1878
|
-
import
|
|
1951
|
+
import * as Schema20 from "effect/Schema";
|
|
1952
|
+
import React21, { useEffect as useEffect6, useState as useState9 } from "react";
|
|
1879
1953
|
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT6 } from "@dxos/conductor";
|
|
1880
1954
|
import { Input as Input2 } from "@dxos/react-ui";
|
|
1881
1955
|
import { createAnchorMap as createAnchorMap10 } from "@dxos/react-ui-canvas-editor";
|
|
1882
|
-
var SwitchShape =
|
|
1883
|
-
type:
|
|
1956
|
+
var SwitchShape = Schema20.extend(ComputeShape, Schema20.Struct({
|
|
1957
|
+
type: Schema20.Literal("switch")
|
|
1884
1958
|
}));
|
|
1885
1959
|
var createSwitch = (props) => createShape({
|
|
1886
1960
|
type: "switch",
|
|
@@ -1892,16 +1966,16 @@ var createSwitch = (props) => createShape({
|
|
|
1892
1966
|
});
|
|
1893
1967
|
var SwitchComponent = ({ shape }) => {
|
|
1894
1968
|
const { runtime } = useComputeNodeState(shape);
|
|
1895
|
-
const [value, setValue] =
|
|
1969
|
+
const [value, setValue] = useState9(false);
|
|
1896
1970
|
useEffect6(() => {
|
|
1897
1971
|
runtime.setOutput(DEFAULT_OUTPUT6, value);
|
|
1898
1972
|
}, [
|
|
1899
1973
|
value
|
|
1900
1974
|
]);
|
|
1901
|
-
return /* @__PURE__ */
|
|
1975
|
+
return /* @__PURE__ */ React21.createElement("div", {
|
|
1902
1976
|
className: "flex w-full justify-center items-center",
|
|
1903
1977
|
onClick: (ev) => ev.stopPropagation()
|
|
1904
|
-
}, /* @__PURE__ */
|
|
1978
|
+
}, /* @__PURE__ */ React21.createElement(Input2.Root, null, /* @__PURE__ */ React21.createElement(Input2.Switch, {
|
|
1905
1979
|
checked: value,
|
|
1906
1980
|
onCheckedChange: (value2) => setValue(value2)
|
|
1907
1981
|
})));
|
|
@@ -1921,14 +1995,14 @@ var switchShape = {
|
|
|
1921
1995
|
};
|
|
1922
1996
|
|
|
1923
1997
|
// src/shapes/Table.tsx
|
|
1924
|
-
import * as
|
|
1925
|
-
import
|
|
1998
|
+
import * as Schema21 from "effect/Schema";
|
|
1999
|
+
import React22 from "react";
|
|
1926
2000
|
import { createInputSchema, createOutputSchema } from "@dxos/conductor";
|
|
1927
2001
|
import { Message } from "@dxos/types";
|
|
1928
2002
|
var InputSchema = createInputSchema(Message.Message);
|
|
1929
|
-
var OutputSchema = createOutputSchema(
|
|
1930
|
-
var TableShape =
|
|
1931
|
-
type:
|
|
2003
|
+
var OutputSchema = createOutputSchema(Schema21.mutable(Schema21.Array(Message.Message)));
|
|
2004
|
+
var TableShape = Schema21.extend(ComputeShape, Schema21.Struct({
|
|
2005
|
+
type: Schema21.Literal("table")
|
|
1932
2006
|
}));
|
|
1933
2007
|
var createTable = (props) => createShape({
|
|
1934
2008
|
type: "table",
|
|
@@ -1939,7 +2013,7 @@ var createTable = (props) => createShape({
|
|
|
1939
2013
|
...props
|
|
1940
2014
|
});
|
|
1941
2015
|
var TableComponent = ({ shape }) => {
|
|
1942
|
-
return /* @__PURE__ */
|
|
2016
|
+
return /* @__PURE__ */ React22.createElement(Box, {
|
|
1943
2017
|
shape
|
|
1944
2018
|
});
|
|
1945
2019
|
};
|
|
@@ -1954,16 +2028,16 @@ var tableShape = {
|
|
|
1954
2028
|
};
|
|
1955
2029
|
|
|
1956
2030
|
// src/shapes/Template.tsx
|
|
1957
|
-
import * as
|
|
1958
|
-
import
|
|
2031
|
+
import * as Schema22 from "effect/Schema";
|
|
2032
|
+
import React23, { useRef as useRef5 } from "react";
|
|
1959
2033
|
import { ComputeValueType as ComputeValueType3, TemplateOutput, VoidInput as VoidInput2, getTemplateInputSchema as getTemplateInputSchema2 } from "@dxos/conductor";
|
|
1960
2034
|
import { toJsonSchema } from "@dxos/echo/internal";
|
|
1961
2035
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
1962
2036
|
import { TextBox as TextBox4 } from "@dxos/react-ui-canvas-editor";
|
|
1963
|
-
var
|
|
1964
|
-
var TemplateShape =
|
|
1965
|
-
type:
|
|
1966
|
-
valueType:
|
|
2037
|
+
var __dxlog_file7 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/Template.tsx";
|
|
2038
|
+
var TemplateShape = Schema22.extend(ComputeShape, Schema22.Struct({
|
|
2039
|
+
type: Schema22.Literal("template"),
|
|
2040
|
+
valueType: Schema22.optional(ComputeValueType3)
|
|
1967
2041
|
}));
|
|
1968
2042
|
var TextInputComponent3 = ({ shape, title, ...props }) => {
|
|
1969
2043
|
const { node } = useComputeNodeState(shape);
|
|
@@ -1977,26 +2051,18 @@ var TextInputComponent3 = ({ shape, title, ...props }) => {
|
|
|
1977
2051
|
}
|
|
1978
2052
|
};
|
|
1979
2053
|
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
|
-
});
|
|
2054
|
+
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
2055
|
node.valueType = newType;
|
|
1990
2056
|
node.inputSchema = toJsonSchema(getTemplateInputSchema2(node));
|
|
1991
2057
|
};
|
|
1992
|
-
return /* @__PURE__ */
|
|
2058
|
+
return /* @__PURE__ */ React23.createElement(Box, {
|
|
1993
2059
|
shape,
|
|
1994
2060
|
title: "Template",
|
|
1995
|
-
status: /* @__PURE__ */
|
|
2061
|
+
status: /* @__PURE__ */ React23.createElement(TypeSelect, {
|
|
1996
2062
|
value: node.valueType ?? "string",
|
|
1997
2063
|
onValueChange: handleTypeChange
|
|
1998
2064
|
})
|
|
1999
|
-
}, /* @__PURE__ */
|
|
2065
|
+
}, /* @__PURE__ */ React23.createElement(TextBox4, {
|
|
2000
2066
|
...props,
|
|
2001
2067
|
ref: inputRef,
|
|
2002
2068
|
value: node.value,
|
|
@@ -2017,7 +2083,7 @@ var templateShape = {
|
|
|
2017
2083
|
type: "template",
|
|
2018
2084
|
name: "Template",
|
|
2019
2085
|
icon: "ph--article--regular",
|
|
2020
|
-
component: (props) => /* @__PURE__ */
|
|
2086
|
+
component: (props) => /* @__PURE__ */ React23.createElement(TextInputComponent3, {
|
|
2021
2087
|
...props,
|
|
2022
2088
|
placeholder: "Prompt"
|
|
2023
2089
|
}),
|
|
@@ -2027,13 +2093,13 @@ var templateShape = {
|
|
|
2027
2093
|
};
|
|
2028
2094
|
|
|
2029
2095
|
// src/shapes/Text.tsx
|
|
2030
|
-
import * as
|
|
2031
|
-
import
|
|
2096
|
+
import * as Schema23 from "effect/Schema";
|
|
2097
|
+
import React24 from "react";
|
|
2032
2098
|
import { DEFAULT_INPUT as DEFAULT_INPUT7 } from "@dxos/conductor";
|
|
2033
2099
|
import { TextBox as TextBox5 } from "@dxos/react-ui-canvas-editor";
|
|
2034
2100
|
import { createAnchorMap as createAnchorMap11 } from "@dxos/react-ui-canvas-editor";
|
|
2035
|
-
var TextShape =
|
|
2036
|
-
type:
|
|
2101
|
+
var TextShape = Schema23.extend(ComputeShape, Schema23.Struct({
|
|
2102
|
+
type: Schema23.Literal("text")
|
|
2037
2103
|
}));
|
|
2038
2104
|
var createText = (props) => createShape({
|
|
2039
2105
|
type: "text",
|
|
@@ -2052,10 +2118,10 @@ var TextComponent = ({ shape }) => {
|
|
|
2052
2118
|
runtime.evalNode();
|
|
2053
2119
|
}
|
|
2054
2120
|
};
|
|
2055
|
-
return /* @__PURE__ */
|
|
2121
|
+
return /* @__PURE__ */ React24.createElement(Box, {
|
|
2056
2122
|
shape,
|
|
2057
2123
|
onAction: handleAction
|
|
2058
|
-
}, /* @__PURE__ */
|
|
2124
|
+
}, /* @__PURE__ */ React24.createElement(TextBox5, {
|
|
2059
2125
|
value
|
|
2060
2126
|
}));
|
|
2061
2127
|
};
|
|
@@ -2075,16 +2141,16 @@ var textShape = {
|
|
|
2075
2141
|
};
|
|
2076
2142
|
|
|
2077
2143
|
// src/shapes/Thread.tsx
|
|
2078
|
-
import * as
|
|
2079
|
-
import
|
|
2144
|
+
import * as Schema24 from "effect/Schema";
|
|
2145
|
+
import React25, { useEffect as useEffect7, useRef as useRef6 } from "react";
|
|
2080
2146
|
import { createInputSchema as createInputSchema2, createOutputSchema as createOutputSchema2 } from "@dxos/conductor";
|
|
2081
2147
|
import { ScrollArea as ScrollArea3 } from "@dxos/react-ui";
|
|
2082
2148
|
import { Message as Message2 } from "@dxos/types";
|
|
2083
2149
|
import { mx as mx3 } from "@dxos/ui-theme";
|
|
2084
2150
|
var InputSchema2 = createInputSchema2(Message2.Message);
|
|
2085
|
-
var OutputSchema2 = createOutputSchema2(
|
|
2086
|
-
var ThreadShape =
|
|
2087
|
-
type:
|
|
2151
|
+
var OutputSchema2 = createOutputSchema2(Schema24.mutable(Schema24.Array(Message2.Message)));
|
|
2152
|
+
var ThreadShape = Schema24.extend(ComputeShape, Schema24.Struct({
|
|
2153
|
+
type: Schema24.Literal("thread")
|
|
2088
2154
|
}));
|
|
2089
2155
|
var createThread = (props) => createShape({
|
|
2090
2156
|
type: "thread",
|
|
@@ -2104,31 +2170,30 @@ var ThreadComponent = ({ shape }) => {
|
|
|
2104
2170
|
}, [
|
|
2105
2171
|
items
|
|
2106
2172
|
]);
|
|
2107
|
-
return /* @__PURE__ */
|
|
2173
|
+
return /* @__PURE__ */ React25.createElement(Box, {
|
|
2108
2174
|
shape
|
|
2109
|
-
}, /* @__PURE__ */
|
|
2175
|
+
}, /* @__PURE__ */ React25.createElement(ScrollArea3.Root, {
|
|
2110
2176
|
orientation: "vertical"
|
|
2111
|
-
}, /* @__PURE__ */
|
|
2177
|
+
}, /* @__PURE__ */ React25.createElement(ScrollArea3.Viewport, {
|
|
2112
2178
|
classNames: "gap-2 p-2",
|
|
2113
2179
|
ref: scrollRef
|
|
2114
2180
|
}, [
|
|
2115
2181
|
...items
|
|
2116
|
-
].map((item, i) => /* @__PURE__ */
|
|
2182
|
+
].map((item, i) => /* @__PURE__ */ React25.createElement(ThreadItem, {
|
|
2117
2183
|
key: i,
|
|
2118
2184
|
item
|
|
2119
2185
|
})))));
|
|
2120
2186
|
};
|
|
2121
2187
|
var ThreadItem = ({ classNames, item }) => {
|
|
2122
2188
|
if (typeof item !== "object") {
|
|
2123
|
-
return /* @__PURE__ */
|
|
2124
|
-
role: "none",
|
|
2189
|
+
return /* @__PURE__ */ React25.createElement("div", {
|
|
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,
|