@dxos/react-ui-canvas-compute 0.8.4-main.3eb6e50203 → 0.8.4-main.3fbcb4aa9b

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.
Files changed (107) hide show
  1. package/dist/lib/browser/index.mjs +427 -504
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +427 -504
  5. package/dist/lib/node-esm/index.mjs.map +4 -4
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/types/src/components/DiagnosticOverlay.d.ts.map +1 -1
  8. package/dist/types/src/compute-layout.d.ts.map +1 -1
  9. package/dist/types/src/compute.stories.d.ts +1 -1
  10. package/dist/types/src/compute.stories.d.ts.map +1 -1
  11. package/dist/types/src/graph/controller.d.ts +33 -28
  12. package/dist/types/src/graph/controller.d.ts.map +1 -1
  13. package/dist/types/src/graph/node-defs.d.ts.map +1 -1
  14. package/dist/types/src/hooks/useComputeGraphController.d.ts.map +1 -1
  15. package/dist/types/src/hooks/useComputeNodeState.d.ts +2 -3
  16. package/dist/types/src/hooks/useComputeNodeState.d.ts.map +1 -1
  17. package/dist/types/src/hooks/useGraphMonitor.d.ts.map +1 -1
  18. package/dist/types/src/shapes/Append.d.ts +1 -1
  19. package/dist/types/src/shapes/Append.d.ts.map +1 -1
  20. package/dist/types/src/shapes/Array.d.ts +1 -1
  21. package/dist/types/src/shapes/Array.d.ts.map +1 -1
  22. package/dist/types/src/shapes/Audio.d.ts +1 -1
  23. package/dist/types/src/shapes/Audio.d.ts.map +1 -1
  24. package/dist/types/src/shapes/Beacon.d.ts +1 -1
  25. package/dist/types/src/shapes/Beacon.d.ts.map +1 -1
  26. package/dist/types/src/shapes/Boolean.d.ts +7 -7
  27. package/dist/types/src/shapes/Boolean.d.ts.map +1 -1
  28. package/dist/types/src/shapes/Chat.d.ts +1 -1
  29. package/dist/types/src/shapes/Chat.d.ts.map +1 -1
  30. package/dist/types/src/shapes/Constant.d.ts +1 -1
  31. package/dist/types/src/shapes/Constant.d.ts.map +1 -1
  32. package/dist/types/src/shapes/Database.d.ts +1 -1
  33. package/dist/types/src/shapes/Database.d.ts.map +1 -1
  34. package/dist/types/src/shapes/{Queue.d.ts → Feed.d.ts} +9 -9
  35. package/dist/types/src/shapes/Feed.d.ts.map +1 -0
  36. package/dist/types/src/shapes/Function.d.ts +1 -1
  37. package/dist/types/src/shapes/Function.d.ts.map +1 -1
  38. package/dist/types/src/shapes/Gpt.d.ts +1 -1
  39. package/dist/types/src/shapes/Gpt.d.ts.map +1 -1
  40. package/dist/types/src/shapes/GptRealtime.d.ts +1 -1
  41. package/dist/types/src/shapes/GptRealtime.d.ts.map +1 -1
  42. package/dist/types/src/shapes/Json.d.ts +2 -2
  43. package/dist/types/src/shapes/Json.d.ts.map +1 -1
  44. package/dist/types/src/shapes/Logic.d.ts +2 -2
  45. package/dist/types/src/shapes/Logic.d.ts.map +1 -1
  46. package/dist/types/src/shapes/RNG.d.ts +2 -2
  47. package/dist/types/src/shapes/RNG.d.ts.map +1 -1
  48. package/dist/types/src/shapes/Scope.d.ts +1 -1
  49. package/dist/types/src/shapes/Scope.d.ts.map +1 -1
  50. package/dist/types/src/shapes/Surface.d.ts +1 -1
  51. package/dist/types/src/shapes/Surface.d.ts.map +1 -1
  52. package/dist/types/src/shapes/Switch.d.ts +1 -1
  53. package/dist/types/src/shapes/Switch.d.ts.map +1 -1
  54. package/dist/types/src/shapes/Table.d.ts +1 -1
  55. package/dist/types/src/shapes/Table.d.ts.map +1 -1
  56. package/dist/types/src/shapes/Template.d.ts +2 -2
  57. package/dist/types/src/shapes/Template.d.ts.map +1 -1
  58. package/dist/types/src/shapes/Text.d.ts +1 -1
  59. package/dist/types/src/shapes/Text.d.ts.map +1 -1
  60. package/dist/types/src/shapes/TextToImage.d.ts +1 -1
  61. package/dist/types/src/shapes/TextToImage.d.ts.map +1 -1
  62. package/dist/types/src/shapes/Thread.d.ts +1 -1
  63. package/dist/types/src/shapes/Thread.d.ts.map +1 -1
  64. package/dist/types/src/shapes/Trigger.d.ts +4 -3
  65. package/dist/types/src/shapes/Trigger.d.ts.map +1 -1
  66. package/dist/types/src/shapes/common/Box.d.ts.map +1 -1
  67. package/dist/types/src/shapes/common/FunctionBody.d.ts.map +1 -1
  68. package/dist/types/src/shapes/common/TypeSelect.d.ts +1 -1
  69. package/dist/types/src/shapes/common/TypeSelect.d.ts.map +1 -1
  70. package/dist/types/src/shapes/defs.d.ts +1 -1
  71. package/dist/types/src/shapes/defs.d.ts.map +1 -1
  72. package/dist/types/src/shapes/index.d.ts +2 -2
  73. package/dist/types/src/shapes/index.d.ts.map +1 -1
  74. package/dist/types/src/testing/circuits.d.ts.map +1 -1
  75. package/dist/types/tsconfig.tsbuildinfo +1 -1
  76. package/package.json +47 -48
  77. package/src/README.md +0 -3
  78. package/src/compute.stories.tsx +32 -13
  79. package/src/graph/controller.ts +54 -23
  80. package/src/graph/node-defs.ts +28 -28
  81. package/src/hooks/useComputeNodeState.ts +3 -5
  82. package/src/hooks/useGraphMonitor.ts +3 -3
  83. package/src/registry.ts +2 -2
  84. package/src/shapes/Audio.tsx +2 -3
  85. package/src/shapes/Beacon.tsx +1 -2
  86. package/src/shapes/Boolean.tsx +2 -2
  87. package/src/shapes/Chat.tsx +0 -1
  88. package/src/shapes/Constant.tsx +0 -1
  89. package/src/shapes/{Queue.tsx → Feed.tsx} +14 -15
  90. package/src/shapes/Function.tsx +3 -3
  91. package/src/shapes/Gpt.tsx +0 -1
  92. package/src/shapes/GptRealtime.tsx +1 -1
  93. package/src/shapes/Json.tsx +9 -3
  94. package/src/shapes/RNG.tsx +0 -1
  95. package/src/shapes/Scope.tsx +1 -2
  96. package/src/shapes/Surface.tsx +6 -2
  97. package/src/shapes/Switch.tsx +1 -2
  98. package/src/shapes/Template.tsx +0 -1
  99. package/src/shapes/Text.tsx +0 -1
  100. package/src/shapes/Thread.tsx +2 -6
  101. package/src/shapes/Trigger.tsx +15 -20
  102. package/src/shapes/common/Box.tsx +5 -7
  103. package/src/shapes/common/FunctionBody.tsx +2 -2
  104. package/src/shapes/common/TypeSelect.tsx +1 -1
  105. package/src/shapes/index.ts +2 -2
  106. package/src/testing/circuits.ts +2 -2
  107. 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.3eb6e50203",
