@dxos/react-ui-canvas-compute 0.8.4-main.937b3ca → 0.8.4-main.9be5663bfe
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 +399 -389
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +399 -389
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/compute.stories.d.ts.map +1 -1
- package/dist/types/src/graph/controller.d.ts +2 -2
- package/dist/types/src/graph/controller.d.ts.map +1 -1
- package/dist/types/src/hooks/useComputeNodeState.d.ts.map +1 -1
- package/dist/types/src/hooks/useGraphMonitor.d.ts +2 -2
- package/dist/types/src/hooks/useGraphMonitor.d.ts.map +1 -1
- package/dist/types/src/shapes/Audio.d.ts.map +1 -1
- package/dist/types/src/shapes/Beacon.d.ts.map +1 -1
- package/dist/types/src/shapes/Chat.d.ts.map +1 -1
- package/dist/types/src/shapes/Constant.d.ts.map +1 -1
- package/dist/types/src/shapes/{Queue.d.ts → Feed.d.ts} +8 -8
- package/dist/types/src/shapes/Feed.d.ts.map +1 -0
- package/dist/types/src/shapes/Function.d.ts.map +1 -1
- package/dist/types/src/shapes/Gpt.d.ts.map +1 -1
- package/dist/types/src/shapes/Json.d.ts.map +1 -1
- package/dist/types/src/shapes/RNG.d.ts.map +1 -1
- package/dist/types/src/shapes/Scope.d.ts.map +1 -1
- package/dist/types/src/shapes/Surface.d.ts.map +1 -1
- package/dist/types/src/shapes/Switch.d.ts.map +1 -1
- package/dist/types/src/shapes/Template.d.ts.map +1 -1
- package/dist/types/src/shapes/Text.d.ts.map +1 -1
- package/dist/types/src/shapes/Thread.d.ts.map +1 -1
- package/dist/types/src/shapes/Trigger.d.ts +2 -1
- package/dist/types/src/shapes/Trigger.d.ts.map +1 -1
- package/dist/types/src/shapes/common/Box.d.ts +3 -3
- package/dist/types/src/shapes/common/Box.d.ts.map +1 -1
- package/dist/types/src/shapes/common/FunctionBody.d.ts +2 -2
- package/dist/types/src/shapes/common/FunctionBody.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/tsconfig.tsbuildinfo +1 -1
- package/package.json +50 -48
- package/src/README.md +0 -3
- package/src/compute.stories.tsx +17 -9
- package/src/graph/controller.ts +5 -2
- package/src/graph/node-defs.ts +28 -28
- package/src/hooks/useComputeNodeState.ts +0 -1
- package/src/hooks/useGraphMonitor.ts +5 -5
- package/src/registry.ts +2 -2
- package/src/schema.test.ts +3 -3
- package/src/shapes/Audio.tsx +2 -3
- package/src/shapes/Beacon.tsx +1 -2
- package/src/shapes/Boolean.tsx +2 -2
- package/src/shapes/Chat.tsx +0 -1
- package/src/shapes/Constant.tsx +0 -1
- package/src/shapes/{Queue.tsx → Feed.tsx} +21 -20
- package/src/shapes/Function.tsx +3 -3
- package/src/shapes/Gpt.tsx +6 -2
- package/src/shapes/GptRealtime.tsx +1 -1
- package/src/shapes/Json.tsx +7 -3
- package/src/shapes/RNG.tsx +0 -1
- package/src/shapes/Scope.tsx +1 -2
- package/src/shapes/Surface.tsx +4 -3
- package/src/shapes/Switch.tsx +1 -2
- package/src/shapes/Template.tsx +0 -1
- package/src/shapes/Text.tsx +0 -1
- package/src/shapes/Thread.tsx +14 -8
- package/src/shapes/Trigger.tsx +9 -9
- package/src/shapes/common/Box.tsx +7 -10
- package/src/shapes/common/FunctionBody.tsx +4 -4
- package/src/shapes/common/TypeSelect.tsx +1 -1
- 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.9be5663bfe",
|
|
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",
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
"exports": {
|
|
15
15
|
".": {
|
|
16
16
|
"source": "./src/index.ts",
|
|
17
|
-
"types": "./dist/types/src/index.d.ts",
|
|
18
17
|
"browser": "./dist/lib/browser/index.mjs",
|
|
19
|
-
"node": "./dist/lib/node-esm/index.mjs"
|
|
18
|
+
"node": "./dist/lib/node-esm/index.mjs",
|
|
19
|
+
"types": "./dist/types/src/index.d.ts"
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"types": "dist/types/src/index.d.ts",
|
|
@@ -30,64 +30,66 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@antv/graphlib": "^2.0.4",
|
|
32
32
|
"@antv/layout": "^1.2.13",
|
|
33
|
-
"@effect/platform": "0.
|
|
33
|
+
"@effect/platform": "0.94.4",
|
|
34
34
|
"chess.js": "^1.0.0",
|
|
35
|
-
"@dxos/
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/conductor": "0.8.4-main.
|
|
39
|
-
"@dxos/context": "0.8.4-main.
|
|
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/react-
|
|
53
|
-
"@dxos/react-
|
|
54
|
-
"@dxos/react-ui-canvas": "0.8.4-main.
|
|
55
|
-
"@dxos/react-ui-canvas-editor": "0.8.4-main.
|
|
56
|
-
"@dxos/react-ui-editor": "0.8.4-main.
|
|
57
|
-
"@dxos/react-ui-
|
|
58
|
-
"@dxos/react-ui-sfx": "0.8.4-main.
|
|
59
|
-
"@dxos/
|
|
60
|
-
"@dxos/react-
|
|
61
|
-
"@dxos/react-
|
|
62
|
-
"@dxos/
|
|
63
|
-
"@dxos/
|
|
64
|
-
"@dxos/util": "0.8.4-main.
|
|
35
|
+
"@dxos/assistant": "0.8.4-main.9be5663bfe",
|
|
36
|
+
"@dxos/app-framework": "0.8.4-main.9be5663bfe",
|
|
37
|
+
"@dxos/async": "0.8.4-main.9be5663bfe",
|
|
38
|
+
"@dxos/conductor": "0.8.4-main.9be5663bfe",
|
|
39
|
+
"@dxos/context": "0.8.4-main.9be5663bfe",
|
|
40
|
+
"@dxos/blueprints": "0.8.4-main.9be5663bfe",
|
|
41
|
+
"@dxos/debug": "0.8.4-main.9be5663bfe",
|
|
42
|
+
"@dxos/echo": "0.8.4-main.9be5663bfe",
|
|
43
|
+
"@dxos/edge-client": "0.8.4-main.9be5663bfe",
|
|
44
|
+
"@dxos/effect": "0.8.4-main.9be5663bfe",
|
|
45
|
+
"@dxos/functions-runtime": "0.8.4-main.9be5663bfe",
|
|
46
|
+
"@dxos/graph": "0.8.4-main.9be5663bfe",
|
|
47
|
+
"@dxos/functions": "0.8.4-main.9be5663bfe",
|
|
48
|
+
"@dxos/keys": "0.8.4-main.9be5663bfe",
|
|
49
|
+
"@dxos/log": "0.8.4-main.9be5663bfe",
|
|
50
|
+
"@dxos/invariant": "0.8.4-main.9be5663bfe",
|
|
51
|
+
"@dxos/operation": "0.8.4-main.9be5663bfe",
|
|
52
|
+
"@dxos/react-client": "0.8.4-main.9be5663bfe",
|
|
53
|
+
"@dxos/react-ui-attention": "0.8.4-main.9be5663bfe",
|
|
54
|
+
"@dxos/react-ui-canvas": "0.8.4-main.9be5663bfe",
|
|
55
|
+
"@dxos/react-ui-canvas-editor": "0.8.4-main.9be5663bfe",
|
|
56
|
+
"@dxos/react-ui-editor": "0.8.4-main.9be5663bfe",
|
|
57
|
+
"@dxos/react-ui-mosaic": "0.8.4-main.9be5663bfe",
|
|
58
|
+
"@dxos/react-ui-sfx": "0.8.4-main.9be5663bfe",
|
|
59
|
+
"@dxos/react-ui-form": "0.8.4-main.9be5663bfe",
|
|
60
|
+
"@dxos/react-edge-client": "0.8.4-main.9be5663bfe",
|
|
61
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.9be5663bfe",
|
|
62
|
+
"@dxos/react-ui-stack": "0.8.4-main.9be5663bfe",
|
|
63
|
+
"@dxos/schema": "0.8.4-main.9be5663bfe",
|
|
64
|
+
"@dxos/util": "0.8.4-main.9be5663bfe",
|
|
65
|
+
"@dxos/types": "0.8.4-main.9be5663bfe",
|
|
66
|
+
"@dxos/ai": "0.8.4-main.9be5663bfe"
|
|
65
67
|
},
|
|
66
68
|
"devDependencies": {
|
|
67
|
-
"@effect/ai": "0.
|
|
68
|
-
"@effect/experimental": "0.
|
|
69
|
+
"@effect/ai": "0.33.2",
|
|
70
|
+
"@effect/experimental": "0.58.0",
|
|
69
71
|
"@types/lodash.defaultsdeep": "^4.6.6",
|
|
70
72
|
"@types/react": "~19.2.7",
|
|
71
73
|
"@types/react-dom": "~19.2.3",
|
|
72
|
-
"effect": "3.
|
|
74
|
+
"effect": "3.20.0",
|
|
73
75
|
"lodash.defaultsdeep": "^4.6.1",
|
|
74
76
|
"react": "~19.2.3",
|
|
75
77
|
"react-dom": "~19.2.3",
|
|
76
|
-
"vite": "7.1.
|
|
77
|
-
"@dxos/app-framework": "0.8.4-main.
|
|
78
|
-
"@dxos/
|
|
79
|
-
"@dxos/random": "0.8.4-main.
|
|
80
|
-
"@dxos/
|
|
81
|
-
"@dxos/
|
|
82
|
-
"@dxos/
|
|
83
|
-
"@dxos/
|
|
78
|
+
"vite": "^7.1.11",
|
|
79
|
+
"@dxos/app-framework": "0.8.4-main.9be5663bfe",
|
|
80
|
+
"@dxos/assistant-toolkit": "0.8.4-main.9be5663bfe",
|
|
81
|
+
"@dxos/random": "0.8.4-main.9be5663bfe",
|
|
82
|
+
"@dxos/compute": "0.8.4-main.9be5663bfe",
|
|
83
|
+
"@dxos/react-ui": "0.8.4-main.9be5663bfe",
|
|
84
|
+
"@dxos/ui-theme": "0.8.4-main.9be5663bfe",
|
|
85
|
+
"@dxos/storybook-utils": "0.8.4-main.9be5663bfe"
|
|
84
86
|
},
|
|
85
87
|
"peerDependencies": {
|
|
86
|
-
"effect": "3.
|
|
88
|
+
"effect": "3.20.0",
|
|
87
89
|
"react": "~19.2.3",
|
|
88
90
|
"react-dom": "~19.2.3",
|
|
89
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
90
|
-
"@dxos/ui-theme": "0.8.4-main.
|
|
91
|
+
"@dxos/react-ui": "0.8.4-main.9be5663bfe",
|
|
92
|
+
"@dxos/ui-theme": "0.8.4-main.9be5663bfe"
|
|
91
93
|
},
|
|
92
94
|
"publishConfig": {
|
|
93
95
|
"access": "public"
|
package/src/README.md
CHANGED
package/src/compute.stories.tsx
CHANGED
|
@@ -11,17 +11,18 @@ import { AiServiceTestingPreset } from '@dxos/ai/testing';
|
|
|
11
11
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
12
12
|
import { capabilities } from '@dxos/assistant-toolkit/testing';
|
|
13
13
|
import { type ComputeGraphModel, type ComputeNode, type GraphDiagnostic } from '@dxos/conductor';
|
|
14
|
+
import { Feed } from '@dxos/echo';
|
|
14
15
|
import { CredentialsService, TracingService } from '@dxos/functions';
|
|
15
16
|
import { FunctionInvocationServiceLayerTest } from '@dxos/functions-runtime';
|
|
16
17
|
import { TestDatabaseLayer } from '@dxos/functions-runtime/testing';
|
|
17
18
|
import { withClientProvider } from '@dxos/react-client/testing';
|
|
18
19
|
import { Select, Toolbar } from '@dxos/react-ui';
|
|
19
|
-
import { withTheme } from '@dxos/react-ui/testing';
|
|
20
20
|
import { withAttention } from '@dxos/react-ui-attention/testing';
|
|
21
21
|
import { Editor, type EditorController, type EditorRootProps, ShapeRegistry } from '@dxos/react-ui-canvas-editor';
|
|
22
22
|
import { Container, useSelection } from '@dxos/react-ui-canvas-editor/testing';
|
|
23
23
|
import { Form } from '@dxos/react-ui-form';
|
|
24
|
-
import {
|
|
24
|
+
import { Json } from '@dxos/react-ui-syntax-highlighter';
|
|
25
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
25
26
|
|
|
26
27
|
import { DiagnosticOverlay } from './components';
|
|
27
28
|
import { ComputeShapeLayout } from './compute-layout';
|
|
@@ -122,7 +123,7 @@ const DefaultStory = ({
|
|
|
122
123
|
}
|
|
123
124
|
|
|
124
125
|
return (
|
|
125
|
-
<div className='grid grid-cols-[
|
|
126
|
+
<div className='grid grid-cols-[1fr_360px] h-full w-full'>
|
|
126
127
|
<ComputeContext.Provider value={{ controller }}>
|
|
127
128
|
<Container id={id} classNames={['flex grow overflow-hidden', !sidebar && 'col-span-2']}>
|
|
128
129
|
<Editor.Root<ComputeShape>
|
|
@@ -146,10 +147,10 @@ const DefaultStory = ({
|
|
|
146
147
|
</ComputeContext.Provider>
|
|
147
148
|
|
|
148
149
|
{sidebar && (
|
|
149
|
-
<Container id='sidebar' classNames='flex flex-col
|
|
150
|
+
<Container id='sidebar' classNames='flex flex-col h-full overflow-hidden'>
|
|
150
151
|
<Toolbar.Root>
|
|
151
152
|
<Select.Root value={sidebar} onValueChange={(value) => setSidebar(value as RenderProps['sidebar'])}>
|
|
152
|
-
<Select.TriggerButton classNames='
|
|
153
|
+
<Select.TriggerButton classNames='w-full'>{sidebar}</Select.TriggerButton>
|
|
153
154
|
<Select.Portal>
|
|
154
155
|
<Select.Content>
|
|
155
156
|
<Select.Viewport>
|
|
@@ -165,7 +166,7 @@ const DefaultStory = ({
|
|
|
165
166
|
</Select.Root>
|
|
166
167
|
</Toolbar.Root>
|
|
167
168
|
|
|
168
|
-
<div className='flex flex-col
|
|
169
|
+
<div className='flex flex-col h-full overflow-hidden divide-y divider-separator'>
|
|
169
170
|
{/* TODO(burdon): Provide schema. */}
|
|
170
171
|
{sidebar === 'selected' && selected && (
|
|
171
172
|
<Form.Root<ComputeNode> values={getComputeNode(selected.id) ?? {}}>
|
|
@@ -177,7 +178,12 @@ const DefaultStory = ({
|
|
|
177
178
|
</Form.Viewport>
|
|
178
179
|
</Form.Root>
|
|
179
180
|
)}
|
|
180
|
-
<
|
|
181
|
+
<Json.Root data={json}>
|
|
182
|
+
<Json.Content>
|
|
183
|
+
<Json.Filter />
|
|
184
|
+
<Json.Data />
|
|
185
|
+
</Json.Content>
|
|
186
|
+
</Json.Root>
|
|
181
187
|
</div>
|
|
182
188
|
</Container>
|
|
183
189
|
)}
|
|
@@ -190,8 +196,9 @@ const meta = {
|
|
|
190
196
|
component: Editor.Root as any,
|
|
191
197
|
render: DefaultStory,
|
|
192
198
|
decorators: [
|
|
193
|
-
withTheme,
|
|
194
|
-
|
|
199
|
+
withTheme(),
|
|
200
|
+
withLayout({ layout: 'fullscreen' }),
|
|
201
|
+
withAttention(),
|
|
195
202
|
withClientProvider({ createIdentity: true, createSpace: true }),
|
|
196
203
|
withPluginManager({ capabilities }),
|
|
197
204
|
],
|
|
@@ -221,6 +228,7 @@ const ServiceLayer = Layer.empty.pipe(
|
|
|
221
228
|
TestDatabaseLayer(),
|
|
222
229
|
CredentialsService.configuredLayer([]),
|
|
223
230
|
TracingService.layerNoop,
|
|
231
|
+
Feed.notAvailable,
|
|
224
232
|
),
|
|
225
233
|
),
|
|
226
234
|
Layer.orDie,
|
package/src/graph/controller.ts
CHANGED
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
isNotExecuted,
|
|
26
26
|
} from '@dxos/conductor';
|
|
27
27
|
import { Resource } from '@dxos/context';
|
|
28
|
-
import type { Database } from '@dxos/echo';
|
|
28
|
+
import type { Database, Feed } from '@dxos/echo';
|
|
29
29
|
import { unwrapExit } from '@dxos/effect';
|
|
30
30
|
import {
|
|
31
31
|
ComputeEventLogger,
|
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
type CredentialsService,
|
|
34
34
|
type FunctionInvocationService,
|
|
35
35
|
type QueueService,
|
|
36
|
+
Trace,
|
|
36
37
|
TracingService,
|
|
37
38
|
} from '@dxos/functions';
|
|
38
39
|
import { log } from '@dxos/log';
|
|
@@ -41,7 +42,6 @@ import { type ContentBlock } from '@dxos/types';
|
|
|
41
42
|
|
|
42
43
|
import { createComputeGraph } from '../hooks';
|
|
43
44
|
import { type ComputeShape } from '../shapes';
|
|
44
|
-
|
|
45
45
|
import { resolveComputeNode } from './node-defs';
|
|
46
46
|
|
|
47
47
|
// TODO(burdon): API package for conductor.
|
|
@@ -87,6 +87,7 @@ type ComputeOutputEvent = {
|
|
|
87
87
|
export type ComputeServices =
|
|
88
88
|
| AiService.AiService
|
|
89
89
|
| Database.Service
|
|
90
|
+
| Feed.FeedService
|
|
90
91
|
| QueueService
|
|
91
92
|
| CredentialsService
|
|
92
93
|
| FunctionInvocationService;
|
|
@@ -266,6 +267,7 @@ export class ComputeGraphController extends Resource {
|
|
|
266
267
|
Effect.provide(
|
|
267
268
|
ComputeEventLogger.layerFromTracing.pipe(
|
|
268
269
|
Layer.provideMerge(TracingService.layerNoop), // TODO(dmaretskyi): Plug-in tracing events to visual feedback in the compute graph editor.
|
|
270
|
+
Layer.provideMerge(Trace.writerLayerNoop),
|
|
269
271
|
),
|
|
270
272
|
),
|
|
271
273
|
Effect.flatMap(computeValueBag),
|
|
@@ -333,6 +335,7 @@ export class ComputeGraphController extends Resource {
|
|
|
333
335
|
Effect.provide(
|
|
334
336
|
ComputeEventLogger.layerFromTracing.pipe(
|
|
335
337
|
Layer.provideMerge(TracingService.layerNoop), // TODO(dmaretskyi): Plug-in tracing events to visual feedback in the compute graph editor.
|
|
338
|
+
Layer.provideMerge(Trace.writerLayerNoop),
|
|
336
339
|
),
|
|
337
340
|
),
|
|
338
341
|
|
package/src/graph/node-defs.ts
CHANGED
|
@@ -39,41 +39,41 @@ const nodeFactory: Record<NodeType | 'trigger', (shape: ComputeShape) => Compute
|
|
|
39
39
|
[NODE_OUTPUT]: () => createNode(NODE_OUTPUT),
|
|
40
40
|
|
|
41
41
|
// Extensions.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
'text-to-image': () => createNode('text-to-image'), // TODO(burdon): Rename ai-impage-tool
|
|
43
|
+
and: () => createNode('and'),
|
|
44
|
+
append: () => createNode('append'),
|
|
45
|
+
audio: () => createNode('audio'),
|
|
46
|
+
beacon: () => createNode('beacon'),
|
|
47
|
+
chat: () => createNode('chat'),
|
|
48
|
+
constant: (shape) =>
|
|
49
49
|
createNode('constant', {
|
|
50
50
|
value: (shape as ConstantShape).value,
|
|
51
51
|
}),
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
52
|
+
'make-queue': () => createNode('make-queue'),
|
|
53
|
+
database: () => createNode('database'),
|
|
54
|
+
gpt: () => createNode('gpt'),
|
|
55
|
+
'gpt-realtime': () => createNode('gpt-realtime'),
|
|
56
|
+
if: () => createNode('if'),
|
|
57
|
+
'if-else': () => createNode('if-else'),
|
|
58
|
+
function: () => createNode('function'),
|
|
59
|
+
json: () => createNode('json'),
|
|
60
|
+
'json-transform': () => createNode('json-transform'),
|
|
61
|
+
not: () => createNode('not'),
|
|
62
|
+
or: () => createNode('or'),
|
|
63
|
+
queue: () => createNode('queue'),
|
|
64
|
+
rng: () => createNode('rng'),
|
|
65
|
+
reducer: () => createNode('reducer'),
|
|
66
|
+
scope: () => createNode('scope'),
|
|
67
|
+
surface: () => createNode('surface'),
|
|
68
|
+
switch: () => createNode('switch'),
|
|
69
|
+
template: (shape) => {
|
|
70
70
|
const node = createNode('template', { valueType: (shape as TemplateShape).valueType, value: shape.text });
|
|
71
71
|
node.inputSchema = JsonSchema.toJsonSchema(getTemplateInputSchema(node));
|
|
72
72
|
return node;
|
|
73
73
|
},
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
text: () => createNode('text'),
|
|
75
|
+
thread: () => createNode('thread'),
|
|
76
|
+
trigger: () => createNode(NODE_INPUT),
|
|
77
77
|
};
|
|
78
78
|
|
|
79
79
|
const createNode = (type: string, props?: Partial<ComputeNode>): ComputeNode => ({
|
|
@@ -7,7 +7,7 @@ import { useMemo } from 'react';
|
|
|
7
7
|
import { type ComputeEdge, ComputeGraphModel, type ComputeNode, DEFAULT_INPUT, DEFAULT_OUTPUT } from '@dxos/conductor';
|
|
8
8
|
import { Obj, Ref } from '@dxos/echo';
|
|
9
9
|
import { invariant } from '@dxos/invariant';
|
|
10
|
-
import { type
|
|
10
|
+
import { type CanvasBoard, type CanvasGraphModel, type GraphMonitor } from '@dxos/react-ui-canvas-editor';
|
|
11
11
|
import { isNonNullable } from '@dxos/util';
|
|
12
12
|
|
|
13
13
|
import { createComputeNode, isValidComputeNode } from '../graph';
|
|
@@ -18,7 +18,7 @@ import { type ComputeShape, type TriggerShape } from '../shapes';
|
|
|
18
18
|
*/
|
|
19
19
|
export const mapEdge = (
|
|
20
20
|
graph: CanvasGraphModel,
|
|
21
|
-
{ source, target, output = DEFAULT_OUTPUT, input = DEFAULT_INPUT }: Connection,
|
|
21
|
+
{ source, target, output = DEFAULT_OUTPUT, input = DEFAULT_INPUT }: CanvasBoard.Connection,
|
|
22
22
|
): ComputeEdge => {
|
|
23
23
|
const sourceNode = graph.findNode(source) as ComputeShape;
|
|
24
24
|
const targetNode = graph.findNode(target) as ComputeShape;
|
|
@@ -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.change(functionTrigger, (
|
|
116
|
-
|
|
117
|
-
|
|
115
|
+
Obj.change(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/schema.test.ts
CHANGED
|
@@ -7,9 +7,9 @@ import { describe, test } from 'vitest';
|
|
|
7
7
|
|
|
8
8
|
import { Graph } from '@dxos/graph';
|
|
9
9
|
import {
|
|
10
|
+
CanvasBoard,
|
|
10
11
|
CanvasGraphModel,
|
|
11
12
|
Polygon,
|
|
12
|
-
Shape,
|
|
13
13
|
createEllipse,
|
|
14
14
|
createPath,
|
|
15
15
|
createRectangle,
|
|
@@ -26,7 +26,7 @@ describe('compute', () => {
|
|
|
26
26
|
console.log(JSON.stringify(node, null, 2));
|
|
27
27
|
expect(Schema.is(ComputeShape)(node)).toBe(true);
|
|
28
28
|
expect(Schema.is(Polygon)(node)).toBe(true);
|
|
29
|
-
expect(Schema.is(Shape)(node)).toBe(true);
|
|
29
|
+
expect(Schema.is(CanvasBoard.Shape)(node)).toBe(true);
|
|
30
30
|
expect(Schema.is(Graph.Node)(node)).toBe(true);
|
|
31
31
|
|
|
32
32
|
const graph: Graph.Any = { nodes: [], edges: [] };
|
|
@@ -39,7 +39,7 @@ describe('compute', () => {
|
|
|
39
39
|
|
|
40
40
|
describe('schema', () => {
|
|
41
41
|
test('basic types', ({ expect }) => {
|
|
42
|
-
const shapes: Shape[] = [];
|
|
42
|
+
const shapes: CanvasBoard.Shape[] = [];
|
|
43
43
|
shapes.push(createRectangle({ id: 'shape-1', center: { x: 0, y: 0 }, size: { width: 80, height: 80 } }));
|
|
44
44
|
shapes.push(createEllipse({ id: 'shape-2', center: { x: 0, y: 0 }, size: { width: 80, height: 80 } }));
|
|
45
45
|
shapes.push(createFunction({ id: 'shape-3', center: { x: 0, y: 0 } }));
|
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(
|
|
@@ -35,10 +34,10 @@ export const AudioComponent = ({ shape }: ShapeComponentProps<AudioShape>) => {
|
|
|
35
34
|
|
|
36
35
|
// https://docs.pmnd.rs/react-three-fiber/api/canvas#render-props
|
|
37
36
|
return (
|
|
38
|
-
<div className='flex
|
|
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(
|
|
@@ -33,7 +32,7 @@ export const BeaconComponent = ({ shape }: ShapeComponentProps<BeaconShape>) =>
|
|
|
33
32
|
const value = input?.type === 'executed' ? input.value : false;
|
|
34
33
|
|
|
35
34
|
return (
|
|
36
|
-
<div className='flex
|
|
35
|
+
<div className='flex w-full justify-center items-center'>
|
|
37
36
|
<Icon
|
|
38
37
|
icon='ph--sun--regular'
|
|
39
38
|
classNames={['transition opacity-20 duration-1000', isTruthy(value) && 'opacity-100 text-yellow-500']}
|
package/src/shapes/Boolean.tsx
CHANGED
|
@@ -57,7 +57,7 @@ const defineShape = <S extends GateShape>({
|
|
|
57
57
|
// Be careful not to name component factories with a capital letter.
|
|
58
58
|
component: () => {
|
|
59
59
|
return (
|
|
60
|
-
<div className='flex
|
|
60
|
+
<div className='flex w-full justify-center items-center'>
|
|
61
61
|
<Symbol />
|
|
62
62
|
</div>
|
|
63
63
|
);
|
|
@@ -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
|
|
|
@@ -6,35 +6,34 @@ import * as Schema from 'effect/Schema';
|
|
|
6
6
|
import React, { Fragment } from 'react';
|
|
7
7
|
|
|
8
8
|
import { DEFAULT_OUTPUT, QueueInput, QueueOutput } from '@dxos/conductor';
|
|
9
|
-
import { type ThemedClassName } from '@dxos/react-ui';
|
|
9
|
+
import { ScrollArea, type ThemedClassName } from '@dxos/react-ui';
|
|
10
10
|
import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
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
|
|
|
@@ -46,22 +45,24 @@ export const QueueComponent = ({ shape }: ShapeComponentProps<QueueShape>) => {
|
|
|
46
45
|
|
|
47
46
|
return (
|
|
48
47
|
<Box shape={shape} status={`${items.length} items`} onAction={handleAction}>
|
|
49
|
-
<
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
<ScrollArea.Root orientation='vertical'>
|
|
49
|
+
<ScrollArea.Viewport classNames='divide-y divide-separator'>
|
|
50
|
+
{[...items].map((item, i) => (
|
|
51
|
+
<FeedItem key={i} classNames='p-1 px-2' item={item} />
|
|
52
|
+
))}
|
|
53
|
+
</ScrollArea.Viewport>
|
|
54
|
+
</ScrollArea.Root>
|
|
54
55
|
</Box>
|
|
55
56
|
);
|
|
56
57
|
};
|
|
57
58
|
|
|
58
|
-
export const
|
|
59
|
+
export const FeedItem = ({ classNames, item }: ThemedClassName<{ item: any }>) => {
|
|
59
60
|
if (typeof item !== 'object') {
|
|
60
61
|
return <div className={mx(classNames, 'whitespace-pre-wrap')}>{item}</div>;
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
return (
|
|
64
|
-
<div className={mx('grid grid-cols-[
|
|
65
|
+
<div className={mx('grid grid-cols-[80px_1fr]', classNames)}>
|
|
65
66
|
{Object.entries(item).map(([key, value]) => (
|
|
66
67
|
<Fragment key={key}>
|
|
67
68
|
<div className='p-1 text-xs text-subdued'>{key}</div>
|
|
@@ -72,12 +73,12 @@ export const QueueItem = ({ classNames, item }: ThemedClassName<{ item: any }>)
|
|
|
72
73
|
);
|
|
73
74
|
};
|
|
74
75
|
|
|
75
|
-
export const
|
|
76
|
-
type: '
|
|
77
|
-
name: '
|
|
76
|
+
export const feedShape: ShapeDef<FeedShape> = {
|
|
77
|
+
type: 'feed',
|
|
78
|
+
name: 'Feed',
|
|
78
79
|
icon: 'ph--queue--regular',
|
|
79
|
-
component:
|
|
80
|
-
createShape:
|
|
80
|
+
component: FeedComponent,
|
|
81
|
+
createShape: createFeed,
|
|
81
82
|
getAnchors: (shape) => createFunctionAnchors(shape, QueueInput, QueueOutput),
|
|
82
83
|
resizable: true,
|
|
83
84
|
};
|
package/src/shapes/Function.tsx
CHANGED
|
@@ -7,7 +7,8 @@ import React, { useCallback, useRef } from 'react';
|
|
|
7
7
|
|
|
8
8
|
import { AnyOutput, FunctionInput } from '@dxos/conductor';
|
|
9
9
|
import { Ref, getSnapshot, isInstanceOf } from '@dxos/echo/internal';
|
|
10
|
-
import {
|
|
10
|
+
import { Script } from '@dxos/functions';
|
|
11
|
+
import { Operation } from '@dxos/operation';
|
|
11
12
|
import { useClient } from '@dxos/react-client';
|
|
12
13
|
import { Filter, parseId } from '@dxos/react-client/echo';
|
|
13
14
|
import {
|
|
@@ -19,7 +20,6 @@ import {
|
|
|
19
20
|
} from '@dxos/react-ui-canvas-editor';
|
|
20
21
|
|
|
21
22
|
import { useComputeNodeState } from '../hooks';
|
|
22
|
-
|
|
23
23
|
import { Box, createFunctionAnchors } from './common';
|
|
24
24
|
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
25
25
|
|
|
@@ -66,7 +66,7 @@ const TextInputComponent = ({ shape, title, ...props }: TextInputComponentProps)
|
|
|
66
66
|
return;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
const [fn] = await space.db.query(Filter.type(
|
|
69
|
+
const [fn] = await space.db.query(Filter.type(Operation.PersistentOperation, { source: Ref.make(object) })).run();
|
|
70
70
|
if (!fn) {
|
|
71
71
|
return;
|
|
72
72
|
}
|