@dxos/react-ui-canvas-compute 0.8.4-main.9be5663bfe → 0.8.4-main.abd8ff62ef
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 +76 -153
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +76 -153
- 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 +43 -46
- 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 +1 -1
- package/src/shapes/Function.tsx +2 -2
- package/src/shapes/Json.tsx +9 -7
- package/src/shapes/Surface.tsx +4 -1
- package/src/shapes/Trigger.tsx +8 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/react-ui-canvas-compute",
|
|
3
|
-
"version": "0.8.4-main.
|
|
3
|
+
"version": "0.8.4-main.abd8ff62ef",
|
|
4
4
|
"description": "A compute graph extension for the canvas editor component.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -20,9 +20,6 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"types": "dist/types/src/index.d.ts",
|
|
23
|
-
"typesVersions": {
|
|
24
|
-
"*": {}
|
|
25
|
-
},
|
|
26
23
|
"files": [
|
|
27
24
|
"dist",
|
|
28
25
|
"src"
|
|
@@ -32,38 +29,39 @@
|
|
|
32
29
|
"@antv/layout": "^1.2.13",
|
|
33
30
|
"@effect/platform": "0.94.4",
|
|
34
31
|
"chess.js": "^1.0.0",
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/app-framework": "0.8.4-main.
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/echo": "0.8.4-main.
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/invariant": "0.8.4-main.
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/react-ui-
|
|
55
|
-
"@dxos/react-
|
|
56
|
-
"@dxos/react-ui-
|
|
57
|
-
"@dxos/react-ui-
|
|
58
|
-
"@dxos/react-ui-
|
|
59
|
-
"@dxos/react-ui-form": "0.8.4-main.
|
|
60
|
-
"@dxos/react-
|
|
61
|
-
"@dxos/react-ui-
|
|
62
|
-
"@dxos/react-
|
|
63
|
-
"@dxos/
|
|
64
|
-
"@dxos/
|
|
65
|
-
"@dxos/
|
|
66
|
-
"@dxos/
|
|
32
|
+
"@dxos/ai": "0.8.4-main.abd8ff62ef",
|
|
33
|
+
"@dxos/app-framework": "0.8.4-main.abd8ff62ef",
|
|
34
|
+
"@dxos/app-toolkit": "0.8.4-main.abd8ff62ef",
|
|
35
|
+
"@dxos/assistant": "0.8.4-main.abd8ff62ef",
|
|
36
|
+
"@dxos/async": "0.8.4-main.abd8ff62ef",
|
|
37
|
+
"@dxos/compute": "0.8.4-main.abd8ff62ef",
|
|
38
|
+
"@dxos/conductor": "0.8.4-main.abd8ff62ef",
|
|
39
|
+
"@dxos/echo": "0.8.4-main.abd8ff62ef",
|
|
40
|
+
"@dxos/debug": "0.8.4-main.abd8ff62ef",
|
|
41
|
+
"@dxos/context": "0.8.4-main.abd8ff62ef",
|
|
42
|
+
"@dxos/effect": "0.8.4-main.abd8ff62ef",
|
|
43
|
+
"@dxos/echo-db": "0.8.4-main.abd8ff62ef",
|
|
44
|
+
"@dxos/edge-client": "0.8.4-main.abd8ff62ef",
|
|
45
|
+
"@dxos/functions-runtime": "0.8.4-main.abd8ff62ef",
|
|
46
|
+
"@dxos/functions": "0.8.4-main.abd8ff62ef",
|
|
47
|
+
"@dxos/invariant": "0.8.4-main.abd8ff62ef",
|
|
48
|
+
"@dxos/graph": "0.8.4-main.abd8ff62ef",
|
|
49
|
+
"@dxos/log": "0.8.4-main.abd8ff62ef",
|
|
50
|
+
"@dxos/keys": "0.8.4-main.abd8ff62ef",
|
|
51
|
+
"@dxos/react-ui-attention": "0.8.4-main.abd8ff62ef",
|
|
52
|
+
"@dxos/react-client": "0.8.4-main.abd8ff62ef",
|
|
53
|
+
"@dxos/react-ui-canvas": "0.8.4-main.abd8ff62ef",
|
|
54
|
+
"@dxos/react-ui-canvas-editor": "0.8.4-main.abd8ff62ef",
|
|
55
|
+
"@dxos/react-ui-editor": "0.8.4-main.abd8ff62ef",
|
|
56
|
+
"@dxos/react-ui-form": "0.8.4-main.abd8ff62ef",
|
|
57
|
+
"@dxos/react-ui-mosaic": "0.8.4-main.abd8ff62ef",
|
|
58
|
+
"@dxos/react-ui-sfx": "0.8.4-main.abd8ff62ef",
|
|
59
|
+
"@dxos/react-edge-client": "0.8.4-main.abd8ff62ef",
|
|
60
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.abd8ff62ef",
|
|
61
|
+
"@dxos/types": "0.8.4-main.abd8ff62ef",
|
|
62
|
+
"@dxos/util": "0.8.4-main.abd8ff62ef",
|
|
63
|
+
"@dxos/schema": "0.8.4-main.abd8ff62ef",
|
|
64
|
+
"@dxos/react-ui-stack": "0.8.4-main.abd8ff62ef"
|
|
67
65
|
},
|
|
68
66
|
"devDependencies": {
|
|
69
67
|
"@effect/ai": "0.33.2",
|
|
@@ -75,21 +73,20 @@
|
|
|
75
73
|
"lodash.defaultsdeep": "^4.6.1",
|
|
76
74
|
"react": "~19.2.3",
|
|
77
75
|
"react-dom": "~19.2.3",
|
|
78
|
-
"vite": "^
|
|
79
|
-
"@dxos/app-framework": "0.8.4-main.
|
|
80
|
-
"@dxos/assistant-toolkit": "0.8.4-main.
|
|
81
|
-
"@dxos/random": "0.8.4-main.
|
|
82
|
-
"@dxos/
|
|
83
|
-
"@dxos/
|
|
84
|
-
"@dxos/ui-theme": "0.8.4-main.
|
|
85
|
-
"@dxos/storybook-utils": "0.8.4-main.9be5663bfe"
|
|
76
|
+
"vite": "^8.0.10",
|
|
77
|
+
"@dxos/app-framework": "0.8.4-main.abd8ff62ef",
|
|
78
|
+
"@dxos/assistant-toolkit": "0.8.4-main.abd8ff62ef",
|
|
79
|
+
"@dxos/random": "0.8.4-main.abd8ff62ef",
|
|
80
|
+
"@dxos/react-ui": "0.8.4-main.abd8ff62ef",
|
|
81
|
+
"@dxos/storybook-utils": "0.8.4-main.abd8ff62ef",
|
|
82
|
+
"@dxos/ui-theme": "0.8.4-main.abd8ff62ef"
|
|
86
83
|
},
|
|
87
84
|
"peerDependencies": {
|
|
88
85
|
"effect": "3.20.0",
|
|
89
86
|
"react": "~19.2.3",
|
|
90
87
|
"react-dom": "~19.2.3",
|
|
91
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
92
|
-
"@dxos/ui-theme": "0.8.4-main.
|
|
88
|
+
"@dxos/react-ui": "0.8.4-main.abd8ff62ef",
|
|
89
|
+
"@dxos/ui-theme": "0.8.4-main.abd8ff62ef"
|
|
93
90
|
},
|
|
94
91
|
"publishConfig": {
|
|
95
92
|
"access": "public"
|
package/src/compute.stories.tsx
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
6
7
|
import * as Layer from 'effect/Layer';
|
|
7
8
|
import * as ManagedRuntime from 'effect/ManagedRuntime';
|
|
8
9
|
import React, { type PropsWithChildren, useEffect, useMemo, useRef, useState } from 'react';
|
|
@@ -10,18 +11,18 @@ import React, { type PropsWithChildren, useEffect, useMemo, useRef, useState } f
|
|
|
10
11
|
import { AiServiceTestingPreset } from '@dxos/ai/testing';
|
|
11
12
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
12
13
|
import { capabilities } from '@dxos/assistant-toolkit/testing';
|
|
14
|
+
import { Operation, OperationRegistry } from '@dxos/compute';
|
|
13
15
|
import { type ComputeGraphModel, type ComputeNode, type GraphDiagnostic } from '@dxos/conductor';
|
|
14
16
|
import { Feed } from '@dxos/echo';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import { TestDatabaseLayer } from '@dxos/functions-runtime/testing';
|
|
17
|
+
import { TestDatabaseLayer } from '@dxos/echo-db/testing';
|
|
18
|
+
import { configuredCredentialsLayer } from '@dxos/functions';
|
|
18
19
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
19
20
|
import { Select, Toolbar } from '@dxos/react-ui';
|
|
20
21
|
import { withAttention } from '@dxos/react-ui-attention/testing';
|
|
21
22
|
import { Editor, type EditorController, type EditorRootProps, ShapeRegistry } from '@dxos/react-ui-canvas-editor';
|
|
22
23
|
import { Container, useSelection } from '@dxos/react-ui-canvas-editor/testing';
|
|
23
24
|
import { Form } from '@dxos/react-ui-form';
|
|
24
|
-
import {
|
|
25
|
+
import { Syntax } from '@dxos/react-ui-syntax-highlighter';
|
|
25
26
|
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
26
27
|
|
|
27
28
|
import { DiagnosticOverlay } from './components';
|
|
@@ -178,12 +179,14 @@ const DefaultStory = ({
|
|
|
178
179
|
</Form.Viewport>
|
|
179
180
|
</Form.Root>
|
|
180
181
|
)}
|
|
181
|
-
<
|
|
182
|
-
<
|
|
183
|
-
<
|
|
184
|
-
<
|
|
185
|
-
|
|
186
|
-
|
|
182
|
+
<Syntax.Root data={json}>
|
|
183
|
+
<Syntax.Content>
|
|
184
|
+
<Syntax.Filter />
|
|
185
|
+
<Syntax.Viewport>
|
|
186
|
+
<Syntax.Code />
|
|
187
|
+
</Syntax.Viewport>
|
|
188
|
+
</Syntax.Content>
|
|
189
|
+
</Syntax.Root>
|
|
187
190
|
</div>
|
|
188
191
|
</Container>
|
|
189
192
|
)}
|
|
@@ -221,13 +224,21 @@ export default meta;
|
|
|
221
224
|
type Story = StoryObj<typeof meta>;
|
|
222
225
|
|
|
223
226
|
const ServiceLayer = Layer.empty.pipe(
|
|
224
|
-
Layer.provideMerge(
|
|
227
|
+
Layer.provideMerge(
|
|
228
|
+
Layer.mergeAll(
|
|
229
|
+
Layer.succeed(Operation.Service, {
|
|
230
|
+
invoke: () => Effect.die('Operation.Service not available in test.'),
|
|
231
|
+
schedule: () => Effect.die('Operation.Service not available in test.'),
|
|
232
|
+
invokePromise: async () => ({ error: new Error('Not available') }),
|
|
233
|
+
} as any),
|
|
234
|
+
Layer.succeed(OperationRegistry.Service, { resolve: () => Effect.succeed(undefined) } as any),
|
|
235
|
+
),
|
|
236
|
+
),
|
|
225
237
|
Layer.provideMerge(
|
|
226
238
|
Layer.mergeAll(
|
|
227
239
|
AiServiceTestingPreset('direct'),
|
|
228
240
|
TestDatabaseLayer(),
|
|
229
|
-
|
|
230
|
-
TracingService.layerNoop,
|
|
241
|
+
configuredCredentialsLayer([]),
|
|
231
242
|
Feed.notAvailable,
|
|
232
243
|
),
|
|
233
244
|
),
|
package/src/graph/controller.ts
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import type * as Context from 'effect/Context';
|
|
6
5
|
import * as Effect from 'effect/Effect';
|
|
7
6
|
import * as Either from 'effect/Either';
|
|
8
7
|
import * as Exit from 'effect/Exit';
|
|
@@ -12,7 +11,14 @@ import * as Scope from 'effect/Scope';
|
|
|
12
11
|
|
|
13
12
|
import type { AiService } from '@dxos/ai';
|
|
14
13
|
import { Event, synchronized } from '@dxos/async';
|
|
14
|
+
import { type Credential, type Operation, type OperationRegistry, Trace } from '@dxos/compute';
|
|
15
15
|
import {
|
|
16
|
+
ComputeBeginEvent,
|
|
17
|
+
ComputeCustomEvent,
|
|
18
|
+
ComputeEndEvent,
|
|
19
|
+
ComputeInputEvent,
|
|
20
|
+
ComputeNodeContext,
|
|
21
|
+
ComputeOutputEvent,
|
|
16
22
|
type ComputeEdge,
|
|
17
23
|
type ComputeGraphModel,
|
|
18
24
|
type ComputeNode,
|
|
@@ -27,15 +33,7 @@ import {
|
|
|
27
33
|
import { Resource } from '@dxos/context';
|
|
28
34
|
import type { Database, Feed } from '@dxos/echo';
|
|
29
35
|
import { unwrapExit } from '@dxos/effect';
|
|
30
|
-
import {
|
|
31
|
-
ComputeEventLogger,
|
|
32
|
-
type ComputeEventPayload,
|
|
33
|
-
type CredentialsService,
|
|
34
|
-
type FunctionInvocationService,
|
|
35
|
-
type QueueService,
|
|
36
|
-
Trace,
|
|
37
|
-
TracingService,
|
|
38
|
-
} from '@dxos/functions';
|
|
36
|
+
import { type QueueService } from '@dxos/functions';
|
|
39
37
|
import { log } from '@dxos/log';
|
|
40
38
|
import { type CanvasGraphModel } from '@dxos/react-ui-canvas-editor';
|
|
41
39
|
import { type ContentBlock } from '@dxos/types';
|
|
@@ -83,14 +81,25 @@ type ComputeOutputEvent = {
|
|
|
83
81
|
value: RuntimeValue;
|
|
84
82
|
};
|
|
85
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Event emitted by the compute graph during execution.
|
|
86
|
+
*/
|
|
87
|
+
export type ComputeEvent =
|
|
88
|
+
| { type: 'begin-compute'; nodeId: string; inputs: ReadonlyArray<string> }
|
|
89
|
+
| { type: 'end-compute'; nodeId: string; outputs: ReadonlyArray<string> }
|
|
90
|
+
| { type: 'compute-input'; nodeId: string; property: string; value: any }
|
|
91
|
+
| { type: 'compute-output'; nodeId: string; property: string; value: any }
|
|
92
|
+
| { type: 'custom'; nodeId: string; event: any };
|
|
93
|
+
|
|
86
94
|
// TODO(dmaretskyi): Re-use function servies definition.
|
|
87
95
|
export type ComputeServices =
|
|
88
96
|
| AiService.AiService
|
|
89
97
|
| Database.Service
|
|
90
98
|
| Feed.FeedService
|
|
91
99
|
| QueueService
|
|
92
|
-
| CredentialsService
|
|
93
|
-
|
|
|
100
|
+
| Credential.CredentialsService
|
|
101
|
+
| Operation.Service
|
|
102
|
+
| OperationRegistry.Service;
|
|
94
103
|
|
|
95
104
|
/**
|
|
96
105
|
* Nodes that will automatically trigger the execution of the graph on startup.
|
|
@@ -134,7 +143,7 @@ export class ComputeGraphController extends Resource {
|
|
|
134
143
|
/** Computed result. */
|
|
135
144
|
public readonly output = new Event<ComputeOutputEvent>();
|
|
136
145
|
|
|
137
|
-
public readonly events = new Event<
|
|
146
|
+
public readonly events = new Event<ComputeEvent>();
|
|
138
147
|
|
|
139
148
|
constructor(
|
|
140
149
|
private readonly _computeRuntime: ManagedRuntime.ManagedRuntime<ComputeServices, never>,
|
|
@@ -265,9 +274,9 @@ export class ComputeGraphController extends Resource {
|
|
|
265
274
|
Effect.withSpan('runGraph'),
|
|
266
275
|
Scope.extend(scope),
|
|
267
276
|
Effect.provide(
|
|
268
|
-
|
|
269
|
-
Layer.
|
|
270
|
-
|
|
277
|
+
Layer.mergeAll(
|
|
278
|
+
Layer.succeed(Trace.TraceService, this._createTraceWriter()),
|
|
279
|
+
ComputeNodeContext.layerNoop,
|
|
271
280
|
),
|
|
272
281
|
),
|
|
273
282
|
Effect.flatMap(computeValueBag),
|
|
@@ -333,9 +342,9 @@ export class ComputeGraphController extends Resource {
|
|
|
333
342
|
Scope.extend(scope),
|
|
334
343
|
Effect.flatMap(computeValueBag),
|
|
335
344
|
Effect.provide(
|
|
336
|
-
|
|
337
|
-
Layer.
|
|
338
|
-
|
|
345
|
+
Layer.mergeAll(
|
|
346
|
+
Layer.succeed(Trace.TraceService, this._createTraceWriter()),
|
|
347
|
+
ComputeNodeContext.layerNoop,
|
|
339
348
|
),
|
|
340
349
|
),
|
|
341
350
|
|
|
@@ -366,16 +375,18 @@ export class ComputeGraphController extends Resource {
|
|
|
366
375
|
this.update.emit();
|
|
367
376
|
}
|
|
368
377
|
|
|
369
|
-
private
|
|
378
|
+
private _createTraceWriter(): Trace.TraceWriter {
|
|
370
379
|
return {
|
|
371
|
-
|
|
372
|
-
|
|
380
|
+
write: (eventType, payload) => {
|
|
381
|
+
const event = traceEventToComputeEvent(eventType.key, payload);
|
|
382
|
+
if (event) {
|
|
383
|
+
this._handleEvent(event);
|
|
384
|
+
}
|
|
373
385
|
},
|
|
374
|
-
nodeId: undefined, // Not in a context of a specific node.
|
|
375
386
|
};
|
|
376
387
|
}
|
|
377
388
|
|
|
378
|
-
private _handleEvent(event:
|
|
389
|
+
private _handleEvent(event: ComputeEvent): void {
|
|
379
390
|
log('handleEvent', { event });
|
|
380
391
|
switch (event.type) {
|
|
381
392
|
case 'compute-input': {
|
|
@@ -405,6 +416,23 @@ export class ComputeGraphController extends Resource {
|
|
|
405
416
|
}
|
|
406
417
|
}
|
|
407
418
|
|
|
419
|
+
const traceEventToComputeEvent = (key: string, payload: unknown): ComputeEvent | undefined => {
|
|
420
|
+
switch (key) {
|
|
421
|
+
case ComputeBeginEvent.key:
|
|
422
|
+
return { type: 'begin-compute', ...(payload as { nodeId: string; inputs: ReadonlyArray<string> }) };
|
|
423
|
+
case ComputeEndEvent.key:
|
|
424
|
+
return { type: 'end-compute', ...(payload as { nodeId: string; outputs: ReadonlyArray<string> }) };
|
|
425
|
+
case ComputeInputEvent.key:
|
|
426
|
+
return { type: 'compute-input', ...(payload as { nodeId: string; property: string; value: any }) };
|
|
427
|
+
case ComputeOutputEvent.key:
|
|
428
|
+
return { type: 'compute-output', ...(payload as { nodeId: string; property: string; value: any }) };
|
|
429
|
+
case ComputeCustomEvent.key:
|
|
430
|
+
return { type: 'custom', ...(payload as { nodeId: string; event: any }) };
|
|
431
|
+
default:
|
|
432
|
+
return undefined;
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
|
|
408
436
|
/**
|
|
409
437
|
* Waits for all effects in the bag to complete and returns the `RuntimeValue` for each property.
|
|
410
438
|
*/
|
|
@@ -6,10 +6,9 @@ import * as Schema from 'effect/Schema';
|
|
|
6
6
|
import { useCallback, useEffect, useState } from 'react';
|
|
7
7
|
|
|
8
8
|
import type { ComputeNode, ComputeNodeMeta } from '@dxos/conductor';
|
|
9
|
-
import type { ComputeEventPayload } from '@dxos/functions';
|
|
10
9
|
import { invariant } from '@dxos/invariant';
|
|
11
10
|
|
|
12
|
-
import { type RuntimeValue } from '../graph';
|
|
11
|
+
import { type ComputeEvent, type RuntimeValue } from '../graph';
|
|
13
12
|
import { type ComputeShape } from '../shapes';
|
|
14
13
|
import { useComputeContext } from './compute-context';
|
|
15
14
|
|
|
@@ -21,7 +20,7 @@ export type ComputeNodeState = {
|
|
|
21
20
|
outputs: Record<string, RuntimeValue>;
|
|
22
21
|
setOutput: (property: string, value: any) => void;
|
|
23
22
|
evalNode: () => void;
|
|
24
|
-
subscribeToEventLog: (cb: (event:
|
|
23
|
+
subscribeToEventLog: (cb: (event: ComputeEvent) => void) => () => void;
|
|
25
24
|
};
|
|
26
25
|
};
|
|
27
26
|
|
|
@@ -56,7 +55,7 @@ export const useComputeNodeState = (shape: ComputeShape): ComputeNodeState => {
|
|
|
56
55
|
}, [shape.node]);
|
|
57
56
|
|
|
58
57
|
const subscribeToEventLog = useCallback(
|
|
59
|
-
(cb: (event:
|
|
58
|
+
(cb: (event: ComputeEvent) => void): (() => void) => {
|
|
60
59
|
return controller.events.on((ev) => {
|
|
61
60
|
if (ev.nodeId === shape.node) {
|
|
62
61
|
cb(ev);
|
|
@@ -112,7 +112,7 @@ export const createComputeGraph = (graph?: CanvasGraphModel<ComputeShape>) => {
|
|
|
112
112
|
const linkTriggerToCompute = (graph: ComputeGraphModel, computeNode: ComputeNode, triggerData: TriggerShape) => {
|
|
113
113
|
const functionTrigger = triggerData.functionTrigger?.target;
|
|
114
114
|
invariant(functionTrigger);
|
|
115
|
-
Obj.
|
|
115
|
+
Obj.update(functionTrigger, (functionTrigger) => {
|
|
116
116
|
functionTrigger.function = Ref.make(graph.root);
|
|
117
117
|
functionTrigger.inputNodeId = computeNode.id;
|
|
118
118
|
});
|
package/src/shapes/Function.tsx
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React, { useCallback, useRef } from 'react';
|
|
7
7
|
|
|
8
|
+
import { Script } from '@dxos/compute';
|
|
9
|
+
import { Operation } from '@dxos/compute';
|
|
8
10
|
import { AnyOutput, FunctionInput } from '@dxos/conductor';
|
|
9
11
|
import { Ref, getSnapshot, isInstanceOf } from '@dxos/echo/internal';
|
|
10
|
-
import { Script } from '@dxos/functions';
|
|
11
|
-
import { Operation } from '@dxos/operation';
|
|
12
12
|
import { useClient } from '@dxos/react-client';
|
|
13
13
|
import { Filter, parseId } from '@dxos/react-client/echo';
|
|
14
14
|
import {
|
package/src/shapes/Json.tsx
CHANGED
|
@@ -8,7 +8,7 @@ import React from 'react';
|
|
|
8
8
|
import { DEFAULT_INPUT, DefaultOutput, JsonTransformInput } from '@dxos/conductor';
|
|
9
9
|
import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
10
10
|
import { createAnchorMap } from '@dxos/react-ui-canvas-editor';
|
|
11
|
-
import {
|
|
11
|
+
import { Syntax } from '@dxos/react-ui-syntax-highlighter';
|
|
12
12
|
|
|
13
13
|
import { useComputeNodeState } from '../hooks';
|
|
14
14
|
import { Box, createFunctionAnchors, getHeight } from './common';
|
|
@@ -49,12 +49,14 @@ export const JsonComponent = ({ shape, ...props }: JsonComponentProps) => {
|
|
|
49
49
|
|
|
50
50
|
return (
|
|
51
51
|
<Box shape={shape}>
|
|
52
|
-
<
|
|
53
|
-
<
|
|
54
|
-
<
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
<Syntax.Root data={value}>
|
|
53
|
+
<Syntax.Content>
|
|
54
|
+
<Syntax.Filter />
|
|
55
|
+
<Syntax.Viewport>
|
|
56
|
+
<Syntax.Code classNames='text-xs' />
|
|
57
|
+
</Syntax.Viewport>
|
|
58
|
+
</Syntax.Content>
|
|
59
|
+
</Syntax.Root>
|
|
58
60
|
</Box>
|
|
59
61
|
);
|
|
60
62
|
};
|
package/src/shapes/Surface.tsx
CHANGED
|
@@ -6,6 +6,7 @@ import * as Schema from 'effect/Schema';
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
8
|
import { Surface } from '@dxos/app-framework/ui';
|
|
9
|
+
import { AppSurface } from '@dxos/app-toolkit/ui';
|
|
9
10
|
import { DEFAULT_INPUT } from '@dxos/conductor';
|
|
10
11
|
import { Card } from '@dxos/react-ui';
|
|
11
12
|
import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
@@ -47,7 +48,9 @@ export const SurfaceComponent = ({ shape }: ShapeComponentProps<SurfaceShape>) =
|
|
|
47
48
|
// TODO(burdon): Subject property?
|
|
48
49
|
return (
|
|
49
50
|
<Box shape={shape} onAction={handleAction}>
|
|
50
|
-
<Card.Root>
|
|
51
|
+
<Card.Root>
|
|
52
|
+
{value !== null && <Surface.Surface type={AppSurface.Card} data={{ subject: value }} limit={1} />}
|
|
53
|
+
</Card.Root>
|
|
51
54
|
</Box>
|
|
52
55
|
);
|
|
53
56
|
};
|
package/src/shapes/Trigger.tsx
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
import React, { useEffect } from 'react';
|
|
7
7
|
|
|
8
|
+
import { Trigger, TriggerEvent } from '@dxos/compute';
|
|
8
9
|
import { VoidInput } from '@dxos/conductor';
|
|
9
10
|
import { Filter, Obj, Query, Ref } from '@dxos/echo';
|
|
10
11
|
import { type Mutable } from '@dxos/echo/internal';
|
|
11
|
-
import { Trigger, TriggerEvent } from '@dxos/functions';
|
|
12
12
|
import { DXN, SpaceId } from '@dxos/keys';
|
|
13
13
|
import { useSpaces } from '@dxos/react-client/echo';
|
|
14
14
|
import { Select, type SelectRootProps } from '@dxos/react-ui';
|
|
@@ -53,7 +53,7 @@ export const TriggerComponent = ({ shape }: TriggerComponentProps) => {
|
|
|
53
53
|
|
|
54
54
|
useEffect(() => {
|
|
55
55
|
if (functionTrigger && !functionTrigger.spec) {
|
|
56
|
-
Obj.
|
|
56
|
+
Obj.update(functionTrigger, (functionTrigger) => {
|
|
57
57
|
functionTrigger.spec = createTriggerSpec({ triggerKind: 'email', spaceId: space?.id }) as Mutable<Trigger.Spec>;
|
|
58
58
|
});
|
|
59
59
|
}
|
|
@@ -65,7 +65,7 @@ export const TriggerComponent = ({ shape }: TriggerComponentProps) => {
|
|
|
65
65
|
|
|
66
66
|
const setKind = (kind: Trigger.Kind) => {
|
|
67
67
|
if (functionTrigger?.spec?.kind !== kind) {
|
|
68
|
-
Obj.
|
|
68
|
+
Obj.update(functionTrigger!, (obj) => {
|
|
69
69
|
obj.spec = createTriggerSpec({ triggerKind: kind, spaceId: space?.id }) as Mutable<Trigger.Spec>;
|
|
70
70
|
});
|
|
71
71
|
}
|
|
@@ -114,21 +114,16 @@ const createTriggerSpec = (props: { triggerKind?: Trigger.Kind; spaceId?: SpaceI
|
|
|
114
114
|
const kind = props.triggerKind ?? 'email';
|
|
115
115
|
switch (kind) {
|
|
116
116
|
case 'timer':
|
|
117
|
-
return
|
|
117
|
+
return Trigger.specTimer('*/10 * * * * *');
|
|
118
118
|
case 'webhook':
|
|
119
|
-
return {
|
|
119
|
+
return Trigger.specWebhook({ method: 'POST' });
|
|
120
120
|
case 'subscription':
|
|
121
|
-
return
|
|
122
|
-
kind: 'subscription',
|
|
123
|
-
query: {
|
|
124
|
-
ast: Query.select(Filter.nothing()).ast,
|
|
125
|
-
},
|
|
126
|
-
} satisfies Trigger.SubscriptionSpec;
|
|
121
|
+
return Trigger.specSubscription(Query.select(Filter.nothing()));
|
|
127
122
|
case 'email':
|
|
128
|
-
return
|
|
123
|
+
return Trigger.specEmail();
|
|
129
124
|
case 'queue': {
|
|
130
125
|
const dxn = new DXN(DXN.kind.QUEUE, ['data', props.spaceId ?? SpaceId.random(), Obj.ID.random()]).toString();
|
|
131
|
-
return
|
|
126
|
+
return Trigger.specQueue(dxn);
|
|
132
127
|
}
|
|
133
128
|
}
|
|
134
129
|
};
|