3
+ "version": "0.8.4-main.3fbcb4aa9b",
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,15 +14,12 @@
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",
23
- "typesVersions": {
24
- "*": {}
25
- },
26
23
  "files": [
27
24
  "dist",
28
25
  "src"
@@ -32,36 +29,39 @@
32
29
  "@antv/layout": "^1.2.13",
33
30
  "@effect/platform": "0.94.4",
34
31
  "chess.js": "^1.0.0",
35
- "@dxos/ai": "0.8.4-main.3eb6e50203",
36
- "@dxos/app-framework": "0.8.4-main.3eb6e50203",
37
- "@dxos/assistant": "0.8.4-main.3eb6e50203",
38
- "@dxos/async": "0.8.4-main.3eb6e50203",
39
- "@dxos/blueprints": "0.8.4-main.3eb6e50203",
40
- "@dxos/conductor": "0.8.4-main.3eb6e50203",
41
- "@dxos/echo": "0.8.4-main.3eb6e50203",
42
- "@dxos/context": "0.8.4-main.3eb6e50203",
43
- "@dxos/edge-client": "0.8.4-main.3eb6e50203",
44
- "@dxos/debug": "0.8.4-main.3eb6e50203",
45
- "@dxos/effect": "0.8.4-main.3eb6e50203",
46
- "@dxos/graph": "0.8.4-main.3eb6e50203",
47
- "@dxos/functions-runtime": "0.8.4-main.3eb6e50203",
48
- "@dxos/invariant": "0.8.4-main.3eb6e50203",
49
- "@dxos/functions": "0.8.4-main.3eb6e50203",
50
- "@dxos/log": "0.8.4-main.3eb6e50203",
51
- "@dxos/keys": "0.8.4-main.3eb6e50203",
52
- "@dxos/react-edge-client": "0.8.4-main.3eb6e50203",
53
- "@dxos/react-ui-attention": "0.8.4-main.3eb6e50203",
54
- "@dxos/react-ui-canvas-editor": "0.8.4-main.3eb6e50203",
55
- "@dxos/react-ui-canvas": "0.8.4-main.3eb6e50203",
56
- "@dxos/react-ui-editor": "0.8.4-main.3eb6e50203",
57
- "@dxos/react-ui-form": "0.8.4-main.3eb6e50203",
58
- "@dxos/react-ui-sfx": "0.8.4-main.3eb6e50203",
59
- "@dxos/react-ui-stack": "0.8.4-main.3eb6e50203",
60
- "@dxos/react-ui-syntax-highlighter": "0.8.4-main.3eb6e50203",
61
- "@dxos/schema": "0.8.4-main.3eb6e50203",
62
- "@dxos/types": "0.8.4-main.3eb6e50203",
63
- "@dxos/util": "0.8.4-main.3eb6e50203",
64
- "@dxos/react-client": "0.8.4-main.3eb6e50203"
32
+ "@dxos/ai": "0.8.4-main.3fbcb4aa9b",
33
+ "@dxos/app-toolkit": "0.8.4-main.3fbcb4aa9b",
34
+ "@dxos/app-framework": "0.8.4-main.3fbcb4aa9b",
35
+ "@dxos/context": "0.8.4-main.3fbcb4aa9b",
36
+ "@dxos/async": "0.8.4-main.3fbcb4aa9b",
37
+ "@dxos/compute": "0.8.4-main.3fbcb4aa9b",
38
+ "@dxos/debug": "0.8.4-main.3fbcb4aa9b",
39
+ "@dxos/conductor": "0.8.4-main.3fbcb4aa9b",
40
+ "@dxos/echo-db": "0.8.4-main.3fbcb4aa9b",
41
+ "@dxos/echo": "0.8.4-main.3fbcb4aa9b",
42
+ "@dxos/edge-client": "0.8.4-main.3fbcb4aa9b",
43
+ "@dxos/functions": "0.8.4-main.3fbcb4aa9b",
44
+ "@dxos/effect": "0.8.4-main.3fbcb4aa9b",
45
+ "@dxos/graph": "0.8.4-main.3fbcb4aa9b",
46
+ "@dxos/functions-runtime": "0.8.4-main.3fbcb4aa9b",
47
+ "@dxos/log": "0.8.4-main.3fbcb4aa9b",
48
+ "@dxos/keys": "0.8.4-main.3fbcb4aa9b",
49
+ "@dxos/invariant": "0.8.4-main.3fbcb4aa9b",
50
+ "@dxos/react-client": "0.8.4-main.3fbcb4aa9b",
51
+ "@dxos/react-edge-client": "0.8.4-main.3fbcb4aa9b",
52
+ "@dxos/react-ui-attention": "0.8.4-main.3fbcb4aa9b",
53
+ "@dxos/assistant": "0.8.4-main.3fbcb4aa9b",
54
+ "@dxos/react-ui-canvas": "0.8.4-main.3fbcb4aa9b",
55
+ "@dxos/react-ui-canvas-editor": "0.8.4-main.3fbcb4aa9b",
56
+ "@dxos/react-ui-editor": "0.8.4-main.3fbcb4aa9b",
57
+ "@dxos/react-ui-mosaic": "0.8.4-main.3fbcb4aa9b",
58
+ "@dxos/react-ui-sfx": "0.8.4-main.3fbcb4aa9b",
59
+ "@dxos/react-ui-stack": "0.8.4-main.3fbcb4aa9b",
60
+ "@dxos/react-ui-syntax-highlighter": "0.8.4-main.3fbcb4aa9b",
61
+ "@dxos/schema": "0.8.4-main.3fbcb4aa9b",
62
+ "@dxos/types": "0.8.4-main.3fbcb4aa9b",
63
+ "@dxos/util": "0.8.4-main.3fbcb4aa9b",
64
+ "@dxos/react-ui-form": "0.8.4-main.3fbcb4aa9b"
65
65
  },
