@dxos/react-ui-canvas-compute 0.7.5-labs.a279d8c → 0.7.5-labs.c0e040f
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 +145 -41
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +169 -66
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +145 -41
- 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 +7 -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 +20 -1
- package/dist/types/src/graph/controller.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.map +1 -1
- package/dist/types/src/shapes/GptRealtime.d.ts.map +1 -1
- package/dist/types/src/shapes/Trigger.d.ts +3 -0
- package/dist/types/src/shapes/Trigger.d.ts.map +1 -1
- package/dist/types/src/shapes/common/FunctionBody.d.ts.map +1 -1
- package/dist/types/src/shapes/common/TypeSelect.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +40 -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 +9 -1
- 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, SubscriptionTriggerOutput, TimerTriggerOutput, VoidInput as VoidInput3, WebhookTriggerOutput, QueueTriggerOutput } 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 } 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"),
|
|
@@ -2074,7 +2143,7 @@ var createTrigger = (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)
|
|
@@ -2148,6 +2217,17 @@ var createTriggerSpec = (kind) => {
|
|
|
2148
2217
|
return {
|
|
2149
2218
|
type: TriggerKind.Email
|
|
2150
2219
|
};
|
|
2220
|
+
case TriggerKind.Queue: {
|
|
2221
|
+
const dxn = new DXN2(DXN2.kind.QUEUE, [
|
|
2222
|
+
"data",
|
|
2223
|
+
SpaceId.random(),
|
|
2224
|
+
ObjectId4.random()
|
|
2225
|
+
]).toString();
|
|
2226
|
+
return {
|
|
2227
|
+
type: TriggerKind.Queue,
|
|
2228
|
+
queue: dxn
|
|
2229
|
+
};
|
|
2230
|
+
}
|
|
2151
2231
|
}
|
|
2152
2232
|
};
|
|
2153
2233
|
var getOutputSchema = (kind) => {
|
|
@@ -2155,7 +2235,8 @@ var getOutputSchema = (kind) => {
|
|
|
2155
2235
|
[TriggerKind.Email]: EmailTriggerOutput,
|
|
2156
2236
|
[TriggerKind.Subscription]: SubscriptionTriggerOutput,
|
|
2157
2237
|
[TriggerKind.Timer]: TimerTriggerOutput,
|
|
2158
|
-
[TriggerKind.Webhook]: WebhookTriggerOutput
|
|
2238
|
+
[TriggerKind.Webhook]: WebhookTriggerOutput,
|
|
2239
|
+
[TriggerKind.Queue]: QueueTriggerOutput
|
|
2159
2240
|
};
|
|
2160
2241
|
return kindToSchema[kind];
|
|
2161
2242
|
};
|
|
@@ -2171,7 +2252,10 @@ var triggerShape = {
|
|
|
2171
2252
|
// packages/ui/react-ui-canvas-compute/src/shapes/GptRealtime.tsx
|
|
2172
2253
|
import React27, { useState as useState8 } from "react";
|
|
2173
2254
|
import { S as S26 } from "@dxos/echo-schema";
|
|
2255
|
+
import { log as log2 } from "@dxos/log";
|
|
2256
|
+
import { useConfig } from "@dxos/react-client";
|
|
2174
2257
|
import { Icon as Icon5 } from "@dxos/react-ui";
|
|
2258
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shapes/GptRealtime.tsx";
|
|
2175
2259
|
var GptRealtimeShape = S26.extend(ComputeShape, S26.Struct({
|
|
2176
2260
|
type: S26.Literal("gpt-realtime")
|
|
2177
2261
|
}));
|
|
@@ -2186,6 +2270,7 @@ var createGptRealtime = (props) => createShape({
|
|
|
2186
2270
|
var GptRealtimeComponent = ({ shape }) => {
|
|
2187
2271
|
const [isLive, setIsLive] = useState8(false);
|
|
2188
2272
|
const [isReady, setIsReady] = useState8(false);
|
|
2273
|
+
const config = useConfig();
|
|
2189
2274
|
const start = async () => {
|
|
2190
2275
|
setIsLive(true);
|
|
2191
2276
|
try {
|
|
@@ -2207,7 +2292,8 @@ var GptRealtimeComponent = ({ shape }) => {
|
|
|
2207
2292
|
}));
|
|
2208
2293
|
const offer = await peerConnection.createOffer();
|
|
2209
2294
|
await peerConnection.setLocalDescription(offer);
|
|
2210
|
-
const
|
|
2295
|
+
const aiServiceUrl = new URL("/rtc-connect", config.values.runtime?.services?.ai?.server ?? DEFAULT_AI_SERVICE_URL);
|
|
2296
|
+
const response = await fetch(aiServiceUrl, {
|
|
2211
2297
|
method: "POST",
|
|
2212
2298
|
body: offer.sdp,
|
|
2213
2299
|
headers: {
|
|
@@ -2221,7 +2307,12 @@ var GptRealtimeComponent = ({ shape }) => {
|
|
|
2221
2307
|
});
|
|
2222
2308
|
const dataChannel = peerConnection.createDataChannel("response");
|
|
2223
2309
|
const configureData = () => {
|
|
2224
|
-
|
|
2310
|
+
log2.info("Configuring data channel", void 0, {
|
|
2311
|
+
F: __dxlog_file7,
|
|
2312
|
+
L: 87,
|
|
2313
|
+
S: void 0,
|
|
2314
|
+
C: (f, a) => f(...a)
|
|
2315
|
+
});
|
|
2225
2316
|
const event = {
|
|
2226
2317
|
type: "session.update",
|
|
2227
2318
|
session: {
|
|
@@ -2236,7 +2327,14 @@ var GptRealtimeComponent = ({ shape }) => {
|
|
|
2236
2327
|
dataChannel.send(JSON.stringify(event));
|
|
2237
2328
|
};
|
|
2238
2329
|
dataChannel.addEventListener("open", (ev) => {
|
|
2239
|
-
|
|
2330
|
+
log2.info("Opening data channel", {
|
|
2331
|
+
ev
|
|
2332
|
+
}, {
|
|
2333
|
+
F: __dxlog_file7,
|
|
2334
|
+
L: 100,
|
|
2335
|
+
S: void 0,
|
|
2336
|
+
C: (f, a) => f(...a)
|
|
2337
|
+
});
|
|
2240
2338
|
configureData();
|
|
2241
2339
|
});
|
|
2242
2340
|
dataChannel.addEventListener("message", async (ev) => {
|
|
@@ -2245,7 +2343,14 @@ var GptRealtimeComponent = ({ shape }) => {
|
|
|
2245
2343
|
}
|
|
2246
2344
|
});
|
|
2247
2345
|
} catch (error) {
|
|
2248
|
-
|
|
2346
|
+
log2.error("Error in realtime session:", {
|
|
2347
|
+
error
|
|
2348
|
+
}, {
|
|
2349
|
+
F: __dxlog_file7,
|
|
2350
|
+
L: 140,
|
|
2351
|
+
S: void 0,
|
|
2352
|
+
C: (f, a) => f(...a)
|
|
2353
|
+
});
|
|
2249
2354
|
throw error;
|
|
2250
2355
|
}
|
|
2251
2356
|
};
|
|
@@ -2270,7 +2375,7 @@ var gptRealtimeShape = {
|
|
|
2270
2375
|
}), S26.Struct({})),
|
|
2271
2376
|
resizable: true
|
|
2272
2377
|
};
|
|
2273
|
-
var
|
|
2378
|
+
var DEFAULT_AI_SERVICE_URL = "http://localhost:8788";
|
|
2274
2379
|
|
|
2275
2380
|
// packages/ui/react-ui-canvas-compute/src/registry.ts
|
|
2276
2381
|
var computeShapes = [
|
|
@@ -2377,7 +2482,6 @@ export {
|
|
|
2377
2482
|
DatabaseComponent,
|
|
2378
2483
|
DatabaseShape,
|
|
2379
2484
|
FunctionBody,
|
|
2380
|
-
FunctionComponent,
|
|
2381
2485
|
FunctionShape,
|
|
2382
2486
|
GptComponent,
|
|
2383
2487
|
GptRealtimeComponent,
|