@dxos/react-ui-canvas-compute 0.8.4-main.bc674ce → 0.8.4-main.bcb3aa67d6
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 +394 -384
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +394 -384
- 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/useGraphMonitor.d.ts +2 -2
- package/dist/types/src/hooks/useGraphMonitor.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/Surface.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 -1
- package/src/graph/node-defs.ts +28 -28
- 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 -2
- package/src/shapes/Beacon.tsx +1 -1
- package/src/shapes/Boolean.tsx +2 -2
- package/src/shapes/{Queue.tsx → Feed.tsx} +21 -19
- package/src/shapes/Function.tsx +3 -2
- package/src/shapes/Gpt.tsx +6 -1
- package/src/shapes/GptRealtime.tsx +1 -1
- package/src/shapes/Json.tsx +7 -2
- package/src/shapes/Scope.tsx +1 -1
- package/src/shapes/Surface.tsx +4 -2
- package/src/shapes/Switch.tsx +1 -1
- package/src/shapes/Thread.tsx +14 -8
- package/src/shapes/Trigger.tsx +7 -7
- 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.bcb3aa67d6",
|
|
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/async": "0.8.4-main.
|
|
39
|
-
"@dxos/
|
|
40
|
-
"@dxos/
|
|
41
|
-
"@dxos/context": "0.8.4-main.
|
|
42
|
-
"@dxos/echo": "0.8.4-main.
|
|
43
|
-
"@dxos/edge-client": "0.8.4-main.
|
|
44
|
-
"@dxos/
|
|
45
|
-
"@dxos/
|
|
46
|
-
"@dxos/functions": "0.8.4-main.
|
|
47
|
-
"@dxos/
|
|
48
|
-
"@dxos/graph": "0.8.4-main.
|
|
49
|
-
"@dxos/invariant": "0.8.4-main.
|
|
50
|
-
"@dxos/log": "0.8.4-main.
|
|
51
|
-
"@dxos/keys": "0.8.4-main.
|
|
52
|
-
"@dxos/
|
|
53
|
-
"@dxos/react-
|
|
54
|
-
"@dxos/react-
|
|
55
|
-
"@dxos/react-
|
|
56
|
-
"@dxos/react-ui-canvas
|
|
57
|
-
"@dxos/react-ui-editor": "0.8.4-main.
|
|
58
|
-
"@dxos/react-ui-
|
|
59
|
-
"@dxos/react-ui-
|
|
60
|
-
"@dxos/react-ui-
|
|
61
|
-
"@dxos/react-ui-
|
|
62
|
-
"@dxos/
|
|
63
|
-
"@dxos/
|
|
64
|
-
"@dxos/
|
|
35
|
+
"@dxos/app-framework": "0.8.4-main.bcb3aa67d6",
|
|
36
|
+
"@dxos/assistant": "0.8.4-main.bcb3aa67d6",
|
|
37
|
+
"@dxos/blueprints": "0.8.4-main.bcb3aa67d6",
|
|
38
|
+
"@dxos/async": "0.8.4-main.bcb3aa67d6",
|
|
39
|
+
"@dxos/conductor": "0.8.4-main.bcb3aa67d6",
|
|
40
|
+
"@dxos/ai": "0.8.4-main.bcb3aa67d6",
|
|
41
|
+
"@dxos/context": "0.8.4-main.bcb3aa67d6",
|
|
42
|
+
"@dxos/echo": "0.8.4-main.bcb3aa67d6",
|
|
43
|
+
"@dxos/edge-client": "0.8.4-main.bcb3aa67d6",
|
|
44
|
+
"@dxos/effect": "0.8.4-main.bcb3aa67d6",
|
|
45
|
+
"@dxos/functions": "0.8.4-main.bcb3aa67d6",
|
|
46
|
+
"@dxos/functions-runtime": "0.8.4-main.bcb3aa67d6",
|
|
47
|
+
"@dxos/debug": "0.8.4-main.bcb3aa67d6",
|
|
48
|
+
"@dxos/graph": "0.8.4-main.bcb3aa67d6",
|
|
49
|
+
"@dxos/invariant": "0.8.4-main.bcb3aa67d6",
|
|
50
|
+
"@dxos/log": "0.8.4-main.bcb3aa67d6",
|
|
51
|
+
"@dxos/keys": "0.8.4-main.bcb3aa67d6",
|
|
52
|
+
"@dxos/operation": "0.8.4-main.bcb3aa67d6",
|
|
53
|
+
"@dxos/react-client": "0.8.4-main.bcb3aa67d6",
|
|
54
|
+
"@dxos/react-edge-client": "0.8.4-main.bcb3aa67d6",
|
|
55
|
+
"@dxos/react-ui-attention": "0.8.4-main.bcb3aa67d6",
|
|
56
|
+
"@dxos/react-ui-canvas": "0.8.4-main.bcb3aa67d6",
|
|
57
|
+
"@dxos/react-ui-canvas-editor": "0.8.4-main.bcb3aa67d6",
|
|
58
|
+
"@dxos/react-ui-editor": "0.8.4-main.bcb3aa67d6",
|
|
59
|
+
"@dxos/react-ui-form": "0.8.4-main.bcb3aa67d6",
|
|
60
|
+
"@dxos/react-ui-sfx": "0.8.4-main.bcb3aa67d6",
|
|
61
|
+
"@dxos/react-ui-stack": "0.8.4-main.bcb3aa67d6",
|
|
62
|
+
"@dxos/schema": "0.8.4-main.bcb3aa67d6",
|
|
63
|
+
"@dxos/react-ui-syntax-highlighter": "0.8.4-main.bcb3aa67d6",
|
|
64
|
+
"@dxos/types": "0.8.4-main.bcb3aa67d6",
|
|
65
|
+
"@dxos/util": "0.8.4-main.bcb3aa67d6",
|
|
66
|
+
"@dxos/react-ui-mosaic": "0.8.4-main.bcb3aa67d6"
|
|
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/
|
|
80
|
-
"@dxos/assistant-toolkit": "0.8.4-main.
|
|
81
|
-
"@dxos/react-ui": "0.8.4-main.
|
|
82
|
-
"@dxos/
|
|
83
|
-
"@dxos/
|
|
78
|
+
"vite": "^7.1.11",
|
|
79
|
+
"@dxos/app-framework": "0.8.4-main.bcb3aa67d6",
|
|
80
|
+
"@dxos/compute": "0.8.4-main.bcb3aa67d6",
|
|
81
|
+
"@dxos/random": "0.8.4-main.bcb3aa67d6",
|
|
82
|
+
"@dxos/assistant-toolkit": "0.8.4-main.bcb3aa67d6",
|
|
83
|
+
"@dxos/react-ui": "0.8.4-main.bcb3aa67d6",
|
|
84
|
+
"@dxos/ui-theme": "0.8.4-main.bcb3aa67d6",
|
|
85
|
+
"@dxos/storybook-utils": "0.8.4-main.bcb3aa67d6"
|
|
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.bcb3aa67d6",
|
|
92
|
+
"@dxos/ui-theme": "0.8.4-main.bcb3aa67d6"
|
|
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
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
20
21
|
import { withAttention } from '@dxos/react-ui-attention/testing';
|
|
21
22
|
import { Editor, type EditorController, type EditorRootProps, ShapeRegistry } from '@dxos/react-ui-canvas-editor';
|
|
22
23
|
import { Container, useSelection } from '@dxos/react-ui-canvas-editor/testing';
|
|
23
24
|
import { Form } from '@dxos/react-ui-form';
|
|
24
|
-
import {
|
|
25
|
+
import { Json } from '@dxos/react-ui-syntax-highlighter';
|
|
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';
|
|
@@ -87,6 +88,7 @@ type ComputeOutputEvent = {
|
|
|
87
88
|
export type ComputeServices =
|
|
88
89
|
| AiService.AiService
|
|
89
90
|
| Database.Service
|
|
91
|
+
| Feed.Service
|
|
90
92
|
| QueueService
|
|
91
93
|
| CredentialsService
|
|
92
94
|
| FunctionInvocationService;
|
|
@@ -266,6 +268,7 @@ export class ComputeGraphController extends Resource {
|
|
|
266
268
|
Effect.provide(
|
|
267
269
|
ComputeEventLogger.layerFromTracing.pipe(
|
|
268
270
|
Layer.provideMerge(TracingService.layerNoop), // TODO(dmaretskyi): Plug-in tracing events to visual feedback in the compute graph editor.
|
|
271
|
+
Layer.provideMerge(Trace.writerLayerNoop),
|
|
269
272
|
),
|
|
270
273
|
),
|
|
271
274
|
Effect.flatMap(computeValueBag),
|
|
@@ -333,6 +336,7 @@ export class ComputeGraphController extends Resource {
|
|
|
333
336
|
Effect.provide(
|
|
334
337
|
ComputeEventLogger.layerFromTracing.pipe(
|
|
335
338
|
Layer.provideMerge(TracingService.layerNoop), // TODO(dmaretskyi): Plug-in tracing events to visual feedback in the compute graph editor.
|
|
339
|
+
Layer.provideMerge(Trace.writerLayerNoop),
|
|
336
340
|
),
|
|
337
341
|
),
|
|
338
342
|
|
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, (obj) => {
|
|
116
|
+
obj.function = Ref.make(graph.root);
|
|
117
|
+
obj.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
|
@@ -35,10 +35,10 @@ export const AudioComponent = ({ shape }: ShapeComponentProps<AudioShape>) => {
|
|
|
35
35
|
|
|
36
36
|
// https://docs.pmnd.rs/react-three-fiber/api/canvas#render-props
|
|
37
37
|
return (
|
|
38
|
-
<div className='flex
|
|
38
|
+
<div className='flex w-full justify-center items-center'>
|
|
39
39
|
<Icon
|
|
40
40
|
icon={active ? 'ph--microphone--regular' : 'ph--microphone-slash--regular'}
|
|
41
|
-
classNames={['transition opacity-20 duration-1000', active && 'opacity-100 text-
|
|
41
|
+
classNames={['transition opacity-20 duration-1000', active && 'opacity-100 text-error-text']}
|
|
42
42
|
size={8}
|
|
43
43
|
onClick={() => setActive(!active)}
|
|
44
44
|
/>
|
package/src/shapes/Beacon.tsx
CHANGED
|
@@ -33,7 +33,7 @@ export const BeaconComponent = ({ shape }: ShapeComponentProps<BeaconShape>) =>
|
|
|
33
33
|
const value = input?.type === 'executed' ? input.value : false;
|
|
34
34
|
|
|
35
35
|
return (
|
|
36
|
-
<div className='flex
|
|
36
|
+
<div className='flex w-full justify-center items-center'>
|
|
37
37
|
<Icon
|
|
38
38
|
icon='ph--sun--regular'
|
|
39
39
|
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} />
|
|
@@ -6,7 +6,7 @@ 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
|
|
|
@@ -16,25 +16,25 @@ import { createFunctionAnchors } from './common';
|
|
|
16
16
|
import { Box, type BoxActionHandler } from './common';
|
|
17
17
|
import { ComputeShape, type CreateShapeProps, createShape } from './defs';
|
|
18
18
|
|
|
19
|
-
export const
|
|
19
|
+
export const FeedShape = Schema.extend(
|
|
20
20
|
ComputeShape,
|
|
21
21
|
Schema.Struct({
|
|
22
22
|
type: Schema.Literal('queue'),
|
|
23
23
|
}),
|
|
24
24
|
);
|
|
25
25
|
|
|
26
|
-
export type
|
|
26
|
+
export type FeedShape = Schema.Schema.Type<typeof FeedShape>;
|
|
27
27
|
|
|
28
|
-
export type
|
|
28
|
+
export type CreateFeedProps = CreateShapeProps<FeedShape>;
|
|
29
29
|
|
|
30
|
-
export const
|
|
31
|
-
createShape<
|
|
30
|
+
export const createFeed = (props: CreateFeedProps) =>
|
|
31
|
+
createShape<FeedShape>({
|
|
32
32
|
type: 'queue',
|
|
33
33
|
size: { width: 256, height: 512 },
|
|
34
34
|
...props,
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
export const
|
|
37
|
+
export const FeedComponent = ({ shape }: ShapeComponentProps<FeedShape>) => {
|
|
38
38
|
const { runtime } = useComputeNodeState(shape);
|
|
39
39
|
const items = runtime.outputs[DEFAULT_OUTPUT]?.type === 'executed' ? runtime.outputs[DEFAULT_OUTPUT].value : [];
|
|
40
40
|
|
|
@@ -46,22 +46,24 @@ export const QueueComponent = ({ shape }: ShapeComponentProps<QueueShape>) => {
|
|
|
46
46
|
|
|
47
47
|
return (
|
|
48
48
|
<Box shape={shape} status={`${items.length} items`} onAction={handleAction}>
|
|
49
|
-
<
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
<ScrollArea.Root orientation='vertical'>
|
|
50
|
+
<ScrollArea.Viewport classNames='divide-y divide-separator'>
|
|
51
|
+
{[...items].map((item, i) => (
|
|
52
|
+
<FeedItem key={i} classNames='p-1 px-2' item={item} />
|
|
53
|
+
))}
|
|
54
|
+
</ScrollArea.Viewport>
|
|
55
|
+
</ScrollArea.Root>
|
|
54
56
|
</Box>
|
|
55
57
|
);
|
|
56
58
|
};
|
|
57
59
|
|
|
58
|
-
export const
|
|
60
|
+
export const FeedItem = ({ classNames, item }: ThemedClassName<{ item: any }>) => {
|
|
59
61
|
if (typeof item !== 'object') {
|
|
60
62
|
return <div className={mx(classNames, 'whitespace-pre-wrap')}>{item}</div>;
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
return (
|
|
64
|
-
<div className={mx('grid grid-cols-[
|
|
66
|
+
<div className={mx('grid grid-cols-[80px_1fr]', classNames)}>
|
|
65
67
|
{Object.entries(item).map(([key, value]) => (
|
|
66
68
|
<Fragment key={key}>
|
|
67
69
|
<div className='p-1 text-xs text-subdued'>{key}</div>
|
|
@@ -72,12 +74,12 @@ export const QueueItem = ({ classNames, item }: ThemedClassName<{ item: any }>)
|
|
|
72
74
|
);
|
|
73
75
|
};
|
|
74
76
|
|
|
75
|
-
export const
|
|
76
|
-
type: '
|
|
77
|
-
name: '
|
|
77
|
+
export const feedShape: ShapeDef<FeedShape> = {
|
|
78
|
+
type: 'feed',
|
|
79
|
+
name: 'Feed',
|
|
78
80
|
icon: 'ph--queue--regular',
|
|
79
|
-
component:
|
|
80
|
-
createShape:
|
|
81
|
+
component: FeedComponent,
|
|
82
|
+
createShape: createFeed,
|
|
81
83
|
getAnchors: (shape) => createFunctionAnchors(shape, QueueInput, QueueOutput),
|
|
82
84
|
resizable: true,
|
|
83
85
|
};
|
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 {
|
|
@@ -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
|
@@ -6,6 +6,7 @@ import * as Schema from 'effect/Schema';
|
|
|
6
6
|
import React, { useEffect, useState } from 'react';
|
|
7
7
|
|
|
8
8
|
import { GptInput, GptOutput } from '@dxos/conductor';
|
|
9
|
+
import { ScrollArea } from '@dxos/react-ui';
|
|
9
10
|
import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
10
11
|
|
|
11
12
|
import { useComputeNodeState } from '../hooks';
|
|
@@ -74,7 +75,11 @@ export const GptComponent = ({ shape }: ShapeComponentProps<GptShape>) => {
|
|
|
74
75
|
return (
|
|
75
76
|
<FunctionBody
|
|
76
77
|
shape={shape}
|
|
77
|
-
content={
|
|
78
|
+
content={
|
|
79
|
+
<ScrollArea.Root orientation='vertical' thin>
|
|
80
|
+
<ScrollArea.Viewport>{text}</ScrollArea.Viewport>
|
|
81
|
+
</ScrollArea.Root>
|
|
82
|
+
}
|
|
78
83
|
status={`${tokens} tokens`}
|
|
79
84
|
inputSchema={meta.input}
|
|
80
85
|
outputSchema={meta.output}
|
|
@@ -143,7 +143,7 @@ export const GptRealtimeComponent = ({ shape }: ShapeComponentProps<GptRealtimeS
|
|
|
143
143
|
};
|
|
144
144
|
|
|
145
145
|
return (
|
|
146
|
-
<div className='flex
|
|
146
|
+
<div className='flex w-full justify-center items-center'>
|
|
147
147
|
<Icon
|
|
148
148
|
icon={isReady ? 'ph--waveform--regular' : isLive ? 'ph--pulse--regular' : 'ph--play--regular'}
|
|
149
149
|
size={16}
|
package/src/shapes/Json.tsx
CHANGED
|
@@ -8,7 +8,7 @@ import React from 'react';
|
|
|
8
8
|
import { DEFAULT_INPUT, DefaultOutput, JsonTransformInput } from '@dxos/conductor';
|
|
9
9
|
import { type ShapeComponentProps, type ShapeDef } from '@dxos/react-ui-canvas-editor';
|
|
10
10
|
import { createAnchorMap } from '@dxos/react-ui-canvas-editor';
|
|
11
|
-
import {
|
|
11
|
+
import { Json } from '@dxos/react-ui-syntax-highlighter';
|
|
12
12
|
|
|
13
13
|
import { useComputeNodeState } from '../hooks';
|
|
14
14
|
|
|
@@ -50,7 +50,12 @@ export const JsonComponent = ({ shape, ...props }: JsonComponentProps) => {
|
|
|
50
50
|
|
|
51
51
|
return (
|
|
52
52
|
<Box shape={shape}>
|
|
53
|
-
<
|
|
53
|
+
<Json.Root data={value}>
|
|
54
|
+
<Json.Content>
|
|
55
|
+
<Json.Filter />
|
|
56
|
+
<Json.Data classNames='text-xs' />
|
|
57
|
+
</Json.Content>
|
|
58
|
+
</Json.Root>
|
|
54
59
|
</Box>
|
|
55
60
|
);
|
|
56
61
|
};
|
package/src/shapes/Scope.tsx
CHANGED
|
@@ -39,7 +39,7 @@ export const ScopeComponent = ({ shape }: ShapeComponentProps<ScopeShape>) => {
|
|
|
39
39
|
const { getAverage } = useAudioStream(active);
|
|
40
40
|
|
|
41
41
|
return (
|
|
42
|
-
<div className='flex
|
|
42
|
+
<div className='flex w-full justify-center items-center bg-black'>
|
|
43
43
|
<Chaos active={active} getValue={getAverage} options={{ ...shaderPresets.heptapod, zoom: 1.2 }} />
|
|
44
44
|
</div>
|
|
45
45
|
);
|