66
66
  "devDependencies": {
67
67
  "@effect/ai": "0.33.2",
@@ -69,25 +69,24 @@
69
69
  "@types/lodash.defaultsdeep": "^4.6.6",
70
70
  "@types/react": "~19.2.7",
71
71
  "@types/react-dom": "~19.2.3",
72
- "effect": "3.19.16",
72
+ "effect": "3.20.0",
73
73
  "lodash.defaultsdeep": "^4.6.1",
74
74
  "react": "~19.2.3",
75
75
  "react-dom": "~19.2.3",
76
- "vite": "7.1.9",
77
- "@dxos/app-framework": "0.8.4-main.3eb6e50203",
78
- "@dxos/assistant-toolkit": "0.8.4-main.3eb6e50203",
79
- "@dxos/compute": "0.8.4-main.3eb6e50203",
80
- "@dxos/react-ui": "0.8.4-main.3eb6e50203",
81
- "@dxos/random": "0.8.4-main.3eb6e50203",
82
- "@dxos/storybook-utils": "0.8.4-main.3eb6e50203",
83
- "@dxos/ui-theme": "0.8.4-main.3eb6e50203"
76
+ "vite": "^8.0.10",
77
+ "@dxos/app-framework": "0.8.4-main.3fbcb4aa9b",
78
+ "@dxos/assistant-toolkit": "0.8.4-main.3fbcb4aa9b",
79
+ "@dxos/random": "0.8.4-main.3fbcb4aa9b",
80
+ "@dxos/react-ui": "0.8.4-main.3fbcb4aa9b",
81
+ "@dxos/storybook-utils": "0.8.4-main.3fbcb4aa9b",
82
+ "@dxos/ui-theme": "0.8.4-main.3fbcb4aa9b"
84
83
  },
