@dxos/react-ui-canvas-compute 0.8.4-main.1f223c7 → 0.8.4-main.2244d791bb
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 +788 -966
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +788 -966
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/compute.stories.d.ts +25 -2
- package/dist/types/src/compute.stories.d.ts.map +1 -1
- package/dist/types/src/graph/controller.d.ts +20 -33
- package/dist/types/src/graph/controller.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeGraphController.d.ts +1 -1
- package/dist/types/src/hooks/useComputeGraphController.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeNodeState.d.ts +2 -2
- package/dist/types/src/hooks/useComputeNodeState.d.ts.map +1 -1
- package/dist/types/src/hooks/useGraphMonitor.d.ts +2 -2
- package/dist/types/src/hooks/useGraphMonitor.d.ts.map +1 -1
- package/dist/types/src/json.test.d.ts +1 -1
- package/dist/types/src/json.test.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 +1 -1
- 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 +2 -2
- 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/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 +1 -1
- package/dist/types/src/shapes/Json.d.ts.map +1 -1
- package/dist/types/src/shapes/Logic.d.ts +1 -1
- package/dist/types/src/shapes/Logic.d.ts.map +1 -1
- package/dist/types/src/shapes/Queue.d.ts +1 -1
- package/dist/types/src/shapes/Queue.d.ts.map +1 -1
- package/dist/types/src/shapes/RNG.d.ts +1 -1
- 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 +1 -1
- 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 +6 -5
- package/dist/types/src/shapes/Trigger.d.ts.map +1 -1
- package/dist/types/src/shapes/common/Box.d.ts +4 -4
- package/dist/types/src/shapes/common/Box.d.ts.map +1 -1
- package/dist/types/src/shapes/common/FunctionBody.d.ts +3 -3
- package/dist/types/src/shapes/common/FunctionBody.d.ts.map +1 -1
- package/dist/types/src/shapes/defs.d.ts +2 -1
- package/dist/types/src/shapes/defs.d.ts.map +1 -1
- package/dist/types/src/testing/circuits.d.ts +18 -24
- package/dist/types/src/testing/circuits.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +56 -52
- package/src/compute-layout.ts +1 -1
- package/src/compute.stories.tsx +73 -117
- package/src/graph/controller.ts +114 -73
- package/src/graph/node-defs.ts +3 -3
- package/src/hooks/useComputeGraphController.ts +1 -1
- package/src/hooks/useComputeNodeState.ts +5 -4
- package/src/hooks/useGraphMonitor.ts +11 -10
- package/src/json.test.ts +4 -4
- package/src/schema.test.ts +12 -12
- package/src/shapes/Append.tsx +1 -1
- package/src/shapes/Array.tsx +1 -1
- package/src/shapes/Audio.tsx +2 -2
- package/src/shapes/Beacon.tsx +2 -2
- package/src/shapes/Boolean.tsx +3 -3
- package/src/shapes/Chat.tsx +1 -1
- package/src/shapes/Constant.tsx +1 -1
- package/src/shapes/Database.tsx +1 -1
- package/src/shapes/Function.tsx +12 -10
- package/src/shapes/Gpt.tsx +7 -2
- package/src/shapes/GptRealtime.tsx +2 -2
- package/src/shapes/Json.tsx +1 -1
- package/src/shapes/Logic.tsx +1 -1
- package/src/shapes/Queue.tsx +15 -9
- package/src/shapes/RNG.tsx +6 -2
- package/src/shapes/Scope.tsx +2 -2
- package/src/shapes/Surface.tsx +8 -4
- package/src/shapes/Switch.tsx +2 -2
- package/src/shapes/Table.tsx +4 -4
- package/src/shapes/Template.tsx +2 -2
- package/src/shapes/Text.tsx +1 -1
- package/src/shapes/TextToImage.tsx +1 -1
- package/src/shapes/Thread.tsx +19 -13
- package/src/shapes/Trigger.tsx +39 -44
- package/src/shapes/common/Box.tsx +8 -9
- package/src/shapes/common/FunctionBody.tsx +6 -5
- package/src/shapes/common/TypeSelect.tsx +1 -1
- package/src/shapes/defs.ts +5 -4
- package/src/testing/circuits.ts +5 -14
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import "@dxos/node-std/globals";
|
|
2
2
|
|
|
3
3
|
// src/graph/controller.ts
|
|
4
|
-
import
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Either from "effect/Either";
|
|
6
|
+
import * as Exit from "effect/Exit";
|
|
7
|
+
import * as Layer from "effect/Layer";
|
|
8
|
+
import * as Scope from "effect/Scope";
|
|
5
9
|
import { Event, synchronized } from "@dxos/async";
|
|
6
10
|
import { GraphExecutor, ValueBag, isNotExecuted } from "@dxos/conductor";
|
|
7
11
|
import { Resource } from "@dxos/context";
|
|
12
|
+
import { unwrapExit } from "@dxos/effect";
|
|
13
|
+
import { ComputeEventLogger, TracingService } from "@dxos/functions";
|
|
8
14
|
import { log } from "@dxos/log";
|
|
9
15
|
|
|
10
16
|
// src/hooks/compute-context.ts
|
|
@@ -66,7 +72,7 @@ var useComputeGraphController = ({ controller, graph, editorRef }) => {
|
|
|
66
72
|
};
|
|
67
73
|
|
|
68
74
|
// src/hooks/useComputeNodeState.ts
|
|
69
|
-
import
|
|
75
|
+
import * as Schema from "effect/Schema";
|
|
70
76
|
import { useCallback, useEffect as useEffect2, useState as useState2 } from "react";
|
|
71
77
|
import { invariant } from "@dxos/invariant";
|
|
72
78
|
var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/hooks/useComputeNodeState.ts";
|
|
@@ -142,9 +148,8 @@ var useComputeNodeState = (shape) => {
|
|
|
142
148
|
// src/hooks/useGraphMonitor.ts
|
|
143
149
|
import { useMemo } from "react";
|
|
144
150
|
import { ComputeGraphModel, DEFAULT_INPUT, DEFAULT_OUTPUT } from "@dxos/conductor";
|
|
145
|
-
import {
|
|
151
|
+
import { Obj, Ref } from "@dxos/echo";
|
|
146
152
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
147
|
-
import { getSpace } from "@dxos/react-client/echo";
|
|
148
153
|
import { isNonNullable } from "@dxos/util";
|
|
149
154
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/hooks/useGraphMonitor.ts";
|
|
150
155
|
var mapEdge = (graph, { source, target, output = DEFAULT_OUTPUT, input = DEFAULT_INPUT }) => {
|
|
@@ -152,7 +157,7 @@ var mapEdge = (graph, { source, target, output = DEFAULT_OUTPUT, input = DEFAULT
|
|
|
152
157
|
const targetNode = graph.findNode(target);
|
|
153
158
|
invariant2(sourceNode?.node, void 0, {
|
|
154
159
|
F: __dxlog_file2,
|
|
155
|
-
L:
|
|
160
|
+
L: 25,
|
|
156
161
|
S: void 0,
|
|
157
162
|
A: [
|
|
158
163
|
"sourceNode?.node",
|
|
@@ -161,7 +166,7 @@ var mapEdge = (graph, { source, target, output = DEFAULT_OUTPUT, input = DEFAULT
|
|
|
161
166
|
});
|
|
162
167
|
invariant2(targetNode?.node, void 0, {
|
|
163
168
|
F: __dxlog_file2,
|
|
164
|
-
L:
|
|
169
|
+
L: 26,
|
|
165
170
|
S: void 0,
|
|
166
171
|
A: [
|
|
167
172
|
"targetNode?.node",
|
|
@@ -169,7 +174,7 @@ var mapEdge = (graph, { source, target, output = DEFAULT_OUTPUT, input = DEFAULT
|
|
|
169
174
|
]
|
|
170
175
|
});
|
|
171
176
|
return {
|
|
172
|
-
id:
|
|
177
|
+
id: Obj.ID.random(),
|
|
173
178
|
source: sourceNode.node,
|
|
174
179
|
target: targetNode.node,
|
|
175
180
|
output,
|
|
@@ -185,7 +190,7 @@ var useGraphMonitor = (model) => {
|
|
|
185
190
|
}
|
|
186
191
|
invariant2(node.type, void 0, {
|
|
187
192
|
F: __dxlog_file2,
|
|
188
|
-
L:
|
|
193
|
+
L: 51,
|
|
189
194
|
S: void 0,
|
|
190
195
|
A: [
|
|
191
196
|
"node.type",
|
|
@@ -243,25 +248,27 @@ var linkTriggerToCompute = (graph, computeNode, triggerData) => {
|
|
|
243
248
|
const functionTrigger = triggerData.functionTrigger?.target;
|
|
244
249
|
invariant2(functionTrigger, void 0, {
|
|
245
250
|
F: __dxlog_file2,
|
|
246
|
-
L:
|
|
251
|
+
L: 114,
|
|
247
252
|
S: void 0,
|
|
248
253
|
A: [
|
|
249
254
|
"functionTrigger",
|
|
250
255
|
""
|
|
251
256
|
]
|
|
252
257
|
});
|
|
253
|
-
functionTrigger
|
|
254
|
-
|
|
258
|
+
Obj.change(functionTrigger, (t) => {
|
|
259
|
+
t.function = Ref.make(graph.root);
|
|
260
|
+
t.inputNodeId = computeNode.id;
|
|
261
|
+
});
|
|
255
262
|
};
|
|
256
263
|
var deleteTriggerObjects = (computeGraph, deleted) => {
|
|
257
|
-
const
|
|
258
|
-
if (!
|
|
264
|
+
const db = Obj.getDatabase(computeGraph.root);
|
|
265
|
+
if (!db) {
|
|
259
266
|
return;
|
|
260
267
|
}
|
|
261
268
|
for (const node of deleted.nodes) {
|
|
262
269
|
if (node.type === "trigger") {
|
|
263
270
|
const trigger = node;
|
|
264
|
-
|
|
271
|
+
db.remove(trigger.functionTrigger.target);
|
|
265
272
|
}
|
|
266
273
|
}
|
|
267
274
|
};
|
|
@@ -269,7 +276,7 @@ var deleteTriggerObjects = (computeGraph, deleted) => {
|
|
|
269
276
|
// src/graph/node-defs.ts
|
|
270
277
|
import { NODE_INPUT, NODE_OUTPUT, getTemplateInputSchema, registry } from "@dxos/conductor";
|
|
271
278
|
import { raise as raise2 } from "@dxos/debug";
|
|
272
|
-
import {
|
|
279
|
+
import { JsonSchema, Obj as Obj2 } from "@dxos/echo";
|
|
273
280
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
274
281
|
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/graph/node-defs.ts";
|
|
275
282
|
var resolveComputeNode = async (node) => {
|
|
@@ -329,7 +336,7 @@ var nodeFactory = {
|
|
|
329
336
|
valueType: shape.valueType,
|
|
330
337
|
value: shape.text
|
|
331
338
|
});
|
|
332
|
-
node.inputSchema = toJsonSchema(getTemplateInputSchema(node));
|
|
339
|
+
node.inputSchema = JsonSchema.toJsonSchema(getTemplateInputSchema(node));
|
|
333
340
|
return node;
|
|
334
341
|
},
|
|
335
342
|
["text"]: () => createNode("text"),
|
|
@@ -337,25 +344,12 @@ var nodeFactory = {
|
|
|
337
344
|
["trigger"]: () => createNode(NODE_INPUT)
|
|
338
345
|
};
|
|
339
346
|
var createNode = (type, props) => ({
|
|
340
|
-
id:
|
|
347
|
+
id: Obj2.ID.random(),
|
|
341
348
|
type,
|
|
342
349
|
...props
|
|
343
350
|
});
|
|
344
351
|
|
|
345
352
|
// src/graph/controller.ts
|
|
346
|
-
function _define_property(obj, key, value) {
|
|
347
|
-
if (key in obj) {
|
|
348
|
-
Object.defineProperty(obj, key, {
|
|
349
|
-
value,
|
|
350
|
-
enumerable: true,
|
|
351
|
-
configurable: true,
|
|
352
|
-
writable: true
|
|
353
|
-
});
|
|
354
|
-
} else {
|
|
355
|
-
obj[key] = value;
|
|
356
|
-
}
|
|
357
|
-
return obj;
|
|
358
|
-
}
|
|
359
353
|
function _ts_decorate(decorators, target, key, desc) {
|
|
360
354
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
361
355
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -369,15 +363,38 @@ var AUTO_TRIGGER_NODES = [
|
|
|
369
363
|
"switch",
|
|
370
364
|
"constant"
|
|
371
365
|
];
|
|
372
|
-
var createComputeGraphController = (graph,
|
|
366
|
+
var createComputeGraphController = (graph, computeRuntime) => {
|
|
373
367
|
const computeGraph = createComputeGraph(graph);
|
|
374
|
-
const controller = new ComputeGraphController(
|
|
368
|
+
const controller = new ComputeGraphController(computeRuntime, computeGraph);
|
|
375
369
|
return {
|
|
376
370
|
controller,
|
|
377
371
|
graph
|
|
378
372
|
};
|
|
379
373
|
};
|
|
380
374
|
var ComputeGraphController = class extends Resource {
|
|
375
|
+
_computeRuntime;
|
|
376
|
+
_graph;
|
|
377
|
+
_executor = new GraphExecutor({
|
|
378
|
+
computeNodeResolver: (node) => resolveComputeNode(node)
|
|
379
|
+
});
|
|
380
|
+
_diagnostics = [];
|
|
381
|
+
/**
|
|
382
|
+
* Canvas force-sets outputs of those nodes.
|
|
383
|
+
*/
|
|
384
|
+
_forcedOutputs = {};
|
|
385
|
+
/**
|
|
386
|
+
* Runtime state of the execution graph.
|
|
387
|
+
*/
|
|
388
|
+
_runtimeStateInputs = {};
|
|
389
|
+
_runtimeStateOutputs = {};
|
|
390
|
+
// TODO(burdon): Remove? Make state reactive?
|
|
391
|
+
update = new Event();
|
|
392
|
+
/** Computed result. */
|
|
393
|
+
output = new Event();
|
|
394
|
+
events = new Event();
|
|
395
|
+
constructor(_computeRuntime, _graph) {
|
|
396
|
+
super(), this._computeRuntime = _computeRuntime, this._graph = _graph;
|
|
397
|
+
}
|
|
381
398
|
toJSON() {
|
|
382
399
|
return {
|
|
383
400
|
graph: this._graph,
|
|
@@ -438,8 +455,7 @@ var ComputeGraphController = class extends Resource {
|
|
|
438
455
|
return this._runtimeStateOutputs[nodeId] ?? {};
|
|
439
456
|
}
|
|
440
457
|
setOutput(nodeId, property, value) {
|
|
441
|
-
|
|
442
|
-
(_this__forcedOutputs = this._forcedOutputs)[_nodeId = nodeId] ?? (_this__forcedOutputs[_nodeId] = {});
|
|
458
|
+
this._forcedOutputs[nodeId] ??= {};
|
|
443
459
|
this._forcedOutputs[nodeId][property] = value;
|
|
444
460
|
queueMicrotask(async () => {
|
|
445
461
|
try {
|
|
@@ -447,7 +463,7 @@ var ComputeGraphController = class extends Resource {
|
|
|
447
463
|
} catch (err) {
|
|
448
464
|
log.catch(err, void 0, {
|
|
449
465
|
F: __dxlog_file4,
|
|
450
|
-
L:
|
|
466
|
+
L: 229,
|
|
451
467
|
S: this,
|
|
452
468
|
C: (f, a) => f(...a)
|
|
453
469
|
});
|
|
@@ -469,12 +485,11 @@ var ComputeGraphController = class extends Resource {
|
|
|
469
485
|
for (const [nodeId2, outputs] of Object.entries(this._forcedOutputs)) {
|
|
470
486
|
executor.setOutputs(nodeId2, Effect.succeed(ValueBag.make(outputs)));
|
|
471
487
|
}
|
|
472
|
-
|
|
473
|
-
await Effect.runPromise(Effect.gen(this, function* () {
|
|
488
|
+
unwrapExit(await this._computeRuntime.runPromiseExit(Effect.gen(this, function* () {
|
|
474
489
|
const scope = yield* Scope.make();
|
|
475
490
|
const executable = yield* Effect.promise(() => resolveComputeNode(this._graph.getNode(nodeId)));
|
|
476
491
|
const computingOutputs = executable.exec != null;
|
|
477
|
-
const effect = (computingOutputs ? executor.computeOutputs(nodeId) : executor.computeInputs(nodeId)).pipe(Effect.withSpan("runGraph"), Scope.extend(scope), Effect.
|
|
492
|
+
const effect = (computingOutputs ? executor.computeOutputs(nodeId) : executor.computeInputs(nodeId)).pipe(Effect.withSpan("runGraph"), Scope.extend(scope), Effect.provide(ComputeEventLogger.layerFromTracing.pipe(Layer.provideMerge(TracingService.layerNoop))), Effect.flatMap(computeValueBag), Effect.withSpan("test"), Effect.tap((values) => {
|
|
478
493
|
for (const [key, value] of Object.entries(values)) {
|
|
479
494
|
if (computingOutputs) {
|
|
480
495
|
this._onOutputComputed(nodeId, key, value);
|
|
@@ -485,7 +500,7 @@ var ComputeGraphController = class extends Resource {
|
|
|
485
500
|
}));
|
|
486
501
|
yield* effect;
|
|
487
502
|
yield* Scope.close(scope, Exit.void);
|
|
488
|
-
}));
|
|
503
|
+
})));
|
|
489
504
|
this.update.emit();
|
|
490
505
|
}
|
|
491
506
|
/**
|
|
@@ -506,13 +521,13 @@ var ComputeGraphController = class extends Resource {
|
|
|
506
521
|
const allAffectedNodes = [
|
|
507
522
|
...new Set(triggerNodes.flatMap((node) => executor.getAllDependantNodes(node.id)))
|
|
508
523
|
];
|
|
509
|
-
await
|
|
524
|
+
unwrapExit(await this._computeRuntime.runPromiseExit(Effect.gen(this, function* () {
|
|
510
525
|
const scope = yield* Scope.make();
|
|
511
526
|
const tasks = [];
|
|
512
527
|
for (const node of allAffectedNodes) {
|
|
513
528
|
const executable = yield* Effect.promise(() => resolveComputeNode(this._graph.getNode(node)));
|
|
514
529
|
const computingOutputs = executable.exec != null;
|
|
515
|
-
const effect = (computingOutputs ? executor.computeOutputs(node) : executor.computeInputs(node)).pipe(Effect.withSpan("runGraph"), Scope.extend(scope), Effect.flatMap(computeValueBag), Effect.provide(
|
|
530
|
+
const effect = (computingOutputs ? executor.computeOutputs(node) : executor.computeInputs(node)).pipe(Effect.withSpan("runGraph"), Scope.extend(scope), Effect.flatMap(computeValueBag), Effect.provide(ComputeEventLogger.layerFromTracing.pipe(Layer.provideMerge(TracingService.layerNoop))), Effect.withSpan("test"), Effect.tap((values) => {
|
|
516
531
|
for (const [key, value] of Object.entries(values)) {
|
|
517
532
|
if (computingOutputs) {
|
|
518
533
|
this._onOutputComputed(node, key, value);
|
|
@@ -525,7 +540,7 @@ var ComputeGraphController = class extends Resource {
|
|
|
525
540
|
}
|
|
526
541
|
yield* Effect.all(tasks);
|
|
527
542
|
yield* Scope.close(scope, Exit.void);
|
|
528
|
-
}));
|
|
543
|
+
})));
|
|
529
544
|
this.update.emit();
|
|
530
545
|
}
|
|
531
546
|
_createLogger() {
|
|
@@ -541,7 +556,7 @@ var ComputeGraphController = class extends Resource {
|
|
|
541
556
|
event
|
|
542
557
|
}, {
|
|
543
558
|
F: __dxlog_file4,
|
|
544
|
-
L:
|
|
559
|
+
L: 376,
|
|
545
560
|
S: this,
|
|
546
561
|
C: (f, a) => f(...a)
|
|
547
562
|
});
|
|
@@ -564,13 +579,11 @@ var ComputeGraphController = class extends Resource {
|
|
|
564
579
|
this.events.emit(event);
|
|
565
580
|
}
|
|
566
581
|
_onInputComputed(nodeId, property, value) {
|
|
567
|
-
|
|
568
|
-
(_this__runtimeStateInputs = this._runtimeStateInputs)[_nodeId = nodeId] ?? (_this__runtimeStateInputs[_nodeId] = {});
|
|
582
|
+
this._runtimeStateInputs[nodeId] ??= {};
|
|
569
583
|
this._runtimeStateInputs[nodeId][property] = value;
|
|
570
584
|
}
|
|
571
585
|
_onOutputComputed(nodeId, property, value) {
|
|
572
|
-
|
|
573
|
-
(_this__runtimeStateOutputs = this._runtimeStateOutputs)[_nodeId = nodeId] ?? (_this__runtimeStateOutputs[_nodeId] = {});
|
|
586
|
+
this._runtimeStateOutputs[nodeId] ??= {};
|
|
574
587
|
this._runtimeStateOutputs[nodeId][property] = value;
|
|
575
588
|
this.output.emit({
|
|
576
589
|
nodeId,
|
|
@@ -578,19 +591,6 @@ var ComputeGraphController = class extends Resource {
|
|
|
578
591
|
value
|
|
579
592
|
});
|
|
580
593
|
}
|
|
581
|
-
constructor(_serviceContainer, _graph) {
|
|
582
|
-
super(), _define_property(this, "_serviceContainer", void 0), _define_property(this, "_graph", void 0), _define_property(this, "_executor", void 0), _define_property(this, "_diagnostics", void 0), /**
|
|
583
|
-
* Canvas force-sets outputs of those nodes.
|
|
584
|
-
*/
|
|
585
|
-
_define_property(this, "_forcedOutputs", void 0), /**
|
|
586
|
-
* Runtime state of the execution graph.
|
|
587
|
-
*/
|
|
588
|
-
_define_property(this, "_runtimeStateInputs", void 0), _define_property(this, "_runtimeStateOutputs", void 0), // TODO(burdon): Remove? Make state reactive?
|
|
589
|
-
_define_property(this, "update", void 0), /** Computed result. */
|
|
590
|
-
_define_property(this, "output", void 0), _define_property(this, "events", void 0), this._serviceContainer = _serviceContainer, this._graph = _graph, this._executor = new GraphExecutor({
|
|
591
|
-
computeNodeResolver: (node) => resolveComputeNode(node)
|
|
592
|
-
}), this._diagnostics = [], this._forcedOutputs = {}, this._runtimeStateInputs = {}, this._runtimeStateOutputs = {}, this.update = new Event(), this.output = new Event(), this.events = new Event();
|
|
593
|
-
}
|
|
594
594
|
};
|
|
595
595
|
_ts_decorate([
|
|
596
596
|
synchronized
|
|
@@ -633,88 +633,82 @@ var computeValueBag = (bag) => {
|
|
|
633
633
|
import { noteShape } from "@dxos/react-ui-canvas-editor";
|
|
634
634
|
|
|
635
635
|
// src/shapes/common/Box.tsx
|
|
636
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
637
636
|
import React, { forwardRef } from "react";
|
|
638
637
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
639
638
|
import { Icon, IconButton } from "@dxos/react-ui";
|
|
640
639
|
import { useEditorContext, useShapeDef } from "@dxos/react-ui-canvas-editor";
|
|
641
|
-
import { mx } from "@dxos/
|
|
640
|
+
import { mx } from "@dxos/ui-theme";
|
|
642
641
|
var __dxlog_file5 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/common/Box.tsx";
|
|
643
642
|
var headerHeight = 32;
|
|
644
643
|
var footerHeight = 32;
|
|
645
644
|
var Box = /* @__PURE__ */ forwardRef(({ children, classNames, shape, title, status, open, onAction }, forwardedRef) => {
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
}
|
|
700
|
-
})));
|
|
701
|
-
} finally {
|
|
702
|
-
_effect.f();
|
|
703
|
-
}
|
|
645
|
+
invariant4(shape.type, void 0, {
|
|
646
|
+
F: __dxlog_file5,
|
|
647
|
+
L: 29,
|
|
648
|
+
S: void 0,
|
|
649
|
+
A: [
|
|
650
|
+
"shape.type",
|
|
651
|
+
""
|
|
652
|
+
]
|
|
653
|
+
});
|
|
654
|
+
const { icon, name, openable } = useShapeDef(shape.type) ?? {
|
|
655
|
+
icon: "ph--placeholder--regular"
|
|
656
|
+
};
|
|
657
|
+
const { debug } = useEditorContext();
|
|
658
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
659
|
+
ref: forwardedRef,
|
|
660
|
+
className: "flex flex-col bs-full is-full justify-between"
|
|
661
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
662
|
+
className: "flex shrink-0 is-full justify-between items-center bs-[32px] bg-hoverSurface"
|
|
663
|
+
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
664
|
+
icon,
|
|
665
|
+
classNames: "mx-2"
|
|
666
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
667
|
+
className: "grow text-sm truncate"
|
|
668
|
+
}, debug ? shape.type : name ?? shape.text ?? title), /* @__PURE__ */ React.createElement(IconButton, {
|
|
669
|
+
classNames: "p-1 text-green-500",
|
|
670
|
+
variant: "ghost",
|
|
671
|
+
icon: "ph--play--regular",
|
|
672
|
+
size: 4,
|
|
673
|
+
label: "run",
|
|
674
|
+
iconOnly: true,
|
|
675
|
+
onDoubleClick: (ev) => ev.stopPropagation(),
|
|
676
|
+
onClick: (ev) => {
|
|
677
|
+
ev.stopPropagation();
|
|
678
|
+
onAction?.("run");
|
|
679
|
+
}
|
|
680
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
681
|
+
className: mx("flex flex-col bs-full grow overflow-hidden", classNames)
|
|
682
|
+
}, children), /* @__PURE__ */ React.createElement("div", {
|
|
683
|
+
className: "flex shrink-0 is-full justify-between items-center bs-[32px] bg-hoverSurface"
|
|
684
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
685
|
+
className: "grow pli-2 text-sm truncate"
|
|
686
|
+
}, debug ? shape.id : status), openable && /* @__PURE__ */ React.createElement(IconButton, {
|
|
687
|
+
classNames: "p-1",
|
|
688
|
+
variant: "ghost",
|
|
689
|
+
icon: open ? "ph--caret-up--regular" : "ph--caret-down--regular",
|
|
690
|
+
size: 4,
|
|
691
|
+
label: open ? "close" : "open",
|
|
692
|
+
iconOnly: true,
|
|
693
|
+
onClick: (ev) => {
|
|
694
|
+
ev.stopPropagation();
|
|
695
|
+
onAction?.(open ? "close" : "open");
|
|
696
|
+
}
|
|
697
|
+
})));
|
|
704
698
|
});
|
|
705
699
|
|
|
706
700
|
// src/shapes/common/FunctionBody.tsx
|
|
707
|
-
import
|
|
708
|
-
import { SchemaAST as SchemaAST2 } from "effect";
|
|
701
|
+
import * as SchemaAST2 from "effect/SchemaAST";
|
|
709
702
|
import React2, { useRef, useState as useState3 } from "react";
|
|
710
703
|
import { VoidInput, VoidOutput } from "@dxos/conductor";
|
|
711
704
|
import { useCanvasContext } from "@dxos/react-ui-canvas";
|
|
712
705
|
import { createAnchors, getParentShapeElement, rowHeight } from "@dxos/react-ui-canvas-editor";
|
|
713
706
|
|
|
714
707
|
// src/shapes/defs.ts
|
|
715
|
-
import
|
|
708
|
+
import * as Schema2 from "effect/Schema";
|
|
709
|
+
import * as SchemaAST from "effect/SchemaAST";
|
|
716
710
|
import { DEFAULT_INPUT as DEFAULT_INPUT2, DEFAULT_OUTPUT as DEFAULT_OUTPUT2 } from "@dxos/conductor";
|
|
717
|
-
import {
|
|
711
|
+
import { Obj as Obj3 } from "@dxos/echo";
|
|
718
712
|
import { Polygon } from "@dxos/react-ui-canvas-editor";
|
|
719
713
|
var getProperties = (ast) => SchemaAST.getPropertySignatures(ast).map(({ name }) => ({
|
|
720
714
|
name: name.toString()
|
|
@@ -732,13 +726,13 @@ var parseAnchorId = (id) => {
|
|
|
732
726
|
};
|
|
733
727
|
var ComputeShape = Schema2.extend(Polygon, Schema2.Struct({
|
|
734
728
|
// TODO(burdon): Rename computeNode?
|
|
735
|
-
node: Schema2.optional(
|
|
729
|
+
node: Schema2.optional(Obj3.ID.annotations({
|
|
736
730
|
description: "Compute node id"
|
|
737
731
|
}))
|
|
738
732
|
}).pipe(Schema2.mutable));
|
|
739
733
|
var createShape = ({ id, ...rest }) => {
|
|
740
734
|
return {
|
|
741
|
-
id: id ??
|
|
735
|
+
id: id ?? Obj3.ID.random(),
|
|
742
736
|
...rest
|
|
743
737
|
};
|
|
744
738
|
};
|
|
@@ -747,70 +741,65 @@ var createShape = ({ id, ...rest }) => {
|
|
|
747
741
|
var bodyPadding = 8;
|
|
748
742
|
var expandedHeight = 200;
|
|
749
743
|
var FunctionBody = ({ shape, name, content, inputSchema = VoidInput, outputSchema = VoidOutput, ...props }) => {
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
setOpen(true);
|
|
765
|
-
break;
|
|
766
|
-
}
|
|
767
|
-
case "close": {
|
|
768
|
-
const el = getParentShapeElement(rootRef.current, shape.id);
|
|
769
|
-
el.style.height = "";
|
|
770
|
-
setOpen(false);
|
|
771
|
-
break;
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
};
|
|
775
|
-
const inputs = getProperties(inputSchema.ast);
|
|
776
|
-
const outputs = getProperties(outputSchema.ast);
|
|
777
|
-
const columnCount = inputs.length && outputs.length ? 2 : 1;
|
|
778
|
-
return /* @__PURE__ */ React2.createElement(Box, {
|
|
779
|
-
ref: rootRef,
|
|
780
|
-
shape,
|
|
781
|
-
title: name,
|
|
782
|
-
classNames: "divide-y divide-separator",
|
|
783
|
-
open,
|
|
784
|
-
onAction: handleAction,
|
|
785
|
-
...props
|
|
786
|
-
}, /* @__PURE__ */ React2.createElement("div", {
|
|
787
|
-
className: `grid grid-cols-${columnCount} items-center`,
|
|
788
|
-
style: {
|
|
789
|
-
paddingTop: bodyPadding,
|
|
790
|
-
paddingBottom: bodyPadding
|
|
791
|
-
}
|
|
792
|
-
}, (inputs?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement("div", {
|
|
793
|
-
className: "flex flex-col"
|
|
794
|
-
}, inputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
|
|
795
|
-
key: name2,
|
|
796
|
-
className: "px-2 truncate text-sm font-mono items-center",
|
|
797
|
-
style: {
|
|
798
|
-
height: rowHeight
|
|
744
|
+
const { scale } = useCanvasContext();
|
|
745
|
+
const rootRef = useRef(null);
|
|
746
|
+
const [open, setOpen] = useState3(false);
|
|
747
|
+
const handleAction = (action) => {
|
|
748
|
+
if (!rootRef.current) {
|
|
749
|
+
return;
|
|
750
|
+
}
|
|
751
|
+
switch (action) {
|
|
752
|
+
case "open": {
|
|
753
|
+
const el = getParentShapeElement(rootRef.current, shape.id);
|
|
754
|
+
const { height } = el.getBoundingClientRect();
|
|
755
|
+
el.style.height = `${height / scale + expandedHeight}px`;
|
|
756
|
+
setOpen(true);
|
|
757
|
+
break;
|
|
799
758
|
}
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
style: {
|
|
806
|
-
height: rowHeight
|
|
759
|
+
case "close": {
|
|
760
|
+
const el = getParentShapeElement(rootRef.current, shape.id);
|
|
761
|
+
el.style.height = "";
|
|
762
|
+
setOpen(false);
|
|
763
|
+
break;
|
|
807
764
|
}
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
765
|
+
}
|
|
766
|
+
};
|
|
767
|
+
const inputs = getProperties(inputSchema.ast);
|
|
768
|
+
const outputs = getProperties(outputSchema.ast);
|
|
769
|
+
const columnCount = inputs.length && outputs.length ? 2 : 1;
|
|
770
|
+
return /* @__PURE__ */ React2.createElement(Box, {
|
|
771
|
+
ref: rootRef,
|
|
772
|
+
shape,
|
|
773
|
+
title: name,
|
|
774
|
+
classNames: "divide-y divide-separator",
|
|
775
|
+
open,
|
|
776
|
+
onAction: handleAction,
|
|
777
|
+
...props
|
|
778
|
+
}, /* @__PURE__ */ React2.createElement("div", {
|
|
779
|
+
className: `grid grid-cols-${columnCount} items-center`,
|
|
780
|
+
style: {
|
|
781
|
+
paddingTop: bodyPadding,
|
|
782
|
+
paddingBottom: bodyPadding
|
|
783
|
+
}
|
|
784
|
+
}, (inputs?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement("div", {
|
|
785
|
+
className: "flex flex-col"
|
|
786
|
+
}, inputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
|
|
787
|
+
key: name2,
|
|
788
|
+
className: "pli-2 truncate text-sm font-mono items-center",
|
|
789
|
+
style: {
|
|
790
|
+
height: rowHeight
|
|
791
|
+
}
|
|
792
|
+
}, name2))), (outputs?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement("div", {
|
|
793
|
+
className: "flex flex-col"
|
|
794
|
+
}, outputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
|
|
795
|
+
key: name2,
|
|
796
|
+
className: "pli-2 truncate text-sm font-mono items-center text-right",
|
|
797
|
+
style: {
|
|
798
|
+
height: rowHeight
|
|
799
|
+
}
|
|
800
|
+
}, name2)))), open && /* @__PURE__ */ React2.createElement("div", {
|
|
801
|
+
className: "flex flex-col grow overflow-hidden"
|
|
802
|
+
}, content));
|
|
814
803
|
};
|
|
815
804
|
var getHeight = (input) => {
|
|
816
805
|
const properties = SchemaAST2.getPropertySignatures(input.ast);
|
|
@@ -831,47 +820,35 @@ var createFunctionAnchors = (shape, input = VoidInput, output = VoidOutput) => {
|
|
|
831
820
|
};
|
|
832
821
|
|
|
833
822
|
// src/shapes/common/TypeSelect.tsx
|
|
834
|
-
import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
|
|
835
823
|
import React3 from "react";
|
|
836
824
|
import { ComputeValueType } from "@dxos/conductor";
|
|
837
825
|
import { Select } from "@dxos/react-ui";
|
|
838
826
|
var TypeSelect = ({ value, onValueChange }) => {
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
value: type
|
|
850
|
-
}, type))), /* @__PURE__ */ React3.createElement(Select.ScrollDownButton, null), /* @__PURE__ */ React3.createElement(Select.Arrow, null))));
|
|
851
|
-
} finally {
|
|
852
|
-
_effect.f();
|
|
853
|
-
}
|
|
827
|
+
return /* @__PURE__ */ React3.createElement(Select.Root, {
|
|
828
|
+
value,
|
|
829
|
+
onValueChange
|
|
830
|
+
}, /* @__PURE__ */ React3.createElement(Select.TriggerButton, {
|
|
831
|
+
variant: "ghost",
|
|
832
|
+
classNames: "is-full !pli-0"
|
|
833
|
+
}), /* @__PURE__ */ React3.createElement(Select.Portal, null, /* @__PURE__ */ React3.createElement(Select.Content, null, /* @__PURE__ */ React3.createElement(Select.ScrollUpButton, null), /* @__PURE__ */ React3.createElement(Select.Viewport, null, ComputeValueType.literals.map((type) => /* @__PURE__ */ React3.createElement(Select.Option, {
|
|
834
|
+
key: type,
|
|
835
|
+
value: type
|
|
836
|
+
}, type))), /* @__PURE__ */ React3.createElement(Select.ScrollDownButton, null), /* @__PURE__ */ React3.createElement(Select.Arrow, null))));
|
|
854
837
|
};
|
|
855
838
|
|
|
856
839
|
// src/shapes/Array.tsx
|
|
857
|
-
import
|
|
858
|
-
import { Schema as Schema3 } from "effect";
|
|
840
|
+
import * as Schema3 from "effect/Schema";
|
|
859
841
|
import React4 from "react";
|
|
860
842
|
import { ReducerInput, ReducerOutput } from "@dxos/conductor";
|
|
861
843
|
var ReducerShape = Schema3.extend(ComputeShape, Schema3.Struct({
|
|
862
844
|
type: Schema3.Literal("reducer")
|
|
863
845
|
}));
|
|
864
846
|
var ReducerComponent = ({ shape }) => {
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
outputSchema: ReducerOutput
|
|
871
|
-
});
|
|
872
|
-
} finally {
|
|
873
|
-
_effect.f();
|
|
874
|
-
}
|
|
847
|
+
return /* @__PURE__ */ React4.createElement(FunctionBody, {
|
|
848
|
+
shape,
|
|
849
|
+
inputSchema: ReducerInput,
|
|
850
|
+
outputSchema: ReducerOutput
|
|
851
|
+
});
|
|
875
852
|
};
|
|
876
853
|
var createReducer = ({ id, size = {
|
|
877
854
|
width: 192,
|
|
@@ -891,8 +868,7 @@ var reducerShape = {
|
|
|
891
868
|
};
|
|
892
869
|
|
|
893
870
|
// src/shapes/Append.tsx
|
|
894
|
-
import
|
|
895
|
-
import { Schema as Schema4 } from "effect";
|
|
871
|
+
import * as Schema4 from "effect/Schema";
|
|
896
872
|
import React5 from "react";
|
|
897
873
|
import { AppendInput } from "@dxos/conductor";
|
|
898
874
|
var AppendShape = Schema4.extend(ComputeShape, Schema4.Struct({
|
|
@@ -907,15 +883,10 @@ var createAppend = (props) => createShape({
|
|
|
907
883
|
...props
|
|
908
884
|
});
|
|
909
885
|
var AppendComponent = ({ shape }) => {
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
inputSchema: AppendInput
|
|
915
|
-
});
|
|
916
|
-
} finally {
|
|
917
|
-
_effect.f();
|
|
918
|
-
}
|
|
886
|
+
return /* @__PURE__ */ React5.createElement(FunctionBody, {
|
|
887
|
+
shape,
|
|
888
|
+
inputSchema: AppendInput
|
|
889
|
+
});
|
|
919
890
|
};
|
|
920
891
|
var appendShape = {
|
|
921
892
|
type: "append",
|
|
@@ -927,8 +898,7 @@ var appendShape = {
|
|
|
927
898
|
};
|
|
928
899
|
|
|
929
900
|
// src/shapes/Audio.tsx
|
|
930
|
-
import
|
|
931
|
-
import { Schema as Schema5 } from "effect";
|
|
901
|
+
import * as Schema5 from "effect/Schema";
|
|
932
902
|
import React6, { useEffect as useEffect3, useState as useState4 } from "react";
|
|
933
903
|
import { Icon as Icon2 } from "@dxos/react-ui";
|
|
934
904
|
import { createAnchorMap } from "@dxos/react-ui-canvas-editor";
|
|
@@ -944,29 +914,24 @@ var createAudio = (props) => createShape({
|
|
|
944
914
|
...props
|
|
945
915
|
});
|
|
946
916
|
var AudioComponent = ({ shape }) => {
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
onClick: () => setActive(!active)
|
|
966
|
-
}));
|
|
967
|
-
} finally {
|
|
968
|
-
_effect.f();
|
|
969
|
-
}
|
|
917
|
+
const { node } = useComputeNodeState(shape);
|
|
918
|
+
const [active, setActive] = useState4(false);
|
|
919
|
+
useEffect3(() => {
|
|
920
|
+
node.value = active;
|
|
921
|
+
}, [
|
|
922
|
+
active
|
|
923
|
+
]);
|
|
924
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
925
|
+
className: "flex is-full justify-center items-center"
|
|
926
|
+
}, /* @__PURE__ */ React6.createElement(Icon2, {
|
|
927
|
+
icon: active ? "ph--microphone--regular" : "ph--microphone-slash--regular",
|
|
928
|
+
classNames: [
|
|
929
|
+
"transition opacity-20 duration-1000",
|
|
930
|
+
active && "opacity-100 text-red-500"
|
|
931
|
+
],
|
|
932
|
+
size: 8,
|
|
933
|
+
onClick: () => setActive(!active)
|
|
934
|
+
}));
|
|
970
935
|
};
|
|
971
936
|
var audioShape = {
|
|
972
937
|
type: "audio",
|
|
@@ -983,8 +948,7 @@ var audioShape = {
|
|
|
983
948
|
};
|
|
984
949
|
|
|
985
950
|
// src/shapes/Beacon.tsx
|
|
986
|
-
import
|
|
987
|
-
import { Schema as Schema6 } from "effect";
|
|
951
|
+
import * as Schema6 from "effect/Schema";
|
|
988
952
|
import React7 from "react";
|
|
989
953
|
import { DEFAULT_INPUT as DEFAULT_INPUT3, isTruthy } from "@dxos/conductor";
|
|
990
954
|
import { Icon as Icon3 } from "@dxos/react-ui";
|
|
@@ -1001,24 +965,19 @@ var createBeacon = (props) => createShape({
|
|
|
1001
965
|
...props
|
|
1002
966
|
});
|
|
1003
967
|
var BeaconComponent = ({ shape }) => {
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
size: 8
|
|
1018
|
-
}));
|
|
1019
|
-
} finally {
|
|
1020
|
-
_effect.f();
|
|
1021
|
-
}
|
|
968
|
+
const { runtime } = useComputeNodeState(shape);
|
|
969
|
+
const input = runtime.inputs[DEFAULT_INPUT3];
|
|
970
|
+
const value = input?.type === "executed" ? input.value : false;
|
|
971
|
+
return /* @__PURE__ */ React7.createElement("div", {
|
|
972
|
+
className: "flex is-full justify-center items-center"
|
|
973
|
+
}, /* @__PURE__ */ React7.createElement(Icon3, {
|
|
974
|
+
icon: "ph--sun--regular",
|
|
975
|
+
classNames: [
|
|
976
|
+
"transition opacity-20 duration-1000",
|
|
977
|
+
isTruthy(value) && "opacity-100 text-yellow-500"
|
|
978
|
+
],
|
|
979
|
+
size: 8
|
|
980
|
+
}));
|
|
1022
981
|
};
|
|
1023
982
|
var beaconShape = {
|
|
1024
983
|
type: "beacon",
|
|
@@ -1035,7 +994,7 @@ var beaconShape = {
|
|
|
1035
994
|
};
|
|
1036
995
|
|
|
1037
996
|
// src/shapes/Boolean.tsx
|
|
1038
|
-
import
|
|
997
|
+
import * as Schema7 from "effect/Schema";
|
|
1039
998
|
import React8 from "react";
|
|
1040
999
|
import { getAnchorPoints } from "@dxos/react-ui-canvas-editor";
|
|
1041
1000
|
import { createAnchors as createAnchors2 } from "@dxos/react-ui-canvas-editor";
|
|
@@ -1059,7 +1018,7 @@ var defineShape = ({ type, name, icon, symbol: Symbol, createShape: createShape2
|
|
|
1059
1018
|
// Be careful not to name component factories with a capital letter.
|
|
1060
1019
|
component: () => {
|
|
1061
1020
|
return /* @__PURE__ */ React8.createElement("div", {
|
|
1062
|
-
className: "flex
|
|
1021
|
+
className: "flex is-full justify-center items-center"
|
|
1063
1022
|
}, /* @__PURE__ */ React8.createElement(Symbol, null));
|
|
1064
1023
|
},
|
|
1065
1024
|
createShape: createShape2,
|
|
@@ -1086,7 +1045,7 @@ var createSymbol = (pathConstructor, inputs) => ({
|
|
|
1086
1045
|
});
|
|
1087
1046
|
return /* @__PURE__ */ React8.createElement("svg", {
|
|
1088
1047
|
viewBox: `0 0 ${width} ${height}`,
|
|
1089
|
-
className: "
|
|
1048
|
+
className: "is-full bs-full"
|
|
1090
1049
|
}, getAnchorPoints({
|
|
1091
1050
|
x: 0,
|
|
1092
1051
|
y: centerY
|
|
@@ -1208,8 +1167,7 @@ var notShape = defineShape({
|
|
|
1208
1167
|
});
|
|
1209
1168
|
|
|
1210
1169
|
// src/shapes/Chat.tsx
|
|
1211
|
-
import
|
|
1212
|
-
import { Schema as Schema8 } from "effect";
|
|
1170
|
+
import * as Schema8 from "effect/Schema";
|
|
1213
1171
|
import React9, { useRef as useRef2 } from "react";
|
|
1214
1172
|
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT3 } from "@dxos/conductor";
|
|
1215
1173
|
import { TextBox } from "@dxos/react-ui-canvas-editor";
|
|
@@ -1218,28 +1176,23 @@ var ChatShape = Schema8.extend(ComputeShape, Schema8.Struct({
|
|
|
1218
1176
|
type: Schema8.Literal("chat")
|
|
1219
1177
|
}));
|
|
1220
1178
|
var TextInputComponent = ({ shape, title, ...props }) => {
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
const
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
...props
|
|
1239
|
-
}));
|
|
1240
|
-
} finally {
|
|
1241
|
-
_effect.f();
|
|
1242
|
-
}
|
|
1179
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1180
|
+
const inputRef = useRef2(null);
|
|
1181
|
+
const handleEnter = (text) => {
|
|
1182
|
+
const value = text.trim();
|
|
1183
|
+
if (value.length) {
|
|
1184
|
+
runtime.setOutput(DEFAULT_OUTPUT3, value);
|
|
1185
|
+
inputRef.current?.setText("");
|
|
1186
|
+
}
|
|
1187
|
+
};
|
|
1188
|
+
return /* @__PURE__ */ React9.createElement(Box, {
|
|
1189
|
+
shape,
|
|
1190
|
+
title
|
|
1191
|
+
}, /* @__PURE__ */ React9.createElement(TextBox, {
|
|
1192
|
+
ref: inputRef,
|
|
1193
|
+
onEnter: handleEnter,
|
|
1194
|
+
...props
|
|
1195
|
+
}));
|
|
1243
1196
|
};
|
|
1244
1197
|
var createChat = (props) => createShape({
|
|
1245
1198
|
type: "chat",
|
|
@@ -1269,8 +1222,7 @@ var chatShape = {
|
|
|
1269
1222
|
};
|
|
1270
1223
|
|
|
1271
1224
|
// src/shapes/Constant.tsx
|
|
1272
|
-
import
|
|
1273
|
-
import { Schema as Schema9 } from "effect";
|
|
1225
|
+
import * as Schema9 from "effect/Schema";
|
|
1274
1226
|
import React10, { useCallback as useCallback2, useRef as useRef3, useState as useState5 } from "react";
|
|
1275
1227
|
import { ComputeValueType as ComputeValueType2 } from "@dxos/conductor";
|
|
1276
1228
|
import { Input } from "@dxos/react-ui";
|
|
@@ -1293,57 +1245,52 @@ var inferType = (value) => {
|
|
|
1293
1245
|
}
|
|
1294
1246
|
};
|
|
1295
1247
|
var ConstantComponent = ({ shape, title, chat, ...props }) => {
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
const
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
if (
|
|
1305
|
-
|
|
1306
|
-
if (!isNaN(floatValue)) {
|
|
1307
|
-
node.value = floatValue;
|
|
1308
|
-
}
|
|
1309
|
-
} else if (type === "object") {
|
|
1310
|
-
node.value = safeParseJson(value, {});
|
|
1311
|
-
} else {
|
|
1312
|
-
node.value = value;
|
|
1248
|
+
const { node } = useComputeNodeState(shape);
|
|
1249
|
+
const [type, setType] = useState5(inferType(node.value) ?? ComputeValueType2.literals[0]);
|
|
1250
|
+
const inputRef = useRef3(null);
|
|
1251
|
+
const handleEnter = useCallback2((text) => {
|
|
1252
|
+
const value = text.trim();
|
|
1253
|
+
if (value.length) {
|
|
1254
|
+
if (type === "number") {
|
|
1255
|
+
const floatValue = parseFloat(value);
|
|
1256
|
+
if (!isNaN(floatValue)) {
|
|
1257
|
+
node.value = floatValue;
|
|
1313
1258
|
}
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
type
|
|
1318
|
-
]);
|
|
1319
|
-
return /* @__PURE__ */ React10.createElement(Box, {
|
|
1320
|
-
shape,
|
|
1321
|
-
title,
|
|
1322
|
-
status: /* @__PURE__ */ React10.createElement(TypeSelect, {
|
|
1323
|
-
value: type,
|
|
1324
|
-
onValueChange: setType
|
|
1325
|
-
})
|
|
1326
|
-
}, (type === "string" || type === "number") && /* @__PURE__ */ React10.createElement(TextBox2, {
|
|
1327
|
-
...props,
|
|
1328
|
-
ref: inputRef,
|
|
1329
|
-
value: node.value,
|
|
1330
|
-
onEnter: handleEnter
|
|
1331
|
-
}), type === "object" && /* @__PURE__ */ React10.createElement(TextBox2, {
|
|
1332
|
-
...props,
|
|
1333
|
-
ref: inputRef,
|
|
1334
|
-
value: JSON.stringify(node.value, null, 2),
|
|
1335
|
-
language: "json"
|
|
1336
|
-
}), type === "boolean" && /* @__PURE__ */ React10.createElement("div", {
|
|
1337
|
-
className: "flex grow justify-center items-center"
|
|
1338
|
-
}, /* @__PURE__ */ React10.createElement(Input.Root, null, /* @__PURE__ */ React10.createElement(Input.Switch, {
|
|
1339
|
-
checked: node.value,
|
|
1340
|
-
onCheckedChange: (value) => {
|
|
1259
|
+
} else if (type === "object") {
|
|
1260
|
+
node.value = safeParseJson(value, {});
|
|
1261
|
+
} else {
|
|
1341
1262
|
node.value = value;
|
|
1342
1263
|
}
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1264
|
+
inputRef.current?.focus();
|
|
1265
|
+
}
|
|
1266
|
+
}, [
|
|
1267
|
+
type
|
|
1268
|
+
]);
|
|
1269
|
+
return /* @__PURE__ */ React10.createElement(Box, {
|
|
1270
|
+
shape,
|
|
1271
|
+
title,
|
|
1272
|
+
status: /* @__PURE__ */ React10.createElement(TypeSelect, {
|
|
1273
|
+
value: type,
|
|
1274
|
+
onValueChange: setType
|
|
1275
|
+
})
|
|
1276
|
+
}, (type === "string" || type === "number") && /* @__PURE__ */ React10.createElement(TextBox2, {
|
|
1277
|
+
...props,
|
|
1278
|
+
ref: inputRef,
|
|
1279
|
+
value: node.value,
|
|
1280
|
+
onEnter: handleEnter
|
|
1281
|
+
}), type === "object" && /* @__PURE__ */ React10.createElement(TextBox2, {
|
|
1282
|
+
...props,
|
|
1283
|
+
ref: inputRef,
|
|
1284
|
+
value: JSON.stringify(node.value, null, 2),
|
|
1285
|
+
language: "json"
|
|
1286
|
+
}), type === "boolean" && /* @__PURE__ */ React10.createElement("div", {
|
|
1287
|
+
className: "flex grow justify-center items-center"
|
|
1288
|
+
}, /* @__PURE__ */ React10.createElement(Input.Root, null, /* @__PURE__ */ React10.createElement(Input.Switch, {
|
|
1289
|
+
checked: node.value,
|
|
1290
|
+
onCheckedChange: (value) => {
|
|
1291
|
+
node.value = value;
|
|
1292
|
+
}
|
|
1293
|
+
}))));
|
|
1347
1294
|
};
|
|
1348
1295
|
var createConstant = (props) => createShape({
|
|
1349
1296
|
type: "constant",
|
|
@@ -1372,8 +1319,7 @@ var constantShape = {
|
|
|
1372
1319
|
};
|
|
1373
1320
|
|
|
1374
1321
|
// src/shapes/Database.tsx
|
|
1375
|
-
import
|
|
1376
|
-
import { Schema as Schema10 } from "effect";
|
|
1322
|
+
import * as Schema10 from "effect/Schema";
|
|
1377
1323
|
import React11 from "react";
|
|
1378
1324
|
import { createAnchorMap as createAnchorMap5 } from "@dxos/react-ui-canvas-editor";
|
|
1379
1325
|
var DatabaseShape = Schema10.extend(ComputeShape, Schema10.Struct({
|
|
@@ -1388,14 +1334,9 @@ var createDatabase = (props) => createShape({
|
|
|
1388
1334
|
...props
|
|
1389
1335
|
});
|
|
1390
1336
|
var DatabaseComponent = ({ shape }) => {
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
shape
|
|
1395
|
-
});
|
|
1396
|
-
} finally {
|
|
1397
|
-
_effect.f();
|
|
1398
|
-
}
|
|
1337
|
+
return /* @__PURE__ */ React11.createElement(Box, {
|
|
1338
|
+
shape
|
|
1339
|
+
});
|
|
1399
1340
|
};
|
|
1400
1341
|
var databaseShape = {
|
|
1401
1342
|
type: "database",
|
|
@@ -1412,12 +1353,11 @@ var databaseShape = {
|
|
|
1412
1353
|
};
|
|
1413
1354
|
|
|
1414
1355
|
// src/shapes/Function.tsx
|
|
1415
|
-
import
|
|
1416
|
-
import { Schema as Schema11 } from "effect";
|
|
1356
|
+
import * as Schema11 from "effect/Schema";
|
|
1417
1357
|
import React12, { useCallback as useCallback3, useRef as useRef4 } from "react";
|
|
1418
1358
|
import { AnyOutput, FunctionInput } from "@dxos/conductor";
|
|
1419
|
-
import { Ref as Ref2, getSnapshot, isInstanceOf } from "@dxos/echo
|
|
1420
|
-
import {
|
|
1359
|
+
import { Ref as Ref2, getSnapshot, isInstanceOf } from "@dxos/echo/internal";
|
|
1360
|
+
import { Function, Script } from "@dxos/functions";
|
|
1421
1361
|
import { useClient } from "@dxos/react-client";
|
|
1422
1362
|
import { Filter, parseId } from "@dxos/react-client/echo";
|
|
1423
1363
|
import { TextBox as TextBox3 } from "@dxos/react-ui-canvas-editor";
|
|
@@ -1433,59 +1373,54 @@ var createFunction = (props) => createShape({
|
|
|
1433
1373
|
...props
|
|
1434
1374
|
});
|
|
1435
1375
|
var TextInputComponent2 = ({ shape, title, ...props }) => {
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
const
|
|
1441
|
-
const
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
onEnter: handleEnter
|
|
1485
|
-
}));
|
|
1486
|
-
} finally {
|
|
1487
|
-
_effect.f();
|
|
1488
|
-
}
|
|
1376
|
+
const client = useClient();
|
|
1377
|
+
const { node, runtime } = useComputeNodeState(shape);
|
|
1378
|
+
const inputRef = useRef4(null);
|
|
1379
|
+
const handleEnter = useCallback3(async (text) => {
|
|
1380
|
+
const value = text.trim();
|
|
1381
|
+
const { spaceId, objectId } = parseId(value);
|
|
1382
|
+
if (!spaceId || !objectId) {
|
|
1383
|
+
return;
|
|
1384
|
+
}
|
|
1385
|
+
const space = client.spaces.get(spaceId);
|
|
1386
|
+
const object = space?.db.getObjectById(objectId);
|
|
1387
|
+
if (!space || !isInstanceOf(Script.Script, object)) {
|
|
1388
|
+
return;
|
|
1389
|
+
}
|
|
1390
|
+
const [fn] = await space.db.query(Filter.type(Function.Function, {
|
|
1391
|
+
source: Ref2.make(object)
|
|
1392
|
+
})).run();
|
|
1393
|
+
if (!fn) {
|
|
1394
|
+
return;
|
|
1395
|
+
}
|
|
1396
|
+
node.value = value;
|
|
1397
|
+
node.function = Ref2.make(fn);
|
|
1398
|
+
node.inputSchema = fn.inputSchema ? getSnapshot(fn.inputSchema) : void 0;
|
|
1399
|
+
node.outputSchema = fn.outputSchema ? getSnapshot(fn.outputSchema) : void 0;
|
|
1400
|
+
}, [
|
|
1401
|
+
client,
|
|
1402
|
+
node
|
|
1403
|
+
]);
|
|
1404
|
+
const handleAction = useCallback3((action) => {
|
|
1405
|
+
if (action !== "run") {
|
|
1406
|
+
return;
|
|
1407
|
+
}
|
|
1408
|
+
runtime.evalNode();
|
|
1409
|
+
}, [
|
|
1410
|
+
runtime
|
|
1411
|
+
]);
|
|
1412
|
+
return /* @__PURE__ */ React12.createElement(Box, {
|
|
1413
|
+
shape,
|
|
1414
|
+
title: "Function",
|
|
1415
|
+
onAction: handleAction
|
|
1416
|
+
}, /* @__PURE__ */ React12.createElement(TextBox3, {
|
|
1417
|
+
...props,
|
|
1418
|
+
ref: inputRef,
|
|
1419
|
+
value: node.value,
|
|
1420
|
+
language: node.valueType === "object" ? "json" : void 0,
|
|
1421
|
+
onBlur: handleEnter,
|
|
1422
|
+
onEnter: handleEnter
|
|
1423
|
+
}));
|
|
1489
1424
|
};
|
|
1490
1425
|
var functionShape = {
|
|
1491
1426
|
type: "function",
|
|
@@ -1497,10 +1432,10 @@ var functionShape = {
|
|
|
1497
1432
|
};
|
|
1498
1433
|
|
|
1499
1434
|
// src/shapes/Gpt.tsx
|
|
1500
|
-
import
|
|
1501
|
-
import { Schema as Schema12 } from "effect";
|
|
1435
|
+
import * as Schema12 from "effect/Schema";
|
|
1502
1436
|
import React13, { useEffect as useEffect4, useState as useState6 } from "react";
|
|
1503
1437
|
import { GptInput, GptOutput } from "@dxos/conductor";
|
|
1438
|
+
import { ScrollArea } from "@dxos/react-ui";
|
|
1504
1439
|
var GptShape = Schema12.extend(ComputeShape, Schema12.Struct({
|
|
1505
1440
|
type: Schema12.Literal("gpt")
|
|
1506
1441
|
}));
|
|
@@ -1513,54 +1448,50 @@ var createGpt = (props) => createShape({
|
|
|
1513
1448
|
...props
|
|
1514
1449
|
});
|
|
1515
1450
|
var GptComponent = ({ shape }) => {
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
const
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
});
|
|
1540
|
-
break;
|
|
1541
|
-
}
|
|
1451
|
+
const { meta, runtime } = useComputeNodeState(shape);
|
|
1452
|
+
const [text, setText] = useState6("");
|
|
1453
|
+
const [tokens, setTokens] = useState6(0);
|
|
1454
|
+
useEffect4(() => {
|
|
1455
|
+
return runtime.subscribeToEventLog((ev) => {
|
|
1456
|
+
switch (ev.type) {
|
|
1457
|
+
case "begin-compute": {
|
|
1458
|
+
setText("");
|
|
1459
|
+
break;
|
|
1460
|
+
}
|
|
1461
|
+
case "custom": {
|
|
1462
|
+
const token = ev.event;
|
|
1463
|
+
switch (token.type) {
|
|
1464
|
+
case "content_block_delta":
|
|
1465
|
+
switch (token.delta.type) {
|
|
1466
|
+
case "text_delta": {
|
|
1467
|
+
const delta = token.delta.text;
|
|
1468
|
+
setText((prev) => {
|
|
1469
|
+
const text2 = prev + delta;
|
|
1470
|
+
setTokens(text2.split(" ").length);
|
|
1471
|
+
return text2;
|
|
1472
|
+
});
|
|
1473
|
+
break;
|
|
1542
1474
|
}
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
break;
|
|
1475
|
+
}
|
|
1476
|
+
break;
|
|
1546
1477
|
}
|
|
1478
|
+
break;
|
|
1547
1479
|
}
|
|
1548
|
-
}
|
|
1549
|
-
}, [
|
|
1550
|
-
runtime?.subscribeToEventLog
|
|
1551
|
-
]);
|
|
1552
|
-
return /* @__PURE__ */ React13.createElement(FunctionBody, {
|
|
1553
|
-
shape,
|
|
1554
|
-
content: /* @__PURE__ */ React13.createElement("div", {
|
|
1555
|
-
className: "px-2 py-1 overflow-y-scroll"
|
|
1556
|
-
}, text),
|
|
1557
|
-
status: `${tokens} tokens`,
|
|
1558
|
-
inputSchema: meta.input,
|
|
1559
|
-
outputSchema: meta.output
|
|
1480
|
+
}
|
|
1560
1481
|
});
|
|
1561
|
-
}
|
|
1562
|
-
|
|
1563
|
-
|
|
1482
|
+
}, [
|
|
1483
|
+
runtime?.subscribeToEventLog
|
|
1484
|
+
]);
|
|
1485
|
+
return /* @__PURE__ */ React13.createElement(FunctionBody, {
|
|
1486
|
+
shape,
|
|
1487
|
+
content: /* @__PURE__ */ React13.createElement(ScrollArea.Root, {
|
|
1488
|
+
orientation: "vertical",
|
|
1489
|
+
thin: true
|
|
1490
|
+
}, /* @__PURE__ */ React13.createElement(ScrollArea.Viewport, null, text)),
|
|
1491
|
+
status: `${tokens} tokens`,
|
|
1492
|
+
inputSchema: meta.input,
|
|
1493
|
+
outputSchema: meta.output
|
|
1494
|
+
});
|
|
1564
1495
|
};
|
|
1565
1496
|
var gptShape = {
|
|
1566
1497
|
type: "gpt",
|
|
@@ -1573,8 +1504,7 @@ var gptShape = {
|
|
|
1573
1504
|
};
|
|
1574
1505
|
|
|
1575
1506
|
// src/shapes/Json.tsx
|
|
1576
|
-
import
|
|
1577
|
-
import { Schema as Schema13 } from "effect";
|
|
1507
|
+
import * as Schema13 from "effect/Schema";
|
|
1578
1508
|
import React14 from "react";
|
|
1579
1509
|
import { DEFAULT_INPUT as DEFAULT_INPUT4, DefaultOutput, JsonTransformInput } from "@dxos/conductor";
|
|
1580
1510
|
import { createAnchorMap as createAnchorMap6 } from "@dxos/react-ui-canvas-editor";
|
|
@@ -1586,30 +1516,20 @@ var JsonTransformShape = Schema13.extend(ComputeShape, Schema13.Struct({
|
|
|
1586
1516
|
type: Schema13.Literal("json-transform")
|
|
1587
1517
|
}));
|
|
1588
1518
|
var JsonComponent = ({ shape, ...props }) => {
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
classNames: "text-xs"
|
|
1599
|
-
}));
|
|
1600
|
-
} finally {
|
|
1601
|
-
_effect.f();
|
|
1602
|
-
}
|
|
1519
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1520
|
+
const input = runtime.inputs[DEFAULT_INPUT4];
|
|
1521
|
+
const value = input?.type === "executed" ? input.value : void 0;
|
|
1522
|
+
return /* @__PURE__ */ React14.createElement(Box, {
|
|
1523
|
+
shape
|
|
1524
|
+
}, /* @__PURE__ */ React14.createElement(JsonFilter, {
|
|
1525
|
+
data: value,
|
|
1526
|
+
classNames: "text-xs"
|
|
1527
|
+
}));
|
|
1603
1528
|
};
|
|
1604
1529
|
var JsonTransformComponent = ({ shape, ...props }) => {
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
shape
|
|
1609
|
-
});
|
|
1610
|
-
} finally {
|
|
1611
|
-
_effect.f();
|
|
1612
|
-
}
|
|
1530
|
+
return /* @__PURE__ */ React14.createElement(Box, {
|
|
1531
|
+
shape
|
|
1532
|
+
});
|
|
1613
1533
|
};
|
|
1614
1534
|
var createJson = (props) => createShape({
|
|
1615
1535
|
type: "json",
|
|
@@ -1656,8 +1576,7 @@ var jsonTransformShape = {
|
|
|
1656
1576
|
};
|
|
1657
1577
|
|
|
1658
1578
|
// src/shapes/Logic.tsx
|
|
1659
|
-
import
|
|
1660
|
-
import { Schema as Schema14 } from "effect";
|
|
1579
|
+
import * as Schema14 from "effect/Schema";
|
|
1661
1580
|
import React15 from "react";
|
|
1662
1581
|
import { IfElseInput, IfElseOutput, IfInput, IfOutput } from "@dxos/conductor";
|
|
1663
1582
|
var IfShape = Schema14.extend(ComputeShape, Schema14.Struct({
|
|
@@ -1667,28 +1586,18 @@ var IfElseShape = Schema14.extend(ComputeShape, Schema14.Struct({
|
|
|
1667
1586
|
type: Schema14.Literal("if-else")
|
|
1668
1587
|
}));
|
|
1669
1588
|
var IfComponent = ({ shape, ...props }) => {
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
outputSchema: IfOutput
|
|
1676
|
-
});
|
|
1677
|
-
} finally {
|
|
1678
|
-
_effect.f();
|
|
1679
|
-
}
|
|
1589
|
+
return /* @__PURE__ */ React15.createElement(FunctionBody, {
|
|
1590
|
+
shape,
|
|
1591
|
+
inputSchema: IfInput,
|
|
1592
|
+
outputSchema: IfOutput
|
|
1593
|
+
});
|
|
1680
1594
|
};
|
|
1681
1595
|
var IfElseComponent = ({ shape, ...props }) => {
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
outputSchema: IfElseOutput
|
|
1688
|
-
});
|
|
1689
|
-
} finally {
|
|
1690
|
-
_effect.f();
|
|
1691
|
-
}
|
|
1596
|
+
return /* @__PURE__ */ React15.createElement(FunctionBody, {
|
|
1597
|
+
shape,
|
|
1598
|
+
inputSchema: IfElseInput,
|
|
1599
|
+
outputSchema: IfElseOutput
|
|
1600
|
+
});
|
|
1692
1601
|
};
|
|
1693
1602
|
var createIf = (props) => createShape({
|
|
1694
1603
|
type: "if",
|
|
@@ -1724,11 +1633,11 @@ var ifElseShape = {
|
|
|
1724
1633
|
};
|
|
1725
1634
|
|
|
1726
1635
|
// src/shapes/Queue.tsx
|
|
1727
|
-
import
|
|
1728
|
-
import { Schema as Schema15 } from "effect";
|
|
1636
|
+
import * as Schema15 from "effect/Schema";
|
|
1729
1637
|
import React16, { Fragment } from "react";
|
|
1730
1638
|
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT4, QueueInput, QueueOutput } from "@dxos/conductor";
|
|
1731
|
-
import {
|
|
1639
|
+
import { ScrollArea as ScrollArea2 } from "@dxos/react-ui";
|
|
1640
|
+
import { mx as mx2 } from "@dxos/ui-theme";
|
|
1732
1641
|
var QueueShape = Schema15.extend(ComputeShape, Schema15.Struct({
|
|
1733
1642
|
type: Schema15.Literal("queue")
|
|
1734
1643
|
}));
|
|
@@ -1741,50 +1650,42 @@ var createQueue = (props) => createShape({
|
|
|
1741
1650
|
...props
|
|
1742
1651
|
});
|
|
1743
1652
|
var QueueComponent = ({ shape }) => {
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
} finally {
|
|
1767
|
-
_effect.f();
|
|
1768
|
-
}
|
|
1653
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1654
|
+
const items = runtime.outputs[DEFAULT_OUTPUT4]?.type === "executed" ? runtime.outputs[DEFAULT_OUTPUT4].value : [];
|
|
1655
|
+
const handleAction = (action) => {
|
|
1656
|
+
if (action === "run") {
|
|
1657
|
+
runtime.evalNode();
|
|
1658
|
+
}
|
|
1659
|
+
};
|
|
1660
|
+
return /* @__PURE__ */ React16.createElement(Box, {
|
|
1661
|
+
shape,
|
|
1662
|
+
status: `${items.length} items`,
|
|
1663
|
+
onAction: handleAction
|
|
1664
|
+
}, /* @__PURE__ */ React16.createElement(ScrollArea2.Root, {
|
|
1665
|
+
orientation: "vertical"
|
|
1666
|
+
}, /* @__PURE__ */ React16.createElement(ScrollArea2.Viewport, {
|
|
1667
|
+
classNames: "divide-y divide-separator"
|
|
1668
|
+
}, [
|
|
1669
|
+
...items
|
|
1670
|
+
].map((item, i) => /* @__PURE__ */ React16.createElement(QueueItem, {
|
|
1671
|
+
key: i,
|
|
1672
|
+
classNames: "p-1 pli-2",
|
|
1673
|
+
item
|
|
1674
|
+
})))));
|
|
1769
1675
|
};
|
|
1770
1676
|
var QueueItem = ({ classNames, item }) => {
|
|
1771
|
-
|
|
1772
|
-
try {
|
|
1773
|
-
if (typeof item !== "object") {
|
|
1774
|
-
return /* @__PURE__ */ React16.createElement("div", {
|
|
1775
|
-
className: mx2(classNames, "whitespace-pre-wrap")
|
|
1776
|
-
}, item);
|
|
1777
|
-
}
|
|
1677
|
+
if (typeof item !== "object") {
|
|
1778
1678
|
return /* @__PURE__ */ React16.createElement("div", {
|
|
1779
|
-
className: mx2("
|
|
1780
|
-
},
|
|
1781
|
-
key
|
|
1782
|
-
}, /* @__PURE__ */ React16.createElement("div", {
|
|
1783
|
-
className: "p-1 text-xs text-subdued"
|
|
1784
|
-
}, key), /* @__PURE__ */ React16.createElement("div", null, typeof value === "string" ? value : JSON.stringify(value)))));
|
|
1785
|
-
} finally {
|
|
1786
|
-
_effect.f();
|
|
1679
|
+
className: mx2(classNames, "whitespace-pre-wrap")
|
|
1680
|
+
}, item);
|
|
1787
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)))));
|
|
1788
1689
|
};
|
|
1789
1690
|
var queueShape = {
|
|
1790
1691
|
type: "queue",
|
|
@@ -1797,8 +1698,7 @@ var queueShape = {
|
|
|
1797
1698
|
};
|
|
1798
1699
|
|
|
1799
1700
|
// src/shapes/RNG.tsx
|
|
1800
|
-
import
|
|
1801
|
-
import { Schema as Schema16 } from "effect";
|
|
1701
|
+
import * as Schema16 from "effect/Schema";
|
|
1802
1702
|
import React17, { useEffect as useEffect5, useState as useState7 } from "react";
|
|
1803
1703
|
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT5 } from "@dxos/conductor";
|
|
1804
1704
|
import { Icon as Icon4 } from "@dxos/react-ui";
|
|
@@ -1826,42 +1726,37 @@ var icons = [
|
|
|
1826
1726
|
];
|
|
1827
1727
|
var pickIcon = () => icons[Math.floor(Math.random() * icons.length)];
|
|
1828
1728
|
var RandomComponent = ({ shape }) => {
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
clearTimeout(t1);
|
|
1844
|
-
clearTimeout(t2);
|
|
1845
|
-
};
|
|
1846
|
-
}, [
|
|
1847
|
-
spin
|
|
1848
|
-
]);
|
|
1849
|
-
const handleClick = (ev) => {
|
|
1850
|
-
ev.stopPropagation();
|
|
1851
|
-
runtime.setOutput(DEFAULT_OUTPUT5, Math.random());
|
|
1852
|
-
setSpin(true);
|
|
1729
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1730
|
+
const [spin, setSpin] = useState7(false);
|
|
1731
|
+
const [icon, setIcon] = useState7(pickIcon());
|
|
1732
|
+
useEffect5(() => {
|
|
1733
|
+
if (!spin) {
|
|
1734
|
+
return;
|
|
1735
|
+
}
|
|
1736
|
+
const i = setInterval(() => setIcon(pickIcon()), 250);
|
|
1737
|
+
const t1 = setTimeout(() => clearInterval(i), 900);
|
|
1738
|
+
const t2 = setTimeout(() => setSpin(false), 1100);
|
|
1739
|
+
return () => {
|
|
1740
|
+
clearInterval(i);
|
|
1741
|
+
clearTimeout(t1);
|
|
1742
|
+
clearTimeout(t2);
|
|
1853
1743
|
};
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
}
|
|
1744
|
+
}, [
|
|
1745
|
+
spin
|
|
1746
|
+
]);
|
|
1747
|
+
const handleClick = (ev) => {
|
|
1748
|
+
ev.stopPropagation();
|
|
1749
|
+
runtime.setOutput(DEFAULT_OUTPUT5, Math.random());
|
|
1750
|
+
setSpin(true);
|
|
1751
|
+
};
|
|
1752
|
+
return /* @__PURE__ */ React17.createElement("div", {
|
|
1753
|
+
className: "flex grow items-center justify-center"
|
|
1754
|
+
}, /* @__PURE__ */ React17.createElement(Icon4, {
|
|
1755
|
+
icon,
|
|
1756
|
+
classNames: spin && "animate-[spin_1s]",
|
|
1757
|
+
size: 10,
|
|
1758
|
+
onClick: handleClick
|
|
1759
|
+
}));
|
|
1865
1760
|
};
|
|
1866
1761
|
var randomShape = {
|
|
1867
1762
|
type: "rng",
|
|
@@ -1878,8 +1773,7 @@ var randomShape = {
|
|
|
1878
1773
|
};
|
|
1879
1774
|
|
|
1880
1775
|
// src/shapes/Scope.tsx
|
|
1881
|
-
import
|
|
1882
|
-
import { Schema as Schema17 } from "effect";
|
|
1776
|
+
import * as Schema17 from "effect/Schema";
|
|
1883
1777
|
import React18 from "react";
|
|
1884
1778
|
import { DEFAULT_INPUT as DEFAULT_INPUT5 } from "@dxos/conductor";
|
|
1885
1779
|
import { createAnchorMap as createAnchorMap8 } from "@dxos/react-ui-canvas-editor";
|
|
@@ -1897,25 +1791,20 @@ var createScope = (props) => createShape({
|
|
|
1897
1791
|
...props
|
|
1898
1792
|
});
|
|
1899
1793
|
var ScopeComponent = ({ shape }) => {
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
}
|
|
1915
|
-
}));
|
|
1916
|
-
} finally {
|
|
1917
|
-
_effect.f();
|
|
1918
|
-
}
|
|
1794
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1795
|
+
const input = runtime.inputs[DEFAULT_INPUT5];
|
|
1796
|
+
const active = input?.type === "executed" ? input.value : false;
|
|
1797
|
+
const { getAverage } = useAudioStream(active);
|
|
1798
|
+
return /* @__PURE__ */ React18.createElement("div", {
|
|
1799
|
+
className: "flex is-full justify-center items-center bg-black"
|
|
1800
|
+
}, /* @__PURE__ */ React18.createElement(Chaos, {
|
|
1801
|
+
active,
|
|
1802
|
+
getValue: getAverage,
|
|
1803
|
+
options: {
|
|
1804
|
+
...shaderPresets.heptapod,
|
|
1805
|
+
zoom: 1.2
|
|
1806
|
+
}
|
|
1807
|
+
}));
|
|
1919
1808
|
};
|
|
1920
1809
|
var scopeShape = {
|
|
1921
1810
|
type: "scope",
|
|
@@ -1932,10 +1821,9 @@ var scopeShape = {
|
|
|
1932
1821
|
};
|
|
1933
1822
|
|
|
1934
1823
|
// src/shapes/Surface.tsx
|
|
1935
|
-
import
|
|
1936
|
-
import { Schema as Schema18 } from "effect";
|
|
1824
|
+
import * as Schema18 from "effect/Schema";
|
|
1937
1825
|
import React19 from "react";
|
|
1938
|
-
import { Surface } from "@dxos/app-framework";
|
|
1826
|
+
import { Surface } from "@dxos/app-framework/ui";
|
|
1939
1827
|
import { DEFAULT_INPUT as DEFAULT_INPUT6 } from "@dxos/conductor";
|
|
1940
1828
|
import { createAnchorMap as createAnchorMap9 } from "@dxos/react-ui-canvas-editor";
|
|
1941
1829
|
var SurfaceShape = Schema18.extend(ComputeShape, Schema18.Struct({
|
|
@@ -1950,29 +1838,24 @@ var createSurface = (props) => createShape({
|
|
|
1950
1838
|
...props
|
|
1951
1839
|
});
|
|
1952
1840
|
var SurfaceComponent = ({ shape }) => {
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
limit: 1
|
|
1972
|
-
}));
|
|
1973
|
-
} finally {
|
|
1974
|
-
_effect.f();
|
|
1975
|
-
}
|
|
1841
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1842
|
+
const input = runtime.inputs[DEFAULT_INPUT6];
|
|
1843
|
+
const value = input?.type === "executed" ? input.value : null;
|
|
1844
|
+
const handleAction = (action) => {
|
|
1845
|
+
if (action === "run") {
|
|
1846
|
+
runtime.evalNode();
|
|
1847
|
+
}
|
|
1848
|
+
};
|
|
1849
|
+
return /* @__PURE__ */ React19.createElement(Box, {
|
|
1850
|
+
shape,
|
|
1851
|
+
onAction: handleAction
|
|
1852
|
+
}, value !== null && /* @__PURE__ */ React19.createElement(Surface.Surface, {
|
|
1853
|
+
role: "card--extrinsic",
|
|
1854
|
+
data: {
|
|
1855
|
+
value
|
|
1856
|
+
},
|
|
1857
|
+
limit: 1
|
|
1858
|
+
}));
|
|
1976
1859
|
};
|
|
1977
1860
|
var surfaceShape = {
|
|
1978
1861
|
type: "surface",
|
|
@@ -1990,8 +1873,7 @@ var surfaceShape = {
|
|
|
1990
1873
|
};
|
|
1991
1874
|
|
|
1992
1875
|
// src/shapes/Switch.tsx
|
|
1993
|
-
import
|
|
1994
|
-
import { Schema as Schema19 } from "effect";
|
|
1876
|
+
import * as Schema19 from "effect/Schema";
|
|
1995
1877
|
import React20, { useEffect as useEffect6, useState as useState8 } from "react";
|
|
1996
1878
|
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT6 } from "@dxos/conductor";
|
|
1997
1879
|
import { Input as Input2 } from "@dxos/react-ui";
|
|
@@ -2008,25 +1890,20 @@ var createSwitch = (props) => createShape({
|
|
|
2008
1890
|
...props
|
|
2009
1891
|
});
|
|
2010
1892
|
var SwitchComponent = ({ shape }) => {
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
onCheckedChange: (value2) => setValue(value2)
|
|
2026
|
-
})));
|
|
2027
|
-
} finally {
|
|
2028
|
-
_effect.f();
|
|
2029
|
-
}
|
|
1893
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1894
|
+
const [value, setValue] = useState8(false);
|
|
1895
|
+
useEffect6(() => {
|
|
1896
|
+
runtime.setOutput(DEFAULT_OUTPUT6, value);
|
|
1897
|
+
}, [
|
|
1898
|
+
value
|
|
1899
|
+
]);
|
|
1900
|
+
return /* @__PURE__ */ React20.createElement("div", {
|
|
1901
|
+
className: "flex is-full justify-center items-center",
|
|
1902
|
+
onClick: (ev) => ev.stopPropagation()
|
|
1903
|
+
}, /* @__PURE__ */ React20.createElement(Input2.Root, null, /* @__PURE__ */ React20.createElement(Input2.Switch, {
|
|
1904
|
+
checked: value,
|
|
1905
|
+
onCheckedChange: (value2) => setValue(value2)
|
|
1906
|
+
})));
|
|
2030
1907
|
};
|
|
2031
1908
|
var switchShape = {
|
|
2032
1909
|
type: "switch",
|
|
@@ -2043,13 +1920,12 @@ var switchShape = {
|
|
|
2043
1920
|
};
|
|
2044
1921
|
|
|
2045
1922
|
// src/shapes/Table.tsx
|
|
2046
|
-
import
|
|
2047
|
-
import { Schema as Schema20 } from "effect";
|
|
1923
|
+
import * as Schema20 from "effect/Schema";
|
|
2048
1924
|
import React21 from "react";
|
|
2049
1925
|
import { createInputSchema, createOutputSchema } from "@dxos/conductor";
|
|
2050
|
-
import {
|
|
2051
|
-
var InputSchema = createInputSchema(
|
|
2052
|
-
var OutputSchema = createOutputSchema(Schema20.mutable(Schema20.Array(
|
|
1926
|
+
import { Message } from "@dxos/types";
|
|
1927
|
+
var InputSchema = createInputSchema(Message.Message);
|
|
1928
|
+
var OutputSchema = createOutputSchema(Schema20.mutable(Schema20.Array(Message.Message)));
|
|
2053
1929
|
var TableShape = Schema20.extend(ComputeShape, Schema20.Struct({
|
|
2054
1930
|
type: Schema20.Literal("table")
|
|
2055
1931
|
}));
|
|
@@ -2062,14 +1938,9 @@ var createTable = (props) => createShape({
|
|
|
2062
1938
|
...props
|
|
2063
1939
|
});
|
|
2064
1940
|
var TableComponent = ({ shape }) => {
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
shape
|
|
2069
|
-
});
|
|
2070
|
-
} finally {
|
|
2071
|
-
_effect.f();
|
|
2072
|
-
}
|
|
1941
|
+
return /* @__PURE__ */ React21.createElement(Box, {
|
|
1942
|
+
shape
|
|
1943
|
+
});
|
|
2073
1944
|
};
|
|
2074
1945
|
var tableShape = {
|
|
2075
1946
|
type: "table",
|
|
@@ -2082,11 +1953,10 @@ var tableShape = {
|
|
|
2082
1953
|
};
|
|
2083
1954
|
|
|
2084
1955
|
// src/shapes/Template.tsx
|
|
2085
|
-
import
|
|
2086
|
-
import { Schema as Schema21 } from "effect";
|
|
1956
|
+
import * as Schema21 from "effect/Schema";
|
|
2087
1957
|
import React22, { useRef as useRef5 } from "react";
|
|
2088
1958
|
import { ComputeValueType as ComputeValueType3, TemplateOutput, VoidInput as VoidInput2, getTemplateInputSchema as getTemplateInputSchema2 } from "@dxos/conductor";
|
|
2089
|
-
import { toJsonSchema
|
|
1959
|
+
import { toJsonSchema } from "@dxos/echo/internal";
|
|
2090
1960
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
2091
1961
|
import { TextBox as TextBox4 } from "@dxos/react-ui-canvas-editor";
|
|
2092
1962
|
var __dxlog_file6 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/Template.tsx";
|
|
@@ -2095,49 +1965,44 @@ var TemplateShape = Schema21.extend(ComputeShape, Schema21.Struct({
|
|
|
2095
1965
|
valueType: Schema21.optional(ComputeValueType3)
|
|
2096
1966
|
}));
|
|
2097
1967
|
var TextInputComponent3 = ({ shape, title, ...props }) => {
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
const
|
|
2102
|
-
|
|
2103
|
-
const
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
onEnter: handleEnter
|
|
2137
|
-
}));
|
|
2138
|
-
} finally {
|
|
2139
|
-
_effect.f();
|
|
2140
|
-
}
|
|
1968
|
+
const { node } = useComputeNodeState(shape);
|
|
1969
|
+
const inputRef = useRef5(null);
|
|
1970
|
+
const handleEnter = (text) => {
|
|
1971
|
+
const value = text.trim();
|
|
1972
|
+
if (value.length) {
|
|
1973
|
+
const schema = getTemplateInputSchema2(node);
|
|
1974
|
+
node.value = value;
|
|
1975
|
+
node.inputSchema = toJsonSchema(schema);
|
|
1976
|
+
}
|
|
1977
|
+
};
|
|
1978
|
+
const handleTypeChange = (newType) => {
|
|
1979
|
+
invariant5(Schema21.is(ComputeValueType3)(newType), "Invalid type", {
|
|
1980
|
+
F: __dxlog_file6,
|
|
1981
|
+
L: 59,
|
|
1982
|
+
S: void 0,
|
|
1983
|
+
A: [
|
|
1984
|
+
"Schema.is(ComputeValueType)(newType)",
|
|
1985
|
+
"'Invalid type'"
|
|
1986
|
+
]
|
|
1987
|
+
});
|
|
1988
|
+
node.valueType = newType;
|
|
1989
|
+
node.inputSchema = toJsonSchema(getTemplateInputSchema2(node));
|
|
1990
|
+
};
|
|
1991
|
+
return /* @__PURE__ */ React22.createElement(Box, {
|
|
1992
|
+
shape,
|
|
1993
|
+
title: "Template",
|
|
1994
|
+
status: /* @__PURE__ */ React22.createElement(TypeSelect, {
|
|
1995
|
+
value: node.valueType ?? "string",
|
|
1996
|
+
onValueChange: handleTypeChange
|
|
1997
|
+
})
|
|
1998
|
+
}, /* @__PURE__ */ React22.createElement(TextBox4, {
|
|
1999
|
+
...props,
|
|
2000
|
+
ref: inputRef,
|
|
2001
|
+
value: node.value,
|
|
2002
|
+
language: node.valueType === "object" ? "json" : void 0,
|
|
2003
|
+
onBlur: handleEnter,
|
|
2004
|
+
onEnter: handleEnter
|
|
2005
|
+
}));
|
|
2141
2006
|
};
|
|
2142
2007
|
var createTemplate = (props) => createShape({
|
|
2143
2008
|
type: "template",
|
|
@@ -2161,8 +2026,7 @@ var templateShape = {
|
|
|
2161
2026
|
};
|
|
2162
2027
|
|
|
2163
2028
|
// src/shapes/Text.tsx
|
|
2164
|
-
import
|
|
2165
|
-
import { Schema as Schema22 } from "effect";
|
|
2029
|
+
import * as Schema22 from "effect/Schema";
|
|
2166
2030
|
import React23 from "react";
|
|
2167
2031
|
import { DEFAULT_INPUT as DEFAULT_INPUT7 } from "@dxos/conductor";
|
|
2168
2032
|
import { TextBox as TextBox5 } from "@dxos/react-ui-canvas-editor";
|
|
@@ -2179,25 +2043,20 @@ var createText = (props) => createShape({
|
|
|
2179
2043
|
...props
|
|
2180
2044
|
});
|
|
2181
2045
|
var TextComponent = ({ shape }) => {
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
value
|
|
2197
|
-
}));
|
|
2198
|
-
} finally {
|
|
2199
|
-
_effect.f();
|
|
2200
|
-
}
|
|
2046
|
+
const { runtime } = useComputeNodeState(shape);
|
|
2047
|
+
const input = runtime.inputs[DEFAULT_INPUT7];
|
|
2048
|
+
const value = input?.type === "executed" ? input.value : 0;
|
|
2049
|
+
const handleAction = (action) => {
|
|
2050
|
+
if (action === "run") {
|
|
2051
|
+
runtime.evalNode();
|
|
2052
|
+
}
|
|
2053
|
+
};
|
|
2054
|
+
return /* @__PURE__ */ React23.createElement(Box, {
|
|
2055
|
+
shape,
|
|
2056
|
+
onAction: handleAction
|
|
2057
|
+
}, /* @__PURE__ */ React23.createElement(TextBox5, {
|
|
2058
|
+
value
|
|
2059
|
+
}));
|
|
2201
2060
|
};
|
|
2202
2061
|
var textShape = {
|
|
2203
2062
|
type: "text",
|
|
@@ -2215,14 +2074,14 @@ var textShape = {
|
|
|
2215
2074
|
};
|
|
2216
2075
|
|
|
2217
2076
|
// src/shapes/Thread.tsx
|
|
2218
|
-
import
|
|
2219
|
-
import { Schema as Schema23 } from "effect";
|
|
2077
|
+
import * as Schema23 from "effect/Schema";
|
|
2220
2078
|
import React24, { useEffect as useEffect7, useRef as useRef6 } from "react";
|
|
2221
2079
|
import { createInputSchema as createInputSchema2, createOutputSchema as createOutputSchema2 } from "@dxos/conductor";
|
|
2222
|
-
import {
|
|
2223
|
-
import {
|
|
2224
|
-
|
|
2225
|
-
var
|
|
2080
|
+
import { ScrollArea as ScrollArea3 } from "@dxos/react-ui";
|
|
2081
|
+
import { Message as Message2 } from "@dxos/types";
|
|
2082
|
+
import { mx as mx3 } from "@dxos/ui-theme";
|
|
2083
|
+
var InputSchema2 = createInputSchema2(Message2.Message);
|
|
2084
|
+
var OutputSchema2 = createOutputSchema2(Schema23.mutable(Schema23.Array(Message2.Message)));
|
|
2226
2085
|
var ThreadShape = Schema23.extend(ComputeShape, Schema23.Struct({
|
|
2227
2086
|
type: Schema23.Literal("thread")
|
|
2228
2087
|
}));
|
|
@@ -2235,49 +2094,42 @@ var createThread = (props) => createShape({
|
|
|
2235
2094
|
...props
|
|
2236
2095
|
});
|
|
2237
2096
|
var ThreadComponent = ({ shape }) => {
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
} finally {
|
|
2261
|
-
_effect.f();
|
|
2262
|
-
}
|
|
2097
|
+
const items = [];
|
|
2098
|
+
const scrollRef = useRef6(null);
|
|
2099
|
+
useEffect7(() => {
|
|
2100
|
+
if (scrollRef.current) {
|
|
2101
|
+
scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
|
|
2102
|
+
}
|
|
2103
|
+
}, [
|
|
2104
|
+
items
|
|
2105
|
+
]);
|
|
2106
|
+
return /* @__PURE__ */ React24.createElement(Box, {
|
|
2107
|
+
shape
|
|
2108
|
+
}, /* @__PURE__ */ React24.createElement(ScrollArea3.Root, {
|
|
2109
|
+
orientation: "vertical"
|
|
2110
|
+
}, /* @__PURE__ */ React24.createElement(ScrollArea3.Viewport, {
|
|
2111
|
+
classNames: "gap-2 p-2",
|
|
2112
|
+
ref: scrollRef
|
|
2113
|
+
}, [
|
|
2114
|
+
...items
|
|
2115
|
+
].map((item, i) => /* @__PURE__ */ React24.createElement(ThreadItem, {
|
|
2116
|
+
key: i,
|
|
2117
|
+
item
|
|
2118
|
+
})))));
|
|
2263
2119
|
};
|
|
2264
2120
|
var ThreadItem = ({ classNames, item }) => {
|
|
2265
|
-
|
|
2266
|
-
try {
|
|
2267
|
-
if (typeof item !== "object") {
|
|
2268
|
-
return /* @__PURE__ */ React24.createElement("div", {
|
|
2269
|
-
className: mx3(classNames)
|
|
2270
|
-
}, item);
|
|
2271
|
-
}
|
|
2272
|
-
const { role, message } = item;
|
|
2121
|
+
if (typeof item !== "object") {
|
|
2273
2122
|
return /* @__PURE__ */ React24.createElement("div", {
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
}, message));
|
|
2278
|
-
} finally {
|
|
2279
|
-
_effect.f();
|
|
2123
|
+
role: "none",
|
|
2124
|
+
className: mx3(classNames)
|
|
2125
|
+
}, item);
|
|
2280
2126
|
}
|
|
2127
|
+
const { role, message } = item;
|
|
2128
|
+
return /* @__PURE__ */ React24.createElement("div", {
|
|
2129
|
+
className: mx3("flex", classNames, role === "user" && "justify-end")
|
|
2130
|
+
}, /* @__PURE__ */ React24.createElement("div", {
|
|
2131
|
+
className: mx3("block rounded-md p-1 pli-2 text-sm", role === "user" ? "bg-blue-100 dark:bg-blue-800" : role === "system" ? "bg-red-100, dark:bg-red-800" : "whitespace-pre-wrap bg-neutral-50 dark:bg-neutral-800")
|
|
2132
|
+
}, message));
|
|
2281
2133
|
};
|
|
2282
2134
|
var threadShape = {
|
|
2283
2135
|
type: "thread",
|
|
@@ -2290,8 +2142,7 @@ var threadShape = {
|
|
|
2290
2142
|
};
|
|
2291
2143
|
|
|
2292
2144
|
// src/shapes/TextToImage.tsx
|
|
2293
|
-
import
|
|
2294
|
-
import { Schema as Schema24 } from "effect";
|
|
2145
|
+
import * as Schema24 from "effect/Schema";
|
|
2295
2146
|
import React25 from "react";
|
|
2296
2147
|
import { createAnchorMap as createAnchorMap12 } from "@dxos/react-ui-canvas-editor";
|
|
2297
2148
|
var TextToImageShape = Schema24.extend(ComputeShape, Schema24.Struct({
|
|
@@ -2306,14 +2157,9 @@ var createTextToImage = (props) => createShape({
|
|
|
2306
2157
|
...props
|
|
2307
2158
|
});
|
|
2308
2159
|
var TextToImageComponent = ({ shape }) => {
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
shape
|
|
2313
|
-
});
|
|
2314
|
-
} finally {
|
|
2315
|
-
_effect.f();
|
|
2316
|
-
}
|
|
2160
|
+
return /* @__PURE__ */ React25.createElement(Box, {
|
|
2161
|
+
shape
|
|
2162
|
+
});
|
|
2317
2163
|
};
|
|
2318
2164
|
var textToImageShape = {
|
|
2319
2165
|
type: "text-to-image",
|
|
@@ -2330,22 +2176,20 @@ var textToImageShape = {
|
|
|
2330
2176
|
};
|
|
2331
2177
|
|
|
2332
2178
|
// src/shapes/Trigger.tsx
|
|
2333
|
-
import
|
|
2334
|
-
import { Schema as Schema25 } from "effect";
|
|
2179
|
+
import * as Schema25 from "effect/Schema";
|
|
2335
2180
|
import React26, { useEffect as useEffect8 } from "react";
|
|
2336
2181
|
import { VoidInput as VoidInput3 } from "@dxos/conductor";
|
|
2337
|
-
import { Filter as Filter2, Obj, Query } from "@dxos/echo";
|
|
2338
|
-
import {
|
|
2339
|
-
import { EmailTriggerOutput, FunctionTrigger, QueueTriggerOutput, SubscriptionTriggerOutput, TimerTriggerOutput, TriggerKinds, WebhookTriggerOutput } from "@dxos/functions";
|
|
2182
|
+
import { Filter as Filter2, Obj as Obj4, Query, Ref as Ref3, Type } from "@dxos/echo";
|
|
2183
|
+
import { Trigger, TriggerEvent } from "@dxos/functions";
|
|
2340
2184
|
import { DXN, SpaceId } from "@dxos/keys";
|
|
2341
2185
|
import { useSpace } from "@dxos/react-client/echo";
|
|
2342
2186
|
import { Select as Select2 } from "@dxos/react-ui";
|
|
2343
2187
|
var TriggerShape = Schema25.extend(ComputeShape, Schema25.Struct({
|
|
2344
2188
|
type: Schema25.Literal("trigger"),
|
|
2345
|
-
functionTrigger: Schema25.optional(
|
|
2189
|
+
functionTrigger: Schema25.optional(Type.Ref(Trigger.Trigger))
|
|
2346
2190
|
}));
|
|
2347
2191
|
var createTrigger = (props) => {
|
|
2348
|
-
const functionTrigger =
|
|
2192
|
+
const functionTrigger = Trigger.make({
|
|
2349
2193
|
enabled: true,
|
|
2350
2194
|
spec: createTriggerSpec(props)
|
|
2351
2195
|
});
|
|
@@ -2354,72 +2198,66 @@ var createTrigger = (props) => {
|
|
|
2354
2198
|
functionTrigger: Ref3.make(functionTrigger),
|
|
2355
2199
|
size: {
|
|
2356
2200
|
width: 192,
|
|
2357
|
-
height: getHeight(
|
|
2201
|
+
height: getHeight(TriggerEvent.EmailEvent)
|
|
2358
2202
|
},
|
|
2359
2203
|
...props
|
|
2360
2204
|
});
|
|
2361
2205
|
};
|
|
2362
2206
|
var TriggerComponent = ({ shape }) => {
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
functionTrigger.spec = createTriggerSpec({
|
|
2207
|
+
const space = useSpace();
|
|
2208
|
+
const functionTrigger = shape.functionTrigger?.target;
|
|
2209
|
+
useEffect8(() => {
|
|
2210
|
+
if (functionTrigger && !functionTrigger.spec) {
|
|
2211
|
+
Obj4.change(functionTrigger, (t) => {
|
|
2212
|
+
t.spec = createTriggerSpec({
|
|
2370
2213
|
triggerKind: "email",
|
|
2371
2214
|
spaceId: space?.id
|
|
2372
2215
|
});
|
|
2373
|
-
}
|
|
2374
|
-
}
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2216
|
+
});
|
|
2217
|
+
}
|
|
2218
|
+
}, [
|
|
2219
|
+
functionTrigger,
|
|
2220
|
+
functionTrigger?.spec
|
|
2221
|
+
]);
|
|
2222
|
+
useEffect8(() => {
|
|
2223
|
+
shape.size.height = getHeight(getOutputSchema(functionTrigger?.spec?.kind ?? "email"));
|
|
2224
|
+
}, [
|
|
2225
|
+
functionTrigger?.spec?.kind
|
|
2226
|
+
]);
|
|
2227
|
+
const setKind = (kind) => {
|
|
2228
|
+
if (functionTrigger?.spec?.kind !== kind) {
|
|
2229
|
+
Obj4.change(functionTrigger, (t) => {
|
|
2230
|
+
t.spec = createTriggerSpec({
|
|
2386
2231
|
triggerKind: kind,
|
|
2387
2232
|
spaceId: space?.id
|
|
2388
2233
|
});
|
|
2389
|
-
}
|
|
2390
|
-
};
|
|
2391
|
-
if (!functionTrigger?.spec) {
|
|
2392
|
-
return;
|
|
2234
|
+
});
|
|
2393
2235
|
}
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
value: functionTrigger.spec?.kind,
|
|
2398
|
-
onValueChange: (kind) => setKind(kind)
|
|
2399
|
-
}),
|
|
2400
|
-
inputSchema: VoidInput3,
|
|
2401
|
-
outputSchema: getOutputSchema(functionTrigger.spec.kind)
|
|
2402
|
-
});
|
|
2403
|
-
} finally {
|
|
2404
|
-
_effect.f();
|
|
2236
|
+
};
|
|
2237
|
+
if (!functionTrigger?.spec) {
|
|
2238
|
+
return;
|
|
2405
2239
|
}
|
|
2240
|
+
return /* @__PURE__ */ React26.createElement(FunctionBody, {
|
|
2241
|
+
shape,
|
|
2242
|
+
status: /* @__PURE__ */ React26.createElement(TriggerKindSelect, {
|
|
2243
|
+
value: functionTrigger.spec?.kind,
|
|
2244
|
+
onValueChange: (kind) => setKind(kind)
|
|
2245
|
+
}),
|
|
2246
|
+
inputSchema: VoidInput3,
|
|
2247
|
+
outputSchema: getOutputSchema(functionTrigger.spec.kind)
|
|
2248
|
+
});
|
|
2406
2249
|
};
|
|
2407
2250
|
var TriggerKindSelect = ({ value, onValueChange }) => {
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
value: kind
|
|
2419
|
-
}, kind))), /* @__PURE__ */ React26.createElement(Select2.ScrollDownButton, null), /* @__PURE__ */ React26.createElement(Select2.Arrow, null))));
|
|
2420
|
-
} finally {
|
|
2421
|
-
_effect.f();
|
|
2422
|
-
}
|
|
2251
|
+
return /* @__PURE__ */ React26.createElement(Select2.Root, {
|
|
2252
|
+
value,
|
|
2253
|
+
onValueChange
|
|
2254
|
+
}, /* @__PURE__ */ React26.createElement(Select2.TriggerButton, {
|
|
2255
|
+
variant: "ghost",
|
|
2256
|
+
classNames: "is-full !pli-0"
|
|
2257
|
+
}), /* @__PURE__ */ React26.createElement(Select2.Portal, null, /* @__PURE__ */ React26.createElement(Select2.Content, null, /* @__PURE__ */ React26.createElement(Select2.ScrollUpButton, null), /* @__PURE__ */ React26.createElement(Select2.Viewport, null, Trigger.Kinds.map((kind) => /* @__PURE__ */ React26.createElement(Select2.Option, {
|
|
2258
|
+
key: kind,
|
|
2259
|
+
value: kind
|
|
2260
|
+
}, kind))), /* @__PURE__ */ React26.createElement(Select2.ScrollDownButton, null), /* @__PURE__ */ React26.createElement(Select2.Arrow, null))));
|
|
2423
2261
|
};
|
|
2424
2262
|
var createTriggerSpec = (props) => {
|
|
2425
2263
|
const kind = props.triggerKind ?? "email";
|
|
@@ -2437,7 +2275,9 @@ var createTriggerSpec = (props) => {
|
|
|
2437
2275
|
case "subscription":
|
|
2438
2276
|
return {
|
|
2439
2277
|
kind: "subscription",
|
|
2440
|
-
query:
|
|
2278
|
+
query: {
|
|
2279
|
+
ast: Query.select(Filter2.nothing()).ast
|
|
2280
|
+
}
|
|
2441
2281
|
};
|
|
2442
2282
|
case "email":
|
|
2443
2283
|
return {
|
|
@@ -2447,7 +2287,7 @@ var createTriggerSpec = (props) => {
|
|
|
2447
2287
|
const dxn = new DXN(DXN.kind.QUEUE, [
|
|
2448
2288
|
"data",
|
|
2449
2289
|
props.spaceId ?? SpaceId.random(),
|
|
2450
|
-
|
|
2290
|
+
Obj4.ID.random()
|
|
2451
2291
|
]).toString();
|
|
2452
2292
|
return {
|
|
2453
2293
|
kind: "queue",
|
|
@@ -2458,11 +2298,11 @@ var createTriggerSpec = (props) => {
|
|
|
2458
2298
|
};
|
|
2459
2299
|
var getOutputSchema = (kind) => {
|
|
2460
2300
|
const kindToSchema = {
|
|
2461
|
-
["email"]:
|
|
2462
|
-
["subscription"]:
|
|
2463
|
-
["timer"]:
|
|
2464
|
-
["webhook"]:
|
|
2465
|
-
["queue"]:
|
|
2301
|
+
["email"]: TriggerEvent.EmailEvent,
|
|
2302
|
+
["subscription"]: TriggerEvent.SubscriptionEvent,
|
|
2303
|
+
["timer"]: TriggerEvent.TimerEvent,
|
|
2304
|
+
["webhook"]: TriggerEvent.WebhookEvent,
|
|
2305
|
+
["queue"]: TriggerEvent.QueueEvent
|
|
2466
2306
|
};
|
|
2467
2307
|
return kindToSchema[kind];
|
|
2468
2308
|
};
|
|
@@ -2476,8 +2316,7 @@ var triggerShape = {
|
|
|
2476
2316
|
};
|
|
2477
2317
|
|
|
2478
2318
|
// src/shapes/GptRealtime.tsx
|
|
2479
|
-
import
|
|
2480
|
-
import { Schema as Schema26 } from "effect";
|
|
2319
|
+
import * as Schema26 from "effect/Schema";
|
|
2481
2320
|
import React27, { useState as useState9 } from "react";
|
|
2482
2321
|
import { log as log2 } from "@dxos/log";
|
|
2483
2322
|
import { useConfig } from "@dxos/react-client";
|
|
@@ -2495,105 +2334,100 @@ var createGptRealtime = (props) => createShape({
|
|
|
2495
2334
|
...props
|
|
2496
2335
|
});
|
|
2497
2336
|
var GptRealtimeComponent = ({ shape }) => {
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
const
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2337
|
+
const [isLive, setIsLive] = useState9(false);
|
|
2338
|
+
const [isReady, setIsReady] = useState9(false);
|
|
2339
|
+
const config = useConfig();
|
|
2340
|
+
const start = async () => {
|
|
2341
|
+
setIsLive(true);
|
|
2342
|
+
try {
|
|
2343
|
+
const peerConnection = new RTCPeerConnection();
|
|
2344
|
+
peerConnection.ontrack = (event) => {
|
|
2345
|
+
const audioElement = document.createElement("audio");
|
|
2346
|
+
audioElement.srcObject = event.streams[0];
|
|
2347
|
+
audioElement.autoplay = true;
|
|
2348
|
+
audioElement.controls = false;
|
|
2349
|
+
audioElement.style.display = "none";
|
|
2350
|
+
document.body.appendChild(audioElement);
|
|
2351
|
+
setIsReady(true);
|
|
2352
|
+
};
|
|
2353
|
+
const stream = await navigator.mediaDevices.getUserMedia({
|
|
2354
|
+
audio: true
|
|
2355
|
+
});
|
|
2356
|
+
stream.getTracks().forEach((track) => peerConnection.addTransceiver(track, {
|
|
2357
|
+
direction: "sendrecv"
|
|
2358
|
+
}));
|
|
2359
|
+
const offer = await peerConnection.createOffer();
|
|
2360
|
+
await peerConnection.setLocalDescription(offer);
|
|
2361
|
+
const AiServiceUrl = new URL("/rtc-connect", config.values.runtime?.services?.ai?.server ?? DEFAULT_AI_SERVICE_URL);
|
|
2362
|
+
const response = await fetch(AiServiceUrl, {
|
|
2363
|
+
method: "POST",
|
|
2364
|
+
body: offer.sdp,
|
|
2365
|
+
headers: {
|
|
2366
|
+
"Content-Type": "application/sdp"
|
|
2367
|
+
}
|
|
2368
|
+
});
|
|
2369
|
+
const answer = await response.text();
|
|
2370
|
+
await peerConnection.setRemoteDescription({
|
|
2371
|
+
sdp: answer,
|
|
2372
|
+
type: "answer"
|
|
2373
|
+
});
|
|
2374
|
+
const dataChannel = peerConnection.createDataChannel("response");
|
|
2375
|
+
const configureData = () => {
|
|
2376
|
+
log2.info("Configuring data channel", void 0, {
|
|
2377
|
+
F: __dxlog_file7,
|
|
2378
|
+
L: 87,
|
|
2379
|
+
S: void 0,
|
|
2380
|
+
C: (f, a) => f(...a)
|
|
2518
2381
|
});
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
headers: {
|
|
2529
|
-
"Content-Type": "application/sdp"
|
|
2382
|
+
const event = {
|
|
2383
|
+
type: "session.update",
|
|
2384
|
+
session: {
|
|
2385
|
+
modalities: [
|
|
2386
|
+
"text",
|
|
2387
|
+
"audio"
|
|
2388
|
+
],
|
|
2389
|
+
// Provide the tools. Note they match the keys in the `fns` object above
|
|
2390
|
+
tools: []
|
|
2530
2391
|
}
|
|
2531
|
-
});
|
|
2532
|
-
const answer = await response.text();
|
|
2533
|
-
await peerConnection.setRemoteDescription({
|
|
2534
|
-
sdp: answer,
|
|
2535
|
-
type: "answer"
|
|
2536
|
-
});
|
|
2537
|
-
const dataChannel = peerConnection.createDataChannel("response");
|
|
2538
|
-
const configureData = () => {
|
|
2539
|
-
log2.info("Configuring data channel", void 0, {
|
|
2540
|
-
F: __dxlog_file7,
|
|
2541
|
-
L: 87,
|
|
2542
|
-
S: void 0,
|
|
2543
|
-
C: (f, a) => f(...a)
|
|
2544
|
-
});
|
|
2545
|
-
const event = {
|
|
2546
|
-
type: "session.update",
|
|
2547
|
-
session: {
|
|
2548
|
-
modalities: [
|
|
2549
|
-
"text",
|
|
2550
|
-
"audio"
|
|
2551
|
-
],
|
|
2552
|
-
// Provide the tools. Note they match the keys in the `fns` object above
|
|
2553
|
-
tools: []
|
|
2554
|
-
}
|
|
2555
|
-
};
|
|
2556
|
-
dataChannel.send(JSON.stringify(event));
|
|
2557
2392
|
};
|
|
2558
|
-
dataChannel.
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
L: 100,
|
|
2564
|
-
S: void 0,
|
|
2565
|
-
C: (f, a) => f(...a)
|
|
2566
|
-
});
|
|
2567
|
-
configureData();
|
|
2568
|
-
});
|
|
2569
|
-
dataChannel.addEventListener("message", async (ev) => {
|
|
2570
|
-
const msg = JSON.parse(ev.data);
|
|
2571
|
-
if (msg.type === "response.function_call_arguments.done") {
|
|
2572
|
-
}
|
|
2573
|
-
});
|
|
2574
|
-
} catch (error) {
|
|
2575
|
-
log2.error("Error in realtime session:", {
|
|
2576
|
-
error
|
|
2393
|
+
dataChannel.send(JSON.stringify(event));
|
|
2394
|
+
};
|
|
2395
|
+
dataChannel.addEventListener("open", (ev) => {
|
|
2396
|
+
log2.info("Opening data channel", {
|
|
2397
|
+
ev
|
|
2577
2398
|
}, {
|
|
2578
2399
|
F: __dxlog_file7,
|
|
2579
|
-
L:
|
|
2400
|
+
L: 100,
|
|
2580
2401
|
S: void 0,
|
|
2581
2402
|
C: (f, a) => f(...a)
|
|
2582
2403
|
});
|
|
2583
|
-
|
|
2584
|
-
}
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2404
|
+
configureData();
|
|
2405
|
+
});
|
|
2406
|
+
dataChannel.addEventListener("message", async (ev) => {
|
|
2407
|
+
const msg = JSON.parse(ev.data);
|
|
2408
|
+
if (msg.type === "response.function_call_arguments.done") {
|
|
2409
|
+
}
|
|
2410
|
+
});
|
|
2411
|
+
} catch (error) {
|
|
2412
|
+
log2.error("Error in realtime session:", {
|
|
2413
|
+
error
|
|
2414
|
+
}, {
|
|
2415
|
+
F: __dxlog_file7,
|
|
2416
|
+
L: 140,
|
|
2417
|
+
S: void 0,
|
|
2418
|
+
C: (f, a) => f(...a)
|
|
2419
|
+
});
|
|
2420
|
+
throw error;
|
|
2421
|
+
}
|
|
2422
|
+
};
|
|
2423
|
+
return /* @__PURE__ */ React27.createElement("div", {
|
|
2424
|
+
className: "flex is-full justify-center items-center"
|
|
2425
|
+
}, /* @__PURE__ */ React27.createElement(Icon5, {
|
|
2426
|
+
icon: isReady ? "ph--waveform--regular" : isLive ? "ph--pulse--regular" : "ph--play--regular",
|
|
2427
|
+
size: 16,
|
|
2428
|
+
classNames: !isLive && "cursor-pointer",
|
|
2429
|
+
onClick: start
|
|
2430
|
+
}));
|
|
2597
2431
|
};
|
|
2598
2432
|
var gptRealtimeShape = {
|
|
2599
2433
|
type: "gpt-realtime",
|
|
@@ -2673,22 +2507,13 @@ var computeShapes = [
|
|
|
2673
2507
|
|
|
2674
2508
|
// src/compute-layout.ts
|
|
2675
2509
|
import { DefaultInput, DefaultOutput as DefaultOutput2 } from "@dxos/conductor";
|
|
2676
|
-
import { toEffectSchema } from "@dxos/echo
|
|
2510
|
+
import { toEffectSchema } from "@dxos/echo/internal";
|
|
2677
2511
|
import { ShapeLayout } from "@dxos/react-ui-canvas-editor";
|
|
2678
|
-
function _define_property2(obj, key, value) {
|
|
2679
|
-
if (key in obj) {
|
|
2680
|
-
Object.defineProperty(obj, key, {
|
|
2681
|
-
value,
|
|
2682
|
-
enumerable: true,
|
|
2683
|
-
configurable: true,
|
|
2684
|
-
writable: true
|
|
2685
|
-
});
|
|
2686
|
-
} else {
|
|
2687
|
-
obj[key] = value;
|
|
2688
|
-
}
|
|
2689
|
-
return obj;
|
|
2690
|
-
}
|
|
2691
2512
|
var ComputeShapeLayout = class extends ShapeLayout {
|
|
2513
|
+
_controller;
|
|
2514
|
+
constructor(_controller, registry2) {
|
|
2515
|
+
super(registry2), this._controller = _controller;
|
|
2516
|
+
}
|
|
2692
2517
|
// TODO(burdon): Doesn't update.
|
|
2693
2518
|
getAnchors(shape) {
|
|
2694
2519
|
const shapeDef = this._registry.getShapeDef(shape.type);
|
|
@@ -2703,9 +2528,6 @@ var ComputeShapeLayout = class extends ShapeLayout {
|
|
|
2703
2528
|
}
|
|
2704
2529
|
return anchors;
|
|
2705
2530
|
}
|
|
2706
|
-
constructor(_controller, registry2) {
|
|
2707
|
-
super(registry2), _define_property2(this, "_controller", void 0), this._controller = _controller;
|
|
2708
|
-
}
|
|
2709
2531
|
};
|
|
2710
2532
|
export {
|
|
2711
2533
|
AndShape,
|