@dxos/react-ui-canvas-compute 0.8.4-main.8360d9e660 → 0.8.4-main.8baae0fced
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 +382 -459
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +382 -459
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/DiagnosticOverlay.d.ts.map +1 -1
- package/dist/types/src/compute-layout.d.ts.map +1 -1
- package/dist/types/src/compute.stories.d.ts +1 -1
- package/dist/types/src/compute.stories.d.ts.map +1 -1
- package/dist/types/src/graph/controller.d.ts +45 -30
- 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/{Queue.d.ts → Feed.d.ts} +9 -9
- package/dist/types/src/shapes/Feed.d.ts.map +1 -0
- package/dist/types/src/shapes/Function.d.ts +1 -1
- package/dist/types/src/shapes/Function.d.ts.map +1 -1
- package/dist/types/src/shapes/Gpt.d.ts +1 -1
- package/dist/types/src/shapes/Gpt.d.ts.map +1 -1
- package/dist/types/src/shapes/GptRealtime.d.ts +1 -1
- package/dist/types/src/shapes/GptRealtime.d.ts.map +1 -1
- package/dist/types/src/shapes/Json.d.ts +2 -2
- package/dist/types/src/shapes/Json.d.ts.map +1 -1
- package/dist/types/src/shapes/Logic.d.ts +2 -2
- package/dist/types/src/shapes/Logic.d.ts.map +1 -1
- package/dist/types/src/shapes/RNG.d.ts +2 -2
- package/dist/types/src/shapes/RNG.d.ts.map +1 -1
- package/dist/types/src/shapes/Scope.d.ts +1 -1
- package/dist/types/src/shapes/Scope.d.ts.map +1 -1
- package/dist/types/src/shapes/Surface.d.ts +1 -1
- package/dist/types/src/shapes/Surface.d.ts.map +1 -1
- package/dist/types/src/shapes/Switch.d.ts +1 -1
- package/dist/types/src/shapes/Switch.d.ts.map +1 -1
- package/dist/types/src/shapes/Table.d.ts +1 -1
- package/dist/types/src/shapes/Table.d.ts.map +1 -1
- package/dist/types/src/shapes/Template.d.ts +2 -2
- package/dist/types/src/shapes/Template.d.ts.map +1 -1
- package/dist/types/src/shapes/Text.d.ts +1 -1
- package/dist/types/src/shapes/Text.d.ts.map +1 -1
- package/dist/types/src/shapes/TextToImage.d.ts +1 -1
- package/dist/types/src/shapes/TextToImage.d.ts.map +1 -1
- package/dist/types/src/shapes/Thread.d.ts +1 -1
- package/dist/types/src/shapes/Thread.d.ts.map +1 -1
- package/dist/types/src/shapes/Trigger.d.ts +2 -2
- package/dist/types/src/shapes/Trigger.d.ts.map +1 -1
- package/dist/types/src/shapes/common/Box.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/shapes/index.d.ts +2 -2
- package/dist/types/src/shapes/index.d.ts.map +1 -1
- package/dist/types/src/testing/circuits.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +47 -48
- package/src/compute.stories.tsx +26 -10
- package/src/graph/controller.ts +65 -26
- package/src/hooks/useComputeNodeState.ts +3 -5
- package/src/hooks/useGraphMonitor.ts +3 -3
- package/src/registry.ts +2 -2
- package/src/shapes/Audio.tsx +0 -1
- package/src/shapes/Beacon.tsx +0 -1
- package/src/shapes/Boolean.tsx +1 -1
- package/src/shapes/Chat.tsx +0 -1
- package/src/shapes/Constant.tsx +0 -1
- package/src/shapes/{Queue.tsx → Feed.tsx} +13 -14
- package/src/shapes/Function.tsx +5 -4
- package/src/shapes/Gpt.tsx +0 -1
- package/src/shapes/Json.tsx +9 -3
- package/src/shapes/RNG.tsx +0 -1
- package/src/shapes/Scope.tsx +0 -1
- package/src/shapes/Surface.tsx +4 -2
- package/src/shapes/Switch.tsx +0 -1
- package/src/shapes/Template.tsx +0 -1
- package/src/shapes/Text.tsx +0 -1
- package/src/shapes/Thread.tsx +1 -5
- package/src/shapes/Trigger.tsx +12 -17
- package/src/shapes/common/Box.tsx +0 -2
- package/src/shapes/index.ts +2 -2
- package/src/testing/circuits.ts +2 -2
- package/dist/types/src/shapes/Queue.d.ts.map +0 -1
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.8baae0fced",
|
|
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",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "https://github.com/dxos/dxos"
|
|
10
10
|
},
|
|
11
|
-
"license": "
|
|
11
|
+
"license": "FSL-1.1-Apache-2.0",
|
|
12
12
|
"author": "DXOS.org",
|
|
13
13
|
"type": "module",
|
|
14
14
|
"exports": {
|
|
@@ -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,37 +29,40 @@
|
|
|
32
29
|
"@antv/layout": "^1.2.13",
|
|
33
30
|
"@effect/platform": "0.94.4",
|
|
34
31
|
"chess.js": "^1.0.0",
|
|
35
|
-
"@dxos/ai": "0.8.4-main.
|
|
36
|
-
"@dxos/app-framework": "0.8.4-main.
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/async": "0.8.4-main.
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/conductor": "0.8.4-main.
|
|
43
|
-
"@dxos/
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/
|
|
49
|
-
"@dxos/
|
|
50
|
-
"@dxos/
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/
|
|
54
|
-
"@dxos/
|
|
55
|
-
"@dxos/react-
|
|
56
|
-
"@dxos/react-ui-
|
|
57
|
-
"@dxos/react-
|
|
58
|
-
"@dxos/react-ui-
|
|
59
|
-
"@dxos/react-ui-
|
|
60
|
-
"@dxos/
|
|
61
|
-
"@dxos/react-ui-
|
|
62
|
-
"@dxos/
|
|
63
|
-
"@dxos/
|
|
64
|
-
"@dxos/
|
|
65
|
-
"@dxos/
|
|
32
|
+
"@dxos/ai": "0.8.4-main.8baae0fced",
|
|
33
|
+
"@dxos/app-framework": "0.8.4-main.8baae0fced",
|
|
34
|
+
"@dxos/app-toolkit": "0.8.4-main.8baae0fced",
|
|
35
|
+
"@dxos/assistant": "0.8.4-main.8baae0fced",
|
|
36
|
+
"@dxos/async": "0.8.4-main.8baae0fced",
|
|
37
|
+
"@dxos/compute": "0.8.4-main.8baae0fced",
|
|
38
|
+
"@dxos/compute-runtime": "0.8.4-main.8baae0fced",
|
|
39
|
+
"@dxos/conductor": "0.8.4-main.8baae0fced",
|
|
40
|
+
"@dxos/context": "0.8.4-main.8baae0fced",
|
|
41
|
+
"@dxos/debug": "0.8.4-main.8baae0fced",
|
|
42
|
+
"@dxos/echo-db": "0.8.4-main.8baae0fced",
|
|
43
|
+
"@dxos/edge-client": "0.8.4-main.8baae0fced",
|
|
44
|
+
"@dxos/echo": "0.8.4-main.8baae0fced",
|
|
45
|
+
"@dxos/effect": "0.8.4-main.8baae0fced",
|
|
46
|
+
"@dxos/functions": "0.8.4-main.8baae0fced",
|
|
47
|
+
"@dxos/graph": "0.8.4-main.8baae0fced",
|
|
48
|
+
"@dxos/functions-runtime": "0.8.4-main.8baae0fced",
|
|
49
|
+
"@dxos/invariant": "0.8.4-main.8baae0fced",
|
|
50
|
+
"@dxos/log": "0.8.4-main.8baae0fced",
|
|
51
|
+
"@dxos/keys": "0.8.4-main.8baae0fced",
|
|
52
|
+
"@dxos/react-client": "0.8.4-main.8baae0fced",
|
|
53
|
+
"@dxos/react-ui-canvas": "0.8.4-main.8baae0fced",
|
|
54
|
+
"@dxos/react-edge-client": "0.8.4-main.8baae0fced",
|
|
55
|
+
"@dxos/react-ui-attention": "0.8.4-main.8baae0fced",
|
|
56
|
+
"@dxos/react-ui-canvas-editor": "0.8.4-main.8baae0fced",
|
|
57
|
+
"@dxos/react-ui-editor": "0.8.4-main.8baae0fced",
|
|
58
|
+
"@dxos/react-ui-mosaic": "0.8.4-main.8baae0fced",
|
|
59
|
+
"@dxos/react-ui-form": "0.8.4-main.8baae0fced",
|
|
60
|
+
"@dxos/react-ui-stack": "0.8.4-main.8baae0fced",
|
|
61
|
+
"@dxos/react-ui-sfx": "0.8.4-main.8baae0fced",
|
|
62
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.8baae0fced",
|
|
63
|
+
"@dxos/types": "0.8.4-main.8baae0fced",
|
|
64
|
+
"@dxos/schema": "0.8.4-main.8baae0fced",
|
|
65
|
+
"@dxos/util": "0.8.4-main.8baae0fced"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@effect/ai": "0.33.2",
|
|
@@ -70,25 +70,24 @@
|
|
|
70
70
|
"@types/lodash.defaultsdeep": "^4.6.6",
|
|
71
71
|
"@types/react": "~19.2.7",
|
|
72
72
|
"@types/react-dom": "~19.2.3",
|
|
73
|
-
"effect": "3.
|
|
73
|
+
"effect": "3.20.0",
|
|
74
74
|
"lodash.defaultsdeep": "^4.6.1",
|
|
75
75
|
"react": "~19.2.3",
|
|
76
76
|
"react-dom": "~19.2.3",
|
|
77
|
-
"vite": "^
|
|
78
|
-
"@dxos/app-framework": "0.8.4-main.
|
|
79
|
-
"@dxos/assistant-toolkit": "0.8.4-main.
|
|
80
|
-
"@dxos/
|
|
81
|
-
"@dxos/
|
|
82
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
83
|
-
"@dxos/
|
|
84
|
-
"@dxos/ui-theme": "0.8.4-main.8360d9e660"
|
|
77
|
+
"vite": "^8.0.13",
|
|
78
|
+
"@dxos/app-framework": "0.8.4-main.8baae0fced",
|
|
79
|
+
"@dxos/assistant-toolkit": "0.8.4-main.8baae0fced",
|
|
80
|
+
"@dxos/random": "0.8.4-main.8baae0fced",
|
|
81
|
+
"@dxos/storybook-utils": "0.8.4-main.8baae0fced",
|
|
82
|
+
"@dxos/react-ui": "0.8.4-main.8baae0fced",
|
|
83
|
+
"@dxos/ui-theme": "0.8.4-main.8baae0fced"
|
|
85
84
|
},
|
|
86
85
|
"peerDependencies": {
|
|
87
|
-
"effect": "3.
|
|
86
|
+
"effect": "3.20.0",
|
|
88
87
|
"react": "~19.2.3",
|
|
89
88
|
"react-dom": "~19.2.3",
|
|
90
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
91
|
-
"@dxos/ui-theme": "0.8.4-main.
|
|
89
|
+
"@dxos/react-ui": "0.8.4-main.8baae0fced",
|
|
90
|
+
"@dxos/ui-theme": "0.8.4-main.8baae0fced"
|
|
92
91
|
},
|
|
93
92
|
"publishConfig": {
|
|
94
93
|
"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,19 +11,19 @@ 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';
|
|
15
|
+
import { TestDatabaseLayer } from '@dxos/compute-runtime/testing';
|
|
13
16
|
import { type ComputeGraphModel, type ComputeNode, type GraphDiagnostic } from '@dxos/conductor';
|
|
14
17
|
import { Feed } from '@dxos/echo';
|
|
15
|
-
import {
|
|
16
|
-
import { FunctionInvocationServiceLayerTest } from '@dxos/functions-runtime';
|
|
17
|
-
import { TestDatabaseLayer } from '@dxos/functions-runtime/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
|
-
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
21
21
|
import { withAttention } from '@dxos/react-ui-attention/testing';
|
|
22
22
|
import { Editor, type EditorController, type EditorRootProps, ShapeRegistry } from '@dxos/react-ui-canvas-editor';
|
|
23
23
|
import { Container, useSelection } from '@dxos/react-ui-canvas-editor/testing';
|
|
24
24
|
import { Form } from '@dxos/react-ui-form';
|
|
25
|
-
import {
|
|
25
|
+
import { Syntax } from '@dxos/react-ui-syntax-highlighter';
|
|
26
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
26
27
|
|
|
27
28
|
import { DiagnosticOverlay } from './components';
|
|
28
29
|
import { ComputeShapeLayout } from './compute-layout';
|
|
@@ -123,7 +124,7 @@ const DefaultStory = ({
|
|
|
123
124
|
}
|
|
124
125
|
|
|
125
126
|
return (
|
|
126
|
-
<div className='grid grid-cols-[1fr_360px]
|
|
127
|
+
<div className='grid grid-cols-[1fr_360px] h-full w-full'>
|
|
127
128
|
<ComputeContext.Provider value={{ controller }}>
|
|
128
129
|
<Container id={id} classNames={['flex grow overflow-hidden', !sidebar && 'col-span-2']}>
|
|
129
130
|
<Editor.Root<ComputeShape>
|
|
@@ -178,7 +179,14 @@ const DefaultStory = ({
|
|
|
178
179
|
</Form.Viewport>
|
|
179
180
|
</Form.Root>
|
|
180
181
|
)}
|
|
181
|
-
<
|
|
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>
|
|
182
190
|
</div>
|
|
183
191
|
</Container>
|
|
184
192
|
)}
|
|
@@ -216,13 +224,21 @@ export default meta;
|
|
|
216
224
|
type Story = StoryObj<typeof meta>;
|
|
217
225
|
|
|
218
226
|
const ServiceLayer = Layer.empty.pipe(
|
|
219
|
-
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
|
+
),
|
|
220
237
|
Layer.provideMerge(
|
|
221
238
|
Layer.mergeAll(
|
|
222
239
|
AiServiceTestingPreset('direct'),
|
|
223
240
|
TestDatabaseLayer(),
|
|
224
|
-
|
|
225
|
-
TracingService.layerNoop,
|
|
241
|
+
configuredCredentialsLayer([]),
|
|
226
242
|
Feed.notAvailable,
|
|
227
243
|
),
|
|
228
244
|
),
|
package/src/graph/controller.ts
CHANGED
|
@@ -2,17 +2,22 @@
|
|
|
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';
|
|
9
8
|
import * as Layer from 'effect/Layer';
|
|
10
|
-
import type * as ManagedRuntime from 'effect/ManagedRuntime';
|
|
11
9
|
import * as Scope from 'effect/Scope';
|
|
12
10
|
|
|
13
11
|
import type { AiService } from '@dxos/ai';
|
|
14
12
|
import { Event, synchronized } from '@dxos/async';
|
|
13
|
+
import { type Credential, type Operation, type OperationRegistry, Trace } from '@dxos/compute';
|
|
15
14
|
import {
|
|
15
|
+
ComputeBeginEvent,
|
|
16
|
+
ComputeCustomEvent,
|
|
17
|
+
ComputeEndEvent,
|
|
18
|
+
ComputeInputEvent,
|
|
19
|
+
ComputeNodeContext,
|
|
20
|
+
ComputeOutputEvent,
|
|
16
21
|
type ComputeEdge,
|
|
17
22
|
type ComputeGraphModel,
|
|
18
23
|
type ComputeNode,
|
|
@@ -27,21 +32,13 @@ import {
|
|
|
27
32
|
import { Resource } from '@dxos/context';
|
|
28
33
|
import type { Database, Feed } from '@dxos/echo';
|
|
29
34
|
import { unwrapExit } from '@dxos/effect';
|
|
30
|
-
import {
|
|
31
|
-
ComputeEventLogger,
|
|
32
|
-
type ComputeEventPayload,
|
|
33
|
-
type CredentialsService,
|
|
34
|
-
type FunctionInvocationService,
|
|
35
|
-
type QueueService,
|
|
36
|
-
TracingService,
|
|
37
|
-
} from '@dxos/functions';
|
|
35
|
+
import { type QueueService } from '@dxos/functions';
|
|
38
36
|
import { log } from '@dxos/log';
|
|
39
37
|
import { type CanvasGraphModel } from '@dxos/react-ui-canvas-editor';
|
|
40
38
|
import { type ContentBlock } from '@dxos/types';
|
|
41
39
|
|
|
42
40
|
import { createComputeGraph } from '../hooks';
|
|
43
41
|
import { type ComputeShape } from '../shapes';
|
|
44
|
-
|
|
45
42
|
import { resolveComputeNode } from './node-defs';
|
|
46
43
|
|
|
47
44
|
// TODO(burdon): API package for conductor.
|
|
@@ -83,23 +80,44 @@ type ComputeOutputEvent = {
|
|
|
83
80
|
value: RuntimeValue;
|
|
84
81
|
};
|
|
85
82
|
|
|
83
|
+
/**
|
|
84
|
+
* Event emitted by the compute graph during execution.
|
|
85
|
+
*/
|
|
86
|
+
export type ComputeEvent =
|
|
87
|
+
| { type: 'begin-compute'; nodeId: string; inputs: ReadonlyArray<string> }
|
|
88
|
+
| { type: 'end-compute'; nodeId: string; outputs: ReadonlyArray<string> }
|
|
89
|
+
| { type: 'compute-input'; nodeId: string; property: string; value: any }
|
|
90
|
+
| { type: 'compute-output'; nodeId: string; property: string; value: any }
|
|
91
|
+
| { type: 'custom'; nodeId: string; event: any };
|
|
92
|
+
|
|
86
93
|
// TODO(dmaretskyi): Re-use function servies definition.
|
|
87
94
|
export type ComputeServices =
|
|
88
95
|
| AiService.AiService
|
|
89
96
|
| Database.Service
|
|
90
|
-
| Feed.
|
|
97
|
+
| Feed.FeedService
|
|
91
98
|
| QueueService
|
|
92
|
-
| CredentialsService
|
|
93
|
-
|
|
|
99
|
+
| Credential.CredentialsService
|
|
100
|
+
| Operation.Service
|
|
101
|
+
| OperationRegistry.Service;
|
|
94
102
|
|
|
95
103
|
/**
|
|
96
104
|
* Nodes that will automatically trigger the execution of the graph on startup.
|
|
97
105
|
*/
|
|
98
106
|
const AUTO_TRIGGER_NODES = ['chat', 'switch', 'constant'];
|
|
99
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Minimal runtime interface required by the {@link ComputeGraphController}.
|
|
110
|
+
*
|
|
111
|
+
* Satisfied by both `effect/ManagedRuntime.ManagedRuntime` and ad-hoc adapters
|
|
112
|
+
* built on top of the app-framework `ProcessManagerRuntime`.
|
|
113
|
+
*/
|
|
114
|
+
export interface ComputeGraphRuntime {
|
|
115
|
+
runPromiseExit<A, E>(effect: Effect.Effect<A, E, ComputeServices>): Promise<Exit.Exit<A, E>>;
|
|
116
|
+
}
|
|
117
|
+
|
|
100
118
|
export const createComputeGraphController = (
|
|
101
119
|
graph: CanvasGraphModel<ComputeShape>,
|
|
102
|
-
computeRuntime:
|
|
120
|
+
computeRuntime: ComputeGraphRuntime,
|
|
103
121
|
) => {
|
|
104
122
|
const computeGraph = createComputeGraph(graph);
|
|
105
123
|
const controller = new ComputeGraphController(computeRuntime, computeGraph);
|
|
@@ -134,10 +152,10 @@ export class ComputeGraphController extends Resource {
|
|
|
134
152
|
/** Computed result. */
|
|
135
153
|
public readonly output = new Event<ComputeOutputEvent>();
|
|
136
154
|
|
|
137
|
-
public readonly events = new Event<
|
|
155
|
+
public readonly events = new Event<ComputeEvent>();
|
|
138
156
|
|
|
139
157
|
constructor(
|
|
140
|
-
private readonly _computeRuntime:
|
|
158
|
+
private readonly _computeRuntime: ComputeGraphRuntime,
|
|
141
159
|
/** Persistent compute graph. */
|
|
142
160
|
private readonly _graph: ComputeGraphModel,
|
|
143
161
|
) {
|
|
@@ -265,8 +283,9 @@ export class ComputeGraphController extends Resource {
|
|
|
265
283
|
Effect.withSpan('runGraph'),
|
|
266
284
|
Scope.extend(scope),
|
|
267
285
|
Effect.provide(
|
|
268
|
-
|
|
269
|
-
Layer.
|
|
286
|
+
Layer.mergeAll(
|
|
287
|
+
Layer.succeed(Trace.TraceService, this._createTraceWriter()),
|
|
288
|
+
ComputeNodeContext.layerNoop,
|
|
270
289
|
),
|
|
271
290
|
),
|
|
272
291
|
Effect.flatMap(computeValueBag),
|
|
@@ -332,8 +351,9 @@ export class ComputeGraphController extends Resource {
|
|
|
332
351
|
Scope.extend(scope),
|
|
333
352
|
Effect.flatMap(computeValueBag),
|
|
334
353
|
Effect.provide(
|
|
335
|
-
|
|
336
|
-
Layer.
|
|
354
|
+
Layer.mergeAll(
|
|
355
|
+
Layer.succeed(Trace.TraceService, this._createTraceWriter()),
|
|
356
|
+
ComputeNodeContext.layerNoop,
|
|
337
357
|
),
|
|
338
358
|
),
|
|
339
359
|
|
|
@@ -364,16 +384,18 @@ export class ComputeGraphController extends Resource {
|
|
|
364
384
|
this.update.emit();
|
|
365
385
|
}
|
|
366
386
|
|
|
367
|
-
private
|
|
387
|
+
private _createTraceWriter(): Trace.TraceWriter {
|
|
368
388
|
return {
|
|
369
|
-
|
|
370
|
-
|
|
389
|
+
write: (eventType, payload) => {
|
|
390
|
+
const event = traceEventToComputeEvent(eventType.key, payload);
|
|
391
|
+
if (event) {
|
|
392
|
+
this._handleEvent(event);
|
|
393
|
+
}
|
|
371
394
|
},
|
|
372
|
-
nodeId: undefined, // Not in a context of a specific node.
|
|
373
395
|
};
|
|
374
396
|
}
|
|
375
397
|
|
|
376
|
-
private _handleEvent(event:
|
|
398
|
+
private _handleEvent(event: ComputeEvent): void {
|
|
377
399
|
log('handleEvent', { event });
|
|
378
400
|
switch (event.type) {
|
|
379
401
|
case 'compute-input': {
|
|
@@ -403,6 +425,23 @@ export class ComputeGraphController extends Resource {
|
|
|
403
425
|
}
|
|
404
426
|
}
|
|
405
427
|
|
|
428
|
+
const traceEventToComputeEvent = (key: string, payload: unknown): ComputeEvent | undefined => {
|
|
429
|
+
switch (key) {
|
|
430
|
+
case ComputeBeginEvent.key:
|
|
431
|
+
return { type: 'begin-compute', ...(payload as { nodeId: string; inputs: ReadonlyArray<string> }) };
|
|
432
|
+
case ComputeEndEvent.key:
|
|
433
|
+
return { type: 'end-compute', ...(payload as { nodeId: string; outputs: ReadonlyArray<string> }) };
|
|
434
|
+
case ComputeInputEvent.key:
|
|
435
|
+
return { type: 'compute-input', ...(payload as { nodeId: string; property: string; value: any }) };
|
|
436
|
+
case ComputeOutputEvent.key:
|
|
437
|
+
return { type: 'compute-output', ...(payload as { nodeId: string; property: string; value: any }) };
|
|
438
|
+
case ComputeCustomEvent.key:
|
|
439
|
+
return { type: 'custom', ...(payload as { nodeId: string; event: any }) };
|
|
440
|
+
default:
|
|
441
|
+
return undefined;
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
|
|
406
445
|
/**
|
|
407
446
|
* Waits for all effects in the bag to complete and returns the `RuntimeValue` for each property.
|
|
408
447
|
*/
|
|
@@ -6,12 +6,10 @@ 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
|
-
|
|
15
13
|
import { useComputeContext } from './compute-context';
|
|
16
14
|
|
|
17
15
|
export type ComputeNodeState = {
|
|
@@ -22,7 +20,7 @@ export type ComputeNodeState = {
|
|
|
22
20
|
outputs: Record<string, RuntimeValue>;
|
|
23
21
|
setOutput: (property: string, value: any) => void;
|
|
24
22
|
evalNode: () => void;
|
|
25
|
-
subscribeToEventLog: (cb: (event:
|
|
23
|
+
subscribeToEventLog: (cb: (event: ComputeEvent) => void) => () => void;
|
|
26
24
|
};
|
|
27
25
|
};
|
|
28
26
|
|
|
@@ -57,7 +55,7 @@ export const useComputeNodeState = (shape: ComputeShape): ComputeNodeState => {
|
|
|
57
55
|
}, [shape.node]);
|
|
58
56
|
|
|
59
57
|
const subscribeToEventLog = useCallback(
|
|
60
|
-
(cb: (event:
|
|
58
|
+
(cb: (event: ComputeEvent) => void): (() => void) => {
|
|
61
59
|
return controller.events.on((ev) => {
|
|
62
60
|
if (ev.nodeId === shape.node) {
|
|
63
61
|
cb(ev);
|
|
@@ -112,9 +112,9 @@ 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.
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
Obj.update(functionTrigger, (functionTrigger) => {
|
|
116
|
+
functionTrigger.function = Ref.make(graph.root);
|
|
117
|
+
functionTrigger.inputNodeId = computeNode.id;
|
|
118
118
|
});
|
|
119
119
|
};
|
|
120
120
|
|
package/src/registry.ts
CHANGED
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
jsonTransformShape,
|
|
23
23
|
notShape,
|
|
24
24
|
orShape,
|
|
25
|
-
|
|
25
|
+
feedShape,
|
|
26
26
|
randomShape,
|
|
27
27
|
reducerShape,
|
|
28
28
|
scopeShape,
|
|
@@ -82,7 +82,7 @@ export const computeShapes: { title: string; shapes: ShapeDef[] }[] = [
|
|
|
82
82
|
shapes: [
|
|
83
83
|
//
|
|
84
84
|
jsonShape,
|
|
85
|
-
|
|
85
|
+
feedShape,
|
|
86
86
|
threadShape,
|
|
87
87
|
textShape,
|
|
88
88
|
surfaceShape,
|
package/src/shapes/Audio.tsx
CHANGED
|
@@ -9,7 +9,6 @@ import { Icon } from '@dxos/react-ui';
|
|
|
9
9
|
import { type ShapeComponentProps, type ShapeDef, createAnchorMap } from '@dxos/react-ui-canvas-editor';
|
|
10
10
|
|
|
11
11
|
import { useComputeNodeState } from '../hooks';
|
|
12
|
-
|
|
13
12
|
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
14
13
|
|
|
15
14
|
export const AudioShape = Schema.extend(
|
package/src/shapes/Beacon.tsx
CHANGED
|
@@ -10,7 +10,6 @@ import { Icon } from '@dxos/react-ui';
|
|
|
10
10
|
import { type ShapeComponentProps, type ShapeDef, createAnchorMap } from '@dxos/react-ui-canvas-editor';
|
|
11
11
|
|
|
12
12
|
import { useComputeNodeState } from '../hooks';
|
|
13
|
-
|
|
14
13
|
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
15
14
|
|
|
16
15
|
export const BeaconShape = Schema.extend(
|
package/src/shapes/Boolean.tsx
CHANGED
|
@@ -95,7 +95,7 @@ const createSymbol =
|
|
|
95
95
|
const paths = pathConstructor({ startX, endX, height });
|
|
96
96
|
|
|
97
97
|
return (
|
|
98
|
-
<svg viewBox={`0 0 ${width} ${height}`} className='
|
|
98
|
+
<svg viewBox={`0 0 ${width} ${height}`} className='h-full w-full'>
|
|
99
99
|
{/* Input line. */}
|
|
100
100
|
{getAnchorPoints({ x: 0, y: centerY }, inputs).map(({ x, y }, i) => (
|
|
101
101
|
<line key={i} x1={x} y1={y} x2={startX * 1.3} y2={y} strokeWidth={strokeWidth} className={className} />
|
package/src/shapes/Chat.tsx
CHANGED
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
import { createAnchorMap } from '@dxos/react-ui-canvas-editor';
|
|
17
17
|
|
|
18
18
|
import { useComputeNodeState } from '../hooks';
|
|
19
|
-
|
|
20
19
|
import { Box } from './common';
|
|
21
20
|
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
22
21
|
|
package/src/shapes/Constant.tsx
CHANGED
|
@@ -18,7 +18,6 @@ import { createAnchorMap } from '@dxos/react-ui-canvas-editor';
|
|
|
18
18
|
import { safeParseJson } from '@dxos/util';
|
|
19
19
|
|
|
20
20
|
import { useComputeNodeState } from '../hooks';
|
|
21
|
-
|
|
22
21
|
import { Box, TypeSelect } from './common';
|
|
23
22
|
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
24
23
|
|
|
@@ -11,30 +11,29 @@ import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-e
|
|
|
11
11
|
import { mx } from '@dxos/ui-theme';
|
|
12
12
|
|
|
13
13
|
import { useComputeNodeState } from '../hooks';
|
|
14
|
-
|
|
15
14
|
import { createFunctionAnchors } from './common';
|
|
16
15
|
import { Box, type BoxActionHandler } from './common';
|
|
17
16
|
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
18
17
|
|
|
19
|
-
export const
|
|
18
|
+
export const FeedShape = Schema.extend(
|
|
20
19
|
ComputeShape,
|
|
21
20
|
Schema.Struct({
|
|
22
21
|
type: Schema.Literal('queue'),
|
|
23
22
|
}),
|
|
24
23
|
);
|
|
25
24
|
|
|
26
|
-
export type
|
|
25
|
+
export type FeedShape = Schema.Schema.Type<typeof FeedShape>;
|
|
27
26
|
|
|
28
|
-
export type
|
|
27
|
+
export type CreateFeedProps = CreateShapeProps<FeedShape>;
|
|
29
28
|
|
|
30
|
-
export const
|
|
31
|
-
createShape<
|
|
29
|
+
export const createFeed = (props: CreateFeedProps) =>
|
|
30
|
+
createShape<FeedShape>({
|
|
32
31
|
type: 'queue',
|
|
33
32
|
size: { width: 256, height: 512 },
|
|
34
33
|
...props,
|
|
35
34
|
});
|
|
36
35
|
|
|
37
|
-
export const
|
|
36
|
+
export const FeedComponent = ({ shape }: ShapeComponentProps<FeedShape>) => {
|
|
38
37
|
const { runtime } = useComputeNodeState(shape);
|
|
39
38
|
const items = runtime.outputs[DEFAULT_OUTPUT]?.type === 'executed' ? runtime.outputs[DEFAULT_OUTPUT].value : [];
|
|
40
39
|
|
|
@@ -49,7 +48,7 @@ export const QueueComponent = ({ shape }: ShapeComponentProps<QueueShape>) => {
|
|
|
49
48
|
<ScrollArea.Root orientation='vertical'>
|
|
50
49
|
<ScrollArea.Viewport classNames='divide-y divide-separator'>
|
|
51
50
|
{[...items].map((item, i) => (
|
|
52
|
-
<
|
|
51
|
+
<FeedItem key={i} classNames='p-1 px-2' item={item} />
|
|
53
52
|
))}
|
|
54
53
|
</ScrollArea.Viewport>
|
|
55
54
|
</ScrollArea.Root>
|
|
@@ -57,7 +56,7 @@ export const QueueComponent = ({ shape }: ShapeComponentProps<QueueShape>) => {
|
|
|
57
56
|
);
|
|
58
57
|
};
|
|
59
58
|
|
|
60
|
-
export const
|
|
59
|
+
export const FeedItem = ({ classNames, item }: ThemedClassName<{ item: any }>) => {
|
|
61
60
|
if (typeof item !== 'object') {
|
|
62
61
|
return <div className={mx(classNames, 'whitespace-pre-wrap')}>{item}</div>;
|
|
63
62
|
}
|
|
@@ -74,12 +73,12 @@ export const QueueItem = ({ classNames, item }: ThemedClassName<{ item: any }>)
|
|
|
74
73
|
);
|
|
75
74
|
};
|
|
76
75
|
|
|
77
|
-
export const
|
|
78
|
-
type: '
|
|
79
|
-
name: '
|
|
76
|
+
export const feedShape: ShapeDef<FeedShape> = {
|
|
77
|
+
type: 'feed',
|
|
78
|
+
name: 'Feed',
|
|
80
79
|
icon: 'ph--queue--regular',
|
|
81
|
-
component:
|
|
82
|
-
createShape:
|
|
80
|
+
component: FeedComponent,
|
|
81
|
+
createShape: createFeed,
|
|
83
82
|
getAnchors: (shape) => createFunctionAnchors(shape, QueueInput, QueueOutput),
|
|
84
83
|
resizable: true,
|
|
85
84
|
};
|
package/src/shapes/Function.tsx
CHANGED
|
@@ -5,11 +5,13 @@
|
|
|
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';
|
|
11
|
+
import { Filter } from '@dxos/echo';
|
|
9
12
|
import { Ref, getSnapshot, isInstanceOf } from '@dxos/echo/internal';
|
|
10
|
-
import {
|
|
13
|
+
import { parseId } from '@dxos/keys';
|
|
11
14
|
import { useClient } from '@dxos/react-client';
|
|
12
|
-
import { Filter, parseId } from '@dxos/react-client/echo';
|
|
13
15
|
import {
|
|
14
16
|
type ShapeComponentProps,
|
|
15
17
|
type ShapeDef,
|
|
@@ -19,7 +21,6 @@ import {
|
|
|
19
21
|
} from '@dxos/react-ui-canvas-editor';
|
|
20
22
|
|
|
21
23
|
import { useComputeNodeState } from '../hooks';
|
|
22
|
-
|
|
23
24
|
import { Box, createFunctionAnchors } from './common';
|
|
24
25
|
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
25
26
|
|
|
@@ -66,7 +67,7 @@ const TextInputComponent = ({ shape, title, ...props }: TextInputComponentProps)
|
|
|
66
67
|
return;
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
const [fn] = await space.db.query(Filter.type(
|
|
70
|
+
const [fn] = await space.db.query(Filter.type(Operation.PersistentOperation, { source: Ref.make(object) })).run();
|
|
70
71
|
if (!fn) {
|
|
71
72
|
return;
|
|
72
73
|
}
|
package/src/shapes/Gpt.tsx
CHANGED
|
@@ -10,7 +10,6 @@ import { ScrollArea } from '@dxos/react-ui';
|
|
|
10
10
|
import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
11
11
|
|
|
12
12
|
import { useComputeNodeState } from '../hooks';
|
|
13
|
-
|
|
14
13
|
import { FunctionBody, createFunctionAnchors, getHeight } from './common';
|
|
15
14
|
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
16
15
|
|
package/src/shapes/Json.tsx
CHANGED
|
@@ -8,10 +8,9 @@ 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
|
-
|
|
15
14
|
import { Box, createFunctionAnchors, getHeight } from './common';
|
|
16
15
|
import { ComputeShape, type CreateShapeProps, createAnchorId, createShape } from './defs';
|
|
17
16
|
|
|
@@ -50,7 +49,14 @@ export const JsonComponent = ({ shape, ...props }: JsonComponentProps) => {
|
|
|
50
49
|
|
|
51
50
|
return (
|
|
52
51
|
<Box shape={shape}>
|
|
53
|
-
<
|
|
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>
|
|
54
60
|
</Box>
|
|
55
61
|
);
|
|
56
62
|
};
|