85
84
  "peerDependencies": {
86
- "effect": "3.19.16",
85
+ "effect": "3.20.0",
87
86
  "react": "~19.2.3",
88
87
  "react-dom": "~19.2.3",
89
- "@dxos/react-ui": "0.8.4-main.3eb6e50203",
90
- "@dxos/ui-theme": "0.8.4-main.3eb6e50203"
88
+ "@dxos/react-ui": "0.8.4-main.3fbcb4aa9b",
89
+ "@dxos/ui-theme": "0.8.4-main.3fbcb4aa9b"
91
90
  },
92
91
  "publishConfig": {
93
92
  "access": "public"
package/src/README.md CHANGED
@@ -42,6 +42,3 @@
42
42
  - logs associated with a node or a graph
43
43
  - node state updates (can a node have internal state separate from inputs/outputs)
44
44
  - timestep? - to correlate events that happen during a single execution time
45
-
46
-
47
-
@@ -3,6 +3,7 @@
3
3
  //
4
4
 
5
5
  import { type Meta, type StoryObj } from '@storybook/react-vite';
6
+ import * as Effect from 'effect/Effect';
6
7
  import * as Layer from 'effect/Layer';
7
8
  import * as ManagedRuntime from 'effect/ManagedRuntime';
8
9
  import React, { type PropsWithChildren, useEffect, useMemo, useRef, useState } from 'react';
@@ -10,18 +11,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';
13
15
  import { type ComputeGraphModel, type ComputeNode, type GraphDiagnostic } from '@dxos/conductor';
14
- import { CredentialsService, TracingService } from '@dxos/functions';
15
- import { FunctionInvocationServiceLayerTest } from '@dxos/functions-runtime';
16
- import { TestDatabaseLayer } from '@dxos/functions-runtime/testing';
16
+ import { Feed } from '@dxos/echo';
17
+ import { TestDatabaseLayer } from '@dxos/echo-db/testing';
18
+ import { configuredCredentialsLayer } from '@dxos/functions';
17
19
  import { withClientProvider } from '@dxos/react-client/testing';
18
20
  import { Select, Toolbar } from '@dxos/react-ui';
19
- import { 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 { JsonFilter } from '@dxos/react-ui-syntax-highlighter';
25
+ import { Syntax } from '@dxos/react-ui-syntax-highlighter';
26
+ import { withLayout, withTheme } from '@dxos/react-ui/testing';
25
27
 
26
28
  import { DiagnosticOverlay } from './components';
27
29
  import { ComputeShapeLayout } from './compute-layout';
@@ -122,7 +124,7 @@ const DefaultStory = ({
122
124
  }
123
125
 
124
126
  return (
125
- <div className='grid grid-cols-[1fr,360px] is-full bs-full'>
127
+ <div className='grid grid-cols-[1fr_360px] h-full w-full'>
126
128
  <ComputeContext.Provider value={{ controller }}>
127
129
  <Container id={id} classNames={['flex grow overflow-hidden', !sidebar && 'col-span-2']}>
128
130
  <Editor.Root<ComputeShape>
@@ -146,10 +148,10 @@ const DefaultStory = ({
146
148
  </ComputeContext.Provider>
147
149
 
148
150
  {sidebar && (
149
- <Container id='sidebar' classNames='flex flex-col bs-full overflow-hidden'>
151
+ <Container id='sidebar' classNames='flex flex-col h-full overflow-hidden'>
150
152
  <Toolbar.Root>
151
153
  <Select.Root value={sidebar} onValueChange={(value) => setSidebar(value as RenderProps['sidebar'])}>
152
- <Select.TriggerButton classNames='is-full'>{sidebar}</Select.TriggerButton>
154
+ <Select.TriggerButton classNames='w-full'>{sidebar}</Select.TriggerButton>
153
155
  <Select.Portal>
154
156
  <Select.Content>
155
157
  <Select.Viewport>
@@ -165,7 +167,7 @@ const DefaultStory = ({
165
167
  </Select.Root>
166
168
  </Toolbar.Root>
167
169
 
168
- <div className='flex flex-col bs-full overflow-hidden divide-y divider-separator'>
170
+ <div className='flex flex-col h-full overflow-hidden divide-y divider-separator'>
169
171
  {/* TODO(burdon): Provide schema. */}
170
172
  {sidebar === 'selected' && selected && (
171
173
  <Form.Root<ComputeNode> values={getComputeNode(selected.id) ?? {}}>
@@ -177,7 +179,14 @@ const DefaultStory = ({
177
179
  </Form.Viewport>
178
180
  </Form.Root>
179
181
  )}
180
- <JsonFilter data={json} />
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>
181
190
  </div>
182
191
  </Container>
183
192
  )}
@@ -191,6 +200,7 @@ const meta = {
191
200
  render: DefaultStory,
192
201
  decorators: [
193
202
  withTheme(),
203
+ withLayout({ layout: 'fullscreen' }),
194
204
  withAttention(),
195
205
  withClientProvider({ createIdentity: true, createSpace: true }),
196
206
  withPluginManager({ capabilities }),
@@ -214,13 +224,22 @@ export default meta;
214
224
  type Story = StoryObj<typeof meta>;
215
225
 
216
226
  const ServiceLayer = Layer.empty.pipe(
217
- Layer.provideMerge(FunctionInvocationServiceLayerTest()),
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
+ ),
218
237
  Layer.provideMerge(
219
238
  Layer.mergeAll(
220
239
  AiServiceTestingPreset('direct'),
221
240
  TestDatabaseLayer(),
222
- CredentialsService.configuredLayer([]),
223
- TracingService.layerNoop,
241
+ configuredCredentialsLayer([]),
242
+ Feed.notAvailable,
224
243
  ),
225
244
  ),
226
245
  Layer.orDie,
@@ -2,7 +2,6 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import type * as Context from 'effect/Context';
6
5
  import * as Effect from 'effect/Effect';
7
6
  import * as Either from 'effect/Either';
8
7
  import * as Exit from 'effect/Exit';
@@ -12,7 +11,14 @@ import * as Scope from 'effect/Scope';
12
11
 
13
12
  import type { AiService } from '@dxos/ai';
14
13
  import { Event, synchronized } from '@dxos/async';
14
+ import { type Credential, type Operation, type OperationRegistry, Trace } from '@dxos/compute';
15
15
  import {
16
+ ComputeBeginEvent,
17
+ ComputeCustomEvent,
18
+ ComputeEndEvent,
19
+ ComputeInputEvent,
20
+ ComputeNodeContext,
21
+ ComputeOutputEvent,
16
22
  type ComputeEdge,
17
23
  type ComputeGraphModel,
18
24
  type ComputeNode,
@@ -25,23 +31,15 @@ import {
25
31
  isNotExecuted,
26
32
  } from '@dxos/conductor';
27
33
  import { Resource } from '@dxos/context';
28
- import type { Database } from '@dxos/echo';
34
+ import type { Database, Feed } from '@dxos/echo';
29
35
  import { unwrapExit } from '@dxos/effect';
30
- import {
31
- ComputeEventLogger,
32
- type ComputeEventPayload,
33
- type CredentialsService,
34
- type FunctionInvocationService,
35
- type QueueService,
36
- TracingService,
37
- } from '@dxos/functions';
36
+ import { type QueueService } from '@dxos/functions';
38
37
  import { log } from '@dxos/log';
39
38
  import { type CanvasGraphModel } from '@dxos/react-ui-canvas-editor';
40
39
  import { type ContentBlock } from '@dxos/types';
41
40
 
42
41
  import { createComputeGraph } from '../hooks';
43
42
  import { type ComputeShape } from '../shapes';
44
-
45
43
  import { resolveComputeNode } from './node-defs';
46
44
 
47
45
  // TODO(burdon): API package for conductor.
@@ -83,13 +81,25 @@ type ComputeOutputEvent = {
83
81
  value: RuntimeValue;
84
82
  };
85
83
 
84
+ /**
85
+ * Event emitted by the compute graph during execution.
86
+ */
87
+ export type ComputeEvent =
88
+ | { type: 'begin-compute'; nodeId: string; inputs: ReadonlyArray<string> }
89
+ | { type: 'end-compute'; nodeId: string; outputs: ReadonlyArray<string> }
90
+ | { type: 'compute-input'; nodeId: string; property: string; value: any }
91
+ | { type: 'compute-output'; nodeId: string; property: string; value: any }
92
+ | { type: 'custom'; nodeId: string; event: any };
93
+
86
94
  // TODO(dmaretskyi): Re-use function servies definition.
87
95
  export type ComputeServices =
88
96
  | AiService.AiService
89
97
  | Database.Service
98
+ | Feed.FeedService
90
99
  | QueueService
91
- | CredentialsService
92
- | FunctionInvocationService;
100
+ | Credential.CredentialsService
101
+ | Operation.Service
102
+ | OperationRegistry.Service;
93
103
 
94
104
  /**
95
105
  * Nodes that will automatically trigger the execution of the graph on startup.
@@ -133,7 +143,7 @@ export class ComputeGraphController extends Resource {
133
143
  /** Computed result. */
134
144
  public readonly output = new Event<ComputeOutputEvent>();
135
145
 
136
- public readonly events = new Event<ComputeEventPayload>();
146
+ public readonly events = new Event<ComputeEvent>();
137
147
 
138
148
  constructor(
139
149
  private readonly _computeRuntime: ManagedRuntime.ManagedRuntime<ComputeServices, never>,
@@ -264,8 +274,9 @@ export class ComputeGraphController extends Resource {
264
274
  Effect.withSpan('runGraph'),
265
275
  Scope.extend(scope),
266
276
  Effect.provide(
267
- ComputeEventLogger.layerFromTracing.pipe(
268
- Layer.provideMerge(TracingService.layerNoop), // TODO(dmaretskyi): Plug-in tracing events to visual feedback in the compute graph editor.
277
+ Layer.mergeAll(
278
+ Layer.succeed(Trace.TraceService, this._createTraceWriter()),
279
+ ComputeNodeContext.layerNoop,
269
280
  ),
270
281
  ),
271
282
  Effect.flatMap(computeValueBag),
@@ -331,8 +342,9 @@ export class ComputeGraphController extends Resource {
331
342
  Scope.extend(scope),
332
343
  Effect.flatMap(computeValueBag),
333
344
  Effect.provide(
334
- ComputeEventLogger.layerFromTracing.pipe(
335
- Layer.provideMerge(TracingService.layerNoop), // TODO(dmaretskyi): Plug-in tracing events to visual feedback in the compute graph editor.
345
+ Layer.mergeAll(
346
+ Layer.succeed(Trace.TraceService, this._createTraceWriter()),
347
+ ComputeNodeContext.layerNoop,
336
348
  ),
337
349
  ),
338
350
 
@@ -363,16 +375,18 @@ export class ComputeGraphController extends Resource {
363
375
  this.update.emit();
364
376
  }
365
377
 
366
- private _createLogger(): Context.Tag.Service<ComputeEventLogger> {
378
+ private _createTraceWriter(): Trace.TraceWriter {
367
379
  return {
368
- log: (event) => {
369
- this._handleEvent(event);
380
+ write: (eventType, payload) => {
381
+ const event = traceEventToComputeEvent(eventType.key, payload);
382
+ if (event) {
383
+ this._handleEvent(event);
384
+ }
370
385
  },
371
- nodeId: undefined, // Not in a context of a specific node.
372
386
  };
373
387
  }
374
388
 
375
- private _handleEvent(event: ComputeEventPayload): void {
389
+ private _handleEvent(event: ComputeEvent): void {
376
390
  log('handleEvent', { event });
377
391
  switch (event.type) {
378
392
  case 'compute-input': {
@@ -402,6 +416,23 @@ export class ComputeGraphController extends Resource {
402
416
  }
403
417
  }
404
418
 
419
+ const traceEventToComputeEvent = (key: string, payload: unknown): ComputeEvent | undefined => {
420
+ switch (key) {
421
+ case ComputeBeginEvent.key:
422
+ return { type: 'begin-compute', ...(payload as { nodeId: string; inputs: ReadonlyArray<string> }) };
423
+ case ComputeEndEvent.key:
424
+ return { type: 'end-compute', ...(payload as { nodeId: string; outputs: ReadonlyArray<string> }) };
425
+ case ComputeInputEvent.key:
426
+ return { type: 'compute-input', ...(payload as { nodeId: string; property: string; value: any }) };
427
+ case ComputeOutputEvent.key:
428
+ return { type: 'compute-output', ...(payload as { nodeId: string; property: string; value: any }) };
429
+ case ComputeCustomEvent.key:
430
+ return { type: 'custom', ...(payload as { nodeId: string; event: any }) };
431
+ default:
432
+ return undefined;
433
+ }
434
+ };
435
+
405
436
  /**
406
437
  * Waits for all effects in the bag to complete and returns the `RuntimeValue` for each property.
407
438
  */
@@ -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
- ['text-to-image' as const]: () => createNode('text-to-image'), // TODO(burdon): Rename ai-impage-tool
43
- ['and' as const]: () => createNode('and'),
44
- ['append' as const]: () => createNode('append'),
45
- ['audio' as const]: () => createNode('audio'),
46
- ['beacon' as const]: () => createNode('beacon'),
47
- ['chat' as const]: () => createNode('chat'),
48
- ['constant' as const]: (shape) =>
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
- ['make-queue' as const]: () => createNode('make-queue'),
53
- ['database' as const]: () => createNode('database'),
54
- ['gpt' as const]: () => createNode('gpt'),
55
- ['gpt-realtime' as const]: () => createNode('gpt-realtime'),
56
- ['if' as const]: () => createNode('if'),
57
- ['if-else' as const]: () => createNode('if-else'),
58
- ['function' as const]: () => createNode('function'),
59
- ['json' as const]: () => createNode('json'),
60
- ['json-transform' as const]: () => createNode('json-transform'),
61
- ['not' as const]: () => createNode('not'),
62
- ['or' as const]: () => createNode('or'),
63
- ['queue' as const]: () => createNode('queue'),
64
- ['rng' as const]: () => createNode('rng'),
65
- ['reducer' as const]: () => createNode('reducer'),
66
- ['scope' as const]: () => createNode('scope'),
67
- ['surface' as const]: () => createNode('surface'),
68
- ['switch' as const]: () => createNode('switch'),
69
- ['template' as const]: (shape) => {
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
- ['text' as const]: () => createNode('text'),
75
- ['thread' as const]: () => createNode('thread'),
76
- ['trigger' as const]: () => createNode(NODE_INPUT),
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 => ({
@@ -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: ComputeEventPayload) => void) => void;
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: ComputeEventPayload) => void) => {
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.change(functionTrigger, (t) => {
116
- t.function = Ref.make(graph.root);
117
- t.inputNodeId = computeNode.id;
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
- queueShape,
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
- queueShape,
85
+ feedShape,
86
86
  threadShape,
87
87
  textShape,
88
88
  surfaceShape,
@@ -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 is-full justify-center items-center'>
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-red-500']}
40
+ classNames={['transition opacity-20 duration-1000', active && 'opacity-100 text-error-text']}
42
41
  size={8}
43
42
  onClick={() => setActive(!active)}
44
43
  />
@@ -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 is-full justify-center items-center'>
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']}
@@ -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 is-full justify-center items-center'>
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='is-full bs-full'>
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} />
@@ -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
 
@@ -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