@dxos/react-ui-canvas-compute 0.7.5-labs.a279d8c → 0.7.5-labs.a8b535d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/index.mjs +158 -46
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +180 -69
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +158 -46
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/DiagnosticOverlay.d.ts +6 -0
- package/dist/types/src/components/DiagnosticOverlay.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +2 -0
- package/dist/types/src/components/index.d.ts.map +1 -0
- package/dist/types/src/compute-layout.d.ts +1 -1
- package/dist/types/src/compute-layout.d.ts.map +1 -1
- package/dist/types/src/compute.stories.d.ts.map +1 -1
- package/dist/types/src/graph/controller.d.ts +23 -4
- package/dist/types/src/graph/controller.d.ts.map +1 -1
- package/dist/types/src/shapes/Append.d.ts +1 -2
- package/dist/types/src/shapes/Append.d.ts.map +1 -1
- package/dist/types/src/shapes/Array.d.ts +1 -2
- package/dist/types/src/shapes/Array.d.ts.map +1 -1
- package/dist/types/src/shapes/Audio.d.ts +1 -2
- package/dist/types/src/shapes/Audio.d.ts.map +1 -1
- package/dist/types/src/shapes/Beacon.d.ts +1 -2
- package/dist/types/src/shapes/Beacon.d.ts.map +1 -1
- package/dist/types/src/shapes/Chat.d.ts +1 -2
- package/dist/types/src/shapes/Chat.d.ts.map +1 -1
- package/dist/types/src/shapes/Constant.d.ts +1 -2
- package/dist/types/src/shapes/Constant.d.ts.map +1 -1
- package/dist/types/src/shapes/Database.d.ts +1 -2
- package/dist/types/src/shapes/Database.d.ts.map +1 -1
- package/dist/types/src/shapes/Function.d.ts +1 -3
- package/dist/types/src/shapes/Function.d.ts.map +1 -1
- package/dist/types/src/shapes/Gpt.d.ts +1 -2
- package/dist/types/src/shapes/Gpt.d.ts.map +1 -1
- package/dist/types/src/shapes/GptRealtime.d.ts +1 -2
- package/dist/types/src/shapes/GptRealtime.d.ts.map +1 -1
- package/dist/types/src/shapes/Json.d.ts +2 -3
- package/dist/types/src/shapes/Json.d.ts.map +1 -1
- package/dist/types/src/shapes/Logic.d.ts +2 -3
- package/dist/types/src/shapes/Logic.d.ts.map +1 -1
- package/dist/types/src/shapes/Queue.d.ts +2 -3
- package/dist/types/src/shapes/Queue.d.ts.map +1 -1
- package/dist/types/src/shapes/RNG.d.ts +1 -2
- package/dist/types/src/shapes/RNG.d.ts.map +1 -1
- package/dist/types/src/shapes/Scope.d.ts +1 -2
- package/dist/types/src/shapes/Scope.d.ts.map +1 -1
- package/dist/types/src/shapes/Surface.d.ts +1 -2
- package/dist/types/src/shapes/Surface.d.ts.map +1 -1
- package/dist/types/src/shapes/Switch.d.ts +1 -2
- package/dist/types/src/shapes/Switch.d.ts.map +1 -1
- package/dist/types/src/shapes/Table.d.ts +1 -2
- package/dist/types/src/shapes/Table.d.ts.map +1 -1
- package/dist/types/src/shapes/Text.d.ts +1 -2
- package/dist/types/src/shapes/Text.d.ts.map +1 -1
- package/dist/types/src/shapes/TextToImage.d.ts +1 -2
- package/dist/types/src/shapes/TextToImage.d.ts.map +1 -1
- package/dist/types/src/shapes/Thread.d.ts +2 -3
- package/dist/types/src/shapes/Thread.d.ts.map +1 -1
- package/dist/types/src/shapes/Trigger.d.ts +8 -4
- package/dist/types/src/shapes/Trigger.d.ts.map +1 -1
- package/dist/types/src/shapes/common/Box.d.ts +1 -1
- package/dist/types/src/shapes/common/FunctionBody.d.ts +1 -1
- package/dist/types/src/shapes/common/FunctionBody.d.ts.map +1 -1
- package/dist/types/src/shapes/common/TypeSelect.d.ts +1 -2
- package/dist/types/src/shapes/common/TypeSelect.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +41 -40
- package/src/components/DiagnosticOverlay.tsx +23 -0
- package/src/components/index.ts +5 -0
- package/src/compute-layout.ts +1 -1
- package/src/compute.stories.tsx +17 -14
- package/src/graph/controller.ts +28 -3
- package/src/hooks/useGraphMonitor.ts +2 -2
- package/src/shapes/Function.tsx +83 -9
- package/src/shapes/Gpt.tsx +2 -2
- package/src/shapes/GptRealtime.tsx +12 -5
- package/src/shapes/Trigger.tsx +18 -7
- package/src/shapes/common/FunctionBody.tsx +1 -0
- package/src/shapes/common/TypeSelect.tsx +5 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import "@dxos/node-std/globals";
|
|
2
2
|
|
|
3
3
|
// packages/ui/react-ui-canvas-compute/src/graph/controller.ts
|
|
4
|
+
import { FetchHttpClient } from "@effect/platform";
|
|
4
5
|
import { Effect, Either, Exit, Layer, Scope } from "effect";
|
|
5
6
|
import { Event, synchronized } from "@dxos/async";
|
|
6
|
-
import { isNotExecuted, makeValueBag, EventLogger, GptService, GraphExecutor, MockGpt, QueueService, SpaceService } from "@dxos/conductor";
|
|
7
|
+
import { isNotExecuted, makeValueBag, EventLogger, GptService, GraphExecutor, MockGpt, QueueService, SpaceService, FunctionCallService } from "@dxos/conductor";
|
|
7
8
|
import { Resource } from "@dxos/context";
|
|
8
9
|
import { log } from "@dxos/log";
|
|
9
10
|
|
|
@@ -171,7 +172,7 @@ import { ObjectId as ObjectId2 } from "@dxos/echo-schema";
|
|
|
171
172
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
172
173
|
import { DXN } from "@dxos/keys";
|
|
173
174
|
import { getSpace } from "@dxos/react-client/echo";
|
|
174
|
-
import {
|
|
175
|
+
import { isNonNullable } from "@dxos/util";
|
|
175
176
|
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-canvas-compute/src/hooks/useGraphMonitor.ts";
|
|
176
177
|
var mapEdge = (graph, { source, target, output = DEFAULT_OUTPUT, input = DEFAULT_INPUT }) => {
|
|
177
178
|
const sourceNode = graph.findNode(source);
|
|
@@ -238,7 +239,7 @@ var useGraphMonitor = (model) => {
|
|
|
238
239
|
const nodeIds = subgraph.nodes.map((shape) => shape.node);
|
|
239
240
|
const edgeIds = subgraph.edges.map(({ source, target, output = DEFAULT_OUTPUT, input = DEFAULT_INPUT }) => {
|
|
240
241
|
return model.edges.find((computeEdge) => computeEdge.input === input && computeEdge.output === output)?.id;
|
|
241
|
-
}).filter(
|
|
242
|
+
}).filter(isNonNullable);
|
|
242
243
|
model.removeNodes(nodeIds);
|
|
243
244
|
model.removeEdges(edgeIds);
|
|
244
245
|
deleteTriggerObjects(model, subgraph);
|
|
@@ -323,6 +324,7 @@ var ComputeGraphController = class extends Resource {
|
|
|
323
324
|
this._executor = new GraphExecutor({
|
|
324
325
|
computeNodeResolver: (node) => resolveComputeNode(node)
|
|
325
326
|
});
|
|
327
|
+
this._diagnostics = [];
|
|
326
328
|
this._services = {};
|
|
327
329
|
this._forcedOutputs = {};
|
|
328
330
|
this._runtimeStateInputs = {};
|
|
@@ -342,11 +344,22 @@ var ComputeGraphController = class extends Resource {
|
|
|
342
344
|
};
|
|
343
345
|
}
|
|
344
346
|
setServices(services) {
|
|
347
|
+
log.info("setServices", {
|
|
348
|
+
services
|
|
349
|
+
}, {
|
|
350
|
+
F: __dxlog_file4,
|
|
351
|
+
L: 149,
|
|
352
|
+
S: this,
|
|
353
|
+
C: (f, a) => f(...a)
|
|
354
|
+
});
|
|
345
355
|
Object.assign(this._services, services);
|
|
346
356
|
}
|
|
347
357
|
get graph() {
|
|
348
358
|
return this._graph;
|
|
349
359
|
}
|
|
360
|
+
get diagnostics() {
|
|
361
|
+
return this._diagnostics;
|
|
362
|
+
}
|
|
350
363
|
get userState() {
|
|
351
364
|
return this._forcedOutputs;
|
|
352
365
|
}
|
|
@@ -399,7 +412,7 @@ var ComputeGraphController = class extends Resource {
|
|
|
399
412
|
} catch (err) {
|
|
400
413
|
log.catch(err, void 0, {
|
|
401
414
|
F: __dxlog_file4,
|
|
402
|
-
L:
|
|
415
|
+
L: 218,
|
|
403
416
|
S: this,
|
|
404
417
|
C: (f, a) => f(...a)
|
|
405
418
|
});
|
|
@@ -410,6 +423,11 @@ var ComputeGraphController = class extends Resource {
|
|
|
410
423
|
const { meta } = await resolveComputeNode(node);
|
|
411
424
|
return meta;
|
|
412
425
|
}
|
|
426
|
+
async checkGraph() {
|
|
427
|
+
const executor = this._executor.clone();
|
|
428
|
+
await executor.load(this._graph);
|
|
429
|
+
this._diagnostics = executor.getDiagnostics();
|
|
430
|
+
}
|
|
413
431
|
async evalNode(nodeId) {
|
|
414
432
|
const executor = this._executor.clone();
|
|
415
433
|
await executor.load(this._graph);
|
|
@@ -421,7 +439,7 @@ var ComputeGraphController = class extends Resource {
|
|
|
421
439
|
const scope = yield* Scope.make();
|
|
422
440
|
const executable = yield* Effect.promise(() => resolveComputeNode(this._graph.getNode(nodeId)));
|
|
423
441
|
const computingOutputs = executable.exec != null;
|
|
424
|
-
const effect = (computingOutputs ? executor.computeOutputs(nodeId) : executor.computeInputs(nodeId)).pipe(Effect.withSpan("runGraph"),
|
|
442
|
+
const effect = (computingOutputs ? executor.computeOutputs(nodeId) : executor.computeInputs(nodeId)).pipe(Effect.withSpan("runGraph"), Scope.extend(scope), Effect.flatMap(computeValueBag), Effect.provide(services), Effect.withSpan("test"), Effect.tap((values) => {
|
|
425
443
|
for (const [key, value] of Object.entries(values)) {
|
|
426
444
|
if (computingOutputs) {
|
|
427
445
|
this._onOutputComputed(nodeId, key, value);
|
|
@@ -460,7 +478,7 @@ var ComputeGraphController = class extends Resource {
|
|
|
460
478
|
for (const node of allAffectedNodes) {
|
|
461
479
|
const executable = yield* Effect.promise(() => resolveComputeNode(this._graph.getNode(node)));
|
|
462
480
|
const computingOutputs = executable.exec != null;
|
|
463
|
-
const effect = (computingOutputs ? executor.computeOutputs(node) : executor.computeInputs(node)).pipe(Effect.withSpan("runGraph"),
|
|
481
|
+
const effect = (computingOutputs ? executor.computeOutputs(node) : executor.computeInputs(node)).pipe(Effect.withSpan("runGraph"), Scope.extend(scope), Effect.flatMap(computeValueBag), Effect.provide(services), Effect.withSpan("test"), Effect.tap((values) => {
|
|
464
482
|
for (const [key, value] of Object.entries(values)) {
|
|
465
483
|
if (computingOutputs) {
|
|
466
484
|
this._onOutputComputed(node, key, value);
|
|
@@ -485,7 +503,8 @@ var ComputeGraphController = class extends Resource {
|
|
|
485
503
|
const gptLayer = Layer.succeed(GptService, services.gpt);
|
|
486
504
|
const queueLayer = services.edgeHttpClient != null ? QueueService.fromClient(services.edgeHttpClient) : QueueService.notAvailable;
|
|
487
505
|
const spaceLayer = services.spaceService != null ? Layer.succeed(SpaceService, services.spaceService) : SpaceService.empty;
|
|
488
|
-
|
|
506
|
+
const functionCallServiceLayer = services.edgeHttpClient != null && services.spaceService != null ? Layer.succeed(FunctionCallService, FunctionCallService.fromClient(services.edgeHttpClient.baseUrl, services.spaceService.spaceId)) : Layer.succeed(FunctionCallService, FunctionCallService.mock());
|
|
507
|
+
return Layer.mergeAll(logLayer, gptLayer, queueLayer, spaceLayer, functionCallServiceLayer, FetchHttpClient.layer);
|
|
489
508
|
}
|
|
490
509
|
_createLogger() {
|
|
491
510
|
return {
|
|
@@ -500,7 +519,7 @@ var ComputeGraphController = class extends Resource {
|
|
|
500
519
|
event
|
|
501
520
|
}, {
|
|
502
521
|
F: __dxlog_file4,
|
|
503
|
-
L:
|
|
522
|
+
L: 376,
|
|
504
523
|
S: this,
|
|
505
524
|
C: (f, a) => f(...a)
|
|
506
525
|
});
|
|
@@ -536,6 +555,9 @@ var ComputeGraphController = class extends Resource {
|
|
|
536
555
|
});
|
|
537
556
|
}
|
|
538
557
|
};
|
|
558
|
+
_ts_decorate([
|
|
559
|
+
synchronized
|
|
560
|
+
], ComputeGraphController.prototype, "checkGraph", null);
|
|
539
561
|
_ts_decorate([
|
|
540
562
|
synchronized
|
|
541
563
|
], ComputeGraphController.prototype, "exec", null);
|
|
@@ -764,8 +786,8 @@ var createFunctionAnchors = (shape, input = VoidInput, output = VoidOutput) => {
|
|
|
764
786
|
|
|
765
787
|
// packages/ui/react-ui-canvas-compute/src/shapes/common/TypeSelect.tsx
|
|
766
788
|
import React3 from "react";
|
|
767
|
-
import { Select } from "@dxos/react-ui";
|
|
768
789
|
import { ComputeValueType } from "@dxos/conductor";
|
|
790
|
+
import { Select } from "@dxos/react-ui";
|
|
769
791
|
var TypeSelect = ({ value, onValueChange }) => {
|
|
770
792
|
return /* @__PURE__ */ React3.createElement(Select.Root, {
|
|
771
793
|
value,
|
|
@@ -1292,34 +1314,80 @@ var databaseShape = {
|
|
|
1292
1314
|
};
|
|
1293
1315
|
|
|
1294
1316
|
// packages/ui/react-ui-canvas-compute/src/shapes/Function.tsx
|
|
1295
|
-
import React12 from "react";
|
|
1317
|
+
import React12, { useCallback as useCallback3, useRef as useRef4 } from "react";
|
|
1296
1318
|
import { AnyOutput, FunctionInput } from "@dxos/conductor";
|
|
1297
|
-
import { S as S11 } from "@dxos/echo-schema";
|
|
1319
|
+
import { getSnapshot, S as S11 } from "@dxos/echo-schema";
|
|
1320
|
+
import { FunctionType, ScriptType } from "@dxos/functions";
|
|
1321
|
+
import { useClient } from "@dxos/react-client";
|
|
1322
|
+
import { Filter, makeRef, parseId } from "@dxos/react-client/echo";
|
|
1323
|
+
import { TextBox as TextBox3 } from "@dxos/react-ui-canvas-editor";
|
|
1298
1324
|
var FunctionShape = S11.extend(ComputeShape, S11.Struct({
|
|
1299
1325
|
type: S11.Literal("function")
|
|
1300
1326
|
}));
|
|
1301
1327
|
var createFunction = (props) => createShape({
|
|
1302
1328
|
type: "function",
|
|
1303
1329
|
size: {
|
|
1304
|
-
width:
|
|
1305
|
-
height:
|
|
1330
|
+
width: 256,
|
|
1331
|
+
height: 192
|
|
1306
1332
|
},
|
|
1307
1333
|
...props
|
|
1308
1334
|
});
|
|
1309
|
-
var
|
|
1310
|
-
|
|
1335
|
+
var TextInputComponent2 = ({ shape, title, ...props }) => {
|
|
1336
|
+
const client = useClient();
|
|
1337
|
+
const { node, runtime } = useComputeNodeState(shape);
|
|
1338
|
+
const inputRef = useRef4(null);
|
|
1339
|
+
const handleEnter = useCallback3(async (text) => {
|
|
1340
|
+
const value = text.trim();
|
|
1341
|
+
const { spaceId, objectId } = parseId(value);
|
|
1342
|
+
if (!spaceId || !objectId) {
|
|
1343
|
+
return;
|
|
1344
|
+
}
|
|
1345
|
+
const space = client.spaces.get(spaceId);
|
|
1346
|
+
const object = space?.db.getObjectById(objectId);
|
|
1347
|
+
if (!space || !(object instanceof ScriptType)) {
|
|
1348
|
+
return;
|
|
1349
|
+
}
|
|
1350
|
+
const { objects: [fn] } = await space.db.query(Filter.schema(FunctionType, {
|
|
1351
|
+
source: object
|
|
1352
|
+
})).run();
|
|
1353
|
+
if (!fn) {
|
|
1354
|
+
return;
|
|
1355
|
+
}
|
|
1356
|
+
node.value = value;
|
|
1357
|
+
node.function = makeRef(fn);
|
|
1358
|
+
node.inputSchema = getSnapshot(fn.inputSchema);
|
|
1359
|
+
node.outputSchema = getSnapshot(fn.outputSchema);
|
|
1360
|
+
}, [
|
|
1361
|
+
client,
|
|
1362
|
+
node
|
|
1363
|
+
]);
|
|
1364
|
+
const handleAction = useCallback3((action) => {
|
|
1365
|
+
if (action !== "run") {
|
|
1366
|
+
return;
|
|
1367
|
+
}
|
|
1368
|
+
runtime.evalNode();
|
|
1369
|
+
}, [
|
|
1370
|
+
runtime
|
|
1371
|
+
]);
|
|
1372
|
+
return /* @__PURE__ */ React12.createElement(Box, {
|
|
1311
1373
|
shape,
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
}
|
|
1374
|
+
title: "Function",
|
|
1375
|
+
onAction: handleAction
|
|
1376
|
+
}, /* @__PURE__ */ React12.createElement(TextBox3, {
|
|
1377
|
+
...props,
|
|
1378
|
+
ref: inputRef,
|
|
1379
|
+
value: node.value,
|
|
1380
|
+
language: node.valueType === "object" ? "json" : void 0,
|
|
1381
|
+
onBlur: handleEnter,
|
|
1382
|
+
onEnter: handleEnter
|
|
1383
|
+
}));
|
|
1315
1384
|
};
|
|
1316
1385
|
var functionShape = {
|
|
1317
1386
|
type: "function",
|
|
1318
1387
|
name: "Function",
|
|
1319
1388
|
icon: "ph--function--regular",
|
|
1320
|
-
component:
|
|
1389
|
+
component: TextInputComponent2,
|
|
1321
1390
|
createShape: createFunction,
|
|
1322
|
-
// TODO(burdon): Get dynamic schema.
|
|
1323
1391
|
getAnchors: (shape) => createFunctionAnchors(shape, FunctionInput, AnyOutput)
|
|
1324
1392
|
};
|
|
1325
1393
|
|
|
@@ -1840,19 +1908,19 @@ var tableShape = {
|
|
|
1840
1908
|
};
|
|
1841
1909
|
|
|
1842
1910
|
// packages/ui/react-ui-canvas-compute/src/shapes/Template.tsx
|
|
1843
|
-
import React22, { useRef as
|
|
1911
|
+
import React22, { useRef as useRef5 } from "react";
|
|
1844
1912
|
import { ComputeValueType as ComputeValueType3, getTemplateInputSchema as getTemplateInputSchema2, TemplateOutput, VoidInput as VoidInput2 } from "@dxos/conductor";
|
|
1845
1913
|
import { S as S21, toJsonSchema as toJsonSchema2 } from "@dxos/echo-schema";
|
|
1846
1914
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
1847
|
-
import { TextBox as
|
|
1915
|
+
import { TextBox as TextBox4 } from "@dxos/react-ui-canvas-editor";
|
|
1848
1916
|
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/Template.tsx";
|
|
1849
1917
|
var TemplateShape = S21.extend(ComputeShape, S21.Struct({
|
|
1850
1918
|
type: S21.Literal("template"),
|
|
1851
1919
|
valueType: S21.optional(ComputeValueType3)
|
|
1852
1920
|
}));
|
|
1853
|
-
var
|
|
1921
|
+
var TextInputComponent3 = ({ shape, title, ...props }) => {
|
|
1854
1922
|
const { node } = useComputeNodeState(shape);
|
|
1855
|
-
const inputRef =
|
|
1923
|
+
const inputRef = useRef5(null);
|
|
1856
1924
|
const handleEnter = (text) => {
|
|
1857
1925
|
const value = text.trim();
|
|
1858
1926
|
if (value.length) {
|
|
@@ -1881,7 +1949,7 @@ var TextInputComponent2 = ({ shape, title, ...props }) => {
|
|
|
1881
1949
|
value: node.valueType ?? "string",
|
|
1882
1950
|
onValueChange: handleTypeChange
|
|
1883
1951
|
})
|
|
1884
|
-
}, /* @__PURE__ */ React22.createElement(
|
|
1952
|
+
}, /* @__PURE__ */ React22.createElement(TextBox4, {
|
|
1885
1953
|
...props,
|
|
1886
1954
|
ref: inputRef,
|
|
1887
1955
|
value: node.value,
|
|
@@ -1902,7 +1970,7 @@ var templateShape = {
|
|
|
1902
1970
|
type: "template",
|
|
1903
1971
|
name: "Template",
|
|
1904
1972
|
icon: "ph--article--regular",
|
|
1905
|
-
component: (props) => /* @__PURE__ */ React22.createElement(
|
|
1973
|
+
component: (props) => /* @__PURE__ */ React22.createElement(TextInputComponent3, {
|
|
1906
1974
|
...props,
|
|
1907
1975
|
placeholder: "Prompt"
|
|
1908
1976
|
}),
|
|
@@ -1915,7 +1983,7 @@ var templateShape = {
|
|
|
1915
1983
|
import React23 from "react";
|
|
1916
1984
|
import { DEFAULT_INPUT as DEFAULT_INPUT7 } from "@dxos/conductor";
|
|
1917
1985
|
import { S as S22 } from "@dxos/echo-schema";
|
|
1918
|
-
import { TextBox as
|
|
1986
|
+
import { TextBox as TextBox5 } from "@dxos/react-ui-canvas-editor";
|
|
1919
1987
|
import { createAnchorMap as createAnchorMap11 } from "@dxos/react-ui-canvas-editor";
|
|
1920
1988
|
var TextShape = S22.extend(ComputeShape, S22.Struct({
|
|
1921
1989
|
type: S22.Literal("text")
|
|
@@ -1940,7 +2008,7 @@ var TextComponent = ({ shape }) => {
|
|
|
1940
2008
|
return /* @__PURE__ */ React23.createElement(Box, {
|
|
1941
2009
|
shape,
|
|
1942
2010
|
onAction: handleAction
|
|
1943
|
-
}, /* @__PURE__ */ React23.createElement(
|
|
2011
|
+
}, /* @__PURE__ */ React23.createElement(TextBox5, {
|
|
1944
2012
|
value
|
|
1945
2013
|
}));
|
|
1946
2014
|
};
|
|
@@ -1960,7 +2028,7 @@ var textShape = {
|
|
|
1960
2028
|
};
|
|
1961
2029
|
|
|
1962
2030
|
// packages/ui/react-ui-canvas-compute/src/shapes/Thread.tsx
|
|
1963
|
-
import React24, { useEffect as useEffect6, useRef as
|
|
2031
|
+
import React24, { useEffect as useEffect6, useRef as useRef6 } from "react";
|
|
1964
2032
|
import { createInputSchema as createInputSchema2, createOutputSchema as createOutputSchema2, GptMessage as GptMessage2 } from "@dxos/conductor";
|
|
1965
2033
|
import { S as S23 } from "@dxos/echo-schema";
|
|
1966
2034
|
import { mx as mx5 } from "@dxos/react-ui-theme";
|
|
@@ -1979,7 +2047,7 @@ var createThread = (props) => createShape({
|
|
|
1979
2047
|
});
|
|
1980
2048
|
var ThreadComponent = ({ shape }) => {
|
|
1981
2049
|
const items = [];
|
|
1982
|
-
const scrollRef =
|
|
2050
|
+
const scrollRef = useRef6(null);
|
|
1983
2051
|
useEffect6(() => {
|
|
1984
2052
|
if (scrollRef.current) {
|
|
1985
2053
|
scrollRef.current.scrollTop = scrollRef.current.scrollHeight;
|
|
@@ -2058,10 +2126,11 @@ var textToImageShape = {
|
|
|
2058
2126
|
|
|
2059
2127
|
// packages/ui/react-ui-canvas-compute/src/shapes/Trigger.tsx
|
|
2060
2128
|
import React26, { useEffect as useEffect7 } from "react";
|
|
2061
|
-
import { EmailTriggerOutput, SubscriptionTriggerOutput, TimerTriggerOutput, VoidInput as VoidInput3, WebhookTriggerOutput } from "@dxos/conductor";
|
|
2062
|
-
import { Ref, S as S25 } from "@dxos/echo-schema";
|
|
2129
|
+
import { EmailTriggerOutput, QueueTriggerOutput, SubscriptionTriggerOutput, TimerTriggerOutput, VoidInput as VoidInput3, WebhookTriggerOutput } from "@dxos/conductor";
|
|
2130
|
+
import { ObjectId as ObjectId4, Ref, S as S25 } from "@dxos/echo-schema";
|
|
2063
2131
|
import { FunctionTrigger, TriggerKind } from "@dxos/functions";
|
|
2064
|
-
import {
|
|
2132
|
+
import { DXN as DXN2, SpaceId } from "@dxos/keys";
|
|
2133
|
+
import { create, makeRef as makeRef2, useSpace } from "@dxos/react-client/echo";
|
|
2065
2134
|
import { Select as Select2 } from "@dxos/react-ui";
|
|
2066
2135
|
var TriggerShape = S25.extend(ComputeShape, S25.Struct({
|
|
2067
2136
|
type: S25.Literal("trigger"),
|
|
@@ -2070,11 +2139,11 @@ var TriggerShape = S25.extend(ComputeShape, S25.Struct({
|
|
|
2070
2139
|
var createTrigger = (props) => {
|
|
2071
2140
|
const functionTrigger = create(FunctionTrigger, {
|
|
2072
2141
|
enabled: true,
|
|
2073
|
-
spec: createTriggerSpec(props
|
|
2142
|
+
spec: createTriggerSpec(props)
|
|
2074
2143
|
});
|
|
2075
2144
|
return createShape({
|
|
2076
2145
|
type: "trigger",
|
|
2077
|
-
functionTrigger:
|
|
2146
|
+
functionTrigger: makeRef2(functionTrigger),
|
|
2078
2147
|
size: {
|
|
2079
2148
|
width: 192,
|
|
2080
2149
|
height: getHeight(EmailTriggerOutput)
|
|
@@ -2083,10 +2152,14 @@ var createTrigger = (props) => {
|
|
|
2083
2152
|
});
|
|
2084
2153
|
};
|
|
2085
2154
|
var TriggerComponent = ({ shape }) => {
|
|
2155
|
+
const space = useSpace();
|
|
2086
2156
|
const functionTrigger = shape.functionTrigger?.target;
|
|
2087
2157
|
useEffect7(() => {
|
|
2088
2158
|
if (functionTrigger && !functionTrigger.spec) {
|
|
2089
|
-
functionTrigger.spec = createTriggerSpec(
|
|
2159
|
+
functionTrigger.spec = createTriggerSpec({
|
|
2160
|
+
triggerKind: TriggerKind.Email,
|
|
2161
|
+
spaceId: space?.id
|
|
2162
|
+
});
|
|
2090
2163
|
}
|
|
2091
2164
|
}, [
|
|
2092
2165
|
functionTrigger,
|
|
@@ -2099,7 +2172,10 @@ var TriggerComponent = ({ shape }) => {
|
|
|
2099
2172
|
]);
|
|
2100
2173
|
const setKind = (kind) => {
|
|
2101
2174
|
if (functionTrigger?.spec?.type !== kind) {
|
|
2102
|
-
functionTrigger.spec = createTriggerSpec(
|
|
2175
|
+
functionTrigger.spec = createTriggerSpec({
|
|
2176
|
+
triggerKind: TriggerKind.Email,
|
|
2177
|
+
spaceId: space?.id
|
|
2178
|
+
});
|
|
2103
2179
|
}
|
|
2104
2180
|
};
|
|
2105
2181
|
if (!functionTrigger?.spec) {
|
|
@@ -2127,12 +2203,13 @@ var TriggerKindSelect = ({ value, onValueChange }) => {
|
|
|
2127
2203
|
value: type
|
|
2128
2204
|
}, type))), /* @__PURE__ */ React26.createElement(Select2.ScrollDownButton, null), /* @__PURE__ */ React26.createElement(Select2.Arrow, null))));
|
|
2129
2205
|
};
|
|
2130
|
-
var createTriggerSpec = (
|
|
2206
|
+
var createTriggerSpec = (props) => {
|
|
2207
|
+
const kind = props.triggerKind ?? TriggerKind.Email;
|
|
2131
2208
|
switch (kind) {
|
|
2132
2209
|
case TriggerKind.Timer:
|
|
2133
2210
|
return {
|
|
2134
2211
|
type: TriggerKind.Timer,
|
|
2135
|
-
cron: "
|
|
2212
|
+
cron: "*/10 * * * * *"
|
|
2136
2213
|
};
|
|
2137
2214
|
case TriggerKind.Webhook:
|
|
2138
2215
|
return {
|
|
@@ -2148,6 +2225,17 @@ var createTriggerSpec = (kind) => {
|
|
|
2148
2225
|
return {
|
|
2149
2226
|
type: TriggerKind.Email
|
|
2150
2227
|
};
|
|
2228
|
+
case TriggerKind.Queue: {
|
|
2229
|
+
const dxn = new DXN2(DXN2.kind.QUEUE, [
|
|
2230
|
+
"data",
|
|
2231
|
+
props.spaceId ?? SpaceId.random(),
|
|
2232
|
+
ObjectId4.random()
|
|
2233
|
+
]).toString();
|
|
2234
|
+
return {
|
|
2235
|
+
type: TriggerKind.Queue,
|
|
2236
|
+
queue: dxn
|
|
2237
|
+
};
|
|
2238
|
+
}
|
|
2151
2239
|
}
|
|
2152
2240
|
};
|
|
2153
2241
|
var getOutputSchema = (kind) => {
|
|
@@ -2155,7 +2243,8 @@ var getOutputSchema = (kind) => {
|
|
|
2155
2243
|
[TriggerKind.Email]: EmailTriggerOutput,
|
|
2156
2244
|
[TriggerKind.Subscription]: SubscriptionTriggerOutput,
|
|
2157
2245
|
[TriggerKind.Timer]: TimerTriggerOutput,
|
|
2158
|
-
[TriggerKind.Webhook]: WebhookTriggerOutput
|
|
2246
|
+
[TriggerKind.Webhook]: WebhookTriggerOutput,
|
|
2247
|
+
[TriggerKind.Queue]: QueueTriggerOutput
|
|
2159
2248
|
};
|
|
2160
2249
|
return kindToSchema[kind];
|
|
2161
2250
|
};
|
|
@@ -2171,7 +2260,10 @@ var triggerShape = {
|
|
|
2171
2260
|
// packages/ui/react-ui-canvas-compute/src/shapes/GptRealtime.tsx
|
|
2172
2261
|
import React27, { useState as useState8 } from "react";
|
|
2173
2262
|
import { S as S26 } from "@dxos/echo-schema";
|
|
2263
|
+
import { log as log2 } from "@dxos/log";
|
|
2264
|
+
import { useConfig } from "@dxos/react-client";
|
|
2174
2265
|
import { Icon as Icon5 } from "@dxos/react-ui";
|
|
2266
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/GptRealtime.tsx";
|
|
2175
2267
|
var GptRealtimeShape = S26.extend(ComputeShape, S26.Struct({
|
|
2176
2268
|
type: S26.Literal("gpt-realtime")
|
|
2177
2269
|
}));
|
|
@@ -2186,6 +2278,7 @@ var createGptRealtime = (props) => createShape({
|
|
|
2186
2278
|
var GptRealtimeComponent = ({ shape }) => {
|
|
2187
2279
|
const [isLive, setIsLive] = useState8(false);
|
|
2188
2280
|
const [isReady, setIsReady] = useState8(false);
|
|
2281
|
+
const config = useConfig();
|
|
2189
2282
|
const start = async () => {
|
|
2190
2283
|
setIsLive(true);
|
|
2191
2284
|
try {
|
|
@@ -2207,7 +2300,8 @@ var GptRealtimeComponent = ({ shape }) => {
|
|
|
2207
2300
|
}));
|
|
2208
2301
|
const offer = await peerConnection.createOffer();
|
|
2209
2302
|
await peerConnection.setLocalDescription(offer);
|
|
2210
|
-
const
|
|
2303
|
+
const aiServiceUrl = new URL("/rtc-connect", config.values.runtime?.services?.ai?.server ?? DEFAULT_AI_SERVICE_URL);
|
|
2304
|
+
const response = await fetch(aiServiceUrl, {
|
|
2211
2305
|
method: "POST",
|
|
2212
2306
|
body: offer.sdp,
|
|
2213
2307
|
headers: {
|
|
@@ -2221,7 +2315,12 @@ var GptRealtimeComponent = ({ shape }) => {
|
|
|
2221
2315
|
});
|
|
2222
2316
|
const dataChannel = peerConnection.createDataChannel("response");
|
|
2223
2317
|
const configureData = () => {
|
|
2224
|
-
|
|
2318
|
+
log2.info("Configuring data channel", void 0, {
|
|
2319
|
+
F: __dxlog_file7,
|
|
2320
|
+
L: 87,
|
|
2321
|
+
S: void 0,
|
|
2322
|
+
C: (f, a) => f(...a)
|
|
2323
|
+
});
|
|
2225
2324
|
const event = {
|
|
2226
2325
|
type: "session.update",
|
|
2227
2326
|
session: {
|
|
@@ -2236,7 +2335,14 @@ var GptRealtimeComponent = ({ shape }) => {
|
|
|
2236
2335
|
dataChannel.send(JSON.stringify(event));
|
|
2237
2336
|
};
|
|
2238
2337
|
dataChannel.addEventListener("open", (ev) => {
|
|
2239
|
-
|
|
2338
|
+
log2.info("Opening data channel", {
|
|
2339
|
+
ev
|
|
2340
|
+
}, {
|
|
2341
|
+
F: __dxlog_file7,
|
|
2342
|
+
L: 100,
|
|
2343
|
+
S: void 0,
|
|
2344
|
+
C: (f, a) => f(...a)
|
|
2345
|
+
});
|
|
2240
2346
|
configureData();
|
|
2241
2347
|
});
|
|
2242
2348
|
dataChannel.addEventListener("message", async (ev) => {
|
|
@@ -2245,7 +2351,14 @@ var GptRealtimeComponent = ({ shape }) => {
|
|
|
2245
2351
|
}
|
|
2246
2352
|
});
|
|
2247
2353
|
} catch (error) {
|
|
2248
|
-
|
|
2354
|
+
log2.error("Error in realtime session:", {
|
|
2355
|
+
error
|
|
2356
|
+
}, {
|
|
2357
|
+
F: __dxlog_file7,
|
|
2358
|
+
L: 140,
|
|
2359
|
+
S: void 0,
|
|
2360
|
+
C: (f, a) => f(...a)
|
|
2361
|
+
});
|
|
2249
2362
|
throw error;
|
|
2250
2363
|
}
|
|
2251
2364
|
};
|
|
@@ -2270,7 +2383,7 @@ var gptRealtimeShape = {
|
|
|
2270
2383
|
}), S26.Struct({})),
|
|
2271
2384
|
resizable: true
|
|
2272
2385
|
};
|
|
2273
|
-
var
|
|
2386
|
+
var DEFAULT_AI_SERVICE_URL = "http://localhost:8788";
|
|
2274
2387
|
|
|
2275
2388
|
// packages/ui/react-ui-canvas-compute/src/registry.ts
|
|
2276
2389
|
var computeShapes = [
|
|
@@ -2377,7 +2490,6 @@ export {
|
|
|
2377
2490
|
DatabaseComponent,
|
|
2378
2491
|
DatabaseShape,
|
|
2379
2492
|
FunctionBody,
|
|
2380
|
-
FunctionComponent,
|
|
2381
2493
|
FunctionShape,
|
|
2382
2494
|
GptComponent,
|
|
2383
2495
|
GptRealtimeComponent,
|