@dxos/react-ui-canvas-compute 0.8.4-main.937b3ca → 0.8.4-main.9be5663bfe
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 +399 -389
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +399 -389
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/compute.stories.d.ts.map +1 -1
- package/dist/types/src/graph/controller.d.ts +2 -2
- package/dist/types/src/graph/controller.d.ts.map +1 -1
- 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/shapes/Audio.d.ts.map +1 -1
- package/dist/types/src/shapes/Beacon.d.ts.map +1 -1
- package/dist/types/src/shapes/Chat.d.ts.map +1 -1
- package/dist/types/src/shapes/Constant.d.ts.map +1 -1
- package/dist/types/src/shapes/{Queue.d.ts → Feed.d.ts} +8 -8
- package/dist/types/src/shapes/Feed.d.ts.map +1 -0
- package/dist/types/src/shapes/Function.d.ts.map +1 -1
- package/dist/types/src/shapes/Gpt.d.ts.map +1 -1
- package/dist/types/src/shapes/Json.d.ts.map +1 -1
- package/dist/types/src/shapes/RNG.d.ts.map +1 -1
- package/dist/types/src/shapes/Scope.d.ts.map +1 -1
- package/dist/types/src/shapes/Surface.d.ts.map +1 -1
- package/dist/types/src/shapes/Switch.d.ts.map +1 -1
- package/dist/types/src/shapes/Template.d.ts.map +1 -1
- package/dist/types/src/shapes/Text.d.ts.map +1 -1
- package/dist/types/src/shapes/Thread.d.ts.map +1 -1
- package/dist/types/src/shapes/Trigger.d.ts +2 -1
- package/dist/types/src/shapes/Trigger.d.ts.map +1 -1
- package/dist/types/src/shapes/common/Box.d.ts +3 -3
- package/dist/types/src/shapes/common/Box.d.ts.map +1 -1
- package/dist/types/src/shapes/common/FunctionBody.d.ts +2 -2
- package/dist/types/src/shapes/common/FunctionBody.d.ts.map +1 -1
- package/dist/types/src/shapes/index.d.ts +2 -2
- package/dist/types/src/shapes/index.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +50 -48
- package/src/README.md +0 -3
- package/src/compute.stories.tsx +17 -9
- package/src/graph/controller.ts +5 -2
- package/src/graph/node-defs.ts +28 -28
- package/src/hooks/useComputeNodeState.ts +0 -1
- package/src/hooks/useGraphMonitor.ts +5 -5
- package/src/registry.ts +2 -2
- package/src/schema.test.ts +3 -3
- package/src/shapes/Audio.tsx +2 -3
- package/src/shapes/Beacon.tsx +1 -2
- package/src/shapes/Boolean.tsx +2 -2
- package/src/shapes/Chat.tsx +0 -1
- package/src/shapes/Constant.tsx +0 -1
- package/src/shapes/{Queue.tsx → Feed.tsx} +21 -20
- package/src/shapes/Function.tsx +3 -3
- package/src/shapes/Gpt.tsx +6 -2
- package/src/shapes/GptRealtime.tsx +1 -1
- package/src/shapes/Json.tsx +7 -3
- package/src/shapes/RNG.tsx +0 -1
- package/src/shapes/Scope.tsx +1 -2
- package/src/shapes/Surface.tsx +4 -3
- package/src/shapes/Switch.tsx +1 -2
- package/src/shapes/Template.tsx +0 -1
- package/src/shapes/Text.tsx +0 -1
- package/src/shapes/Thread.tsx +14 -8
- package/src/shapes/Trigger.tsx +9 -9
- package/src/shapes/common/Box.tsx +7 -10
- package/src/shapes/common/FunctionBody.tsx +4 -4
- package/src/shapes/common/TypeSelect.tsx +1 -1
- package/src/shapes/index.ts +2 -2
- package/src/testing/circuits.ts +2 -2
- package/dist/types/src/shapes/Queue.d.ts.map +0 -1
|
@@ -10,7 +10,7 @@ import { Event, synchronized } from "@dxos/async";
|
|
|
10
10
|
import { GraphExecutor, ValueBag, isNotExecuted } from "@dxos/conductor";
|
|
11
11
|
import { Resource } from "@dxos/context";
|
|
12
12
|
import { unwrapExit } from "@dxos/effect";
|
|
13
|
-
import { ComputeEventLogger, TracingService } from "@dxos/functions";
|
|
13
|
+
import { ComputeEventLogger, Trace, TracingService } from "@dxos/functions";
|
|
14
14
|
import { log } from "@dxos/log";
|
|
15
15
|
|
|
16
16
|
// src/hooks/compute-context.ts
|
|
@@ -80,7 +80,7 @@ var useComputeNodeState = (shape) => {
|
|
|
80
80
|
const { controller } = useComputeContext();
|
|
81
81
|
invariant(controller, void 0, {
|
|
82
82
|
F: __dxlog_file,
|
|
83
|
-
L:
|
|
83
|
+
L: 33,
|
|
84
84
|
S: void 0,
|
|
85
85
|
A: [
|
|
86
86
|
"controller",
|
|
@@ -93,7 +93,7 @@ var useComputeNodeState = (shape) => {
|
|
|
93
93
|
queueMicrotask(async () => {
|
|
94
94
|
invariant(shape.node, "Node not specified", {
|
|
95
95
|
F: __dxlog_file,
|
|
96
|
-
L:
|
|
96
|
+
L: 39,
|
|
97
97
|
S: void 0,
|
|
98
98
|
A: [
|
|
99
99
|
"shape.node",
|
|
@@ -255,9 +255,9 @@ var linkTriggerToCompute = (graph, computeNode, triggerData) => {
|
|
|
255
255
|
""
|
|
256
256
|
]
|
|
257
257
|
});
|
|
258
|
-
Obj.change(functionTrigger, (
|
|
259
|
-
|
|
260
|
-
|
|
258
|
+
Obj.change(functionTrigger, (functionTrigger2) => {
|
|
259
|
+
functionTrigger2.function = Ref.make(graph.root);
|
|
260
|
+
functionTrigger2.inputNodeId = computeNode.id;
|
|
261
261
|
});
|
|
262
262
|
};
|
|
263
263
|
var deleteTriggerObjects = (computeGraph, deleted) => {
|
|
@@ -305,33 +305,33 @@ var nodeFactory = {
|
|
|
305
305
|
[NODE_INPUT]: () => createNode(NODE_INPUT),
|
|
306
306
|
[NODE_OUTPUT]: () => createNode(NODE_OUTPUT),
|
|
307
307
|
// Extensions.
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
308
|
+
"text-to-image": () => createNode("text-to-image"),
|
|
309
|
+
and: () => createNode("and"),
|
|
310
|
+
append: () => createNode("append"),
|
|
311
|
+
audio: () => createNode("audio"),
|
|
312
|
+
beacon: () => createNode("beacon"),
|
|
313
|
+
chat: () => createNode("chat"),
|
|
314
|
+
constant: (shape) => createNode("constant", {
|
|
315
315
|
value: shape.value
|
|
316
316
|
}),
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
317
|
+
"make-queue": () => createNode("make-queue"),
|
|
318
|
+
database: () => createNode("database"),
|
|
319
|
+
gpt: () => createNode("gpt"),
|
|
320
|
+
"gpt-realtime": () => createNode("gpt-realtime"),
|
|
321
|
+
if: () => createNode("if"),
|
|
322
|
+
"if-else": () => createNode("if-else"),
|
|
323
|
+
function: () => createNode("function"),
|
|
324
|
+
json: () => createNode("json"),
|
|
325
|
+
"json-transform": () => createNode("json-transform"),
|
|
326
|
+
not: () => createNode("not"),
|
|
327
|
+
or: () => createNode("or"),
|
|
328
|
+
queue: () => createNode("queue"),
|
|
329
|
+
rng: () => createNode("rng"),
|
|
330
|
+
reducer: () => createNode("reducer"),
|
|
331
|
+
scope: () => createNode("scope"),
|
|
332
|
+
surface: () => createNode("surface"),
|
|
333
|
+
switch: () => createNode("switch"),
|
|
334
|
+
template: (shape) => {
|
|
335
335
|
const node = createNode("template", {
|
|
336
336
|
valueType: shape.valueType,
|
|
337
337
|
value: shape.text
|
|
@@ -339,9 +339,9 @@ var nodeFactory = {
|
|
|
339
339
|
node.inputSchema = JsonSchema.toJsonSchema(getTemplateInputSchema(node));
|
|
340
340
|
return node;
|
|
341
341
|
},
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
342
|
+
text: () => createNode("text"),
|
|
343
|
+
thread: () => createNode("thread"),
|
|
344
|
+
trigger: () => createNode(NODE_INPUT)
|
|
345
345
|
};
|
|
346
346
|
var createNode = (type, props) => ({
|
|
347
347
|
id: Obj2.ID.random(),
|
|
@@ -463,7 +463,7 @@ var ComputeGraphController = class extends Resource {
|
|
|
463
463
|
} catch (err) {
|
|
464
464
|
log.catch(err, void 0, {
|
|
465
465
|
F: __dxlog_file4,
|
|
466
|
-
L:
|
|
466
|
+
L: 230,
|
|
467
467
|
S: this,
|
|
468
468
|
C: (f, a) => f(...a)
|
|
469
469
|
});
|
|
@@ -489,7 +489,7 @@ var ComputeGraphController = class extends Resource {
|
|
|
489
489
|
const scope = yield* Scope.make();
|
|
490
490
|
const executable = yield* Effect.promise(() => resolveComputeNode(this._graph.getNode(nodeId)));
|
|
491
491
|
const computingOutputs = executable.exec != null;
|
|
492
|
-
const effect = (computingOutputs ? executor.computeOutputs(nodeId) : executor.computeInputs(nodeId)).pipe(Effect.withSpan("runGraph"), Scope.extend(scope), Effect.provide(ComputeEventLogger.layerFromTracing.pipe(Layer.provideMerge(TracingService.layerNoop))), Effect.flatMap(computeValueBag), Effect.withSpan("test"), Effect.tap((values) => {
|
|
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), Layer.provideMerge(Trace.writerLayerNoop))), Effect.flatMap(computeValueBag), Effect.withSpan("test"), Effect.tap((values) => {
|
|
493
493
|
for (const [key, value] of Object.entries(values)) {
|
|
494
494
|
if (computingOutputs) {
|
|
495
495
|
this._onOutputComputed(nodeId, key, value);
|
|
@@ -527,7 +527,7 @@ var ComputeGraphController = class extends Resource {
|
|
|
527
527
|
for (const node of allAffectedNodes) {
|
|
528
528
|
const executable = yield* Effect.promise(() => resolveComputeNode(this._graph.getNode(node)));
|
|
529
529
|
const computingOutputs = executable.exec != null;
|
|
530
|
-
const effect = (computingOutputs ? executor.computeOutputs(node) : executor.computeInputs(node)).pipe(Effect.withSpan("runGraph"), Scope.extend(scope), Effect.flatMap(computeValueBag), Effect.provide(ComputeEventLogger.layerFromTracing.pipe(Layer.provideMerge(TracingService.layerNoop))), Effect.withSpan("test"), Effect.tap((values) => {
|
|
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), Layer.provideMerge(Trace.writerLayerNoop))), Effect.withSpan("test"), Effect.tap((values) => {
|
|
531
531
|
for (const [key, value] of Object.entries(values)) {
|
|
532
532
|
if (computingOutputs) {
|
|
533
533
|
this._onOutputComputed(node, key, value);
|
|
@@ -556,7 +556,7 @@ var ComputeGraphController = class extends Resource {
|
|
|
556
556
|
event
|
|
557
557
|
}, {
|
|
558
558
|
F: __dxlog_file4,
|
|
559
|
-
L:
|
|
559
|
+
L: 379,
|
|
560
560
|
S: this,
|
|
561
561
|
C: (f, a) => f(...a)
|
|
562
562
|
});
|
|
@@ -644,7 +644,7 @@ var footerHeight = 32;
|
|
|
644
644
|
var Box = /* @__PURE__ */ forwardRef(({ children, classNames, shape, title, status, open, onAction }, forwardedRef) => {
|
|
645
645
|
invariant4(shape.type, void 0, {
|
|
646
646
|
F: __dxlog_file5,
|
|
647
|
-
L:
|
|
647
|
+
L: 29,
|
|
648
648
|
S: void 0,
|
|
649
649
|
A: [
|
|
650
650
|
"shape.type",
|
|
@@ -657,9 +657,9 @@ var Box = /* @__PURE__ */ forwardRef(({ children, classNames, shape, title, stat
|
|
|
657
657
|
const { debug } = useEditorContext();
|
|
658
658
|
return /* @__PURE__ */ React.createElement("div", {
|
|
659
659
|
ref: forwardedRef,
|
|
660
|
-
className: "flex flex-col
|
|
660
|
+
className: "flex flex-col h-full w-full justify-between"
|
|
661
661
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
662
|
-
className: "flex shrink-0
|
|
662
|
+
className: "flex shrink-0 w-full justify-between items-center h-[32px] bg-input-surface"
|
|
663
663
|
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
664
664
|
icon,
|
|
665
665
|
classNames: "mx-2"
|
|
@@ -669,7 +669,6 @@ var Box = /* @__PURE__ */ forwardRef(({ children, classNames, shape, title, stat
|
|
|
669
669
|
classNames: "p-1 text-green-500",
|
|
670
670
|
variant: "ghost",
|
|
671
671
|
icon: "ph--play--regular",
|
|
672
|
-
size: 4,
|
|
673
672
|
label: "run",
|
|
674
673
|
iconOnly: true,
|
|
675
674
|
onDoubleClick: (ev) => ev.stopPropagation(),
|
|
@@ -678,16 +677,15 @@ var Box = /* @__PURE__ */ forwardRef(({ children, classNames, shape, title, stat
|
|
|
678
677
|
onAction?.("run");
|
|
679
678
|
}
|
|
680
679
|
})), /* @__PURE__ */ React.createElement("div", {
|
|
681
|
-
className: mx("flex flex-col
|
|
680
|
+
className: mx("flex flex-col h-full grow overflow-hidden", classNames)
|
|
682
681
|
}, children), /* @__PURE__ */ React.createElement("div", {
|
|
683
|
-
className: "flex shrink-0
|
|
682
|
+
className: "flex shrink-0 w-full justify-between items-center h-[32px] bg-input-surface"
|
|
684
683
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
685
|
-
className: "grow
|
|
684
|
+
className: "grow px-2 text-sm truncate"
|
|
686
685
|
}, debug ? shape.id : status), openable && /* @__PURE__ */ React.createElement(IconButton, {
|
|
687
686
|
classNames: "p-1",
|
|
688
687
|
variant: "ghost",
|
|
689
688
|
icon: open ? "ph--caret-up--regular" : "ph--caret-down--regular",
|
|
690
|
-
size: 4,
|
|
691
689
|
label: open ? "close" : "open",
|
|
692
690
|
iconOnly: true,
|
|
693
691
|
onClick: (ev) => {
|
|
@@ -785,7 +783,7 @@ var FunctionBody = ({ shape, name, content, inputSchema = VoidInput, outputSchem
|
|
|
785
783
|
className: "flex flex-col"
|
|
786
784
|
}, inputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
|
|
787
785
|
key: name2,
|
|
788
|
-
className: "
|
|
786
|
+
className: "px-2 truncate text-sm font-mono items-center",
|
|
789
787
|
style: {
|
|
790
788
|
height: rowHeight
|
|
791
789
|
}
|
|
@@ -793,7 +791,7 @@ var FunctionBody = ({ shape, name, content, inputSchema = VoidInput, outputSchem
|
|
|
793
791
|
className: "flex flex-col"
|
|
794
792
|
}, outputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
|
|
795
793
|
key: name2,
|
|
796
|
-
className: "
|
|
794
|
+
className: "px-2 truncate text-sm font-mono items-center text-right",
|
|
797
795
|
style: {
|
|
798
796
|
height: rowHeight
|
|
799
797
|
}
|
|
@@ -829,7 +827,7 @@ var TypeSelect = ({ value, onValueChange }) => {
|
|
|
829
827
|
onValueChange
|
|
830
828
|
}, /* @__PURE__ */ React3.createElement(Select.TriggerButton, {
|
|
831
829
|
variant: "ghost",
|
|
832
|
-
classNames: "
|
|
830
|
+
classNames: "w-full px-0!"
|
|
833
831
|
}), /* @__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
832
|
key: type,
|
|
835
833
|
value: type
|
|
@@ -922,12 +920,12 @@ var AudioComponent = ({ shape }) => {
|
|
|
922
920
|
active
|
|
923
921
|
]);
|
|
924
922
|
return /* @__PURE__ */ React6.createElement("div", {
|
|
925
|
-
className: "flex
|
|
923
|
+
className: "flex w-full justify-center items-center"
|
|
926
924
|
}, /* @__PURE__ */ React6.createElement(Icon2, {
|
|
927
925
|
icon: active ? "ph--microphone--regular" : "ph--microphone-slash--regular",
|
|
928
926
|
classNames: [
|
|
929
927
|
"transition opacity-20 duration-1000",
|
|
930
|
-
active && "opacity-100 text-
|
|
928
|
+
active && "opacity-100 text-error-text"
|
|
931
929
|
],
|
|
932
930
|
size: 8,
|
|
933
931
|
onClick: () => setActive(!active)
|
|
@@ -969,7 +967,7 @@ var BeaconComponent = ({ shape }) => {
|
|
|
969
967
|
const input = runtime.inputs[DEFAULT_INPUT3];
|
|
970
968
|
const value = input?.type === "executed" ? input.value : false;
|
|
971
969
|
return /* @__PURE__ */ React7.createElement("div", {
|
|
972
|
-
className: "flex
|
|
970
|
+
className: "flex w-full justify-center items-center"
|
|
973
971
|
}, /* @__PURE__ */ React7.createElement(Icon3, {
|
|
974
972
|
icon: "ph--sun--regular",
|
|
975
973
|
classNames: [
|
|
@@ -1018,7 +1016,7 @@ var defineShape = ({ type, name, icon, symbol: Symbol, createShape: createShape2
|
|
|
1018
1016
|
// Be careful not to name component factories with a capital letter.
|
|
1019
1017
|
component: () => {
|
|
1020
1018
|
return /* @__PURE__ */ React8.createElement("div", {
|
|
1021
|
-
className: "flex
|
|
1019
|
+
className: "flex w-full justify-center items-center"
|
|
1022
1020
|
}, /* @__PURE__ */ React8.createElement(Symbol, null));
|
|
1023
1021
|
},
|
|
1024
1022
|
createShape: createShape2,
|
|
@@ -1045,7 +1043,7 @@ var createSymbol = (pathConstructor, inputs) => ({
|
|
|
1045
1043
|
});
|
|
1046
1044
|
return /* @__PURE__ */ React8.createElement("svg", {
|
|
1047
1045
|
viewBox: `0 0 ${width} ${height}`,
|
|
1048
|
-
className: "
|
|
1046
|
+
className: "h-full w-full"
|
|
1049
1047
|
}, getAnchorPoints({
|
|
1050
1048
|
x: 0,
|
|
1051
1049
|
y: centerY
|
|
@@ -1352,17 +1350,83 @@ var databaseShape = {
|
|
|
1352
1350
|
})
|
|
1353
1351
|
};
|
|
1354
1352
|
|
|
1355
|
-
// src/shapes/
|
|
1353
|
+
// src/shapes/Feed.tsx
|
|
1356
1354
|
import * as Schema11 from "effect/Schema";
|
|
1357
|
-
import React12, {
|
|
1355
|
+
import React12, { Fragment } from "react";
|
|
1356
|
+
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT4, QueueInput, QueueOutput } from "@dxos/conductor";
|
|
1357
|
+
import { ScrollArea } from "@dxos/react-ui";
|
|
1358
|
+
import { mx as mx2 } from "@dxos/ui-theme";
|
|
1359
|
+
var FeedShape = Schema11.extend(ComputeShape, Schema11.Struct({
|
|
1360
|
+
type: Schema11.Literal("queue")
|
|
1361
|
+
}));
|
|
1362
|
+
var createFeed = (props) => createShape({
|
|
1363
|
+
type: "queue",
|
|
1364
|
+
size: {
|
|
1365
|
+
width: 256,
|
|
1366
|
+
height: 512
|
|
1367
|
+
},
|
|
1368
|
+
...props
|
|
1369
|
+
});
|
|
1370
|
+
var FeedComponent = ({ shape }) => {
|
|
1371
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1372
|
+
const items = runtime.outputs[DEFAULT_OUTPUT4]?.type === "executed" ? runtime.outputs[DEFAULT_OUTPUT4].value : [];
|
|
1373
|
+
const handleAction = (action) => {
|
|
1374
|
+
if (action === "run") {
|
|
1375
|
+
runtime.evalNode();
|
|
1376
|
+
}
|
|
1377
|
+
};
|
|
1378
|
+
return /* @__PURE__ */ React12.createElement(Box, {
|
|
1379
|
+
shape,
|
|
1380
|
+
status: `${items.length} items`,
|
|
1381
|
+
onAction: handleAction
|
|
1382
|
+
}, /* @__PURE__ */ React12.createElement(ScrollArea.Root, {
|
|
1383
|
+
orientation: "vertical"
|
|
1384
|
+
}, /* @__PURE__ */ React12.createElement(ScrollArea.Viewport, {
|
|
1385
|
+
classNames: "divide-y divide-separator"
|
|
1386
|
+
}, [
|
|
1387
|
+
...items
|
|
1388
|
+
].map((item, i) => /* @__PURE__ */ React12.createElement(FeedItem, {
|
|
1389
|
+
key: i,
|
|
1390
|
+
classNames: "p-1 px-2",
|
|
1391
|
+
item
|
|
1392
|
+
})))));
|
|
1393
|
+
};
|
|
1394
|
+
var FeedItem = ({ classNames, item }) => {
|
|
1395
|
+
if (typeof item !== "object") {
|
|
1396
|
+
return /* @__PURE__ */ React12.createElement("div", {
|
|
1397
|
+
className: mx2(classNames, "whitespace-pre-wrap")
|
|
1398
|
+
}, item);
|
|
1399
|
+
}
|
|
1400
|
+
return /* @__PURE__ */ React12.createElement("div", {
|
|
1401
|
+
className: mx2("grid grid-cols-[80px_1fr]", classNames)
|
|
1402
|
+
}, Object.entries(item).map(([key, value]) => /* @__PURE__ */ React12.createElement(Fragment, {
|
|
1403
|
+
key
|
|
1404
|
+
}, /* @__PURE__ */ React12.createElement("div", {
|
|
1405
|
+
className: "p-1 text-xs text-subdued"
|
|
1406
|
+
}, key), /* @__PURE__ */ React12.createElement("div", null, typeof value === "string" ? value : JSON.stringify(value)))));
|
|
1407
|
+
};
|
|
1408
|
+
var feedShape = {
|
|
1409
|
+
type: "feed",
|
|
1410
|
+
name: "Feed",
|
|
1411
|
+
icon: "ph--queue--regular",
|
|
1412
|
+
component: FeedComponent,
|
|
1413
|
+
createShape: createFeed,
|
|
1414
|
+
getAnchors: (shape) => createFunctionAnchors(shape, QueueInput, QueueOutput),
|
|
1415
|
+
resizable: true
|
|
1416
|
+
};
|
|
1417
|
+
|
|
1418
|
+
// src/shapes/Function.tsx
|
|
1419
|
+
import * as Schema12 from "effect/Schema";
|
|
1420
|
+
import React13, { useCallback as useCallback3, useRef as useRef4 } from "react";
|
|
1358
1421
|
import { AnyOutput, FunctionInput } from "@dxos/conductor";
|
|
1359
1422
|
import { Ref as Ref2, getSnapshot, isInstanceOf } from "@dxos/echo/internal";
|
|
1360
|
-
import {
|
|
1423
|
+
import { Script } from "@dxos/functions";
|
|
1424
|
+
import { Operation } from "@dxos/operation";
|
|
1361
1425
|
import { useClient } from "@dxos/react-client";
|
|
1362
1426
|
import { Filter, parseId } from "@dxos/react-client/echo";
|
|
1363
1427
|
import { TextBox as TextBox3 } from "@dxos/react-ui-canvas-editor";
|
|
1364
|
-
var FunctionShape =
|
|
1365
|
-
type:
|
|
1428
|
+
var FunctionShape = Schema12.extend(ComputeShape, Schema12.Struct({
|
|
1429
|
+
type: Schema12.Literal("function")
|
|
1366
1430
|
}));
|
|
1367
1431
|
var createFunction = (props) => createShape({
|
|
1368
1432
|
type: "function",
|
|
@@ -1387,7 +1451,7 @@ var TextInputComponent2 = ({ shape, title, ...props }) => {
|
|
|
1387
1451
|
if (!space || !isInstanceOf(Script.Script, object)) {
|
|
1388
1452
|
return;
|
|
1389
1453
|
}
|
|
1390
|
-
const [fn] = await space.db.query(Filter.type(
|
|
1454
|
+
const [fn] = await space.db.query(Filter.type(Operation.PersistentOperation, {
|
|
1391
1455
|
source: Ref2.make(object)
|
|
1392
1456
|
})).run();
|
|
1393
1457
|
if (!fn) {
|
|
@@ -1409,11 +1473,11 @@ var TextInputComponent2 = ({ shape, title, ...props }) => {
|
|
|
1409
1473
|
}, [
|
|
1410
1474
|
runtime
|
|
1411
1475
|
]);
|
|
1412
|
-
return /* @__PURE__ */
|
|
1476
|
+
return /* @__PURE__ */ React13.createElement(Box, {
|
|
1413
1477
|
shape,
|
|
1414
1478
|
title: "Function",
|
|
1415
1479
|
onAction: handleAction
|
|
1416
|
-
}, /* @__PURE__ */
|
|
1480
|
+
}, /* @__PURE__ */ React13.createElement(TextBox3, {
|
|
1417
1481
|
...props,
|
|
1418
1482
|
ref: inputRef,
|
|
1419
1483
|
value: node.value,
|
|
@@ -1432,11 +1496,12 @@ var functionShape = {
|
|
|
1432
1496
|
};
|
|
1433
1497
|
|
|
1434
1498
|
// src/shapes/Gpt.tsx
|
|
1435
|
-
import * as
|
|
1436
|
-
import
|
|
1499
|
+
import * as Schema13 from "effect/Schema";
|
|
1500
|
+
import React14, { useEffect as useEffect4, useState as useState6 } from "react";
|
|
1437
1501
|
import { GptInput, GptOutput } from "@dxos/conductor";
|
|
1438
|
-
|
|
1439
|
-
|
|
1502
|
+
import { ScrollArea as ScrollArea2 } from "@dxos/react-ui";
|
|
1503
|
+
var GptShape = Schema13.extend(ComputeShape, Schema13.Struct({
|
|
1504
|
+
type: Schema13.Literal("gpt")
|
|
1440
1505
|
}));
|
|
1441
1506
|
var createGpt = (props) => createShape({
|
|
1442
1507
|
type: "gpt",
|
|
@@ -1481,11 +1546,12 @@ var GptComponent = ({ shape }) => {
|
|
|
1481
1546
|
}, [
|
|
1482
1547
|
runtime?.subscribeToEventLog
|
|
1483
1548
|
]);
|
|
1484
|
-
return /* @__PURE__ */
|
|
1549
|
+
return /* @__PURE__ */ React14.createElement(FunctionBody, {
|
|
1485
1550
|
shape,
|
|
1486
|
-
content: /* @__PURE__ */
|
|
1487
|
-
|
|
1488
|
-
|
|
1551
|
+
content: /* @__PURE__ */ React14.createElement(ScrollArea2.Root, {
|
|
1552
|
+
orientation: "vertical",
|
|
1553
|
+
thin: true
|
|
1554
|
+
}, /* @__PURE__ */ React14.createElement(ScrollArea2.Viewport, null, text)),
|
|
1489
1555
|
status: `${tokens} tokens`,
|
|
1490
1556
|
inputSchema: meta.input,
|
|
1491
1557
|
outputSchema: meta.output
|
|
@@ -1501,31 +1567,160 @@ var gptShape = {
|
|
|
1501
1567
|
openable: true
|
|
1502
1568
|
};
|
|
1503
1569
|
|
|
1570
|
+
// src/shapes/GptRealtime.tsx
|
|
1571
|
+
import * as Schema14 from "effect/Schema";
|
|
1572
|
+
import React15, { useState as useState7 } from "react";
|
|
1573
|
+
import { log as log2 } from "@dxos/log";
|
|
1574
|
+
import { useConfig } from "@dxos/react-client";
|
|
1575
|
+
import { Icon as Icon4 } from "@dxos/react-ui";
|
|
1576
|
+
var __dxlog_file6 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/GptRealtime.tsx";
|
|
1577
|
+
var GptRealtimeShape = Schema14.extend(ComputeShape, Schema14.Struct({
|
|
1578
|
+
type: Schema14.Literal("gpt-realtime")
|
|
1579
|
+
}));
|
|
1580
|
+
var createGptRealtime = (props) => createShape({
|
|
1581
|
+
type: "gpt-realtime",
|
|
1582
|
+
size: {
|
|
1583
|
+
width: 256,
|
|
1584
|
+
height: 256
|
|
1585
|
+
},
|
|
1586
|
+
...props
|
|
1587
|
+
});
|
|
1588
|
+
var GptRealtimeComponent = ({ shape }) => {
|
|
1589
|
+
const [isLive, setIsLive] = useState7(false);
|
|
1590
|
+
const [isReady, setIsReady] = useState7(false);
|
|
1591
|
+
const config = useConfig();
|
|
1592
|
+
const start = async () => {
|
|
1593
|
+
setIsLive(true);
|
|
1594
|
+
try {
|
|
1595
|
+
const peerConnection = new RTCPeerConnection();
|
|
1596
|
+
peerConnection.ontrack = (event) => {
|
|
1597
|
+
const audioElement = document.createElement("audio");
|
|
1598
|
+
audioElement.srcObject = event.streams[0];
|
|
1599
|
+
audioElement.autoplay = true;
|
|
1600
|
+
audioElement.controls = false;
|
|
1601
|
+
audioElement.style.display = "none";
|
|
1602
|
+
document.body.appendChild(audioElement);
|
|
1603
|
+
setIsReady(true);
|
|
1604
|
+
};
|
|
1605
|
+
const stream = await navigator.mediaDevices.getUserMedia({
|
|
1606
|
+
audio: true
|
|
1607
|
+
});
|
|
1608
|
+
stream.getTracks().forEach((track) => peerConnection.addTransceiver(track, {
|
|
1609
|
+
direction: "sendrecv"
|
|
1610
|
+
}));
|
|
1611
|
+
const offer = await peerConnection.createOffer();
|
|
1612
|
+
await peerConnection.setLocalDescription(offer);
|
|
1613
|
+
const AiServiceUrl = new URL("/rtc-connect", config.values.runtime?.services?.ai?.server ?? DEFAULT_AI_SERVICE_URL);
|
|
1614
|
+
const response = await fetch(AiServiceUrl, {
|
|
1615
|
+
method: "POST",
|
|
1616
|
+
body: offer.sdp,
|
|
1617
|
+
headers: {
|
|
1618
|
+
"Content-Type": "application/sdp"
|
|
1619
|
+
}
|
|
1620
|
+
});
|
|
1621
|
+
const answer = await response.text();
|
|
1622
|
+
await peerConnection.setRemoteDescription({
|
|
1623
|
+
sdp: answer,
|
|
1624
|
+
type: "answer"
|
|
1625
|
+
});
|
|
1626
|
+
const dataChannel = peerConnection.createDataChannel("response");
|
|
1627
|
+
const configureData = () => {
|
|
1628
|
+
log2.info("Configuring data channel", void 0, {
|
|
1629
|
+
F: __dxlog_file6,
|
|
1630
|
+
L: 87,
|
|
1631
|
+
S: void 0,
|
|
1632
|
+
C: (f, a) => f(...a)
|
|
1633
|
+
});
|
|
1634
|
+
const event = {
|
|
1635
|
+
type: "session.update",
|
|
1636
|
+
session: {
|
|
1637
|
+
modalities: [
|
|
1638
|
+
"text",
|
|
1639
|
+
"audio"
|
|
1640
|
+
],
|
|
1641
|
+
// Provide the tools. Note they match the keys in the `fns` object above
|
|
1642
|
+
tools: []
|
|
1643
|
+
}
|
|
1644
|
+
};
|
|
1645
|
+
dataChannel.send(JSON.stringify(event));
|
|
1646
|
+
};
|
|
1647
|
+
dataChannel.addEventListener("open", (ev) => {
|
|
1648
|
+
log2.info("Opening data channel", {
|
|
1649
|
+
ev
|
|
1650
|
+
}, {
|
|
1651
|
+
F: __dxlog_file6,
|
|
1652
|
+
L: 100,
|
|
1653
|
+
S: void 0,
|
|
1654
|
+
C: (f, a) => f(...a)
|
|
1655
|
+
});
|
|
1656
|
+
configureData();
|
|
1657
|
+
});
|
|
1658
|
+
dataChannel.addEventListener("message", async (ev) => {
|
|
1659
|
+
const msg = JSON.parse(ev.data);
|
|
1660
|
+
if (msg.type === "response.function_call_arguments.done") {
|
|
1661
|
+
}
|
|
1662
|
+
});
|
|
1663
|
+
} catch (error) {
|
|
1664
|
+
log2.error("Error in realtime session:", {
|
|
1665
|
+
error
|
|
1666
|
+
}, {
|
|
1667
|
+
F: __dxlog_file6,
|
|
1668
|
+
L: 140,
|
|
1669
|
+
S: void 0,
|
|
1670
|
+
C: (f, a) => f(...a)
|
|
1671
|
+
});
|
|
1672
|
+
throw error;
|
|
1673
|
+
}
|
|
1674
|
+
};
|
|
1675
|
+
return /* @__PURE__ */ React15.createElement("div", {
|
|
1676
|
+
className: "flex w-full justify-center items-center"
|
|
1677
|
+
}, /* @__PURE__ */ React15.createElement(Icon4, {
|
|
1678
|
+
icon: isReady ? "ph--waveform--regular" : isLive ? "ph--pulse--regular" : "ph--play--regular",
|
|
1679
|
+
size: 16,
|
|
1680
|
+
classNames: !isLive && "cursor-pointer",
|
|
1681
|
+
onClick: start
|
|
1682
|
+
}));
|
|
1683
|
+
};
|
|
1684
|
+
var gptRealtimeShape = {
|
|
1685
|
+
type: "gpt-realtime",
|
|
1686
|
+
name: "GPT Realtime",
|
|
1687
|
+
icon: "ph--pulse--regular",
|
|
1688
|
+
component: GptRealtimeComponent,
|
|
1689
|
+
createShape: createGptRealtime,
|
|
1690
|
+
// TODO(dmaretskyi): Can we fetch the schema dynamically?
|
|
1691
|
+
getAnchors: (shape) => createFunctionAnchors(shape, Schema14.Struct({
|
|
1692
|
+
audio: Schema14.Any
|
|
1693
|
+
}), Schema14.Struct({})),
|
|
1694
|
+
resizable: true
|
|
1695
|
+
};
|
|
1696
|
+
var DEFAULT_AI_SERVICE_URL = "http://localhost:8788";
|
|
1697
|
+
|
|
1504
1698
|
// src/shapes/Json.tsx
|
|
1505
|
-
import * as
|
|
1506
|
-
import
|
|
1699
|
+
import * as Schema15 from "effect/Schema";
|
|
1700
|
+
import React16 from "react";
|
|
1507
1701
|
import { DEFAULT_INPUT as DEFAULT_INPUT4, DefaultOutput, JsonTransformInput } from "@dxos/conductor";
|
|
1508
1702
|
import { createAnchorMap as createAnchorMap6 } from "@dxos/react-ui-canvas-editor";
|
|
1509
|
-
import {
|
|
1510
|
-
var JsonShape =
|
|
1511
|
-
type:
|
|
1703
|
+
import { Json } from "@dxos/react-ui-syntax-highlighter";
|
|
1704
|
+
var JsonShape = Schema15.extend(ComputeShape, Schema15.Struct({
|
|
1705
|
+
type: Schema15.Literal("json")
|
|
1512
1706
|
}));
|
|
1513
|
-
var JsonTransformShape =
|
|
1514
|
-
type:
|
|
1707
|
+
var JsonTransformShape = Schema15.extend(ComputeShape, Schema15.Struct({
|
|
1708
|
+
type: Schema15.Literal("json-transform")
|
|
1515
1709
|
}));
|
|
1516
1710
|
var JsonComponent = ({ shape, ...props }) => {
|
|
1517
1711
|
const { runtime } = useComputeNodeState(shape);
|
|
1518
1712
|
const input = runtime.inputs[DEFAULT_INPUT4];
|
|
1519
1713
|
const value = input?.type === "executed" ? input.value : void 0;
|
|
1520
|
-
return /* @__PURE__ */
|
|
1714
|
+
return /* @__PURE__ */ React16.createElement(Box, {
|
|
1521
1715
|
shape
|
|
1522
|
-
}, /* @__PURE__ */
|
|
1523
|
-
data: value
|
|
1716
|
+
}, /* @__PURE__ */ React16.createElement(Json.Root, {
|
|
1717
|
+
data: value
|
|
1718
|
+
}, /* @__PURE__ */ React16.createElement(Json.Content, null, /* @__PURE__ */ React16.createElement(Json.Filter, null), /* @__PURE__ */ React16.createElement(Json.Data, {
|
|
1524
1719
|
classNames: "text-xs"
|
|
1525
|
-
}));
|
|
1720
|
+
}))));
|
|
1526
1721
|
};
|
|
1527
1722
|
var JsonTransformComponent = ({ shape, ...props }) => {
|
|
1528
|
-
return /* @__PURE__ */
|
|
1723
|
+
return /* @__PURE__ */ React16.createElement(Box, {
|
|
1529
1724
|
shape
|
|
1530
1725
|
});
|
|
1531
1726
|
};
|
|
@@ -1541,7 +1736,7 @@ var jsonShape = {
|
|
|
1541
1736
|
type: "json",
|
|
1542
1737
|
name: "JSON",
|
|
1543
1738
|
icon: "ph--code--regular",
|
|
1544
|
-
component: (props) => /* @__PURE__ */
|
|
1739
|
+
component: (props) => /* @__PURE__ */ React16.createElement(JsonComponent, props),
|
|
1545
1740
|
createShape: createJson,
|
|
1546
1741
|
getAnchors: (shape) => createAnchorMap6(shape, {
|
|
1547
1742
|
[createAnchorId("input")]: {
|
|
@@ -1567,31 +1762,31 @@ var jsonTransformShape = {
|
|
|
1567
1762
|
type: "json-transform",
|
|
1568
1763
|
name: "Transform",
|
|
1569
1764
|
icon: "ph--shuffle-simple--regular",
|
|
1570
|
-
component: (props) => /* @__PURE__ */
|
|
1765
|
+
component: (props) => /* @__PURE__ */ React16.createElement(JsonTransformComponent, props),
|
|
1571
1766
|
createShape: createJsonTransform,
|
|
1572
1767
|
getAnchors: (shape) => createFunctionAnchors(shape, JsonTransformInput, DefaultOutput),
|
|
1573
1768
|
resizable: true
|
|
1574
1769
|
};
|
|
1575
1770
|
|
|
1576
1771
|
// src/shapes/Logic.tsx
|
|
1577
|
-
import * as
|
|
1578
|
-
import
|
|
1772
|
+
import * as Schema16 from "effect/Schema";
|
|
1773
|
+
import React17 from "react";
|
|
1579
1774
|
import { IfElseInput, IfElseOutput, IfInput, IfOutput } from "@dxos/conductor";
|
|
1580
|
-
var IfShape =
|
|
1581
|
-
type:
|
|
1775
|
+
var IfShape = Schema16.extend(ComputeShape, Schema16.Struct({
|
|
1776
|
+
type: Schema16.Literal("if")
|
|
1582
1777
|
}));
|
|
1583
|
-
var IfElseShape =
|
|
1584
|
-
type:
|
|
1778
|
+
var IfElseShape = Schema16.extend(ComputeShape, Schema16.Struct({
|
|
1779
|
+
type: Schema16.Literal("if-else")
|
|
1585
1780
|
}));
|
|
1586
1781
|
var IfComponent = ({ shape, ...props }) => {
|
|
1587
|
-
return /* @__PURE__ */
|
|
1782
|
+
return /* @__PURE__ */ React17.createElement(FunctionBody, {
|
|
1588
1783
|
shape,
|
|
1589
1784
|
inputSchema: IfInput,
|
|
1590
1785
|
outputSchema: IfOutput
|
|
1591
1786
|
});
|
|
1592
1787
|
};
|
|
1593
1788
|
var IfElseComponent = ({ shape, ...props }) => {
|
|
1594
|
-
return /* @__PURE__ */
|
|
1789
|
+
return /* @__PURE__ */ React17.createElement(FunctionBody, {
|
|
1595
1790
|
shape,
|
|
1596
1791
|
inputSchema: IfElseInput,
|
|
1597
1792
|
outputSchema: IfElseOutput
|
|
@@ -1609,7 +1804,7 @@ var ifShape = {
|
|
|
1609
1804
|
type: "if",
|
|
1610
1805
|
name: "IF",
|
|
1611
1806
|
icon: "ph--arrows-split--regular",
|
|
1612
|
-
component: (props) => /* @__PURE__ */
|
|
1807
|
+
component: (props) => /* @__PURE__ */ React17.createElement(IfComponent, props),
|
|
1613
1808
|
createShape: createIf,
|
|
1614
1809
|
getAnchors: (shape) => createFunctionAnchors(shape, IfInput, IfOutput)
|
|
1615
1810
|
};
|
|
@@ -1625,83 +1820,21 @@ var ifElseShape = {
|
|
|
1625
1820
|
type: "if-else",
|
|
1626
1821
|
name: "IF/ELSE",
|
|
1627
1822
|
icon: "ph--arrows-merge--regular",
|
|
1628
|
-
component: (props) => /* @__PURE__ */
|
|
1823
|
+
component: (props) => /* @__PURE__ */ React17.createElement(IfElseComponent, props),
|
|
1629
1824
|
createShape: createIfElse,
|
|
1630
1825
|
getAnchors: (shape) => createFunctionAnchors(shape, IfElseInput, IfElseOutput)
|
|
1631
1826
|
};
|
|
1632
1827
|
|
|
1633
|
-
// src/shapes/Queue.tsx
|
|
1634
|
-
import * as Schema15 from "effect/Schema";
|
|
1635
|
-
import React16, { Fragment } from "react";
|
|
1636
|
-
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT4, QueueInput, QueueOutput } from "@dxos/conductor";
|
|
1637
|
-
import { mx as mx2 } from "@dxos/ui-theme";
|
|
1638
|
-
var QueueShape = Schema15.extend(ComputeShape, Schema15.Struct({
|
|
1639
|
-
type: Schema15.Literal("queue")
|
|
1640
|
-
}));
|
|
1641
|
-
var createQueue = (props) => createShape({
|
|
1642
|
-
type: "queue",
|
|
1643
|
-
size: {
|
|
1644
|
-
width: 256,
|
|
1645
|
-
height: 512
|
|
1646
|
-
},
|
|
1647
|
-
...props
|
|
1648
|
-
});
|
|
1649
|
-
var QueueComponent = ({ shape }) => {
|
|
1650
|
-
const { runtime } = useComputeNodeState(shape);
|
|
1651
|
-
const items = runtime.outputs[DEFAULT_OUTPUT4]?.type === "executed" ? runtime.outputs[DEFAULT_OUTPUT4].value : [];
|
|
1652
|
-
const handleAction = (action) => {
|
|
1653
|
-
if (action === "run") {
|
|
1654
|
-
runtime.evalNode();
|
|
1655
|
-
}
|
|
1656
|
-
};
|
|
1657
|
-
return /* @__PURE__ */ React16.createElement(Box, {
|
|
1658
|
-
shape,
|
|
1659
|
-
status: `${items.length} items`,
|
|
1660
|
-
onAction: handleAction
|
|
1661
|
-
}, /* @__PURE__ */ React16.createElement("div", {
|
|
1662
|
-
className: "flex flex-col is-full overflow-y-auto divide-y divide-separator"
|
|
1663
|
-
}, [
|
|
1664
|
-
...items
|
|
1665
|
-
].map((item, i) => /* @__PURE__ */ React16.createElement(QueueItem, {
|
|
1666
|
-
key: i,
|
|
1667
|
-
classNames: "p-1 pli-2",
|
|
1668
|
-
item
|
|
1669
|
-
}))));
|
|
1670
|
-
};
|
|
1671
|
-
var QueueItem = ({ classNames, item }) => {
|
|
1672
|
-
if (typeof item !== "object") {
|
|
1673
|
-
return /* @__PURE__ */ React16.createElement("div", {
|
|
1674
|
-
className: mx2(classNames, "whitespace-pre-wrap")
|
|
1675
|
-
}, item);
|
|
1676
|
-
}
|
|
1677
|
-
return /* @__PURE__ */ React16.createElement("div", {
|
|
1678
|
-
className: mx2("grid grid-cols-[80px,1fr]", classNames)
|
|
1679
|
-
}, Object.entries(item).map(([key, value]) => /* @__PURE__ */ React16.createElement(Fragment, {
|
|
1680
|
-
key
|
|
1681
|
-
}, /* @__PURE__ */ React16.createElement("div", {
|
|
1682
|
-
className: "p-1 text-xs text-subdued"
|
|
1683
|
-
}, key), /* @__PURE__ */ React16.createElement("div", null, typeof value === "string" ? value : JSON.stringify(value)))));
|
|
1684
|
-
};
|
|
1685
|
-
var queueShape = {
|
|
1686
|
-
type: "queue",
|
|
1687
|
-
name: "Queue",
|
|
1688
|
-
icon: "ph--queue--regular",
|
|
1689
|
-
component: QueueComponent,
|
|
1690
|
-
createShape: createQueue,
|
|
1691
|
-
getAnchors: (shape) => createFunctionAnchors(shape, QueueInput, QueueOutput),
|
|
1692
|
-
resizable: true
|
|
1693
|
-
};
|
|
1694
|
-
|
|
1695
1828
|
// src/shapes/RNG.tsx
|
|
1696
|
-
import * as
|
|
1697
|
-
import
|
|
1829
|
+
import * as Schema17 from "effect/Schema";
|
|
1830
|
+
import React18, { useEffect as useEffect5, useState as useState8 } from "react";
|
|
1698
1831
|
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT5 } from "@dxos/conductor";
|
|
1699
|
-
import { Icon as
|
|
1832
|
+
import { Icon as Icon5 } from "@dxos/react-ui";
|
|
1700
1833
|
import { createAnchorMap as createAnchorMap7 } from "@dxos/react-ui-canvas-editor";
|
|
1701
|
-
var RandomShape =
|
|
1702
|
-
type:
|
|
1703
|
-
min:
|
|
1704
|
-
max:
|
|
1834
|
+
var RandomShape = Schema17.extend(ComputeShape, Schema17.Struct({
|
|
1835
|
+
type: Schema17.Literal("rng"),
|
|
1836
|
+
min: Schema17.optional(Schema17.Number),
|
|
1837
|
+
max: Schema17.optional(Schema17.Number)
|
|
1705
1838
|
}));
|
|
1706
1839
|
var createRandom = (props) => createShape({
|
|
1707
1840
|
type: "rng",
|
|
@@ -1722,8 +1855,8 @@ var icons = [
|
|
|
1722
1855
|
var pickIcon = () => icons[Math.floor(Math.random() * icons.length)];
|
|
1723
1856
|
var RandomComponent = ({ shape }) => {
|
|
1724
1857
|
const { runtime } = useComputeNodeState(shape);
|
|
1725
|
-
const [spin, setSpin] =
|
|
1726
|
-
const [icon, setIcon] =
|
|
1858
|
+
const [spin, setSpin] = useState8(false);
|
|
1859
|
+
const [icon, setIcon] = useState8(pickIcon());
|
|
1727
1860
|
useEffect5(() => {
|
|
1728
1861
|
if (!spin) {
|
|
1729
1862
|
return;
|
|
@@ -1744,9 +1877,9 @@ var RandomComponent = ({ shape }) => {
|
|
|
1744
1877
|
runtime.setOutput(DEFAULT_OUTPUT5, Math.random());
|
|
1745
1878
|
setSpin(true);
|
|
1746
1879
|
};
|
|
1747
|
-
return /* @__PURE__ */
|
|
1880
|
+
return /* @__PURE__ */ React18.createElement("div", {
|
|
1748
1881
|
className: "flex grow items-center justify-center"
|
|
1749
|
-
}, /* @__PURE__ */
|
|
1882
|
+
}, /* @__PURE__ */ React18.createElement(Icon5, {
|
|
1750
1883
|
icon,
|
|
1751
1884
|
classNames: spin && "animate-[spin_1s]",
|
|
1752
1885
|
size: 10,
|
|
@@ -1768,13 +1901,13 @@ var randomShape = {
|
|
|
1768
1901
|
};
|
|
1769
1902
|
|
|
1770
1903
|
// src/shapes/Scope.tsx
|
|
1771
|
-
import * as
|
|
1772
|
-
import
|
|
1904
|
+
import * as Schema18 from "effect/Schema";
|
|
1905
|
+
import React19 from "react";
|
|
1773
1906
|
import { DEFAULT_INPUT as DEFAULT_INPUT5 } from "@dxos/conductor";
|
|
1774
1907
|
import { createAnchorMap as createAnchorMap8 } from "@dxos/react-ui-canvas-editor";
|
|
1775
1908
|
import { Chaos, shaderPresets, useAudioStream } from "@dxos/react-ui-sfx";
|
|
1776
|
-
var ScopeShape =
|
|
1777
|
-
type:
|
|
1909
|
+
var ScopeShape = Schema18.extend(ComputeShape, Schema18.Struct({
|
|
1910
|
+
type: Schema18.Literal("scope")
|
|
1778
1911
|
}));
|
|
1779
1912
|
var createScope = (props) => createShape({
|
|
1780
1913
|
type: "scope",
|
|
@@ -1790,9 +1923,9 @@ var ScopeComponent = ({ shape }) => {
|
|
|
1790
1923
|
const input = runtime.inputs[DEFAULT_INPUT5];
|
|
1791
1924
|
const active = input?.type === "executed" ? input.value : false;
|
|
1792
1925
|
const { getAverage } = useAudioStream(active);
|
|
1793
|
-
return /* @__PURE__ */
|
|
1794
|
-
className: "flex
|
|
1795
|
-
}, /* @__PURE__ */
|
|
1926
|
+
return /* @__PURE__ */ React19.createElement("div", {
|
|
1927
|
+
className: "flex w-full justify-center items-center bg-black"
|
|
1928
|
+
}, /* @__PURE__ */ React19.createElement(Chaos, {
|
|
1796
1929
|
active,
|
|
1797
1930
|
getValue: getAverage,
|
|
1798
1931
|
options: {
|
|
@@ -1816,13 +1949,14 @@ var scopeShape = {
|
|
|
1816
1949
|
};
|
|
1817
1950
|
|
|
1818
1951
|
// src/shapes/Surface.tsx
|
|
1819
|
-
import * as
|
|
1820
|
-
import
|
|
1821
|
-
import { Surface } from "@dxos/app-framework/
|
|
1952
|
+
import * as Schema19 from "effect/Schema";
|
|
1953
|
+
import React20 from "react";
|
|
1954
|
+
import { Surface } from "@dxos/app-framework/ui";
|
|
1822
1955
|
import { DEFAULT_INPUT as DEFAULT_INPUT6 } from "@dxos/conductor";
|
|
1956
|
+
import { Card } from "@dxos/react-ui";
|
|
1823
1957
|
import { createAnchorMap as createAnchorMap9 } from "@dxos/react-ui-canvas-editor";
|
|
1824
|
-
var SurfaceShape =
|
|
1825
|
-
type:
|
|
1958
|
+
var SurfaceShape = Schema19.extend(ComputeShape, Schema19.Struct({
|
|
1959
|
+
type: Schema19.Literal("surface")
|
|
1826
1960
|
}));
|
|
1827
1961
|
var createSurface = (props) => createShape({
|
|
1828
1962
|
type: "surface",
|
|
@@ -1841,16 +1975,16 @@ var SurfaceComponent = ({ shape }) => {
|
|
|
1841
1975
|
runtime.evalNode();
|
|
1842
1976
|
}
|
|
1843
1977
|
};
|
|
1844
|
-
return /* @__PURE__ */
|
|
1978
|
+
return /* @__PURE__ */ React20.createElement(Box, {
|
|
1845
1979
|
shape,
|
|
1846
1980
|
onAction: handleAction
|
|
1847
|
-
}, value !== null && /* @__PURE__ */
|
|
1848
|
-
role: "card--
|
|
1981
|
+
}, /* @__PURE__ */ React20.createElement(Card.Root, null, value !== null && /* @__PURE__ */ React20.createElement(Surface.Surface, {
|
|
1982
|
+
role: "card--content",
|
|
1849
1983
|
data: {
|
|
1850
1984
|
value
|
|
1851
1985
|
},
|
|
1852
1986
|
limit: 1
|
|
1853
|
-
}));
|
|
1987
|
+
})));
|
|
1854
1988
|
};
|
|
1855
1989
|
var surfaceShape = {
|
|
1856
1990
|
type: "surface",
|
|
@@ -1868,13 +2002,13 @@ var surfaceShape = {
|
|
|
1868
2002
|
};
|
|
1869
2003
|
|
|
1870
2004
|
// src/shapes/Switch.tsx
|
|
1871
|
-
import * as
|
|
1872
|
-
import
|
|
2005
|
+
import * as Schema20 from "effect/Schema";
|
|
2006
|
+
import React21, { useEffect as useEffect6, useState as useState9 } from "react";
|
|
1873
2007
|
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT6 } from "@dxos/conductor";
|
|
1874
2008
|
import { Input as Input2 } from "@dxos/react-ui";
|
|
1875
2009
|
import { createAnchorMap as createAnchorMap10 } from "@dxos/react-ui-canvas-editor";
|
|
1876
|
-
var SwitchShape =
|
|
1877
|
-
type:
|
|
2010
|
+
var SwitchShape = Schema20.extend(ComputeShape, Schema20.Struct({
|
|
2011
|
+
type: Schema20.Literal("switch")
|
|
1878
2012
|
}));
|
|
1879
2013
|
var createSwitch = (props) => createShape({
|
|
1880
2014
|
type: "switch",
|
|
@@ -1886,16 +2020,16 @@ var createSwitch = (props) => createShape({
|
|
|
1886
2020
|
});
|
|
1887
2021
|
var SwitchComponent = ({ shape }) => {
|
|
1888
2022
|
const { runtime } = useComputeNodeState(shape);
|
|
1889
|
-
const [value, setValue] =
|
|
2023
|
+
const [value, setValue] = useState9(false);
|
|
1890
2024
|
useEffect6(() => {
|
|
1891
2025
|
runtime.setOutput(DEFAULT_OUTPUT6, value);
|
|
1892
2026
|
}, [
|
|
1893
2027
|
value
|
|
1894
2028
|
]);
|
|
1895
|
-
return /* @__PURE__ */
|
|
1896
|
-
className: "flex
|
|
2029
|
+
return /* @__PURE__ */ React21.createElement("div", {
|
|
2030
|
+
className: "flex w-full justify-center items-center",
|
|
1897
2031
|
onClick: (ev) => ev.stopPropagation()
|
|
1898
|
-
}, /* @__PURE__ */
|
|
2032
|
+
}, /* @__PURE__ */ React21.createElement(Input2.Root, null, /* @__PURE__ */ React21.createElement(Input2.Switch, {
|
|
1899
2033
|
checked: value,
|
|
1900
2034
|
onCheckedChange: (value2) => setValue(value2)
|
|
1901
2035
|
})));
|
|
@@ -1915,14 +2049,14 @@ var switchShape = {
|
|
|
1915
2049
|
};
|
|
1916
2050
|
|
|
1917
2051
|
// src/shapes/Table.tsx
|
|
1918
|
-
import * as
|
|
1919
|
-
import
|
|
2052
|
+
import * as Schema21 from "effect/Schema";
|
|
2053
|
+
import React22 from "react";
|
|
1920
2054
|
import { createInputSchema, createOutputSchema } from "@dxos/conductor";
|
|
1921
2055
|
import { Message } from "@dxos/types";
|
|
1922
2056
|
var InputSchema = createInputSchema(Message.Message);
|
|
1923
|
-
var OutputSchema = createOutputSchema(
|
|
1924
|
-
var TableShape =
|
|
1925
|
-
type:
|
|
2057
|
+
var OutputSchema = createOutputSchema(Schema21.mutable(Schema21.Array(Message.Message)));
|
|
2058
|
+
var TableShape = Schema21.extend(ComputeShape, Schema21.Struct({
|
|
2059
|
+
type: Schema21.Literal("table")
|
|
1926
2060
|
}));
|
|
1927
2061
|
var createTable = (props) => createShape({
|
|
1928
2062
|
type: "table",
|
|
@@ -1933,7 +2067,7 @@ var createTable = (props) => createShape({
|
|
|
1933
2067
|
...props
|
|
1934
2068
|
});
|
|
1935
2069
|
var TableComponent = ({ shape }) => {
|
|
1936
|
-
return /* @__PURE__ */
|
|
2070
|
+
return /* @__PURE__ */ React22.createElement(Box, {
|
|
1937
2071
|
shape
|
|
1938
2072
|
});
|
|
1939
2073
|
};
|
|
@@ -1948,16 +2082,16 @@ var tableShape = {
|
|
|
1948
2082
|
};
|
|
1949
2083
|
|
|
1950
2084
|
// src/shapes/Template.tsx
|
|
1951
|
-
import * as
|
|
1952
|
-
import
|
|
2085
|
+
import * as Schema22 from "effect/Schema";
|
|
2086
|
+
import React23, { useRef as useRef5 } from "react";
|
|
1953
2087
|
import { ComputeValueType as ComputeValueType3, TemplateOutput, VoidInput as VoidInput2, getTemplateInputSchema as getTemplateInputSchema2 } from "@dxos/conductor";
|
|
1954
2088
|
import { toJsonSchema } from "@dxos/echo/internal";
|
|
1955
2089
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
1956
2090
|
import { TextBox as TextBox4 } from "@dxos/react-ui-canvas-editor";
|
|
1957
|
-
var
|
|
1958
|
-
var TemplateShape =
|
|
1959
|
-
type:
|
|
1960
|
-
valueType:
|
|
2091
|
+
var __dxlog_file7 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/Template.tsx";
|
|
2092
|
+
var TemplateShape = Schema22.extend(ComputeShape, Schema22.Struct({
|
|
2093
|
+
type: Schema22.Literal("template"),
|
|
2094
|
+
valueType: Schema22.optional(ComputeValueType3)
|
|
1961
2095
|
}));
|
|
1962
2096
|
var TextInputComponent3 = ({ shape, title, ...props }) => {
|
|
1963
2097
|
const { node } = useComputeNodeState(shape);
|
|
@@ -1971,9 +2105,9 @@ var TextInputComponent3 = ({ shape, title, ...props }) => {
|
|
|
1971
2105
|
}
|
|
1972
2106
|
};
|
|
1973
2107
|
const handleTypeChange = (newType) => {
|
|
1974
|
-
invariant5(
|
|
1975
|
-
F:
|
|
1976
|
-
L:
|
|
2108
|
+
invariant5(Schema22.is(ComputeValueType3)(newType), "Invalid type", {
|
|
2109
|
+
F: __dxlog_file7,
|
|
2110
|
+
L: 58,
|
|
1977
2111
|
S: void 0,
|
|
1978
2112
|
A: [
|
|
1979
2113
|
"Schema.is(ComputeValueType)(newType)",
|
|
@@ -1983,14 +2117,14 @@ var TextInputComponent3 = ({ shape, title, ...props }) => {
|
|
|
1983
2117
|
node.valueType = newType;
|
|
1984
2118
|
node.inputSchema = toJsonSchema(getTemplateInputSchema2(node));
|
|
1985
2119
|
};
|
|
1986
|
-
return /* @__PURE__ */
|
|
2120
|
+
return /* @__PURE__ */ React23.createElement(Box, {
|
|
1987
2121
|
shape,
|
|
1988
2122
|
title: "Template",
|
|
1989
|
-
status: /* @__PURE__ */
|
|
2123
|
+
status: /* @__PURE__ */ React23.createElement(TypeSelect, {
|
|
1990
2124
|
value: node.valueType ?? "string",
|
|
1991
2125
|
onValueChange: handleTypeChange
|
|
1992
2126
|
})
|
|
1993
|
-
}, /* @__PURE__ */
|
|
2127
|
+
}, /* @__PURE__ */ React23.createElement(TextBox4, {
|
|
1994
2128
|
...props,
|
|
1995
2129
|
ref: inputRef,
|
|
1996
2130
|
value: node.value,
|
|
@@ -2011,7 +2145,7 @@ var templateShape = {
|
|
|
2011
2145
|
type: "template",
|
|
2012
2146
|
name: "Template",
|
|
2013
2147
|
icon: "ph--article--regular",
|
|
2014
|
-
component: (props) => /* @__PURE__ */
|
|
2148
|
+
component: (props) => /* @__PURE__ */ React23.createElement(TextInputComponent3, {
|
|
2015
2149
|
...props,
|
|
2016
2150
|
placeholder: "Prompt"
|
|
2017
2151
|
}),
|
|
@@ -2021,13 +2155,13 @@ var templateShape = {
|
|
|
2021
2155
|
};
|
|
2022
2156
|
|
|
2023
2157
|
// src/shapes/Text.tsx
|
|
2024
|
-
import * as
|
|
2025
|
-
import
|
|
2158
|
+
import * as Schema23 from "effect/Schema";
|
|
2159
|
+
import React24 from "react";
|
|
2026
2160
|
import { DEFAULT_INPUT as DEFAULT_INPUT7 } from "@dxos/conductor";
|
|
2027
2161
|
import { TextBox as TextBox5 } from "@dxos/react-ui-canvas-editor";
|
|
2028
2162
|
import { createAnchorMap as createAnchorMap11 } from "@dxos/react-ui-canvas-editor";
|
|
2029
|
-
var TextShape =
|
|
2030
|
-
type:
|
|
2163
|
+
var TextShape = Schema23.extend(ComputeShape, Schema23.Struct({
|
|
2164
|
+
type: Schema23.Literal("text")
|
|
2031
2165
|
}));
|
|
2032
2166
|
var createText = (props) => createShape({
|
|
2033
2167
|
type: "text",
|
|
@@ -2046,10 +2180,10 @@ var TextComponent = ({ shape }) => {
|
|
|
2046
2180
|
runtime.evalNode();
|
|
2047
2181
|
}
|
|
2048
2182
|
};
|
|
2049
|
-
return /* @__PURE__ */
|
|
2183
|
+
return /* @__PURE__ */ React24.createElement(Box, {
|
|
2050
2184
|
shape,
|
|
2051
2185
|
onAction: handleAction
|
|
2052
|
-
}, /* @__PURE__ */
|
|
2186
|
+
}, /* @__PURE__ */ React24.createElement(TextBox5, {
|
|
2053
2187
|
value
|
|
2054
2188
|
}));
|
|
2055
2189
|
};
|
|
@@ -2069,15 +2203,16 @@ var textShape = {
|
|
|
2069
2203
|
};
|
|
2070
2204
|
|
|
2071
2205
|
// src/shapes/Thread.tsx
|
|
2072
|
-
import * as
|
|
2073
|
-
import
|
|
2206
|
+
import * as Schema24 from "effect/Schema";
|
|
2207
|
+
import React25, { useEffect as useEffect7, useRef as useRef6 } from "react";
|
|
2074
2208
|
import { createInputSchema as createInputSchema2, createOutputSchema as createOutputSchema2 } from "@dxos/conductor";
|
|
2209
|
+
import { ScrollArea as ScrollArea3 } from "@dxos/react-ui";
|
|
2075
2210
|
import { Message as Message2 } from "@dxos/types";
|
|
2076
2211
|
import { mx as mx3 } from "@dxos/ui-theme";
|
|
2077
2212
|
var InputSchema2 = createInputSchema2(Message2.Message);
|
|
2078
|
-
var OutputSchema2 = createOutputSchema2(
|
|
2079
|
-
var ThreadShape =
|
|
2080
|
-
type:
|
|
2213
|
+
var OutputSchema2 = createOutputSchema2(Schema24.mutable(Schema24.Array(Message2.Message)));
|
|
2214
|
+
var ThreadShape = Schema24.extend(ComputeShape, Schema24.Struct({
|
|
2215
|
+
type: Schema24.Literal("thread")
|
|
2081
2216
|
}));
|
|
2082
2217
|
var createThread = (props) => createShape({
|
|
2083
2218
|
type: "thread",
|
|
@@ -2097,29 +2232,32 @@ var ThreadComponent = ({ shape }) => {
|
|
|
2097
2232
|
}, [
|
|
2098
2233
|
items
|
|
2099
2234
|
]);
|
|
2100
|
-
return /* @__PURE__ */
|
|
2235
|
+
return /* @__PURE__ */ React25.createElement(Box, {
|
|
2101
2236
|
shape
|
|
2102
|
-
}, /* @__PURE__ */
|
|
2103
|
-
|
|
2104
|
-
|
|
2237
|
+
}, /* @__PURE__ */ React25.createElement(ScrollArea3.Root, {
|
|
2238
|
+
orientation: "vertical"
|
|
2239
|
+
}, /* @__PURE__ */ React25.createElement(ScrollArea3.Viewport, {
|
|
2240
|
+
classNames: "gap-2 p-2",
|
|
2241
|
+
ref: scrollRef
|
|
2105
2242
|
}, [
|
|
2106
2243
|
...items
|
|
2107
|
-
].map((item, i) => /* @__PURE__ */
|
|
2244
|
+
].map((item, i) => /* @__PURE__ */ React25.createElement(ThreadItem, {
|
|
2108
2245
|
key: i,
|
|
2109
2246
|
item
|
|
2110
|
-
}))));
|
|
2247
|
+
})))));
|
|
2111
2248
|
};
|
|
2112
2249
|
var ThreadItem = ({ classNames, item }) => {
|
|
2113
2250
|
if (typeof item !== "object") {
|
|
2114
|
-
return /* @__PURE__ */
|
|
2251
|
+
return /* @__PURE__ */ React25.createElement("div", {
|
|
2252
|
+
role: "none",
|
|
2115
2253
|
className: mx3(classNames)
|
|
2116
2254
|
}, item);
|
|
2117
2255
|
}
|
|
2118
2256
|
const { role, message } = item;
|
|
2119
|
-
return /* @__PURE__ */
|
|
2257
|
+
return /* @__PURE__ */ React25.createElement("div", {
|
|
2120
2258
|
className: mx3("flex", classNames, role === "user" && "justify-end")
|
|
2121
|
-
}, /* @__PURE__ */
|
|
2122
|
-
className: mx3("block rounded-md p-1
|
|
2259
|
+
}, /* @__PURE__ */ React25.createElement("div", {
|
|
2260
|
+
className: mx3("block rounded-md p-1 px-2 text-sm", role === "user" ? "bg-blue-100 dark:bg-blue-800" : role === "system" ? "bg-red-100, dark:bg-red-800" : "whitespace-pre-wrap bg-neutral-50 dark:bg-neutral-800")
|
|
2123
2261
|
}, message));
|
|
2124
2262
|
};
|
|
2125
2263
|
var threadShape = {
|
|
@@ -2133,11 +2271,11 @@ var threadShape = {
|
|
|
2133
2271
|
};
|
|
2134
2272
|
|
|
2135
2273
|
// src/shapes/TextToImage.tsx
|
|
2136
|
-
import * as
|
|
2137
|
-
import
|
|
2274
|
+
import * as Schema25 from "effect/Schema";
|
|
2275
|
+
import React26 from "react";
|
|
2138
2276
|
import { createAnchorMap as createAnchorMap12 } from "@dxos/react-ui-canvas-editor";
|
|
2139
|
-
var TextToImageShape =
|
|
2140
|
-
type:
|
|
2277
|
+
var TextToImageShape = Schema25.extend(ComputeShape, Schema25.Struct({
|
|
2278
|
+
type: Schema25.Literal("text-to-image")
|
|
2141
2279
|
}));
|
|
2142
2280
|
var createTextToImage = (props) => createShape({
|
|
2143
2281
|
type: "text-to-image",
|
|
@@ -2148,7 +2286,7 @@ var createTextToImage = (props) => createShape({
|
|
|
2148
2286
|
...props
|
|
2149
2287
|
});
|
|
2150
2288
|
var TextToImageComponent = ({ shape }) => {
|
|
2151
|
-
return /* @__PURE__ */
|
|
2289
|
+
return /* @__PURE__ */ React26.createElement(Box, {
|
|
2152
2290
|
shape
|
|
2153
2291
|
});
|
|
2154
2292
|
};
|
|
@@ -2167,17 +2305,17 @@ var textToImageShape = {
|
|
|
2167
2305
|
};
|
|
2168
2306
|
|
|
2169
2307
|
// src/shapes/Trigger.tsx
|
|
2170
|
-
import * as
|
|
2171
|
-
import
|
|
2308
|
+
import * as Schema26 from "effect/Schema";
|
|
2309
|
+
import React27, { useEffect as useEffect8 } from "react";
|
|
2172
2310
|
import { VoidInput as VoidInput3 } from "@dxos/conductor";
|
|
2173
|
-
import { Filter as Filter2, Obj as Obj4, Query, Ref as Ref3
|
|
2311
|
+
import { Filter as Filter2, Obj as Obj4, Query, Ref as Ref3 } from "@dxos/echo";
|
|
2174
2312
|
import { Trigger, TriggerEvent } from "@dxos/functions";
|
|
2175
2313
|
import { DXN, SpaceId } from "@dxos/keys";
|
|
2176
|
-
import {
|
|
2314
|
+
import { useSpaces } from "@dxos/react-client/echo";
|
|
2177
2315
|
import { Select as Select2 } from "@dxos/react-ui";
|
|
2178
|
-
var TriggerShape =
|
|
2179
|
-
type:
|
|
2180
|
-
functionTrigger:
|
|
2316
|
+
var TriggerShape = Schema26.extend(ComputeShape, Schema26.Struct({
|
|
2317
|
+
type: Schema26.Literal("trigger"),
|
|
2318
|
+
functionTrigger: Schema26.optional(Ref3.Ref(Trigger.Trigger))
|
|
2181
2319
|
}));
|
|
2182
2320
|
var createTrigger = (props) => {
|
|
2183
2321
|
const functionTrigger = Trigger.make({
|
|
@@ -2195,12 +2333,12 @@ var createTrigger = (props) => {
|
|
|
2195
2333
|
});
|
|
2196
2334
|
};
|
|
2197
2335
|
var TriggerComponent = ({ shape }) => {
|
|
2198
|
-
const space =
|
|
2336
|
+
const [space] = useSpaces();
|
|
2199
2337
|
const functionTrigger = shape.functionTrigger?.target;
|
|
2200
2338
|
useEffect8(() => {
|
|
2201
2339
|
if (functionTrigger && !functionTrigger.spec) {
|
|
2202
|
-
Obj4.change(functionTrigger, (
|
|
2203
|
-
|
|
2340
|
+
Obj4.change(functionTrigger, (functionTrigger2) => {
|
|
2341
|
+
functionTrigger2.spec = createTriggerSpec({
|
|
2204
2342
|
triggerKind: "email",
|
|
2205
2343
|
spaceId: space?.id
|
|
2206
2344
|
});
|
|
@@ -2217,8 +2355,8 @@ var TriggerComponent = ({ shape }) => {
|
|
|
2217
2355
|
]);
|
|
2218
2356
|
const setKind = (kind) => {
|
|
2219
2357
|
if (functionTrigger?.spec?.kind !== kind) {
|
|
2220
|
-
Obj4.change(functionTrigger, (
|
|
2221
|
-
|
|
2358
|
+
Obj4.change(functionTrigger, (obj) => {
|
|
2359
|
+
obj.spec = createTriggerSpec({
|
|
2222
2360
|
triggerKind: kind,
|
|
2223
2361
|
spaceId: space?.id
|
|
2224
2362
|
});
|
|
@@ -2228,9 +2366,9 @@ var TriggerComponent = ({ shape }) => {
|
|
|
2228
2366
|
if (!functionTrigger?.spec) {
|
|
2229
2367
|
return;
|
|
2230
2368
|
}
|
|
2231
|
-
return /* @__PURE__ */
|
|
2369
|
+
return /* @__PURE__ */ React27.createElement(FunctionBody, {
|
|
2232
2370
|
shape,
|
|
2233
|
-
status: /* @__PURE__ */
|
|
2371
|
+
status: /* @__PURE__ */ React27.createElement(TriggerKindSelect, {
|
|
2234
2372
|
value: functionTrigger.spec?.kind,
|
|
2235
2373
|
onValueChange: (kind) => setKind(kind)
|
|
2236
2374
|
}),
|
|
@@ -2239,16 +2377,16 @@ var TriggerComponent = ({ shape }) => {
|
|
|
2239
2377
|
});
|
|
2240
2378
|
};
|
|
2241
2379
|
var TriggerKindSelect = ({ value, onValueChange }) => {
|
|
2242
|
-
return /* @__PURE__ */
|
|
2380
|
+
return /* @__PURE__ */ React27.createElement(Select2.Root, {
|
|
2243
2381
|
value,
|
|
2244
2382
|
onValueChange
|
|
2245
|
-
}, /* @__PURE__ */
|
|
2383
|
+
}, /* @__PURE__ */ React27.createElement(Select2.TriggerButton, {
|
|
2246
2384
|
variant: "ghost",
|
|
2247
|
-
classNames: "
|
|
2248
|
-
}), /* @__PURE__ */
|
|
2385
|
+
classNames: "w-full px-0!"
|
|
2386
|
+
}), /* @__PURE__ */ React27.createElement(Select2.Portal, null, /* @__PURE__ */ React27.createElement(Select2.Content, null, /* @__PURE__ */ React27.createElement(Select2.ScrollUpButton, null), /* @__PURE__ */ React27.createElement(Select2.Viewport, null, Trigger.Kinds.map((kind) => /* @__PURE__ */ React27.createElement(Select2.Option, {
|
|
2249
2387
|
key: kind,
|
|
2250
2388
|
value: kind
|
|
2251
|
-
}, kind))), /* @__PURE__ */
|
|
2389
|
+
}, kind))), /* @__PURE__ */ React27.createElement(Select2.ScrollDownButton, null), /* @__PURE__ */ React27.createElement(Select2.Arrow, null))));
|
|
2252
2390
|
};
|
|
2253
2391
|
var createTriggerSpec = (props) => {
|
|
2254
2392
|
const kind = props.triggerKind ?? "email";
|
|
@@ -2306,134 +2444,6 @@ var triggerShape = {
|
|
|
2306
2444
|
getAnchors: (shape) => createFunctionAnchors(shape, VoidInput3, getOutputSchema(shape.functionTrigger?.target?.spec?.kind ?? "email"))
|
|
2307
2445
|
};
|
|
2308
2446
|
|
|
2309
|
-
// src/shapes/GptRealtime.tsx
|
|
2310
|
-
import * as Schema26 from "effect/Schema";
|
|
2311
|
-
import React27, { useState as useState9 } from "react";
|
|
2312
|
-
import { log as log2 } from "@dxos/log";
|
|
2313
|
-
import { useConfig } from "@dxos/react-client";
|
|
2314
|
-
import { Icon as Icon5 } from "@dxos/react-ui";
|
|
2315
|
-
var __dxlog_file7 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/GptRealtime.tsx";
|
|
2316
|
-
var GptRealtimeShape = Schema26.extend(ComputeShape, Schema26.Struct({
|
|
2317
|
-
type: Schema26.Literal("gpt-realtime")
|
|
2318
|
-
}));
|
|
2319
|
-
var createGptRealtime = (props) => createShape({
|
|
2320
|
-
type: "gpt-realtime",
|
|
2321
|
-
size: {
|
|
2322
|
-
width: 256,
|
|
2323
|
-
height: 256
|
|
2324
|
-
},
|
|
2325
|
-
...props
|
|
2326
|
-
});
|
|
2327
|
-
var GptRealtimeComponent = ({ shape }) => {
|
|
2328
|
-
const [isLive, setIsLive] = useState9(false);
|
|
2329
|
-
const [isReady, setIsReady] = useState9(false);
|
|
2330
|
-
const config = useConfig();
|
|
2331
|
-
const start = async () => {
|
|
2332
|
-
setIsLive(true);
|
|
2333
|
-
try {
|
|
2334
|
-
const peerConnection = new RTCPeerConnection();
|
|
2335
|
-
peerConnection.ontrack = (event) => {
|
|
2336
|
-
const audioElement = document.createElement("audio");
|
|
2337
|
-
audioElement.srcObject = event.streams[0];
|
|
2338
|
-
audioElement.autoplay = true;
|
|
2339
|
-
audioElement.controls = false;
|
|
2340
|
-
audioElement.style.display = "none";
|
|
2341
|
-
document.body.appendChild(audioElement);
|
|
2342
|
-
setIsReady(true);
|
|
2343
|
-
};
|
|
2344
|
-
const stream = await navigator.mediaDevices.getUserMedia({
|
|
2345
|
-
audio: true
|
|
2346
|
-
});
|
|
2347
|
-
stream.getTracks().forEach((track) => peerConnection.addTransceiver(track, {
|
|
2348
|
-
direction: "sendrecv"
|
|
2349
|
-
}));
|
|
2350
|
-
const offer = await peerConnection.createOffer();
|
|
2351
|
-
await peerConnection.setLocalDescription(offer);
|
|
2352
|
-
const AiServiceUrl = new URL("/rtc-connect", config.values.runtime?.services?.ai?.server ?? DEFAULT_AI_SERVICE_URL);
|
|
2353
|
-
const response = await fetch(AiServiceUrl, {
|
|
2354
|
-
method: "POST",
|
|
2355
|
-
body: offer.sdp,
|
|
2356
|
-
headers: {
|
|
2357
|
-
"Content-Type": "application/sdp"
|
|
2358
|
-
}
|
|
2359
|
-
});
|
|
2360
|
-
const answer = await response.text();
|
|
2361
|
-
await peerConnection.setRemoteDescription({
|
|
2362
|
-
sdp: answer,
|
|
2363
|
-
type: "answer"
|
|
2364
|
-
});
|
|
2365
|
-
const dataChannel = peerConnection.createDataChannel("response");
|
|
2366
|
-
const configureData = () => {
|
|
2367
|
-
log2.info("Configuring data channel", void 0, {
|
|
2368
|
-
F: __dxlog_file7,
|
|
2369
|
-
L: 87,
|
|
2370
|
-
S: void 0,
|
|
2371
|
-
C: (f, a) => f(...a)
|
|
2372
|
-
});
|
|
2373
|
-
const event = {
|
|
2374
|
-
type: "session.update",
|
|
2375
|
-
session: {
|
|
2376
|
-
modalities: [
|
|
2377
|
-
"text",
|
|
2378
|
-
"audio"
|
|
2379
|
-
],
|
|
2380
|
-
// Provide the tools. Note they match the keys in the `fns` object above
|
|
2381
|
-
tools: []
|
|
2382
|
-
}
|
|
2383
|
-
};
|
|
2384
|
-
dataChannel.send(JSON.stringify(event));
|
|
2385
|
-
};
|
|
2386
|
-
dataChannel.addEventListener("open", (ev) => {
|
|
2387
|
-
log2.info("Opening data channel", {
|
|
2388
|
-
ev
|
|
2389
|
-
}, {
|
|
2390
|
-
F: __dxlog_file7,
|
|
2391
|
-
L: 100,
|
|
2392
|
-
S: void 0,
|
|
2393
|
-
C: (f, a) => f(...a)
|
|
2394
|
-
});
|
|
2395
|
-
configureData();
|
|
2396
|
-
});
|
|
2397
|
-
dataChannel.addEventListener("message", async (ev) => {
|
|
2398
|
-
const msg = JSON.parse(ev.data);
|
|
2399
|
-
if (msg.type === "response.function_call_arguments.done") {
|
|
2400
|
-
}
|
|
2401
|
-
});
|
|
2402
|
-
} catch (error) {
|
|
2403
|
-
log2.error("Error in realtime session:", {
|
|
2404
|
-
error
|
|
2405
|
-
}, {
|
|
2406
|
-
F: __dxlog_file7,
|
|
2407
|
-
L: 140,
|
|
2408
|
-
S: void 0,
|
|
2409
|
-
C: (f, a) => f(...a)
|
|
2410
|
-
});
|
|
2411
|
-
throw error;
|
|
2412
|
-
}
|
|
2413
|
-
};
|
|
2414
|
-
return /* @__PURE__ */ React27.createElement("div", {
|
|
2415
|
-
className: "flex is-full justify-center items-center"
|
|
2416
|
-
}, /* @__PURE__ */ React27.createElement(Icon5, {
|
|
2417
|
-
icon: isReady ? "ph--waveform--regular" : isLive ? "ph--pulse--regular" : "ph--play--regular",
|
|
2418
|
-
size: 16,
|
|
2419
|
-
classNames: !isLive && "cursor-pointer",
|
|
2420
|
-
onClick: start
|
|
2421
|
-
}));
|
|
2422
|
-
};
|
|
2423
|
-
var gptRealtimeShape = {
|
|
2424
|
-
type: "gpt-realtime",
|
|
2425
|
-
name: "GPT Realtime",
|
|
2426
|
-
icon: "ph--pulse--regular",
|
|
2427
|
-
component: GptRealtimeComponent,
|
|
2428
|
-
createShape: createGptRealtime,
|
|
2429
|
-
// TODO(dmaretskyi): Can we fetch the schema dynamically?
|
|
2430
|
-
getAnchors: (shape) => createFunctionAnchors(shape, Schema26.Struct({
|
|
2431
|
-
audio: Schema26.Any
|
|
2432
|
-
}), Schema26.Struct({})),
|
|
2433
|
-
resizable: true
|
|
2434
|
-
};
|
|
2435
|
-
var DEFAULT_AI_SERVICE_URL = "http://localhost:8788";
|
|
2436
|
-
|
|
2437
2447
|
// src/registry.ts
|
|
2438
2448
|
var computeShapes = [
|
|
2439
2449
|
{
|
|
@@ -2479,7 +2489,7 @@ var computeShapes = [
|
|
|
2479
2489
|
shapes: [
|
|
2480
2490
|
//
|
|
2481
2491
|
jsonShape,
|
|
2482
|
-
|
|
2492
|
+
feedShape,
|
|
2483
2493
|
threadShape,
|
|
2484
2494
|
textShape,
|
|
2485
2495
|
surfaceShape,
|
|
@@ -2538,6 +2548,9 @@ export {
|
|
|
2538
2548
|
ConstantShape,
|
|
2539
2549
|
DatabaseComponent,
|
|
2540
2550
|
DatabaseShape,
|
|
2551
|
+
FeedComponent,
|
|
2552
|
+
FeedItem,
|
|
2553
|
+
FeedShape,
|
|
2541
2554
|
FunctionBody,
|
|
2542
2555
|
FunctionShape,
|
|
2543
2556
|
GptComponent,
|
|
@@ -2555,9 +2568,6 @@ export {
|
|
|
2555
2568
|
JsonTransformShape,
|
|
2556
2569
|
NotShape,
|
|
2557
2570
|
OrShape,
|
|
2558
|
-
QueueComponent,
|
|
2559
|
-
QueueItem,
|
|
2560
|
-
QueueShape,
|
|
2561
2571
|
RandomComponent,
|
|
2562
2572
|
RandomShape,
|
|
2563
2573
|
ReducerComponent,
|
|
@@ -2600,6 +2610,7 @@ export {
|
|
|
2600
2610
|
createComputeNode,
|
|
2601
2611
|
createConstant,
|
|
2602
2612
|
createDatabase,
|
|
2613
|
+
createFeed,
|
|
2603
2614
|
createFunction,
|
|
2604
2615
|
createFunctionAnchors,
|
|
2605
2616
|
createGpt,
|
|
@@ -2610,7 +2621,6 @@ export {
|
|
|
2610
2621
|
createJsonTransform,
|
|
2611
2622
|
createNot,
|
|
2612
2623
|
createOr,
|
|
2613
|
-
createQueue,
|
|
2614
2624
|
createRandom,
|
|
2615
2625
|
createReducer,
|
|
2616
2626
|
createScope,
|
|
@@ -2624,6 +2634,7 @@ export {
|
|
|
2624
2634
|
createThread,
|
|
2625
2635
|
createTrigger,
|
|
2626
2636
|
databaseShape,
|
|
2637
|
+
feedShape,
|
|
2627
2638
|
footerHeight,
|
|
2628
2639
|
functionShape,
|
|
2629
2640
|
getHeight,
|
|
@@ -2640,7 +2651,6 @@ export {
|
|
|
2640
2651
|
notShape,
|
|
2641
2652
|
orShape,
|
|
2642
2653
|
parseAnchorId,
|
|
2643
|
-
queueShape,
|
|
2644
2654
|
randomShape,
|
|
2645
2655
|
reducerShape,
|
|
2646
2656
|
resolveComputeNode,
|