@dxos/react-ui-canvas-compute 0.8.4-main.c85a9c8dae → 0.8.4-main.d9fc60f731
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 +391 -469
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +391 -469
- 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 +44 -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 +7 -30
- 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 +50 -51
- package/src/compute.stories.tsx +26 -10
- package/src/graph/controller.ts +64 -27
- 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 +1 -2
- 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/Table.tsx +3 -2
- package/src/shapes/Template.tsx +0 -1
- package/src/shapes/Text.tsx +0 -1
- package/src/shapes/Thread.tsx +4 -7
- package/src/shapes/Trigger.tsx +23 -23
- package/src/shapes/common/Box.tsx +1 -3
- package/src/shapes/index.ts +2 -2
- package/src/testing/circuits.ts +5 -5
- 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.d9fc60f731",
|
|
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"
|
|
@@ -30,65 +27,67 @@
|
|
|
30
27
|
"dependencies": {
|
|
31
28
|
"@antv/graphlib": "^2.0.4",
|
|
32
29
|
"@antv/layout": "^1.2.13",
|
|
33
|
-
"@effect/platform": "0.
|
|
30
|
+
"@effect/platform": "0.96.1",
|
|
34
31
|
"chess.js": "^1.0.0",
|
|
35
|
-
"
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
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-ui-
|
|
58
|
-
"@dxos/react-
|
|
59
|
-
"@dxos/react-ui-
|
|
60
|
-
"@dxos/react-ui-
|
|
61
|
-
"@dxos/
|
|
62
|
-
"@dxos/
|
|
63
|
-
"@dxos/react-ui-stack": "0.8.4-main.
|
|
64
|
-
"@dxos/
|
|
65
|
-
"@dxos/
|
|
32
|
+
"workerize-loader": "^2.0.2",
|
|
33
|
+
"@dxos/ai": "0.8.4-main.d9fc60f731",
|
|
34
|
+
"@dxos/app-framework": "0.8.4-main.d9fc60f731",
|
|
35
|
+
"@dxos/app-toolkit": "0.8.4-main.d9fc60f731",
|
|
36
|
+
"@dxos/async": "0.8.4-main.d9fc60f731",
|
|
37
|
+
"@dxos/compute": "0.8.4-main.d9fc60f731",
|
|
38
|
+
"@dxos/compute-runtime": "0.8.4-main.d9fc60f731",
|
|
39
|
+
"@dxos/assistant": "0.8.4-main.d9fc60f731",
|
|
40
|
+
"@dxos/conductor": "0.8.4-main.d9fc60f731",
|
|
41
|
+
"@dxos/debug": "0.8.4-main.d9fc60f731",
|
|
42
|
+
"@dxos/context": "0.8.4-main.d9fc60f731",
|
|
43
|
+
"@dxos/effect": "0.8.4-main.d9fc60f731",
|
|
44
|
+
"@dxos/edge-client": "0.8.4-main.d9fc60f731",
|
|
45
|
+
"@dxos/echo": "0.8.4-main.d9fc60f731",
|
|
46
|
+
"@dxos/functions-runtime": "0.8.4-main.d9fc60f731",
|
|
47
|
+
"@dxos/functions": "0.8.4-main.d9fc60f731",
|
|
48
|
+
"@dxos/graph": "0.8.4-main.d9fc60f731",
|
|
49
|
+
"@dxos/keys": "0.8.4-main.d9fc60f731",
|
|
50
|
+
"@dxos/invariant": "0.8.4-main.d9fc60f731",
|
|
51
|
+
"@dxos/log": "0.8.4-main.d9fc60f731",
|
|
52
|
+
"@dxos/react-client": "0.8.4-main.d9fc60f731",
|
|
53
|
+
"@dxos/react-ui-attention": "0.8.4-main.d9fc60f731",
|
|
54
|
+
"@dxos/react-ui-canvas": "0.8.4-main.d9fc60f731",
|
|
55
|
+
"@dxos/react-edge-client": "0.8.4-main.d9fc60f731",
|
|
56
|
+
"@dxos/react-ui-editor": "0.8.4-main.d9fc60f731",
|
|
57
|
+
"@dxos/react-ui-form": "0.8.4-main.d9fc60f731",
|
|
58
|
+
"@dxos/react-ui-mosaic": "0.8.4-main.d9fc60f731",
|
|
59
|
+
"@dxos/react-ui-sfx": "0.8.4-main.d9fc60f731",
|
|
60
|
+
"@dxos/react-ui-stack": "0.8.4-main.d9fc60f731",
|
|
61
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.d9fc60f731",
|
|
62
|
+
"@dxos/schema": "0.8.4-main.d9fc60f731",
|
|
63
|
+
"@dxos/types": "0.8.4-main.d9fc60f731",
|
|
64
|
+
"@dxos/react-ui-canvas-editor": "0.8.4-main.d9fc60f731",
|
|
65
|
+
"@dxos/util": "0.8.4-main.d9fc60f731"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@effect/ai": "0.
|
|
69
|
-
"@effect/experimental": "0.
|
|
68
|
+
"@effect/ai": "0.35.0",
|
|
69
|
+
"@effect/experimental": "0.60.0",
|
|
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.21.2",
|
|
74
74
|
"lodash.defaultsdeep": "^4.6.1",
|
|
75
75
|
"react": "~19.2.3",
|
|
76
76
|
"react-dom": "~19.2.3",
|
|
77
|
-
"vite": "^
|
|
78
|
-
"@dxos/
|
|
79
|
-
"@dxos/
|
|
80
|
-
"@dxos/
|
|
81
|
-
"@dxos/
|
|
82
|
-
"@dxos/
|
|
83
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
84
|
-
"@dxos/ui-theme": "0.8.4-main.c85a9c8dae"
|
|
77
|
+
"vite": "^8.0.14",
|
|
78
|
+
"@dxos/app-framework": "0.8.4-main.d9fc60f731",
|
|
79
|
+
"@dxos/assistant-toolkit": "0.8.4-main.d9fc60f731",
|
|
80
|
+
"@dxos/random": "0.8.4-main.d9fc60f731",
|
|
81
|
+
"@dxos/storybook-utils": "0.8.4-main.d9fc60f731",
|
|
82
|
+
"@dxos/ui-theme": "0.8.4-main.d9fc60f731",
|
|
83
|
+
"@dxos/react-ui": "0.8.4-main.d9fc60f731"
|
|
85
84
|
},
|
|
86
85
|
"peerDependencies": {
|
|
87
|
-
"effect": "3.
|
|
86
|
+
"effect": "3.21.2",
|
|
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.d9fc60f731",
|
|
90
|
+
"@dxos/ui-theme": "0.8.4-main.d9fc60f731"
|
|
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,12 @@ 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';
|
|
38
35
|
import { log } from '@dxos/log';
|
|
39
36
|
import { type CanvasGraphModel } from '@dxos/react-ui-canvas-editor';
|
|
40
37
|
import { type ContentBlock } from '@dxos/types';
|
|
41
38
|
|
|
42
39
|
import { createComputeGraph } from '../hooks';
|
|
43
40
|
import { type ComputeShape } from '../shapes';
|
|
44
|
-
|
|
45
41
|
import { resolveComputeNode } from './node-defs';
|
|
46
42
|
|
|
47
43
|
// TODO(burdon): API package for conductor.
|
|
@@ -83,23 +79,43 @@ type ComputeOutputEvent = {
|
|
|
83
79
|
value: RuntimeValue;
|
|
84
80
|
};
|
|
85
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Event emitted by the compute graph during execution.
|
|
84
|
+
*/
|
|
85
|
+
export type ComputeEvent =
|
|
86
|
+
| { type: 'begin-compute'; nodeId: string; inputs: ReadonlyArray<string> }
|
|
87
|
+
| { type: 'end-compute'; nodeId: string; outputs: ReadonlyArray<string> }
|
|
88
|
+
| { type: 'compute-input'; nodeId: string; property: string; value: any }
|
|
89
|
+
| { type: 'compute-output'; nodeId: string; property: string; value: any }
|
|
90
|
+
| { type: 'custom'; nodeId: string; event: any };
|
|
91
|
+
|
|
86
92
|
// TODO(dmaretskyi): Re-use function servies definition.
|
|
87
93
|
export type ComputeServices =
|
|
88
94
|
| AiService.AiService
|
|
89
95
|
| Database.Service
|
|
90
|
-
| Feed.
|
|
91
|
-
|
|
|
92
|
-
|
|
|
93
|
-
|
|
|
96
|
+
| Feed.FeedService
|
|
97
|
+
| Credential.CredentialsService
|
|
98
|
+
| Operation.Service
|
|
99
|
+
| OperationRegistry.Service;
|
|
94
100
|
|
|
95
101
|
/**
|
|
96
102
|
* Nodes that will automatically trigger the execution of the graph on startup.
|
|
97
103
|
*/
|
|
98
104
|
const AUTO_TRIGGER_NODES = ['chat', 'switch', 'constant'];
|
|
99
105
|
|
|
106
|
+
/**
|
|
107
|
+
* Minimal runtime interface required by the {@link ComputeGraphController}.
|
|
108
|
+
*
|
|
109
|
+
* Satisfied by both `effect/ManagedRuntime.ManagedRuntime` and ad-hoc adapters
|
|
110
|
+
* built on top of the app-framework `ProcessManagerRuntime`.
|
|
111
|
+
*/
|
|
112
|
+
export interface ComputeGraphRuntime {
|
|
113
|
+
runPromiseExit<A, E>(effect: Effect.Effect<A, E, ComputeServices>): Promise<Exit.Exit<A, E>>;
|
|
114
|
+
}
|
|
115
|
+
|
|
100
116
|
export const createComputeGraphController = (
|
|
101
117
|
graph: CanvasGraphModel<ComputeShape>,
|
|
102
|
-
computeRuntime:
|
|
118
|
+
computeRuntime: ComputeGraphRuntime,
|
|
103
119
|
) => {
|
|
104
120
|
const computeGraph = createComputeGraph(graph);
|
|
105
121
|
const controller = new ComputeGraphController(computeRuntime, computeGraph);
|
|
@@ -134,10 +150,10 @@ export class ComputeGraphController extends Resource {
|
|
|
134
150
|
/** Computed result. */
|
|
135
151
|
public readonly output = new Event<ComputeOutputEvent>();
|
|
136
152
|
|
|
137
|
-
public readonly events = new Event<
|
|
153
|
+
public readonly events = new Event<ComputeEvent>();
|
|
138
154
|
|
|
139
155
|
constructor(
|
|
140
|
-
private readonly _computeRuntime:
|
|
156
|
+
private readonly _computeRuntime: ComputeGraphRuntime,
|
|
141
157
|
/** Persistent compute graph. */
|
|
142
158
|
private readonly _graph: ComputeGraphModel,
|
|
143
159
|
) {
|
|
@@ -265,8 +281,9 @@ export class ComputeGraphController extends Resource {
|
|
|
265
281
|
Effect.withSpan('runGraph'),
|
|
266
282
|
Scope.extend(scope),
|
|
267
283
|
Effect.provide(
|
|
268
|
-
|
|
269
|
-
Layer.
|
|
284
|
+
Layer.mergeAll(
|
|
285
|
+
Layer.succeed(Trace.TraceService, this._createTraceWriter()),
|
|
286
|
+
ComputeNodeContext.layerNoop,
|
|
270
287
|
),
|
|
271
288
|
),
|
|
272
289
|
Effect.flatMap(computeValueBag),
|
|
@@ -332,8 +349,9 @@ export class ComputeGraphController extends Resource {
|
|
|
332
349
|
Scope.extend(scope),
|
|
333
350
|
Effect.flatMap(computeValueBag),
|
|
334
351
|
Effect.provide(
|
|
335
|
-
|
|
336
|
-
Layer.
|
|
352
|
+
Layer.mergeAll(
|
|
353
|
+
Layer.succeed(Trace.TraceService, this._createTraceWriter()),
|
|
354
|
+
ComputeNodeContext.layerNoop,
|
|
337
355
|
),
|
|
338
356
|
),
|
|
339
357
|
|
|
@@ -364,16 +382,18 @@ export class ComputeGraphController extends Resource {
|
|
|
364
382
|
this.update.emit();
|
|
365
383
|
}
|
|
366
384
|
|
|
367
|
-
private
|
|
385
|
+
private _createTraceWriter(): Trace.TraceWriter {
|
|
368
386
|
return {
|
|
369
|
-
|
|
370
|
-
|
|
387
|
+
write: (eventType, payload) => {
|
|
388
|
+
const event = traceEventToComputeEvent(eventType.key, payload);
|
|
389
|
+
if (event) {
|
|
390
|
+
this._handleEvent(event);
|
|
391
|
+
}
|
|
371
392
|
},
|
|
372
|
-
nodeId: undefined, // Not in a context of a specific node.
|
|
373
393
|
};
|
|
374
394
|
}
|
|
375
395
|
|
|
376
|
-
private _handleEvent(event:
|
|
396
|
+
private _handleEvent(event: ComputeEvent): void {
|
|
377
397
|
log('handleEvent', { event });
|
|
378
398
|
switch (event.type) {
|
|
379
399
|
case 'compute-input': {
|
|
@@ -403,6 +423,23 @@ export class ComputeGraphController extends Resource {
|
|
|
403
423
|
}
|
|
404
424
|
}
|
|
405
425
|
|
|
426
|
+
const traceEventToComputeEvent = (key: string, payload: unknown): ComputeEvent | undefined => {
|
|
427
|
+
switch (key) {
|
|
428
|
+
case ComputeBeginEvent.key:
|
|
429
|
+
return { type: 'begin-compute', ...(payload as { nodeId: string; inputs: ReadonlyArray<string> }) };
|
|
430
|
+
case ComputeEndEvent.key:
|
|
431
|
+
return { type: 'end-compute', ...(payload as { nodeId: string; outputs: ReadonlyArray<string> }) };
|
|
432
|
+
case ComputeInputEvent.key:
|
|
433
|
+
return { type: 'compute-input', ...(payload as { nodeId: string; property: string; value: any }) };
|
|
434
|
+
case ComputeOutputEvent.key:
|
|
435
|
+
return { type: 'compute-output', ...(payload as { nodeId: string; property: string; value: any }) };
|
|
436
|
+
case ComputeCustomEvent.key:
|
|
437
|
+
return { type: 'custom', ...(payload as { nodeId: string; event: any }) };
|
|
438
|
+
default:
|
|
439
|
+
return undefined;
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
|
|
406
443
|
/**
|
|
407
444
|
* Waits for all effects in the bag to complete and returns the `RuntimeValue` for each property.
|
|
408
445
|
*/
|
|
@@ -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(
|
|
@@ -38,7 +37,7 @@ export const AudioComponent = ({ shape }: ShapeComponentProps<AudioShape>) => {
|
|
|
38
37
|
<div className='flex w-full justify-center items-center'>
|
|
39
38
|
<Icon
|
|
40
39
|
icon={active ? 'ph--microphone--regular' : 'ph--microphone-slash--regular'}
|
|
41
|
-
classNames={['transition opacity-20 duration-1000', active && 'opacity-100 text-
|
|
40
|
+
classNames={['transition opacity-20 duration-1000', active && 'opacity-100 text-error-text']}
|
|
42
41
|
size={8}
|
|
43
42
|
onClick={() => setActive(!active)}
|
|
44
43
|
/>
|
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
|
|