@dxos/react-ui-canvas-compute 0.8.4-main.ae835ea → 0.8.4-main.bc2380dfbc
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/LICENSE +102 -5
- package/dist/lib/browser/index.mjs +916 -1158
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +916 -1158
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/DiagnosticOverlay.d.ts.map +1 -1
- package/dist/types/src/compute-layout.d.ts.map +1 -1
- package/dist/types/src/compute.stories.d.ts +22 -1
- package/dist/types/src/compute.stories.d.ts.map +1 -1
- package/dist/types/src/graph/controller.d.ts +40 -35
- package/dist/types/src/graph/controller.d.ts.map +1 -1
- package/dist/types/src/graph/node-defs.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeGraphController.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeNodeState.d.ts +4 -5
- 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/Append.d.ts +1 -1
- package/dist/types/src/shapes/Append.d.ts.map +1 -1
- package/dist/types/src/shapes/Array.d.ts +1 -1
- package/dist/types/src/shapes/Array.d.ts.map +1 -1
- package/dist/types/src/shapes/Audio.d.ts +1 -1
- package/dist/types/src/shapes/Audio.d.ts.map +1 -1
- package/dist/types/src/shapes/Beacon.d.ts +1 -1
- package/dist/types/src/shapes/Beacon.d.ts.map +1 -1
- package/dist/types/src/shapes/Boolean.d.ts +7 -7
- package/dist/types/src/shapes/Boolean.d.ts.map +1 -1
- package/dist/types/src/shapes/Chat.d.ts +1 -1
- package/dist/types/src/shapes/Chat.d.ts.map +1 -1
- package/dist/types/src/shapes/Constant.d.ts +1 -1
- package/dist/types/src/shapes/Constant.d.ts.map +1 -1
- package/dist/types/src/shapes/Database.d.ts +1 -1
- package/dist/types/src/shapes/Database.d.ts.map +1 -1
- package/dist/types/src/shapes/{Queue.d.ts → Feed.d.ts} +9 -9
- package/dist/types/src/shapes/Feed.d.ts.map +1 -0
- package/dist/types/src/shapes/Function.d.ts +1 -1
- package/dist/types/src/shapes/Function.d.ts.map +1 -1
- package/dist/types/src/shapes/Gpt.d.ts +1 -1
- package/dist/types/src/shapes/Gpt.d.ts.map +1 -1
- package/dist/types/src/shapes/GptRealtime.d.ts +1 -1
- package/dist/types/src/shapes/GptRealtime.d.ts.map +1 -1
- package/dist/types/src/shapes/Json.d.ts +2 -2
- package/dist/types/src/shapes/Json.d.ts.map +1 -1
- package/dist/types/src/shapes/Logic.d.ts +2 -2
- package/dist/types/src/shapes/Logic.d.ts.map +1 -1
- package/dist/types/src/shapes/RNG.d.ts +2 -2
- package/dist/types/src/shapes/RNG.d.ts.map +1 -1
- package/dist/types/src/shapes/Scope.d.ts +1 -1
- package/dist/types/src/shapes/Scope.d.ts.map +1 -1
- package/dist/types/src/shapes/Surface.d.ts +1 -1
- package/dist/types/src/shapes/Surface.d.ts.map +1 -1
- package/dist/types/src/shapes/Switch.d.ts +1 -1
- package/dist/types/src/shapes/Switch.d.ts.map +1 -1
- package/dist/types/src/shapes/Table.d.ts +1 -1
- package/dist/types/src/shapes/Table.d.ts.map +1 -1
- package/dist/types/src/shapes/Template.d.ts +2 -2
- package/dist/types/src/shapes/Template.d.ts.map +1 -1
- package/dist/types/src/shapes/Text.d.ts +1 -1
- package/dist/types/src/shapes/Text.d.ts.map +1 -1
- package/dist/types/src/shapes/TextToImage.d.ts +1 -1
- package/dist/types/src/shapes/TextToImage.d.ts.map +1 -1
- package/dist/types/src/shapes/Thread.d.ts +1 -1
- package/dist/types/src/shapes/Thread.d.ts.map +1 -1
- package/dist/types/src/shapes/Trigger.d.ts +6 -4
- 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 +2 -2
- package/dist/types/src/shapes/common/FunctionBody.d.ts.map +1 -1
- package/dist/types/src/shapes/common/TypeSelect.d.ts +1 -1
- package/dist/types/src/shapes/common/TypeSelect.d.ts.map +1 -1
- package/dist/types/src/shapes/defs.d.ts +1 -1
- package/dist/types/src/shapes/defs.d.ts.map +1 -1
- package/dist/types/src/shapes/index.d.ts +2 -2
- package/dist/types/src/shapes/index.d.ts.map +1 -1
- package/dist/types/src/testing/circuits.d.ts +18 -24
- package/dist/types/src/testing/circuits.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +61 -58
- package/src/README.md +0 -3
- package/src/compute.stories.tsx +89 -114
- package/src/graph/controller.ts +139 -78
- package/src/graph/node-defs.ts +31 -31
- package/src/hooks/useComputeNodeState.ts +7 -8
- package/src/hooks/useGraphMonitor.ts +11 -10
- package/src/json.test.ts +3 -3
- package/src/registry.ts +2 -2
- package/src/schema.test.ts +11 -11
- package/src/shapes/Audio.tsx +1 -2
- package/src/shapes/Beacon.tsx +0 -1
- package/src/shapes/Boolean.tsx +1 -1
- package/src/shapes/Chat.tsx +0 -1
- package/src/shapes/Constant.tsx +0 -1
- package/src/shapes/{Queue.tsx → Feed.tsx} +26 -21
- package/src/shapes/Function.tsx +12 -9
- package/src/shapes/Gpt.tsx +6 -2
- package/src/shapes/Json.tsx +9 -3
- package/src/shapes/RNG.tsx +5 -2
- package/src/shapes/Scope.tsx +0 -1
- package/src/shapes/Surface.tsx +12 -4
- package/src/shapes/Switch.tsx +0 -1
- package/src/shapes/Table.tsx +3 -3
- package/src/shapes/Template.tsx +0 -1
- package/src/shapes/Text.tsx +0 -1
- package/src/shapes/Thread.tsx +12 -10
- package/src/shapes/Trigger.tsx +21 -21
- package/src/shapes/common/Box.tsx +5 -8
- package/src/shapes/common/FunctionBody.tsx +2 -2
- package/src/shapes/common/TypeSelect.tsx +1 -1
- package/src/shapes/defs.ts +3 -3
- package/src/shapes/index.ts +2 -2
- package/src/testing/circuits.ts +7 -16
- package/dist/types/src/shapes/Queue.d.ts.map +0 -1
|
@@ -4,10 +4,13 @@ import { createRequire } from 'node:module';const require = createRequire(import
|
|
|
4
4
|
import * as Effect from "effect/Effect";
|
|
5
5
|
import * as Either from "effect/Either";
|
|
6
6
|
import * as Exit from "effect/Exit";
|
|
7
|
+
import * as Layer from "effect/Layer";
|
|
7
8
|
import * as Scope from "effect/Scope";
|
|
8
9
|
import { Event, synchronized } from "@dxos/async";
|
|
9
|
-
import {
|
|
10
|
+
import { Trace } from "@dxos/compute";
|
|
11
|
+
import { ComputeBeginEvent, ComputeCustomEvent, ComputeEndEvent, ComputeInputEvent, ComputeNodeContext, ComputeOutputEvent, GraphExecutor, ValueBag, isNotExecuted } from "@dxos/conductor";
|
|
10
12
|
import { Resource } from "@dxos/context";
|
|
13
|
+
import { unwrapExit } from "@dxos/effect";
|
|
11
14
|
import { log } from "@dxos/log";
|
|
12
15
|
|
|
13
16
|
// src/hooks/compute-context.ts
|
|
@@ -75,28 +78,12 @@ import { invariant } from "@dxos/invariant";
|
|
|
75
78
|
var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/hooks/useComputeNodeState.ts";
|
|
76
79
|
var useComputeNodeState = (shape) => {
|
|
77
80
|
const { controller } = useComputeContext();
|
|
78
|
-
invariant(controller, void 0, {
|
|
79
|
-
F: __dxlog_file,
|
|
80
|
-
L: 34,
|
|
81
|
-
S: void 0,
|
|
82
|
-
A: [
|
|
83
|
-
"controller",
|
|
84
|
-
""
|
|
85
|
-
]
|
|
86
|
-
});
|
|
81
|
+
invariant(controller, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 12, S: void 0, A: ["controller", ""] });
|
|
87
82
|
const [meta, setMeta] = useState2();
|
|
88
83
|
useEffect2(() => {
|
|
89
84
|
let disposed = false;
|
|
90
85
|
queueMicrotask(async () => {
|
|
91
|
-
invariant(shape.node, "Node not specified", {
|
|
92
|
-
F: __dxlog_file,
|
|
93
|
-
L: 40,
|
|
94
|
-
S: void 0,
|
|
95
|
-
A: [
|
|
96
|
-
"shape.node",
|
|
97
|
-
"'Node not specified'"
|
|
98
|
-
]
|
|
99
|
-
});
|
|
86
|
+
invariant(shape.node, "Node not specified", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 17, S: void 0, A: ["shape.node", "'Node not specified'"] });
|
|
100
87
|
const node = controller.getComputeNode(shape.node);
|
|
101
88
|
const meta2 = await controller.getMeta(node);
|
|
102
89
|
if (disposed) {
|
|
@@ -145,34 +132,17 @@ var useComputeNodeState = (shape) => {
|
|
|
145
132
|
// src/hooks/useGraphMonitor.ts
|
|
146
133
|
import { useMemo } from "react";
|
|
147
134
|
import { ComputeGraphModel, DEFAULT_INPUT, DEFAULT_OUTPUT } from "@dxos/conductor";
|
|
148
|
-
import {
|
|
135
|
+
import { Obj, Ref } from "@dxos/echo";
|
|
149
136
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
150
|
-
import { getSpace } from "@dxos/react-client/echo";
|
|
151
137
|
import { isNonNullable } from "@dxos/util";
|
|
152
138
|
var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/hooks/useGraphMonitor.ts";
|
|
153
139
|
var mapEdge = (graph, { source, target, output = DEFAULT_OUTPUT, input = DEFAULT_INPUT }) => {
|
|
154
140
|
const sourceNode = graph.findNode(source);
|
|
155
141
|
const targetNode = graph.findNode(target);
|
|
156
|
-
invariant2(sourceNode?.node, void 0, {
|
|
157
|
-
|
|
158
|
-
L: 26,
|
|
159
|
-
S: void 0,
|
|
160
|
-
A: [
|
|
161
|
-
"sourceNode?.node",
|
|
162
|
-
""
|
|
163
|
-
]
|
|
164
|
-
});
|
|
165
|
-
invariant2(targetNode?.node, void 0, {
|
|
166
|
-
F: __dxlog_file2,
|
|
167
|
-
L: 27,
|
|
168
|
-
S: void 0,
|
|
169
|
-
A: [
|
|
170
|
-
"targetNode?.node",
|
|
171
|
-
""
|
|
172
|
-
]
|
|
173
|
-
});
|
|
142
|
+
invariant2(sourceNode?.node, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 15, S: void 0, A: ["sourceNode?.node", ""] });
|
|
143
|
+
invariant2(targetNode?.node, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 16, S: void 0, A: ["targetNode?.node", ""] });
|
|
174
144
|
return {
|
|
175
|
-
id:
|
|
145
|
+
id: Obj.ID.random(),
|
|
176
146
|
source: sourceNode.node,
|
|
177
147
|
target: targetNode.node,
|
|
178
148
|
output,
|
|
@@ -186,15 +156,7 @@ var useGraphMonitor = (model) => {
|
|
|
186
156
|
if (!model) {
|
|
187
157
|
return;
|
|
188
158
|
}
|
|
189
|
-
invariant2(node.type, void 0, {
|
|
190
|
-
F: __dxlog_file2,
|
|
191
|
-
L: 52,
|
|
192
|
-
S: void 0,
|
|
193
|
-
A: [
|
|
194
|
-
"node.type",
|
|
195
|
-
""
|
|
196
|
-
]
|
|
197
|
-
});
|
|
159
|
+
invariant2(node.type, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 37, S: void 0, A: ["node.type", ""] });
|
|
198
160
|
if (!isValidComputeNode(node.type)) {
|
|
199
161
|
return;
|
|
200
162
|
}
|
|
@@ -244,27 +206,21 @@ var createComputeGraph = (graph) => {
|
|
|
244
206
|
};
|
|
245
207
|
var linkTriggerToCompute = (graph, computeNode, triggerData) => {
|
|
246
208
|
const functionTrigger = triggerData.functionTrigger?.target;
|
|
247
|
-
invariant2(functionTrigger, void 0, {
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
A: [
|
|
252
|
-
"functionTrigger",
|
|
253
|
-
""
|
|
254
|
-
]
|
|
209
|
+
invariant2(functionTrigger, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 88, S: void 0, A: ["functionTrigger", ""] });
|
|
210
|
+
Obj.update(functionTrigger, (functionTrigger2) => {
|
|
211
|
+
functionTrigger2.function = Ref.make(graph.root);
|
|
212
|
+
functionTrigger2.inputNodeId = computeNode.id;
|
|
255
213
|
});
|
|
256
|
-
functionTrigger.function = Ref.make(graph.root);
|
|
257
|
-
functionTrigger.inputNodeId = computeNode.id;
|
|
258
214
|
};
|
|
259
215
|
var deleteTriggerObjects = (computeGraph, deleted) => {
|
|
260
|
-
const
|
|
261
|
-
if (!
|
|
216
|
+
const db = Obj.getDatabase(computeGraph.root);
|
|
217
|
+
if (!db) {
|
|
262
218
|
return;
|
|
263
219
|
}
|
|
264
220
|
for (const node of deleted.nodes) {
|
|
265
221
|
if (node.type === "trigger") {
|
|
266
222
|
const trigger = node;
|
|
267
|
-
|
|
223
|
+
db.remove(trigger.functionTrigger.target);
|
|
268
224
|
}
|
|
269
225
|
}
|
|
270
226
|
};
|
|
@@ -272,20 +228,12 @@ var deleteTriggerObjects = (computeGraph, deleted) => {
|
|
|
272
228
|
// src/graph/node-defs.ts
|
|
273
229
|
import { NODE_INPUT, NODE_OUTPUT, getTemplateInputSchema, registry } from "@dxos/conductor";
|
|
274
230
|
import { raise as raise2 } from "@dxos/debug";
|
|
275
|
-
import {
|
|
231
|
+
import { JsonSchema, Obj as Obj2 } from "@dxos/echo";
|
|
276
232
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
277
233
|
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/graph/node-defs.ts";
|
|
278
234
|
var resolveComputeNode = async (node) => {
|
|
279
235
|
const impl = registry[node.type];
|
|
280
|
-
invariant3(impl, `Unknown node type: ${node.type}`, {
|
|
281
|
-
F: __dxlog_file3,
|
|
282
|
-
L: 22,
|
|
283
|
-
S: void 0,
|
|
284
|
-
A: [
|
|
285
|
-
"impl",
|
|
286
|
-
"`Unknown node type: ${node.type}`"
|
|
287
|
-
]
|
|
288
|
-
});
|
|
236
|
+
invariant3(impl, `Unknown node type: ${node.type}`, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 10, S: void 0, A: ["impl", "`Unknown node type: ${node.type}`"] });
|
|
289
237
|
return impl;
|
|
290
238
|
};
|
|
291
239
|
var isValidComputeNode = (type) => {
|
|
@@ -301,74 +249,74 @@ var nodeFactory = {
|
|
|
301
249
|
[NODE_INPUT]: () => createNode(NODE_INPUT),
|
|
302
250
|
[NODE_OUTPUT]: () => createNode(NODE_OUTPUT),
|
|
303
251
|
// Extensions.
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
252
|
+
"text-to-image": () => createNode("text-to-image"),
|
|
253
|
+
and: () => createNode("and"),
|
|
254
|
+
append: () => createNode("append"),
|
|
255
|
+
audio: () => createNode("audio"),
|
|
256
|
+
beacon: () => createNode("beacon"),
|
|
257
|
+
chat: () => createNode("chat"),
|
|
258
|
+
constant: (shape) => createNode("constant", {
|
|
311
259
|
value: shape.value
|
|
312
260
|
}),
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
261
|
+
"make-queue": () => createNode("make-queue"),
|
|
262
|
+
database: () => createNode("database"),
|
|
263
|
+
gpt: () => createNode("gpt"),
|
|
264
|
+
"gpt-realtime": () => createNode("gpt-realtime"),
|
|
265
|
+
if: () => createNode("if"),
|
|
266
|
+
"if-else": () => createNode("if-else"),
|
|
267
|
+
function: () => createNode("function"),
|
|
268
|
+
json: () => createNode("json"),
|
|
269
|
+
"json-transform": () => createNode("json-transform"),
|
|
270
|
+
not: () => createNode("not"),
|
|
271
|
+
or: () => createNode("or"),
|
|
272
|
+
queue: () => createNode("queue"),
|
|
273
|
+
rng: () => createNode("rng"),
|
|
274
|
+
reducer: () => createNode("reducer"),
|
|
275
|
+
scope: () => createNode("scope"),
|
|
276
|
+
surface: () => createNode("surface"),
|
|
277
|
+
switch: () => createNode("switch"),
|
|
278
|
+
template: (shape) => {
|
|
331
279
|
const node = createNode("template", {
|
|
332
280
|
valueType: shape.valueType,
|
|
333
281
|
value: shape.text
|
|
334
282
|
});
|
|
335
|
-
node.inputSchema = toJsonSchema(getTemplateInputSchema(node));
|
|
283
|
+
node.inputSchema = JsonSchema.toJsonSchema(getTemplateInputSchema(node));
|
|
336
284
|
return node;
|
|
337
285
|
},
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
286
|
+
text: () => createNode("text"),
|
|
287
|
+
thread: () => createNode("thread"),
|
|
288
|
+
trigger: () => createNode(NODE_INPUT)
|
|
341
289
|
};
|
|
342
290
|
var createNode = (type, props) => ({
|
|
343
|
-
id:
|
|
291
|
+
id: Obj2.ID.random(),
|
|
344
292
|
type,
|
|
345
293
|
...props
|
|
346
294
|
});
|
|
347
295
|
|
|
348
296
|
// src/graph/controller.ts
|
|
297
|
+
var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/graph/controller.ts";
|
|
349
298
|
function _ts_decorate(decorators, target, key, desc) {
|
|
350
299
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
351
300
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
352
301
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
353
302
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
354
303
|
}
|
|
355
|
-
var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/graph/controller.ts";
|
|
356
304
|
var InvalidStateError = Error;
|
|
357
305
|
var AUTO_TRIGGER_NODES = [
|
|
358
306
|
"chat",
|
|
359
307
|
"switch",
|
|
360
308
|
"constant"
|
|
361
309
|
];
|
|
362
|
-
var createComputeGraphController = (graph,
|
|
310
|
+
var createComputeGraphController = (graph, computeRuntime) => {
|
|
363
311
|
const computeGraph = createComputeGraph(graph);
|
|
364
|
-
const controller = new ComputeGraphController(
|
|
312
|
+
const controller = new ComputeGraphController(computeRuntime, computeGraph);
|
|
365
313
|
return {
|
|
366
314
|
controller,
|
|
367
315
|
graph
|
|
368
316
|
};
|
|
369
317
|
};
|
|
370
318
|
var ComputeGraphController = class extends Resource {
|
|
371
|
-
|
|
319
|
+
_computeRuntime;
|
|
372
320
|
_graph;
|
|
373
321
|
_executor = new GraphExecutor({
|
|
374
322
|
computeNodeResolver: (node) => resolveComputeNode(node)
|
|
@@ -388,8 +336,8 @@ var ComputeGraphController = class extends Resource {
|
|
|
388
336
|
/** Computed result. */
|
|
389
337
|
output = new Event();
|
|
390
338
|
events = new Event();
|
|
391
|
-
constructor(
|
|
392
|
-
super(), this.
|
|
339
|
+
constructor(_computeRuntime, _graph) {
|
|
340
|
+
super(), this._computeRuntime = _computeRuntime, this._graph = _graph;
|
|
393
341
|
}
|
|
394
342
|
toJSON() {
|
|
395
343
|
return {
|
|
@@ -457,12 +405,7 @@ var ComputeGraphController = class extends Resource {
|
|
|
457
405
|
try {
|
|
458
406
|
await this.exec(nodeId);
|
|
459
407
|
} catch (err) {
|
|
460
|
-
log.catch(err, void 0, {
|
|
461
|
-
F: __dxlog_file4,
|
|
462
|
-
L: 210,
|
|
463
|
-
S: this,
|
|
464
|
-
C: (f, a) => f(...a)
|
|
465
|
-
});
|
|
408
|
+
log.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 128, S: this });
|
|
466
409
|
}
|
|
467
410
|
});
|
|
468
411
|
}
|
|
@@ -481,12 +424,11 @@ var ComputeGraphController = class extends Resource {
|
|
|
481
424
|
for (const [nodeId2, outputs] of Object.entries(this._forcedOutputs)) {
|
|
482
425
|
executor.setOutputs(nodeId2, Effect.succeed(ValueBag.make(outputs)));
|
|
483
426
|
}
|
|
484
|
-
|
|
485
|
-
await Effect.runPromise(Effect.gen(this, function* () {
|
|
427
|
+
unwrapExit(await this._computeRuntime.runPromiseExit(Effect.gen(this, function* () {
|
|
486
428
|
const scope = yield* Scope.make();
|
|
487
429
|
const executable = yield* Effect.promise(() => resolveComputeNode(this._graph.getNode(nodeId)));
|
|
488
430
|
const computingOutputs = executable.exec != null;
|
|
489
|
-
const effect = (computingOutputs ? executor.computeOutputs(nodeId) : executor.computeInputs(nodeId)).pipe(Effect.withSpan("runGraph"), Scope.extend(scope), Effect.
|
|
431
|
+
const effect = (computingOutputs ? executor.computeOutputs(nodeId) : executor.computeInputs(nodeId)).pipe(Effect.withSpan("runGraph"), Scope.extend(scope), Effect.provide(Layer.mergeAll(Layer.succeed(Trace.TraceService, this._createTraceWriter()), ComputeNodeContext.layerNoop)), Effect.flatMap(computeValueBag), Effect.withSpan("test"), Effect.tap((values) => {
|
|
490
432
|
for (const [key, value] of Object.entries(values)) {
|
|
491
433
|
if (computingOutputs) {
|
|
492
434
|
this._onOutputComputed(nodeId, key, value);
|
|
@@ -497,7 +439,7 @@ var ComputeGraphController = class extends Resource {
|
|
|
497
439
|
}));
|
|
498
440
|
yield* effect;
|
|
499
441
|
yield* Scope.close(scope, Exit.void);
|
|
500
|
-
}));
|
|
442
|
+
})));
|
|
501
443
|
this.update.emit();
|
|
502
444
|
}
|
|
503
445
|
/**
|
|
@@ -518,13 +460,13 @@ var ComputeGraphController = class extends Resource {
|
|
|
518
460
|
const allAffectedNodes = [
|
|
519
461
|
...new Set(triggerNodes.flatMap((node) => executor.getAllDependantNodes(node.id)))
|
|
520
462
|
];
|
|
521
|
-
await
|
|
463
|
+
unwrapExit(await this._computeRuntime.runPromiseExit(Effect.gen(this, function* () {
|
|
522
464
|
const scope = yield* Scope.make();
|
|
523
465
|
const tasks = [];
|
|
524
466
|
for (const node of allAffectedNodes) {
|
|
525
467
|
const executable = yield* Effect.promise(() => resolveComputeNode(this._graph.getNode(node)));
|
|
526
468
|
const computingOutputs = executable.exec != null;
|
|
527
|
-
const effect = (computingOutputs ? executor.computeOutputs(node) : executor.computeInputs(node)).pipe(Effect.withSpan("runGraph"), Scope.extend(scope), Effect.flatMap(computeValueBag), Effect.provide(
|
|
469
|
+
const effect = (computingOutputs ? executor.computeOutputs(node) : executor.computeInputs(node)).pipe(Effect.withSpan("runGraph"), Scope.extend(scope), Effect.flatMap(computeValueBag), Effect.provide(Layer.mergeAll(Layer.succeed(Trace.TraceService, this._createTraceWriter()), ComputeNodeContext.layerNoop)), Effect.withSpan("test"), Effect.tap((values) => {
|
|
528
470
|
for (const [key, value] of Object.entries(values)) {
|
|
529
471
|
if (computingOutputs) {
|
|
530
472
|
this._onOutputComputed(node, key, value);
|
|
@@ -537,26 +479,23 @@ var ComputeGraphController = class extends Resource {
|
|
|
537
479
|
}
|
|
538
480
|
yield* Effect.all(tasks);
|
|
539
481
|
yield* Scope.close(scope, Exit.void);
|
|
540
|
-
}));
|
|
482
|
+
})));
|
|
541
483
|
this.update.emit();
|
|
542
484
|
}
|
|
543
|
-
|
|
485
|
+
_createTraceWriter() {
|
|
544
486
|
return {
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
487
|
+
write: (eventType, payload) => {
|
|
488
|
+
const event = traceEventToComputeEvent(eventType.key, payload);
|
|
489
|
+
if (event) {
|
|
490
|
+
this._handleEvent(event);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
549
493
|
};
|
|
550
494
|
}
|
|
551
495
|
_handleEvent(event) {
|
|
552
496
|
log("handleEvent", {
|
|
553
497
|
event
|
|
554
|
-
}, {
|
|
555
|
-
F: __dxlog_file4,
|
|
556
|
-
L: 346,
|
|
557
|
-
S: this,
|
|
558
|
-
C: (f, a) => f(...a)
|
|
559
|
-
});
|
|
498
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 223, S: this });
|
|
560
499
|
switch (event.type) {
|
|
561
500
|
case "compute-input": {
|
|
562
501
|
this._onInputComputed(event.nodeId, event.property, {
|
|
@@ -595,6 +534,37 @@ _ts_decorate([
|
|
|
595
534
|
_ts_decorate([
|
|
596
535
|
synchronized
|
|
597
536
|
], ComputeGraphController.prototype, "exec", null);
|
|
537
|
+
var traceEventToComputeEvent = (key, payload) => {
|
|
538
|
+
switch (key) {
|
|
539
|
+
case ComputeBeginEvent.key:
|
|
540
|
+
return {
|
|
541
|
+
type: "begin-compute",
|
|
542
|
+
...payload
|
|
543
|
+
};
|
|
544
|
+
case ComputeEndEvent.key:
|
|
545
|
+
return {
|
|
546
|
+
type: "end-compute",
|
|
547
|
+
...payload
|
|
548
|
+
};
|
|
549
|
+
case ComputeInputEvent.key:
|
|
550
|
+
return {
|
|
551
|
+
type: "compute-input",
|
|
552
|
+
...payload
|
|
553
|
+
};
|
|
554
|
+
case ComputeOutputEvent.key:
|
|
555
|
+
return {
|
|
556
|
+
type: "compute-output",
|
|
557
|
+
...payload
|
|
558
|
+
};
|
|
559
|
+
case ComputeCustomEvent.key:
|
|
560
|
+
return {
|
|
561
|
+
type: "custom",
|
|
562
|
+
...payload
|
|
563
|
+
};
|
|
564
|
+
default:
|
|
565
|
+
return void 0;
|
|
566
|
+
}
|
|
567
|
+
};
|
|
598
568
|
var computeValueBag = (bag) => {
|
|
599
569
|
return Effect.all(Object.entries(bag.values).map(([key, eff]) => Effect.either(eff).pipe(Effect.map((value) => {
|
|
600
570
|
if (Either.isLeft(value)) {
|
|
@@ -630,78 +600,61 @@ var computeValueBag = (bag) => {
|
|
|
630
600
|
import { noteShape } from "@dxos/react-ui-canvas-editor";
|
|
631
601
|
|
|
632
602
|
// src/shapes/common/Box.tsx
|
|
633
|
-
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
634
603
|
import React, { forwardRef } from "react";
|
|
635
604
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
636
605
|
import { Icon, IconButton } from "@dxos/react-ui";
|
|
637
606
|
import { useEditorContext, useShapeDef } from "@dxos/react-ui-canvas-editor";
|
|
638
|
-
import { mx } from "@dxos/
|
|
607
|
+
import { mx } from "@dxos/ui-theme";
|
|
639
608
|
var __dxlog_file5 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/common/Box.tsx";
|
|
640
609
|
var headerHeight = 32;
|
|
641
610
|
var footerHeight = 32;
|
|
642
611
|
var Box = /* @__PURE__ */ forwardRef(({ children, classNames, shape, title, status, open, onAction }, forwardedRef) => {
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
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
|
-
}, 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
|
-
})));
|
|
698
|
-
} finally {
|
|
699
|
-
_effect.f();
|
|
700
|
-
}
|
|
612
|
+
invariant4(shape.type, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 12, S: void 0, A: ["shape.type", ""] });
|
|
613
|
+
const { icon, name, openable } = useShapeDef(shape.type) ?? {
|
|
614
|
+
icon: "ph--placeholder--regular"
|
|
615
|
+
};
|
|
616
|
+
const { debug } = useEditorContext();
|
|
617
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
618
|
+
ref: forwardedRef,
|
|
619
|
+
className: "flex flex-col h-full w-full justify-between"
|
|
620
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
621
|
+
className: "flex shrink-0 w-full justify-between items-center h-[32px] bg-input-surface"
|
|
622
|
+
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
623
|
+
icon,
|
|
624
|
+
classNames: "mx-2"
|
|
625
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
626
|
+
className: "grow text-sm truncate"
|
|
627
|
+
}, debug ? shape.type : name ?? shape.text ?? title), /* @__PURE__ */ React.createElement(IconButton, {
|
|
628
|
+
classNames: "p-1 text-green-500",
|
|
629
|
+
variant: "ghost",
|
|
630
|
+
icon: "ph--play--regular",
|
|
631
|
+
label: "run",
|
|
632
|
+
iconOnly: true,
|
|
633
|
+
onDoubleClick: (ev) => ev.stopPropagation(),
|
|
634
|
+
onClick: (ev) => {
|
|
635
|
+
ev.stopPropagation();
|
|
636
|
+
onAction?.("run");
|
|
637
|
+
}
|
|
638
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
639
|
+
className: mx("flex flex-col h-full grow overflow-hidden", classNames)
|
|
640
|
+
}, children), /* @__PURE__ */ React.createElement("div", {
|
|
641
|
+
className: "flex shrink-0 w-full justify-between items-center h-[32px] bg-input-surface"
|
|
642
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
643
|
+
className: "grow px-2 text-sm truncate"
|
|
644
|
+
}, debug ? shape.id : status), openable && /* @__PURE__ */ React.createElement(IconButton, {
|
|
645
|
+
classNames: "p-1",
|
|
646
|
+
variant: "ghost",
|
|
647
|
+
icon: open ? "ph--caret-up--regular" : "ph--caret-down--regular",
|
|
648
|
+
label: open ? "close" : "open",
|
|
649
|
+
iconOnly: true,
|
|
650
|
+
onClick: (ev) => {
|
|
651
|
+
ev.stopPropagation();
|
|
652
|
+
onAction?.(open ? "close" : "open");
|
|
653
|
+
}
|
|
654
|
+
})));
|
|
701
655
|
});
|
|
702
656
|
|
|
703
657
|
// src/shapes/common/FunctionBody.tsx
|
|
704
|
-
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
705
658
|
import * as SchemaAST2 from "effect/SchemaAST";
|
|
706
659
|
import React2, { useRef, useState as useState3 } from "react";
|
|
707
660
|
import { VoidInput, VoidOutput } from "@dxos/conductor";
|
|
@@ -712,7 +665,7 @@ import { createAnchors, getParentShapeElement, rowHeight } from "@dxos/react-ui-
|
|
|
712
665
|
import * as Schema2 from "effect/Schema";
|
|
713
666
|
import * as SchemaAST from "effect/SchemaAST";
|
|
714
667
|
import { DEFAULT_INPUT as DEFAULT_INPUT2, DEFAULT_OUTPUT as DEFAULT_OUTPUT2 } from "@dxos/conductor";
|
|
715
|
-
import {
|
|
668
|
+
import { Obj as Obj3 } from "@dxos/echo";
|
|
716
669
|
import { Polygon } from "@dxos/react-ui-canvas-editor";
|
|
717
670
|
var getProperties = (ast) => SchemaAST.getPropertySignatures(ast).map(({ name }) => ({
|
|
718
671
|
name: name.toString()
|
|
@@ -730,13 +683,13 @@ var parseAnchorId = (id) => {
|
|
|
730
683
|
};
|
|
731
684
|
var ComputeShape = Schema2.extend(Polygon, Schema2.Struct({
|
|
732
685
|
// TODO(burdon): Rename computeNode?
|
|
733
|
-
node: Schema2.optional(
|
|
686
|
+
node: Schema2.optional(Obj3.ID.annotations({
|
|
734
687
|
description: "Compute node id"
|
|
735
688
|
}))
|
|
736
689
|
}).pipe(Schema2.mutable));
|
|
737
690
|
var createShape = ({ id, ...rest }) => {
|
|
738
691
|
return {
|
|
739
|
-
id: id ??
|
|
692
|
+
id: id ?? Obj3.ID.random(),
|
|
740
693
|
...rest
|
|
741
694
|
};
|
|
742
695
|
};
|
|
@@ -745,70 +698,65 @@ var createShape = ({ id, ...rest }) => {
|
|
|
745
698
|
var bodyPadding = 8;
|
|
746
699
|
var expandedHeight = 200;
|
|
747
700
|
var FunctionBody = ({ shape, name, content, inputSchema = VoidInput, outputSchema = VoidOutput, ...props }) => {
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
setOpen(true);
|
|
763
|
-
break;
|
|
764
|
-
}
|
|
765
|
-
case "close": {
|
|
766
|
-
const el = getParentShapeElement(rootRef.current, shape.id);
|
|
767
|
-
el.style.height = "";
|
|
768
|
-
setOpen(false);
|
|
769
|
-
break;
|
|
770
|
-
}
|
|
771
|
-
}
|
|
772
|
-
};
|
|
773
|
-
const inputs = getProperties(inputSchema.ast);
|
|
774
|
-
const outputs = getProperties(outputSchema.ast);
|
|
775
|
-
const columnCount = inputs.length && outputs.length ? 2 : 1;
|
|
776
|
-
return /* @__PURE__ */ React2.createElement(Box, {
|
|
777
|
-
ref: rootRef,
|
|
778
|
-
shape,
|
|
779
|
-
title: name,
|
|
780
|
-
classNames: "divide-y divide-separator",
|
|
781
|
-
open,
|
|
782
|
-
onAction: handleAction,
|
|
783
|
-
...props
|
|
784
|
-
}, /* @__PURE__ */ React2.createElement("div", {
|
|
785
|
-
className: `grid grid-cols-${columnCount} items-center`,
|
|
786
|
-
style: {
|
|
787
|
-
paddingTop: bodyPadding,
|
|
788
|
-
paddingBottom: bodyPadding
|
|
789
|
-
}
|
|
790
|
-
}, (inputs?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement("div", {
|
|
791
|
-
className: "flex flex-col"
|
|
792
|
-
}, inputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
|
|
793
|
-
key: name2,
|
|
794
|
-
className: "px-2 truncate text-sm font-mono items-center",
|
|
795
|
-
style: {
|
|
796
|
-
height: rowHeight
|
|
701
|
+
const { scale } = useCanvasContext();
|
|
702
|
+
const rootRef = useRef(null);
|
|
703
|
+
const [open, setOpen] = useState3(false);
|
|
704
|
+
const handleAction = (action) => {
|
|
705
|
+
if (!rootRef.current) {
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
switch (action) {
|
|
709
|
+
case "open": {
|
|
710
|
+
const el = getParentShapeElement(rootRef.current, shape.id);
|
|
711
|
+
const { height } = el.getBoundingClientRect();
|
|
712
|
+
el.style.height = `${height / scale + expandedHeight}px`;
|
|
713
|
+
setOpen(true);
|
|
714
|
+
break;
|
|
797
715
|
}
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
style: {
|
|
804
|
-
height: rowHeight
|
|
716
|
+
case "close": {
|
|
717
|
+
const el = getParentShapeElement(rootRef.current, shape.id);
|
|
718
|
+
el.style.height = "";
|
|
719
|
+
setOpen(false);
|
|
720
|
+
break;
|
|
805
721
|
}
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
722
|
+
}
|
|
723
|
+
};
|
|
724
|
+
const inputs = getProperties(inputSchema.ast);
|
|
725
|
+
const outputs = getProperties(outputSchema.ast);
|
|
726
|
+
const columnCount = inputs.length && outputs.length ? 2 : 1;
|
|
727
|
+
return /* @__PURE__ */ React2.createElement(Box, {
|
|
728
|
+
ref: rootRef,
|
|
729
|
+
shape,
|
|
730
|
+
title: name,
|
|
731
|
+
classNames: "divide-y divide-separator",
|
|
732
|
+
open,
|
|
733
|
+
onAction: handleAction,
|
|
734
|
+
...props
|
|
735
|
+
}, /* @__PURE__ */ React2.createElement("div", {
|
|
736
|
+
className: `grid grid-cols-${columnCount} items-center`,
|
|
737
|
+
style: {
|
|
738
|
+
paddingTop: bodyPadding,
|
|
739
|
+
paddingBottom: bodyPadding
|
|
740
|
+
}
|
|
741
|
+
}, (inputs?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement("div", {
|
|
742
|
+
className: "flex flex-col"
|
|
743
|
+
}, inputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
|
|
744
|
+
key: name2,
|
|
745
|
+
className: "px-2 truncate text-sm font-mono items-center",
|
|
746
|
+
style: {
|
|
747
|
+
height: rowHeight
|
|
748
|
+
}
|
|
749
|
+
}, name2))), (outputs?.length ?? 0) > 0 && /* @__PURE__ */ React2.createElement("div", {
|
|
750
|
+
className: "flex flex-col"
|
|
751
|
+
}, outputs?.map(({ name: name2 }) => /* @__PURE__ */ React2.createElement("div", {
|
|
752
|
+
key: name2,
|
|
753
|
+
className: "px-2 truncate text-sm font-mono items-center text-right",
|
|
754
|
+
style: {
|
|
755
|
+
height: rowHeight
|
|
756
|
+
}
|
|
757
|
+
}, name2)))), open && /* @__PURE__ */ React2.createElement("div", {
|
|
758
|
+
className: "flex flex-col grow overflow-hidden"
|
|
759
|
+
}, content));
|
|
812
760
|
};
|
|
813
761
|
var getHeight = (input) => {
|
|
814
762
|
const properties = SchemaAST2.getPropertySignatures(input.ast);
|
|
@@ -829,30 +777,23 @@ var createFunctionAnchors = (shape, input = VoidInput, output = VoidOutput) => {
|
|
|
829
777
|
};
|
|
830
778
|
|
|
831
779
|
// src/shapes/common/TypeSelect.tsx
|
|
832
|
-
import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
|
|
833
780
|
import React3 from "react";
|
|
834
781
|
import { ComputeValueType } from "@dxos/conductor";
|
|
835
782
|
import { Select } from "@dxos/react-ui";
|
|
836
783
|
var TypeSelect = ({ value, onValueChange }) => {
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
value: type
|
|
848
|
-
}, type))), /* @__PURE__ */ React3.createElement(Select.ScrollDownButton, null), /* @__PURE__ */ React3.createElement(Select.Arrow, null))));
|
|
849
|
-
} finally {
|
|
850
|
-
_effect.f();
|
|
851
|
-
}
|
|
784
|
+
return /* @__PURE__ */ React3.createElement(Select.Root, {
|
|
785
|
+
value,
|
|
786
|
+
onValueChange
|
|
787
|
+
}, /* @__PURE__ */ React3.createElement(Select.TriggerButton, {
|
|
788
|
+
variant: "ghost",
|
|
789
|
+
classNames: "w-full px-0!"
|
|
790
|
+
}), /* @__PURE__ */ React3.createElement(Select.Portal, null, /* @__PURE__ */ React3.createElement(Select.Content, null, /* @__PURE__ */ React3.createElement(Select.ScrollUpButton, null), /* @__PURE__ */ React3.createElement(Select.Viewport, null, ComputeValueType.literals.map((type) => /* @__PURE__ */ React3.createElement(Select.Option, {
|
|
791
|
+
key: type,
|
|
792
|
+
value: type
|
|
793
|
+
}, type))), /* @__PURE__ */ React3.createElement(Select.ScrollDownButton, null), /* @__PURE__ */ React3.createElement(Select.Arrow, null))));
|
|
852
794
|
};
|
|
853
795
|
|
|
854
796
|
// src/shapes/Array.tsx
|
|
855
|
-
import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
|
|
856
797
|
import * as Schema3 from "effect/Schema";
|
|
857
798
|
import React4 from "react";
|
|
858
799
|
import { ReducerInput, ReducerOutput } from "@dxos/conductor";
|
|
@@ -860,16 +801,11 @@ var ReducerShape = Schema3.extend(ComputeShape, Schema3.Struct({
|
|
|
860
801
|
type: Schema3.Literal("reducer")
|
|
861
802
|
}));
|
|
862
803
|
var ReducerComponent = ({ shape }) => {
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
outputSchema: ReducerOutput
|
|
869
|
-
});
|
|
870
|
-
} finally {
|
|
871
|
-
_effect.f();
|
|
872
|
-
}
|
|
804
|
+
return /* @__PURE__ */ React4.createElement(FunctionBody, {
|
|
805
|
+
shape,
|
|
806
|
+
inputSchema: ReducerInput,
|
|
807
|
+
outputSchema: ReducerOutput
|
|
808
|
+
});
|
|
873
809
|
};
|
|
874
810
|
var createReducer = ({ id, size = {
|
|
875
811
|
width: 192,
|
|
@@ -889,7 +825,6 @@ var reducerShape = {
|
|
|
889
825
|
};
|
|
890
826
|
|
|
891
827
|
// src/shapes/Append.tsx
|
|
892
|
-
import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
|
|
893
828
|
import * as Schema4 from "effect/Schema";
|
|
894
829
|
import React5 from "react";
|
|
895
830
|
import { AppendInput } from "@dxos/conductor";
|
|
@@ -905,15 +840,10 @@ var createAppend = (props) => createShape({
|
|
|
905
840
|
...props
|
|
906
841
|
});
|
|
907
842
|
var AppendComponent = ({ shape }) => {
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
inputSchema: AppendInput
|
|
913
|
-
});
|
|
914
|
-
} finally {
|
|
915
|
-
_effect.f();
|
|
916
|
-
}
|
|
843
|
+
return /* @__PURE__ */ React5.createElement(FunctionBody, {
|
|
844
|
+
shape,
|
|
845
|
+
inputSchema: AppendInput
|
|
846
|
+
});
|
|
917
847
|
};
|
|
918
848
|
var appendShape = {
|
|
919
849
|
type: "append",
|
|
@@ -925,7 +855,6 @@ var appendShape = {
|
|
|
925
855
|
};
|
|
926
856
|
|
|
927
857
|
// src/shapes/Audio.tsx
|
|
928
|
-
import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
|
|
929
858
|
import * as Schema5 from "effect/Schema";
|
|
930
859
|
import React6, { useEffect as useEffect3, useState as useState4 } from "react";
|
|
931
860
|
import { Icon as Icon2 } from "@dxos/react-ui";
|
|
@@ -942,29 +871,24 @@ var createAudio = (props) => createShape({
|
|
|
942
871
|
...props
|
|
943
872
|
});
|
|
944
873
|
var AudioComponent = ({ shape }) => {
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
onClick: () => setActive(!active)
|
|
964
|
-
}));
|
|
965
|
-
} finally {
|
|
966
|
-
_effect.f();
|
|
967
|
-
}
|
|
874
|
+
const { node } = useComputeNodeState(shape);
|
|
875
|
+
const [active, setActive] = useState4(false);
|
|
876
|
+
useEffect3(() => {
|
|
877
|
+
node.value = active;
|
|
878
|
+
}, [
|
|
879
|
+
active
|
|
880
|
+
]);
|
|
881
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
882
|
+
className: "flex w-full justify-center items-center"
|
|
883
|
+
}, /* @__PURE__ */ React6.createElement(Icon2, {
|
|
884
|
+
icon: active ? "ph--microphone--regular" : "ph--microphone-slash--regular",
|
|
885
|
+
classNames: [
|
|
886
|
+
"transition opacity-20 duration-1000",
|
|
887
|
+
active && "opacity-100 text-error-text"
|
|
888
|
+
],
|
|
889
|
+
size: 8,
|
|
890
|
+
onClick: () => setActive(!active)
|
|
891
|
+
}));
|
|
968
892
|
};
|
|
969
893
|
var audioShape = {
|
|
970
894
|
type: "audio",
|
|
@@ -981,7 +905,6 @@ var audioShape = {
|
|
|
981
905
|
};
|
|
982
906
|
|
|
983
907
|
// src/shapes/Beacon.tsx
|
|
984
|
-
import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
|
|
985
908
|
import * as Schema6 from "effect/Schema";
|
|
986
909
|
import React7 from "react";
|
|
987
910
|
import { DEFAULT_INPUT as DEFAULT_INPUT3, isTruthy } from "@dxos/conductor";
|
|
@@ -999,24 +922,19 @@ var createBeacon = (props) => createShape({
|
|
|
999
922
|
...props
|
|
1000
923
|
});
|
|
1001
924
|
var BeaconComponent = ({ shape }) => {
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
size: 8
|
|
1016
|
-
}));
|
|
1017
|
-
} finally {
|
|
1018
|
-
_effect.f();
|
|
1019
|
-
}
|
|
925
|
+
const { runtime } = useComputeNodeState(shape);
|
|
926
|
+
const input = runtime.inputs[DEFAULT_INPUT3];
|
|
927
|
+
const value = input?.type === "executed" ? input.value : false;
|
|
928
|
+
return /* @__PURE__ */ React7.createElement("div", {
|
|
929
|
+
className: "flex w-full justify-center items-center"
|
|
930
|
+
}, /* @__PURE__ */ React7.createElement(Icon3, {
|
|
931
|
+
icon: "ph--sun--regular",
|
|
932
|
+
classNames: [
|
|
933
|
+
"transition opacity-20 duration-1000",
|
|
934
|
+
isTruthy(value) && "opacity-100 text-yellow-500"
|
|
935
|
+
],
|
|
936
|
+
size: 8
|
|
937
|
+
}));
|
|
1020
938
|
};
|
|
1021
939
|
var beaconShape = {
|
|
1022
940
|
type: "beacon",
|
|
@@ -1084,7 +1002,7 @@ var createSymbol = (pathConstructor, inputs) => ({
|
|
|
1084
1002
|
});
|
|
1085
1003
|
return /* @__PURE__ */ React8.createElement("svg", {
|
|
1086
1004
|
viewBox: `0 0 ${width} ${height}`,
|
|
1087
|
-
className: "
|
|
1005
|
+
className: "h-full w-full"
|
|
1088
1006
|
}, getAnchorPoints({
|
|
1089
1007
|
x: 0,
|
|
1090
1008
|
y: centerY
|
|
@@ -1206,7 +1124,6 @@ var notShape = defineShape({
|
|
|
1206
1124
|
});
|
|
1207
1125
|
|
|
1208
1126
|
// src/shapes/Chat.tsx
|
|
1209
|
-
import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
|
|
1210
1127
|
import * as Schema8 from "effect/Schema";
|
|
1211
1128
|
import React9, { useRef as useRef2 } from "react";
|
|
1212
1129
|
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT3 } from "@dxos/conductor";
|
|
@@ -1216,28 +1133,23 @@ var ChatShape = Schema8.extend(ComputeShape, Schema8.Struct({
|
|
|
1216
1133
|
type: Schema8.Literal("chat")
|
|
1217
1134
|
}));
|
|
1218
1135
|
var TextInputComponent = ({ shape, title, ...props }) => {
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
const
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
...props
|
|
1237
|
-
}));
|
|
1238
|
-
} finally {
|
|
1239
|
-
_effect.f();
|
|
1240
|
-
}
|
|
1136
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1137
|
+
const inputRef = useRef2(null);
|
|
1138
|
+
const handleEnter = (text) => {
|
|
1139
|
+
const value = text.trim();
|
|
1140
|
+
if (value.length) {
|
|
1141
|
+
runtime.setOutput(DEFAULT_OUTPUT3, value);
|
|
1142
|
+
inputRef.current?.setText("");
|
|
1143
|
+
}
|
|
1144
|
+
};
|
|
1145
|
+
return /* @__PURE__ */ React9.createElement(Box, {
|
|
1146
|
+
shape,
|
|
1147
|
+
title
|
|
1148
|
+
}, /* @__PURE__ */ React9.createElement(TextBox, {
|
|
1149
|
+
ref: inputRef,
|
|
1150
|
+
onEnter: handleEnter,
|
|
1151
|
+
...props
|
|
1152
|
+
}));
|
|
1241
1153
|
};
|
|
1242
1154
|
var createChat = (props) => createShape({
|
|
1243
1155
|
type: "chat",
|
|
@@ -1267,7 +1179,6 @@ var chatShape = {
|
|
|
1267
1179
|
};
|
|
1268
1180
|
|
|
1269
1181
|
// src/shapes/Constant.tsx
|
|
1270
|
-
import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
|
|
1271
1182
|
import * as Schema9 from "effect/Schema";
|
|
1272
1183
|
import React10, { useCallback as useCallback2, useRef as useRef3, useState as useState5 } from "react";
|
|
1273
1184
|
import { ComputeValueType as ComputeValueType2 } from "@dxos/conductor";
|
|
@@ -1291,57 +1202,52 @@ var inferType = (value) => {
|
|
|
1291
1202
|
}
|
|
1292
1203
|
};
|
|
1293
1204
|
var ConstantComponent = ({ shape, title, chat, ...props }) => {
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
const
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
if (
|
|
1303
|
-
|
|
1304
|
-
if (!isNaN(floatValue)) {
|
|
1305
|
-
node.value = floatValue;
|
|
1306
|
-
}
|
|
1307
|
-
} else if (type === "object") {
|
|
1308
|
-
node.value = safeParseJson(value, {});
|
|
1309
|
-
} else {
|
|
1310
|
-
node.value = value;
|
|
1205
|
+
const { node } = useComputeNodeState(shape);
|
|
1206
|
+
const [type, setType] = useState5(inferType(node.value) ?? ComputeValueType2.literals[0]);
|
|
1207
|
+
const inputRef = useRef3(null);
|
|
1208
|
+
const handleEnter = useCallback2((text) => {
|
|
1209
|
+
const value = text.trim();
|
|
1210
|
+
if (value.length) {
|
|
1211
|
+
if (type === "number") {
|
|
1212
|
+
const floatValue = parseFloat(value);
|
|
1213
|
+
if (!isNaN(floatValue)) {
|
|
1214
|
+
node.value = floatValue;
|
|
1311
1215
|
}
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
type
|
|
1316
|
-
]);
|
|
1317
|
-
return /* @__PURE__ */ React10.createElement(Box, {
|
|
1318
|
-
shape,
|
|
1319
|
-
title,
|
|
1320
|
-
status: /* @__PURE__ */ React10.createElement(TypeSelect, {
|
|
1321
|
-
value: type,
|
|
1322
|
-
onValueChange: setType
|
|
1323
|
-
})
|
|
1324
|
-
}, (type === "string" || type === "number") && /* @__PURE__ */ React10.createElement(TextBox2, {
|
|
1325
|
-
...props,
|
|
1326
|
-
ref: inputRef,
|
|
1327
|
-
value: node.value,
|
|
1328
|
-
onEnter: handleEnter
|
|
1329
|
-
}), type === "object" && /* @__PURE__ */ React10.createElement(TextBox2, {
|
|
1330
|
-
...props,
|
|
1331
|
-
ref: inputRef,
|
|
1332
|
-
value: JSON.stringify(node.value, null, 2),
|
|
1333
|
-
language: "json"
|
|
1334
|
-
}), type === "boolean" && /* @__PURE__ */ React10.createElement("div", {
|
|
1335
|
-
className: "flex grow justify-center items-center"
|
|
1336
|
-
}, /* @__PURE__ */ React10.createElement(Input.Root, null, /* @__PURE__ */ React10.createElement(Input.Switch, {
|
|
1337
|
-
checked: node.value,
|
|
1338
|
-
onCheckedChange: (value) => {
|
|
1216
|
+
} else if (type === "object") {
|
|
1217
|
+
node.value = safeParseJson(value, {});
|
|
1218
|
+
} else {
|
|
1339
1219
|
node.value = value;
|
|
1340
1220
|
}
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1221
|
+
inputRef.current?.focus();
|
|
1222
|
+
}
|
|
1223
|
+
}, [
|
|
1224
|
+
type
|
|
1225
|
+
]);
|
|
1226
|
+
return /* @__PURE__ */ React10.createElement(Box, {
|
|
1227
|
+
shape,
|
|
1228
|
+
title,
|
|
1229
|
+
status: /* @__PURE__ */ React10.createElement(TypeSelect, {
|
|
1230
|
+
value: type,
|
|
1231
|
+
onValueChange: setType
|
|
1232
|
+
})
|
|
1233
|
+
}, (type === "string" || type === "number") && /* @__PURE__ */ React10.createElement(TextBox2, {
|
|
1234
|
+
...props,
|
|
1235
|
+
ref: inputRef,
|
|
1236
|
+
value: node.value,
|
|
1237
|
+
onEnter: handleEnter
|
|
1238
|
+
}), type === "object" && /* @__PURE__ */ React10.createElement(TextBox2, {
|
|
1239
|
+
...props,
|
|
1240
|
+
ref: inputRef,
|
|
1241
|
+
value: JSON.stringify(node.value, null, 2),
|
|
1242
|
+
language: "json"
|
|
1243
|
+
}), type === "boolean" && /* @__PURE__ */ React10.createElement("div", {
|
|
1244
|
+
className: "flex grow justify-center items-center"
|
|
1245
|
+
}, /* @__PURE__ */ React10.createElement(Input.Root, null, /* @__PURE__ */ React10.createElement(Input.Switch, {
|
|
1246
|
+
checked: node.value,
|
|
1247
|
+
onCheckedChange: (value) => {
|
|
1248
|
+
node.value = value;
|
|
1249
|
+
}
|
|
1250
|
+
}))));
|
|
1345
1251
|
};
|
|
1346
1252
|
var createConstant = (props) => createShape({
|
|
1347
1253
|
type: "constant",
|
|
@@ -1370,7 +1276,6 @@ var constantShape = {
|
|
|
1370
1276
|
};
|
|
1371
1277
|
|
|
1372
1278
|
// src/shapes/Database.tsx
|
|
1373
|
-
import { useSignals as _useSignals10 } from "@preact-signals/safe-react/tracking";
|
|
1374
1279
|
import * as Schema10 from "effect/Schema";
|
|
1375
1280
|
import React11 from "react";
|
|
1376
1281
|
import { createAnchorMap as createAnchorMap5 } from "@dxos/react-ui-canvas-editor";
|
|
@@ -1386,14 +1291,9 @@ var createDatabase = (props) => createShape({
|
|
|
1386
1291
|
...props
|
|
1387
1292
|
});
|
|
1388
1293
|
var DatabaseComponent = ({ shape }) => {
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
shape
|
|
1393
|
-
});
|
|
1394
|
-
} finally {
|
|
1395
|
-
_effect.f();
|
|
1396
|
-
}
|
|
1294
|
+
return /* @__PURE__ */ React11.createElement(Box, {
|
|
1295
|
+
shape
|
|
1296
|
+
});
|
|
1397
1297
|
};
|
|
1398
1298
|
var databaseShape = {
|
|
1399
1299
|
type: "database",
|
|
@@ -1409,18 +1309,84 @@ var databaseShape = {
|
|
|
1409
1309
|
})
|
|
1410
1310
|
};
|
|
1411
1311
|
|
|
1412
|
-
// src/shapes/
|
|
1413
|
-
import { useSignals as _useSignals11 } from "@preact-signals/safe-react/tracking";
|
|
1312
|
+
// src/shapes/Feed.tsx
|
|
1414
1313
|
import * as Schema11 from "effect/Schema";
|
|
1415
|
-
import React12, {
|
|
1314
|
+
import React12, { Fragment } from "react";
|
|
1315
|
+
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT4, QueueInput, QueueOutput } from "@dxos/conductor";
|
|
1316
|
+
import { ScrollArea } from "@dxos/react-ui";
|
|
1317
|
+
import { mx as mx2 } from "@dxos/ui-theme";
|
|
1318
|
+
var FeedShape = Schema11.extend(ComputeShape, Schema11.Struct({
|
|
1319
|
+
type: Schema11.Literal("queue")
|
|
1320
|
+
}));
|
|
1321
|
+
var createFeed = (props) => createShape({
|
|
1322
|
+
type: "queue",
|
|
1323
|
+
size: {
|
|
1324
|
+
width: 256,
|
|
1325
|
+
height: 512
|
|
1326
|
+
},
|
|
1327
|
+
...props
|
|
1328
|
+
});
|
|
1329
|
+
var FeedComponent = ({ shape }) => {
|
|
1330
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1331
|
+
const items = runtime.outputs[DEFAULT_OUTPUT4]?.type === "executed" ? runtime.outputs[DEFAULT_OUTPUT4].value : [];
|
|
1332
|
+
const handleAction = (action) => {
|
|
1333
|
+
if (action === "run") {
|
|
1334
|
+
runtime.evalNode();
|
|
1335
|
+
}
|
|
1336
|
+
};
|
|
1337
|
+
return /* @__PURE__ */ React12.createElement(Box, {
|
|
1338
|
+
shape,
|
|
1339
|
+
status: `${items.length} items`,
|
|
1340
|
+
onAction: handleAction
|
|
1341
|
+
}, /* @__PURE__ */ React12.createElement(ScrollArea.Root, {
|
|
1342
|
+
orientation: "vertical"
|
|
1343
|
+
}, /* @__PURE__ */ React12.createElement(ScrollArea.Viewport, {
|
|
1344
|
+
classNames: "divide-y divide-separator"
|
|
1345
|
+
}, [
|
|
1346
|
+
...items
|
|
1347
|
+
].map((item, i) => /* @__PURE__ */ React12.createElement(FeedItem, {
|
|
1348
|
+
key: i,
|
|
1349
|
+
classNames: "p-1 px-2",
|
|
1350
|
+
item
|
|
1351
|
+
})))));
|
|
1352
|
+
};
|
|
1353
|
+
var FeedItem = ({ classNames, item }) => {
|
|
1354
|
+
if (typeof item !== "object") {
|
|
1355
|
+
return /* @__PURE__ */ React12.createElement("div", {
|
|
1356
|
+
className: mx2(classNames, "whitespace-pre-wrap")
|
|
1357
|
+
}, item);
|
|
1358
|
+
}
|
|
1359
|
+
return /* @__PURE__ */ React12.createElement("div", {
|
|
1360
|
+
className: mx2("grid grid-cols-[80px_1fr]", classNames)
|
|
1361
|
+
}, Object.entries(item).map(([key, value]) => /* @__PURE__ */ React12.createElement(Fragment, {
|
|
1362
|
+
key
|
|
1363
|
+
}, /* @__PURE__ */ React12.createElement("div", {
|
|
1364
|
+
className: "p-1 text-xs text-subdued"
|
|
1365
|
+
}, key), /* @__PURE__ */ React12.createElement("div", null, typeof value === "string" ? value : JSON.stringify(value)))));
|
|
1366
|
+
};
|
|
1367
|
+
var feedShape = {
|
|
1368
|
+
type: "feed",
|
|
1369
|
+
name: "Feed",
|
|
1370
|
+
icon: "ph--queue--regular",
|
|
1371
|
+
component: FeedComponent,
|
|
1372
|
+
createShape: createFeed,
|
|
1373
|
+
getAnchors: (shape) => createFunctionAnchors(shape, QueueInput, QueueOutput),
|
|
1374
|
+
resizable: true
|
|
1375
|
+
};
|
|
1376
|
+
|
|
1377
|
+
// src/shapes/Function.tsx
|
|
1378
|
+
import * as Schema12 from "effect/Schema";
|
|
1379
|
+
import React13, { useCallback as useCallback3, useRef as useRef4 } from "react";
|
|
1380
|
+
import { Script } from "@dxos/compute";
|
|
1381
|
+
import { Operation } from "@dxos/compute";
|
|
1416
1382
|
import { AnyOutput, FunctionInput } from "@dxos/conductor";
|
|
1383
|
+
import { Filter } from "@dxos/echo";
|
|
1417
1384
|
import { Ref as Ref2, getSnapshot, isInstanceOf } from "@dxos/echo/internal";
|
|
1418
|
-
import {
|
|
1385
|
+
import { parseId } from "@dxos/keys";
|
|
1419
1386
|
import { useClient } from "@dxos/react-client";
|
|
1420
|
-
import { Filter, parseId } from "@dxos/react-client/echo";
|
|
1421
1387
|
import { TextBox as TextBox3 } from "@dxos/react-ui-canvas-editor";
|
|
1422
|
-
var FunctionShape =
|
|
1423
|
-
type:
|
|
1388
|
+
var FunctionShape = Schema12.extend(ComputeShape, Schema12.Struct({
|
|
1389
|
+
type: Schema12.Literal("function")
|
|
1424
1390
|
}));
|
|
1425
1391
|
var createFunction = (props) => createShape({
|
|
1426
1392
|
type: "function",
|
|
@@ -1431,59 +1397,54 @@ var createFunction = (props) => createShape({
|
|
|
1431
1397
|
...props
|
|
1432
1398
|
});
|
|
1433
1399
|
var TextInputComponent2 = ({ shape, title, ...props }) => {
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
const
|
|
1439
|
-
const
|
|
1440
|
-
|
|
1441
|
-
|
|
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
|
-
onEnter: handleEnter
|
|
1483
|
-
}));
|
|
1484
|
-
} finally {
|
|
1485
|
-
_effect.f();
|
|
1486
|
-
}
|
|
1400
|
+
const client = useClient();
|
|
1401
|
+
const { node, runtime } = useComputeNodeState(shape);
|
|
1402
|
+
const inputRef = useRef4(null);
|
|
1403
|
+
const handleEnter = useCallback3(async (text) => {
|
|
1404
|
+
const value = text.trim();
|
|
1405
|
+
const { spaceId, objectId } = parseId(value);
|
|
1406
|
+
if (!spaceId || !objectId) {
|
|
1407
|
+
return;
|
|
1408
|
+
}
|
|
1409
|
+
const space = client.spaces.get(spaceId);
|
|
1410
|
+
const object = space?.db.getObjectById(objectId);
|
|
1411
|
+
if (!space || !isInstanceOf(Script.Script, object)) {
|
|
1412
|
+
return;
|
|
1413
|
+
}
|
|
1414
|
+
const [fn] = await space.db.query(Filter.type(Operation.PersistentOperation, {
|
|
1415
|
+
source: Ref2.make(object)
|
|
1416
|
+
})).run();
|
|
1417
|
+
if (!fn) {
|
|
1418
|
+
return;
|
|
1419
|
+
}
|
|
1420
|
+
node.value = value;
|
|
1421
|
+
node.function = Ref2.make(fn);
|
|
1422
|
+
node.inputSchema = fn.inputSchema ? getSnapshot(fn.inputSchema) : void 0;
|
|
1423
|
+
node.outputSchema = fn.outputSchema ? getSnapshot(fn.outputSchema) : void 0;
|
|
1424
|
+
}, [
|
|
1425
|
+
client,
|
|
1426
|
+
node
|
|
1427
|
+
]);
|
|
1428
|
+
const handleAction = useCallback3((action) => {
|
|
1429
|
+
if (action !== "run") {
|
|
1430
|
+
return;
|
|
1431
|
+
}
|
|
1432
|
+
runtime.evalNode();
|
|
1433
|
+
}, [
|
|
1434
|
+
runtime
|
|
1435
|
+
]);
|
|
1436
|
+
return /* @__PURE__ */ React13.createElement(Box, {
|
|
1437
|
+
shape,
|
|
1438
|
+
title: "Function",
|
|
1439
|
+
onAction: handleAction
|
|
1440
|
+
}, /* @__PURE__ */ React13.createElement(TextBox3, {
|
|
1441
|
+
...props,
|
|
1442
|
+
ref: inputRef,
|
|
1443
|
+
value: node.value,
|
|
1444
|
+
language: node.valueType === "object" ? "json" : void 0,
|
|
1445
|
+
onBlur: handleEnter,
|
|
1446
|
+
onEnter: handleEnter
|
|
1447
|
+
}));
|
|
1487
1448
|
};
|
|
1488
1449
|
var functionShape = {
|
|
1489
1450
|
type: "function",
|
|
@@ -1495,12 +1456,12 @@ var functionShape = {
|
|
|
1495
1456
|
};
|
|
1496
1457
|
|
|
1497
1458
|
// src/shapes/Gpt.tsx
|
|
1498
|
-
import
|
|
1499
|
-
import
|
|
1500
|
-
import React13, { useEffect as useEffect4, useState as useState6 } from "react";
|
|
1459
|
+
import * as Schema13 from "effect/Schema";
|
|
1460
|
+
import React14, { useEffect as useEffect4, useState as useState6 } from "react";
|
|
1501
1461
|
import { GptInput, GptOutput } from "@dxos/conductor";
|
|
1502
|
-
|
|
1503
|
-
|
|
1462
|
+
import { ScrollArea as ScrollArea2 } from "@dxos/react-ui";
|
|
1463
|
+
var GptShape = Schema13.extend(ComputeShape, Schema13.Struct({
|
|
1464
|
+
type: Schema13.Literal("gpt")
|
|
1504
1465
|
}));
|
|
1505
1466
|
var createGpt = (props) => createShape({
|
|
1506
1467
|
type: "gpt",
|
|
@@ -1511,54 +1472,50 @@ var createGpt = (props) => createShape({
|
|
|
1511
1472
|
...props
|
|
1512
1473
|
});
|
|
1513
1474
|
var GptComponent = ({ shape }) => {
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
const
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
});
|
|
1538
|
-
break;
|
|
1539
|
-
}
|
|
1475
|
+
const { meta, runtime } = useComputeNodeState(shape);
|
|
1476
|
+
const [text, setText] = useState6("");
|
|
1477
|
+
const [tokens, setTokens] = useState6(0);
|
|
1478
|
+
useEffect4(() => {
|
|
1479
|
+
return runtime.subscribeToEventLog((ev) => {
|
|
1480
|
+
switch (ev.type) {
|
|
1481
|
+
case "begin-compute": {
|
|
1482
|
+
setText("");
|
|
1483
|
+
break;
|
|
1484
|
+
}
|
|
1485
|
+
case "custom": {
|
|
1486
|
+
const token = ev.event;
|
|
1487
|
+
switch (token.type) {
|
|
1488
|
+
case "content_block_delta":
|
|
1489
|
+
switch (token.delta.type) {
|
|
1490
|
+
case "text_delta": {
|
|
1491
|
+
const delta = token.delta.text;
|
|
1492
|
+
setText((prev) => {
|
|
1493
|
+
const text2 = prev + delta;
|
|
1494
|
+
setTokens(text2.split(" ").length);
|
|
1495
|
+
return text2;
|
|
1496
|
+
});
|
|
1497
|
+
break;
|
|
1540
1498
|
}
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
break;
|
|
1499
|
+
}
|
|
1500
|
+
break;
|
|
1544
1501
|
}
|
|
1502
|
+
break;
|
|
1545
1503
|
}
|
|
1546
|
-
}
|
|
1547
|
-
}, [
|
|
1548
|
-
runtime?.subscribeToEventLog
|
|
1549
|
-
]);
|
|
1550
|
-
return /* @__PURE__ */ React13.createElement(FunctionBody, {
|
|
1551
|
-
shape,
|
|
1552
|
-
content: /* @__PURE__ */ React13.createElement("div", {
|
|
1553
|
-
className: "px-2 py-1 overflow-y-scroll"
|
|
1554
|
-
}, text),
|
|
1555
|
-
status: `${tokens} tokens`,
|
|
1556
|
-
inputSchema: meta.input,
|
|
1557
|
-
outputSchema: meta.output
|
|
1504
|
+
}
|
|
1558
1505
|
});
|
|
1559
|
-
}
|
|
1560
|
-
|
|
1561
|
-
|
|
1506
|
+
}, [
|
|
1507
|
+
runtime?.subscribeToEventLog
|
|
1508
|
+
]);
|
|
1509
|
+
return /* @__PURE__ */ React14.createElement(FunctionBody, {
|
|
1510
|
+
shape,
|
|
1511
|
+
content: /* @__PURE__ */ React14.createElement(ScrollArea2.Root, {
|
|
1512
|
+
orientation: "vertical",
|
|
1513
|
+
thin: true
|
|
1514
|
+
}, /* @__PURE__ */ React14.createElement(ScrollArea2.Viewport, null, text)),
|
|
1515
|
+
status: `${tokens} tokens`,
|
|
1516
|
+
inputSchema: meta.input,
|
|
1517
|
+
outputSchema: meta.output
|
|
1518
|
+
});
|
|
1562
1519
|
};
|
|
1563
1520
|
var gptShape = {
|
|
1564
1521
|
type: "gpt",
|
|
@@ -1570,44 +1527,147 @@ var gptShape = {
|
|
|
1570
1527
|
openable: true
|
|
1571
1528
|
};
|
|
1572
1529
|
|
|
1530
|
+
// src/shapes/GptRealtime.tsx
|
|
1531
|
+
import * as Schema14 from "effect/Schema";
|
|
1532
|
+
import React15, { useState as useState7 } from "react";
|
|
1533
|
+
import { log as log2 } from "@dxos/log";
|
|
1534
|
+
import { useConfig } from "@dxos/react-client";
|
|
1535
|
+
import { Icon as Icon4 } from "@dxos/react-ui";
|
|
1536
|
+
var __dxlog_file6 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/GptRealtime.tsx";
|
|
1537
|
+
var GptRealtimeShape = Schema14.extend(ComputeShape, Schema14.Struct({
|
|
1538
|
+
type: Schema14.Literal("gpt-realtime")
|
|
1539
|
+
}));
|
|
1540
|
+
var createGptRealtime = (props) => createShape({
|
|
1541
|
+
type: "gpt-realtime",
|
|
1542
|
+
size: {
|
|
1543
|
+
width: 256,
|
|
1544
|
+
height: 256
|
|
1545
|
+
},
|
|
1546
|
+
...props
|
|
1547
|
+
});
|
|
1548
|
+
var GptRealtimeComponent = ({ shape }) => {
|
|
1549
|
+
const [isLive, setIsLive] = useState7(false);
|
|
1550
|
+
const [isReady, setIsReady] = useState7(false);
|
|
1551
|
+
const config = useConfig();
|
|
1552
|
+
const start = async () => {
|
|
1553
|
+
setIsLive(true);
|
|
1554
|
+
try {
|
|
1555
|
+
const peerConnection = new RTCPeerConnection();
|
|
1556
|
+
peerConnection.ontrack = (event) => {
|
|
1557
|
+
const audioElement = document.createElement("audio");
|
|
1558
|
+
audioElement.srcObject = event.streams[0];
|
|
1559
|
+
audioElement.autoplay = true;
|
|
1560
|
+
audioElement.controls = false;
|
|
1561
|
+
audioElement.style.display = "none";
|
|
1562
|
+
document.body.appendChild(audioElement);
|
|
1563
|
+
setIsReady(true);
|
|
1564
|
+
};
|
|
1565
|
+
const stream = await navigator.mediaDevices.getUserMedia({
|
|
1566
|
+
audio: true
|
|
1567
|
+
});
|
|
1568
|
+
stream.getTracks().forEach((track) => peerConnection.addTransceiver(track, {
|
|
1569
|
+
direction: "sendrecv"
|
|
1570
|
+
}));
|
|
1571
|
+
const offer = await peerConnection.createOffer();
|
|
1572
|
+
await peerConnection.setLocalDescription(offer);
|
|
1573
|
+
const AiServiceUrl = new URL("/rtc-connect", config.values.runtime?.services?.ai?.server ?? DEFAULT_AI_SERVICE_URL);
|
|
1574
|
+
const response = await fetch(AiServiceUrl, {
|
|
1575
|
+
method: "POST",
|
|
1576
|
+
body: offer.sdp,
|
|
1577
|
+
headers: {
|
|
1578
|
+
"Content-Type": "application/sdp"
|
|
1579
|
+
}
|
|
1580
|
+
});
|
|
1581
|
+
const answer = await response.text();
|
|
1582
|
+
await peerConnection.setRemoteDescription({
|
|
1583
|
+
sdp: answer,
|
|
1584
|
+
type: "answer"
|
|
1585
|
+
});
|
|
1586
|
+
const dataChannel = peerConnection.createDataChannel("response");
|
|
1587
|
+
const configureData = () => {
|
|
1588
|
+
log2.info("Configuring data channel", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 69, S: void 0 });
|
|
1589
|
+
const event = {
|
|
1590
|
+
type: "session.update",
|
|
1591
|
+
session: {
|
|
1592
|
+
modalities: [
|
|
1593
|
+
"text",
|
|
1594
|
+
"audio"
|
|
1595
|
+
],
|
|
1596
|
+
// Provide the tools. Note they match the keys in the `fns` object above
|
|
1597
|
+
tools: []
|
|
1598
|
+
}
|
|
1599
|
+
};
|
|
1600
|
+
dataChannel.send(JSON.stringify(event));
|
|
1601
|
+
};
|
|
1602
|
+
dataChannel.addEventListener("open", (ev) => {
|
|
1603
|
+
log2.info("Opening data channel", {
|
|
1604
|
+
ev
|
|
1605
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 84, S: void 0 });
|
|
1606
|
+
configureData();
|
|
1607
|
+
});
|
|
1608
|
+
dataChannel.addEventListener("message", async (ev) => {
|
|
1609
|
+
const msg = JSON.parse(ev.data);
|
|
1610
|
+
if (msg.type === "response.function_call_arguments.done") {
|
|
1611
|
+
}
|
|
1612
|
+
});
|
|
1613
|
+
} catch (error) {
|
|
1614
|
+
log2.error("Error in realtime session:", {
|
|
1615
|
+
error
|
|
1616
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 124, S: void 0 });
|
|
1617
|
+
throw error;
|
|
1618
|
+
}
|
|
1619
|
+
};
|
|
1620
|
+
return /* @__PURE__ */ React15.createElement("div", {
|
|
1621
|
+
className: "flex w-full justify-center items-center"
|
|
1622
|
+
}, /* @__PURE__ */ React15.createElement(Icon4, {
|
|
1623
|
+
icon: isReady ? "ph--waveform--regular" : isLive ? "ph--pulse--regular" : "ph--play--regular",
|
|
1624
|
+
size: 16,
|
|
1625
|
+
classNames: !isLive && "cursor-pointer",
|
|
1626
|
+
onClick: start
|
|
1627
|
+
}));
|
|
1628
|
+
};
|
|
1629
|
+
var gptRealtimeShape = {
|
|
1630
|
+
type: "gpt-realtime",
|
|
1631
|
+
name: "GPT Realtime",
|
|
1632
|
+
icon: "ph--pulse--regular",
|
|
1633
|
+
component: GptRealtimeComponent,
|
|
1634
|
+
createShape: createGptRealtime,
|
|
1635
|
+
// TODO(dmaretskyi): Can we fetch the schema dynamically?
|
|
1636
|
+
getAnchors: (shape) => createFunctionAnchors(shape, Schema14.Struct({
|
|
1637
|
+
audio: Schema14.Any
|
|
1638
|
+
}), Schema14.Struct({})),
|
|
1639
|
+
resizable: true
|
|
1640
|
+
};
|
|
1641
|
+
var DEFAULT_AI_SERVICE_URL = "http://localhost:8788";
|
|
1642
|
+
|
|
1573
1643
|
// src/shapes/Json.tsx
|
|
1574
|
-
import
|
|
1575
|
-
import
|
|
1576
|
-
import React14 from "react";
|
|
1644
|
+
import * as Schema15 from "effect/Schema";
|
|
1645
|
+
import React16 from "react";
|
|
1577
1646
|
import { DEFAULT_INPUT as DEFAULT_INPUT4, DefaultOutput, JsonTransformInput } from "@dxos/conductor";
|
|
1578
1647
|
import { createAnchorMap as createAnchorMap6 } from "@dxos/react-ui-canvas-editor";
|
|
1579
|
-
import {
|
|
1580
|
-
var JsonShape =
|
|
1581
|
-
type:
|
|
1648
|
+
import { Syntax } from "@dxos/react-ui-syntax-highlighter";
|
|
1649
|
+
var JsonShape = Schema15.extend(ComputeShape, Schema15.Struct({
|
|
1650
|
+
type: Schema15.Literal("json")
|
|
1582
1651
|
}));
|
|
1583
|
-
var JsonTransformShape =
|
|
1584
|
-
type:
|
|
1652
|
+
var JsonTransformShape = Schema15.extend(ComputeShape, Schema15.Struct({
|
|
1653
|
+
type: Schema15.Literal("json-transform")
|
|
1585
1654
|
}));
|
|
1586
1655
|
var JsonComponent = ({ shape, ...props }) => {
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
}));
|
|
1598
|
-
} finally {
|
|
1599
|
-
_effect.f();
|
|
1600
|
-
}
|
|
1656
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1657
|
+
const input = runtime.inputs[DEFAULT_INPUT4];
|
|
1658
|
+
const value = input?.type === "executed" ? input.value : void 0;
|
|
1659
|
+
return /* @__PURE__ */ React16.createElement(Box, {
|
|
1660
|
+
shape
|
|
1661
|
+
}, /* @__PURE__ */ React16.createElement(Syntax.Root, {
|
|
1662
|
+
data: value
|
|
1663
|
+
}, /* @__PURE__ */ React16.createElement(Syntax.Content, null, /* @__PURE__ */ React16.createElement(Syntax.Filter, null), /* @__PURE__ */ React16.createElement(Syntax.Viewport, null, /* @__PURE__ */ React16.createElement(Syntax.Code, {
|
|
1664
|
+
classNames: "text-xs"
|
|
1665
|
+
})))));
|
|
1601
1666
|
};
|
|
1602
1667
|
var JsonTransformComponent = ({ shape, ...props }) => {
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
shape
|
|
1607
|
-
});
|
|
1608
|
-
} finally {
|
|
1609
|
-
_effect.f();
|
|
1610
|
-
}
|
|
1668
|
+
return /* @__PURE__ */ React16.createElement(Box, {
|
|
1669
|
+
shape
|
|
1670
|
+
});
|
|
1611
1671
|
};
|
|
1612
1672
|
var createJson = (props) => createShape({
|
|
1613
1673
|
type: "json",
|
|
@@ -1621,7 +1681,7 @@ var jsonShape = {
|
|
|
1621
1681
|
type: "json",
|
|
1622
1682
|
name: "JSON",
|
|
1623
1683
|
icon: "ph--code--regular",
|
|
1624
|
-
component: (props) => /* @__PURE__ */
|
|
1684
|
+
component: (props) => /* @__PURE__ */ React16.createElement(JsonComponent, props),
|
|
1625
1685
|
createShape: createJson,
|
|
1626
1686
|
getAnchors: (shape) => createAnchorMap6(shape, {
|
|
1627
1687
|
[createAnchorId("input")]: {
|
|
@@ -1647,46 +1707,35 @@ var jsonTransformShape = {
|
|
|
1647
1707
|
type: "json-transform",
|
|
1648
1708
|
name: "Transform",
|
|
1649
1709
|
icon: "ph--shuffle-simple--regular",
|
|
1650
|
-
component: (props) => /* @__PURE__ */
|
|
1710
|
+
component: (props) => /* @__PURE__ */ React16.createElement(JsonTransformComponent, props),
|
|
1651
1711
|
createShape: createJsonTransform,
|
|
1652
1712
|
getAnchors: (shape) => createFunctionAnchors(shape, JsonTransformInput, DefaultOutput),
|
|
1653
1713
|
resizable: true
|
|
1654
1714
|
};
|
|
1655
1715
|
|
|
1656
1716
|
// src/shapes/Logic.tsx
|
|
1657
|
-
import
|
|
1658
|
-
import
|
|
1659
|
-
import React15 from "react";
|
|
1717
|
+
import * as Schema16 from "effect/Schema";
|
|
1718
|
+
import React17 from "react";
|
|
1660
1719
|
import { IfElseInput, IfElseOutput, IfInput, IfOutput } from "@dxos/conductor";
|
|
1661
|
-
var IfShape =
|
|
1662
|
-
type:
|
|
1720
|
+
var IfShape = Schema16.extend(ComputeShape, Schema16.Struct({
|
|
1721
|
+
type: Schema16.Literal("if")
|
|
1663
1722
|
}));
|
|
1664
|
-
var IfElseShape =
|
|
1665
|
-
type:
|
|
1723
|
+
var IfElseShape = Schema16.extend(ComputeShape, Schema16.Struct({
|
|
1724
|
+
type: Schema16.Literal("if-else")
|
|
1666
1725
|
}));
|
|
1667
1726
|
var IfComponent = ({ shape, ...props }) => {
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
outputSchema: IfOutput
|
|
1674
|
-
});
|
|
1675
|
-
} finally {
|
|
1676
|
-
_effect.f();
|
|
1677
|
-
}
|
|
1727
|
+
return /* @__PURE__ */ React17.createElement(FunctionBody, {
|
|
1728
|
+
shape,
|
|
1729
|
+
inputSchema: IfInput,
|
|
1730
|
+
outputSchema: IfOutput
|
|
1731
|
+
});
|
|
1678
1732
|
};
|
|
1679
1733
|
var IfElseComponent = ({ shape, ...props }) => {
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
outputSchema: IfElseOutput
|
|
1686
|
-
});
|
|
1687
|
-
} finally {
|
|
1688
|
-
_effect.f();
|
|
1689
|
-
}
|
|
1734
|
+
return /* @__PURE__ */ React17.createElement(FunctionBody, {
|
|
1735
|
+
shape,
|
|
1736
|
+
inputSchema: IfElseInput,
|
|
1737
|
+
outputSchema: IfElseOutput
|
|
1738
|
+
});
|
|
1690
1739
|
};
|
|
1691
1740
|
var createIf = (props) => createShape({
|
|
1692
1741
|
type: "if",
|
|
@@ -1700,7 +1749,7 @@ var ifShape = {
|
|
|
1700
1749
|
type: "if",
|
|
1701
1750
|
name: "IF",
|
|
1702
1751
|
icon: "ph--arrows-split--regular",
|
|
1703
|
-
component: (props) => /* @__PURE__ */
|
|
1752
|
+
component: (props) => /* @__PURE__ */ React17.createElement(IfComponent, props),
|
|
1704
1753
|
createShape: createIf,
|
|
1705
1754
|
getAnchors: (shape) => createFunctionAnchors(shape, IfInput, IfOutput)
|
|
1706
1755
|
};
|
|
@@ -1716,95 +1765,21 @@ var ifElseShape = {
|
|
|
1716
1765
|
type: "if-else",
|
|
1717
1766
|
name: "IF/ELSE",
|
|
1718
1767
|
icon: "ph--arrows-merge--regular",
|
|
1719
|
-
component: (props) => /* @__PURE__ */
|
|
1768
|
+
component: (props) => /* @__PURE__ */ React17.createElement(IfElseComponent, props),
|
|
1720
1769
|
createShape: createIfElse,
|
|
1721
1770
|
getAnchors: (shape) => createFunctionAnchors(shape, IfElseInput, IfElseOutput)
|
|
1722
1771
|
};
|
|
1723
1772
|
|
|
1724
|
-
// src/shapes/Queue.tsx
|
|
1725
|
-
import { useSignals as _useSignals15 } from "@preact-signals/safe-react/tracking";
|
|
1726
|
-
import * as Schema15 from "effect/Schema";
|
|
1727
|
-
import React16, { Fragment } from "react";
|
|
1728
|
-
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT4, QueueInput, QueueOutput } from "@dxos/conductor";
|
|
1729
|
-
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
1730
|
-
var QueueShape = Schema15.extend(ComputeShape, Schema15.Struct({
|
|
1731
|
-
type: Schema15.Literal("queue")
|
|
1732
|
-
}));
|
|
1733
|
-
var createQueue = (props) => createShape({
|
|
1734
|
-
type: "queue",
|
|
1735
|
-
size: {
|
|
1736
|
-
width: 256,
|
|
1737
|
-
height: 512
|
|
1738
|
-
},
|
|
1739
|
-
...props
|
|
1740
|
-
});
|
|
1741
|
-
var QueueComponent = ({ shape }) => {
|
|
1742
|
-
var _effect = _useSignals15();
|
|
1743
|
-
try {
|
|
1744
|
-
const { runtime } = useComputeNodeState(shape);
|
|
1745
|
-
const items = runtime.outputs[DEFAULT_OUTPUT4]?.type === "executed" ? runtime.outputs[DEFAULT_OUTPUT4].value : [];
|
|
1746
|
-
const handleAction = (action) => {
|
|
1747
|
-
if (action === "run") {
|
|
1748
|
-
runtime.evalNode();
|
|
1749
|
-
}
|
|
1750
|
-
};
|
|
1751
|
-
return /* @__PURE__ */ React16.createElement(Box, {
|
|
1752
|
-
shape,
|
|
1753
|
-
status: `${items.length} items`,
|
|
1754
|
-
onAction: handleAction
|
|
1755
|
-
}, /* @__PURE__ */ React16.createElement("div", {
|
|
1756
|
-
className: "flex flex-col w-full overflow-y-scroll divide-y divide-separator"
|
|
1757
|
-
}, [
|
|
1758
|
-
...items
|
|
1759
|
-
].map((item, i) => /* @__PURE__ */ React16.createElement(QueueItem, {
|
|
1760
|
-
key: i,
|
|
1761
|
-
classNames: "p-1 px-2",
|
|
1762
|
-
item
|
|
1763
|
-
}))));
|
|
1764
|
-
} finally {
|
|
1765
|
-
_effect.f();
|
|
1766
|
-
}
|
|
1767
|
-
};
|
|
1768
|
-
var QueueItem = ({ classNames, item }) => {
|
|
1769
|
-
var _effect = _useSignals15();
|
|
1770
|
-
try {
|
|
1771
|
-
if (typeof item !== "object") {
|
|
1772
|
-
return /* @__PURE__ */ React16.createElement("div", {
|
|
1773
|
-
className: mx2(classNames, "whitespace-pre-wrap")
|
|
1774
|
-
}, item);
|
|
1775
|
-
}
|
|
1776
|
-
return /* @__PURE__ */ React16.createElement("div", {
|
|
1777
|
-
className: mx2("grid grid-cols-[80px,1fr]", classNames)
|
|
1778
|
-
}, Object.entries(item).map(([key, value]) => /* @__PURE__ */ React16.createElement(Fragment, {
|
|
1779
|
-
key
|
|
1780
|
-
}, /* @__PURE__ */ React16.createElement("div", {
|
|
1781
|
-
className: "p-1 text-xs text-subdued"
|
|
1782
|
-
}, key), /* @__PURE__ */ React16.createElement("div", null, typeof value === "string" ? value : JSON.stringify(value)))));
|
|
1783
|
-
} finally {
|
|
1784
|
-
_effect.f();
|
|
1785
|
-
}
|
|
1786
|
-
};
|
|
1787
|
-
var queueShape = {
|
|
1788
|
-
type: "queue",
|
|
1789
|
-
name: "Queue",
|
|
1790
|
-
icon: "ph--queue--regular",
|
|
1791
|
-
component: QueueComponent,
|
|
1792
|
-
createShape: createQueue,
|
|
1793
|
-
getAnchors: (shape) => createFunctionAnchors(shape, QueueInput, QueueOutput),
|
|
1794
|
-
resizable: true
|
|
1795
|
-
};
|
|
1796
|
-
|
|
1797
1773
|
// src/shapes/RNG.tsx
|
|
1798
|
-
import
|
|
1799
|
-
import
|
|
1800
|
-
import React17, { useEffect as useEffect5, useState as useState7 } from "react";
|
|
1774
|
+
import * as Schema17 from "effect/Schema";
|
|
1775
|
+
import React18, { useEffect as useEffect5, useState as useState8 } from "react";
|
|
1801
1776
|
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT5 } from "@dxos/conductor";
|
|
1802
|
-
import { Icon as
|
|
1777
|
+
import { Icon as Icon5 } from "@dxos/react-ui";
|
|
1803
1778
|
import { createAnchorMap as createAnchorMap7 } from "@dxos/react-ui-canvas-editor";
|
|
1804
|
-
var RandomShape =
|
|
1805
|
-
type:
|
|
1806
|
-
min:
|
|
1807
|
-
max:
|
|
1779
|
+
var RandomShape = Schema17.extend(ComputeShape, Schema17.Struct({
|
|
1780
|
+
type: Schema17.Literal("rng"),
|
|
1781
|
+
min: Schema17.optional(Schema17.Number),
|
|
1782
|
+
max: Schema17.optional(Schema17.Number)
|
|
1808
1783
|
}));
|
|
1809
1784
|
var createRandom = (props) => createShape({
|
|
1810
1785
|
type: "rng",
|
|
@@ -1824,42 +1799,37 @@ var icons = [
|
|
|
1824
1799
|
];
|
|
1825
1800
|
var pickIcon = () => icons[Math.floor(Math.random() * icons.length)];
|
|
1826
1801
|
var RandomComponent = ({ shape }) => {
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
clearTimeout(t1);
|
|
1842
|
-
clearTimeout(t2);
|
|
1843
|
-
};
|
|
1844
|
-
}, [
|
|
1845
|
-
spin
|
|
1846
|
-
]);
|
|
1847
|
-
const handleClick = (ev) => {
|
|
1848
|
-
ev.stopPropagation();
|
|
1849
|
-
runtime.setOutput(DEFAULT_OUTPUT5, Math.random());
|
|
1850
|
-
setSpin(true);
|
|
1802
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1803
|
+
const [spin, setSpin] = useState8(false);
|
|
1804
|
+
const [icon, setIcon] = useState8(pickIcon());
|
|
1805
|
+
useEffect5(() => {
|
|
1806
|
+
if (!spin) {
|
|
1807
|
+
return;
|
|
1808
|
+
}
|
|
1809
|
+
const i = setInterval(() => setIcon(pickIcon()), 250);
|
|
1810
|
+
const t1 = setTimeout(() => clearInterval(i), 900);
|
|
1811
|
+
const t2 = setTimeout(() => setSpin(false), 1100);
|
|
1812
|
+
return () => {
|
|
1813
|
+
clearInterval(i);
|
|
1814
|
+
clearTimeout(t1);
|
|
1815
|
+
clearTimeout(t2);
|
|
1851
1816
|
};
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
}
|
|
1817
|
+
}, [
|
|
1818
|
+
spin
|
|
1819
|
+
]);
|
|
1820
|
+
const handleClick = (ev) => {
|
|
1821
|
+
ev.stopPropagation();
|
|
1822
|
+
runtime.setOutput(DEFAULT_OUTPUT5, Math.random());
|
|
1823
|
+
setSpin(true);
|
|
1824
|
+
};
|
|
1825
|
+
return /* @__PURE__ */ React18.createElement("div", {
|
|
1826
|
+
className: "flex grow items-center justify-center"
|
|
1827
|
+
}, /* @__PURE__ */ React18.createElement(Icon5, {
|
|
1828
|
+
icon,
|
|
1829
|
+
classNames: spin && "animate-[spin_1s]",
|
|
1830
|
+
size: 10,
|
|
1831
|
+
onClick: handleClick
|
|
1832
|
+
}));
|
|
1863
1833
|
};
|
|
1864
1834
|
var randomShape = {
|
|
1865
1835
|
type: "rng",
|
|
@@ -1876,14 +1846,13 @@ var randomShape = {
|
|
|
1876
1846
|
};
|
|
1877
1847
|
|
|
1878
1848
|
// src/shapes/Scope.tsx
|
|
1879
|
-
import
|
|
1880
|
-
import
|
|
1881
|
-
import React18 from "react";
|
|
1849
|
+
import * as Schema18 from "effect/Schema";
|
|
1850
|
+
import React19 from "react";
|
|
1882
1851
|
import { DEFAULT_INPUT as DEFAULT_INPUT5 } from "@dxos/conductor";
|
|
1883
1852
|
import { createAnchorMap as createAnchorMap8 } from "@dxos/react-ui-canvas-editor";
|
|
1884
1853
|
import { Chaos, shaderPresets, useAudioStream } from "@dxos/react-ui-sfx";
|
|
1885
|
-
var ScopeShape =
|
|
1886
|
-
type:
|
|
1854
|
+
var ScopeShape = Schema18.extend(ComputeShape, Schema18.Struct({
|
|
1855
|
+
type: Schema18.Literal("scope")
|
|
1887
1856
|
}));
|
|
1888
1857
|
var createScope = (props) => createShape({
|
|
1889
1858
|
type: "scope",
|
|
@@ -1895,25 +1864,20 @@ var createScope = (props) => createShape({
|
|
|
1895
1864
|
...props
|
|
1896
1865
|
});
|
|
1897
1866
|
var ScopeComponent = ({ shape }) => {
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
}
|
|
1913
|
-
}));
|
|
1914
|
-
} finally {
|
|
1915
|
-
_effect.f();
|
|
1916
|
-
}
|
|
1867
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1868
|
+
const input = runtime.inputs[DEFAULT_INPUT5];
|
|
1869
|
+
const active = input?.type === "executed" ? input.value : false;
|
|
1870
|
+
const { getAverage } = useAudioStream(active);
|
|
1871
|
+
return /* @__PURE__ */ React19.createElement("div", {
|
|
1872
|
+
className: "flex w-full justify-center items-center bg-black"
|
|
1873
|
+
}, /* @__PURE__ */ React19.createElement(Chaos, {
|
|
1874
|
+
active,
|
|
1875
|
+
getValue: getAverage,
|
|
1876
|
+
options: {
|
|
1877
|
+
...shaderPresets.heptapod,
|
|
1878
|
+
zoom: 1.2
|
|
1879
|
+
}
|
|
1880
|
+
}));
|
|
1917
1881
|
};
|
|
1918
1882
|
var scopeShape = {
|
|
1919
1883
|
type: "scope",
|
|
@@ -1930,14 +1894,15 @@ var scopeShape = {
|
|
|
1930
1894
|
};
|
|
1931
1895
|
|
|
1932
1896
|
// src/shapes/Surface.tsx
|
|
1933
|
-
import
|
|
1934
|
-
import
|
|
1935
|
-
import
|
|
1936
|
-
import {
|
|
1897
|
+
import * as Schema19 from "effect/Schema";
|
|
1898
|
+
import React20 from "react";
|
|
1899
|
+
import { Surface } from "@dxos/app-framework/ui";
|
|
1900
|
+
import { AppSurface } from "@dxos/app-toolkit/ui";
|
|
1937
1901
|
import { DEFAULT_INPUT as DEFAULT_INPUT6 } from "@dxos/conductor";
|
|
1902
|
+
import { Card } from "@dxos/react-ui";
|
|
1938
1903
|
import { createAnchorMap as createAnchorMap9 } from "@dxos/react-ui-canvas-editor";
|
|
1939
|
-
var SurfaceShape =
|
|
1940
|
-
type:
|
|
1904
|
+
var SurfaceShape = Schema19.extend(ComputeShape, Schema19.Struct({
|
|
1905
|
+
type: Schema19.Literal("surface")
|
|
1941
1906
|
}));
|
|
1942
1907
|
var createSurface = (props) => createShape({
|
|
1943
1908
|
type: "surface",
|
|
@@ -1948,29 +1913,24 @@ var createSurface = (props) => createShape({
|
|
|
1948
1913
|
...props
|
|
1949
1914
|
});
|
|
1950
1915
|
var SurfaceComponent = ({ shape }) => {
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
limit: 1
|
|
1970
|
-
}));
|
|
1971
|
-
} finally {
|
|
1972
|
-
_effect.f();
|
|
1973
|
-
}
|
|
1916
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1917
|
+
const input = runtime.inputs[DEFAULT_INPUT6];
|
|
1918
|
+
const value = input?.type === "executed" ? input.value : null;
|
|
1919
|
+
const handleAction = (action) => {
|
|
1920
|
+
if (action === "run") {
|
|
1921
|
+
runtime.evalNode();
|
|
1922
|
+
}
|
|
1923
|
+
};
|
|
1924
|
+
return /* @__PURE__ */ React20.createElement(Box, {
|
|
1925
|
+
shape,
|
|
1926
|
+
onAction: handleAction
|
|
1927
|
+
}, /* @__PURE__ */ React20.createElement(Card.Root, null, value !== null && /* @__PURE__ */ React20.createElement(Surface.Surface, {
|
|
1928
|
+
type: AppSurface.Card,
|
|
1929
|
+
data: {
|
|
1930
|
+
subject: value
|
|
1931
|
+
},
|
|
1932
|
+
limit: 1
|
|
1933
|
+
})));
|
|
1974
1934
|
};
|
|
1975
1935
|
var surfaceShape = {
|
|
1976
1936
|
type: "surface",
|
|
@@ -1988,14 +1948,13 @@ var surfaceShape = {
|
|
|
1988
1948
|
};
|
|
1989
1949
|
|
|
1990
1950
|
// src/shapes/Switch.tsx
|
|
1991
|
-
import
|
|
1992
|
-
import
|
|
1993
|
-
import React20, { useEffect as useEffect6, useState as useState8 } from "react";
|
|
1951
|
+
import * as Schema20 from "effect/Schema";
|
|
1952
|
+
import React21, { useEffect as useEffect6, useState as useState9 } from "react";
|
|
1994
1953
|
import { DEFAULT_OUTPUT as DEFAULT_OUTPUT6 } from "@dxos/conductor";
|
|
1995
1954
|
import { Input as Input2 } from "@dxos/react-ui";
|
|
1996
1955
|
import { createAnchorMap as createAnchorMap10 } from "@dxos/react-ui-canvas-editor";
|
|
1997
|
-
var SwitchShape =
|
|
1998
|
-
type:
|
|
1956
|
+
var SwitchShape = Schema20.extend(ComputeShape, Schema20.Struct({
|
|
1957
|
+
type: Schema20.Literal("switch")
|
|
1999
1958
|
}));
|
|
2000
1959
|
var createSwitch = (props) => createShape({
|
|
2001
1960
|
type: "switch",
|
|
@@ -2006,25 +1965,20 @@ var createSwitch = (props) => createShape({
|
|
|
2006
1965
|
...props
|
|
2007
1966
|
});
|
|
2008
1967
|
var SwitchComponent = ({ shape }) => {
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
onCheckedChange: (value2) => setValue(value2)
|
|
2024
|
-
})));
|
|
2025
|
-
} finally {
|
|
2026
|
-
_effect.f();
|
|
2027
|
-
}
|
|
1968
|
+
const { runtime } = useComputeNodeState(shape);
|
|
1969
|
+
const [value, setValue] = useState9(false);
|
|
1970
|
+
useEffect6(() => {
|
|
1971
|
+
runtime.setOutput(DEFAULT_OUTPUT6, value);
|
|
1972
|
+
}, [
|
|
1973
|
+
value
|
|
1974
|
+
]);
|
|
1975
|
+
return /* @__PURE__ */ React21.createElement("div", {
|
|
1976
|
+
className: "flex w-full justify-center items-center",
|
|
1977
|
+
onClick: (ev) => ev.stopPropagation()
|
|
1978
|
+
}, /* @__PURE__ */ React21.createElement(Input2.Root, null, /* @__PURE__ */ React21.createElement(Input2.Switch, {
|
|
1979
|
+
checked: value,
|
|
1980
|
+
onCheckedChange: (value2) => setValue(value2)
|
|
1981
|
+
})));
|
|
2028
1982
|
};
|
|
2029
1983
|
var switchShape = {
|
|
2030
1984
|
type: "switch",
|
|
@@ -2041,15 +1995,14 @@ var switchShape = {
|
|
|
2041
1995
|
};
|
|
2042
1996
|
|
|
2043
1997
|
// src/shapes/Table.tsx
|
|
2044
|
-
import
|
|
2045
|
-
import
|
|
2046
|
-
import React21 from "react";
|
|
1998
|
+
import * as Schema21 from "effect/Schema";
|
|
1999
|
+
import React22 from "react";
|
|
2047
2000
|
import { createInputSchema, createOutputSchema } from "@dxos/conductor";
|
|
2048
|
-
import {
|
|
2049
|
-
var InputSchema = createInputSchema(
|
|
2050
|
-
var OutputSchema = createOutputSchema(
|
|
2051
|
-
var TableShape =
|
|
2052
|
-
type:
|
|
2001
|
+
import { Message } from "@dxos/types";
|
|
2002
|
+
var InputSchema = createInputSchema(Message.Message);
|
|
2003
|
+
var OutputSchema = createOutputSchema(Schema21.mutable(Schema21.Array(Message.Message)));
|
|
2004
|
+
var TableShape = Schema21.extend(ComputeShape, Schema21.Struct({
|
|
2005
|
+
type: Schema21.Literal("table")
|
|
2053
2006
|
}));
|
|
2054
2007
|
var createTable = (props) => createShape({
|
|
2055
2008
|
type: "table",
|
|
@@ -2060,14 +2013,9 @@ var createTable = (props) => createShape({
|
|
|
2060
2013
|
...props
|
|
2061
2014
|
});
|
|
2062
2015
|
var TableComponent = ({ shape }) => {
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
shape
|
|
2067
|
-
});
|
|
2068
|
-
} finally {
|
|
2069
|
-
_effect.f();
|
|
2070
|
-
}
|
|
2016
|
+
return /* @__PURE__ */ React22.createElement(Box, {
|
|
2017
|
+
shape
|
|
2018
|
+
});
|
|
2071
2019
|
};
|
|
2072
2020
|
var tableShape = {
|
|
2073
2021
|
type: "table",
|
|
@@ -2080,62 +2028,48 @@ var tableShape = {
|
|
|
2080
2028
|
};
|
|
2081
2029
|
|
|
2082
2030
|
// src/shapes/Template.tsx
|
|
2083
|
-
import
|
|
2084
|
-
import
|
|
2085
|
-
import React22, { useRef as useRef5 } from "react";
|
|
2031
|
+
import * as Schema22 from "effect/Schema";
|
|
2032
|
+
import React23, { useRef as useRef5 } from "react";
|
|
2086
2033
|
import { ComputeValueType as ComputeValueType3, TemplateOutput, VoidInput as VoidInput2, getTemplateInputSchema as getTemplateInputSchema2 } from "@dxos/conductor";
|
|
2087
|
-
import { toJsonSchema
|
|
2034
|
+
import { toJsonSchema } from "@dxos/echo/internal";
|
|
2088
2035
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
2089
2036
|
import { TextBox as TextBox4 } from "@dxos/react-ui-canvas-editor";
|
|
2090
|
-
var
|
|
2091
|
-
var TemplateShape =
|
|
2092
|
-
type:
|
|
2093
|
-
valueType:
|
|
2037
|
+
var __dxlog_file7 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/Template.tsx";
|
|
2038
|
+
var TemplateShape = Schema22.extend(ComputeShape, Schema22.Struct({
|
|
2039
|
+
type: Schema22.Literal("template"),
|
|
2040
|
+
valueType: Schema22.optional(ComputeValueType3)
|
|
2094
2041
|
}));
|
|
2095
2042
|
var TextInputComponent3 = ({ shape, title, ...props }) => {
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
const
|
|
2100
|
-
|
|
2101
|
-
const
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
};
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
onValueChange: handleTypeChange
|
|
2127
|
-
})
|
|
2128
|
-
}, /* @__PURE__ */ React22.createElement(TextBox4, {
|
|
2129
|
-
...props,
|
|
2130
|
-
ref: inputRef,
|
|
2131
|
-
value: node.value,
|
|
2132
|
-
language: node.valueType === "object" ? "json" : void 0,
|
|
2133
|
-
onBlur: handleEnter,
|
|
2134
|
-
onEnter: handleEnter
|
|
2135
|
-
}));
|
|
2136
|
-
} finally {
|
|
2137
|
-
_effect.f();
|
|
2138
|
-
}
|
|
2043
|
+
const { node } = useComputeNodeState(shape);
|
|
2044
|
+
const inputRef = useRef5(null);
|
|
2045
|
+
const handleEnter = (text) => {
|
|
2046
|
+
const value = text.trim();
|
|
2047
|
+
if (value.length) {
|
|
2048
|
+
const schema = getTemplateInputSchema2(node);
|
|
2049
|
+
node.value = value;
|
|
2050
|
+
node.inputSchema = toJsonSchema(schema);
|
|
2051
|
+
}
|
|
2052
|
+
};
|
|
2053
|
+
const handleTypeChange = (newType) => {
|
|
2054
|
+
invariant5(Schema22.is(ComputeValueType3)(newType), "Invalid type", { "~LogMeta": "~LogMeta", F: __dxlog_file7, L: 32, S: void 0, A: ["Schema.is(ComputeValueType)(newType)", "'Invalid type'"] });
|
|
2055
|
+
node.valueType = newType;
|
|
2056
|
+
node.inputSchema = toJsonSchema(getTemplateInputSchema2(node));
|
|
2057
|
+
};
|
|
2058
|
+
return /* @__PURE__ */ React23.createElement(Box, {
|
|
2059
|
+
shape,
|
|
2060
|
+
title: "Template",
|
|
2061
|
+
status: /* @__PURE__ */ React23.createElement(TypeSelect, {
|
|
2062
|
+
value: node.valueType ?? "string",
|
|
2063
|
+
onValueChange: handleTypeChange
|
|
2064
|
+
})
|
|
2065
|
+
}, /* @__PURE__ */ React23.createElement(TextBox4, {
|
|
2066
|
+
...props,
|
|
2067
|
+
ref: inputRef,
|
|
2068
|
+
value: node.value,
|
|
2069
|
+
language: node.valueType === "object" ? "json" : void 0,
|
|
2070
|
+
onBlur: handleEnter,
|
|
2071
|
+
onEnter: handleEnter
|
|
2072
|
+
}));
|
|
2139
2073
|
};
|
|
2140
2074
|
var createTemplate = (props) => createShape({
|
|
2141
2075
|
type: "template",
|
|
@@ -2149,7 +2083,7 @@ var templateShape = {
|
|
|
2149
2083
|
type: "template",
|
|
2150
2084
|
name: "Template",
|
|
2151
2085
|
icon: "ph--article--regular",
|
|
2152
|
-
component: (props) => /* @__PURE__ */
|
|
2086
|
+
component: (props) => /* @__PURE__ */ React23.createElement(TextInputComponent3, {
|
|
2153
2087
|
...props,
|
|
2154
2088
|
placeholder: "Prompt"
|
|
2155
2089
|
}),
|
|
@@ -2159,14 +2093,13 @@ var templateShape = {
|
|
|
2159
2093
|
};
|
|
2160
2094
|
|
|
2161
2095
|
// src/shapes/Text.tsx
|
|
2162
|
-
import
|
|
2163
|
-
import
|
|
2164
|
-
import React23 from "react";
|
|
2096
|
+
import * as Schema23 from "effect/Schema";
|
|
2097
|
+
import React24 from "react";
|
|
2165
2098
|
import { DEFAULT_INPUT as DEFAULT_INPUT7 } from "@dxos/conductor";
|
|
2166
2099
|
import { TextBox as TextBox5 } from "@dxos/react-ui-canvas-editor";
|
|
2167
2100
|
import { createAnchorMap as createAnchorMap11 } from "@dxos/react-ui-canvas-editor";
|
|
2168
|
-
var TextShape =
|
|
2169
|
-
type:
|
|
2101
|
+
var TextShape = Schema23.extend(ComputeShape, Schema23.Struct({
|
|
2102
|
+
type: Schema23.Literal("text")
|
|
2170
2103
|
}));
|
|
2171
2104
|
var createText = (props) => createShape({
|
|
2172
2105
|
type: "text",
|
|
@@ -2177,25 +2110,20 @@ var createText = (props) => createShape({
|
|
|
2177
2110
|
...props
|
|
2178
2111
|
});
|
|
2179
2112
|
var TextComponent = ({ shape }) => {
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
value
|
|
2195
|
-
}));
|
|
2196
|
-
} finally {
|
|
2197
|
-
_effect.f();
|
|
2198
|
-
}
|
|
2113
|
+
const { runtime } = useComputeNodeState(shape);
|
|
2114
|
+
const input = runtime.inputs[DEFAULT_INPUT7];
|
|
2115
|
+
const value = input?.type === "executed" ? input.value : 0;
|
|
2116
|
+
const handleAction = (action) => {
|
|
2117
|
+
if (action === "run") {
|
|
2118
|
+
runtime.evalNode();
|
|
2119
|
+
}
|
|
2120
|
+
};
|
|
2121
|
+
return /* @__PURE__ */ React24.createElement(Box, {
|
|
2122
|
+
shape,
|
|
2123
|
+
onAction: handleAction
|
|
2124
|
+
}, /* @__PURE__ */ React24.createElement(TextBox5, {
|
|
2125
|
+
value
|
|
2126
|
+
}));
|
|
2199
2127
|
};
|
|
2200
2128
|
var textShape = {
|
|
2201
2129
|
type: "text",
|
|
@@ -2213,16 +2141,16 @@ var textShape = {
|
|
|
2213
2141
|
};
|
|
2214
2142
|
|
|
2215
2143
|
// src/shapes/Thread.tsx
|
|
2216
|
-
import
|
|
2217
|
-
import
|
|
2218
|
-
import React24, { useEffect as useEffect7, useRef as useRef6 } from "react";
|
|
2144
|
+
import * as Schema24 from "effect/Schema";
|
|
2145
|
+
import React25, { useEffect as useEffect7, useRef as useRef6 } from "react";
|
|
2219
2146
|
import { createInputSchema as createInputSchema2, createOutputSchema as createOutputSchema2 } from "@dxos/conductor";
|
|
2220
|
-
import {
|
|
2221
|
-
import {
|
|
2222
|
-
|
|
2223
|
-
var
|
|
2224
|
-
var
|
|
2225
|
-
|
|
2147
|
+
import { ScrollArea as ScrollArea3 } from "@dxos/react-ui";
|
|
2148
|
+
import { Message as Message2 } from "@dxos/types";
|
|
2149
|
+
import { mx as mx3 } from "@dxos/ui-theme";
|
|
2150
|
+
var InputSchema2 = createInputSchema2(Message2.Message);
|
|
2151
|
+
var OutputSchema2 = createOutputSchema2(Schema24.mutable(Schema24.Array(Message2.Message)));
|
|
2152
|
+
var ThreadShape = Schema24.extend(ComputeShape, Schema24.Struct({
|
|
2153
|
+
type: Schema24.Literal("thread")
|
|
2226
2154
|
}));
|
|
2227
2155
|
var createThread = (props) => createShape({
|
|
2228
2156
|
type: "thread",
|
|
@@ -2233,49 +2161,41 @@ var createThread = (props) => createShape({
|
|
|
2233
2161
|
...props
|
|
2234
2162
|
});
|
|
2235
2163
|
var ThreadComponent = ({ shape }) => {
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
} finally {
|
|
2259
|
-
_effect.f();
|
|
2260
|
-
}
|
|
2164
|
+
const items = [];
|
|
2165
|
+
const scrollRef = useRef6(null);
|
|
2166
|
+
useEffect7(() => {
|
|
2167
|
+
if (scrollRef.current) {
|
|
2168
|
+
scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
|
|
2169
|
+
}
|
|
2170
|
+
}, [
|
|
2171
|
+
items
|
|
2172
|
+
]);
|
|
2173
|
+
return /* @__PURE__ */ React25.createElement(Box, {
|
|
2174
|
+
shape
|
|
2175
|
+
}, /* @__PURE__ */ React25.createElement(ScrollArea3.Root, {
|
|
2176
|
+
orientation: "vertical"
|
|
2177
|
+
}, /* @__PURE__ */ React25.createElement(ScrollArea3.Viewport, {
|
|
2178
|
+
classNames: "gap-2 p-2",
|
|
2179
|
+
ref: scrollRef
|
|
2180
|
+
}, [
|
|
2181
|
+
...items
|
|
2182
|
+
].map((item, i) => /* @__PURE__ */ React25.createElement(ThreadItem, {
|
|
2183
|
+
key: i,
|
|
2184
|
+
item
|
|
2185
|
+
})))));
|
|
2261
2186
|
};
|
|
2262
2187
|
var ThreadItem = ({ classNames, item }) => {
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
className: mx3(classNames)
|
|
2268
|
-
}, item);
|
|
2269
|
-
}
|
|
2270
|
-
const { role, message } = item;
|
|
2271
|
-
return /* @__PURE__ */ React24.createElement("div", {
|
|
2272
|
-
className: mx3("flex", classNames, role === "user" && "justify-end")
|
|
2273
|
-
}, /* @__PURE__ */ React24.createElement("div", {
|
|
2274
|
-
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")
|
|
2275
|
-
}, message));
|
|
2276
|
-
} finally {
|
|
2277
|
-
_effect.f();
|
|
2188
|
+
if (typeof item !== "object") {
|
|
2189
|
+
return /* @__PURE__ */ React25.createElement("div", {
|
|
2190
|
+
className: mx3(classNames)
|
|
2191
|
+
}, item);
|
|
2278
2192
|
}
|
|
2193
|
+
const { role, message } = item;
|
|
2194
|
+
return /* @__PURE__ */ React25.createElement("div", {
|
|
2195
|
+
className: mx3("flex", classNames, role === "user" && "justify-end")
|
|
2196
|
+
}, /* @__PURE__ */ React25.createElement("div", {
|
|
2197
|
+
className: mx3("block rounded-md p-1 px-2 text-sm", role === "user" ? "bg-blue-100 dark:bg-blue-800" : role === "system" ? "bg-red-100, dark:bg-red-800" : "whitespace-pre-wrap bg-neutral-50 dark:bg-neutral-800")
|
|
2198
|
+
}, message));
|
|
2279
2199
|
};
|
|
2280
2200
|
var threadShape = {
|
|
2281
2201
|
type: "thread",
|
|
@@ -2288,12 +2208,11 @@ var threadShape = {
|
|
|
2288
2208
|
};
|
|
2289
2209
|
|
|
2290
2210
|
// src/shapes/TextToImage.tsx
|
|
2291
|
-
import
|
|
2292
|
-
import
|
|
2293
|
-
import React25 from "react";
|
|
2211
|
+
import * as Schema25 from "effect/Schema";
|
|
2212
|
+
import React26 from "react";
|
|
2294
2213
|
import { createAnchorMap as createAnchorMap12 } from "@dxos/react-ui-canvas-editor";
|
|
2295
|
-
var TextToImageShape =
|
|
2296
|
-
type:
|
|
2214
|
+
var TextToImageShape = Schema25.extend(ComputeShape, Schema25.Struct({
|
|
2215
|
+
type: Schema25.Literal("text-to-image")
|
|
2297
2216
|
}));
|
|
2298
2217
|
var createTextToImage = (props) => createShape({
|
|
2299
2218
|
type: "text-to-image",
|
|
@@ -2304,14 +2223,9 @@ var createTextToImage = (props) => createShape({
|
|
|
2304
2223
|
...props
|
|
2305
2224
|
});
|
|
2306
2225
|
var TextToImageComponent = ({ shape }) => {
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
shape
|
|
2311
|
-
});
|
|
2312
|
-
} finally {
|
|
2313
|
-
_effect.f();
|
|
2314
|
-
}
|
|
2226
|
+
return /* @__PURE__ */ React26.createElement(Box, {
|
|
2227
|
+
shape
|
|
2228
|
+
});
|
|
2315
2229
|
};
|
|
2316
2230
|
var textToImageShape = {
|
|
2317
2231
|
type: "text-to-image",
|
|
@@ -2328,19 +2242,17 @@ var textToImageShape = {
|
|
|
2328
2242
|
};
|
|
2329
2243
|
|
|
2330
2244
|
// src/shapes/Trigger.tsx
|
|
2331
|
-
import
|
|
2332
|
-
import
|
|
2333
|
-
import
|
|
2245
|
+
import * as Schema26 from "effect/Schema";
|
|
2246
|
+
import React27, { useEffect as useEffect8 } from "react";
|
|
2247
|
+
import { Trigger, TriggerEvent } from "@dxos/compute";
|
|
2334
2248
|
import { VoidInput as VoidInput3 } from "@dxos/conductor";
|
|
2335
|
-
import { Filter as Filter2, Query } from "@dxos/echo";
|
|
2336
|
-
import { ObjectId as ObjectId4, Ref as Ref3 } from "@dxos/echo/internal";
|
|
2337
|
-
import { Trigger, TriggerEvent } from "@dxos/functions";
|
|
2249
|
+
import { Filter as Filter2, Obj as Obj4, Query, Ref as Ref3 } from "@dxos/echo";
|
|
2338
2250
|
import { DXN, SpaceId } from "@dxos/keys";
|
|
2339
|
-
import {
|
|
2251
|
+
import { useSpaces } from "@dxos/react-client/echo";
|
|
2340
2252
|
import { Select as Select2 } from "@dxos/react-ui";
|
|
2341
|
-
var TriggerShape =
|
|
2342
|
-
type:
|
|
2343
|
-
functionTrigger:
|
|
2253
|
+
var TriggerShape = Schema26.extend(ComputeShape, Schema26.Struct({
|
|
2254
|
+
type: Schema26.Literal("trigger"),
|
|
2255
|
+
functionTrigger: Schema26.optional(Ref3.Ref(Trigger.Trigger))
|
|
2344
2256
|
}));
|
|
2345
2257
|
var createTrigger = (props) => {
|
|
2346
2258
|
const functionTrigger = Trigger.make({
|
|
@@ -2358,101 +2270,81 @@ var createTrigger = (props) => {
|
|
|
2358
2270
|
});
|
|
2359
2271
|
};
|
|
2360
2272
|
var TriggerComponent = ({ shape }) => {
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
functionTrigger.spec = createTriggerSpec({
|
|
2273
|
+
const [space] = useSpaces();
|
|
2274
|
+
const functionTrigger = shape.functionTrigger?.target;
|
|
2275
|
+
useEffect8(() => {
|
|
2276
|
+
if (functionTrigger && !functionTrigger.spec) {
|
|
2277
|
+
Obj4.update(functionTrigger, (functionTrigger2) => {
|
|
2278
|
+
functionTrigger2.spec = createTriggerSpec({
|
|
2368
2279
|
triggerKind: "email",
|
|
2369
2280
|
spaceId: space?.id
|
|
2370
2281
|
});
|
|
2371
|
-
}
|
|
2372
|
-
}
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2282
|
+
});
|
|
2283
|
+
}
|
|
2284
|
+
}, [
|
|
2285
|
+
functionTrigger,
|
|
2286
|
+
functionTrigger?.spec
|
|
2287
|
+
]);
|
|
2288
|
+
useEffect8(() => {
|
|
2289
|
+
shape.size.height = getHeight(getOutputSchema(functionTrigger?.spec?.kind ?? "email"));
|
|
2290
|
+
}, [
|
|
2291
|
+
functionTrigger?.spec?.kind
|
|
2292
|
+
]);
|
|
2293
|
+
const setKind = (kind) => {
|
|
2294
|
+
if (functionTrigger?.spec?.kind !== kind) {
|
|
2295
|
+
Obj4.update(functionTrigger, (obj) => {
|
|
2296
|
+
obj.spec = createTriggerSpec({
|
|
2384
2297
|
triggerKind: kind,
|
|
2385
2298
|
spaceId: space?.id
|
|
2386
2299
|
});
|
|
2387
|
-
}
|
|
2388
|
-
};
|
|
2389
|
-
if (!functionTrigger?.spec) {
|
|
2390
|
-
return;
|
|
2300
|
+
});
|
|
2391
2301
|
}
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
value: functionTrigger.spec?.kind,
|
|
2396
|
-
onValueChange: (kind) => setKind(kind)
|
|
2397
|
-
}),
|
|
2398
|
-
inputSchema: VoidInput3,
|
|
2399
|
-
outputSchema: getOutputSchema(functionTrigger.spec.kind)
|
|
2400
|
-
});
|
|
2401
|
-
} finally {
|
|
2402
|
-
_effect.f();
|
|
2302
|
+
};
|
|
2303
|
+
if (!functionTrigger?.spec) {
|
|
2304
|
+
return;
|
|
2403
2305
|
}
|
|
2306
|
+
return /* @__PURE__ */ React27.createElement(FunctionBody, {
|
|
2307
|
+
shape,
|
|
2308
|
+
status: /* @__PURE__ */ React27.createElement(TriggerKindSelect, {
|
|
2309
|
+
value: functionTrigger.spec?.kind,
|
|
2310
|
+
onValueChange: (kind) => setKind(kind)
|
|
2311
|
+
}),
|
|
2312
|
+
inputSchema: VoidInput3,
|
|
2313
|
+
outputSchema: getOutputSchema(functionTrigger.spec.kind)
|
|
2314
|
+
});
|
|
2404
2315
|
};
|
|
2405
2316
|
var TriggerKindSelect = ({ value, onValueChange }) => {
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
value: kind
|
|
2417
|
-
}, kind))), /* @__PURE__ */ React26.createElement(Select2.ScrollDownButton, null), /* @__PURE__ */ React26.createElement(Select2.Arrow, null))));
|
|
2418
|
-
} finally {
|
|
2419
|
-
_effect.f();
|
|
2420
|
-
}
|
|
2317
|
+
return /* @__PURE__ */ React27.createElement(Select2.Root, {
|
|
2318
|
+
value,
|
|
2319
|
+
onValueChange
|
|
2320
|
+
}, /* @__PURE__ */ React27.createElement(Select2.TriggerButton, {
|
|
2321
|
+
variant: "ghost",
|
|
2322
|
+
classNames: "w-full px-0!"
|
|
2323
|
+
}), /* @__PURE__ */ React27.createElement(Select2.Portal, null, /* @__PURE__ */ React27.createElement(Select2.Content, null, /* @__PURE__ */ React27.createElement(Select2.ScrollUpButton, null), /* @__PURE__ */ React27.createElement(Select2.Viewport, null, Trigger.Kinds.map((kind) => /* @__PURE__ */ React27.createElement(Select2.Option, {
|
|
2324
|
+
key: kind,
|
|
2325
|
+
value: kind
|
|
2326
|
+
}, kind))), /* @__PURE__ */ React27.createElement(Select2.ScrollDownButton, null), /* @__PURE__ */ React27.createElement(Select2.Arrow, null))));
|
|
2421
2327
|
};
|
|
2422
2328
|
var createTriggerSpec = (props) => {
|
|
2423
2329
|
const kind = props.triggerKind ?? "email";
|
|
2424
2330
|
switch (kind) {
|
|
2425
2331
|
case "timer":
|
|
2426
|
-
return
|
|
2427
|
-
kind: "timer",
|
|
2428
|
-
cron: "*/10 * * * * *"
|
|
2429
|
-
};
|
|
2332
|
+
return Trigger.specTimer("*/10 * * * * *");
|
|
2430
2333
|
case "webhook":
|
|
2431
|
-
return {
|
|
2432
|
-
kind: "webhook",
|
|
2334
|
+
return Trigger.specWebhook({
|
|
2433
2335
|
method: "POST"
|
|
2434
|
-
};
|
|
2336
|
+
});
|
|
2435
2337
|
case "subscription":
|
|
2436
|
-
return
|
|
2437
|
-
kind: "subscription",
|
|
2438
|
-
query: {
|
|
2439
|
-
ast: Query.select(Filter2.nothing()).ast
|
|
2440
|
-
}
|
|
2441
|
-
};
|
|
2338
|
+
return Trigger.specSubscription(Query.select(Filter2.nothing()));
|
|
2442
2339
|
case "email":
|
|
2443
|
-
return
|
|
2444
|
-
kind: "email"
|
|
2445
|
-
};
|
|
2340
|
+
return Trigger.specEmail();
|
|
2446
2341
|
case "queue": {
|
|
2447
2342
|
const dxn = new DXN(DXN.kind.QUEUE, [
|
|
2448
2343
|
"data",
|
|
2449
2344
|
props.spaceId ?? SpaceId.random(),
|
|
2450
|
-
|
|
2345
|
+
Obj4.ID.random()
|
|
2451
2346
|
]).toString();
|
|
2452
|
-
return
|
|
2453
|
-
kind: "queue",
|
|
2454
|
-
queue: dxn
|
|
2455
|
-
};
|
|
2347
|
+
return Trigger.specQueue(dxn);
|
|
2456
2348
|
}
|
|
2457
2349
|
}
|
|
2458
2350
|
};
|
|
@@ -2475,140 +2367,6 @@ var triggerShape = {
|
|
|
2475
2367
|
getAnchors: (shape) => createFunctionAnchors(shape, VoidInput3, getOutputSchema(shape.functionTrigger?.target?.spec?.kind ?? "email"))
|
|
2476
2368
|
};
|
|
2477
2369
|
|
|
2478
|
-
// src/shapes/GptRealtime.tsx
|
|
2479
|
-
import { useSignals as _useSignals26 } from "@preact-signals/safe-react/tracking";
|
|
2480
|
-
import * as Schema26 from "effect/Schema";
|
|
2481
|
-
import React27, { useState as useState9 } from "react";
|
|
2482
|
-
import { log as log2 } from "@dxos/log";
|
|
2483
|
-
import { useConfig } from "@dxos/react-client";
|
|
2484
|
-
import { Icon as Icon5 } from "@dxos/react-ui";
|
|
2485
|
-
var __dxlog_file7 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/GptRealtime.tsx";
|
|
2486
|
-
var GptRealtimeShape = Schema26.extend(ComputeShape, Schema26.Struct({
|
|
2487
|
-
type: Schema26.Literal("gpt-realtime")
|
|
2488
|
-
}));
|
|
2489
|
-
var createGptRealtime = (props) => createShape({
|
|
2490
|
-
type: "gpt-realtime",
|
|
2491
|
-
size: {
|
|
2492
|
-
width: 256,
|
|
2493
|
-
height: 256
|
|
2494
|
-
},
|
|
2495
|
-
...props
|
|
2496
|
-
});
|
|
2497
|
-
var GptRealtimeComponent = ({ shape }) => {
|
|
2498
|
-
var _effect = _useSignals26();
|
|
2499
|
-
try {
|
|
2500
|
-
const [isLive, setIsLive] = useState9(false);
|
|
2501
|
-
const [isReady, setIsReady] = useState9(false);
|
|
2502
|
-
const config = useConfig();
|
|
2503
|
-
const start = async () => {
|
|
2504
|
-
setIsLive(true);
|
|
2505
|
-
try {
|
|
2506
|
-
const peerConnection = new RTCPeerConnection();
|
|
2507
|
-
peerConnection.ontrack = (event) => {
|
|
2508
|
-
const audioElement = document.createElement("audio");
|
|
2509
|
-
audioElement.srcObject = event.streams[0];
|
|
2510
|
-
audioElement.autoplay = true;
|
|
2511
|
-
audioElement.controls = false;
|
|
2512
|
-
audioElement.style.display = "none";
|
|
2513
|
-
document.body.appendChild(audioElement);
|
|
2514
|
-
setIsReady(true);
|
|
2515
|
-
};
|
|
2516
|
-
const stream = await navigator.mediaDevices.getUserMedia({
|
|
2517
|
-
audio: true
|
|
2518
|
-
});
|
|
2519
|
-
stream.getTracks().forEach((track) => peerConnection.addTransceiver(track, {
|
|
2520
|
-
direction: "sendrecv"
|
|
2521
|
-
}));
|
|
2522
|
-
const offer = await peerConnection.createOffer();
|
|
2523
|
-
await peerConnection.setLocalDescription(offer);
|
|
2524
|
-
const AiServiceUrl = new URL("/rtc-connect", config.values.runtime?.services?.ai?.server ?? DEFAULT_AI_SERVICE_URL);
|
|
2525
|
-
const response = await fetch(AiServiceUrl, {
|
|
2526
|
-
method: "POST",
|
|
2527
|
-
body: offer.sdp,
|
|
2528
|
-
headers: {
|
|
2529
|
-
"Content-Type": "application/sdp"
|
|
2530
|
-
}
|
|
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
|
-
};
|
|
2558
|
-
dataChannel.addEventListener("open", (ev) => {
|
|
2559
|
-
log2.info("Opening data channel", {
|
|
2560
|
-
ev
|
|
2561
|
-
}, {
|
|
2562
|
-
F: __dxlog_file7,
|
|
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
|
|
2577
|
-
}, {
|
|
2578
|
-
F: __dxlog_file7,
|
|
2579
|
-
L: 140,
|
|
2580
|
-
S: void 0,
|
|
2581
|
-
C: (f, a) => f(...a)
|
|
2582
|
-
});
|
|
2583
|
-
throw error;
|
|
2584
|
-
}
|
|
2585
|
-
};
|
|
2586
|
-
return /* @__PURE__ */ React27.createElement("div", {
|
|
2587
|
-
className: "flex w-full justify-center items-center"
|
|
2588
|
-
}, /* @__PURE__ */ React27.createElement(Icon5, {
|
|
2589
|
-
icon: isReady ? "ph--waveform--regular" : isLive ? "ph--pulse--regular" : "ph--play--regular",
|
|
2590
|
-
size: 16,
|
|
2591
|
-
classNames: !isLive && "cursor-pointer",
|
|
2592
|
-
onClick: start
|
|
2593
|
-
}));
|
|
2594
|
-
} finally {
|
|
2595
|
-
_effect.f();
|
|
2596
|
-
}
|
|
2597
|
-
};
|
|
2598
|
-
var gptRealtimeShape = {
|
|
2599
|
-
type: "gpt-realtime",
|
|
2600
|
-
name: "GPT Realtime",
|
|
2601
|
-
icon: "ph--pulse--regular",
|
|
2602
|
-
component: GptRealtimeComponent,
|
|
2603
|
-
createShape: createGptRealtime,
|
|
2604
|
-
// TODO(dmaretskyi): Can we fetch the schema dynamically?
|
|
2605
|
-
getAnchors: (shape) => createFunctionAnchors(shape, Schema26.Struct({
|
|
2606
|
-
audio: Schema26.Any
|
|
2607
|
-
}), Schema26.Struct({})),
|
|
2608
|
-
resizable: true
|
|
2609
|
-
};
|
|
2610
|
-
var DEFAULT_AI_SERVICE_URL = "http://localhost:8788";
|
|
2611
|
-
|
|
2612
2370
|
// src/registry.ts
|
|
2613
2371
|
var computeShapes = [
|
|
2614
2372
|
{
|
|
@@ -2654,7 +2412,7 @@ var computeShapes = [
|
|
|
2654
2412
|
shapes: [
|
|
2655
2413
|
//
|
|
2656
2414
|
jsonShape,
|
|
2657
|
-
|
|
2415
|
+
feedShape,
|
|
2658
2416
|
threadShape,
|
|
2659
2417
|
textShape,
|
|
2660
2418
|
surfaceShape,
|
|
@@ -2713,6 +2471,9 @@ export {
|
|
|
2713
2471
|
ConstantShape,
|
|
2714
2472
|
DatabaseComponent,
|
|
2715
2473
|
DatabaseShape,
|
|
2474
|
+
FeedComponent,
|
|
2475
|
+
FeedItem,
|
|
2476
|
+
FeedShape,
|
|
2716
2477
|
FunctionBody,
|
|
2717
2478
|
FunctionShape,
|
|
2718
2479
|
GptComponent,
|
|
@@ -2730,9 +2491,6 @@ export {
|
|
|
2730
2491
|
JsonTransformShape,
|
|
2731
2492
|
NotShape,
|
|
2732
2493
|
OrShape,
|
|
2733
|
-
QueueComponent,
|
|
2734
|
-
QueueItem,
|
|
2735
|
-
QueueShape,
|
|
2736
2494
|
RandomComponent,
|
|
2737
2495
|
RandomShape,
|
|
2738
2496
|
ReducerComponent,
|
|
@@ -2775,6 +2533,7 @@ export {
|
|
|
2775
2533
|
createComputeNode,
|
|
2776
2534
|
createConstant,
|
|
2777
2535
|
createDatabase,
|
|
2536
|
+
createFeed,
|
|
2778
2537
|
createFunction,
|
|
2779
2538
|
createFunctionAnchors,
|
|
2780
2539
|
createGpt,
|
|
@@ -2785,7 +2544,6 @@ export {
|
|
|
2785
2544
|
createJsonTransform,
|
|
2786
2545
|
createNot,
|
|
2787
2546
|
createOr,
|
|
2788
|
-
createQueue,
|
|
2789
2547
|
createRandom,
|
|
2790
2548
|
createReducer,
|
|
2791
2549
|
createScope,
|
|
@@ -2799,6 +2557,7 @@ export {
|
|
|
2799
2557
|
createThread,
|
|
2800
2558
|
createTrigger,
|
|
2801
2559
|
databaseShape,
|
|
2560
|
+
feedShape,
|
|
2802
2561
|
footerHeight,
|
|
2803
2562
|
functionShape,
|
|
2804
2563
|
getHeight,
|
|
@@ -2815,7 +2574,6 @@ export {
|
|
|
2815
2574
|
notShape,
|
|
2816
2575
|
orShape,
|
|
2817
2576
|
parseAnchorId,
|
|
2818
|
-
queueShape,
|
|
2819
2577
|
randomShape,
|
|
2820
2578
|
reducerShape,
|
|
2821
2579
|
resolveComputeNode,
|