@dxos/react-ui-canvas-compute 0.8.4-main.74a063c4e0 → 0.8.4-main.765dc60934
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 +83 -160
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +83 -160
- 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.map +1 -1
- package/dist/types/src/compute-layout.d.ts.map +1 -1
- package/dist/types/src/compute.stories.d.ts +1 -1
- package/dist/types/src/compute.stories.d.ts.map +1 -1
- package/dist/types/src/graph/controller.d.ts +32 -27
- 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 +2 -3
- package/dist/types/src/hooks/useComputeNodeState.d.ts.map +1 -1
- 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/Feed.d.ts +1 -1
- package/dist/types/src/shapes/Feed.d.ts.map +1 -1
- package/dist/types/src/shapes/Function.d.ts +1 -1
- package/dist/types/src/shapes/Function.d.ts.map +1 -1
- package/dist/types/src/shapes/Gpt.d.ts +1 -1
- package/dist/types/src/shapes/Gpt.d.ts.map +1 -1
- package/dist/types/src/shapes/GptRealtime.d.ts +1 -1
- package/dist/types/src/shapes/GptRealtime.d.ts.map +1 -1
- package/dist/types/src/shapes/Json.d.ts +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 +2 -2
- 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 +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/testing/circuits.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +44 -47
- package/src/compute.stories.tsx +24 -13
- package/src/graph/controller.ts +52 -24
- package/src/hooks/useComputeNodeState.ts +3 -4
- package/src/hooks/useGraphMonitor.ts +3 -3
- package/src/shapes/Function.tsx +4 -3
- package/src/shapes/Json.tsx +9 -7
- package/src/shapes/Surface.tsx +4 -1
- package/src/shapes/Thread.tsx +1 -5
- package/src/shapes/Trigger.tsx +11 -16
package/LICENSE
CHANGED
|
@@ -1,8 +1,105 @@
|
|
|
1
|
-
|
|
2
|
-
Copyright (c) 2022 DXOS
|
|
1
|
+
# Functional Source License, Version 1.1, ALv2 Future License
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
## Abbreviation
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
FSL-1.1-Apache-2.0
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 DXOS
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
### The Software
|
|
18
|
+
|
|
19
|
+
The "Software" is each version of the software that we make available under
|
|
20
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
21
|
+
Conditions with the Software.
|
|
22
|
+
|
|
23
|
+
### License Grant
|
|
24
|
+
|
|
25
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
26
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
27
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
28
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
29
|
+
|
|
30
|
+
### Permitted Purpose
|
|
31
|
+
|
|
32
|
+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
|
|
33
|
+
means making the Software available to others in a commercial product or
|
|
34
|
+
service that:
|
|
35
|
+
|
|
36
|
+
1. substitutes for the Software;
|
|
37
|
+
|
|
38
|
+
2. substitutes for any other product or service we offer using the Software
|
|
39
|
+
that exists as of the date we make the Software available; or
|
|
40
|
+
|
|
41
|
+
3. offers the same or substantially similar functionality as the Software.
|
|
42
|
+
|
|
43
|
+
Permitted Purposes specifically include using the Software:
|
|
44
|
+
|
|
45
|
+
1. for your internal use and access;
|
|
46
|
+
|
|
47
|
+
2. for non-commercial education;
|
|
48
|
+
|
|
49
|
+
3. for non-commercial research; and
|
|
50
|
+
|
|
51
|
+
4. in connection with professional services that you provide to a licensee
|
|
52
|
+
using the Software in accordance with these Terms and Conditions.
|
|
53
|
+
|
|
54
|
+
### Patents
|
|
55
|
+
|
|
56
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
57
|
+
patents, the license grant above includes a license under our patents. If you
|
|
58
|
+
make a claim against any party that the Software infringes or contributes to
|
|
59
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
60
|
+
immediately.
|
|
61
|
+
|
|
62
|
+
### Redistribution
|
|
63
|
+
|
|
64
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
65
|
+
the Software.
|
|
66
|
+
|
|
67
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
68
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
69
|
+
remove any copyright notices provided in or with the Software.
|
|
70
|
+
|
|
71
|
+
### Disclaimer
|
|
72
|
+
|
|
73
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
74
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
75
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
76
|
+
|
|
77
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
78
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
|
|
79
|
+
EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
|
|
80
|
+
|
|
81
|
+
### Trademarks
|
|
82
|
+
|
|
83
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
84
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
85
|
+
trademarks, trade names, service marks or product names.
|
|
86
|
+
|
|
87
|
+
## Grant of Future License
|
|
88
|
+
|
|
89
|
+
We hereby irrevocably grant you an additional license to use the Software under
|
|
90
|
+
the Apache License, Version 2.0 that is effective on the second anniversary of
|
|
91
|
+
the date we make the Software available. On or after that date, you may use the
|
|
92
|
+
Software under the Apache License, Version 2.0, in which case the following
|
|
93
|
+
will apply:
|
|
94
|
+
|
|
95
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
96
|
+
this file except in compliance with the License.
|
|
97
|
+
|
|
98
|
+
You may obtain a copy of the License at
|
|
99
|
+
|
|
100
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
101
|
+
|
|
102
|
+
Unless required by applicable law or agreed to in writing, software distributed
|
|
103
|
+
under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
104
|
+
CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
|
105
|
+
specific language governing permissions and limitations under the License.
|
|
@@ -7,10 +7,10 @@ import * as Exit from "effect/Exit";
|
|
|
7
7
|
import * as Layer from "effect/Layer";
|
|
8
8
|
import * as Scope from "effect/Scope";
|
|
9
9
|
import { Event, synchronized } from "@dxos/async";
|
|
10
|
-
import {
|
|
10
|
+
import { Trace } from "@dxos/compute";
|
|
11
|
+
import { ComputeBeginEvent, ComputeCustomEvent, ComputeEndEvent, ComputeInputEvent, ComputeNodeContext, ComputeOutputEvent, GraphExecutor, ValueBag, isNotExecuted } from "@dxos/conductor";
|
|
11
12
|
import { Resource } from "@dxos/context";
|
|
12
13
|
import { unwrapExit } from "@dxos/effect";
|
|
13
|
-
import { ComputeEventLogger, Trace, TracingService } from "@dxos/functions";
|
|
14
14
|
import { log } from "@dxos/log";
|
|
15
15
|
|
|
16
16
|
// src/hooks/compute-context.ts
|
|
@@ -78,28 +78,12 @@ import { invariant } from "@dxos/invariant";
|
|
|
78
78
|
var __dxlog_file = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/hooks/useComputeNodeState.ts";
|
|
79
79
|
var useComputeNodeState = (shape) => {
|
|
80
80
|
const { controller } = useComputeContext();
|
|
81
|
-
invariant(controller, void 0, {
|
|
82
|
-
F: __dxlog_file,
|
|
83
|
-
L: 33,
|
|
84
|
-
S: void 0,
|
|
85
|
-
A: [
|
|
86
|
-
"controller",
|
|
87
|
-
""
|
|
88
|
-
]
|
|
89
|
-
});
|
|
81
|
+
invariant(controller, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 12, S: void 0, A: ["controller", ""] });
|
|
90
82
|
const [meta, setMeta] = useState2();
|
|
91
83
|
useEffect2(() => {
|
|
92
84
|
let disposed = false;
|
|
93
85
|
queueMicrotask(async () => {
|
|
94
|
-
invariant(shape.node, "Node not specified", {
|
|
95
|
-
F: __dxlog_file,
|
|
96
|
-
L: 39,
|
|
97
|
-
S: void 0,
|
|
98
|
-
A: [
|
|
99
|
-
"shape.node",
|
|
100
|
-
"'Node not specified'"
|
|
101
|
-
]
|
|
102
|
-
});
|
|
86
|
+
invariant(shape.node, "Node not specified", { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 17, S: void 0, A: ["shape.node", "'Node not specified'"] });
|
|
103
87
|
const node = controller.getComputeNode(shape.node);
|
|
104
88
|
const meta2 = await controller.getMeta(node);
|
|
105
89
|
if (disposed) {
|
|
@@ -155,24 +139,8 @@ var __dxlog_file2 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/hook
|
|
|
155
139
|
var mapEdge = (graph, { source, target, output = DEFAULT_OUTPUT, input = DEFAULT_INPUT }) => {
|
|
156
140
|
const sourceNode = graph.findNode(source);
|
|
157
141
|
const targetNode = graph.findNode(target);
|
|
158
|
-
invariant2(sourceNode?.node, void 0, {
|
|
159
|
-
|
|
160
|
-
L: 25,
|
|
161
|
-
S: void 0,
|
|
162
|
-
A: [
|
|
163
|
-
"sourceNode?.node",
|
|
164
|
-
""
|
|
165
|
-
]
|
|
166
|
-
});
|
|
167
|
-
invariant2(targetNode?.node, void 0, {
|
|
168
|
-
F: __dxlog_file2,
|
|
169
|
-
L: 26,
|
|
170
|
-
S: void 0,
|
|
171
|
-
A: [
|
|
172
|
-
"targetNode?.node",
|
|
173
|
-
""
|
|
174
|
-
]
|
|
175
|
-
});
|
|
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", ""] });
|
|
176
144
|
return {
|
|
177
145
|
id: Obj.ID.random(),
|
|
178
146
|
source: sourceNode.node,
|
|
@@ -188,15 +156,7 @@ var useGraphMonitor = (model) => {
|
|
|
188
156
|
if (!model) {
|
|
189
157
|
return;
|
|
190
158
|
}
|
|
191
|
-
invariant2(node.type, void 0, {
|
|
192
|
-
F: __dxlog_file2,
|
|
193
|
-
L: 51,
|
|
194
|
-
S: void 0,
|
|
195
|
-
A: [
|
|
196
|
-
"node.type",
|
|
197
|
-
""
|
|
198
|
-
]
|
|
199
|
-
});
|
|
159
|
+
invariant2(node.type, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 37, S: void 0, A: ["node.type", ""] });
|
|
200
160
|
if (!isValidComputeNode(node.type)) {
|
|
201
161
|
return;
|
|
202
162
|
}
|
|
@@ -246,18 +206,10 @@ var createComputeGraph = (graph) => {
|
|
|
246
206
|
};
|
|
247
207
|
var linkTriggerToCompute = (graph, computeNode, triggerData) => {
|
|
248
208
|
const functionTrigger = triggerData.functionTrigger?.target;
|
|
249
|
-
invariant2(functionTrigger, void 0, {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
A: [
|
|
254
|
-
"functionTrigger",
|
|
255
|
-
""
|
|
256
|
-
]
|
|
257
|
-
});
|
|
258
|
-
Obj.change(functionTrigger, (obj) => {
|
|
259
|
-
obj.function = Ref.make(graph.root);
|
|
260
|
-
obj.inputNodeId = computeNode.id;
|
|
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;
|
|
261
213
|
});
|
|
262
214
|
};
|
|
263
215
|
var deleteTriggerObjects = (computeGraph, deleted) => {
|
|
@@ -281,15 +233,7 @@ import { invariant as invariant3 } from "@dxos/invariant";
|
|
|
281
233
|
var __dxlog_file3 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/graph/node-defs.ts";
|
|
282
234
|
var resolveComputeNode = async (node) => {
|
|
283
235
|
const impl = registry[node.type];
|
|
284
|
-
invariant3(impl, `Unknown node type: ${node.type}`, {
|
|
285
|
-
F: __dxlog_file3,
|
|
286
|
-
L: 22,
|
|
287
|
-
S: void 0,
|
|
288
|
-
A: [
|
|
289
|
-
"impl",
|
|
290
|
-
"`Unknown node type: ${node.type}`"
|
|
291
|
-
]
|
|
292
|
-
});
|
|
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}`"] });
|
|
293
237
|
return impl;
|
|
294
238
|
};
|
|
295
239
|
var isValidComputeNode = (type) => {
|
|
@@ -350,13 +294,13 @@ var createNode = (type, props) => ({
|
|
|
350
294
|
});
|
|
351
295
|
|
|
352
296
|
// src/graph/controller.ts
|
|
297
|
+
var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/graph/controller.ts";
|
|
353
298
|
function _ts_decorate(decorators, target, key, desc) {
|
|
354
299
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
355
300
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
356
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;
|
|
357
302
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
358
303
|
}
|
|
359
|
-
var __dxlog_file4 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/graph/controller.ts";
|
|
360
304
|
var InvalidStateError = Error;
|
|
361
305
|
var AUTO_TRIGGER_NODES = [
|
|
362
306
|
"chat",
|
|
@@ -461,12 +405,7 @@ var ComputeGraphController = class extends Resource {
|
|
|
461
405
|
try {
|
|
462
406
|
await this.exec(nodeId);
|
|
463
407
|
} catch (err) {
|
|
464
|
-
log.catch(err, void 0, {
|
|
465
|
-
F: __dxlog_file4,
|
|
466
|
-
L: 230,
|
|
467
|
-
S: this,
|
|
468
|
-
C: (f, a) => f(...a)
|
|
469
|
-
});
|
|
408
|
+
log.catch(err, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 128, S: this });
|
|
470
409
|
}
|
|
471
410
|
});
|
|
472
411
|
}
|
|
@@ -489,7 +428,7 @@ var ComputeGraphController = class extends Resource {
|
|
|
489
428
|
const scope = yield* Scope.make();
|
|
490
429
|
const executable = yield* Effect.promise(() => resolveComputeNode(this._graph.getNode(nodeId)));
|
|
491
430
|
const computingOutputs = executable.exec != null;
|
|
492
|
-
const effect = (computingOutputs ? executor.computeOutputs(nodeId) : executor.computeInputs(nodeId)).pipe(Effect.withSpan("runGraph"), Scope.extend(scope), Effect.provide(
|
|
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) => {
|
|
493
432
|
for (const [key, value] of Object.entries(values)) {
|
|
494
433
|
if (computingOutputs) {
|
|
495
434
|
this._onOutputComputed(nodeId, key, value);
|
|
@@ -527,7 +466,7 @@ var ComputeGraphController = class extends Resource {
|
|
|
527
466
|
for (const node of allAffectedNodes) {
|
|
528
467
|
const executable = yield* Effect.promise(() => resolveComputeNode(this._graph.getNode(node)));
|
|
529
468
|
const computingOutputs = executable.exec != null;
|
|
530
|
-
const effect = (computingOutputs ? executor.computeOutputs(node) : executor.computeInputs(node)).pipe(Effect.withSpan("runGraph"), Scope.extend(scope), Effect.flatMap(computeValueBag), Effect.provide(
|
|
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) => {
|
|
531
470
|
for (const [key, value] of Object.entries(values)) {
|
|
532
471
|
if (computingOutputs) {
|
|
533
472
|
this._onOutputComputed(node, key, value);
|
|
@@ -543,23 +482,20 @@ var ComputeGraphController = class extends Resource {
|
|
|
543
482
|
})));
|
|
544
483
|
this.update.emit();
|
|
545
484
|
}
|
|
546
|
-
|
|
485
|
+
_createTraceWriter() {
|
|
547
486
|
return {
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
487
|
+
write: (eventType, payload) => {
|
|
488
|
+
const event = traceEventToComputeEvent(eventType.key, payload);
|
|
489
|
+
if (event) {
|
|
490
|
+
this._handleEvent(event);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
552
493
|
};
|
|
553
494
|
}
|
|
554
495
|
_handleEvent(event) {
|
|
555
496
|
log("handleEvent", {
|
|
556
497
|
event
|
|
557
|
-
}, {
|
|
558
|
-
F: __dxlog_file4,
|
|
559
|
-
L: 379,
|
|
560
|
-
S: this,
|
|
561
|
-
C: (f, a) => f(...a)
|
|
562
|
-
});
|
|
498
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file4, L: 223, S: this });
|
|
563
499
|
switch (event.type) {
|
|
564
500
|
case "compute-input": {
|
|
565
501
|
this._onInputComputed(event.nodeId, event.property, {
|
|
@@ -598,6 +534,37 @@ _ts_decorate([
|
|
|
598
534
|
_ts_decorate([
|
|
599
535
|
synchronized
|
|
600
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
|
+
};
|
|
601
568
|
var computeValueBag = (bag) => {
|
|
602
569
|
return Effect.all(Object.entries(bag.values).map(([key, eff]) => Effect.either(eff).pipe(Effect.map((value) => {
|
|
603
570
|
if (Either.isLeft(value)) {
|
|
@@ -642,15 +609,7 @@ var __dxlog_file5 = "/__w/dxos/dxos/packages/ui/react-ui-canvas-compute/src/shap
|
|
|
642
609
|
var headerHeight = 32;
|
|
643
610
|
var footerHeight = 32;
|
|
644
611
|
var Box = /* @__PURE__ */ forwardRef(({ children, classNames, shape, title, status, open, onAction }, forwardedRef) => {
|
|
645
|
-
invariant4(shape.type, void 0, {
|
|
646
|
-
F: __dxlog_file5,
|
|
647
|
-
L: 29,
|
|
648
|
-
S: void 0,
|
|
649
|
-
A: [
|
|
650
|
-
"shape.type",
|
|
651
|
-
""
|
|
652
|
-
]
|
|
653
|
-
});
|
|
612
|
+
invariant4(shape.type, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file5, L: 12, S: void 0, A: ["shape.type", ""] });
|
|
654
613
|
const { icon, name, openable } = useShapeDef(shape.type) ?? {
|
|
655
614
|
icon: "ph--placeholder--regular"
|
|
656
615
|
};
|
|
@@ -1418,12 +1377,13 @@ var feedShape = {
|
|
|
1418
1377
|
// src/shapes/Function.tsx
|
|
1419
1378
|
import * as Schema12 from "effect/Schema";
|
|
1420
1379
|
import React13, { useCallback as useCallback3, useRef as useRef4 } from "react";
|
|
1380
|
+
import { Script } from "@dxos/compute";
|
|
1381
|
+
import { Operation } from "@dxos/compute";
|
|
1421
1382
|
import { AnyOutput, FunctionInput } from "@dxos/conductor";
|
|
1383
|
+
import { Filter } from "@dxos/echo";
|
|
1422
1384
|
import { Ref as Ref2, getSnapshot, isInstanceOf } from "@dxos/echo/internal";
|
|
1423
|
-
import {
|
|
1424
|
-
import { Operation } from "@dxos/operation";
|
|
1385
|
+
import { parseId } from "@dxos/keys";
|
|
1425
1386
|
import { useClient } from "@dxos/react-client";
|
|
1426
|
-
import { Filter, parseId } from "@dxos/react-client/echo";
|
|
1427
1387
|
import { TextBox as TextBox3 } from "@dxos/react-ui-canvas-editor";
|
|
1428
1388
|
var FunctionShape = Schema12.extend(ComputeShape, Schema12.Struct({
|
|
1429
1389
|
type: Schema12.Literal("function")
|
|
@@ -1625,12 +1585,7 @@ var GptRealtimeComponent = ({ shape }) => {
|
|
|
1625
1585
|
});
|
|
1626
1586
|
const dataChannel = peerConnection.createDataChannel("response");
|
|
1627
1587
|
const configureData = () => {
|
|
1628
|
-
log2.info("Configuring data channel", void 0, {
|
|
1629
|
-
F: __dxlog_file6,
|
|
1630
|
-
L: 87,
|
|
1631
|
-
S: void 0,
|
|
1632
|
-
C: (f, a) => f(...a)
|
|
1633
|
-
});
|
|
1588
|
+
log2.info("Configuring data channel", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 69, S: void 0 });
|
|
1634
1589
|
const event = {
|
|
1635
1590
|
type: "session.update",
|
|
1636
1591
|
session: {
|
|
@@ -1647,12 +1602,7 @@ var GptRealtimeComponent = ({ shape }) => {
|
|
|
1647
1602
|
dataChannel.addEventListener("open", (ev) => {
|
|
1648
1603
|
log2.info("Opening data channel", {
|
|
1649
1604
|
ev
|
|
1650
|
-
}, {
|
|
1651
|
-
F: __dxlog_file6,
|
|
1652
|
-
L: 100,
|
|
1653
|
-
S: void 0,
|
|
1654
|
-
C: (f, a) => f(...a)
|
|
1655
|
-
});
|
|
1605
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 84, S: void 0 });
|
|
1656
1606
|
configureData();
|
|
1657
1607
|
});
|
|
1658
1608
|
dataChannel.addEventListener("message", async (ev) => {
|
|
@@ -1663,12 +1613,7 @@ var GptRealtimeComponent = ({ shape }) => {
|
|
|
1663
1613
|
} catch (error) {
|
|
1664
1614
|
log2.error("Error in realtime session:", {
|
|
1665
1615
|
error
|
|
1666
|
-
}, {
|
|
1667
|
-
F: __dxlog_file6,
|
|
1668
|
-
L: 140,
|
|
1669
|
-
S: void 0,
|
|
1670
|
-
C: (f, a) => f(...a)
|
|
1671
|
-
});
|
|
1616
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file6, L: 124, S: void 0 });
|
|
1672
1617
|
throw error;
|
|
1673
1618
|
}
|
|
1674
1619
|
};
|
|
@@ -1700,7 +1645,7 @@ import * as Schema15 from "effect/Schema";
|
|
|
1700
1645
|
import React16 from "react";
|
|
1701
1646
|
import { DEFAULT_INPUT as DEFAULT_INPUT4, DefaultOutput, JsonTransformInput } from "@dxos/conductor";
|
|
1702
1647
|
import { createAnchorMap as createAnchorMap6 } from "@dxos/react-ui-canvas-editor";
|
|
1703
|
-
import {
|
|
1648
|
+
import { Syntax } from "@dxos/react-ui-syntax-highlighter";
|
|
1704
1649
|
var JsonShape = Schema15.extend(ComputeShape, Schema15.Struct({
|
|
1705
1650
|
type: Schema15.Literal("json")
|
|
1706
1651
|
}));
|
|
@@ -1713,11 +1658,11 @@ var JsonComponent = ({ shape, ...props }) => {
|
|
|
1713
1658
|
const value = input?.type === "executed" ? input.value : void 0;
|
|
1714
1659
|
return /* @__PURE__ */ React16.createElement(Box, {
|
|
1715
1660
|
shape
|
|
1716
|
-
}, /* @__PURE__ */ React16.createElement(
|
|
1661
|
+
}, /* @__PURE__ */ React16.createElement(Syntax.Root, {
|
|
1717
1662
|
data: value
|
|
1718
|
-
}, /* @__PURE__ */ React16.createElement(
|
|
1663
|
+
}, /* @__PURE__ */ React16.createElement(Syntax.Content, null, /* @__PURE__ */ React16.createElement(Syntax.Filter, null), /* @__PURE__ */ React16.createElement(Syntax.Viewport, null, /* @__PURE__ */ React16.createElement(Syntax.Code, {
|
|
1719
1664
|
classNames: "text-xs"
|
|
1720
|
-
}))));
|
|
1665
|
+
})))));
|
|
1721
1666
|
};
|
|
1722
1667
|
var JsonTransformComponent = ({ shape, ...props }) => {
|
|
1723
1668
|
return /* @__PURE__ */ React16.createElement(Box, {
|
|
@@ -1952,6 +1897,7 @@ var scopeShape = {
|
|
|
1952
1897
|
import * as Schema19 from "effect/Schema";
|
|
1953
1898
|
import React20 from "react";
|
|
1954
1899
|
import { Surface } from "@dxos/app-framework/ui";
|
|
1900
|
+
import { AppSurface } from "@dxos/app-toolkit/ui";
|
|
1955
1901
|
import { DEFAULT_INPUT as DEFAULT_INPUT6 } from "@dxos/conductor";
|
|
1956
1902
|
import { Card } from "@dxos/react-ui";
|
|
1957
1903
|
import { createAnchorMap as createAnchorMap9 } from "@dxos/react-ui-canvas-editor";
|
|
@@ -1979,9 +1925,9 @@ var SurfaceComponent = ({ shape }) => {
|
|
|
1979
1925
|
shape,
|
|
1980
1926
|
onAction: handleAction
|
|
1981
1927
|
}, /* @__PURE__ */ React20.createElement(Card.Root, null, value !== null && /* @__PURE__ */ React20.createElement(Surface.Surface, {
|
|
1982
|
-
|
|
1928
|
+
type: AppSurface.Card,
|
|
1983
1929
|
data: {
|
|
1984
|
-
value
|
|
1930
|
+
subject: value
|
|
1985
1931
|
},
|
|
1986
1932
|
limit: 1
|
|
1987
1933
|
})));
|
|
@@ -2105,15 +2051,7 @@ var TextInputComponent3 = ({ shape, title, ...props }) => {
|
|
|
2105
2051
|
}
|
|
2106
2052
|
};
|
|
2107
2053
|
const handleTypeChange = (newType) => {
|
|
2108
|
-
invariant5(Schema22.is(ComputeValueType3)(newType), "Invalid type", {
|
|
2109
|
-
F: __dxlog_file7,
|
|
2110
|
-
L: 58,
|
|
2111
|
-
S: void 0,
|
|
2112
|
-
A: [
|
|
2113
|
-
"Schema.is(ComputeValueType)(newType)",
|
|
2114
|
-
"'Invalid type'"
|
|
2115
|
-
]
|
|
2116
|
-
});
|
|
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'"] });
|
|
2117
2055
|
node.valueType = newType;
|
|
2118
2056
|
node.inputSchema = toJsonSchema(getTemplateInputSchema2(node));
|
|
2119
2057
|
};
|
|
@@ -2249,7 +2187,6 @@ var ThreadComponent = ({ shape }) => {
|
|
|
2249
2187
|
var ThreadItem = ({ classNames, item }) => {
|
|
2250
2188
|
if (typeof item !== "object") {
|
|
2251
2189
|
return /* @__PURE__ */ React25.createElement("div", {
|
|
2252
|
-
role: "none",
|
|
2253
2190
|
className: mx3(classNames)
|
|
2254
2191
|
}, item);
|
|
2255
2192
|
}
|
|
@@ -2307,11 +2244,11 @@ var textToImageShape = {
|
|
|
2307
2244
|
// src/shapes/Trigger.tsx
|
|
2308
2245
|
import * as Schema26 from "effect/Schema";
|
|
2309
2246
|
import React27, { useEffect as useEffect8 } from "react";
|
|
2247
|
+
import { Trigger, TriggerEvent } from "@dxos/compute";
|
|
2310
2248
|
import { VoidInput as VoidInput3 } from "@dxos/conductor";
|
|
2311
2249
|
import { Filter as Filter2, Obj as Obj4, Query, Ref as Ref3 } from "@dxos/echo";
|
|
2312
|
-
import { Trigger, TriggerEvent } from "@dxos/functions";
|
|
2313
2250
|
import { DXN, SpaceId } from "@dxos/keys";
|
|
2314
|
-
import {
|
|
2251
|
+
import { useSpaces } from "@dxos/react-client/echo";
|
|
2315
2252
|
import { Select as Select2 } from "@dxos/react-ui";
|
|
2316
2253
|
var TriggerShape = Schema26.extend(ComputeShape, Schema26.Struct({
|
|
2317
2254
|
type: Schema26.Literal("trigger"),
|
|
@@ -2333,12 +2270,12 @@ var createTrigger = (props) => {
|
|
|
2333
2270
|
});
|
|
2334
2271
|
};
|
|
2335
2272
|
var TriggerComponent = ({ shape }) => {
|
|
2336
|
-
const space =
|
|
2273
|
+
const [space] = useSpaces();
|
|
2337
2274
|
const functionTrigger = shape.functionTrigger?.target;
|
|
2338
2275
|
useEffect8(() => {
|
|
2339
2276
|
if (functionTrigger && !functionTrigger.spec) {
|
|
2340
|
-
Obj4.
|
|
2341
|
-
|
|
2277
|
+
Obj4.update(functionTrigger, (functionTrigger2) => {
|
|
2278
|
+
functionTrigger2.spec = createTriggerSpec({
|
|
2342
2279
|
triggerKind: "email",
|
|
2343
2280
|
spaceId: space?.id
|
|
2344
2281
|
});
|
|
@@ -2355,7 +2292,7 @@ var TriggerComponent = ({ shape }) => {
|
|
|
2355
2292
|
]);
|
|
2356
2293
|
const setKind = (kind) => {
|
|
2357
2294
|
if (functionTrigger?.spec?.kind !== kind) {
|
|
2358
|
-
Obj4.
|
|
2295
|
+
Obj4.update(functionTrigger, (obj) => {
|
|
2359
2296
|
obj.spec = createTriggerSpec({
|
|
2360
2297
|
triggerKind: kind,
|
|
2361
2298
|
spaceId: space?.id
|
|
@@ -2392,36 +2329,22 @@ var createTriggerSpec = (props) => {
|
|
|
2392
2329
|
const kind = props.triggerKind ?? "email";
|
|
2393
2330
|
switch (kind) {
|
|
2394
2331
|
case "timer":
|
|
2395
|
-
return
|
|
2396
|
-
kind: "timer",
|
|
2397
|
-
cron: "*/10 * * * * *"
|
|
2398
|
-
};
|
|
2332
|
+
return Trigger.specTimer("*/10 * * * * *");
|
|
2399
2333
|
case "webhook":
|
|
2400
|
-
return {
|
|
2401
|
-
kind: "webhook",
|
|
2334
|
+
return Trigger.specWebhook({
|
|
2402
2335
|
method: "POST"
|
|
2403
|
-
};
|
|
2336
|
+
});
|
|
2404
2337
|
case "subscription":
|
|
2405
|
-
return
|
|
2406
|
-
kind: "subscription",
|
|
2407
|
-
query: {
|
|
2408
|
-
ast: Query.select(Filter2.nothing()).ast
|
|
2409
|
-
}
|
|
2410
|
-
};
|
|
2338
|
+
return Trigger.specSubscription(Query.select(Filter2.nothing()));
|
|
2411
2339
|
case "email":
|
|
2412
|
-
return
|
|
2413
|
-
kind: "email"
|
|
2414
|
-
};
|
|
2340
|
+
return Trigger.specEmail();
|
|
2415
2341
|
case "queue": {
|
|
2416
2342
|
const dxn = new DXN(DXN.kind.QUEUE, [
|
|
2417
2343
|
"data",
|
|
2418
2344
|
props.spaceId ?? SpaceId.random(),
|
|
2419
2345
|
Obj4.ID.random()
|
|
2420
2346
|
]).toString();
|
|
2421
|
-
return
|
|
2422
|
-
kind: "queue",
|
|
2423
|
-
queue: dxn
|
|
2424
|
-
};
|
|
2347
|
+
return Trigger.specQueue(dxn);
|
|
2425
2348
|
}
|
|
2426
2349
|
}
|
|
2427
2350
|
};
|